CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 &)
 
const
MuonToTrackingParticleAssociatorByHitsImpl
operator= (const MuonToTrackingParticleAssociatorByHitsImpl &)
 

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 )
private

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(), edm::OwnVector< T, P >::data(), edm::RefToBaseVector< T >::end(), TrackerMuonHitExtractor::getMuonHits(), reco::GlobalTk, reco::Muon::globalTrack(), reco::InnerTk, edm::Ref< C, T, F >::isNonnull(), reco::Muon::isTrackerMuon(), m_helper, m_hitExtractor, m_resources, reco::OuterTk, reco::Muon::outerTrack(), edm::RefToBaseVector< T >::push_back(), edm::RefVector< C, T, F >::push_back(), edm::OwnVector< T, P >::push_back(), reco::Segments, 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  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; ++ith) {
97  allTMRecHits.push_back(**ith);
98  }
99  indices.second += hits.size();
100  }
101  muonHitIndices.push_back(indices);
102  }
103  // convert indices into pairs of iterators to references
104  typedef std::pair<size_t, size_t> index_pair;
105  trackingRecHit_iterator hitRefBegin = allTMRecHits.data().begin();
106  for (std::vector<std::pair<size_t, size_t> >::const_iterator idxs = muonHitIndices.begin(), idxend = muonHitIndices.end(); idxs != idxend; ++idxs) {
107  muonHitRefs.push_back(std::make_pair(hitRefBegin+idxs->first,
108  hitRefBegin+idxs->second));
109  }
110 
111  }
112  break;
113  }
114 
116  auto recSimColl = m_helper->associateRecoToSimIndices(muonHitRefs,tPC, m_resources);
117  for (auto it = recSimColl.begin(), ed = recSimColl.end(); it != ed; ++it) {
118  edm::RefToBase<reco::Muon> rec = muons[it->first];
119  std::vector<std::pair<TrackingParticleRef, double> > & tpAss = recToSim[rec];
120  for ( auto const & a : it->second) {
121  tpAss.push_back(std::make_pair(tPC[a.idx], a.quality));
122  }
123  }
124  auto simRecColl = m_helper->associateSimToRecoIndices(muonHitRefs,tPC,m_resources);
125  for (auto it = simRecColl.begin(), ed = simRecColl.end(); it != ed; ++it) {
126  TrackingParticleRef sim = tPC[it->first];
127  std::vector<std::pair<edm::RefToBase<reco::Muon>, double> > & recAss = simToRec[sim];
128  for ( auto const & a: it->second ) {
129  recAss.push_back(std::make_pair(muons[a.idx], a.quality));
130  }
131  }
132 }
type
Definition: HCALResponse.h:21
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
std::vector< const TrackingRecHit * > getMuonHits(const reco::Muon &mu) const
bool isTrackerMuon() const
Definition: Muon.h:219
size_type size() const
Definition: OwnVector.h:254
const_iterator end() const
virtual TrackRef track() const
reference to a Track
Definition: Muon.h:49
Definition: sim.h:19
IndexAssociation associateSimToRecoIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, Resources const &) const
void push_back(D *&d)
Definition: OwnVector.h:280
std::vector< std::pair< trackingRecHit_iterator, trackingRecHit_iterator > > TrackHitsCollection
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
Definition: Muon.h:51
const_iterator begin() const
IndexAssociation associateRecoToSimIndices(const TrackHitsCollection &, const edm::RefVector< TrackingParticleCollection > &, Resources const &) const
base const & data() const
Definition: OwnVector.h:372
double a
Definition: hdecay.h:121
void push_back(const RefToBase< T > &)
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
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 135 of file MuonToTrackingParticleAssociatorByHitsImpl.cc.

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

139  {
140 
142  for (unsigned int j=0; j<tPCH->size();j++)
144 
145  edm::RefToBaseVector<reco::Muon> muonBaseRefVector;
146  for (size_t i = 0; i < tCH->size(); ++i)
147  muonBaseRefVector.push_back(tCH->refAt(i));
148 
149  associateMuons(recToSim, simToRec, muonBaseRefVector,type,tpc);
150 }
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
void associateMuons(reco::MuonToSimCollection &recoToSim, reco::SimToMuonCollection &simToReco, const edm::RefToBaseVector< reco::Muon > &muons, reco::MuonTrackType type, const edm::RefVector< TrackingParticleCollection > &tpColl) const override
int j
Definition: DBlmapReader.cc:9
void push_back(const RefToBase< T > &)
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:62
const MuonToTrackingParticleAssociatorByHitsImpl& MuonToTrackingParticleAssociatorByHitsImpl::operator= ( const MuonToTrackingParticleAssociatorByHitsImpl )
private

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().