| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /// @file | ||
| 2 | /// @brief common objects used in algorithms | ||
| 3 | #pragma once | ||
| 4 | |||
| 5 | #include <optional> | ||
| 6 | #include <string> | ||
| 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 2 → 3 taken 11426 times.
✓ Branch 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 4 → 5 taken 11426 times.
✓ Branch 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 34 → 35 taken 70 times.
✓ Branch 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 | /// @param sec the sector number to check | ||
| 136 | /// @returns `true` if the sector number is a valid sector number | ||
| 137 | inline bool IsValidSector(int const& sec) | ||
| 138 | { | ||
| 139 |
10/11✓ Branch 4 → 5 taken 3433 times.
✗ Branch 4 → 56 not taken.
✓ Branch 4 → 69 taken 1822 times.
✓ Branch 6 → 11 taken 30 times.
✓ Branch 6 → 12 taken 17793 times.
✓ Branch 20 → 21 taken 16124 times.
✓ Branch 20 → 27 taken 45256 times.
✓ Branch 31 → 32 taken 815 times.
✓ Branch 31 → 33 taken 1511 times.
✓ Branch 47 → 48 taken 827 times.
✓ Branch 47 → 49 taken 1651 times.
|
89262 | return sec >= 1 && sec <= 6; |
| 140 | } | ||
| 141 | |||
| 142 | /// detector IDs; this is a _copy_ of `coatjava`'s `DetectorType` `enum` | ||
| 143 | enum DetectorType { | ||
| 144 | UNDEFINED = 0, | ||
| 145 | BMT = 1, | ||
| 146 | BST = 2, | ||
| 147 | CND = 3, | ||
| 148 | CTOF = 4, | ||
| 149 | CVT = 5, | ||
| 150 | DC = 6, | ||
| 151 | ECAL = 7, | ||
| 152 | FMT = 8, | ||
| 153 | FT = 9, | ||
| 154 | FTCAL = 10, | ||
| 155 | FTHODO = 11, | ||
| 156 | FTOF = 12, | ||
| 157 | FTTRK = 13, | ||
| 158 | HTCC = 15, | ||
| 159 | LTCC = 16, | ||
| 160 | RF = 17, | ||
| 161 | RICH = 18, | ||
| 162 | RTPC = 19, | ||
| 163 | HEL = 20, | ||
| 164 | BAND = 21, | ||
| 165 | RASTER = 22, | ||
| 166 | URWELL = 23, | ||
| 167 | AHDC = 24, | ||
| 168 | ATOF = 25, | ||
| 169 | RECOIL = 26, | ||
| 170 | TARGET = 100, | ||
| 171 | MAGNETS = 101, | ||
| 172 | }; | ||
| 173 | |||
| 174 | /// detector layer IDs; this is a _copy_ of `coatjava`'s `DetectorLayer` class | ||
| 175 | class DetectorLayer | ||
| 176 | { | ||
| 177 | public: | ||
| 178 | /// @doxygen_off | ||
| 179 | static int const CND_INNER = 1; | ||
| 180 | static int const CND_MIDDLE = 2; | ||
| 181 | static int const CND_OUTER = 3; | ||
| 182 | |||
| 183 | static int const PCAL_U = 1; | ||
| 184 | static int const PCAL_V = 2; | ||
| 185 | static int const PCAL_W = 3; | ||
| 186 | static int const PCAL_Z = 9; // layer number used to define the longitudinal coordinate of the cluster | ||
| 187 | |||
| 188 | static int const EC_INNER_U = 4; | ||
| 189 | static int const EC_INNER_V = 5; | ||
| 190 | static int const EC_INNER_W = 6; | ||
| 191 | static int const EC_INNER_Z = 9; // layer number used to define the longitudinal coordinate of the cluster | ||
| 192 | |||
| 193 | static int const EC_OUTER_U = 7; | ||
| 194 | static int const EC_OUTER_V = 8; | ||
| 195 | static int const EC_OUTER_W = 9; | ||
| 196 | static int const EC_OUTER_Z = 9; // layer number used to define the longitudinal coordinate of the cluster | ||
| 197 | |||
| 198 | static int const PCAL = PCAL_U; | ||
| 199 | static int const EC_INNER = EC_INNER_U; | ||
| 200 | static int const EC_OUTER = EC_OUTER_U; | ||
| 201 | |||
| 202 | static int const FTOF1A = 1; | ||
| 203 | static int const FTOF1B = 2; | ||
| 204 | static int const FTOF2 = 3; | ||
| 205 | |||
| 206 | static int const TARGET_CENTER = 1; | ||
| 207 | static int const TARGET_DOWNSTREAM = 2; | ||
| 208 | static int const TARGET_UPSTREAM = 3; | ||
| 209 | |||
| 210 | static int const FTTRK_MODULE1 = 1; | ||
| 211 | static int const FTTRK_MODULE2 = 2; | ||
| 212 | static int const FTTRK_LAYER1 = 1; | ||
| 213 | static int const FTTRK_LAYER2 = 2; | ||
| 214 | static int const FTTRK_LAYER3 = 3; | ||
| 215 | static int const FTTRK_LAYER4 = 4; | ||
| 216 | |||
| 217 | static int const RICH_MAPMT = 1; | ||
| 218 | static int const RICH_AEROGEL_B1 = 2; | ||
| 219 | static int const RICH_AEROGEL_B2 = 3; | ||
| 220 | static int const RICH_AEROGEL_L1 = 4; | ||
| 221 | /// @doxygen_on | ||
| 222 | }; | ||
| 223 | |||
| 224 | /// MC run number | ||
| 225 | int const MC_RUN_NUM = 11; | ||
| 226 | |||
| 227 | } | ||
| 228 |