File indexing completed on 2025-01-09 23:33:51
0001 #include "RecoMuon/CosmicMuonProducer/plugins/GlobalCosmicMuonProducer.h"
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <memory>
0013 #include "FWCore/Framework/interface/ConsumesCollector.h"
0014
0015
0016 #include "FWCore/Framework/interface/Frameworkfwd.h"
0017
0018 #include "FWCore/Framework/interface/Event.h"
0019 #include "FWCore/Framework/interface/MakerMacros.h"
0020
0021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0022
0023 #include "FWCore/Framework/interface/EventSetup.h"
0024 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0025
0026 #include "DataFormats/MuonReco/interface/MuonTrackLinks.h"
0027 #include "DataFormats/MuonReco/interface/MuonFwd.h"
0028 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
0029
0030 #include "RecoMuon/CosmicMuonProducer/interface/GlobalCosmicMuonTrajectoryBuilder.h"
0031 #include "RecoMuon/TrackingTools/interface/MuonTrackFinder.h"
0032 #include "RecoMuon/TrackingTools/interface/MuonTrackLoader.h"
0033 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
0034
0035
0036
0037
0038 GlobalCosmicMuonProducer::GlobalCosmicMuonProducer(const edm::ParameterSet& iConfig) {
0039 edm::ParameterSet tbpar = iConfig.getParameter<edm::ParameterSet>("TrajectoryBuilderParameters");
0040 theTrackCollectionToken = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("MuonCollectionLabel"));
0041
0042
0043 edm::ParameterSet serviceParameters = iConfig.getParameter<edm::ParameterSet>("ServiceParameters");
0044
0045
0046 edm::ParameterSet trackLoaderParameters = iConfig.getParameter<edm::ParameterSet>("TrackLoaderParameters");
0047
0048
0049 theService = std::make_unique<MuonServiceProxy>(serviceParameters, consumesCollector());
0050 edm::ConsumesCollector iC = consumesCollector();
0051 theTrackFinder = std::make_unique<MuonTrackFinder>(
0052 std::make_unique<GlobalCosmicMuonTrajectoryBuilder>(tbpar, theService.get(), iC),
0053 std::make_unique<MuonTrackLoader>(trackLoaderParameters, iC, theService.get()),
0054 iC);
0055
0056 produces<reco::TrackCollection>();
0057 produces<TrackingRecHitCollection>();
0058 produces<reco::TrackExtraCollection>();
0059 produces<std::vector<Trajectory> >();
0060 produces<TrajTrackAssociationCollection>();
0061
0062 produces<reco::MuonTrackLinksCollection>();
0063 }
0064
0065 GlobalCosmicMuonProducer::~GlobalCosmicMuonProducer() {}
0066
0067
0068 void GlobalCosmicMuonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0069 const std::string metname = "Muon|RecoMuon|GlobalCosmicMuonProducer";
0070 LogTrace(metname) << "Global Cosmic Muon Reconstruction started";
0071
0072 edm::Handle<reco::TrackCollection> cosMuons;
0073 iEvent.getByToken(theTrackCollectionToken, cosMuons);
0074 if (!cosMuons.isValid()) {
0075 LogTrace(metname) << "Muon Track collection is invalid!!!";
0076 return;
0077 }
0078
0079
0080 theService->update(iSetup);
0081
0082
0083 LogTrace(metname) << "Track Reconstruction";
0084
0085 std::vector<MuonTrajectoryBuilder::TrackCand> cosTrackCands;
0086 for (unsigned int position = 0; position != cosMuons->size(); ++position) {
0087 reco::TrackRef cosTrackRef(cosMuons, position);
0088 MuonTrajectoryBuilder::TrackCand cosCand = MuonTrajectoryBuilder::TrackCand((Trajectory*)nullptr, cosTrackRef);
0089 cosTrackCands.push_back(cosCand);
0090 }
0091 theTrackFinder->reconstruct(cosTrackCands, iEvent, iSetup);
0092 LogTrace(metname) << "Event loaded";
0093 }
0094
0095 #include "FWCore/Framework/interface/MakerMacros.h"
0096 DEFINE_FWK_MODULE(GlobalCosmicMuonProducer);