From 6041c891583bcbb0c454f0eb610e0262be645aa9 Mon Sep 17 00:00:00 2001 From: mmusich Date: Sat, 20 Mar 2021 11:37:30 +0100 Subject: [PATCH] migrate Validation/RecoTrack to esConsumes --- .../RecoTrack/interface/MultiTrackValidator.h | 11 ++-- .../interface/SiPixelTrackingRecHitsValid.h | 3 ++ .../interface/SiStripTrackingRecHitsValid.h | 18 ++++--- .../plugins/JetCoreMCtruthSeedGenerator.cc | 33 ++++-------- .../RecoTrack/plugins/MultiTrackValidator.cc | 13 +++-- .../plugins/MultiTrackValidatorGenPs.cc | 8 +-- .../plugins/SiPixelTrackingRecHitsValid.cc | 20 ++++---- .../plugins/TrackFromSeedProducer.cc | 27 +++++----- .../RecoTrack/plugins/TrackingNtuple.cc | 40 +++++++-------- .../src/SiStripTrackingRecHitsValid.cc | 50 ++++++------------- 10 files changed, 98 insertions(+), 125 deletions(-) diff --git a/Validation/RecoTrack/interface/MultiTrackValidator.h b/Validation/RecoTrack/interface/MultiTrackValidator.h index 2a3f9cef90421..607ae67e7b90a 100644 --- a/Validation/RecoTrack/interface/MultiTrackValidator.h +++ b/Validation/RecoTrack/interface/MultiTrackValidator.h @@ -20,6 +20,7 @@ #include "CommonTools/RecoAlgos/interface/CosmicTrackingParticleSelector.h" #include "SimTracker/Common/interface/TrackingParticleSelector.h" #include "CommonTools/RecoAlgos/interface/RecoTrackSelectorBase.h" +#include "SimTracker/Records/interface/TrackAssociatorRecord.h" #include "SimTracker/TrackAssociation/interface/ParametersDefinerForTP.h" #include "CommonTools/Utils/interface/DynArray.h" #include "DataFormats/Common/interface/ValueMap.h" @@ -52,6 +53,13 @@ class MultiTrackValidator : public DQMGlobalEDAnalyzer tTopoEsToken; + + std::string parametersDefiner; + const edm::ESGetToken tpDefinerEsToken; + const bool parametersDefinerIsCosmic_; + //these are used by MTVGenPs // MTV-specific data members std::vector associators; @@ -72,9 +80,6 @@ class MultiTrackValidator : public DQMGlobalEDAnalyzer> m_dEdx1Tag; edm::EDGetTokenT> m_dEdx2Tag; - std::string parametersDefiner; - - const bool parametersDefinerIsCosmic_; const bool ignoremissingtkcollection_; const bool useAssociators_; const bool calculateDrSingleCollection_; diff --git a/Validation/RecoTrack/interface/SiPixelTrackingRecHitsValid.h b/Validation/RecoTrack/interface/SiPixelTrackingRecHitsValid.h index 8fafefc7c241d..6dd774542b1d0 100644 --- a/Validation/RecoTrack/interface/SiPixelTrackingRecHitsValid.h +++ b/Validation/RecoTrack/interface/SiPixelTrackingRecHitsValid.h @@ -79,6 +79,9 @@ class SiPixelTrackingRecHitsValid : public DQMOneEDAnalyzer<> { const BoundPlane& plane); private: + const edm::ESGetToken tTopoEsToken_; + const edm::ESGetToken tGeomEsToken_; + TrackerHitAssociator::Config trackerHitAssociatorConfig_; //TrackLocalAngle *anglefinder_; DQMStore* dbe_; diff --git a/Validation/RecoTrack/interface/SiStripTrackingRecHitsValid.h b/Validation/RecoTrack/interface/SiStripTrackingRecHitsValid.h index ad3a5db515de5..d061e88ca66c6 100644 --- a/Validation/RecoTrack/interface/SiStripTrackingRecHitsValid.h +++ b/Validation/RecoTrack/interface/SiStripTrackingRecHitsValid.h @@ -32,6 +32,7 @@ #include "TrackingTools/TrackFitters/interface/KFTrajectoryFitter.h" #include "TrackingTools/TrackFitters/interface/KFTrajectorySmoother.h" #include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h" +#include "RecoLocalTracker/Records/interface/TkStripCPERecord.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -45,6 +46,7 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/ESWatcher.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" //--- for SimHit association @@ -246,9 +248,15 @@ class SiStripTrackingRecHitsValid : public DQMEDAnalyzer { protected: void analyze(const edm::Event& e, const edm::EventSetup& c) override; void bookHistograms(DQMStore::IBooker& ibooker, const edm::Run& run, const edm::EventSetup& es) override; - const MagneticField* magfield2_; private: + const edm::ESGetToken m_geomToken; + const edm::ESGetToken m_topoToken, m_topoTokenBR; + const edm::ESGetToken m_SiStripDetCablingToken; + const edm::ESGetToken m_stripCPEToken; + + edm::ESWatcher watchSiStripDetCablingRcd_; + DQMStore* dbe_; bool runStandalone; bool outputMEsInRootFile; @@ -385,9 +393,6 @@ class SiStripTrackingRecHitsValid : public DQMEDAnalyzer { std::map StereoAndMatchedMEsMap; std::map > LayerDetMap; std::map > StereoAndMatchedDetMap; - - edm::ESHandle SiStripDetCabling_; - std::pair projectHit(const PSimHit& hit, const StripGeomDetUnit* stripDet, const BoundPlane& plane); @@ -429,7 +434,6 @@ class SiStripTrackingRecHitsValid : public DQMEDAnalyzer { edm::ParameterSet conf_; TrackerHitAssociator::Config trackerHitAssociatorConfig_; - unsigned long long m_cacheID_; edm::ParameterSet Parameters; RecHitProperties rechitpro; @@ -437,7 +441,7 @@ class SiStripTrackingRecHitsValid : public DQMEDAnalyzer { void rechitanalysis(LocalVector ldir, const TrackingRecHit* rechit, const StripGeomDetUnit* stripdet, - edm::ESHandle stripcpe, + const StripClusterParameterEstimator* stripcpe, TrackerHitAssociator& associate, bool simplehit1or2D); @@ -446,7 +450,7 @@ class SiStripTrackingRecHitsValid : public DQMEDAnalyzer { const TrackingRecHit* rechit, const GluedGeomDet* gluedDet, TrackerHitAssociator& associate, - edm::ESHandle stripcpe, + const StripClusterParameterEstimator* stripcpe, const MatchStatus matchedmonorstereo); float track_rapidity; diff --git a/Validation/RecoTrack/plugins/JetCoreMCtruthSeedGenerator.cc b/Validation/RecoTrack/plugins/JetCoreMCtruthSeedGenerator.cc index a0f366c42b493..e153370563a78 100644 --- a/Validation/RecoTrack/plugins/JetCoreMCtruthSeedGenerator.cc +++ b/Validation/RecoTrack/plugins/JetCoreMCtruthSeedGenerator.cc @@ -23,8 +23,8 @@ #include "FWCore/Framework/interface/one/EDProducer.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/EventSetup.h" -#include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h" @@ -96,10 +96,10 @@ class JetCoreMCtruthSeedGenerator : public edm::one::EDProducer magfield_; + const edm::ESGetToken geomEsToken_; + const edm::ESGetToken pixelCPEEsToken_; + const edm::ESGetToken tTopoEsToken_; edm::ESHandle geometry_; - edm::ESHandle propagator_; edm::EDGetTokenT> vertices_; edm::EDGetTokenT> pixelClusters_; @@ -114,7 +114,6 @@ class JetCoreMCtruthSeedGenerator : public edm::one::EDProducer> findIntersection(const GlobalVector&, const reco::Candidate::Point&, @@ -158,8 +157,9 @@ class JetCoreMCtruthSeedGenerator : public edm::one::EDProducer("pixelCPE")))), + tTopoEsToken_(esConsumes()), vertices_(consumes(iConfig.getParameter("vertices"))), pixelClusters_( consumes>(iConfig.getParameter("pixelClusters"))), @@ -170,10 +170,7 @@ JetCoreMCtruthSeedGenerator::JetCoreMCtruthSeedGenerator(const edm::ParameterSet ptMin_(iConfig.getParameter("ptMin")), deltaR_(iConfig.getParameter("deltaR")), chargeFracMin_(iConfig.getParameter("chargeFractionMin")), - centralMIPCharge_(iConfig.getParameter("centralMIPCharge")), - pixelCPE_(iConfig.getParameter("pixelCPE")) - -{ + centralMIPCharge_(iConfig.getParameter("centralMIPCharge")) { produces(); produces(); } @@ -187,9 +184,7 @@ void JetCoreMCtruthSeedGenerator::produce(edm::Event& iEvent, const edm::EventSe using namespace edm; using namespace reco; - iSetup.get().get(magfield_); - iSetup.get().get(geometry_); - iSetup.get().get("AnalyticalPropagator", propagator_); + geometry_ = iSetup.getHandle(geomEsToken_); const auto& inputPixelClusters_ = iEvent.get(pixelClusters_); const auto& simtracksVector = iEvent.get(simtracksToken_); @@ -198,14 +193,8 @@ void JetCoreMCtruthSeedGenerator::produce(edm::Event& iEvent, const edm::EventSe const auto& vertices = iEvent.get(vertices_); const auto& cores = iEvent.get(cores_); - edm::ESHandle pixelCPEhandle; - const PixelClusterParameterEstimator* pixelCPE; - iSetup.get().get(pixelCPE_, pixelCPEhandle); - pixelCPE = pixelCPEhandle.product(); - - edm::ESHandle tTopoHandle; - iSetup.get().get(tTopoHandle); - const TrackerTopology* const tTopo = tTopoHandle.product(); + const PixelClusterParameterEstimator* pixelCPE = &iSetup.getData(pixelCPEEsToken_); + const TrackerTopology* const tTopo = &iSetup.getData(tTopoEsToken_); auto output = std::make_unique>(); diff --git a/Validation/RecoTrack/plugins/MultiTrackValidator.cc b/Validation/RecoTrack/plugins/MultiTrackValidator.cc index 9d1e404908fee..5a97863518ba3 100644 --- a/Validation/RecoTrack/plugins/MultiTrackValidator.cc +++ b/Validation/RecoTrack/plugins/MultiTrackValidator.cc @@ -47,10 +47,12 @@ namespace { } // namespace MultiTrackValidator::MultiTrackValidator(const edm::ParameterSet& pset) - : associators(pset.getUntrackedParameter>("associators")), - label(pset.getParameter>("label")), + : tTopoEsToken(esConsumes()), parametersDefiner(pset.getParameter("parametersDefiner")), + tpDefinerEsToken(esConsumes(edm::ESInputTag("", parametersDefiner))), parametersDefinerIsCosmic_(parametersDefiner == "CosmicParametersDefinerForTP"), + associators(pset.getUntrackedParameter>("associators")), + label(pset.getParameter>("label")), ignoremissingtkcollection_(pset.getUntrackedParameter("ignoremissingtrackcollection", false)), useAssociators_(pset.getParameter("UseAssociators")), calculateDrSingleCollection_(pset.getUntrackedParameter("calculateDrSingleCollection")), @@ -586,14 +588,11 @@ void MultiTrackValidator::dqmAnalyze(const edm::Event& event, << "====================================================\n" << "\n"; - edm::ESHandle parametersDefinerTPHandle; - setup.get().get(parametersDefiner, parametersDefinerTPHandle); + const auto& parametersDefinerTPHandle = setup.getHandle(tpDefinerEsToken); //Since we modify the object, we must clone it auto parametersDefinerTP = parametersDefinerTPHandle->clone(); - edm::ESHandle httopo; - setup.get().get(httopo); - const TrackerTopology& ttopo = *httopo; + const TrackerTopology& ttopo = setup.getData(tTopoEsToken); // FIXME: we really need to move to edm::View for reading the // TrackingParticles... Unfortunately it has non-trivial diff --git a/Validation/RecoTrack/plugins/MultiTrackValidatorGenPs.cc b/Validation/RecoTrack/plugins/MultiTrackValidatorGenPs.cc index db5e03b574a36..733b8324270bf 100644 --- a/Validation/RecoTrack/plugins/MultiTrackValidatorGenPs.cc +++ b/Validation/RecoTrack/plugins/MultiTrackValidatorGenPs.cc @@ -74,12 +74,8 @@ void MultiTrackValidatorGenPs::dqmAnalyze(const edm::Event& event, << "====================================================\n" << "\n"; - edm::ESHandle parametersDefinerTP; - setup.get().get(parametersDefiner, parametersDefinerTP); - - edm::ESHandle httopo; - setup.get().get(httopo); - const TrackerTopology& ttopo = *httopo; + const auto& parametersDefinerTP = &setup.getData(tpDefinerEsToken); + const TrackerTopology& ttopo = setup.getData(tTopoEsToken); edm::Handle TPCollectionHeff; event.getByToken(label_tp_effic, TPCollectionHeff); diff --git a/Validation/RecoTrack/plugins/SiPixelTrackingRecHitsValid.cc b/Validation/RecoTrack/plugins/SiPixelTrackingRecHitsValid.cc index 720e92f12bcec..2849ed83c983c 100644 --- a/Validation/RecoTrack/plugins/SiPixelTrackingRecHitsValid.cc +++ b/Validation/RecoTrack/plugins/SiPixelTrackingRecHitsValid.cc @@ -105,7 +105,12 @@ void SiPixelTrackingRecHitsValid::beginJob() { } SiPixelTrackingRecHitsValid::SiPixelTrackingRecHitsValid(const edm::ParameterSet& ps) - : trackerHitAssociatorConfig_(ps, consumesCollector()), dbe_(nullptr), tfile_(nullptr), t_(nullptr) { + : tTopoEsToken_(esConsumes()), + tGeomEsToken_(esConsumes()), + trackerHitAssociatorConfig_(ps, consumesCollector()), + dbe_(nullptr), + tfile_(nullptr), + t_(nullptr) { //Read config file MTCCtrack_ = ps.getParameter("MTCCtrack"); runStandalone = ps.getParameter("runStandalone"); @@ -1103,8 +1108,7 @@ SiPixelTrackingRecHitsValid::~SiPixelTrackingRecHitsValid() { // Functions that gets called by framework every event void SiPixelTrackingRecHitsValid::analyze(const edm::Event& e, const edm::EventSetup& es) { //Retrieve tracker topology from geometry - edm::ESHandle tTopo; - es.get().get(tTopo); + const auto& tTopo = &es.getData(tTopoEsToken_); run = e.id().run(); evt = e.id().event(); @@ -1124,9 +1128,7 @@ void SiPixelTrackingRecHitsValid::analyze(const edm::Event& e, const edm::EventS std::vector matched; TrackerHitAssociator associate(e, trackerHitAssociatorConfig_); - edm::ESHandle pDD; - es.get().get(pDD); - const TrackerGeometry* tracker = &(*pDD); + const TrackerGeometry* tracker = &es.getData(tGeomEsToken_); if (!MTCCtrack_) { // --------------------------------------- all hits ----------------------------------------------------------- @@ -1139,8 +1141,8 @@ void SiPixelTrackingRecHitsValid::analyze(const edm::Event& e, const edm::EventS // << " Pixel RecHits" << std::endl; //-----Iterate over detunits - for (TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++) { - DetId detId = ((*it)->geographicalId()); + for (const auto& it : tracker->dets()) { + DetId detId = it->geographicalId(); unsigned int subid = detId.subdetId(); if (!((subid == 1) || (subid == 2))) @@ -1162,7 +1164,7 @@ void SiPixelTrackingRecHitsValid::analyze(const edm::Event& e, const edm::EventS float rechitx = lp.x(); float rechity = lp.y(); - detId = (*it)->geographicalId(); + detId = it->geographicalId(); subdetId = (int)detId.subdetId(); if ((int)detId.subdetId() == (int)PixelSubdetector::PixelBarrel) { mePosxBarrel_all_hits->Fill(rechitx); diff --git a/Validation/RecoTrack/plugins/TrackFromSeedProducer.cc b/Validation/RecoTrack/plugins/TrackFromSeedProducer.cc index e5627e2811db7..aa3cfca3fb9f6 100644 --- a/Validation/RecoTrack/plugins/TrackFromSeedProducer.cc +++ b/Validation/RecoTrack/plugins/TrackFromSeedProducer.cc @@ -60,8 +60,10 @@ class TrackFromSeedProducer : public edm::global::EDProducer<> { // ----------member data --------------------------- edm::EDGetTokenT > seedsToken; edm::EDGetTokenT beamSpotToken; - std::string tTRHBuilderName; const edm::ESGetToken geoToken_; + const edm::ESGetToken tTopoToken_; + const edm::ESGetToken mfToken_; + const edm::ESGetToken ttrhToken_; }; // @@ -76,7 +78,10 @@ class TrackFromSeedProducer : public edm::global::EDProducer<> { // constructors and destructor // TrackFromSeedProducer::TrackFromSeedProducer(const edm::ParameterSet& iConfig) - : geoToken_(esConsumes()) { + : geoToken_(esConsumes()), + tTopoToken_(esConsumes()), + mfToken_(esConsumes()), + ttrhToken_(esConsumes(edm::ESInputTag("", iConfig.getParameter("TTRHBuilder")))) { //register your products produces(); produces(); @@ -85,7 +90,6 @@ TrackFromSeedProducer::TrackFromSeedProducer(const edm::ParameterSet& iConfig) // read parametes edm::InputTag seedsTag(iConfig.getParameter("src")); edm::InputTag beamSpotTag(iConfig.getParameter("beamSpot")); - tTRHBuilderName = iConfig.getParameter("TTRHBuilder"); //consumes seedsToken = consumes >(seedsTag); @@ -121,16 +125,9 @@ void TrackFromSeedProducer::produce(edm::StreamID, edm::Event& iEvent, const edm // some objects to build to tracks TSCBLBuilderNoMaterial tscblBuilder; - edm::ESHandle tTRHBuilder; - iSetup.get().get(tTRHBuilderName, tTRHBuilder); - - edm::ESHandle theMF; - iSetup.get().get(theMF); - - edm::ESHandle httopo; - iSetup.get().get(httopo); - const TrackerTopology& ttopo = *httopo; - + const auto& tTRHBuilder = &iSetup.getData(ttrhToken_); + const auto& theMF = &iSetup.getData(mfToken_); + const TrackerTopology& ttopo = iSetup.getData(tTopoToken_); const GlobalTrackingGeometry* const geometry_ = &iSetup.getData(geoToken_); // create tracks from seeds @@ -141,10 +138,10 @@ void TrackFromSeedProducer::produce(edm::StreamID, edm::Event& iEvent, const edm TrajectoryStateOnSurface state; if (seed.nHits() == 0) { //this is for deepCore seeds only const Surface* deepCore_sruface = &geometry_->idToDet(seed.startingState().detId())->specificSurface(); - state = trajectoryStateTransform::transientState(seed.startingState(), deepCore_sruface, theMF.product()); + state = trajectoryStateTransform::transientState(seed.startingState(), deepCore_sruface, theMF); } else { TransientTrackingRecHit::RecHitPointer lastRecHit = tTRHBuilder->build(&*(seed.recHits().end() - 1)); - state = trajectoryStateTransform::transientState(seed.startingState(), lastRecHit->surface(), theMF.product()); + state = trajectoryStateTransform::transientState(seed.startingState(), lastRecHit->surface(), theMF); } TrajectoryStateClosestToBeamLine tsAtClosestApproachSeed = tscblBuilder(*state.freeState(), *beamSpot); //as in TrackProducerAlgorithm diff --git a/Validation/RecoTrack/plugins/TrackingNtuple.cc b/Validation/RecoTrack/plugins/TrackingNtuple.cc index 8a56a2fc25245..3d6fad17b49aa 100644 --- a/Validation/RecoTrack/plugins/TrackingNtuple.cc +++ b/Validation/RecoTrack/plugins/TrackingNtuple.cc @@ -626,6 +626,12 @@ class TrackingNtuple : public edm::one::EDAnalyzer { HitType hitType); // ----------member data --------------------------- + const edm::ESGetToken mfToken_; + const edm::ESGetToken ttrhToken_; + const edm::ESGetToken tTopoToken_; + const edm::ESGetToken tGeomToken_; + const edm::ESGetToken paramsDefineToken_; + std::vector>> seedTokens_; std::vector>> seedStopInfoTokens_; edm::EDGetTokenT> trackToken_; @@ -651,8 +657,6 @@ class TrackingNtuple : public edm::one::EDAnalyzer { edm::EDGetTokenT> tpNLayersToken_; edm::EDGetTokenT> tpNPixelLayersToken_; edm::EDGetTokenT> tpNStripStereoLayersToken_; - std::string builderName_; - std::string parametersDefinerName_; const bool includeSeeds_; const bool includeAllHits_; const bool includeMVA_; @@ -1255,7 +1259,13 @@ class TrackingNtuple : public edm::one::EDAnalyzer { // constructors and destructor // TrackingNtuple::TrackingNtuple(const edm::ParameterSet& iConfig) - : trackToken_(consumes>(iConfig.getUntrackedParameter("tracks"))), + : mfToken_(esConsumes()), + ttrhToken_(esConsumes(edm::ESInputTag("", iConfig.getUntrackedParameter("TTRHBuilder")))), + tTopoToken_(esConsumes()), + tGeomToken_(esConsumes()), + paramsDefineToken_( + esConsumes(edm::ESInputTag("", iConfig.getUntrackedParameter("parametersDefiner")))), + trackToken_(consumes>(iConfig.getUntrackedParameter("tracks"))), clusterTPMapToken_(consumes(iConfig.getUntrackedParameter("clusterTPMap"))), simHitTPMapToken_(consumes( iConfig.getUntrackedParameter("simHitTPMap"))), @@ -1289,8 +1299,6 @@ TrackingNtuple::TrackingNtuple(const edm::ParameterSet& iConfig) iConfig.getUntrackedParameter("trackingParticleNpixellayers"))), tpNStripStereoLayersToken_(consumes>( iConfig.getUntrackedParameter("trackingParticleNstripstereolayers"))), - builderName_(iConfig.getUntrackedParameter("TTRHBuilder")), - parametersDefinerName_(iConfig.getUntrackedParameter("parametersDefiner")), includeSeeds_(iConfig.getUntrackedParameter("includeSeeds")), includeAllHits_(iConfig.getUntrackedParameter("includeAllHits")), includeMVA_(iConfig.getUntrackedParameter("includeMVA")), @@ -1985,20 +1993,10 @@ void TrackingNtuple::analyze(const edm::Event& iEvent, const edm::EventSetup& iS using namespace reco; using namespace std; - edm::ESHandle mfHandle; - iSetup.get().get(mfHandle); - const auto& mf = *mfHandle; - - edm::ESHandle theTTRHBuilder; - iSetup.get().get(builderName_, theTTRHBuilder); - - edm::ESHandle tTopoHandle; - iSetup.get().get(tTopoHandle); - const TrackerTopology& tTopo = *tTopoHandle; - - edm::ESHandle geometryHandle; - iSetup.get().get(geometryHandle); - const TrackerGeometry& tracker = *geometryHandle; + const auto& mf = iSetup.getData(mfToken_); + const auto& theTTRHBuilder = &iSetup.getData(ttrhToken_); + const TrackerTopology& tTopo = iSetup.getData(tTopoToken_); + const TrackerGeometry& tracker = iSetup.getData(tGeomToken_); edm::Handle theAssociator; iEvent.getByToken(trackAssociatorToken_, theAssociator); @@ -3387,9 +3385,7 @@ void TrackingNtuple::fillTrackingParticles(const edm::Event& iEvent, const reco::TrackToTrackingParticleAssociator& associatorByHits, const std::vector& tpHitList, const TrackingParticleRefKeyToCount& tpKeyToClusterCount) { - edm::ESHandle parametersDefinerH; - iSetup.get().get(parametersDefinerName_, parametersDefinerH); - const ParametersDefinerForTP* parametersDefiner = parametersDefinerH.product(); + const ParametersDefinerForTP* parametersDefiner = &iSetup.getData(paramsDefineToken_); // Number of 3D layers for TPs edm::Handle> tpNLayersH; diff --git a/Validation/RecoTrack/src/SiStripTrackingRecHitsValid.cc b/Validation/RecoTrack/src/SiStripTrackingRecHitsValid.cc index 6e37eef4f6d43..234fd3010b9a0 100644 --- a/Validation/RecoTrack/src/SiStripTrackingRecHitsValid.cc +++ b/Validation/RecoTrack/src/SiStripTrackingRecHitsValid.cc @@ -42,10 +42,14 @@ class TFile; //Constructor SiStripTrackingRecHitsValid::SiStripTrackingRecHitsValid(const edm::ParameterSet &ps) - : dbe_(edm::Service().operator->()), + : m_geomToken(esConsumes()), + m_topoToken(esConsumes()), + m_topoTokenBR(esConsumes()), + m_SiStripDetCablingToken(esConsumes()), + m_stripCPEToken(esConsumes(edm::ESInputTag("", "SimpleStripCPE"))), + dbe_(edm::Service().operator->()), conf_(ps), - trackerHitAssociatorConfig_(ps, consumesCollector()), - m_cacheID_(0) + trackerHitAssociatorConfig_(ps, consumesCollector()) // trajectoryInput_( ps.getParameter("trajectoryInput") ) { topFolderName_ = conf_.getParameter("TopFolderName"); @@ -537,9 +541,7 @@ SiStripTrackingRecHitsValid::~SiStripTrackingRecHitsValid() {} void SiStripTrackingRecHitsValid::bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &es) { - unsigned long long cacheID = es.get().cacheIdentifier(); - if (m_cacheID_ != cacheID) { - m_cacheID_ = cacheID; + if (watchSiStripDetCablingRcd_.check(es)) { edm::LogInfo("SiStripRecHitsValid") << "SiStripRecHitsValid::beginRun: " << " Creating MEs for new Cabling "; @@ -562,27 +564,9 @@ void SiStripTrackingRecHitsValid::analyze(const edm::Event &e, const edm::EventS TrackerHitAssociator associate(e, trackerHitAssociatorConfig_); //Retrieve tracker topology from geometry - edm::ESHandle tTopoHandle; - es.get().get(tTopoHandle); - const TrackerTopology *const tTopo = tTopoHandle.product(); - - edm::ESHandle pDD; - es.get().get(pDD); - const TrackerGeometry &tracker(*pDD); - - const TrackerGeometry *tracker2; - edm::ESHandle estracker; - es.get().get(estracker); - tracker2 = &(*estracker); - - edm::ESHandle magfield; - es.get().get(magfield); - - const MagneticField &magfield_(*magfield); - magfield2_ = &magfield_; - - edm::ESHandle stripcpe; - es.get().get("SimpleStripCPE", stripcpe); + const TrackerTopology *const tTopo = &es.getData(m_topoToken); + const TrackerGeometry &tracker = es.getData(m_geomToken); + const auto &stripcpe = &es.getData(m_stripCPEToken); // Mangano's @@ -676,7 +660,7 @@ void SiStripTrackingRecHitsValid::analyze(const edm::Event &e, const edm::EventS auto hm = matchedhit->monoHit(); const SiStripRecHit2D *monohit = &hm; // const GeomDetUnit * monodet=gdet->monoDet(); - GluedGeomDet *gdet = (GluedGeomDet *)tracker2->idToDet(matchedhit->geographicalId()); + GluedGeomDet *gdet = (GluedGeomDet *)tracker.idToDet(matchedhit->geographicalId()); if (monohit) { isrechitrphi = 1; @@ -1076,7 +1060,7 @@ void SiStripTrackingRecHitsValid::rechitanalysis_matched(LocalVector ldir, const TrackingRecHit *rechit, const GluedGeomDet *gluedDet, TrackerHitAssociator &associate, - edm::ESHandle stripcpe, + const StripClusterParameterEstimator *stripcpe, const MatchStatus matchedmonorstereo) { rechitpro.resx = -999999.; rechitpro.resy = -999999.; @@ -1260,7 +1244,7 @@ void SiStripTrackingRecHitsValid::rechitanalysis_matched(LocalVector ldir, void SiStripTrackingRecHitsValid::rechitanalysis(LocalVector ldir, const TrackingRecHit *rechit, const StripGeomDetUnit *stripdet, - edm::ESHandle stripcpe, + const StripClusterParameterEstimator *stripcpe, TrackerHitAssociator &associate, bool simplehit1or2D) { rechitpro.resx = -999999.; @@ -1376,12 +1360,10 @@ void SiStripTrackingRecHitsValid::rechitanalysis(LocalVector ldir, //-------------------------------------------------------------------------------------------- void SiStripTrackingRecHitsValid::createMEs(DQMStore::IBooker &ibooker, const edm::EventSetup &es) { //Retrieve tracker topology from geometry - edm::ESHandle tTopoHandle; - es.get().get(tTopoHandle); - const TrackerTopology *const tTopo = tTopoHandle.product(); + const TrackerTopology *const tTopo = &es.getData(m_topoTokenBR); // take from eventSetup the SiStripDetCabling object - here will use SiStripDetControl later on - es.get().get(SiStripDetCabling_); + const auto &SiStripDetCabling_ = &es.getData(m_SiStripDetCablingToken); // get list of active detectors from SiStripDetCabling std::vector activeDets;