CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/RecoMuon/TrackingTools/src/MuonTrackFinder.cc

Go to the documentation of this file.
00001 
00009 #include "FWCore/Framework/interface/EventSetup.h"
00010 #include "FWCore/Framework/interface/Event.h"
00011 #include "DataFormats/Common/interface/Handle.h"
00012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00013 
00014 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00015 #include "DataFormats/TrackReco/interface/Track.h"
00016 #include "DataFormats/MuonReco/interface/Muon.h"
00017 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00018 
00019 #include "RecoMuon/TrackingTools/interface/MuonTrackFinder.h"
00020 #include "RecoMuon/TrackingTools/interface/MuonTrajectoryBuilder.h"
00021 #include "RecoMuon/TrackingTools/interface/MuonTrajectoryCleaner.h"
00022 #include "RecoMuon/TrackingTools/interface/MuonTrackLoader.h"
00023 
00024 #include "TrackingTools/GeomPropagators/interface/Propagator.h"
00025 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00026 
00027 using namespace std;
00028 using namespace edm;
00029 
00030 // Constructor, with default cleaner. For the STA reconstruction the trackLoader must have the propagator.
00031 MuonTrackFinder::MuonTrackFinder(MuonTrajectoryBuilder *ConcreteMuonTrajectoryBuilder,
00032                                  MuonTrackLoader *trackLoader) :
00033   theTrajBuilder(ConcreteMuonTrajectoryBuilder),
00034   theTrajCleaner(new MuonTrajectoryCleaner()),
00035   theTrackLoader(trackLoader) {
00036 }
00037 
00038 // Constructor, with user-defined cleaner. For the STA reconstruction the trackLoader must have the propagator.
00039 MuonTrackFinder::MuonTrackFinder(MuonTrajectoryBuilder *ConcreteMuonTrajectoryBuilder,
00040                                  MuonTrackLoader *trackLoader,
00041                                  MuonTrajectoryCleaner* cleaner) :
00042   theTrajBuilder(ConcreteMuonTrajectoryBuilder),
00043   theTrajCleaner(cleaner),
00044   theTrackLoader(trackLoader) {
00045 }
00046 
00047 // destructor
00048 MuonTrackFinder::~MuonTrackFinder() {
00049 
00050   LogTrace("Muon|RecoMuon|MuonTrackFinder")<<"MuonTrackFinder destructor called"<<endl;
00051   delete theTrajBuilder;
00052   delete theTrajCleaner;
00053   delete theTrackLoader;
00054 
00055 }
00056 
00057 // percolate the event setup
00058 void MuonTrackFinder::setEvent(const Event& event) {
00059   theTrajBuilder->setEvent(event);
00060 }
00061 
00062 // convert the trajectories into tracks and load them in to the event
00063 edm::OrphanHandle<reco::TrackCollection>  
00064 MuonTrackFinder::load(const TrajectoryContainer& trajectories, 
00065                       edm::Event& event) {
00066   
00067   return theTrackLoader->loadTracks(trajectories, event);
00068 }
00069 
00070 // convert the trajectories into tracks and load them in to the event
00071 void MuonTrackFinder::load(const CandidateContainer& muonCands,
00072                            Event& event) {
00073                            
00074     theTrackLoader->loadTracks(muonCands, event);
00075 
00076 }
00077 
00078 // reconstruct trajectories
00079 edm::OrphanHandle<reco::TrackCollection>
00080 MuonTrackFinder::reconstruct(const edm::Handle<edm::View<TrajectorySeed> >& seeds,
00081                              edm::Event& event){
00082   
00083   const string metname = "Muon|RecoMuon|MuonTrackFinder";
00084   LogTrace(metname)<<"SA Recostruction starting from: "<<seeds->size()<<endl;  
00085   
00086   // Percolate the event 
00087   setEvent(event);
00088   
00089   // Trajectory container
00090   TrajectoryContainer muonTrajectories;
00091   TrajectorySeedCollection::size_type nSeed = 0;
00092   // reconstruct the trajectory
00093   edm::View<TrajectorySeed>::const_iterator seed;
00094   for(seed = seeds->begin();
00095       seed != seeds->end(); ++seed, ++nSeed){
00096     LogTrace(metname)<<"+++ New Seed +++"<<endl;
00097     TrajectoryContainer muonTrajs_temp = theTrajBuilder->trajectories(*seed);
00098     for(TrajectoryContainer::iterator it = muonTrajs_temp.begin(); 
00099         it != muonTrajs_temp.end(); ++it){
00100       (*it)->setSeedRef(seeds->refAt(nSeed));
00101       muonTrajectories.push_back(*it); 
00102     }
00103   }
00104   
00105   // clean the clone traj
00106   LogTrace(metname)<<"Clean the trajectories container"<<endl;
00107   if(theTrajCleaner) theTrajCleaner->clean(muonTrajectories, event); //used by reference...
00108   
00109   // convert the trajectories into tracks and load them in to the event
00110   LogTrace(metname)
00111     <<"Convert the trajectories into tracks and load them in to the event"<<endl;
00112   return load(muonTrajectories,event);
00113   
00114 }
00115 
00116 
00117 // reconstruct trajectories
00118 void MuonTrackFinder::reconstruct(const std::vector<TrackCand>& staCandColl,
00119                                   Event& event){
00120 
00121   const string metname = "Muon|RecoMuon|MuonTrackFinder";
00122 
00123   // percolate the event 
00124   setEvent(event);
00125 
00126   // Muon Candidate container
00127   CandidateContainer muonCandidates;
00128 
00129   // reconstruct the muon candidates
00130   for (vector<TrackCand>::const_iterator staCand = staCandColl.begin(); staCand != staCandColl.end(); ++staCand) {
00131     CandidateContainer muonCands_temp = theTrajBuilder->trajectories(*staCand);
00132     muonCandidates.insert(muonCandidates.end(), muonCands_temp.begin(),muonCands_temp.end());
00133   }                                  
00134   
00135   // clean the cloned candidates
00136   if(theTrajCleaner) theTrajCleaner->clean(muonCandidates);
00137 
00138   // convert the trajectories into staTracks and load them into the event
00139   LogTrace(metname)<<"Load Muon Candidates into the event"<<endl;
00140   load(muonCandidates,event);
00141 
00142 }