diff --git a/HLTrigger/special/plugins/HLTMuonPointingFilter.cc b/HLTrigger/special/plugins/HLTMuonPointingFilter.cc index 23568db53081e..2be02acc2fa19 100644 --- a/HLTrigger/special/plugins/HLTMuonPointingFilter.cc +++ b/HLTrigger/special/plugins/HLTMuonPointingFilter.cc @@ -19,13 +19,8 @@ #include "DataFormats/TrackReco/interface/Track.h" -#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h" -#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h" -#include "MagneticField/Engine/interface/MagneticField.h" -#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" #include "TrackingTools/TransientTrack/interface/TransientTrack.h" #include "TrackingTools/GeomPropagators/interface/Propagator.h" -#include "TrackingTools/Records/interface/TrackingComponentsRecord.h" /* C++ Headers */ using namespace std; @@ -38,24 +33,18 @@ HLTMuonPointingFilter::HLTMuonPointingFilter(const edm::ParameterSet& pset) : theSTAMuonToken( consumes(pset.getParameter("SALabel"))), // token to read the muons thePropagatorName(pset.getParameter("PropagatorName")), + thePropagatorToken(esConsumes(edm::ESInputTag("", thePropagatorName))), + theMGFieldToken(esConsumes()), + theTrackingGeometryToken(esConsumes()), theRadius(pset.getParameter("radius")), // cyl's radius (cm) theMaxZ(pset.getParameter("maxZ")), // cyl's half lenght (cm) thePixHits(pset.getParameter("PixHits")), // pixel hits theTkLayers(pset.getParameter("TkLayers")), // tracker layers with measurements theMuonHits(pset.getParameter("MuonHits")), // muon hits - thePropagator(nullptr), - m_cacheRecordId(0) { - // Get a surface (here a cylinder of radius 1290mm) ECAL - Cylinder::PositionType pos0; - Cylinder::RotationType rot0; - theCyl = Cylinder::build(theRadius, pos0, rot0); - - Plane::PositionType posPos(0, 0, theMaxZ); - Plane::PositionType posNeg(0, 0, -theMaxZ); - - thePosPlane = Plane::build(posPos, rot0); - theNegPlane = Plane::build(posNeg, rot0); - + // Get a surface (here a cylinder of radius 1290mm) ECAL + theCyl(Cylinder::build(theRadius, Cylinder::PositionType{}, Cylinder::RotationType{})), + thePosPlane(Plane::build(Plane::PositionType{0, 0, static_cast(theMaxZ)}, Plane::RotationType{})), + theNegPlane(Plane::build(Plane::PositionType{0, 0, static_cast(-theMaxZ)}, Plane::RotationType{})) { LogDebug("HLTMuonPointing") << " SALabel : " << pset.getParameter("SALabel") << " Radius : " << theRadius << " Half lenght : " << theMaxZ << " Min pixel hits : " << thePixHits << " Min tk layers measurements : " << theTkLayers @@ -66,30 +55,20 @@ HLTMuonPointingFilter::HLTMuonPointingFilter(const edm::ParameterSet& pset) HLTMuonPointingFilter::~HLTMuonPointingFilter() = default; /* Operations */ -bool HLTMuonPointingFilter::filter(edm::Event& event, const edm::EventSetup& eventSetup) { +bool HLTMuonPointingFilter::filter(edm::StreamID, edm::Event& event, const edm::EventSetup& eventSetup) const { bool accept = false; - const TrackingComponentsRecord& tkRec = eventSetup.get(); - if (not thePropagator or tkRec.cacheIdentifier() != m_cacheRecordId) { - // delete the old propagator - delete thePropagator; - - // get the new propagator from the EventSetup and clone it (for thread safety) - ESHandle propagatorHandle; - tkRec.get(thePropagatorName, propagatorHandle); - thePropagator = propagatorHandle.product()->clone(); - if (thePropagator->propagationDirection() != anyDirection) - throw cms::Exception("Configuration") - << "the propagator " << thePropagatorName - << " should be configured with PropagationDirection = \"anyDirection\"" << std::endl; - m_cacheRecordId = tkRec.cacheIdentifier(); + auto const& propagator = eventSetup.getData(thePropagatorToken); + + if (propagator.propagationDirection() != anyDirection) { + throw cms::Exception("Configuration") + << "the propagator " << thePropagatorName + << " should be configured with PropagationDirection = \"anyDirection\"" << std::endl; } - ESHandle theMGField; - eventSetup.get().get(theMGField); + ESHandle theMGField = eventSetup.getHandle(theMGFieldToken); - ESHandle theTrackingGeometry; - eventSetup.get().get(theTrackingGeometry); + ESHandle theTrackingGeometry = eventSetup.getHandle(theTrackingGeometryToken); // Get the RecTrack collection from the event Handle staTracks; @@ -110,7 +89,7 @@ bool HLTMuonPointingFilter::filter(edm::Event& event, const edm::EventSetup& eve LogDebug("HLTMuonPointing") << " InnerTSOS " << innerTSOS; - TrajectoryStateOnSurface tsosAtCyl = thePropagator->propagate(*innerTSOS.freeState(), *theCyl); + TrajectoryStateOnSurface tsosAtCyl = propagator.propagate(*innerTSOS.freeState(), *theCyl); if (tsosAtCyl.isValid()) { LogDebug("HLTMuonPointing") << " extrap TSOS " << tsosAtCyl << " number of pixel hits " << pixelHits @@ -132,9 +111,9 @@ bool HLTMuonPointingFilter::filter(edm::Event& event, const edm::EventSetup& eve << " number of muon hits " << nMuonHits; TrajectoryStateOnSurface tsosAtPlane; if (tsosAtCyl.globalPosition().z() > 0) - tsosAtPlane = thePropagator->propagate(*innerTSOS.freeState(), *thePosPlane); + tsosAtPlane = propagator.propagate(*innerTSOS.freeState(), *thePosPlane); else - tsosAtPlane = thePropagator->propagate(*innerTSOS.freeState(), *theNegPlane); + tsosAtPlane = propagator.propagate(*innerTSOS.freeState(), *theNegPlane); if (tsosAtPlane.isValid()) { if (tsosAtPlane.globalPosition().perp() < theRadius) { diff --git a/HLTrigger/special/plugins/HLTMuonPointingFilter.h b/HLTrigger/special/plugins/HLTMuonPointingFilter.h index d9ee3127da048..ae255a1e5a7bf 100644 --- a/HLTrigger/special/plugins/HLTMuonPointingFilter.h +++ b/HLTrigger/special/plugins/HLTMuonPointingFilter.h @@ -11,7 +11,7 @@ */ /* Base Class Headers */ -#include "FWCore/Framework/interface/EDFilter.h" +#include "FWCore/Framework/interface/global/EDFilter.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" @@ -22,14 +22,21 @@ class Propagator; #include "DataFormats/GeometrySurface/interface/Plane.h" #include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h" +#include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "TrackingTools/Records/interface/TrackingComponentsRecord.h" + /* C++ Headers */ #include +#include /* ====================================================================== */ /* Class HLTMuonPointingFilter Interface */ -class HLTMuonPointingFilter : public edm::EDFilter { +class HLTMuonPointingFilter : public edm::global::EDFilter<> { public: /// Constructor HLTMuonPointingFilter(const edm::ParameterSet &); @@ -38,23 +45,27 @@ class HLTMuonPointingFilter : public edm::EDFilter { ~HLTMuonPointingFilter() override; /* Operations */ - bool filter(edm::Event &, edm::EventSetup const &) override; + bool filter(edm::StreamID, edm::Event &, edm::EventSetup const &) const override; static void fillDescriptions(edm::ConfigurationDescriptions &descriptions); private: const edm::EDGetTokenT theSTAMuonToken; - const std::string thePropagatorName; // name of propagator to be used - const double theRadius; // radius of cylinder - const double theMaxZ; // half length of cylinder - const unsigned int thePixHits; // number of pixel hits - const unsigned int theTkLayers; // number of tracker layers with measurements - const unsigned int theMuonHits; // number of valid muon hits - - Cylinder::CylinderPointer theCyl; - Plane::PlanePointer thePosPlane, theNegPlane; - - mutable Propagator *thePropagator; - unsigned long long m_cacheRecordId; + + const std::string + thePropagatorName; // name of propagator to be used const edm::ESGetToken thePropagatorToken; + const edm::ESGetToken thePropagatorToken; + const edm::ESGetToken theMGFieldToken; + const edm::ESGetToken theTrackingGeometryToken; + + const double theRadius; // radius of cylinder + const double theMaxZ; // half length of cylinder + const unsigned int thePixHits; // number of pixel hits + const unsigned int theTkLayers; // number of tracker layers with measurements + const unsigned int theMuonHits; // number of valid muon hits + + const Cylinder::CylinderPointer theCyl; + const Plane::PlanePointer thePosPlane; + const Plane::PlanePointer theNegPlane; }; #endif // Muon_HLTMuonPointingFilter_h