CMS 3D CMS Logo

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

#include <MuonToTrackingParticleAssociatorByHitsImpl.h>

Inheritance diagram for MuonToTrackingParticleAssociatorByHitsImpl:
reco::MuonToTrackingParticleAssociatorBaseImpl

Public Types

using TrackHitsCollection = MuonAssociatorByHitsHelper::TrackHitsCollection
 

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, TrackerHitAssociator::Config const &iTracker, CSCHitAssociator::Config const &iCSC, DTHitAssociator::Config const &iDT, RPCHitAssociator::Config const &iRPC, GEMHitAssociator::Config const &iGEM, edm::Event const &iEvent, edm::EventSetup const &iSetup, const TrackerTopology *iTopo, std::function< void(const TrackHitsCollection &, const TrackingParticleCollection &)>, MuonAssociatorByHitsHelper const *iHelper)
 
 MuonToTrackingParticleAssociatorByHitsImpl (const MuonToTrackingParticleAssociatorByHitsImpl &)=delete
 
const MuonToTrackingParticleAssociatorByHitsImploperator= (const MuonToTrackingParticleAssociatorByHitsImpl &)=delete
 
- Public Member Functions inherited from reco::MuonToTrackingParticleAssociatorBaseImpl
 MuonToTrackingParticleAssociatorBaseImpl ()
 
virtual ~MuonToTrackingParticleAssociatorBaseImpl ()
 

Private Attributes

CSCHitAssociator const m_csc
 
DTHitAssociator const m_dt
 
GEMHitAssociator const m_gem
 
MuonAssociatorByHitsHelper const * m_helper
 
TrackerMuonHitExtractor const * m_hitExtractor
 
MuonAssociatorByHitsHelper::Resources m_resources
 
RPCHitAssociator const m_rpc
 
TrackerHitAssociator const m_tracker
 

Detailed Description

MuonToTrackingParticleAssociatorByHitsImpl.h "MuonToTrackingParticleAssociatorByHitsImpl.h"

Description: [one line class summary]

Usage: <usage>

Definition at line 33 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Member Typedef Documentation

◆ TrackHitsCollection

Definition at line 35 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Constructor & Destructor Documentation

◆ MuonToTrackingParticleAssociatorByHitsImpl() [1/2]

MuonToTrackingParticleAssociatorByHitsImpl::MuonToTrackingParticleAssociatorByHitsImpl ( TrackerMuonHitExtractor const &  iHitExtractor,
TrackerHitAssociator::Config const &  iTracker,
CSCHitAssociator::Config const &  iCSC,
DTHitAssociator::Config const &  iDT,
RPCHitAssociator::Config const &  iRPC,
GEMHitAssociator::Config const &  iGEM,
edm::Event const &  iEvent,
edm::EventSetup const &  iSetup,
const TrackerTopology iTopo,
std::function< void(const TrackHitsCollection &, const TrackingParticleCollection &)>  iDiagnostics,
MuonAssociatorByHitsHelper const *  iHelper 
)

Definition at line 30 of file MuonToTrackingParticleAssociatorByHitsImpl.cc.

42  : m_hitExtractor(&iHitExtractor),
43  m_tracker(iEvent, iTracker),
44  m_csc(iEvent, iSetup, iCSC),
45  m_dt(iEvent, iSetup, iDT, true),
46  m_rpc(iEvent, iRPC),
47  m_gem(iEvent, iGEM),
48  m_resources(iTopo, &m_tracker, &m_csc, &m_dt, &m_rpc, &m_gem, iDiagnostics),
49  m_helper(iHelper) {}
int iEvent
Definition: GenABIO.cc:224

◆ MuonToTrackingParticleAssociatorByHitsImpl() [2/2]

MuonToTrackingParticleAssociatorByHitsImpl::MuonToTrackingParticleAssociatorByHitsImpl ( const MuonToTrackingParticleAssociatorByHitsImpl )
delete

Member Function Documentation

◆ associateMuons() [1/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 58 of file MuonToTrackingParticleAssociatorByHitsImpl.cc.

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, dqmdumpme::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(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, edm::RefToBase< T >::key(), m_helper, m_hitExtractor, m_resources, DiMuonV_cfg::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, MultiTrackValidator_cfi::sim, edm::OwnVector< T, P >::size(), reco::Muon::track(), and trackerHitRTTI::vector.

Referenced by associateMuons().

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

◆ associateMuons() [2/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 207 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().

212  {
214  for (unsigned int j = 0; j < tPCH->size(); j++)
216 
217  edm::RefToBaseVector<reco::Muon> muonBaseRefVector;
218  for (size_t i = 0; i < tCH->size(); ++i)
219  muonBaseRefVector.push_back(tCH->refAt(i));
220 
221  associateMuons(recToSim, simToRec, muonBaseRefVector, type, tpc);
222 }
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

◆ operator=()

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

Member Data Documentation

◆ m_csc

CSCHitAssociator const MuonToTrackingParticleAssociatorByHitsImpl::m_csc
private

Definition at line 77 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

◆ m_dt

DTHitAssociator const MuonToTrackingParticleAssociatorByHitsImpl::m_dt
private

Definition at line 78 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

◆ m_gem

GEMHitAssociator const MuonToTrackingParticleAssociatorByHitsImpl::m_gem
private

Definition at line 80 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

◆ m_helper

MuonAssociatorByHitsHelper const* MuonToTrackingParticleAssociatorByHitsImpl::m_helper
private

Definition at line 82 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Referenced by associateMuons().

◆ m_hitExtractor

TrackerMuonHitExtractor const* MuonToTrackingParticleAssociatorByHitsImpl::m_hitExtractor
private

Definition at line 75 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Referenced by associateMuons().

◆ m_resources

MuonAssociatorByHitsHelper::Resources MuonToTrackingParticleAssociatorByHitsImpl::m_resources
private

Definition at line 81 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

Referenced by associateMuons().

◆ m_rpc

RPCHitAssociator const MuonToTrackingParticleAssociatorByHitsImpl::m_rpc
private

Definition at line 79 of file MuonToTrackingParticleAssociatorByHitsImpl.h.

◆ m_tracker

TrackerHitAssociator const MuonToTrackingParticleAssociatorByHitsImpl::m_tracker
private

Definition at line 76 of file MuonToTrackingParticleAssociatorByHitsImpl.h.