CMS 3D CMS Logo

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

#include <MtdSimLayerClusterToTPAssociatorByTrackIdImpl.h>

Inheritance diagram for MtdSimLayerClusterToTPAssociatorByTrackIdImpl:
reco::MtdSimLayerClusterToTPAssociatorBaseImpl

Public Member Functions

reco::SimToTPCollectionMtd associateSimToTP (const edm::Handle< MtdSimLayerClusterCollection > &simClusH, const edm::Handle< TrackingParticleCollection > &trackingParticleH) const override
 Associate a MtdSimLayerCluster to TrackingParticle. More...
 
reco::TPToSimCollectionMtd associateTPToSim (const edm::Handle< MtdSimLayerClusterCollection > &simClusH, const edm::Handle< TrackingParticleCollection > &trackingParticleH) const override
 Associate a TrackingParticle to MtdSimLayerCluster. More...
 
 MtdSimLayerClusterToTPAssociatorByTrackIdImpl (edm::EDProductGetter const &)
 
- Public Member Functions inherited from reco::MtdSimLayerClusterToTPAssociatorBaseImpl
 MtdSimLayerClusterToTPAssociatorBaseImpl ()
 Constructor. More...
 
virtual ~MtdSimLayerClusterToTPAssociatorBaseImpl ()
 Destructor. More...
 

Private Attributes

edm::EDProductGetter const * productGetter_
 

Detailed Description

Definition at line 10 of file MtdSimLayerClusterToTPAssociatorByTrackIdImpl.h.

Constructor & Destructor Documentation

◆ MtdSimLayerClusterToTPAssociatorByTrackIdImpl()

MtdSimLayerClusterToTPAssociatorByTrackIdImpl::MtdSimLayerClusterToTPAssociatorByTrackIdImpl ( edm::EDProductGetter const &  productGetter)
explicit

Definition at line 11 of file MtdSimLayerClusterToTPAssociatorByTrackIdImpl.cc.

EDProductGetter const * productGetter(std::atomic< void const *> const &iCache)

Member Function Documentation

◆ associateSimToTP()

reco::SimToTPCollectionMtd MtdSimLayerClusterToTPAssociatorByTrackIdImpl::associateSimToTP ( const edm::Handle< MtdSimLayerClusterCollection > &  simClusH,
const edm::Handle< TrackingParticleCollection > &  trackingParticleH 
) const
overridevirtual

Associate a MtdSimLayerCluster to TrackingParticle.

Reimplemented from reco::MtdSimLayerClusterToTPAssociatorBaseImpl.

Definition at line 19 of file MtdSimLayerClusterToTPAssociatorByTrackIdImpl.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, LogDebug, valuemaptraslator_cfi::outputCollection, edm::Handle< T >::product(), productGetter_, EncodedEventId::rawId(), SimClusterToCaloParticleAssociation_cfi::simClusters, cmsswSequenceInfo::tp, and muonClassificationByHits_cfi::trackingParticles.

21  {
23 
24  // -- get the collections
25  const auto& simClusters = *simClusH.product();
26  const auto& trackingParticles = *trackingParticleH.product();
27 
28  // -- Loop over tracking particles and build a temporary map of trackId, eventId --> tpRef
29  std::map<std::pair<unsigned int, uint32_t>, TrackingParticleRef> tpIdMap;
30  for (auto tpIt = trackingParticles.begin(); tpIt != trackingParticles.end(); tpIt++) {
31  const auto& tp = *tpIt;
32  unsigned int tpTrackId = tp.g4Tracks()[0].trackId();
33  EncodedEventId tpEventId = tp.eventId();
34  TrackingParticleRef tpRef =
35  edm::Ref<TrackingParticleCollection>(trackingParticleH, tpIt - trackingParticles.begin());
36  tpIdMap[std::make_pair(tpTrackId, tpEventId.rawId())] = tpRef;
37  }
38 
39  // -- loop over sim clusters and get the trackId, eventId
40 
41  LogDebug("MtdSimLayerClusterToTPAssociator")
42  << " Found " << simClusters.size() << " MtdSimLayerClusters in the event";
43 
44  for (auto simClusIt = simClusters.begin(); simClusIt != simClusters.end(); simClusIt++) {
45  const auto& simClus = *simClusIt;
46  size_t simClusIndex = simClusIt - simClusters.begin();
47  MtdSimLayerClusterRef simClusterRef = edm::Ref<MtdSimLayerClusterCollection>(simClusH, simClusIndex);
48  unsigned int simClusTrackId = simClus.g4Tracks()[0].trackId();
49  EncodedEventId simClusEventId = simClus.eventId();
50 
51  // -- Check the trackId offset of the sim hits and keep only clusters with "direct" hits (offset == 0)
52  /*
53  if (simClus.trackIdOffset() != 0 ) continue;
54  */
55 
56  std::pair uniqueId = std::make_pair(simClusTrackId, simClusEventId.rawId());
57  auto it = tpIdMap.find(uniqueId);
58 
59  if (it != tpIdMap.end()) {
60  TrackingParticleRef tpRef = tpIdMap[uniqueId];
61  outputCollection.insert(simClusterRef, tpRef);
62 
63  LogDebug("MtdSimLayerClusterToTPAssociator::associateSimToTP")
64  << "MtdSimLayerCluster: index = " << simClusIndex << " simClus TrackId = " << simClusTrackId
65  << " simClus EventId = " << simClusEventId.rawId() << " simClus Eta = " << simClus.eta()
66  << " simClus Phi = " << simClus.phi() << " simClus Time = " << simClus.simLCTime()
67  << " simClus Energy = " << simClus.simLCEnergy() << std::endl;
68  LogDebug("MtdSimLayerClusterToTPAssociator::associateSimToTP")
69  << " --> Found associated tracking particle: tp TrackId = " << (*tpRef).g4Tracks()[0].trackId()
70  << " tp EventId = " << (*tpRef).eventId().rawId() << std::endl;
71  }
72 
73  } // -- end loop over sim clus
74 
75  return outputCollection;
76 }
uint32_t rawId() const
get the raw id
T const * product() const
Definition: Handle.h:70
#define LogDebug(id)

◆ associateTPToSim()

reco::TPToSimCollectionMtd MtdSimLayerClusterToTPAssociatorByTrackIdImpl::associateTPToSim ( const edm::Handle< MtdSimLayerClusterCollection > &  simClusH,
const edm::Handle< TrackingParticleCollection > &  trackingParticleH 
) const
overridevirtual

Associate a TrackingParticle to MtdSimLayerCluster.

Reimplemented from reco::MtdSimLayerClusterToTPAssociatorBaseImpl.

Definition at line 78 of file MtdSimLayerClusterToTPAssociatorByTrackIdImpl.cc.

References mps_fire::i, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, LogDebug, valuemaptraslator_cfi::outputCollection, edm::Handle< T >::product(), productGetter_, push_back(), EncodedEventId::rawId(), SimClusterToCaloParticleAssociation_cfi::simClusters, cmsswSequenceInfo::tp, and muonClassificationByHits_cfi::trackingParticles.

80  {
82 
83  // -- get the collections
84  const auto& simClusters = *simClusH.product();
85  const auto& trackingParticles = *trackingParticleH.product();
86 
87  // -- Loop over MtdSimLayerClusters and build a temporary map of trackId, eventId --> simClusterRef
88  std::map<std::pair<unsigned int, uint32_t>, std::vector<MtdSimLayerClusterRef>> simClusIdMap;
89  for (auto simClusIt = simClusters.begin(); simClusIt != simClusters.end(); simClusIt++) {
90  const auto& simClus = *simClusIt;
91  unsigned int simClusTrackId = simClus.g4Tracks()[0].trackId();
92  EncodedEventId simClusEventId = simClus.eventId();
93  MtdSimLayerClusterRef simClusterRef =
94  edm::Ref<MtdSimLayerClusterCollection>(simClusH, simClusIt - simClusters.begin());
95  simClusIdMap[std::make_pair(simClusTrackId, simClusEventId.rawId())].push_back(simClusterRef);
96  }
97 
98  // -- Loop over the tracking particles
99  for (auto tpIt = trackingParticles.begin(); tpIt != trackingParticles.end(); tpIt++) {
100  const auto& tp = *tpIt;
101  size_t tpIndex = tpIt - trackingParticles.begin();
102  TrackingParticleRef tpRef = edm::Ref<TrackingParticleCollection>(trackingParticleH, tpIndex);
103  unsigned int tpTrackId = tp.g4Tracks()[0].trackId();
104  EncodedEventId tpEventId = tp.eventId();
105 
106  std::pair uniqueId = std::make_pair(tpTrackId, tpEventId.rawId());
107  auto it = simClusIdMap.find(uniqueId);
108 
109  if (it != simClusIdMap.end()) {
110  for (unsigned int i = 0; i < simClusIdMap[uniqueId].size(); i++) {
111  MtdSimLayerClusterRef simClusterRef = simClusIdMap[uniqueId][i];
112  // -- Check the trackId offset of the sim hits and keep only clusters with "direct" hits (offset == 0)
113  /*
114  if (simClus.trackIdOffset() != 0 ) continue;
115  */
116 
117  outputCollection.insert(tpRef, simClusterRef);
118 
119  LogDebug("MtdSimLayerClusterToTPAssociator")
120  << "Tracking particle: index = " << tpIndex << " tp TrackId = " << tpTrackId
121  << " tp EventId = " << tpEventId.rawId();
122  LogDebug("MtdSimLayerClusterToTPAssociator")
123  << " --> Found associated MtdSimLayerCluster: simClus TrackId = "
124  << (*simClusterRef).g4Tracks()[0].trackId() << " simClus EventId = " << (*simClusterRef).eventId().rawId()
125  << " simClus Eta = " << (*simClusterRef).eta() << " simClus Phi = " << (*simClusterRef).phi()
126  << " simClus Time = " << (*simClusterRef).simLCTime()
127  << " simClus Energy = " << (*simClusterRef).simLCEnergy() << std::endl;
128  }
129  }
130  }
131 
132  return outputCollection;
133 }
uint32_t rawId() const
get the raw id
T const * product() const
Definition: Handle.h:70
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
#define LogDebug(id)

Member Data Documentation

◆ productGetter_

edm::EDProductGetter const* MtdSimLayerClusterToTPAssociatorByTrackIdImpl::productGetter_
private