CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 = 0
 

Detailed Description

Definition at line 15 of file ParameterMgr.h.

Constructor & Destructor Documentation

ParameterMgr::ParameterMgr ( )
inlineprivate

Definition at line 18 of file ParameterMgr.h.

Referenced by getInstance().

18 {};

Member Function Documentation

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

Definition at line 69 of file ParameterMgr.cc.

References dtNoiseDBValidation_cfg::cerr, ALIUtils::debug, getVal(), mergeVDriftHistosByStation::name, and theParameters.

Referenced by editorTools.UserCodeTool::__init__(), metTools.AddMETCollection::__init__(), trackTools.MakeAODTrackCandidates::__init__(), coreTools.RunOnData::__init__(), HiCoreTools.RestrictInputToAOD::__init__(), runJetUncertainties.RunJetUncertainties::__init__(), runType1CaloMEtUncertainties.RunType1CaloMEtUncertainties::__init__(), jmeUncertaintyTools.JetMEtUncertaintyTools::__init__(), runNoPileUpMEtUncertainties.RunNoPileUpMEtUncertainties::__init__(), runMVAMEtUncertainties.RunMVAMEtUncertainties::__init__(), runType1PFMEtUncertainties.RunType1PFMEtUncertainties::__init__(), Vispa.Plugins.ConfigEditor.ToolDataAccessor.ImportTool::__init__(), jetTools.AddJetCollection::__init__(), editorTools.ChangeSource::__init__(), HiCoreTools.RemoveMCMatching::__init__(), cmsswVersionTools.PickRelValInputFiles::__init__(), coreTools.RemoveMCMatching::__init__(), trackTools.MakePATTrackCandidates::__init__(), trigTools.SwitchOnTrigger::__init__(), HiCoreTools.RemoveAllPATObjectsBut::__init__(), HiCoreTools.RemoveSpecificPATObjects::__init__(), trigTools.SwitchOnTriggerStandAlone::__init__(), trackTools.MakeTrackCandidates::__init__(), tauTools.AddTauCollection::__init__(), trigTools.SwitchOnTriggerMatching::__init__(), HiCoreTools.RemoveCleaning::__init__(), HiCoreTools.AddCleaning::__init__(), trigTools.SwitchOnTriggerMatchingStandAlone::__init__(), trigTools.SwitchOnTriggerMatchEmbedding::__init__(), jetTools.SwitchJetCollection::__init__(), jetTools.AddJetID::__init__(), jetTools.SetTagInfos::__init__(), and Model::readSystemDescription().

70 {
71  if( theParameters.find( name ) != theParameters.end() ) {
72  if( ALIUtils::debug >= 1) std::cerr << "!! WARNING: PARAMETER " << name << " appears twice, it will take first value " << std::endl;
73  } else {
74  theParameters[name] = getVal( valstr );
75  }
76 
77 }
static ALIint debug
Definition: ALIUtils.h:35
ALIdouble getVal(const ALIstring &str, const ALIdouble dimensionFactor=1.)
Definition: ParameterMgr.cc:31
void ParameterMgr::addRandomFlatParameter ( const ALIstring name,
const ALIstring valMean,
const ALIstring valInterval 
)

Definition at line 103 of file ParameterMgr.cc.

References dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, ALIUtils::debug, getVal(), MergeJob_cfg::interval, timingPdfMaker::mean, mergeVDriftHistosByStation::name, and theParameters.

Referenced by Model::readSystemDescription().

104 {
105  if( theParameters.find( name ) != theParameters.end() ) {
106  if( ALIUtils::debug >= 1) std::cerr << "!! WARNING: PARAMETER " << name << " appears twice, it will take first value " << std::endl;
107  } else {
108  ALIdouble mean = getVal( valMean );
109  ALIdouble interval = getVal( valInterval );
110  ALIdouble val = CLHEP::HepRandom::getTheEngine()->flat();
111  // flat between ]mean-interval, mean+interval[
112  val = val * 2*interval + mean-interval;
113  theParameters[name] = val;
114  if( ALIUtils::debug >= 2 )std::cout << " addRandomFlatParameter " << name << " " << valMean << " " << valInterval << " = " << val << std::endl;
115  }
116 
117 }
long double ALIdouble
Definition: CocoaGlobals.h:11
tuple interval
Definition: MergeJob_cfg.py:20
static ALIint debug
Definition: ALIUtils.h:35
tuple cout
Definition: gather_cfg.py:121
ALIdouble getVal(const ALIstring &str, const ALIdouble dimensionFactor=1.)
Definition: ParameterMgr.cc:31
void ParameterMgr::addRandomGaussParameter ( const ALIstring name,
const ALIstring valMean,
const ALIstring valStdDev 
)

Definition at line 87 of file ParameterMgr.cc.

References dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, ALIUtils::debug, getVal(), timingPdfMaker::mean, mergeVDriftHistosByStation::name, and theParameters.

Referenced by Model::readSystemDescription().

88 {
89  if( theParameters.find( name ) != theParameters.end() ) {
90  if( ALIUtils::debug >= 1) std::cerr << "!! WARNING: PARAMETER " << name << " appears twice, it will take first value " << std::endl;
91  } else {
92  ALIdouble mean = getVal( valMean );
93  ALIdouble stddev = getVal( valStdDev );
94  ALIdouble val = CLHEP::RandGauss::shoot( mean, stddev );
95  theParameters[name] = val;
96  if( ALIUtils::debug >= -2 ) std::cout << " addRandomGaussParameter " << name << " " << valMean << " " << valStdDev << " = " << val << std::endl;
97  }
98 
99 }
long double ALIdouble
Definition: CocoaGlobals.h:11
static ALIint debug
Definition: ALIUtils.h:35
tuple cout
Definition: gather_cfg.py:121
ALIdouble getVal(const ALIstring &str, const ALIdouble dimensionFactor=1.)
Definition: ParameterMgr.cc:31
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().

20 {
21  if( !theInstance ) {
23  }
24 
25  return theInstance;
26 
27 }
static ParameterMgr * theInstance
Definition: ParameterMgr.h:34
ALIint ParameterMgr::getParameterValue ( const ALIstring name,
ALIdouble val 
)

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

123 {
124  //- std::cout << " ParameterMgr::getParameterValu " << name << " " << std::endl;
125  //---------- Convert negative parameters
126  ALIstring namet = name;
127  ALIint negpar = 1;
128  if( namet[0] == '-' ) {
129  negpar = -1;
130  namet = namet.substr(1, namet.length() );
131  }
132 
133  //---------- Find Parameter by name
134  msd::iterator ite = theParameters.find( namet );
135  if( ite == theParameters.end() ) {
136  /* msd::iterator ite2 = theParameters.find( name );
137  for( ite2 = theParameters.begin(); ite2 != theParameters.end(); ite2++ ) {
138  std::cout << "PARAMETER: " << (*ite2).first << " = " << (*ite2).second << std::endl;
139  }
140  */
141  return 0;
142  } else {
143  val = (*ite).second * negpar;
144  //- std::cout << "PARAMETER: " << val << " name " << name << std::endl;
145  return 1;
146  }
147 
148 }
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 31 of file ParameterMgr.cc.

References dtNoiseDBValidation_cfg::cerr, getParameterValue(), ALIUnitDefinition::GetValueOf(), and ALIUtils::IsNumber().

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

32 {
33  //If there is a '*', the characters after '*' are the unit
34  ALIint iast = str.find('*');
35  // ALIdouble vl;
36  if( iast != -1 ) {
37  ALIstring valstr = str.substr( 0, iast );
38  ALIstring unitstr = str.substr(iast+1, str.length() );
39 
40  //- std::cout << iast << "parametermgr " << str << " " << valstr << " " << unitstr << std::endl;
41  if( !ALIUtils::IsNumber( valstr ) ) {
42  std::cerr << " ParameterMgr::getVal of an ALIstring that is not a number: " << valstr << std::endl;
43  abort();
44  }
45 
46  //- std::cout << " getVal " << atof( valstr.c_str() ) << " * " << ALIUnitDefinition::GetValueOf(unitstr) << std::endl;
47  return atof( valstr.c_str() ) * ALIUnitDefinition::GetValueOf(unitstr);
48  } else {
49  //If there is not a '*', use the dimensionFactor
50  if( !ALIUtils::IsNumber( str ) ) {
51  //--- Check if it is referring to a previous parameter.
52  ALIdouble val;
53  if( getParameterValue( str, val ) ) {
54  return val;
55  } else {
56  std::cerr << " ParameterMgr::getVal of an string that is not a number nor a previous parameter: " << str << std::endl;
57  abort();
58  }
59  }
60 
61 
62  //- std::cout << "ParameterMgr::getVal " << atof( str.c_str() ) << " * " << dimensionFactor << std::endl;
63  return atof( str.c_str() ) * dimensionFactor;
64  }
65 }
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:34
static ALIdouble GetValueOf(ALIstring)
std::string ALIstring
Definition: CocoaGlobals.h:9
void ParameterMgr::setRandomSeed ( const long  seed)

Definition at line 80 of file ParameterMgr.cc.

Referenced by Model::readSystemDescription().

81 {
82  CLHEP::HepRandom::setTheSeed( seed );
83 }

Member Data Documentation

ParameterMgr * ParameterMgr::theInstance = 0
staticprivate

Definition at line 34 of file ParameterMgr.h.

Referenced by getInstance().

msd ParameterMgr::theParameters
private