CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
virtual int nstrips() const =0
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
int j
Definition: DBlmapReader.cc:9
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
SiStripGainRandomCalculator(const edm::ParameterSet &)
const T & get() const
Definition: EventSetup.h:55
std::vector< std::pair< uint32_t, unsigned short > > detid_apvs_
tuple cout
Definition: gather_cfg.py:121