ATLAS Offline Software
Loading...
Searching...
No Matches
ParticleHypothesisEncoding.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
5
6#include <stdexcept>
7
9
11
12xAOD::ParticleHypothesis convert(Acts::ParticleHypothesis h) {
13 if (ATH_LIKELY(h == Acts::ParticleHypothesis::pion())) {
14 return xAOD::pion;
15 } else if ( h == Acts::ParticleHypothesis::muon()) {
16 return xAOD::muon;
17 } else if (h == Acts::ParticleHypothesis::electron()) {
18 return xAOD::electron;
19 } else if (h == Acts::ParticleHypothesis::geantino()) {
20 return xAOD::geantino;
21 } else {
22 throw std::domain_error(
23 "ActsTrk::ParticleHypothesis conversion to xAOD does not handle particle of abs(pdg)" + std::to_string(h.absolutePdg()));
24 }
25 return xAOD::undefined;
26}
27
28Acts::ParticleHypothesis convert(Trk::ParticleHypothesis h) {
29 switch (h) {
30 using enum Trk::ParticleHypothesis;
31 case pion:
32 return Acts::ParticleHypothesis::pion();
33 case geantino:
34 return Acts::ParticleHypothesis::chargedGeantino();
35 case electron:
36 return Acts::ParticleHypothesis::electron();
37 case muon:
38 return Acts::ParticleHypothesis::muon();
39 case kaon:
40 throw std::domain_error("ActsTrk::ParticleHypothesis conversion to Acts does not handle kaon");
41 case proton:
42 return Acts::ParticleHypothesis(Acts::PdgParticle::eProton);
43 case photon:
44 return Acts::ParticleHypothesis::photon();
45 case neutron:
46 return Acts::ParticleHypothesis(Acts::PdgParticle::eNeutron);
47 case pi0:
48 return Acts::ParticleHypothesis::pion0();
49 case k0:
50 throw std::domain_error("ActsTrk::ParticleHypothesis conversion to Acts does not handle k0");
51 case nonInteractingMuon:
52 throw std::domain_error("ActsTrk::ParticleHypothesis conversion to Acts does not handle nonInteractingMuon");
53 default:
54 break;
55 }
56 throw std::domain_error("ActsTrk::ParticleHypothesis conversion to Acts failed for" +std::to_string(h));
57}
58
59Acts::ParticleHypothesis convert(xAOD::ParticleHypothesis h) {
60 switch (h) {
61 case xAOD::geantino:
62 return Acts::ParticleHypothesis::geantino();
63 case xAOD::electron:
64 return Acts::ParticleHypothesis::electron();
65 case xAOD::muon:
66 return Acts::ParticleHypothesis::muon();
67 case xAOD::pion:
68 return Acts::ParticleHypothesis::pion();
69 case xAOD::kaon:
70 throw std::domain_error(
71 "ActsTrk::ParticleHypothesis conversion to Acts does not handle "
72 "kaon");
73 // return Acts::ParticleHypothesis(321); // TODO add in ACTS
74 case xAOD::proton:
75 return Acts::ParticleHypothesis(Acts::PdgParticle::eProton);
76 case xAOD::photon:
77 return Acts::ParticleHypothesis::photon();
78 case xAOD::neutron:
79 throw std::domain_error(
80 "ActsTrk::ParticleHypothesis conversion to Acts doe not handle "
81 "neutron");
82 // return Acts::ParticleHypothesis(2112); // TODO add in ACTS
83 case xAOD::pi0:
84 return Acts::ParticleHypothesis::pion0();
85 case xAOD::k0:
86 throw std::domain_error(
87 "ActsTrk::ParticleHypothesis conversion to Acts doe not handle K0");
88 // return Acts::ParticleHypothesis(311); // TODO add in ACTS
90 throw std::domain_error(
91 "ActsTrk::ParticleHypothesis conversion to Acts does not handle "
92 "nonInteractingMuon");
93 case xAOD::undefined:
94 throw std::domain_error(
95 "ActsTrk::ParticleHypothesis conversion to Acts does not handle "
96 "undefined/noHypothesis");
97 default:
98 throw std::domain_error(
99 "ActsTrk::ParticleHypothesis conversion to Acts failed for" +
100 std::to_string(h));
101 }
102}
103} // namespace ActsTrk::ParticleHypothesis
#define ATH_LIKELY(x)
Header file for AthHistogramAlgorithm.
xAOD::ParticleHypothesis convert(Acts::ParticleHypothesis h)
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
@ pi0
for Fatras usage
@ nonInteractingMuon
for Fatras usage
@ neutron
for Fatras usage
@ k0
for Fatras usage