CMS 3D CMS Logo

ParameterMgr Class Reference

#include <Alignment/CocoaModel/interface/ParameterMgr.h>

List of all members.

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 (  )  [inline, private]

Definition at line 18 of file ParameterMgr.h.

00018 {};


Member Function Documentation

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

Definition at line 68 of file ParameterMgr.cc.

References TestMuL1L2Filter_cff::cerr, ALIUtils::debug, lat::endl(), getVal(), and theParameters.

Referenced by Model::readSystemDescription().

00069 {
00070   if( theParameters.find( name ) != theParameters.end() ) {
00071     if( ALIUtils::debug >= 1) std::cerr << "!! WARNING: PARAMETER " << name << " appears twice, it will take first value " << std::endl;
00072   } else {
00073     theParameters[name] = getVal( valstr );
00074   }
00075 
00076 }

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

Definition at line 102 of file ParameterMgr.cc.

References TestMuL1L2Filter_cff::cerr, GenMuonPlsPt100GeV_cfg::cout, ALIUtils::debug, lat::endl(), getVal(), mean(), and theParameters.

Referenced by Model::readSystemDescription().

00103 {
00104   if( theParameters.find( name ) != theParameters.end() ) {
00105     if( ALIUtils::debug >= 1) std::cerr << "!! WARNING: PARAMETER " << name << " appears twice, it will take first value " << std::endl;
00106   } else {
00107     ALIdouble mean = getVal( valMean );
00108     ALIdouble interval = getVal( valInterval );
00109     ALIdouble val = HepRandom::getTheEngine()->flat();
00110     // flat between ]mean-interval, mean+interval[
00111     val = val * 2*interval + mean-interval;
00112     theParameters[name] = val;
00113     if( ALIUtils::debug >= 2 )std::cout << " addRandomFlatParameter " << name << " " << valMean << " " << valInterval << " = " << val << std::endl;
00114   }
00115 
00116 }

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

Definition at line 86 of file ParameterMgr.cc.

References TestMuL1L2Filter_cff::cerr, GenMuonPlsPt100GeV_cfg::cout, ALIUtils::debug, lat::endl(), getVal(), mean(), and theParameters.

Referenced by Model::readSystemDescription().

00087 {
00088   if( theParameters.find( name ) != theParameters.end() ) {
00089     if( ALIUtils::debug >= 1) std::cerr << "!! WARNING: PARAMETER " << name << " appears twice, it will take first value " << std::endl;
00090   } else {
00091     ALIdouble mean = getVal( valMean );
00092     ALIdouble stddev = getVal( valStdDev );
00093     ALIdouble val = RandGauss::shoot( mean, stddev );
00094     theParameters[name] = val;
00095     if( ALIUtils::debug >= -2 ) std::cout << " addRandomGaussParameter "  << name << " " << valMean << " " << valStdDev << " = " << val << std::endl;
00096   }
00097 
00098 }

ParameterMgr * ParameterMgr::getInstance (  )  [static]

Definition at line 18 of file ParameterMgr.cc.

References theInstance.

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

00019 {
00020   if( !theInstance ) {
00021     theInstance = new ParameterMgr;
00022   }
00023 
00024   return theInstance;
00025 
00026 }

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

Definition at line 121 of file ParameterMgr.cc.

References theParameters.

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

00122 {
00123   //-  std::cout << " ParameterMgr::getParameterValu " << name << " " << std::endl;
00124   //---------- Convert negative parameters
00125   ALIstring namet = name;
00126   ALIint negpar = 1;
00127   if( namet[0] == '-' ) {
00128     negpar = -1;
00129     namet = namet.substr(1, namet.length() );
00130   }
00131 
00132   //---------- Find Parameter by name
00133   msd::iterator ite = theParameters.find( namet );
00134   if( ite == theParameters.end() ) {
00135     /*    msd::iterator ite2 = theParameters.find( name );
00136     for( ite2 = theParameters.begin(); ite2 != theParameters.end(); ite2++ ) {
00137       std::cout << "PARAMETER: " << (*ite2).first << " = " << (*ite2).second << std::endl;
00138     }
00139     */
00140     return 0;
00141   } else {
00142     val = (*ite).second * negpar;
00143     //-    std::cout << "PARAMETER: " << val << " name " << name << std::endl; 
00144     return 1;
00145   }
00146 
00147 }

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

Definition at line 30 of file ParameterMgr.cc.

References TestMuL1L2Filter_cff::cerr, lat::endl(), getParameterValue(), ALIUnitDefinition::GetValueOf(), and ALIUtils::IsNumber().

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

00031 {
00032   //If there is a '*', the characters after '*' are the unit
00033   ALIint iast =  str.find('*');
00034   //  ALIdouble vl;
00035   if( iast != -1 ) {
00036     ALIstring valstr = str.substr( 0, iast );
00037     ALIstring unitstr = str.substr(iast+1, str.length() );
00038 
00039     //-    std::cout << iast << "parametermgr " << str << " " << valstr << " " << unitstr << std::endl;
00040     if( !ALIUtils::IsNumber( valstr ) ) {
00041       std::cerr << " ParameterMgr::getVal of an ALIstring that is not a number: " << valstr << std::endl;
00042       abort();
00043     }
00044  
00045     //-    std::cout << " getVal " <<  atof( valstr.c_str() ) << " * " << ALIUnitDefinition::GetValueOf(unitstr) << std::endl;
00046     return atof( valstr.c_str() ) * ALIUnitDefinition::GetValueOf(unitstr);
00047   } else {
00048   //If there is not a '*', use the dimensionFactor 
00049     if( !ALIUtils::IsNumber( str ) ) {
00050       //--- Check if it is referring to a previous parameter.
00051       ALIdouble val;
00052       if( getParameterValue( str, val ) ) {
00053         return val;
00054       } else {
00055         std::cerr << " ParameterMgr::getVal of an string that is not a number nor a previous parameter: " << str << std::endl;
00056         abort();
00057       }
00058     }
00059 
00060 
00061     //-    std::cout << "ParameterMgr::getVal " << atof( str.c_str() ) << " * " << dimensionFactor << std::endl;
00062     return atof( str.c_str() ) * dimensionFactor;
00063   }
00064 }

void ParameterMgr::setRandomSeed ( const long  seed  ) 

Definition at line 79 of file ParameterMgr.cc.

Referenced by Model::readSystemDescription().

00080 {
00081   HepRandom::setTheSeed( seed );
00082 }


Member Data Documentation

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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:29:27 2009 for CMSSW by  doxygen 1.5.4