English Français

Documentation / Manuel développeur

Modules disponibles

Calibration,  DataServer,  Launcher,  MetaModelOptim,  Modeler,  Optimizer,  ReLauncher,  Reliability,  ReOptimizer,  Sampler,  Sensitivity,  UncertModeler,  XmlProblem,   Uranie / DataServer: TAttribute.h Source File
Uranie / DataServer v4.9.0
/* @license-end */
TAttribute.h
Go to the documentation of this file.
1
2// 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#include "TSystem.h"
46
47#include "DataServer.h"
48
49//URANIE
50//#include "UExceptions.h"
51
52//STL
53#include <vector>
54#include <map>
55#include <list>
56#include <iostream>
57using std::vector;
58using std::string;
59using std::map;
60using std::cout;
61using std::endl;
62using std::list;
63
64//URANIE
65
66//#include "UExceptions.h"
67
68#define DLE_MAX 1.42387e+64
69
105namespace URANIE
106{
107namespace DataServer
108{
109
136
137class TAttribute: public TNamed
138{
139public:
152 // Attributes
153protected:
154 //---------------------------------------------
158 TString _sunity;
159 TString _snote;
160 Bool_t _blog;
161 Int_t _nshare;
163 Int_t _nlevel;
164 Bool_t _haveSon;
166
167 //---------------------------------------------
172
173 list<TEventList *> _nfields;
174
175 list<TAttributeFileKey *> _KeyList;
177
178 //---------------------------------------------
182 Double_t upperBound;
184
185 Double_t lowerBound;
187
188 Double_t _defaultValue;
190
191 vector<double> _defaultVector;
193
196
197 Double_t _stepValue;
200
201 //---------------------------------------------
205 vector<Double_t> _vminimum;
206 vector<Double_t> _vmaximum;
207 vector<Double_t> _vmean;
208 vector<Double_t> _vstd;
209
210 vector<Double_t> *_vbuffer;
211 vector<map<double,double>* > _vquantile;
212
217
220 TString _slurmValue;
221
222public:
223 //---------------------------------------------
241
243 TAttribute(const char* name, const char* title);
244
246
250 TAttribute(TString name);
252
257 TAttribute(TString name, EType type);
259
265 TAttribute(TString name,TString value, EType type);
267
272 TAttribute(TString name, Double_t lower, Double_t upper);
274 TAttribute(const TAttribute &attr);
276
281 TAttribute *Clone(const char *newname) const;
283 virtual ~TAttribute();
285
286
287 //---------------------------------------------
292
299 void checkSizeBeforePush(const char* type, int iel, Double_t val);
300
302
307 Double_t checkSizeBeforeGet(const char* type, int iel=0);
308
310
316 void setQuantile(double prob, double quantile, int iel=0);
318 void getQuantilesSize(int &nb, int iel=0);
320
331 void getQuantiles(double* prob, double* quantile, int iel=0);
333
337 void getQuantile(double &prob, double &quantile, int iel=0);
339
343 void getQuantileVector(double &prob, vector<double> &quantile);
344
345 // Calculates with a sampling
346 Double_t getMinimum(int iel=0){
347 return checkSizeBeforeGet("Minimum", iel);
348 }
350 Double_t getMinimumSize(){
351
352 return _vminimum.size();
353 }
355 Bool_t hasDefault() {
356
357 switch(_nType)
358 {
359 case kVector :
360 return hasDefaultVector();
361 case kString :
362 return hasDefaultString();
363 default :
364 return hasDefaultValue();
365 }
366 }
368
371 void setMinimum(Double_t val,int iel=0){
372 checkSizeBeforePush("Minimum", iel, val);
373 }
374
375 Double_t getMaximum(int iel=0){
376 return checkSizeBeforeGet("Maximum", iel);
377 }
379 Double_t getMaximumSize(){
380 return _vmaximum.size();
381 }
383
386 void setMaximum(Double_t val,int iel=0){
387 checkSizeBeforePush("Maximum", iel, val);
388 }
389
391
395 void getStatisticalVector(const char *type, vector<double> &vec);
396
397 Double_t getMean(int iel=0)
398 {
399 return checkSizeBeforeGet("Mean", iel);
400 }
402 Double_t getMeanSize()
403 {
404 return _vmean.size();
405 }
407
410 void setMean(Double_t val,int iel=0);
411
412 Double_t getStd(int iel=0)
413 {
414 return checkSizeBeforeGet("Std", iel);
415 }
417 Double_t getStdSize()
418 {
419 return _vstd.size();
420 }
422
425 void setStd(Double_t val,int iel=0);
426 void setSlurmOption(TString value)
427 {
428 _slurmValue=value;
429 }
430
432
433
434 //---------------------------------------------
438
441 {
442 return _nType;
443 }
445
451 TString getDataTypeStr();
452
454
457 void setTitle(const char* title)
458 {
459 SetTitle(title);
460 }
461 void setTitle(TString str)
462 {
463 SetTitle(str.Data());
464 }
465
466 TString getTitle()
467 {
468 return TString(GetTitle());
469 }
470
472 void setDataType(EType thetype)
473 {
474 _nType = thetype;
475 }
477
482 void setDataType(TString name);
483
485
488 TString getLegend();
489
490
491 TString getUnit()
492 {
493 return _sunity;
494 }
495 void setUnit(TString str)
496 {
497 _sunity = str;
498 }
499
500 TString getUnity()
501 {
502 return _sunity;
503 }
504 void setUnity(TString str)
505 {
506 _sunity = str;
507 }
508
509 TString getNote()
510 {
511 return _snote;
512 }
513 void setNote(TString str)
514 {
515 _snote = str;
516 }
517
518 Bool_t setDefault(TString value);
519 TString getDefault(TString format="%e");
520
521 Bool_t setDefaultValue(Double_t val);
522 Bool_t getDefaultValue(Double_t &val);
524
525 Bool_t setDefaultVector(vector<double> &vec);
526 Bool_t getDefaultVector(vector<double> *val);
528
529 Bool_t setDefaultString(TString str);
530 Bool_t getDefaultString(string &str);
532
533 void setStepValue(Double_t val);
534
535 Bool_t getStepValue(Double_t &val);
537 {
538 return _slurmValue;
539 }
541 {
542 return _norigin;
543 }
545 {
546 _norigin = ind;
547 }
548
549 Int_t getShare()
550 {
551 return _nshare;
552 }
553
556 {
558 }
560 void setInput()
561 {
563 }
564
567 {
568 return _nAttribute;
569 }
570
571
573
574 //---------------------------------------------
579
581
584 void setFileNameOfKey(TString str);
585
587 list<URANIE::DataServer::TAttributeFileKey *> getKeyList()
588 {
589 return _KeyList;
590 }
591 ;
592
594
597 //void setFieldOfKey(Int_t ind) { _nfield = ind;}
598 void setFieldOfKey(Int_t ind);
599 void setFieldOfKey(Int_t sIndex, Int_t ind);
600
602
650 void setFileKey(TString sfile, TString skey = "",
651 TString sformatToSubstitute = "%e",
653
655
665 void setFileFlag(TString sfile, TString skey = "", TString sformatToSubstitute = "%e")
666 {
667 setFileKey(sfile, skey, sformatToSubstitute, TAttributeFileKey::kFlag);
668 }
669
671
680 void setFileXMLAttribute(TString sfile, TString sXPathAttribute, TString sformatToSubstitute = "%e")
681 {
682 setFileKey(sfile, sXPathAttribute, sformatToSubstitute, TAttributeFileKey::kXMLAttribute);
683 }
684
686
695 void setFileXMLField(TString sfile, TString sXPathField, TString sformatToSubstitute = "%e")
696 {
697 setFileKey(sfile, sXPathField, sformatToSubstitute, TAttributeFileKey::kXMLField);
698 }
699
700 void setFileFMU(TString sfile, TString sXPathField, TString sformatToSubstitute = "%e")
701 {
702 setFileKey(sfile, sXPathField, sformatToSubstitute, TAttributeFileKey::kFMU);
703 }
704
706
707 //---------------------------------------------
712
714 {
715 return _sFormatSubstitute.Data();
716 }
717
719 void setFormatToSubstitute(TString str)
720 {
721 _sFormatSubstitute = str;
722 }
723
725
726 //---------------------------------------------
730
731 Bool_t isInput()
732 {
733 return (((_norigin == kAttribute) || (_norigin == kConstant)) && (_nAttribute == kInput));
734 }
735
737 Bool_t isOutput()
738 {
739 return ((_norigin == kAttribute) && (_nAttribute == kOutput));
740 }
741
742 void addShare()
743 {
744 _nshare++;
745 }
746 void delShare()
747 {
748 _nshare--;
749 }
751 {
752 _nshare = 1;
753 }
754
757
758 //---------------------------------------------
762
763 /*
764 \param val (Double_t) The lower bound value of the attribute
765 */
766 virtual void setLowerBound(Double_t val, bool internalcall=false);
768 /*s
769 \return The lower bound value of the attribute
770 */
771 Double_t getLowerBound()
772 {
773 return lowerBound;
774 }
776 /*
777 \return If the attribute have a lower bound value return kTRUE else return kFALSE
778 */
780 {
781 return _bHaveLowerBound;
782 }
783
785 /*
786 \param val (Double_t) The upper bound value of the attribute
787 */
788 virtual void setUpperBound(Double_t val, bool internalcall=false);
790 /*
791 \return The upper bound value of the attribute
792 */
793 Double_t getUpperBound()
794 {
795 return upperBound;
796 }
798 /*
799 \return If the attribute have an upper bound value return kTRUE else return kFALSE
800 */
802 {
803 return _bHaveUpperBound;
804 }
805
807 /*
808 \exception if the lower bound is superior of the upper boun
809 \exception if the upper bound is inferior of the lower boun
810
811 \param lower (Double_t) The lower bound value of the attribute
812 \param upper (Double_t) The upper bound value of the attribute
813 */
814 virtual void setBounds(Double_t lower, Double_t upper);
816 /*
817 \return If the attribute have a lower AND an upper bounds return kTRUE else return kFALSE
818 */
819 Bool_t isBounded()
820 {
822 }
824
825 //---------------------------------------------
829 void setLog()
830 {
831 _blog = kTRUE;
832 }
833 void unsetLog()
834 {
835 _blog = kFALSE;
836 }
838 {
839 _blog = _blog ? kFALSE : kTRUE;
840 }
841 Bool_t getLog()
842 {
843 return _blog;
844 }
845 virtual void printLog();
847
848public:
849
850 //---------------------------------------------
857 Int_t getLevel();
858 void setLevel(Int_t nlevel);
859 Bool_t haveSon();
861 ClassDef(URANIE::DataServer::TAttribute, ID_DATASERVER)
862 //Definition of an variable
863
864};
865
866} // Fin du namespace DataServer
867} // Fin du namespace URANIE
868
869#endif
Description of a variable (field).
Definition TAttribute.h:138
void setOutput()
Sets the attribute as an output attribute.
Definition TAttribute.h:555
EType getDataType() const
Returns the datatype of the considered attribute.
Definition TAttribute.h:440
EOrigin
Definition TAttribute.h:141
@ kDeleted
Definition TAttribute.h:142
@ kAttribute
Definition TAttribute.h:142
@ kInternal
Definition TAttribute.h:142
@ kConstant
Definition TAttribute.h:142
@ kIterator
Definition TAttribute.h:142
void setMinimum(Double_t val, int iel=0)
Set the minimum value oef element iel.
Definition TAttribute.h:371
const char * getFormatToSubstitute()
Returns the format of substitution.
Definition TAttribute.h:713
void getQuantileVector(double &prob, vector< double > &quantile)
Returns the vector of quantile given the probability.
TString getUnity()
Definition TAttribute.h:500
Bool_t isOutput()
Tests if the attribute is an output attribute.
Definition TAttribute.h:737
Int_t getShare()
Definition TAttribute.h:549
void setNote(TString str)
Definition TAttribute.h:513
Int_t _nlevel
level to its "father"
Definition TAttribute.h:163
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:665
TString getDefault(TString format="%e")
void setSonAttribute(TAttribute *tatt)
void delShare()
Definition TAttribute.h:746
void setMaximum(Double_t val, int iel=0)
Set the maximum value oef element iel.
Definition TAttribute.h:386
TAttribute()
Default constructor.
Bool_t _bHaveStepValue
If have a step value.
Definition TAttribute.h:198
void checkSizeBeforePush(const char *type, int iel, Double_t val)
Internal method used to check the validity of all setters when dealing with vectors.
Int_t _nshare
The number of time this attribute is shared in TDataServer.
Definition TAttribute.h:161
EType
Definition TAttribute.h:149
@ kReal
Definition TAttribute.h:150
@ kString
Definition TAttribute.h:150
@ kInconnu
Definition TAttribute.h:150
@ kCategory
Definition TAttribute.h:150
@ kDefault
Definition TAttribute.h:150
@ kVector
Definition TAttribute.h:150
void setLog()
Definition TAttribute.h:829
void setLevel(Int_t nlevel)
Double_t _stepValue
Step value when using in Optimization.
Definition TAttribute.h:197
TAttribute(TString name, EType type)
Constructor by name and type only.
void setFileNameOfKey(TString str)
Sets the file name for a key.
virtual void setBounds(Double_t lower, Double_t upper)
Sets the two bounds values (lower and upper) of the attribute.
TString _snote
Note.
Definition TAttribute.h:159
virtual void setUpperBound(Double_t val, bool internalcall=false)
Sets the upper bound value of the attribute.
TString getDataTypeStr()
Returns the datatype as TString.
Bool_t isLowerBounded()
Returns a boolean if the attribute have a lower bound.
Definition TAttribute.h:779
void setQuantile(double prob, double quantile, int iel=0)
Set the quantile value.
vector< double > _defaultVector
Default value for vector.
Definition TAttribute.h:191
TAttribute * Clone(const char *newname) const
Clone an attribute with a new name.
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.
EAttribute _nAttribute
The nature of attributes : kInput (default) or kOutput.
Definition TAttribute.h:215
void getQuantilesSize(int &nb, int iel=0)
Returns the number of quantile computed and stored for element iel.
Double_t lowerBound
Lower bound.
Definition TAttribute.h:185
Bool_t setDefault(TString value)
Bool_t _bHaveLowerBound
If have a lower bound.
Definition TAttribute.h:186
list< URANIE::DataServer::TAttributeFileKey * > getKeyList()
Gets KeyList for the attribute.
Definition TAttribute.h:587
TString getTitle()
Definition TAttribute.h:466
vector< map< double, double > * > _vquantile
‍buffer pointer to check addresses
Definition TAttribute.h:211
Double_t getMean(int iel=0)
Definition TAttribute.h:397
void setOrigin(EOrigin ind)
Definition TAttribute.h:544
void unsetLog()
Definition TAttribute.h:833
vector< Double_t > _vminimum
All minimun calculated.
Definition TAttribute.h:205
void setDataType(TString name)
Change the type of data.
Bool_t getStepValue(Double_t &val)
TString getSlurmOption()
Definition TAttribute.h:536
void setStd(Double_t val, int iel=0)
Set the std value oef element iel.
Double_t getMaximumSize()
Returns the size of the vector of maximum.
Definition TAttribute.h:379
TString getNote()
Definition TAttribute.h:509
void setUnity(TString str)
Definition TAttribute.h:504
Bool_t _bHaveDefaultValue
If have a default value.
Definition TAttribute.h:189
vector< Double_t > _vmaximum
All maximun calculated.
Definition TAttribute.h:206
Bool_t setDefaultValue(Double_t val)
Double_t getMaximum(int iel=0)
Definition TAttribute.h:375
Bool_t getDefaultString(string &str)
void setTitle(TString str)
Definition TAttribute.h:461
void setFieldOfKey(Int_t sIndex, Int_t ind)
Double_t getUpperBound()
Gets the upper bound value of the attribute.
Definition TAttribute.h:793
Double_t getLowerBound()
Gets the lower bound value of the attribute.
Definition TAttribute.h:771
virtual void setLowerBound(Double_t val, bool internalcall=false)
Sets the lower bound value of the attribute.
string _defaultString
Default value for string.
Definition TAttribute.h:194
Bool_t getDefaultValue(Double_t &val)
TAttribute * _attSon
Son attribute.
Definition TAttribute.h:162
Double_t getStdSize()
Returns the size of the vector of std.
Definition TAttribute.h:417
virtual ~TAttribute()
Default destructor.
Double_t getMeanSize()
Returns the size of the vector of mean.
Definition TAttribute.h:402
void getQuantiles(double *prob, double *quantile, int iel=0)
Returns all the probabilities and corresponding quantiles computed for element iel.
Bool_t getLog()
Definition TAttribute.h:841
vector< Double_t > _vstd
All std calculated.
Definition TAttribute.h:208
Bool_t _haveSon
true if the attribute have a son
Definition TAttribute.h:164
Bool_t hasDefault()
Details whether this attribute has a default value.
Definition TAttribute.h:355
vector< Double_t > _vmean
All mean calculated.
Definition TAttribute.h:207
Bool_t _bHaveDefaultVector
If have a default value for vector.
Definition TAttribute.h:192
Bool_t isBounded()
Returns a boolean if the attribute have a lower AND an upper bounds.
Definition TAttribute.h:819
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...
Double_t getMinimum(int iel=0)
Definition TAttribute.h:346
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:680
void setFieldOfKey(Int_t ind)
Sets index ind in the unique field related to a unique key.
void setStepValue(Double_t val)
Bool_t setDefaultVector(vector< double > &vec)
void setInput()
Sets the attribute as Input.
Definition TAttribute.h:560
void addShare()
Definition TAttribute.h:742
TString getLegend()
Returns the legend of the attribut.
EOrigin getOrigin()
Definition TAttribute.h:540
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:695
void setFileFMU(TString sfile, TString sXPathField, TString sformatToSubstitute="%e")
Definition TAttribute.h:700
EOrigin _norigin
The origin of the attribute (Internal of uranie, attribute or Input, Output...)
Definition TAttribute.h:214
void setTitle(const char *title)
Defines the title of the attribute.
Definition TAttribute.h:457
void setFormatToSubstitute(TString str)
Sets the format of substitution.
Definition TAttribute.h:719
EAttribute
Definition TAttribute.h:145
@ kOutput
Definition TAttribute.h:146
@ kInput
Definition TAttribute.h:146
TAttribute(const TAttribute &attr)
Copy constructor.
void changeLog()
Definition TAttribute.h:837
vector< Double_t > * _vbuffer
Definition TAttribute.h:210
TString _slurmValue
Definition TAttribute.h:220
Double_t getMinimumSize()
Returns the size of the vector of minimum.
Definition TAttribute.h:350
TAttribute(TString name, TString value, EType type)
Constructor by name and range.
Bool_t getDefaultVector(vector< double > *val)
list< TEventList * > _nfields
List of all TEventLists created for the attribute.
Definition TAttribute.h:173
Bool_t isInput()
Tests if the attribute is an input attribute.
Definition TAttribute.h:731
Bool_t isUpperBounded()
Returns a boolean if the attribute have an upper bound.
Definition TAttribute.h:801
void setUnit(TString str)
Definition TAttribute.h:495
void setDataType(EType thetype)
Change the type of data.
Definition TAttribute.h:472
TString getUnit()
Definition TAttribute.h:491
Double_t _defaultValue
Default value.
Definition TAttribute.h:188
TAttribute(TString name)
Constructor by name only.
TAttribute(TString name, Double_t lower, Double_t upper)
Constructor by name and range.
Bool_t _blog
Log printing.
Definition TAttribute.h:160
TString _sFormatSubstitute
Format to substitute the value.
Definition TAttribute.h:171
TString _sunity
Unity.
Definition TAttribute.h:158
list< TAttributeFileKey * > _KeyList
List of Keys Attributes structures.
Definition TAttribute.h:175
void setMean(Double_t val, int iel=0)
Set the mean value oef element iel.
EAttribute getInputOutput()
Returns the input/Output information of the attribute.
Definition TAttribute.h:566
Bool_t setDefaultString(TString str)
void getStatisticalVector(const char *type, vector< double > &vec)
Returns the vector of considered statistical value.
Bool_t _bHaveUpperBound
If have an upper bound.
Definition TAttribute.h:183
EType _nType
The type of attribute: real (double), vector (of double), string...
Definition TAttribute.h:216
void setSlurmOption(TString value)
Definition TAttribute.h:426
Bool_t _bHaveDefaultString
If have a default value for string.
Definition TAttribute.h:195
void getQuantile(double &prob, double &quantile, int iel=0)
Returns the value of the quantile for element iel, given the probability.
TAttribute(const char *name, const char *title)
void initShare()
Definition TAttribute.h:750
Double_t getStd(int iel=0)
Definition TAttribute.h:412
Double_t upperBound
Upper bound.
Definition TAttribute.h:182
struct URANIE::DataServer::STRUCT TAttributeFileKey
ROOT.
Definition TAttribute.h:106
Definition TAttribute.h:111
TString _sFormat
Format to perform substitutions.
Definition TAttribute.h:132
TString _sKey
Name of the key.
Definition TAttribute.h:131
EFileType _sFileType
Type of substitution.
Definition TAttribute.h:133
TString _sFile
File related to a key.
Definition TAttribute.h:130
EFileType
the enum of input file typ
Definition TAttribute.h:117
@ kNewColumn
Definition TAttribute.h:124
@ kNewRow
Definition TAttribute.h:123
@ kXMLField
Definition TAttribute.h:126
@ kKey
Definition TAttribute.h:119
@ kFlag
Definition TAttribute.h:120
@ kNewKey
Definition TAttribute.h:121
@ kUnknown
Definition TAttribute.h:118
@ kXMLAttribute
Definition TAttribute.h:125
@ kNewTDS
Definition TAttribute.h:128
@ kFMU
Definition TAttribute.h:127
@ kNewLine
Definition TAttribute.h:122
TEventList * _sEventList
EventList related to a specific couple file/key.
Definition TAttribute.h:134