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 ( )
inlineprivate

Member Function Documentation

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

Definition at line 63 of file ParameterMgr.cc.

References beam_dqm_sourceclient-live_cfg::cerr, ALIUtils::debug, getVal(), Skims_PA_cff::name, and theParameters.

Referenced by editorTools.UserCodeTool::__init__(), trackTools.MakeAODTrackCandidates::__init__(), metTools.AddMETCollection::__init__(), HiCoreTools.RestrictInputToAOD::__init__(), coreTools.RunOnData::__init__(), runJetUncertainties.RunJetUncertainties::__init__(), runMETCorrectionsAndUncertainties.RunMETCorrectionsAndUncertainties::__init__(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool::__init__(), editorTools.ChangeSource::__init__(), cmsswVersionTools.PickRelValInputFiles::__init__(), HiCoreTools.RemoveMCMatching::__init__(), coreTools.RemoveMCMatching::__init__(), trackTools.MakePATTrackCandidates::__init__(), trigTools.SwitchOnTrigger::__init__(), HiCoreTools.RemoveAllPATObjectsBut::__init__(), HiCoreTools.RemoveSpecificPATObjects::__init__(), trigTools.SwitchOnTriggerStandAlone::__init__(), tauTools.AddTauCollection::__init__(), trackTools.MakeTrackCandidates::__init__(), trigTools.SwitchOnTriggerMatching::__init__(), HiCoreTools.RemoveCleaning::__init__(), HiCoreTools.AddCleaning::__init__(), trigTools.SwitchOnTriggerMatchingStandAlone::__init__(), trigTools.SwitchOnTriggerMatchEmbedding::__init__(), jetTools.AddJetCollection::__init__(), jetTools.SwitchJetCollection::__init__(), jetTools.UpdateJetCollection::__init__(), jetTools.AddJetID::__init__(), jetTools.SetTagInfos::__init__(), ParameterMgr(), and Model::readSystemDescription().

63  {
64  if (theParameters.find(name) != theParameters.end()) {
65  if (ALIUtils::debug >= 1)
66  std::cerr << "!! WARNING: PARAMETER " << name << " appears twice, it will take first value " << std::endl;
67  } else {
68  theParameters[name] = getVal(valstr);
69  }
70 }
static ALIint debug
Definition: ALIUtils.h:34
ALIdouble getVal(const ALIstring &str, const ALIdouble dimensionFactor=1.)
Definition: ParameterMgr.cc:27
void ParameterMgr::addRandomFlatParameter ( const ALIstring name,
const ALIstring valMean,
const ALIstring valInterval 
)

Definition at line 93 of file ParameterMgr.cc.

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

Referenced by ParameterMgr(), and Model::readSystemDescription().

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 }
long double ALIdouble
Definition: CocoaGlobals.h:11
static ALIint debug
Definition: ALIUtils.h:34
ALIdouble getVal(const ALIstring &str, const ALIdouble dimensionFactor=1.)
Definition: ParameterMgr.cc:27
void ParameterMgr::addRandomGaussParameter ( const ALIstring name,
const ALIstring valMean,
const ALIstring valStdDev 
)

Definition at line 75 of file ParameterMgr.cc.

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

Referenced by ParameterMgr(), and Model::readSystemDescription().

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 }
long double ALIdouble
Definition: CocoaGlobals.h:11
static ALIint debug
Definition: ALIUtils.h:34
ALIdouble getVal(const ALIstring &str, const ALIdouble dimensionFactor=1.)
Definition: ParameterMgr.cc:27
ParameterMgr * ParameterMgr::getInstance ( )
static

Definition at line 18 of file ParameterMgr.cc.

References ParameterMgr(), and theInstance.

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

18  {
19  if (!theInstance) {
21  }
22 
23  return theInstance;
24 }
static ParameterMgr * theInstance
Definition: ParameterMgr.h:32
ALIint ParameterMgr::getParameterValue ( const ALIstring name,
ALIdouble val 
)

Definition at line 114 of file ParameterMgr.cc.

References Skims_PA_cff::name, and theParameters.

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

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 }
int ALIint
Definition: CocoaGlobals.h:15
std::string ALIstring
Definition: CocoaGlobals.h:9
ALIdouble ParameterMgr::getVal ( const ALIstring str,
const ALIdouble  dimensionFactor = 1. 
)

Definition at line 27 of file ParameterMgr.cc.

References beam_dqm_sourceclient-live_cfg::cerr, getParameterValue(), ALIUnitDefinition::GetValueOf(), ALIUtils::IsNumber(), and heppy_batch::val.

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

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 }
long double ALIdouble
Definition: CocoaGlobals.h:11
int ALIint
Definition: CocoaGlobals.h:15
ALIint getParameterValue(const ALIstring &name, ALIdouble &val)
static int IsNumber(const ALIstring &str)
Definition: ALIUtils.cc:33
static ALIdouble GetValueOf(ALIstring)
std::string ALIstring
Definition: CocoaGlobals.h:9
#define str(s)
void ParameterMgr::setRandomSeed ( const long  seed)

Definition at line 72 of file ParameterMgr.cc.

Referenced by ParameterMgr(), and Model::readSystemDescription().

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

Member Data Documentation

ParameterMgr * ParameterMgr::theInstance = nullptr
staticprivate

Definition at line 32 of file ParameterMgr.h.

Referenced by getInstance().

msd ParameterMgr::theParameters
private