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 using namespace cms;
21 using namespace std;
22 
24  : ConditionDBWriter<SiStripApvGain>(iConfig), m_cacheID_(0) {
25  edm::LogInfo("SiStripGainRandomCalculator::SiStripGainRandomCalculator");
26 
27  // std::string Mode=iConfig.getParameter<std::string>("Mode");
28  // if (Mode==std::string("Gaussian")) GaussianMode_=true;
29  // else if (IOVMode==std::string("Constant")) ConstantMode_=true;
30  // else edm::LogError("SiStripGainRandomCalculator::SiStripGainRandomCalculator(): ERROR - unknown generation mode...will not store anything on the DB") << std::endl;
31 
32  detid_apvs_.clear();
33 
34  meanGain_ = iConfig.getParameter<double>("MeanGain");
35  sigmaGain_ = iConfig.getParameter<double>("SigmaGain");
36  minimumPosValue_ = iConfig.getParameter<double>("MinPositiveGain");
37  printdebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
38 }
39 
41  edm::LogInfo("SiStripGainRandomCalculator::~SiStripGainRandomCalculator");
42 }
43 
45  unsigned long long cacheID = iSetup.get<TrackerDigiGeometryRecord>().cacheIdentifier();
46 
47  if (m_cacheID_ != cacheID) {
48  m_cacheID_ = cacheID;
49 
51 
52  iSetup.get<TrackerDigiGeometryRecord>().get(pDD);
53  edm::LogInfo("SiStripGainRandomCalculator::algoAnalyze - got new geometry ") << std::endl;
54 
55  detid_apvs_.clear();
56 
57  edm::LogInfo("SiStripGainCalculator") << " There are " << pDD->detUnits().size() << " detectors" << std::endl;
58 
59  for (const auto& it : pDD->detUnits()) {
60  if (dynamic_cast<const StripGeomDetUnit*>(it) != nullptr) {
61  uint32_t detid = (it->geographicalId()).rawId();
62  const StripTopology& p = dynamic_cast<const StripGeomDetUnit*>(it)->specificTopology();
63  unsigned short NAPVs = p.nstrips() / 128;
64  if (NAPVs < 1 || NAPVs > 6) {
65  edm::LogError("SiStripGainCalculator")
66  << " Problem with Number of strips in detector.. " << p.nstrips() << " Exiting program" << endl;
67  exit(1);
68  }
69  detid_apvs_.push_back(pair<uint32_t, unsigned short>(detid, NAPVs));
70  if (printdebug_)
71  edm::LogInfo("SiStripGainCalculator") << "detid " << detid << " apvs " << NAPVs;
72  }
73  }
74  }
75 }
76 
77 std::unique_ptr<SiStripApvGain> SiStripGainRandomCalculator::getNewObject() {
78  std::cout << "SiStripGainRandomCalculator::getNewObject called" << std::endl;
79 
80  auto obj = std::make_unique<SiStripApvGain>();
81 
82  for (std::vector<pair<uint32_t, unsigned short> >::const_iterator it = detid_apvs_.begin(); it != detid_apvs_.end();
83  it++) {
84  //Generate Gain for det detid
85  std::vector<float> theSiStripVector;
86  for (unsigned short j = 0; j < it->second; j++) {
87  float gain;
88 
89  // if(sigmaGain_/meanGain_ < 0.00001) gain = meanGain_;
90  // else{
91  gain = CLHEP::RandGauss::shoot(meanGain_, sigmaGain_);
92  if (gain <= minimumPosValue_)
94  // }
95 
96  if (printdebug_)
97  edm::LogInfo("SiStripGainCalculator") << "detid " << it->first << " \t"
98  << " apv " << j << " \t" << gain << " \t" << std::endl;
99  theSiStripVector.push_back(gain);
100  }
101 
102  SiStripApvGain::Range range(theSiStripVector.begin(), theSiStripVector.end());
103  if (!obj->put(it->first, range))
104  edm::LogError("SiStripGainCalculator") << "[SiStripGainCalculator::beginJob] detid already exists" << std::endl;
105  }
106 
107  return obj;
108 }
FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
StripGeomDetUnit.h
MessageLogger.h
TrackerGeometry.h
ESHandle.h
SiStripGainRandomCalculator::getNewObject
std::unique_ptr< SiStripApvGain > getNewObject() override
Definition: SiStripGainRandomCalculator.cc:77
SiStripGainRandomCalculator::sigmaGain_
double sigmaGain_
Definition: SiStripGainRandomCalculator.h:39
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::LogInfo
Definition: MessageLogger.h:254
SiStripGainRandomCalculator::algoAnalyze
void algoAnalyze(const edm::Event &, const edm::EventSetup &) override
Definition: SiStripGainRandomCalculator.cc:44
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
SiStripGainRandomCalculator::meanGain_
double meanGain_
Definition: SiStripGainRandomCalculator.h:38
StripTopology.h
SiStripGainRandomCalculator::minimumPosValue_
double minimumPosValue_
Definition: SiStripGainRandomCalculator.h:40
SiStripGainRandomCalculator.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
ConditionDBWriter
Definition: ConditionDBWriter.h:149
TrackerGeometry::detUnits
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
Definition: TrackerGeometry.h:61
SiStripGainRandomCalculator::~SiStripGainRandomCalculator
~SiStripGainRandomCalculator() override
Definition: SiStripGainRandomCalculator.cc:40
TrackerDigiGeometryRecord
Definition: TrackerDigiGeometryRecord.h:15
edm::ESHandle< TrackerGeometry >
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
TrackerDigiGeometryRecord.h
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
SiStripGainRandomCalculator::m_cacheID_
unsigned long long m_cacheID_
Definition: SiStripGainRandomCalculator.h:43
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
SiStripGainRandomCalculator::detid_apvs_
std::vector< std::pair< uint32_t, unsigned short > > detid_apvs_
Definition: SiStripGainRandomCalculator.h:42
PedestalClient_cfi.gain
gain
Definition: PedestalClient_cfi.py:37
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
GeomDet.h
SiStripGainRandomCalculator::printdebug_
bool printdebug_
Definition: SiStripGainRandomCalculator.h:44
std
Definition: JetResolutionObject.h:76
SiStripApvGain::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripApvGain.h:28
beamvalidation.exit
def exit(msg="")
Definition: beamvalidation.py:53
ParameterSet.h
SiStripGainRandomCalculator::SiStripGainRandomCalculator
SiStripGainRandomCalculator(const edm::ParameterSet &)
Definition: SiStripGainRandomCalculator.cc:23
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
SiStripApvGain
Definition: SiStripApvGain.h:25
StripTopology
Definition: StripTopology.h:11
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21