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 
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 }
GlobalTrajectoryBuilderBase
Definition: GlobalTrajectoryBuilderBase.h:42
GlobalTrajectoryBuilderBase::chooseRegionalTrackerTracks
std::vector< TrackCand > chooseRegionalTrackerTracks(const TrackCand &, const std::vector< TrackCand > &)
choose tracker tracks within region of interest
Definition: GlobalTrajectoryBuilderBase.cc:309
taus_updatedMVAIds_cff.category
category
Definition: taus_updatedMVAIds_cff.py:30
service
Definition: service.py:1
GlobalTrajectoryBuilderBase::thePtCut
float thePtCut
Definition: GlobalTrajectoryBuilderBase.h:144
GlobalMuonTrajectoryBuilder.h
MessageLogger.h
edm
HLT enums.
Definition: AlignableModifier.h:19
GlobalMuonTrackMatcher.h
GlobalMuonTrackMatcher::match
double match(const TrackCand &sta, const TrackCand &track, int matchOption=0, int surfaceOption=1) const
Definition: GlobalMuonTrackMatcher.cc:100
GlobalTrajectoryBuilderBase::trackMatcher
GlobalMuonTrackMatcher * trackMatcher() const
Definition: GlobalTrajectoryBuilderBase.h:115
GlobalTrajectoryBuilderBase::build
MuonTrajectoryBuilder::CandidateContainer build(const TrackCand &, MuonTrajectoryBuilder::CandidateContainer &) const
build combined trajectory from sta Track and tracker RecHits
Definition: GlobalTrajectoryBuilderBase.cc:162
MuonServiceProxy_cff.MuonServiceProxy
MuonServiceProxy
Definition: MuonServiceProxy_cff.py:15
MuonTrajectoryBuilder::CandidateContainer
MuonCandidate::CandidateContainer CandidateContainer
Definition: MuonTrajectoryBuilder.h:24
edm::Ref< TrackCollection >
GlobalMuonTrajectoryBuilder::trajectories
MuonTrajectoryBuilder::CandidateContainer trajectories(const TrackCand &) override
reconstruct trajectories from standalone and tracker only Tracks
Definition: GlobalMuonTrajectoryBuilder.cc:88
Track.h
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:49
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GlobalTrajectoryBuilderBase::setEvent
void setEvent(const edm::Event &) override
pass the Event to the algo at each event
Definition: GlobalTrajectoryBuilderBase.cc:136
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
MuonCandidate.h
MuonCandidate::CandidateContainer
std::vector< std::unique_ptr< MuonCandidate > > CandidateContainer
Definition: MuonCandidate.h:18
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
GlobalMuonTrajectoryBuilder::setEvent
void setEvent(const edm::Event &) override
pass the Event to the algo at each event
Definition: GlobalMuonTrajectoryBuilder.cc:75
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
std
Definition: JetResolutionObject.h:76
Trajectory
Definition: Trajectory.h:38
GlobalMuonTrajectoryBuilder::makeTkCandCollection
std::vector< TrackCand > makeTkCandCollection(const TrackCand &) override
make a TrackCand collection using tracker Track, Trajectory information
Definition: GlobalMuonTrajectoryBuilder.cc:143
MuonServiceProxy.h
GlobalMuonTrajectoryBuilder::~GlobalMuonTrajectoryBuilder
~GlobalMuonTrajectoryBuilder() override
destructor
Definition: GlobalMuonTrajectoryBuilder.cc:70
MuonTrajectoryBuilder::TrackCand
std::pair< const Trajectory *, reco::TrackRef > TrackCand
Definition: MuonTrajectoryBuilder.h:25
GlobalMuonTrajectoryBuilder::allTrackerTracksToken
edm::EDGetTokenT< reco::TrackCollection > allTrackerTracksToken
Definition: GlobalMuonTrajectoryBuilder.h:49
mps_fire.result
result
Definition: mps_fire.py:303
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
GlobalMuonTrajectoryBuilder::GlobalMuonTrajectoryBuilder
GlobalMuonTrajectoryBuilder(const edm::ParameterSet &, const MuonServiceProxy *, edm::ConsumesCollector &)
constructor with Parameter Set and MuonServiceProxy
Definition: GlobalMuonTrajectoryBuilder.cc:56
GlobalMuonTrajectoryBuilder::allTrackerTracks
edm::Handle< reco::TrackCollection > allTrackerTracks
Definition: GlobalMuonTrajectoryBuilder.h:50
GlobalMuonTrajectoryBuilder::theTkTrackLabel
edm::InputTag theTkTrackLabel
Definition: GlobalMuonTrajectoryBuilder.h:48