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.

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.

Definition at line 70 of file TRestMetadata.h.

#include <TRestMetadata.h>

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

Public Member Functions

void AddLog (std::string log="", bool print=true)
 Add logs to messageBuffer. More...
 
void DoNotStore ()
 If this method is called the metadata information will not be stored in disk. More...
 
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. More...
 
std::string GetConfigBuffer ()
 Returns the config section of this class. More...
 
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. More...
 
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. More...
 
TString GetErrorMessage ()
 Returns a std::string containing the error message. More...
 
TString GetLibraryVersion ()
 Returns the REST libraty version stored in fLibraryVersion. More...
 
TString GetMainDataPath ()
 Gets a std::string with the path used for data storage. More...
 
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. More...
 
TRestStringOutput::REST_Verbose_Level GetVerboseLevel ()
 returns the verboselevel in type of REST_Verbose_Level enumerator More...
 
TString GetVerboseLevelString ()
 returns the verbose level in type of TString More...
 
TString GetVersion ()
 Returns the REST version stored in fVersion. More...
 
Int_t GetVersionCode ()
 
Bool_t GetWarning () const
 It returns true if an error was identified by a derived metadata class. More...
 
TString GetWarningMessage ()
 Returns a std::string containing the warning message. More...
 
virtual void Initialize ()
 Making default settings. More...
 
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. More...
 
virtual void Merge (const TRestMetadata &)
 
TRestMetadataoperator= (const TRestMetadata &)=delete
 
void Print ()
 Implementing TObject::Print() method. More...
 
void PrintConfigBuffer ()
 Print the config xml section stored in the class. More...
 
void PrintMessageBuffer ()
 Print the buffered message. More...
 
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 More...
 
void SetError (std::string message="", bool print=true)
 A metadata class may use this method to signal that something went wrong. More...
 
void SetHostmgr (TRestManager *m)
 Set the host manager for this class. More...
 
void SetSectionName (std::string sName)
 set the section name, clear the section content More...
 
void SetVerboseLevel (TRestStringOutput::REST_Verbose_Level v)
 sets the verbose level More...
 
void SetWarning (std::string message="", bool print=true)
 A metadata class may use this method to signal that something went wrong. More...
 
void Store ()
 If this method is called the metadata information will be stored in disk. More...
 
 TRestMetadata (const TRestMetadata &)=delete
 
virtual void UpdateMetadataMembers ()
 Method to allow implementation of specific metadata members updates at inherited classes. More...
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
 overwriting the write() method with fStore considered More...
 
void WriteConfigBuffer (std::string fName)
 Writes the config buffer to a file in append mode. More...
 
 ~TRestMetadata ()
 TRestMetadata default destructor. More...
 

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. More...
 
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". More...
 
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". More...
 
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. More...
 
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. More...
 
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. More...
 
TString GetSearchPath ()
 
virtual void InitFromConfigFile ()
 To make settings from rml file. This method must be implemented in the derived class. More...
 
virtual void InitFromRootFile ()
 Method called after the object is retrieved from root file. More...
 
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. More...
 
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. More...
 
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. More...
 
TiXmlElement * StringToElement (std::string definition)
 Parsing a string into TiXmlElement object. More...
 
 TRestMetadata ()
 TRestMetadata default constructor. More...
 
 TRestMetadata (const char *configFilename)
 constructor More...
 
void UnSetVersion ()
 Resets the version of TRestRun to -1, in case the file is old REST file. Only TRestRun is allowed to update version. More...
 

Protected Attributes

std::string configBuffer
 The buffer where the corresponding metadata section is stored. Filled only during Write() More...
 
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. More...
 
TiXmlElement * fElement
 Saving the sectional element together with global element. More...
 
TiXmlElement * fElementGlobal
 Saving the global element, to be passed to the resident class, if necessary. More...
 
Bool_t fError = false
 It can be used as a way to identify that something went wrong using SetError method. More...
 
TString fErrorMessage = ""
 A std::string to store an optional error message through method SetError. More...
 
TRestManagerfHostmgr
 All metadata classes can be initialized and managed by TRestManager. More...
 
Int_t fNErrors = 0
 It counts the number of errors notified. More...
 
Int_t fNWarnings = 0
 It counts the number of warnings notified. More...
 
std::string fSectionName
 Section name given in the constructor of the derived metadata class. More...
 
Bool_t fStore
 This variable is used to determine if the metadata structure should be stored in the ROOT file. More...
 
std::map< std::string, std::string > fVariables
 Saving a list of rml variables. name-value std::pair. More...
 
TRestStringOutput::REST_Verbose_Level fVerboseLevel
 Verbose level used to print debug info. More...
 
Bool_t fWarning = false
 It can be used as a way to identify that something went wrong using SetWarning method. More...
 
TString fWarningMessage = ""
 It can be used as a way to identify that something went wrong using SetWarning method. More...
 
std::string messageBuffer
 The buffer to store the output message through TRestStringOutput in this class. More...
 
endl_t RESTendl
 Termination flag object for TRestStringOutput. More...
 

Private Member Functions

void ExpandForLoopOnce (TiXmlElement *e, const std::map< std::string, std::string > &forLoopVar)
 Helper method for TRestMetadata::ExpandForLoops(). More...
 
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. More...
 
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(). More...
 

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

Constructor & Destructor Documentation

◆ TRestMetadata() [1/2]

TRestMetadata::TRestMetadata ( )
protected

TRestMetadata default constructor.

Definition at line 493 of file TRestMetadata.cxx.

◆ TRestMetadata() [2/2]

TRestMetadata::TRestMetadata ( const char *  configFilename)
protected

constructor

Definition at line 518 of file TRestMetadata.cxx.

◆ ~TRestMetadata()

TRestMetadata::~TRestMetadata ( )

TRestMetadata default destructor.

Definition at line 543 of file TRestMetadata.cxx.

Member Function Documentation

◆ AddLog()

void TRestMetadata::AddLog ( std::string  log = "",
bool  print = true 
)

Add logs to messageBuffer.

Definition at line 2628 of file TRestMetadata.cxx.

◆ DoNotStore()

void TRestMetadata::DoNotStore ( )
inline

If this method is called the metadata information will not be stored in disk.

Definition at line 317 of file TRestMetadata.h.

◆ 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 1883 of file TRestMetadata.cxx.

◆ ExpandForLoopOnce()

void TRestMetadata::ExpandForLoopOnce ( TiXmlElement *  e,
const std::map< std::string, std::string > &  forLoopVar 
)
private

Helper method for TRestMetadata::ExpandForLoops().

Definition at line 1068 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 1166 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 981 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 1246 of file TRestMetadata.cxx.

◆ FieldNamesToUpper()

string TRestMetadata::FieldNamesToUpper ( std::string  inputString)
private

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.

Definition at line 2031 of file TRestMetadata.cxx.

◆ Get2DVectorParameterWithUnits() [1/2]

TVector2 TRestMetadata::Get2DVectorParameterWithUnits ( std::string  parName,
TiXmlElement *  e,
TVector2  defaultValue = TVector2(-1, -1) 
)
protected

Definition at line 1529 of file TRestMetadata.cxx.

◆ Get2DVectorParameterWithUnits() [2/2]

TVector2 TRestMetadata::Get2DVectorParameterWithUnits ( std::string  parName,
TVector2  defaultValue = TVector2(-1, -1) 
)

Definition at line 1632 of file TRestMetadata.cxx.

◆ Get3DVectorParameterWithUnits() [1/2]

TVector3 TRestMetadata::Get3DVectorParameterWithUnits ( std::string  parName,
TiXmlElement *  e,
TVector3  defaultValue = TVector3(-1, -1, -1) 
)
protected

Definition at line 1547 of file TRestMetadata.cxx.

◆ Get3DVectorParameterWithUnits() [2/2]

TVector3 TRestMetadata::Get3DVectorParameterWithUnits ( std::string  parName,
TVector3  defaultValue = TVector3(-1, -1, -1) 
)

Definition at line 1647 of file TRestMetadata.cxx.

◆ GetCommit()

TString TRestMetadata::GetCommit ( )

Returns the REST commit value stored in fCommit.

Definition at line 2263 of file TRestMetadata.cxx.

◆ GetConfigBuffer()

std::string TRestMetadata::GetConfigBuffer ( )

Returns the config section of this class.

Definition at line 2315 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 2322 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 2340 of file TRestMetadata.cxx.

◆ GetDataPath()

TString TRestMetadata::GetDataPath ( )
inline

Returns a std::string with the path used for data storage.

Definition at line 291 of file TRestMetadata.h.

◆ GetDblParameterWithUnits() [1/2]

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 1619 of file TRestMetadata.cxx.

◆ GetDblParameterWithUnits() [2/2]

Double_t TRestMetadata::GetDblParameterWithUnits ( std::string  parName,
TiXmlElement *  e,
Double_t  defaultVal = PARAMETER_NOT_FOUND_DBL 
)
protected

Definition at line 1513 of file TRestMetadata.cxx.

◆ GetElement()

TiXmlElement * TRestMetadata::GetElement ( std::string  eleDeclare,
TiXmlElement *  e = nullptr 
)
protected

Get an xml element from a given parent element, according to its declaration.

Definition at line 1739 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 1678 of file TRestMetadata.cxx.

◆ GetElementWithName() [1/2]

TiXmlElement * TRestMetadata::GetElementWithName ( std::string  eleDeclare,
std::string  eleName 
)
protected

Get an xml element from the default location, according to its declaration and its field "name".

Definition at line 1756 of file TRestMetadata.cxx.

◆ GetElementWithName() [2/2]

TiXmlElement * TRestMetadata::GetElementWithName ( std::string  eleDeclare,
std::string  eleName,
TiXmlElement *  e 
)
protected

Get an xml element from a given parent element, according to its declaration and its field "name".

Definition at line 1764 of file TRestMetadata.cxx.

◆ GetError()

Bool_t TRestMetadata::GetError ( ) const
inline

It returns true if an error was identified by a derived metadata class.

Definition at line 210 of file TRestMetadata.h.

◆ GetErrorMessage()

TString TRestMetadata::GetErrorMessage ( )

Returns a std::string containing the error message.

Definition at line 2657 of file TRestMetadata.cxx.

◆ GetFieldValue() [1/2]

std::string TRestMetadata::GetFieldValue ( std::string  fieldName,
std::string  definition,
size_t  fromPosition = 0 
)
protected

Gets field value in an xml element string by parsing it as TiXmlElement.

Definition at line 2053 of file TRestMetadata.cxx.

◆ GetFieldValue() [2/2]

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 1573 of file TRestMetadata.cxx.

◆ GetKEYDefinition() [1/4]

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 1981 of file TRestMetadata.cxx.

◆ GetKEYDefinition() [2/4]

string TRestMetadata::GetKEYDefinition ( std::string  keyName,
size_t &  Position 
)
protected

Definition at line 1986 of file TRestMetadata.cxx.

◆ GetKEYDefinition() [3/4]

string TRestMetadata::GetKEYDefinition ( std::string  keyName,
size_t &  Position,
std::string  buffer 
)
protected

Definition at line 1994 of file TRestMetadata.cxx.

◆ GetKEYDefinition() [4/4]

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

Definition at line 1990 of file TRestMetadata.cxx.

◆ GetKEYStructure() [1/5]

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 1929 of file TRestMetadata.cxx.

◆ GetKEYStructure() [2/5]

string TRestMetadata::GetKEYStructure ( std::string  keyName,
size_t &  Position 
)
protected

Definition at line 1935 of file TRestMetadata.cxx.

◆ GetKEYStructure() [3/5]

string TRestMetadata::GetKEYStructure ( std::string  keyName,
size_t &  Position,
std::string  buffer 
)
protected

Definition at line 1946 of file TRestMetadata.cxx.

◆ GetKEYStructure() [4/5]

string TRestMetadata::GetKEYStructure ( std::string  keyName,
size_t &  Position,
TiXmlElement *  ele 
)
protected

Definition at line 1952 of file TRestMetadata.cxx.

◆ GetKEYStructure() [5/5]

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

Definition at line 1940 of file TRestMetadata.cxx.

◆ GetLibraryVersion()

TString TRestMetadata::GetLibraryVersion ( )

Returns the REST libraty version stored in fLibraryVersion.

Definition at line 2268 of file TRestMetadata.cxx.

◆ GetMainDataPath()

TString TRestMetadata::GetMainDataPath ( )
inline

Gets a std::string with the path used for data storage.

Definition at line 306 of file TRestMetadata.h.

◆ GetNextElement()

TiXmlElement * TRestMetadata::GetNextElement ( TiXmlElement *  e)
protected

Get the next sibling xml element of this element, with same eleDeclare.

Definition at line 1747 of file TRestMetadata.cxx.

◆ GetNumberOfErrors()

Int_t TRestMetadata::GetNumberOfErrors ( ) const
inline

Definition at line 230 of file TRestMetadata.h.

◆ GetNumberOfWarnings()

Int_t TRestMetadata::GetNumberOfWarnings ( ) const
inline

Definition at line 232 of file TRestMetadata.h.

◆ 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 2067 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" >

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 1489 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 1450 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 1836 of file TRestMetadata.cxx.

◆ GetParametersList()

std::map< string, string > TRestMetadata::GetParametersList ( )
protected

It retrieves a map of all parameter:value found in the metadata class.

Definition at line 2469 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 2390 of file TRestMetadata.cxx.

◆ GetSectionName()

std::string TRestMetadata::GetSectionName ( )

Returns the section name of this class, defined at the beginning of fSectionName.

Definition at line 2307 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 1807 of file TRestMetadata.cxx.

◆ GetVerboseLevel()

TRestStringOutput::REST_Verbose_Level TRestMetadata::GetVerboseLevel ( )
inline

returns the verboselevel in type of REST_Verbose_Level enumerator

Definition at line 300 of file TRestMetadata.h.

◆ GetVerboseLevelString()

TString TRestMetadata::GetVerboseLevelString ( )

returns the verbose level in type of TString

Returns a string corresponding to current verbose level.

Definition at line 2358 of file TRestMetadata.cxx.

◆ GetVersion()

TString TRestMetadata::GetVersion ( )

Returns the REST version stored in fVersion.

Definition at line 2258 of file TRestMetadata.cxx.

◆ GetVersionCode()

Int_t TRestMetadata::GetVersionCode ( )

Definition at line 2302 of file TRestMetadata.cxx.

◆ GetWarning()

Bool_t TRestMetadata::GetWarning ( ) const
inline

It returns true if an error was identified by a derived metadata class.

Definition at line 213 of file TRestMetadata.h.

◆ GetWarningMessage()

TString TRestMetadata::GetWarningMessage ( )

Returns a std::string containing the warning message.

Definition at line 2664 of file TRestMetadata.cxx.

◆ InitFromConfigFile()

virtual void TRestMetadata::InitFromConfigFile ( )
inlineprotectedvirtual

To make settings from rml file. This method must be implemented in the derived class.

Reimplemented in TRestAxionBufferGas, TRestAxionLikelihood, TRestAxionMagneticField, TRestAxionOptics, TRestAxionSolarModel, TRestAxionSpectrum, TRestAxionTemplate, TRestAxionXrayWindow, TRestGeant4ParticleSource, TRestDataQualityProcess, TRestDataSetCalibration, TRestDataSetOdds, TRestMySQLToAnalysisProcess, TRestRealTimeAddInputFileProcess, TRestSummaryProcess, TRestAnalysisPlot, TRestCut, TRestDataSet, TRestDataSetPlot, TRestEventProcess, TRestGDMLParser, TRestManager, TRestMessenger, TRestMetadataPlot, TRestProcessRunner, TRestRun, TRestTask, TRestCombinedMask, TRestAxionMCPLOptics, TRestAxionTransmissionProcess, TRestAxionTrueWolterOptics, TRestAxionWolterOptics, TRestDetectorHitsToTrackFastProcess, TRestGeant4ToDetectorHitsProcess, TRestRawReadoutAnalysisProcess, TRestTrackToDetectorHitsProcess, TRestDetector, TRestDetectorAvalancheProcess, TRestDetectorDaqChannelSwitchingProcess, TRestDetectorDriftVolume, TRestDetectorElectronDiffusionProcess, TRestDetectorFiducializationProcess, TRestDetectorGainMap, TRestDetectorGas, TRestDetectorHits3DReconstructionProcess, TRestDetectorHitsAnalysisProcess, TRestDetectorHitsNormalizationProcess, TRestDetectorHitsReductionProcess, TRestDetectorHitsRotateAndTranslateProcess, TRestDetectorHitsShuffleProcess, TRestDetectorPositionMappingProcess, TRestDetectorReadout, TRestDetectorSetup, TRestDetectorSignalChannelActivityProcess, TRestDetectorSignalViewerProcess, TRestDetectorSingleChannelAnalysisProcess, TRestGeant4BlobAnalysisProcess, TRestGeant4Metadata, TRestGeant4NeutronTaggingProcess, TRestGeant4ParticleSourceDecay0, TRestGeant4PhysicsLists, TRestGeant4VetoAnalysisProcess, TRestRawDAQMetadata, TRestRawMemoryBufferToSignalProcess, TRestRawPeaksFinderProcess, TRestRawSignalAnalysisProcess, TRestRawSignalConvolutionFittingProcess, TRestRawSignalIdTaggingProcess, TRestRawSignalRangeReductionProcess, TRestRawSignalRemoveChannelsProcess, TRestRawSignalViewerProcess, TRestRawToSignalProcess, TRestRawVetoAnalysisProcess, TRestTrackAnalysisProcess, TRestTrackBlobAnalysisProcess, TRestTrackDetachIsolatedNodesProcess, TRestTrackPointLikeAnalysisProcess, TRestTrackReconnectionProcess, and TRestWimpSensitivity.

Definition at line 137 of file TRestMetadata.h.

◆ InitFromRootFile()

virtual void TRestMetadata::InitFromRootFile ( )
inlineprotectedvirtual

Method called after the object is retrieved from root file.

Reimplemented in TRestDetectorGas.

Definition at line 146 of file TRestMetadata.h.

◆ Initialize()

virtual void TRestMetadata::Initialize ( )
inlinevirtual

Making default settings.

Reimplemented in TRestAxionBufferGas, TRestAxionLikelihood, TRestAxionMagneticField, TRestAxionOptics, TRestAxionOpticsMirror, TRestAxionSolarFlux, TRestAxionSolarModel, TRestAxionSpectrum, TRestAxionTemplate, TRestAxionXrayWindow, TRestBenchMarkProcess, TRestDataQualityProcess, TRestDataSetCalibration, TRestDataSetOdds, TRestEventRateAnalysisProcess, TRestEventSelectionProcess, TRestMySQLToAnalysisProcess, TRestRealTimeAddInputFileProcess, TRestRealTimeDrawingProcess, TRestSummaryProcess, TRestAnalysisPlot, TRestCut, TRestDataSet, TRestDataSetPlot, TRestManager, TRestMessenger, TRestMetadataPlot, TRestProcessRunner, TRestRun, TRestCombinedMask, TRestGridMask, TRestRingsMask, TRestSpiderMask, TRestStrippedMask, TRestAxionAnalysisProcess, TRestAxionDeviationProcess, TRestAxionFieldPropagationProcess, TRestAxionGeneratorProcess, TRestAxionMCPLOptics, TRestAxionOpticsProcess, TRestAxionTransmissionProcess, TRestAxionTransportProcess, TRestAxionTrueWolterOptics, TRestAxionWolterOptics, TRestDetectorHitsToTrackFastProcess, TRestDetectorHitsToTrackProcess, TRestDetectorSignalToRawSignalProcess, TRestGeant4ToDetectorHitsProcess, TRestRawReadoutAnalysisProcess, TRestRawToDetectorSignalProcess, TRestTrackToDetectorHitsProcess, TRestDetectorAvalancheProcess, TRestDetectorDaqChannelSwitchingProcess, TRestDetectorDriftVolume, TRestDetectorElectronDiffusionProcess, TRestDetectorFiducializationProcess, TRestDetectorGarfieldDriftProcess, TRestDetectorGas, TRestDetectorHits3DReconstructionProcess, TRestDetectorHitsAnalysisProcess, TRestDetectorHitsGaussAnalysisProcess, TRestDetectorHitsNormalizationProcess, TRestDetectorHitsReductionProcess, TRestDetectorHitsRotateAndTranslateProcess, TRestDetectorHitsShuffleProcess, TRestDetectorHitsSmearingProcess, TRestDetectorHitsToSignalProcess, TRestDetectorPositionMappingProcess, TRestDetectorReadout, TRestDetectorSetup, TRestDetectorSignalChannelActivityProcess, TRestDetectorSignalRecoveryProcess, TRestDetectorSignalToHitsProcess, TRestDetectorSignalViewerProcess, TRestDetectorSingleChannelAnalysisProcess, TRestDetectorTriggerAnalysisProcess, TRestGeant4AnalysisProcess, TRestGeant4BlobAnalysisProcess, TRestGeant4Metadata, TRestGeant4NeutronTaggingProcess, TRestGeant4PhysicsLists, TRestGeant4VetoAnalysisProcess, TRestRawAFTERToSignalProcess, TRestRawBaseLineCorrectionProcess, TRestRawBiPoToSignalProcess, TRestRawCommonNoiseReductionProcess, TRestRawDAQMetadata, TRestRawFEUDreamToSignalProcess, TRestRawFindResponseSignalProcess, TRestRawMemoryBufferToSignalProcess, TRestRawMultiCoBoAsAdToSignalProcess, TRestRawMultiFEMINOSToSignalProcess, TRestRawSignalAddNoiseProcess, TRestRawSignalAnalysisProcess, TRestRawSignalChannelActivityProcess, TRestRawSignalConvolutionFittingProcess, TRestRawSignalFittingProcess, TRestRawSignalGeneralFitProcess, TRestRawSignalIdTaggingProcess, TRestRawSignalRangeReductionProcess, TRestRawSignalRemoveChannelsProcess, TRestRawSignalShapingProcess, TRestRawSignalViewerProcess, TRestRawTDSToSignalProcess, TRestRawToSignalProcess, TRestRawUSTCToSignalProcess, TRestRawVetoAnalysisProcess, TRestTrackAnalysisProcess, TRestTrackBlobAnalysisProcess, TRestTrackDetachIsolatedNodesProcess, TRestTrackLineAnalysisProcess, TRestTrackLinearizationProcess, TRestTrackPathMinimizationProcess, TRestTrackPointLikeAnalysisProcess, TRestTrackReconnectionProcess, TRestTrackReductionProcess, TRestTrackViewerProcess, and TRestWimpSensitivity.

Definition at line 247 of file TRestMetadata.h.

◆ 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 712 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 766 of file TRestMetadata.cxx.

◆ isCleanState()

Bool_t TRestMetadata::isCleanState ( ) const
inline

Definition at line 287 of file TRestMetadata.h.

◆ isOfficialRelease()

Bool_t TRestMetadata::isOfficialRelease ( ) const
inline

Definition at line 285 of file TRestMetadata.h.

◆ 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 675 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 638 of file TRestMetadata.cxx.

◆ LoadConfigFromFile()

Int_t TRestMetadata::LoadConfigFromFile ( const std::string &  configFilename,
const std::string &  sectionName = "" 
)

Give the file name, find out the corresponding section. Then call the main starter.

Definition at line 552 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 TRestEventProcess, and TRestManager.

Definition at line 800 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 2671 of file TRestMetadata.cxx.

◆ Print()

void TRestMetadata::Print ( )
inline

Implementing TObject::Print() method.

Definition at line 250 of file TRestMetadata.h.

◆ PrintConfigBuffer()

void TRestMetadata::PrintConfigBuffer ( )

Print the config xml section stored in the class.

Prints current config buffer on screen.

Definition at line 2193 of file TRestMetadata.cxx.

◆ PrintMessageBuffer()

void TRestMetadata::PrintMessageBuffer ( )

Print the buffered message.

Definition at line 2227 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 TRestAxionBufferGas, TRestAxionLikelihood, TRestAxionMagneticField, TRestAxionOptics, TRestAxionOpticsMirror, TRestAxionSolarFlux, TRestAxionSolarModel, TRestAxionSpectrum, TRestAxionTemplate, TRestAxionXrayWindow, TRestBenchMarkProcess, TRestDataQualityProcess, TRestDataSetCalibration, TRestDataSetOdds, TRestEventRateAnalysisProcess, TRestEventSelectionProcess, TRestMySQLToAnalysisProcess, TRestRealTimeAddInputFileProcess, TRestRealTimeDrawingProcess, TRestSummaryProcess, TRestAnalysisPlot, TRestCut, TRestDataSet, TRestDataSetPlot, TRestManager, TRestMessenger, TRestMetadataPlot, TRestProcessRunner, TRestRun, TRestCombinedMask, TRestGridMask, TRestPatternMask, TRestRingsMask, TRestSpiderMask, TRestStrippedMask, TRestAxionAnalysisProcess, TRestAxionDeviationProcess, TRestAxionEventProcess, TRestAxionFieldPropagationProcess, TRestAxionGeneratorProcess, TRestAxionMCPLOptics, TRestAxionSolarQCDFlux, TRestAxionTransmissionProcess, TRestAxionTransportProcess, TRestAxionTrueWolterOptics, TRestAxionWolterOptics, TRestDetectorHitsToTrackFastProcess, TRestDetectorHitsToTrackProcess, TRestDetectorSignalToRawSignalProcess, TRestGeant4ToDetectorHitsProcess, TRestRawReadoutAnalysisProcess, TRestRawToDetectorSignalProcess, TRestTrackToDetectorHitsProcess, TRestDetector, TRestDetectorAvalancheProcess, TRestDetectorDaqChannelSwitchingProcess, TRestDetectorDriftVolume, TRestDetectorElectronDiffusionProcess, TRestDetectorFiducializationProcess, TRestDetectorGas, TRestDetectorHits3DReconstructionProcess, TRestDetectorHitsAnalysisProcess, TRestDetectorHitsGaussAnalysisProcess, TRestDetectorHitsNormalizationProcess, TRestDetectorHitsReductionProcess, TRestDetectorHitsRotateAndTranslateProcess, TRestDetectorHitsShuffleProcess, TRestDetectorHitsSmearingProcess, TRestDetectorHitsToSignalProcess, TRestDetectorPositionMappingProcess, TRestDetectorReadout, TRestDetectorSetup, TRestDetectorSignalChannelActivityProcess, TRestDetectorSignalRecoveryProcess, TRestDetectorSignalToHitsProcess, TRestDetectorSignalViewerProcess, TRestDetectorSingleChannelAnalysisProcess, TRestDetectorTriggerAnalysisProcess, TRestGeant4AnalysisProcess, TRestGeant4BlobAnalysisProcess, TRestGeant4Metadata, TRestGeant4NeutronTaggingProcess, TRestGeant4PhysicsLists, TRestGeant4VetoAnalysisProcess, TRestLegacyProcess, TRestRawZeroSuppresionProcess, TRestRawBaseLineCorrectionProcess, TRestRawBiPoToSignalProcess, TRestRawCommonNoiseReductionProcess, TRestRawDAQMetadata, TRestRawFindResponseSignalProcess, TRestRawMemoryBufferToSignalProcess, TRestRawPeaksFinderProcess, TRestRawSignalAddNoiseProcess, TRestRawSignalAnalysisProcess, TRestRawSignalChannelActivityProcess, TRestRawSignalConvolutionFittingProcess, TRestRawSignalFittingProcess, TRestRawSignalGeneralFitProcess, TRestRawSignalIdTaggingProcess, TRestRawSignalRangeReductionProcess, TRestRawSignalRemoveChannelsProcess, TRestRawSignalShapingProcess, TRestRawSignalViewerProcess, TRestRawToSignalProcess, TRestRawVetoAnalysisProcess, TRestTrackAnalysisProcess, TRestTrackBlobAnalysisProcess, TRestTrackDetachIsolatedNodesProcess, TRestTrackLineAnalysisProcess, TRestTrackLinearizationProcess, TRestTrackPathMinimizationProcess, TRestTrackPointLikeAnalysisProcess, TRestTrackReconnectionProcess, TRestTrackReductionProcess, TRestTrackViewerProcess, and TRestWimpSensitivity.

Definition at line 2233 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 2174 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:70

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 2448 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 924 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 888 of file TRestMetadata.cxx.

◆ ReadOneParameter()

void TRestMetadata::ReadOneParameter ( std::string  name,
std::string  value 
)
private

Definition at line 2520 of file TRestMetadata.cxx.

◆ ReadParametersList()

void TRestMetadata::ReadParametersList ( std::map< std::string, std::string > &  list)
protected

It reads a parameter list and associates it to its corresponding metadata member. par0 --> fPar0.

Definition at line 2460 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 2130 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 848 of file TRestMetadata.cxx.

◆ ReplaceForLoopVars()

void TRestMetadata::ReplaceForLoopVars ( TiXmlElement *  e,
std::map< std::string, std::string >  forLoopVar 
)
private

Helper method for TRestMetadata::ExpandForLoops().

Definition at line 1099 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 2086 of file TRestMetadata.cxx.

◆ ReSetVersion()

void TRestMetadata::ReSetVersion ( )
protected

Resets the version of TRestRun to REST_RELEASE. Only TRestRun is allowed to update version.

Definition at line 2273 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 2161 of file TRestMetadata.cxx.

◆ SetConfigFile()

void TRestMetadata::SetConfigFile ( std::string  configFilename)
inline

set config file path from external

Definition at line 323 of file TRestMetadata.h.

◆ SetError()

void TRestMetadata::SetError ( std::string  message = "",
bool  print = true 
)

A metadata class may use this method to signal that something went wrong.

Definition at line 2635 of file TRestMetadata.cxx.

◆ SetHostmgr()

void TRestMetadata::SetHostmgr ( TRestManager m)
inline

Set the host manager for this class.

Definition at line 325 of file TRestMetadata.h.

◆ SetLibraryVersion()

void TRestMetadata::SetLibraryVersion ( TString  version)
protected

Set the library version of this metadata class.

Definition at line 2300 of file TRestMetadata.cxx.

◆ SetSectionName()

void TRestMetadata::SetSectionName ( std::string  sName)
inline

set the section name, clear the section content

Definition at line 321 of file TRestMetadata.h.

◆ SetVerboseLevel()

void TRestMetadata::SetVerboseLevel ( TRestStringOutput::REST_Verbose_Level  v)
inline

sets the verbose level

Definition at line 328 of file TRestMetadata.h.

◆ SetWarning()

void TRestMetadata::SetWarning ( std::string  message = "",
bool  print = true 
)

A metadata class may use this method to signal that something went wrong.

Definition at line 2646 of file TRestMetadata.cxx.

◆ Store()

void TRestMetadata::Store ( )
inline

If this method is called the metadata information will be stored in disk.

Definition at line 319 of file TRestMetadata.h.

◆ 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 1871 of file TRestMetadata.cxx.

◆ UnSetVersion()

void TRestMetadata::UnSetVersion ( )
protected

Resets the version of TRestRun to -1, in case the file is old REST file. Only TRestRun is allowed to update version.

Definition at line 2286 of file TRestMetadata.cxx.

◆ UpdateMetadataMembers()

virtual void TRestMetadata::UpdateMetadataMembers ( )
inlinevirtual

Method to allow implementation of specific metadata members updates at inherited classes.

Reimplemented in TRestDetector.

Definition at line 256 of file TRestMetadata.h.

◆ Write()

Int_t TRestMetadata::Write ( const char *  name = nullptr,
Int_t  option = 0,
Int_t  bufsize = 0 
)
virtual

overwriting the write() method with fStore considered

Reimplemented in TRestCut, TRestDetectorGas, and TRestRun.

Definition at line 2415 of file TRestMetadata.cxx.

◆ WriteConfigBuffer()

void TRestMetadata::WriteConfigBuffer ( std::string  fName)

Writes the config buffer to a file in append mode.

Definition at line 2209 of file TRestMetadata.cxx.

Field Documentation

◆ configBuffer

std::string TRestMetadata::configBuffer
protected

The buffer where the corresponding metadata section is stored. Filled only during Write()

Definition at line 162 of file TRestMetadata.h.

◆ fCleanState

Bool_t TRestMetadata::fCleanState = false
private

Definition at line 90 of file TRestMetadata.h.

◆ fCommit

TString TRestMetadata::fCommit = REST_COMMIT
private

Definition at line 86 of file TRestMetadata.h.

◆ 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 158 of file TRestMetadata.h.

◆ fConstants

std::map<std::string, std::string> TRestMetadata::fConstants
protected

Saving a list of rml constants. name-value std::pair. Constants are temporary for this class only.

Definition at line 182 of file TRestMetadata.h.

◆ fElement

TiXmlElement* TRestMetadata::fElement
protected

Saving the sectional element together with global element.

Definition at line 176 of file TRestMetadata.h.

◆ fElementGlobal

TiXmlElement* TRestMetadata::fElementGlobal
protected

Saving the global element, to be passed to the resident class, if necessary.

Definition at line 178 of file TRestMetadata.h.

◆ fError

Bool_t TRestMetadata::fError = false
protected

It can be used as a way to identify that something went wrong using SetError method.

Definition at line 185 of file TRestMetadata.h.

◆ fErrorMessage

TString TRestMetadata::fErrorMessage = ""
protected

A std::string to store an optional error message through method SetError.

Definition at line 197 of file TRestMetadata.h.

◆ fHostmgr

TRestManager* TRestMetadata::fHostmgr
protected

All metadata classes can be initialized and managed by TRestManager.

Definition at line 172 of file TRestMetadata.h.

◆ fLibraryVersion

TString TRestMetadata::fLibraryVersion = "0"
private

Definition at line 87 of file TRestMetadata.h.

◆ fNErrors

Int_t TRestMetadata::fNErrors = 0
protected

It counts the number of errors notified.

Definition at line 188 of file TRestMetadata.h.

◆ fNWarnings

Int_t TRestMetadata::fNWarnings = 0
protected

It counts the number of warnings notified.

Definition at line 194 of file TRestMetadata.h.

◆ fOfficialRelease

Bool_t TRestMetadata::fOfficialRelease = false
private

Definition at line 89 of file TRestMetadata.h.

◆ fSectionName

std::string TRestMetadata::fSectionName
protected

Section name given in the constructor of the derived metadata class.

Definition at line 160 of file TRestMetadata.h.

◆ fStore

Bool_t TRestMetadata::fStore
protected

This variable is used to determine if the metadata structure should be stored in the ROOT file.

Definition at line 174 of file TRestMetadata.h.

◆ fVariables

std::map<std::string, std::string> TRestMetadata::fVariables
protected

Saving a list of rml variables. name-value std::pair.

Definition at line 180 of file TRestMetadata.h.

◆ fVerboseLevel

TRestStringOutput::REST_Verbose_Level TRestMetadata::fVerboseLevel
protected

Verbose level used to print debug info.

Definition at line 167 of file TRestMetadata.h.

◆ fVersion

TString TRestMetadata::fVersion = REST_RELEASE
private

REST version std::string, only used for archive and retrieve.

Definition at line 85 of file TRestMetadata.h.

◆ fWarning

Bool_t TRestMetadata::fWarning = false
protected

It can be used as a way to identify that something went wrong using SetWarning method.

Definition at line 191 of file TRestMetadata.h.

◆ fWarningMessage

TString TRestMetadata::fWarningMessage = ""
protected

It can be used as a way to identify that something went wrong using SetWarning method.

Definition at line 200 of file TRestMetadata.h.

◆ messageBuffer

std::string TRestMetadata::messageBuffer
protected

The buffer to store the output message through TRestStringOutput in this class.

Definition at line 164 of file TRestMetadata.h.

◆ RESTendl

endl_t TRestMetadata::RESTendl
protected

Termination flag object for TRestStringOutput.

Definition at line 169 of file TRestMetadata.h.


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