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 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  // need to make copies, because they might get different noise generators
162  theHBHEAmplifier->setHBtuningParameter(HBtp);
163  theHBHEAmplifier->setHEtuningParameter(HEtp);
166  theHBHEAmplifier->setUseOldHB(useOldNoiseHB);
167  theHBHEAmplifier->setUseOldHE(useOldNoiseHE);
168  theHFAmplifier->setUseOldHF(useOldNoiseHF);
169  theHOAmplifier->setUseOldHO(useOldNoiseHO);
170 
173 
174  // std::cout << "HcalDigitizer: theUpgradeCoderFactory created" << std::endl;
175 
182 
183  // std::cout << "HcalDigitizer: theUpgradeElectronicsSim created" << std::endl;
184 
185  // a code of 1 means make all cells SiPM
186  std::vector<int> hbSiPMCells(ps.getParameter<edm::ParameterSet>("hb").getParameter<std::vector<int> >("siPMCells"));
187  //std::vector<int> hoSiPMCells(ps.getParameter<edm::ParameterSet>("ho").getParameter<std::vector<int> >("siPMCells"));
188  // 0 means none, 1 means all, and 2 means use hardcoded
189 
190  // std::cout << std::endl << " hbSiPMCells = " << hbSiPMCells[0] << std::endl;
191 
192  bool doHBHEHPD = hbSiPMCells.empty() || (hbSiPMCells[0] != 1);
193  bool doHOHPD = (theHOSiPMCode != 1);
194  bool doHBHESiPM = !hbSiPMCells.empty();
195  bool doHOSiPM = (theHOSiPMCode != 0);
196  if(doHBHEHPD) {
198  edm::LogInfo("HcalDigitizer") <<"Set scale for HB towers";
200 
203  bool changeResponse = ps.getParameter<bool>("ChangeResponse");
204  edm::FileInPath fname = ps.getParameter<edm::FileInPath>("CorrFactorFile");
205  if (changeResponse) {
206  std::string corrFileName = fname.fullPath();
207  edm::LogInfo("HcalDigitizer") << "Set scale for HB towers from " << corrFileName;
208  theHBHEResponse->setHBHEScale(corrFileName); //GMA
209  }
210  }
211  if(doHOHPD) {
215  }
216 
217  if(doHBHESiPM) {
220  if (doHBHEUpgrade) {
222 
223  // std::cout << "HcalDigitizer: theHBHEUpgradeDigitizer created" << std::endl;
224 
225  } else {
227  }
228  }
229  if(doHOSiPM) {
233  }
234 
235  // if both are present, fill the SiPM cells now
236  if(doHBHEHPD && doHBHESiPM) {
237 
238  // std::cout << "HcalDigitizer: fill the SiPM cells now" << std::endl;
239 
241  }
242 
245 
246  bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
247  if(doTimeSlew) {
248  // no time slewing for HF
250  theHBHEAmplifier->setTimeSlewSim(theTimeSlewSim);
253  }
254 
255  if (doHFUpgrade) {
257 
258  // std::cout << "HcalDigitizer: theHFUpgradeDigitizer created" << std::endl;
259 
260  } else {
262  }
264 
265  edm::ParameterSet ps0 = ps.getParameter<edm::ParameterSet>("HcalReLabel");
266  relabel_ = ps0.getUntrackedParameter<bool>("RelabelHits");
267  if (relabel_) {
269  }
270 
271  bool doHPDNoise = ps.getParameter<bool>("doHPDNoise");
272  if(doHPDNoise) {
273  //edm::ParameterSet hpdNoisePset = ps.getParameter<edm::ParameterSet>("HPDNoiseLibrary");
277  }
278 
279  if(ps.getParameter<bool>("doIonFeedback") && theHBHEResponse) {
282  if(ps.getParameter<bool>("doThermalNoise")) {
283  theHBHEAmplifier->setIonFeedbackSim(theIonFeedback);
284  }
285  }
286 
287  if(ps.getParameter<bool>("injectTestHits") ) {
295 
296  // std::cout << "HcalDigitizer: theHBHEUpgradeDigitizer setNoise"
297  // << std::endl;
298  }
300  if(theHFUpgradeDigitizer) {
302 
303  // std::cout << "HcalDigitizer: theHFUpgradeDigitizer setNoise"
304  // << std::endl;
305  }
307  }
308 
310  if ( ! rng.isAvailable()) {
311  throw cms::Exception("Configuration")
312  << "HcalDigitizer requires the RandomNumberGeneratorService\n"
313  "which is not present in the configuration file. You must add the service\n"
314  "in the configuration file or remove the modules that require it.";
315  }
316 
317  CLHEP::HepRandomEngine& engine = rng->getEngine();
328 
330 
331  if(agingFlagHE) m_HEDarkening = new HEDarkening();
332  if(agingFlagHF) m_HFRecalibration = new HFRecalibration();
333 }
334 
335 
339  if(theHODigitizer) delete theHODigitizer;
341  if(theHFDigitizer) delete theHFDigitizer;
342  delete theZDCDigitizer;
345  delete theParameterMap;
346  delete theHBHEResponse;
347  delete theHBHESiPMResponse;
348  delete theHOResponse;
349  delete theHOSiPMResponse;
350  delete theHFResponse;
351  delete theZDCResponse;
352  delete theHBHEElectronicsSim;
353  delete theHFElectronicsSim;
354  delete theHOElectronicsSim;
355  delete theZDCElectronicsSim;
358  delete theHBHEAmplifier;
359  delete theHFAmplifier;
360  delete theHOAmplifier;
361  delete theZDCAmplifier;
362  delete theCoderFactory;
363  delete theUpgradeCoderFactory;
364  delete theHitCorrection;
365  delete theNoiseGenerator;
366  if (theRelabeller) delete theRelabeller;
367 }
368 
369 
371  noiseGenerator->setParameterMap(theParameterMap);
372  noiseGenerator->setElectronicsSim(theHBHEElectronicsSim);
374  theHBHEAmplifier->setNoiseSignalGenerator(noiseGenerator);
375 }
376 
378  noiseGenerator->setParameterMap(theParameterMap);
379  noiseGenerator->setElectronicsSim(theHFElectronicsSim);
382  theHFAmplifier->setNoiseSignalGenerator(noiseGenerator);
383 }
384 
386  noiseGenerator->setParameterMap(theParameterMap);
387  noiseGenerator->setElectronicsSim(theHOElectronicsSim);
388  theHODigitizer->setNoiseSignalGenerator(noiseGenerator);
389  theHOAmplifier->setNoiseSignalGenerator(noiseGenerator);
390 }
391 
393  noiseGenerator->setParameterMap(theParameterMap);
394  noiseGenerator->setElectronicsSim(theZDCElectronicsSim);
395  theZDCDigitizer->setNoiseSignalGenerator(noiseGenerator);
396  theZDCAmplifier->setNoiseSignalGenerator(noiseGenerator);
397 }
398 
400  // get the appropriate gains, noises, & widths for this event
401  edm::ESHandle<HcalDbService> conditions;
402  eventSetup.get<HcalDbRecord>().get(conditions);
403  theHBHEAmplifier->setDbService(conditions.product());
404  theHFAmplifier->setDbService(conditions.product());
405  theHOAmplifier->setDbService(conditions.product());
406  theZDCAmplifier->setDbService(conditions.product());
409 
410  theCoderFactory->setDbService(conditions.product());
412  theParameterMap->setDbService(conditions.product());
413 
415  eventSetup.get<HcalCholeskyMatricesRcd>().get(refCholesky);
416  const HcalCholeskyMatrices * myCholesky = refCholesky.product();
417 
418  edm::ESHandle<HcalPedestals> pedshandle;
419  eventSetup.get<HcalPedestalsRcd>().get(pedshandle);
420  const HcalPedestals * myADCPedestals = pedshandle.product();
421 
422  theHBHEAmplifier->setCholesky(myCholesky);
423  theHFAmplifier->setCholesky(myCholesky);
424  theHOAmplifier->setCholesky(myCholesky);
425 
426  theHBHEAmplifier->setADCPeds(myADCPedestals);
427  theHFAmplifier->setADCPeds(myADCPedestals);
428  theHOAmplifier->setADCPeds(myADCPedestals);
429 
430  if(theHitCorrection != 0) {
432  }
433 
434  //initialize hits
443 
444 }
445 
446 void HcalDigitizer::accumulateCaloHits(edm::Handle<std::vector<PCaloHit> > const& hcalHandle, edm::Handle<std::vector<PCaloHit> > const& zdcHandle, int bunchCrossing) {
447  // Step A: pass in inputs, and accumulate digirs
448  if(isHCAL) {
449  std::vector<PCaloHit> hcalHits = *hcalHandle.product();
450  //evaluate darkening before relabeling
452  darkening(hcalHits);
453  }
454  if (relabel_) {
455  // Relabel PCaloHits
456  edm::LogInfo("HcalDigitizer") << "Calling Relabeller";
457  theRelabeller->process(hcalHits);
458  }
459  if(theHitCorrection != 0) {
460  theHitCorrection->fillChargeSums(hcalHits);
461  }
462  if(hbhegeo) {
463  if(theHBHEDigitizer) theHBHEDigitizer->add(hcalHits, bunchCrossing);
464  if(theHBHESiPMDigitizer) theHBHESiPMDigitizer->add(hcalHits, bunchCrossing);
466  // std::cout << "HcalDigitizer::accumulateCaloHits theHBHEUpgradeDigitizer->add" << std::endl;
467  theHBHEUpgradeDigitizer->add(hcalHits, bunchCrossing);
468  }
469  }
470 
471  if(hogeo) {
472  if(theHODigitizer) theHODigitizer->add(hcalHits, bunchCrossing);
473  if(theHOSiPMDigitizer) theHOSiPMDigitizer->add(hcalHits, bunchCrossing);
474  }
475 
476  if(hfgeo) {
477  if(theHFDigitizer) theHFDigitizer->add(hcalHits, bunchCrossing);
478  if(theHFUpgradeDigitizer) theHFUpgradeDigitizer->add(hcalHits, bunchCrossing);
479  }
480  } else {
481  edm::LogInfo("HcalDigitizer") << "We don't have HCAL hit collection available ";
482  }
483 
484  if(isZDC) {
485  if(zdcgeo) {
486  theZDCDigitizer->add(*zdcHandle.product(), bunchCrossing);
487  }
488  } else {
489  edm::LogInfo("HcalDigitizer") << "We don't have ZDC hit collection available ";
490  }
491 }
492 
493 void HcalDigitizer::accumulate(edm::Event const& e, edm::EventSetup const& eventSetup) {
494  // Step A: Get Inputs
495  edm::InputTag zdcTag(hitsProducer_, "ZDCHITS");
497  e.getByLabel(zdcTag, zdcHandle);
498  isZDC = zdcHandle.isValid();
499 
500  edm::InputTag hcalTag(hitsProducer_, "HcalHits");
502  e.getByLabel(hcalTag, hcalHandle);
503  isHCAL = hcalHandle.isValid();
504 
505  accumulateCaloHits(hcalHandle, zdcHandle, 0);
506 }
507 
509  // Step A: Get Inputs
510  edm::InputTag zdcTag(hitsProducer_, "ZDCHITS");
512  e.getByLabel(zdcTag, zdcHandle);
513  isZDC = zdcHandle.isValid();
514 
515  edm::InputTag hcalTag(hitsProducer_, "HcalHits");
517  e.getByLabel(hcalTag, hcalHandle);
518  isHCAL = hcalHandle.isValid();
519 
520  accumulateCaloHits(hcalHandle, zdcHandle, e.bunchCrossing());
521 }
522 
524 
525  // Step B: Create empty output
526  std::auto_ptr<HBHEDigiCollection> hbheResult(new HBHEDigiCollection());
527  std::auto_ptr<HODigiCollection> hoResult(new HODigiCollection());
528  std::auto_ptr<HFDigiCollection> hfResult(new HFDigiCollection());
529  std::auto_ptr<ZDCDigiCollection> zdcResult(new ZDCDigiCollection());
530  std::auto_ptr<HBHEUpgradeDigiCollection> hbheupgradeResult(new HBHEUpgradeDigiCollection());
531  std::auto_ptr<HFUpgradeDigiCollection> hfupgradeResult(new HFUpgradeDigiCollection());
532 
533  // Step C: Invoke the algorithm, getting back outputs.
534  if(isHCAL&&hbhegeo){
535  if(theHBHEDigitizer) theHBHEDigitizer->run(*hbheResult);
538  theHBHEUpgradeDigitizer->run(*hbheupgradeResult);
539 
540  // std::cout << "HcalDigitizer::finalizeEvent theHBHEUpgradeDigitizer->run" << std::endl;
541  }
542  }
543  if(isHCAL&&hogeo) {
544  if(theHODigitizer) theHODigitizer->run(*hoResult);
545  if(theHOSiPMDigitizer) theHOSiPMDigitizer->run(*hoResult);
546  }
547  if(isHCAL&&hfgeo) {
548  if(theHFDigitizer) theHFDigitizer->run(*hfResult);
549  if(theHFUpgradeDigitizer) theHFUpgradeDigitizer->run(*hfupgradeResult);
550  }
551  if(isZDC&&zdcgeo) {
552  theZDCDigitizer->run(*zdcResult);
553  }
554 
555  edm::LogInfo("HcalDigitizer") << "HCAL HBHE digis : " << hbheResult->size();
556  edm::LogInfo("HcalDigitizer") << "HCAL HO digis : " << hoResult->size();
557  edm::LogInfo("HcalDigitizer") << "HCAL HF digis : " << hfResult->size();
558  edm::LogInfo("HcalDigitizer") << "HCAL ZDC digis : " << zdcResult->size();
559  edm::LogInfo("HcalDigitizer") << "HCAL HBHE upgrade digis : " << hbheupgradeResult->size();
560  edm::LogInfo("HcalDigitizer") << "HCAL HF upgrade digis : " << hfupgradeResult->size();
561 
562  /*
563  std::cout << std::endl;
564  std::cout << "HCAL HBHE digis : " << hbheResult->size() << std::endl;
565  std::cout << "HCAL HO digis : " << hoResult->size() << std::endl;
566  std::cout << "HCAL HF digis : " << hfResult->size() << std::endl;
567 
568  std::cout << "HCAL HBHE upgrade digis : " << hbheupgradeResult->size()
569  << std::endl;
570  std::cout << "HCAL HF upgrade digis : " << hfupgradeResult->size()
571  << std::endl;
572  */
573 
574  // Step D: Put outputs into event
575  e.put(hbheResult);
576  e.put(hoResult);
577  e.put(hfResult);
578  e.put(zdcResult);
579  e.put(hbheupgradeResult,"HBHEUpgradeDigiCollection");
580  e.put(hfupgradeResult, "HFUpgradeDigiCollection");
581 
582  // std::cout << std::endl << "========> HcalDigitizer e.put "
583  // << std::endl << std::endl;
584 
585  if(theHitCorrection) {
587  }
588 }
589 
590 
592  checkGeometry(es);
593  theShapes->beginRun(es);
594 }
595 
596 
598  theShapes->endRun();
599 }
600 
601 
603  // TODO find a way to avoid doing this every event
605  eventSetup.get<CaloGeometryRecord>().get(geometry);
606  // See if it's been updated
607  if(&*geometry != theGeometry)
608  {
609  theGeometry = &*geometry;
610  updateGeometry(eventSetup);
611  }
612 }
613 
614 
623 
624  const std::vector<DetId>& hbCells = theGeometry->getValidDetIds(DetId::Hcal, HcalBarrel);
625  const std::vector<DetId>& heCells = theGeometry->getValidDetIds(DetId::Hcal, HcalEndcap);
626  const std::vector<DetId>& hoCells = theGeometry->getValidDetIds(DetId::Hcal, HcalOuter);
627  const std::vector<DetId>& hfCells = theGeometry->getValidDetIds(DetId::Hcal, HcalForward);
628  const std::vector<DetId>& zdcCells = theGeometry->getValidDetIds(DetId::Calo, HcalZDCDetId::SubdetectorId);
629  //const std::vector<DetId>& hcalTrigCells = geometry->getValidDetIds(DetId::Hcal, HcalTriggerTower);
630  //const std::vector<DetId>& hcalCalib = geometry->getValidDetIds(DetId::Calo, HcalCastorDetId::SubdetectorId);
631  //std::cout<<"HcalDigitizer::CheckGeometry number of cells: "<<zdcCells.size()<<std::endl;
632  if(zdcCells.empty()) zdcgeo = false;
633  if(hbCells.empty() && heCells.empty()) hbhegeo = false;
634  if(hoCells.empty()) hogeo = false;
635  if(hfCells.empty()) hfgeo = false;
636  // combine HB & HE
637 
638  theHBHEDetIds = hbCells;
639  theHBHEDetIds.insert(theHBHEDetIds.end(), heCells.begin(), heCells.end());
640 
642  //HcalDigitizerImpl::fillCells(hoCells, theHODigitizer, theHOSiPMDigitizer);
643  buildHOSiPMCells(hoCells, eventSetup);
646  theZDCDigitizer->setDetIds(zdcCells);
649 
650  // std::cout << " HcalDigitizer::updateGeometry theHBHEUpgradeDigitizer->setDetIds(theHBHEDetIds)"<< std::endl;
651  }
652 
653 }
654 
655 
656 void HcalDigitizer::buildHOSiPMCells(const std::vector<DetId>& allCells, const edm::EventSetup & eventSetup) {
657  // all HPD
658  if(theHOSiPMCode == 0) {
659  theHODigitizer->setDetIds(allCells);
660  } else if(theHOSiPMCode == 1) {
661  theHOSiPMDigitizer->setDetIds(allCells);
662  // FIXME pick Zecotek or hamamatsu?
663  } else if(theHOSiPMCode == 2) {
664  std::vector<HcalDetId> zecotekDetIds, hamamatsuDetIds;
666  eventSetup.get<HcalMCParamsRcd>().get(p);
668  eventSetup.get<IdealGeometryRecord>().get(htopo);
669 
670  HcalMCParams mcParams(*p.product());
671  if (mcParams.topo()==0) {
672  mcParams.setTopo(htopo.product());
673  }
674 
675  for(std::vector<DetId>::const_iterator detItr = allCells.begin();
676  detItr != allCells.end(); ++detItr) {
677  int shapeType = mcParams.getValues(*detItr)->signalShape();
678  if(shapeType == HcalShapes::ZECOTEK) {
679  zecotekDetIds.emplace_back(*detItr);
680  theHOSiPMDetIds.push_back(*detItr);
681  } else if(shapeType == HcalShapes::HAMAMATSU) {
682  hamamatsuDetIds.emplace_back(*detItr);
683  theHOSiPMDetIds.push_back(*detItr);
684  } else {
685  theHOHPDDetIds.push_back(*detItr);
686  }
687  }
688 
689  assert(theHODigitizer);
690  assert(theHOSiPMDigitizer);
694  // FIXME not applying a HitFilter to the HPDs, for now
695  theParameterMap->setHOZecotekDetIds(zecotekDetIds);
696  theParameterMap->setHOHamamatsuDetIds(hamamatsuDetIds);
697 
698  // make sure we don't got through this exercise again
699  theHOSiPMCode = -2;
700  }
701 }
702 
703 void HcalDigitizer::darkening(std::vector<PCaloHit>& hcalHits){
704 
705  for (unsigned int ii=0; ii<hcalHits.size(); ++ii) {
706  uint32_t tmpId = hcalHits[ii].id();
707  int det, z, depth, ieta, phi, lay;
708  HcalTestNumbering::unpackHcalIndex(tmpId,det,z,depth,ieta,phi,lay);
709 
710  bool darkened = false;
711  float dweight = 1.;
712 
713  //HE darkening
714  if(det==int(HcalEndcap) && m_HEDarkening){
715  dweight = m_HEDarkening->degradation(deliveredLumi,ieta,lay-2);//NB:diff. layer count
716  darkened = true;
717  }
718 
719  //HF darkening - approximate: invert recalibration factor
720  else if(det==int(HcalForward) && m_HFRecalibration){
721  dweight = 1.0/m_HFRecalibration->getCorr(ieta,depth,deliveredLumi);
722  darkened = true;
723  }
724 
725  //create new hit with darkened energy
726  //if(darkened) hcalHits[ii] = PCaloHit(hcalHits[ii].energyEM()*dweight,hcalHits[ii].energyHad()*dweight,hcalHits[ii].time(),hcalHits[ii].geantTrackId(),hcalHits[ii].id());
727 
728  //reset hit energy
729  if(darkened) hcalHits[ii].setEnergy(hcalHits[ii].energy()*dweight);
730  }
731 
732 }
733 
734 
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 setTimeSlewSim(const HcalTimeSlewSim *timeSlewSim)
Definition: HcalAmplifier.h:36
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)
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
double deliveredLumi
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)
void setRandomEngine(CLHEP::HepRandomEngine &engine)
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 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 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