CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
57  const MuonServiceProxy* service,
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  tkTrajs.push_back(std::make_unique<MuonCandidate>(nullptr, staCand.second, (*tkt).second, nullptr));
120  }
121 
122  if (tkTrajs.empty()) {
123  LogTrace(category) << " tkTrajs empty";
124  if (staCandIn.first == nullptr)
125  delete staCand.first;
126 
127  return CandidateContainer();
128  }
129 
130  CandidateContainer result = build(staCand, tkTrajs);
131  LogTrace(category) << " Found " << result.size() << " GLBMuons from one STACand";
132 
133  // free memory
134  if (staCandIn.first == nullptr)
135  delete staCand.first;
136 
137  return result;
138 }
139 
140 //
141 // make a TrackCand collection using tracker Track, Trajectory information
142 //
143 vector<GlobalMuonTrajectoryBuilder::TrackCand> GlobalMuonTrajectoryBuilder::makeTkCandCollection(
144  const TrackCand& staCand) {
145  const std::string category = "Muon|RecoMuon|GlobalMuonTrajectoryBuilder|makeTkCandCollection";
146 
147  vector<TrackCand> tkCandColl;
148 
149  vector<TrackCand> tkTrackCands;
150 
151  for (unsigned int position = 0; position != allTrackerTracks->size(); ++position) {
153  TrackCand tkCand = TrackCand((Trajectory*)nullptr, tkTrackRef);
154  tkTrackCands.push_back(tkCand);
155  }
156 
157  tkCandColl = chooseRegionalTrackerTracks(staCand, tkTrackCands);
158 
159  return tkCandColl;
160 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
MuonCandidate::CandidateContainer CandidateContainer
GlobalMuonTrackMatcher * trackMatcher() const
std::pair< const Trajectory *, reco::TrackRef > TrackCand
static const char category[]
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
#define LogTrace(id)
tuple result
Definition: mps_fire.py:311
~GlobalMuonTrajectoryBuilder() override
destructor
void setEvent(const edm::Event &) override
pass the Event to the algo at each event
double match(const TrackCand &sta, const TrackCand &track, int matchOption=0, int surfaceOption=1) const
GlobalMuonTrajectoryBuilder(const edm::ParameterSet &, const MuonServiceProxy *, edm::ConsumesCollector &)
constructor with Parameter Set and MuonServiceProxy
std::vector< std::unique_ptr< MuonCandidate > > CandidateContainer
Definition: MuonCandidate.h:18
edm::Handle< reco::TrackCollection > allTrackerTracks
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MuonTrajectoryBuilder::CandidateContainer build(const TrackCand &, MuonTrajectoryBuilder::CandidateContainer &) const
build combined trajectory from sta Track and tracker RecHits
static int position[264][3]
Definition: ReadPGInfo.cc:289
#define LogDebug(id)