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
12Trk::ParticleHypothesis convertTrk(Acts::ParticleHypothesis h) {
13 if (ATH_LIKELY(h == Acts::ParticleHypothesis::pion())) {
15 } else if ( h == Acts::ParticleHypothesis::muon()) {
17 } else if (h == Acts::ParticleHypothesis::electron()) {
19 } else if (h == Acts::ParticleHypothesis::geantino()) {
21 } else {
22 throw std::domain_error(
23 "ActsTrk::ParticleHypothesis conversion to Trk does not handle particle of abs(pdg)" + std::to_string(h.absolutePdg()));
24 }
26 }
27xAOD::ParticleHypothesis convert(Acts::ParticleHypothesis h) {
28 if (ATH_LIKELY(h == Acts::ParticleHypothesis::pion())) {
29 return xAOD::pion;
30 } else if ( h == Acts::ParticleHypothesis::muon()) {
31 return xAOD::muon;
32 } else if (h == Acts::ParticleHypothesis::electron()) {
33 return xAOD::electron;
34 } else if (h == Acts::ParticleHypothesis::geantino()) {
35 return xAOD::geantino;
36 } else {
37 throw std::domain_error(
38 "ActsTrk::ParticleHypothesis conversion to xAOD does not handle particle of abs(pdg)" + std::to_string(h.absolutePdg()));
39 }
40 return xAOD::undefined;
41}
42
43Acts::ParticleHypothesis convert(Trk::ParticleHypothesis h) {
44 switch (h) {
45 using enum Trk::ParticleHypothesis;
46 case pion:
47 return Acts::ParticleHypothesis::pion();
48 case geantino:
49 return Acts::ParticleHypothesis::chargedGeantino();
50 case electron:
51 return Acts::ParticleHypothesis::electron();
52 case muon:
53 return Acts::ParticleHypothesis::muon();
54 case kaon:
55 throw std::domain_error("ActsTrk::ParticleHypothesis conversion to Acts does not handle kaon");
56 case proton:
57 return Acts::ParticleHypothesis(Acts::PdgParticle::eProton);
58 case photon:
59 return Acts::ParticleHypothesis::photon();
60 case neutron:
61 return Acts::ParticleHypothesis(Acts::PdgParticle::eNeutron);
62 case pi0:
63 return Acts::ParticleHypothesis::pion0();
64 case k0:
65 throw std::domain_error("ActsTrk::ParticleHypothesis conversion to Acts does not handle k0");
66 case nonInteractingMuon:
67 throw std::domain_error("ActsTrk::ParticleHypothesis conversion to Acts does not handle nonInteractingMuon");
68 default:
69 break;
70 }
71 throw std::domain_error("ActsTrk::ParticleHypothesis conversion to Acts failed for" +std::to_string(h));
72}
73
74Acts::ParticleHypothesis convert(xAOD::ParticleHypothesis h) {
75 switch (h) {
76 case xAOD::geantino:
77 return Acts::ParticleHypothesis::geantino();
78 case xAOD::electron:
79 return Acts::ParticleHypothesis::electron();
80 case xAOD::muon:
81 return Acts::ParticleHypothesis::muon();
82 case xAOD::pion:
83 return Acts::ParticleHypothesis::pion();
84 case xAOD::kaon:
85 throw std::domain_error(
86 "ActsTrk::ParticleHypothesis conversion to Acts does not handle "
87 "kaon");
88 // return Acts::ParticleHypothesis(321); // TODO add in ACTS
89 case xAOD::proton:
90 return Acts::ParticleHypothesis(Acts::PdgParticle::eProton);
91 case xAOD::photon:
92 return Acts::ParticleHypothesis::photon();
93 case xAOD::neutron:
94 throw std::domain_error(
95 "ActsTrk::ParticleHypothesis conversion to Acts doe not handle "
96 "neutron");
97 // return Acts::ParticleHypothesis(2112); // TODO add in ACTS
98 case xAOD::pi0:
99 return Acts::ParticleHypothesis::pion0();
100 case xAOD::k0:
101 throw std::domain_error(
102 "ActsTrk::ParticleHypothesis conversion to Acts doe not handle K0");
103 // return Acts::ParticleHypothesis(311); // TODO add in ACTS
105 throw std::domain_error(
106 "ActsTrk::ParticleHypothesis conversion to Acts does not handle "
107 "nonInteractingMuon");
108 case xAOD::undefined:
109 throw std::domain_error(
110 "ActsTrk::ParticleHypothesis conversion to Acts does not handle "
111 "undefined/noHypothesis");
112 default:
113 throw std::domain_error(
114 "ActsTrk::ParticleHypothesis conversion to Acts failed for" +
115 std::to_string(h));
116 }
117}
118} // namespace ActsTrk::ParticleHypothesis
#define ATH_LIKELY(x)
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