CMS 3D CMS Logo

SiStripGainRandomCalculator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Package: SiStripChannelGain
3 // Class: SiStripGainRandomCalculator
4 // Original Author: G. Bruno
5 // Created: Mon May 20 10:04:31 CET 2007
6 
11 
17 
18 #include "CLHEP/Random/RandGauss.h"
19 
20 
21 using namespace cms;
22 using namespace std;
23 
24 
26 
27 
28  edm::LogInfo("SiStripGainRandomCalculator::SiStripGainRandomCalculator");
29 
30 // std::string Mode=iConfig.getParameter<std::string>("Mode");
31 // if (Mode==std::string("Gaussian")) GaussianMode_=true;
32 // else if (IOVMode==std::string("Constant")) ConstantMode_=true;
33 // else edm::LogError("SiStripGainRandomCalculator::SiStripGainRandomCalculator(): ERROR - unknown generation mode...will not store anything on the DB") << std::endl;
34 
35  detid_apvs_.clear();
36 
37  meanGain_=iConfig.getParameter<double>("MeanGain");
38  sigmaGain_=iConfig.getParameter<double>("SigmaGain");
39  minimumPosValue_=iConfig.getParameter<double>("MinPositiveGain");
40  printdebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
41 
42 
43 }
44 
45 
47 
48  edm::LogInfo("SiStripGainRandomCalculator::~SiStripGainRandomCalculator");
49 }
50 
51 
52 
54 
55 
56  unsigned long long cacheID = iSetup.get<TrackerDigiGeometryRecord>().cacheIdentifier();
57 
58  if (m_cacheID_ != cacheID) {
59 
60  m_cacheID_ = cacheID;
61 
63 
64  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
65  edm::LogInfo("SiStripGainRandomCalculator::algoAnalyze - got new geometry ")<<std::endl;
66 
67  detid_apvs_.clear();
68 
69  edm::LogInfo("SiStripGainCalculator") <<" There are "<<pDD->detUnits().size() <<" detectors"<<std::endl;
70 
71  for(TrackerGeometry::DetUnitContainer::const_iterator it = pDD->detUnits().begin(); it != pDD->detUnits().end(); it++){
72 
73  if( dynamic_cast<const StripGeomDetUnit*>((*it))!=0){
74  uint32_t detid=((*it)->geographicalId()).rawId();
75  const StripTopology & p = dynamic_cast<const StripGeomDetUnit*>((*it))->specificTopology();
76  unsigned short NAPVs = p.nstrips()/128;
77  if(NAPVs<1 || NAPVs>6 ) {
78  edm::LogError("SiStripGainCalculator")<<" Problem with Number of strips in detector.. "<< p.nstrips() <<" Exiting program"<<endl;
79  exit(1);
80  }
81  detid_apvs_.push_back( pair<uint32_t,unsigned short>(detid,NAPVs) );
82  if (printdebug_)
83  edm::LogInfo("SiStripGainCalculator")<< "detid " << detid << " apvs " << NAPVs;
84  }
85  }
86  }
87 
88 
89 }
90 
91 
93 
94  std::cout<<"SiStripGainRandomCalculator::getNewObject called"<<std::endl;
95 
97 
98  for(std::vector< pair<uint32_t,unsigned short> >::const_iterator it = detid_apvs_.begin(); it != detid_apvs_.end(); it++){
99  //Generate Gain for det detid
100  std::vector<float> theSiStripVector;
101  for(unsigned short j=0; j<it->second; j++){
102  float gain;
103 
104  // if(sigmaGain_/meanGain_ < 0.00001) gain = meanGain_;
105  // else{
106  gain = CLHEP::RandGauss::shoot(meanGain_, sigmaGain_);
107  if(gain<=minimumPosValue_) gain=minimumPosValue_;
108  // }
109 
110  if (printdebug_)
111  edm::LogInfo("SiStripGainCalculator") << "detid " << it->first << " \t"
112  << " apv " << j << " \t"
113  << gain << " \t"
114  << std::endl;
115  theSiStripVector.push_back(gain);
116  }
117 
118 
119  SiStripApvGain::Range range(theSiStripVector.begin(),theSiStripVector.end());
120  if ( ! obj->put(it->first,range) )
121  edm::LogError("SiStripGainCalculator")<<"[SiStripGainCalculator::beginJob] detid already exists"<<std::endl;
122 
123  }
124 
125  return obj;
126 
127 }
128 
129 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool put(const uint32_t &detID, Range input)
void algoAnalyze(const edm::Event &, const edm::EventSetup &)
std::pair< ContainerIterator, ContainerIterator > Range
SiStripGainRandomCalculator(const edm::ParameterSet &)
virtual int nstrips() const =0
const T & get() const
Definition: EventSetup.h:55
std::vector< std::pair< uint32_t, unsigned short > > detid_apvs_
const DetUnitContainer & detUnits() const override
Returm a vector of all GeomDetUnit.
Definition: event.py:1