#include <ParameterMgr.h>
Public Member Functions | |
void | addParameter (const ALIstring &name, const ALIstring &valstr) |
void | addRandomFlatParameter (const ALIstring &name, const ALIstring &valMean, const ALIstring &valInterval) |
void | addRandomGaussParameter (const ALIstring &name, const ALIstring &valMean, const ALIstring &valStdDev) |
ALIint | getParameterValue (const ALIstring &name, ALIdouble &val) |
ALIdouble | getVal (const ALIstring &str, const ALIdouble dimensionFactor=1.) |
void | setRandomSeed (const long seed) |
Static Public Member Functions | |
static ParameterMgr * | getInstance () |
Private Member Functions | |
ParameterMgr () | |
Private Attributes | |
msd | theParameters |
Static Private Attributes | |
static ParameterMgr * | theInstance = 0 |
Definition at line 15 of file ParameterMgr.h.
ParameterMgr::ParameterMgr | ( | ) | [inline, private] |
Definition at line 69 of file ParameterMgr.cc.
References benchmark_cfg::cerr, ALIUtils::debug, getVal(), mergeVDriftHistosByStation::name, and theParameters.
Referenced by Model::readSystemDescription().
{ if( theParameters.find( name ) != theParameters.end() ) { if( ALIUtils::debug >= 1) std::cerr << "!! WARNING: PARAMETER " << name << " appears twice, it will take first value " << std::endl; } else { theParameters[name] = getVal( valstr ); } }
void ParameterMgr::addRandomFlatParameter | ( | const ALIstring & | name, |
const ALIstring & | valMean, | ||
const ALIstring & | valInterval | ||
) |
Definition at line 103 of file ParameterMgr.cc.
References benchmark_cfg::cerr, gather_cfg::cout, ALIUtils::debug, getVal(), MergeJob_cfg::interval, plotscripts::mean(), mergeVDriftHistosByStation::name, and theParameters.
Referenced by Model::readSystemDescription().
{ if( theParameters.find( name ) != theParameters.end() ) { if( ALIUtils::debug >= 1) std::cerr << "!! WARNING: PARAMETER " << name << " appears twice, it will take first value " << std::endl; } else { ALIdouble mean = getVal( valMean ); ALIdouble interval = getVal( valInterval ); ALIdouble val = CLHEP::HepRandom::getTheEngine()->flat(); // flat between ]mean-interval, mean+interval[ val = val * 2*interval + mean-interval; theParameters[name] = val; if( ALIUtils::debug >= 2 )std::cout << " addRandomFlatParameter " << name << " " << valMean << " " << valInterval << " = " << val << std::endl; } }
void ParameterMgr::addRandomGaussParameter | ( | const ALIstring & | name, |
const ALIstring & | valMean, | ||
const ALIstring & | valStdDev | ||
) |
Definition at line 87 of file ParameterMgr.cc.
References benchmark_cfg::cerr, gather_cfg::cout, ALIUtils::debug, getVal(), plotscripts::mean(), mergeVDriftHistosByStation::name, and theParameters.
Referenced by Model::readSystemDescription().
{ if( theParameters.find( name ) != theParameters.end() ) { if( ALIUtils::debug >= 1) std::cerr << "!! WARNING: PARAMETER " << name << " appears twice, it will take first value " << std::endl; } else { ALIdouble mean = getVal( valMean ); ALIdouble stddev = getVal( valStdDev ); ALIdouble val = CLHEP::RandGauss::shoot( mean, stddev ); theParameters[name] = val; if( ALIUtils::debug >= -2 ) std::cout << " addRandomGaussParameter " << name << " " << valMean << " " << valStdDev << " = " << val << std::endl; } }
ParameterMgr * ParameterMgr::getInstance | ( | ) | [static] |
Definition at line 19 of file ParameterMgr.cc.
References ParameterMgr(), and theInstance.
Referenced by Measurement::fillData(), Entry::fillFromInputFileSigma(), Entry::fillFromInputFileValue(), Model::getParameterValue(), and Model::readSystemDescription().
{ if( !theInstance ) { theInstance = new ParameterMgr; } return theInstance; }
Definition at line 122 of file ParameterMgr.cc.
References mergeVDriftHistosByStation::name, and theParameters.
Referenced by Measurement::fillData(), Entry::fillFromInputFileSigma(), Entry::fillFromInputFileValue(), Model::getParameterValue(), and getVal().
{ //- std::cout << " ParameterMgr::getParameterValu " << name << " " << std::endl; //---------- Convert negative parameters ALIstring namet = name; ALIint negpar = 1; if( namet[0] == '-' ) { negpar = -1; namet = namet.substr(1, namet.length() ); } //---------- Find Parameter by name msd::iterator ite = theParameters.find( namet ); if( ite == theParameters.end() ) { /* msd::iterator ite2 = theParameters.find( name ); for( ite2 = theParameters.begin(); ite2 != theParameters.end(); ite2++ ) { std::cout << "PARAMETER: " << (*ite2).first << " = " << (*ite2).second << std::endl; } */ return 0; } else { val = (*ite).second * negpar; //- std::cout << "PARAMETER: " << val << " name " << name << std::endl; return 1; } }
Definition at line 31 of file ParameterMgr.cc.
References benchmark_cfg::cerr, getParameterValue(), ALIUnitDefinition::GetValueOf(), and ALIUtils::IsNumber().
Referenced by addParameter(), addRandomFlatParameter(), and addRandomGaussParameter().
{ //If there is a '*', the characters after '*' are the unit ALIint iast = str.find('*'); // ALIdouble vl; if( iast != -1 ) { ALIstring valstr = str.substr( 0, iast ); ALIstring unitstr = str.substr(iast+1, str.length() ); //- std::cout << iast << "parametermgr " << str << " " << valstr << " " << unitstr << std::endl; if( !ALIUtils::IsNumber( valstr ) ) { std::cerr << " ParameterMgr::getVal of an ALIstring that is not a number: " << valstr << std::endl; abort(); } //- std::cout << " getVal " << atof( valstr.c_str() ) << " * " << ALIUnitDefinition::GetValueOf(unitstr) << std::endl; return atof( valstr.c_str() ) * ALIUnitDefinition::GetValueOf(unitstr); } else { //If there is not a '*', use the dimensionFactor if( !ALIUtils::IsNumber( str ) ) { //--- Check if it is referring to a previous parameter. ALIdouble val; if( getParameterValue( str, val ) ) { return val; } else { std::cerr << " ParameterMgr::getVal of an string that is not a number nor a previous parameter: " << str << std::endl; abort(); } } //- std::cout << "ParameterMgr::getVal " << atof( str.c_str() ) << " * " << dimensionFactor << std::endl; return atof( str.c_str() ) * dimensionFactor; } }
void ParameterMgr::setRandomSeed | ( | const long | seed | ) |
Definition at line 80 of file ParameterMgr.cc.
Referenced by Model::readSystemDescription().
{ CLHEP::HepRandom::setTheSeed( seed ); }
ParameterMgr * ParameterMgr::theInstance = 0 [static, private] |
Definition at line 34 of file ParameterMgr.h.
Referenced by getInstance().
msd ParameterMgr::theParameters [private] |
Definition at line 36 of file ParameterMgr.h.
Referenced by addParameter(), addRandomFlatParameter(), addRandomGaussParameter(), and getParameterValue().