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 rest of {Cosmic,GlobalCosmic,Global,L2,L3,Standalone}MuonProduer to EventSetup consumes #31779

Merged
merged 2 commits into from
Oct 15, 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
4 changes: 2 additions & 2 deletions RecoMuon/CosmicMuonProducer/src/CosmicMuonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "DataFormats/TrackReco/interface/Track.h"
Expand Down Expand Up @@ -59,7 +58,8 @@ CosmicMuonProducer::CosmicMuonProducer(const ParameterSet& iConfig) {
theService = std::make_unique<MuonServiceProxy>(serviceParameters, consumesCollector());
theTrackFinder =
std::make_unique<MuonTrackFinder>(std::make_unique<CosmicMuonTrajectoryBuilder>(tbpar, theService.get(), iC),
std::make_unique<MuonTrackLoader>(trackLoaderParameters, iC, theService.get()));
std::make_unique<MuonTrackLoader>(trackLoaderParameters, iC, theService.get()),
iC);

produces<reco::TrackCollection>();
produces<TrackingRecHitCollection>();
Expand Down
4 changes: 2 additions & 2 deletions RecoMuon/CosmicMuonProducer/src/GlobalCosmicMuonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "DataFormats/MuonReco/interface/MuonTrackLinks.h"
Expand Down Expand Up @@ -51,7 +50,8 @@ GlobalCosmicMuonProducer::GlobalCosmicMuonProducer(const edm::ParameterSet& iCon
edm::ConsumesCollector iC = consumesCollector();
theTrackFinder = std::make_unique<MuonTrackFinder>(
std::make_unique<GlobalCosmicMuonTrajectoryBuilder>(tbpar, theService.get(), iC),
std::make_unique<MuonTrackLoader>(trackLoaderParameters, iC, theService.get()));
std::make_unique<MuonTrackLoader>(trackLoaderParameters, iC, theService.get()),
iC);

produces<reco::TrackCollection>();
produces<TrackingRecHitCollection>();
Expand Down
4 changes: 1 addition & 3 deletions RecoMuon/GlobalMuonProducer/src/GlobalMuonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ GlobalMuonProducer::GlobalMuonProducer(const ParameterSet& parameterSet) {
auto mtl = std::make_unique<MuonTrackLoader>(trackLoaderParameters, iC, theService);
auto gmtb = std::make_unique<GlobalMuonTrajectoryBuilder>(trajectoryBuilderParameters, theService, iC);

theTrackFinder = new MuonTrackFinder(std::move(gmtb), std::move(mtl));
theTrackFinder = std::make_unique<MuonTrackFinder>(std::move(gmtb), std::move(mtl), iC);

setAlias(parameterSet.getParameter<std::string>("@module_label"));
produces<reco::TrackCollection>().setBranchAlias(theAlias + "Tracks");
Expand All @@ -82,8 +82,6 @@ GlobalMuonProducer::~GlobalMuonProducer() {
LogTrace("Muon|RecoMuon|GlobalMuonProducer") << "destructor called" << endl;
if (theService)
delete theService;
if (theTrackFinder)
delete theTrackFinder;
}

//
Expand Down
2 changes: 1 addition & 1 deletion RecoMuon/GlobalMuonProducer/src/GlobalMuonProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class GlobalMuonProducer : public edm::stream::EDProducer<> {
edm::EDGetTokenT<TrajTrackAssociationCollection> staAssoMapToken;
edm::EDGetTokenT<reco::TrackToTrackMap> updatedStaAssoMapToken;

MuonTrackFinder* theTrackFinder;
std::unique_ptr<MuonTrackFinder> theTrackFinder;

/// the event setup proxy, it takes care the services update
MuonServiceProxy* theService;
Expand Down
3 changes: 2 additions & 1 deletion RecoMuon/L2MuonProducer/src/L2MuonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ L2MuonProducer::L2MuonProducer(const ParameterSet& parameterSet) {
theTrackFinder =
std::make_unique<MuonTrackFinder>(std::move(trajectoryBuilder),
std::make_unique<MuonTrackLoader>(trackLoaderParameters, iC, theService.get()),
std::make_unique<MuonTrajectoryCleaner>(true));
std::make_unique<MuonTrajectoryCleaner>(true),
iC);

produces<reco::TrackCollection>();
produces<reco::TrackCollection>("UpdatedAtVtx");
Expand Down
2 changes: 1 addition & 1 deletion RecoMuon/L3MuonProducer/src/L3MuonProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ L3MuonProducer::L3MuonProducer(const ParameterSet& parameterSet) {
// instantiate the concrete trajectory builder in the Track Finder
auto mtl = std::make_unique<MuonTrackLoader>(trackLoaderParameters, iC, theService.get());
auto l3mtb = std::make_unique<L3MuonTrajectoryBuilder>(trajectoryBuilderParameters, theService.get(), iC);
theTrackFinder = std::make_unique<MuonTrackFinder>(std::move(l3mtb), std::move(mtl));
theTrackFinder = std::make_unique<MuonTrackFinder>(std::move(l3mtb), std::move(mtl), iC);

theL2SeededTkLabel =
trackLoaderParameters.getUntrackedParameter<std::string>("MuonSeededTracksInstance", std::string());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ StandAloneMuonProducer::StandAloneMuonProducer(const ParameterSet& parameterSet)
trajectoryBuilder =
std::make_unique<StandAloneMuonTrajectoryBuilder>(trajectoryBuilderParameters, theService.get(), iC);
}
theTrackFinder = std::make_unique<MuonTrackFinder>(std::move(trajectoryBuilder), std::move(trackLoader));
theTrackFinder = std::make_unique<MuonTrackFinder>(std::move(trajectoryBuilder), std::move(trackLoader), iC);

setAlias(parameterSet.getParameter<std::string>("@module_label"));

Expand Down
19 changes: 9 additions & 10 deletions RecoMuon/TrackingTools/interface/MuonTrackFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,13 @@
#include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
#include "TrackingTools/PatternTools/interface/Trajectory.h"
#include "RecoMuon/TrackingTools/interface/MuonCandidate.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/FrameworkfwdMostUsed.h"

#include <vector>

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

class MuonTrajectoryBuilder;
class MuonTrajectoryCleaner;
class MuonTrackLoader;
Expand All @@ -37,12 +32,14 @@ class MuonTrackFinder {
public:
/// Constructor, with default cleaner. For the STA reconstruction the trackLoader must have the propagator.
MuonTrackFinder(std::unique_ptr<MuonTrajectoryBuilder> ConcreteMuonTrajectoryBuilder,
std::unique_ptr<MuonTrackLoader> trackLoader);
std::unique_ptr<MuonTrackLoader> trackLoader,
edm::ConsumesCollector iC);

/// Constructor, with user-defined cleaner. For the STA reconstruction the trackLoader must have the propagator.
MuonTrackFinder(std::unique_ptr<MuonTrajectoryBuilder> ConcreteMuonTrajectoryBuilder,
std::unique_ptr<MuonTrackLoader> trackLoader,
std::unique_ptr<MuonTrajectoryCleaner> cleaner);
std::unique_ptr<MuonTrajectoryCleaner> cleaner,
edm::ConsumesCollector iC);

/// destructor
virtual ~MuonTrackFinder();
Expand All @@ -68,6 +65,8 @@ class MuonTrackFinder {
void load(CandidateContainer&, edm::Event&, const TrackerTopology& ttopo);

private:
const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> theTtopoToken;

std::unique_ptr<MuonTrajectoryBuilder> theTrajBuilder;

std::unique_ptr<MuonTrajectoryCleaner> theTrajCleaner;
Expand Down
29 changes: 14 additions & 15 deletions RecoMuon/TrackingTools/src/MuonTrackFinder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,25 @@
#include "TrackingTools/GeomPropagators/interface/Propagator.h"
#include "TrackingTools/PatternTools/interface/Trajectory.h"

#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"

using namespace std;
using namespace edm;

// Constructor, with default cleaner. For the STA reconstruction the trackLoader must have the propagator.
MuonTrackFinder::MuonTrackFinder(std::unique_ptr<MuonTrajectoryBuilder> ConcreteMuonTrajectoryBuilder,
std::unique_ptr<MuonTrackLoader> trackLoader)
: theTrajBuilder(std::move(ConcreteMuonTrajectoryBuilder)),
theTrajCleaner(new MuonTrajectoryCleaner()),
theTrackLoader(std::move(trackLoader)) {}
std::unique_ptr<MuonTrackLoader> trackLoader,
edm::ConsumesCollector iC)
: MuonTrackFinder(std::move(ConcreteMuonTrajectoryBuilder),
std::move(trackLoader),
std::make_unique<MuonTrajectoryCleaner>(),
iC) {}

// Constructor, with user-defined cleaner. For the STA reconstruction the trackLoader must have the propagator.
MuonTrackFinder::MuonTrackFinder(std::unique_ptr<MuonTrajectoryBuilder> ConcreteMuonTrajectoryBuilder,
std::unique_ptr<MuonTrackLoader> trackLoader,
std::unique_ptr<MuonTrajectoryCleaner> cleaner)
: theTrajBuilder(std::move(ConcreteMuonTrajectoryBuilder)),
std::unique_ptr<MuonTrajectoryCleaner> cleaner,
edm::ConsumesCollector iC)
: theTtopoToken(iC.esConsumes()),
theTrajBuilder(std::move(ConcreteMuonTrajectoryBuilder)),
theTrajCleaner(std::move(cleaner)),
theTrackLoader(std::move(trackLoader)) {}

Expand Down Expand Up @@ -72,8 +73,7 @@ edm::OrphanHandle<reco::TrackCollection> MuonTrackFinder::reconstruct(
// Percolate the event
setEvent(event);

edm::ESHandle<TrackerTopology> httopo;
es.get<TrackerTopologyRcd>().get(httopo);
const auto& ttopo = es.getData(theTtopoToken);

// Trajectory container
TrajectoryContainer muonTrajectories;
Expand All @@ -96,7 +96,7 @@ edm::OrphanHandle<reco::TrackCollection> MuonTrackFinder::reconstruct(

// convert the trajectories into tracks and load them in to the event
LogTrace(metname) << "Convert the trajectories into tracks and load them in to the event" << endl;
return load(muonTrajectories, event, *httopo);
return load(muonTrajectories, event, ttopo);
}

// reconstruct trajectories
Expand All @@ -106,8 +106,7 @@ void MuonTrackFinder::reconstruct(const std::vector<TrackCand>& staCandColl, Eve
// percolate the event
setEvent(event);

edm::ESHandle<TrackerTopology> httopo;
es.get<TrackerTopologyRcd>().get(httopo);
const auto& ttopo = es.getData(theTtopoToken);

// Muon Candidate container
CandidateContainer muonCandidates;
Expand All @@ -126,5 +125,5 @@ void MuonTrackFinder::reconstruct(const std::vector<TrackCand>& staCandColl, Eve

// convert the trajectories into staTracks and load them into the event
LogTrace(metname) << "Load Muon Candidates into the event" << endl;
load(muonCandidates, event, *httopo);
load(muonCandidates, event, ttopo);
}