From a71c1ddbe8182f1da627c0130805d92c406eff44 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Thu, 9 Sep 2021 19:05:44 +0200 Subject: [PATCH 1/6] Remove unnecessary use of EventSetup from OuterEstimator --- RecoTracker/TkTrackingRegions/src/OuterEstimator.h | 5 +---- .../src/RectangularEtaPhiTrackingRegion.cc | 6 ++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/RecoTracker/TkTrackingRegions/src/OuterEstimator.h b/RecoTracker/TkTrackingRegions/src/OuterEstimator.h index 465b11987c728..be4b38112a4c0 100644 --- a/RecoTracker/TkTrackingRegions/src/OuterEstimator.h +++ b/RecoTracker/TkTrackingRegions/src/OuterEstimator.h @@ -15,8 +15,6 @@ #include "OuterDetCompatibility.h" #include "OuterHitCompatibility.h" -#include "FWCore/Framework/interface/EventSetup.h" - #include "FWCore/Utilities/interface/Visibility.h" template @@ -25,8 +23,7 @@ class dso_internal OuterEstimator final : public MeasurementEstimator { using OuterHitCompat = OuterHitCompatibility; OuterEstimator(const OuterDetCompatibility& detCompatibility, - const OuterHitCompat& hitCompatibility, - const edm::EventSetup& iSetup) + const OuterHitCompat& hitCompatibility) : theDetCompatibility(detCompatibility), theHitCompatibility(hitCompatibility) {} ~OuterEstimator() override {} diff --git a/RecoTracker/TkTrackingRegions/src/RectangularEtaPhiTrackingRegion.cc b/RecoTracker/TkTrackingRegions/src/RectangularEtaPhiTrackingRegion.cc index da72a58eeebd2..5d44fdf837745 100644 --- a/RecoTracker/TkTrackingRegions/src/RectangularEtaPhiTrackingRegion.cc +++ b/RecoTracker/TkTrackingRegions/src/RectangularEtaPhiTrackingRegion.cc @@ -237,8 +237,7 @@ std::unique_ptr RectangularEtaPhiTrackingRegion::estimator } return std::make_unique>(OuterDetCompatibility(layer, phiRange, detRWindow, hitZWindow), - OuterHitCompatibility(phiPrediction, zPrediction), - iSetup); + OuterHitCompatibility(phiPrediction, zPrediction)); } std::unique_ptr RectangularEtaPhiTrackingRegion::estimator(const ForwardDetLayer* layer, @@ -297,8 +296,7 @@ std::unique_ptr RectangularEtaPhiTrackingRegion::estimator } return std::make_unique>(OuterDetCompatibility(layer, phiRange, hitRWindow, detZWindow), - OuterHitCompatibility(phiPrediction, rPrediction), - iSetup); + OuterHitCompatibility(phiPrediction, rPrediction)); } OuterHitPhiPrediction RectangularEtaPhiTrackingRegion::phiWindow(const MagneticField& field) const { From 41eba9ad9f10564186ba793f8a23ecf7de83e817 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Fri, 10 Sep 2021 21:41:46 +0200 Subject: [PATCH 2/6] Move accessing EventSetup from RectangularEtaPhiTrackingRegion to the functions that create those objects --- .../plugins/HITRegionalPixelSeedGenerator.cc | 43 ++++++++++++----- .../Muons/plugins/FastTSGFromL2Muon.cc | 2 +- HLTrigger/btau/plugins/L3MumuTrackingRegion.h | 21 +++++++-- ...rackingRegionsFromSuperClustersProducer.cc | 30 +++++++++--- .../plugins/HIMuonTrackingRegionProducer.h | 2 +- .../HITrackingRegionForPrimaryVtxProducer.h | 38 +++++++++------ .../plugins/HITrackingRegionProducer.h | 46 +++++++++++++------ .../interface/GlobalTrajectoryBuilderBase.h | 8 ++++ .../interface/MuonTrackingRegionBuilder.h | 22 +++++---- .../src/GlobalTrajectoryBuilderBase.cc | 11 ++++- .../src/MuonTrackingRegionBuilder.cc | 40 ++++++++++++++-- .../interface/L1MuonRegionProducer.h | 20 ++++---- .../plugins/TSGFromL1Muon.cc | 5 +- .../plugins/TSGFromL2Muon.cc | 2 +- .../src/L1MuonRegionProducer.cc | 22 +++++++-- .../src/TauRegionalPixelSeedGenerator.h | 20 ++++++-- .../src/TrackingRegionsFromBeamSpotAndL2Tau.h | 16 ++++++- .../RectangularEtaPhiTrackingRegion.h | 34 ++++++++++---- .../AreaSeededTrackingRegionsBuilder.cc | 23 ++++++++-- .../AreaSeededTrackingRegionsBuilder.h | 17 ++++++- .../AreaSeededTrackingRegionsProducer.h | 2 +- ...didatePointSeededTrackingRegionsProducer.h | 28 +++++++++-- .../CandidateSeededTrackingRegionsProducer.h | 24 ++++++++-- ...reaTrackingRegionsSeedingLayersProducer.cc | 2 +- .../PointSeededTrackingRegionsProducer.h | 23 +++++++++- .../TkTrackingRegions/src/OuterEstimator.h | 3 +- .../src/RectangularEtaPhiTrackingRegion.cc | 45 +++++------------- 27 files changed, 397 insertions(+), 152 deletions(-) diff --git a/Calibration/HcalIsolatedTrackReco/plugins/HITRegionalPixelSeedGenerator.cc b/Calibration/HcalIsolatedTrackReco/plugins/HITRegionalPixelSeedGenerator.cc index 663795d2470d7..6f3d57bc0d2b7 100644 --- a/Calibration/HcalIsolatedTrackReco/plugins/HITRegionalPixelSeedGenerator.cc +++ b/Calibration/HcalIsolatedTrackReco/plugins/HITRegionalPixelSeedGenerator.cc @@ -7,8 +7,11 @@ #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Utilities/interface/InputTag.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h" -#include "RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h" #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h" #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" @@ -31,10 +34,11 @@ class HITRegionalPixelSeedGenerator : public TrackingRegionProducer { public: - explicit HITRegionalPixelSeedGenerator(const edm::ParameterSet& conf_, edm::ConsumesCollector&& iC) { + explicit HITRegionalPixelSeedGenerator(const edm::ParameterSet& conf, edm::ConsumesCollector&& iC) + : token_bfield(iC.esConsumes()), token_msmaker(iC.esConsumes()) { edm::LogVerbatim("HITRegionalPixelSeedGenerator") << "Enter the HITRegionalPixelSeedGenerator"; - edm::ParameterSet regionPSet = conf_.getParameter("RegionPSet"); + edm::ParameterSet regionPSet = conf.getParameter("RegionPSet"); ptmin = regionPSet.getParameter("ptMin"); originradius = regionPSet.getParameter("originRadius"); @@ -69,6 +73,9 @@ class HITRegionalPixelSeedGenerator : public TrackingRegionProducer { double deltaZVertex = halflength; + auto const& bfield = es.getData(token_bfield); + auto const& msmaker = es.getData(token_msmaker); + if (usetracks_) { edm::Handle tracks; e.getByToken(token_trks, tracks); @@ -93,8 +100,15 @@ class HITRegionalPixelSeedGenerator : public TrackingRegionProducer { GlobalVector ptrVec((itr)->px(), (itr)->py(), (itr)->pz()); globalVector = ptrVec; - result.push_back(std::make_unique( - globalVector, GlobalPoint(0, 0, originz), ptmin, originradius, deltaZVertex, deltaTrackEta, deltaTrackPhi)); + result.push_back(std::make_unique(globalVector, + GlobalPoint(0, 0, originz), + ptmin, + originradius, + deltaZVertex, + deltaTrackEta, + deltaTrackPhi, + bfield, + &msmaker)); } } @@ -127,8 +141,15 @@ class HITRegionalPixelSeedGenerator : public TrackingRegionProducer { (isoPixTrackRefs[p]->track())->pz()); globalVector = ptrVec; - result.push_back(std::make_unique( - globalVector, GlobalPoint(0, 0, originz), ptmin, originradius, deltaZVertex, deltaTrackEta, deltaTrackPhi)); + result.push_back(std::make_unique(globalVector, + GlobalPoint(0, 0, originz), + ptmin, + originradius, + deltaZVertex, + deltaTrackEta, + deltaTrackPhi, + bfield, + &msmaker)); } } @@ -155,7 +176,7 @@ class HITRegionalPixelSeedGenerator : public TrackingRegionProducer { GlobalPoint vertex(0, 0, originz); result.push_back(std::make_unique( - jetVector, vertex, ptmin, originradius, deltaZVertex, deltaL1JetEta, deltaL1JetPhi)); + jetVector, vertex, ptmin, originradius, deltaZVertex, deltaL1JetEta, deltaL1JetPhi, bfield, &msmaker)); } } if (fixedReg_) { @@ -175,15 +196,13 @@ class HITRegionalPixelSeedGenerator : public TrackingRegionProducer { } result.push_back(std::make_unique( - fixedVector, vertex, ptmin, originradius, deltaZVertex, deltaL1JetEta, deltaL1JetPhi)); + fixedVector, vertex, ptmin, originradius, deltaZVertex, deltaL1JetEta, deltaL1JetPhi, bfield, &msmaker)); } return result; } private: - edm::ParameterSet conf_; - float ptmin; float originradius; float halflength; @@ -201,6 +220,8 @@ class HITRegionalPixelSeedGenerator : public TrackingRegionProducer { edm::EDGetTokenT token_vertex; edm::EDGetTokenT token_isoTrack; edm::EDGetTokenT token_l1jet; + edm::ESGetToken token_bfield; + edm::ESGetToken token_msmaker; }; #include "FWCore/PluginManager/interface/ModuleDef.h" diff --git a/FastSimulation/Muons/plugins/FastTSGFromL2Muon.cc b/FastSimulation/Muons/plugins/FastTSGFromL2Muon.cc index 624d09739ea33..b22fbe8d7e8c4 100644 --- a/FastSimulation/Muons/plugins/FastTSGFromL2Muon.cc +++ b/FastSimulation/Muons/plugins/FastTSGFromL2Muon.cc @@ -56,7 +56,7 @@ void FastTSGFromL2Muon::produce(edm::Event& ev, const edm::EventSetup& es) { std::unique_ptr result(new L3MuonTrajectorySeedCollection()); // Region builder - theRegionBuilder->setEvent(ev); + theRegionBuilder->setEvent(ev, es); // Retrieve the Monte Carlo truth (SimTracks) edm::Handle theSimTracks; diff --git a/HLTrigger/btau/plugins/L3MumuTrackingRegion.h b/HLTrigger/btau/plugins/L3MumuTrackingRegion.h index a6ba11cc7663e..017adb8c0db54 100644 --- a/HLTrigger/btau/plugins/L3MumuTrackingRegion.h +++ b/HLTrigger/btau/plugins/L3MumuTrackingRegion.h @@ -4,6 +4,10 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/ConsumesCollector.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h" #include "RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h" #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h" @@ -16,7 +20,8 @@ class L3MumuTrackingRegion : public TrackingRegionProducer { public: - L3MumuTrackingRegion(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC) { + L3MumuTrackingRegion(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC) + : theFieldToken(iC.esConsumes()), theMSMakerToken(iC.esConsumes()) { edm::ParameterSet regionPSet = cfg.getParameter("RegionPSet"); theVertexTag = regionPSet.getParameter("vertexSrc"); @@ -49,7 +54,7 @@ class L3MumuTrackingRegion : public TrackingRegionProducer { } } - ~L3MumuTrackingRegion() override {} + ~L3MumuTrackingRegion() override = default; std::vector > regions(const edm::Event& ev, const edm::EventSetup& es) const override { @@ -61,6 +66,8 @@ class L3MumuTrackingRegion : public TrackingRegionProducer { ev.getByToken(theMeasurementTrackerToken, hmte); measurementTracker = hmte.product(); } + const auto& field = es.getData(theFieldToken); + const auto& msmaker = es.getData(theMSMakerToken); // optional constraint for vertex // get highest Pt pixel vertex (if existing) @@ -89,8 +96,10 @@ class L3MumuTrackingRegion : public TrackingRegionProducer { deltaZVertex, theDeltaEta, theDeltaPhi, - m_howToUseMeasurementTracker, + field, + &msmaker, true, + m_howToUseMeasurementTracker, measurementTracker, m_searchOpt)); } @@ -110,8 +119,10 @@ class L3MumuTrackingRegion : public TrackingRegionProducer { deltaZVertex, theDeltaEta, theDeltaPhi, - m_howToUseMeasurementTracker, + field, + &msmaker, true, + m_howToUseMeasurementTracker, measurementTracker, m_searchOpt)); } @@ -136,6 +147,8 @@ class L3MumuTrackingRegion : public TrackingRegionProducer { double theDeltaPhi; edm::EDGetTokenT theMeasurementTrackerToken; RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_howToUseMeasurementTracker; + edm::ESGetToken theFieldToken; + edm::ESGetToken theMSMakerToken; bool m_searchOpt; }; diff --git a/RecoEgamma/EgammaElectronProducers/plugins/TrackingRegionsFromSuperClustersProducer.cc b/RecoEgamma/EgammaElectronProducers/plugins/TrackingRegionsFromSuperClustersProducer.cc index 9d3e0d2329349..1d0461e3b9e1c 100644 --- a/RecoEgamma/EgammaElectronProducers/plugins/TrackingRegionsFromSuperClustersProducer.cc +++ b/RecoEgamma/EgammaElectronProducers/plugins/TrackingRegionsFromSuperClustersProducer.cc @@ -38,6 +38,10 @@ #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h" #include "DataFormats/EgammaReco/interface/SuperCluster.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h" #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h" #include "RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h" @@ -103,7 +107,8 @@ class TrackingRegionsFromSuperClustersProducer : public TrackingRegionProducer { const double deltaZVertex, const Charge charge, const MeasurementTrackerEvent* measTrackerEvent, - const MagneticField& magField) const; + const MagneticField& magField, + const MultipleScatteringParametrisationMaker* msmaker) const; private: void validateConfigSettings() const; @@ -134,6 +139,7 @@ class TrackingRegionsFromSuperClustersProducer : public TrackingRegionProducer { std::vector>> superClustersTokens_; const edm::ESGetToken magFieldToken_; + edm::ESGetToken msmakerToken_; }; namespace { @@ -182,6 +188,9 @@ TrackingRegionsFromSuperClustersProducer::TrackingRegionsFromSuperClustersProduc for (const auto& tag : superClustersTags) { superClustersTokens_.emplace_back(iC.consumes(tag)); } + if (precise_) { + msmakerToken_ = iC.esConsumes(); + } } void TrackingRegionsFromSuperClustersProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { @@ -231,15 +240,19 @@ std::vector> TrackingRegionsFromSuperClustersPro measTrackerEvent = getHandle(iEvent, measTrackerEventToken_).product(); } auto const& magField = iSetup.getData(magFieldToken_); + const MultipleScatteringParametrisationMaker* msmaker = nullptr; + if (precise_) { + msmaker = &iSetup.getData(msmakerToken_); + } for (auto& superClustersToken : superClustersTokens_) { auto superClustersHandle = getHandle(iEvent, superClustersToken); for (auto& superClusterRef : *superClustersHandle) { //do both charge hypothesises - trackingRegions.emplace_back( - createTrackingRegion(*superClusterRef, vtxPos, deltaZVertex, Charge::POS, measTrackerEvent, magField)); - trackingRegions.emplace_back( - createTrackingRegion(*superClusterRef, vtxPos, deltaZVertex, Charge::NEG, measTrackerEvent, magField)); + trackingRegions.emplace_back(createTrackingRegion( + *superClusterRef, vtxPos, deltaZVertex, Charge::POS, measTrackerEvent, magField, msmaker)); + trackingRegions.emplace_back(createTrackingRegion( + *superClusterRef, vtxPos, deltaZVertex, Charge::NEG, measTrackerEvent, magField, msmaker)); } } return trackingRegions; @@ -283,7 +296,8 @@ std::unique_ptr TrackingRegionsFromSuperClustersProducer::create const double deltaZVertex, const Charge charge, const MeasurementTrackerEvent* measTrackerEvent, - const MagneticField& magField) const { + const MagneticField& magField, + const MultipleScatteringParametrisationMaker* msmaker) const { const GlobalPoint clusterPos(superCluster.position().x(), superCluster.position().y(), superCluster.position().z()); const double energy = superCluster.energy(); @@ -295,8 +309,10 @@ std::unique_ptr TrackingRegionsFromSuperClustersProducer::create deltaZVertex, deltaEtaRegion_, deltaPhiRegion_, - whereToUseMeasTracker_, + magField, + msmaker, precise_, + whereToUseMeasTracker_, measTrackerEvent); } diff --git a/RecoHI/HiMuonAlgos/plugins/HIMuonTrackingRegionProducer.h b/RecoHI/HiMuonAlgos/plugins/HIMuonTrackingRegionProducer.h index e9c6ca215a84f..264c71106527d 100644 --- a/RecoHI/HiMuonAlgos/plugins/HIMuonTrackingRegionProducer.h +++ b/RecoHI/HiMuonAlgos/plugins/HIMuonTrackingRegionProducer.h @@ -53,7 +53,7 @@ class HIMuonTrackingRegionProducer : public TrackingRegionProducer { std::vector > result; // initialize the region builder - theRegionBuilder->setEvent(ev); + theRegionBuilder->setEvent(ev, es); // get stand-alone muon collection edm::Handle muonH; diff --git a/RecoHI/HiTracking/plugins/HITrackingRegionForPrimaryVtxProducer.h b/RecoHI/HiTracking/plugins/HITrackingRegionForPrimaryVtxProducer.h index 3bb5e6fd2ece8..bc2f687250c38 100644 --- a/RecoHI/HiTracking/plugins/HITrackingRegionForPrimaryVtxProducer.h +++ b/RecoHI/HiTracking/plugins/HITrackingRegionForPrimaryVtxProducer.h @@ -11,6 +11,11 @@ #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/ConsumesCollector.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" + #include "DataFormats/BeamSpot/interface/BeamSpot.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -28,7 +33,8 @@ class HITrackingRegionForPrimaryVtxProducer : public TrackingRegionProducer { public: - HITrackingRegionForPrimaryVtxProducer(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC) { + HITrackingRegionForPrimaryVtxProducer(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC) + : theTtopoToken(iC.esConsumes()), theFieldToken(iC.esConsumes()) { edm::ParameterSet regionPSet = cfg.getParameter("RegionPSet"); thePtMin = regionPSet.getParameter("ptMin"); theOriginRadius = regionPSet.getParameter("originRadius"); @@ -51,9 +57,13 @@ class HITrackingRegionForPrimaryVtxProducer : public TrackingRegionProducer { theUseFixedError = regionPSet.getParameter("useFixedError"); vertexCollName = regionPSet.getParameter("VertexCollection"); vertexCollToken = iC.consumes(vertexCollName); + + if (thePrecise) { + theMSMakerToken = iC.esConsumes(); + } } - ~HITrackingRegionForPrimaryVtxProducer() override {} + ~HITrackingRegionForPrimaryVtxProducer() override = default; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; @@ -88,11 +98,10 @@ class HITrackingRegionForPrimaryVtxProducer : public TrackingRegionProducer { edm::Handle recHitColl; ev.getByToken(theSiPixelRecHitsToken, recHitColl); - edm::ESHandle httopo; - es.get().get(httopo); + auto const& ttopo = es.getData(theTtopoToken); std::vector theChosenHits; - edmNew::copyDetSetRange(*recHitColl, theChosenHits, httopo->pxbDetIdLayerComparator(1)); + edmNew::copyDetSetRange(*recHitColl, theChosenHits, ttopo.pxbDetIdLayerComparator(1)); return theChosenHits.size(); } @@ -159,16 +168,14 @@ class HITrackingRegionForPrimaryVtxProducer : public TrackingRegionProducer { } if (estTracks > regTracking) { // regional tracking + const auto& field = es.getData(theFieldToken); + const MultipleScatteringParametrisationMaker* msmaker = nullptr; + if (thePrecise) { + msmaker = &es.getData(theMSMakerToken); + } + result.push_back(std::make_unique( - theDirection, - origin, - thePtMin, - theOriginRadius, - halflength, - etaB, - phiB, - RectangularEtaPhiTrackingRegion::UseMeasurementTracker::kNever, - thePrecise)); + theDirection, origin, thePtMin, theOriginRadius, halflength, etaB, phiB, field, msmaker, thePrecise)); } else { // global tracking LogTrace("heavyIonHLTVertexing") << " [HIVertexing: Global Tracking]"; result.push_back( @@ -196,6 +203,9 @@ class HITrackingRegionForPrimaryVtxProducer : public TrackingRegionProducer { bool theUseFixedError; edm::InputTag vertexCollName; edm::EDGetTokenT vertexCollToken; + edm::ESGetToken theTtopoToken; + edm::ESGetToken theFieldToken; + edm::ESGetToken theMSMakerToken; }; #endif diff --git a/RecoHI/HiTracking/plugins/HITrackingRegionProducer.h b/RecoHI/HiTracking/plugins/HITrackingRegionProducer.h index a3d0e63658213..5c57d4e181bbe 100644 --- a/RecoHI/HiTracking/plugins/HITrackingRegionProducer.h +++ b/RecoHI/HiTracking/plugins/HITrackingRegionProducer.h @@ -14,12 +14,17 @@ #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h" #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" #include "TMath.h" class HITrackingRegionProducer : public TrackingRegionProducer { public: - HITrackingRegionProducer(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC) { + HITrackingRegionProducer(const edm::ParameterSet& cfg, edm::ConsumesCollector&& iC) + : theTtopoToken(iC.esConsumes()), theFieldToken(iC.esConsumes()) { edm::ParameterSet regionPSet = cfg.getParameter("RegionPSet"); thePtMin = regionPSet.getParameter("ptMin"); @@ -36,9 +41,12 @@ class HITrackingRegionProducer : public TrackingRegionProducer { theSiPixelRecHitsToken = iC.consumes(theSiPixelRecHits); theOrigin = GlobalPoint(xPos, yPos, zPos); theDirection = GlobalVector(xDir, yDir, zDir); + if (thePrecise) { + theMSMakerToken = iC.esConsumes(); + } } - ~HITrackingRegionProducer() override {} + ~HITrackingRegionProducer() override = default; int estimateMultiplicity(const edm::Event& ev, const edm::EventSetup& es) const { //rechits @@ -46,8 +54,7 @@ class HITrackingRegionProducer : public TrackingRegionProducer { ev.getByToken(theSiPixelRecHitsToken, recHitColl); //Retrieve tracker topology from geometry - edm::ESHandle tTopo; - es.get().get(tTopo); + const auto& tTopo = es.getData(theTtopoToken); int numRecHits = 0; //FIXME: this can be optimized quite a bit by looping only on the per-det 'items' of DetSetVector @@ -61,7 +68,7 @@ class HITrackingRegionProducer : public TrackingRegionProducer { unsigned int subid = detId.subdetId(); //subdetector type, barrel=1, fpix=2 unsigned int layer = 0; - layer = tTopo->pxbLayer(detId); + layer = tTopo.pxbLayer(detId); if (detType == 1 && subid == 1 && layer == 1) { numRecHits += hits.size(); } @@ -102,16 +109,22 @@ class HITrackingRegionProducer : public TrackingRegionProducer { // tracking region selection std::vector > result; if (estTracks > regTracking) { // regional tracking - result.push_back(std::make_unique( - theDirection, - theOrigin, - thePtMin, - theOriginRadius, - theOriginHalfLength, - etaB, - phiB, - RectangularEtaPhiTrackingRegion::UseMeasurementTracker::kNever, - thePrecise)); + const auto& field = es.getData(theFieldToken); + const MultipleScatteringParametrisationMaker* msmaker = nullptr; + if (thePrecise) { + msmaker = &es.getData(theMSMakerToken); + } + + result.push_back(std::make_unique(theDirection, + theOrigin, + thePtMin, + theOriginRadius, + theOriginHalfLength, + etaB, + phiB, + field, + msmaker, + thePrecise)); } else { // global tracking LogTrace("heavyIonHLTVertexing") << " [HIVertexing: Global Tracking]"; result.push_back(std::make_unique( @@ -123,6 +136,9 @@ class HITrackingRegionProducer : public TrackingRegionProducer { private: edm::InputTag theSiPixelRecHits; edm::EDGetTokenT theSiPixelRecHitsToken; + edm::ESGetToken theTtopoToken; + edm::ESGetToken theFieldToken; + edm::ESGetToken theMSMakerToken; double thePtMin; GlobalPoint theOrigin; double theOriginRadius; diff --git a/RecoMuon/GlobalTrackingTools/interface/GlobalTrajectoryBuilderBase.h b/RecoMuon/GlobalTrackingTools/interface/GlobalTrajectoryBuilderBase.h index 6395b24a92a70..6d5a31d4a2555 100644 --- a/RecoMuon/GlobalTrackingTools/interface/GlobalTrajectoryBuilderBase.h +++ b/RecoMuon/GlobalTrackingTools/interface/GlobalTrajectoryBuilderBase.h @@ -23,6 +23,10 @@ #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h" #include "FWCore/Framework/interface/ConsumesCollector.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h" #include "TrackingTools/TrackRefitter/interface/TrackTransformer.h" @@ -164,5 +168,9 @@ class GlobalTrajectoryBuilderBase : public MuonTrajectoryBuilder { const TransientTrackingRecHitBuilder* theMuonRecHitBuilder; edm::ESGetToken theTopoToken; const TrackerTopology* theTopo; + edm::ESGetToken theFieldToken; + const MagneticField* theField; + edm::ESGetToken theMSMakerToken; + const MultipleScatteringParametrisationMaker* theMSMaker; }; #endif diff --git a/RecoMuon/GlobalTrackingTools/interface/MuonTrackingRegionBuilder.h b/RecoMuon/GlobalTrackingTools/interface/MuonTrackingRegionBuilder.h index 4de5c831237b8..fde97353e4511 100644 --- a/RecoMuon/GlobalTrackingTools/interface/MuonTrackingRegionBuilder.h +++ b/RecoMuon/GlobalTrackingTools/interface/MuonTrackingRegionBuilder.h @@ -34,11 +34,10 @@ class MuonServiceProxy; class MeasurementTrackerEvent; - -namespace edm { - class ParameterSet; - class Event; -} // namespace edm +class MagneticField; +class IdealMagneticFieldRecord; +class MultipleScatteringParametrisationMaker; +class TrackerMultipleScatteringRecord; class MuonTrackingRegionBuilder : public TrackingRegionProducer { public: @@ -54,11 +53,15 @@ class MuonTrackingRegionBuilder : public TrackingRegionProducer { /// Define tracking region std::unique_ptr region(const reco::TrackRef&) const; - std::unique_ptr region(const reco::Track& t) const { return region(t, *theEvent); } - std::unique_ptr region(const reco::Track&, const edm::Event&) const; + std::unique_ptr region(const reco::Track& t) const { + return region(t, *theEvent, *theEventSetup); + } + std::unique_ptr region(const reco::Track&, + const edm::Event&, + const edm::EventSetup&) const; /// Pass the Event to the algo at each event - virtual void setEvent(const edm::Event&); + void setEvent(const edm::Event&, const edm::EventSetup&); /// Add Fill Descriptions static void fillDescriptions(edm::ConfigurationDescriptions& descriptions); @@ -69,6 +72,7 @@ class MuonTrackingRegionBuilder : public TrackingRegionProducer { void build(const edm::ParameterSet&, edm::ConsumesCollector&); const edm::Event* theEvent; + const edm::EventSetup* theEventSetup; bool useVertex; bool useFixedZ; @@ -101,5 +105,7 @@ class MuonTrackingRegionBuilder : public TrackingRegionProducer { edm::EDGetTokenT beamSpotToken; edm::EDGetTokenT vertexCollectionToken; edm::EDGetTokenT inputCollectionToken; + edm::ESGetToken bfieldToken; + edm::ESGetToken msmakerToken; }; #endif diff --git a/RecoMuon/GlobalTrackingTools/src/GlobalTrajectoryBuilderBase.cc b/RecoMuon/GlobalTrackingTools/src/GlobalTrajectoryBuilderBase.cc index 5fcc25afe8486..0ee6b779492e2 100644 --- a/RecoMuon/GlobalTrackingTools/src/GlobalTrajectoryBuilderBase.cc +++ b/RecoMuon/GlobalTrackingTools/src/GlobalTrajectoryBuilderBase.cc @@ -107,6 +107,8 @@ GlobalTrajectoryBuilderBase::GlobalTrajectoryBuilderBase(const edm::ParameterSet iC.esConsumes(edm::ESInputTag("", par.getParameter("TrackerRecHitBuilder"))); theMuonRecHitBuilderToken = iC.esConsumes(edm::ESInputTag("", par.getParameter("MuonRecHitBuilder"))); theTopoToken = iC.esConsumes(); + theFieldToken = iC.esConsumes(); + theMSMakerToken = iC.esConsumes(); theRPCInTheFit = par.getParameter("RefitRPCHits"); @@ -137,7 +139,7 @@ void GlobalTrajectoryBuilderBase::setEvent(const edm::Event& event) { theEvent = &event; theTrackTransformer->setServices(theService->eventSetup()); - theRegionBuilder->setEvent(event); + theRegionBuilder->setEvent(event, theService->eventSetup()); theGlbRefitter->setEvent(event); theGlbRefitter->setServices(theService->eventSetup()); @@ -147,6 +149,9 @@ void GlobalTrajectoryBuilderBase::setEvent(const edm::Event& event) { //Retrieve tracker topology from geometry theTopo = &theService->eventSetup().getData(theTopoToken); + + theField = &theService->eventSetup().getData(theFieldToken); + theMSMaker = &theService->eventSetup().getData(theMSMakerToken); } // @@ -345,7 +350,9 @@ RectangularEtaPhiTrackingRegion GlobalTrajectoryBuilderBase::defineRegionOfInter region1->originRBound(), region1->originZBound(), etaMargin, - region1->phiMargin()); + region1->phiMargin(), + *theField, + theMSMaker); return region2; } diff --git a/RecoMuon/GlobalTrackingTools/src/MuonTrackingRegionBuilder.cc b/RecoMuon/GlobalTrackingTools/src/MuonTrackingRegionBuilder.cc index a3d9b5cf5c28e..4f24a49b47e12 100644 --- a/RecoMuon/GlobalTrackingTools/src/MuonTrackingRegionBuilder.cc +++ b/RecoMuon/GlobalTrackingTools/src/MuonTrackingRegionBuilder.cc @@ -16,11 +16,16 @@ #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h" #include "RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h" +#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h" #include "TrackingTools/PatternTools/interface/TSCPBuilderNoMaterial.h" @@ -90,6 +95,11 @@ void MuonTrackingRegionBuilder::build(const edm::ParameterSet& par, edm::Consume // Input muon collection inputCollectionToken = iC.consumes(par.getParameter("input")); + + bfieldToken = iC.esConsumes(); + if (thePrecise) { + msmakerToken = iC.esConsumes(); + } } // @@ -104,7 +114,7 @@ std::vector> MuonTrackingRegionBuilder::regions( int nRegions = 0; for (auto it = tracks->cbegin(), ed = tracks->cend(); it != ed && nRegions < theMaxRegions; ++it) { - result.push_back(region(*it, ev)); + result.push_back(region(*it, ev, es)); nRegions++; } @@ -121,13 +131,17 @@ std::unique_ptr MuonTrackingRegionBuilder::regi // // ToDo: Not sure if this is needed? // -void MuonTrackingRegionBuilder::setEvent(const edm::Event& event) { theEvent = &event; } +void MuonTrackingRegionBuilder::setEvent(const edm::Event& event, const edm::EventSetup& es) { + theEvent = &event; + theEventSetup = &es; +} // // Main member function called to create the ROI // std::unique_ptr MuonTrackingRegionBuilder::region(const reco::Track& staTrack, - const edm::Event& ev) const { + const edm::Event& ev, + const edm::EventSetup& es) const { // get track momentum/direction at vertex const math::XYZVector& mom = staTrack.momentum(); GlobalVector dirVector(mom.x(), mom.y(), mom.z()); @@ -223,8 +237,24 @@ std::unique_ptr MuonTrackingRegionBuilder::regi measurementTracker = hmte.product(); } - auto region = std::make_unique( - dirVector, vertexPos, minPt, deltaR, deltaZ, region_dEta, region_dPhi, theOnDemand, thePrecise, measurementTracker); + const auto& bfield = es.getData(bfieldToken); + const MultipleScatteringParametrisationMaker* msmaker = nullptr; + if (thePrecise) { + msmaker = &es.getData(msmakerToken); + } + + auto region = std::make_unique(dirVector, + vertexPos, + minPt, + deltaR, + deltaZ, + region_dEta, + region_dPhi, + bfield, + msmaker, + thePrecise, + theOnDemand, + measurementTracker); LogDebug("MuonTrackingRegionBuilder") << "the region parameters are:\n" << "\n dirVector: " << dirVector << "\n vertexPos: " << vertexPos diff --git a/RecoMuon/TrackerSeedGenerator/interface/L1MuonRegionProducer.h b/RecoMuon/TrackerSeedGenerator/interface/L1MuonRegionProducer.h index b5d0f5bf4745f..92e2e555f85cb 100644 --- a/RecoMuon/TrackerSeedGenerator/interface/L1MuonRegionProducer.h +++ b/RecoMuon/TrackerSeedGenerator/interface/L1MuonRegionProducer.h @@ -1,5 +1,7 @@ #ifndef RecoMuon_TrackerSeedGenerator_L1MuonRegionProducer_H #define RecoMuon_TrackerSeedGenerator_L1MuonRegionProducer_H +#include "FWCore/Framework/interface/ConsumesCollector.h" +#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h" #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h" #include "DataFormats/GeometryVector/interface/GlobalPoint.h" #include @@ -7,18 +9,17 @@ class TrackingRegion; class L1MuGMTCand; -namespace edm { - class Event; - class EventSetup; - class ParameterSet; -} // namespace edm +class MagneticField; +class IdealMagneticFieldRecord; +class MultipleScatteringParametrisationMaker; +class TrackerMultipleScatteringRecord; class L1MuonRegionProducer { public: - L1MuonRegionProducer(const edm::ParameterSet& cfg); - ~L1MuonRegionProducer() {} + L1MuonRegionProducer(const edm::ParameterSet& cfg, edm::ConsumesCollector iC); + ~L1MuonRegionProducer() = default; void setL1Constraint(const L1MuGMTCand& muon); - std::vector > regions() const; + std::vector > regions(const edm::EventSetup& iSetup) const; private: // region configuration @@ -28,6 +29,9 @@ class L1MuonRegionProducer { // L1 constraint double thePtL1, thePhiL1, theEtaL1; int theChargeL1; + + edm::ESGetToken theFieldToken; + edm::ESGetToken theMSMakerToken; }; #endif diff --git a/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL1Muon.cc b/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL1Muon.cc index 40339c38d0ad9..1e600345fe24f 100644 --- a/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL1Muon.cc +++ b/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL1Muon.cc @@ -51,7 +51,8 @@ TSGFromL1Muon::TSGFromL1Muon(const edm::ParameterSet& cfg) : theSFPTConfig(consu theSourceToken = iC.consumes(theSourceTag); - theRegionProducer = std::make_unique(cfg.getParameter("RegionFactoryPSet")); + theRegionProducer = + std::make_unique(cfg.getParameter("RegionFactoryPSet"), iC); theFitter = std::make_unique(cfg.getParameter("FitterPSet")); edm::ParameterSet cleanerPSet = cfg.getParameter("CleanerPSet"); @@ -85,7 +86,7 @@ void TSGFromL1Muon::produce(edm::Event& ev, const edm::EventSetup& es) { theFitter->setL1Constraint(muon); typedef std::vector > Regions; - Regions regions = theRegionProducer->regions(); + Regions regions = theRegionProducer->regions(es); for (Regions::const_iterator ir = regions.begin(); ir != regions.end(); ++ir) { L1MuonSeedsMerger::TracksAndHits tracks; const TrackingRegion& region = **ir; diff --git a/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL2Muon.cc b/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL2Muon.cc index 2fd0c81c68ed5..1cfba3a316c40 100644 --- a/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL2Muon.cc +++ b/RecoMuon/TrackerSeedGenerator/plugins/TSGFromL2Muon.cc @@ -67,7 +67,7 @@ void TSGFromL2Muon::produce(edm::Event& ev, const edm::EventSetup& es) { theService->update(es); theTkSeedGenerator->setEvent(ev); if (theRegionBuilder) - theRegionBuilder->setEvent(ev); + theRegionBuilder->setEvent(ev, es); if (theSeedCleaner) theSeedCleaner->setEvent(ev); diff --git a/RecoMuon/TrackerSeedGenerator/src/L1MuonRegionProducer.cc b/RecoMuon/TrackerSeedGenerator/src/L1MuonRegionProducer.cc index c9221397dc10d..1ce41a89fedaa 100644 --- a/RecoMuon/TrackerSeedGenerator/src/L1MuonRegionProducer.cc +++ b/RecoMuon/TrackerSeedGenerator/src/L1MuonRegionProducer.cc @@ -5,10 +5,15 @@ #include "RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h" #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h" #include "RecoMuon/TrackerSeedGenerator/interface/L1MuonPixelTrackFitter.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" using namespace std; -L1MuonRegionProducer::L1MuonRegionProducer(const edm::ParameterSet& cfg) { +L1MuonRegionProducer::L1MuonRegionProducer(const edm::ParameterSet& cfg, edm::ConsumesCollector iC) + : theFieldToken(iC.esConsumes()), theMSMakerToken(iC.esConsumes()) { edm::ParameterSet regionPSet = cfg.getParameter("RegionPSet"); thePtMin = regionPSet.getParameter("ptMin"); @@ -25,7 +30,9 @@ void L1MuonRegionProducer::setL1Constraint(const L1MuGMTCand& muon) { theChargeL1 = muon.charge(); } -std::vector > L1MuonRegionProducer::regions() const { +std::vector > L1MuonRegionProducer::regions(const edm::EventSetup& iSetup) const { + const auto& field = iSetup.getData(theFieldToken); + const auto& msmaker = iSetup.getData(theMSMakerToken); double dx = cos(thePhiL1); double dy = sin(thePhiL1); double dz = sinh(theEtaL1); @@ -36,8 +43,15 @@ std::vector > L1MuonRegionProducer::regions() co bending = fabs(bending); double errBending = L1MuonPixelTrackFitter::getBendingError(1. / thePtMin, theEtaL1); - result.push_back(std::make_unique( - direction, theOrigin, thePtMin, theOriginRadius, theOriginHalfLength, 0.15, bending + 3 * errBending)); + result.push_back(std::make_unique(direction, + theOrigin, + thePtMin, + theOriginRadius, + theOriginHalfLength, + 0.15, + bending + 3 * errBending, + field, + &msmaker)); return result; } diff --git a/RecoTauTag/HLTProducers/src/TauRegionalPixelSeedGenerator.h b/RecoTauTag/HLTProducers/src/TauRegionalPixelSeedGenerator.h index 3e2c3a75bfea0..517ba9c23174e 100644 --- a/RecoTauTag/HLTProducers/src/TauRegionalPixelSeedGenerator.h +++ b/RecoTauTag/HLTProducers/src/TauRegionalPixelSeedGenerator.h @@ -17,6 +17,10 @@ #include "DataFormats/TrackReco/interface/Track.h" #include "DataFormats/JetReco/interface/CaloJetCollection.h" #include "DataFormats/Math/interface/Vector3D.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h" #include "RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h" #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h" @@ -32,10 +36,11 @@ class TauRegionalPixelSeedGenerator : public TrackingRegionProducer { public: - explicit TauRegionalPixelSeedGenerator(const edm::ParameterSet& conf_, edm::ConsumesCollector&& iC) { + explicit TauRegionalPixelSeedGenerator(const edm::ParameterSet& conf, edm::ConsumesCollector&& iC) + : token_bfield(iC.esConsumes()), token_msmaker(iC.esConsumes()) { edm::LogInfo("TauRegionalPixelSeedGenerator") << "Enter the TauRegionalPixelSeedGenerator"; - edm::ParameterSet regionPSet = conf_.getParameter("RegionPSet"); + edm::ParameterSet regionPSet = conf.getParameter("RegionPSet"); m_ptMin = regionPSet.getParameter("ptMin"); m_originRadius = regionPSet.getParameter("originRadius"); @@ -127,6 +132,9 @@ class TauRegionalPixelSeedGenerator : public TrackingRegionProducer { measurementTracker = hmte.product(); } + const auto& bfield = es.getData(token_bfield); + const auto& msmaker = es.getData(token_msmaker); + for (const reco::Candidate& myJet : *h_jets) { GlobalVector jetVector(myJet.momentum().x(), myJet.momentum().y(), myJet.momentum().z()); // GlobalPoint vertex(0, 0, originZ); @@ -137,8 +145,10 @@ class TauRegionalPixelSeedGenerator : public TrackingRegionProducer { deltaZVertex, m_deltaEta, m_deltaPhi, - m_howToUseMeasurementTracker, + bfield, + &msmaker, true, + m_howToUseMeasurementTracker, measurementTracker, m_searchOpt)); } @@ -147,8 +157,6 @@ class TauRegionalPixelSeedGenerator : public TrackingRegionProducer { } private: - edm::ParameterSet conf_; - float m_ptMin; float m_originRadius; float m_halfLength; @@ -157,6 +165,8 @@ class TauRegionalPixelSeedGenerator : public TrackingRegionProducer { edm::EDGetTokenT token_vertex; edm::EDGetTokenT token_jet; edm::EDGetTokenT token_measurementTracker; + edm::ESGetToken token_bfield; + edm::ESGetToken token_msmaker; RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_howToUseMeasurementTracker; bool m_searchOpt; }; diff --git a/RecoTauTag/HLTProducers/src/TrackingRegionsFromBeamSpotAndL2Tau.h b/RecoTauTag/HLTProducers/src/TrackingRegionsFromBeamSpotAndL2Tau.h index cc64408a28d5f..9e5bde7f1cb20 100644 --- a/RecoTauTag/HLTProducers/src/TrackingRegionsFromBeamSpotAndL2Tau.h +++ b/RecoTauTag/HLTProducers/src/TrackingRegionsFromBeamSpotAndL2Tau.h @@ -52,6 +52,10 @@ class TrackingRegionsFromBeamSpotAndL2Tau : public TrackingRegionProducer { token_measurementTracker = iC.consumes(regionPSet.getParameter("measurementTrackerName")); } + token_field = iC.esConsumes(); + if (m_precise) { + token_msmaker = iC.esConsumes(); + } } ~TrackingRegionsFromBeamSpotAndL2Tau() override {} @@ -105,6 +109,12 @@ class TrackingRegionsFromBeamSpotAndL2Tau : public TrackingRegionProducer { measurementTracker = hmte.product(); } + const auto& field = es.getData(token_field); + const MultipleScatteringParametrisationMaker* msmaker = nullptr; + if (m_precise) { + msmaker = &es.getData(token_msmaker); + } + // create maximum JetMaxN tracking regions in directions of // highest pt jets that are above threshold and are within allowed eta // (we expect that jet collection was sorted in decreasing pt order) @@ -123,8 +133,10 @@ class TrackingRegionsFromBeamSpotAndL2Tau : public TrackingRegionProducer { m_originHalfLength, m_deltaEta, m_deltaPhi, - m_whereToUseMeasurementTracker, + field, + msmaker, m_precise, + m_whereToUseMeasurementTracker, measurementTracker, m_searchOpt)); ++n_regions; @@ -147,6 +159,8 @@ class TrackingRegionsFromBeamSpotAndL2Tau : public TrackingRegionProducer { RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker; bool m_searchOpt; edm::EDGetTokenT token_beamSpot; + edm::ESGetToken token_field; + edm::ESGetToken token_msmaker; bool m_precise; }; diff --git a/RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h b/RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h index fdebb7f2f5bcd..835e6f57b2d23 100644 --- a/RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h +++ b/RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h @@ -21,6 +21,8 @@ class OuterHitPhiPrediction; class BarrelDetLayer; class ForwardDetLayer; class MeasurementTrackerEvent; +class MagneticField; +class MultipleScatteringParametrisationMaker; class RectangularEtaPhiTrackingRegion final : public TrackingRegion { public: @@ -51,8 +53,9 @@ class RectangularEtaPhiTrackingRegion final : public TrackingRegion { theMeasurementTrackerUsage(rh.theMeasurementTrackerUsage), thePrecise(rh.thePrecise), theUseEtaPhi(rh.theUseEtaPhi), - theMeasurementTracker(rh.theMeasurementTracker) {} - + theMeasurementTracker(rh.theMeasurementTracker), + theField(rh.theField), + theMSMaker(rh.theMSMaker) {} RectangularEtaPhiTrackingRegion& operator=(RectangularEtaPhiTrackingRegion const&) = delete; RectangularEtaPhiTrackingRegion(RectangularEtaPhiTrackingRegion&&) = default; RectangularEtaPhiTrackingRegion& operator=(RectangularEtaPhiTrackingRegion&&) = delete; @@ -83,6 +86,7 @@ class RectangularEtaPhiTrackingRegion final : public TrackingRegion { * deltaPhi - allowed deviation of the initial direction of particle * in phi in respect to direction of the region * whereToUseMeasurementTracker: 1=everywhere, 0=outside pixles, -1=nowhere + * msmaker - Needed if either precise or useMS is true */ RectangularEtaPhiTrackingRegion(const GlobalVector& dir, const GlobalPoint& vertexPos, @@ -91,8 +95,10 @@ class RectangularEtaPhiTrackingRegion final : public TrackingRegion { float zVertex, float deltaEta, float deltaPhi, - UseMeasurementTracker whereToUseMeasurementTracker = UseMeasurementTracker::kNever, + const MagneticField& field, + const MultipleScatteringParametrisationMaker* msmaker, bool precise = true, + UseMeasurementTracker whereToUseMeasurementTracker = UseMeasurementTracker::kNever, const MeasurementTrackerEvent* measurementTracker = nullptr, bool etaPhiRegion = false) : RectangularEtaPhiTrackingRegion(dir, @@ -102,8 +108,10 @@ class RectangularEtaPhiTrackingRegion final : public TrackingRegion { zVertex, Margin(std::abs(deltaEta), std::abs(deltaEta)), Margin(std::abs(deltaPhi), std::abs(deltaPhi)), - whereToUseMeasurementTracker, + field, + msmaker, precise, + whereToUseMeasurementTracker, measurementTracker, etaPhiRegion) {} @@ -120,8 +128,10 @@ class RectangularEtaPhiTrackingRegion final : public TrackingRegion { float zVertex, Margin etaMargin, Margin phiMargin, - UseMeasurementTracker whereToUseMeasurementTracker = UseMeasurementTracker::kNever, + const MagneticField& field, + const MultipleScatteringParametrisationMaker* msmaker, bool precise = true, + UseMeasurementTracker whereToUseMeasurementTracker = UseMeasurementTracker::kNever, const MeasurementTrackerEvent* measurementTracker = nullptr, bool etaPhiRegion = false) : RectangularEtaPhiTrackingRegion(dir, @@ -131,8 +141,10 @@ class RectangularEtaPhiTrackingRegion final : public TrackingRegion { zVertex, etaMargin, phiMargin, - whereToUseMeasurementTracker, + field, + msmaker, precise, + whereToUseMeasurementTracker, measurementTracker, etaPhiRegion) {} @@ -147,8 +159,10 @@ class RectangularEtaPhiTrackingRegion final : public TrackingRegion { float zVertex, Margin etaMargin, Margin phiMargin, - UseMeasurementTracker whereToUseMeasurementTracker = UseMeasurementTracker::kNever, + const MagneticField& field, + const MultipleScatteringParametrisationMaker* msmaker, bool precise = true, + UseMeasurementTracker whereToUseMeasurementTracker = UseMeasurementTracker::kNever, const MeasurementTrackerEvent* measurementTracker = nullptr, bool etaPhiRegion = false, bool useMS = true) @@ -158,7 +172,9 @@ class RectangularEtaPhiTrackingRegion final : public TrackingRegion { thePrecise(precise), theUseMS(useMS), theUseEtaPhi(etaPhiRegion), - theMeasurementTracker(measurementTracker) { + theMeasurementTracker(measurementTracker), + theField(&field), + theMSMaker(msmaker) { initEtaRange(dir, etaMargin); } @@ -223,6 +239,8 @@ class RectangularEtaPhiTrackingRegion final : public TrackingRegion { bool theUseMS = false; bool theUseEtaPhi = false; const MeasurementTrackerEvent* theMeasurementTracker = nullptr; + const MagneticField* theField = nullptr; + const MultipleScatteringParametrisationMaker* theMSMaker = nullptr; using cacheHitPointer = mayown_ptr; using cacheHits = std::vector; diff --git a/RecoTracker/TkTrackingRegions/plugins/AreaSeededTrackingRegionsBuilder.cc b/RecoTracker/TkTrackingRegions/plugins/AreaSeededTrackingRegionsBuilder.cc index c19217f0a8c4d..fff63eac363e0 100644 --- a/RecoTracker/TkTrackingRegions/plugins/AreaSeededTrackingRegionsBuilder.cc +++ b/RecoTracker/TkTrackingRegions/plugins/AreaSeededTrackingRegionsBuilder.cc @@ -16,7 +16,7 @@ namespace { AreaSeededTrackingRegionsBuilder::AreaSeededTrackingRegionsBuilder(const edm::ParameterSet& regPSet, edm::ConsumesCollector& iC) - : candidates_(regPSet, iC) { + : candidates_(regPSet, iC), token_field(iC.esConsumes()) { m_extraPhi = regPSet.getParameter("extraPhi"); m_extraEta = regPSet.getParameter("extraEta"); @@ -31,6 +31,9 @@ AreaSeededTrackingRegionsBuilder::AreaSeededTrackingRegionsBuilder(const edm::Pa iC.consumes(regPSet.getParameter("measurementTrackerName")); } m_searchOpt = regPSet.getParameter("searchOpt"); + if (m_precise) { + token_msmaker = iC.esConsumes(); + } } void AreaSeededTrackingRegionsBuilder::fillDescriptions(edm::ParameterSetDescription& desc) { @@ -47,8 +50,14 @@ void AreaSeededTrackingRegionsBuilder::fillDescriptions(edm::ParameterSetDescrip desc.add("searchOpt", false); } -AreaSeededTrackingRegionsBuilder::Builder AreaSeededTrackingRegionsBuilder::beginEvent(const edm::Event& e) const { - auto builder = Builder(this); +AreaSeededTrackingRegionsBuilder::Builder AreaSeededTrackingRegionsBuilder::beginEvent( + const edm::Event& e, const edm::EventSetup& es) const { + const auto& field = es.getData(token_field); + const MultipleScatteringParametrisationMaker* msmaker = nullptr; + if (m_precise) { + msmaker = &es.getData(token_msmaker); + } + auto builder = Builder(this, &field, msmaker); if (!token_measurementTracker.isUninitialized()) { edm::Handle hmte; @@ -291,8 +300,10 @@ std::unique_ptr AreaSeededTrackingRegionsBuilder::Builder::regio origin.second, dEtaTemp, dPhiTemp, - m_conf->m_whereToUseMeasurementTracker, + *m_field, + m_msmaker, m_conf->m_precise, + m_conf->m_whereToUseMeasurementTracker, m_measurementTracker, m_conf->m_searchOpt); } @@ -315,8 +326,10 @@ std::unique_ptr AreaSeededTrackingRegionsBuilder::Builder::regio origin.second, dEta, dPhi, - m_conf->m_whereToUseMeasurementTracker, + *m_field, + m_msmaker, m_conf->m_precise, + m_conf->m_whereToUseMeasurementTracker, m_measurementTracker, m_conf->m_searchOpt); } diff --git a/RecoTracker/TkTrackingRegions/plugins/AreaSeededTrackingRegionsBuilder.h b/RecoTracker/TkTrackingRegions/plugins/AreaSeededTrackingRegionsBuilder.h index deff02d4f4659..4630abb2aa780 100644 --- a/RecoTracker/TkTrackingRegions/plugins/AreaSeededTrackingRegionsBuilder.h +++ b/RecoTracker/TkTrackingRegions/plugins/AreaSeededTrackingRegionsBuilder.h @@ -12,6 +12,12 @@ #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" + +#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" + #include "TrackingSeedCandidates.h" class AreaSeededTrackingRegionsBuilder { public: @@ -72,7 +78,10 @@ class AreaSeededTrackingRegionsBuilder { class Builder { public: - explicit Builder(const AreaSeededTrackingRegionsBuilder* conf) : m_conf(conf) {} + explicit Builder(const AreaSeededTrackingRegionsBuilder* conf, + const MagneticField* field, + const MultipleScatteringParametrisationMaker* msmaker) + : m_conf(conf), m_field(field), m_msmaker(msmaker) {} ~Builder() = default; void setMeasurementTracker(const MeasurementTrackerEvent* mte) { m_measurementTracker = mte; } @@ -88,6 +97,8 @@ class AreaSeededTrackingRegionsBuilder { const AreaSeededTrackingRegionsBuilder* m_conf = nullptr; const MeasurementTrackerEvent* m_measurementTracker = nullptr; + const MagneticField* m_field = nullptr; + const MultipleScatteringParametrisationMaker* m_msmaker = nullptr; TrackingSeedCandidates::Objects candidates; }; @@ -98,7 +109,7 @@ class AreaSeededTrackingRegionsBuilder { static void fillDescriptions(edm::ParameterSetDescription& desc); - Builder beginEvent(const edm::Event& e) const; + Builder beginEvent(const edm::Event& e, const edm::EventSetup& es) const; private: std::vector m_areas; @@ -110,6 +121,8 @@ class AreaSeededTrackingRegionsBuilder { bool m_precise; edm::EDGetTokenT token_measurementTracker; RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker; + edm::ESGetToken token_field; + edm::ESGetToken token_msmaker; bool m_searchOpt; }; diff --git a/RecoTracker/TkTrackingRegions/plugins/AreaSeededTrackingRegionsProducer.h b/RecoTracker/TkTrackingRegions/plugins/AreaSeededTrackingRegionsProducer.h index ee002233c9d1c..68bb97a282614 100644 --- a/RecoTracker/TkTrackingRegions/plugins/AreaSeededTrackingRegionsProducer.h +++ b/RecoTracker/TkTrackingRegions/plugins/AreaSeededTrackingRegionsProducer.h @@ -92,7 +92,7 @@ class AreaSeededTrackingRegionsProducer { std::vector > regions(const edm::Event& e, const edm::EventSetup& es) const { auto origins = m_origins.origins(e); - auto builder = m_builder.beginEvent(e); + auto builder = m_builder.beginEvent(e, es); return builder.regions(origins, m_areas); } diff --git a/RecoTracker/TkTrackingRegions/plugins/CandidatePointSeededTrackingRegionsProducer.h b/RecoTracker/TkTrackingRegions/plugins/CandidatePointSeededTrackingRegionsProducer.h index 3e5c6d71c73e7..bdf6973f017e3 100644 --- a/RecoTracker/TkTrackingRegions/plugins/CandidatePointSeededTrackingRegionsProducer.h +++ b/RecoTracker/TkTrackingRegions/plugins/CandidatePointSeededTrackingRegionsProducer.h @@ -60,7 +60,7 @@ class CandidatePointSeededTrackingRegionsProducer : public TrackingRegionProduce enum class SeedingMode { CANDIDATE_SEEDED, POINT_SEEDED, CANDIDATE_POINT_SEEDED }; explicit CandidatePointSeededTrackingRegionsProducer(const edm::ParameterSet& conf, edm::ConsumesCollector&& iC) - : m_origins(conf.getParameter("RegionPSet"), iC) { + : m_origins(conf.getParameter("RegionPSet"), iC), token_field(iC.esConsumes()) { edm::ParameterSet regPSet = conf.getParameter("RegionPSet"); // seeding mode @@ -142,9 +142,13 @@ class CandidatePointSeededTrackingRegionsProducer : public TrackingRegionProduce m_searchOpt = false; if (regPSet.exists("searchOpt")) m_searchOpt = regPSet.getParameter("searchOpt"); + + if (m_precise) { + token_msmaker = iC.esConsumes(); + } } - ~CandidatePointSeededTrackingRegionsProducer() override {} + ~CandidatePointSeededTrackingRegionsProducer() override = default; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; @@ -209,6 +213,12 @@ class CandidatePointSeededTrackingRegionsProducer : public TrackingRegionProduce measurementTracker = hmte.product(); } + const auto& field = es.getData(token_field); + const MultipleScatteringParametrisationMaker* msmaker = nullptr; + if (m_precise) { + msmaker = &es.getData(token_msmaker); + } + // create tracking regions (maximum MaxNRegions of them) in directions of the // objects of interest (we expect that the collection was sorted in decreasing pt order) int n_regions = 0; @@ -225,8 +235,10 @@ class CandidatePointSeededTrackingRegionsProducer : public TrackingRegionProduce origin.second, m_deltaEta_Cand, m_deltaPhi_Cand, - m_whereToUseMeasurementTracker, + field, + msmaker, m_precise, + m_whereToUseMeasurementTracker, measurementTracker, m_searchOpt)); ++n_regions; @@ -250,8 +262,10 @@ class CandidatePointSeededTrackingRegionsProducer : public TrackingRegionProduce origin.second, m_deltaEta_Point, m_deltaPhi_Point, - m_whereToUseMeasurementTracker, + field, + msmaker, m_precise, + m_whereToUseMeasurementTracker, measurementTracker, m_searchOpt)); ++n_regions; @@ -318,8 +332,10 @@ class CandidatePointSeededTrackingRegionsProducer : public TrackingRegionProduce origin.second, deltaEta_RoI, deltaPhi_RoI, - m_whereToUseMeasurementTracker, + field, + msmaker, m_precise, + m_whereToUseMeasurementTracker, measurementTracker, m_searchOpt)); ++n_regions; @@ -360,6 +376,8 @@ class CandidatePointSeededTrackingRegionsProducer : public TrackingRegionProduce bool m_precise; edm::EDGetTokenT m_token_measurementTracker; RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker; + edm::ESGetToken token_field; + edm::ESGetToken token_msmaker; bool m_searchOpt; }; diff --git a/RecoTracker/TkTrackingRegions/plugins/CandidateSeededTrackingRegionsProducer.h b/RecoTracker/TkTrackingRegions/plugins/CandidateSeededTrackingRegionsProducer.h index 54fa6464b02ec..0e29edac62667 100644 --- a/RecoTracker/TkTrackingRegions/plugins/CandidateSeededTrackingRegionsProducer.h +++ b/RecoTracker/TkTrackingRegions/plugins/CandidateSeededTrackingRegionsProducer.h @@ -16,6 +16,10 @@ #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/Candidate/interface/Candidate.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" /** class CandidateSeededTrackingRegionsProducer * @@ -46,7 +50,8 @@ class CandidateSeededTrackingRegionsProducer : public TrackingRegionProducer { public: typedef enum { BEAM_SPOT_FIXED, BEAM_SPOT_SIGMA, VERTICES_FIXED, VERTICES_SIGMA } Mode; - explicit CandidateSeededTrackingRegionsProducer(const edm::ParameterSet& conf, edm::ConsumesCollector&& iC) { + explicit CandidateSeededTrackingRegionsProducer(const edm::ParameterSet& conf, edm::ConsumesCollector&& iC) + : token_field(iC.esConsumes()) { edm::ParameterSet regPSet = conf.getParameter("RegionPSet"); // operation mode @@ -101,9 +106,12 @@ class CandidateSeededTrackingRegionsProducer : public TrackingRegionProducer { edm::LogError("CandidateSeededTrackingRegionsProducer") << "nSigmaZBeamSpot must be positive for BeamSpotSigma mode!"; } + if (m_precise) { + token_msmaker = iC.esConsumes(); + } } - ~CandidateSeededTrackingRegionsProducer() override {} + ~CandidateSeededTrackingRegionsProducer() override = default; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { edm::ParameterSetDescription desc; @@ -193,6 +201,12 @@ class CandidateSeededTrackingRegionsProducer : public TrackingRegionProducer { measurementTracker = hmte.product(); } + const auto& field = es.getData(token_field); + const MultipleScatteringParametrisationMaker* msmaker = nullptr; + if (m_precise) { + msmaker = &es.getData(token_msmaker); + } + // create tracking regions (maximum MaxNRegions of them) in directions of the // objects of interest (we expect that the collection was sorted in decreasing pt order) int n_regions = 0; @@ -208,8 +222,10 @@ class CandidateSeededTrackingRegionsProducer : public TrackingRegionProducer { origins[j].second, m_deltaEta, m_deltaPhi, - m_whereToUseMeasurementTracker, + field, + msmaker, m_precise, + m_whereToUseMeasurementTracker, measurementTracker, m_searchOpt)); ++n_regions; @@ -238,6 +254,8 @@ class CandidateSeededTrackingRegionsProducer : public TrackingRegionProducer { bool m_precise; edm::EDGetTokenT token_measurementTracker; RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker; + edm::ESGetToken token_field; + edm::ESGetToken token_msmaker; bool m_searchOpt; float m_nSigmaZVertex; diff --git a/RecoTracker/TkTrackingRegions/plugins/PixelInactiveAreaTrackingRegionsSeedingLayersProducer.cc b/RecoTracker/TkTrackingRegions/plugins/PixelInactiveAreaTrackingRegionsSeedingLayersProducer.cc index 537356c4720b9..050898097e32a 100644 --- a/RecoTracker/TkTrackingRegions/plugins/PixelInactiveAreaTrackingRegionsSeedingLayersProducer.cc +++ b/RecoTracker/TkTrackingRegions/plugins/PixelInactiveAreaTrackingRegionsSeedingLayersProducer.cc @@ -71,7 +71,7 @@ void PixelInactiveAreaTrackingRegionsSeedingLayersProducer::produce(edm::Event& auto regions = std::make_unique(seedingLayers); const auto origins = origins_.origins(iEvent); - const auto builder = trackingRegionsBuilder_.beginEvent(iEvent); + const auto builder = trackingRegionsBuilder_.beginEvent(iEvent, iSetup); const auto allAreas = inactiveAreaFinder_.inactiveAreas(iEvent, iSetup); for (const auto& origin : origins) { diff --git a/RecoTracker/TkTrackingRegions/plugins/PointSeededTrackingRegionsProducer.h b/RecoTracker/TkTrackingRegions/plugins/PointSeededTrackingRegionsProducer.h index 2dba422aaa6d8..32700222a266a 100644 --- a/RecoTracker/TkTrackingRegions/plugins/PointSeededTrackingRegionsProducer.h +++ b/RecoTracker/TkTrackingRegions/plugins/PointSeededTrackingRegionsProducer.h @@ -17,6 +17,10 @@ #include "DataFormats/VertexReco/interface/Vertex.h" #include "DataFormats/VertexReco/interface/VertexFwd.h" #include "DataFormats/Candidate/interface/Candidate.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" #include #include @@ -49,7 +53,8 @@ class PointSeededTrackingRegionsProducer : public TrackingRegionProducer { public: typedef enum { BEAM_SPOT_FIXED, BEAM_SPOT_SIGMA, VERTICES_FIXED, VERTICES_SIGMA } Mode; - explicit PointSeededTrackingRegionsProducer(const edm::ParameterSet& conf, edm::ConsumesCollector&& iC) { + explicit PointSeededTrackingRegionsProducer(const edm::ParameterSet& conf, edm::ConsumesCollector&& iC) + : token_field(iC.esConsumes()) { edm::ParameterSet regPSet = conf.getParameter("RegionPSet"); // operation mode @@ -109,6 +114,10 @@ class PointSeededTrackingRegionsProducer : public TrackingRegionProducer { edm::LogError("PointSeededTrackingRegionsProducer") << "nSigmaZBeamSpot must be positive for BeamSpotSigma mode!"; } + + if (m_precise) { + token_msmaker = iC.esConsumes(); + } } ~PointSeededTrackingRegionsProducer() override {} @@ -161,6 +170,12 @@ class PointSeededTrackingRegionsProducer : public TrackingRegionProducer { if (!bs.isValid()) return result; + const auto& field = es.getData(token_field); + const MultipleScatteringParametrisationMaker* msmaker = nullptr; + if (m_precise) { + msmaker = &es.getData(token_msmaker); + } + // this is a default origin for all modes GlobalPoint default_origin(bs->x0(), bs->y0(), bs->z0()); @@ -219,8 +234,10 @@ class PointSeededTrackingRegionsProducer : public TrackingRegionProducer { origins[j].second, m_deltaEta, m_deltaPhi, - m_whereToUseMeasurementTracker, + field, + msmaker, m_precise, + m_whereToUseMeasurementTracker, measurementTracker, m_searchOpt)); ++n_regions; @@ -250,6 +267,8 @@ class PointSeededTrackingRegionsProducer : public TrackingRegionProducer { bool m_precise; edm::EDGetTokenT token_measurementTracker; RectangularEtaPhiTrackingRegion::UseMeasurementTracker m_whereToUseMeasurementTracker; + edm::ESGetToken token_field; + edm::ESGetToken token_msmaker; bool m_searchOpt; float m_nSigmaZVertex; diff --git a/RecoTracker/TkTrackingRegions/src/OuterEstimator.h b/RecoTracker/TkTrackingRegions/src/OuterEstimator.h index be4b38112a4c0..ccf8d59afe37f 100644 --- a/RecoTracker/TkTrackingRegions/src/OuterEstimator.h +++ b/RecoTracker/TkTrackingRegions/src/OuterEstimator.h @@ -22,8 +22,7 @@ class dso_internal OuterEstimator final : public MeasurementEstimator { public: using OuterHitCompat = OuterHitCompatibility; - OuterEstimator(const OuterDetCompatibility& detCompatibility, - const OuterHitCompat& hitCompatibility) + OuterEstimator(const OuterDetCompatibility& detCompatibility, const OuterHitCompat& hitCompatibility) : theDetCompatibility(detCompatibility), theHitCompatibility(hitCompatibility) {} ~OuterEstimator() override {} diff --git a/RecoTracker/TkTrackingRegions/src/RectangularEtaPhiTrackingRegion.cc b/RecoTracker/TkTrackingRegions/src/RectangularEtaPhiTrackingRegion.cc index 5d44fdf837745..f096d576f7ea1 100644 --- a/RecoTracker/TkTrackingRegions/src/RectangularEtaPhiTrackingRegion.cc +++ b/RecoTracker/TkTrackingRegions/src/RectangularEtaPhiTrackingRegion.cc @@ -19,14 +19,9 @@ #include "RecoTracker/TkMSParametrization/interface/PixelRecoUtilities.h" #include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" #include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisation.h" -#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "MagneticField/Engine/interface/MagneticField.h" -#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" -#include "RecoTracker/Record/interface/CkfComponentsRecord.h" -#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h" #include "RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h" #include "TrackingTools/MeasurementDet/interface/LayerMeasurements.h" @@ -128,9 +123,7 @@ std::unique_ptr RectangularEtaPhiTrackingRegion::checkRZOld( float innerScatt = 0; //CHECK if (theUseMS) { - edm::ESHandle hmaker; - iSetup.get().get(hmaker); - MultipleScatteringParametrisation oSigma = hmaker->parametrisation(layer); + MultipleScatteringParametrisation oSigma = theMSMaker->parametrisation(layer); float cotThetaOuter = theMeanLambda; float sinThetaOuterInv = std::sqrt(1.f + sqr(cotThetaOuter)); outerZscatt = 3.f * oSigma(ptMin(), cotThetaOuter) * sinThetaOuterInv; @@ -146,9 +139,7 @@ std::unique_ptr RectangularEtaPhiTrackingRegion::checkRZOld( //CHECK if (theUseMS) { - edm::ESHandle hmaker; - iSetup.get().get(hmaker); - MultipleScatteringParametrisation iSigma = hmaker->parametrisation(layer); + MultipleScatteringParametrisation iSigma = theMSMaker->parametrisation(layer); innerScatt = 3.f * (outerlayer ? iSigma(ptMin(), vtxMean, outer, outerlayer->seqNum()) : iSigma(ptMin(), vtxMean, outer)); @@ -196,10 +187,7 @@ std::unique_ptr RectangularEtaPhiTrackingRegion::estimator return nullptr; // phi prediction - edm::ESHandle hfield; - iSetup.get().get(hfield); - const auto& field = *hfield; - OuterHitPhiPrediction phiPrediction = phiWindow(field); + OuterHitPhiPrediction phiPrediction = phiWindow(*theField); // // optional corrections for tolerance (mult.scatt, error, bending) @@ -209,11 +197,9 @@ std::unique_ptr RectangularEtaPhiTrackingRegion::estimator auto invR = 1.f / radius; auto cotTheta = (hitZWindow.mean() - origin().z()) * invR; auto sinThetaInv = std::sqrt(1.f + sqr(cotTheta)); - edm::ESHandle hmaker; - iSetup.get().get(hmaker); - MultipleScatteringParametrisation msSigma = hmaker->parametrisation(layer); + MultipleScatteringParametrisation msSigma = theMSMaker->parametrisation(layer); auto scatt = 3.f * msSigma(ptMin(), cotTheta); - auto bendR = longitudinalBendingCorrection(radius, ptMin(), field); + auto bendR = longitudinalBendingCorrection(radius, ptMin(), *theField); float hitErrRPhi = 0.; float hitErrZ = 0.; @@ -256,10 +242,7 @@ std::unique_ptr RectangularEtaPhiTrackingRegion::estimator return nullptr; // phi prediction - edm::ESHandle hfield; - iSetup.get().get(hfield); - const auto& field = *hfield; - OuterHitPhiPrediction phiPrediction = phiWindow(field); + OuterHitPhiPrediction phiPrediction = phiWindow(*theField); OuterHitPhiPrediction::Range phiRange = phiPrediction(detRWindow.max()); // @@ -268,11 +251,9 @@ std::unique_ptr RectangularEtaPhiTrackingRegion::estimator if (thePrecise) { float cotTheta = (detZWindow.mean() - origin().z()) / hitRWindow.mean(); float cosThetaInv = std::sqrt(1 + sqr(cotTheta)) / cotTheta; - edm::ESHandle hmaker; - iSetup.get().get(hmaker); - MultipleScatteringParametrisation msSigma = hmaker->parametrisation(layer); + MultipleScatteringParametrisation msSigma = theMSMaker->parametrisation(layer); float scatt = 3.f * msSigma(ptMin(), cotTheta); - float bendR = longitudinalBendingCorrection(hitRWindow.max(), ptMin(), field); + float bendR = longitudinalBendingCorrection(hitRWindow.max(), ptMin(), *theField); float hitErrRPhi = 0.; float hitErrR = 0.; float corrPhi = (scatt + hitErrRPhi) / detRWindow.min(); @@ -342,10 +323,6 @@ TrackingRegion::Hits RectangularEtaPhiTrackingRegion::hits(const edm::EventSetup measurementMethod = true; if (measurementMethod) { - edm::ESHandle field; - es.get().get(field); - const MagneticField* magField = field.product(); - const GlobalPoint vtx = origin(); GlobalVector dir = direction(); @@ -378,13 +355,13 @@ TrackingRegion::Hits RectangularEtaPhiTrackingRegion::hits(const edm::EventSetup Surface::RotationType rot(sin(phi), -cos(phi), 0, 0, 0, -1, cos(phi), sin(phi), 0); Plane::PlanePointer surface = Plane::build(GlobalPoint(0., 0., 0.), rot); - //TrajectoryStateOnSurface tsos(lpar, *surface, magField); + //TrajectoryStateOnSurface tsos(lpar, *surface, theField); - FreeTrajectoryState fts(GlobalTrajectoryParameters(vtx, dir, 1, magField)); + FreeTrajectoryState fts(GlobalTrajectoryParameters(vtx, dir, 1, theField)); TrajectoryStateOnSurface tsos(fts, *surface); // propagator - StraightLinePropagator prop(magField, alongMomentum); + StraightLinePropagator prop(theField, alongMomentum); LayerMeasurements lm(theMeasurementTracker->measurementTracker(), *theMeasurementTracker); From 8804416b13d6c94d8467b633a520e11e06c7d6b0 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Fri, 10 Sep 2021 22:10:37 +0200 Subject: [PATCH 3/6] Move accessing EventSetup from GlobalTrackingRegion to the functions that create TrackingRegion objects --- .../interface/GlobalTrackingRegion.h | 8 ++++++- ...GlobalTrackingRegionProducerFromBeamSpot.h | 19 ++++++++++++--- ...GlobalTrackingRegionWithVerticesProducer.h | 23 ++++++++++++++----- .../src/GlobalTrackingRegion.cc | 8 +------ 4 files changed, 41 insertions(+), 17 deletions(-) diff --git a/RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h b/RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h index 8345904804827..ff9d805cfede0 100644 --- a/RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h +++ b/RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h @@ -8,6 +8,7 @@ */ #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" #include class GlobalTrackingRegion final : public TrackingRegion { @@ -17,14 +18,18 @@ class GlobalTrackingRegion final : public TrackingRegion { * originHalfLength, positioned at "origin". * This class DOES provide the possibility to displace the origin * in the transverse plane. + * + * if useMS == true, msmaker needs to be given */ GlobalTrackingRegion(float ptMin, const GlobalPoint& origin, float originRadius, float originHalfLength, bool precise = false, - bool useMS = false) + bool useMS = false, + const MultipleScatteringParametrisationMaker* msmaker = nullptr) : TrackingRegionBase(GlobalVector(0, 0, 0), origin, Range(-1 / ptMin, 1 / ptMin), originRadius, originHalfLength), + theMSMaker(msmaker), thePrecise(precise), theUseMS(useMS) {} @@ -62,6 +67,7 @@ class GlobalTrackingRegion final : public TrackingRegion { std::string print() const override; private: + const MultipleScatteringParametrisationMaker* theMSMaker = nullptr; bool thePrecise = false; bool theUseMS = false; }; diff --git a/RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegionProducerFromBeamSpot.h b/RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegionProducerFromBeamSpot.h index a550dd4d75be6..1db932cfc7bba 100644 --- a/RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegionProducerFromBeamSpot.h +++ b/RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegionProducerFromBeamSpot.h @@ -12,6 +12,8 @@ #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/Utilities/interface/Exception.h" #include "FWCore/Framework/interface/ConsumesCollector.h" +#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" class GlobalTrackingRegionProducerFromBeamSpot : public TrackingRegionProducer { public: @@ -33,9 +35,12 @@ class GlobalTrackingRegionProducerFromBeamSpot : public TrackingRegionProducer { theUseMS = (regionPSet.existsAs("useMultipleScattering") ? regionPSet.getParameter("useMultipleScattering") : false); + if (theUseMS) { + token_msmaker = iC.esConsumes(); + } } - ~GlobalTrackingRegionProducerFromBeamSpot() override {} + ~GlobalTrackingRegionProducerFromBeamSpot() override = default; static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) { { @@ -75,7 +80,8 @@ class GlobalTrackingRegionProducerFromBeamSpot : public TrackingRegionProducer { } } - std::vector > regions(const edm::Event& ev, const edm::EventSetup&) const override { + std::vector > regions(const edm::Event& ev, + const edm::EventSetup& es) const override { std::vector > result; edm::Handle bsHandle; ev.getByToken(token_beamSpot, bsHandle); @@ -84,12 +90,18 @@ class GlobalTrackingRegionProducerFromBeamSpot : public TrackingRegionProducer { GlobalPoint origin(bs.x0(), bs.y0(), bs.z0()); + const MultipleScatteringParametrisationMaker* msmaker = nullptr; + if (theUseMS) { + msmaker = &es.getData(token_msmaker); + } + result.push_back(std::make_unique(thePtMin, origin, theOriginRadius, std::max(theNSigmaZ * bs.sigmaZ(), theOriginHalfLength), thePrecise, - theUseMS)); + theUseMS, + msmaker)); } return result; } @@ -100,6 +112,7 @@ class GlobalTrackingRegionProducerFromBeamSpot : public TrackingRegionProducer { double theOriginHalfLength; double theNSigmaZ; edm::EDGetTokenT token_beamSpot; + edm::ESGetToken token_msmaker; bool thePrecise; bool theUseMS; }; diff --git a/RecoTracker/TkTrackingRegions/plugins/GlobalTrackingRegionWithVerticesProducer.h b/RecoTracker/TkTrackingRegions/plugins/GlobalTrackingRegionWithVerticesProducer.h index 7a841e33e71fe..3cad10eac9ec1 100644 --- a/RecoTracker/TkTrackingRegions/plugins/GlobalTrackingRegionWithVerticesProducer.h +++ b/RecoTracker/TkTrackingRegions/plugins/GlobalTrackingRegionWithVerticesProducer.h @@ -49,6 +49,10 @@ class GlobalTrackingRegionWithVerticesProducer : public TrackingRegionProducer { edm::InputTag pixelClustersForScaling = regionPSet.getParameter("pixelClustersForScaling"); if (theOriginRScaling || thePtMinScaling || theHalfLengthScaling) token_pc = iC.consumes >(pixelClustersForScaling); + + if (theUseMS) { + token_msmaker = iC.esConsumes(); + } } ~GlobalTrackingRegionWithVerticesProducer() override {} @@ -86,7 +90,8 @@ class GlobalTrackingRegionWithVerticesProducer : public TrackingRegionProducer { descriptions.add("globalTrackingRegionWithVertices", descRegion); } - std::vector > regions(const edm::Event& ev, const edm::EventSetup&) const override { + std::vector > regions(const edm::Event& ev, + const edm::EventSetup& es) const override { std::vector > result; GlobalPoint theOrigin; @@ -101,6 +106,11 @@ class GlobalTrackingRegionWithVerticesProducer : public TrackingRegionProducer { throw cms::Exception("Seeding") << "ERROR: input beamSpot is not valid in GlobalTrackingRegionWithVertices"; } + const MultipleScatteringParametrisationMaker* msmaker = nullptr; + if (theUseMS) { + msmaker = &es.getData(token_msmaker); + } + if (theUseFoundVertices) { edm::Handle vertexCollection; ev.getByToken(token_vertex, vertexCollection); @@ -152,14 +162,14 @@ class GlobalTrackingRegionWithVerticesProducer : public TrackingRegionProducer { //if region has 0 size, return 'result' empty, otherwise make a tracking region if (scaledOriginRadius != 0 && scaledHalfLength != 0) { result.push_back(std::make_unique( - scaledPtMin, theOrigin_, scaledOriginRadius, scaledHalfLength, thePrecise, theUseMS)); + scaledPtMin, theOrigin_, scaledOriginRadius, scaledHalfLength, thePrecise, theUseMS, msmaker)); } } //end of region scaling code, pp behavior below else { double theOriginHalfLength_ = (theUseFixedError ? theFixedError : (iV->zError()) * theSigmaZVertex); result.push_back(std::make_unique( - thePtMin, theOrigin_, theOriginRadius, theOriginHalfLength_, thePrecise, theUseMS)); + thePtMin, theOrigin_, theOriginRadius, theOriginHalfLength_, thePrecise, theUseMS, msmaker)); if (theMaxNVertices >= 0 && result.size() >= static_cast(theMaxNVertices)) break; } @@ -167,11 +177,11 @@ class GlobalTrackingRegionWithVerticesProducer : public TrackingRegionProducer { if (result.empty() && !(theOriginRScaling || thePtMinScaling || theHalfLengthScaling)) { result.push_back(std::make_unique( - thePtMin, theOrigin, theOriginRadius, bsSigmaZ, thePrecise, theUseMS)); + thePtMin, theOrigin, theOriginRadius, bsSigmaZ, thePrecise, theUseMS, msmaker)); } } else { - result.push_back( - std::make_unique(thePtMin, theOrigin, theOriginRadius, bsSigmaZ, thePrecise, theUseMS)); + result.push_back(std::make_unique( + thePtMin, theOrigin, theOriginRadius, bsSigmaZ, thePrecise, theUseMS, msmaker)); } return result; @@ -194,6 +204,7 @@ class GlobalTrackingRegionWithVerticesProducer : public TrackingRegionProducer { bool theUseFixedError; edm::EDGetTokenT token_vertex; edm::EDGetTokenT token_beamSpot; + edm::ESGetToken token_msmaker; //HI-related variables bool theOriginRScaling; diff --git a/RecoTracker/TkTrackingRegions/src/GlobalTrackingRegion.cc b/RecoTracker/TkTrackingRegions/src/GlobalTrackingRegion.cc index ec1ed855382f5..f151070e83435 100644 --- a/RecoTracker/TkTrackingRegions/src/GlobalTrackingRegion.cc +++ b/RecoTracker/TkTrackingRegions/src/GlobalTrackingRegion.cc @@ -6,14 +6,10 @@ #include "RecoTracker/TkTrackingRegions/interface/HitRCheck.h" #include "RecoTracker/TkTrackingRegions/interface/HitZCheck.h" -#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" #include "RecoTracker/TkMSParametrization/interface/PixelRecoUtilities.h" -#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" #include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisation.h" #include "RecoTracker/TkMSParametrization/interface/PixelRecoPointRZ.h" #include "RecoTracker/TkMSParametrization/interface/PixelRecoLineRZ.h" -#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" -#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" template T sqr(T t) { @@ -91,9 +87,7 @@ std::unique_ptr GlobalTrackingRegion::checkRZ(const DetLayer HitRZConstraint rzConstraint(leftLine, rightLine); if UNLIKELY (theUseMS) { - edm::ESHandle hmaker; - iSetup.get().get(hmaker); - MultipleScatteringParametrisation iSigma = hmaker->parametrisation(layer); + MultipleScatteringParametrisation iSigma = theMSMaker->parametrisation(layer); PixelRecoPointRZ vtxMean(0., origin().z()); float innerScatt = 3.f * (outerlayer ? iSigma(ptMin(), vtxMean, outerred, outerlayer->seqNum()) From 46009a23ae5f4b97977dd5a99ed9b934e396156c Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Sat, 11 Sep 2021 00:39:41 +0200 Subject: [PATCH 4/6] Move accessing EventSetup from CosmicTrackingRegion to the functions that create those objects --- .../interface/CosmicRegionalSeedGenerator.h | 6 +- .../interface/CosmicTrackingRegion.h | 16 +++--- .../src/CosmicRegionalSeedGenerator.cc | 56 +++++++------------ .../src/CosmicTrackingRegion.cc | 11 +--- 4 files changed, 31 insertions(+), 58 deletions(-) diff --git a/RecoTracker/SpecialSeedGenerators/interface/CosmicRegionalSeedGenerator.h b/RecoTracker/SpecialSeedGenerators/interface/CosmicRegionalSeedGenerator.h index c822745c0bcc0..a9ecd494bf113 100644 --- a/RecoTracker/SpecialSeedGenerators/interface/CosmicRegionalSeedGenerator.h +++ b/RecoTracker/SpecialSeedGenerators/interface/CosmicRegionalSeedGenerator.h @@ -56,20 +56,16 @@ class CosmicRegionalSeedGenerator : public TrackingRegionProducer { const edm::EventSetup& es) const override; private: - edm::ParameterSet conf_; - edm::ParameterSet regionPSet; - float ptMin_; float rVertex_; float zVertex_; float deltaEta_; float deltaPhi_; - std::string thePropagatorName_; std::string regionBase_; - edm::ESGetToken trackerToken_; edm::ESGetToken propagatorToken_; + edm::ESGetToken magfieldToken_; edm::InputTag recoMuonsCollection_; edm::InputTag recoTrackMuonsCollection_; diff --git a/RecoTracker/SpecialSeedGenerators/interface/CosmicTrackingRegion.h b/RecoTracker/SpecialSeedGenerators/interface/CosmicTrackingRegion.h index c89070933d887..1cff9b9fc6d4a 100644 --- a/RecoTracker/SpecialSeedGenerators/interface/CosmicTrackingRegion.h +++ b/RecoTracker/SpecialSeedGenerators/interface/CosmicTrackingRegion.h @@ -12,7 +12,7 @@ #include "RecoTracker/TkTrackingRegions/interface/HitRZConstraint.h" #include "FWCore/Framework/interface/EventSetup.h" #include "RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h" -#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "MagneticField/Engine/interface/MagneticField.h" #include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h" #include "DataFormats/TrackingRecHit/interface/mayown_ptr.h" @@ -56,11 +56,12 @@ class CosmicTrackingRegion : public TrackingRegionBase { float zVertex, float deltaEta, float deltaPhi, + const MagneticField& magField, float dummy = 0., const MeasurementTrackerEvent* measurementTracker = nullptr) : TrackingRegionBase(dir, vertexPos, Range(-1 / ptMin, 1 / ptMin), rVertex, zVertex), theMeasurementTracker_(measurementTracker), - measurementTrackerName_("") {} + theMagneticField_(&magField) {} CosmicTrackingRegion(const GlobalVector& dir, const GlobalPoint& vertexPos, @@ -69,17 +70,16 @@ class CosmicTrackingRegion : public TrackingRegionBase { float zVertex, float deltaEta, float deltaPhi, - const edm::ParameterSet& extra, + const MagneticField& magField, const MeasurementTrackerEvent* measurementTracker = nullptr) : TrackingRegionBase(dir, vertexPos, Range(-1 / ptMin, 1 / ptMin), rVertex, zVertex), - theMeasurementTracker_(measurementTracker) { - measurementTrackerName_ = extra.getParameter("measurementTrackerName"); - } + theMeasurementTracker_(measurementTracker), + theMagneticField_(&magField) {} CosmicTrackingRegion(CosmicTrackingRegion const& rh) : TrackingRegionBase(rh), theMeasurementTracker_(rh.theMeasurementTracker_), - measurementTrackerName_(rh.measurementTrackerName_) {} + theMagneticField_(rh.theMagneticField_) {} TrackingRegion::Hits hits(const edm::EventSetup& es, const SeedingLayerSetsHits::SeedingLayer& layer) const override; @@ -107,7 +107,7 @@ class CosmicTrackingRegion : public TrackingRegionBase { void hits_(const edm::EventSetup& es, const T& layer, TrackingRegion::Hits& result) const; const MeasurementTrackerEvent* theMeasurementTracker_; - std::string measurementTrackerName_; + const MagneticField* theMagneticField_; using cacheHitPointer = mayown_ptr; using cacheHits = std::vector; diff --git a/RecoTracker/SpecialSeedGenerators/src/CosmicRegionalSeedGenerator.cc b/RecoTracker/SpecialSeedGenerators/src/CosmicRegionalSeedGenerator.cc index fc5649f629548..237ace8f956fb 100644 --- a/RecoTracker/SpecialSeedGenerators/src/CosmicRegionalSeedGenerator.cc +++ b/RecoTracker/SpecialSeedGenerators/src/CosmicRegionalSeedGenerator.cc @@ -16,29 +16,26 @@ using namespace reco; using namespace edm; CosmicRegionalSeedGenerator::CosmicRegionalSeedGenerator(edm::ParameterSet const& conf, edm::ConsumesCollector&& iC) - : conf_(conf) { + : magfieldToken_(iC.esConsumes()) { edm::LogInfo("CosmicRegionalSeedGenerator") << "Begin Run:: Constructing CosmicRegionalSeedGenerator"; - regionPSet = conf_.getParameter("RegionPSet"); + edm::ParameterSet regionPSet = conf.getParameter("RegionPSet"); ptMin_ = regionPSet.getParameter("ptMin"); rVertex_ = regionPSet.getParameter("rVertex"); zVertex_ = regionPSet.getParameter("zVertex"); deltaEta_ = regionPSet.getParameter("deltaEtaRegion"); deltaPhi_ = regionPSet.getParameter("deltaPhiRegion"); - edm::ParameterSet toolsPSet = conf_.getParameter("ToolsPSet"); - thePropagatorName_ = toolsPSet.getParameter("thePropagatorName"); + edm::ParameterSet toolsPSet = conf.getParameter("ToolsPSet"); + propagatorToken_ = iC.esConsumes(edm::ESInputTag("", toolsPSet.getParameter("thePropagatorName"))); regionBase_ = toolsPSet.getParameter("regionBase"); - trackerToken_ = iC.esConsumes(); - propagatorToken_ = iC.esConsumes(edm::ESInputTag("", thePropagatorName_)); - - edm::ParameterSet collectionsPSet = conf_.getParameter("CollectionsPSet"); + edm::ParameterSet collectionsPSet = conf.getParameter("CollectionsPSet"); recoMuonsCollection_ = collectionsPSet.getParameter("recoMuonsCollection"); recoTrackMuonsCollection_ = collectionsPSet.getParameter("recoTrackMuonsCollection"); recoL2MuonsCollection_ = collectionsPSet.getParameter("recoL2MuonsCollection"); - edm::ParameterSet regionInJetsCheckPSet = conf_.getParameter("RegionInJetsCheckPSet"); + edm::ParameterSet regionInJetsCheckPSet = conf.getParameter("RegionInJetsCheckPSet"); doJetsExclusionCheck_ = regionInJetsCheckPSet.getParameter("doJetsExclusionCheck"); deltaRExclusionSize_ = regionInJetsCheckPSet.getParameter("deltaRExclusionSize"); jetsPtMin_ = regionInJetsCheckPSet.getParameter("jetsPtMin"); @@ -64,6 +61,11 @@ std::vector> CosmicRegionalSeedGenerator::region event.getByToken(measurementTrackerEventToken_, hmte); measurementTracker = hmte.product(); } + + //get the propagator + auto const& propagator = es.getData(propagatorToken_); + auto const& magfield = es.getData(magfieldToken_); + //________________________________________ // //Seeding on Sta muon (MC && Datas) @@ -90,12 +92,6 @@ std::vector> CosmicRegionalSeedGenerator::region edm::Handle caloJetsHandle; event.getByToken(recoCaloJetsToken_, caloJetsHandle); - //get the propagator - edm::ESHandle thePropagator = es.getHandle(propagatorToken_); - - //get tracker geometry - edm::ESHandle theTrackerGeometry = es.getHandle(trackerToken_); - //definition of the region //+++++++++++++++++++++++++ @@ -141,9 +137,9 @@ std::vector> CosmicRegionalSeedGenerator::region if (staMuon->standAloneMuon()->outerPosition().y() > 0) initialRegionMomentum *= -1; GlobalTrajectoryParameters glb_parameters( - initialRegionPosition, initialRegionMomentum, charge, thePropagator->magneticField()); + initialRegionPosition, initialRegionMomentum, charge, propagator.magneticField()); FreeTrajectoryState fts(glb_parameters); - StateOnTrackerBound onBounds(thePropagator.product()); + StateOnTrackerBound onBounds(&propagator); TrajectoryStateOnSurface outer = onBounds(fts); if (!outer.isValid()) { @@ -197,7 +193,7 @@ std::vector> CosmicRegionalSeedGenerator::region //definition of the region result.push_back(std::make_unique( - (-1) * regionMom, center, ptMin_, rVertex_, zVertex_, deltaEta_, deltaPhi_, regionPSet, measurementTracker)); + (-1) * regionMom, center, ptMin_, rVertex_, zVertex_, deltaEta_, deltaPhi_, magfield, measurementTracker)); LogDebug("CosmicRegionalSeedGenerator") << "Final CosmicTrackingRegion \n " @@ -238,12 +234,6 @@ std::vector> CosmicRegionalSeedGenerator::region edm::Handle caloJetsHandle; event.getByToken(recoCaloJetsToken_, caloJetsHandle); - //get the propagator - edm::ESHandle thePropagator = es.getHandle(propagatorToken_); - - //get tracker geometry - edm::ESHandle theTrackerGeometry = es.getHandle(trackerToken_); - //definition of the region //+++++++++++++++++++++++++ @@ -279,9 +269,9 @@ std::vector> CosmicRegionalSeedGenerator::region if (cosmicMuon->outerPosition().y() > 0 && cosmicMuon->momentum().y() < 0) initialRegionMomentum *= -1; GlobalTrajectoryParameters glb_parameters( - initialRegionPosition, initialRegionMomentum, charge, thePropagator->magneticField()); + initialRegionPosition, initialRegionMomentum, charge, propagator.magneticField()); FreeTrajectoryState fts(glb_parameters); - StateOnTrackerBound onBounds(thePropagator.product()); + StateOnTrackerBound onBounds(&propagator); TrajectoryStateOnSurface outer = onBounds(fts); if (!outer.isValid()) { @@ -334,7 +324,7 @@ std::vector> CosmicRegionalSeedGenerator::region //definition of the region result.push_back(std::make_unique( - (-1) * regionMom, center, ptMin_, rVertex_, zVertex_, deltaEta_, deltaPhi_, regionPSet, measurementTracker)); + (-1) * regionMom, center, ptMin_, rVertex_, zVertex_, deltaEta_, deltaPhi_, magfield, measurementTracker)); LogDebug("CosmicRegionalSeedGenerator") << "Final CosmicTrackingRegion \n " @@ -371,12 +361,6 @@ std::vector> CosmicRegionalSeedGenerator::region LogDebug("CosmicRegionalSeedGenerator") << "L2 muons collection size = " << L2MuonsHandle->size(); - //get the propagator - edm::ESHandle thePropagator = es.getHandle(propagatorToken_); - - //get tracker geometry - edm::ESHandle theTrackerGeometry = es.getHandle(trackerToken_); - //definition of the region //+++++++++++++++++++++++++ @@ -416,9 +400,9 @@ std::vector> CosmicRegionalSeedGenerator::region } GlobalTrajectoryParameters glb_parameters( - initialRegionPosition, initialRegionMomentum, charge, thePropagator->magneticField()); + initialRegionPosition, initialRegionMomentum, charge, propagator.magneticField()); FreeTrajectoryState fts(glb_parameters); - StateOnTrackerBound onBounds(thePropagator.product()); + StateOnTrackerBound onBounds(&propagator); TrajectoryStateOnSurface outer = onBounds(fts); if (!outer.isValid()) { @@ -447,7 +431,7 @@ std::vector> CosmicRegionalSeedGenerator::region //definition of the region result.push_back(std::make_unique( - (-1) * regionMom, center, ptMin_, rVertex_, zVertex_, deltaEta_, deltaPhi_, regionPSet, measurementTracker)); + (-1) * regionMom, center, ptMin_, rVertex_, zVertex_, deltaEta_, deltaPhi_, magfield, measurementTracker)); LogDebug("CosmicRegionalSeedGenerator") << "Final L2TrackingRegion \n " diff --git a/RecoTracker/SpecialSeedGenerators/src/CosmicTrackingRegion.cc b/RecoTracker/SpecialSeedGenerators/src/CosmicTrackingRegion.cc index dd80119ce3b09..fa17c7d50dbea 100644 --- a/RecoTracker/SpecialSeedGenerators/src/CosmicTrackingRegion.cc +++ b/RecoTracker/SpecialSeedGenerators/src/CosmicTrackingRegion.cc @@ -13,8 +13,6 @@ #include "DataFormats/GeometrySurface/interface/BoundPlane.h" -#include "FWCore/Framework/interface/ESHandle.h" - namespace { template T sqr(T t) { @@ -65,11 +63,6 @@ void CosmicTrackingRegion::hits_(const edm::EventSetup& es, const T& layer, Trac LogDebug("CosmicTrackingRegion") << "Looking at hits on subdet/layer " << layer.name(); EtaPhiMeasurementEstimator est(0.3, 0.3); - //magnetic field - edm::ESHandle field; - es.get().get(field); - const MagneticField* magField = field.product(); - //region const GlobalPoint vtx = origin(); GlobalVector dir = direction(); @@ -85,12 +78,12 @@ void CosmicTrackingRegion::hits_(const edm::EventSetup& es, const T& layer, Trac Surface::RotationType rot(sin(phi), -cos(phi), 0, 0, 0, -1, cos(phi), sin(phi), 0); Plane::PlanePointer surface = Plane::build(vtx, rot); - FreeTrajectoryState fts(GlobalTrajectoryParameters(vtx, dir, 1, magField)); + FreeTrajectoryState fts(GlobalTrajectoryParameters(vtx, dir, 1, theMagneticField_)); TrajectoryStateOnSurface tsos(fts, *surface); LogDebug("CosmicTrackingRegion") << "The state used to find measurement with the measurement tracker is:\n" << tsos; //propagator - AnalyticalPropagator prop(magField, alongMomentum); + AnalyticalPropagator prop(theMagneticField_, alongMomentum); //propagation verification (debug) //++++++++++++++++++++++++++++++++ From c73b9b6e463b4f366e90968c7cd963d5075db107 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Mon, 13 Sep 2021 02:58:39 +0200 Subject: [PATCH 5/6] Remove EventSetup from TrackingRegion method arguments --- .../Tracking/src/SeedFinderSelector.cc | 3 +- .../src/PixelTripletLowPtGenerator.cc | 2 +- .../plugins/PixelTripletHLTGenerator.cc | 2 +- .../plugins/PixelTripletLargeTipGenerator.cc | 2 +- .../plugins/PixelTripletNoTipGenerator.cc | 2 +- ...inedHitPairGeneratorForPhotonConversion.cc | 2 +- ...tQuadrupletGeneratorForPhotonConversion.cc | 2 +- ...neratorFromLayerPairForPhotonConversion.cc | 23 ++++++++----- ...eneratorFromLayerPairForPhotonConversion.h | 7 +++- ...neratorFromLayerPairForPhotonConversion.cc | 17 ++++------ ...eneratorFromLayerPairForPhotonConversion.h | 6 +--- .../interface/CosmicTrackingRegion.h | 6 ++-- .../interface/SimpleCosmicBONSeeder.h | 9 ++---- .../src/BeamHaloPairGenerator.cc | 4 +-- .../src/CosmicTrackingRegion.cc | 7 ++-- .../src/GenericPairGenerator.cc | 4 +-- .../src/GenericTripletGenerator.cc | 6 ++-- .../src/SimpleCosmicBONSeeder.cc | 32 +++++++++---------- .../TkHitPairs/interface/LayerHitMapCache.h | 8 ++--- .../src/HitPairGeneratorFromLayerPair.cc | 5 ++- .../MultiHitGeneratorFromPairAndLayers.h | 1 - .../plugins/MultiHitFromChi2EDProducer.cc | 3 +- .../plugins/MultiHitGeneratorFromChi2.cc | 12 +++---- .../plugins/MultiHitGeneratorFromChi2.h | 4 --- .../interface/GlobalTrackingRegion.h | 3 +- .../RectangularEtaPhiTrackingRegion.h | 13 +++----- .../interface/TrackingRegion.h | 4 +-- .../src/GlobalTrackingRegion.cc | 4 +-- .../src/RectangularEtaPhiTrackingRegion.cc | 18 ++++------- 29 files changed, 89 insertions(+), 122 deletions(-) diff --git a/FastSimulation/Tracking/src/SeedFinderSelector.cc b/FastSimulation/Tracking/src/SeedFinderSelector.cc index b352bef2eabd8..cdf17b45b2a74 100644 --- a/FastSimulation/Tracking/src/SeedFinderSelector.cc +++ b/FastSimulation/Tracking/src/SeedFinderSelector.cc @@ -150,8 +150,7 @@ bool SeedFinderSelector::pass(const std::vector &hits return !tripletresult.empty(); } else if (multiHitGenerator_) { OrderedMultiHits tripletresult; - multiHitGenerator_->hitTriplets( - *trackingRegion_, tripletresult, *eventSetup_, result, &thmp, thirdLayerDetLayer, 1); + multiHitGenerator_->hitTriplets(*trackingRegion_, tripletresult, result, &thmp, thirdLayerDetLayer, 1); return !tripletresult.empty(); } //new for Phase1 diff --git a/RecoPixelVertexing/PixelLowPtUtilities/src/PixelTripletLowPtGenerator.cc b/RecoPixelVertexing/PixelLowPtUtilities/src/PixelTripletLowPtGenerator.cc index 8b2b2b3470c90..e1dfba39ba51f 100644 --- a/RecoPixelVertexing/PixelLowPtUtilities/src/PixelTripletLowPtGenerator.cc +++ b/RecoPixelVertexing/PixelLowPtUtilities/src/PixelTripletLowPtGenerator.cc @@ -91,7 +91,7 @@ void PixelTripletLowPtGenerator::hitTriplets(const TrackingRegion& region, // Set aliases const RecHitsSortedInPhi** thirdHitMap = new const RecHitsSortedInPhi*[size]; for (int il = 0; il < size; il++) - thirdHitMap[il] = &(*theLayerCache)(thirdLayers[il], region, es); + thirdHitMap[il] = &(*theLayerCache)(thirdLayers[il], region); // Get tracker getTracker(es); diff --git a/RecoPixelVertexing/PixelTriplets/plugins/PixelTripletHLTGenerator.cc b/RecoPixelVertexing/PixelTriplets/plugins/PixelTripletHLTGenerator.cc index 490372d06a107..53373a0a65a54 100644 --- a/RecoPixelVertexing/PixelTriplets/plugins/PixelTripletHLTGenerator.cc +++ b/RecoPixelVertexing/PixelTriplets/plugins/PixelTripletHLTGenerator.cc @@ -94,7 +94,7 @@ void PixelTripletHLTGenerator::hitTriplets(const TrackingRegion& region, const RecHitsSortedInPhi* thirdHitMap[size]; vector thirdLayerDetLayer(size, nullptr); for (int il = 0; il < size; ++il) { - thirdHitMap[il] = &layerCache(thirdLayers[il], region, es); + thirdHitMap[il] = &layerCache(thirdLayers[il], region); thirdLayerDetLayer[il] = thirdLayers[il].detLayer(); } hitTriplets(region, result, es, doublets, thirdHitMap, thirdLayerDetLayer, size, tripletLastLayerIndex); diff --git a/RecoPixelVertexing/PixelTriplets/plugins/PixelTripletLargeTipGenerator.cc b/RecoPixelVertexing/PixelTriplets/plugins/PixelTripletLargeTipGenerator.cc index 3de960c80e0bc..77c1a3643736c 100644 --- a/RecoPixelVertexing/PixelTriplets/plugins/PixelTripletLargeTipGenerator.cc +++ b/RecoPixelVertexing/PixelTriplets/plugins/PixelTripletLargeTipGenerator.cc @@ -112,7 +112,7 @@ void PixelTripletLargeTipGenerator::hitTriplets(const TrackingRegion& region, const RecHitsSortedInPhi* thirdHitMap[size]; vector thirdLayerDetLayer(size, nullptr); for (int il = 0; il < size; ++il) { - thirdHitMap[il] = &layerCache(thirdLayers[il], region, es); + thirdHitMap[il] = &layerCache(thirdLayers[il], region); thirdLayerDetLayer[il] = thirdLayers[il].detLayer(); } hitTriplets(region, result, es, doublets, thirdHitMap, thirdLayerDetLayer, size, tripletLastLayerIndex); diff --git a/RecoPixelVertexing/PixelTriplets/plugins/PixelTripletNoTipGenerator.cc b/RecoPixelVertexing/PixelTriplets/plugins/PixelTripletNoTipGenerator.cc index 48980e80c9a76..c71a00a8b1fb6 100644 --- a/RecoPixelVertexing/PixelTriplets/plugins/PixelTripletNoTipGenerator.cc +++ b/RecoPixelVertexing/PixelTriplets/plugins/PixelTripletNoTipGenerator.cc @@ -72,7 +72,7 @@ void PixelTripletNoTipGenerator::hitTriplets(const TrackingRegion& region, const RecHitsSortedInPhi** thirdHitMap = new const RecHitsSortedInPhi*[size]; for (int il = 0; il <= size - 1; il++) { - thirdHitMap[il] = &(*theLayerCache)(thirdLayers[il], region, es); + thirdHitMap[il] = &(*theLayerCache)(thirdLayers[il], region); } const auto& field = es.getData(fieldToken_); diff --git a/RecoTracker/ConversionSeedGenerators/plugins/CombinedHitPairGeneratorForPhotonConversion.cc b/RecoTracker/ConversionSeedGenerators/plugins/CombinedHitPairGeneratorForPhotonConversion.cc index cd50047445a9d..4b8ee63fade32 100644 --- a/RecoTracker/ConversionSeedGenerators/plugins/CombinedHitPairGeneratorForPhotonConversion.cc +++ b/RecoTracker/ConversionSeedGenerators/plugins/CombinedHitPairGeneratorForPhotonConversion.cc @@ -18,7 +18,7 @@ CombinedHitPairGeneratorForPhotonConversion::CombinedHitPairGeneratorForPhotonCo theMaxElement = cfg.getParameter("maxElement"); maxHitPairsPerTrackAndGenerator = cfg.getParameter("maxHitPairsPerTrackAndGenerator"); theGenerator = std::make_unique( - 0, 1, &theLayerCache, 0, maxHitPairsPerTrackAndGenerator); + iC, 0, 1, &theLayerCache, 0, maxHitPairsPerTrackAndGenerator); } const OrderedHitPairs& CombinedHitPairGeneratorForPhotonConversion::run(const ConversionRegion& convRegion, diff --git a/RecoTracker/ConversionSeedGenerators/plugins/CombinedHitQuadrupletGeneratorForPhotonConversion.cc b/RecoTracker/ConversionSeedGenerators/plugins/CombinedHitQuadrupletGeneratorForPhotonConversion.cc index 298b26a00b523..9c686c5efa74c 100644 --- a/RecoTracker/ConversionSeedGenerators/plugins/CombinedHitQuadrupletGeneratorForPhotonConversion.cc +++ b/RecoTracker/ConversionSeedGenerators/plugins/CombinedHitQuadrupletGeneratorForPhotonConversion.cc @@ -33,7 +33,7 @@ void CombinedHitQuadrupletGeneratorForPhotonConversion::hitPairs(const TrackingR assert(layers.numberOfLayersInSet() == 2); for (SeedingLayerSetsHits::LayerSetIndex i = 0; i < hlayers->size() && result.size() < maxHitQuadruplets; ++i) { - theGenerator->hitPairs(region, result, layers[i], ev, es); + theGenerator->hitPairs(region, result, layers[i]); } theLayerCache.clear(); } diff --git a/RecoTracker/ConversionSeedGenerators/plugins/HitPairGeneratorFromLayerPairForPhotonConversion.cc b/RecoTracker/ConversionSeedGenerators/plugins/HitPairGeneratorFromLayerPairForPhotonConversion.cc index 1c583299faa29..e8fdb2eeb7d64 100644 --- a/RecoTracker/ConversionSeedGenerators/plugins/HitPairGeneratorFromLayerPairForPhotonConversion.cc +++ b/RecoTracker/ConversionSeedGenerators/plugins/HitPairGeneratorFromLayerPairForPhotonConversion.cc @@ -36,8 +36,17 @@ namespace { #include "DataFormats/Math/interface/deltaPhi.h" HitPairGeneratorFromLayerPairForPhotonConversion::HitPairGeneratorFromLayerPairForPhotonConversion( - unsigned int inner, unsigned int outer, LayerCacheType* layerCache, unsigned int nSize, unsigned int max) - : theLayerCache(*layerCache), theOuterLayer(outer), theInnerLayer(inner), theMaxElement(max) {} + edm::ConsumesCollector iC, + unsigned int inner, + unsigned int outer, + LayerCacheType* layerCache, + unsigned int nSize, + unsigned int max) + : theLayerCache(*layerCache), + theOuterLayer(outer), + theInnerLayer(inner), + theMaxElement(max), + theFieldToken(iC.esConsumes()) {} void HitPairGeneratorFromLayerPairForPhotonConversion::hitPairs(const ConversionRegion& convRegion, const TrackingRegion& region, @@ -69,11 +78,11 @@ void HitPairGeneratorFromLayerPairForPhotonConversion::hitPairs(const Conversion return; //FIXME, the maxSearchR(Z) are not optimized /*get hit sorted in phi for each layer: NB: doesn't apply any region cut*/ - const RecHitsSortedInPhi& innerHitsMap = theLayerCache(innerLayerObj, region, es); + const RecHitsSortedInPhi& innerHitsMap = theLayerCache(innerLayerObj, region); if (innerHitsMap.empty()) return; - const RecHitsSortedInPhi& outerHitsMap = theLayerCache(outerLayerObj, region, es); + const RecHitsSortedInPhi& outerHitsMap = theLayerCache(outerLayerObj, region); if (outerHitsMap.empty()) return; /*----------------*/ @@ -88,9 +97,7 @@ void HitPairGeneratorFromLayerPairForPhotonConversion::hitPairs(const Conversion float innerPhimin, innerPhimax; /*Getting only the Hits in the outer layer that are compatible with the conversion region*/ - edm::ESHandle hfield; - es.get().get(hfield); - const auto& field = *hfield; + const auto& field = es.getData(theFieldToken); if (!getPhiRange(outerPhimin, outerPhimax, *outerLayerObj.detLayer(), convRegion, field)) return; outerHitsMap.hits(outerPhimin, outerPhimax, outerHits); @@ -121,7 +128,7 @@ void HitPairGeneratorFromLayerPairForPhotonConversion::hitPairs(const Conversion if (phiRange.empty()) continue; */ - std::unique_ptr checkRZ = region.checkRZ(innerLayerObj.detLayer(), ohit, es); + std::unique_ptr checkRZ = region.checkRZ(innerLayerObj.detLayer(), ohit); if (!checkRZ) { #ifdef mydebug_Seed ss << "*******\nNo valid checkRZ\n*******" << std::endl; diff --git a/RecoTracker/ConversionSeedGenerators/plugins/HitPairGeneratorFromLayerPairForPhotonConversion.h b/RecoTracker/ConversionSeedGenerators/plugins/HitPairGeneratorFromLayerPairForPhotonConversion.h index 1aca05b95039a..89cc05899eed9 100644 --- a/RecoTracker/ConversionSeedGenerators/plugins/HitPairGeneratorFromLayerPairForPhotonConversion.h +++ b/RecoTracker/ConversionSeedGenerators/plugins/HitPairGeneratorFromLayerPairForPhotonConversion.h @@ -3,12 +3,15 @@ #include "RecoTracker/TkHitPairs/interface/HitPairGenerator.h" #include "RecoTracker/TkHitPairs/interface/LayerHitMapCache.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Utilities/interface/Visibility.h" #include "ConversionRegion.h" class DetLayer; +class IdealMagneticFieldRecord; +class MagneticField; class TrackingRegion; class dso_hidden HitPairGeneratorFromLayerPairForPhotonConversion { // : public HitPairGenerator { @@ -18,7 +21,8 @@ class dso_hidden HitPairGeneratorFromLayerPairForPhotonConversion { // : public typedef SeedingLayerSetsHits::SeedingLayerSet Layers; typedef SeedingLayerSetsHits::SeedingLayer Layer; - HitPairGeneratorFromLayerPairForPhotonConversion(unsigned int inner, + HitPairGeneratorFromLayerPairForPhotonConversion(edm::ConsumesCollector iC, + unsigned int inner, unsigned int outer, LayerCacheType* layerCache, unsigned int nSize = 30000, @@ -58,6 +62,7 @@ class dso_hidden HitPairGeneratorFromLayerPairForPhotonConversion { // : public const unsigned int theOuterLayer; const unsigned int theInnerLayer; const unsigned int theMaxElement; + const edm::ESGetToken theFieldToken; std::stringstream ss; }; diff --git a/RecoTracker/ConversionSeedGenerators/plugins/HitQuadrupletGeneratorFromLayerPairForPhotonConversion.cc b/RecoTracker/ConversionSeedGenerators/plugins/HitQuadrupletGeneratorFromLayerPairForPhotonConversion.cc index d81105435826b..9d3f6b5215fa8 100644 --- a/RecoTracker/ConversionSeedGenerators/plugins/HitQuadrupletGeneratorFromLayerPairForPhotonConversion.cc +++ b/RecoTracker/ConversionSeedGenerators/plugins/HitQuadrupletGeneratorFromLayerPairForPhotonConversion.cc @@ -10,9 +10,6 @@ #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionBase.h" #include "RecoTracker/TkHitPairs/interface/OrderedHitPairs.h" -#include "FWCore/Framework/interface/Event.h" -#include "FWCore/Framework/interface/EventSetup.h" - using namespace GeomDetEnumerators; using namespace std; #include "RecoTracker/TkMSParametrization/interface/PixelRecoUtilities.h" @@ -40,9 +37,7 @@ HitQuadrupletGeneratorFromLayerPairForPhotonConversion::HitQuadrupletGeneratorFr void HitQuadrupletGeneratorFromLayerPairForPhotonConversion::hitPairs(const TrackingRegion ®ion, OrderedHitPairs &result, - const Layers &layers, - const edm::Event &event, - const edm::EventSetup &es) { + const Layers &layers) { ss->str(""); typedef OrderedHitPair::InnerRecHit InnerHit; @@ -58,11 +53,11 @@ void HitQuadrupletGeneratorFromLayerPairForPhotonConversion::hitPairs(const Trac #endif /*get hit sorted in phi for each layer: NB: doesn't apply any region cut*/ - const RecHitsSortedInPhi &innerHitsMap = theLayerCache(innerLayerObj, region, es); + const RecHitsSortedInPhi &innerHitsMap = theLayerCache(innerLayerObj, region); if (innerHitsMap.empty()) return; - const RecHitsSortedInPhi &outerHitsMap = theLayerCache(outerLayerObj, region, es); + const RecHitsSortedInPhi &outerHitsMap = theLayerCache(outerLayerObj, region); if (outerHitsMap.empty()) return; /*----------------*/ @@ -84,7 +79,7 @@ void HitQuadrupletGeneratorFromLayerPairForPhotonConversion::hitPairs(const Trac GlobalPoint oPos = ohit->globalPosition(); totCountP2++; - std::unique_ptr checkRZ = region.checkRZ(outerLayerObj.detLayer(), ohit, es); + std::unique_ptr checkRZ = region.checkRZ(outerLayerObj.detLayer(), ohit); for (nextoh = oh + 1; nextoh != outerHits.second; ++nextoh) { RecHitsSortedInPhi::Hit nohit = (*nextoh).hit(); GlobalPoint noPos = nohit->globalPosition(); @@ -126,8 +121,8 @@ void HitQuadrupletGeneratorFromLayerPairForPhotonConversion::hitPairs(const Trac (*ss) << "\tiphimin, iphimax " << innerPhimin << " " << innerPhimax << std::endl; #endif - std::unique_ptr checkRZb = region.checkRZ(innerLayerObj.detLayer(), ohit, es); - std::unique_ptr checkRZc = region.checkRZ(innerLayerObj.detLayer(), nohit, es); + std::unique_ptr checkRZb = region.checkRZ(innerLayerObj.detLayer(), ohit); + std::unique_ptr checkRZc = region.checkRZ(innerLayerObj.detLayer(), nohit); /*Loop on inner hits*/ vector::const_iterator ieh = innerHits.end(); diff --git a/RecoTracker/ConversionSeedGenerators/plugins/HitQuadrupletGeneratorFromLayerPairForPhotonConversion.h b/RecoTracker/ConversionSeedGenerators/plugins/HitQuadrupletGeneratorFromLayerPairForPhotonConversion.h index 8c9b67263a4b1..29260c88ca287 100644 --- a/RecoTracker/ConversionSeedGenerators/plugins/HitQuadrupletGeneratorFromLayerPairForPhotonConversion.h +++ b/RecoTracker/ConversionSeedGenerators/plugins/HitQuadrupletGeneratorFromLayerPairForPhotonConversion.h @@ -23,11 +23,7 @@ class HitQuadrupletGeneratorFromLayerPairForPhotonConversion { ~HitQuadrupletGeneratorFromLayerPairForPhotonConversion() {} - void hitPairs(const TrackingRegion ®, - OrderedHitPairs &prs, - const Layers &layers, - const edm::Event &ev, - const edm::EventSetup &es); + void hitPairs(const TrackingRegion ®, OrderedHitPairs &prs, const Layers &layers); bool failCheckRZCompatibility(const RecHitsSortedInPhi::Hit &hit, const DetLayer &layer, diff --git a/RecoTracker/SpecialSeedGenerators/interface/CosmicTrackingRegion.h b/RecoTracker/SpecialSeedGenerators/interface/CosmicTrackingRegion.h index 1cff9b9fc6d4a..a767dce325d55 100644 --- a/RecoTracker/SpecialSeedGenerators/interface/CosmicTrackingRegion.h +++ b/RecoTracker/SpecialSeedGenerators/interface/CosmicTrackingRegion.h @@ -10,7 +10,6 @@ #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionBase.h" #include "RecoTracker/TkTrackingRegions/interface/HitRZConstraint.h" -#include "FWCore/Framework/interface/EventSetup.h" #include "RecoTracker/MeasurementDet/interface/MeasurementTrackerEvent.h" #include "MagneticField/Engine/interface/MagneticField.h" @@ -81,11 +80,10 @@ class CosmicTrackingRegion : public TrackingRegionBase { theMeasurementTracker_(rh.theMeasurementTracker_), theMagneticField_(rh.theMagneticField_) {} - TrackingRegion::Hits hits(const edm::EventSetup& es, const SeedingLayerSetsHits::SeedingLayer& layer) const override; + TrackingRegion::Hits hits(const SeedingLayerSetsHits::SeedingLayer& layer) const override; std::unique_ptr checkRZ(const DetLayer* layer, const Hit& outerHit, - const edm::EventSetup& iSetup, const DetLayer* outerlayer = nullptr, float lr = 0, float gz = 0, @@ -104,7 +102,7 @@ class CosmicTrackingRegion : public TrackingRegionBase { private: template - void hits_(const edm::EventSetup& es, const T& layer, TrackingRegion::Hits& result) const; + void hits_(const T& layer, TrackingRegion::Hits& result) const; const MeasurementTrackerEvent* theMeasurementTracker_; const MagneticField* theMagneticField_; diff --git a/RecoTracker/SpecialSeedGenerators/interface/SimpleCosmicBONSeeder.h b/RecoTracker/SpecialSeedGenerators/interface/SimpleCosmicBONSeeder.h index 99f8ba76f78d4..ec2051908399a 100644 --- a/RecoTracker/SpecialSeedGenerators/interface/SimpleCosmicBONSeeder.h +++ b/RecoTracker/SpecialSeedGenerators/interface/SimpleCosmicBONSeeder.h @@ -47,8 +47,8 @@ class SimpleCosmicBONSeeder : public edm::stream::EDProducer<> { void produce(edm::Event &e, const edm::EventSetup &c) override; void init(const edm::EventSetup &c); - bool triplets(const edm::Event &e, const edm::EventSetup &c); - bool seeds(TrajectorySeedCollection &output, const edm::EventSetup &iSetup); + bool triplets(const edm::Event &e); + bool seeds(TrajectorySeedCollection &output); void done(); bool goodTriplet(const GlobalPoint &inner, @@ -58,12 +58,9 @@ class SimpleCosmicBONSeeder : public edm::stream::EDProducer<> { std::pair pqFromHelixFit(const GlobalPoint &inner, const GlobalPoint &middle, - const GlobalPoint &outer, - const edm::EventSetup &iSetup) const; + const GlobalPoint &outer) const; private: - edm::ParameterSet conf_; - const edm::EDGetTokenT seedingLayerToken_; const edm::ESGetToken magfieldToken_; const edm::ESGetToken trackerToken_; diff --git a/RecoTracker/SpecialSeedGenerators/src/BeamHaloPairGenerator.cc b/RecoTracker/SpecialSeedGenerators/src/BeamHaloPairGenerator.cc index 2f5b387d7093d..1829be6e4e900 100644 --- a/RecoTracker/SpecialSeedGenerators/src/BeamHaloPairGenerator.cc +++ b/RecoTracker/SpecialSeedGenerators/src/BeamHaloPairGenerator.cc @@ -23,8 +23,8 @@ const OrderedSeedingHits& BeamHaloPairGenerator::run(const TrackingRegion& regio throw cms::Exception("CtfSpecialSeedGenerator") << "You are using " << layers.numberOfLayersInSet() << " layers in set instead of 2 "; for (SeedingLayerSetsHits::SeedingLayerSet ls : layers) { - auto innerHits = region.hits(es, ls[0]); - auto outerHits = region.hits(es, ls[1]); + auto innerHits = region.hits(ls[0]); + auto outerHits = region.hits(ls[1]); for (auto iOuterHit = outerHits.begin(); iOuterHit != outerHits.end(); iOuterHit++) { for (auto iInnerHit = innerHits.begin(); iInnerHit != innerHits.end(); iInnerHit++) { diff --git a/RecoTracker/SpecialSeedGenerators/src/CosmicTrackingRegion.cc b/RecoTracker/SpecialSeedGenerators/src/CosmicTrackingRegion.cc index fa17c7d50dbea..98abfbbcce720 100644 --- a/RecoTracker/SpecialSeedGenerators/src/CosmicTrackingRegion.cc +++ b/RecoTracker/SpecialSeedGenerators/src/CosmicTrackingRegion.cc @@ -46,15 +46,14 @@ void CosmicTrackingRegion::checkTracks(reco::TrackCollection const& tracks, std: } } -TrackingRegion::Hits CosmicTrackingRegion::hits(const edm::EventSetup& es, - const SeedingLayerSetsHits::SeedingLayer& layer) const { +TrackingRegion::Hits CosmicTrackingRegion::hits(const SeedingLayerSetsHits::SeedingLayer& layer) const { TrackingRegion::Hits result; - hits_(es, layer, result); + hits_(layer, result); return result; } template -void CosmicTrackingRegion::hits_(const edm::EventSetup& es, const T& layer, TrackingRegion::Hits& result) const { +void CosmicTrackingRegion::hits_(const T& layer, TrackingRegion::Hits& result) const { //get and name collections //++++++++++++++++++++++++ diff --git a/RecoTracker/SpecialSeedGenerators/src/GenericPairGenerator.cc b/RecoTracker/SpecialSeedGenerators/src/GenericPairGenerator.cc index 5aa2e2c74ef1f..7ab9404fb547a 100644 --- a/RecoTracker/SpecialSeedGenerators/src/GenericPairGenerator.cc +++ b/RecoTracker/SpecialSeedGenerators/src/GenericPairGenerator.cc @@ -24,8 +24,8 @@ const OrderedSeedingHits& GenericPairGenerator::run(const TrackingRegion& region << "You are using " << layers.numberOfLayersInSet() << " layers in set instead of 2 "; for (SeedingLayerSetsHits::SeedingLayerSet ls : layers) { - auto innerHits = region.hits(es, ls[0]); - auto outerHits = region.hits(es, ls[1]); + auto innerHits = region.hits(ls[0]); + auto outerHits = region.hits(ls[1]); for (auto iOuterHit = outerHits.begin(); iOuterHit != outerHits.end(); iOuterHit++) { for (auto iInnerHit = innerHits.begin(); iInnerHit != innerHits.end(); iInnerHit++) { hitPairs.push_back(OrderedHitPair(&(**iInnerHit), &(**iOuterHit))); diff --git a/RecoTracker/SpecialSeedGenerators/src/GenericTripletGenerator.cc b/RecoTracker/SpecialSeedGenerators/src/GenericTripletGenerator.cc index a1a10424afdbf..5262256b23e91 100644 --- a/RecoTracker/SpecialSeedGenerators/src/GenericTripletGenerator.cc +++ b/RecoTracker/SpecialSeedGenerators/src/GenericTripletGenerator.cc @@ -24,11 +24,11 @@ const OrderedSeedingHits& GenericTripletGenerator::run(const TrackingRegion& reg << "You are using " << layers.numberOfLayersInSet() << " layers in set instead of 3 "; std::map radius_triplet_map; for (SeedingLayerSetsHits::SeedingLayerSet ls : layers) { - auto innerHits = region.hits(es, ls[0]); + auto innerHits = region.hits(ls[0]); //std::cout << "innerHits.size()=" << innerHits.size() << std::endl; - auto middleHits = region.hits(es, ls[1]); + auto middleHits = region.hits(ls[1]); //std::cout << "middleHits.size()=" << middleHits.size() << std::endl; - auto outerHits = region.hits(es, ls[2]); + auto outerHits = region.hits(ls[2]); //std::cout << "outerHits.size()=" << outerHits.size() << std::endl; //std::cout << "trying " << innerHits.size()*middleHits.size()*outerHits.size() << " combinations "<(conf.getParameter("TripletsSrc"))), + : seedingLayerToken_(consumes(conf.getParameter("TripletsSrc"))), magfieldToken_(esConsumes()), trackerToken_(esConsumes()), - ttrhBuilderToken_(esConsumes(edm::ESInputTag("", conf_.getParameter("TTRHBuilder")))), + ttrhBuilderToken_(esConsumes(edm::ESInputTag("", conf.getParameter("TTRHBuilder")))), writeTriplets_(conf.getParameter("writeTriplets")), seedOnMiddle_(conf.existsAs("seedOnMiddle") ? conf.getParameter("seedOnMiddle") : false), rescaleError_(conf.existsAs("rescaleError") ? conf.getParameter("rescaleError") : 1.0), @@ -37,7 +36,7 @@ SimpleCosmicBONSeeder::SimpleCosmicBONSeeder(edm::ParameterSet const &conf) check_(conf.getParameter("ClusterCheckPSet"), consumesCollector()), maxTriplets_(conf.getParameter("maxTriplets")), maxSeeds_(conf.getParameter("maxSeeds")) { - edm::ParameterSet regionConf = conf_.getParameter("RegionPSet"); + edm::ParameterSet regionConf = conf.getParameter("RegionPSet"); float ptmin = regionConf.getParameter("ptMin"); float originradius = regionConf.getParameter("originRadius"); float halflength = regionConf.getParameter("originHalfLength"); @@ -46,8 +45,8 @@ SimpleCosmicBONSeeder::SimpleCosmicBONSeeder(edm::ParameterSet const &conf) pMin_ = regionConf.getParameter("pMin"); //***top-bottom - positiveYOnly = conf_.getParameter("PositiveYOnly"); - negativeYOnly = conf_.getParameter("NegativeYOnly"); + positiveYOnly = conf.getParameter("PositiveYOnly"); + negativeYOnly = conf.getParameter("NegativeYOnly"); //*** produces(); @@ -98,9 +97,9 @@ void SimpleCosmicBONSeeder::produce(edm::Event &ev, const edm::EventSetup &es) { edm::LogError("TooManyClusters") << "Found too many clusters (" << clustsOrZero << "), bailing out.\n"; } else { init(es); - bool tripletsOk = triplets(ev, es); + bool tripletsOk = triplets(ev); if (tripletsOk) { - bool seedsOk = seeds(*output, es); + bool seedsOk = seeds(*output); if (!seedsOk) { } @@ -168,7 +167,7 @@ struct HigherInnerHit { } }; -bool SimpleCosmicBONSeeder::triplets(const edm::Event &e, const edm::EventSetup &es) { +bool SimpleCosmicBONSeeder::triplets(const edm::Event &e) { hitTriplets.clear(); hitTriplets.reserve(0); edm::Handle hlayers; @@ -183,9 +182,9 @@ bool SimpleCosmicBONSeeder::triplets(const edm::Event &e, const edm::EventSetup for (SeedingLayerSetsHits::LayerSetIndex layerIndex = 0; layerIndex < layers.size(); ++layerIndex) { SeedingLayerSetsHits::SeedingLayerSet ls = layers[layerIndex]; /// ctfseeding SeedinHits and their iterators - auto innerHits = region_.hits(es, ls[0]); - auto middleHits = region_.hits(es, ls[1]); - auto outerHits = region_.hits(es, ls[2]); + auto innerHits = region_.hits(ls[0]); + auto middleHits = region_.hits(ls[1]); + auto outerHits = region_.hits(ls[2]); if (tripletsVerbosity_ > 0) { std::cout << "GenericTripletGenerator iLss = " << seedingLayersToString(ls) << " (" << layerIndex @@ -291,7 +290,7 @@ bool SimpleCosmicBONSeeder::triplets(const edm::Event &e, const edm::EventSetup << " + " << outerpos << std::endl; } if (tripletsVerbosity_ > 3 && (helixVerbosity_ > 0)) { // debug the momentum here too - pqFromHelixFit(innerpos, middlepos, outerpos, es); + pqFromHelixFit(innerpos, middlepos, outerpos); } } } @@ -402,8 +401,7 @@ bool SimpleCosmicBONSeeder::goodTriplet(const GlobalPoint &inner, std::pair SimpleCosmicBONSeeder::pqFromHelixFit(const GlobalPoint &inner, const GlobalPoint &middle, - const GlobalPoint &outer, - const edm::EventSetup &iSetup) const { + const GlobalPoint &outer) const { if (helixVerbosity_ > 0) { std::cout << "DEBUG PZ =====" << std::endl; FastHelix helix(inner, middle, outer, magfield->nominalValue(), &*magfield); @@ -453,7 +451,7 @@ std::pair SimpleCosmicBONSeeder::pqFromHelixFit(const GlobalP return mypq; } -bool SimpleCosmicBONSeeder::seeds(TrajectorySeedCollection &output, const edm::EventSetup &iSetup) { +bool SimpleCosmicBONSeeder::seeds(TrajectorySeedCollection &output) { typedef TrajectoryStateOnSurface TSOS; for (size_t it = 0; it < hitTriplets.size(); it++) { @@ -483,7 +481,7 @@ bool SimpleCosmicBONSeeder::seeds(TrajectorySeedCollection &output, const edm::E } // First use FastHelix out of the box - std::pair pq = pqFromHelixFit(inner, middle, outer, iSetup); + std::pair pq = pqFromHelixFit(inner, middle, outer); GlobalVector gv = pq.first; float ch = pq.second; float Mom = sqrt(gv.x() * gv.x() + gv.y() * gv.y() + gv.z() * gv.z()); diff --git a/RecoTracker/TkHitPairs/interface/LayerHitMapCache.h b/RecoTracker/TkHitPairs/interface/LayerHitMapCache.h index 0ebd41fbf6259..02e6c4cac489b 100644 --- a/RecoTracker/TkHitPairs/interface/LayerHitMapCache.h +++ b/RecoTracker/TkHitPairs/interface/LayerHitMapCache.h @@ -77,15 +77,13 @@ class LayerHitMapCache { return ptr; } - const RecHitsSortedInPhi& operator()(const SeedingLayerSetsHits::SeedingLayer& layer, - const TrackingRegion& region, - const edm::EventSetup& iSetup) { + const RecHitsSortedInPhi& operator()(const SeedingLayerSetsHits::SeedingLayer& layer, const TrackingRegion& region) { int key = layer.index(); assert(key >= 0); const RecHitsSortedInPhi* lhm = theCache.get(key); if (lhm == nullptr) { - auto tmp = add( - layer, std::make_unique(region.hits(iSetup, layer), region.origin(), layer.detLayer())); + auto tmp = + add(layer, std::make_unique(region.hits(layer), region.origin(), layer.detLayer())); tmp->theOrigin = region.origin(); lhm = tmp; LogDebug("LayerHitMapCache") << " I got" << lhm->all().second - lhm->all().first diff --git a/RecoTracker/TkHitPairs/src/HitPairGeneratorFromLayerPair.cc b/RecoTracker/TkHitPairs/src/HitPairGeneratorFromLayerPair.cc index e2757c4b6bafa..0434e4db856bb 100644 --- a/RecoTracker/TkHitPairs/src/HitPairGeneratorFromLayerPair.cc +++ b/RecoTracker/TkHitPairs/src/HitPairGeneratorFromLayerPair.cc @@ -92,11 +92,11 @@ HitDoublets HitPairGeneratorFromLayerPair::doublets(const TrackingRegion& region const Layer& innerLayer, const Layer& outerLayer, LayerCacheType& layerCache) { - const RecHitsSortedInPhi& innerHitsMap = layerCache(innerLayer, region, iSetup); + const RecHitsSortedInPhi& innerHitsMap = layerCache(innerLayer, region); if (innerHitsMap.empty()) return HitDoublets(innerHitsMap, innerHitsMap); - const RecHitsSortedInPhi& outerHitsMap = layerCache(outerLayer, region, iSetup); + const RecHitsSortedInPhi& outerHitsMap = layerCache(outerLayer, region); if (outerHitsMap.empty()) return HitDoublets(innerHitsMap, outerHitsMap); HitDoublets result(innerHitsMap, outerHitsMap); @@ -140,7 +140,6 @@ void HitPairGeneratorFromLayerPair::doublets(const TrackingRegion& region, std::unique_ptr checkRZ = region.checkRZ(&innerHitDetLayer, ohit, - iSetup, &outerHitDetLayer, outerHitsMap.rv(io), outerHitsMap.z[io], diff --git a/RecoTracker/TkSeedGenerator/interface/MultiHitGeneratorFromPairAndLayers.h b/RecoTracker/TkSeedGenerator/interface/MultiHitGeneratorFromPairAndLayers.h index 78df55143d9cf..7b100c69c79df 100644 --- a/RecoTracker/TkSeedGenerator/interface/MultiHitGeneratorFromPairAndLayers.h +++ b/RecoTracker/TkSeedGenerator/interface/MultiHitGeneratorFromPairAndLayers.h @@ -43,7 +43,6 @@ class MultiHitGeneratorFromPairAndLayers { virtual void hitTriplets(const TrackingRegion& region, OrderedMultiHits& result, - const edm::EventSetup& es, const HitDoublets& doublets, const RecHitsSortedInPhi** thirdHitMap, const std::vector& thirdLayerDetLayer, diff --git a/RecoTracker/TkSeedGenerator/plugins/MultiHitFromChi2EDProducer.cc b/RecoTracker/TkSeedGenerator/plugins/MultiHitFromChi2EDProducer.cc index 69cb5dc6ae325..3385be3523457 100644 --- a/RecoTracker/TkSeedGenerator/plugins/MultiHitFromChi2EDProducer.cc +++ b/RecoTracker/TkSeedGenerator/plugins/MultiHitFromChi2EDProducer.cc @@ -118,8 +118,7 @@ void MultiHitFromChi2EDProducer::produce(edm::Event& iEvent, const edm::EventSet } const auto& thirdLayers = found->second; - generator_.hitSets( - region, multihits, iEvent, iSetup, layerPair.doublets(), thirdLayers, hitCache, refittedHitStorage); + generator_.hitSets(region, multihits, layerPair.doublets(), thirdLayers, hitCache, refittedHitStorage); #ifdef EDM_ML_DEBUG LogTrace("MultiHitFromChi2EDProducer") diff --git a/RecoTracker/TkSeedGenerator/plugins/MultiHitGeneratorFromChi2.cc b/RecoTracker/TkSeedGenerator/plugins/MultiHitGeneratorFromChi2.cc index 19113d6b7c0b5..274e1a211b49d 100644 --- a/RecoTracker/TkSeedGenerator/plugins/MultiHitGeneratorFromChi2.cc +++ b/RecoTracker/TkSeedGenerator/plugins/MultiHitGeneratorFromChi2.cc @@ -180,13 +180,11 @@ void MultiHitGeneratorFromChi2::hitSets(const TrackingRegion& region, } assert(theLayerCache); - hitSets(region, result, ev, es, doublets, thirdLayers, *theLayerCache, cache); + hitSets(region, result, doublets, thirdLayers, *theLayerCache, cache); } void MultiHitGeneratorFromChi2::hitSets(const TrackingRegion& region, OrderedMultiHits& result, - const edm::Event& ev, - const edm::EventSetup& es, const HitDoublets& doublets, const std::vector& thirdLayers, LayerCacheType& layerCache, @@ -195,26 +193,24 @@ void MultiHitGeneratorFromChi2::hitSets(const TrackingRegion& region, const RecHitsSortedInPhi* thirdHitMap[size]; vector thirdLayerDetLayer(size, nullptr); for (int il = 0; il < size; ++il) { - thirdHitMap[il] = &layerCache(thirdLayers[il], region, es); + thirdHitMap[il] = &layerCache(thirdLayers[il], region); thirdLayerDetLayer[il] = thirdLayers[il].detLayer(); } - hitSets(region, result, es, doublets, thirdHitMap, thirdLayerDetLayer, size, refittedHitStorage); + hitSets(region, result, doublets, thirdHitMap, thirdLayerDetLayer, size, refittedHitStorage); } void MultiHitGeneratorFromChi2::hitTriplets(const TrackingRegion& region, OrderedMultiHits& result, - const edm::EventSetup& es, const HitDoublets& doublets, const RecHitsSortedInPhi** thirdHitMap, const std::vector& thirdLayerDetLayer, const int nThirdLayers) { - hitSets(region, result, es, doublets, thirdHitMap, thirdLayerDetLayer, nThirdLayers, cache); + hitSets(region, result, doublets, thirdHitMap, thirdLayerDetLayer, nThirdLayers, cache); } void MultiHitGeneratorFromChi2::hitSets(const TrackingRegion& region, OrderedMultiHits& result, - const edm::EventSetup& es, const HitDoublets& doublets, const RecHitsSortedInPhi** thirdHitMap, const std::vector& thirdLayerDetLayer, diff --git a/RecoTracker/TkSeedGenerator/plugins/MultiHitGeneratorFromChi2.h b/RecoTracker/TkSeedGenerator/plugins/MultiHitGeneratorFromChi2.h index 0745265712ccd..35bb6dff11967 100644 --- a/RecoTracker/TkSeedGenerator/plugins/MultiHitGeneratorFromChi2.h +++ b/RecoTracker/TkSeedGenerator/plugins/MultiHitGeneratorFromChi2.h @@ -57,8 +57,6 @@ class dso_hidden MultiHitGeneratorFromChi2 final : public MultiHitGeneratorFromP void hitSets(const TrackingRegion& region, OrderedMultiHits& trs, - const edm::Event& ev, - const edm::EventSetup& es, const HitDoublets& doublets, const std::vector& thirdLayers, LayerCacheType& layerCache, @@ -66,7 +64,6 @@ class dso_hidden MultiHitGeneratorFromChi2 final : public MultiHitGeneratorFromP void hitTriplets(const TrackingRegion& region, OrderedMultiHits& result, - const edm::EventSetup& es, const HitDoublets& doublets, const RecHitsSortedInPhi** thirdHitMap, const std::vector& thirdLayerDetLayer, @@ -74,7 +71,6 @@ class dso_hidden MultiHitGeneratorFromChi2 final : public MultiHitGeneratorFromP void hitSets(const TrackingRegion& region, OrderedMultiHits& result, - const edm::EventSetup& es, const HitDoublets& doublets, const RecHitsSortedInPhi** thirdHitMap, const std::vector& thirdLayerDetLayer, diff --git a/RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h b/RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h index ff9d805cfede0..7aec7df3e91f3 100644 --- a/RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h +++ b/RecoTracker/TkTrackingRegions/interface/GlobalTrackingRegion.h @@ -46,11 +46,10 @@ class GlobalTrackingRegion final : public TrackingRegion { originHalfLength), thePrecise(precise) {} - TrackingRegion::Hits hits(const edm::EventSetup& es, const SeedingLayerSetsHits::SeedingLayer& layer) const override; + TrackingRegion::Hits hits(const SeedingLayerSetsHits::SeedingLayer& layer) const override; std::unique_ptr checkRZ(const DetLayer* layer, const Hit& outerHit, - const edm::EventSetup& iSetup, const DetLayer* outerlayer = nullptr, float lr = 0, float gz = 0, diff --git a/RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h b/RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h index 835e6f57b2d23..a0c5bd701f6db 100644 --- a/RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h +++ b/RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h @@ -12,7 +12,6 @@ #include "RecoTracker/TkTrackingRegions/interface/TkTrackingRegionsMargin.h" //#include "CommonDet/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h" #include "RecoTracker/TkTrackingRegions/interface/HitRZConstraint.h" -#include "FWCore/Framework/interface/EventSetup.h" #include "DataFormats/TrackerRecHit2D/interface/BaseTrackerRecHit.h" #include "DataFormats/TrackingRecHit/interface/mayown_ptr.h" @@ -189,7 +188,7 @@ class RectangularEtaPhiTrackingRegion final : public TrackingRegion { /// is precise error calculation switched on bool isPrecise() const { return thePrecise; } - TrackingRegion::Hits hits(const edm::EventSetup& es, const SeedingLayerSetsHits::SeedingLayer& layer) const override; + TrackingRegion::Hits hits(const SeedingLayerSetsHits::SeedingLayer& layer) const override; /// Set the elements of the mask corresponding to the tracks that are compatable with the region. /// Does not reset the elements corresponding to the tracks that are not compatible. @@ -197,13 +196,12 @@ class RectangularEtaPhiTrackingRegion final : public TrackingRegion { std::unique_ptr checkRZ(const DetLayer* layer, const Hit& outerHit, - const edm::EventSetup& iSetup, const DetLayer* outerlayer = nullptr, float lr = 0, float gz = 0, float dr = 0, float dz = 0) const override { - return checkRZOld(layer, outerHit, iSetup, outerlayer); + return checkRZOld(layer, outerHit, outerlayer); } std::unique_ptr clone() const override { @@ -216,13 +214,10 @@ class RectangularEtaPhiTrackingRegion final : public TrackingRegion { private: std::unique_ptr checkRZOld(const DetLayer* layer, const Hit& outerHit, - const edm::EventSetup& iSetup, const DetLayer* outerlayer) const; - std::unique_ptr estimator(const BarrelDetLayer* layer, - const edm::EventSetup& iSetup) const dso_internal; - std::unique_ptr estimator(const ForwardDetLayer* layer, - const edm::EventSetup& iSetup) const dso_internal; + std::unique_ptr estimator(const BarrelDetLayer* layer) const dso_internal; + std::unique_ptr estimator(const ForwardDetLayer* layer) const dso_internal; OuterHitPhiPrediction phiWindow(const MagneticField& field) const dso_internal; HitRZConstraint rzConstraint() const dso_internal; diff --git a/RecoTracker/TkTrackingRegions/interface/TrackingRegion.h b/RecoTracker/TkTrackingRegions/interface/TrackingRegion.h index 10ad64e2110aa..3d2d7673fe84f 100644 --- a/RecoTracker/TkTrackingRegions/interface/TrackingRegion.h +++ b/RecoTracker/TkTrackingRegions/interface/TrackingRegion.h @@ -16,7 +16,6 @@ #include "RecoTracker/TkTrackingRegions/interface/HitRCheck.h" #include "RecoTracker/TkTrackingRegions/interface/HitZCheck.h" -#include "FWCore/Framework/interface/EventSetup.h" #include "TrackingTools/TransientTrackingRecHit/interface/SeedingLayerSetsHits.h" #include "DataFormats/TrackReco/interface/Track.h" @@ -89,7 +88,6 @@ class TrackingRegion { /// and outer hit constraint virtual std::unique_ptr checkRZ(const DetLayer* layer, const Hit& outerHit, - const edm::EventSetup& iSetup, const DetLayer* outerlayer = nullptr, float lr = 0, float gz = 0, @@ -97,7 +95,7 @@ class TrackingRegion { float dz = 0) const = 0; /// get hits from layer compatible with region constraints - virtual Hits hits(const edm::EventSetup& es, const SeedingLayerSetsHits::SeedingLayer& layer) const = 0; + virtual Hits hits(const SeedingLayerSetsHits::SeedingLayer& layer) const = 0; /// Set the elements of the mask corresponding to the tracks that are compatable with the region. /// Does not reset the elements corresponding to the tracks that are not compatible. diff --git a/RecoTracker/TkTrackingRegions/src/GlobalTrackingRegion.cc b/RecoTracker/TkTrackingRegions/src/GlobalTrackingRegion.cc index f151070e83435..4317844608e04 100644 --- a/RecoTracker/TkTrackingRegions/src/GlobalTrackingRegion.cc +++ b/RecoTracker/TkTrackingRegions/src/GlobalTrackingRegion.cc @@ -24,14 +24,12 @@ std::string GlobalTrackingRegion::print() const { return str.str(); } -TrackingRegion::Hits GlobalTrackingRegion::hits(const edm::EventSetup& es, - const SeedingLayerSetsHits::SeedingLayer& layer) const { +TrackingRegion::Hits GlobalTrackingRegion::hits(const SeedingLayerSetsHits::SeedingLayer& layer) const { return layer.hits(); } std::unique_ptr GlobalTrackingRegion::checkRZ(const DetLayer* layer, const Hit& outerHit, - const edm::EventSetup& iSetup, const DetLayer* outerlayer, float lr, float gz, diff --git a/RecoTracker/TkTrackingRegions/src/RectangularEtaPhiTrackingRegion.cc b/RecoTracker/TkTrackingRegions/src/RectangularEtaPhiTrackingRegion.cc index f096d576f7ea1..715c4c3fe24bc 100644 --- a/RecoTracker/TkTrackingRegions/src/RectangularEtaPhiTrackingRegion.cc +++ b/RecoTracker/TkTrackingRegions/src/RectangularEtaPhiTrackingRegion.cc @@ -99,7 +99,6 @@ void RectangularEtaPhiTrackingRegion::initEtaRange(const GlobalVector& dir, cons std::unique_ptr RectangularEtaPhiTrackingRegion::checkRZOld(const DetLayer* layer, const Hit& outerHit, - const edm::EventSetup& iSetup, const DetLayer* outerlayer) const { bool isBarrel = (layer->location() == GeomDetEnumerators::barrel); GlobalPoint ohit = outerHit->globalPosition(); @@ -166,8 +165,7 @@ std::unique_ptr RectangularEtaPhiTrackingRegion::checkRZOld( } } -std::unique_ptr RectangularEtaPhiTrackingRegion::estimator(const BarrelDetLayer* layer, - const edm::EventSetup& iSetup) const { +std::unique_ptr RectangularEtaPhiTrackingRegion::estimator(const BarrelDetLayer* layer) const { using Algo = HitZCheck; // det dimensions @@ -226,8 +224,7 @@ std::unique_ptr RectangularEtaPhiTrackingRegion::estimator OuterHitCompatibility(phiPrediction, zPrediction)); } -std::unique_ptr RectangularEtaPhiTrackingRegion::estimator(const ForwardDetLayer* layer, - const edm::EventSetup& iSetup) const { +std::unique_ptr RectangularEtaPhiTrackingRegion::estimator(const ForwardDetLayer* layer) const { using Algo = HitRCheck; // det dimensions, ranges float halfThickness = 0.5f * layer->surface().bounds().thickness(); @@ -307,8 +304,7 @@ HitRZConstraint RectangularEtaPhiTrackingRegion::rzConstraint() const { return HitRZConstraint(pLeft, theLambdaRange.min(), pRight, theLambdaRange.max()); } -TrackingRegion::Hits RectangularEtaPhiTrackingRegion::hits(const edm::EventSetup& es, - const SeedingLayerSetsHits::SeedingLayer& layer) const { +TrackingRegion::Hits RectangularEtaPhiTrackingRegion::hits(const SeedingLayerSetsHits::SeedingLayer& layer) const { TrackingRegion::Hits result; //ESTIMATOR @@ -331,12 +327,12 @@ TrackingRegion::Hits RectangularEtaPhiTrackingRegion::hits(const edm::EventSetup GeomDetEnumerators::isBarrel(detLayer->subDetector())) || (!theUseEtaPhi && detLayer->location() == GeomDetEnumerators::barrel)) { const BarrelDetLayer& bl = dynamic_cast(*detLayer); - est = estimator(&bl, es); + est = estimator(&bl); } else if ((GeomDetEnumerators::isTrackerPixel(detLayer->subDetector()) && GeomDetEnumerators::isEndcap(detLayer->subDetector())) || (!theUseEtaPhi && detLayer->location() == GeomDetEnumerators::endcap)) { const ForwardDetLayer& fl = dynamic_cast(*detLayer); - est = estimator(&fl, es); + est = estimator(&fl); } EtaPhiMeasurementEstimator etaPhiEstimator((theEtaRange.second - theEtaRange.first) * 0.5f, @@ -383,7 +379,7 @@ TrackingRegion::Hits RectangularEtaPhiTrackingRegion::hits(const edm::EventSetup // if (detLayer->location() == GeomDetEnumerators::barrel) { const BarrelDetLayer& bl = dynamic_cast(*detLayer); - auto est = estimator(&bl, es); + auto est = estimator(&bl); if (!est) return result; using Algo = HitZCheck; @@ -397,7 +393,7 @@ TrackingRegion::Hits RectangularEtaPhiTrackingRegion::hits(const edm::EventSetup } else { const ForwardDetLayer& fl = dynamic_cast(*detLayer); - auto est = estimator(&fl, es); + auto est = estimator(&fl); if (!est) return result; using Algo = HitRCheck; From ef18849e5c41f2dca5076c87a0d20eef42fa8ad8 Mon Sep 17 00:00:00 2001 From: Matti Kortelainen Date: Fri, 24 Sep 2021 18:02:03 +0200 Subject: [PATCH 6/6] Finish esConsumes migratoin for HitPairGeneratorFromLayerPair --- .../Tracking/interface/SeedFinderSelector.h | 8 +++++ .../Tracking/src/SeedFinderSelector.cc | 20 +++++++---- .../plugins/CombinedHitTripletGenerator.cc | 2 +- .../interface/CombinedHitPairGenerator.h | 2 -- .../interface/HitPairGeneratorFromLayerPair.h | 13 +++++-- .../TkHitPairs/plugins/HitPairEDProducer.cc | 23 ++++++------ .../src/CombinedHitPairGenerator.cc | 9 +---- .../src/HitPairGeneratorFromLayerPair.cc | 36 +++++++++++-------- .../plugins/CombinedMultiHitGenerator.cc | 2 +- 9 files changed, 69 insertions(+), 46 deletions(-) diff --git a/FastSimulation/Tracking/interface/SeedFinderSelector.h b/FastSimulation/Tracking/interface/SeedFinderSelector.h index 2b472ba8ab492..d3a5331e7fce5 100644 --- a/FastSimulation/Tracking/interface/SeedFinderSelector.h +++ b/FastSimulation/Tracking/interface/SeedFinderSelector.h @@ -21,6 +21,10 @@ class MultiHitGeneratorFromPairAndLayers; class HitTripletGeneratorFromPairAndLayers; class CAHitTripletGenerator; class CAHitQuadrupletGenerator; +class IdealMagneticFieldRecord; +class MagneticField; +class MultipleScatteringParametrisationMaker; +class TrackerMultipleScatteringRecord; class SeedFinderSelector { public: @@ -45,7 +49,11 @@ class SeedFinderSelector { const std::string measurementTrackerLabel_; const edm::ESGetToken measurementTrackerESToken_; const edm::ESGetToken trackerTopologyESToken_; + const edm::ESGetToken fieldESToken_; + const edm::ESGetToken msMakerESToken_; const TrackerTopology* trackerTopology_ = nullptr; + const MagneticField* field_ = nullptr; + const MultipleScatteringParametrisationMaker* msmaker_ = nullptr; std::unique_ptr CAHitTriplGenerator_; std::unique_ptr CAHitQuadGenerator_; std::unique_ptr seedingLayers_; diff --git a/FastSimulation/Tracking/src/SeedFinderSelector.cc b/FastSimulation/Tracking/src/SeedFinderSelector.cc index cdf17b45b2a74..db3d124ca19f4 100644 --- a/FastSimulation/Tracking/src/SeedFinderSelector.cc +++ b/FastSimulation/Tracking/src/SeedFinderSelector.cc @@ -17,6 +17,8 @@ #include "RecoPixelVertexing/PixelTriplets/interface/CAHitQuadrupletGenerator.h" #include "RecoPixelVertexing/PixelTriplets/interface/OrderedHitSeeds.h" #include "RecoTracker/TkHitPairs/interface/IntermediateHitDoublets.h" +#include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" +#include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" // data formats #include "DataFormats/TrackerRecHit2D/interface/FastTrackerRecHit.h" @@ -26,7 +28,9 @@ SeedFinderSelector::SeedFinderSelector(const edm::ParameterSet &cfg, edm::Consum measurementTracker_(nullptr), measurementTrackerLabel_(cfg.getParameter("measurementTracker")), measurementTrackerESToken_(consumesCollector.esConsumes(edm::ESInputTag("", measurementTrackerLabel_))), - trackerTopologyESToken_(consumesCollector.esConsumes()) { + trackerTopologyESToken_(consumesCollector.esConsumes()), + fieldESToken_(consumesCollector.esConsumes()), + msMakerESToken_(consumesCollector.esConsumes()) { if (cfg.exists("pixelTripletGeneratorFactory")) { const edm::ParameterSet &tripletConfig = cfg.getParameter("pixelTripletGeneratorFactory"); pixelTripletGenerator_ = HitTripletGeneratorFromPairAndLayersFactory::get()->create( @@ -80,6 +84,8 @@ void SeedFinderSelector::initEvent(const edm::Event &ev, const edm::EventSetup & measurementTracker_ = &es.getData(measurementTrackerESToken_); trackerTopology_ = &es.getData(trackerTopologyESToken_); + field_ = &es.getData(fieldESToken_); + msmaker_ = &es.getData(msMakerESToken_); if (multiHitGenerator_) { multiHitGenerator_->initES(es); @@ -124,7 +130,7 @@ bool SeedFinderSelector::pass(const std::vector &hits HitDoublets result(fhm, shm); HitPairGeneratorFromLayerPair::doublets( - *trackingRegion_, *firstLayer, *secondLayer, fhm, shm, *eventSetup_, 0, result); + *trackingRegion_, *firstLayer, *secondLayer, fhm, shm, *field_, *msmaker_, 0, result); if (result.empty()) { return false; @@ -208,13 +214,13 @@ bool SeedFinderSelector::pass(const std::vector &hits pairCandidate1[1], std::make_unique(sHits, trackingRegion_->origin(), sLayer)); HitDoublets res1(firsthm, secondhm); HitPairGeneratorFromLayerPair::doublets( - *trackingRegion_, *fLayer, *sLayer, firsthm, secondhm, *eventSetup_, 0, res1); + *trackingRegion_, *fLayer, *sLayer, firsthm, secondhm, *field_, *msmaker_, 0, res1); filler.addDoublets(pairCandidate1, std::move(res1)); const RecHitsSortedInPhi &thirdhm = *layerCache.add( pairCandidate2[1], std::make_unique(tHits, trackingRegion_->origin(), tLayer)); HitDoublets res2(secondhm, thirdhm); HitPairGeneratorFromLayerPair::doublets( - *trackingRegion_, *sLayer, *tLayer, secondhm, thirdhm, *eventSetup_, 0, res2); + *trackingRegion_, *sLayer, *tLayer, secondhm, thirdhm, *field_, *msmaker_, 0, res2); filler.addDoublets(pairCandidate2, std::move(res2)); std::vector tripletresult; @@ -289,19 +295,19 @@ bool SeedFinderSelector::pass(const std::vector &hits pairCandidate1[1], std::make_unique(sHits, trackingRegion_->origin(), sLayer)); HitDoublets res1(firsthm, secondhm); HitPairGeneratorFromLayerPair::doublets( - *trackingRegion_, *fLayer, *sLayer, firsthm, secondhm, *eventSetup_, 0, res1); + *trackingRegion_, *fLayer, *sLayer, firsthm, secondhm, *field_, *msmaker_, 0, res1); filler.addDoublets(pairCandidate1, std::move(res1)); const RecHitsSortedInPhi &thirdhm = *layerCache.add( pairCandidate2[1], std::make_unique(tHits, trackingRegion_->origin(), tLayer)); HitDoublets res2(secondhm, thirdhm); HitPairGeneratorFromLayerPair::doublets( - *trackingRegion_, *sLayer, *tLayer, secondhm, thirdhm, *eventSetup_, 0, res2); + *trackingRegion_, *sLayer, *tLayer, secondhm, thirdhm, *field_, *msmaker_, 0, res2); filler.addDoublets(pairCandidate2, std::move(res2)); const RecHitsSortedInPhi &fourthhm = *layerCache.add( pairCandidate3[1], std::make_unique(frHits, trackingRegion_->origin(), frLayer)); HitDoublets res3(thirdhm, fourthhm); HitPairGeneratorFromLayerPair::doublets( - *trackingRegion_, *tLayer, *frLayer, thirdhm, fourthhm, *eventSetup_, 0, res3); + *trackingRegion_, *tLayer, *frLayer, thirdhm, fourthhm, *field_, *msmaker_, 0, res3); filler.addDoublets(pairCandidate3, std::move(res3)); std::vector quadrupletresult; diff --git a/RecoPixelVertexing/PixelTriplets/plugins/CombinedHitTripletGenerator.cc b/RecoPixelVertexing/PixelTriplets/plugins/CombinedHitTripletGenerator.cc index 52492104f2dfa..2de7427d2e087 100644 --- a/RecoPixelVertexing/PixelTriplets/plugins/CombinedHitTripletGenerator.cc +++ b/RecoPixelVertexing/PixelTriplets/plugins/CombinedHitTripletGenerator.cc @@ -13,7 +13,7 @@ CombinedHitTripletGenerator::CombinedHitTripletGenerator(const edm::ParameterSet edm::ParameterSet generatorPSet = cfg.getParameter("GeneratorPSet"); std::string generatorName = generatorPSet.getParameter("ComponentName"); theGenerator = HitTripletGeneratorFromPairAndLayersFactory::get()->create(generatorName, generatorPSet, iC); - theGenerator->init(std::make_unique(0, 1, &theLayerCache), &theLayerCache); + theGenerator->init(std::make_unique(iC, 0, 1, &theLayerCache), &theLayerCache); } CombinedHitTripletGenerator::~CombinedHitTripletGenerator() {} diff --git a/RecoTracker/TkHitPairs/interface/CombinedHitPairGenerator.h b/RecoTracker/TkHitPairs/interface/CombinedHitPairGenerator.h index df5ef71da4dbf..d10bafa7a5f46 100644 --- a/RecoTracker/TkHitPairs/interface/CombinedHitPairGenerator.h +++ b/RecoTracker/TkHitPairs/interface/CombinedHitPairGenerator.h @@ -37,8 +37,6 @@ class CombinedHitPairGenerator : public HitPairGenerator { const edm::EventSetup& es) override; private: - CombinedHitPairGenerator(const CombinedHitPairGenerator& cb); - edm::EDGetTokenT theSeedingLayerToken; LayerCacheType theLayerCache; diff --git a/RecoTracker/TkHitPairs/interface/HitPairGeneratorFromLayerPair.h b/RecoTracker/TkHitPairs/interface/HitPairGeneratorFromLayerPair.h index c5df7f962298d..01612daede15e 100644 --- a/RecoTracker/TkHitPairs/interface/HitPairGeneratorFromLayerPair.h +++ b/RecoTracker/TkHitPairs/interface/HitPairGeneratorFromLayerPair.h @@ -1,11 +1,16 @@ #ifndef HitPairGeneratorFromLayerPair_h #define HitPairGeneratorFromLayerPair_h +#include "FWCore/Framework/interface/ConsumesCollector.h" #include "RecoTracker/TkHitPairs/interface/OrderedHitPairs.h" #include "RecoTracker/TkHitPairs/interface/LayerHitMapCache.h" #include "TrackingTools/TransientTrackingRecHit/interface/SeedingLayerSetsHits.h" class DetLayer; +class IdealMagneticFieldRecord; +class MagneticField; +class MultipleScatteringParametrisationMaker; +class TrackerMultipleScatteringRecord; class TrackingRegion; class HitPairGeneratorFromLayerPair { @@ -14,7 +19,8 @@ class HitPairGeneratorFromLayerPair { typedef SeedingLayerSetsHits::SeedingLayerSet Layers; typedef SeedingLayerSetsHits::SeedingLayer Layer; - HitPairGeneratorFromLayerPair(unsigned int inner, + HitPairGeneratorFromLayerPair(edm::ConsumesCollector iC, + unsigned int inner, unsigned int outer, LayerCacheType* layerCache, unsigned int max = 0); @@ -56,7 +62,8 @@ class HitPairGeneratorFromLayerPair { const DetLayer& outerHitDetLayer, const RecHitsSortedInPhi& innerHitsMap, const RecHitsSortedInPhi& outerHitsMap, - const edm::EventSetup& iSetup, + const MagneticField& field, + const MultipleScatteringParametrisationMaker& msmaker, const unsigned int theMaxElement, HitDoublets& result); @@ -65,6 +72,8 @@ class HitPairGeneratorFromLayerPair { private: LayerCacheType* theLayerCache; + const edm::ESGetToken theFieldToken; + const edm::ESGetToken theMSMakerToken; const unsigned int theOuterLayer; const unsigned int theInnerLayer; const unsigned int theMaxElement; diff --git a/RecoTracker/TkHitPairs/plugins/HitPairEDProducer.cc b/RecoTracker/TkHitPairs/plugins/HitPairEDProducer.cc index 11f4d513afbba..ef54265376a8d 100644 --- a/RecoTracker/TkHitPairs/plugins/HitPairEDProducer.cc +++ b/RecoTracker/TkHitPairs/plugins/HitPairEDProducer.cc @@ -40,7 +40,7 @@ class HitPairEDProducer : public edm::stream::EDProducer<> { namespace { class ImplBase { public: - ImplBase(const edm::ParameterSet& iConfig); + ImplBase(const edm::ParameterSet& iConfig, edm::ConsumesCollector iC); virtual ~ImplBase() = default; virtual void produces(edm::ProducesCollector) const = 0; @@ -55,10 +55,11 @@ namespace { HitPairGeneratorFromLayerPair generator_; std::vector layerPairBegins_; }; - ImplBase::ImplBase(const edm::ParameterSet& iConfig) + ImplBase::ImplBase(const edm::ParameterSet& iConfig, edm::ConsumesCollector iC) : maxElement_(iConfig.getParameter("maxElement")), maxElementTotal_(iConfig.getParameter("maxElementTotal")), - generator_(0, 1, nullptr, maxElement_), // these indices are dummy, TODO: cleanup HitPairGeneratorFromLayerPair + generator_( + iC, 0, 1, nullptr, maxElement_), // these indices are dummy, TODO: cleanup HitPairGeneratorFromLayerPair layerPairBegins_(iConfig.getParameter>("layerPairs")) { if (layerPairBegins_.empty()) throw cms::Exception("Configuration") @@ -70,8 +71,8 @@ namespace { class Impl : public ImplBase { public: template - Impl(const edm::ParameterSet& iConfig, Args&&... args) - : ImplBase(iConfig), regionsLayers_(&layerPairBegins_, std::forward(args)...) {} + Impl(const edm::ParameterSet& iConfig, edm::ConsumesCollector iC, Args&&... args) + : ImplBase(iConfig, iC), regionsLayers_(&layerPairBegins_, std::forward(args)..., iC) {} ~Impl() override = default; void produces(edm::ProducesCollector producesCollector) const override { @@ -340,7 +341,7 @@ namespace { RegionsLayersSeparate(const std::vector* layerPairBegins, const edm::InputTag& seedingLayerTag, const edm::InputTag& regionTag, - edm::ConsumesCollector&& iC) + edm::ConsumesCollector iC) : layerPairBegins_(layerPairBegins), seedingLayerToken_(iC.consumes(seedingLayerTag)), regionToken_(iC.consumes>(regionTag)) {} @@ -399,7 +400,7 @@ namespace { RegionsLayersTogether(const std::vector* layerPairBegins, const edm::InputTag& regionLayerTag, - edm::ConsumesCollector&& iC) + edm::ConsumesCollector iC) : regionLayerToken_(iC.consumes(regionLayerTag)) { if (layerPairBegins->size() != 1) { throw cms::Exception("LogicError") << "With trackingRegionsSeedingLayers mode, it doesn't make sense to " @@ -456,14 +457,14 @@ HitPairEDProducer::HitPairEDProducer(const edm::ParameterSet& iConfig) { << "Mode 'trackingRegionsSeedingLayers' makes sense only with 'produceSeedingHitsSets', now also " "'produceIntermediateHitDoublets is active"; impl_ = std::make_unique<::Impl<::ImplSeedingHitSets, ::ImplIntermediateHitDoublets, ::RegionsLayersSeparate>>( - iConfig, layersTag, regionTag, consumesCollector()); + iConfig, consumesCollector(), layersTag, regionTag); } else if (produceSeedingHitSets) { if (useRegionLayers) { impl_ = std::make_unique<::Impl<::ImplSeedingHitSets, ::DoNothing, ::RegionsLayersTogether>>( - iConfig, regionLayerTag, consumesCollector()); + iConfig, consumesCollector(), regionLayerTag); } else { impl_ = std::make_unique<::Impl<::ImplSeedingHitSets, ::DoNothing, ::RegionsLayersSeparate>>( - iConfig, layersTag, regionTag, consumesCollector()); + iConfig, consumesCollector(), layersTag, regionTag); } } else if (produceIntermediateHitDoublets) { if (useRegionLayers) @@ -471,7 +472,7 @@ HitPairEDProducer::HitPairEDProducer(const edm::ParameterSet& iConfig) { << "Mode 'trackingRegionsSeedingLayers' makes sense only with 'produceSeedingHitsSets', now " "'produceIntermediateHitDoublets is active instead"; impl_ = std::make_unique<::Impl<::DoNothing, ::ImplIntermediateHitDoublets, ::RegionsLayersSeparate>>( - iConfig, layersTag, regionTag, consumesCollector()); + iConfig, consumesCollector(), layersTag, regionTag); } else throw cms::Exception("Configuration") << "HitPairEDProducer requires either produceIntermediateHitDoublets or produceSeedingHitSets to be True. If " diff --git a/RecoTracker/TkHitPairs/src/CombinedHitPairGenerator.cc b/RecoTracker/TkHitPairs/src/CombinedHitPairGenerator.cc index 57f896ebb6ac5..b6167db1c3159 100644 --- a/RecoTracker/TkHitPairs/src/CombinedHitPairGenerator.cc +++ b/RecoTracker/TkHitPairs/src/CombinedHitPairGenerator.cc @@ -7,14 +7,7 @@ CombinedHitPairGenerator::CombinedHitPairGenerator(const edm::ParameterSet& cfg, edm::ConsumesCollector& iC) : theSeedingLayerToken(iC.consumes(cfg.getParameter("SeedingLayers"))) { theMaxElement = cfg.getParameter("maxElement"); - theGenerator = std::make_unique(0, 1, &theLayerCache, theMaxElement); -} - -CombinedHitPairGenerator::CombinedHitPairGenerator(const CombinedHitPairGenerator& cb) - : HitPairGenerator(cb), - theSeedingLayerToken(cb.theSeedingLayerToken), - theGenerator(std::make_unique(0, 1, &theLayerCache, cb.theMaxElement)) { - theMaxElement = cb.theMaxElement; + theGenerator = std::make_unique(iC, 0, 1, &theLayerCache, theMaxElement); } CombinedHitPairGenerator::~CombinedHitPairGenerator() {} diff --git a/RecoTracker/TkHitPairs/src/HitPairGeneratorFromLayerPair.cc b/RecoTracker/TkHitPairs/src/HitPairGeneratorFromLayerPair.cc index 0434e4db856bb..e01bd012a0e9c 100644 --- a/RecoTracker/TkHitPairs/src/HitPairGeneratorFromLayerPair.cc +++ b/RecoTracker/TkHitPairs/src/HitPairGeneratorFromLayerPair.cc @@ -31,13 +31,15 @@ namespace { #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h" #include "RecoTracker/TkMSParametrization/interface/MultipleScatteringParametrisationMaker.h" #include "RecoTracker/Record/interface/TrackerMultipleScatteringRecord.h" -#include "FWCore/Framework/interface/ESHandle.h" -HitPairGeneratorFromLayerPair::HitPairGeneratorFromLayerPair(unsigned int inner, - unsigned int outer, - LayerCacheType* layerCache, - unsigned int max) - : theLayerCache(layerCache), theOuterLayer(outer), theInnerLayer(inner), theMaxElement(max) {} +HitPairGeneratorFromLayerPair::HitPairGeneratorFromLayerPair( + edm::ConsumesCollector iC, unsigned int inner, unsigned int outer, LayerCacheType* layerCache, unsigned int max) + : theLayerCache(layerCache), + theFieldToken(iC.esConsumes()), + theMSMakerToken(iC.esConsumes()), + theOuterLayer(outer), + theInnerLayer(inner), + theMaxElement(max) {} HitPairGeneratorFromLayerPair::~HitPairGeneratorFromLayerPair() {} @@ -99,10 +101,19 @@ HitDoublets HitPairGeneratorFromLayerPair::doublets(const TrackingRegion& region const RecHitsSortedInPhi& outerHitsMap = layerCache(outerLayer, region); if (outerHitsMap.empty()) return HitDoublets(innerHitsMap, outerHitsMap); + const auto& field = iSetup.getData(theFieldToken); + const auto& msmaker = iSetup.getData(theMSMakerToken); HitDoublets result(innerHitsMap, outerHitsMap); result.reserve(std::max(innerHitsMap.size(), outerHitsMap.size())); - doublets( - region, *innerLayer.detLayer(), *outerLayer.detLayer(), innerHitsMap, outerHitsMap, iSetup, theMaxElement, result); + doublets(region, + *innerLayer.detLayer(), + *outerLayer.detLayer(), + innerHitsMap, + outerHitsMap, + field, + msmaker, + theMaxElement, + result); return result; } @@ -112,16 +123,13 @@ void HitPairGeneratorFromLayerPair::doublets(const TrackingRegion& region, const DetLayer& outerHitDetLayer, const RecHitsSortedInPhi& innerHitsMap, const RecHitsSortedInPhi& outerHitsMap, - const edm::EventSetup& iSetup, + const MagneticField& field, + const MultipleScatteringParametrisationMaker& msmaker, const unsigned int theMaxElement, HitDoublets& result) { // HitDoublets result(innerHitsMap,outerHitsMap); result.reserve(std::max(innerHitsMap.size(),outerHitsMap.size())); typedef RecHitsSortedInPhi::Hit Hit; - edm::ESHandle hfield; - iSetup.get().get(hfield); - edm::ESHandle hmaker; - iSetup.get().get(hmaker); - InnerDeltaPhi deltaPhi(outerHitDetLayer, innerHitDetLayer, region, *hfield, *hmaker); + InnerDeltaPhi deltaPhi(outerHitDetLayer, innerHitDetLayer, region, field, msmaker); // std::cout << "layers " << theInnerLayer.detLayer()->seqNum() << " " << outerLayer.detLayer()->seqNum() << std::endl; diff --git a/RecoTracker/TkSeedGenerator/plugins/CombinedMultiHitGenerator.cc b/RecoTracker/TkSeedGenerator/plugins/CombinedMultiHitGenerator.cc index 37c59a2907b84..a38c6730b4aff 100644 --- a/RecoTracker/TkSeedGenerator/plugins/CombinedMultiHitGenerator.cc +++ b/RecoTracker/TkSeedGenerator/plugins/CombinedMultiHitGenerator.cc @@ -13,7 +13,7 @@ CombinedMultiHitGenerator::CombinedMultiHitGenerator(const edm::ParameterSet& cf edm::ParameterSet generatorPSet = cfg.getParameter("GeneratorPSet"); std::string generatorName = generatorPSet.getParameter("ComponentName"); theGenerator = MultiHitGeneratorFromPairAndLayersFactory::get()->create(generatorName, generatorPSet, iC); - theGenerator->init(std::make_unique(0, 1, &theLayerCache), &theLayerCache); + theGenerator->init(std::make_unique(iC, 0, 1, &theLayerCache), &theLayerCache); } CombinedMultiHitGenerator::~CombinedMultiHitGenerator() {}