Skip to content

Commit e20d05d

Browse files
committed
Photons esConsumes migration v1
1 parent eb347dd commit e20d05d

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

Validation/RecoEgamma/plugins/PhotonPostprocessing.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ PhotonPostprocessing::~PhotonPostprocessing() {}
5757

5858
void PhotonPostprocessing::beginJob() {}
5959

60-
void PhotonPostprocessing::analyze(const edm::Event& e, const edm::EventSetup& esup) {}
60+
void PhotonPostprocessing::analyze(const edm::Event& e, const edm::EventSetup& ) {}
6161

6262
void PhotonPostprocessing::endJob() {
6363
if (standAlone_)
6464
runPostprocessing();
6565
}
6666

67-
void PhotonPostprocessing::endRun(const edm::Run& run, const edm::EventSetup& setup) {
67+
void PhotonPostprocessing::endRun(const edm::Run& run, const edm::EventSetup& ) {
6868
if (!standAlone_)
6969
runPostprocessing();
7070
}

Validation/RecoEgamma/plugins/PhotonValidator.cc

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#include "TrackingTools/PatternTools/interface/TwoTrackMinimumDistance.h"
2929
#include "TrackingTools/TransientTrack/interface/TrackTransientTrack.h"
3030
//
31-
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
32-
#include "TrackingTools/Records/interface/TransientTrackRecord.h"
3331
#include "CLHEP/Units/GlobalPhysicalConstants.h"
3432
#include "CommonTools/Statistics/interface/ChiSquaredProbability.h"
3533

@@ -60,12 +58,9 @@
6058
#include "RecoEgamma/EgammaMCTools/interface/ElectronMCTruth.h"
6159
#include "RecoEcal/EgammaCoreTools/interface/EcalClusterTools.h"
6260

63-
#include "Geometry/Records/interface/CaloGeometryRecord.h"
6461
#include "Geometry/CaloTopology/interface/CaloTopology.h"
6562
#include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h"
66-
//
67-
//#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
68-
//
63+
6964
#include "TFile.h"
7065
#include "TH1.h"
7166
#include "TH2.h"
@@ -84,8 +79,9 @@
8479
using namespace std;
8580

8681
PhotonValidator::PhotonValidator(const edm::ParameterSet& pset)
87-
88-
{
82+
: magneticFieldToken_{esConsumes<edm::Transition::BeginRun>()},
83+
caloGeometryToken_{esConsumes()},
84+
transientTrackBuilderToken_{esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))} {
8985
fName_ = pset.getParameter<std::string>("analyzerName");
9086
verbosity_ = pset.getUntrackedParameter<int>("Verbosity");
9187
parameters_ = pset;
@@ -158,7 +154,7 @@ PhotonValidator::PhotonValidator(const edm::ParameterSet& pset)
158154

159155
PhotonValidator::~PhotonValidator() {}
160156

161-
void PhotonValidator::bookHistograms(DQMStore::IBooker& iBooker, edm::Run const& run, edm::EventSetup const& es) {
157+
void PhotonValidator::bookHistograms(DQMStore::IBooker& iBooker, edm::Run const& run, edm::EventSetup const&) {
162158
double resMin = parameters_.getParameter<double>("resMin");
163159
double resMax = parameters_.getParameter<double>("resMax");
164160
int resBin = parameters_.getParameter<int>("resBin");
@@ -3161,14 +3157,12 @@ void PhotonValidator::dqmBeginRun(edm::Run const& r, edm::EventSetup const& theE
31613157
//get magnetic field
31623158
edm::LogInfo("ConvertedPhotonProducer") << " get magnetic field"
31633159
<< "\n";
3164-
theEventSetup.get<IdealMagneticFieldRecord>().get(theMF_);
3160+
theMF_ = theEventSetup.getHandle(magneticFieldToken_);
31653161

31663162
thePhotonMCTruthFinder_ = std::make_unique<PhotonMCTruthFinder>();
31673163
}
31683164

3169-
void PhotonValidator::dqmEndRun(edm::Run const& r, edm::EventSetup const& theEventSetup) {
3170-
thePhotonMCTruthFinder_.reset();
3171-
}
3165+
void PhotonValidator::dqmEndRun(edm::Run const& r, edm::EventSetup const&) { thePhotonMCTruthFinder_.reset(); }
31723166

31733167
void PhotonValidator::analyze(const edm::Event& e, const edm::EventSetup& esup) {
31743168
thePhotonMCTruthFinder_->clear();
@@ -3191,15 +3185,14 @@ void PhotonValidator::analyze(const edm::Event& e, const edm::EventSetup& esup)
31913185
<< "\n";
31923186

31933187
// get the geometry from the event setup:
3194-
esup.get<CaloGeometryRecord>().get(theCaloGeom_);
3188+
theCaloGeom_ = esup.getHandle(caloGeometryToken_);
31953189

31963190
edm::Handle<reco::VertexCollection> vtxH;
31973191
e.getByToken(offline_pvToken_, vtxH);
31983192
h_nRecoVtx_->Fill(float(vtxH->size()));
31993193

32003194
// Transform Track into TransientTrack (needed by the Vertex fitter)
3201-
edm::ESHandle<TransientTrackBuilder> theTTB;
3202-
esup.get<TransientTrackRecord>().get("TransientTrackBuilder", theTTB);
3195+
auto theTTB = esup.getHandle(transientTrackBuilderToken_);
32033196

32043197
///// Get the recontructed photons
32053198
Handle<reco::PhotonCollection> photonHandle;

Validation/RecoEgamma/plugins/PhotonValidator.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
#include "SimDataFormats/Vertex/interface/SimVertex.h"
2525
#include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
2626
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
27+
#include "Geometry/Records/interface/CaloGeometryRecord.h"
28+
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
29+
#include "TrackingTools/Records/interface/TransientTrackRecord.h"
2730
//
2831
//DQM services
2932
#include "DQMServices/Core/interface/DQMStore.h"
@@ -119,6 +122,10 @@ class PhotonValidator : public DQMOneEDAnalyzer<> {
119122
edm::EDGetTokenT<edm::HepMCProduct> hepMC_Token_;
120123
edm::EDGetTokenT<reco::GenJetCollection> genjets_Token_;
121124

125+
const edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magneticFieldToken_;
126+
const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> caloGeometryToken_;
127+
const edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> transientTrackBuilderToken_;
128+
122129
std::unique_ptr<PhotonMCTruthFinder> thePhotonMCTruthFinder_;
123130

124131
bool fastSim_;

Validation/RecoEgamma/plugins/PhotonValidatorMiniAOD.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ PhotonValidatorMiniAOD::~PhotonValidatorMiniAOD() {}
4545

4646
void PhotonValidatorMiniAOD::bookHistograms(DQMStore::IBooker &iBooker,
4747
edm::Run const &run,
48-
edm::EventSetup const &es) {
48+
edm::EventSetup const &) {
4949
double eMin = parameters_.getParameter<double>("eMin");
5050
double eMax = parameters_.getParameter<double>("eMax");
5151
int eBin = parameters_.getParameter<int>("eBin");
@@ -193,7 +193,7 @@ void PhotonValidatorMiniAOD::bookHistograms(DQMStore::IBooker &iBooker,
193193
h_phoIso_[2] = iBooker.book1D(histname + "Endcap_miniAOD", "PF photonIso: Endcap", etBin, etMin, 20.);
194194
}
195195

196-
void PhotonValidatorMiniAOD::analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) {
196+
void PhotonValidatorMiniAOD::analyze(const edm::Event &iEvent, const edm::EventSetup &) {
197197
// ********************************************************************************
198198
using namespace edm;
199199

0 commit comments

Comments
 (0)