REST-for-Physics
v2.3
Rare Event Searches ToolKit for Physics
|
A base class for any REST metadata class.
One of the core classes of REST. Abstract class from which all REST "metadata classes" must derive. A metadata class in REST is any holder of data other than event data that is relevant to understand the origin and history of transformations that a given set of event data has gone through. For example the geometry of a simulation, the parameters of a process, the properties of a gas, the readout pattern used to "pixelize" data, etc... are examples of metadata. All metadata classes can be "initialized" via configuration (.rml) files that the user can write. Alternatively they can be read from root files. TRestMetadata contains the common functionality that allows metadata to be read from .rml files or previously stored
TRestMetadata structures stored in a ROOT file.
A class deriving from TRestMetadata can retrieve information from a plain text configuration file (or RML file). The syntaxis in an RML file is imposed by TRestMetadata. The rml file is encoded in standard xml format and has a structure similar to the real class structure. The following piece of code shows the common structure of the metadata description corresponding to a specific metadata class.
In REST, the key word "ClassName", "SomeCommand", "ContainedClassName" shown above are all called xml decalration. The key words like "field1="value1"" or "name="userGivenName"" are called fields or xml attributes. All the sealed xml structure is called xml element or xml section.
Note that the decalration "include", "for", "variable" and "constant" is reserved for the software. They works differently than others, which we will talk later.
The rml file is designed to start up/instruct all the metadata classes. Usually we implement the method Initialize() and calls it in the constructor to do some default settings.
The starter method LoadConfigFromFile() is implemented in this class, with four overloads, as shown in the following.
If no arguments are provided, LoadConfigFromFile() will only call the Initialize() method. If given the rml file name, it will find out the needed rml sections. We can also directly give the xml sections to the method. Two xml sections are used to startup the class: the section for the class and a global section. Additionally we can give a map object to the method to import additional variables.
The "section for the class" is an xml section with the value of class name. It is the main information source for the class's startup. The "global" section is a special xml section in the rml file, containing global information which could be seen by all the class sections.
With the xml sections given, LoadConfigFromFile() first merge them together. Then it calls LoadSectionMetadata(), which loads some universal parameters like name, title and verbose level. This method also preprocesses the config sections, expanding the include/for definition and replacing the variables. After this, LoadConfigFromFile() calls the method InitFromConfigFile().
InitFromConfigFile() is a pure virtual method and every child classes have to implement it. This method defines how the metadata class loads its xml config section. A simple kind of implementation is to add few lines of GetParameter():
A more advanced usage is sequential startup, when the metadata class contains another metadata class. We can write in the host class's InitFromConfigFile() to new the resident class, and the call the resident class's LoadConfigFromFile() method, giving the child section as the resident class's config section. The rml hierarchy could therefore be the same as class residence.
For example, when received an xml section declared "TRestRun", the host "TRestManager" will pass this section (together with its global section) to its resident "TRestRun". The TRestRun class can therefore perform a startup using these sections.
By default, LoadConfigFromFile() will look into only the first-level child sections of both global and sectional section. If the section value is either "variable" or "constant", the class will keep them for replacement.
LoadConfigFromFile() will replace the field values of xml sections before they are used. The procedure of replacing is as following:
After replacement, LoadConfigFromFile() will call TFormula to evaluate the string if it is identified as an math expression.
The result string of the field value is either a number string or a string with concrete content. In the example code above, the section declared with parameter
will have its field value reset to string 126.
See also the section The globals section.
It is possible to link to other files in any section. There are two include modes:
After the expansion is done, variable replacement is also performed.
If the target file is a root file, there will be a different way to load, see TRestRun::ImportMetadata()
The definition of FOR loops is implemented in RML in order to allow extense definitions, where many elements may need to be added to an existing array in our metadata structure. The use of FOR loops allows to introduce more versatil and extense definitions. Its implementation was fundamentally triggered by its use in the construction of complex, multi-channel generic readouts by TRestDetectorReadout.
The for loop definition can be either from-to-step
structure or in
structure. The loop variable is defined in variable
attribute, which is treated same as rml variable. In from-to-step
structure, the value must be numbers. REST will loop form from
to to
with step size step
. In in
structure, the values are treated as string, and must be separated with :
. For example:
The first for loop definition will be expanded to 64 <readoutChannel sections with 64 <addPixel sections in each. The nCh and nPix variables will be 0~64 in each section. The second for loop definition will be expanded to 7 <TRestAnalysisPlot sections with nMod be valued 0,2,3,4,6,8,9 respectivelly.
It is supported in rml to use <if structure. If the condition matches, the inner sections of <if section will be expaned to and seen by the parent section. This helps to identify different use cases of the rml. For example:
Here "condition" specifies the comparing condition, it can either be a complete expression or just the right side of it. In incomplete case, the left side shall be expressed by "evaluate", which is a shell command to be executed.
In the example, if the home directory is "/home/nkx", the process "TRestRawZeroSuppresionProcess" will be added. If the date is larger than 2019-08-21, the process "TRestDetectorSignalToHitsProcess" will be added.
Condition markers supports: ==
, !=
, >
, <
, <=
, >=
. Its better to escape the ">", "<" markers. Note that those markers are also valid for strings. If the two sides of the expression are not numbers, REST will perform string comparasion. The ordering is according to the alphabet. A common misleading fact is that "1235">"12345", rather than 1235<12345 as number.
The *globals* section allows to specify common definitions that can be used by any other metadata or process definitions found in the same RML. We may define a parameter (such as the `sampling` rate of electronics) which is usually common to different rawsignal processes. Or we can define a particular value is to be used many times by different classes, it is better to create a `constant` or `variable` inside the `globals` section.
Possible key values included in this section are:
The global section will have effect on all the metadata structures (or sections) that are defined in a same RML file. It does not affect to other possible linked sections defined by reference using for example nameref.
See also the section Replacement of variables and expressions.
Some times we don't want to write a long full path to specify files, especially when multiple files are in a same remote directory. REST provides a universal file path definition in rml.
When calling TRestMetadata::SearchFile(), REST will search the file in all the paths defined in section "searchPath", and return a full name if found. Include definition has already adopted this search strategy. Child classes can also take advantage of it.
Three fields in the first line of an xml section will be looked for before anything else. They are: name, title, and verboseLevel. If not specified, LoadConfigFromFile() will find in the globals section. If still not fond, it will use the default value.
Field "name" and "title" is needed by TNamed classes. The "verboseLevel" is used for changing the amount of output infomation. The following line would print on screen any debug message implemented in TRestDetectorSignalAnalysisProcess.
Some physical parameters are need to specify the unit so that the provided value makes sense. For example, when defining the electric field we must provide its units.
The physical field values wrote in this way will be converted to the standard unit system used by REST. REST_Units namespace provides details on the different existing units, unit conversion and unit definition.
When we retrieve any value from a REST member in a TRestMetadata class the value will be returned in the default REST units (mm, keV, V/cm, us). We may convert this member to the desired units (as defined in REST_Units), by doing:
GetParameter(), GetElement(), GetElementWithName(), SearchFile(). Details are shown in the function's document
RESTsoft - Software for Rare Event Searches with TPCs
History of developments:
2014-june: First concept. As part of conceptualization of previous REST code (REST v2) Igor G. Irastorza
2015-jul: Re-implementation to read .rml files with xml-inspired syntax Javier Galán
2017-Aug: Major change to xml reading and class startup procedure Kaixiang Ni
Definition at line 74 of file TRestMetadata.h.
#include <TRestMetadata.h>
Public Member Functions | |
void | AddLog (std::string log="", bool print=true) |
Add logs to messageBuffer. | |
void | DoNotStore () |
If this method is called the metadata information will not be stored in disk. | |
TVector2 | Get2DVectorParameterWithUnits (std::string parName, TVector2 defaultValue=TVector2(-1, -1)) |
TVector3 | Get3DVectorParameterWithUnits (std::string parName, TVector3 defaultValue=TVector3(-1, -1, -1)) |
TString | GetCommit () |
Returns the REST commit value stored in fCommit. | |
std::string | GetConfigBuffer () |
Returns the config section of this class. | |
std::string | GetDataMemberValue (std::string memberName) |
Get the value of data member as string. More... | |
std::vector< std::string > | GetDataMemberValues (std::string memberName, Int_t precision=0) |
Get the value of datamember as a vector of strings. More... | |
TString | GetDataPath () |
Returns a std::string with the path used for data storage. | |
Double_t | GetDblParameterWithUnits (std::string parName, Double_t defaultValue=PARAMETER_NOT_FOUND_DBL) |
Gets the value of the parameter name parName, after applying unit conversion. More... | |
Bool_t | GetError () const |
It returns true if an error was identified by a derived metadata class. | |
TString | GetErrorMessage () |
Returns a std::string containing the error message. | |
TString | GetLibraryVersion () |
Returns the REST libraty version stored in fLibraryVersion. | |
TString | GetMainDataPath () |
Gets a std::string with the path used for data storage. | |
Int_t | GetNumberOfErrors () const |
Int_t | GetNumberOfWarnings () const |
std::string | GetParameter (std::string parName, TString defaultValue=PARAMETER_NOT_FOUND_STR) |
Returns corresponding REST Metadata parameter from multiple sources. More... | |
std::string | GetSectionName () |
Returns the section name of this class, defined at the beginning of fSectionName. | |
TRestStringOutput::REST_Verbose_Level | GetVerboseLevel () |
returns the verboselevel in type of REST_Verbose_Level enumerator | |
TString | GetVerboseLevelString () |
returns the verbose level in type of TString More... | |
TString | GetVersion () |
Returns the REST version stored in fVersion. | |
Int_t | GetVersionCode () |
UInt_t | GetVersionMajor () const |
UInt_t | GetVersionMinor () const |
UInt_t | GetVersionPatch () const |
Bool_t | GetWarning () const |
It returns true if an error was identified by a derived metadata class. | |
TString | GetWarningMessage () |
Returns a std::string containing the warning message. | |
virtual void | Initialize () |
Making default settings. | |
TRestMetadata * | InstantiateChildMetadata (int index, std::string pattern="") |
This method will retrieve a new TRestMetadata instance of a child element of the present TRestMetadata instance based on the index given by argument, which defines the element order to be retrieved, 0 for first element found, 1 for the second element found, etc. More... | |
TRestMetadata * | InstantiateChildMetadata (std::string pattern="", std::string name="") |
This method will retrieve a new TRestMetadata instance of a child element of the present TRestMetadata instance based on the name given by argument. More... | |
Bool_t | isCleanState () const |
Bool_t | isOfficialRelease () const |
Int_t | LoadConfigFromBuffer () |
Initialize data from a string element buffer. More... | |
Int_t | LoadConfigFromElement (TiXmlElement *eSectional, TiXmlElement *eGlobal, std::map< std::string, std::string > envs={}) |
Main starter method. More... | |
Int_t | LoadConfigFromFile (const std::string &configFilename, const std::string §ionName="") |
Give the file name, find out the corresponding section. Then call the main starter. | |
virtual void | Merge (const TRestMetadata &) |
TRestMetadata & | operator= (const TRestMetadata &) |
void | Print () |
Implementing TObject::Print() method. | |
void | PrintConfigBuffer () |
Print the config xml section stored in the class. More... | |
void | PrintMessageBuffer () |
Print the buffered message. | |
virtual void | PrintMetadata () |
Implemented it in the derived metadata class to print out specific metadata information. More... | |
void | PrintTimeStamp (Double_t timeStamp) |
Print the current time on local machine. More... | |
void | SetConfigFile (std::string configFilename) |
set config file path from external | |
void | SetError (std::string message="", bool print=true, int maxPrint=5) |
A metadata class may use this method to signal that something went wrong. | |
void | SetHostmgr (TRestManager *m) |
Set the host manager for this class. | |
void | SetSectionName (std::string sName) |
set the section name, clear the section content | |
void | SetVerboseLevel (TRestStringOutput::REST_Verbose_Level v) |
sets the verbose level | |
void | SetWarning (std::string message="", bool print=true, int maxPrint=5) |
A metadata class may use this method to signal that something went wrong. | |
void | Store () |
If this method is called the metadata information will be stored in disk. | |
TRestMetadata (const TRestMetadata &) | |
virtual void | UpdateMetadataMembers () |
Method to allow implementation of specific metadata members updates at inherited classes. | |
virtual Int_t | Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) |
overwriting the write() method with fStore considered | |
void | WriteConfigBuffer (std::string fName) |
Writes the config buffer to a file in append mode. | |
~TRestMetadata () | |
TRestMetadata default destructor. | |
Protected Member Functions | |
std::string | ElementToString (TiXmlElement *ele) |
Convert an TiXmlElement object to string. More... | |
TVector2 | Get2DVectorParameterWithUnits (std::string parName, TiXmlElement *e, TVector2 defaultValue=TVector2(-1, -1)) |
TVector3 | Get3DVectorParameterWithUnits (std::string parName, TiXmlElement *e, TVector3 defaultValue=TVector3(-1, -1, -1)) |
Double_t | GetDblParameterWithUnits (std::string parName, TiXmlElement *e, Double_t defaultVal=PARAMETER_NOT_FOUND_DBL) |
TiXmlElement * | GetElement (std::string eleDeclare, TiXmlElement *e=nullptr) |
Get an xml element from a given parent element, according to its declaration. | |
TiXmlElement * | GetElementFromFile (std::string configFilename, std::string NameOrDecalre="") |
Open an xml encoded file and find its element. More... | |
TiXmlElement * | GetElementWithName (std::string eleDeclare, std::string eleName) |
Get an xml element from the default location, according to its declaration and its field "name". | |
TiXmlElement * | GetElementWithName (std::string eleDeclare, std::string eleName, TiXmlElement *e) |
Get an xml element from a given parent element, according to its declaration and its field "name". | |
std::string | GetFieldValue (std::string fieldName, std::string definition, size_t fromPosition=0) |
Gets field value in an xml element string by parsing it as TiXmlElement. | |
std::string | GetFieldValue (std::string parName, TiXmlElement *e) |
Returns the field value of an xml element which has the specified name. More... | |
std::string | GetKEYDefinition (std::string keyName) |
Gets the first key definition for keyName found inside buffer starting at fromPosition. More... | |
std::string | GetKEYDefinition (std::string keyName, size_t &Position) |
std::string | GetKEYDefinition (std::string keyName, size_t &Position, std::string buffer) |
std::string | GetKEYDefinition (std::string keyName, std::string buffer) |
std::string | GetKEYStructure (std::string keyName) |
Gets the first key structure for keyName found inside buffer after fromPosition. More... | |
std::string | GetKEYStructure (std::string keyName, size_t &Position) |
std::string | GetKEYStructure (std::string keyName, size_t &Position, std::string buffer) |
std::string | GetKEYStructure (std::string keyName, size_t &Position, TiXmlElement *ele) |
std::string | GetKEYStructure (std::string keyName, std::string buffer) |
TiXmlElement * | GetNextElement (TiXmlElement *e) |
Get the next sibling xml element of this element, with same eleDeclare. | |
std::string | GetParameter (std::string parName, size_t &pos, std::string inputString) |
Returns the value for the parameter name parName found in inputString. More... | |
std::string | GetParameter (std::string parName, TiXmlElement *e, TString defaultValue=PARAMETER_NOT_FOUND_STR) |
Returns the value for the parameter named parName in the given section. More... | |
std::pair< std::string, std::string > | GetParameterAndUnits (std::string parname, TiXmlElement *e=nullptr) |
Returns the unit string of the given parameter of the given xml section. More... | |
std::map< std::string, std::string > | GetParametersList () |
It retrieves a map of all parameter:value found in the metadata class. | |
TString | GetSearchPath () |
virtual void | InitFromConfigFile () |
To make settings from rml file. This method must be implemented in the derived class. | |
virtual void | InitFromRootFile () |
Method called after the object is retrieved from root file. | |
virtual Int_t | LoadSectionMetadata () |
This method does some preparation of xml section. More... | |
void | ReadAllParameters () |
Reflection methods, Set value of a datamember in class according to TRestMetadata::fElement. More... | |
void | ReadParametersList (std::map< std::string, std::string > &list) |
It reads a parameter list and associates it to its corresponding metadata member. par0 --> fPar0. | |
std::string | ReplaceConstants (const std::string buffer) |
Identifies "constants" in the input buffer, and replace them with corresponding value. More... | |
std::string | ReplaceVariables (const std::string buffer) |
Identifies environmental variable replacing marks in the input buffer, and replace them with corresponding value. More... | |
void | ReSetVersion () |
Resets the version of TRestRun to REST_RELEASE. Only TRestRun is allowed to update version. | |
std::string | SearchFile (std::string filename) |
Search files in current directory and directories specified in "searchPath" section. More... | |
void | SetLibraryVersion (TString version) |
Set the library version of this metadata class. | |
TiXmlElement * | StringToElement (std::string definition) |
Parsing a string into TiXmlElement object. More... | |
TRestMetadata () | |
TRestMetadata default constructor. | |
TRestMetadata (const char *configFilename) | |
constructor | |
void | UnSetVersion () |
Resets the version of TRestRun to -1, in case the file is old REST file. Only TRestRun is allowed to update version. | |
Protected Attributes | |
std::string | configBuffer |
The buffer where the corresponding metadata section is stored. Filled only during Write() | |
std::string | fConfigFileName |
Full name of the rml file. More... | |
std::map< std::string, std::string > | fConstants |
Saving a list of rml constants. name-value std::pair. Constants are temporary for this class only. | |
TiXmlElement * | fElement |
Saving the sectional element together with global element. | |
TiXmlElement * | fElementGlobal |
Saving the global element, to be passed to the resident class, if necessary. | |
Bool_t | fError = false |
It can be used as a way to identify that something went wrong using SetError method. | |
TString | fErrorMessage = "" |
A std::string to store an optional error message through method SetError. | |
TRestManager * | fHostmgr |
All metadata classes can be initialized and managed by TRestManager. | |
Int_t | fNErrors = 0 |
It counts the number of errors notified. | |
Int_t | fNWarnings = 0 |
It counts the number of warnings notified. | |
std::string | fSectionName |
Section name given in the constructor of the derived metadata class. | |
Bool_t | fStore |
This variable is used to determine if the metadata structure should be stored in the ROOT file. | |
std::map< std::string, std::string > | fVariables |
Saving a list of rml variables. name-value std::pair. | |
TRestStringOutput::REST_Verbose_Level | fVerboseLevel |
Verbose level used to print debug info. | |
Bool_t | fWarning = false |
It can be used as a way to identify that something went wrong using SetWarning method. | |
TString | fWarningMessage = "" |
It can be used as a way to identify that something went wrong using SetWarning method. | |
std::string | messageBuffer |
The buffer to store the output message through TRestStringOutput in this class. | |
endl_t | RESTendl |
Termination flag object for TRestStringOutput. | |
Private Member Functions | |
void | ExpandForLoopOnce (TiXmlElement *e, const std::map< std::string, std::string > &forLoopVar) |
Helper method for TRestMetadata::ExpandForLoops(). | |
void | ExpandForLoops (TiXmlElement *e, std::map< std::string, std::string > forLoopVar) |
Expands the loop structures found in the given xml section. More... | |
void | ExpandIfSections (TiXmlElement *e) |
Judge the if condition and expands the elements inside it. More... | |
void | ExpandIncludeFile (TiXmlElement *e) |
Open the given rml file and find the corresponding section. More... | |
std::string | FieldNamesToUpper (std::string inputString) |
This method updates all the field names inside the definition string provided by argument to make them upper case, the result will be given in the return string. | |
std::string | GetUnits (TiXmlElement *e) |
Returns a string with the unit name given in the given xml element. More... | |
void | ReadElement (TiXmlElement *e, bool recursive=false) |
Read the given xml section, applying rml syntax(if, for, include, etc.) More... | |
void | ReadEnvInElement (TiXmlElement *e, bool overwrite=true) |
Identify an environmental variable section and add it into env section list. More... | |
void | ReadOneParameter (std::string name, std::string value) |
TiXmlElement * | ReplaceElementAttributes (TiXmlElement *e) |
replace the field value(attribute) of the given xml element More... | |
void | ReplaceForLoopVars (TiXmlElement *e, std::map< std::string, std::string > forLoopVar) |
Helper method for TRestMetadata::ExpandForLoops(). | |
Private Attributes | |
Bool_t | fCleanState = false |
TString | fCommit = REST_COMMIT |
TString | fLibraryVersion = "0" |
Bool_t | fOfficialRelease = false |
TString | fVersion = REST_RELEASE |
REST version std::string, only used for archive and retrieve. | |
|
protected |
Convert an TiXmlElement object to string.
This method does't arrange the output. All the contents are written in one line.
Definition at line 1905 of file TRestMetadata.cxx.
|
private |
Expands the loop structures found in the given xml section.
The expansion is done by creating new TiXmlElement objects and inserting them in the given xml section. Loop variable is treated samely as REST "variable"
Definition at line 1188 of file TRestMetadata.cxx.
|
private |
Judge the if condition and expands the elements inside it.
The example IF structure:
"evaluate" specifies the shell command, the output of which is used. "condition" specifies the comparing condition. So here if the home directory is "/home/nkx", the process "TRestRawZeroSuppresionProcess" will be added If the current date is larger than 2019-08-21, the process "TRestDetectorSignalToHitsProcess" will be added
Supports condition markers: ==
, !=
, >
, <
, <=
, >=
. Its better to escape the ">", "<" markers. Note that the >
, <
calculation is also valid for strings. The ordering is according to the alphabet
Definition at line 1003 of file TRestMetadata.cxx.
|
private |
Open the given rml file and find the corresponding section.
It will search rml file in both current directory and "searchPath". Two include modes:
Definition at line 1268 of file TRestMetadata.cxx.
string TRestMetadata::GetDataMemberValue | ( | std::string | memberName | ) |
Get the value of data member as string.
All kinds of data member can be found, including non-streamed data member and base-class data member
Definition at line 2344 of file TRestMetadata.cxx.
std::vector< string > TRestMetadata::GetDataMemberValues | ( | std::string | memberName, |
Int_t | precision = 0 |
||
) |
Get the value of datamember as a vector of strings.
If the datamember specified in the argument is a vector with several elements, those elements will be assigned to the std::vector. If the argument requests a data member that is not a vector in nature, this method will still return a valid vector string with a single element.
All kinds of data member can be found, including non-streamed data member and base-class data member
If precision value is higher than 0, then the resulting values will be truncated after finding ".". This can be used to define a float precision.
Definition at line 2362 of file TRestMetadata.cxx.
Double_t TRestMetadata::GetDblParameterWithUnits | ( | std::string | parName, |
Double_t | defaultVal = PARAMETER_NOT_FOUND_DBL |
||
) |
Gets the value of the parameter name parName, after applying unit conversion.
Searches the parameter in given element. The parameter must be defined providing the additional units, in the same field value or some where in the element. As in the following example :
Or
We recomment defining units in the same field value, which makes things clear.
parName | The name of the parameter from which we want to obtain the value. |
ele | The target element in which we are going to search. |
defaultVal | The default return value if it fails to find such parameter with unit. |
Definition at line 1641 of file TRestMetadata.cxx.
|
protected |
Open an xml encoded file and find its element.
If NameOrDecalre is a blank string, then it will return the first root element Otherwise it will search within all the root elements and sub-root elements
The root element is the parent of any other xml elements in the file. There could be only one root element in each xml encoded file in standard xml foamat. We recommened the users to write rml in this way, however, multi-root element is still supported in this method.
Exits the whole program if the xml file does not exist, or is in wrong in syntax. Returns NULL if no element matches NameOrDecalre
Definition at line 1700 of file TRestMetadata.cxx.
|
protected |
Returns the field value of an xml element which has the specified name.
A version of GetParameter() but only find parameter in the fields of xml element. If not found, the returned string is "Not defined"
Definition at line 1595 of file TRestMetadata.cxx.
|
protected |
Gets the first key definition for keyName found inside buffer starting at fromPosition.
A key definition is written as follows:
The returned key definition will be fixed to:
which is in standard xml form
Definition at line 2003 of file TRestMetadata.cxx.
|
protected |
Gets the first key structure for keyName found inside buffer after fromPosition.
A key definition is written as follows:
Definition at line 1951 of file TRestMetadata.cxx.
|
protected |
Returns the value for the parameter name parName found in inputString.
The methods starts searching in inputString after a given position pos.
Definition at line 2089 of file TRestMetadata.cxx.
|
protected |
Returns the value for the parameter named parName in the given section.
There are two kinds of parameter in REST.
The first one is obviously a parameter. The xml element itself serves as a peice of parameter. The name and the value are given in its fields. This is the classic definition. We also generalize the concept of parameter to the elements' fields. All the fields in an element can be seen as parameter. So there are 4 parameters in the second example, including: id, name, rotation and firstDaqChannel. This method first finds parameter in the fields of the given element. If not find, it searches its the child elements. If still not find, it returns the default value. If not specified, the default value string is "NO_SUCH_PARA".
parName | The name of the parameter from which we want to obtain the value. |
e | The target eml element where the program is to search the parameter |
defaultValue | The default value if the parameter is not found |
Definition at line 1511 of file TRestMetadata.cxx.
string TRestMetadata::GetParameter | ( | std::string | parName, |
TString | defaultValue = PARAMETER_NOT_FOUND_STR |
||
) |
Returns corresponding REST Metadata parameter from multiple sources.
It first finds the parameter from REST arguments from command line. If not found, it calls GetParameter() method to find parameter in TRestMetadata::fElement If still not found, it returns the default value.
parName | The name of the parameter from which we want to obtain the value. |
defaultValue | The default value if the parameter is not found |
Definition at line 1472 of file TRestMetadata.cxx.
|
protected |
Returns the unit string of the given parameter of the given xml section.
It will firstly find the parameter section from the given xml section. Then it will search units definition in:
If argument section is not given(==NULL), it will use the local section(fElement)
Definition at line 1858 of file TRestMetadata.cxx.
|
protected |
Returns a string with a list of pathes defined, in decreasing order of precedence: 1) in sections "searchPath", 2) in "configPath"(the path of main rml file), 3) default data path: "$REST_PATH/data/"
To add a searchPath, use:
Or
"searchPath" can also be added multiple times. Both of them will be added into the output string. A separator ":" is inserted between each defined paths. To separate them, use inline method Split() provided by TRestStringHelper. Uniformed search path definition provides us uniformed file search tool, see TRestMetadata::SearchFile().
Definition at line 2412 of file TRestMetadata.cxx.
|
private |
Returns a string with the unit name given in the given xml element.
if given the target attribute, it will find the unit for this. e.g. value="(1,-13)mm" "-3mm" "50,units=mm" can both be recoginzed. if not given, it will find the unit as a parameter of the element. e.g. <... value="3" units="mm" .../>
Definition at line 1829 of file TRestMetadata.cxx.
TString TRestMetadata::GetVerboseLevelString | ( | ) |
returns the verbose level in type of TString
Returns a string corresponding to current verbose level.
Definition at line 2380 of file TRestMetadata.cxx.
TRestMetadata * TRestMetadata::InstantiateChildMetadata | ( | int | index, |
std::string | pattern = "" |
||
) |
This method will retrieve a new TRestMetadata instance of a child element of the present TRestMetadata instance based on the index
given by argument, which defines the element order to be retrieved, 0 for first element found, 1 for the second element found, etc.
In brief, it will create an instance of TRestChildClass
in the following example:
An optional argument may help to restrict the search to a particular metadata element.
Otherwise, the first child section that satisfies that it starts by TRest
will be considered.
If no child element is found with the required criteria, nullptr
will be returned.
Definition at line 734 of file TRestMetadata.cxx.
TRestMetadata * TRestMetadata::InstantiateChildMetadata | ( | std::string | pattern = "" , |
std::string | name = "" |
||
) |
This method will retrieve a new TRestMetadata instance of a child element of the present TRestMetadata instance based on the name
given by argument.
In brief, it will create an instance of TRestChildClass
in the following example:
Two optional arguments may help to restrict the search to a particular metadata class name and user given name.
Otherwise, the first child section that satisfies that it starts by TRest
will be returned.
If no child element is found with the required criteria, nullptr
will be returned.
Definition at line 788 of file TRestMetadata.cxx.
Int_t TRestMetadata::LoadConfigFromBuffer | ( | ) |
Initialize data from a string element buffer.
This method is usually called when the object is retrieved from root file. It will call InitFromRootFile() after parsing configBuffer(string) to fElement(TiXmlElement)
Definition at line 697 of file TRestMetadata.cxx.
Int_t TRestMetadata::LoadConfigFromElement | ( | TiXmlElement * | eSectional, |
TiXmlElement * | eGlobal, | ||
std::map< std::string, std::string > | envs = {} |
||
) |
Main starter method.
First merge the sectional and global sections together, then save the input env section. To make start up it calls the following methods in sequence: LoadSectionMetadata(), InitFromConfigFile()
Definition at line 660 of file TRestMetadata.cxx.
|
protectedvirtual |
This method does some preparation of xml section.
Preparation includes: setting the name, title and verbose level of the current class. Finding out and saving the env sections.
By calling TRestMetadata::ReadElement(), is also expands for loops and include definitions, and replaces env and expressions in rml config section.
Reimplemented in TRestManager, and TRestEventProcess.
Definition at line 822 of file TRestMetadata.cxx.
|
virtual |
Merge the metadata information from another metadata object. Needs to be implemented in the derived class.
Definition at line 2695 of file TRestMetadata.cxx.
void TRestMetadata::PrintConfigBuffer | ( | ) |
Print the config xml section stored in the class.
Prints current config buffer on screen.
Definition at line 2215 of file TRestMetadata.cxx.
|
virtual |
Implemented it in the derived metadata class to print out specific metadata information.
Prints metadata content on screen. Usually overloaded by the derived metadata class.
Reimplemented in TRestWimpSensitivity, TRestTrackViewerProcess, TRestTrackReductionProcess, TRestTrackReconnectionProcess, TRestTrackPointLikeAnalysisProcess, TRestTrackPathMinimizationProcess, TRestTrackLinearizationProcess, TRestTrackLineAnalysisProcess, TRestTrackDetachIsolatedNodesProcess, TRestTrackBlobAnalysisProcess, TRestTrackAnalysisProcess, TRestRawVetoAnalysisProcess, TRestRawToSignalProcess, TRestRawSignalViewerProcess, TRestRawSignalShapingProcess, TRestRawSignalRemoveChannelsProcess, TRestRawSignalRangeReductionProcess, TRestRawSignalIdTaggingProcess, TRestRawSignalGeneralFitProcess, TRestRawSignalFittingProcess, TRestRawSignalConvolutionFittingProcess, TRestRawSignalChannelActivityProcess, TRestRawSignalAnalysisProcess, TRestRawSignalAddNoiseProcess, TRestRawPeaksFinderProcess, TRestRawMemoryBufferToSignalProcess, TRestRawFindResponseSignalProcess, TRestRawDAQMetadata, TRestRawCommonNoiseReductionProcess, TRestRawBiPoToSignalProcess, TRestRawBiPoAnalysisProcess, TRestRawBaseLineCorrectionProcess, TRestRawZeroSuppresionProcess, TRestRawSignalRecoverChannelsProcess, TRestLegacyProcess, TRestGeant4VetoAnalysisProcess, TRestGeant4QuenchingProcess, TRestGeant4PhysicsLists, TRestGeant4ParticleSourceDecay0, TRestGeant4ParticleSourceCry, TRestGeant4ParticleSource, TRestGeant4NeutronTaggingProcess, TRestGeant4Metadata, TRestGeant4BlobAnalysisProcess, TRestGeant4AnalysisProcess, TRestDetectorTriggerAnalysisProcess, TRestDetectorSingleChannelAnalysisProcess, TRestDetectorSignalViewerProcess, TRestDetectorSignalToHitsProcess, TRestDetectorSignalRecoveryProcess, TRestDetectorSignalChannelActivityProcess, TRestDetectorSetup, TRestDetectorReadout, TRestDetectorPositionMappingProcess, TRestDetectorLightAttenuationProcess, TRestDetectorHitsTranslationProcess, TRestDetectorHitsToSignalProcess, TRestDetectorHitsSpecularProcess, TRestDetectorHitsSmearingProcess, TRestDetectorHitsShuffleProcess, TRestDetectorHitsRotationProcess, TRestDetectorHitsReductionProcess, TRestDetectorHitsReadoutAnalysisProcess, TRestDetectorHitsNormalizationProcess, TRestDetectorHitsGaussAnalysisProcess, TRestDetectorHitsAnalysisProcess, TRestDetectorHits3DReconstructionProcess, TRestDetectorHitmapAnalysisProcess, TRestDetectorGas, TRestDetectorFiducializationProcess, TRestDetectorElectronDiffusionProcess, TRestDetectorDriftVolume, TRestDetectorDaqChannelSwitchingProcess, TRestDetectorAvalancheProcess, TRestDetector, TRestTrackToDetectorHitsProcess, TRestRawToDetectorSignalProcess, TRestRawReadoutAnalysisProcess, TRestGeant4ToDetectorHitsProcess, TRestDetectorSignalToRawSignalProcess, TRestDetectorHitsToTrackProcess, TRestDetectorHitsToTrackFastProcess, TRestAxionWolterOptics, TRestAxionTrueWolterOptics, TRestAxionTransportProcess, TRestAxionTransmissionProcess, TRestAxionSolarQCDFlux, TRestAxionMCPLOptics, TRestAxionGeneratorProcess, TRestAxionFieldPropagationProcess, TRestAxionEventProcess, TRestAxionDeviationProcess, TRestAxionAnalysisProcess, TRestSensitivity, TRestResponse, TRestExperimentList, TRestExperiment, TRestComponentFormula, TRestComponentDataSet, TRestComponent, TRestStrippedMask, TRestSpiderMask, TRestRingsMask, TRestRadialStrippedMask, TRestPatternMask, TRestGridMask, TRestCombinedMask, TRestRun, TRestProcessRunner, TRestMetadataPlot, TRestMessenger, TRestManager, TRestDataSetPlot, TRestDataSet, TRestCut, TRestAnalysisPlot, TRestSummaryProcess, TRestRealTimeDrawingProcess, TRestRealTimeAddInputFileProcess, TRestMySQLToAnalysisProcess, TRestEventSelectionProcess, TRestEventRateAnalysisProcess, TRestDataSetOdds, TRestDataSetGainMap, TRestDataSetCalibration, TRestDataQualityProcess, TRestBenchMarkProcess, TRestAxionXrayWindow, TRestAxionTemplate, TRestAxionSpectrum, TRestAxionSolarModel, TRestAxionSolarFlux, TRestAxionOpticsMirror, TRestAxionOptics, TRestAxionMagneticField, TRestAxionLikelihood, and TRestAxionBufferGas.
Definition at line 2255 of file TRestMetadata.cxx.
void TRestMetadata::PrintTimeStamp | ( | Double_t | timeStamp | ) |
Print the current time on local machine.
Prints a UNIX timestamp in human readable format.
Definition at line 2196 of file TRestMetadata.cxx.
|
protected |
Reflection methods, Set value of a datamember in class according to TRestMetadata::fElement.
It will loop over all the parameters in the rml and gDetector. (The repeated one won't override the existing one. rml parameters in prior.) Then it will find the corresponding datamember for the parameter. If found, it will set the datamember value. For example, we write:
After loading the rml file and calling this method, the value of "fPar0" will be set to 10.
We have a naming convention for the parameters in rml and the data members in class. The names of data member shall all start from "f" and have the second character in capital form. For example, data member "fTargetName" is linked to parameter "targetName". In the previous code "fPar0" is linked to "par0".
Note that parameters include <parameter section and all the attributes in fElement.
Definition at line 2470 of file TRestMetadata.cxx.
|
private |
Read the given xml section, applying rml syntax(if, for, include, etc.)
The expansion is done recursively except for child sections declared after "TRest". They are supposed to be a metadata class and to be doing the expansion themselves. If the argument "recursive" is true, these child sections will also be processed. Before expansion, ReplaceElementAttributes() will first be called.
Definition at line 946 of file TRestMetadata.cxx.
|
private |
Identify an environmental variable section and add it into env section list.
Vaild section declaration: "variable", "constant". If the section exists already, its value will be updated if "updateexisting" is true. If a system env with the same name has been defined already, then the system env will be used, unless the attribute "overwrite" is true.
Example of environmental variable section:
Definition at line 910 of file TRestMetadata.cxx.
|
protected |
Identifies "constants" in the input buffer, and replace them with corresponding value.
Constans are the substrings directly appeared in the buffer
Definition at line 2152 of file TRestMetadata.cxx.
|
private |
replace the field value(attribute) of the given xml element
it calls ReplaceVariables(), ReplaceConstants() and ReplaceMathematicalExpressions() in sequence. "name" attribute won't be replaced by constants to avoid conflict.
Definition at line 870 of file TRestMetadata.cxx.
|
protected |
Identifies environmental variable replacing marks in the input buffer, and replace them with corresponding value.
Replacing marks is like ${VARIABLE_NAME}. "variables" include system env, values added through <variable section, and rest command line arguments(–c option). The replacing sequence is same. i.e. try to replace with system env first, if not found, try to replace <variable section, if still not found, try to replace with command line arguments. If all not found, return the initial value.
Definition at line 2108 of file TRestMetadata.cxx.
|
protected |
Search files in current directory and directories specified in "searchPath" section.
Return blank string if file not found, return directly filename if found in current directory, return full name (path+name) if found in "searchPath".
Definition at line 2183 of file TRestMetadata.cxx.
|
protected |
Parsing a string into TiXmlElement object.
This method creates TiXmlElement object with the alloator "new". Be advised to delete the object after using it!
Definition at line 1893 of file TRestMetadata.cxx.
|
protected |
Full name of the rml file.
Data members NOTE!! In root6 the "#ifndef __CINT__" structure is not helpful any more! Attatch "//! something" structure in comment line to avoid variables being saved by root. see more detail in https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#automatically-generated-streamers
Definition at line 162 of file TRestMetadata.h.