Hall C ROOT/C++ Analyzer (hcana)
THcParmList Class Reference

A list parameters and their values.

Parameters may be integers, real numbers or strings. Integers and floating point numbers can be one dimensional arrays. (Strings can not be arrays.) In addition to values, each parameter may have a title/description. (No titles are saved for string parameters.)

The Hall C analyzer make one instance of this class available via the global gHcParms. The detector classes look for their configuration parameters in that list.

This class is built on THaVarList, adding a method to load the list of parameters from Hall C ENGINE style CTP parameter files and a method to retrieve a set of parameters from the list.

An instance of Podd::Textvars is created to hold the string parameters.

Definition at line 27 of file THcParmList.h.

Public Member Functions

Int_t AddString (const std::string &name, const std::string &value)
 
Int_t GetArray (const char *attr, Int_t *array, Int_t size)
 Read in a set of Int_t's in to a C-style array. More...
 
Int_t GetArray (const char *attr, Double_t *array, Int_t size)
 Read in a set of Double_t's in to a vector. More...
 
const char * GetString (const std::string &name) const
 
virtual void Load (const char *fname, Int_t RunNumber=0)
 Load the parameter cache by reading a CTP style parameter file. More...
 
Int_t LoadParmValues (const DBRequest *list, const char *prefix="")
 Retrieve parameter values from the parameter cache. More...
 
virtual void PrintFull (Option_t *opt="") const
 Print all the numeric parameter desciptions and value and text parameters. More...
 
void RemoveString (const std::string &name)
 
 THcParmList ()
 
virtual ~THcParmList ()
 

Private Member Functions

template<class T >
Int_t ReadArray (const char *attrC, T *array, Int_t size)
 Dictionary of string parameters. More...
 

Private Attributes

Podd::Textvars * TextList
 

#include <THcParmList.h>

Inheritance diagram for THcParmList:

Constructor & Destructor Documentation

THcParmList::THcParmList ( )
virtual THcParmList::~THcParmList ( )
inlinevirtual

Definition at line 32 of file THcParmList.h.

Member Function Documentation

Int_t THcParmList::AddString ( const std::string &  name,
const std::string &  value 
)
inline

Definition at line 42 of file THcParmList.h.

Int_t THcParmList::GetArray ( const char *  attr,
Int_t array,
Int_t  size 
)

Read in a set of Int_t's in to a C-style array.

Definition at line 631 of file THcParmList.cxx.

Int_t THcParmList::GetArray ( const char *  attr,
Double_t array,
Int_t  size 
)

Read in a set of Double_t's in to a vector.

Definition at line 636 of file THcParmList.cxx.

const char* THcParmList::GetString ( const std::string &  name) const
inline

Definition at line 38 of file THcParmList.h.

void THcParmList::Load ( const char *  fname,
Int_t  RunNumber = 0 
)
virtual

Load the parameter cache by reading a CTP style parameter file.

Most parameter files used in the ENGINE should work.

A line in the file of the form

varname = value1[, value2, value3, value4] [; Comment]

adds the variable varname to the parameter cache and the value after the equal sign is stored. If a list of values is given, then the values are saved as an array. Lists of values may be continued on additional lines. Lines without a = are interpreted as such continuation lines. Text after a ";" is treated as a comment. If this comment is on a line defining a parameter, then it is saved as the title/description for the parameter.

Values may be expressions composed of numbers and previously defined parameters. These expressions are evaluated with THaFormula.

Lines of the form

varname = "A string"

or

varname = 'A string'

create string parameters.

A parameter file can load other files with the include statement

#include "filename"

The ENGINE CTP support parameter "blocks" which were marked with begin and end statements. These statements are ignored.

Definition at line 84 of file THcParmList.cxx.

Int_t THcParmList::LoadParmValues ( const DBRequest *  list,
const char *  prefix = "" 
)

Retrieve parameter values from the parameter cache.

The following example loads several parameters held in the gHcParms parameter cache into scalar variables or arrays.

DBRequest list[]={
{"nplanes", &fNPlanes, kInt},
{"name", &fName, kString},
{"array", fArray, kDouble, fArraySize},
{"optional", &FOptionalvar, kDouble, 0, 1},
{0}
};
gHcParms->LoadParmValues((DBRequest*)&list,"h");

If a string is passed as the second parameter of LoadParmValues, then that string is prepended to the parameter names given in the DBRequest list. In the above example, the values for the parameters hnplanes, hname, harray, and hoptional are loaded.

If a requested parameter is not found in the parameter cache, an error is printed. If the 5th element of a DBRequest structure is true (non zero), then there will be no error if the parameter is missing.

Definition at line 522 of file THcParmList.cxx.

void THcParmList::PrintFull ( Option_t opt = "") const
virtual

Print all the numeric parameter desciptions and value and text parameters.

Definition at line 690 of file THcParmList.cxx.

template<class T >
Int_t THcParmList::ReadArray ( const char *  attrC,
T array,
Int_t  size 
)
private

Dictionary of string parameters.

Copy values from parameter store to array.

No resizing is done, so only 'size' elements may be stored.

Definition at line 643 of file THcParmList.cxx.

void THcParmList::RemoveString ( const std::string &  name)
inline

Definition at line 45 of file THcParmList.h.

Member Data Documentation

Podd::Textvars* THcParmList::TextList
private

Definition at line 64 of file THcParmList.h.

Collaboration diagram for THcParmList:

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