From a713564a9289a8b7b5bae8031eedd75e5db05c3a Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 3 Mar 2021 12:07:22 -0600 Subject: [PATCH 1/4] Removed unused EventSetup arguments --- .../interface/EcalFenixStrip.h | 17 ++++---------- .../interface/EcalFenixTcp.h | 16 +++----------- .../interface/EcalTrigPrimFunctionalAlgo.h | 22 ++++++------------- .../EcalTrigPrimAlgos/src/EcalFenixStrip.cc | 8 ++----- .../EcalTrigPrimAlgos/src/EcalFenixTcp.cc | 14 +++--------- .../src/EcalTrigPrimFunctionalAlgo.cc | 19 ++++++---------- .../plugins/EcalTrigPrimProducer.cc | 4 ++-- 7 files changed, 28 insertions(+), 72 deletions(-) diff --git a/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixStrip.h b/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixStrip.h index 4b0f32dbb8290..082c7346fa649 100644 --- a/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixStrip.h +++ b/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixStrip.h @@ -8,8 +8,6 @@ #include #include "DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h" #include #include @@ -30,12 +28,7 @@ class EcalTPGStripStatus; class EcalFenixStrip { public: // constructor, destructor - EcalFenixStrip(const edm::EventSetup &setup, - const EcalElectronicsMapping *theMapping, - bool debug, - bool famos, - int maxNrSamples, - int nbMaxXtals); + EcalFenixStrip(const EcalElectronicsMapping *theMapping, bool debug, bool famos, int maxNrSamples, int nbMaxXtals); virtual ~EcalFenixStrip(); private: @@ -100,10 +93,8 @@ class EcalFenixStrip { // main methods // process method is splitted in 2 parts: - // the first one is templated, the same except input + // the first one is overloaded, the same except input // the second part is slightly different for barrel/endcap - template - void process(const edm::EventSetup &, std::vector &, int nrxtals, std::vector &out); void process_part2_barrel(uint32_t stripid, const EcalTPGSlidingWindow *ecaltpgSlidW, const EcalTPGFineGrainStripEE *ecaltpgFgStripEE); @@ -130,7 +121,7 @@ class EcalFenixStrip { // ========================= implementations // ============================================================== - void process(const edm::EventSetup &setup, std::vector &samples, int nrXtals, std::vector &out) { + void process(std::vector &samples, int nrXtals, std::vector &out) { // now call processing if (samples.empty()) { std::cout << " Warning: 0 size vector found in EcalFenixStripProcess!!!!!" << std::endl; @@ -155,7 +146,7 @@ class EcalFenixStrip { out = format_out_; } - void process(const edm::EventSetup &setup, std::vector &samples, int nrXtals, std::vector &out) { + void process(std::vector &samples, int nrXtals, std::vector &out) { // now call processing if (samples.empty()) { std::cout << " Warning: 0 size vector found in EcalFenixStripProcess!!!!!" << std::endl; diff --git a/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixTcp.h b/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixTcp.h index 50a01a1387beb..f61a82c1401b8 100644 --- a/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixTcp.h +++ b/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalFenixTcp.h @@ -13,8 +13,6 @@ #include #include -#include "FWCore/Framework/interface/EventSetup.h" - #include #include @@ -71,25 +69,17 @@ class EcalFenixTcp { } // end temporary, for timing tests - EcalFenixTcp(const edm::EventSetup &setup, - bool tcpFormat, - bool debug, - bool famos, - int binOfMax, - int maxNrSamples, - int nbMaxStrips); + EcalFenixTcp(bool tcpFormat, bool debug, bool famos, int binOfMax, int maxNrSamples, int nbMaxStrips); virtual ~EcalFenixTcp(); - void process(const edm::EventSetup &setup, - std::vector &bid, // dummy argument for template call + void process(std::vector &bid, // dummy argument for template call std::vector> &tpframetow, int nStr, std::vector &tptow, std::vector &tptow2, bool isInInnerRings, EcalTrigTowerDetId thisTower); - void process(const edm::EventSetup &setup, - std::vector &bid, // dummy argument for template call + void process(std::vector &bid, // dummy argument for template call std::vector> &tpframetow, int nStr, std::vector &tptow, diff --git a/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalTrigPrimFunctionalAlgo.h b/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalTrigPrimFunctionalAlgo.h index e24b344fe65e3..85ac3802cb196 100644 --- a/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalTrigPrimFunctionalAlgo.h +++ b/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalTrigPrimFunctionalAlgo.h @@ -51,19 +51,12 @@ class EcalTrigPrimFunctionalAlgo { virtual ~EcalTrigPrimFunctionalAlgo(); - void run(const edm::EventSetup &, - const EBDigiCollection *col, - EcalTrigPrimDigiCollection &result, - EcalTrigPrimDigiCollection &resultTcp); - void run(const edm::EventSetup &, - const EEDigiCollection *col, - EcalTrigPrimDigiCollection &result, - EcalTrigPrimDigiCollection &resultTcp); + void run(const EBDigiCollection *col, EcalTrigPrimDigiCollection &result, EcalTrigPrimDigiCollection &resultTcp); + void run(const EEDigiCollection *col, EcalTrigPrimDigiCollection &result, EcalTrigPrimDigiCollection &resultTcp); void run_part1_EB(EBDigiCollection const *col); void run_part1_EE(EEDigiCollection const *col); template - void run_part2(const edm::EventSetup &, - Coll const *col, + void run_part2(Coll const *col, std::vector>>> &towerMap, EcalTrigPrimDigiCollection &result, EcalTrigPrimDigiCollection &resultTcp); @@ -122,8 +115,8 @@ class EcalTrigPrimFunctionalAlgo { return ind; } - EcalFenixStrip *estrip_; - EcalFenixTcp *etcp_; + std::unique_ptr estrip_; + std::unique_ptr etcp_; edm::ESHandle eTTmap_; const CaloSubdetectorGeometry *theEndcapGeometry; @@ -165,7 +158,6 @@ class EcalTrigPrimFunctionalAlgo { template void EcalTrigPrimFunctionalAlgo::run_part2( - const edm::EventSetup &setup, Coll const *col, std::vector>>> &towerMap, EcalTrigPrimDigiCollection &result, @@ -194,14 +186,14 @@ void EcalTrigPrimFunctionalAlgo::run_part2( // size; nr of crystals/strip if ((towerMap[index])[i].first > 0) { - estrip_->process(setup, df, (towerMap[index])[i].first, striptp_[nstr++]); + estrip_->process(df, (towerMap[index])[i].first, striptp_[nstr++]); } } // loop over strips in one tower bool isInInnerRings = false; if (thisTower.subDet() == EcalEndcap && (thisTower.ietaAbs() == 27 || thisTower.ietaAbs() == 28)) isInInnerRings = true; - etcp_->process(setup, dummy, striptp_, nstr, towtp_, towtp2_, isInInnerRings, thisTower); + etcp_->process(dummy, striptp_, nstr, towtp_, towtp2_, isInInnerRings, thisTower); // prepare TP-s // special treatment for 2 inner endcap rings diff --git a/SimCalorimetry/EcalTrigPrimAlgos/src/EcalFenixStrip.cc b/SimCalorimetry/EcalTrigPrimAlgos/src/EcalFenixStrip.cc index 2e54905595de2..32667292d7277 100644 --- a/SimCalorimetry/EcalTrigPrimAlgos/src/EcalFenixStrip.cc +++ b/SimCalorimetry/EcalTrigPrimAlgos/src/EcalFenixStrip.cc @@ -8,12 +8,8 @@ #include //------------------------------------------------------------------------------------- -EcalFenixStrip::EcalFenixStrip(const edm::EventSetup &setup, - const EcalElectronicsMapping *theMapping, - bool debug, - bool famos, - int maxNrSamples, - int nbMaxXtals) +EcalFenixStrip::EcalFenixStrip( + const EcalElectronicsMapping *theMapping, bool debug, bool famos, int maxNrSamples, int nbMaxXtals) : theMapping_(theMapping), debug_(debug), famos_(famos), nbMaxXtals_(nbMaxXtals) { linearizer_.resize(nbMaxXtals_); for (int i = 0; i < nbMaxXtals_; i++) diff --git a/SimCalorimetry/EcalTrigPrimAlgos/src/EcalFenixTcp.cc b/SimCalorimetry/EcalTrigPrimAlgos/src/EcalFenixTcp.cc index e552c1128c323..7a3f1d82d2c86 100644 --- a/SimCalorimetry/EcalTrigPrimAlgos/src/EcalFenixTcp.cc +++ b/SimCalorimetry/EcalTrigPrimAlgos/src/EcalFenixTcp.cc @@ -11,13 +11,7 @@ #include //---------------------------------------------------------------------------------------- -EcalFenixTcp::EcalFenixTcp(const edm::EventSetup &setup, - bool tcpFormat, - bool debug, - bool famos, - int binOfMax, - int maxNrSamples, - int nbMaxStrips) +EcalFenixTcp::EcalFenixTcp(bool tcpFormat, bool debug, bool famos, int binOfMax, int maxNrSamples, int nbMaxStrips) : debug_(debug), nbMaxStrips_(nbMaxStrips) { bypasslin_.resize(nbMaxStrips_); for (int i = 0; i < nbMaxStrips_; i++) @@ -51,8 +45,7 @@ EcalFenixTcp::~EcalFenixTcp() { } //----------------------------------------------------------------------------------------- -void EcalFenixTcp::process(const edm::EventSetup &setup, - std::vector &bid, // dummy argument for template call +void EcalFenixTcp::process(std::vector &bid, // dummy argument for template call std::vector> &tpframetow, int nStr, std::vector &tptow, @@ -77,8 +70,7 @@ void EcalFenixTcp::process(const edm::EventSetup &setup, } //----------------------------------------------------------------------------------------- -void EcalFenixTcp::process(const edm::EventSetup &setup, - std::vector &bid, // dummy argument for template call +void EcalFenixTcp::process(std::vector &bid, // dummy argument for template call std::vector> &tpframetow, int nStr, std::vector &tptow, diff --git a/SimCalorimetry/EcalTrigPrimAlgos/src/EcalTrigPrimFunctionalAlgo.cc b/SimCalorimetry/EcalTrigPrimAlgos/src/EcalTrigPrimFunctionalAlgo.cc index 7f3951f3fb24b..4b712fd1c0f04 100644 --- a/SimCalorimetry/EcalTrigPrimAlgos/src/EcalTrigPrimFunctionalAlgo.cc +++ b/SimCalorimetry/EcalTrigPrimAlgos/src/EcalTrigPrimFunctionalAlgo.cc @@ -80,8 +80,8 @@ void EcalTrigPrimFunctionalAlgo::init(const edm::EventSetup &setup) { theMapping_ = ecalmapping.product(); // create main sub algos - estrip_ = new EcalFenixStrip(setup, theMapping_, debug_, famos_, maxNrSamples_, nbMaxXtals_); - etcp_ = new EcalFenixTcp(setup, tcpFormat_, debug_, famos_, binOfMaximum_, maxNrSamples_, nbMaxStrips_); + estrip_ = std::make_unique(theMapping_, debug_, famos_, maxNrSamples_, nbMaxXtals_); + etcp_ = std::make_unique(tcpFormat_, debug_, famos_, binOfMaximum_, maxNrSamples_, nbMaxStrips_); // initialise data structures initStructures(towerMapEB_); @@ -93,26 +93,21 @@ void EcalTrigPrimFunctionalAlgo::init(const edm::EventSetup &setup) { } //---------------------------------------------------------------------- -EcalTrigPrimFunctionalAlgo::~EcalTrigPrimFunctionalAlgo() { - delete estrip_; - delete etcp_; -} +EcalTrigPrimFunctionalAlgo::~EcalTrigPrimFunctionalAlgo() {} //---------------------------------------------------------------------- -void EcalTrigPrimFunctionalAlgo::run(const edm::EventSetup &setup, - EBDigiCollection const *col, +void EcalTrigPrimFunctionalAlgo::run(EBDigiCollection const *col, EcalTrigPrimDigiCollection &result, EcalTrigPrimDigiCollection &resultTcp) { run_part1_EB(col); - run_part2(setup, col, towerMapEB_, result, resultTcp); + run_part2(col, towerMapEB_, result, resultTcp); } //---------------------------------------------------------------------- -void EcalTrigPrimFunctionalAlgo::run(const edm::EventSetup &setup, - EEDigiCollection const *col, +void EcalTrigPrimFunctionalAlgo::run(EEDigiCollection const *col, EcalTrigPrimDigiCollection &result, EcalTrigPrimDigiCollection &resultTcp) { run_part1_EE(col); - run_part2(setup, col, towerMapEE_, result, resultTcp); + run_part2(col, towerMapEE_, result, resultTcp); } //---------------------------------------------------------------------- int EcalTrigPrimFunctionalAlgo::findStripNr(const EBDetId &id) { diff --git a/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc b/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc index 640b2fe102fec..582ee8efde4e1 100644 --- a/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc +++ b/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc @@ -274,12 +274,12 @@ void EcalTrigPrimProducer::produce(edm::Event &e, const edm::EventSetup &iSetup) const EEDigiCollection *eedc = nullptr; if (barrel) { ebdc = ebDigis.product(); - algo_->run(iSetup, ebdc, *pOut, *pOutTcp); + algo_->run(ebdc, *pOut, *pOutTcp); } if (endcap) { eedc = eeDigis.product(); - algo_->run(iSetup, eedc, *pOut, *pOutTcp); + algo_->run(eedc, *pOut, *pOutTcp); } edm::LogInfo("produce") << "For Barrel + Endcap, " << pOut->size() << " TP Digis were produced"; From e40391c7ea08b63cae219b74c62e0a37aecc40a1 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 3 Mar 2021 13:59:46 -0600 Subject: [PATCH 2/4] Removed access to EventSetup in EcalTrigPrimFunctionalAlgo This will aid migration to esConsumes. --- .../interface/EcalTrigPrimFunctionalAlgo.h | 20 +++++--- .../src/EcalTrigPrimFunctionalAlgo.cc | 48 ++++++++++++------- .../plugins/EcalTrigPrimProducer.cc | 24 +++++++++- 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalTrigPrimFunctionalAlgo.h b/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalTrigPrimFunctionalAlgo.h index 85ac3802cb196..e7952eea1a762 100644 --- a/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalTrigPrimFunctionalAlgo.h +++ b/SimCalorimetry/EcalTrigPrimAlgos/interface/EcalTrigPrimFunctionalAlgo.h @@ -27,8 +27,6 @@ #include "DataFormats/Common/interface/SortedCollection.h" #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" -#include "FWCore/Framework/interface/ESHandle.h" -#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include @@ -46,8 +44,18 @@ class EcalElectronicsMapping; class EcalTrigPrimFunctionalAlgo { public: + //Not barrelOnly + EcalTrigPrimFunctionalAlgo(const EcalTrigTowerConstituentsMap *eTTmap, + const CaloSubdetectorGeometry *endcapGeometry, + const EcalElectronicsMapping *theMapping, + int binofmax, + bool tcpFormat, + bool debug, + bool famos); + + //barrel only explicit EcalTrigPrimFunctionalAlgo( - const edm::EventSetup &setup, int binofmax, bool tcpFormat, bool barrelOnly, bool debug, bool famos); + const EcalElectronicsMapping *theMapping, int binofmax, bool tcpFormat, bool debug, bool famos); virtual ~EcalTrigPrimFunctionalAlgo(); @@ -95,7 +103,7 @@ class EcalTrigPrimFunctionalAlgo { } private: - void init(const edm::EventSetup &); + void init(); template void initStructures(std::vector>>> &towMap); template @@ -118,8 +126,8 @@ class EcalTrigPrimFunctionalAlgo { std::unique_ptr estrip_; std::unique_ptr etcp_; - edm::ESHandle eTTmap_; - const CaloSubdetectorGeometry *theEndcapGeometry; + const EcalTrigTowerConstituentsMap *eTTmap_ = nullptr; + const CaloSubdetectorGeometry *theEndcapGeometry_ = nullptr; const EcalElectronicsMapping *theMapping_; float threshold; diff --git a/SimCalorimetry/EcalTrigPrimAlgos/src/EcalTrigPrimFunctionalAlgo.cc b/SimCalorimetry/EcalTrigPrimAlgos/src/EcalTrigPrimFunctionalAlgo.cc index 4b712fd1c0f04..9877047d07e43 100644 --- a/SimCalorimetry/EcalTrigPrimAlgos/src/EcalTrigPrimFunctionalAlgo.cc +++ b/SimCalorimetry/EcalTrigPrimAlgos/src/EcalTrigPrimFunctionalAlgo.cc @@ -48,11 +48,36 @@ const unsigned int EcalTrigPrimFunctionalAlgo::maxNrTPs_ = 2448; // FIXME?? //---------------------------------------------------------------------- +EcalTrigPrimFunctionalAlgo::EcalTrigPrimFunctionalAlgo(const EcalTrigTowerConstituentsMap *eTTmap, + const CaloSubdetectorGeometry *endcapGeometry, + const EcalElectronicsMapping *theMapping, + int binofmax, + bool tcpFormat, + bool debug, + bool famos) + : eTTmap_(eTTmap), + theEndcapGeometry_(endcapGeometry), + theMapping_(theMapping), + binOfMaximum_(binofmax), + tcpFormat_(tcpFormat), + barrelOnly_(true), + debug_(debug), + famos_(famos) + +{ + if (famos_) + maxNrSamples_ = 1; // get from input?? + else + maxNrSamples_ = 10; + this->init(); +} + EcalTrigPrimFunctionalAlgo::EcalTrigPrimFunctionalAlgo( - const edm::EventSetup &setup, int binofmax, bool tcpFormat, bool barrelOnly, bool debug, bool famos) - : binOfMaximum_(binofmax), + const EcalElectronicsMapping *theMapping, int binofmax, bool tcpFormat, bool debug, bool famos) + : theMapping_(theMapping), + binOfMaximum_(binofmax), tcpFormat_(tcpFormat), - barrelOnly_(barrelOnly), + barrelOnly_(true), debug_(debug), famos_(famos) @@ -61,24 +86,11 @@ EcalTrigPrimFunctionalAlgo::EcalTrigPrimFunctionalAlgo( maxNrSamples_ = 1; // get from input?? else maxNrSamples_ = 10; - this->init(setup); + this->init(); } //---------------------------------------------------------------------- -void EcalTrigPrimFunctionalAlgo::init(const edm::EventSetup &setup) { - if (!barrelOnly_) { - edm::ESHandle theGeometry; - edm::ESHandle theEndcapGeometry_handle; - setup.get().get(theGeometry); - setup.get().get("EcalEndcap", theEndcapGeometry_handle); - theEndcapGeometry = &(*theEndcapGeometry_handle); - setup.get().get(eTTmap_); - } - // endcap mapping - edm::ESHandle ecalmapping; - setup.get().get(ecalmapping); - theMapping_ = ecalmapping.product(); - +void EcalTrigPrimFunctionalAlgo::init() { // create main sub algos estrip_ = std::make_unique(theMapping_, debug_, famos_, maxNrSamples_, nbMaxXtals_); etcp_ = std::make_unique(tcpFormat_, debug_, famos_, binOfMaximum_, maxNrSamples_, nbMaxStrips_); diff --git a/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc b/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc index 582ee8efde4e1..29cb799a9fafe 100644 --- a/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc +++ b/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc @@ -42,6 +42,7 @@ #include "CondFormats/DataRecord/interface/EcalTPGTowerStatusRcd.h" #include "CondFormats/DataRecord/interface/EcalTPGWeightGroupRcd.h" #include "CondFormats/DataRecord/interface/EcalTPGWeightIdMapRcd.h" +#include "CondFormats/DataRecord/interface/EcalTPGPedestalsRcd.h" #include "CondFormats/EcalObjects/interface/EcalTPGCrystalStatus.h" #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainEBGroup.h" #include "CondFormats/EcalObjects/interface/EcalTPGFineGrainEBIdMap.h" @@ -58,6 +59,9 @@ #include "CondFormats/EcalObjects/interface/EcalTPGWeightGroup.h" #include "CondFormats/EcalObjects/interface/EcalTPGWeightIdMap.h" +#include "Geometry/EcalMapping/interface/EcalMappingRcd.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" + #include "EcalTrigPrimProducer.h" #include @@ -126,8 +130,24 @@ void EcalTrigPrimProducer::beginRun(edm::Run const &run, edm::EventSetup const & // ProcessHistory is guaranteed to be constant for an entire Run binOfMaximum_ = findBinOfMaximum(fillBinOfMaximumFromHistory_, binOfMaximum_, run.processHistory()); - algo_ = std::make_unique(setup, binOfMaximum_, tcpFormat_, barrelOnly_, debug_, famos_); - + edm::ESHandle ecalmapping; + setup.get().get(ecalmapping); + if (barrelOnly_) { + algo_ = + std::make_unique(ecalmapping.product(), binOfMaximum_, tcpFormat_, debug_, famos_); + } else { + edm::ESHandle theEndcapGeometry_handle; + setup.get().get("EcalEndcap", theEndcapGeometry_handle); + edm::ESHandle eTTmap; + setup.get().get(eTTmap); + algo_ = std::make_unique(eTTmap.product(), + theEndcapGeometry_handle.product(), + ecalmapping.product(), + binOfMaximum_, + tcpFormat_, + debug_, + famos_); + } // get a first version of the records cacheID_ = this->getRecords(setup); } From 73bc38bebc2b698d49872d866a2dd3ec356ef337 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 3 Mar 2021 14:17:26 -0600 Subject: [PATCH 3/4] Move all EcalTrigPrimProducer references to cc file --- .../plugins/EcalTrigPrimProducer.cc | 38 ++++++++++- .../plugins/EcalTrigPrimProducer.h | 64 ------------------- .../plugins/SealModules.cc | 2 - 3 files changed, 35 insertions(+), 69 deletions(-) delete mode 100644 SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.h diff --git a/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc b/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc index 29cb799a9fafe..80fd48d937e41 100644 --- a/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc +++ b/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc @@ -18,8 +18,10 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/EDGetToken.h" #include "FWCore/Utilities/interface/InputTag.h" #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" @@ -62,12 +64,39 @@ #include "Geometry/EcalMapping/interface/EcalMappingRcd.h" #include "Geometry/Records/interface/CaloGeometryRecord.h" -#include "EcalTrigPrimProducer.h" - #include #include "SimCalorimetry/EcalTrigPrimAlgos/interface/EcalTrigPrimFunctionalAlgo.h" +class EcalTrigPrimProducer : public edm::stream::EDProducer<> { +public: + explicit EcalTrigPrimProducer(const edm::ParameterSet &conf); + + ~EcalTrigPrimProducer() override; + + void beginRun(const edm::Run &run, const edm::EventSetup &es) override; + void endRun(const edm::Run &, const edm::EventSetup &) override; + void produce(edm::Event &e, const edm::EventSetup &c) override; + + static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); + +private: + std::unique_ptr algo_; + bool barrelOnly_; + bool tcpFormat_; + bool debug_; + bool famos_; + edm::EDGetTokenT tokenEB_; + edm::EDGetTokenT tokenEE_; + + int binOfMaximum_; + bool fillBinOfMaximumFromHistory_; + + // method to get EventSetupRecords + unsigned long long getRecords(edm::EventSetup const &setup); + unsigned long long cacheID_; +}; + EcalTrigPrimProducer::EcalTrigPrimProducer(const edm::ParameterSet &iConfig) : barrelOnly_(iConfig.getParameter("BarrelOnly")), tcpFormat_(iConfig.getParameter("TcpOutput")), @@ -78,7 +107,8 @@ EcalTrigPrimProducer::EcalTrigPrimProducer(const edm::ParameterSet &iConfig) tokenEE_(consumes( edm::InputTag(iConfig.getParameter("Label"), iConfig.getParameter("InstanceEE")))), binOfMaximum_(iConfig.getParameter("binOfMaximum")), - fillBinOfMaximumFromHistory_(-1 == binOfMaximum_) { + fillBinOfMaximumFromHistory_(-1 == binOfMaximum_), + cacheID_(0){ // register your products produces(); if (tcpFormat_) @@ -347,3 +377,5 @@ void EcalTrigPrimProducer::fillDescriptions(edm::ConfigurationDescriptions &desc desc.add("binOfMaximum", -1)->setComment(kComment); descriptions.addDefault(desc); } + +DEFINE_FWK_MODULE(EcalTrigPrimProducer); diff --git a/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.h b/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.h deleted file mode 100644 index 63cf6d232200e..0000000000000 --- a/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.h +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef EcaltrigprimProducer_h -#define EcaltrigprimProducer_h - -/** \class EcalTrigPrimProducer - * - * EcalTrigPrimProducer produces a EcalTrigPrimDigiCollection - * Simulation as close as possible to hardware - * Main algorithm is EcalTrigPrimFunctionalAlgo which is now - * templated to take EBdataFrames/EEDataFrames as input - * - * \author Ursula Berthon, Stephanie Baffioni, Pascal Paganini, LLR Palaiseau - * - * \version 1st Version may 2006 - * \version 2nd Version jul 2006 - * \version 3rd Version nov 2006 - * \version 4th Version apr 2007 full endcap - * - ************************************************************/ - -#include - -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/stream/EDProducer.h" -#include "FWCore/Utilities/interface/EDGetToken.h" - -#include "DataFormats/Common/interface/Handle.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - -class EcalTrigPrimFunctionalAlgo; -class EBDigiCollection; -class EEDigiCollection; - -class EcalTrigPrimProducer : public edm::stream::EDProducer<> { -public: - explicit EcalTrigPrimProducer(const edm::ParameterSet &conf); - - ~EcalTrigPrimProducer() override; - - void beginRun(const edm::Run &run, const edm::EventSetup &es) override; - void endRun(const edm::Run &, const edm::EventSetup &) override; - void produce(edm::Event &e, const edm::EventSetup &c) override; - - static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); - -private: - std::unique_ptr algo_; - bool barrelOnly_; - bool tcpFormat_; - bool debug_; - bool famos_; - edm::EDGetTokenT tokenEB_; - edm::EDGetTokenT tokenEE_; - - int binOfMaximum_; - bool fillBinOfMaximumFromHistory_; - - // method to get EventSetupRecords - unsigned long long getRecords(edm::EventSetup const &setup); - unsigned long long cacheID_; -}; - -#endif diff --git a/SimCalorimetry/EcalTrigPrimProducers/plugins/SealModules.cc b/SimCalorimetry/EcalTrigPrimProducers/plugins/SealModules.cc index 75abc362112a8..cf90bacf0bb6a 100644 --- a/SimCalorimetry/EcalTrigPrimProducers/plugins/SealModules.cc +++ b/SimCalorimetry/EcalTrigPrimProducers/plugins/SealModules.cc @@ -4,10 +4,8 @@ #include "EcalTPInputAnalyzer.h" #include "EcalTrigPrimAnalyzer.h" #include "EcalTrigPrimESProducer.h" -#include "EcalTrigPrimProducer.h" #include "EcalTrigPrimSpikeESProducer.h" -DEFINE_FWK_MODULE(EcalTrigPrimProducer); DEFINE_FWK_MODULE(EcalTPInputAnalyzer); DEFINE_FWK_MODULE(EcalTrigPrimAnalyzer); DEFINE_FWK_MODULE(EcalTPCondAnalyzer); From 2d30dc63012c90692c71887b68794c917a77a4e5 Mon Sep 17 00:00:00 2001 From: Christopher Jones Date: Wed, 3 Mar 2021 15:04:00 -0600 Subject: [PATCH 4/4] Add esConsumes to EcalTrigPrimProducer --- .../plugins/EcalTrigPrimProducer.cc | 144 +++++++++--------- 1 file changed, 74 insertions(+), 70 deletions(-) diff --git a/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc b/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc index 80fd48d937e41..0e9cadce08b77 100644 --- a/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc +++ b/SimCalorimetry/EcalTrigPrimProducers/plugins/EcalTrigPrimProducer.cc @@ -89,6 +89,34 @@ class EcalTrigPrimProducer : public edm::stream::EDProducer<> { edm::EDGetTokenT tokenEB_; edm::EDGetTokenT tokenEE_; + const edm::ESGetToken tokenEcalMapping_; + //these are only used if we also handle the endcap + edm::ESGetToken tokenEndcapGeom_; + edm::ESGetToken tokenETTMap_; + + // for EcalFenixStrip... + // get parameter records for xtals + edm::ESGetToken tokenEcalTPGLinearization_; + edm::ESGetToken tokenEcalTPGPedestals_; + edm::ESGetToken tokenEcalTPGCrystalStatus_; + + // for strips + edm::ESGetToken tokenEcalTPGSlidingWindow_; + edm::ESGetToken tokenEcalTPGWEightIdMap_; + edm::ESGetToken tokenEcalTPGWEightGroup_; + edm::ESGetToken tokenEcalTPGFineGrainStripEE_; + edm::ESGetToken tokenEcalTPGStripStatus_; + + // .. and for EcalFenixTcp + // get parameter records for towers + edm::ESGetToken tokenEcalTPGFineGrainEBGroup_; + edm::ESGetToken tokenEcalTPGLutGroup_; + edm::ESGetToken tokenEcalTPGLutIdMap_; + edm::ESGetToken tokenEcalTPGFineGrainEBIdMap_; + edm::ESGetToken tokenEcalTPGFineGrainTowerEE_; + edm::ESGetToken tokenEcalTPGTowerStatus_; + edm::ESGetToken tokenEcalTPGSpike_; + int binOfMaximum_; bool fillBinOfMaximumFromHistory_; @@ -106,13 +134,33 @@ EcalTrigPrimProducer::EcalTrigPrimProducer(const edm::ParameterSet &iConfig) edm::InputTag(iConfig.getParameter("Label"), iConfig.getParameter("InstanceEB")))), tokenEE_(consumes( edm::InputTag(iConfig.getParameter("Label"), iConfig.getParameter("InstanceEE")))), + tokenEcalMapping_(esConsumes()), + tokenEcalTPGLinearization_(esConsumes()), + tokenEcalTPGPedestals_(esConsumes()), + tokenEcalTPGCrystalStatus_(esConsumes()), + tokenEcalTPGSlidingWindow_(esConsumes()), + tokenEcalTPGWEightIdMap_(esConsumes()), + tokenEcalTPGWEightGroup_(esConsumes()), + tokenEcalTPGFineGrainStripEE_(esConsumes()), + tokenEcalTPGStripStatus_(esConsumes()), + tokenEcalTPGFineGrainEBGroup_(esConsumes()), + tokenEcalTPGLutGroup_(esConsumes()), + tokenEcalTPGLutIdMap_(esConsumes()), + tokenEcalTPGFineGrainEBIdMap_(esConsumes()), + tokenEcalTPGFineGrainTowerEE_(esConsumes()), + tokenEcalTPGTowerStatus_(esConsumes()), + tokenEcalTPGSpike_(esConsumes()), binOfMaximum_(iConfig.getParameter("binOfMaximum")), fillBinOfMaximumFromHistory_(-1 == binOfMaximum_), - cacheID_(0){ + cacheID_(0) { // register your products produces(); if (tcpFormat_) produces("formatTCP"); + if (not barrelOnly_) { + tokenEndcapGeom_ = esConsumes(edm::ESInputTag("", "EcalEndcap")); + tokenETTMap_ = esConsumes(); + } } static int findBinOfMaximum(bool iFillFromHistory, int iPSetValue, edm::ProcessHistory const &iHistory) { @@ -160,61 +208,37 @@ void EcalTrigPrimProducer::beginRun(edm::Run const &run, edm::EventSetup const & // ProcessHistory is guaranteed to be constant for an entire Run binOfMaximum_ = findBinOfMaximum(fillBinOfMaximumFromHistory_, binOfMaximum_, run.processHistory()); - edm::ESHandle ecalmapping; - setup.get().get(ecalmapping); + auto const &ecalmapping = setup.getData(tokenEcalMapping_); if (barrelOnly_) { - algo_ = - std::make_unique(ecalmapping.product(), binOfMaximum_, tcpFormat_, debug_, famos_); + algo_ = std::make_unique(&ecalmapping, binOfMaximum_, tcpFormat_, debug_, famos_); } else { - edm::ESHandle theEndcapGeometry_handle; - setup.get().get("EcalEndcap", theEndcapGeometry_handle); - edm::ESHandle eTTmap; - setup.get().get(eTTmap); - algo_ = std::make_unique(eTTmap.product(), - theEndcapGeometry_handle.product(), - ecalmapping.product(), - binOfMaximum_, - tcpFormat_, - debug_, - famos_); + auto const &endcapGeometry = setup.getData(tokenEndcapGeom_); + auto const &eTTmap = setup.getData(tokenETTMap_); + algo_ = std::make_unique( + &eTTmap, &endcapGeometry, &ecalmapping, binOfMaximum_, tcpFormat_, debug_, famos_); } - // get a first version of the records - cacheID_ = this->getRecords(setup); } -void EcalTrigPrimProducer::endRun(edm::Run const &run, edm::EventSetup const &setup) { algo_.reset(); } +void EcalTrigPrimProducer::endRun(edm::Run const &run, edm::EventSetup const &setup) { + algo_.reset(); + cacheID_ = 0; +} unsigned long long EcalTrigPrimProducer::getRecords(edm::EventSetup const &setup) { // get Eventsetup records // for EcalFenixStrip... // get parameter records for xtals - edm::ESHandle theEcalTPGLinearization_handle; - setup.get().get(theEcalTPGLinearization_handle); - const EcalTPGLinearizationConst *ecaltpLin = theEcalTPGLinearization_handle.product(); - edm::ESHandle theEcalTPGPedestals_handle; - setup.get().get(theEcalTPGPedestals_handle); - const EcalTPGPedestals *ecaltpPed = theEcalTPGPedestals_handle.product(); - edm::ESHandle theEcalTPGCrystalStatus_handle; - setup.get().get(theEcalTPGCrystalStatus_handle); - const EcalTPGCrystalStatus *ecaltpgBadX = theEcalTPGCrystalStatus_handle.product(); + const EcalTPGLinearizationConst *ecaltpLin = &setup.getData(tokenEcalTPGLinearization_); + const EcalTPGPedestals *ecaltpPed = &setup.getData(tokenEcalTPGPedestals_); + const EcalTPGCrystalStatus *ecaltpgBadX = &setup.getData(tokenEcalTPGCrystalStatus_); // for strips - edm::ESHandle theEcalTPGSlidingWindow_handle; - setup.get().get(theEcalTPGSlidingWindow_handle); - const EcalTPGSlidingWindow *ecaltpgSlidW = theEcalTPGSlidingWindow_handle.product(); - edm::ESHandle theEcalTPGWEightIdMap_handle; - setup.get().get(theEcalTPGWEightIdMap_handle); - const EcalTPGWeightIdMap *ecaltpgWeightMap = theEcalTPGWEightIdMap_handle.product(); - edm::ESHandle theEcalTPGWEightGroup_handle; - setup.get().get(theEcalTPGWEightGroup_handle); - const EcalTPGWeightGroup *ecaltpgWeightGroup = theEcalTPGWEightGroup_handle.product(); - edm::ESHandle theEcalTPGFineGrainStripEE_handle; - setup.get().get(theEcalTPGFineGrainStripEE_handle); - const EcalTPGFineGrainStripEE *ecaltpgFgStripEE = theEcalTPGFineGrainStripEE_handle.product(); - edm::ESHandle theEcalTPGStripStatus_handle; - setup.get().get(theEcalTPGStripStatus_handle); - const EcalTPGStripStatus *ecaltpgStripStatus = theEcalTPGStripStatus_handle.product(); + const EcalTPGSlidingWindow *ecaltpgSlidW = &setup.getData(tokenEcalTPGSlidingWindow_); + const EcalTPGWeightIdMap *ecaltpgWeightMap = &setup.getData(tokenEcalTPGWEightIdMap_); + const EcalTPGWeightGroup *ecaltpgWeightGroup = &setup.getData(tokenEcalTPGWEightGroup_); + const EcalTPGFineGrainStripEE *ecaltpgFgStripEE = &setup.getData(tokenEcalTPGFineGrainStripEE_); + const EcalTPGStripStatus *ecaltpgStripStatus = &setup.getData(tokenEcalTPGStripStatus_); algo_->setPointers(ecaltpLin, ecaltpPed, @@ -227,33 +251,13 @@ unsigned long long EcalTrigPrimProducer::getRecords(edm::EventSetup const &setup // .. and for EcalFenixTcp // get parameter records for towers - edm::ESHandle theEcalTPGFineGrainEBGroup_handle; - setup.get().get(theEcalTPGFineGrainEBGroup_handle); - const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup = theEcalTPGFineGrainEBGroup_handle.product(); - - edm::ESHandle theEcalTPGLutGroup_handle; - setup.get().get(theEcalTPGLutGroup_handle); - const EcalTPGLutGroup *ecaltpgLutGroup = theEcalTPGLutGroup_handle.product(); - - edm::ESHandle theEcalTPGLutIdMap_handle; - setup.get().get(theEcalTPGLutIdMap_handle); - const EcalTPGLutIdMap *ecaltpgLut = theEcalTPGLutIdMap_handle.product(); - - edm::ESHandle theEcalTPGFineGrainEBIdMap_handle; - setup.get().get(theEcalTPGFineGrainEBIdMap_handle); - const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB = theEcalTPGFineGrainEBIdMap_handle.product(); - - edm::ESHandle theEcalTPGFineGrainTowerEE_handle; - setup.get().get(theEcalTPGFineGrainTowerEE_handle); - const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE = theEcalTPGFineGrainTowerEE_handle.product(); - - edm::ESHandle theEcalTPGTowerStatus_handle; - setup.get().get(theEcalTPGTowerStatus_handle); - const EcalTPGTowerStatus *ecaltpgBadTT = theEcalTPGTowerStatus_handle.product(); - - edm::ESHandle theEcalTPGSpike_handle; - setup.get().get(theEcalTPGSpike_handle); - const EcalTPGSpike *ecaltpgSpike = theEcalTPGSpike_handle.product(); + const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup = &setup.getData(tokenEcalTPGFineGrainEBGroup_); + const EcalTPGLutGroup *ecaltpgLutGroup = &setup.getData(tokenEcalTPGLutGroup_); + const EcalTPGLutIdMap *ecaltpgLut = &setup.getData(tokenEcalTPGLutIdMap_); + const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB = &setup.getData(tokenEcalTPGFineGrainEBIdMap_); + const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE = &setup.getData(tokenEcalTPGFineGrainTowerEE_); + const EcalTPGTowerStatus *ecaltpgBadTT = &setup.getData(tokenEcalTPGTowerStatus_); + const EcalTPGSpike *ecaltpgSpike = &setup.getData(tokenEcalTPGSpike_); algo_->setPointers2(ecaltpgFgEBGroup, ecaltpgLutGroup,