File indexing completed on 2024-04-06 11:58:08
0001 #include "CalibCalorimetry/HcalAlgos/interface/HcalPulseContainmentManager.h"
0002 #include "FWCore/Framework/interface/ConsumesCollector.h"
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include <iostream>
0005
0006 HcalPulseContainmentManager::HcalPulseContainmentManager(float max_fracerror, bool phaseAsInSim)
0007 : entries_(), shapes_(), max_fracerror_(max_fracerror), phaseAsInSim_(phaseAsInSim) {
0008 hcalTimeSlew_delay_ = nullptr;
0009 }
0010
0011 HcalPulseContainmentManager::HcalPulseContainmentManager(float max_fracerror,
0012 bool phaseAsInSim,
0013 edm::ConsumesCollector iC)
0014 : entries_(),
0015 shapes_(iC),
0016 max_fracerror_(max_fracerror),
0017 phaseAsInSim_(phaseAsInSim),
0018 delayToken_(iC.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", "HBHE"))) {}
0019
0020 void HcalPulseContainmentManager::beginRun(edm::EventSetup const& es) {
0021 hcalTimeSlew_delay_ = &es.getData(delayToken_);
0022
0023 shapes_.beginRun(es);
0024 }
0025
0026 void HcalPulseContainmentManager::beginRun(const HcalDbService* conditions, const HcalTimeSlew* delay) {
0027 hcalTimeSlew_delay_ = delay;
0028
0029 shapes_.beginRun(conditions);
0030 }
0031
0032 double HcalPulseContainmentManager::correction(const HcalDetId& detId, int toAdd, float fixedphase_ns, double fc_ampl) {
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048 return get(detId, toAdd, fixedphase_ns)->getCorrection(fc_ampl);
0049 }
0050
0051 const HcalPulseContainmentCorrection* HcalPulseContainmentManager::get(const HcalDetId& detId,
0052 int toAdd,
0053 float fixedphase_ns) {
0054
0055 const HcalPulseShape* shape = &(shapes_.shapeForReco(detId));
0056 for (std::vector<HcalPulseContainmentEntry>::const_iterator entryItr = entries_.begin(); entryItr != entries_.end();
0057 ++entryItr) {
0058 if (entryItr->shape_ == shape && entryItr->toAdd_ == toAdd && entryItr->fixedphase_ns_ == fixedphase_ns) {
0059 return &entryItr->correction_;
0060 }
0061 }
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077 HcalPulseContainmentEntry entry(
0078 toAdd,
0079 fixedphase_ns,
0080 shape,
0081 HcalPulseContainmentCorrection(shape, toAdd, fixedphase_ns, phaseAsInSim_, max_fracerror_, hcalTimeSlew_delay_));
0082 entries_.push_back(entry);
0083 return &(entries_.back().correction_);
0084 }