From 3ef704558bd89fdbb2a1c438f1aa7e858826bfec Mon Sep 17 00:00:00 2001 From: Sunanda Date: Fri, 11 Mar 2022 07:45:08 +0100 Subject: [PATCH 1/2] Take care of deprecated code in FastSimulation/ForwardDetectors --- .../ForwardDetectors/plugins/CastorFastClusterProducer.cc | 7 ++----- .../ForwardDetectors/plugins/CastorFastClusterProducer.h | 7 ++++--- .../ForwardDetectors/plugins/CastorFastTowerProducer.cc | 7 ++----- .../ForwardDetectors/plugins/CastorFastTowerProducer.h | 7 ++++--- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/FastSimulation/ForwardDetectors/plugins/CastorFastClusterProducer.cc b/FastSimulation/ForwardDetectors/plugins/CastorFastClusterProducer.cc index 73ea2b1e2536a..3b6cd6c039151 100644 --- a/FastSimulation/ForwardDetectors/plugins/CastorFastClusterProducer.cc +++ b/FastSimulation/ForwardDetectors/plugins/CastorFastClusterProducer.cc @@ -28,7 +28,6 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -44,14 +43,13 @@ // genCandidate particle includes #include "DataFormats/Candidate/interface/Candidate.h" -#include "DataFormats/HepMCCandidate/interface/GenParticle.h" #include "FastSimulation/ForwardDetectors/plugins/CastorFastClusterProducer.h" // // constructors and destructor // -CastorFastClusterProducer::CastorFastClusterProducer(const edm::ParameterSet& iConfig) { +CastorFastClusterProducer::CastorFastClusterProducer(const edm::ParameterSet& iConfig) : tokGenPart_(consumes(edm::InputTag{"genParticles"})) { //register your products produces(); @@ -80,8 +78,7 @@ void CastorFastClusterProducer::produce(edm::Event& iEvent, const edm::EventSetu //cout << "entering event" << endl; - Handle genParticles; - iEvent.getByLabel("genParticles", genParticles); + const edm::Handle& genParticles = iEvent.getHandle(tokGenPart_); // make pointer to towers that will be made unique_ptr CastorClusters(new CastorClusterCollection); diff --git a/FastSimulation/ForwardDetectors/plugins/CastorFastClusterProducer.h b/FastSimulation/ForwardDetectors/plugins/CastorFastClusterProducer.h index 2b1e71aca2a7c..14cb7c0083d74 100644 --- a/FastSimulation/ForwardDetectors/plugins/CastorFastClusterProducer.h +++ b/FastSimulation/ForwardDetectors/plugins/CastorFastClusterProducer.h @@ -2,12 +2,12 @@ #define FastSimulation_ForwardDetectors_CastorFastClusterProducer_h #include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/EDGetToken.h" // Castorobject includes #include "DataFormats/CastorReco/interface/CastorCluster.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" #include "DataFormats/Math/interface/Point3D.h" // @@ -27,6 +27,7 @@ class CastorFastClusterProducer : public edm::stream::EDProducer<> { typedef math::XYZPointD Point; typedef ROOT::Math::RhoEtaPhiPoint ClusterPoint; typedef std::vector CastorClusterCollection; + const edm::EDGetTokenT tokGenPart_; }; #endif diff --git a/FastSimulation/ForwardDetectors/plugins/CastorFastTowerProducer.cc b/FastSimulation/ForwardDetectors/plugins/CastorFastTowerProducer.cc index 295ab71afa901..4f410fb0e8437 100644 --- a/FastSimulation/ForwardDetectors/plugins/CastorFastTowerProducer.cc +++ b/FastSimulation/ForwardDetectors/plugins/CastorFastTowerProducer.cc @@ -28,7 +28,6 @@ // user include files #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -44,14 +43,13 @@ // genCandidate particle includes #include "DataFormats/Candidate/interface/Candidate.h" -#include "DataFormats/HepMCCandidate/interface/GenParticle.h" #include "FastSimulation/ForwardDetectors/plugins/CastorFastTowerProducer.h" // // constructors and destructor // -CastorFastTowerProducer::CastorFastTowerProducer(const edm::ParameterSet& iConfig) { +CastorFastTowerProducer::CastorFastTowerProducer(const edm::ParameterSet& iConfig) : tokGenPart_(consumes(edm::InputTag{"genParticles"})) { //register your products produces(); @@ -80,8 +78,7 @@ void CastorFastTowerProducer::produce(edm::Event& iEvent, const edm::EventSetup& //cout << "entering event" << endl; - Handle genParticles; - iEvent.getByLabel("genParticles", genParticles); + const edm::Handle& genParticles = iEvent.getHandle(tokGenPart_); // make pointer to towers that will be made unique_ptr CastorTowers(new CastorTowerCollection); diff --git a/FastSimulation/ForwardDetectors/plugins/CastorFastTowerProducer.h b/FastSimulation/ForwardDetectors/plugins/CastorFastTowerProducer.h index b6da56a66082d..2c8b236eed858 100644 --- a/FastSimulation/ForwardDetectors/plugins/CastorFastTowerProducer.h +++ b/FastSimulation/ForwardDetectors/plugins/CastorFastTowerProducer.h @@ -3,12 +3,12 @@ // Castorobject includes #include "DataFormats/CastorReco/interface/CastorTower.h" - -#include "FWCore/ParameterSet/interface/ParameterSet.h" - #include "DataFormats/Math/interface/Point3D.h" +#include "DataFormats/HepMCCandidate/interface/GenParticle.h" #include "FWCore/Framework/interface/stream/EDProducer.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/Utilities/interface/EDGetToken.h" // // class decleration @@ -27,6 +27,7 @@ class CastorFastTowerProducer : public edm::stream::EDProducer<> { typedef math::XYZPointD Point; typedef ROOT::Math::RhoEtaPhiPoint TowerPoint; typedef std::vector CastorTowerCollection; + const edm::EDGetTokenT tokGenPart_; }; #endif From 2f0d8e1fb5b0b79f470423ca0b9763dc9418de25 Mon Sep 17 00:00:00 2001 From: Sunanda Date: Fri, 11 Mar 2022 08:04:30 +0100 Subject: [PATCH 2/2] Code check --- .../ForwardDetectors/plugins/CastorFastClusterProducer.cc | 3 ++- .../ForwardDetectors/plugins/CastorFastTowerProducer.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/FastSimulation/ForwardDetectors/plugins/CastorFastClusterProducer.cc b/FastSimulation/ForwardDetectors/plugins/CastorFastClusterProducer.cc index 3b6cd6c039151..f342670d9f9f4 100644 --- a/FastSimulation/ForwardDetectors/plugins/CastorFastClusterProducer.cc +++ b/FastSimulation/ForwardDetectors/plugins/CastorFastClusterProducer.cc @@ -49,7 +49,8 @@ // // constructors and destructor // -CastorFastClusterProducer::CastorFastClusterProducer(const edm::ParameterSet& iConfig) : tokGenPart_(consumes(edm::InputTag{"genParticles"})) { +CastorFastClusterProducer::CastorFastClusterProducer(const edm::ParameterSet& iConfig) + : tokGenPart_(consumes(edm::InputTag{"genParticles"})) { //register your products produces(); diff --git a/FastSimulation/ForwardDetectors/plugins/CastorFastTowerProducer.cc b/FastSimulation/ForwardDetectors/plugins/CastorFastTowerProducer.cc index 4f410fb0e8437..e105a1e549d14 100644 --- a/FastSimulation/ForwardDetectors/plugins/CastorFastTowerProducer.cc +++ b/FastSimulation/ForwardDetectors/plugins/CastorFastTowerProducer.cc @@ -49,7 +49,8 @@ // // constructors and destructor // -CastorFastTowerProducer::CastorFastTowerProducer(const edm::ParameterSet& iConfig) : tokGenPart_(consumes(edm::InputTag{"genParticles"})) { +CastorFastTowerProducer::CastorFastTowerProducer(const edm::ParameterSet& iConfig) + : tokGenPart_(consumes(edm::InputTag{"genParticles"})) { //register your products produces();