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