CMS 3D CMS Logo

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