Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-05 11:11:21

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           int sub     = detId.subdet();
0035           int depth   = detId.depth();
0036           int inteta  = detId.ieta();
0037           int intphi  = detId.iphi();
0038           
0039           std::cout << "* HcalPulseContainmentManager::correction,   cell:" 
0040                     << " sub, ieta, iphi, depth = " 
0041                     << sub << "  " << inteta << "  " << intphi 
0042                     << "  " << depth  << "  toAaa= " << toAdd 
0043             <<"  phase = " << fixedphase_ns << "  ampl = " 
0044             << fc_ampl 
0045                     << std::endl;
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   // const HcalPulseShape * shape = &(shapes_.shape(detId));
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           int sub     = detId.subdet();
0065           int depth   = detId.depth();
0066           int inteta  = detId.ieta();
0067           int intphi  = detId.iphi();
0068           
0069           std::cout << "* HcalPulseContainmentManager::get new entry,  cell:" 
0070                     << " sub, ieta, iphi, depth = " 
0071                     << sub << "  " << inteta << "  " << intphi 
0072                     << "  " << depth   
0073                     << std::endl;
0074   */
0075 
0076   // didn't find it.  Make one.
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 }