Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:44

0001 #include "RecoMuon/CosmicMuonProducer/src/GlobalCosmicMuonProducer.h"
0002 
0003 /**\class GlobalCosmicMuonProducer
0004  *
0005  *  reconstruct muons using dt,csc,rpc and tracker starting from cosmic muon
0006  *  tracks
0007  *
0008  * \author:  Chang Liu  - Purdue University <Chang.Liu@cern.ch>
0009 **/
0010 
0011 // system include files
0012 #include <memory>
0013 #include "FWCore/Framework/interface/ConsumesCollector.h"
0014 
0015 // user include files
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 // constructors and destructor
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   // service parameters
0043   edm::ParameterSet serviceParameters = iConfig.getParameter<edm::ParameterSet>("ServiceParameters");
0044 
0045   // TrackLoader parameters
0046   edm::ParameterSet trackLoaderParameters = iConfig.getParameter<edm::ParameterSet>("TrackLoaderParameters");
0047 
0048   // the services
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 // ------------ method called to produce the data  ------------
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   // Update the services
0080   theService->update(iSetup);
0081 
0082   // Reconstruct the tracks in the tracker+muon system
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 }