diff --git a/SimCalorimetry/EcalElectronicsEmulation/interface/EcalFEtoDigi.h b/SimCalorimetry/EcalElectronicsEmulation/interface/EcalFEtoDigi.h index 7579280adb433..8f3bb80091d7a 100644 --- a/SimCalorimetry/EcalElectronicsEmulation/interface/EcalFEtoDigi.h +++ b/SimCalorimetry/EcalElectronicsEmulation/interface/EcalFEtoDigi.h @@ -8,7 +8,6 @@ * Created: Thu Feb 22 11:32:53 CET 2007 */ -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/Frameworkfwd.h" @@ -18,8 +17,11 @@ #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/Exception.h" +#include "CondFormats/DataRecord/interface/EcalTPGLutGroupRcd.h" +#include "CondFormats/DataRecord/interface/EcalTPGLutIdMapRcd.h" +#include "CondFormats/EcalObjects/interface/EcalTPGLutGroup.h" +#include "CondFormats/EcalObjects/interface/EcalTPGLutIdMap.h" #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" -//#include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h" #include #include @@ -50,15 +52,18 @@ class EcalFEtoDigi : public edm::one::EDProducer<> { int SMidToTCCid(const int) const; void getLUT(unsigned int *lut, const int towerId, const edm::EventSetup &) const; + const edm::ESGetToken tpgLutGroupToken_; + const edm::ESGetToken tpgLutIdMapToken_; + TCCInputData inputdata_[N_SM]; - std::string basename_; - bool useIdentityLUT_; + const std::string basename_; + const bool useIdentityLUT_; int sm_; bool singlefile; - int fileEventOffset_; - bool debug_; + const int fileEventOffset_; + const bool debug_; std::ofstream outfile; }; diff --git a/SimCalorimetry/EcalElectronicsEmulation/src/EcalFEtoDigi.cc b/SimCalorimetry/EcalElectronicsEmulation/src/EcalFEtoDigi.cc index 76866e7e8065e..a1e14424b83da 100644 --- a/SimCalorimetry/EcalElectronicsEmulation/src/EcalFEtoDigi.cc +++ b/SimCalorimetry/EcalElectronicsEmulation/src/EcalFEtoDigi.cc @@ -1,16 +1,13 @@ -#include "CondFormats/DataRecord/interface/EcalTPGLutGroupRcd.h" -#include "CondFormats/DataRecord/interface/EcalTPGLutIdMapRcd.h" -#include "CondFormats/EcalObjects/interface/EcalTPGLutGroup.h" -#include "CondFormats/EcalObjects/interface/EcalTPGLutIdMap.h" #include "SimCalorimetry/EcalElectronicsEmulation/interface/EcalFEtoDigi.h" -EcalFEtoDigi::EcalFEtoDigi(const edm::ParameterSet &iConfig) { - basename_ = iConfig.getUntrackedParameter("FlatBaseName", "ecal_tcc_"); - sm_ = iConfig.getUntrackedParameter("SuperModuleId", -1); - fileEventOffset_ = iConfig.getUntrackedParameter("FileEventOffset", 0); - useIdentityLUT_ = iConfig.getUntrackedParameter("UseIdentityLUT", false); - debug_ = iConfig.getUntrackedParameter("debugPrintFlag", false); - +EcalFEtoDigi::EcalFEtoDigi(const edm::ParameterSet &iConfig) + : tpgLutGroupToken_(esConsumes()), + tpgLutIdMapToken_(esConsumes()), + basename_(iConfig.getUntrackedParameter("FlatBaseName", "ecal_tcc_")), + useIdentityLUT_(iConfig.getUntrackedParameter("UseIdentityLUT", false)), + sm_(iConfig.getUntrackedParameter("SuperModuleId", -1)), + fileEventOffset_(iConfig.getUntrackedParameter("FileEventOffset", 0)), + debug_(iConfig.getUntrackedParameter("debugPrintFlag", false)) { singlefile = (sm_ == -1) ? false : true; produces(); @@ -301,17 +298,13 @@ int EcalFEtoDigi::SMidToTCCid(const int smid) const { return (smid <= 18) ? smid /// return the LUT from eventSetup void EcalFEtoDigi::getLUT(unsigned int *lut, const int towerId, const edm::EventSetup &evtSetup) const { - edm::ESHandle lutGrpHandle; - evtSetup.get().get(lutGrpHandle); - const EcalTPGGroups::EcalTPGGroupsMap &lutGrpMap = lutGrpHandle.product()->getMap(); + const EcalTPGGroups::EcalTPGGroupsMap &lutGrpMap = evtSetup.getData(tpgLutGroupToken_).getMap(); EcalTPGGroups::EcalTPGGroupsMapItr itgrp = lutGrpMap.find(towerId); uint32_t lutGrp = 999; if (itgrp != lutGrpMap.end()) lutGrp = itgrp->second; - edm::ESHandle lutMapHandle; - evtSetup.get().get(lutMapHandle); - const EcalTPGLutIdMap::EcalTPGLutMap &lutMap = lutMapHandle.product()->getMap(); + const EcalTPGLutIdMap::EcalTPGLutMap &lutMap = evtSetup.getData(tpgLutIdMapToken_).getMap(); EcalTPGLutIdMap::EcalTPGLutMapItr itLut = lutMap.find(lutGrp); if (itLut != lutMap.end()) { const unsigned int *theLut = (itLut->second).getLut(); diff --git a/SimCalorimetry/EcalSelectiveReadoutProducers/interface/EcalSRCondTools.h b/SimCalorimetry/EcalSelectiveReadoutProducers/interface/EcalSRCondTools.h index ac11ead800bc1..1c24c59541e90 100644 --- a/SimCalorimetry/EcalSelectiveReadoutProducers/interface/EcalSRCondTools.h +++ b/SimCalorimetry/EcalSelectiveReadoutProducers/interface/EcalSRCondTools.h @@ -10,7 +10,10 @@ #include "FWCore/Utilities/interface/ESGetToken.h" #include "CondFormats/EcalObjects/interface/EcalSRSettings.h" #include "CondFormats/DataRecord/interface/EcalSRSettingsRcd.h" +#include "CondFormats/EcalObjects/interface/EcalTPGPhysicsConst.h" +#include "CondFormats/DataRecord/interface/EcalTPGPhysicsConstRcd.h" +#include /** */ class EcalSRCondTools : public edm::one::EDAnalyzer<> { @@ -68,10 +71,14 @@ class EcalSRCondTools : public edm::one::EDAnalyzer<> { //fields private: - edm::ParameterSet ps_; - edm::ESGetToken hSrToken_; + const edm::ParameterSet ps_; + const std::string mode_; + bool iomode_write_; bool done_; + + edm::ESGetToken hSrToken_; + edm::ESGetToken tpgPhysicsConstToken_; }; #endif //SRCONDACCESS_H not defined diff --git a/SimCalorimetry/EcalSelectiveReadoutProducers/src/EcalSRCondTools.cc b/SimCalorimetry/EcalSelectiveReadoutProducers/src/EcalSRCondTools.cc index 178250bdecd4e..b962dac29815f 100644 --- a/SimCalorimetry/EcalSelectiveReadoutProducers/src/EcalSRCondTools.cc +++ b/SimCalorimetry/EcalSelectiveReadoutProducers/src/EcalSRCondTools.cc @@ -12,11 +12,6 @@ #include "FWCore/ServiceRegistry/interface/Service.h" #include "CondCore/DBOutputService/interface/PoolDBOutputService.h" -#include "CondFormats/EcalObjects/interface/EcalSRSettings.h" -#include "CondFormats/EcalObjects/interface/EcalTPGPhysicsConst.h" -#include "CondFormats/DataRecord/interface/EcalTPGPhysicsConstRcd.h" - -#include #include #include #include @@ -58,7 +53,13 @@ constexpr int dccNum[12][12] = { using namespace std; EcalSRCondTools::EcalSRCondTools(const edm::ParameterSet& ps) - : ps_(ps), hSrToken_(esConsumes()), done_(false) {} + : ps_(ps), mode_(ps.getParameter("mode")), iomode_write_(true), done_(false) { + if (mode_ == "read") { + iomode_write_ = false; + hSrToken_ = esConsumes(); + tpgPhysicsConstToken_ = esConsumes(); + } +} EcalSRCondTools::~EcalSRCondTools() {} @@ -67,10 +68,7 @@ void EcalSRCondTools::analyze(const edm::Event& event, const edm::EventSetup& es return; EcalSRSettings* sr = new EcalSRSettings; - string mode = ps_.getParameter("mode"); - - bool iomode_write = true; - if (mode == "online_config" || mode == "combine_config") { + if (mode_ == "online_config" || mode_ == "combine_config") { string fname = ps_.getParameter("onlineSrpConfigFile"); ifstream f(fname.c_str()); if (!f.good()) { @@ -79,20 +77,16 @@ void EcalSRCondTools::analyze(const edm::Event& event, const edm::EventSetup& es importSrpConfigFile(*sr, f, true); } - if (mode == "python_config" || mode == "combine_config") { + if (mode_ == "python_config" || mode_ == "combine_config") { importParameterSet(*sr, ps_); } - if (mode == "read") { - iomode_write = false; - } - - if (!(mode == "python_config" || mode == "online_config" || mode == "combine_config" || (mode == "read"))) { - throw cms::Exception("Config") << "Invalid value," << mode << ", for parameter mode. " + if (!(mode_ == "python_config" || mode_ == "online_config" || mode_ == "combine_config" || (mode_ == "read"))) { + throw cms::Exception("Config") << "Invalid value," << mode_ << ", for parameter mode. " << "Valid values: online_config, python_config, combine_config, read"; } - if (iomode_write) { + if (iomode_write_) { sr->bxGlobalOffset_ = ps_.getParameter("bxGlobalOffset"); sr->automaticSrpSelect_ = ps_.getParameter("automaticSrpSelect"); sr->automaticMasks_ = ps_.getParameter("automaticMasks"); @@ -107,7 +101,7 @@ void EcalSRCondTools::analyze(const edm::Event& event, const edm::EventSetup& es db->writeOne(sr, firstSinceTime, "EcalSRSettingsRcd"); done_ = true; } else { //read mode - edm::ESHandle hSr = es.getHandle(hSrToken_); + const edm::ESHandle hSr = es.getHandle(hSrToken_); if (!hSr.isValid()) { cout << "EcalSRSettings record not found. Check the Cond DB Global tag.\n"; } else { @@ -117,8 +111,7 @@ void EcalSRCondTools::analyze(const edm::Event& event, const edm::EventSetup& es } //trigger tower thresholds (from FENIX configuration): - edm::ESHandle hTp; - es.get().get(hTp); + const edm::ESHandle hTp = es.getHandle(tpgPhysicsConstToken_); if (!hTp.isValid()) { cout << "EcalTPGPhysicsConst record not found. Check the Cond DB Global tag.\n"; } else { diff --git a/SimCalorimetry/EcalSimAlgos/interface/EcalSignalGenerator.h b/SimCalorimetry/EcalSimAlgos/interface/EcalSignalGenerator.h index c6ea2e46708a8..4ee72404d7be8 100644 --- a/SimCalorimetry/EcalSimAlgos/interface/EcalSignalGenerator.h +++ b/SimCalorimetry/EcalSimAlgos/interface/EcalSignalGenerator.h @@ -2,7 +2,7 @@ #define EcalSimAlgos_EcalSignalGenerator_h #include "SimCalorimetry/EcalSimAlgos/interface/EcalBaseSignalGenerator.h" -#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventPrincipal.h" @@ -42,7 +42,7 @@ * as noise */ -#include +//#include #include #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -61,45 +61,54 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator { EcalSignalGenerator() : EcalBaseSignalGenerator() {} - EcalSignalGenerator(const edm::InputTag& inputTag, - const edm::EDGetTokenT& t, + EcalSignalGenerator(edm::ConsumesCollector& cc, + const edm::InputTag& inputTag, const double EBs25notCont, const double EEs25notCont, const double peToABarrel, const double peToAEndcap, const bool timeDependent = false) - : EcalBaseSignalGenerator(), theEvent(nullptr), theEventPrincipal(nullptr), theInputTag(inputTag), tok_(t) { + : EcalBaseSignalGenerator(), + m_gainRatiosToken(cc.esConsumes()), + m_interCalibConstantsMCToken(cc.esConsumes()), + m_adcToGeVConstantToken(cc.esConsumes()), + m_esGainToken(cc.esConsumes()), + m_esMIPToGeVConstantToken(cc.esConsumes()), + m_esIntercalibConstantsToken(cc.esConsumes()), + theEvent(nullptr), + theEventPrincipal(nullptr), + theInputTag(inputTag), + m_tok(cc.consumes(inputTag)), + m_EBs25notCont(EBs25notCont), + m_EEs25notCont(EEs25notCont), + m_peToABarrel(peToABarrel), + m_peToAEndcap(peToAEndcap), + m_timeDependent(timeDependent) { EcalMGPAGainRatio* defaultRatios = new EcalMGPAGainRatio(); theDefaultGains[2] = defaultRatios->gain6Over1(); theDefaultGains[1] = theDefaultGains[2] * (defaultRatios->gain12Over6()); - m_EBs25notCont = EBs25notCont; - m_EEs25notCont = EEs25notCont; - m_peToABarrel = peToABarrel; - m_peToAEndcap = peToAEndcap; - m_timeDependent = timeDependent; + + if (m_timeDependent) { + m_laserDbToken = cc.esConsumes(); + m_laserDbMCToken = cc.esConsumes(); + } } ~EcalSignalGenerator() override {} void initializeEvent(const edm::Event* event, const edm::EventSetup* eventSetup) { theEvent = event; - eventSetup->get().get(grHandle); // find the gains + m_gainRatios = &eventSetup->getData(m_gainRatiosToken); // find the gains // Ecal Intercalibration Constants - eventSetup->get().get(pIcal); - ical = pIcal.product(); + ical = &eventSetup->getData(m_interCalibConstantsMCToken); // adc to GeV - eventSetup->get().get(pAgc); - agc = pAgc.product(); + agc = &eventSetup->getData(m_adcToGeVConstantToken); m_maxEneEB = (agc->getEBValue()) * theDefaultGains[1] * MAXADC * m_EBs25notCont; m_maxEneEE = (agc->getEEValue()) * theDefaultGains[1] * MAXADC * m_EEs25notCont; if (m_timeDependent) { //---- - // Ecal LaserCorrection Constants for laser correction ratio - edm::ESHandle laser; - eventSetup->get().get(laser); - // const edm::TimeValue_t eventTimeValue = theEvent->getRun().runAuxiliary().beginTime().value(); // @@ -108,7 +117,8 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator { // m_iTime = eventTimeValue; - m_lasercals = laser.product(); + // Ecal LaserCorrection Constants for laser correction ratio + m_lasercals = &eventSetup->getData(m_laserDbToken); // // the "prime" is exactly the same as the usual laser service, BUT @@ -116,25 +126,18 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator { // NB: in the creation of the tag make sure the "prime" (MC) tag is prepared properly! // NB again: if many IOVs also in "MC" tag, then fancy things could be perfomed ... left for the future // - edm::ESHandle laser_prime; - eventSetup->get().get(laser_prime); - m_lasercals_prime = laser_prime.product(); + m_lasercals_prime = &eventSetup->getData(m_laserDbMCToken); //clear the laser cache for each event time CalibCache().swap(m_valueLCCache_LC); CalibCache().swap(m_valueLCCache_LC_prime); //--- also the "prime" ... yes - //---- } //ES - eventSetup->get().get(hesgain); - eventSetup->get().get(hesMIPToGeV); - eventSetup->get().get(hesMIPs); - - esgain = hesgain.product(); - esmips = hesMIPs.product(); - esMipToGeV = hesMIPToGeV.product(); + esgain = &eventSetup->getData(m_esGainToken); + esmips = &eventSetup->getData(m_esIntercalibConstantsToken); + esMipToGeV = &eventSetup->getData(m_esMIPToGeVConstantToken); if (1.1 > esgain->getESGain()) ESgain = 1; else @@ -148,21 +151,16 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator { /// some users use EventPrincipals, not Events. We support both void initializeEvent(const edm::EventPrincipal* eventPrincipal, const edm::EventSetup* eventSetup) { theEventPrincipal = eventPrincipal; - eventSetup->get().get(grHandle); // find the gains + m_gainRatios = &eventSetup->getData(m_gainRatiosToken); // find the gains // Ecal Intercalibration Constants - eventSetup->get().get(pIcal); - ical = pIcal.product(); + ical = &eventSetup->getData(m_interCalibConstantsMCToken); // adc to GeV - eventSetup->get().get(pAgc); - agc = pAgc.product(); + agc = &eventSetup->getData(m_adcToGeVConstantToken); m_maxEneEB = (agc->getEBValue()) * theDefaultGains[1] * MAXADC * m_EBs25notCont; m_maxEneEE = (agc->getEEValue()) * theDefaultGains[1] * MAXADC * m_EEs25notCont; if (m_timeDependent) { //---- - // Ecal LaserCorrection Constants for laser correction ratio - edm::ESHandle laser; - eventSetup->get().get(laser); edm::TimeValue_t eventTimeValue = 0; if (theEventPrincipal) { // @@ -175,11 +173,10 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator { edm::LogError("EcalSignalGenerator") << " theEventPrincipal not defined??? " << std::endl; } m_iTime = eventTimeValue; - m_lasercals = laser.product(); - edm::ESHandle laser_prime; - eventSetup->get().get(laser_prime); - m_lasercals_prime = laser_prime.product(); + // Ecal LaserCorrection Constants for laser correction ratio + m_lasercals = &eventSetup->getData(m_laserDbToken); + m_lasercals_prime = &eventSetup->getData(m_laserDbMCToken); //clear the laser cache for each event time CalibCache().swap(m_valueLCCache_LC); @@ -188,13 +185,9 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator { } //ES - eventSetup->get().get(hesgain); - eventSetup->get().get(hesMIPToGeV); - eventSetup->get().get(hesMIPs); - - esgain = hesgain.product(); - esmips = hesMIPs.product(); - esMipToGeV = hesMIPToGeV.product(); + esgain = &eventSetup->getData(m_esGainToken); + esmips = &eventSetup->getData(m_esIntercalibConstantsToken); + esMipToGeV = &eventSetup->getData(m_esMIPToGeVConstantToken); if (1.1 > esgain->getESGain()) ESgain = 1; else @@ -211,7 +204,7 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator { const COLLECTION* digis = nullptr; // try accessing by whatever is set, Event or EventPrincipal if (theEvent) { - if (theEvent->getByToken(tok_, pDigis)) { + if (theEvent->getByToken(m_tok, pDigis)) { digis = pDigis.product(); // get a ptr to the product } else { throw cms::Exception("EcalSignalGenerator") << "Cannot find input data " << theInputTag; @@ -278,7 +271,7 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator { const std::vector GetGainRatios(const DetId& detid) { std::vector gainRatios(4); // get gain ratios - EcalMGPAGainRatio theRatio = (*grHandle)[detid]; + EcalMGPAGainRatio theRatio = (*m_gainRatios)[detid]; gainRatios[0] = 0.; gainRatios[3] = 1.; @@ -294,21 +287,24 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator { return detId.subdetId() == EcalBarrel ? m_peToABarrel : m_peToAEndcap; } + const edm::ESGetToken m_gainRatiosToken; + const edm::ESGetToken m_interCalibConstantsMCToken; + const edm::ESGetToken m_adcToGeVConstantToken; + edm::ESGetToken m_laserDbToken; + edm::ESGetToken m_laserDbMCToken; + const edm::ESGetToken m_esGainToken; + const edm::ESGetToken m_esMIPToGeVConstantToken; + const edm::ESGetToken m_esIntercalibConstantsToken; + /// these fields are set in initializeEvent() const edm::Event* theEvent; const edm::EventPrincipal* theEventPrincipal; - edm::ESHandle grHandle; - edm::ESHandle pIcal; - edm::ESHandle pAgc; + const EcalGainRatios* m_gainRatios; /// these come from the ParameterSet - edm::InputTag theInputTag; - edm::EDGetTokenT tok_; - - edm::ESHandle hesgain; - edm::ESHandle hesMIPToGeV; - edm::ESHandle hesMIPs; + const edm::InputTag theInputTag; + const edm::EDGetTokenT m_tok; const ESGain* esgain; const ESIntercalibConstants* esmips; @@ -316,11 +312,11 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator { int ESgain; double ESMIPToGeV; - double m_EBs25notCont; - double m_EEs25notCont; + const double m_EBs25notCont; + const double m_EEs25notCont; - double m_peToABarrel; - double m_peToAEndcap; + const double m_peToABarrel; + const double m_peToAEndcap; double m_maxEneEB; // max attainable energy in the ecal barrel double m_maxEneEE; // max attainable energy in the ecal endcap @@ -328,7 +324,7 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator { const EcalADCToGeVConstant* agc; const EcalIntercalibConstantsMC* ical; - bool m_timeDependent; + const bool m_timeDependent; edm::TimeValue_t m_iTime; CalibCache m_valueLCCache_LC; CalibCache m_valueLCCache_LC_prime; diff --git a/SimCalorimetry/EcalSimProducers/plugins/PreMixingEcalWorker.cc b/SimCalorimetry/EcalSimProducers/plugins/PreMixingEcalWorker.cc index cfe528757c688..ac2ba542bebe4 100644 --- a/SimCalorimetry/EcalSimProducers/plugins/PreMixingEcalWorker.cc +++ b/SimCalorimetry/EcalSimProducers/plugins/PreMixingEcalWorker.cc @@ -41,10 +41,6 @@ class PreMixingEcalWorker : public PreMixingWorker { std::string EEDigiCollectionDM_; // secondary name to be given to collection of digis std::string ESDigiCollectionDM_; // secondary name to be given to collection of digis - edm::EDGetTokenT tok_eb_; - edm::EDGetTokenT tok_ee_; - edm::EDGetTokenT tok_es_; - const double m_EBs25notCont; const double m_EEs25notCont; const double m_peToABarrel; @@ -64,19 +60,16 @@ PreMixingEcalWorker::PreMixingEcalWorker(const edm::ParameterSet &ps, : EBPileInputTag_(ps.getParameter("EBPileInputTag")), EEPileInputTag_(ps.getParameter("EEPileInputTag")), ESPileInputTag_(ps.getParameter("ESPileInputTag")), - tok_eb_(iC.consumes(EBPileInputTag_)), - tok_ee_(iC.consumes(EEPileInputTag_)), - tok_es_(iC.consumes(ESPileInputTag_)), m_EBs25notCont(ps.getParameter("EBs25notContainment")), m_EEs25notCont(ps.getParameter("EEs25notContainment")), m_peToABarrel(ps.getParameter("photoelectronsToAnalogBarrel")), m_peToAEndcap(ps.getParameter("photoelectronsToAnalogEndcap")), m_timeDependent(ps.getParameter("timeDependent")), theEBSignalGenerator( - EBPileInputTag_, tok_eb_, m_EBs25notCont, m_EEs25notCont, m_peToABarrel, m_peToAEndcap, m_timeDependent), + iC, EBPileInputTag_, m_EBs25notCont, m_EEs25notCont, m_peToABarrel, m_peToAEndcap, m_timeDependent), theEESignalGenerator( - EEPileInputTag_, tok_ee_, m_EBs25notCont, m_EEs25notCont, m_peToABarrel, m_peToAEndcap, m_timeDependent), - theESSignalGenerator(ESPileInputTag_, tok_es_, m_EBs25notCont, m_EEs25notCont, m_peToABarrel, m_peToAEndcap), + iC, EEPileInputTag_, m_EBs25notCont, m_EEs25notCont, m_peToABarrel, m_peToAEndcap, m_timeDependent), + theESSignalGenerator(iC, ESPileInputTag_, m_EBs25notCont, m_EEs25notCont, m_peToABarrel, m_peToAEndcap), myEcalDigitizer_(ps, iC) { EBDigiCollectionDM_ = ps.getParameter("EBDigiCollectionDM"); EEDigiCollectionDM_ = ps.getParameter("EEDigiCollectionDM"); diff --git a/SimCalorimetry/EcalZeroSuppressionProducers/interface/EcalZeroSuppressionProducer.h b/SimCalorimetry/EcalZeroSuppressionProducers/interface/EcalZeroSuppressionProducer.h index 87eec5fa8512c..6f9325bafe5dd 100644 --- a/SimCalorimetry/EcalZeroSuppressionProducers/interface/EcalZeroSuppressionProducer.h +++ b/SimCalorimetry/EcalZeroSuppressionProducers/interface/EcalZeroSuppressionProducer.h @@ -9,7 +9,6 @@ #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" #include "DataFormats/Provenance/interface/Provenance.h" #include "FWCore/Framework/interface/ConsumesCollector.h" -#include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -22,9 +21,6 @@ class EcalZeroSuppressionProducer : public edm::stream::EDProducer<> { public: - // The following is not yet used, but will be the primary - // constructor when the parameter set system is available. - // explicit EcalZeroSuppressionProducer(const edm::ParameterSet ¶ms); ~EcalZeroSuppressionProducer() override; @@ -34,20 +30,21 @@ class EcalZeroSuppressionProducer : public edm::stream::EDProducer<> { void initCalibrations(const edm::EventSetup &eventSetup); private: - double glbBarrelThreshold_; - double glbEndcapThreshold_; + const double glbBarrelThreshold_; + const double glbEndcapThreshold_; - std::string digiProducer_; // name of module/plugin/producer making digis - std::string EBdigiCollection_; // secondary name given to collection of digis - std::string EEdigiCollection_; // secondary name given to collection of digis - std::string EBZSdigiCollection_; // secondary name given to collection of digis - std::string EEZSdigiCollection_; // secondary name given to collection of digis + const std::string digiProducer_; // name of module/plugin/producer making digis + const std::string ebDigiCollection_; // secondary name given to collection of digis + const std::string eeDigiCollection_; // secondary name given to collection of digis + const std::string ebZSdigiCollection_; // secondary name given to collection of digis + const std::string eeZSdigiCollection_; // secondary name given to collection of digis EcalZeroSuppressor theBarrelZeroSuppressor_; EcalZeroSuppressor theEndcapZeroSuppressor_; - edm::EDGetTokenT EB_token; - edm::EDGetTokenT EE_token; + const edm::EDGetTokenT ebToken_; + const edm::EDGetTokenT eeToken_; + const edm::ESGetToken pedestalToken_; }; #endif diff --git a/SimCalorimetry/EcalZeroSuppressionProducers/src/EcalZeroSuppressionProducer.cc b/SimCalorimetry/EcalZeroSuppressionProducers/src/EcalZeroSuppressionProducer.cc index 1c207d6ed0fe7..7646572a6ba65 100644 --- a/SimCalorimetry/EcalZeroSuppressionProducers/src/EcalZeroSuppressionProducer.cc +++ b/SimCalorimetry/EcalZeroSuppressionProducers/src/EcalZeroSuppressionProducer.cc @@ -1,24 +1,19 @@ #include "SimCalorimetry/EcalZeroSuppressionProducers/interface/EcalZeroSuppressionProducer.h" -EcalZeroSuppressionProducer::EcalZeroSuppressionProducer(const edm::ParameterSet ¶ms) { - digiProducer_ = params.getParameter("digiProducer"); - EBdigiCollection_ = params.getParameter("EBdigiCollection"); - EEdigiCollection_ = params.getParameter("EEdigiCollection"); - EBZSdigiCollection_ = params.getParameter("EBZSdigiCollection"); - EEZSdigiCollection_ = params.getParameter("EEZSdigiCollection"); - - // initialize the default values for the thresholds in number of noise sigmas - - glbBarrelThreshold_ = params.getUntrackedParameter("glbBarrelThreshold", 0.2); - glbEndcapThreshold_ = params.getUntrackedParameter("glbEndcapThreshold", 0.4); - - produces(EBZSdigiCollection_); - produces(EEZSdigiCollection_); - - EB_token = consumes(edm::InputTag(digiProducer_)); - EE_token = consumes(edm::InputTag(digiProducer_)); - ; +EcalZeroSuppressionProducer::EcalZeroSuppressionProducer(const edm::ParameterSet ¶ms) + : glbBarrelThreshold_(params.getUntrackedParameter("glbBarrelThreshold", 0.2)), + glbEndcapThreshold_(params.getUntrackedParameter("glbEndcapThreshold", 0.4)), + digiProducer_(params.getParameter("digiProducer")), + ebDigiCollection_(params.getParameter("EBdigiCollection")), + eeDigiCollection_(params.getParameter("EEdigiCollection")), + ebZSdigiCollection_(params.getParameter("EBZSdigiCollection")), + eeZSdigiCollection_(params.getParameter("EEZSdigiCollection")), + ebToken_(consumes(edm::InputTag(digiProducer_))), + eeToken_(consumes(edm::InputTag(digiProducer_))), + pedestalToken_(esConsumes()) { + produces(ebZSdigiCollection_); + produces(eeZSdigiCollection_); } EcalZeroSuppressionProducer::~EcalZeroSuppressionProducer() {} @@ -34,26 +29,26 @@ void EcalZeroSuppressionProducer::produce(edm::Event &event, const edm::EventSet const EBDigiCollection *fullBarrelDigis = nullptr; const EEDigiCollection *fullEndcapDigis = nullptr; - event.getByToken(EB_token, pEBDigis); + event.getByToken(ebToken_, pEBDigis); if (pEBDigis.isValid()) { fullBarrelDigis = pEBDigis.product(); // get a ptr to the produc edm::LogInfo("ZeroSuppressionInfo") << "total # fullBarrelDigis: " << fullBarrelDigis->size(); } else { - edm::LogError("ZeroSuppressionError") << "Error! can't get the product " << EBdigiCollection_.c_str(); + edm::LogError("ZeroSuppressionError") << "Error! can't get the product " << ebDigiCollection_.c_str(); } - event.getByToken(EE_token, pEEDigis); + event.getByToken(eeToken_, pEEDigis); if (pEEDigis.isValid()) { fullEndcapDigis = pEEDigis.product(); // get a ptr to the product edm::LogInfo("ZeroSuppressionInfo") << "total # fullEndcapDigis: " << fullEndcapDigis->size(); } else { - edm::LogError("ZeroSuppressionError") << "Error! can't get the product " << EEdigiCollection_.c_str(); + edm::LogError("ZeroSuppressionError") << "Error! can't get the product " << eeDigiCollection_.c_str(); } // collection of zero suppressed digis to put in the event - std::unique_ptr gzsBarrelDigis(new EBDigiCollection()); - std::unique_ptr gzsEndcapDigis(new EEDigiCollection()); + auto gzsBarrelDigis = std::make_unique(); + auto gzsEndcapDigis = std::make_unique(); CaloDigiCollectionSorter sorter(5); @@ -99,17 +94,14 @@ void EcalZeroSuppressionProducer::produce(edm::Event &event, const edm::EventSet // } } // Step D: Put outputs into event - event.put(std::move(gzsBarrelDigis), EBZSdigiCollection_); - event.put(std::move(gzsEndcapDigis), EEZSdigiCollection_); + event.put(std::move(gzsBarrelDigis), ebZSdigiCollection_); + event.put(std::move(gzsEndcapDigis), eeZSdigiCollection_); } void EcalZeroSuppressionProducer::initCalibrations(const edm::EventSetup &eventSetup) { // Pedestals from event setup + const auto &thePedestals = eventSetup.getData(pedestalToken_); - edm::ESHandle dbPed; - eventSetup.get().get(dbPed); - const EcalPedestals *thePedestals = dbPed.product(); - - theBarrelZeroSuppressor_.setPedestals(thePedestals); - theEndcapZeroSuppressor_.setPedestals(thePedestals); + theBarrelZeroSuppressor_.setPedestals(&thePedestals); + theEndcapZeroSuppressor_.setPedestals(&thePedestals); }