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 // $Id: SiStripGainRandomCalculator.cc,v 1.7 2010/04/12 23:23:46 elmer Exp $
7 
12 
18 
19 #include "CLHEP/Random/RandGauss.h"
20 
21 
22 using namespace cms;
23 using namespace std;
24 
25 
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 }
45 
46 
48 
49  edm::LogInfo("SiStripGainRandomCalculator::~SiStripGainRandomCalculator");
50 }
51 
52 
53 
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 }
91 
92 
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 }
129 
130 
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