CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
MuonToTrackingParticleAssociatorByHitsImpl Class Reference

#include <MuonToTrackingParticleAssociatorByHitsImpl.h>

Inheritance diagram for MuonToTrackingParticleAssociatorByHitsImpl:
reco::MuonToTrackingParticleAssociatorBaseImpl

Public Member Functions

void associateMuons (reco::MuonToSimCollection &recoToSim, reco::SimToMuonCollection &simToReco, const edm::RefToBaseVector< reco::Muon > &muons, reco::MuonTrackType type, const edm::RefVector< TrackingParticleCollection > &tpColl) const override
 
void associateMuons (reco::MuonToSimCollection &recoToSim, reco::SimToMuonCollection &simToReco, const edm::Handle< edm::View< reco::Muon >> &muons, reco::MuonTrackType type, const edm::Handle< TrackingParticleCollection > &tpColl) const override
 
 MuonToTrackingParticleAssociatorByHitsImpl (TrackerMuonHitExtractor const &iHitExtractor, MuonAssociatorByHitsHelper::Resources const &iResources, MuonAssociatorByHitsHelper const *iHelper)
 
- Public Member Functions inherited from reco::MuonToTrackingParticleAssociatorBaseImpl
 MuonToTrackingParticleAssociatorBaseImpl ()
 
virtual ~MuonToTrackingParticleAssociatorBaseImpl ()
 

Private Member Functions

 MuonToTrackingParticleAssociatorByHitsImpl (const MuonToTrackingParticleAssociatorByHitsImpl &)=delete
 
const MuonToTrackingParticleAssociatorByHitsImploperator= (const MuonToTrackingParticleAssociatorByHitsImpl &)=delete
 

Private Attributes

MuonAssociatorByHitsHelper const * m_helper
 
TrackerMuonHitExtractor const * m_hitExtractor
 
MuonAssociatorByHitsHelper::Resources m_resources
 

Detailed Description

MuonToTrackingParticleAssociatorByHitsImpl.h "MuonToTrackingParticleAssociatorByHitsImpl.h"

Description: [one line class summary]

Usage: <usage>

Definition at line 32 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Constructor & Destructor Documentation

MuonToTrackingParticleAssociatorByHitsImpl::MuonToTrackingParticleAssociatorByHitsImpl ( TrackerMuonHitExtractor const &  iHitExtractor,
MuonAssociatorByHitsHelper::Resources const &  iResources,
MuonAssociatorByHitsHelper const *  iHelper 
)

Definition at line 30 of file MuonToTrackingParticleAssociatorByHitsImpl.cc.

34  : m_hitExtractor(&iHitExtractor), m_resources(iResources), m_helper(iHelper) {}
MuonToTrackingParticleAssociatorByHitsImpl::MuonToTrackingParticleAssociatorByHitsImpl ( const MuonToTrackingParticleAssociatorByHitsImpl )
privatedelete

Member Function Documentation

void MuonToTrackingParticleAssociatorByHitsImpl::associateMuons ( reco::MuonToSimCollection recoToSim,
reco::SimToMuonCollection simToReco,
const edm::RefToBaseVector< reco::Muon > &  muons,
reco::MuonTrackType  type,
const edm::RefVector< TrackingParticleCollection > &  tpColl 
) const
overridevirtual

PART 1: Fill MuonToSimAssociatorByHits::TrackHitsCollection

PART 2: call the association routines

Implements reco::MuonToTrackingParticleAssociatorBaseImpl.

Definition at line 43 of file MuonToTrackingParticleAssociatorByHitsImpl.cc.

References a, MuonAssociatorByHitsHelper::associateRecoToSimIndices(), MuonAssociatorByHitsHelper::associateSimToRecoIndices(), edm::RefToBaseVector< T >::begin(), reco::LeafCandidate::charge(), edm::OwnVector< T, P >::data(), edm::RefToBaseVector< T >::end(), reco::LeafCandidate::eta(), TrackerMuonHitExtractor::getMuonHits(), reco::GlbOrTrk, reco::GlobalTk, reco::Muon::globalTrack(), hfClusterShapes_cfi::hits, bTagCombinedSVVariables_cff::indices, reco::InnerTk, reco::Muon::isGEMMuon(), reco::Muon::isGlobalMuon(), reco::Muon::isME0Muon(), reco::Muon::isMuon(), edm::Ref< C, T, F >::isNonnull(), reco::Muon::isPFMuon(), reco::Muon::isRPCMuon(), reco::Muon::isStandAloneMuon(), reco::Muon::isTrackerMuon(), edm::RefToBase< T >::key(), m_helper, m_hitExtractor, m_resources, reco::OuterTk, reco::Muon::outerTrack(), reco::LeafCandidate::p(), reco::LeafCandidate::phi(), reco::LeafCandidate::pt(), edm::RefToBaseVector< T >::push_back(), edm::RefVector< C, T, F >::push_back(), edm::OwnVector< T, P >::push_back(), reco::Segments, particleFlowSimParticle_cfi::sim, edm::RefToBaseVector< T >::size(), edm::OwnVector< T, P >::size(), and reco::Muon::track().

Referenced by associateMuons().

48  {
51  edm::OwnVector<TrackingRecHit> allTMRecHits; // this I will fill in only for tracker muon hits from
52  // segments
53 
54  std::vector<edm::OwnVector<TrackingRecHit>> TMRecHits; // used for case GlbOrTrk
56 
57  switch (type) {
58  case reco::InnerTk:
59  for (edm::RefToBaseVector<reco::Muon>::const_iterator it = muons.begin(), ed = muons.end(); it != ed; ++it) {
61  if (mur->track().isNonnull()) {
62  muonHitRefs.push_back(std::make_pair(mur->track()->recHitsBegin(), mur->track()->recHitsEnd()));
63  } else {
64  muonHitRefs.push_back(std::make_pair(allTMRecHits.data().end(), allTMRecHits.data().end()));
65  }
66  }
67  break;
68  case reco::OuterTk:
69  for (edm::RefToBaseVector<reco::Muon>::const_iterator it = muons.begin(), ed = muons.end(); it != ed; ++it) {
71  if (mur->outerTrack().isNonnull()) {
72  muonHitRefs.push_back(std::make_pair(mur->outerTrack()->recHitsBegin(), mur->outerTrack()->recHitsEnd()));
73  } else {
74  muonHitRefs.push_back(std::make_pair(allTMRecHits.data().end(), allTMRecHits.data().end()));
75  }
76  }
77  break;
78  case reco::GlobalTk:
79  for (edm::RefToBaseVector<reco::Muon>::const_iterator it = muons.begin(), ed = muons.end(); it != ed; ++it) {
81  if (mur->globalTrack().isNonnull()) {
82  muonHitRefs.push_back(std::make_pair(mur->globalTrack()->recHitsBegin(), mur->globalTrack()->recHitsEnd()));
83  } else {
84  muonHitRefs.push_back(std::make_pair(allTMRecHits.data().end(), allTMRecHits.data().end()));
85  }
86  }
87  break;
88  case reco::Segments: {
89  // puts hits in the vector, and record indices
90  std::vector<std::pair<size_t, size_t>> muonHitIndices;
91  for (edm::RefToBaseVector<reco::Muon>::const_iterator it = muons.begin(), ed = muons.end(); it != ed; ++it) {
93  std::pair<size_t, size_t> indices(allTMRecHits.size(), allTMRecHits.size());
94  if (mur->isTrackerMuon()) {
95  std::vector<const TrackingRecHit *> hits = m_hitExtractor->getMuonHits(*mur);
96  for (std::vector<const TrackingRecHit *>::const_iterator ith = hits.begin(), edh = hits.end(); ith != edh;
97  ++ith) {
98  allTMRecHits.push_back(**ith);
99  }
100  indices.second += hits.size();
101  }
102  muonHitIndices.push_back(indices);
103  }
104  // convert indices into pairs of iterators to references
105  typedef std::pair<size_t, size_t> index_pair;
106  trackingRecHit_iterator hitRefBegin = allTMRecHits.data().begin();
107  for (std::vector<std::pair<size_t, size_t>>::const_iterator idxs = muonHitIndices.begin(),
108  idxend = muonHitIndices.end();
109  idxs != idxend;
110  ++idxs) {
111  muonHitRefs.push_back(std::make_pair(hitRefBegin + idxs->first, hitRefBegin + idxs->second));
112  }
113 
114  } break;
115  case reco::GlbOrTrk: {
116  edm::LogVerbatim("MuonToTrackingParticleAssociatorByHitsImpl")
117  << "\n"
118  << "There are " << muons.size() << " selected reco::Muons.";
119 
120  int isel = 0;
121  for (edm::RefToBaseVector<reco::Muon>::const_iterator it = muons.begin(), ed = muons.end(); it != ed; ++it) {
122  edm::RefToBase<reco::Muon> mur = *it;
123 
124  edm::LogVerbatim("MuonToTrackingParticleAssociatorByHitsImpl")
125  << " #" << isel << ", reco::Muon key = " << mur.key() << ", q*p = " << mur->charge() * mur->p()
126  << ", pT = " << mur->pt() << ", eta = " << mur->eta() << ", phi = " << mur->phi();
127 
128  // Global muon with valid muon hits
129  if (mur->isGlobalMuon() && mur->globalTrack()->hitPattern().numberOfValidMuonHits() > 0) {
130  edm::LogVerbatim("MuonToTrackingParticleAssociatorByHitsImpl")
131  << "\t this is a Global Muon with valid muon hits";
132  muonHitRefs.push_back(std::make_pair(mur->globalTrack()->recHitsBegin(), mur->globalTrack()->recHitsEnd()));
133  }
134 
135  // Tracker Muon
136  else if (mur->isTrackerMuon()) {
137  edm::LogVerbatim("MuonToTrackingParticleAssociatorByHitsImpl") << "\t this is a Tracker Muon";
139 
140  std::vector<const TrackingRecHit *> hits = m_hitExtractor->getMuonHits(*mur);
141  for (std::vector<const TrackingRecHit *>::const_iterator ith = hits.begin(), edh = hits.end(); ith != edh;
142  ++ith) {
143  TMvec.push_back(**ith);
144  }
145 
146  TMRecHits.push_back(TMvec);
147 
148  muonHitRefs.push_back(std::make_pair(TMRecHits.rbegin()->data().begin(), TMRecHits.rbegin()->data().end()));
149  }
150 
151  // Standalone muon or Global without valid muon hits
152  else if (mur->outerTrack().isNonnull()) {
153  edm::LogVerbatim("MuonToTrackingParticleAssociatorByHitsImpl") << "\t this is a Standalone muon";
154  muonHitRefs.push_back(std::make_pair(mur->outerTrack()->recHitsBegin(), mur->outerTrack()->recHitsEnd()));
155  }
156 
157  else {
158  edm::LogVerbatim("MuonToTrackingParticleAssociatorByHitsImpl") << "\t what muon is this ?";
159  edm::LogVerbatim("MuonToTrackingParticleAssociatorByHitsImpl")
160  << "isMuon : " << mur->isMuon() << ", isPFMuon : " << mur->isPFMuon()
161  << ", isTrackerMuon : " << mur->isTrackerMuon() << ", isStandAloneMuon : " << mur->isStandAloneMuon()
162  << ", isGlobalMuon : " << mur->isGlobalMuon() << ", isRPCMuon : " << mur->isRPCMuon()
163  << ", isGEMMuon : " << mur->isGEMMuon() << ", isME0Muon : " << mur->isME0Muon();
164  muonHitRefs.push_back(std::make_pair(noTM.data().end(), noTM.data().end()));
165  }
166 
167  isel++;
168  } // loop on muons
169 
170  } break;
171  }
172 
174  auto recSimColl = m_helper->associateRecoToSimIndices(muonHitRefs, tPC, m_resources);
175  for (auto it = recSimColl.begin(), ed = recSimColl.end(); it != ed; ++it) {
176  edm::RefToBase<reco::Muon> rec = muons[it->first];
177  std::vector<std::pair<TrackingParticleRef, double>> &tpAss = recToSim[rec];
178  for (auto const &a : it->second) {
179  tpAss.push_back(std::make_pair(tPC[a.idx], a.quality));
180  }
181  }
182  auto simRecColl = m_helper->associateSimToRecoIndices(muonHitRefs, tPC, m_resources);
183  for (auto it = simRecColl.begin(), ed = simRecColl.end(); it != ed; ++it) {
184  TrackingParticleRef sim = tPC[it->first];
185  std::vector<std::pair<edm::RefToBase<reco::Muon>, double>> &recAss = simToRec[sim];
186  for (auto const &a : it->second) {
187  recAss.push_back(std::make_pair(muons[a.idx], a.quality));
188  }
189  }
190 }
type
Definition: HCALResponse.h:21
bool isMuon() const override
Definition: Muon.h:297
TrackRef track() const override
reference to a Track
Definition: Muon.h:46
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
double eta() const final
momentum pseudorapidity
bool isStandAloneMuon() const override
Definition: Muon.h:300
std::vector< const TrackingRecHit * > getMuonHits(const reco::Muon &mu) const
size_type size() const
Definition: OwnVector.h:300
const_iterator end() const
double pt() const final
transverse momentum
int charge() const final
electric charge
IndexAssociation associateSimToRecoIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, Resources const &) const
bool isME0Muon() const
Definition: Muon.h:305
bool isTrackerMuon() const override
Definition: Muon.h:299
bool isRPCMuon() const
Definition: Muon.h:303
void push_back(D *&d)
Definition: OwnVector.h:326
std::vector< std::pair< trackingRecHit_iterator, trackingRecHit_iterator > > TrackHitsCollection
bool isGlobalMuon() const override
Definition: Muon.h:298
size_t key() const
Definition: RefToBase.h:219
size_type size() const
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:48
double p() const final
magnitude of momentum vector
bool isGEMMuon() const
Definition: Muon.h:304
const_iterator begin() const
IndexAssociation associateRecoToSimIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, Resources const &) const
base const & data() const
Definition: OwnVector.h:476
double a
Definition: hdecay.h:119
void push_back(const RefToBase< T > &)
bool isPFMuon() const
Definition: Muon.h:302
double phi() const final
momentum azimuthal angle
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:51
void MuonToTrackingParticleAssociatorByHitsImpl::associateMuons ( reco::MuonToSimCollection recoToSim,
reco::SimToMuonCollection simToReco,
const edm::Handle< edm::View< reco::Muon >> &  muons,
reco::MuonTrackType  type,
const edm::Handle< TrackingParticleCollection > &  tpColl 
) const
overridevirtual

Implements reco::MuonToTrackingParticleAssociatorBaseImpl.

Definition at line 192 of file MuonToTrackingParticleAssociatorByHitsImpl.cc.

References associateMuons(), mps_fire::i, edm::HandleBase::id(), dqmiolumiharvest::j, edm::RefToBaseVector< T >::push_back(), and edm::RefVector< C, T, F >::push_back().

197  {
199  for (unsigned int j = 0; j < tPCH->size(); j++)
201 
202  edm::RefToBaseVector<reco::Muon> muonBaseRefVector;
203  for (size_t i = 0; i < tCH->size(); ++i)
204  muonBaseRefVector.push_back(tCH->refAt(i));
205 
206  associateMuons(recToSim, simToRec, muonBaseRefVector, type, tpc);
207 }
type
Definition: HCALResponse.h:21
void associateMuons(reco::MuonToSimCollection &recoToSim, reco::SimToMuonCollection &simToReco, const edm::RefToBaseVector< reco::Muon > &muons, reco::MuonTrackType type, const edm::RefVector< TrackingParticleCollection > &tpColl) const override
void push_back(const RefToBase< T > &)
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
const MuonToTrackingParticleAssociatorByHitsImpl& MuonToTrackingParticleAssociatorByHitsImpl::operator= ( const MuonToTrackingParticleAssociatorByHitsImpl )
privatedelete

Member Data Documentation

MuonAssociatorByHitsHelper const* MuonToTrackingParticleAssociatorByHitsImpl::m_helper
private

Definition at line 65 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Referenced by associateMuons().

TrackerMuonHitExtractor const* MuonToTrackingParticleAssociatorByHitsImpl::m_hitExtractor
private

Definition at line 63 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Referenced by associateMuons().

MuonAssociatorByHitsHelper::Resources MuonToTrackingParticleAssociatorByHitsImpl::m_resources
private

Definition at line 64 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Referenced by associateMuons().