IAP GITLAB

Skip to content
Snippets Groups Projects
Commit c8b23364 authored by Felix Riehn's avatar Felix Riehn
Browse files

added particle list example

parent 0cac30ac
No related branches found
No related tags found
1 merge request!186Resolve "particle list example"
......@@ -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)
......
/*
* (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;
}
......@@ -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"
......
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