diff --git a/Documentation/Examples/CMakeLists.txt b/Documentation/Examples/CMakeLists.txt index 81c6fc535538d6789ee6170fbe44e6b2fb7fedd5..af5958a0b53dd6f480be615b2b1f4bc9126f0d43 100644 --- a/Documentation/Examples/CMakeLists.txt +++ b/Documentation/Examples/CMakeLists.txt @@ -2,6 +2,10 @@ CORSIKA_ADD_TEST (helix_example) target_link_libraries (helix_example CORSIKAgeometry CORSIKAunits) install (TARGETS helix_example DESTINATION share/examples) +CORSIKA_ADD_TEST (particle_list_example) +target_link_libraries (particle_list_example CORSIKAparticles CORSIKAunits CORSIKAprocesses ProcessSibyll) +install (TARGETS particle_list_example DESTINATION share/examples) + CORSIKA_ADD_TEST (geometry_example) target_link_libraries (geometry_example CORSIKAgeometry CORSIKAunits) install (TARGETS geometry_example DESTINATION share/examples) diff --git a/Documentation/Examples/particle_list_example.cc b/Documentation/Examples/particle_list_example.cc new file mode 100644 index 0000000000000000000000000000000000000000..ec3fba9e68664ea41bd99795903b621bef448dd4 --- /dev/null +++ b/Documentation/Examples/particle_list_example.cc @@ -0,0 +1,47 @@ +/* + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#include <corsika/particles/ParticleProperties.h> +#include <corsika/units/PhysicalUnits.h> +#include <corsika/process/ProcessSequence.h> +#include <corsika/setup/SetupEnvironment.h> +#include <corsika/process/sibyll/ParticleConversion.h> + +#include <iomanip> +#include <iostream> +using namespace corsika::units; +using namespace corsika::units::si; +using namespace corsika::particles; +using namespace std; + +// +// The example main program for a particle list +// +int main() { + cout << "--------------------" + << "particles in CORSIKA" + << "--------------------" << endl; + cout << std::setw(20) << "Name" + << " | " << std::setw(10) << "PDG-id" + << " | " << std::setw(10) << "mass (GeV)" + << " | " << std::setw(10) << "SIBYLL-id" + << endl; + cout << std::setw(58) << std::setfill('-') << "-" << endl; + for (auto p : corsika::particles::detail::all_particles) { + if (p != Code::Unknown && !IsNucleus(p)) + cout << std::setw(20) << std::setfill(' ') << p << " | " + << std::setw(10) << static_cast<int>(GetPDG(p)) << " | " + << std::setw(10) << GetMass(p) / 1_GeV << " | " + << std::setw(10) << static_cast<int>(corsika::process::sibyll::ConvertToSibyll(p)) << " | " + + << endl; + } + cout << std::setw(54) << std::setfill('-') << "-" << endl; +} diff --git a/Framework/Particles/pdxml_reader.py b/Framework/Particles/pdxml_reader.py index 7d1d3588a51d4117780e748ca96b565af2bd3af1..b640d8368de3e9d1e8b282fbf6c72aeda63020bd 100755 --- a/Framework/Particles/pdxml_reader.py +++ b/Framework/Particles/pdxml_reader.py @@ -316,6 +316,14 @@ def gen_properties(particle_db): # number of particles, size of tables string = "static constexpr std::size_t size = {size:d};\n".format(size = len(particle_db)) string += "\n" + + # all particles + string += "constexpr std::initializer_list<Code> all_particles = {" + for k in particle_db: + #print(k) + string += " Code::{name:s},\n".format(name = k) + string += "};\n" + string += "\n" # particle masses table string += "static constexpr std::array<corsika::units::si::HEPMassType const, size> masses = {\n"