ATLAS Offline Software
ClusterToTruthAssociation.h
Go to the documentation of this file.
1 #ifndef ACTSTRK_CLUSTERTOTRUTHASSOCIATION_H
2 #define ACTSTRK_CLUSTERTOTRUTHASSOCIATION_H 1
3 
8 
11 #include <unordered_map>
12 
14 
15 // Adapter to use MeasurementToTruthAssociation algorithm to
16 // xAOD::PixelClusterContainer and xAOD::StripClusterContainer to
17 // xAOD::TruthParticles using the InDetSimDataCollection and
18 // the xAODTruthParticleLink which pairs HepMcParticleLinks with the
19 // corresponding xAOD::TruthParticle.
20 
21 #include <iostream>
22 
24 {
25 private:
27 public:
29  : m_truthParticleLinks(&truth_particle_links)
30  {}
31  operator bool() const {
32  return true;
33  }
35  if (deposit.first.isValid()) {
36  ElementLink<xAOD::TruthParticleContainer> truth_particle_link = m_truthParticleLinks->find(deposit.first);
37  if (truth_particle_link) {
38  return *truth_particle_link;
39  }
40  }
41  return nullptr;
42  }
43  inline bool isHardScatter(const InDetSimData::Deposit &deposit) {
44  return deposit.first.eventIndex()==0;
45  }
46 };
47 
48 // specialisation for the MeasurementToTruthAssociationAlg
49 template <>
50 inline auto ActsTrk::makeDepositToTruthParticleMap(const xAODTruthParticleLinkVector *truth_particle_links) {
51  if (!truth_particle_links) {
52  throw std::runtime_error("Invalid xAODTruthParticleLinkVector.");
53  }
54 
55  return HepMcLinkToTruthParticleMap(*truth_particle_links);
56 }
57 
58 // property name for the input xAODTruthParticleLinkVector
59 template <>
60 inline const char *ActsTrk::getInTruthPropertyName<xAODTruthParticleLinkVector>() {
61  return "InputTruthParticleLinks";
62 }
63 
64 // specialisation for the MeasurementToTruthAssociationAlg
65 template <>
66 inline auto ActsTrk::getSimDataDeposits([[maybe_unused]] const InDetSimDataCollection &sim_data_collection,
67  InDetSimDataCollection::const_iterator sim_data_iter_for_identifier) {
68  return sim_data_iter_for_identifier->second.getdeposits();
69 }
70 
71 template <>
72 inline float ActsTrk::getDepositedEnergy(const std::pair<HepMcParticleLink, float> &deposit) {
73  return deposit.second;
74 }
75 
77 
78 
79 namespace ActsTrk {
80 
81  // name the specialistion to get a nicer name in python
83  : public MeasurementToTruthAssociationAlg<xAOD::PixelClusterContainer,
84  InDetSimDataCollection,
85  xAODTruthParticleLinkVector,
86  MeasurementToTruthAssociationDebugHistograms>
87  {
88  public:
93  };
94 
95  // name the specialistion to get a nicer name in python
97  : public MeasurementToTruthAssociationAlg<xAOD::StripClusterContainer,
98  InDetSimDataCollection,
99  xAODTruthParticleLinkVector,
100  MeasurementToTruthAssociationDebugHistograms>
101  {
102  public:
107  };
108  // name the specialistion to get a nicer name in python
110  : public MeasurementToTruthAssociationAlg<xAOD::HGTDClusterContainer,
111  InDetSimDataCollection,
112  xAODTruthParticleLinkVector,
113  MeasurementToTruthAssociationDebugHistograms>
114  {
115  public:
120  };
121 
122 }
123 #endif
HepMcLinkToTruthParticleMap::HepMcLinkToTruthParticleMap
HepMcLinkToTruthParticleMap(const xAODTruthParticleLinkVector &truth_particle_links)
Definition: ClusterToTruthAssociation.h:28
xAODTruthParticleLinkVector::find
ElementLink< xAOD::TruthParticleContainer > find(const HepMcParticleLink &hepMCLink) const
Definition: xAODTruthParticleLink.h:28
ActsTrk::makeDepositToTruthParticleMap
auto makeDepositToTruthParticleMap(const T_TruthEventCollection *truth_particle_links)
InDetSimDataCollection
Definition: InDetSimDataCollection.h:25
ActsTrk::MeasurementToTruthAssociationAlg
Algorithm template to associate measurements of a certain type to a xAOD truth particles using a sim ...
Definition: MeasurementToTruthAssociationAlg.h:141
ActsTrk::PixelClusterToTruthAssociationAlg
Definition: ClusterToTruthAssociation.h:87
ActsTrk::getDepositedEnergy
float getDepositedEnergy(const T_Deposit &)
HepMcLinkToTruthParticleMap::m_truthParticleLinks
const xAODTruthParticleLinkVector * m_truthParticleLinks
Definition: ClusterToTruthAssociation.h:26
ActsTrk::HgtdClusterToTruthAssociationAlg
Definition: ClusterToTruthAssociation.h:114
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
xAOD::HGTDClusterContainer
HGTDClusterContainer_v1 HGTDClusterContainer
Define the version of the HGTD cluster container.
Definition: HGTDClusterContainer.h:14
PixelClusterContainer.h
HGTDClusterContainer.h
MeasurementToTruthAssociationDebugHistograms
constexpr bool MeasurementToTruthAssociationDebugHistograms
Definition: ClusterToTruthAssociation.h:76
xAOD::PixelClusterContainer
PixelClusterContainer_v1 PixelClusterContainer
Define the version of the pixel cluster container.
Definition: Event/xAOD/xAODInDetMeasurement/xAODInDetMeasurement/PixelClusterContainer.h:14
xAOD::StripClusterContainer
StripClusterContainer_v1 StripClusterContainer
Define the version of the strip cluster container.
Definition: StripClusterContainer.h:14
MeasurementToTruthAssociationAlg.h
HepMcLinkToTruthParticleMap::isHardScatter
bool isHardScatter(const InDetSimData::Deposit &deposit)
Definition: ClusterToTruthAssociation.h:43
HepMcLinkToTruthParticleMap::getTruthParticle
const xAOD::TruthParticle * getTruthParticle(const InDetSimData::Deposit &deposit)
Definition: ClusterToTruthAssociation.h:34
StripClusterContainer.h
InDetSimDataCollection.h
xAODTruthParticleLinkVector
Definition: xAODTruthParticleLink.h:26
ActsTrk::MeasurementToTruthAssociationAlg< xAOD::PixelClusterContainer, InDetSimDataCollection, xAODTruthParticleLinkVector, MeasurementToTruthAssociationDebugHistograms >::MeasurementToTruthAssociationAlg
MeasurementToTruthAssociationAlg(const std::string &name, ISvcLocator *pSvcLocator)
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MSTrackingVolumeBuilder.cxx:24
InDetSimData::Deposit
std::pair< HepMcParticleLink, float > Deposit
Definition: InDetSimData.h:48
ActsTrk::getSimDataDeposits
auto getSimDataDeposits(const T_SimDataCollection &sim_data_collection, T_SimDataIterator sim_data_iter_for_identifier)
xAOD::bool
setBGCode setTAP setLVL2ErrorBits bool
Definition: TrigDecision_v1.cxx:60
HepMcLinkToTruthParticleMap
Definition: ClusterToTruthAssociation.h:24
ActsTrk::StripClusterToTruthAssociationAlg
Definition: ClusterToTruthAssociation.h:101