From d5ed28d77eb0f938f29896fdbf3ac3351365bb8d Mon Sep 17 00:00:00 2001 From: Suvankar Roy Chowdhury Date: Mon, 27 Sep 2021 17:58:44 +0200 Subject: [PATCH 1/3] migrate modules to use esConsumes --- .../plugins/CalibratedElectronProducersRun2.cc | 8 +++++--- .../plugins/ElectronIdMVAProducer.cc | 8 ++++---- .../plugins/ElectronRegressionEnergyProducer.cc | 15 ++++++++------- .../plugins/GBRForestGetterFromDB.cc | 13 ++++++------- .../RegressionEnergyPatElectronProducer.cc | 11 ++++------- .../plugins/RegressionEnergyPatElectronProducer.h | 4 ++++ 6 files changed, 31 insertions(+), 28 deletions(-) diff --git a/EgammaAnalysis/ElectronTools/plugins/CalibratedElectronProducersRun2.cc b/EgammaAnalysis/ElectronTools/plugins/CalibratedElectronProducersRun2.cc index cbc00e9a8cdbc..dd9edcaab41df 100644 --- a/EgammaAnalysis/ElectronTools/plugins/CalibratedElectronProducersRun2.cc +++ b/EgammaAnalysis/ElectronTools/plugins/CalibratedElectronProducersRun2.cc @@ -32,11 +32,12 @@ class CalibratedElectronProducerRun2T : public edm::stream::EDProducer<> { private: edm::EDGetTokenT > theElectronToken; std::string theGBRForestName; - edm::ESHandle theGBRForestHandle; EpCombinationTool theEpCombinationTool; ElectronEnergyCalibratorRun2 theEnCorrectorRun2; std::unique_ptr theSemiDeterministicRng; + + edm::ESGetToken gbrforestToken_; }; template @@ -52,6 +53,7 @@ CalibratedElectronProducerRun2T::CalibratedElectronProducerRun2T(const edm::P theSemiDeterministicRng = std::make_unique(); theEnCorrectorRun2.initPrivateRng(theSemiDeterministicRng.get()); } + gbrforestToken_ = esConsumes(edm::ESInputTag("", theGBRForestName)); produces >(); } @@ -60,8 +62,8 @@ CalibratedElectronProducerRun2T::~CalibratedElectronProducerRun2T() {} template void CalibratedElectronProducerRun2T::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) { - iSetup.get().get(theGBRForestName, theGBRForestHandle); - theEpCombinationTool.init(theGBRForestHandle.product()); + const GBRForest *theGBRForest = &iSetup.getData(gbrforestToken_); + theEpCombinationTool.init(theGBRForest); edm::Handle > in; iEvent.getByToken(theElectronToken, in); diff --git a/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc b/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc index 7bf1f668ca68d..8986f491255ea 100644 --- a/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc +++ b/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc @@ -37,6 +37,7 @@ class ElectronIdMVAProducer : public edm::EDFilter { edm::EDGetTokenT reducedEBRecHitCollectionToken_; edm::EDGetTokenT reducedEERecHitCollectionToken_; const EcalClusterLazyTools::ESGetTokens ecalClusterToolsESGetTokens_; + edm::ESGetToken ttrackbuilderToken_; double _Rho; std::string method_; @@ -73,6 +74,8 @@ ElectronIdMVAProducer::ElectronIdMVAProducer(const edm::ParameterSet& iConfig) Trig_ = iConfig.getParameter("Trig"); NoIP_ = iConfig.getParameter("NoIP"); + ttrackbuilderToken_ = esConsumes(edm::ESInputTag("", "TransientTrackBuilder")); + produces >(""); mvaID_ = new EGammaMvaEleEstimator(); @@ -134,10 +137,7 @@ bool ElectronIdMVAProducer::filter(edm::Event& iEvent, const edm::EventSetup& iS ecalClusterToolsESGetTokens_.get(iSetup), reducedEBRecHitCollectionToken_, reducedEERecHitCollectionToken_); - - edm::ESHandle builder; - iSetup.get().get("TransientTrackBuilder", builder); - TransientTrackBuilder thebuilder = *(builder.product()); + auto const& thebuilder = iSetup.getData(ttrackbuilderToken_); edm::Handle egCollection; iEvent.getByToken(electronToken_, egCollection); diff --git a/EgammaAnalysis/ElectronTools/plugins/ElectronRegressionEnergyProducer.cc b/EgammaAnalysis/ElectronTools/plugins/ElectronRegressionEnergyProducer.cc index 7696c51aef853..57090135675cd 100644 --- a/EgammaAnalysis/ElectronTools/plugins/ElectronRegressionEnergyProducer.cc +++ b/EgammaAnalysis/ElectronTools/plugins/ElectronRegressionEnergyProducer.cc @@ -57,6 +57,9 @@ class ElectronRegressionEnergyProducer : public edm::EDFilter { edm::EDGetTokenT hVertexToken_; edm::EDGetTokenT hRhoKt6PFJetsToken_; + + edm::ESGetToken ecalTopoToken_; + edm::ESGetToken caloGeomToken_; }; ElectronRegressionEnergyProducer::ElectronRegressionEnergyProducer(const edm::ParameterSet& iConfig) { @@ -75,6 +78,9 @@ ElectronRegressionEnergyProducer::ElectronRegressionEnergyProducer(const edm::Pa hVertexToken_ = consumes(edm::InputTag("offlinePrimaryVertices")); hRhoKt6PFJetsToken_ = consumes(edm::InputTag("kt6PFJets", "rho")); + ecalTopoToken_ = esConsumes(); + caloGeomToken_ = esConsumes(); + produces >(nameEnergyReg_); produces >(nameEnergyErrorReg_); @@ -104,13 +110,8 @@ bool ElectronRegressionEnergyProducer::filter(edm::Event& iEvent, const edm::Eve assert(regressionEvaluator->isInitialized()); if (!geomInitialized_) { - edm::ESHandle theCaloTopology; - iSetup.get().get(theCaloTopology); - ecalTopology_ = &(*theCaloTopology); - - edm::ESHandle theCaloGeometry; - iSetup.get().get(theCaloGeometry); - caloGeometry_ = &(*theCaloGeometry); + ecalTopology_ = &(iSetup.getData(ecalTopoToken_)); + caloGeometry_ = &(iSetup.getData(caloGeomToken_)); geomInitialized_ = true; } diff --git a/EgammaAnalysis/ElectronTools/plugins/GBRForestGetterFromDB.cc b/EgammaAnalysis/ElectronTools/plugins/GBRForestGetterFromDB.cc index 799516f15c328..91c69bbf18c66 100644 --- a/EgammaAnalysis/ElectronTools/plugins/GBRForestGetterFromDB.cc +++ b/EgammaAnalysis/ElectronTools/plugins/GBRForestGetterFromDB.cc @@ -1,16 +1,14 @@ #ifndef CalibratedElectronProducer_h #define CalibratedElectronProducer_h -#include #include - #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" - +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "CondFormats/DataRecord/interface/GBRWrapperRcd.h" #include "CondFormats/GBRForest/interface/GBRForest.h" #include @@ -25,23 +23,24 @@ class GBRForestGetterFromDB : public edm::one::EDAnalyzer<> { std::string theGBRForestName; std::string theOutputFileName; std::string theOutputObjectName; - edm::ESHandle theGBRForestHandle; + edm::ESGetToken theGBRForestToken_; }; GBRForestGetterFromDB::GBRForestGetterFromDB(const edm::ParameterSet &conf) : theGBRForestName(conf.getParameter("grbForestName")), theOutputFileName(conf.getUntrackedParameter("outputFileName")), theOutputObjectName(conf.getUntrackedParameter( - "outputObjectName", theGBRForestName.empty() ? "GBRForest" : theGBRForestName)) {} + "outputObjectName", theGBRForestName.empty() ? "GBRForest" : theGBRForestName)), + theGBRForestToken_(esConsumes()) {} GBRForestGetterFromDB::~GBRForestGetterFromDB() {} void GBRForestGetterFromDB::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) { - iSetup.get().get(theGBRForestName, theGBRForestHandle); + auto theGBRForestHandle = iSetup.getHandle(theGBRForestToken_); TFile *fOut = TFile::Open(theOutputFileName.c_str(), "RECREATE"); fOut->WriteObject(theGBRForestHandle.product(), theOutputObjectName.c_str()); fOut->Close(); - std::cout << "Wrote output to " << theOutputFileName << std::endl; + edm::LogPrint("GBRForestGetterFromDB") << "Wrote output to " << theOutputFileName; } #include "FWCore/Framework/interface/MakerMacros.h" diff --git a/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.cc b/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.cc index 2d1673c0ca2d5..2822f66ca96e2 100644 --- a/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.cc +++ b/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.cc @@ -25,6 +25,8 @@ RegressionEnergyPatElectronProducer::RegressionEnergyPatElectronProducer(const e regressionInputFile_ = cfg.getParameter("regressionInputFile"); recHitCollectionEBToken_ = mayConsume(cfg.getParameter("recHitCollectionEB")); recHitCollectionEEToken_ = mayConsume(cfg.getParameter("recHitCollectionEE")); + ecalTopoToken_ = esConsumes(); + caloGeomToken_ = esConsumes(); nameEnergyReg_ = cfg.getParameter("nameEnergyReg"); nameEnergyErrorReg_ = cfg.getParameter("nameEnergyErrorReg"); debug_ = cfg.getUntrackedParameter("debug"); @@ -87,13 +89,8 @@ RegressionEnergyPatElectronProducer::~RegressionEnergyPatElectronProducer() { de void RegressionEnergyPatElectronProducer::produce(edm::Event& event, const edm::EventSetup& setup) { assert(regressionEvaluator_->isInitialized()); if (!geomInitialized_) { - edm::ESHandle theCaloTopology; - setup.get().get(theCaloTopology); - ecalTopology_ = &(*theCaloTopology); - - edm::ESHandle theCaloGeometry; - setup.get().get(theCaloGeometry); - caloGeometry_ = &(*theCaloGeometry); + ecalTopology_ = &setup.getData(ecalTopoToken_); + caloGeometry_ = &setup.getData(caloGeomToken_); geomInitialized_ = true; } diff --git a/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.h b/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.h index 8617f77530a78..cfa4f62947e4c 100644 --- a/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.h +++ b/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.h @@ -16,6 +16,8 @@ #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/VertexReco/interface/Vertex.h" +class CaloTopologyRecord; +class CaloGeometryRecord; class RegressionEnergyPatElectronProducer : public edm::EDProducer { public: explicit RegressionEnergyPatElectronProducer(const edm::ParameterSet &); @@ -31,6 +33,8 @@ class RegressionEnergyPatElectronProducer : public edm::EDProducer { edm::EDGetTokenT recHitCollectionEBToken_; edm::EDGetTokenT recHitCollectionEEToken_; + edm::ESGetToken ecalTopoToken_; + edm::ESGetToken caloGeomToken_; // bool useReducedRecHits_; From beab45d3b90c8085060736408748ded6b67f1e32 Mon Sep 17 00:00:00 2001 From: Suvankar Roy Chowdhury Date: Tue, 28 Sep 2021 12:16:38 +0200 Subject: [PATCH 2/3] make modules threadsafe --- .../plugins/EGammaCutBasedEleIdAnalyzer.cc | 11 ++++---- .../plugins/ElectronIdMVAProducer.cc | 4 +-- .../ElectronIsolatorFromEffectiveArea.cc | 4 +-- .../plugins/ElectronPATIdMVAProducer.cc | 4 +-- .../ElectronRegressionEnergyProducer.cc | 6 ++--- .../PatElectronEAIsoCorrectionProducer.cc | 4 +-- .../plugins/PhotonIsoProducer.cc | 26 ++++++++++--------- .../RegressionEnergyPatElectronProducer.cc | 16 +++++------- .../RegressionEnergyPatElectronProducer.h | 5 ++-- 9 files changed, 40 insertions(+), 40 deletions(-) diff --git a/EgammaAnalysis/ElectronTools/plugins/EGammaCutBasedEleIdAnalyzer.cc b/EgammaAnalysis/ElectronTools/plugins/EGammaCutBasedEleIdAnalyzer.cc index 42a1e6eed1e78..916893465785a 100644 --- a/EgammaAnalysis/ElectronTools/plugins/EGammaCutBasedEleIdAnalyzer.cc +++ b/EgammaAnalysis/ElectronTools/plugins/EGammaCutBasedEleIdAnalyzer.cc @@ -21,7 +21,7 @@ Description: [one line class summary] // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Utilities/interface/transform.h" @@ -45,7 +45,7 @@ Description: [one line class summary] // class declaration // -class EGammaCutBasedEleIdAnalyzer : public edm::EDAnalyzer { +class EGammaCutBasedEleIdAnalyzer : public edm::one::EDAnalyzer<> { public: typedef std::vector > > IsoDepositMaps; typedef std::vector > > IsoDepositVals; @@ -61,11 +61,12 @@ class EGammaCutBasedEleIdAnalyzer : public edm::EDAnalyzer { void analyze(const edm::Event &, const edm::EventSetup &) override; void endJob() override; + /* void beginRun(edm::Run const &, edm::EventSetup const &) override; void endRun(edm::Run const &, edm::EventSetup const &) override; void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override; void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override; - + */ // ----------member data --------------------------- // input tags @@ -254,7 +255,7 @@ void EGammaCutBasedEleIdAnalyzer::beginJob() { // ------------ method called once each job just after ending the event loop ------------ void EGammaCutBasedEleIdAnalyzer::endJob() {} - +/* // ------------ method called when starting to processes a run ------------ void EGammaCutBasedEleIdAnalyzer::beginRun(edm::Run const &, edm::EventSetup const &) {} @@ -266,7 +267,7 @@ void EGammaCutBasedEleIdAnalyzer::beginLuminosityBlock(edm::LuminosityBlock cons // ------------ method called when ending the processing of a luminosity block ------------ void EGammaCutBasedEleIdAnalyzer::endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) {} - +*/ // ------------ method fills 'descriptions' with the allowed parameters for the module ------------ void EGammaCutBasedEleIdAnalyzer::fillDescriptions(edm::ConfigurationDescriptions &descriptions) { //The following says we do not know what parameters are allowed so do no validation diff --git a/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc b/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc index 8986f491255ea..e6988eb8ad46f 100644 --- a/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc +++ b/EgammaAnalysis/ElectronTools/plugins/ElectronIdMVAProducer.cc @@ -3,7 +3,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -21,7 +21,7 @@ // class declaration // -class ElectronIdMVAProducer : public edm::EDFilter { +class ElectronIdMVAProducer : public edm::stream::EDFilter<> { public: explicit ElectronIdMVAProducer(const edm::ParameterSet&); ~ElectronIdMVAProducer() override; diff --git a/EgammaAnalysis/ElectronTools/plugins/ElectronIsolatorFromEffectiveArea.cc b/EgammaAnalysis/ElectronTools/plugins/ElectronIsolatorFromEffectiveArea.cc index ffdcd2778848d..d423e05aa207a 100644 --- a/EgammaAnalysis/ElectronTools/plugins/ElectronIsolatorFromEffectiveArea.cc +++ b/EgammaAnalysis/ElectronTools/plugins/ElectronIsolatorFromEffectiveArea.cc @@ -1,5 +1,5 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -11,7 +11,7 @@ #include "EgammaAnalysis/ElectronTools/interface/ElectronEffectiveArea.h" -class ElectronIsolatorFromEffectiveArea : public edm::EDFilter { +class ElectronIsolatorFromEffectiveArea : public edm::stream::EDFilter<> { public: typedef edm::ValueMap CandDoubleMap; typedef ElectronEffectiveArea EEA; diff --git a/EgammaAnalysis/ElectronTools/plugins/ElectronPATIdMVAProducer.cc b/EgammaAnalysis/ElectronTools/plugins/ElectronPATIdMVAProducer.cc index 7a26e15098ea8..3305f3c6a306e 100644 --- a/EgammaAnalysis/ElectronTools/plugins/ElectronPATIdMVAProducer.cc +++ b/EgammaAnalysis/ElectronTools/plugins/ElectronPATIdMVAProducer.cc @@ -3,7 +3,7 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -21,7 +21,7 @@ // class declaration // -class ElectronPATIdMVAProducer : public edm::EDProducer { +class ElectronPATIdMVAProducer : public edm::stream::EDProducer<> { public: explicit ElectronPATIdMVAProducer(const edm::ParameterSet&); ~ElectronPATIdMVAProducer() override; diff --git a/EgammaAnalysis/ElectronTools/plugins/ElectronRegressionEnergyProducer.cc b/EgammaAnalysis/ElectronTools/plugins/ElectronRegressionEnergyProducer.cc index 57090135675cd..dd76bef027fb2 100644 --- a/EgammaAnalysis/ElectronTools/plugins/ElectronRegressionEnergyProducer.cc +++ b/EgammaAnalysis/ElectronTools/plugins/ElectronRegressionEnergyProducer.cc @@ -5,13 +5,13 @@ #include "FWCore/Framework/interface/Frameworkfwd.h" #include "DataFormats/Common/interface/Handle.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/MakerMacros.h" -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/Framework/interface/ESHandle.h" #include "Geometry/Records/interface/CaloTopologyRecord.h" @@ -27,7 +27,7 @@ // class declaration // -class ElectronRegressionEnergyProducer : public edm::EDFilter { +class ElectronRegressionEnergyProducer : public edm::stream::EDFilter<> { public: explicit ElectronRegressionEnergyProducer(const edm::ParameterSet&); ~ElectronRegressionEnergyProducer() override; diff --git a/EgammaAnalysis/ElectronTools/plugins/PatElectronEAIsoCorrectionProducer.cc b/EgammaAnalysis/ElectronTools/plugins/PatElectronEAIsoCorrectionProducer.cc index 928bdae0d2e59..e4c60c6965b06 100644 --- a/EgammaAnalysis/ElectronTools/plugins/PatElectronEAIsoCorrectionProducer.cc +++ b/EgammaAnalysis/ElectronTools/plugins/PatElectronEAIsoCorrectionProducer.cc @@ -1,4 +1,4 @@ -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -6,7 +6,7 @@ #include "DataFormats/PatCandidates/interface/Electron.h" #include "DataFormats/Common/interface/ValueMap.h" -class PatElectronEAIsoCorrectionProducer : public edm::EDProducer { +class PatElectronEAIsoCorrectionProducer : public edm::stream::EDProducer<> { public: explicit PatElectronEAIsoCorrectionProducer(const edm::ParameterSet& iConfig); ~PatElectronEAIsoCorrectionProducer() override{}; diff --git a/EgammaAnalysis/ElectronTools/plugins/PhotonIsoProducer.cc b/EgammaAnalysis/ElectronTools/plugins/PhotonIsoProducer.cc index 18bb9ff939be9..8efbd7bd3838a 100644 --- a/EgammaAnalysis/ElectronTools/plugins/PhotonIsoProducer.cc +++ b/EgammaAnalysis/ElectronTools/plugins/PhotonIsoProducer.cc @@ -3,11 +3,11 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/stream/EDFilter.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" - +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "DataFormats/EgammaCandidates/interface/GsfElectron.h" #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" @@ -22,7 +22,7 @@ // class declaration // -class PhotonIsoProducer : public edm::EDFilter { +class PhotonIsoProducer : public edm::stream::EDFilter<> { public: explicit PhotonIsoProducer(const edm::ParameterSet&); ~PhotonIsoProducer() override; @@ -117,15 +117,17 @@ bool PhotonIsoProducer::filter(edm::Event& iEvent, const edm::EventSetup& iSetup isolator.fGetIsolation(&*aPho, &thePfColl, myVtxRef, vertexCollection); if (verbose_) { - std::cout << " run " << iEvent.id().run() << " lumi " << iEvent.id().luminosityBlock() << " event " - << iEvent.id().event(); - std::cout << " pt " << aPho->pt() << " eta " << aPho->eta() << " phi " << aPho->phi() << " charge " - << aPho->charge() << " : " << std::endl; - ; - - std::cout << " ChargedIso " << isolator.getIsolationCharged() << std::endl; - std::cout << " PhotonIso " << isolator.getIsolationPhoton() << std::endl; - std::cout << " NeutralHadron Iso " << isolator.getIsolationNeutral() << std::endl; + edm::LogPrint("PhotonIsoProducer") << " run " << iEvent.id().run() + << " lumi " << iEvent.id().luminosityBlock() + << " event " << iEvent.id().event(); + edm::LogPrint("PhotonIsoProducer") << " pt " << aPho->pt() + << " eta " << aPho->eta() + << " phi " << aPho->phi() + << " charge " << aPho->charge() << " : "; + + edm::LogPrint("PhotonIsoProducer") << " ChargedIso " << isolator.getIsolationCharged(); + edm::LogPrint("PhotonIsoProducer") << " PhotonIso " << isolator.getIsolationPhoton(); + edm::LogPrint("PhotonIsoProducer") << " NeutralHadron Iso " << isolator.getIsolationNeutral(); } chIsoValues.push_back(isolator.getIsolationCharged()); diff --git a/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.cc b/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.cc index 2822f66ca96e2..dbc728b259b81 100644 --- a/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.cc +++ b/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.cc @@ -43,9 +43,7 @@ RegressionEnergyPatElectronProducer::RegressionEnergyPatElectronProducer(const e } if (inputCollectionType_ == 0 && !produceValueMaps_) { - std::cout << " You are running on GsfElectrons and the producer is not configured to produce ValueMaps with the " - "results. In that case, it does not nothing !! " - << std::endl; + edm::LogPrint("RegressionEnergyPatElectronProducer") << " You are running on GsfElectrons and the producer is not configured to produce ValueMaps with the results. In that case, it does not nothing !! "; } if (inputCollectionType_ == 0) { @@ -54,7 +52,7 @@ RegressionEnergyPatElectronProducer::RegressionEnergyPatElectronProducer(const e produces(); } else { throw cms::Exception("InconsistentParameters") - << " inputCollectionType should be either 0 (GsfElectrons) or 1 (pat::Electrons) " << std::endl; + << " inputCollectionType should be either 0 (GsfElectrons) or 1 (pat::Electrons) " ; } //set regression type @@ -81,7 +79,7 @@ RegressionEnergyPatElectronProducer::RegressionEnergyPatElectronProducer(const e geomInitialized_ = false; - std::cout << " Finished initialization " << std::endl; + edm::LogPrint("RegressionEnergyPatElectronProducer") << " Finished initialization " ; } RegressionEnergyPatElectronProducer::~RegressionEnergyPatElectronProducer() { delete regressionEvaluator_; } @@ -159,10 +157,10 @@ void RegressionEnergyPatElectronProducer::produce(edm::Event& event, const edm:: for (unsigned iele = 0; iele < nElectrons_; ++iele) { const reco::GsfElectron* ele = (inputCollectionType_ == 0) ? &(*gsfCollectionH)[iele] : &(*patCollectionH)[iele]; if (debug_) { - std::cout << "***********************************************************************\n"; - std::cout << "Run Lumi Event: " << event.id().run() << " " << event.luminosityBlock() << " " << event.id().event() + edm::LogPrint("RegressionEnergyPatElectronProducer") << "***********************************************************************\n"; + edm::LogPrint("RegressionEnergyPatElectronProducer") << "Run Lumi Event: " << event.id().run() << " " << event.luminosityBlock() << " " << event.id().event() << "\n"; - std::cout << "Pat Electron : " << ele->pt() << " " << ele->eta() << " " << ele->phi() << "\n"; + edm::LogPrint("RegressionEnergyPatElectronProducer") << "Pat Electron : " << ele->pt() << " " << ele->eta() << " " << ele->phi() << "\n"; } pat::Electron* myPatElectron = (inputCollectionType_ == 0) ? nullptr : new pat::Electron((*patCollectionH)[iele]); @@ -513,7 +511,7 @@ void RegressionEnergyPatElectronProducer::produce(edm::Event& event, const edm:: energyValues.push_back(RegressionMomentum); energyErrorValues.push_back(RegressionMomentumError); } else { - std::cout << "Error: RegressionType = " << energyRegressionType_ << " is not supported.\n"; + edm::LogPrint("RegressionEnergyPatElectronProducer") << "Error: RegressionType = " << energyRegressionType_ << " is not supported.\n"; } if (inputCollectionType_ == 1) { diff --git a/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.h b/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.h index cfa4f62947e4c..9a5383dea1cad 100644 --- a/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.h +++ b/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.h @@ -2,7 +2,7 @@ #define RegressionEnergyPatElectronProducer_h #include "DataFormats/Common/interface/Handle.h" -#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/stream/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" @@ -10,7 +10,6 @@ #include "Geometry/CaloGeometry/interface/CaloGeometry.h" #include "EgammaAnalysis/ElectronTools/interface/ElectronEnergyRegressionEvaluate.h" -//#include "EGamma/EGammaAnalysisTools/interface/ElectronEnergyRegressionEvaluate.h" #include "DataFormats/PatCandidates/interface/Electron.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" @@ -18,7 +17,7 @@ class CaloTopologyRecord; class CaloGeometryRecord; -class RegressionEnergyPatElectronProducer : public edm::EDProducer { +class RegressionEnergyPatElectronProducer : public edm::stream::EDProducer<> { public: explicit RegressionEnergyPatElectronProducer(const edm::ParameterSet &); ~RegressionEnergyPatElectronProducer() override; From 633adb2249aa242e1e4a09b5a8b193c8bd4334d0 Mon Sep 17 00:00:00 2001 From: Suvankar Roy Chowdhury Date: Tue, 28 Sep 2021 13:54:50 +0200 Subject: [PATCH 3/3] code checks and format --- .../plugins/PhotonIsoProducer.cc | 11 ++++------ .../RegressionEnergyPatElectronProducer.cc | 22 ++++++++++++------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/EgammaAnalysis/ElectronTools/plugins/PhotonIsoProducer.cc b/EgammaAnalysis/ElectronTools/plugins/PhotonIsoProducer.cc index 8efbd7bd3838a..e8b2ac31e5eb0 100644 --- a/EgammaAnalysis/ElectronTools/plugins/PhotonIsoProducer.cc +++ b/EgammaAnalysis/ElectronTools/plugins/PhotonIsoProducer.cc @@ -117,13 +117,10 @@ bool PhotonIsoProducer::filter(edm::Event& iEvent, const edm::EventSetup& iSetup isolator.fGetIsolation(&*aPho, &thePfColl, myVtxRef, vertexCollection); if (verbose_) { - edm::LogPrint("PhotonIsoProducer") << " run " << iEvent.id().run() - << " lumi " << iEvent.id().luminosityBlock() - << " event " << iEvent.id().event(); - edm::LogPrint("PhotonIsoProducer") << " pt " << aPho->pt() - << " eta " << aPho->eta() - << " phi " << aPho->phi() - << " charge " << aPho->charge() << " : "; + edm::LogPrint("PhotonIsoProducer") << " run " << iEvent.id().run() << " lumi " << iEvent.id().luminosityBlock() + << " event " << iEvent.id().event(); + edm::LogPrint("PhotonIsoProducer") << " pt " << aPho->pt() << " eta " << aPho->eta() << " phi " << aPho->phi() + << " charge " << aPho->charge() << " : "; edm::LogPrint("PhotonIsoProducer") << " ChargedIso " << isolator.getIsolationCharged(); edm::LogPrint("PhotonIsoProducer") << " PhotonIso " << isolator.getIsolationPhoton(); diff --git a/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.cc b/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.cc index dbc728b259b81..0059f6e563716 100644 --- a/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.cc +++ b/EgammaAnalysis/ElectronTools/plugins/RegressionEnergyPatElectronProducer.cc @@ -43,7 +43,9 @@ RegressionEnergyPatElectronProducer::RegressionEnergyPatElectronProducer(const e } if (inputCollectionType_ == 0 && !produceValueMaps_) { - edm::LogPrint("RegressionEnergyPatElectronProducer") << " You are running on GsfElectrons and the producer is not configured to produce ValueMaps with the results. In that case, it does not nothing !! "; + edm::LogPrint("RegressionEnergyPatElectronProducer") + << " You are running on GsfElectrons and the producer is not configured to produce ValueMaps with the results. " + "In that case, it does not nothing !! "; } if (inputCollectionType_ == 0) { @@ -52,7 +54,7 @@ RegressionEnergyPatElectronProducer::RegressionEnergyPatElectronProducer(const e produces(); } else { throw cms::Exception("InconsistentParameters") - << " inputCollectionType should be either 0 (GsfElectrons) or 1 (pat::Electrons) " ; + << " inputCollectionType should be either 0 (GsfElectrons) or 1 (pat::Electrons) "; } //set regression type @@ -79,7 +81,7 @@ RegressionEnergyPatElectronProducer::RegressionEnergyPatElectronProducer(const e geomInitialized_ = false; - edm::LogPrint("RegressionEnergyPatElectronProducer") << " Finished initialization " ; + edm::LogPrint("RegressionEnergyPatElectronProducer") << " Finished initialization "; } RegressionEnergyPatElectronProducer::~RegressionEnergyPatElectronProducer() { delete regressionEvaluator_; } @@ -157,10 +159,13 @@ void RegressionEnergyPatElectronProducer::produce(edm::Event& event, const edm:: for (unsigned iele = 0; iele < nElectrons_; ++iele) { const reco::GsfElectron* ele = (inputCollectionType_ == 0) ? &(*gsfCollectionH)[iele] : &(*patCollectionH)[iele]; if (debug_) { - edm::LogPrint("RegressionEnergyPatElectronProducer") << "***********************************************************************\n"; - edm::LogPrint("RegressionEnergyPatElectronProducer") << "Run Lumi Event: " << event.id().run() << " " << event.luminosityBlock() << " " << event.id().event() - << "\n"; - edm::LogPrint("RegressionEnergyPatElectronProducer") << "Pat Electron : " << ele->pt() << " " << ele->eta() << " " << ele->phi() << "\n"; + edm::LogPrint("RegressionEnergyPatElectronProducer") + << "***********************************************************************\n"; + edm::LogPrint("RegressionEnergyPatElectronProducer") + << "Run Lumi Event: " << event.id().run() << " " << event.luminosityBlock() << " " << event.id().event() + << "\n"; + edm::LogPrint("RegressionEnergyPatElectronProducer") + << "Pat Electron : " << ele->pt() << " " << ele->eta() << " " << ele->phi() << "\n"; } pat::Electron* myPatElectron = (inputCollectionType_ == 0) ? nullptr : new pat::Electron((*patCollectionH)[iele]); @@ -511,7 +516,8 @@ void RegressionEnergyPatElectronProducer::produce(edm::Event& event, const edm:: energyValues.push_back(RegressionMomentum); energyErrorValues.push_back(RegressionMomentumError); } else { - edm::LogPrint("RegressionEnergyPatElectronProducer") << "Error: RegressionType = " << energyRegressionType_ << " is not supported.\n"; + edm::LogPrint("RegressionEnergyPatElectronProducer") + << "Error: RegressionType = " << energyRegressionType_ << " is not supported.\n"; } if (inputCollectionType_ == 1) {