CMS 3D CMS Logo

Public Member Functions | Private Member Functions

SiStripApvGainGenerator Class Reference

#include <SiStripApvGainGenerator.h>

Inheritance diagram for SiStripApvGainGenerator:
SiStripCondObjBuilderBase< SiStripApvGain >

List of all members.

Public Member Functions

void getObj (SiStripApvGain *&obj)
 SiStripApvGainGenerator (const edm::ParameterSet &, const edm::ActivityRegistry &)
 ~SiStripApvGainGenerator ()

Private Member Functions

void createObject ()

Detailed Description

Two ways to generate the gain:

Definition at line 16 of file SiStripApvGainGenerator.h.


Constructor & Destructor Documentation

SiStripApvGainGenerator::SiStripApvGainGenerator ( const edm::ParameterSet iConfig,
const edm::ActivityRegistry aReg 
) [explicit]

Definition at line 10 of file SiStripApvGainGenerator.cc.

                                                                                                              :
  SiStripCondObjBuilderBase<SiStripApvGain>::SiStripCondObjBuilderBase(iConfig)
{
  edm::LogInfo("SiStripApvGainGenerator") <<  "[SiStripApvGainGenerator::SiStripApvGainGenerator]";
}
SiStripApvGainGenerator::~SiStripApvGainGenerator ( )

Definition at line 16 of file SiStripApvGainGenerator.cc.

                                                  { 
  edm::LogInfo("SiStripApvGainGenerator") <<  "[SiStripApvGainGenerator::~SiStripApvGainGenerator]";
}

Member Function Documentation

void SiStripApvGainGenerator::createObject ( ) [private]

Definition at line 20 of file SiStripApvGainGenerator.cc.

References SiStripCondObjBuilderBase< SiStripApvGain >::_pset, prof2calltree::count, cmsRelvalreport::exit, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), j, LogDebug, SiStripCondObjBuilderBase< SiStripApvGain >::obj_, SiStripApvGain::put(), and matplotRender::reader.

Referenced by getObj().

                                          {
    
  obj_ = new SiStripApvGain();

  std::string genMode = _pset.getParameter<std::string>("genMode");

  double meanGain_=_pset.getParameter<double>("MeanGain");
  double sigmaGain_=_pset.getParameter<double>("SigmaGain");
  double minimumPosValue_=_pset.getParameter<double>("MinPositiveGain");

  edm::FileInPath fp_ = _pset.getParameter<edm::FileInPath>("file");
  uint32_t  printdebug_ = _pset.getUntrackedParameter<uint32_t>("printDebug", 5);
  uint32_t count=0;

  SiStripDetInfoFileReader reader(fp_.fullPath());

  const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo > DetInfos  = reader.getAllData();
  float gainValue;
  for(std::map<uint32_t, SiStripDetInfoFileReader::DetInfo >::const_iterator it = DetInfos.begin(); it != DetInfos.end(); it++){    
  
    std::vector<float> theSiStripVector;
    for(unsigned short j=0; j<it->second.nApvs; j++){
  
      if(genMode=="default")
        gainValue=meanGain_;
      else if (genMode=="gaussian") {
        gainValue = CLHEP::RandGauss::shoot(meanGain_, sigmaGain_);
        if(gainValue<=minimumPosValue_) gainValue=minimumPosValue_;
      }
      else {
        LogDebug("SiStripApvGain") << "ERROR: wrong genMode specifier : " << genMode << ", please select one of \"default\" or \"gaussian\"" << std::endl;
        exit(1);
      }
        
      if (count<printdebug_) {
        edm::LogInfo("SiStripApvGainGenerator") << "detid: " << it->first  << " Apv: " << j <<  " gain: " << gainValue  << std::endl;       
      }
      theSiStripVector.push_back(gainValue);
    }
    count++;
    SiStripApvGain::Range range(theSiStripVector.begin(),theSiStripVector.end());
    if ( ! obj_->put(it->first,range) )
      edm::LogError("SiStripApvGainGenerator")<<" detid already exists"<<std::endl;
  }
}
void SiStripApvGainGenerator::getObj ( SiStripApvGain *&  obj) [inline, virtual]

Returns the CondObj

Reimplemented from SiStripCondObjBuilderBase< SiStripApvGain >.

Definition at line 22 of file SiStripApvGainGenerator.h.

References createObject(), and SiStripCondObjBuilderBase< SiStripApvGain >::obj_.

{createObject(); obj=obj_;}