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 
166  // need to make copies, because they might get different noise generators
167  theHBHEAmplifier = new HcalAmplifier(theParameterMap, doNoise, PreMix1, PreMix2);
168  theHFAmplifier = new HcalAmplifier(theParameterMap, doNoise, PreMix1, PreMix2);
169  theHOAmplifier = new HcalAmplifier(theParameterMap, doNoise, PreMix1, PreMix2);
170  theZDCAmplifier = new HcalAmplifier(theParameterMap, doNoise, PreMix1, PreMix2);
175  theHBHEAmplifier->setUseOldHB(useOldNoiseHB);
176  theHBHEAmplifier->setUseOldHE(useOldNoiseHE);
177  theHFAmplifier->setUseOldHF(useOldNoiseHF);
178  theHOAmplifier->setUseOldHO(useOldNoiseHO);
179 
182 
183  // std::cout << "HcalDigitizer: theUpgradeCoderFactory created" << std::endl;
184 
191 
192  // std::cout << "HcalDigitizer: theUpgradeElectronicsSim created" << std::endl;
193 
194  // a code of 1 means make all cells SiPM
195  std::vector<int> hbSiPMCells(ps.getParameter<edm::ParameterSet>("hb").getParameter<std::vector<int> >("siPMCells"));
196  //std::vector<int> hoSiPMCells(ps.getParameter<edm::ParameterSet>("ho").getParameter<std::vector<int> >("siPMCells"));
197  // 0 means none, 1 means all, and 2 means use hardcoded
198 
199  // std::cout << std::endl << " hbSiPMCells = " << hbSiPMCells[0] << std::endl;
200 
201  bool doHBHEHPD = hbSiPMCells.empty() || (hbSiPMCells[0] != 1);
202  bool doHOHPD = (theHOSiPMCode != 1);
203  bool doHBHESiPM = !hbSiPMCells.empty();
204  bool doHOSiPM = (theHOSiPMCode != 0);
205  if(doHBHEHPD) {
207  edm::LogInfo("HcalDigitizer") <<"Set scale for HB towers";
209 
212  bool changeResponse = ps.getParameter<bool>("ChangeResponse");
213  edm::FileInPath fname = ps.getParameter<edm::FileInPath>("CorrFactorFile");
214  if (changeResponse) {
215  std::string corrFileName = fname.fullPath();
216  edm::LogInfo("HcalDigitizer") << "Set scale for HB towers from " << corrFileName;
217  theHBHEResponse->setHBHEScale(corrFileName); //GMA
218  }
219  }
220  if(doHOHPD) {
224  }
225 
226  if(doHBHESiPM) {
229  if (doHBHEUpgrade) {
231 
232  // std::cout << "HcalDigitizer: theHBHEUpgradeDigitizer created" << std::endl;
233 
234  } else {
236  }
237  }
238  if(doHOSiPM) {
242  }
243 
244  // if both are present, fill the SiPM cells now
245  if(doHBHEHPD && doHBHESiPM) {
246 
247  // std::cout << "HcalDigitizer: fill the SiPM cells now" << std::endl;
248 
250  }
251 
254 
255  bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
256  //initialize: they won't be called later if flag is set
257  theTimeSlewSim = 0;
258  if(doTimeSlew) {
259  // no time slewing for HF
260  theTimeSlewSim = new HcalTimeSlewSim(theParameterMap);
261  theHBHEAmplifier->setTimeSlewSim(theTimeSlewSim);
262  theHOAmplifier->setTimeSlewSim(theTimeSlewSim);
263  theZDCAmplifier->setTimeSlewSim(theTimeSlewSim);
264  }
265 
266  if (doHFUpgrade) {
268 
269  // std::cout << "HcalDigitizer: theHFUpgradeDigitizer created" << std::endl;
270 
271  } else {
273  }
275 
276  edm::ParameterSet ps0 = ps.getParameter<edm::ParameterSet>("HcalReLabel");
277  relabel_ = ps0.getUntrackedParameter<bool>("RelabelHits");
278  if (relabel_) {
280  }
281 
282  bool doHPDNoise = ps.getParameter<bool>("doHPDNoise");
283  if(doHPDNoise) {
284  //edm::ParameterSet hpdNoisePset = ps.getParameter<edm::ParameterSet>("HPDNoiseLibrary");
288  }
289 
290  if(ps.getParameter<bool>("doIonFeedback") && theHBHEResponse) {
293  if(ps.getParameter<bool>("doThermalNoise")) {
295  }
296  }
297 
298  if(ps.getParameter<bool>("injectTestHits") ) {
306 
307  // std::cout << "HcalDigitizer: theHBHEUpgradeDigitizer setNoise"
308  // << std::endl;
309  }
311  if(theHFUpgradeDigitizer) {
313 
314  // std::cout << "HcalDigitizer: theHFUpgradeDigitizer setNoise"
315  // << std::endl;
316  }
318  }
319 
320  if(agingFlagHE) m_HEDarkening = new HEDarkening();
321  if(agingFlagHF) m_HFRecalibration = new HFRecalibration();
322 }
323 
324 
328  if(theHODigitizer) delete theHODigitizer;
330  if(theHFDigitizer) delete theHFDigitizer;
331  delete theZDCDigitizer;
334  delete theParameterMap;
335  delete theHBHEResponse;
336  delete theHBHESiPMResponse;
337  delete theHOResponse;
338  delete theHOSiPMResponse;
339  delete theHFResponse;
340  delete theZDCResponse;
341  delete theHBHEElectronicsSim;
342  delete theHFElectronicsSim;
343  delete theHOElectronicsSim;
344  delete theZDCElectronicsSim;
347  delete theHBHEAmplifier;
348  delete theHFAmplifier;
349  delete theHOAmplifier;
350  delete theZDCAmplifier;
351  delete theCoderFactory;
352  delete theUpgradeCoderFactory;
353  delete theHitCorrection;
354  delete theNoiseGenerator;
355  if (theRelabeller) delete theRelabeller;
356 }
357 
358 
360  noiseGenerator->setParameterMap(theParameterMap);
361  noiseGenerator->setElectronicsSim(theHBHEElectronicsSim);
363  theHBHEAmplifier->setNoiseSignalGenerator(noiseGenerator);
364 }
365 
367  noiseGenerator->setParameterMap(theParameterMap);
368  noiseGenerator->setElectronicsSim(theHFElectronicsSim);
371  theHFAmplifier->setNoiseSignalGenerator(noiseGenerator);
372 }
373 
375  noiseGenerator->setParameterMap(theParameterMap);
376  noiseGenerator->setElectronicsSim(theHOElectronicsSim);
377  theHODigitizer->setNoiseSignalGenerator(noiseGenerator);
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  eventSetup.get<HcalCholeskyMatricesRcd>().get(refCholesky);
405  const HcalCholeskyMatrices * myCholesky = refCholesky.product();
406 
407  edm::ESHandle<HcalPedestals> pedshandle;
408  eventSetup.get<HcalPedestalsRcd>().get(pedshandle);
409  const HcalPedestals * myADCPedestals = pedshandle.product();
410 
411  theHBHEAmplifier->setCholesky(myCholesky);
412  theHFAmplifier->setCholesky(myCholesky);
413  theHOAmplifier->setCholesky(myCholesky);
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  if(theHOSiPMCode == 0) {
648  theHODigitizer->setDetIds(allCells);
649  } else if(theHOSiPMCode == 1) {
650  theHOSiPMDigitizer->setDetIds(allCells);
651  // FIXME pick Zecotek or hamamatsu?
652  } else if(theHOSiPMCode == 2) {
653  std::vector<HcalDetId> zecotekDetIds, hamamatsuDetIds;
655  eventSetup.get<HcalMCParamsRcd>().get(p);
657  eventSetup.get<IdealGeometryRecord>().get(htopo);
658 
659  HcalMCParams mcParams(*p.product());
660  if (mcParams.topo()==0) {
661  mcParams.setTopo(htopo.product());
662  }
663 
664  for(std::vector<DetId>::const_iterator detItr = allCells.begin();
665  detItr != allCells.end(); ++detItr) {
666  int shapeType = mcParams.getValues(*detItr)->signalShape();
667  if(shapeType == HcalShapes::ZECOTEK) {
668  zecotekDetIds.emplace_back(*detItr);
669  theHOSiPMDetIds.push_back(*detItr);
670  } else if(shapeType == HcalShapes::HAMAMATSU) {
671  hamamatsuDetIds.emplace_back(*detItr);
672  theHOSiPMDetIds.push_back(*detItr);
673  } else {
674  theHOHPDDetIds.push_back(*detItr);
675  }
676  }
677 
678  assert(theHODigitizer);
679  assert(theHOSiPMDigitizer);
683  // FIXME not applying a HitFilter to the HPDs, for now
684  theParameterMap->setHOZecotekDetIds(zecotekDetIds);
685  theParameterMap->setHOHamamatsuDetIds(hamamatsuDetIds);
686 
687  // make sure we don't got through this exercise again
688  theHOSiPMCode = -2;
689  }
690 }
691 
692 void HcalDigitizer::darkening(std::vector<PCaloHit>& hcalHits){
693 
694  for (unsigned int ii=0; ii<hcalHits.size(); ++ii) {
695  uint32_t tmpId = hcalHits[ii].id();
696  int det, z, depth, ieta, phi, lay;
697  HcalTestNumbering::unpackHcalIndex(tmpId,det,z,depth,ieta,phi,lay);
698 
699  bool darkened = false;
700  float dweight = 1.;
701 
702  //HE darkening
703  if(det==int(HcalEndcap) && m_HEDarkening){
704  dweight = m_HEDarkening->degradation(deliveredLumi,ieta,lay-2);//NB:diff. layer count
705  darkened = true;
706  }
707 
708  //HF darkening - approximate: invert recalibration factor
709  else if(det==int(HcalForward) && m_HFRecalibration){
710  dweight = 1.0/m_HFRecalibration->getCorr(ieta,depth,deliveredLumi);
711  darkened = true;
712  }
713 
714  //create new hit with darkened energy
715  //if(darkened) hcalHits[ii] = PCaloHit(hcalHits[ii].energyEM()*dweight,hcalHits[ii].energyHad()*dweight,hcalHits[ii].time(),hcalHits[ii].geantTrackId(),hcalHits[ii].id());
716 
717  //reset hit energy
718  if(darkened) hcalHits[ii].setEnergy(hcalHits[ii].energy()*dweight);
719  }
720 
721 }
722 
723 
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
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)
void setTopo(const HcalTopology *topo) const
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:53
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
void initializeEvent(edm::Event const &e, edm::EventSetup const &c)
void setDbService(const HcalDbService *service)
void setIonFeedbackSim(HPDIonFeedbackSim *feedbackSim)
Definition: HcalAmplifier.h:30
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:76
edm::SortedCollection< HcalUpgradeDataFrame > HBHEUpgradeDigiCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
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:34
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:37
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:52
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 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