CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/RecoMuon/CosmicMuonProducer/src/GlobalCosmicMuonProducer.cc

Go to the documentation of this file.
00001 #include "RecoMuon/CosmicMuonProducer/src/GlobalCosmicMuonProducer.h"
00002 
00013 // system include files
00014 #include <memory>
00015 
00016 // user include files
00017 #include "FWCore/Framework/interface/Frameworkfwd.h"
00018 
00019 #include "FWCore/Framework/interface/Event.h"
00020 #include "FWCore/Framework/interface/MakerMacros.h"
00021 
00022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00023 
00024 #include "FWCore/Framework/interface/EventSetup.h"
00025 #include "FWCore/Framework/interface/ESHandle.h"
00026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00027 
00028 #include "DataFormats/TrackReco/interface/Track.h"
00029 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00030 #include "DataFormats/MuonReco/interface/MuonTrackLinks.h"
00031 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00032 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
00033 
00034 #include "RecoMuon/CosmicMuonProducer/interface/GlobalCosmicMuonTrajectoryBuilder.h"
00035 #include "RecoMuon/TrackingTools/interface/MuonTrackFinder.h"
00036 #include "RecoMuon/TrackingTools/interface/MuonTrackLoader.h"
00037 #include "RecoMuon/TrackingTools/interface/MuonServiceProxy.h"
00038 
00039 //
00040 // constructors and destructor
00041 //
00042 GlobalCosmicMuonProducer::GlobalCosmicMuonProducer(const edm::ParameterSet& iConfig)
00043 {
00044 
00045   edm::ParameterSet tbpar = iConfig.getParameter<edm::ParameterSet>("TrajectoryBuilderParameters");
00046   theTrackCollectionLabel = iConfig.getParameter<edm::InputTag>("MuonCollectionLabel");
00047 
00048   // service parameters
00049   edm::ParameterSet serviceParameters = iConfig.getParameter<edm::ParameterSet>("ServiceParameters");
00050   
00051   // TrackLoader parameters
00052   edm::ParameterSet trackLoaderParameters = iConfig.getParameter<edm::ParameterSet>("TrackLoaderParameters");
00053   
00054   // the services
00055   theService = new MuonServiceProxy(serviceParameters);
00056   
00057   theTrackFinder = new MuonTrackFinder(new GlobalCosmicMuonTrajectoryBuilder(tbpar,theService),
00058                                        new MuonTrackLoader(trackLoaderParameters, theService));
00059 
00060   produces<reco::TrackCollection>();
00061   produces<TrackingRecHitCollection>();
00062   produces<reco::TrackExtraCollection>();
00063   produces<std::vector<Trajectory> >();
00064   produces<TrajTrackAssociationCollection>();
00065 
00066   produces<reco::MuonTrackLinksCollection>();
00067 
00068 }
00069 
00070 
00071 GlobalCosmicMuonProducer::~GlobalCosmicMuonProducer()
00072 {
00073   if (theService) delete theService;
00074   if (theTrackFinder) delete theTrackFinder;
00075 }
00076 
00077 
00078 // ------------ method called to produce the data  ------------
00079 void
00080 GlobalCosmicMuonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00081 {
00082   const std::string metname = "Muon|RecoMuon|GlobalCosmicMuonProducer";  
00083   LogTrace(metname)<<"Global Cosmic Muon Reconstruction started";  
00084   
00085   edm::Handle<reco::TrackCollection> cosMuons;
00086   iEvent.getByLabel(theTrackCollectionLabel,cosMuons);
00087   if (!cosMuons.isValid()) {
00088     LogTrace(metname)<< "Muon Track collection is invalid!!!";
00089     return;
00090   }
00091   
00092   // Update the services
00093   theService->update(iSetup);
00094   
00095   // Reconstruct the tracks in the tracker+muon system
00096   LogTrace(metname)<<"Track Reconstruction";
00097 
00098   std::vector<MuonTrajectoryBuilder::TrackCand> cosTrackCands;
00099   for ( unsigned int position = 0; position != cosMuons->size(); ++position ) {
00100     reco::TrackRef cosTrackRef(cosMuons,position);
00101     MuonTrajectoryBuilder::TrackCand cosCand = MuonTrajectoryBuilder::TrackCand((Trajectory*)(0),cosTrackRef);
00102     cosTrackCands.push_back(cosCand); 
00103   }
00104   theTrackFinder->reconstruct(cosTrackCands,iEvent);
00105   LogTrace(metname)<<"Event loaded";
00106 
00107 }
00108