CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
SiStripGainRandomCalculator Class Reference

#include <SiStripGainRandomCalculator.h>

Inheritance diagram for SiStripGainRandomCalculator:
ConditionDBWriter< SiStripApvGain > edm::EDAnalyzer

Public Member Functions

 SiStripGainRandomCalculator (const edm::ParameterSet &)
 
 ~SiStripGainRandomCalculator ()
 
- Public Member Functions inherited from ConditionDBWriter< SiStripApvGain >
 ConditionDBWriter (const edm::ParameterSet &iConfig)
 
virtual ~ConditionDBWriter ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

void algoAnalyze (const edm::Event &, const edm::EventSetup &)
 
SiStripApvGaingetNewObject ()
 

Private Attributes

std::vector< std::pair
< uint32_t, unsigned short > > 
detid_apvs_
 
unsigned long long m_cacheID_
 
double meanGain_
 
double minimumPosValue_
 
bool printdebug_
 
double sigmaGain_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from ConditionDBWriter< SiStripApvGain >
void setDoStore (const bool doStore)
 When set to false the payload will not be written to the db. More...
 
void storeOnDbNow ()
 
cond::Time_t timeOfLastIOV ()
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 27 of file SiStripGainRandomCalculator.h.

Constructor & Destructor Documentation

SiStripGainRandomCalculator::SiStripGainRandomCalculator ( const edm::ParameterSet iConfig)
explicit

Definition at line 26 of file SiStripGainRandomCalculator.cc.

References detid_apvs_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), meanGain_, minimumPosValue_, printdebug_, and sigmaGain_.

27 
28 
29  edm::LogInfo("SiStripGainRandomCalculator::SiStripGainRandomCalculator");
30 
31 // std::string Mode=iConfig.getParameter<std::string>("Mode");
32 // if (Mode==std::string("Gaussian")) GaussianMode_=true;
33 // else if (IOVMode==std::string("Constant")) ConstantMode_=true;
34 // else edm::LogError("SiStripGainRandomCalculator::SiStripGainRandomCalculator(): ERROR - unknown generation mode...will not store anything on the DB") << std::endl;
35 
36  detid_apvs_.clear();
37 
38  meanGain_=iConfig.getParameter<double>("MeanGain");
39  sigmaGain_=iConfig.getParameter<double>("SigmaGain");
40  minimumPosValue_=iConfig.getParameter<double>("MinPositiveGain");
41  printdebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
42 
43 
44 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::pair< uint32_t, unsigned short > > detid_apvs_
SiStripGainRandomCalculator::~SiStripGainRandomCalculator ( )

Definition at line 47 of file SiStripGainRandomCalculator.cc.

47  {
48 
49  edm::LogInfo("SiStripGainRandomCalculator::~SiStripGainRandomCalculator");
50 }

Member Function Documentation

void SiStripGainRandomCalculator::algoAnalyze ( const edm::Event event,
const edm::EventSetup iSetup 
)
privatevirtual

Reimplemented from ConditionDBWriter< SiStripApvGain >.

Definition at line 54 of file SiStripGainRandomCalculator.cc.

References cond::rpcobgas::detid, detid_apvs_, cmsRelvalreport::exit, edm::EventSetup::get(), m_cacheID_, StripTopology::nstrips(), AlCaHLTBitMon_ParallelJobs::p, and printdebug_.

54  {
55 
56 
57  unsigned long long cacheID = iSetup.get<TrackerDigiGeometryRecord>().cacheIdentifier();
58 
59  if (m_cacheID_ != cacheID) {
60 
61  m_cacheID_ = cacheID;
62 
64 
65  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
66  edm::LogInfo("SiStripGainRandomCalculator::algoAnalyze - got new geometry ")<<std::endl;
67 
68  detid_apvs_.clear();
69 
70  edm::LogInfo("SiStripGainCalculator") <<" There are "<<pDD->detUnits().size() <<" detectors"<<std::endl;
71 
72  for(TrackerGeometry::DetUnitContainer::const_iterator it = pDD->detUnits().begin(); it != pDD->detUnits().end(); it++){
73 
74  if( dynamic_cast<StripGeomDetUnit*>((*it))!=0){
75  uint32_t detid=((*it)->geographicalId()).rawId();
76  const StripTopology& p = dynamic_cast<StripGeomDetUnit*>((*it))->specificTopology();
77  unsigned short NAPVs = p.nstrips()/128;
78  if(NAPVs<1 || NAPVs>6 ) {
79  edm::LogError("SiStripGainCalculator")<<" Problem with Number of strips in detector.. "<< p.nstrips() <<" Exiting program"<<endl;
80  exit(1);
81  }
82  detid_apvs_.push_back( pair<uint32_t,unsigned short>(detid,NAPVs) );
83  if (printdebug_)
84  edm::LogInfo("SiStripGainCalculator")<< "detid " << detid << " apvs " << NAPVs;
85  }
86  }
87  }
88 
89 
90 }
virtual int nstrips() const =0
const T & get() const
Definition: EventSetup.h:55
std::vector< std::pair< uint32_t, unsigned short > > detid_apvs_
SiStripApvGain * SiStripGainRandomCalculator::getNewObject ( )
privatevirtual

Implements ConditionDBWriter< SiStripApvGain >.

Definition at line 93 of file SiStripGainRandomCalculator.cc.

References gather_cfg::cout, detid_apvs_, j, meanGain_, minimumPosValue_, getGTfromDQMFile::obj, printdebug_, SiStripApvGain::put(), and sigmaGain_.

93  {
94 
95  std::cout<<"SiStripGainRandomCalculator::getNewObject called"<<std::endl;
96 
98 
99  for(std::vector< pair<uint32_t,unsigned short> >::const_iterator it = detid_apvs_.begin(); it != detid_apvs_.end(); it++){
100  //Generate Gain for det detid
101  std::vector<float> theSiStripVector;
102  for(unsigned short j=0; j<it->second; j++){
103  float gain;
104 
105  // if(sigmaGain_/meanGain_ < 0.00001) gain = meanGain_;
106  // else{
107  gain = CLHEP::RandGauss::shoot(meanGain_, sigmaGain_);
108  if(gain<=minimumPosValue_) gain=minimumPosValue_;
109  // }
110 
111  if (printdebug_)
112  edm::LogInfo("SiStripGainCalculator") << "detid " << it->first << " \t"
113  << " apv " << j << " \t"
114  << gain << " \t"
115  << std::endl;
116  theSiStripVector.push_back(gain);
117  }
118 
119 
120  SiStripApvGain::Range range(theSiStripVector.begin(),theSiStripVector.end());
121  if ( ! obj->put(it->first,range) )
122  edm::LogError("SiStripGainCalculator")<<"[SiStripGainCalculator::beginJob] detid already exists"<<std::endl;
123 
124  }
125 
126  return obj;
127 
128 }
bool put(const uint32_t &detID, Range input)
std::pair< ContainerIterator, ContainerIterator > Range
int j
Definition: DBlmapReader.cc:9
std::vector< std::pair< uint32_t, unsigned short > > detid_apvs_
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

std::vector< std::pair<uint32_t, unsigned short> > SiStripGainRandomCalculator::detid_apvs_
private
unsigned long long SiStripGainRandomCalculator::m_cacheID_
private

Definition at line 47 of file SiStripGainRandomCalculator.h.

Referenced by algoAnalyze().

double SiStripGainRandomCalculator::meanGain_
private

Definition at line 42 of file SiStripGainRandomCalculator.h.

Referenced by getNewObject(), and SiStripGainRandomCalculator().

double SiStripGainRandomCalculator::minimumPosValue_
private

Definition at line 44 of file SiStripGainRandomCalculator.h.

Referenced by getNewObject(), and SiStripGainRandomCalculator().

bool SiStripGainRandomCalculator::printdebug_
private
double SiStripGainRandomCalculator::sigmaGain_
private

Definition at line 43 of file SiStripGainRandomCalculator.h.

Referenced by getNewObject(), and SiStripGainRandomCalculator().