CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDigitizer.cc
Go to the documentation of this file.
35 #include <boost/foreach.hpp>
39 
40 namespace HcalDigitizerImpl {
41 
42  template<typename SIPMDIGITIZER>
43  void fillSiPMCells(std::vector<int> & siPMCells, SIPMDIGITIZER * siPMDigitizer)
44  {
45  std::vector<DetId> siPMDetIds;
46  siPMDetIds.reserve(siPMCells.size());
47  for(std::vector<int>::const_iterator idItr = siPMCells.begin();
48  idItr != siPMCells.end(); ++idItr)
49  {
50  siPMDetIds.emplace_back(*idItr);
51  }
52  siPMDigitizer->setDetIds(siPMDetIds);
53  }
54 
55  // if both exist, assume the SiPM one has cells filled, and
56  // assign the rest to the HPD
57  template<typename HPDDIGITIZER, typename SIPMDIGITIZER>
58  void fillCells(std::vector<DetId>& allCells,
59  HPDDIGITIZER * hpdDigitizer,
60  SIPMDIGITIZER * siPMDigitizer)
61  {
62  // if both digitizers exist, split up the cells
63  if(siPMDigitizer && hpdDigitizer)
64  {
65  std::vector<DetId> siPMDetIds = siPMDigitizer->detIds();
66  std::sort(siPMDetIds.begin(), siPMDetIds.end());
67  std::vector<DetId> sortedCells = allCells;
68  std::sort(sortedCells.begin(), sortedCells.end());
69  std::vector<DetId> hpdCells;
70  std::set_difference(sortedCells.begin(), sortedCells.end(),
71  siPMDetIds.begin(), siPMDetIds.end(),
72  std::back_inserter(hpdCells) );
73  hpdDigitizer->setDetIds(hpdCells);
74  }
75  else
76  {
77  if(siPMDigitizer) siPMDigitizer->setDetIds(allCells);
78  if(hpdDigitizer) hpdDigitizer->setDetIds(allCells);
79  }
80  }
81 } // namespace HcaiDigitizerImpl
82 
83 
85  theGeometry(0),
86  theParameterMap(new HcalSimParameterMap(ps)),
87  theShapes(new HcalShapes()),
88  theHBHEResponse(0),
89  theHBHESiPMResponse(0),
90  theHOResponse(0),
91  theHOSiPMResponse(0),
92  theHFResponse(new CaloHitResponse(theParameterMap, theShapes)),
93  theZDCResponse(new CaloHitResponse(theParameterMap, theShapes)),
94  theHBHEAmplifier(0),
95  theHFAmplifier(0),
96  theHOAmplifier(0),
97  theZDCAmplifier(0),
98  theIonFeedback(0),
99  theCoderFactory(0),
100  theUpgradeCoderFactory(0),
101  theHBHEElectronicsSim(0),
102  theHFElectronicsSim(0),
103  theHOElectronicsSim(0),
104  theZDCElectronicsSim(0),
105  theUpgradeHBHEElectronicsSim(0),
106  theUpgradeHFElectronicsSim(0),
107  theHBHEHitFilter(),
108  theHFHitFilter(ps.getParameter<bool>("doHFWindow")),
109  theHOHitFilter(),
110  theHOSiPMHitFilter(HcalOuter),
111  theZDCHitFilter(),
112  theHitCorrection(0),
113  theNoiseGenerator(0),
114  theNoiseHitGenerator(0),
115  theHBHEDigitizer(0),
116  theHBHESiPMDigitizer(0),
117  theHODigitizer(0),
118  theHOSiPMDigitizer(0),
119  theHFDigitizer(0),
120  theZDCDigitizer(0),
121  theHBHEUpgradeDigitizer(0),
122  theHFUpgradeDigitizer(0),
123  theRelabeller(0),
124  isZDC(true),
125  isHCAL(true),
126  zdcgeo(true),
127  hbhegeo(true),
128  hogeo(true),
129  hfgeo(true),
130  hitsProducer_(ps.getParameter<std::string>("hitsProducer")),
131  theHOSiPMCode(ps.getParameter<edm::ParameterSet>("ho").getParameter<int>("siPMCode")),
132  deliveredLumi(0.),
133  m_HEDarkening(0),
134  m_HFRecalibration(0)
135 {
136  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(hitsProducer_, "ZDCHITS"));
137  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(hitsProducer_, "HcalHits"));
138 
139  bool doNoise = ps.getParameter<bool>("doNoise");
140  bool PreMix1 = ps.getParameter<bool>("HcalPreMixStage1"); // special threshold/pedestal treatment
141  bool PreMix2 = ps.getParameter<bool>("HcalPreMixStage2"); // special threshold/pedestal treatment
142  bool useOldNoiseHB = ps.getParameter<bool>("useOldHB");
143  bool useOldNoiseHE = ps.getParameter<bool>("useOldHE");
144  bool useOldNoiseHF = ps.getParameter<bool>("useOldHF");
145  bool useOldNoiseHO = ps.getParameter<bool>("useOldHO");
146  bool doEmpty = ps.getParameter<bool>("doEmpty");
147  double HBtp = ps.getParameter<double>("HBTuningParameter");
148  double HEtp = ps.getParameter<double>("HETuningParameter");
149  double HFtp = ps.getParameter<double>("HFTuningParameter");
150  double HOtp = ps.getParameter<double>("HOTuningParameter");
151  bool doHBHEUpgrade = ps.getParameter<bool>("HBHEUpgradeQIE");
152  bool doHFUpgrade = ps.getParameter<bool>("HFUpgradeQIE");
153  deliveredLumi = ps.getParameter<double>("DelivLuminosity");
154  bool agingFlagHE = ps.getParameter<bool>("HEDarkening");
155  bool agingFlagHF = ps.getParameter<bool>("HFDarkening");
156 
157 
158  if(PreMix1 && PreMix2) {
159  throw cms::Exception("Configuration")
160  << "HcalDigitizer cannot operate in PreMixing digitization and PreMixing\n"
161  "digi combination modes at the same time. Please set one mode to False\n"
162  "in the configuration file.";
163  }
164 
165  // need to make copies, because they might get different noise generators
166  theHBHEAmplifier = new HcalAmplifier(theParameterMap, doNoise, PreMix1, PreMix2);
167  theHFAmplifier = new HcalAmplifier(theParameterMap, doNoise, PreMix1, PreMix2);
168  theHOAmplifier = new HcalAmplifier(theParameterMap, doNoise, PreMix1, PreMix2);
169  theZDCAmplifier = new HcalAmplifier(theParameterMap, doNoise, PreMix1, PreMix2);
174  theHBHEAmplifier->setUseOldHB(useOldNoiseHB);
175  theHBHEAmplifier->setUseOldHE(useOldNoiseHE);
176  theHFAmplifier->setUseOldHF(useOldNoiseHF);
177  theHOAmplifier->setUseOldHO(useOldNoiseHO);
178 
181 
182  // std::cout << "HcalDigitizer: theUpgradeCoderFactory created" << std::endl;
183 
190 
191  // std::cout << "HcalDigitizer: theUpgradeElectronicsSim created" << std::endl;
192 
193  // a code of 1 means make all cells SiPM
194  std::vector<int> hbSiPMCells(ps.getParameter<edm::ParameterSet>("hb").getParameter<std::vector<int> >("siPMCells"));
195  //std::vector<int> hoSiPMCells(ps.getParameter<edm::ParameterSet>("ho").getParameter<std::vector<int> >("siPMCells"));
196  // 0 means none, 1 means all, and 2 means use hardcoded
197 
198  // std::cout << std::endl << " hbSiPMCells = " << hbSiPMCells[0] << std::endl;
199 
200  bool doHBHEHPD = hbSiPMCells.empty() || (hbSiPMCells[0] != 1);
201  bool doHOHPD = (theHOSiPMCode != 1);
202  bool doHBHESiPM = !hbSiPMCells.empty();
203  bool doHOSiPM = (theHOSiPMCode != 0);
204  if(doHBHEHPD) {
206  edm::LogInfo("HcalDigitizer") <<"Set scale for HB towers";
208 
211  bool changeResponse = ps.getParameter<bool>("ChangeResponse");
212  edm::FileInPath fname = ps.getParameter<edm::FileInPath>("CorrFactorFile");
213  if (changeResponse) {
214  std::string corrFileName = fname.fullPath();
215  edm::LogInfo("HcalDigitizer") << "Set scale for HB towers from " << corrFileName;
216  theHBHEResponse->setHBHEScale(corrFileName); //GMA
217  }
218  }
219  if(doHOHPD) {
223  }
224 
225  if(doHBHESiPM) {
228  if (doHBHEUpgrade) {
230 
231  // std::cout << "HcalDigitizer: theHBHEUpgradeDigitizer created" << std::endl;
232 
233  } else {
235  }
236  }
237  if(doHOSiPM) {
241  }
242 
243  // if both are present, fill the SiPM cells now
244  if(doHBHEHPD && doHBHESiPM) {
245 
246  // std::cout << "HcalDigitizer: fill the SiPM cells now" << std::endl;
247 
249  }
250 
253 
254  bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
255  //initialize: they won't be called later if flag is set
256  theTimeSlewSim = 0;
257  if(doTimeSlew) {
258  // no time slewing for HF
259  theTimeSlewSim = new HcalTimeSlewSim(theParameterMap);
260  theHBHEAmplifier->setTimeSlewSim(theTimeSlewSim);
261  theHOAmplifier->setTimeSlewSim(theTimeSlewSim);
262  theZDCAmplifier->setTimeSlewSim(theTimeSlewSim);
263  }
264 
265  if (doHFUpgrade) {
267 
268  // std::cout << "HcalDigitizer: theHFUpgradeDigitizer created" << std::endl;
269 
270  } else {
272  }
274 
275  edm::ParameterSet ps0 = ps.getParameter<edm::ParameterSet>("HcalReLabel");
276  relabel_ = ps0.getUntrackedParameter<bool>("RelabelHits");
277  if (relabel_) {
279  }
280 
281  bool doHPDNoise = ps.getParameter<bool>("doHPDNoise");
282  if(doHPDNoise) {
283  //edm::ParameterSet hpdNoisePset = ps.getParameter<edm::ParameterSet>("HPDNoiseLibrary");
287  }
288 
289  if(ps.getParameter<bool>("doIonFeedback") && theHBHEResponse) {
292  if(ps.getParameter<bool>("doThermalNoise")) {
294  }
295  }
296 
297  if(ps.getParameter<bool>("injectTestHits") ) {
305 
306  // std::cout << "HcalDigitizer: theHBHEUpgradeDigitizer setNoise"
307  // << std::endl;
308  }
310  if(theHFUpgradeDigitizer) {
312 
313  // std::cout << "HcalDigitizer: theHFUpgradeDigitizer setNoise"
314  // << std::endl;
315  }
317  }
318 
319  if(agingFlagHE) m_HEDarkening = new HEDarkening();
320  if(agingFlagHF) m_HFRecalibration = new HFRecalibration();
321 }
322 
323 
327  if(theHODigitizer) delete theHODigitizer;
329  if(theHFDigitizer) delete theHFDigitizer;
330  delete theZDCDigitizer;
333  delete theParameterMap;
334  delete theHBHEResponse;
335  delete theHBHESiPMResponse;
336  delete theHOResponse;
337  delete theHOSiPMResponse;
338  delete theHFResponse;
339  delete theZDCResponse;
340  delete theHBHEElectronicsSim;
341  delete theHFElectronicsSim;
342  delete theHOElectronicsSim;
343  delete theZDCElectronicsSim;
346  delete theHBHEAmplifier;
347  delete theHFAmplifier;
348  delete theHOAmplifier;
349  delete theZDCAmplifier;
350  delete theCoderFactory;
351  delete theUpgradeCoderFactory;
352  delete theHitCorrection;
353  delete theNoiseGenerator;
354  if (theRelabeller) delete theRelabeller;
355 }
356 
357 
359  noiseGenerator->setParameterMap(theParameterMap);
360  noiseGenerator->setElectronicsSim(theHBHEElectronicsSim);
362  theHBHEAmplifier->setNoiseSignalGenerator(noiseGenerator);
363 }
364 
366  noiseGenerator->setParameterMap(theParameterMap);
367  noiseGenerator->setElectronicsSim(theHFElectronicsSim);
370  theHFAmplifier->setNoiseSignalGenerator(noiseGenerator);
371 }
372 
374  noiseGenerator->setParameterMap(theParameterMap);
375  noiseGenerator->setElectronicsSim(theHOElectronicsSim);
378  theHOAmplifier->setNoiseSignalGenerator(noiseGenerator);
379 }
380 
382  noiseGenerator->setParameterMap(theParameterMap);
383  noiseGenerator->setElectronicsSim(theZDCElectronicsSim);
384  theZDCDigitizer->setNoiseSignalGenerator(noiseGenerator);
385  theZDCAmplifier->setNoiseSignalGenerator(noiseGenerator);
386 }
387 
389  // get the appropriate gains, noises, & widths for this event
390  edm::ESHandle<HcalDbService> conditions;
391  eventSetup.get<HcalDbRecord>().get(conditions);
392  theHBHEAmplifier->setDbService(conditions.product());
393  theHFAmplifier->setDbService(conditions.product());
394  theHOAmplifier->setDbService(conditions.product());
395  theZDCAmplifier->setDbService(conditions.product());
398 
399  theCoderFactory->setDbService(conditions.product());
401  theParameterMap->setDbService(conditions.product());
402 
404  if (eventSetup.find(edm::eventsetup::EventSetupRecordKey::makeKey<HcalCholeskyMatricesRcd>())) {
405  eventSetup.get<HcalCholeskyMatricesRcd>().get(refCholesky);
406  const HcalCholeskyMatrices * myCholesky = refCholesky.product();
407  theHBHEAmplifier->setCholesky(myCholesky);
408  theHFAmplifier->setCholesky(myCholesky);
409  theHOAmplifier->setCholesky(myCholesky);
410  }
411  edm::ESHandle<HcalPedestals> pedshandle;
412  eventSetup.get<HcalPedestalsRcd>().get(pedshandle);
413  const HcalPedestals * myADCPedestals = pedshandle.product();
414 
415  theHBHEAmplifier->setADCPeds(myADCPedestals);
416  theHFAmplifier->setADCPeds(myADCPedestals);
417  theHOAmplifier->setADCPeds(myADCPedestals);
418 
419  if(theHitCorrection != 0) {
421  }
422 
423  //initialize hits
432 
433 }
434 
435 void HcalDigitizer::accumulateCaloHits(edm::Handle<std::vector<PCaloHit> > const& hcalHandle, edm::Handle<std::vector<PCaloHit> > const& zdcHandle, int bunchCrossing, CLHEP::HepRandomEngine* engine) {
436  // Step A: pass in inputs, and accumulate digirs
437  if(isHCAL) {
438  std::vector<PCaloHit> hcalHits = *hcalHandle.product();
439  //evaluate darkening before relabeling
441  darkening(hcalHits);
442  }
443  if (relabel_) {
444  // Relabel PCaloHits
445  edm::LogInfo("HcalDigitizer") << "Calling Relabeller";
446  theRelabeller->process(hcalHits);
447  }
448  if(theHitCorrection != 0) {
449  theHitCorrection->fillChargeSums(hcalHits);
450  }
451  if(hbhegeo) {
452  if(theHBHEDigitizer) theHBHEDigitizer->add(hcalHits, bunchCrossing, engine);
453  if(theHBHESiPMDigitizer) theHBHESiPMDigitizer->add(hcalHits, bunchCrossing, engine);
455  // std::cout << "HcalDigitizer::accumulateCaloHits theHBHEUpgradeDigitizer->add" << std::endl;
456  theHBHEUpgradeDigitizer->add(hcalHits, bunchCrossing, engine);
457  }
458  }
459 
460  if(hogeo) {
461  if(theHODigitizer) theHODigitizer->add(hcalHits, bunchCrossing, engine);
462  if(theHOSiPMDigitizer) theHOSiPMDigitizer->add(hcalHits, bunchCrossing, engine);
463  }
464 
465  if(hfgeo) {
466  if(theHFDigitizer) theHFDigitizer->add(hcalHits, bunchCrossing, engine);
467  if(theHFUpgradeDigitizer) theHFUpgradeDigitizer->add(hcalHits, bunchCrossing, engine);
468  }
469  } else {
470  edm::LogInfo("HcalDigitizer") << "We don't have HCAL hit collection available ";
471  }
472 
473  if(isZDC) {
474  if(zdcgeo) {
475  theZDCDigitizer->add(*zdcHandle.product(), bunchCrossing, engine);
476  }
477  } else {
478  edm::LogInfo("HcalDigitizer") << "We don't have ZDC hit collection available ";
479  }
480 }
481 
482 void HcalDigitizer::accumulate(edm::Event const& e, edm::EventSetup const& eventSetup, CLHEP::HepRandomEngine* engine) {
483  // Step A: Get Inputs
484  edm::InputTag zdcTag(hitsProducer_, "ZDCHITS");
486  e.getByLabel(zdcTag, zdcHandle);
487  isZDC = zdcHandle.isValid();
488 
489  edm::InputTag hcalTag(hitsProducer_, "HcalHits");
491  e.getByLabel(hcalTag, hcalHandle);
492  isHCAL = hcalHandle.isValid();
493 
494  accumulateCaloHits(hcalHandle, zdcHandle, 0, engine);
495 }
496 
497 void HcalDigitizer::accumulate(PileUpEventPrincipal const& e, edm::EventSetup const& eventSetup, CLHEP::HepRandomEngine* engine) {
498  // Step A: Get Inputs
499  edm::InputTag zdcTag(hitsProducer_, "ZDCHITS");
501  e.getByLabel(zdcTag, zdcHandle);
502  isZDC = zdcHandle.isValid();
503 
504  edm::InputTag hcalTag(hitsProducer_, "HcalHits");
506  e.getByLabel(hcalTag, hcalHandle);
507  isHCAL = hcalHandle.isValid();
508 
509  accumulateCaloHits(hcalHandle, zdcHandle, e.bunchCrossing(), engine);
510 }
511 
512 void HcalDigitizer::finalizeEvent(edm::Event& e, const edm::EventSetup& eventSetup, CLHEP::HepRandomEngine* engine) {
513 
514  // Step B: Create empty output
515  std::auto_ptr<HBHEDigiCollection> hbheResult(new HBHEDigiCollection());
516  std::auto_ptr<HODigiCollection> hoResult(new HODigiCollection());
517  std::auto_ptr<HFDigiCollection> hfResult(new HFDigiCollection());
518  std::auto_ptr<ZDCDigiCollection> zdcResult(new ZDCDigiCollection());
519  std::auto_ptr<HBHEUpgradeDigiCollection> hbheupgradeResult(new HBHEUpgradeDigiCollection());
520  std::auto_ptr<HFUpgradeDigiCollection> hfupgradeResult(new HFUpgradeDigiCollection());
521 
522  // Step C: Invoke the algorithm, getting back outputs.
523  if(isHCAL&&hbhegeo){
524  if(theHBHEDigitizer) theHBHEDigitizer->run(*hbheResult, engine);
525  if(theHBHESiPMDigitizer) theHBHESiPMDigitizer->run(*hbheResult, engine);
527  theHBHEUpgradeDigitizer->run(*hbheupgradeResult, engine);
528 
529  // std::cout << "HcalDigitizer::finalizeEvent theHBHEUpgradeDigitizer->run" << std::endl;
530  }
531  }
532  if(isHCAL&&hogeo) {
533  if(theHODigitizer) theHODigitizer->run(*hoResult, engine);
534  if(theHOSiPMDigitizer) theHOSiPMDigitizer->run(*hoResult, engine);
535  }
536  if(isHCAL&&hfgeo) {
537  if(theHFDigitizer) theHFDigitizer->run(*hfResult, engine);
538  if(theHFUpgradeDigitizer) theHFUpgradeDigitizer->run(*hfupgradeResult, engine);
539  }
540  if(isZDC&&zdcgeo) {
541  theZDCDigitizer->run(*zdcResult, engine);
542  }
543 
544  edm::LogInfo("HcalDigitizer") << "HCAL HBHE digis : " << hbheResult->size();
545  edm::LogInfo("HcalDigitizer") << "HCAL HO digis : " << hoResult->size();
546  edm::LogInfo("HcalDigitizer") << "HCAL HF digis : " << hfResult->size();
547  edm::LogInfo("HcalDigitizer") << "HCAL ZDC digis : " << zdcResult->size();
548  edm::LogInfo("HcalDigitizer") << "HCAL HBHE upgrade digis : " << hbheupgradeResult->size();
549  edm::LogInfo("HcalDigitizer") << "HCAL HF upgrade digis : " << hfupgradeResult->size();
550 
551  /*
552  std::cout << std::endl;
553  std::cout << "HCAL HBHE digis : " << hbheResult->size() << std::endl;
554  std::cout << "HCAL HO digis : " << hoResult->size() << std::endl;
555  std::cout << "HCAL HF digis : " << hfResult->size() << std::endl;
556 
557  std::cout << "HCAL HBHE upgrade digis : " << hbheupgradeResult->size()
558  << std::endl;
559  std::cout << "HCAL HF upgrade digis : " << hfupgradeResult->size()
560  << std::endl;
561  */
562 
563  // Step D: Put outputs into event
564  e.put(hbheResult);
565  e.put(hoResult);
566  e.put(hfResult);
567  e.put(zdcResult);
568  e.put(hbheupgradeResult,"HBHEUpgradeDigiCollection");
569  e.put(hfupgradeResult, "HFUpgradeDigiCollection");
570 
571  // std::cout << std::endl << "========> HcalDigitizer e.put "
572  // << std::endl << std::endl;
573 
574  if(theHitCorrection) {
576  }
577 }
578 
579 
581  checkGeometry(es);
582  theShapes->beginRun(es);
583 }
584 
585 
587  theShapes->endRun();
588 }
589 
590 
592  // TODO find a way to avoid doing this every event
594  eventSetup.get<CaloGeometryRecord>().get(geometry);
595  // See if it's been updated
596  if(&*geometry != theGeometry)
597  {
598  theGeometry = &*geometry;
599  updateGeometry(eventSetup);
600  }
601 }
602 
603 
612 
613  const std::vector<DetId>& hbCells = theGeometry->getValidDetIds(DetId::Hcal, HcalBarrel);
614  const std::vector<DetId>& heCells = theGeometry->getValidDetIds(DetId::Hcal, HcalEndcap);
615  const std::vector<DetId>& hoCells = theGeometry->getValidDetIds(DetId::Hcal, HcalOuter);
616  const std::vector<DetId>& hfCells = theGeometry->getValidDetIds(DetId::Hcal, HcalForward);
617  const std::vector<DetId>& zdcCells = theGeometry->getValidDetIds(DetId::Calo, HcalZDCDetId::SubdetectorId);
618  //const std::vector<DetId>& hcalTrigCells = geometry->getValidDetIds(DetId::Hcal, HcalTriggerTower);
619  //const std::vector<DetId>& hcalCalib = geometry->getValidDetIds(DetId::Calo, HcalCastorDetId::SubdetectorId);
620  //std::cout<<"HcalDigitizer::CheckGeometry number of cells: "<<zdcCells.size()<<std::endl;
621  if(zdcCells.empty()) zdcgeo = false;
622  if(hbCells.empty() && heCells.empty()) hbhegeo = false;
623  if(hoCells.empty()) hogeo = false;
624  if(hfCells.empty()) hfgeo = false;
625  // combine HB & HE
626 
627  theHBHEDetIds = hbCells;
628  theHBHEDetIds.insert(theHBHEDetIds.end(), heCells.begin(), heCells.end());
629 
631  //HcalDigitizerImpl::fillCells(hoCells, theHODigitizer, theHOSiPMDigitizer);
632  buildHOSiPMCells(hoCells, eventSetup);
635  theZDCDigitizer->setDetIds(zdcCells);
638 
639  // std::cout << " HcalDigitizer::updateGeometry theHBHEUpgradeDigitizer->setDetIds(theHBHEDetIds)"<< std::endl;
640  }
641 
642 }
643 
644 
645 void HcalDigitizer::buildHOSiPMCells(const std::vector<DetId>& allCells, const edm::EventSetup & eventSetup) {
646  // all HPD
647 
648  if(theHOSiPMCode == 0) {
649  theHODigitizer->setDetIds(allCells);
650  } else if(theHOSiPMCode == 1) {
651  theHOSiPMDigitizer->setDetIds(allCells);
652  // FIXME pick Zecotek or hamamatsu?
653  } else if(theHOSiPMCode == 2) {
654  std::vector<HcalDetId> zecotekDetIds, hamamatsuDetIds;
656  eventSetup.get<HcalMCParamsRcd>().get(p);
658  eventSetup.get<IdealGeometryRecord>().get(htopo);
659 
660  HcalMCParams mcParams(*p.product());
661  if (mcParams.topo()==0) {
662  mcParams.setTopo(htopo.product());
663  }
664 
665  for(std::vector<DetId>::const_iterator detItr = allCells.begin();
666  detItr != allCells.end(); ++detItr) {
667  int shapeType = mcParams.getValues(*detItr)->signalShape();
668  if(shapeType == HcalShapes::ZECOTEK) {
669  zecotekDetIds.emplace_back(*detItr);
670  theHOSiPMDetIds.push_back(*detItr);
671  } else if(shapeType == HcalShapes::HAMAMATSU) {
672  hamamatsuDetIds.emplace_back(*detItr);
673  theHOSiPMDetIds.push_back(*detItr);
674  } else {
675  theHOHPDDetIds.push_back(*detItr);
676  }
677  }
678 
684  // FIXME not applying a HitFilter to the HPDs, for now
685  theParameterMap->setHOZecotekDetIds(zecotekDetIds);
686  theParameterMap->setHOHamamatsuDetIds(hamamatsuDetIds);
687 
688  // make sure we don't got through this exercise again
689  theHOSiPMCode = -2;
690  }
691 }
692 
693 void HcalDigitizer::darkening(std::vector<PCaloHit>& hcalHits){
694 
695  for (unsigned int ii=0; ii<hcalHits.size(); ++ii) {
696  uint32_t tmpId = hcalHits[ii].id();
697  int det, z, depth, ieta, phi, lay;
698  HcalTestNumbering::unpackHcalIndex(tmpId,det,z,depth,ieta,phi,lay);
699 
700  bool darkened = false;
701  float dweight = 1.;
702 
703  //HE darkening
704  if(det==int(HcalEndcap) && m_HEDarkening){
705  dweight = m_HEDarkening->degradation(deliveredLumi,ieta,lay-2);//NB:diff. layer count
706  darkened = true;
707  }
708 
709  //HF darkening - approximate: invert recalibration factor
710  else if(det==int(HcalForward) && m_HFRecalibration){
711  dweight = 1.0/m_HFRecalibration->getCorr(ieta,depth,deliveredLumi);
712  darkened = true;
713  }
714 
715  //create new hit with darkened energy
716  //if(darkened) hcalHits[ii] = PCaloHit(hcalHits[ii].energyEM()*dweight,hcalHits[ii].energyHad()*dweight,hcalHits[ii].time(),hcalHits[ii].geantTrackId(),hcalHits[ii].id());
717 
718  //reset hit energy
719  if(darkened) hcalHits[ii].setEnergy(hcalHits[ii].energy()*dweight);
720  }
721 
722 }
723 
724 
void setUseOldHB(bool useOld)
void setNoiseHitGenerator(CaloVNoiseHitGenerator *generator)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void setHOtuningParameter(double tp)
T getParameter(std::string const &) const
void setGeometry(const CaloGeometry *geometry)
geometry needed for time-of-flight
void setDbService(const HcalDbService *service)
the Producer will probably update this every event
T getUntrackedParameter(std::string const &, T const &) const
HBHEHitFilter theHBHEHitFilter
void setParameterMap(HcalSimParameterMap *map)
void initializeHits()
void setDetIds(const std::vector< DetId > &detIds)
virtual ~HcalDigitizer()
HcalElectronicsSim * theHFElectronicsSim
HBHEDigitizer * theHBHEDigitizer
HOHitFilter theHOHitFilter
assert(m_qm.get())
CaloTDigitizer< HcalUpgradeDigitizerTraits > UpgradeDigitizer
Definition: HcalDigitizer.h:83
void setUseOldHF(bool useOld)
void darkening(std::vector< PCaloHit > &hcalHits)
void add(const std::vector< PCaloHit > &hits, int bunchCrossing, CLHEP::HepRandomEngine *engine)
HFDigitizer * theHFDigitizer
HFHitFilter theHFHitFilter
void checkGeometry(const edm::EventSetup &eventSetup)
HcalSimParameterMap * theParameterMap
Definition: HcalDigitizer.h:85
void setHFtuningParameter(double tp)
void setPECorrection(const CaloVPECorrection *peCorrection)
if you want to correct the photoelectrons
int ii
Definition: cuy.py:588
HcalTimeSlewSim * theTimeSlewSim
void setADCPeds(const HcalPedestals *ADCPeds)
Definition: HcalAmplifier.h:54
void setGeometry(const CaloGeometry *&theGeometry)
HcalAmplifier * theHFAmplifier
Definition: HcalDigitizer.h:98
HcalElectronicsSim * theUpgradeHFElectronicsSim
void fillSiPMCells(std::vector< int > &siPMCells, SIPMDIGITIZER *siPMDigitizer)
HcalCoderFactory * theCoderFactory
HcalHitRelabeller * theRelabeller
float float float z
edm::SortedCollection< ZDCDataFrame > ZDCDigiCollection
HcalCoderFactory * theUpgradeCoderFactory
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
void initializeEvent(edm::Event const &e, edm::EventSetup const &c)
void setDbService(const HcalDbService *service)
void setIonFeedbackSim(HPDIonFeedbackSim *feedbackSim)
Definition: HcalAmplifier.h:31
UpgradeDigitizer * theHFUpgradeDigitizer
void accumulate(edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *)
CaloTDigitizer< HFDigitizerTraits > HFDigitizer
Definition: HcalDigitizer.h:81
void setHOZecotekDetIds(const std::vector< HcalDetId > &ids)
HcalAmplifier * theHBHEAmplifier
Definition: HcalDigitizer.h:97
void setUseOldHO(bool useOld)
edm::SortedCollection< HODataFrame > HODigiCollection
CaloTDigitizer< ZDCDigitizerTraits > ZDCDigitizer
Definition: HcalDigitizer.h:82
std::string hitsProducer_
HcalElectronicsSim * theHOElectronicsSim
void setHEtuningParameter(double tp)
double deliveredLumi
void setUseOldHE(bool useOld)
void setElectronicsSim(HcalElectronicsSim *electronicsSim)
void setHitFilter(const CaloVHitFilter *filter)
if you want to reject hits, for example, from a certain subdetector, set this
double getCorr(int ieta, int idepth, double lumi)
HcalShapes * theShapes
Definition: HcalDigitizer.h:86
Creates electronics signals from hits.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
void setHFNoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
std::vector< DetId > theHBHEDetIds
void buildHOSiPMCells(const std::vector< DetId > &allCells, const edm::EventSetup &eventSetup)
ZDCHitFilter theZDCHitFilter
HPDIonFeedbackSim * theIonFeedback
void fillChargeSums(MixCollection< PCaloHit > &hits)
CaloHitResponse * theHOResponse
Definition: HcalDigitizer.h:90
HcalHitFilter theHOSiPMHitFilter
CaloHitResponse * theHOSiPMResponse
Definition: HcalDigitizer.h:91
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
void setHBHEScale(std::string &)
void setNoiseSignalGenerator(CaloVNoiseSignalGenerator *generator)
ZDCDigitizer * theZDCDigitizer
edm::SortedCollection< HcalUpgradeDataFrame > HFUpgradeDigiCollection
std::vector< DetId > theHOHPDDetIds
bool isValid() const
Definition: HandleBase.h:75
edm::SortedCollection< HcalUpgradeDataFrame > HBHEUpgradeDigiCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
HcalHitCorrection * theHitCorrection
CaloHitResponse * theZDCResponse
Definition: HcalDigitizer.h:93
void endRun()
Definition: HcalShapes.cc:118
void accumulateCaloHits(edm::Handle< std::vector< PCaloHit > > const &hcalHits, edm::Handle< std::vector< PCaloHit > > const &zdcHits, int bunchCrossing, CLHEP::HepRandomEngine *)
void setNoiseSignalGenerator(const CaloVNoiseSignalGenerator *noiseSignalGenerator)
Definition: HcalAmplifier.h:35
HcalElectronicsSim * theZDCElectronicsSim
HcalElectronicsSim * theUpgradeHBHEElectronicsSim
void run(MixCollection< PCaloHit > &, DigiCollection &)
turns hits into digis
static const int SubdetectorId
Definition: HcalZDCDetId.h:20
void beginRun(const edm::EventSetup &es)
void process(std::vector< PCaloHit > &hcalHits)
CaloTDigitizer< HODigitizerTraits > HODigitizer
Definition: HcalDigitizer.h:80
void setTimeSlewSim(HcalTimeSlewSim *timeSlewSim)
Definition: HcalAmplifier.h:38
void setHOHamamatsuDetIds(const std::vector< HcalDetId > &ids)
HcalAmplifier * theHOAmplifier
Definition: HcalDigitizer.h:99
void setDbService(const HcalDbService *service)
HFRecalibration * m_HFRecalibration
const T & get() const
Definition: EventSetup.h:55
HcalElectronicsSim * theHBHEElectronicsSim
T const * product() const
Definition: ESHandle.h:86
void fillCells(std::vector< DetId > &allCells, HPDDIGITIZER *hpdDigitizer, SIPMDIGITIZER *siPMDigitizer)
CaloHitResponse * theHBHEResponse
Definition: HcalDigitizer.h:88
HODigitizer * theHODigitizer
std::vector< DetId > theHOSiPMDetIds
const CaloGeometry * theGeometry
Definition: HcalDigitizer.h:70
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:90
void setCholesky(const HcalCholeskyMatrices *Cholesky)
Definition: HcalAmplifier.h:53
string fname
main script
ESHandle< TrackerGeometry > geometry
CaloHitResponse * theHFResponse
Definition: HcalDigitizer.h:92
HODigitizer * theHOSiPMDigitizer
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
void setZDCNoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
HBHEDigitizer * theHBHESiPMDigitizer
HEDarkening * m_HEDarkening
edm::SortedCollection< HFDataFrame > HFDigiCollection
void setDetIds(const std::vector< DetId > &detIds)
void beginRun(edm::EventSetup const &es)
Definition: HcalShapes.cc:103
CaloHitResponse * theHBHESiPMResponse
Definition: HcalDigitizer.h:89
void setHBtuningParameter(double tp)
void updateGeometry(const edm::EventSetup &eventSetup)
float degradation(float intlumi, int ieta, int lay)
Definition: HEDarkening.cc:52
void setHBHENoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
CaloVNoiseHitGenerator * theNoiseHitGenerator
HcalAmplifier * theZDCAmplifier
void setTopo(const HcalTopology *topo)
void setDbService(const HcalDbService *service)
edm::SortedCollection< HBHEDataFrame > HBHEDigiCollection
void finalizeEvent(edm::Event &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *)
UpgradeDigitizer * theHBHEUpgradeDigitizer
void setHONoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
CaloTDigitizer< HBHEDigitizerTraits > HBHEDigitizer
Definition: HcalDigitizer.h:79
HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector &iC)
CaloVNoiseSignalGenerator * theNoiseGenerator
Definition: DDAxes.h:10