From 89e4f384752fb064d7d3922a2b8c9b57497759b5 Mon Sep 17 00:00:00 2001 From: Andrea Bocci Date: Sun, 23 Aug 2015 21:52:44 +0200 Subject: [PATCH] EcalRecalibRecHitProducer: change into a global::EDProducer - change all configuration parameters into const members - initialise them in the member initializer list - remove unused methods and member variables - change into a global::EDProducer - make the consumes conditional on the data actually being used --- .../plugins/EcalRecalibRecHitProducer.cc | 52 +++++++------------ .../plugins/EcalRecalibRecHitProducer.h | 37 ++++++------- 2 files changed, 35 insertions(+), 54 deletions(-) diff --git a/RecoLocalCalo/EcalRecProducers/plugins/EcalRecalibRecHitProducer.cc b/RecoLocalCalo/EcalRecProducers/plugins/EcalRecalibRecHitProducer.cc index d8eb9fc325e1d..6b293d5529c9b 100644 --- a/RecoLocalCalo/EcalRecProducers/plugins/EcalRecalibRecHitProducer.cc +++ b/RecoLocalCalo/EcalRecProducers/plugins/EcalRecalibRecHitProducer.cc @@ -31,37 +31,26 @@ -EcalRecalibRecHitProducer::EcalRecalibRecHitProducer(const edm::ParameterSet& ps) { - - EBRecHitCollection_ = ps.getParameter("EBRecHitCollection"); - EERecHitCollection_ = ps.getParameter("EERecHitCollection"); - EBRecHitToken_ = consumes(EBRecHitCollection_); - EERecHitToken_ = consumes(EERecHitCollection_); - EBRecalibRecHitCollection_ = ps.getParameter("EBRecalibRecHitCollection"); - EERecalibRecHitCollection_ = ps.getParameter("EERecalibRecHitCollection"); - doEnergyScale_ = ps.getParameter("doEnergyScale"); - doIntercalib_ = ps.getParameter("doIntercalib"); - doLaserCorrections_ = ps.getParameter("doLaserCorrections"); - - doEnergyScaleInverse_ = ps.getParameter("doEnergyScaleInverse"); - doIntercalibInverse_ = ps.getParameter("doIntercalibInverse"); - doLaserCorrectionsInverse_ = ps.getParameter("doLaserCorrectionsInverse"); - - EBalgo_ = new EcalRecHitSimpleAlgo(); - EEalgo_ = new EcalRecHitSimpleAlgo(); - +EcalRecalibRecHitProducer::EcalRecalibRecHitProducer(const edm::ParameterSet& ps) : + EBRecHitCollection_( ps.getParameter("EBRecHitCollection") ), + EERecHitCollection_( ps.getParameter("EERecHitCollection") ), + EBRecHitToken_( (not EBRecHitCollection_.label().empty()) ? consumes(EBRecHitCollection_) : edm::EDGetTokenT() ), + EERecHitToken_( (not EERecHitCollection_.label().empty()) ? consumes(EERecHitCollection_) : edm::EDGetTokenT() ), + EBRecalibRecHitCollection_( ps.getParameter("EBRecalibRecHitCollection") ), + EERecalibRecHitCollection_( ps.getParameter("EERecalibRecHitCollection") ), + doEnergyScale_( ps.getParameter("doEnergyScale") ), + doIntercalib_( ps.getParameter("doIntercalib") ), + doLaserCorrections_( ps.getParameter("doLaserCorrections") ), + + doEnergyScaleInverse_( ps.getParameter("doEnergyScaleInverse") ), + doIntercalibInverse_( ps.getParameter("doIntercalibInverse") ), + doLaserCorrectionsInverse_( ps.getParameter("doLaserCorrectionsInverse") ) +{ produces< EBRecHitCollection >(EBRecalibRecHitCollection_); produces< EERecHitCollection >(EERecalibRecHitCollection_); } -EcalRecalibRecHitProducer::~EcalRecalibRecHitProducer() { - - if (EBalgo_) delete EBalgo_; - if (EEalgo_) delete EEalgo_; - -} - -void EcalRecalibRecHitProducer::produce(edm::Event& evt, const edm::EventSetup& es) +void EcalRecalibRecHitProducer::produce(edm::StreamID sid, edm::Event& evt, const edm::EventSetup& es) const { using namespace edm; Handle< EBRecHitCollection > pEBRecHits; @@ -70,11 +59,11 @@ void EcalRecalibRecHitProducer::produce(edm::Event& evt, const edm::EventSetup& const EBRecHitCollection* EBRecHits = 0; const EERecHitCollection* EERecHits = 0; - if ( EBRecHitCollection_.label() != "" ) { + if (not EBRecHitCollection_.label().empty()) { evt.getByToken( EBRecHitToken_, pEBRecHits); EBRecHits = pEBRecHits.product(); // get a ptr to the product } - if ( EERecHitCollection_.label() != "" ) { + if (not EERecHitCollection_.label().empty()) { evt.getByToken( EERecHitToken_, pEERecHits); EERecHits = pEERecHits.product(); // get a ptr to the product } @@ -174,10 +163,6 @@ void EcalRecalibRecHitProducer::produce(edm::Event& evt, const edm::EventSetup& lasercalib = pLaser->getLaserCorrection( EEDetId(it->id()), evt.time() ); } - // make the rechit and put in the output collection - // must implement op= for EcalRecHit - //EcalRecHit aHit( EEalgo_->makeRecHit(*it, icalconst * lasercalib) ); - if(doIntercalibInverse_){ icalconst = 1.0/icalconst; } @@ -185,6 +170,7 @@ void EcalRecalibRecHitProducer::produce(edm::Event& evt, const edm::EventSetup& lasercalib = 1.0/lasercalib; } + // make the rechit and put in the output collection EcalRecHit aHit( (*it).id(), (*it).energy() * agc_ee * icalconst * lasercalib, (*it).time() ); EERecalibRecHits->push_back( aHit ); } diff --git a/RecoLocalCalo/EcalRecProducers/plugins/EcalRecalibRecHitProducer.h b/RecoLocalCalo/EcalRecProducers/plugins/EcalRecalibRecHitProducer.h index 414bcfdf7ad07..13a1db6accf6d 100644 --- a/RecoLocalCalo/EcalRecProducers/plugins/EcalRecalibRecHitProducer.h +++ b/RecoLocalCalo/EcalRecProducers/plugins/EcalRecalibRecHitProducer.h @@ -7,7 +7,7 @@ * **/ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/global/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -17,31 +17,26 @@ -class EcalRecalibRecHitProducer : public edm::EDProducer { +class EcalRecalibRecHitProducer : public edm::global::EDProducer<> { public: explicit EcalRecalibRecHitProducer(const edm::ParameterSet& ps); - ~EcalRecalibRecHitProducer(); - virtual void produce(edm::Event& evt, const edm::EventSetup& es); + virtual void produce(edm::StreamID sid, edm::Event& evt, const edm::EventSetup& es) const override; private: - - edm::InputTag EBRecHitCollection_; - edm::InputTag EERecHitCollection_; - edm::EDGetTokenT EBRecHitToken_; - edm::EDGetTokenT EERecHitToken_; + const edm::InputTag EBRecHitCollection_; + const edm::InputTag EERecHitCollection_; + const edm::EDGetTokenT EBRecHitToken_; + const edm::EDGetTokenT EERecHitToken_; - std::string EBRecalibRecHitCollection_; // secondary name to be given to EB collection of hits - std::string EERecalibRecHitCollection_; // secondary name to be given to EE collection of hits - - bool doEnergyScale_; - bool doIntercalib_; - bool doLaserCorrections_; - bool doEnergyScaleInverse_; - bool doIntercalibInverse_; - bool doLaserCorrectionsInverse_; - - EcalRecHitAbsAlgo* EBalgo_; - EcalRecHitAbsAlgo* EEalgo_; + const std::string EBRecalibRecHitCollection_; // secondary name to be given to EB collection of hits + const std::string EERecalibRecHitCollection_; // secondary name to be given to EE collection of hits + + const bool doEnergyScale_; + const bool doIntercalib_; + const bool doLaserCorrections_; + const bool doEnergyScaleInverse_; + const bool doIntercalibInverse_; + const bool doLaserCorrectionsInverse_; }; #endif