CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L3MuonTrajectoryBuilder.cc
Go to the documentation of this file.
1 
27 
28 
29 //---------------
30 // C++ Headers --
31 //---------------
32 
33 #include <iostream>
34 #include <iomanip>
35 #include <algorithm>
36 
37 //-------------------------------
38 // Collaborating Class Headers --
39 //-------------------------------
40 
43 
45 
49 
53 
55 
58 
61 
63 
64 using namespace std;
65 using namespace edm;
66 
67 //----------------
68 // Constructors --
69 //----------------
70 
72  const MuonServiceProxy* service) : GlobalTrajectoryBuilderBase(par, service) {
73 
75 
76  theTkCollName = par.getParameter<edm::InputTag>("tkTrajLabel");
77 
78 }
79 
80 
81 //--------------
82 // Destructor --
83 //--------------
84 
87 }
88 
89 //
90 // get information from event
91 //
93 
94  const std::string category = "Muon|RecoMuon|L3MuonTrajectoryBuilder|setEvent";
95 
97 
98  // get tracker TrackCollection from Event
99  event.getByLabel(theTkCollName,allTrackerTracks);
100  LogDebug(category)
101  << "Found " << allTrackerTracks->size()
102  << " tracker Tracks with label "<< theTkCollName;
103 
104 }
105 
106 //
107 // reconstruct trajectories
108 //
110 
111  const std::string category = "Muon|RecoMuon|L3MuonTrajectoryBuilder|trajectories";
112 
113  // cut on muons with low momenta
114  if ( (staCandIn).second->pt() < thePtCut || (staCandIn).second->innerMomentum().Rho() < thePtCut || (staCandIn).second->innerMomentum().R() < 2.5 ) return CandidateContainer();
115 
116  // convert the STA track into a Trajectory if Trajectory not already present
117  TrackCand staCand(staCandIn);
118 
119  vector<TrackCand> trackerTracks;
120 
121  vector<TrackCand> regionalTkTracks = makeTkCandCollection(staCand);
122  LogDebug(category) << "Found " << regionalTkTracks.size() << " tracks within region of interest";
123 
124  // match tracker tracks to muon track
125  trackerTracks = trackMatcher()->match(staCand, regionalTkTracks);
126 
127  LogDebug(category) << "Found " << trackerTracks.size() << " matching tracker tracks within region of interest";
128  if ( trackerTracks.empty() ) return CandidateContainer();
129 
130  // build a combined tracker-muon MuonCandidate
131  //
132  // turn tkMatchedTracks into MuonCandidates
133  //
134  LogDebug(category) << "turn tkMatchedTracks into MuonCandidates";
135  CandidateContainer tkTrajs;
136  for (vector<TrackCand>::const_iterator tkt = trackerTracks.begin(); tkt != trackerTracks.end(); tkt++) {
137  if ((*tkt).first != 0 && (*tkt).first->isValid()) {
138  //
139  MuonCandidate* muonCand = new MuonCandidate( 0 ,staCand.second,(*tkt).second, new Trajectory(*(*tkt).first));
140  tkTrajs.push_back(muonCand);
141  // LogTrace(category) << "tpush";
142  //
143  } else {
144  MuonCandidate* muonCand = new MuonCandidate( 0 ,staCand.second,(*tkt).second, 0);
145  tkTrajs.push_back(muonCand);
146  }
147  }
148 
149  if ( tkTrajs.empty() ) {
150  LogDebug(category) << "tkTrajs empty";
151  return CandidateContainer();
152  }
153 
154  CandidateContainer result = build(staCand, tkTrajs);
155  LogDebug(category) << "Found "<< result.size() << " L3Muons from one L2Cand";
156 
157  // free memory
158  if ( staCandIn.first == 0) delete staCand.first;
159 
160  for( CandidateContainer::const_iterator it = tkTrajs.begin(); it != tkTrajs.end(); ++it) {
161  if ( (*it)->trajectory() ) delete (*it)->trajectory();
162  if ( (*it)->trackerTrajectory() ) delete (*it)->trackerTrajectory();
163  if ( *it ) delete (*it);
164  }
165  tkTrajs.clear();
166 
167  for ( vector<TrackCand>::const_iterator is = regionalTkTracks.begin(); is != regionalTkTracks.end(); ++is) {
168  delete (*is).first;
169  }
170 
171  return result;
172 
173 }
174 
175 //
176 // make a TrackCand collection using tracker Track, Trajectory information
177 //
178 vector<L3MuonTrajectoryBuilder::TrackCand> L3MuonTrajectoryBuilder::makeTkCandCollection(const TrackCand& staCand) {
179 
180  const std::string category = "Muon|RecoMuon|L3MuonTrajectoryBuilder|makeTkCandCollection";
181 
182  vector<TrackCand> tkCandColl;
183 
184  vector<TrackCand> tkTrackCands;
185 
186  for ( unsigned int position = 0; position != allTrackerTracks->size(); ++position ) {
188  TrackCand tkCand = TrackCand((Trajectory*)(0),tkTrackRef);
189  tkCandColl.push_back(tkCand);
190  }
191 
192  for(vector<TrackCand>::const_iterator tk = tkCandColl.begin(); tk != tkCandColl.end() ; ++tk) {
193  edm::Ref<L3MuonTrajectorySeedCollection> l3seedRef = (*tk).second->seedRef().castTo<edm::Ref<L3MuonTrajectorySeedCollection> >() ;
194  reco::TrackRef staTrack = l3seedRef->l2Track();
195  if(staTrack == (staCand.second) ) tkTrackCands.push_back(*tk);
196  }
197 
198  return tkTrackCands;
199 
200 }
201 
#define LogDebug(id)
T getParameter(std::string const &) const
MuonCandidate::CandidateContainer CandidateContainer
GlobalMuonTrackMatcher * trackMatcher() const
virtual void setEvent(const edm::Event &)
pass the Event to the algo at each event
std::pair< const Trajectory *, reco::TrackRef > TrackCand
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
virtual void setEvent(const edm::Event &)
pass the Event to the algo at each event
U second(std::pair< T, U > const &p)
L3MuonTrajectoryBuilder(const edm::ParameterSet &, const MuonServiceProxy *)
constructor with Parameter Set and MuonServiceProxy
edm::Handle< reco::TrackCollection > allTrackerTracks
tuple result
Definition: query.py:137
std::vector< TrackCand > makeTkCandCollection(const TrackCand &)
make a TrackCand collection using tracker Track, Trajectory information
std::vector< MuonCandidate * > CandidateContainer
Definition: MuonCandidate.h:22
double match(const TrackCand &sta, const TrackCand &track, int matchOption=0, int surfaceOption=1) const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
MuonTrajectoryBuilder::CandidateContainer trajectories(const TrackCand &)
reconstruct trajectories from standalone and tracker only Tracks
MuonTrajectoryBuilder::CandidateContainer build(const TrackCand &, MuonTrajectoryBuilder::CandidateContainer &) const
build combined trajectory from sta Track and tracker RecHits
TrajectoryCleaner * theTrajectoryCleaner