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.
37 #include <boost/foreach.hpp>
41 
42 namespace HcalDigitizerImpl {
43 
44  template<typename SIPMDIGITIZER>
45  void fillSiPMCells(std::vector<int> & siPMCells, SIPMDIGITIZER * siPMDigitizer)
46  {
47  std::vector<DetId> siPMDetIds;
48  siPMDetIds.reserve(siPMCells.size());
49  for(std::vector<int>::const_iterator idItr = siPMCells.begin();
50  idItr != siPMCells.end(); ++idItr)
51  {
52  siPMDetIds.emplace_back(*idItr);
53  }
54  siPMDigitizer->setDetIds(siPMDetIds);
55  }
56 
57  // if both exist, assume the SiPM one has cells filled, and
58  // assign the rest to the HPD
59  template<typename HPDDIGITIZER, typename SIPMDIGITIZER>
60  void fillCells(std::vector<DetId>& allCells,
61  HPDDIGITIZER * hpdDigitizer,
62  SIPMDIGITIZER * siPMDigitizer)
63  {
64  // if both digitizers exist, split up the cells
65  if(siPMDigitizer && hpdDigitizer)
66  {
67  std::vector<DetId> siPMDetIds = siPMDigitizer->detIds();
68  std::sort(siPMDetIds.begin(), siPMDetIds.end());
69  std::vector<DetId> sortedCells = allCells;
70  std::sort(sortedCells.begin(), sortedCells.end());
71  std::vector<DetId> hpdCells;
72  std::set_difference(sortedCells.begin(), sortedCells.end(),
73  siPMDetIds.begin(), siPMDetIds.end(),
74  std::back_inserter(hpdCells) );
75  hpdDigitizer->setDetIds(hpdCells);
76  }
77  else
78  {
79  if(siPMDigitizer) siPMDigitizer->setDetIds(allCells);
80  if(hpdDigitizer) hpdDigitizer->setDetIds(allCells);
81  }
82  }
83 } // namespace HcaiDigitizerImpl
84 
85 
87  theGeometry(0),
88  theParameterMap(new HcalSimParameterMap(ps)),
89  theShapes(new HcalShapes()),
90  theHBHEResponse(0),
91  theHBHESiPMResponse(0),
92  theHOResponse(0),
93  theHOSiPMResponse(0),
94  theHFResponse(new CaloHitResponse(theParameterMap, theShapes)),
95  theZDCResponse(new CaloHitResponse(theParameterMap, theShapes)),
96  theHBHEAmplifier(0),
97  theHFAmplifier(0),
98  theHOAmplifier(0),
99  theZDCAmplifier(0),
100  theIonFeedback(0),
101  theCoderFactory(0),
102  theUpgradeCoderFactory(0),
103  theHBHEElectronicsSim(0),
104  theHFElectronicsSim(0),
105  theHOElectronicsSim(0),
106  theZDCElectronicsSim(0),
107  theUpgradeHBHEElectronicsSim(0),
108  theUpgradeHFElectronicsSim(0),
109  theHBHEHitFilter(),
110  theHFHitFilter(ps.getParameter<bool>("doHFWindow")),
111  theHOHitFilter(),
112  theHOSiPMHitFilter(HcalOuter),
113  theZDCHitFilter(),
114  theHitCorrection(0),
115  theNoiseGenerator(0),
116  theNoiseHitGenerator(0),
117  theHBHEDigitizer(0),
118  theHBHESiPMDigitizer(0),
119  theHODigitizer(0),
120  theHOSiPMDigitizer(0),
121  theHFDigitizer(0),
122  theZDCDigitizer(0),
123  theHBHEUpgradeDigitizer(0),
124  theHFUpgradeDigitizer(0),
125  theRelabeller(0),
126  isZDC(true),
127  isHCAL(true),
128  zdcgeo(true),
129  hbhegeo(true),
130  hogeo(true),
131  hfgeo(true),
132  hitsProducer_(ps.getParameter<std::string>("hitsProducer")),
133  theHOSiPMCode(ps.getParameter<edm::ParameterSet>("ho").getParameter<int>("siPMCode")),
134  deliveredLumi(0.),
135  m_HEDarkening(0),
136  m_HFRecalibration(0)
137 {
138  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(hitsProducer_, "ZDCHITS"));
139  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(hitsProducer_, "HcalHits"));
140 
141  bool doNoise = ps.getParameter<bool>("doNoise");
142  bool PreMix1 = ps.getParameter<bool>("HcalPreMixStage1"); // special threshold/pedestal treatment
143  bool PreMix2 = ps.getParameter<bool>("HcalPreMixStage2"); // special threshold/pedestal treatment
144  bool useOldNoiseHB = ps.getParameter<bool>("useOldHB");
145  bool useOldNoiseHE = ps.getParameter<bool>("useOldHE");
146  bool useOldNoiseHF = ps.getParameter<bool>("useOldHF");
147  bool useOldNoiseHO = ps.getParameter<bool>("useOldHO");
148  bool doEmpty = ps.getParameter<bool>("doEmpty");
149  double HBtp = ps.getParameter<double>("HBTuningParameter");
150  double HEtp = ps.getParameter<double>("HETuningParameter");
151  double HFtp = ps.getParameter<double>("HFTuningParameter");
152  double HOtp = ps.getParameter<double>("HOTuningParameter");
153  bool doHBHEUpgrade = ps.getParameter<bool>("HBHEUpgradeQIE");
154  bool doHFUpgrade = ps.getParameter<bool>("HFUpgradeQIE");
155  deliveredLumi = ps.getParameter<double>("DelivLuminosity");
156  bool agingFlagHE = ps.getParameter<bool>("HEDarkening");
157  bool agingFlagHF = ps.getParameter<bool>("HFDarkening");
158 
159 
160  if(PreMix1 && PreMix2) {
161  throw cms::Exception("Configuration")
162  << "HcalDigitizer cannot operate in PreMixing digitization and PreMixing\n"
163  "digi combination modes at the same time. Please set one mode to False\n"
164  "in the configuration file.";
165  }
166 
167 
168  // need to make copies, because they might get different noise generators
169  theHBHEAmplifier = new HcalAmplifier(theParameterMap, doNoise, PreMix1, PreMix2);
170  theHFAmplifier = new HcalAmplifier(theParameterMap, doNoise, PreMix1, PreMix2);
171  theHOAmplifier = new HcalAmplifier(theParameterMap, doNoise, PreMix1, PreMix2);
172  theZDCAmplifier = new HcalAmplifier(theParameterMap, doNoise, PreMix1, PreMix2);
177  theHBHEAmplifier->setUseOldHB(useOldNoiseHB);
178  theHBHEAmplifier->setUseOldHE(useOldNoiseHE);
179  theHFAmplifier->setUseOldHF(useOldNoiseHF);
180  theHOAmplifier->setUseOldHO(useOldNoiseHO);
181 
184 
185  // std::cout << "HcalDigitizer: theUpgradeCoderFactory created" << std::endl;
186 
193 
194  // std::cout << "HcalDigitizer: theUpgradeElectronicsSim created" << std::endl;
195 
196  // a code of 1 means make all cells SiPM
197  std::vector<int> hbSiPMCells(ps.getParameter<edm::ParameterSet>("hb").getParameter<std::vector<int> >("siPMCells"));
198  //std::vector<int> hoSiPMCells(ps.getParameter<edm::ParameterSet>("ho").getParameter<std::vector<int> >("siPMCells"));
199  // 0 means none, 1 means all, and 2 means use hardcoded
200 
201  // std::cout << std::endl << " hbSiPMCells = " << hbSiPMCells[0] << std::endl;
202 
203  bool doHBHEHPD = hbSiPMCells.empty() || (hbSiPMCells[0] != 1);
204  bool doHOHPD = (theHOSiPMCode != 1);
205  bool doHBHESiPM = !hbSiPMCells.empty();
206  bool doHOSiPM = (theHOSiPMCode != 0);
207  if(doHBHEHPD) {
209  edm::LogInfo("HcalDigitizer") <<"Set scale for HB towers";
211 
214  bool changeResponse = ps.getParameter<bool>("ChangeResponse");
215  edm::FileInPath fname = ps.getParameter<edm::FileInPath>("CorrFactorFile");
216  if (changeResponse) {
217  std::string corrFileName = fname.fullPath();
218  edm::LogInfo("HcalDigitizer") << "Set scale for HB towers from " << corrFileName;
219  theHBHEResponse->setHBHEScale(corrFileName); //GMA
220  }
221  }
222  if(doHOHPD) {
226  }
227 
228  if(doHBHESiPM) {
231  if (doHBHEUpgrade) {
233 
234  // std::cout << "HcalDigitizer: theHBHEUpgradeDigitizer created" << std::endl;
235 
236  } else {
238  }
239  }
240  if(doHOSiPM) {
244  }
245 
246  // if both are present, fill the SiPM cells now
247  if(doHBHEHPD && doHBHESiPM) {
248 
249  // std::cout << "HcalDigitizer: fill the SiPM cells now" << std::endl;
250 
252  }
253 
256 
257  bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
258  //initialize: they won't be called later if flag is set
259  theTimeSlewSim = 0;
260  if(doTimeSlew) {
261  // no time slewing for HF
262  theTimeSlewSim = new HcalTimeSlewSim(theParameterMap);
263  theHBHEAmplifier->setTimeSlewSim(theTimeSlewSim);
264  theHOAmplifier->setTimeSlewSim(theTimeSlewSim);
265  theZDCAmplifier->setTimeSlewSim(theTimeSlewSim);
266  }
267 
268  if (doHFUpgrade) {
270 
271  // std::cout << "HcalDigitizer: theHFUpgradeDigitizer created" << std::endl;
272 
273  } else {
275  }
277 
278  edm::ParameterSet ps0 = ps.getParameter<edm::ParameterSet>("HcalReLabel");
279  relabel_ = ps0.getUntrackedParameter<bool>("RelabelHits");
280  if (relabel_) {
282  }
283 
284  bool doHPDNoise = ps.getParameter<bool>("doHPDNoise");
285  if(doHPDNoise) {
286  //edm::ParameterSet hpdNoisePset = ps.getParameter<edm::ParameterSet>("HPDNoiseLibrary");
290  }
291 
292  if(ps.getParameter<bool>("doIonFeedback") && theHBHEResponse) {
295  if(ps.getParameter<bool>("doThermalNoise")) {
297  }
298  }
299 
300  if(ps.getParameter<bool>("injectTestHits") ) {
308 
309  // std::cout << "HcalDigitizer: theHBHEUpgradeDigitizer setNoise"
310  // << std::endl;
311  }
313  if(theHFUpgradeDigitizer) {
315 
316  // std::cout << "HcalDigitizer: theHFUpgradeDigitizer setNoise"
317  // << std::endl;
318  }
320  }
321 
323  if ( ! rng.isAvailable()) {
324  throw cms::Exception("Configuration")
325  << "HcalDigitizer requires the RandomNumberGeneratorService\n"
326  "which is not present in the configuration file. You must add the service\n"
327  "in the configuration file or remove the modules that require it.";
328  }
329 
330  CLHEP::HepRandomEngine& engine = rng->getEngine();
337  if(theTimeSlewSim) theTimeSlewSim->setRandomEngine(engine);
341 
343 
344  if(agingFlagHE) m_HEDarkening = new HEDarkening();
345  if(agingFlagHF) m_HFRecalibration = new HFRecalibration();
346 }
347 
348 
352  if(theHODigitizer) delete theHODigitizer;
354  if(theHFDigitizer) delete theHFDigitizer;
355  delete theZDCDigitizer;
358  delete theParameterMap;
359  delete theHBHEResponse;
360  delete theHBHESiPMResponse;
361  delete theHOResponse;
362  delete theHOSiPMResponse;
363  delete theHFResponse;
364  delete theZDCResponse;
365  delete theHBHEElectronicsSim;
366  delete theHFElectronicsSim;
367  delete theHOElectronicsSim;
368  delete theZDCElectronicsSim;
371  delete theHBHEAmplifier;
372  delete theHFAmplifier;
373  delete theHOAmplifier;
374  delete theZDCAmplifier;
375  delete theCoderFactory;
376  delete theUpgradeCoderFactory;
377  delete theHitCorrection;
378  delete theNoiseGenerator;
379  if (theRelabeller) delete theRelabeller;
380 }
381 
382 
384  noiseGenerator->setParameterMap(theParameterMap);
385  noiseGenerator->setElectronicsSim(theHBHEElectronicsSim);
387  theHBHEAmplifier->setNoiseSignalGenerator(noiseGenerator);
388 }
389 
391  noiseGenerator->setParameterMap(theParameterMap);
392  noiseGenerator->setElectronicsSim(theHFElectronicsSim);
395  theHFAmplifier->setNoiseSignalGenerator(noiseGenerator);
396 }
397 
399  noiseGenerator->setParameterMap(theParameterMap);
400  noiseGenerator->setElectronicsSim(theHOElectronicsSim);
401  theHODigitizer->setNoiseSignalGenerator(noiseGenerator);
402  theHOAmplifier->setNoiseSignalGenerator(noiseGenerator);
403 }
404 
406  noiseGenerator->setParameterMap(theParameterMap);
407  noiseGenerator->setElectronicsSim(theZDCElectronicsSim);
408  theZDCDigitizer->setNoiseSignalGenerator(noiseGenerator);
409  theZDCAmplifier->setNoiseSignalGenerator(noiseGenerator);
410 }
411 
413  // get the appropriate gains, noises, & widths for this event
414  edm::ESHandle<HcalDbService> conditions;
415  eventSetup.get<HcalDbRecord>().get(conditions);
416  theHBHEAmplifier->setDbService(conditions.product());
417  theHFAmplifier->setDbService(conditions.product());
418  theHOAmplifier->setDbService(conditions.product());
419  theZDCAmplifier->setDbService(conditions.product());
422 
423  theCoderFactory->setDbService(conditions.product());
425  theParameterMap->setDbService(conditions.product());
426 
428  eventSetup.get<HcalCholeskyMatricesRcd>().get(refCholesky);
429  const HcalCholeskyMatrices * myCholesky = refCholesky.product();
430 
431  edm::ESHandle<HcalPedestals> pedshandle;
432  eventSetup.get<HcalPedestalsRcd>().get(pedshandle);
433  const HcalPedestals * myADCPedestals = pedshandle.product();
434 
435  theHBHEAmplifier->setCholesky(myCholesky);
436  theHFAmplifier->setCholesky(myCholesky);
437  theHOAmplifier->setCholesky(myCholesky);
438 
439  theHBHEAmplifier->setADCPeds(myADCPedestals);
440  theHFAmplifier->setADCPeds(myADCPedestals);
441  theHOAmplifier->setADCPeds(myADCPedestals);
442 
443  if(theHitCorrection != 0) {
445  }
446 
447  //initialize hits
456 
457 }
458 
459 void HcalDigitizer::accumulateCaloHits(edm::Handle<std::vector<PCaloHit> > const& hcalHandle, edm::Handle<std::vector<PCaloHit> > const& zdcHandle, int bunchCrossing) {
460  // Step A: pass in inputs, and accumulate digirs
461  if(isHCAL) {
462  std::vector<PCaloHit> hcalHits = *hcalHandle.product();
463  //evaluate darkening before relabeling
465  darkening(hcalHits);
466  }
467  if (relabel_) {
468  // Relabel PCaloHits
469  edm::LogInfo("HcalDigitizer") << "Calling Relabeller";
470  theRelabeller->process(hcalHits);
471  }
472  if(theHitCorrection != 0) {
473  theHitCorrection->fillChargeSums(hcalHits);
474  }
475  if(hbhegeo) {
476  if(theHBHEDigitizer) theHBHEDigitizer->add(hcalHits, bunchCrossing);
477  if(theHBHESiPMDigitizer) theHBHESiPMDigitizer->add(hcalHits, bunchCrossing);
479  // std::cout << "HcalDigitizer::accumulateCaloHits theHBHEUpgradeDigitizer->add" << std::endl;
480  theHBHEUpgradeDigitizer->add(hcalHits, bunchCrossing);
481  }
482  }
483 
484  if(hogeo) {
485  if(theHODigitizer) theHODigitizer->add(hcalHits, bunchCrossing);
486  if(theHOSiPMDigitizer) theHOSiPMDigitizer->add(hcalHits, bunchCrossing);
487  }
488 
489  if(hfgeo) {
490  if(theHFDigitizer) theHFDigitizer->add(hcalHits, bunchCrossing);
491  if(theHFUpgradeDigitizer) theHFUpgradeDigitizer->add(hcalHits, bunchCrossing);
492  }
493  } else {
494  edm::LogInfo("HcalDigitizer") << "We don't have HCAL hit collection available ";
495  }
496 
497  if(isZDC) {
498  if(zdcgeo) {
499  theZDCDigitizer->add(*zdcHandle.product(), bunchCrossing);
500  }
501  } else {
502  edm::LogInfo("HcalDigitizer") << "We don't have ZDC hit collection available ";
503  }
504 }
505 
506 void HcalDigitizer::accumulate(edm::Event const& e, edm::EventSetup const& eventSetup) {
507  // Step A: Get Inputs
508  edm::InputTag zdcTag(hitsProducer_, "ZDCHITS");
510  e.getByLabel(zdcTag, zdcHandle);
511  isZDC = zdcHandle.isValid();
512 
513  edm::InputTag hcalTag(hitsProducer_, "HcalHits");
515  e.getByLabel(hcalTag, hcalHandle);
516  isHCAL = hcalHandle.isValid();
517 
518  accumulateCaloHits(hcalHandle, zdcHandle, 0);
519 }
520 
522  // Step A: Get Inputs
523  edm::InputTag zdcTag(hitsProducer_, "ZDCHITS");
525  e.getByLabel(zdcTag, zdcHandle);
526  isZDC = zdcHandle.isValid();
527 
528  edm::InputTag hcalTag(hitsProducer_, "HcalHits");
530  e.getByLabel(hcalTag, hcalHandle);
531  isHCAL = hcalHandle.isValid();
532 
533  accumulateCaloHits(hcalHandle, zdcHandle, e.bunchCrossing());
534 }
535 
537 
538  // Step B: Create empty output
539  std::auto_ptr<HBHEDigiCollection> hbheResult(new HBHEDigiCollection());
540  std::auto_ptr<HODigiCollection> hoResult(new HODigiCollection());
541  std::auto_ptr<HFDigiCollection> hfResult(new HFDigiCollection());
542  std::auto_ptr<ZDCDigiCollection> zdcResult(new ZDCDigiCollection());
543  std::auto_ptr<HBHEUpgradeDigiCollection> hbheupgradeResult(new HBHEUpgradeDigiCollection());
544  std::auto_ptr<HFUpgradeDigiCollection> hfupgradeResult(new HFUpgradeDigiCollection());
545 
546  // Step C: Invoke the algorithm, getting back outputs.
547  if(isHCAL&&hbhegeo){
548  if(theHBHEDigitizer) theHBHEDigitizer->run(*hbheResult);
551  theHBHEUpgradeDigitizer->run(*hbheupgradeResult);
552 
553  // std::cout << "HcalDigitizer::finalizeEvent theHBHEUpgradeDigitizer->run" << std::endl;
554  }
555  }
556  if(isHCAL&&hogeo) {
557  if(theHODigitizer) theHODigitizer->run(*hoResult);
558  if(theHOSiPMDigitizer) theHOSiPMDigitizer->run(*hoResult);
559  }
560  if(isHCAL&&hfgeo) {
561  if(theHFDigitizer) theHFDigitizer->run(*hfResult);
562  if(theHFUpgradeDigitizer) theHFUpgradeDigitizer->run(*hfupgradeResult);
563  }
564  if(isZDC&&zdcgeo) {
565  theZDCDigitizer->run(*zdcResult);
566  }
567 
568  edm::LogInfo("HcalDigitizer") << "HCAL HBHE digis : " << hbheResult->size();
569  edm::LogInfo("HcalDigitizer") << "HCAL HO digis : " << hoResult->size();
570  edm::LogInfo("HcalDigitizer") << "HCAL HF digis : " << hfResult->size();
571  edm::LogInfo("HcalDigitizer") << "HCAL ZDC digis : " << zdcResult->size();
572  edm::LogInfo("HcalDigitizer") << "HCAL HBHE upgrade digis : " << hbheupgradeResult->size();
573  edm::LogInfo("HcalDigitizer") << "HCAL HF upgrade digis : " << hfupgradeResult->size();
574 
575  /*
576  std::cout << std::endl;
577  std::cout << "HCAL HBHE digis : " << hbheResult->size() << std::endl;
578  std::cout << "HCAL HO digis : " << hoResult->size() << std::endl;
579  std::cout << "HCAL HF digis : " << hfResult->size() << std::endl;
580 
581  std::cout << "HCAL HBHE upgrade digis : " << hbheupgradeResult->size()
582  << std::endl;
583  std::cout << "HCAL HF upgrade digis : " << hfupgradeResult->size()
584  << std::endl;
585  */
586 
587  // Step D: Put outputs into event
588  e.put(hbheResult);
589  e.put(hoResult);
590  e.put(hfResult);
591  e.put(zdcResult);
592  e.put(hbheupgradeResult,"HBHEUpgradeDigiCollection");
593  e.put(hfupgradeResult, "HFUpgradeDigiCollection");
594 
595  // std::cout << std::endl << "========> HcalDigitizer e.put "
596  // << std::endl << std::endl;
597 
598  if(theHitCorrection) {
600  }
601 }
602 
603 
605  checkGeometry(es);
606  theShapes->beginRun(es);
607 }
608 
609 
611  theShapes->endRun();
612 }
613 
614 
616  // TODO find a way to avoid doing this every event
618  eventSetup.get<CaloGeometryRecord>().get(geometry);
619  // See if it's been updated
620  if(&*geometry != theGeometry)
621  {
622  theGeometry = &*geometry;
623  updateGeometry(eventSetup);
624  }
625 }
626 
627 
636 
637  const std::vector<DetId>& hbCells = theGeometry->getValidDetIds(DetId::Hcal, HcalBarrel);
638  const std::vector<DetId>& heCells = theGeometry->getValidDetIds(DetId::Hcal, HcalEndcap);
639  const std::vector<DetId>& hoCells = theGeometry->getValidDetIds(DetId::Hcal, HcalOuter);
640  const std::vector<DetId>& hfCells = theGeometry->getValidDetIds(DetId::Hcal, HcalForward);
641  const std::vector<DetId>& zdcCells = theGeometry->getValidDetIds(DetId::Calo, HcalZDCDetId::SubdetectorId);
642  //const std::vector<DetId>& hcalTrigCells = geometry->getValidDetIds(DetId::Hcal, HcalTriggerTower);
643  //const std::vector<DetId>& hcalCalib = geometry->getValidDetIds(DetId::Calo, HcalCastorDetId::SubdetectorId);
644  //std::cout<<"HcalDigitizer::CheckGeometry number of cells: "<<zdcCells.size()<<std::endl;
645  if(zdcCells.empty()) zdcgeo = false;
646  if(hbCells.empty() && heCells.empty()) hbhegeo = false;
647  if(hoCells.empty()) hogeo = false;
648  if(hfCells.empty()) hfgeo = false;
649  // combine HB & HE
650 
651  theHBHEDetIds = hbCells;
652  theHBHEDetIds.insert(theHBHEDetIds.end(), heCells.begin(), heCells.end());
653 
655  //HcalDigitizerImpl::fillCells(hoCells, theHODigitizer, theHOSiPMDigitizer);
656  buildHOSiPMCells(hoCells, eventSetup);
659  theZDCDigitizer->setDetIds(zdcCells);
662 
663  // std::cout << " HcalDigitizer::updateGeometry theHBHEUpgradeDigitizer->setDetIds(theHBHEDetIds)"<< std::endl;
664  }
665 
666 }
667 
668 
669 void HcalDigitizer::buildHOSiPMCells(const std::vector<DetId>& allCells, const edm::EventSetup & eventSetup) {
670  // all HPD
671  if(theHOSiPMCode == 0) {
672  theHODigitizer->setDetIds(allCells);
673  } else if(theHOSiPMCode == 1) {
674  theHOSiPMDigitizer->setDetIds(allCells);
675  // FIXME pick Zecotek or hamamatsu?
676  } else if(theHOSiPMCode == 2) {
677  std::vector<HcalDetId> zecotekDetIds, hamamatsuDetIds;
679  eventSetup.get<HcalMCParamsRcd>().get(p);
681  eventSetup.get<IdealGeometryRecord>().get(htopo);
682 
683  HcalMCParams mcParams(*p.product());
684  if (mcParams.topo()==0) {
685  mcParams.setTopo(htopo.product());
686  }
687 
688  for(std::vector<DetId>::const_iterator detItr = allCells.begin();
689  detItr != allCells.end(); ++detItr) {
690  int shapeType = mcParams.getValues(*detItr)->signalShape();
691  if(shapeType == HcalShapes::ZECOTEK) {
692  zecotekDetIds.emplace_back(*detItr);
693  theHOSiPMDetIds.push_back(*detItr);
694  } else if(shapeType == HcalShapes::HAMAMATSU) {
695  hamamatsuDetIds.emplace_back(*detItr);
696  theHOSiPMDetIds.push_back(*detItr);
697  } else {
698  theHOHPDDetIds.push_back(*detItr);
699  }
700  }
701 
702  assert(theHODigitizer);
703  assert(theHOSiPMDigitizer);
707  // FIXME not applying a HitFilter to the HPDs, for now
708  theParameterMap->setHOZecotekDetIds(zecotekDetIds);
709  theParameterMap->setHOHamamatsuDetIds(hamamatsuDetIds);
710 
711  // make sure we don't got through this exercise again
712  theHOSiPMCode = -2;
713  }
714 }
715 
716 void HcalDigitizer::darkening(std::vector<PCaloHit>& hcalHits){
717 
718  for (unsigned int ii=0; ii<hcalHits.size(); ++ii) {
719  uint32_t tmpId = hcalHits[ii].id();
720  int det, z, depth, ieta, phi, lay;
721  HcalTestNumbering::unpackHcalIndex(tmpId,det,z,depth,ieta,phi,lay);
722 
723  bool darkened = false;
724  float dweight = 1.;
725 
726  //HE darkening
727  if(det==int(HcalEndcap) && m_HEDarkening){
728  dweight = m_HEDarkening->degradation(deliveredLumi,ieta,lay-2);//NB:diff. layer count
729  darkened = true;
730  }
731 
732  //HF darkening - approximate: invert recalibration factor
733  else if(det==int(HcalForward) && m_HFRecalibration){
734  dweight = 1.0/m_HFRecalibration->getCorr(ieta,depth,deliveredLumi);
735  darkened = true;
736  }
737 
738  //create new hit with darkened energy
739  //if(darkened) hcalHits[ii] = PCaloHit(hcalHits[ii].energyEM()*dweight,hcalHits[ii].energyHad()*dweight,hcalHits[ii].time(),hcalHits[ii].geantTrackId(),hcalHits[ii].id());
740 
741  //reset hit energy
742  if(darkened) hcalHits[ii].setEnergy(hcalHits[ii].energy()*dweight);
743  }
744 
745 }
746 
747 
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:79
void setRandomEngine(CLHEP::HepRandomEngine &engine)
void add(const std::vector< PCaloHit > &hits, int bunchCrossing)
void setUseOldHF(bool useOld)
void darkening(std::vector< PCaloHit > &hcalHits)
void setTopo(const HcalTopology *topo) const
HFDigitizer * theHFDigitizer
HFHitFilter theHFHitFilter
void checkGeometry(const edm::EventSetup &eventSetup)
HcalSimParameterMap * theParameterMap
Definition: HcalDigitizer.h:81
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:52
void setGeometry(const CaloGeometry *&theGeometry)
HcalAmplifier * theHFAmplifier
Definition: HcalDigitizer.h:94
HcalElectronicsSim * theUpgradeHFElectronicsSim
void fillSiPMCells(std::vector< int > &siPMCells, SIPMDIGITIZER *siPMDigitizer)
HcalCoderFactory * theCoderFactory
Definition: HcalDigitizer.h:99
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:29
UpgradeDigitizer * theHFUpgradeDigitizer
CaloTDigitizer< HFDigitizerTraits > HFDigitizer
Definition: HcalDigitizer.h:77
void setHOZecotekDetIds(const std::vector< HcalDetId > &ids)
HcalAmplifier * theHBHEAmplifier
Definition: HcalDigitizer.h:93
void setUseOldHO(bool useOld)
edm::SortedCollection< HODataFrame > HODigiCollection
CaloTDigitizer< ZDCDigitizerTraits > ZDCDigitizer
Definition: HcalDigitizer.h:78
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:82
Creates electronics signals from hits.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
void setRandomEngine(CLHEP::HepRandomEngine &engine)
need a shaper in order to set thermal noise
void setHFNoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
std::vector< DetId > theHBHEDetIds
void buildHOSiPMCells(const std::vector< DetId > &allCells, const edm::EventSetup &eventSetup)
ZDCHitFilter theZDCHitFilter
HPDIonFeedbackSim * theIonFeedback
Definition: HcalDigitizer.h:98
void fillChargeSums(MixCollection< PCaloHit > &hits)
bool isAvailable() const
Definition: Service.h:46
CaloHitResponse * theHOResponse
Definition: HcalDigitizer.h:86
HcalHitFilter theHOSiPMHitFilter
CaloHitResponse * theHOSiPMResponse
Definition: HcalDigitizer.h:87
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
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
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:390
HcalHitCorrection * theHitCorrection
CaloHitResponse * theZDCResponse
Definition: HcalDigitizer.h:89
void endRun()
Definition: HcalShapes.cc:118
void setNoiseSignalGenerator(const CaloVNoiseSignalGenerator *noiseSignalGenerator)
Definition: HcalAmplifier.h:33
void accumulateCaloHits(edm::Handle< std::vector< PCaloHit > > const &hcalHits, edm::Handle< std::vector< PCaloHit > > const &zdcHits, int bunchCrossing)
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:76
void accumulate(edm::Event const &e, edm::EventSetup const &c)
void setTimeSlewSim(HcalTimeSlewSim *timeSlewSim)
Definition: HcalAmplifier.h:36
void setHOHamamatsuDetIds(const std::vector< HcalDetId > &ids)
HcalAmplifier * theHOAmplifier
Definition: HcalDigitizer.h:95
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:62
void fillCells(std::vector< DetId > &allCells, HPDDIGITIZER *hpdDigitizer, SIPMDIGITIZER *siPMDigitizer)
CaloHitResponse * theHBHEResponse
Definition: HcalDigitizer.h:84
HODigitizer * theHODigitizer
std::vector< DetId > theHOSiPMDetIds
const CaloGeometry * theGeometry
Definition: HcalDigitizer.h:66
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:51
string fname
main script
ESHandle< TrackerGeometry > geometry
CaloHitResponse * theHFResponse
Definition: HcalDigitizer.h:88
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:85
void setRandomEngine(CLHEP::HepRandomEngine &engine)
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
Definition: HcalDigitizer.h:96
void setDbService(const HcalDbService *service)
edm::SortedCollection< HBHEDataFrame > HBHEDigiCollection
void finalizeEvent(edm::Event &e, edm::EventSetup const &c)
UpgradeDigitizer * theHBHEUpgradeDigitizer
void setHONoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
CaloTDigitizer< HBHEDigitizerTraits > HBHEDigitizer
Definition: HcalDigitizer.h:75
HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector &iC)
CaloVNoiseSignalGenerator * theNoiseGenerator
Definition: DDAxes.h:10