REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
TRestMetadata Class Reference

Detailed Description

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.

RML file structure

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.

<ClassName name="userGivenName" title="User given title" >
<SomeCommand field1="value1" field2="value2">
<ContainedClassName field1="value1" field2="value2" ... >
<SomeCommand field1="value1" field2="value2">
...
</ContainedClassName>
</ClassName>

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.

Sequencial start up procedure of a metadata class

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.

TRestSpecificMetadata::TRestSpecificMetadata()
{
}
void TRestSpecificMetadata::Initialize( )
{
SetSectionName( this->ClassName() );
....
}
virtual void Initialize()
Making default settings.
void SetSectionName(std::string sName)
set the section name, clear the section content

The starter method LoadConfigFromFile() is implemented in this class, with four overloads, as shown in the following.

void LoadConfigFromFile(const char *configFilename, string sectionName = "");
void LoadConfigFromFile(TiXmlElement* eSectional, TiXmlElement* eGlobal);
void LoadConfigFromFile(TiXmlElement* eSectional, TiXmlElement* eGlobal,
map<string, string> envs);
Int_t LoadConfigFromFile(const std::string &configFilename, const std::string &sectionName="")
Give the file name, find out the corresponding section. Then call the main starter.

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():

<TRestMuonAnalysisProcess name = "muAna" title = "Example" verboseLevel =
"info" > <parameter name="XROI" value="(100,300)"/> <parameter
name="YROI" value="(0,-200)"/>
</TRestMuonAnalysisProcess>
void TRestMuonAnalysisProcess::InitFromConfigFile()
{
TVector2 XROI = StringTo2DVector(GetParameter("XROI", "(-100,100)"));
TVector2 YROI = StringTo2DVector(GetParameter("YROI", "(-100,100)"));
X1 = XROI.X(), X2 = XROI.Y(), Y1 = YROI.X(), Y2 = YROI.Y();
}
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.
TVector2 StringTo2DVector(std::string in)
Gets a 2D-vector from a string.

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.

<TRestManager name = "CoBoDataAnalysis" title = "Example" verboseLevel =
"info" > <TRestRun name = "SJTU_Proto" > <addMetadata name
= "PandaReadout_MxM" file = "readouts.root" />
...
{
TiXmlElement*e = fElement->FirstChildElement();
while (e != nullptr)
{
string value = e->Value();
if (value == "TRestRun") {
fRunInfo = new TRestRun();
fRunInfo->LoadConfigFromFile(e, fElementGlobal);
}
else if (value == "TRestAnalysisPlot") {
fPlot = new TRestAnalysisPlot();
fPlot->LoadConfigFromFile(e, fElementGlobal);
}
}
}
Managing applications and executing tasks.
Definition: TRestManager.h:16
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
Definition: TRestManager.h:23
TiXmlElement * fElementGlobal
Saving the global element, to be passed to the resident class, if necessary.
TiXmlElement * fElement
Saving the sectional element together with global element.
Data provider and manager in REST.
Definition: TRestRun.h:18

Replacement of variables and expressions

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.

<global>
<variable name = "CHANNELS" value = "64" overwrite = "false" / >
//this variable can be loaded by both
</global>
<TRestRun name="userGivenName" title="User given title" >
<constant name="nChannels" value="${CHANNELS}" /> //this variable
will be added to the class "TRestDetectorReadout"
<TRestDetectorReadout name="aaaa" >
<variable .... / > //this variable cannot be loaded by the class
"TRestDetectorReadout"
<parameter name="Ch" value="nChannels+${CHANNELS}-2" />
A metadata class to generate/store a readout description.

LoadConfigFromFile() will replace the field values of xml sections before they are used. The procedure of replacing is as following:

  1. recognize the strings surrounded by "${}". Seek and replace in system env first. If not found, replace with variable/constant.
  2. directly replace the strings matching the name of constant by their value.

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.

Including external RML files in a main RML file

It is possible to link to other files in any section. There are two include modes:

  1. raw include. LoadConfigFromFile() will parse all the lines in the file as xml element and insert them inside the local section.
    <TRestXXX>
    <include file="abc.txt"/>
    </TRestXXX>
  2. auto insert. LoadConfigFromFile() will automatically find corresponding section in the file. If the file can be parsed by tinyxml, it will first import its globals section. When searching the section, LoadConfigFromFile() searches according to the name and type. Here "type" can either be the element declare or attribute "type". After finding the section, its child sections as well as attributes will be inserted into the local element.
    <TRestXXX
    name="sAna" file="abc.rml"/>
    Or
    <doXXX type="TRestXXX"
    name="sAna" file="abc.rml"/>

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()

For loop definition

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:

<for variable="nCh" from="0" to="63" step="1" >
<readoutChannel id="${nCh}" >
<for variable="nPix" from="0" to="63" step="1">
<addPixel id="${nPix}" origin="((1+${nCh})*pitch,pitch/4+${nPix}*pitch)"
size="(pixelSize,pixelSize)" rotation="45" />
</for>
</readoutChannel>
</for>
<for variable="nMod" in="0:2:3:4:6:8:9" >
<TRestAnalysisPlot name="ModuleFirstXYHitMap${nMod}" previewPlot="false">
<canvas size="(800,600)" save="M${nMod}_Hitmap.png"/>
<plot name="aaa" title="First X/Y Hitmap of Module ${nMod}" xlabel="X channel"
ylabel="Y channel" value="ON" option="colz">
<variable name="rA_ModuleFirstX.second" range="(0,64)" nbins="64" />
<variable name="rA_ModuleFirstY.second" range="(64,128)" nbins="64" />
<cutString string="rA_ModuleFirstY.first==${nMod}"/>
</plot>
</for>

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.

If definition

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:

<TRestXXX>
<if condition="${HOME}==/home/nkx">
<addProcess type="TRestRawZeroSuppresionProcess" name="zS" value="ON" file="processes.rml"/>
</if>
<if evaluate="date +%Y-%m-%d" condition=">2019-08-21">
<addProcess type = "TRestDetectorSignalToHitsProcess" name = "signalToHits" value = "ON" file =
"processes.rml" />
</if>
</TRestXXX>

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

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:

<globals>
<searchPath value = "$ENV{REST_INPUTDATA}/definitions/" />
<parameter name="verboseLevel" value="info" />
<parameter name="mainDataPath" value="" />
<parameter name="sampling" value="5us" />
<variable name="DetectorPosZ" value="${SYSTEM_POSITION_Z}" />
<variable name="field" value="5" /> // V/cm
<constant name="OpticsPosZ" value="3" />
</globals>

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.

Universal file search path

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.

<globals>
<searchPath value = "$ENV{REST_INPUTDATA}/definitions/" />
<searchPath value = "$ENV{REST_INPUTDATA}/gasFiles/" />
</globals>

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.

Default fields for a section

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.

<TRestDetectorSignalAnalysisProcess name="sgnlAna" title="Data analysis"
verboseLevel="debug" >
...
</TRestDetectorSignalAnalysisProcess>

Using physical units in fields definitions

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.

<parameter name="electricField" value="1000" units="V/cm" />

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:

Double_t valueInMeV = value * REST_Units::MeV;

Other useful public tools

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

Author
Igor Irastorza
Javier Galan
Kaixiang Ni

Definition at line 74 of file TRestMetadata.h.

#include <TRestMetadata.h>

Inheritance diagram for TRestMetadata:
TRestAnalysisPlot TRestAxionBufferGas TRestAxionLikelihood TRestAxionMagneticField TRestAxionOptics TRestAxionOpticsMirror TRestAxionSolarFlux TRestAxionSolarModel TRestAxionSpectrum TRestAxionTemplate TRestAxionXrayWindow TRestComponent TRestCut TRestDataSet TRestDataSetCalibration TRestDataSetGainMap TRestDataSetOdds TRestDataSetPlot TRestDetector TRestDetectorDriftVolume TRestDetectorGainMap TRestDetectorReadout TRestDetectorSetup TRestEventProcess TRestExperiment TRestExperimentList TRestGDMLParser TRestGeant4Metadata TRestGeant4ParticleSource TRestGeant4PhysicsLists TRestManager TRestMessenger TRestMetadataPlot TRestPatternMask TRestProcessRunner TRestRawDAQMetadata TRestRawReadoutMetadata TRestResponse TRestRun TRestSensitivity TRestTask TRestWimpSensitivity

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.
 
TRestMetadataInstantiateChildMetadata (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...
 
TRestMetadataInstantiateChildMetadata (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 &sectionName="")
 Give the file name, find out the corresponding section. Then call the main starter.
 
virtual void Merge (const TRestMetadata &)
 
TRestMetadataoperator= (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.
 
TRestManagerfHostmgr
 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.
 

Member Function Documentation

◆ ElementToString()

string TRestMetadata::ElementToString ( TiXmlElement *  ele)
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.

◆ ExpandForLoops()

void TRestMetadata::ExpandForLoops ( TiXmlElement *  e,
std::map< std::string, std::string >  forLoopVar 
)
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.

◆ ExpandIfSections()

void TRestMetadata::ExpandIfSections ( TiXmlElement *  e)
private

Judge the if condition and expands the elements inside it.

The example IF structure:

<TRestXXX>
<if condition="${HOME}==/home/nkx">
<addProcess type="TRestRawZeroSuppresionProcess" name="zS" value="ON" file="processes.rml"/>
</if>
<if evaluate="date +%Y-%m-%d" condition=">2019-08-21">
<addProcess type = "TRestDetectorSignalToHitsProcess" name = "signalToHits" value = "ON" file =
"processes.rml" />
</if>
</TRestXXX>

"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.

◆ ExpandIncludeFile()

void TRestMetadata::ExpandIncludeFile ( TiXmlElement *  e)
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:

  1. raw include. It will parse all the lines in the file as xml element and insert them inside the local section.
    <TRestXXX>
    <include file="abc.txt"/>
    </TRestXXX>
  2. auto insert. It will automatically find the section in the file, according to "type" and "name". At least one of the two definitions should be specified. Here "type" can either be the element declare or its attribute. After finding the remote section, this method will insert its child sections and attributes into the local xml element.
    <TRestXXX
    name="sAna" file="abc.rml"/>
    Or
    <doXXX type="TRestXXX"
    name="sAna" file="abc.rml"/>
    If the target file is a root file, there will be a different way to load, see TRestRun::ImportMetadata()

Definition at line 1268 of file TRestMetadata.cxx.

◆ GetDataMemberValue()

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.

◆ GetDataMemberValues()

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.

◆ GetDblParameterWithUnits()

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 :

<parameter name="electricField" value="1kV/m"/>
<parameter name="electricField" value="1,kV/m"/>
<parameter name="electricField" value="1,units=kV/m"/>
<parameter name="electricField" value="1" units="kV/m" />

Or

<TRestDetectorSetup electricField="1,kV/m"/>
<TRestDetectorSetup electricField="1,units=kV/m"/>
<TRestDetectorSetup electricField="1" units="kV/m"/>

We recomment defining units in the same field value, which makes things clear.

Parameters
parNameThe name of the parameter from which we want to obtain the value.
eleThe target element in which we are going to search.
defaultValThe default return value if it fails to find such parameter with unit.
Returns
A double/2DVector/3DVector value in the default correspoding REST units (keV, us, mm, Vcm).

Definition at line 1641 of file TRestMetadata.cxx.

◆ GetElementFromFile()

TiXmlElement * TRestMetadata::GetElementFromFile ( std::string  configFilename,
std::string  NameOrDeclare = "" 
)
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.

◆ GetFieldValue()

std::string TRestMetadata::GetFieldValue ( std::string  parName,
TiXmlElement *  e 
)
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.

◆ GetKEYDefinition()

string TRestMetadata::GetKEYDefinition ( std::string  keyName)
protected

Gets the first key definition for keyName found inside buffer starting at fromPosition.

A key definition is written as follows:

<keyName field1="value1" field2="value2" >

The returned key definition will be fixed to:

<keyName field1="value1" field2="value2" />

which is in standard xml form

Definition at line 2003 of file TRestMetadata.cxx.

◆ GetKEYStructure()

string TRestMetadata::GetKEYStructure ( std::string  keyName)
protected

Gets the first key structure for keyName found inside buffer after fromPosition.

A key definition is written as follows:

<keyName field1="value1" field2="value2" >
....
</keyName>

Definition at line 1951 of file TRestMetadata.cxx.

◆ GetParameter() [1/3]

string TRestMetadata::GetParameter ( std::string  parName,
size_t &  pos,
std::string  inputString 
)
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.

◆ GetParameter() [2/3]

string TRestMetadata::GetParameter ( std::string  parName,
TiXmlElement *  e,
TString  defaultValue = PARAMETER_NOT_FOUND_STR 
)
protected

Returns the value for the parameter named parName in the given section.

There are two kinds of parameter in REST.

  1. <parameter name="verboseLevel" value="silent" >
  2. <addReadoutModule id="0" name="module" rotation = "0" firstDaqChannel = "272" / >

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".

Parameters
parNameThe name of the parameter from which we want to obtain the value.
eThe target eml element where the program is to search the parameter
defaultValueThe default value if the parameter is not found
Returns
A string of result, with env and expressions replaced

Definition at line 1511 of file TRestMetadata.cxx.

◆ GetParameter() [3/3]

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.

Parameters
parNameThe name of the parameter from which we want to obtain the value.
defaultValueThe default value if the parameter is not found
Returns
A string of result

Definition at line 1472 of file TRestMetadata.cxx.

◆ GetParameterAndUnits()

pair< string, string > TRestMetadata::GetParameterAndUnits ( std::string  parname,
TiXmlElement *  e = nullptr 
)
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:

  1. value string of this parameter
  2. "units" attribute of the parameter section
  3. "units" attribute of the given section

If argument section is not given(==NULL), it will use the local section(fElement)

Definition at line 1858 of file TRestMetadata.cxx.

◆ GetSearchPath()

TString TRestMetadata::GetSearchPath ( )
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:

<searchPath value="$ENV{REST_INPUTDATA}/definitions/"/>

Or

<searchPath
value="$ENV{REST_INPUTDATA}/definitions/:$ENV{REST_INPUTDATA}/gasFiles/"/>

"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.

◆ GetUnits()

string TRestMetadata::GetUnits ( TiXmlElement *  e)
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.

◆ GetVerboseLevelString()

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.

◆ InstantiateChildMetadata() [1/2]

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:

<TRestThisMetadataClass ...
<TRestChildClass ...> <!-- if index = 0 -->
<TRestChildClass ...> <!-- if index = 1 -->
<TRestChildClass ...> <!-- if index = 2 -->

An optional argument may help to restrict the search to a particular metadata element.

  • pattern: If a pattern value is given, then the pattern must be contained inside the metadata class name. I.e. pattern="TRestGeant4" will require that the class belongs to the geant4 library.

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.

◆ InstantiateChildMetadata() [2/2]

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:

<TRestThisMetadataClass ...
<TRestChildClass ...>

Two optional arguments may help to restrict the search to a particular metadata class name and user given name.

  • pattern: If a pattern value is given, then the pattern must be contained inside the metadata class name. I.e. pattern="TRestGeant4" will require that the class belongs to the geant4 library.
  • name: It can be specified a specific 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.

◆ LoadConfigFromBuffer()

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.

◆ LoadConfigFromElement()

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.

◆ LoadSectionMetadata()

Int_t TRestMetadata::LoadSectionMetadata ( )
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.

◆ Merge()

void TRestMetadata::Merge ( const TRestMetadata metadata)
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.

◆ PrintConfigBuffer()

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.

◆ PrintMetadata()

void TRestMetadata::PrintMetadata ( )
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.

◆ PrintTimeStamp()

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.

◆ ReadAllParameters()

void TRestMetadata::ReadAllParameters ( )
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:

class TRestXXX: public TRestMetadata{
int fPar0;
}
<TRestXXX name="..." par0="10"/>
A base class for any REST metadata class.
Definition: TRestMetadata.h:74

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.

◆ ReadElement()

void TRestMetadata::ReadElement ( TiXmlElement *  e,
bool  recursive = false 
)
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.

◆ ReadEnvInElement()

void TRestMetadata::ReadEnvInElement ( TiXmlElement *  e,
bool  overwrite = true 
)
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:

<variable name="TEST" value="VALUE" overwrite="true" />

Definition at line 910 of file TRestMetadata.cxx.

◆ ReplaceConstants()

string TRestMetadata::ReplaceConstants ( const std::string  buffer)
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.

◆ ReplaceElementAttributes()

TiXmlElement * TRestMetadata::ReplaceElementAttributes ( TiXmlElement *  e)
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.

◆ ReplaceVariables()

string TRestMetadata::ReplaceVariables ( const std::string  buffer)
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.

◆ SearchFile()

string TRestMetadata::SearchFile ( std::string  filename)
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.

◆ StringToElement()

TiXmlElement * TRestMetadata::StringToElement ( std::string  definition)
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.

Field Documentation

◆ fConfigFileName

std::string TRestMetadata::fConfigFileName
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.


The documentation for this class was generated from the following files: