English Français

Documentation / Developer's manual

Available modules

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / Sensitivity: TSensitivity.h Source File
Uranie / Sensitivity  v4.10.0
/* @license-end */
TSensitivity.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2024 CEA/DES
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as published
6 // by the Free Software Foundation, either version 3 of the License, or any
7 // later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 // TSensitivity jeu sep 14 09:01:14 CEST 2006
19 // $Id$
20 // $Author$
21 // $Date$
22 // $Revision$
23 // $State$
25 
80 #ifndef TSENSITIVITY_H
81 #define TSENSITIVITY_H
82 
84 #include "TMethodCall.h"
85 #include "TTree.h"
86 #include "TMatrixD.h"
87 #include "TRandom3.h"
88 #include "TNamed.h"
89 #include "TNtupleD.h"
90 #include "TMath.h"
91 
92 #include <iostream>
93 #include <sstream>
94 using std::cout;
95 using std::endl;
96 
97 // Uranie
98 #include "TDataServer.h"
99 #include "TCode.h"
100 #include "TRun.h"
101 #include "UExceptions.h"
102 #include "Sensitivity.h"
103 #ifdef WITH_LIBSSH
104 #include "TCluster.h"
105 #endif
106 
107 #define MAXLENGTHSTRING 50
108 
109 namespace URANIE {
110 namespace Sensitivity {
111 class TSensitivity: public TNamed
112 {
113 
114  // Attributes
115  //---------------------------------------------
123 protected:
129  Double_t _valSobolCrt;
130  Double_t _valSobolCILower;
131  Double_t _valSobolCIUpper;
132  TMatrixD _minputCorr;
135 
137 
138  //---------------------------------------------
143 public:
145  {
147  };
148 
149  URANIE::DataServer::TDataServer *_tds;
152  TString _sTimeAttribute;
153 
154 #ifdef WITH_LIBSSH
155  URANIE::Launcher::TCluster* _cluster;
156  URANIE::Launcher::TCluster* getCluster(){
157  return _cluster;
158  };
159 
160  void addCluster(URANIE::Launcher::TCluster* cluster){
161  _cluster = cluster;
162  _cluster->setDataServer(_tds);
163  };
164 #endif
165 
166  Int_t _nS;
167  Int_t _nX;
168  UInt_t _nY;
169  UInt_t _nElY;
170  Int_t _nbOut;
171  Int_t _iOut;
172  unsigned int _iy;
173  unsigned int _iely;
174 
176  TString _sFunctionName;
177  URANIE::Launcher::TCode *_code;
178  URANIE::Relauncher::TRun *_run;
179 
181  Int_t _nSeed;
182 
184  Bool_t _blog;
185  Bool_t _bquiet;
188 
189  TString _sIteratorName;
190  TString _sMethodName;
191 
193  TString _sSelectedInput;
194 
195  map<string, unsigned int> _mAttributeSize;
196  map<string, vector<int> > _mAttributeElements;
197  vector<string> _vOutputNames;
198 
199  void setNLauncher(ELauncher codeLauncher){
200  _nLauncher = codeLauncher;
201  };
202 
203  TCanvas *_canvas;
204 
205 #ifdef ROOT5
206  TMethodCall *fMethodCall; //Pointer to MethodCall in case of interpreted function
207  void (*fMethod)(Double_t *x, Double_t *y);
208 #else
209  void (*_pFunction)(double *, double *);
210 #endif
211  TTree* _ntresult;
212 
213 
214  // Operations
215 private:
218  void initInputs();
219  void initResult();
220 
221 protected:
222  //---------------------------------------------
226  void checkCanvasCreation(bool newcan);
229  void drawIndexesHistogram(TString sTitre, const char *select = "", Option_t * option = "");
231  void drawIndexesPie(TString sTitre, const char *select = "", Option_t * option = "");
233 
235 
238  virtual void preTreatment(){}
239 
241 
244  virtual void postTreatment(){}
245 
247 
252  void setNoIntermediateSaved(Bool_t bbool = kTRUE){
253  _bnoIntermediateSaved = bbool;
254  }
255 
256 public:
257  //---------------------------------------------
261  TSensitivity();
264  TSensitivity(URANIE::DataServer::TDataServer *tds, const char *fcn, Int_t ns,
265  const char *varexpinput = "", const char *varexpoutput = "",
266  Option_t * option = "");
267 #ifdef ROOT5
268  TSensitivity(URANIE::DataServer::TDataServer *tds, void *fcn, Int_t ns,
270  const char *varexpinput = "", const char *varexpoutput = "",
271  Option_t * option = "");
272 #else
273  TSensitivity(URANIE::DataServer::TDataServer *tds,
274  void (*fcn)(Double_t*,Double_t*),
275  const char *varexpinput, const char *varexpoutput,
276  Int_t ns, Option_t * option = "");
277 #endif
278  TSensitivity(URANIE::DataServer::TDataServer *tds, const char *varexpinput,
280  const char *varexpoutput, Option_t * option = "");
282 
284  TSensitivity(URANIE::DataServer::TDataServer *tds,
285  URANIE::Launcher::TCode *code, Int_t ns, Option_t * option = "");
287 
289  TSensitivity(URANIE::DataServer::TDataServer *tds,
290  URANIE::Relauncher::TRun *run, Int_t ns, Option_t * option = "");
292  virtual ~TSensitivity();
294 
295  //---------------------------------------------
299  Int_t getID(){
300  return ID_SENSITIVITY;
301  }
303  virtual TTree * getResultTuple(bool commonresulttuple=true){
304  UNUSED(commonresulttuple);
305  return _ntresult;
306  }
307 
308  double getValue(const char * sorder ="", const char * sinputname="", const char * sselect="");
309 
310  vector<int>* getAttributeElements(string str){
311  return ((_mAttributeElements.count(str)==0)?NULL:&_mAttributeElements[str]);
312  }
313 
314 #ifdef ROOT5
315  TMethodCall *GetMethodCall() const{
316  return fMethodCall;
317  }
318  void setFunction(void *fcn, Int_t nx = -1, Int_t ny = 1);
319 #else
320  void setFunction(void (*fct)(Double_t*, Double_t*), Int_t nx = -1, Int_t ny = 1);
321 #endif
322  TString getFunctionName(){
323  return _sFunctionName;
324  }
325  void setSeed(UInt_t nval){
326  _nSeed = nval;
327  }
328  UInt_t getSeed(){
329  return _nSeed;
330  }
332  virtual void setMethodName(const char *str){
333  _sMethodName = TString(str);
334  }
336  const char * getMethodName(){
337  return _sMethodName.Data();
338  }
339 
341 
345  return _bnoIntermediateSaved;
346  }
347 
349  const char * getIteratorName(){
350  return _sIteratorName.Data();
351  }
353  void setSensitivityIteratorName(const char *str){
354  _sIteratorName = TString(str);
355  }
360  void setTimeName(TString sname);
365  TString getTimeName() { return _sTimeAttribute;}
367 
371  virtual void setDrawProgressBar(Bool_t bbool = kTRUE){
372  _bdrawProgressBar = bbool;
373  }
374 
376 
379  void setUsingErrors(bool thebool){ _bgoingThroughError=thebool;}
380 
382 
386  return _bdrawProgressBar;
387  }
392  Bool_t isInputCorrelated() {
393  return _bisInputCorrelated;
394  }
400  return _minputCorr;
401  }
402 
407  Int_t getNInput() {
408  return _nX;
409  }
410 
415  Int_t getNOutput() {
416  return _nY;
417  }
419 
420  //---------------------------------------------
424  virtual void generateSample(Option_t * option = "") = 0;
425  void setInputCorrelationMatrix(TMatrixD Corr);
427 
428  //---------------------------------------------
432 
438  virtual void parseOption(Option_t *option = "");
440 
441  //---------------------------------------------
445 
451  void checkOutputRequested(string attlist, bool fromoption=false);
453 
454  //---------------------------------------------
458 
464  void computeIndexes(Option_t * option = "");
465 
477  virtual void evaluateIndexes(Option_t * option = "") = 0;
478 
489  void fillIndex(const char * sinputname, const char * sorder,
490  Double_t dval, const char* algo = "",
491  Double_t dvalCILower = -1.0, Double_t dvalCIUpper = -1.0);
493 
494  //---------------------------------------------
498  virtual void createTuple(Option_t *option = "");
500  virtual void drawIndexes(TString sTitre, const char *select = "",
501  Option_t * option = "");
502 
504 
505  //---------------------------------------------
509  virtual void setLog(){
510  _blog = kTRUE;
511  }
512  void unsetLog(){
513  _blog = kFALSE;
514  }
515  void changeLog(){
516  _blog = _blog ? kFALSE : kTRUE;
517  }
518  Bool_t getLog(){
519  return _blog;
520  }
521  virtual void printLog(Option_t *option = "");
523 
524  ClassDef(URANIE::Sensitivity::TSensitivity, ID_SENSITIVITY)
525 
526 };
527 
528 } // Fin du namespace Sensitivity
529 } // Fin du namespace URANIE
530 
531 #ifdef ROOT5
532 R__EXTERN URANIE::Sensitivity::TSensitivity *gSensitivity;
533 #endif
534 
535 #endif
Char_t _sOrder[MAXLENGTHSTRING]
The order of sensitivity indexes.
Definition: TSensitivity.h:126
ROOT.
Definition: TCMN.h:45
TSensitivity()
Default constructor.
Int_t _nbOut
Total number of Output to be considered.
Definition: TSensitivity.h:170
Char_t _sMethod[MAXLENGTHSTRING]
The name of the method.
Definition: TSensitivity.h:127
void setUsingErrors(bool thebool)
Set the "using error results anyway" option.
Definition: TSensitivity.h:379
Bool_t getLog()
Definition: TSensitivity.h:518
Int_t _nSeed
The seed of the random generator.
Definition: TSensitivity.h:181
Bool_t _bquiet
Quiet mode.
Definition: TSensitivity.h:185
ELauncher
Definition: TSensitivity.h:144
void setFunction(void(*fct)(Double_t *, Double_t *), Int_t nx=-1, Int_t ny=1)
URANIE::Launcher::TCode * _code
The tcode.
Definition: TSensitivity.h:177
Char_t _sAlgorithm[MAXLENGTHSTRING]
The name of the algorithm to compute the index.
Definition: TSensitivity.h:128
Char_t _sInputAttribute[MAXLENGTHSTRING]
The name of the input attribute.
Definition: TSensitivity.h:125
virtual void generateSample(Option_t *option="")=0
virtual void createTuple(Option_t *option="")
virtual void drawIndexes(TString sTitre, const char *select="", Option_t *option="")
Draws the indexes.
TString _sTimeAttribute
The name of the Time attribute.
Definition: TSensitivity.h:152
unsigned int _iy
iterator over number of element
Definition: TSensitivity.h:172
TString _sIteratorName
The specific iterator attribute for the method.
Definition: TSensitivity.h:189
void drawIndexesPie(TString sTitre, const char *select="", Option_t *option="")
Draws indexes with an pie chart.
UInt_t getSeed()
Definition: TSensitivity.h:328
virtual void printLog(Option_t *option="")
void(* _pFunction)(double *, double *)
Definition: TSensitivity.h:209
Int_t _nS
The number of simulation or other information depend on the used method.
Definition: TSensitivity.h:166
URANIE::Relauncher::TRun * _run
Definition: TSensitivity.h:178
Bool_t _bdrawProgressBar
Boolean to know if the progress bar has to be drawn.
Definition: TSensitivity.h:186
Int_t getNOutput()
Get the number of output attributes.
Definition: TSensitivity.h:415
TString _sFunctionName
The Name of the evaluatuor.
Definition: TSensitivity.h:176
void checkCanvasCreation(bool newcan)
Create a canvas if needed.
Definition: TSensitivity.h:146
vector< int > * getAttributeElements(string str)
Definition: TSensitivity.h:310
Bool_t _bChosenOutputs
Fact that the input list is provided or not.
Definition: TSensitivity.h:183
void unsetLog()
Definition: TSensitivity.h:512
Bool_t _bnoIntermediateSaved
Boolean to know if the progress bar has to be drawn.
Definition: TSensitivity.h:187
virtual void setDrawProgressBar(Bool_t bbool=kTRUE)
Set the "draw progress bar" flag.
Definition: TSensitivity.h:371
TString _sSelectedOutput
The output.
Definition: TSensitivity.h:192
TString _sMethodName
The method name.
Definition: TSensitivity.h:190
void setSensitivityIteratorName(const char *str)
Set the iterator name devoted to compute sensitivity indexes.
Definition: TSensitivity.h:353
void changeLog()
Definition: TSensitivity.h:515
const char * getIteratorName()
Get the name of the iterator attribut of the method.
Definition: TSensitivity.h:349
void setSeed(UInt_t nval)
Definition: TSensitivity.h:325
Bool_t getNoIntermediateSaved()
Get the noIntermediateSaved flag.
Definition: TSensitivity.h:344
virtual void setMethodName(const char *str)
Set the Method name.
Definition: TSensitivity.h:332
Bool_t getDrawProgressBar()
Get the clean flag.
Definition: TSensitivity.h:385
Description of the class TSensitivity.
Definition: TSensitivity.h:111
TString _sSelectedInput
The input.
Definition: TSensitivity.h:193
TMatrixD getMatrixInputCorrelation()
Definition: TSensitivity.h:399
void drawIndexesHistogram(TString sTitre, const char *select="", Option_t *option="")
Draws indexes with an histogram.
Int_t _nX
Dimension of the input.
Definition: TSensitivity.h:167
Int_t _iOut
counter for output
Definition: TSensitivity.h:171
vector< string > _vOutputNames
Name of the output.
Definition: TSensitivity.h:197
void computeIndexes(Option_t *option="")
Compute the Sensitivity Indexes.
Bool_t _bisInputCorrelated
State whether the input correlation matrix is set.
Definition: TSensitivity.h:133
Bool_t _blog
Boolean for edit the log.
Definition: TSensitivity.h:184
TMatrixD _minputCorr
Input correlation matrix if sample needs to be correlated.
Definition: TSensitivity.h:132
unsigned int _iely
iterator over number of element
Definition: TSensitivity.h:173
void checkOutputRequested(string attlist, bool fromoption=false)
Check the output list requested by the user.
Definition: TSensitivity.h:146
map< string, unsigned int > _mAttributeSize
Map of size of element for attribute;.
Definition: TSensitivity.h:195
virtual void parseOption(Option_t *option="")
Read the possible options.
virtual void preTreatment()
PreTreatment for every output.
Definition: TSensitivity.h:238
Int_t getID()
Definition: TSensitivity.h:299
Double_t _valSobolCIUpper
The value of upper Condidence Interval (95)
Definition: TSensitivity.h:131
Bool_t isInputCorrelated()
Definition: TSensitivity.h:392
Bool_t _bgoingThroughError
State whether the error must not block the computation.
Definition: TSensitivity.h:134
#define MAXLENGTHSTRING
Definition: TSensitivity.h:107
virtual TTree * getResultTuple(bool commonresulttuple=true)
Get the result ntuple (default parameter unused but for Morris method)
Definition: TSensitivity.h:303
Double_t _valSobolCrt
The value of sensitivity indexes.
Definition: TSensitivity.h:129
URANIE::DataServer::TDataServer * _tds
Pointeur vers un TDS.
Definition: TSensitivity.h:149
void setNLauncher(ELauncher codeLauncher)
Definition: TSensitivity.h:199
double getValue(const char *sorder="", const char *sinputname="", const char *sselect="")
virtual void postTreatment()
PostTreatment for every output.
Definition: TSensitivity.h:244
const char * getMethodName()
Get the method name.
Definition: TSensitivity.h:336
virtual void setLog()
Definition: TSensitivity.h:509
TList * _listOfInputAttributes
List of the input branches.
Definition: TSensitivity.h:150
map< string, vector< int > > _mAttributeElements
Map of Elements number to run (if vector subselection is requested)
Definition: TSensitivity.h:196
Char_t _sOutputAttribute[MAXLENGTHSTRING]
The name of the output attribute.
Definition: TSensitivity.h:124
Definition: TSensitivity.h:146
UInt_t _nElY
Number of element for one selected output.
Definition: TSensitivity.h:169
void fillIndex(const char *sinputname, const char *sorder, Double_t dval, const char *algo="", Double_t dvalCILower=-1.0, Double_t dvalCIUpper=-1.0)
Method to fill in the tree the value of Sensitivity indexes for an input attribute.
virtual ~TSensitivity()
Default destructor.
TCanvas * _canvas
Canvas object to deal with.
Definition: TSensitivity.h:201
void setNoIntermediateSaved(Bool_t bbool=kTRUE)
Set the "only final file" flag.
Definition: TSensitivity.h:252
virtual void evaluateIndexes(Option_t *option="")=0
Evaluates the index from a Specific TDataServer.
TList * _listOfOutputAttributes
List of the input branches.
Definition: TSensitivity.h:151
TString getTimeName()
Get the name of the time attribute.
Definition: TSensitivity.h:365
ELauncher _nLauncher
The type of launcher.
Definition: TSensitivity.h:175
Double_t _valSobolCILower
The value of lower Condidence Interval (95)
Definition: TSensitivity.h:130
Int_t getNInput()
Get the number of input attributes.
Definition: TSensitivity.h:407
void setInputCorrelationMatrix(TMatrixD Corr)
TTree * _ntresult
The TTree of results.
Definition: TSensitivity.h:211
TObjArray * _drawingGarbageCollector
Garbage collector for prints.
Definition: TSensitivity.h:180
Definition: TSensitivity.h:146
void setTimeName(TString sname)
Set the name of the time attribute (only one)
TString getFunctionName()
Definition: TSensitivity.h:322
UInt_t _nY
Dimension of the target.
Definition: TSensitivity.h:168