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::Handle< edm::View< reco::Muon >> &muons, reco::MuonTrackType type, const edm::Handle< TrackingParticleCollection > &tpColl) const override
 
void associateMuons (reco::MuonToSimCollection &recoToSim, reco::SimToMuonCollection &simToReco, const edm::RefToBaseVector< reco::Muon > &muons, reco::MuonTrackType type, const edm::RefVector< 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

const MuonAssociatorByHitsHelperm_helper
 
const TrackerMuonHitExtractorm_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() [1/2]

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() [2/2]

MuonToTrackingParticleAssociatorByHitsImpl::MuonToTrackingParticleAssociatorByHitsImpl ( const MuonToTrackingParticleAssociatorByHitsImpl )
privatedelete

Member Function Documentation

◆ associateMuons() [1/2]

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.

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 }

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

◆ associateMuons() [2/2]

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.

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 }

References a, MuonAssociatorByHitsHelper::associateRecoToSimIndices(), MuonAssociatorByHitsHelper::associateSimToRecoIndices(), reco::LeafCandidate::charge(), edm::OwnVector< T, P >::data(), 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, PDWG_BPHSkim_cff::muons, reco::OuterTk, reco::Muon::outerTrack(), reco::LeafCandidate::p(), reco::LeafCandidate::phi(), reco::LeafCandidate::pt(), edm::RefVector< C, T, F >::push_back(), edm::OwnVector< T, P >::push_back(), reco::Segments, particleFlowSimParticle_cfi::sim, edm::OwnVector< T, P >::size(), reco::Muon::track(), and trackerHitRTTI::vector.

Referenced by associateMuons().

◆ operator=()

const MuonToTrackingParticleAssociatorByHitsImpl& MuonToTrackingParticleAssociatorByHitsImpl::operator= ( const MuonToTrackingParticleAssociatorByHitsImpl )
privatedelete

Member Data Documentation

◆ m_helper

const MuonAssociatorByHitsHelper* MuonToTrackingParticleAssociatorByHitsImpl::m_helper
private

Definition at line 65 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Referenced by associateMuons().

◆ m_hitExtractor

const TrackerMuonHitExtractor* MuonToTrackingParticleAssociatorByHitsImpl::m_hitExtractor
private

Definition at line 63 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Referenced by associateMuons().

◆ m_resources

MuonAssociatorByHitsHelper::Resources MuonToTrackingParticleAssociatorByHitsImpl::m_resources
private

Definition at line 64 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Referenced by associateMuons().

bTagCombinedSVVariables_cff.indices
indices
Definition: bTagCombinedSVVariables_cff.py:67
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
mps_fire.i
i
Definition: mps_fire.py:428
reco::Muon::isGEMMuon
bool isGEMMuon() const
Definition: Muon.h:305
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
edm::RefToBase::key
size_t key() const
Definition: RefToBase.h:219
reco::Muon::isRPCMuon
bool isRPCMuon() const
Definition: Muon.h:304
MuonToTrackingParticleAssociatorByHitsImpl::m_helper
const MuonAssociatorByHitsHelper * m_helper
Definition: MuonToTrackingParticleAssociatorByHitsImpl.h:65
reco::OuterTk
Definition: MuonTrackType.h:28
MuonToTrackingParticleAssociatorByHitsImpl::m_hitExtractor
const TrackerMuonHitExtractor * m_hitExtractor
Definition: MuonToTrackingParticleAssociatorByHitsImpl.h:63
reco::Muon::isME0Muon
bool isME0Muon() const
Definition: Muon.h:306
reco::InnerTk
Definition: MuonTrackType.h:28
edm::RefVector< TrackingParticleCollection >
MuonAssociatorByHitsHelper::TrackHitsCollection
std::vector< std::pair< trackingRecHit_iterator, trackingRecHit_iterator > > TrackHitsCollection
Definition: MuonAssociatorByHitsHelper.h:34
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
reco::Muon::isMuon
bool isMuon() const override
Definition: Muon.h:298
TrackerMuonHitExtractor::getMuonHits
std::vector< const TrackingRecHit * > getMuonHits(const reco::Muon &mu) const
Definition: TrackerMuonHitExtractor.cc:100
edm::Ref< TrackingParticleCollection >
MuonToTrackingParticleAssociatorByHitsImpl::associateMuons
void associateMuons(reco::MuonToSimCollection &recoToSim, reco::SimToMuonCollection &simToReco, const edm::RefToBaseVector< reco::Muon > &muons, reco::MuonTrackType type, const edm::RefVector< TrackingParticleCollection > &tpColl) const override
Definition: MuonToTrackingParticleAssociatorByHitsImpl.cc:43
edm::RefToBaseVector::push_back
void push_back(const RefToBase< T > &)
Definition: RefToBaseVector.h:217
MuonAssociatorByHitsHelper::associateSimToRecoIndices
IndexAssociation associateSimToRecoIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, Resources const &) const
Definition: MuonAssociatorByHitsHelper.cc:406
reco::Muon::outerTrack
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:48
edm::reftobase::BaseVectorHolder::const_iterator
Definition: BaseVectorHolder.h:54
reco::GlbOrTrk
Definition: MuonTrackType.h:28
reco::GlobalTk
Definition: MuonTrackType.h:28
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
reco::Muon::isGlobalMuon
bool isGlobalMuon() const override
Definition: Muon.h:299
particleFlowSimParticle_cfi.sim
sim
Definition: particleFlowSimParticle_cfi.py:21
a
double a
Definition: hdecay.h:119
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
reco::Muon::globalTrack
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:51
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
sim
Definition: GeometryProducer.h:20
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
reco::LeafCandidate::charge
int charge() const final
electric charge
Definition: LeafCandidate.h:106
edm::RefVector::push_back
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
edm::RefToBaseVector
Definition: EDProductfwd.h:29
reco::Muon::isPFMuon
bool isPFMuon() const
Definition: Muon.h:303
MuonToTrackingParticleAssociatorByHitsImpl::m_resources
MuonAssociatorByHitsHelper::Resources m_resources
Definition: MuonToTrackingParticleAssociatorByHitsImpl.h:64
reco::Muon::track
TrackRef track() const override
reference to a Track
Definition: Muon.h:46
reco::Muon::isTrackerMuon
bool isTrackerMuon() const override
Definition: Muon.h:300
reco::LeafCandidate::phi
double phi() const final
momentum azimuthal angle
Definition: LeafCandidate.h:148
edm::OwnVector::data
base const & data() const
Definition: OwnVector.h:476
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
MuonAssociatorByHitsHelper::associateRecoToSimIndices
IndexAssociation associateRecoToSimIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, Resources const &) const
Definition: MuonAssociatorByHitsHelper.cc:65
reco::LeafCandidate::p
double p() const final
magnitude of momentum vector
Definition: LeafCandidate.h:123
edm::RefToBase
Definition: AssociativeIterator.h:54
reco::Muon::isStandAloneMuon
bool isStandAloneMuon() const override
Definition: Muon.h:301
edm::OwnVector::push_back
void push_back(D *&d)
Definition: OwnVector.h:326
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::OwnVector::size
size_type size() const
Definition: OwnVector.h:300
reco::Segments
Definition: MuonTrackType.h:28
edm::OwnVector< TrackingRecHit >