test
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  theRecNumber(0),
87  theParameterMap(new HcalSimParameterMap(ps)),
88  theShapes(new HcalShapes()),
89  theHBHEResponse(0),
90  theHBHESiPMResponse(0),
91  theHOResponse(0),
92  theHOSiPMResponse(0),
93  theHFResponse(new CaloHitResponse(theParameterMap, theShapes)),
94  theZDCResponse(new CaloHitResponse(theParameterMap, theShapes)),
95  theHBHEAmplifier(0),
96  theHFAmplifier(0),
97  theHOAmplifier(0),
98  theZDCAmplifier(0),
99  theIonFeedback(0),
100  theCoderFactory(0),
101  theUpgradeCoderFactory(0),
102  theHBHEElectronicsSim(0),
103  theHFElectronicsSim(0),
104  theHOElectronicsSim(0),
105  theZDCElectronicsSim(0),
106  theUpgradeHBHEElectronicsSim(0),
107  theUpgradeHFElectronicsSim(0),
108  theHBHEHitFilter(),
109  theHFHitFilter(ps.getParameter<bool>("doHFWindow")),
110  theHOHitFilter(),
111  theHOSiPMHitFilter(HcalOuter),
112  theZDCHitFilter(),
113  theHitCorrection(0),
114  theNoiseGenerator(0),
115  theNoiseHitGenerator(0),
116  theHBHEDigitizer(0),
117  theHBHESiPMDigitizer(0),
118  theHODigitizer(0),
119  theHOSiPMDigitizer(0),
120  theHFDigitizer(0),
121  theZDCDigitizer(0),
122  theHBHEUpgradeDigitizer(0),
123  theHFUpgradeDigitizer(0),
124  theRelabeller(0),
125  isZDC(true),
126  isHCAL(true),
127  zdcgeo(true),
128  hbhegeo(true),
129  hogeo(true),
130  hfgeo(true),
131  hitsProducer_(ps.getParameter<std::string>("hitsProducer")),
132  theHOSiPMCode(ps.getParameter<edm::ParameterSet>("ho").getParameter<int>("siPMCode")),
133  deliveredLumi(0.),
134  m_HEDarkening(0),
135  m_HFRecalibration(0)
136 {
137  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(hitsProducer_, "ZDCHITS"));
138  iC.consumes<std::vector<PCaloHit> >(edm::InputTag(hitsProducer_, "HcalHits"));
139 
140  bool doNoise = ps.getParameter<bool>("doNoise");
141  bool PreMix1 = ps.getParameter<bool>("HcalPreMixStage1"); // special threshold/pedestal treatment
142  bool PreMix2 = ps.getParameter<bool>("HcalPreMixStage2"); // special threshold/pedestal treatment
143  bool useOldNoiseHB = ps.getParameter<bool>("useOldHB");
144  bool useOldNoiseHE = ps.getParameter<bool>("useOldHE");
145  bool useOldNoiseHF = ps.getParameter<bool>("useOldHF");
146  bool useOldNoiseHO = ps.getParameter<bool>("useOldHO");
147  bool doEmpty = ps.getParameter<bool>("doEmpty");
148  double HBtp = ps.getParameter<double>("HBTuningParameter");
149  double HEtp = ps.getParameter<double>("HETuningParameter");
150  double HFtp = ps.getParameter<double>("HFTuningParameter");
151  double HOtp = ps.getParameter<double>("HOTuningParameter");
152  bool doHBHEUpgrade = ps.getParameter<bool>("HBHEUpgradeQIE");
153  bool doHFUpgrade = ps.getParameter<bool>("HFUpgradeQIE");
154  deliveredLumi = ps.getParameter<double>("DelivLuminosity");
155  bool agingFlagHE = ps.getParameter<bool>("HEDarkening");
156  bool agingFlagHF = ps.getParameter<bool>("HFDarkening");
157  double minFCToDelay= ps.getParameter<double>("minFCToDelay");
158 
159  if(PreMix1 && PreMix2) {
160  throw cms::Exception("Configuration")
161  << "HcalDigitizer cannot operate in PreMixing digitization and PreMixing\n"
162  "digi combination modes at the same time. Please set one mode to False\n"
163  "in the configuration file.";
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.size() << 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,minFCToDelay);
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" << std::endl;
308  }
310  if(theHFUpgradeDigitizer) {
312 
313 // std::cout << "HcalDigitizer: theHFUpgradeDigitizer setNoise" << std::endl;
314  }
316  }
317 
318  if(agingFlagHE) m_HEDarkening = new HEDarkening();
319  if(agingFlagHF) m_HFRecalibration = new HFRecalibration();
320 }
321 
322 
326  if(theHODigitizer) delete theHODigitizer;
328  if(theHFDigitizer) delete theHFDigitizer;
329  delete theZDCDigitizer;
332  delete theParameterMap;
333  delete theHBHEResponse;
334  delete theHBHESiPMResponse;
335  delete theHOResponse;
336  delete theHOSiPMResponse;
337  delete theHFResponse;
338  delete theZDCResponse;
339  delete theHBHEElectronicsSim;
340  delete theHFElectronicsSim;
341  delete theHOElectronicsSim;
342  delete theZDCElectronicsSim;
345  delete theHBHEAmplifier;
346  delete theHFAmplifier;
347  delete theHOAmplifier;
348  delete theZDCAmplifier;
349  delete theCoderFactory;
350  delete theUpgradeCoderFactory;
351  delete theHitCorrection;
352  delete theNoiseGenerator;
353  if (theRelabeller) delete theRelabeller;
354 }
355 
356 
358  noiseGenerator->setParameterMap(theParameterMap);
359  noiseGenerator->setElectronicsSim(theHBHEElectronicsSim);
361  theHBHEAmplifier->setNoiseSignalGenerator(noiseGenerator);
362 }
363 
365  noiseGenerator->setParameterMap(theParameterMap);
366  noiseGenerator->setElectronicsSim(theHFElectronicsSim);
369  theHFAmplifier->setNoiseSignalGenerator(noiseGenerator);
370 }
371 
373  noiseGenerator->setParameterMap(theParameterMap);
374  noiseGenerator->setElectronicsSim(theHOElectronicsSim);
377  theHOAmplifier->setNoiseSignalGenerator(noiseGenerator);
378 }
379 
381  noiseGenerator->setParameterMap(theParameterMap);
382  noiseGenerator->setElectronicsSim(theZDCElectronicsSim);
383  theZDCDigitizer->setNoiseSignalGenerator(noiseGenerator);
384  theZDCAmplifier->setNoiseSignalGenerator(noiseGenerator);
385 }
386 
388  // get the appropriate gains, noises, & widths for this event
389  edm::ESHandle<HcalDbService> conditions;
390  eventSetup.get<HcalDbRecord>().get(conditions);
391  theHBHEAmplifier->setDbService(conditions.product());
392  theHFAmplifier->setDbService(conditions.product());
393  theHOAmplifier->setDbService(conditions.product());
394  theZDCAmplifier->setDbService(conditions.product());
397 
398  theCoderFactory->setDbService(conditions.product());
400  theParameterMap->setDbService(conditions.product());
401 
403  if (eventSetup.find(edm::eventsetup::EventSetupRecordKey::makeKey<HcalCholeskyMatricesRcd>())) {
404  eventSetup.get<HcalCholeskyMatricesRcd>().get(refCholesky);
405  const HcalCholeskyMatrices * myCholesky = refCholesky.product();
406  theHBHEAmplifier->setCholesky(myCholesky);
407  theHFAmplifier->setCholesky(myCholesky);
408  theHOAmplifier->setCholesky(myCholesky);
409  }
410  edm::ESHandle<HcalPedestals> pedshandle;
411  eventSetup.get<HcalPedestalsRcd>().get(pedshandle);
412  const HcalPedestals * myADCPedestals = pedshandle.product();
413 
414  theHBHEAmplifier->setADCPeds(myADCPedestals);
415  theHFAmplifier->setADCPeds(myADCPedestals);
416  theHOAmplifier->setADCPeds(myADCPedestals);
417 
418  if(theHitCorrection != 0) {
420  }
421 
422  //initialize hits
431 
432 }
433 
434 void HcalDigitizer::accumulateCaloHits(edm::Handle<std::vector<PCaloHit> > const& hcalHandle, edm::Handle<std::vector<PCaloHit> > const& zdcHandle, int bunchCrossing, CLHEP::HepRandomEngine* engine, const HcalTopology *htopoP) {
435 
436  // Step A: pass in inputs, and accumulate digirs
437  if(isHCAL) {
438  std::vector<PCaloHit> hcalHitsOrig = *hcalHandle.product();
439  std::vector<PCaloHit> hcalHits;
440  hcalHits.reserve(hcalHitsOrig.size());
441 
442  for ( unsigned int i=0; i< hcalHitsOrig.size(); i++) {
443  DetId id(hcalHitsOrig[i].id());
444  HcalDetId hid(id);
445 
446  // if ( id.subdetId()==2 && hid.ietaAbs()<16 ) edm::LogError("HcalDigitizer") << "bad hcal id found in digitizer. Skipping " << id.rawId() << std::endl;
447  if ( !htopoP->validHcal(hid) ) edm::LogError("HcalDigitizer") << "bad hcal id found in digitizer. Skipping " << id.rawId() << std::endl;
448  else
449  hcalHits.push_back(hcalHitsOrig[i]);
450  }
451  //evaluate darkening before relabeling
453  darkening(hcalHits);
454  }
455  if (relabel_) {
456  // Relabel PCaloHits
457  edm::LogInfo("HcalDigitizer") << "Calling Relabeller";
458  theRelabeller->process(hcalHits);
459  }
460  if(theHitCorrection != 0) {
461  theHitCorrection->fillChargeSums(hcalHits);
462  }
463  if(hbhegeo) {
464  if(theHBHEDigitizer) theHBHEDigitizer->add(hcalHits, bunchCrossing, engine);
465  if(theHBHESiPMDigitizer) theHBHESiPMDigitizer->add(hcalHits, bunchCrossing, engine);
467  theHBHEUpgradeDigitizer->add(hcalHits, bunchCrossing, engine);
468  }
469  }
470 
471  if(hogeo) {
472  if(theHODigitizer) theHODigitizer->add(hcalHits, bunchCrossing, engine);
473  if(theHOSiPMDigitizer) theHOSiPMDigitizer->add(hcalHits, bunchCrossing, engine);
474  }
475 
476  if(hfgeo) {
477  if(theHFDigitizer) theHFDigitizer->add(hcalHits, bunchCrossing, engine);
478  if(theHFUpgradeDigitizer) theHFUpgradeDigitizer->add(hcalHits, bunchCrossing, engine);
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, engine);
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, CLHEP::HepRandomEngine* engine) {
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 
506  eventSetup.get<HcalRecNumberingRecord>().get(htopo);
507  const HcalTopology *htopoP=htopo.product();
508 
509  accumulateCaloHits(hcalHandle, zdcHandle, 0, engine, htopoP);
510 }
511 
512 void HcalDigitizer::accumulate(PileUpEventPrincipal const& e, edm::EventSetup const& eventSetup, CLHEP::HepRandomEngine* engine) {
513  // Step A: Get Inputs
514  edm::InputTag zdcTag(hitsProducer_, "ZDCHITS");
516  e.getByLabel(zdcTag, zdcHandle);
517  isZDC = zdcHandle.isValid();
518 
519  edm::InputTag hcalTag(hitsProducer_, "HcalHits");
521  e.getByLabel(hcalTag, hcalHandle);
522  isHCAL = hcalHandle.isValid();
523 
525  eventSetup.get<HcalRecNumberingRecord>().get(htopo);
526  const HcalTopology *htopoP=htopo.product();
527 
528  accumulateCaloHits(hcalHandle, zdcHandle, e.bunchCrossing(), engine, htopoP);
529 }
530 
531 void HcalDigitizer::finalizeEvent(edm::Event& e, const edm::EventSetup& eventSetup, CLHEP::HepRandomEngine* engine) {
532 
533  // Step B: Create empty output
534  std::auto_ptr<HBHEDigiCollection> hbheResult(new HBHEDigiCollection());
535  std::auto_ptr<HODigiCollection> hoResult(new HODigiCollection());
536  std::auto_ptr<HFDigiCollection> hfResult(new HFDigiCollection());
537  std::auto_ptr<ZDCDigiCollection> zdcResult(new ZDCDigiCollection());
538  std::auto_ptr<HBHEUpgradeDigiCollection> hbheupgradeResult(new HBHEUpgradeDigiCollection());
539  std::auto_ptr<HFUpgradeDigiCollection> hfupgradeResult(new HFUpgradeDigiCollection());
540 
541  // Step C: Invoke the algorithm, getting back outputs.
542  if(isHCAL&&hbhegeo){
543  if(theHBHEDigitizer) theHBHEDigitizer->run(*hbheResult, engine);
544  if(theHBHESiPMDigitizer) theHBHESiPMDigitizer->run(*hbheResult, engine);
546  theHBHEUpgradeDigitizer->run(*hbheupgradeResult, engine);
547 
548 // std::cout << "HcalDigitizer::finalizeEvent theHBHEUpgradeDigitizer->run" << std::endl;
549  }
550  }
551  if(isHCAL&&hogeo) {
552  if(theHODigitizer) theHODigitizer->run(*hoResult, engine);
553  if(theHOSiPMDigitizer) theHOSiPMDigitizer->run(*hoResult, engine);
554  }
555  if(isHCAL&&hfgeo) {
556  if(theHFDigitizer) theHFDigitizer->run(*hfResult, engine);
557  if(theHFUpgradeDigitizer) theHFUpgradeDigitizer->run(*hfupgradeResult, engine);
558  }
559  if(isZDC&&zdcgeo) {
560  theZDCDigitizer->run(*zdcResult, engine);
561  }
562 
563  edm::LogInfo("HcalDigitizer") << "HCAL HBHE digis : " << hbheResult->size();
564  edm::LogInfo("HcalDigitizer") << "HCAL HO digis : " << hoResult->size();
565  edm::LogInfo("HcalDigitizer") << "HCAL HF digis : " << hfResult->size();
566  edm::LogInfo("HcalDigitizer") << "HCAL ZDC digis : " << zdcResult->size();
567  edm::LogInfo("HcalDigitizer") << "HCAL HBHE upgrade digis : " << hbheupgradeResult->size();
568  edm::LogInfo("HcalDigitizer") << "HCAL HF upgrade digis : " << hfupgradeResult->size();
569 
570  /*
571  std::cout << std::endl;
572  std::cout << "HCAL HBHE digis : " << hbheResult->size() << std::endl;
573  std::cout << "HCAL HO digis : " << hoResult->size() << std::endl;
574  std::cout << "HCAL HF digis : " << hfResult->size() << std::endl;
575 
576  std::cout << "HCAL HBHE upgrade digis : " << hbheupgradeResult->size()
577  << std::endl;
578  std::cout << "HCAL HF upgrade digis : " << hfupgradeResult->size()
579  << std::endl;
580  */
581 
582  // Step D: Put outputs into event
583  e.put(hbheResult);
584  e.put(hoResult);
585  e.put(hfResult);
586  e.put(zdcResult);
587  e.put(hbheupgradeResult,"HBHEUpgradeDigiCollection");
588  e.put(hfupgradeResult, "HFUpgradeDigiCollection");
589 
590 // std::cout << std::endl << "========> HcalDigitizer e.put " << std::endl << std::endl;
591 
592  if(theHitCorrection) {
594  }
595 }
596 
597 
599  checkGeometry(es);
600  theShapes->beginRun(es);
601 }
602 
603 
605  theShapes->endRun();
606 }
607 
608 
610  // TODO find a way to avoid doing this every event
612  eventSetup.get<CaloGeometryRecord>().get(geometry);
614  eventSetup.get<HcalRecNumberingRecord>().get(pHRNDC);
615 
616  // See if it's been updated
617  if (&*geometry != theGeometry) {
618  theGeometry = &*geometry;
619  theRecNumber= &*pHRNDC;
620  updateGeometry(eventSetup);
621  }
622 }
623 
624 
633 
634  const std::vector<DetId>& hbCells = theGeometry->getValidDetIds(DetId::Hcal, HcalBarrel);
635  const std::vector<DetId>& heCells = theGeometry->getValidDetIds(DetId::Hcal, HcalEndcap);
636  const std::vector<DetId>& hoCells = theGeometry->getValidDetIds(DetId::Hcal, HcalOuter);
637  const std::vector<DetId>& hfCells = theGeometry->getValidDetIds(DetId::Hcal, HcalForward);
638  const std::vector<DetId>& zdcCells = theGeometry->getValidDetIds(DetId::Calo, HcalZDCDetId::SubdetectorId);
639  //const std::vector<DetId>& hcalTrigCells = geometry->getValidDetIds(DetId::Hcal, HcalTriggerTower);
640  //const std::vector<DetId>& hcalCalib = geometry->getValidDetIds(DetId::Calo, HcalCastorDetId::SubdetectorId);
641 // std::cout<<"HcalDigitizer::CheckGeometry number of cells: "<<zdcCells.size()<<std::endl;
642  if(zdcCells.empty()) zdcgeo = false;
643  if(hbCells.empty() && heCells.empty()) hbhegeo = false;
644  if(hoCells.empty()) hogeo = false;
645  if(hfCells.empty()) hfgeo = false;
646  // combine HB & HE
647 
648  theHBHEDetIds = hbCells;
649  theHBHEDetIds.insert(theHBHEDetIds.end(), heCells.begin(), heCells.end());
650 
652  //HcalDigitizerImpl::fillCells(hoCells, theHODigitizer, theHOSiPMDigitizer);
653  buildHOSiPMCells(hoCells, eventSetup);
656  theZDCDigitizer->setDetIds(zdcCells);
659 
660 // std::cout << " HcalDigitizer::updateGeometry theHBHEUpgradeDigitizer->setDetIds(theHBHEDetIds)"<< std::endl;
661  }
662 
663 }
664 
665 
666 void HcalDigitizer::buildHOSiPMCells(const std::vector<DetId>& allCells, const edm::EventSetup & eventSetup) {
667  // all HPD
668 
669  if(theHOSiPMCode == 0) {
670  theHODigitizer->setDetIds(allCells);
671  } else if(theHOSiPMCode == 1) {
672  theHOSiPMDigitizer->setDetIds(allCells);
673  // FIXME pick Zecotek or hamamatsu?
674  } else if(theHOSiPMCode == 2) {
675  std::vector<HcalDetId> zecotekDetIds, hamamatsuDetIds;
677  eventSetup.get<HcalMCParamsRcd>().get(p);
679  eventSetup.get<HcalRecNumberingRecord>().get(htopo);
680 
681  HcalMCParams mcParams(*p.product());
682  if (mcParams.topo()==0) {
683  mcParams.setTopo(htopo.product());
684  }
685 
686  for(std::vector<DetId>::const_iterator detItr = allCells.begin();
687  detItr != allCells.end(); ++detItr) {
688  int shapeType = mcParams.getValues(*detItr)->signalShape();
689  if(shapeType == HcalShapes::ZECOTEK) {
690  zecotekDetIds.emplace_back(*detItr);
691  theHOSiPMDetIds.push_back(*detItr);
692  } else if(shapeType == HcalShapes::HAMAMATSU) {
693  hamamatsuDetIds.emplace_back(*detItr);
694  theHOSiPMDetIds.push_back(*detItr);
695  } else {
696  theHOHPDDetIds.push_back(*detItr);
697  }
698  }
699 
705  // FIXME not applying a HitFilter to the HPDs, for now
706  theParameterMap->setHOZecotekDetIds(zecotekDetIds);
707  theParameterMap->setHOHamamatsuDetIds(hamamatsuDetIds);
708 
709  // make sure we don't got through this exercise again
710  theHOSiPMCode = -2;
711  }
712 }
713 
714 void HcalDigitizer::darkening(std::vector<PCaloHit>& hcalHits){
715 
716  for (unsigned int ii=0; ii<hcalHits.size(); ++ii) {
717  uint32_t tmpId = hcalHits[ii].id();
718  int det, z, depth, ieta, phi, lay;
719  HcalTestNumbering::unpackHcalIndex(tmpId,det,z,depth,ieta,phi,lay);
720 
721  bool darkened = false;
722  float dweight = 1.;
723 
724  //HE darkening
725  if(det==int(HcalEndcap) && m_HEDarkening){
726  dweight = m_HEDarkening->degradation(deliveredLumi,ieta,lay-2);//NB:diff. layer count
727  darkened = true;
728  }
729 
730  //HF darkening - approximate: invert recalibration factor
731  else if(det==int(HcalForward) && m_HFRecalibration){
732  dweight = 1.0/m_HFRecalibration->getCorr(ieta,depth,deliveredLumi);
733  darkened = true;
734  }
735 
736  //create new hit with darkened energy
737  //if(darkened) hcalHits[ii] = PCaloHit(hcalHits[ii].energyEM()*dweight,hcalHits[ii].energyHad()*dweight,hcalHits[ii].time(),hcalHits[ii].geantTrackId(),hcalHits[ii].id());
738 
739  //reset hit energy
740  if(darkened) hcalHits[ii].setEnergy(hcalHits[ii].energy()*dweight);
741  }
742 
743 }
744 
745 
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
int i
Definition: DBlmapReader.cc:9
void setGeometry(const CaloGeometry *&, const HcalDDDRecConstants *&)
const HcalDDDRecConstants * theRecNumber
Definition: HcalDigitizer.h:73
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:86
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:88
void setHFtuningParameter(double tp)
bool validHcal(const HcalDetId &id) const
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
HcalAmplifier * theHFAmplifier
HcalElectronicsSim * theUpgradeHFElectronicsSim
void fillSiPMCells(std::vector< int > &siPMCells, SIPMDIGITIZER *siPMDigitizer)
HcalCoderFactory * theCoderFactory
HcalHitRelabeller * theRelabeller
edm::SortedCollection< ZDCDataFrame > ZDCDigiCollection
HcalCoderFactory * theUpgradeCoderFactory
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:91
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:84
void setHOZecotekDetIds(const std::vector< HcalDetId > &ids)
HcalAmplifier * theHBHEAmplifier
void setUseOldHO(bool useOld)
edm::SortedCollection< HODataFrame > HODigiCollection
CaloTDigitizer< ZDCDigitizerTraits > ZDCDigitizer
Definition: HcalDigitizer.h:85
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:89
Creates electronics signals from hits.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
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:93
HcalHitFilter theHOSiPMHitFilter
CaloHitResponse * theHOSiPMResponse
Definition: HcalDigitizer.h:94
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:420
HcalHitCorrection * theHitCorrection
CaloHitResponse * theZDCResponse
Definition: HcalDigitizer.h:96
void endRun()
Definition: HcalShapes.cc:118
void setNoiseSignalGenerator(const CaloVNoiseSignalGenerator *noiseSignalGenerator)
Definition: HcalAmplifier.h:35
Definition: DetId.h:18
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:83
void setTimeSlewSim(HcalTimeSlewSim *timeSlewSim)
Definition: HcalAmplifier.h:38
void setHOHamamatsuDetIds(const std::vector< HcalDetId > &ids)
void accumulateCaloHits(edm::Handle< std::vector< PCaloHit > > const &hcalHits, edm::Handle< std::vector< PCaloHit > > const &zdcHits, int bunchCrossing, CLHEP::HepRandomEngine *, const HcalTopology *h)
HcalAmplifier * theHOAmplifier
void setDbService(const HcalDbService *service)
HFRecalibration * m_HFRecalibration
const T & get() const
Definition: EventSetup.h:56
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:91
HODigitizer * theHODigitizer
std::vector< DetId > theHOSiPMDetIds
const CaloGeometry * theGeometry
Definition: HcalDigitizer.h:72
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:95
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:92
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:82
HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector &iC)
CaloVNoiseSignalGenerator * theNoiseGenerator