IAP GITLAB

Skip to content
Snippets Groups Projects
particle_list_example.cpp 2.46 KiB
Newer Older
ralfulrich's avatar
ralfulrich committed
/*
 * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
 *
 * 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/framework/core/ParticleProperties.hpp>
#include <corsika/modules/QGSJetII.hpp>
#include <corsika/modules/Sibyll.hpp>
#include <corsika/setup/SetupEnvironment.hpp>
#include <corsika/framework/core/PhysicalUnits.hpp>

ralfulrich's avatar
ralfulrich committed
/*
  NOTE, WARNING, ATTENTION

  The .../Random.hpp implement the hooks of external modules to the C8 random
  number generator. It has to occur excatly ONCE per linked
  executable. If you include the header below multiple times and
  link this togehter, it will fail.
 */
#include <corsika/modules/sibyll/Random.hpp>
#include <corsika/modules/urqmd/Random.hpp>

ralfulrich's avatar
ralfulrich committed
#include <iomanip>
#include <string>

using namespace corsika;
using namespace std;

//
// The example main program for a particle list
//
int main() {

ralfulrich's avatar
ralfulrich committed
  logging::set_level(logging::level::info);
ralfulrich's avatar
ralfulrich committed
  corsika_logger->set_pattern("[%n:%^%-8l%$] %v");
ralfulrich's avatar
ralfulrich committed

  logging::info(
ralfulrich's avatar
ralfulrich committed
      "\n"
ralfulrich's avatar
ralfulrich committed
      "------------------------------------------\n"
ralfulrich's avatar
ralfulrich committed
      "        particles in CORSIKA\n"
      "------------------------------------------\n");
  int const width = 20 + 10 + 10 + 10 + 15 + 15 + 17;
  logging::info(
      "Name                 | "
ralfulrich's avatar
ralfulrich committed
      "PDG-id     | "
      "SIBYLL-id  | "
      "QGSJETII-id| "
      "PDG-mass (GeV)   | "
ralfulrich's avatar
ralfulrich committed
      "SIBYLL-mass (GeV)|");
  logging::info("{:->{}}", ' ', width);
ralfulrich's avatar
ralfulrich committed
  for (auto p : get_all_particles()) {
    if (!is_nucleus(p)) {
      corsika::sibyll::SibyllCode sib_id = corsika::sibyll::convertToSibyll(p);
      auto const sib_mass = (sib_id != corsika::sibyll::SibyllCode::Unknown
                                 ? to_string(corsika::sibyll::getSibyllMass(p) / 1_GeV)
ralfulrich's avatar
ralfulrich committed
                                 : "");
ralfulrich's avatar
ralfulrich committed
      auto const qgs_id = corsika::qgsjetII::convertToQgsjetII(p);
ralfulrich's avatar
ralfulrich committed
      logging::info("{:20} | {:10} | {:10} | {:10} | {:>15.5} | {:>15.5} |", p,
ralfulrich's avatar
ralfulrich committed
                    static_cast<int>(get_PDG(p)),
                    (sib_id != corsika::sibyll::SibyllCode::Unknown
                         ? to_string(static_cast<int>(sib_id))
ralfulrich's avatar
ralfulrich committed
                         : ""),
ralfulrich's avatar
ralfulrich committed
                    (qgs_id != corsika::qgsjetII::QgsjetIICode::Unknown
                         ? to_string(static_cast<int>(qgs_id))
ralfulrich's avatar
ralfulrich committed
                         : ""),
ralfulrich's avatar
ralfulrich committed
                    get_mass(p) / 1_GeV, sib_mass);
    }
  }
ralfulrich's avatar
ralfulrich committed
  logging::info("{:->{}}", ' ', width);
ralfulrich's avatar
ralfulrich committed
}