English Français

Documentation / Developer's manual

Available modules

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / DataServer: TAttribute.h Source File
Uranie / DataServer  v4.10.0
/* @license-end */
TAttribute.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/>.
18 // $Id$
19 // $Author$
20 // $Date$
21 // $Revision$
22 // $State$
24 
36 #ifndef TAttribute_H
37 #define TAttribute_H
38 #include "TString.h"
39 #include <string>
40 
41 //ROOT
42 #include "TEventList.h"
43 #include "TList.h"
44 #include "TROOT.h"
45 
46 #include "DataServer.h"
47 
48 //URANIE
49 //#include "UExceptions.h"
50 
51 //STL
52 #include <vector>
53 #include <map>
54 #include <list>
55 #include <iostream>
56 using std::vector;
57 using std::string;
58 using std::map;
59 using std::cout;
60 using std::endl;
61 using std::list;
62 
63 //URANIE
64 
65 //#include "UExceptions.h"
66 
67 #define DLE_MAX 1.42387e+64
68 
104 namespace URANIE
105 {
106 namespace DataServer
107 {
108 
109 typedef struct STRUCT
110 {
112 
116  {
128  };
129  TString _sFile;
130  TString _sKey;
131  TString _sFormat;
133  TEventList * _sEventList;
135 
136 class TAttribute: public TNamed
137 {
138 public:
139  enum EOrigin
140  {
142  };
144  {
146  };
147  enum EType
148  {
150  };
151  // Attributes
152 protected:
153  //---------------------------------------------
157  TString _sunity;
158  TString _snote;
159  Bool_t _blog;
160  Int_t _nshare;
162  Int_t _nlevel;
163  Bool_t _haveSon;
164 
165 
166  //---------------------------------------------
171 
172  list<TEventList *> _nfields;
173 
174  list<TAttributeFileKey *> _KeyList;
175 
176 
177  //---------------------------------------------
181  Double_t upperBound;
183 
184  Double_t lowerBound;
186 
187  Double_t _defaultValue;
189 
190  vector<double> _defaultVector;
192 
193  string _defaultString;
195 
196  Double_t _stepValue;
198 
199 
200  //---------------------------------------------
204  vector<Double_t> _vminimum;
205  vector<Double_t> _vmaximum;
206  vector<Double_t> _vmean;
207  vector<Double_t> _vstd;
208 
209  vector<Double_t> *_vbuffer;
210  vector<map<double,double>* > _vquantile;
211 
216 
219  TString _slurmValue;
220 
221 public:
222  //---------------------------------------------
240  TAttribute();
242  TAttribute(const char* name, const char* title);
243 
245 
249  TAttribute(TString name);
251 
256  TAttribute(TString name, EType type);
258 
264  TAttribute(TString name,TString value, EType type);
266 
271  TAttribute(TString name, Double_t lower, Double_t upper);
273  TAttribute(const TAttribute &attr);
275 
280  TAttribute *Clone(const char *newname) const;
282  virtual ~TAttribute();
284 
285 
286  //---------------------------------------------
291 
298  void checkSizeBeforePush(const char* type, int iel, Double_t val);
299 
301 
306  Double_t checkSizeBeforeGet(const char* type, int iel=0);
307 
309 
315  void setQuantile(double prob, double quantile, int iel=0);
317  void getQuantilesSize(int &nb, int iel=0);
319 
330  void getQuantiles(double* prob, double* quantile, int iel=0);
332 
336  void getQuantile(double &prob, double &quantile, int iel=0);
338 
342  void getQuantileVector(double &prob, vector<double> &quantile);
343 
344  // Calculates with a sampling
345  Double_t getMinimum(int iel=0){
346  return checkSizeBeforeGet("Minimum", iel);
347  }
349  Double_t getMinimumSize(){
350 
351  return _vminimum.size();
352  }
354  Bool_t hasDefault() {
355 
356  switch(_nType)
357  {
358  case kVector :
359  return hasDefaultVector();
360  case kString :
361  return hasDefaultString();
362  default :
363  return hasDefaultValue();
364  }
365  }
367 
370  void setMinimum(Double_t val,int iel=0){
371  checkSizeBeforePush("Minimum", iel, val);
372  }
373 
374  Double_t getMaximum(int iel=0){
375  return checkSizeBeforeGet("Maximum", iel);
376  }
378  Double_t getMaximumSize(){
379  return _vmaximum.size();
380  }
382 
385  void setMaximum(Double_t val,int iel=0){
386  checkSizeBeforePush("Maximum", iel, val);
387  }
388 
390 
394  void getStatisticalVector(const char *type, vector<double> &vec);
395 
396  Double_t getMean(int iel=0)
397  {
398  return checkSizeBeforeGet("Mean", iel);
399  }
401  Double_t getMeanSize()
402  {
403  return _vmean.size();
404  }
406 
409  void setMean(Double_t val,int iel=0);
410 
411  Double_t getStd(int iel=0)
412  {
413  return checkSizeBeforeGet("Std", iel);
414  }
416  Double_t getStdSize()
417  {
418  return _vstd.size();
419  }
421 
424  void setStd(Double_t val,int iel=0);
425  void setSlurmOption(TString value)
426  {
427  _slurmValue=value;
428  }
429 
431 
432 
433  //---------------------------------------------
437 
440  {
441  return _nType;
442  }
444 
450  TString getDataTypeStr();
451 
453 
456  void setTitle(const char* title)
457  {
458  SetTitle(title);
459  }
460  void setTitle(TString str)
461  {
462  SetTitle(str.Data());
463  }
464 
465  TString getTitle()
466  {
467  return TString(GetTitle());
468  }
469 
471  void setDataType(EType thetype)
472  {
473  _nType = thetype;
474  }
476 
481  void setDataType(TString name);
482 
484 
487  TString getLegend();
488 
489 
490  TString getUnit()
491  {
492  return _sunity;
493  }
494  void setUnit(TString str)
495  {
496  _sunity = str;
497  }
498 
499  TString getUnity()
500  {
501  return _sunity;
502  }
503  void setUnity(TString str)
504  {
505  _sunity = str;
506  }
507 
508  TString getNote()
509  {
510  return _snote;
511  }
512  void setNote(TString str)
513  {
514  _snote = str;
515  }
516 
517  Bool_t setDefault(TString value);
518  TString getDefault(TString format="%e");
519 
520  Bool_t setDefaultValue(Double_t val);
521  Bool_t getDefaultValue(Double_t &val);
522  Bool_t hasDefaultValue();
523 
524  Bool_t setDefaultVector(vector<double> &vec);
525  Bool_t getDefaultVector(vector<double> *val);
526  Bool_t hasDefaultVector();
527 
528  Bool_t setDefaultString(TString str);
529  Bool_t getDefaultString(string &str);
530  Bool_t hasDefaultString();
531 
532  void setStepValue(Double_t val);
533 
534  Bool_t getStepValue(Double_t &val);
535  TString getSlurmOption()
536  {
537  return _slurmValue;
538  }
540  {
541  return _norigin;
542  }
543  void setOrigin(EOrigin ind)
544  {
545  _norigin = ind;
546  }
547 
548  Int_t getShare()
549  {
550  return _nshare;
551  }
552 
554  void setOutput()
555  {
557  }
559  void setInput()
560  {
562  }
563 
566  {
567  return _nAttribute;
568  }
569 
570 
572 
573  //---------------------------------------------
578 
580 
583  void setFileNameOfKey(TString str);
584 
586  list<URANIE::DataServer::TAttributeFileKey *> getKeyList()
587  {
588  return _KeyList;
589  }
590  ;
591 
593 
596  //void setFieldOfKey(Int_t ind) { _nfield = ind;}
597  void setFieldOfKey(Int_t ind);
598  void setFieldOfKey(Int_t sIndex, Int_t ind);
599 
601 
649  void setFileKey(TString sfile, TString skey = "",
650  TString sformatToSubstitute = "%e",
652 
654 
664  void setFileFlag(TString sfile, TString skey = "", TString sformatToSubstitute = "%e")
665  {
666  setFileKey(sfile, skey, sformatToSubstitute, TAttributeFileKey::kFlag);
667  }
668 
670 
679  void setFileXMLAttribute(TString sfile, TString sXPathAttribute, TString sformatToSubstitute = "%e")
680  {
681  setFileKey(sfile, sXPathAttribute, sformatToSubstitute, TAttributeFileKey::kXMLAttribute);
682  }
683 
685 
694  void setFileXMLField(TString sfile, TString sXPathField, TString sformatToSubstitute = "%e")
695  {
696  setFileKey(sfile, sXPathField, sformatToSubstitute, TAttributeFileKey::kXMLField);
697  }
698 
699  void setFileFMU(TString sfile, TString sXPathField, TString sformatToSubstitute = "%e")
700  {
701  setFileKey(sfile, sXPathField, sformatToSubstitute, TAttributeFileKey::kFMU);
702  }
703 
705 
706  //---------------------------------------------
711  const char* getFormatToSubstitute()
713  {
714  return _sFormatSubstitute.Data();
715  }
716 
718  void setFormatToSubstitute(TString str)
719  {
720  _sFormatSubstitute = str;
721  }
722 
724 
725  //---------------------------------------------
729  Bool_t isInput()
731  {
732  return (((_norigin == kAttribute) || (_norigin == kConstant)) && (_nAttribute == kInput));
733  }
734 
736  Bool_t isOutput()
737  {
738  return ((_norigin == kAttribute) && (_nAttribute == kOutput));
739  }
740 
741  void addShare()
742  {
743  _nshare++;
744  }
745  void delShare()
746  {
747  _nshare--;
748  }
749  void initShare()
750  {
751  _nshare = 1;
752  }
753 
754  void clearVectors();
756 
757  //---------------------------------------------
761  /*
763  \param val (Double_t) The lower bound value of the attribute
764  */
765  virtual void setLowerBound(Double_t val, bool internalcall=false);
767  /*s
768  \return The lower bound value of the attribute
769  */
770  Double_t getLowerBound()
771  {
772  return lowerBound;
773  }
775  /*
776  \return If the attribute have a lower bound value return kTRUE else return kFALSE
777  */
778  Bool_t isLowerBounded()
779  {
780  return _bHaveLowerBound;
781  }
782 
784  /*
785  \param val (Double_t) The upper bound value of the attribute
786  */
787  virtual void setUpperBound(Double_t val, bool internalcall=false);
789  /*
790  \return The upper bound value of the attribute
791  */
792  Double_t getUpperBound()
793  {
794  return upperBound;
795  }
797  /*
798  \return If the attribute have an upper bound value return kTRUE else return kFALSE
799  */
800  Bool_t isUpperBounded()
801  {
802  return _bHaveUpperBound;
803  }
804 
806  /*
807  \exception if the lower bound is superior of the upper boun
808  \exception if the upper bound is inferior of the lower boun
809 
810  \param lower (Double_t) The lower bound value of the attribute
811  \param upper (Double_t) The upper bound value of the attribute
812  */
813  virtual void setBounds(Double_t lower, Double_t upper);
815  /*
816  \return If the attribute have a lower AND an upper bounds return kTRUE else return kFALSE
817  */
818  Bool_t isBounded()
819  {
821  }
823 
824  //---------------------------------------------
828  void setLog()
829  {
830  _blog = kTRUE;
831  }
832  void unsetLog()
833  {
834  _blog = kFALSE;
835  }
836  void changeLog()
837  {
838  _blog = _blog ? kFALSE : kTRUE;
839  }
840  Bool_t getLog()
841  {
842  return _blog;
843  }
844  virtual void printLog();
846 
847 public:
848 
849  //---------------------------------------------
854  void setSonAttribute(TAttribute * tatt);
855  void removeSonAttribute();
856  Int_t getLevel();
857  void setLevel(Int_t nlevel);
858  Bool_t haveSon();
860  ClassDef(URANIE::DataServer::TAttribute, ID_DATASERVER)
861  //Definition of an variable
862 
863 };
864 
865 } // Fin du namespace DataServer
866 } // Fin du namespace URANIE
867 
868 #endif
ROOT.
Definition: TAttribute.h:104
void delShare()
Definition: TAttribute.h:745
EAttribute
Definition: TAttribute.h:143
void getQuantileVector(double &prob, vector< double > &quantile)
Returns the vector of quantile given the probability.
void getQuantilesSize(int &nb, int iel=0)
Returns the number of quantile computed and stored for element iel.
EType _nType
The type of attribute: real (double), vector (of double), string...
Definition: TAttribute.h:215
EFileType _sFileType
Type of substitution.
Definition: TAttribute.h:132
TString _slurmValue
Definition: TAttribute.h:219
Bool_t isOutput()
Tests if the attribute is an output attribute.
Definition: TAttribute.h:736
void setStd(Double_t val, int iel=0)
Set the std value oef element iel.
string _defaultString
Default value for string.
Definition: TAttribute.h:193
TAttribute * _attSon
Son attribute.
Definition: TAttribute.h:161
void setNote(TString str)
Definition: TAttribute.h:512
Bool_t setDefaultVector(vector< double > &vec)
Definition: TAttribute.h:149
Bool_t _haveSon
true if the attribute have a son
Definition: TAttribute.h:163
Definition: TAttribute.h:126
Double_t getMaximumSize()
Returns the size of the vector of maximum.
Definition: TAttribute.h:378
Bool_t _bHaveStepValue
If have a step value.
Definition: TAttribute.h:197
Int_t _nlevel
level to its "father"
Definition: TAttribute.h:162
Bool_t _bHaveUpperBound
If have an upper bound.
Definition: TAttribute.h:182
Int_t _nshare
The number of time this attribute is shared in TDataServer.
Definition: TAttribute.h:160
Double_t getMeanSize()
Returns the size of the vector of mean.
Definition: TAttribute.h:401
list< TEventList * > _nfields
List of all TEventLists created for the attribute.
Definition: TAttribute.h:172
vector< Double_t > _vminimum
All minimun calculated.
Definition: TAttribute.h:204
virtual ~TAttribute()
Default destructor.
Bool_t getDefaultValue(Double_t &val)
Definition: TAttribute.h:125
TEventList * _sEventList
EventList related to a specific couple file/key.
Definition: TAttribute.h:133
void setFieldOfKey(Int_t ind)
Sets index ind in the unique field related to a unique key.
Bool_t _bHaveDefaultString
If have a default value for string.
Definition: TAttribute.h:194
vector< Double_t > _vstd
All std calculated.
Definition: TAttribute.h:207
TString getDataTypeStr()
Returns the datatype as TString.
vector< map< double, double > *> _vquantile
buffer pointer to check addresses
Definition: TAttribute.h:210
void setOutput()
Sets the attribute as an output attribute.
Definition: TAttribute.h:554
Bool_t hasDefault()
Details whether this attribute has a default value.
Definition: TAttribute.h:354
Definition: TAttribute.h:141
TString getLegend()
Returns the legend of the attribut.
void setUnity(TString str)
Definition: TAttribute.h:503
virtual void setLowerBound(Double_t val, bool internalcall=false)
Sets the lower bound value of the attribute.
Bool_t setDefaultValue(Double_t val)
Definition: TAttribute.h:121
void changeLog()
Definition: TAttribute.h:836
Double_t getMean(int iel=0)
Definition: TAttribute.h:396
void checkSizeBeforePush(const char *type, int iel, Double_t val)
Internal method used to check the validity of all setters when dealing with vectors.
void setTitle(const char *title)
Defines the title of the attribute.
Definition: TAttribute.h:456
Double_t upperBound
Upper bound.
Definition: TAttribute.h:181
Definition: TAttribute.h:123
Int_t getShare()
Definition: TAttribute.h:548
Bool_t isLowerBounded()
Returns a boolean if the attribute have a lower bound.
Definition: TAttribute.h:778
void setFileXMLField(TString sfile, TString sXPathField, TString sformatToSubstitute="%e")
Defines the input files as an "XML" input file with XPath field and eventually the format to substitu...
Definition: TAttribute.h:694
TString getUnit()
Definition: TAttribute.h:490
TString _sFile
File related to a key.
Definition: TAttribute.h:129
void setSlurmOption(TString value)
Definition: TAttribute.h:425
EOrigin getOrigin()
Definition: TAttribute.h:539
void setTitle(TString str)
Definition: TAttribute.h:460
Double_t getStd(int iel=0)
Definition: TAttribute.h:411
Definition: TAttribute.h:141
Definition: TAttribute.h:149
void setFormatToSubstitute(TString str)
Sets the format of substitution.
Definition: TAttribute.h:718
Definition: TAttribute.h:141
void setMaximum(Double_t val, int iel=0)
Set the maximum value oef element iel.
Definition: TAttribute.h:385
EAttribute _nAttribute
The nature of attributes : kInput (default) or kOutput.
Definition: TAttribute.h:214
void getStatisticalVector(const char *type, vector< double > &vec)
Returns the vector of considered statistical value.
void setLog()
Definition: TAttribute.h:828
EOrigin _norigin
The origin of the attribute (Internal of uranie, attribute or Input, Output...)
Definition: TAttribute.h:213
void setSonAttribute(TAttribute *tatt)
Bool_t getDefaultVector(vector< double > *val)
void getQuantiles(double *prob, double *quantile, int iel=0)
Returns all the probabilities and corresponding quantiles computed for element iel.
void setMean(Double_t val, int iel=0)
Set the mean value oef element iel.
Definition: TAttribute.h:149
Bool_t setDefault(TString value)
void setMinimum(Double_t val, int iel=0)
Set the minimum value oef element iel.
Definition: TAttribute.h:370
vector< Double_t > _vmean
All mean calculated.
Definition: TAttribute.h:206
Double_t getMinimum(int iel=0)
Definition: TAttribute.h:345
const char * getFormatToSubstitute()
Returns the format of substitution.
Definition: TAttribute.h:712
TString getNote()
Definition: TAttribute.h:508
Bool_t setDefaultString(TString str)
Definition: TAttribute.h:145
Definition: TAttribute.h:149
virtual void setBounds(Double_t lower, Double_t upper)
Sets the two bounds values (lower and upper) of the attribute.
void setDataType(EType thetype)
Change the type of data.
Definition: TAttribute.h:471
vector< double > _defaultVector
Default value for vector.
Definition: TAttribute.h:190
list< TAttributeFileKey * > _KeyList
List of Keys Attributes structures.
Definition: TAttribute.h:174
Double_t getMinimumSize()
Returns the size of the vector of minimum.
Definition: TAttribute.h:349
TString _sunity
Unity.
Definition: TAttribute.h:157
Bool_t _bHaveDefaultValue
If have a default value.
Definition: TAttribute.h:188
TAttribute()
Default constructor.
Definition: TAttribute.h:127
void setStepValue(Double_t val)
void unsetLog()
Definition: TAttribute.h:832
vector< Double_t > _vmaximum
All maximun calculated.
Definition: TAttribute.h:205
Definition: TAttribute.h:145
EFileType
the enum of input file typ
Definition: TAttribute.h:115
void getQuantile(double &prob, double &quantile, int iel=0)
Returns the value of the quantile for element iel, given the probability.
void setOrigin(EOrigin ind)
Definition: TAttribute.h:543
void setQuantile(double prob, double quantile, int iel=0)
Set the quantile value.
vector< Double_t > * _vbuffer
Definition: TAttribute.h:209
TString getUnity()
Definition: TAttribute.h:499
Definition: TAttribute.h:149
Bool_t isBounded()
Returns a boolean if the attribute have a lower AND an upper bounds.
Definition: TAttribute.h:818
void initShare()
Definition: TAttribute.h:749
void setUnit(TString str)
Definition: TAttribute.h:494
Definition: TAttribute.h:119
Double_t getMaximum(int iel=0)
Definition: TAttribute.h:374
struct URANIE::DataServer::STRUCT TAttributeFileKey
Definition: TAttribute.h:141
Bool_t getDefaultString(string &str)
TString _snote
Note.
Definition: TAttribute.h:158
Double_t lowerBound
Lower bound.
Definition: TAttribute.h:184
TString getTitle()
Definition: TAttribute.h:465
TAttribute * Clone(const char *newname) const
Clone an attribute with a new name.
Double_t checkSizeBeforeGet(const char *type, int iel=0)
Internal method used to check the validity of all getters when dealing with vectors and return the re...
void setLevel(Int_t nlevel)
TString _sFormatSubstitute
Format to substitute the value.
Definition: TAttribute.h:170
void setFileKey(TString sfile, TString skey="", TString sformatToSubstitute="%e", TAttributeFileKey::EFileType FileType=TAttributeFileKey::kKey)
Defines the input files and eventually others informations like key, format to substitute.
Definition: TAttribute.h:141
Definition: TAttribute.h:124
Bool_t isUpperBounded()
Returns a boolean if the attribute have an upper bound.
Definition: TAttribute.h:800
Double_t _defaultValue
Default value.
Definition: TAttribute.h:187
void setFileNameOfKey(TString str)
Sets the file name for a key.
Double_t getUpperBound()
Gets the upper bound value of the attribute.
Definition: TAttribute.h:792
Bool_t _bHaveDefaultVector
If have a default value for vector.
Definition: TAttribute.h:191
void setFileXMLAttribute(TString sfile, TString sXPathAttribute, TString sformatToSubstitute="%e")
Defines the input files as an "XML" input file with XPath attribute format and eventually the format ...
Definition: TAttribute.h:679
TString _sFormat
Format to perform substitutions.
Definition: TAttribute.h:131
Definition: TAttribute.h:120
EType
Definition: TAttribute.h:147
void setInput()
Sets the attribute as Input.
Definition: TAttribute.h:559
Bool_t isInput()
Tests if the attribute is an input attribute.
Definition: TAttribute.h:730
Double_t getStdSize()
Returns the size of the vector of std.
Definition: TAttribute.h:416
Description of a variable (field).
Definition: TAttribute.h:136
list< URANIE::DataServer::TAttributeFileKey * > getKeyList()
Gets KeyList for the attribute.
Definition: TAttribute.h:586
Bool_t _blog
Log printing.
Definition: TAttribute.h:159
Definition: TAttribute.h:122
TString getDefault(TString format="%e")
EOrigin
Definition: TAttribute.h:139
void addShare()
Definition: TAttribute.h:741
Bool_t _bHaveLowerBound
If have a lower bound.
Definition: TAttribute.h:185
Definition: TAttribute.h:109
Bool_t getLog()
Definition: TAttribute.h:840
void setFileFlag(TString sfile, TString skey="", TString sformatToSubstitute="%e")
Defines the input files as in the "flag" format and eventually others informations like key...
Definition: TAttribute.h:664
Double_t getLowerBound()
Gets the lower bound value of the attribute.
Definition: TAttribute.h:770
Definition: TAttribute.h:117
Double_t _stepValue
Step value when using in Optimization.
Definition: TAttribute.h:196
Bool_t getStepValue(Double_t &val)
TString getSlurmOption()
Definition: TAttribute.h:535
void setFileFMU(TString sfile, TString sXPathField, TString sformatToSubstitute="%e")
Definition: TAttribute.h:699
virtual void setUpperBound(Double_t val, bool internalcall=false)
Sets the upper bound value of the attribute.
Definition: TAttribute.h:118
EAttribute getInputOutput()
Returns the input/Output information of the attribute.
Definition: TAttribute.h:565
EType getDataType() const
Returns the datatype of the considered attribute.
Definition: TAttribute.h:439
TString _sKey
Name of the key.
Definition: TAttribute.h:130
Definition: TAttribute.h:149