diff --git a/examples/cascade_example.cpp b/examples/cascade_example.cpp index 2b9c38759b82a8a817266a803ca6dea1c47b0381..f7693fc400226287e1986bc90e607a4d96b3ca42 100644 --- a/examples/cascade_example.cpp +++ b/examples/cascade_example.cpp @@ -94,10 +94,10 @@ int main() { // setup particle stack, and add primary particle setup::Stack stack; stack.clear(); - const Code beamCode = Code::Nucleus; const int nuclA = 4; const int nuclZ = int(nuclA / 2.15 + 0.7); - const HEPMassType mass = get_nucleus_mass(nuclA, nuclZ); + const Code beamCode = get_nucleus_code(nuclA, nuclZ); + const HEPMassType mass = get_nucleus_mass(beamCode); const HEPEnergyType E0 = nuclA * 1_TeV; double theta = 0.; double phi = 0.; @@ -125,7 +125,7 @@ int main() { cout << "input particle: " << beamCode << endl; cout << "input angles: theta=" << theta << " phi=" << phi << endl; cout << "input momentum: " << plab.getComponents() / 1_GeV << endl; - stack.addParticle(std::make_tuple(beamCode, plab, injectionPos, 0_ns, nuclA, nuclZ)); + stack.addParticle(std::make_tuple(beamCode, plab, injectionPos, 0_ns)); } // setup processes, decays and interactions diff --git a/examples/corsika.cpp b/examples/corsika.cpp index f7fc083e86337ce34c94539fdb41b65219707dc1..8166b9e11a9df6e3040073360689594badb329e8 100644 --- a/examples/corsika.cpp +++ b/examples/corsika.cpp @@ -230,18 +230,20 @@ int main(int argc, char** argv) { // parse the primary ID as a PDG or A/Z code Code beamCode; - HEPEnergyType mass; // check if we want to use a PDG code instead if (app.count("--pdg") > 0) { beamCode = convert_from_PDG(PDGCode(app["--pdg"]->as<int>())); - mass = get_mass(beamCode); } else { // check manually for proton and neutrons - if ((A == 0) && (Z == 1)) beamCode = Code::Proton; - if ((A == 1) && (Z == 1)) beamCode = Code::Neutron; - mass = get_nucleus_mass(A, Z); + if ((A == 0) && (Z == 1)) + beamCode = Code::Proton; + else if ((A == 1) && (Z == 1)) + beamCode = Code::Neutron; + else + beamCode = get_nucleus_code(A, Z); } + HEPEnergyType mass = get_mass(beamCode); // particle energy HEPEnergyType const E0 = 1_GeV * app["--energy"]->as<float>(); diff --git a/examples/hybrid_MC.cpp b/examples/hybrid_MC.cpp index 3619b99bb5cdc885840bc3bfd971a698011f3c32..da892f8d4000cb63fbbbd8085b85adc3fb6f3586 100644 --- a/examples/hybrid_MC.cpp +++ b/examples/hybrid_MC.cpp @@ -157,10 +157,10 @@ int main(int argc, char** argv) { // setup particle stack, and add primary particle setup::Stack stack; stack.clear(); - const Code beamCode = Code::Nucleus; unsigned short const A = std::stoi(std::string(argv[1])); unsigned short Z = std::stoi(std::string(argv[2])); - auto const mass = get_nucleus_mass(A, Z); + const Code beamCode = get_nucleus_code(A, Z); + auto const mass = get_mass(beamCode); const HEPEnergyType E0 = 1_GeV * std::stof(std::string(argv[3])); double theta = 0.; auto const thetaRad = theta / 180. * M_PI; @@ -192,12 +192,7 @@ int main(int argc, char** argv) { std::cout << "point of injection: " << injectionPos.getCoordinates() << std::endl; - if (A != 1) { - stack.addParticle(std::make_tuple(beamCode, plab, injectionPos, 0_ns, A, Z)); - - } else { - stack.addParticle(std::make_tuple(Code::Proton, plab, injectionPos, 0_ns)); - } + stack.addParticle(std::make_tuple(Code::Proton, plab, injectionPos, 0_ns)); std::cout << "shower axis length: " << (showerCore - injectionPos).getNorm() * 1.02 << std::endl; diff --git a/examples/mars.cpp b/examples/mars.cpp index 2d0d7ce5bcaca3233c567fc185c6178158346762..b4c4b381cc7946e6c2c01fccde8d5e1ed43f8001 100644 --- a/examples/mars.cpp +++ b/examples/mars.cpp @@ -259,18 +259,16 @@ int main(int argc, char** argv) { // parse the primary ID as a PDG or A/Z code Code beamCode; - HEPEnergyType mass; // check if we want to use a PDG code instead if (app.count("--pdg") > 0) { beamCode = convert_from_PDG(PDGCode(app["--pdg"]->as<int>())); - mass = get_mass(beamCode); } else { // check manually for proton and neutrons if ((A == 0) && (Z == 1)) beamCode = Code::Proton; if ((A == 1) && (Z == 1)) beamCode = Code::Neutron; - mass = get_nucleus_mass(A, Z); } + HEPEnergyType const mass = get_mass(beamCode); // particle energy HEPEnergyType const E0 = 1_GeV * app["--energy"]->as<float>(); @@ -419,11 +417,7 @@ int main(int argc, char** argv) { stack.clear(); // add the desired particle to the stack - if (A > 1) { - stack.addParticle(std::make_tuple(beamCode, plab, injectionPos, 0_ns, A, Z)); - } else { - stack.addParticle(std::make_tuple(beamCode, plab, injectionPos, 0_ns)); - } + stack.addParticle(std::make_tuple(beamCode, plab, injectionPos, 0_ns)); // run the shower EAS.run(); diff --git a/examples/vertical_EAS.cpp b/examples/vertical_EAS.cpp index 4b10e0436a04891b727c0310fec7a4b4ca950147..638752840c5572219bca4c0833607d3668640cab 100644 --- a/examples/vertical_EAS.cpp +++ b/examples/vertical_EAS.cpp @@ -144,17 +144,20 @@ int main(int argc, char** argv) { // pre-setup particle stack unsigned short const A = std::stoi(std::string(argv[1])); Code beamCode; - HEPEnergyType mass; unsigned short Z = 0; if (A > 0) { - beamCode = Code::Nucleus; Z = std::stoi(std::string(argv[2])); - mass = get_nucleus_mass(A, Z); + if (A == 1 && Z == 0) + beamCode = Code::Neutron; + else if (A == 1 && Z == 1) + beamCode = Code::Proton; + else + beamCode = get_nucleus_code(A, Z); } else { int pdg = std::stoi(std::string(argv[2])); beamCode = convert_from_PDG(PDGCode(pdg)); - mass = get_mass(beamCode); } + HEPEnergyType mass = get_mass(beamCode); HEPEnergyType const E0 = 1_GeV * std::stof(std::string(argv[3])); double theta = 0.; double phi = 180.; @@ -261,23 +264,7 @@ int main(int argc, char** argv) { setup::Stack stack; stack.clear(); - if (A > 1) { - stack.addParticle(std::make_tuple(beamCode, plab, injectionPos, 0_ns, A, Z)); - - } else { - if (A == 1) { - if (Z == 1) { - stack.addParticle(std::make_tuple(Code::Proton, plab, injectionPos, 0_ns)); - } else if (Z == 0) { - stack.addParticle(std::make_tuple(Code::Neutron, plab, injectionPos, 0_ns)); - } else { - std::cerr << "illegal parameters" << std::endl; - return EXIT_FAILURE; - } - } else { - stack.addParticle(std::make_tuple(beamCode, plab, injectionPos, 0_ns)); - } - } + stack.addParticle(std::make_tuple(beamCode, plab, injectionPos, 0_ns)); BetheBlochPDG emContinuous(showerAxis);