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