CORSIKA8  0.0.0
The framework to simulate particle cascades for astroparticle physics
ParticleConversion.hpp
1 /*
2  * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
3  *
4  * This software is distributed under the terms of the GNU General Public
5  * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
6  * the license.
7  */
8 
9 #pragma once
10 
13 
14 #include <epos.hpp>
15 
16 #include <string>
17 
18 namespace corsika::epos {
19 
20  enum class EposCode : int32_t;
21  using EposCodeIntType = std::underlying_type<EposCode>::type;
22 
26  enum class EposXSClass : int8_t {
27  CannotInteract = 0,
28  Baryon = 2,
29  Pion = 1,
30  Kaon = 3,
31  Charm = 4,
32  };
33  using EposXSClassIntType = std::underlying_type<EposXSClass>::type;
34 
35 #include <corsika/modules/epos/Generated.inc>
36 
37  EposCode constexpr convertToEpos(Code pCode) {
38  return corsika2epos[static_cast<CodeIntType>(pCode)];
39  }
40 
41  Code constexpr convertFromEpos(EposCode pCode) {
42  EposCodeIntType const s = static_cast<EposCodeIntType>(pCode);
43  // if nucleus (pdg-id)
44  if (s >= 1000000000) { return Code::Nucleus; }
45  auto const corsikaCode = epos2corsika[s - minEpos];
46  if (corsikaCode == Code::Unknown) {
47  throw std::runtime_error(std::string("EPOS/CORSIKA conversion of ")
48  .append(std::to_string(s))
49  .append(" impossible"));
50  }
51  return corsikaCode;
52  }
53 
54  int constexpr convertToEposRaw(Code pCode) {
55  return static_cast<int>(convertToEpos(pCode));
56  }
57 
58  int constexpr getEposXSCode(Code pCode) {
59  return static_cast<EposXSClassIntType>(
60  corsika2eposXStype[static_cast<CodeIntType>(pCode)]);
61  }
62 
63  bool constexpr canInteract(Code pCode) { return getEposXSCode(pCode) > 0; }
64 
65  HEPMassType getEposMass(Code const);
66 
67  PDGCode getEposPDGId(Code const);
68 
69 } // namespace corsika::epos
70 
71 #include <corsika/detail/modules/epos/ParticleConversion.inl>
int32_t std::underlying_type< Code >::type CodeIntType
The Code enum is the actual place to define CORSIKA 8 particle codes.
Import and extend the phys::units package.
std::string to_string(long double const value)
string representation of value.
Interface to particle properties.