Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate some Muon helper classes and EDProducers to EventSetup consumes #31834

Merged
merged 4 commits into from
Oct 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions RecoMuon/GlobalMuonProducer/src/TevMuonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using namespace reco;
//
// constructor with config
//
TevMuonProducer::TevMuonProducer(const ParameterSet& parameterSet) {
TevMuonProducer::TevMuonProducer(const ParameterSet& parameterSet) : tTopoToken(esConsumes()) {
LogDebug("Muon|RecoMuon|TevMuonProducer") << "constructor called" << endl;

// GLB Muon Collection Label
Expand Down Expand Up @@ -92,9 +92,7 @@ void TevMuonProducer::produce(Event& event, const EventSetup& eventSetup) {
theRefitter->setServices(theService->eventSetup());

//Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopoHand;
eventSetup.get<TrackerTopologyRcd>().get(tTopoHand);
const TrackerTopology* tTopo = tTopoHand.product();
const TrackerTopology* tTopo = &eventSetup.getData(tTopoToken);

// Take the GLB muon container(s)
Handle<reco::TrackCollection> glbMuons;
Expand Down
9 changes: 3 additions & 6 deletions RecoMuon/GlobalMuonProducer/src/TevMuonProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/

#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
#include "RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h"
#include "RecoMuon/TrackingTools/interface/MuonTrackLoader.h"

Expand All @@ -31,14 +32,9 @@

typedef edm::ValueMap<reco::DYTInfo> DYTestimators;

namespace edm {
class ParameterSet;
class Event;
class EventSetup;
} // namespace edm

class MuonTrackFinder;
class MuonServiceProxy;
class TrackerTopologyRcd;

class TevMuonProducer : public edm::stream::EDProducer<> {
public:
Expand All @@ -56,6 +52,7 @@ class TevMuonProducer : public edm::stream::EDProducer<> {
edm::InputTag theGLBCollectionLabel;
edm::EDGetTokenT<reco::TrackCollection> glbMuonsToken;
edm::EDGetTokenT<std::vector<Trajectory> > glbMuonsTrajToken;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken;

/// the event setup proxy, it takes care the services update
std::unique_ptr<MuonServiceProxy> theService;
Expand Down
17 changes: 8 additions & 9 deletions RecoMuon/GlobalTrackingTools/interface/GlobalMuonRefitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"
#include "RecoMuon/TrackingTools/interface/MuonTrajectoryBuilder.h"
#include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
#include "TrackingTools/TrackRefitter/interface/TrackTransformer.h"
Expand All @@ -33,9 +33,6 @@
#include "DataFormats/MuonReco/interface/DYTInfo.h"
#include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h"

namespace edm {
class Event;
}
namespace reco {
class TransientTrack;
}
Expand All @@ -48,6 +45,8 @@ class MuonServiceProxy;
class Trajectory;

class TrajectoryFitter;
class TrajectoryFitterRecord;
class TransientRecHitRecord;

class GlobalMuonRefitter {
public:
Expand Down Expand Up @@ -172,15 +171,15 @@ class GlobalMuonRefitter {
edm::ParameterSet theDYTthrsParameters;
reco::DYTInfo* dytInfo;

std::string theFitterName;
edm::ESGetToken<TrajectoryFitter, TrajectoryFitterRecord> theFitterToken;
std::unique_ptr<TrajectoryFitter> theFitter;

std::string theTrackerRecHitBuilderName;
edm::ESHandle<TransientTrackingRecHitBuilder> theTrackerRecHitBuilder;
edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theTrackerRecHitBuilderToken;
const TransientTrackingRecHitBuilder* theTrackerRecHitBuilder;
TkClonerImpl hitCloner;

std::string theMuonRecHitBuilderName;
edm::ESHandle<TransientTrackingRecHitBuilder> theMuonRecHitBuilder;
edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theMuonRecHitBuilderToken;
const TransientTrackingRecHitBuilder* theMuonRecHitBuilder;

const MuonServiceProxy* theService;
const edm::Event* theEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* \author A. Everett Purdue University
*/

#include "FWCore/Framework/interface/ESHandle.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "RecoMuon/TrackingTools/interface/MuonTrajectoryBuilder.h"
#include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
Expand All @@ -38,6 +37,7 @@ class MuonDetLayerMeasurements;
class MuonServiceProxy;
class MuonTrackingRegionBuilder;
class GlobalMuonRefitter;
class TransientRecHitRecord;

class GlobalTrajectoryBuilderBase : public MuonTrajectoryBuilder {
public:
Expand Down Expand Up @@ -151,18 +151,18 @@ class GlobalTrajectoryBuilderBase : public MuonTrajectoryBuilder {
MuonTrackingRegionBuilder* theRegionBuilder;
const MuonServiceProxy* theService;
GlobalMuonRefitter* theGlbRefitter;
unsigned long long theCacheId_TRH;
bool theRPCInTheFit;
bool theRefitFlag;
int theMuonHitsOption;
float theTECxScale;
float theTECyScale;
std::string theTrackerPropagatorName;
const edm::Event* theEvent;
std::string theTrackerRecHitBuilderName;
edm::ESHandle<TransientTrackingRecHitBuilder> theTrackerRecHitBuilder;
std::string theMuonRecHitBuilderName;
edm::ESHandle<TransientTrackingRecHitBuilder> theMuonRecHitBuilder;
edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theTrackerRecHitBuilderToken;
const TransientTrackingRecHitBuilder* theTrackerRecHitBuilder;
edm::ESGetToken<TransientTrackingRecHitBuilder, TransientRecHitRecord> theMuonRecHitBuilderToken;
const TransientTrackingRecHitBuilder* theMuonRecHitBuilder;
edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> theTopoToken;
const TrackerTopology* theTopo;
};
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
GlobalTrackQualityProducer::GlobalTrackQualityProducer(const edm::ParameterSet& iConfig)
: inputCollection_(iConfig.getParameter<edm::InputTag>("InputCollection")),
inputLinksCollection_(iConfig.getParameter<edm::InputTag>("InputLinksCollection")),
tTopoToken_(esConsumes()),
theService(nullptr),
theGlbRefitter(nullptr),
theGlbMatcher(nullptr) {
Expand Down Expand Up @@ -81,9 +82,7 @@ void GlobalTrackQualityProducer::produce(edm::Event& iEvent, const edm::EventSet
iEvent.getByToken(linkCollectionToken, linkCollectionHandle);

//Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopoHand;
iSetup.get<TrackerTopologyRcd>().get(tTopoHand);
const TrackerTopology* tTopo = tTopoHand.product();
const TrackerTopology* tTopo = &iSetup.getData(tTopoToken_);

// reserve some space
std::vector<reco::MuonQuality> valuesQual;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class GlobalTrackQualityProducer : public edm::stream::EDProducer<> {
edm::InputTag inputLinksCollection_;
edm::EDGetTokenT<reco::TrackCollection> glbMuonsToken;
edm::EDGetTokenT<reco::MuonTrackLinksCollection> linkCollectionToken;
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
MuonServiceProxy* theService;
GlobalMuonRefitter* theGlbRefitter;
GlobalMuonTrackMatcher* theGlbMatcher;
Expand Down
18 changes: 8 additions & 10 deletions RecoMuon/GlobalTrackingTools/src/GlobalMuonRefitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ GlobalMuonRefitter::GlobalMuonRefitter(const edm::ParameterSet& par,
<< "\n"
<< "RefitDirection = insideOut or RefitDirection = outsideIn";

theFitterName = par.getParameter<string>("Fitter");
theFitterToken = iC.esConsumes(edm::ESInputTag("", par.getParameter<string>("Fitter")));
thePropagatorName = par.getParameter<string>("Propagator");

theSkipStation = par.getParameter<int>("SkipStation");
theTrackerSkipSystem = par.getParameter<int>("TrackerSkipSystem");
theTrackerSkipSection = par.getParameter<int>("TrackerSkipSection"); //layer, wheel, or disk depending on the system

theTrackerRecHitBuilderName = par.getParameter<string>("TrackerRecHitBuilder");
theMuonRecHitBuilderName = par.getParameter<string>("MuonRecHitBuilder");
theTrackerRecHitBuilderToken = iC.esConsumes(edm::ESInputTag("", par.getParameter<string>("TrackerRecHitBuilder")));
theMuonRecHitBuilderToken = iC.esConsumes(edm::ESInputTag("", par.getParameter<string>("MuonRecHitBuilder")));

theRPCInTheFit = par.getParameter<bool>("RefitRPCHits");

Expand Down Expand Up @@ -161,17 +161,15 @@ void GlobalMuonRefitter::setEvent(const edm::Event& event) {
}

void GlobalMuonRefitter::setServices(const EventSetup& setup) {
edm::ESHandle<TrajectoryFitter> aFitter;
theService->eventSetup().get<TrajectoryFitter::Record>().get(theFitterName, aFitter);
theFitter = aFitter->clone();
theFitter = setup.getData(theFitterToken).clone();

// Transient Rechit Builders
unsigned long long newCacheId_TRH = setup.get<TransientRecHitRecord>().cacheIdentifier();
if (newCacheId_TRH != theCacheId_TRH) {
LogDebug(theCategory) << "TransientRecHitRecord changed!";
setup.get<TransientRecHitRecord>().get(theTrackerRecHitBuilderName, theTrackerRecHitBuilder);
setup.get<TransientRecHitRecord>().get(theMuonRecHitBuilderName, theMuonRecHitBuilder);
hitCloner = static_cast<TkTransientTrackingRecHitBuilder const*>(theTrackerRecHitBuilder.product())->cloner();
theTrackerRecHitBuilder = &setup.getData(theTrackerRecHitBuilderToken);
theMuonRecHitBuilder = &setup.getData(theMuonRecHitBuilderToken);
hitCloner = static_cast<TkTransientTrackingRecHitBuilder const*>(theTrackerRecHitBuilder)->cloner();
}
theFitter->setHitCloner(&hitCloner);
}
Expand All @@ -188,7 +186,7 @@ vector<Trajectory> GlobalMuonRefitter::refit(const reco::Track& globalTrack,

reco::TransientTrack track(globalTrack, &*(theService->magneticField()), theService->trackingGeometry());

auto tkbuilder = static_cast<TkTransientTrackingRecHitBuilder const*>(theTrackerRecHitBuilder.product());
auto tkbuilder = static_cast<TkTransientTrackingRecHitBuilder const*>(theTrackerRecHitBuilder);

for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit)
if ((*hit)->isValid()) {
Expand Down
23 changes: 8 additions & 15 deletions RecoMuon/GlobalTrackingTools/src/GlobalTrajectoryBuilderBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ GlobalTrajectoryBuilderBase::GlobalTrajectoryBuilderBase(const edm::ParameterSet
theMuonHitsOption = refitterParameters.getParameter<int>("MuonHitsOption");
theRefitFlag = refitterParameters.getParameter<bool>("RefitFlag");

theTrackerRecHitBuilderName = par.getParameter<std::string>("TrackerRecHitBuilder");
theMuonRecHitBuilderName = par.getParameter<std::string>("MuonRecHitBuilder");
theTrackerRecHitBuilderToken =
iC.esConsumes(edm::ESInputTag("", par.getParameter<std::string>("TrackerRecHitBuilder")));
theMuonRecHitBuilderToken = iC.esConsumes(edm::ESInputTag("", par.getParameter<std::string>("MuonRecHitBuilder")));
theTopoToken = iC.esConsumes();

theRPCInTheFit = par.getParameter<bool>("RefitRPCHits");

theTECxScale = par.getParameter<double>("ScaleTECxFactor");
theTECyScale = par.getParameter<double>("ScaleTECyFactor");
thePtCut = par.getParameter<double>("PtCut");
thePCut = par.getParameter<double>("PCut");

theCacheId_TRH = 0;
}

//--------------
Expand Down Expand Up @@ -142,18 +142,11 @@ void GlobalTrajectoryBuilderBase::setEvent(const edm::Event& event) {
theGlbRefitter->setEvent(event);
theGlbRefitter->setServices(theService->eventSetup());

unsigned long long newCacheId_TRH = theService->eventSetup().get<TransientRecHitRecord>().cacheIdentifier();
if (newCacheId_TRH != theCacheId_TRH) {
LogDebug(theCategory) << "TransientRecHitRecord changed!";
theCacheId_TRH = newCacheId_TRH;
theService->eventSetup().get<TransientRecHitRecord>().get(theTrackerRecHitBuilderName, theTrackerRecHitBuilder);
theService->eventSetup().get<TransientRecHitRecord>().get(theMuonRecHitBuilderName, theMuonRecHitBuilder);
}
theTrackerRecHitBuilder = &theService->eventSetup().getData(theTrackerRecHitBuilderToken);
theMuonRecHitBuilder = &theService->eventSetup().getData(theMuonRecHitBuilderToken);

//Retrieve tracker topology from geometry
edm::ESHandle<TrackerTopology> tTopoHand;
theService->eventSetup().get<TrackerTopologyRcd>().get(tTopoHand);
theTopo = tTopoHand.product();
theTopo = &theService->eventSetup().getData(theTopoToken);
}

//
Expand Down Expand Up @@ -510,7 +503,7 @@ TransientTrackingRecHit::ConstRecHitContainer GlobalTrajectoryBuilderBase::getTr
TrajectoryStateOnSurface currTsos = trajectoryStateTransform::innerStateOnSurface(
track, *theService->trackingGeometry(), &*theService->magneticField());

auto tkbuilder = static_cast<TkTransientTrackingRecHitBuilder const*>(theTrackerRecHitBuilder.product());
auto tkbuilder = static_cast<TkTransientTrackingRecHitBuilder const*>(theTrackerRecHitBuilder);
auto hitCloner = tkbuilder->cloner();
for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit) {
if ((*hit)->isValid()) {
Expand Down