HighLAND
Public Member Functions | Static Public Member Functions | List of all members
Parameters Class Reference

#include <Parameters.hxx>

Public Member Functions

bool HasParameter (std::string)
 Check if Parameter is stored in database.
 
int GetParameterI (std::string)
 Get parameter. Value is returned as integer.
 
double GetParameterD (std::string)
 Get parameter. Value is returned as double.
 
std::string GetParameterS (std::string)
 Get parameter. Value is returned as string.
 
void ClearMapOfParameters ()
 Clear all the parameters that have been read.
 
UnitsParserGetUnitsTableParser ()
 
void ReadParamOverrideFile (TString filename)
 
int LoadParametersFile (TString packageName, UInt_t tryFileMode=0, bool fixParameters=false)
 Load the parameters for a given package - needed for multi-threading.
 
void LoadParametersFiles (const std::vector< std::string > &packageNames, bool fixed=false)
 Load the parameters for a list of packages.
 
void SetReadParamOverrideFilePointPassed ()
 Set whether the point in which the overwride parameters file is read is passed or not.
 
void CheckReadParamOverrideFilePointPassed (std::string parameterName)
 

Static Public Member Functions

static ParametersGet (void)
 

Detailed Description

This class provides access to a set of parameters that are defined in a set of text files. The parameters can be used at runtime, by calling ND::params().GetParameterI("tutAnalsyis.param.name") or similar.

Parameters files should be placed in the "parameters" directory in an analysis package, and named as tutAnalysis.parameters.dat, where tutAnalysis is the name of the analysis package. This is where the code will look for a parameter, unless you have already specified the parameter in an "override" file (see below).

The format for parameters files is: < tutAnalysis.param.name = 12345 > Note that you should have spaces between the <>= symbols and your parameter names / values. The first bit of your parameter name MUST be the same as your package name. After that you can have whatever you like. It is useful to use the "dots" to logically group parameters that are related. For example, you could have tutAnalysis.Cuts.PullMu.Max and tutAnalysis.Cuts.PullMu.Min.

Parameters can be read as integers, doubles or strings, using the ND::params().GetParameterI(), ND::params().GetParameterD() and ND::params().GetParameterS() functions, respectively.

You don't need to do anything special to use the ND::params() singleton - the first time you call one of the ND::params().GetParameter functions it will parse the relevant parameters file.

You can use a parameters "override" file to override the values set in the normal parameters file. This override file can contain a subset of the parameters (even just 1 or 2), and can be placed anywhere on your file system. Specify the path to this override file using the -p command-line option. This is very useful if you're using the FLuxWeighting, for example, so that you can run multiple jobs in parallel, and can specify to apply the run 1 flux to run 1 MC files, run 2 flux to run 2 MC files etc.

Definition at line 59 of file Parameters.hxx.

Member Function Documentation

§ CheckReadParamOverrideFilePointPassed()

void Parameters::CheckReadParamOverrideFilePointPassed ( std::string  parameterName)

Checks whether the point in which the overwride parameters file is read is passed or not. To be used in GetParameters methods. It stops and prints an error message if the ReadParamOverrideFile point is not yet passed

Definition at line 259 of file Parameters.cxx.

259  {
260 
261  if (!fReadParamOverrideFilePointPassed){
262  std::cerr << "ERROR: Parameter '" << parameterName << "'" << std::endl
263  << "should no be accessed in analysis algorithm constructors or globally" << std::endl
264  << "since it will not be overwritten when an override parameter file is used (-p option)" << std::endl
265  << "Please move the GetParameter calls to the Initialize method of the analysis algorithm." << std::endl;
266  exit(1);
267  }
268 
269 }

§ Get()

static Parameters& Parameters::Get ( void  )
inlinestatic

Get a reference to the singleton instance of dummy database information. If this is first attempt at reference then singleton is instantiated and parameters are read from text files.

Definition at line 69 of file Parameters.hxx.

69  {
70  if (!fParameters)
71  fParameters = new Parameters();
72  return *fParameters;
73  }

§ GetUnitsTableParser()

UnitsParser* Parameters::GetUnitsTableParser ( )
inline

Return the class which parses any units specified in the parameters file, and converts them to a consistent set of HEP units.

Definition at line 92 of file Parameters.hxx.

92  {
93  return fUnitsParser;
94  }

§ ReadParamOverrideFile()

void Parameters::ReadParamOverrideFile ( TString  filename)

This command allows the user to set parameters from the command line; the command is different from the standard file reading, in that the parameters that are set are 'fixed'. Ie, they are immutable and cannot be changed, even if they exist in some other parameters file that is read in later.

Definition at line 192 of file Parameters.cxx.

192  {
193 
194  std::cout << "Using Parameters override file = " << filename << std::endl;
195 
196  // Setting final input variable to true forces the parameters
197  // that are loaded to be 'fixed'; ie immutable.
198  // The 2 means that an exception is thrown if the file is not found
199  ReadInputFile(filename, "", 2, true);
200 }

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