CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

ParameterMgr Class Reference

#include <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.

Referenced by getInstance().

{};

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 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 dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, ALIUtils::debug, getVal(), MergeJob_cfg::interval, timingPdfMaker::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 dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, ALIUtils::debug, getVal(), timingPdfMaker::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]
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().

{
  //-  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;
  }

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

{
  //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 );
}

Member Data Documentation

ParameterMgr * ParameterMgr::theInstance = 0 [static, private]

Definition at line 34 of file ParameterMgr.h.

Referenced by getInstance().