GCC Code Coverage Report


Directory: ./
File: src/iguana/algorithms/TypeDefs.h
Date: 2025-07-01 22:41:58
Exec Total Coverage
Lines: 5 5 100.0%
Functions: 1 1 100.0%
Branches: 6 6 100.0%

Line Branch Exec Source
1 /// @file
2 /// @brief common objects used in algorithms
3 #pragma once
4
5 #include <string>
6 #include <optional>
7 #include <unordered_map>
8
9 namespace iguana {
10
11 /// Vector element type
12 using vector_element_t = double;
13
14 /// 3-momentum type
15 struct Momentum3 {
16 /// @f$x@f$-component
17 vector_element_t px;
18 /// @f$y@f$-component
19 vector_element_t py;
20 /// @f$z@f$-component
21 vector_element_t pz;
22 };
23
24 /// 4-momentum type
25 struct Momentum4 {
26 /// @f$x@f$-component
27 vector_element_t px;
28 /// @f$y@f$-component
29 vector_element_t py;
30 /// @f$z@f$-component
31 vector_element_t pz;
32 /// @f$E@f$-component
33 vector_element_t E;
34 };
35
36 //////////////////////////////////////////////////////////////////////////////////
37
38 /// Light-weight namespace for particle constants
39 namespace particle {
40 // clang-format off
41
42 /// PDG codes
43 enum PDG {
44 electron = 11,
45 photon = 22,
46 proton = 2212,
47 antiproton = -2212,
48 neutron = 2112,
49 antineutron = -2112,
50 pi_plus = 211,
51 pi_minus = -211,
52 kaon_plus = 321,
53 kaon_minus = -321
54 };
55
56 /// Particle names
57 const std::unordered_map<PDG, std::string> name{
58 { electron, "electron" },
59 { photon, "photon" },
60 { proton, "proton" },
61 { antiproton, "antiproton" },
62 { neutron, "neutron" },
63 { antineutron, "antineutron" },
64 { pi_plus, "pi_plus" },
65 { pi_minus, "pi_minus" },
66 { kaon_plus, "kaon_plus" },
67 { kaon_minus, "kaon_minus" }
68 };
69
70 /// Particle titles
71 const std::unordered_map<PDG, std::string> title{
72 { electron, "e^{-}" },
73 { photon, "#gamma" },
74 { proton, "p" },
75 { antiproton, "#bar{p}" },
76 { neutron, "n" },
77 { antineutron, "#bar{n}" },
78 { pi_plus, "#pi^{+}" },
79 { pi_minus, "#pi^{-}" },
80 { kaon_plus, "K^{+}" },
81 { kaon_minus, "K^{-}" }
82 };
83
84 /// Particle mass in GeV
85 const std::unordered_map<PDG, double> mass{
86 { electron, 0.000511 },
87 { photon, 0.0 },
88 { proton, 0.938272 },
89 { antiproton, 0.938272 },
90 { neutron, 0.939565 },
91 { antineutron, 0.939565 },
92 { pi_plus, 0.139570 },
93 { pi_minus, 0.139570 },
94 { kaon_plus, 0.493677 },
95 { kaon_minus, 0.493677 }
96 };
97
98 /// @brief get a particle property given a PDG code
99 ///
100 /// Example:
101 /// ```cpp
102 /// auto mass = particle::get(particle::mass, particle::PDG::photon); // mass => 0.0
103 /// ```
104 /// @param property the particle property, such as `particle::name`, `particle::title`, or `particle::mass`
105 /// @param pdg_code the `particle::PDG` value
106 /// @returns the value of the property, if defined for this `pdg_code`
107 template <typename VALUE_TYPE>
108
2/2
✓ Branch 0 (2→3) taken 11426 times.
✓ Branch 1 (2→4) taken 70 times.
11496 std::optional<VALUE_TYPE> const get(std::unordered_map<PDG,VALUE_TYPE> const& property, PDG const& pdg_code)
109 {
110
2/2
✓ Branch 0 (4→5) taken 11426 times.
✓ Branch 1 (4→6) taken 70 times.
11496 if(auto const& it = property.find(pdg_code); it != property.end())
111 11426 return it->second;
112 70 return std::nullopt;
113 }
114
115 /// @brief get a particle property given a PDG code
116 ///
117 /// Example:
118 /// ```cpp
119 /// auto mass = particle::get(particle::mass, 22); // mass => 0.0
120 /// ```
121 /// @param property the particle property, such as `particle::name`, `particle::title`, or `particle::mass`
122 /// @param pdg_code the `particle::PDG` value
123 /// @returns the value of the property, if defined for this `pdg_code`
124 template <typename VALUE_TYPE>
125 std::optional<VALUE_TYPE> const get(std::unordered_map<PDG,VALUE_TYPE> const& property, int const& pdg_code)
126 {
127
2/2
✓ Branch 0 (34→35) taken 70 times.
✓ Branch 1 (34→36) taken 11426 times.
11496 return get(property, static_cast<particle::PDG>(pdg_code));
128 }
129
130 // clang-format on
131 }
132
133 //////////////////////////////////////////////////////////////////////////////////
134
135 /// detector IDs; this is a _copy_ of `coatjava`'s `DetectorType` `enum`
136 enum DetectorType {
137 UNDEFINED = 0,
138 BMT = 1,
139 BST = 2,
140 CND = 3,
141 CTOF = 4,
142 CVT = 5,
143 DC = 6,
144 ECAL = 7,
145 FMT = 8,
146 FT = 9,
147 FTCAL = 10,
148 FTHODO = 11,
149 FTOF = 12,
150 FTTRK = 13,
151 HTCC = 15,
152 LTCC = 16,
153 RF = 17,
154 RICH = 18,
155 RTPC = 19,
156 HEL = 20,
157 BAND = 21,
158 RASTER = 22,
159 URWELL = 23,
160 AHDC = 24,
161 ATOF = 25,
162 RECOIL = 26,
163 TARGET = 100,
164 MAGNETS = 101,
165 ECIN = 110,
166 ECOUT = 111,
167 ECTOT = 112,
168 LAC = 113,
169 SC = 114,
170 CC = 115,
171 };
172
173 /// detector layer IDs; this is a _copy_ of `coatjava`'s `DetectorLayer` class
174 class DetectorLayer {
175 public:
176 /// @doxygen_off
177 static int const CND_INNER=1;
178 static int const CND_MIDDLE=2;
179 static int const CND_OUTER=3;
180
181 static int const PCAL_U=1;
182 static int const PCAL_V=2;
183 static int const PCAL_W=3;
184 static int const PCAL_Z=9; // layer number used to define the longitudinal coordinate of the cluster
185
186 static int const EC_INNER_U=4;
187 static int const EC_INNER_V=5;
188 static int const EC_INNER_W=6;
189 static int const EC_INNER_Z=9; // layer number used to define the longitudinal coordinate of the cluster
190
191 static int const EC_OUTER_U=7;
192 static int const EC_OUTER_V=8;
193 static int const EC_OUTER_W=9;
194 static int const EC_OUTER_Z=9; // layer number used to define the longitudinal coordinate of the cluster
195
196 static int const PCAL=PCAL_U;
197 static int const EC_INNER=EC_INNER_U;
198 static int const EC_OUTER=EC_OUTER_U;
199
200 static int const FTOF1A=1;
201 static int const FTOF1B=2;
202 static int const FTOF2=3;
203
204 static int const TARGET_CENTER=1;
205 static int const TARGET_DOWNSTREAM=2;
206 static int const TARGET_UPSTREAM=3;
207
208 static int const FTTRK_MODULE1=1;
209 static int const FTTRK_MODULE2=2;
210 static int const FTTRK_LAYER1=1;
211 static int const FTTRK_LAYER2=2;
212 static int const FTTRK_LAYER3=3;
213 static int const FTTRK_LAYER4=4;
214
215 static int const RICH_MAPMT=1;
216 static int const RICH_AEROGEL_B1=2;
217 static int const RICH_AEROGEL_B2=3;
218 static int const RICH_AEROGEL_L1=4;
219 /// @doxygen_on
220 };
221
222 }
223