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

Description: [one line class summary]

Usage: <usage>

Definition at line 30 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Constructor & Destructor Documentation

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

Definition at line 31 of file MuonToTrackingParticleAssociatorByHitsImpl.cc.

33  :
34  m_hitExtractor(&iHitExtractor),
35  m_resources(iResources),
36  m_helper(iHelper)
37 {
38 }
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 49 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, 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().

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

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

201  {
202 
204  for (unsigned int j=0; j<tPCH->size();j++)
206 
207  edm::RefToBaseVector<reco::Muon> muonBaseRefVector;
208  for (size_t i = 0; i < tCH->size(); ++i)
209  muonBaseRefVector.push_back(tCH->refAt(i));
210 
211  associateMuons(recToSim, simToRec, muonBaseRefVector,type,tpc);
212 }
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:69
const MuonToTrackingParticleAssociatorByHitsImpl& MuonToTrackingParticleAssociatorByHitsImpl::operator= ( const MuonToTrackingParticleAssociatorByHitsImpl )
privatedelete

Member Data Documentation

MuonAssociatorByHitsHelper const* MuonToTrackingParticleAssociatorByHitsImpl::m_helper
private

Definition at line 59 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Referenced by associateMuons().

TrackerMuonHitExtractor const* MuonToTrackingParticleAssociatorByHitsImpl::m_hitExtractor
private

Definition at line 57 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Referenced by associateMuons().

MuonAssociatorByHitsHelper::Resources MuonToTrackingParticleAssociatorByHitsImpl::m_resources
private

Definition at line 58 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Referenced by associateMuons().