CMS 3D CMS Logo

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

#include <LCToSimTSAssociatorByEnergyScoreImpl.h>

Inheritance diagram for LCToSimTSAssociatorByEnergyScoreImpl:
hgcal::LayerClusterToSimTracksterAssociatorBaseImpl

Public Member Functions

hgcal::RecoToSimTracksterCollection associateRecoToSim (const edm::Handle< reco::CaloClusterCollection > &cCH, const edm::Handle< ticl::TracksterCollection > &sTCH, const edm::Handle< CaloParticleCollection > &cPCH, const hgcal::RecoToSimCollection &lCToCPs, const edm::Handle< SimClusterCollection > &sCCH, const hgcal::RecoToSimCollectionWithSimClusters &lCToSCs) const override
 Associate a LayerCluster to SimTracksters. More...
 
hgcal::SimTracksterToRecoCollection associateSimToReco (const edm::Handle< reco::CaloClusterCollection > &cCH, const edm::Handle< ticl::TracksterCollection > &sTCH, const edm::Handle< CaloParticleCollection > &cPCH, const hgcal::SimToRecoCollection &cPToLCs, const edm::Handle< SimClusterCollection > &sCCH, const hgcal::SimToRecoCollectionWithSimClusters &sCToLCs) const override
 Associate a SimTrackster to LayerClusters. More...
 
 LCToSimTSAssociatorByEnergyScoreImpl (edm::EDProductGetter const &)
 
- Public Member Functions inherited from hgcal::LayerClusterToSimTracksterAssociatorBaseImpl
 LayerClusterToSimTracksterAssociatorBaseImpl ()
 Constructor. More...
 
virtual ~LayerClusterToSimTracksterAssociatorBaseImpl ()
 Destructor. More...
 

Private Attributes

edm::EDProductGetter const * productGetter_
 

Detailed Description

Definition at line 22 of file LCToSimTSAssociatorByEnergyScoreImpl.h.

Constructor & Destructor Documentation

◆ LCToSimTSAssociatorByEnergyScoreImpl()

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

Definition at line 10 of file LCToSimTSAssociatorByEnergyScoreImpl.cc.

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

Member Function Documentation

◆ associateRecoToSim()

hgcal::RecoToSimTracksterCollection LCToSimTSAssociatorByEnergyScoreImpl::associateRecoToSim ( const edm::Handle< reco::CaloClusterCollection > &  cCH,
const edm::Handle< ticl::TracksterCollection > &  sTCH,
const edm::Handle< CaloParticleCollection > &  cPCH,
const hgcal::RecoToSimCollection lCToCPs,
const edm::Handle< SimClusterCollection > &  sCCH,
const hgcal::RecoToSimCollectionWithSimClusters lCToSCs 
) const
overridevirtual

Associate a LayerCluster to SimTracksters.

Reimplemented from hgcal::LayerClusterToSimTracksterAssociatorBaseImpl.

Definition at line 13 of file LCToSimTSAssociatorByEnergyScoreImpl.cc.

References edm::AssociationMap< Tag >::end(), edm::AssociationMap< Tag >::find(), edm::HandleBase::id(), edm::AssociationMap< Tag >::insert(), LogDebug, AlCaHLTBitMon_ParallelJobs::p, edm::Handle< T >::product(), and productGetter_.

19  {
21 
22  const auto simTracksters = *sTCH.product();
23 
24  for (size_t lcId = 0; lcId < cCCH.product()->size(); ++lcId) {
25  const edm::Ref<reco::CaloClusterCollection> lcRef(cCCH, lcId);
26  for (size_t tsId = 0; tsId < simTracksters.size(); ++tsId) {
27  if (simTracksters[tsId].seedID() == cPCH.id()) {
28  const auto& cpIt = lCToCPs.find(lcRef);
29  if (cpIt == lCToCPs.end()) {
30  LogDebug("LCToSimTSAssociatorByEnergyScoreImpl")
31  << "LayerCluster Id " << lcId << " not found in CaloParticle association map\n";
32  continue;
33  }
34 
35  const edm::Ref<CaloParticleCollection> cpRef(cPCH, simTracksters[tsId].seedIndex());
36  const auto& cps = cpIt->val;
37  const auto cpPair = std::find_if(
38  std::begin(cps), std::end(cps), [&cpRef](const std::pair<edm::Ref<CaloParticleCollection>, float>& p) {
39  return p.first == cpRef;
40  });
41  if (cpPair == cps.end()) {
42  LogDebug("LCToSimTSAssociatorByEnergyScoreImpl") << "CaloParticle Id " << simTracksters[tsId].seedIndex()
43  << " not found in LayerCluster association map\n";
44  continue;
45  } else {
46  LogDebug("LCToSimTSAssociatorByEnergyScoreImpl")
47  << "LayerCluster Id: \t" << lcId << "\t CaloParticle Id: \t" << cpPair->first.index() << "\t score \t"
48  << cpPair->second << "\n";
49  // Fill AssociationMap
50  returnValue.insert(lcRef, // Ref to LC
51  std::make_pair(edm::Ref<ticl::TracksterCollection>(sTCH, tsId), // Pair <Ref to TS, score>
52  cpPair->second));
53  }
54  } else if (simTracksters[tsId].seedID() == sCCH.id()) {
55  const auto& scIt = lCToSCs.find(lcRef);
56  if (scIt == lCToSCs.end()) {
57  LogDebug("LCToSimTSAssociatorByEnergyScoreImpl")
58  << "LayerCluster Id " << lcId << " not found in SimCluster association map\n";
59  continue;
60  }
61 
62  const edm::Ref<SimClusterCollection> scRef(sCCH, simTracksters[tsId].seedIndex());
63  const auto& scs = scIt->val;
64  const auto scPair = std::find_if(
65  std::begin(scs), std::end(scs), [&scRef](const std::pair<edm::Ref<SimClusterCollection>, float>& p) {
66  return p.first == scRef;
67  });
68  if (scPair == scs.end()) {
69  LogDebug("LCToSimTSAssociatorByEnergyScoreImpl")
70  << "SimCluster Id " << simTracksters[tsId].seedIndex() << " not found in LayerCluster association map\n";
71  continue;
72  } else {
73  LogDebug("LCToSimTSAssociatorByEnergyScoreImpl")
74  << "LayerCluster Id: \t" << lcId << "\t SimCluster Id: \t" << scPair->first.index() << "\t score \t"
75  << scPair->second << "\n";
76  // Fill AssociationMap
77  returnValue.insert(lcRef, // Ref to LC
78  std::make_pair(edm::Ref<ticl::TracksterCollection>(sTCH, tsId), // Pair <Ref to TS, score>
79  scPair->second));
80  }
81  } else {
82  LogDebug("LCToSimTSAssociatorByEnergyScoreImpl")
83  << "The seedID " << simTracksters[tsId].seedID() << " of SimTrackster " << tsId
84  << " is neither a CaloParticle nor a SimCluster!\n";
85  }
86  } // end loop over simTracksters
87  } // end loop over layerClusters
88 
89  return returnValue;
90 }
ProductID id() const
Definition: HandleBase.cc:29
T const * product() const
Definition: Handle.h:70
const_iterator find(const key_type &k) const
find element with specified reference key
const_iterator end() const
last iterator over the map (read only)
#define LogDebug(id)

◆ associateSimToReco()

hgcal::SimTracksterToRecoCollection LCToSimTSAssociatorByEnergyScoreImpl::associateSimToReco ( const edm::Handle< reco::CaloClusterCollection > &  cCH,
const edm::Handle< ticl::TracksterCollection > &  sTCH,
const edm::Handle< CaloParticleCollection > &  cPCH,
const hgcal::SimToRecoCollection cPToLCs,
const edm::Handle< SimClusterCollection > &  sCCH,
const hgcal::SimToRecoCollectionWithSimClusters sCToLCs 
) const
overridevirtual

Associate a SimTrackster to LayerClusters.

Reimplemented from hgcal::LayerClusterToSimTracksterAssociatorBaseImpl.

Definition at line 92 of file LCToSimTSAssociatorByEnergyScoreImpl.cc.

References edm::AssociationMap< Tag >::end(), edm::AssociationMap< Tag >::find(), edm::HandleBase::id(), edm::AssociationMap< Tag >::insert(), LogDebug, AlCaHLTBitMon_ParallelJobs::p, edm::Handle< T >::product(), and productGetter_.

98  {
100 
101  const auto simTracksters = *sTCH.product();
102  for (size_t tsId = 0; tsId < simTracksters.size(); ++tsId) {
103  if (simTracksters[tsId].seedID() == cPCH.id()) {
104  const auto cpId = simTracksters[tsId].seedIndex();
105  const edm::Ref<CaloParticleCollection> cpRef(cPCH, cpId);
106  const auto& lcIt = cPToLCs.find(cpRef);
107  if (lcIt == cPToLCs.end()) {
108  LogDebug("LCToSimTSAssociatorByEnergyScoreImpl")
109  << "CaloParticle Id " << cpId << " not found in LayerCluster association map\n";
110  continue;
111  }
112 
113  const auto& lcs = lcIt->val;
114  for (size_t lcId = 0; lcId < lcs.size(); ++lcId) {
115  const edm::Ref<reco::CaloClusterCollection> lcRef(cCCH, lcId);
116  const auto lcPair =
117  std::find_if(std::begin(lcs),
118  std::end(lcs),
119  [&lcRef](const std::pair<edm::Ref<reco::CaloClusterCollection>, std::pair<float, float>>& p) {
120  return p.first == lcRef;
121  });
122  if (lcPair == lcs.end()) {
123  LogDebug("LCToSimTSAssociatorByEnergyScoreImpl")
124  << "LayerCluster Id " << lcId << " not found in CaloParticle association map\n";
125  continue;
126  } else {
127  LogDebug("LCToSimTSAssociatorByEnergyScoreImpl")
128  << "CaloParticle Id: \t" << cpId << "\t LayerCluster Id: \t" << lcPair->first.index() << "\t score \t"
129  << lcPair->second.second << "\n";
130  // Fill AssociationMap
131  returnValue.insert(
132  edm::Ref<ticl::TracksterCollection>(sTCH, tsId), // Ref to TS
133  std::make_pair(lcRef, // Pair <Ref to LC,
134  std::make_pair(lcPair->second.first, lcPair->second.second)) // pair <energy, score> >
135  );
136  }
137  }
138  } else if (simTracksters[tsId].seedID() == sCCH.id()) {
139  const auto scId = simTracksters[tsId].seedIndex();
140  const edm::Ref<SimClusterCollection> scRef(sCCH, scId);
141  const auto& lcIt = sCToLCs.find(scRef);
142  if (lcIt == sCToLCs.end()) {
143  LogDebug("LCToSimTSAssociatorByEnergyScoreImpl")
144  << "SimCluster Id " << scId << " not found in LayerCluster association map\n";
145  continue;
146  }
147 
148  const auto& lcs = lcIt->val;
149  for (size_t lcId = 0; lcId < lcs.size(); ++lcId) {
150  const edm::Ref<reco::CaloClusterCollection> lcRef(cCCH, lcId);
151  const auto lcPair =
152  std::find_if(std::begin(lcs),
153  std::end(lcs),
154  [&lcRef](const std::pair<edm::Ref<reco::CaloClusterCollection>, std::pair<float, float>>& p) {
155  return p.first == lcRef;
156  });
157  if (lcPair == lcs.end()) {
158  LogDebug("LCToSimTSAssociatorByEnergyScoreImpl")
159  << "LayerCluster Id " << lcId << " not found in SimCluster association map\n";
160  continue;
161  } else {
162  LogDebug("LCToSimTSAssociatorByEnergyScoreImpl")
163  << "SimCluster Id: \t" << scId << "\t LayerCluster Id: \t" << lcPair->first.index() << "\t score \t"
164  << lcPair->second.second << "\n";
165  // Fill AssociationMap
166  returnValue.insert(
167  edm::Ref<ticl::TracksterCollection>(sTCH, tsId), // Ref to TS
168  std::make_pair(lcRef, // Pair <Ref to LC,
169  std::make_pair(lcPair->second.first, lcPair->second.second)) // pair <energy, score> >
170  );
171  }
172  }
173  } else {
174  LogDebug("LCToSimTSAssociatorByEnergyScoreImpl")
175  << "The seedID " << simTracksters[tsId].seedID() << " of SimTrackster " << tsId
176  << " is neither a CaloParticle nor a SimCluster!\n";
177  }
178 
179  } // end loop over simTracksters
180  return returnValue;
181 }
ProductID id() const
Definition: HandleBase.cc:29
T const * product() const
Definition: Handle.h:70
const_iterator find(const key_type &k) const
find element with specified reference key
const_iterator end() const
last iterator over the map (read only)
#define LogDebug(id)

Member Data Documentation

◆ productGetter_

edm::EDProductGetter const* LCToSimTSAssociatorByEnergyScoreImpl::productGetter_
private