CMS 3D CMS Logo

MuonTrackFinder.cc
Go to the documentation of this file.
1 
11 
16 
21 
24 
27 
28 using namespace std;
29 using namespace edm;
30 
31 // Constructor, with default cleaner. For the STA reconstruction the trackLoader must have the propagator.
32 MuonTrackFinder::MuonTrackFinder(MuonTrajectoryBuilder* ConcreteMuonTrajectoryBuilder, MuonTrackLoader* trackLoader)
33  : theTrajBuilder(ConcreteMuonTrajectoryBuilder),
34  theTrajCleaner(new MuonTrajectoryCleaner()),
35  theTrackLoader(trackLoader) {}
36 
37 // Constructor, with user-defined cleaner. For the STA reconstruction the trackLoader must have the propagator.
39  MuonTrackLoader* trackLoader,
40  MuonTrajectoryCleaner* cleaner)
41  : theTrajBuilder(ConcreteMuonTrajectoryBuilder), theTrajCleaner(cleaner), theTrackLoader(trackLoader) {}
42 
43 // destructor
45  LogTrace("Muon|RecoMuon|MuonTrackFinder") << "MuonTrackFinder destructor called" << endl;
46  delete theTrajBuilder;
47  delete theTrajCleaner;
48  delete theTrackLoader;
49 }
50 
51 // percolate the event setup
53 
54 // convert the trajectories into tracks and load them in to the event
57  const TrackerTopology& ttopo) {
58  return theTrackLoader->loadTracks(trajectories, event, ttopo);
59 }
60 
61 // convert the trajectories into tracks and load them in to the event
62 void MuonTrackFinder::load(const CandidateContainer& muonCands, Event& event, const TrackerTopology& ttopo) {
63  theTrackLoader->loadTracks(muonCands, event, ttopo);
64 }
65 
66 // reconstruct trajectories
69  const string metname = "Muon|RecoMuon|MuonTrackFinder";
70  LogTrace(metname) << "SA Recostruction starting from: " << seeds->size() << endl;
71 
72  // Percolate the event
73  setEvent(event);
74 
76  es.get<TrackerTopologyRcd>().get(httopo);
77 
78  // Trajectory container
79  TrajectoryContainer muonTrajectories;
81  // reconstruct the trajectory
83  for (seed = seeds->begin(); seed != seeds->end(); ++seed, ++nSeed) {
84  LogTrace(metname) << "+++ New Seed +++" << endl;
85  TrajectoryContainer muonTrajs_temp = theTrajBuilder->trajectories(*seed);
86  for (TrajectoryContainer::iterator it = muonTrajs_temp.begin(); it != muonTrajs_temp.end(); ++it) {
87  (*it)->setSeedRef(seeds->refAt(nSeed));
88  muonTrajectories.push_back(*it);
89  }
90  }
91 
92  // clean the clone traj
93  LogTrace(metname) << "Clean the trajectories container" << endl;
94  if (theTrajCleaner)
95  theTrajCleaner->clean(muonTrajectories, event, seeds); //used by reference...
96 
97  // convert the trajectories into tracks and load them in to the event
98  LogTrace(metname) << "Convert the trajectories into tracks and load them in to the event" << endl;
99  return load(muonTrajectories, event, *httopo);
100 }
101 
102 // reconstruct trajectories
103 void MuonTrackFinder::reconstruct(const std::vector<TrackCand>& staCandColl, Event& event, const edm::EventSetup& es) {
104  const string metname = "Muon|RecoMuon|MuonTrackFinder";
105 
106  // percolate the event
107  setEvent(event);
108 
110  es.get<TrackerTopologyRcd>().get(httopo);
111 
112  // Muon Candidate container
114 
115  // reconstruct the muon candidates
116  for (vector<TrackCand>::const_iterator staCand = staCandColl.begin(); staCand != staCandColl.end(); ++staCand) {
117  CandidateContainer muonCands_temp = theTrajBuilder->trajectories(*staCand);
118  muonCandidates.insert(muonCandidates.end(), muonCands_temp.begin(), muonCands_temp.end());
119  }
120 
121  // clean the cloned candidates
122  if (theTrajCleaner)
123  theTrajCleaner->clean(muonCandidates);
124 
125  // convert the trajectories into staTracks and load them into the event
126  LogTrace(metname) << "Load Muon Candidates into the event" << endl;
127  load(muonCandidates, event, *httopo);
128 }
void clean(TrajectoryContainer &muonTrajectories, edm::Event &evt, const edm::Handle< edm::View< TrajectorySeed > > &seeds)
Clean the trajectories container, erasing the (worst) clone trajectory.
const std::string metname
uint16_t size_type
virtual TrajectoryContainer trajectories(const TrajectorySeed &)=0
return a container of the reconstructed trajectories compatible with a given seed ...
void setEvent(const edm::Event &)
percolate the Event Setup
virtual ~MuonTrackFinder()
destructor
virtual void setEvent(const edm::Event &event)=0
pass the Event to the algo at each event
const_iterator begin() const
MuonTrackFinder(MuonTrajectoryBuilder *ConcreteMuonTrajectoryBuilder, MuonTrackLoader *trackLoader)
Constructor, with default cleaner. For the STA reconstruction the trackLoader must have the propagato...
edm::OrphanHandle< reco::TrackCollection > load(const TrajectoryContainer &, edm::Event &, const TrackerTopology &ttopo)
convert the trajectories into tracks and load them in to the event
edm::OrphanHandle< reco::TrackCollection > loadTracks(const TrajectoryContainer &, edm::Event &, const TrackerTopology &ttopo, const std::string &="", bool=true)
Convert the trajectories into tracks and load the tracks in the event.
MuonTrackLoader * theTrackLoader
#define LogTrace(id)
MuonCandidate::TrajectoryContainer TrajectoryContainer
MuonTrajectoryBuilder * theTrajBuilder
MuonTrajectoryCleaner * theTrajCleaner
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
T get() const
Definition: EventSetup.h:73
const_iterator end() const
edm::OrphanHandle< reco::TrackCollection > reconstruct(const edm::Handle< edm::View< TrajectorySeed > > &, edm::Event &, const edm::EventSetup &)
reconstruct standalone tracks starting from a collection of seeds
Definition: event.py:1
MuonCandidate::CandidateContainer CandidateContainer