ATLAS Offline Software
ClusterToTruthAssociation.h
Go to the documentation of this file.
1 #ifndef ACTSTRK_CLUSTERTOTRUTHASSOCIATION_H
2 #define ACTSTRK_CLUSTERTOTRUTHASSOCIATION_H 1
3 
7 
10 #include <unordered_map>
11 
13 
14 // Adapter to use MeasurementToTruthAssociation algorithm to
15 // xAOD::PixelClusterContainer and xAOD::StripClusterContainer to
16 // xAOD::TruthParticles using the InDetSimDataCollection and
17 // the xAODTruthParticleLink which pairs HepMcParticleLinks with the
18 // corresponding xAOD::TruthParticle.
19 
20 #include <iostream>
21 
23 {
24 private:
26 public:
28  : m_truthParticleLinks(&truth_particle_links)
29  {}
30  operator bool() const {
31  return true;
32  }
34  if (deposit.first.isValid()) {
35  ElementLink<xAOD::TruthParticleContainer> truth_particle_link = m_truthParticleLinks->find(deposit.first);
36  if (truth_particle_link) {
37  return *truth_particle_link;
38  }
39  }
40  return nullptr;
41  }
42  inline bool isHardScatter(const InDetSimData::Deposit &deposit) {
43  return deposit.first.eventIndex()==0;
44  }
45 };
46 
47 // specialisation for the MeasurementToTruthAssociationAlg
48 template <>
49 inline auto ActsTrk::makeDepositToTruthParticleMap(const xAODTruthParticleLinkVector *truth_particle_links) {
50  if (!truth_particle_links) {
51  throw std::runtime_error("Invalid xAODTruthParticleLinkVector.");
52  }
53 
54  return HepMcLinkToTruthParticleMap(*truth_particle_links);
55 }
56 
57 // property name for the input xAODTruthParticleLinkVector
58 template <>
59 inline const char *ActsTrk::getInTruthPropertyName<xAODTruthParticleLinkVector>() {
60  return "InputTruthParticleLinks";
61 }
62 
63 // specialisation for the MeasurementToTruthAssociationAlg
64 template <>
65 inline auto ActsTrk::getSimDataDeposits([[maybe_unused]] const InDetSimDataCollection &sim_data_collection,
66  InDetSimDataCollection::const_iterator sim_data_iter_for_identifier) {
67  return sim_data_iter_for_identifier->second.getdeposits();
68 }
69 
70 template <>
71 inline float ActsTrk::getDepositedEnergy(const std::pair<HepMcParticleLink, float> &deposit) {
72  return deposit.second;
73 }
74 
76 
77 
78 namespace ActsTrk {
79 
80  // name the specialistion to get a nicer name in python
82  : public MeasurementToTruthAssociationAlg<xAOD::PixelClusterContainer,
83  InDetSimDataCollection,
84  xAODTruthParticleLinkVector,
85  MeasurementToTruthAssociationDebugHistograms>
86  {
87  public:
92  };
93 
94  // name the specialistion to get a nicer name in python
96  : public MeasurementToTruthAssociationAlg<xAOD::StripClusterContainer,
97  InDetSimDataCollection,
98  xAODTruthParticleLinkVector,
99  MeasurementToTruthAssociationDebugHistograms>
100  {
101  public:
106  };
107 
108 }
109 #endif
HepMcLinkToTruthParticleMap::HepMcLinkToTruthParticleMap
HepMcLinkToTruthParticleMap(const xAODTruthParticleLinkVector &truth_particle_links)
Definition: ClusterToTruthAssociation.h:27
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:86
ActsTrk::getDepositedEnergy
float getDepositedEnergy(const T_Deposit &)
HepMcLinkToTruthParticleMap::m_truthParticleLinks
const xAODTruthParticleLinkVector * m_truthParticleLinks
Definition: ClusterToTruthAssociation.h:25
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:41
PixelClusterContainer.h
MeasurementToTruthAssociationDebugHistograms
constexpr bool MeasurementToTruthAssociationDebugHistograms
Definition: ClusterToTruthAssociation.h:75
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:42
HepMcLinkToTruthParticleMap::getTruthParticle
const xAOD::TruthParticle * getTruthParticle(const InDetSimData::Deposit &deposit)
Definition: ClusterToTruthAssociation.h:33
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: MuonDetectorBuilderTool.cxx:34
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:23
ActsTrk::StripClusterToTruthAssociationAlg
Definition: ClusterToTruthAssociation.h:100