CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GlobalMuonTrajectoryBuilder.cc
Go to the documentation of this file.
1 
27 
28 //---------------
29 // C++ Headers --
30 //---------------
31 
32 #include <iostream>
33 #include <iomanip>
34 #include <algorithm>
35 
36 //-------------------------------
37 // Collaborating Class Headers --
38 //-------------------------------
39 
42 
44 
46 
50 
51 using namespace std;
52 using namespace edm;
53 
54 //----------------
55 // Constructors --
56 //----------------
57 
59  const MuonServiceProxy* service) : GlobalTrajectoryBuilderBase(par, service)
60 
61 {
62 
63  theTkTrackLabel = par.getParameter<edm::InputTag>("TrackerCollectionLabel");
64 
65 }
66 
67 
68 //--------------
69 // Destructor --
70 //--------------
71 
73 }
74 
75 //
76 // get information from event
77 //
79 
80  const std::string category = "Muon|RecoMuon|GlobalMuonTrajectoryBuilder|setEvent";
81 
83 
84  // get tracker TrackCollection from Event
85  event.getByLabel(theTkTrackLabel,allTrackerTracks);
86  LogDebug(category)
87  << " Found " << allTrackerTracks->size()
88  << " tracker Tracks with label "<< theTkTrackLabel;
89 
90 }
91 
92 //
93 // reconstruct trajectories
94 //
96 
97  const std::string category = "Muon|RecoMuon|GlobalMuonTrajectoryBuilder|trajectories";
98 
99  // cut on muons with low momenta
100  LogTrace(category) << " STA pt " << staCandIn.second->pt() << " rho " << staCandIn.second->innerMomentum().Rho() << " R " << staCandIn.second->innerMomentum().R() << " theCut " << thePtCut;
101 
102  // convert the STA track into a Trajectory if Trajectory not already present
103  TrackCand staCand(staCandIn);
104 
105  vector<TrackCand> regionalTkTracks = makeTkCandCollection(staCand);
106  LogTrace(category) << " Found " << regionalTkTracks.size() << " tracks within region of interest";
107 
108  // match tracker tracks to muon track
109  vector<TrackCand> trackerTracks = trackMatcher()->match(staCand, regionalTkTracks);
110  LogTrace(category) << " Found " << trackerTracks.size() << " matching tracker tracks within region of interest";
111 
112  if ( trackerTracks.empty() ) {
113  if ( staCandIn.first == 0) delete staCand.first;
114 
115  return CandidateContainer();
116  }
117 
118  // build a combined tracker-muon MuonCandidate
119  //
120  // turn tkMatchedTracks into MuonCandidates
121  //
122  LogTrace(category) << " Turn tkMatchedTracks into MuonCandidates";
123  CandidateContainer tkTrajs;
124  for (vector<TrackCand>::const_iterator tkt = trackerTracks.begin(); tkt != trackerTracks.end(); tkt++) {
125 
126  MuonCandidate* muonCand = new MuonCandidate( 0 ,staCand.second,(*tkt).second, 0);
127  tkTrajs.push_back(muonCand);
128  }
129 
130  if ( tkTrajs.empty() ) {
131  LogTrace(category) << " tkTrajs empty";
132  if ( staCandIn.first == 0) delete staCand.first;
133 
134  return CandidateContainer();
135  }
136 
137  CandidateContainer result = build(staCand, tkTrajs);
138  LogTrace(category) << " Found "<< result.size() << " GLBMuons from one STACand";
139 
140  // free memory
141  if ( staCandIn.first == 0) delete staCand.first;
142 
143  for( CandidateContainer::const_iterator it = tkTrajs.begin(); it != tkTrajs.end(); ++it) {
144  if ( (*it)->trajectory() ) delete (*it)->trajectory();
145  if ( (*it)->trackerTrajectory() ) delete (*it)->trackerTrajectory();
146  if ( *it ) delete (*it);
147  }
148  tkTrajs.clear();
149 
150 
151  return result;
152 
153 }
154 
155 //
156 // make a TrackCand collection using tracker Track, Trajectory information
157 //
158 vector<GlobalMuonTrajectoryBuilder::TrackCand> GlobalMuonTrajectoryBuilder::makeTkCandCollection(const TrackCand& staCand) {
159 
160  const std::string category = "Muon|RecoMuon|GlobalMuonTrajectoryBuilder|makeTkCandCollection";
161 
162  vector<TrackCand> tkCandColl;
163 
164  vector<TrackCand> tkTrackCands;
165 
166  for ( unsigned int position = 0; position != allTrackerTracks->size(); ++position ) {
168  TrackCand tkCand = TrackCand((Trajectory*)(0),tkTrackRef);
169  tkTrackCands.push_back(tkCand);
170  }
171 
172 
173  tkCandColl = chooseRegionalTrackerTracks(staCand,tkTrackCands);
174 
175  return tkCandColl;
176 
177 }
#define LogDebug(id)
std::vector< TrackCand > makeTkCandCollection(const TrackCand &)
make a TrackCand collection using tracker Track, Trajectory information
T getParameter(std::string const &) const
MuonCandidate::CandidateContainer CandidateContainer
virtual void setEvent(const edm::Event &)
pass the Event to the algo at each event
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
std::vector< TrackCand > chooseRegionalTrackerTracks(const TrackCand &, const std::vector< TrackCand > &)
choose tracker tracks within region of interest
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
MuonTrajectoryBuilder::CandidateContainer trajectories(const TrackCand &)
reconstruct trajectories from standalone and tracker only Tracks
tuple result
Definition: query.py:137
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
#define LogTrace(id)
edm::Handle< reco::TrackCollection > allTrackerTracks
MuonTrajectoryBuilder::CandidateContainer build(const TrackCand &, MuonTrajectoryBuilder::CandidateContainer &) const
build combined trajectory from sta Track and tracker RecHits
GlobalMuonTrajectoryBuilder(const edm::ParameterSet &, const MuonServiceProxy *)
constructor with Parameter Set and MuonServiceProxy