CMS 3D CMS Logo

SiStripGainESProducer Class Reference

Description: <one line="" class="" summary>="">. More...

#include <CalibTracker/SiStripESProducer/plugins/real/SiStripGainESProducer.cc>

Inheritance diagram for SiStripGainESProducer:

edm::ESProducer edm::ESProxyFactoryProducer edm::eventsetup::DataProxyProvider

List of all members.

Public Member Functions

std::auto_ptr< SiStripGainproduce (const SiStripGainRcd &)
 SiStripGainESProducer (const edm::ParameterSet &iConfig)
 ~SiStripGainESProducer ()

Private Attributes

std::string apvgain_
bool automaticMode_
double norm_
bool printdebug_


Detailed Description

Description: <one line="" class="" summary>="">.

Implementation: <Notes on="" implementation>="">

Definition at line 40 of file SiStripGainESProducer.h.


Constructor & Destructor Documentation

SiStripGainESProducer::SiStripGainESProducer ( const edm::ParameterSet iConfig  ) 

Definition at line 32 of file SiStripGainESProducer.cc.

References apvgain_, automaticMode_, lat::endl(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), norm_, printdebug_, and edm::ESProducer::setWhatProduced().

00032                                                                           {
00033 
00034   //the following line is needed to tell the framework what
00035   // data is being produced
00036   setWhatProduced(this);
00037   
00038   //now do what ever other initialization is needed
00039   automaticMode_ = iConfig.getParameter<bool>("AutomaticNormalization");
00040   norm_=iConfig.getParameter<double>("NormalizationFactor");
00041   printdebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
00042   apvgain_ = iConfig.getParameter<std::string>("APVGain");
00043 
00044   if(!automaticMode_ && norm_<=0){
00045     edm::LogError("SiStripGainESProducer::SiStripGainESProducer() - ERROR: negative or zero Normalization factor provided. Assuming 1 for such factor") << std::endl;
00046     norm_=1.;
00047   }
00048 
00049 }

SiStripGainESProducer::~SiStripGainESProducer (  ) 

Definition at line 52 of file SiStripGainESProducer.cc.

00053 {
00054  
00055    // do anything here that needs to be done at desctruction time
00056    // (e.g. close files, deallocate resources etc.)
00057 
00058 }


Member Function Documentation

std::auto_ptr< SiStripGain > SiStripGainESProducer::produce ( const SiStripGainRcd iRecord  ) 

Definition at line 66 of file SiStripGainESProducer.cc.

References apvgain_, automaticMode_, lat::endl(), edm::eventsetup::DependentRecordImplementation< RecordT, ListT >::getRecord(), norm_, printdebug_, and edm::ESHandle< T >::product().

00067 {
00068    using namespace edm::es;
00069    edm::ESHandle<SiStripApvGain> pDD;
00070    iRecord.getRecord<SiStripApvGainRcd>().get(apvgain_,pDD );
00071    
00072    double NFactor;
00073 
00074    if(automaticMode_ || printdebug_ ){
00075 
00076      std::vector<uint32_t> DetIds;
00077      pDD->getDetIds(DetIds);
00078 
00079      double SumOfGains=0;
00080      int NGains=0;
00081 
00082      for(std::vector<uint32_t>::const_iterator detit=DetIds.begin(); detit!=DetIds.end(); detit++){
00083 
00084        SiStripApvGain::Range detRange = pDD->getRange(*detit);
00085 
00086        int iComp=0;
00087 
00088        for(std::vector<float>::const_iterator apvit=detRange.first; apvit!=detRange.second; apvit++){
00089 
00090          SumOfGains+=(*apvit);
00091          NGains++;
00092          if (printdebug_)
00093            edm::LogInfo("SiStripGainESProducer::produce()")<< "detid/component: " << *detit <<"/"<<iComp<< "   gain factor " <<*apvit ;
00094          iComp++;
00095 
00096 
00097        }
00098 
00099      }
00100 
00101      if(automaticMode_){
00102        if(SumOfGains>0 && NGains>0){
00103          NFactor=SumOfGains/NGains;
00104        }
00105        else{
00106          edm::LogError("SiStripGainESProducer::produce() - ERROR: empty set of gain values received. Cannot compute normalization factor. Assuming 1 for such factor") << std::endl;
00107          NFactor=1.;
00108        }
00109      }
00110 
00111 
00112    }
00113 
00114    if(!automaticMode_){
00115      NFactor=norm_;
00116    }
00117 
00118 
00119    if (printdebug_)  edm::LogInfo("SiStripGainESProducer::produce()")<< "putting A SiStrip Gain object in eventSetup with normalization factor " << NFactor ;
00120 
00121    SiStripGain * gain = new SiStripGain( *(pDD.product()), NFactor);
00122    return std::auto_ptr<SiStripGain>(gain );
00123 
00124 }


Member Data Documentation

std::string SiStripGainESProducer::apvgain_ [private]

Definition at line 54 of file SiStripGainESProducer.h.

Referenced by produce(), and SiStripGainESProducer().

bool SiStripGainESProducer::automaticMode_ [private]

Definition at line 56 of file SiStripGainESProducer.h.

Referenced by produce(), and SiStripGainESProducer().

double SiStripGainESProducer::norm_ [private]

Definition at line 55 of file SiStripGainESProducer.h.

Referenced by produce(), and SiStripGainESProducer().

bool SiStripGainESProducer::printdebug_ [private]

Definition at line 57 of file SiStripGainESProducer.h.

Referenced by produce(), and SiStripGainESProducer().


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