ATLAS Offline Software
Loading...
Searching...
No Matches
ClusterToTruthAssociation.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef ACTSTRK_CLUSTERTOTRUTHASSOCIATION_H
5#define ACTSTRK_CLUSTERTOTRUTHASSOCIATION_H 1
6
11
14#include <unordered_map>
15
17
18// Adapter to use MeasurementToTruthAssociation algorithm to
19// xAOD::PixelClusterContainer and xAOD::StripClusterContainer to
20// xAOD::TruthParticles using the InDetSimDataCollection and
21// the xAODTruthParticleLink which pairs HepMcParticleLinks with the
22// corresponding xAOD::TruthParticle.
23
24#include <stdexcept>
25
27{
28private:
30public:
32 : m_truthParticleLinks(&truth_particle_links)
33 {}
34 operator bool() const {
35 return true;
36 }
38 if (deposit.first.isValid()) {
39 ElementLink<xAOD::TruthParticleContainer> truth_particle_link = m_truthParticleLinks->find(deposit.first);
40 if (truth_particle_link) {
41 return *truth_particle_link;
42 }
43 }
44 return nullptr;
45 }
46 inline bool isHardScatter(const InDetSimData::Deposit &deposit) {
47 return deposit.first.eventIndex()==0;
48 }
49};
50
51// specialisation for the MeasurementToTruthAssociationAlg
52template <>
53inline auto ActsTrk::makeDepositToTruthParticleMap(const xAODTruthParticleLinkVector *truth_particle_links) {
54 if (!truth_particle_links) {
55 throw std::runtime_error("Invalid xAODTruthParticleLinkVector.");
56 }
57
58 return HepMcLinkToTruthParticleMap(*truth_particle_links);
59}
60
61// property name for the input xAODTruthParticleLinkVector
62template <>
64 return "InputTruthParticleLinks";
65}
66
67// specialisation for the MeasurementToTruthAssociationAlg
68template <>
69//coverity[AUTO_CAUSES_COPY]
70inline auto ActsTrk::getSimDataDeposits([[maybe_unused]] const InDetSimDataCollection &sim_data_collection,
71 InDetSimDataCollection::const_iterator sim_data_iter_for_identifier) {
72 return sim_data_iter_for_identifier->second.getdeposits();
73}
74
75template <>
76inline float ActsTrk::getDepositedEnergy(const std::pair<HepMcParticleLink, float> &deposit) {
77 return deposit.second;
78}
79
81
82
83namespace ActsTrk {
84
85 // name the specialistion to get a nicer name in python
87 : public MeasurementToTruthAssociationAlg<xAOD::PixelClusterContainer,
88 InDetSimDataCollection,
89 xAODTruthParticleLinkVector,
90 MeasurementToTruthAssociationDebugHistograms>
91 {
92 public:
97 };
98
99 // name the specialistion to get a nicer name in python
101 : public MeasurementToTruthAssociationAlg<xAOD::StripClusterContainer,
102 InDetSimDataCollection,
103 xAODTruthParticleLinkVector,
104 MeasurementToTruthAssociationDebugHistograms>
105 {
106 public:
111 };
112 // name the specialistion to get a nicer name in python
114 : public MeasurementToTruthAssociationAlg<xAOD::HGTDClusterContainer,
115 InDetSimDataCollection,
116 xAODTruthParticleLinkVector,
117 MeasurementToTruthAssociationDebugHistograms>
118 {
119 public:
124 };
125
126}
127#endif
constexpr bool MeasurementToTruthAssociationDebugHistograms
HepMcLinkToTruthParticleMap(const xAODTruthParticleLinkVector &truth_particle_links)
bool isHardScatter(const InDetSimData::Deposit &deposit)
const xAOD::TruthParticle * getTruthParticle(const InDetSimData::Deposit &deposit)
const xAODTruthParticleLinkVector * m_truthParticleLinks
std::pair< HepMcParticleLink, float > Deposit
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
float getDepositedEnergy(const T_Deposit &)
auto getSimDataDeposits(const T_SimDataCollection &sim_data_collection, T_SimDataIterator sim_data_iter_for_identifier)
const char * getInTruthPropertyName()
auto makeDepositToTruthParticleMap(const T_TruthEventCollection *truth_particle_links)
PixelClusterContainer_v1 PixelClusterContainer
Define the version of the pixel cluster container.
HGTDClusterContainer_v1 HGTDClusterContainer
Define the version of the HGTD cluster container.
StripClusterContainer_v1 StripClusterContainer
Define the version of the strip cluster container.
TruthParticle_v1 TruthParticle
Typedef to implementation.