CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
ParameterMgr Class Reference

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

Private Member Functions

 ParameterMgr ()
 

Private Attributes

msd theParameters
 

Static Private Attributes

static ParameterMgrtheInstance = nullptr
 

Detailed Description

Definition at line 15 of file ParameterMgr.h.

Constructor & Destructor Documentation

◆ ParameterMgr()

ParameterMgr::ParameterMgr ( )
inlineprivate

Definition at line 17 of file ParameterMgr.h.

17 {};

Referenced by getInstance().

Member Function Documentation

◆ addParameter()

void ParameterMgr::addParameter ( const ALIstring name,
const ALIstring valstr 
)

◆ addRandomFlatParameter()

void ParameterMgr::addRandomFlatParameter ( const ALIstring name,
const ALIstring valMean,
const ALIstring valInterval 
)

Definition at line 93 of file ParameterMgr.cc.

95  {
96  if (theParameters.find(name) != theParameters.end()) {
97  if (ALIUtils::debug >= 1)
98  std::cerr << "!! WARNING: PARAMETER " << name << " appears twice, it will take first value " << std::endl;
99  } else {
100  ALIdouble mean = getVal(valMean);
101  ALIdouble interval = getVal(valInterval);
102  ALIdouble val = CLHEP::HepRandom::getTheEngine()->flat();
103  // flat between ]mean-interval, mean+interval[
104  val = val * 2 * interval + mean - interval;
106  if (ALIUtils::debug >= 2)
107  std::cout << " addRandomFlatParameter " << name << " " << valMean << " " << valInterval << " = " << val
108  << std::endl;
109  }
110 }

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, gather_cfg::cout, ALIUtils::debug, getVal(), readEcalDQMStatus::interval, SiStripPI::mean, Skims_PA_cff::name, theParameters, and heppy_batch::val.

Referenced by Model::readSystemDescription().

◆ addRandomGaussParameter()

void ParameterMgr::addRandomGaussParameter ( const ALIstring name,
const ALIstring valMean,
const ALIstring valStdDev 
)

Definition at line 75 of file ParameterMgr.cc.

77  {
78  if (theParameters.find(name) != theParameters.end()) {
79  if (ALIUtils::debug >= 1)
80  std::cerr << "!! WARNING: PARAMETER " << name << " appears twice, it will take first value " << std::endl;
81  } else {
82  ALIdouble mean = getVal(valMean);
83  ALIdouble stddev = getVal(valStdDev);
84  ALIdouble val = CLHEP::RandGauss::shoot(mean, stddev);
86  if (ALIUtils::debug >= -2)
87  std::cout << " addRandomGaussParameter " << name << " " << valMean << " " << valStdDev << " = " << val
88  << std::endl;
89  }
90 }

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, gather_cfg::cout, ALIUtils::debug, getVal(), SiStripPI::mean, Skims_PA_cff::name, theParameters, and heppy_batch::val.

Referenced by Model::readSystemDescription().

◆ getInstance()

ParameterMgr * ParameterMgr::getInstance ( )
static

◆ getParameterValue()

ALIint ParameterMgr::getParameterValue ( const ALIstring name,
ALIdouble val 
)

Definition at line 114 of file ParameterMgr.cc.

114  {
115  //- std::cout << " ParameterMgr::getParameterValu " << name << " " << std::endl;
116  //---------- Convert negative parameters
117  ALIstring namet = name;
118  ALIint negpar = 1;
119  if (namet[0] == '-') {
120  negpar = -1;
121  namet = namet.substr(1, namet.length());
122  }
123 
124  //---------- Find Parameter by name
125  msd::iterator ite = theParameters.find(namet);
126  if (ite == theParameters.end()) {
127  /* msd::iterator ite2 = theParameters.find( name );
128  for( ite2 = theParameters.begin(); ite2 != theParameters.end(); ite2++ ) {
129  std::cout << "PARAMETER: " << (*ite2).first << " = " << (*ite2).second << std::endl;
130  }
131  */
132  return 0;
133  } else {
134  val = (*ite).second * negpar;
135  //- std::cout << "PARAMETER: " << val << " name " << name << std::endl;
136  return 1;
137  }
138 }

References Skims_PA_cff::name, theParameters, and heppy_batch::val.

Referenced by Measurement::fillData(), Entry::fillFromInputFileSigma(), Entry::fillFromInputFileValue(), Model::getParameterValue(), and getVal().

◆ getVal()

ALIdouble ParameterMgr::getVal ( const ALIstring str,
const ALIdouble  dimensionFactor = 1. 
)

Definition at line 27 of file ParameterMgr.cc.

27  {
28  //If there is a '*', the characters after '*' are the unit
29  ALIint iast = str.find('*');
30  // ALIdouble vl;
31  if (iast != -1) {
32  ALIstring valstr = str.substr(0, iast);
33  ALIstring unitstr = str.substr(iast + 1, str.length());
34 
35  //- std::cout << iast << "parametermgr " << str << " " << valstr << " " << unitstr << std::endl;
36  if (!ALIUtils::IsNumber(valstr)) {
37  std::cerr << " ParameterMgr::getVal of an ALIstring that is not a number: " << valstr << std::endl;
38  abort();
39  }
40 
41  //- std::cout << " getVal " << atof( valstr.c_str() ) << " * " << ALIUnitDefinition::GetValueOf(unitstr) << std::endl;
42  return atof(valstr.c_str()) * ALIUnitDefinition::GetValueOf(unitstr);
43  } else {
44  //If there is not a '*', use the dimensionFactor
45  if (!ALIUtils::IsNumber(str)) {
46  //--- Check if it is referring to a previous parameter.
47  ALIdouble val;
48  if (getParameterValue(str, val)) {
49  return val;
50  } else {
51  std::cerr << " ParameterMgr::getVal of an string that is not a number nor a previous parameter: " << str
52  << std::endl;
53  abort();
54  }
55  }
56 
57  //- std::cout << "ParameterMgr::getVal " << atof( str.c_str() ) << " * " << dimensionFactor << std::endl;
58  return atof(str.c_str()) * dimensionFactor;
59  }
60 }

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, getParameterValue(), ALIUnitDefinition::GetValueOf(), ALIUtils::IsNumber(), str, and heppy_batch::val.

Referenced by addParameter(), addRandomFlatParameter(), and addRandomGaussParameter().

◆ setRandomSeed()

void ParameterMgr::setRandomSeed ( const long  seed)

Definition at line 72 of file ParameterMgr.cc.

72 { CLHEP::HepRandom::setTheSeed(seed); }

References fileCollector::seed.

Referenced by Model::readSystemDescription().

Member Data Documentation

◆ theInstance

ParameterMgr * ParameterMgr::theInstance = nullptr
staticprivate

Definition at line 32 of file ParameterMgr.h.

Referenced by getInstance().

◆ theParameters

msd ParameterMgr::theParameters
private
ParameterMgr::getVal
ALIdouble getVal(const ALIstring &str, const ALIdouble dimensionFactor=1.)
Definition: ParameterMgr.cc:27
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
ParameterMgr::theParameters
msd theParameters
Definition: ParameterMgr.h:34
gather_cfg.cout
cout
Definition: gather_cfg.py:144
ALIstring
std::string ALIstring
Definition: CocoaGlobals.h:9
ParameterMgr::getParameterValue
ALIint getParameterValue(const ALIstring &name, ALIdouble &val)
Definition: ParameterMgr.cc:114
ALIUtils::IsNumber
static int IsNumber(const ALIstring &str)
Definition: ALIUtils.cc:33
ParameterMgr::theInstance
static ParameterMgr * theInstance
Definition: ParameterMgr.h:32
fileCollector.seed
seed
Definition: fileCollector.py:127
ALIUtils::debug
static ALIint debug
Definition: ALIUtils.h:34
str
#define str(s)
Definition: TestProcessor.cc:53
ALIdouble
long double ALIdouble
Definition: CocoaGlobals.h:11
readEcalDQMStatus.interval
interval
Definition: readEcalDQMStatus.py:18
ALIUnitDefinition::GetValueOf
static ALIdouble GetValueOf(ALIstring)
Definition: ALIUnitsTable.cc:65
heppy_batch.val
val
Definition: heppy_batch.py:351
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
ALIint
int ALIint
Definition: CocoaGlobals.h:15
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
ParameterMgr::ParameterMgr
ParameterMgr()
Definition: ParameterMgr.h:17