IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 007626fe authored by Felix Riehn's avatar Felix Riehn Committed by ralfulrich
Browse files

added energy threshold to particle properties

parent 7b32f54e
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,14 @@
namespace corsika {
HEPEnergyType constexpr get_energy_threshold(Code const p) {
return particle::detail::thresholds[static_cast<CodeIntType>(p)];
}
void constexpr set_energy_threshold(Code const p, HEPEnergyType const val) {
particle::detail::thresholds[static_cast<CodeIntType>(p)] = val;
}
HEPMassType constexpr get_mass(Code const p) {
if (p == Code::Nucleus)
throw std::runtime_error("Cannot GetMass() of particle::Nucleus -> unspecified");
......
......@@ -50,6 +50,19 @@ namespace corsika {
int16_t constexpr get_charge_number(Code); //!< electric charge in units of e
ElectricChargeType constexpr get_charge(Code); //!< electric charge
HEPMassType constexpr get_mass(Code); //!< mass
HEPEnergyType constexpr get_energy_threshold(
Code const); //!< get energy threshold below which the particle is discarded, by
//!< default set to particle mass
void constexpr set_energy_threshold(
Code const, HEPEnergyType const); //!< set energy threshold below which the particle
//!< is discarded
inline void set_energy_threshold(std::pair<Code const, HEPEnergyType const>p){
set_energy_threshold(p.first, p.second);
}
inline void set_energy_thresholds(std::unordered_map<Code const,HEPEnergyType const> const& eCuts){
for (auto v : eCuts) set_energy_threshold(v);
}
//! Particle code according to PDG, "Monte Carlo Particle Numbering Scheme"
PDGCode constexpr get_PDG(Code);
......
......@@ -330,7 +330,13 @@ def gen_properties(particle_db):
for p in particle_db.values():
string += " {mass:e} * 1e9 * corsika::units::si::electronvolt, // {name:s}\n".format(mass = p['mass'], name = p['name'])
string += "};\n\n"
# particle threshold table, initially set to the particle mass
string += "static std::array<corsika::units::si::HEPEnergyType, size> thresholds = {\n"
for p in particle_db.values():
string += " {mass:e} * 1e9 * corsika::units::si::electronvolt, // {name:s}\n".format(mass = p['mass'], name = p['name'])
string += "};\n\n"
# PDG code table
string += "static constexpr std::array<PDGCode, size> pdg_codes = {\n"
for p in particle_db.keys():
......
......@@ -80,6 +80,15 @@ TEST_CASE("ParticleProperties", "[Particles]") {
(Approx(2.1970332555864364e-06).epsilon(1e-5)));
}
SECTION("Energy threshold") {
//! by default energy thresholds are set to particle mass
CHECK(get_energy_threshold(Electron::code) / Electron::mass == Approx(1));
set_energy_threshold(Electron::code,10_GeV);
CHECK_FALSE(get_energy_threshold(Code::Electron) == 1_GeV);
CHECK(get_energy_threshold(Code::Electron) == 10_GeV);
}
SECTION("Particle groups: electromagnetic") {
CHECK(is_em(Code::Gamma));
CHECK(is_em(Code::Electron));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment