IAP GITLAB

Skip to content
Snippets Groups Projects
Commit fe02f61c authored by Maximilian Reininghaus's avatar Maximilian Reininghaus :vulcan:
Browse files

Merge branch '201-cascade_example-with-nucleus-primary-doesn-t-work' into 'master'

Resolve "cascade_example with nucleus primary doesn't work"

Closes #201

See merge request !146
parents b304f38d d844df28
No related branches found
No related tags found
No related merge requests found
...@@ -120,14 +120,22 @@ namespace corsika::particles { ...@@ -120,14 +120,22 @@ namespace corsika::particles {
} }
int constexpr GetNucleusA(Code const p) { int constexpr GetNucleusA(Code const p) {
if (p == Code::Nucleus) {
throw std::runtime_error("GetNucleusA(Code::Nucleus) is impossible!");
}
return detail::nucleusA[static_cast<CodeIntType>(p)]; return detail::nucleusA[static_cast<CodeIntType>(p)];
} }
int constexpr GetNucleusZ(Code const p) { int constexpr GetNucleusZ(Code const p) {
if (p == Code::Nucleus) {
throw std::runtime_error("GetNucleusZ(Code::Nucleus) is impossible!");
}
return detail::nucleusZ[static_cast<CodeIntType>(p)]; return detail::nucleusZ[static_cast<CodeIntType>(p)];
} }
bool constexpr IsNucleus(Code const p) { return GetNucleusA(p) != 0; } bool constexpr IsNucleus(Code const p) {
return (p == Code::Nucleus) || (GetNucleusA(p) != 0);
}
/** /**
* the output operator for humand-readable particle codes * the output operator for humand-readable particle codes
......
...@@ -102,6 +102,7 @@ TEST_CASE("ParticleProperties", "[Particles]") { ...@@ -102,6 +102,7 @@ TEST_CASE("ParticleProperties", "[Particles]") {
REQUIRE(IsHadron(Code::Proton)); REQUIRE(IsHadron(Code::Proton));
REQUIRE(IsHadron(Code::PiPlus)); REQUIRE(IsHadron(Code::PiPlus));
REQUIRE(IsHadron(Code::Oxygen)); REQUIRE(IsHadron(Code::Oxygen));
REQUIRE(IsHadron(Code::Nucleus));
} }
SECTION("Particle groups: muons") { SECTION("Particle groups: muons") {
...@@ -124,7 +125,6 @@ TEST_CASE("ParticleProperties", "[Particles]") { ...@@ -124,7 +125,6 @@ TEST_CASE("ParticleProperties", "[Particles]") {
REQUIRE_FALSE(IsNeutrino(Code::Oxygen)); REQUIRE_FALSE(IsNeutrino(Code::Oxygen));
} }
SECTION("Nuclei") { SECTION("Nuclei") {
REQUIRE_FALSE(IsNucleus(Code::Gamma)); REQUIRE_FALSE(IsNucleus(Code::Gamma));
REQUIRE(IsNucleus(Code::Argon)); REQUIRE(IsNucleus(Code::Argon));
...@@ -137,5 +137,8 @@ TEST_CASE("ParticleProperties", "[Particles]") { ...@@ -137,5 +137,8 @@ TEST_CASE("ParticleProperties", "[Particles]") {
REQUIRE(GetNucleusA(Code::Tritium) == 3); REQUIRE(GetNucleusA(Code::Tritium) == 3);
REQUIRE(Hydrogen::GetNucleusZ() == 1); REQUIRE(Hydrogen::GetNucleusZ() == 1);
REQUIRE(Tritium::GetNucleusA() == 3); REQUIRE(Tritium::GetNucleusA() == 3);
REQUIRE_THROWS(GetNucleusA(Code::Nucleus));
REQUIRE_THROWS(GetNucleusZ(Code::Nucleus));
} }
} }
...@@ -227,15 +227,18 @@ namespace corsika::process::sibyll { ...@@ -227,15 +227,18 @@ namespace corsika::process::sibyll {
RootCoordinateSystem::GetInstance().GetRootCoordinateSystem(); RootCoordinateSystem::GetInstance().GetRootCoordinateSystem();
const particles::Code corsikaBeamId = vP.GetPID(); const particles::Code corsikaBeamId = vP.GetPID();
if (!particles::IsNucleus(corsikaBeamId)) {
// no nuclear interaction if (corsikaBeamId != particles::Code::Nucleus) {
return std::numeric_limits<double>::infinity() * 1_g / (1_cm * 1_cm); // check if target-style nucleus (enum), these are not allowed as projectile
if (particles::IsNucleus(corsikaBeamId))
throw std::runtime_error(
"NuclearInteraction: GetInteractionLength: Wrong nucleus type. Nuclear "
"projectiles should use NuclearStackExtension!");
else {
// no nuclear interaction
return std::numeric_limits<double>::infinity() * 1_g / (1_cm * 1_cm);
}
} }
// check if target-style nucleus (enum)
if (corsikaBeamId != particles::Code::Nucleus)
throw std::runtime_error(
"NuclearInteraction: GetInteractionLength: Wrong nucleus type. Nuclear "
"projectiles should use NuclearStackExtension!");
// read from cross section code table // read from cross section code table
...@@ -333,13 +336,6 @@ namespace corsika::process::sibyll { ...@@ -333,13 +336,6 @@ namespace corsika::process::sibyll {
// const auto ProjMass = vP.GetMass(); // const auto ProjMass = vP.GetMass();
cout << "NuclearInteraction: DoInteraction: called with:" << ProjId << endl; cout << "NuclearInteraction: DoInteraction: called with:" << ProjId << endl;
if (!IsNucleus(ProjId)) {
cout << "WARNING: non nuclear projectile in NUCLIB!" << endl;
// this should not happen
// throw std::runtime_error("Non nuclear projectile in NUCLIB!");
return process::EProcessReturn::eOk;
}
// check if target-style nucleus (enum) // check if target-style nucleus (enum)
if (ProjId != particles::Code::Nucleus) if (ProjId != particles::Code::Nucleus)
throw std::runtime_error( throw std::runtime_error(
......
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