IAP GITLAB

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • AirShowerPhysics/corsika
  • rulrich/corsika
  • AAAlvesJr/corsika
  • Andre/corsika
  • arrabito/corsika
  • Nikos/corsika
  • olheiser73/corsika
  • AirShowerPhysics/papers/corsika
  • pranav/corsika
9 results
Show changes
sphinx_rtd_theme == 0.5.1
sphinx == 3.5.3
breathe == 4.27.0
recommonmark == 0.7.1
sphinx_rtd_theme >= 0.5.1
sphinx >= 3.5.3
recommonmark >= 0.7.1
breathe >= 4.27.0
\ No newline at end of file
Tracking
========
Tracking is the process of moving a kinetic object from one point A to another point B.
Physical forces and laws should be applied explicitly or numerically in this process.
There are two main aspects of tracking:
1. The actual proposal of a new point B, thus, a movement.
2. The description of the movement within a 3D geometry with boundaries and different volumina.
Besides this, there furthermore is also the determination of the effects of the
movement (e.g. magnetic fields, refractivity), or the accumulation of local
quantities (e.g. grammage).
For these purposes typically numerical integration routines are needed.
......@@ -9,50 +9,98 @@ find_package (corsika CONFIG REQUIRED)
# this is only for CORSIKA_REGISTER_EXAMPLE
include ("${CMAKE_CURRENT_SOURCE_DIR}/corsikaExamples.cmake")
add_executable (helix_example helix_example.cpp)
target_link_libraries (helix_example CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (helix_example)
# Put binaries in bin directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
add_executable (geometry_example geometry_example.cpp)
target_link_libraries (geometry_example CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (geometry_example)
###################
## cascade_examples
###################
add_executable (stack_example stack_example.cpp)
target_link_libraries (stack_example CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (stack_example)
add_executable (em_shower cascade_examples/em_shower.cpp)
target_link_libraries (em_shower PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (em_shower RUN_OPTIONS 100 8472)
add_executable (cascade_example cascade_example.cpp)
target_link_libraries (cascade_example CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (cascade_example)
if (WITH_FLUKA)
add_executable (mars cascade_examples/mars.cpp)
target_link_libraries (mars PRIVATE CORSIKA8::CORSIKA8)
message("FLUKA found, will make 'mars' example")
else()
message("FLUKA not found, will not make 'mars' example")
endif()
add_executable (boundary_example boundary_example.cpp)
target_link_libraries (boundary_example CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (boundary_example)
add_executable (mc_conex cascade_examples/mc_conex.cpp)
target_link_libraries (mc_conex PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (mc_conex RUN_OPTIONS 4 2 10000.)
add_executable (cascade_proton_example cascade_proton_example.cpp)
target_link_libraries (cascade_proton_example CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (cascade_proton_example)
add_executable (radio_em_shower cascade_examples/radio_em_shower.cpp)
target_link_libraries (radio_em_shower PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (radio_em_shower RUN_OPTIONS 10 1121673489)
add_executable (vertical_EAS vertical_EAS.cpp)
target_link_libraries (vertical_EAS CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (vertical_EAS RUN_OPTIONS 4 2 10000. 1)
if (WITH_FLUKA)
add_executable (water cascade_examples/water.cpp)
target_link_libraries (water PRIVATE CORSIKA8::CORSIKA8)
message("FLUKA found, will make 'water' example")
else()
message("FLUKA not found, will not make 'water' example")
endif()
add_executable (stopping_power stopping_power.cpp)
target_link_libraries (stopping_power CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (stopping_power)
add_executable (staticsequence_example staticsequence_example.cpp)
target_link_libraries (staticsequence_example CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (staticsequence_example)
#####################
## framework_examples
#####################
add_executable (boundary_crossing framework_examples/boundary_crossing.cpp)
target_link_libraries (boundary_crossing PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (boundary_crossing)
add_executable (environment framework_examples/environment.cpp)
target_link_libraries (environment PRIVATE CORSIKA8::CORSIKA8)
add_executable (geometry framework_examples/geometry.cpp)
target_link_libraries (geometry PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (geometry)
add_executable (helix_trajectory framework_examples/helix_trajectory.cpp)
target_link_libraries (helix_trajectory PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (helix_trajectory)
add_executable (known_particles framework_examples/known_particles.cpp)
target_link_libraries (known_particles PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (known_particles)
add_executable (stack framework_examples/stack.cpp)
target_link_libraries (stack PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (stack)
add_executable (static_sequence framework_examples/static_sequence.cpp)
target_link_libraries (static_sequence PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (static_sequence)
###################
## physics_examples
###################
add_executable (cross_section physics_examples/cross_section.cpp)
target_link_libraries (cross_section PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (cross_section RUN_OPTIONS sibyll)
add_executable (had_interactions physics_examples/had_interactions.cpp)
target_link_libraries (had_interactions PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (had_interactions RUN_OPTIONS sibyll)
add_executable (stopping_power physics_examples/stopping_power.cpp)
target_link_libraries (stopping_power PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (stopping_power)
add_executable (particle_list_example particle_list_example.cpp)
target_link_libraries (particle_list_example CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (particle_list_example)
add_executable (synchrotron_clover_leaf physics_examples/synchrotron_clover_leaf.cpp)
target_link_libraries (synchrotron_clover_leaf PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (synchrotron_clover_leaf)
add_executable (em_shower em_shower.cpp)
target_link_libraries (em_shower CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (em_shower RUN_OPTIONS "100.")
add_executable (synchrotron_test_C8tracking physics_examples/synchrotron_test_C8tracking.cpp)
target_link_libraries (synchrotron_test_C8tracking PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (synchrotron_test_C8tracking)
add_executable (hybrid_MC hybrid_MC.cpp)
target_link_libraries (hybrid_MC CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (hybrid_MC RUN_OPTIONS 4 2 10000.)
add_executable (synchrotron_test_manual_tracking physics_examples/synchrotron_test_manual_tracking.cpp)
target_link_libraries (synchrotron_test_manual_tracking PRIVATE CORSIKA8::CORSIKA8)
CORSIKA_REGISTER_EXAMPLE (synchrotron_test_manual_tracking)
# CORSIKA 8 Examples
This directory contains several example scripts that can help you get started to simulate your own showers and/or to begin developing your own interfaces within the C8 framework.
The sub-directories contain the several types of examples:
* **cascade_examples**: scripts to set up running full cascade simulations for various use cases. This is a good starting point if you want to simulate showers for your own experiments.
* **framework_examples**: show how to use and interact with the internal framework of C8
* **physics_examples**: demonstrate various tests of the particle interactions and/or cascades
\ No newline at end of file
/*
* (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/Cascade.hpp>
#include <corsika/framework/process/ProcessSequence.hpp>
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <corsika/framework/random/RNGManager.hpp>
#include <corsika/framework/geometry/Sphere.hpp>
#include <corsika/framework/utility/CorsikaFenv.hpp>
#include <corsika/framework/core/Logging.hpp>
#include <corsika/output/OutputManager.hpp>
#include <corsika/media/Environment.hpp>
#include <corsika/media/HomogeneousMedium.hpp>
#include <corsika/media/NuclearComposition.hpp>
#include <corsika/media/ShowerAxis.hpp>
#include <corsika/media/MediumPropertyModel.hpp>
#include <corsika/media/UniformMagneticField.hpp>
#include <corsika/setup/SetupEnvironment.hpp>
#include <corsika/setup/SetupStack.hpp>
#include <corsika/setup/SetupTrajectory.hpp>
#include <corsika/modules/BetheBlochPDG.hpp>
#include <corsika/modules/StackInspector.hpp>
#include <corsika/modules/Sibyll.hpp>
#include <corsika/modules/ParticleCut.hpp>
#include <corsika/modules/TrackWriter.hpp>
/*
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>
#include <iostream>
#include <limits>
using namespace corsika;
using namespace std;
//
// The example main program for a particle cascade
//
int main() {
logging::set_level(logging::level::info);
std::cout << "cascade_example" << std::endl;
const LengthType height_atmosphere = 112.8_km;
feenableexcept(FE_INVALID);
// initialize random number sequence(s)
RNGManager::getInstance().registerRandomStream("cascade");
// setup environment, geometry
setup::Environment env;
auto& universe = *(env.getUniverse());
CoordinateSystemPtr const& rootCS = env.getCoordinateSystem();
auto world =
setup::Environment::createNode<Sphere>(Point{rootCS, 0_m, 0_m, 0_m}, 150_km);
using MyHomogeneousModel = MediumPropertyModel<
UniformMagneticField<HomogeneousMedium<setup::EnvironmentInterface>>>;
// fraction of oxygen
float const fox = 0.20946;
auto const props = world->setModelProperties<MyHomogeneousModel>(
Medium::AirDry1Atm, MagneticFieldVector(rootCS, 0_T, 0_T, 0_T),
1_kg / (1_m * 1_m * 1_m),
NuclearComposition(std::vector<Code>{Code::Nitrogen, Code::Oxygen},
std::vector<float>{1.f - fox, fox}));
auto innerMedium =
setup::Environment::createNode<Sphere>(Point{rootCS, 0_m, 0_m, 0_m}, 5000_m);
innerMedium->setModelProperties(props);
world->addChild(std::move(innerMedium));
universe.addChild(std::move(world));
// 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 HEPEnergyType E0 = nuclA * 1_TeV;
double theta = 0.;
double phi = 0.;
Point const injectionPos(
rootCS, 0_m, 0_m,
height_atmosphere); // this is the CORSIKA 7 start of atmosphere/universe
OutputManager output("cascade_outputs");
ShowerAxis const showerAxis{injectionPos, Vector{rootCS, 0_m, 0_m, -100_km}, env};
{
auto elab2plab = [](HEPEnergyType Elab, HEPMassType m) {
return sqrt((Elab - m) * (Elab + m));
};
HEPMomentumType P0 = elab2plab(E0, mass);
auto momentumComponents = [](double theta, double phi, HEPMomentumType ptot) {
return std::make_tuple(ptot * sin(theta) * cos(phi), ptot * sin(theta) * sin(phi),
-ptot * cos(theta));
};
auto const [px, py, pz] =
momentumComponents(theta / 180. * M_PI, phi / 180. * M_PI, P0);
auto plab = MomentumVector(rootCS, {px, py, pz});
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, E0, plab, injectionPos, 0_ns, nuclA, nuclZ));
}
// setup processes, decays and interactions
setup::Tracking tracking;
StackInspector<setup::Stack> stackInspect(1, true, E0);
RNGManager::getInstance().registerRandomStream("sibyll");
RNGManager::getInstance().registerRandomStream("pythia");
corsika::sibyll::Interaction sibyll;
corsika::sibyll::NuclearInteraction sibyllNuc(sibyll, env);
corsika::sibyll::Decay decay;
// cascade with only HE model ==> HE cut
ParticleCut cut(80_GeV, true, true);
TrackWriter trackWriter;
output.add("tracks", trackWriter); // register TrackWriter
BetheBlochPDG eLoss{showerAxis};
// assemble all processes into an ordered process list
auto sequence =
make_sequence(stackInspect, sibyll, sibyllNuc, decay, eLoss, cut, trackWriter);
// define air shower object, run simulation
Cascade EAS(env, tracking, sequence, output, stack);
EAS.run();
eLoss.printProfile(); // print longitudinal profile
cut.showResults();
const HEPEnergyType Efinal =
cut.getCutEnergy() + cut.getInvEnergy() + cut.getEmEnergy();
cout << "total cut energy (GeV): " << Efinal / 1_GeV << endl
<< "relative difference (%): " << (Efinal / E0 - 1) * 100 << endl;
cout << "total dEdX energy (GeV): " << eLoss.getTotal() / 1_GeV << endl
<< "relative difference (%): " << eLoss.getTotal() / E0 * 100 << endl;
cut.reset();
output.endOfLibrary();
}
/*
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
* (c) Copyright 2022 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.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
#include <corsika/framework/core/Cascade.hpp>
#include <corsika/framework/utility/SaveBoostHistogram.hpp>
#include <corsika/framework/core/EnergyMomentumOperations.hpp>
#include <corsika/framework/core/Logging.hpp>
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <corsika/framework/geometry/PhysicalGeometry.hpp>
#include <corsika/framework/geometry/Plane.hpp>
#include <corsika/framework/geometry/Sphere.hpp>
#include <corsika/framework/geometry/PhysicalGeometry.hpp>
#include <corsika/framework/process/InteractionCounter.hpp>
#include <corsika/framework/process/ProcessSequence.hpp>
#include <corsika/framework/process/SwitchProcessSequence.hpp>
#include <corsika/framework/random/RNGManager.hpp>
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <corsika/framework/utility/CorsikaFenv.hpp>
#include <corsika/framework/process/InteractionCounter.hpp>
#include <corsika/framework/core/Logging.hpp>
#include <corsika/modules/writers/EnergyLossWriter.hpp>
#include <corsika/modules/writers/LongitudinalWriter.hpp>
#include <corsika/modules/writers/PrimaryWriter.hpp>
#include <corsika/modules/writers/SubWriter.hpp>
#include <corsika/output/OutputManager.hpp>
#include <corsika/media/CORSIKA7Atmospheres.hpp>
#include <corsika/media/Environment.hpp>
#include <corsika/media/LayeredSphericalAtmosphereBuilder.hpp>
#include <corsika/media/NuclearComposition.hpp>
#include <corsika/media/ShowerAxis.hpp>
#include <corsika/media/MediumPropertyModel.hpp>
#include <corsika/media/ShowerAxis.hpp>
#include <corsika/media/UniformMagneticField.hpp>
#include <corsika/modules/LongitudinalProfile.hpp>
#include <corsika/modules/ObservationPlane.hpp>
#include <corsika/modules/PROPOSAL.hpp>
#include <corsika/modules/ParticleCut.hpp>
#include <corsika/modules/Sibyll.hpp>
#include <corsika/modules/Sophia.hpp>
#include <corsika/modules/TrackWriter.hpp>
#include <corsika/modules/PROPOSAL.hpp>
#include <corsika/setup/SetupStack.hpp>
#include <corsika/setup/SetupTrajectory.hpp>
#include <corsika/setup/SetupC7trackedParticles.hpp>
#include <iomanip>
#include <iostream>
......@@ -42,88 +49,81 @@
#include <string>
#include <typeinfo>
/*
NOTE, WARNING, ATTENTION
The .../Random.hpppp 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>
using namespace corsika;
using namespace std;
void registerRandomStreams() {
RNGManager::getInstance().registerRandomStream("cascade");
RNGManager::getInstance().registerRandomStream("proposal");
RNGManager::getInstance().seedAll();
void registerRandomStreams(int seed) {
RNGManager<>::getInstance().registerRandomStream("cascade");
RNGManager<>::getInstance().registerRandomStream("proposal");
RNGManager<>::getInstance().registerRandomStream("sibyll");
RNGManager<>::getInstance().registerRandomStream("sophia");
if (seed == 0) {
std::random_device rd;
seed = rd();
CORSIKA_LOG_INFO("random seed (auto) {} ", seed);
} else {
CORSIKA_LOG_INFO("random seed {} ", seed);
}
RNGManager<>::getInstance().setSeed(seed);
}
using EnvironmentInterface = IMediumPropertyModel<IMagneticFieldModel<IMediumModel>>;
using EnvType = Environment<EnvironmentInterface>;
template <typename T>
using MyExtraEnv = MediumPropertyModel<UniformMagneticField<T>>;
using StackType = setup::Stack<EnvType>;
using TrackingType = setup::Tracking;
int main(int argc, char** argv) {
logging::set_level(logging::level::info);
logging::set_level(logging::level::warn);
if (argc != 2) {
std::cerr << "usage: em_shower <energy/GeV>" << std::endl;
if (!(argc == 2 || argc == 3)) {
std::cerr << "usage: em_shower <energy/GeV> [seed]" << std::endl
<< "seed = 0 for randomized seed" << std::endl;
return 1;
}
feenableexcept(FE_INVALID);
int seed = 0;
if (argc >= 3) { seed = std::stoi(std::string(argv[2])); }
// initialize random number sequence(s)
registerRandomStreams();
registerRandomStreams(seed);
// setup environment, geometry
using EnvType = setup::Environment;
EnvType env;
CoordinateSystemPtr const& rootCS = env.getCoordinateSystem();
Point const center{rootCS, 0_m, 0_m, 0_m};
auto builder = make_layered_spherical_atmosphere_builder<
setup::EnvironmentInterface, MyExtraEnv>::create(center,
constants::EarthRadius::Mean,
Medium::AirDry1Atm,
Vector{rootCS, 0_T, 50_uT, 0_T});
builder.setNuclearComposition(
{{Code::Nitrogen, Code::Oxygen},
{0.7847f, 1.f - 0.7847f}}); // values taken from AIRES manual, Ar removed for now
builder.addExponentialLayer(1222.6562_g / (1_cm * 1_cm), 994186.38_cm, 4_km);
builder.addExponentialLayer(1144.9069_g / (1_cm * 1_cm), 878153.55_cm, 10_km);
builder.addExponentialLayer(1305.5948_g / (1_cm * 1_cm), 636143.04_cm, 40_km);
builder.addExponentialLayer(540.1778_g / (1_cm * 1_cm), 772170.16_cm, 100_km);
builder.addLinearLayer(1e9_cm, 112.8_km);
builder.assemble(env);
// setup particle stack, and add primary particle
setup::Stack stack;
stack.clear();
// build a Linsley US Standard atmosphere into `env`
MagneticFieldVector bField{rootCS, 50_uT, 0_T, 0_T};
create_5layer_atmosphere<EnvironmentInterface, MyExtraEnv>(
env, AtmosphereId::LinsleyUSStd, center, Medium::AirDry1Atm, bField);
std::unordered_map<Code, HEPEnergyType> energy_resolution = {
{Code::Electron, 5_MeV},
{Code::Positron, 5_MeV},
{Code::Photon, 5_MeV},
};
for (auto const& [pcode, energy] : energy_resolution)
set_energy_production_threshold(pcode, energy);
const Code beamCode = Code::Electron;
auto const mass = get_mass(beamCode);
const HEPEnergyType E0 = 1_GeV * std::stof(std::string(argv[1]));
double theta = 0.;
auto const thetaRad = theta / 180. * M_PI;
auto elab2plab = [](HEPEnergyType Elab, HEPMassType m) {
return sqrt((Elab - m) * (Elab + m));
};
HEPMomentumType P0 = elab2plab(E0, mass);
HEPMomentumType P0 = calculate_momentum(E0, mass);
auto momentumComponents = [](double thetaRad, HEPMomentumType ptot) {
return std::make_tuple(ptot * sin(thetaRad), 0_eV, -ptot * cos(thetaRad));
};
auto const [px, py, pz] = momentumComponents(thetaRad, P0);
auto plab = MomentumVector(rootCS, {px, py, pz});
cout << "input particle: " << beamCode << endl;
cout << "input angles: theta=" << theta << endl;
cout << "input momentum: " << plab.getComponents() / 1_GeV
<< ", norm = " << plab.getNorm() << endl;
auto const observationHeight = 1.4_km + builder.getEarthRadius();
auto const injectionHeight = 112.75_km + builder.getEarthRadius();
auto const observationHeight = 0.0_km + constants::EarthRadius::Mean;
auto const injectionHeight = 112.75_km + constants::EarthRadius::Mean;
auto const t = -observationHeight * cos(thetaRad) +
sqrt(-static_pow<2>(sin(thetaRad) * observationHeight) +
static_pow<2>(injectionHeight));
......@@ -131,62 +131,86 @@ int main(int argc, char** argv) {
Point const injectionPos =
showerCore + DirectionVector{rootCS, {-sin(thetaRad), 0, cos(thetaRad)}} * t;
std::cout << "point of injection: " << injectionPos.getCoordinates() << std::endl;
ShowerAxis const showerAxis{injectionPos, (showerCore - injectionPos) * 1.02, env,
false, 1000};
auto const dX = 10_g / square(1_cm); // Binning of the writers along the shower axis
stack.addParticle(std::make_tuple(beamCode, E0, plab, injectionPos, 0_ns));
CORSIKA_LOG_INFO("Primary particle: {}", beamCode);
CORSIKA_LOG_INFO("Zenith angle: {} (rad)", theta);
CORSIKA_LOG_INFO("Momentum: {} (GeV)", plab.getComponents() / 1_GeV);
CORSIKA_LOG_INFO("Propagation dir: {}", plab.getNorm());
CORSIKA_LOG_INFO("Injection point: {}", injectionPos.getCoordinates());
CORSIKA_LOG_INFO("shower axis length: {} ",
(showerCore - injectionPos).getNorm() * 1.02);
std::cout << "shower axis length: " << (showerCore - injectionPos).getNorm() * 1.02
<< std::endl;
// setup processes, decays and interactions
EnergyLossWriter energyloss{showerAxis, dX};
ParticleCut<SubWriter<decltype(energyloss)>> cut(5_MeV, 5_MeV, 100_GeV, 100_GeV,
100_GeV, true, energyloss);
corsika::sibyll::Interaction sibyll(corsika::get_all_elements_in_universe(env),
corsika::setup::C7trackedParticles);
corsika::sophia::InteractionModel sophia;
HEPEnergyType heThresholdNN = 80_GeV;
corsika::proposal::Interaction emCascade(
env, sophia, sibyll.getHadronInteractionModel(), heThresholdNN);
corsika::proposal::ContinuousProcess<SubWriter<decltype(energyloss)>> emContinuous(
env, energyloss);
// NOT possible right now, due to interface differenc in PROPOSAL
// InteractionCounter emCascadeCounted(emCascade);
OutputManager output("em_shower_outputs");
ShowerAxis const showerAxis{injectionPos, (showerCore - injectionPos) * 1.02, env};
// setup processes, decays and interactions
ParticleCut cut(10_GeV, 10_GeV, 100_PeV, 100_PeV, true);
corsika::proposal::Interaction emCascade(env);
corsika::proposal::ContinuousProcess emContinuous(env);
InteractionCounter emCascadeCounted(emCascade);
output.add("energyloss", energyloss);
TrackWriter trackWriter;
output.add("tracks", trackWriter); // register TrackWriter
TrackWriter tracks;
output.add("tracks", tracks);
// long. profile; columns for photon, e+, e- still need to be added
LongitudinalProfile longprof{showerAxis};
LongitudinalWriter profile{showerAxis, dX};
output.add("profile", profile);
LongitudinalProfile<SubWriter<decltype(profile)>> longprof{profile};
Plane const obsPlane(showerCore, DirectionVector(rootCS, {0., 0., 1.}));
ObservationPlane observationLevel(obsPlane, DirectionVector(rootCS, {1., 0., 0.}),
"particles.dat");
output.add("obsplane", observationLevel);
ObservationPlane<TrackingType, ParticleWriterParquet> observationLevel{
obsPlane, DirectionVector(rootCS, {1., 0., 0.})};
output.add("particles", observationLevel);
auto sequence = make_sequence(emCascadeCounted, emContinuous, longprof, cut,
observationLevel, trackWriter);
PrimaryWriter<TrackingType, ParticleWriterParquet> primaryWriter(observationLevel);
output.add("primary", primaryWriter);
auto sequence = make_sequence(emCascade, emContinuous, longprof, observationLevel, cut);
// define air shower object, run simulation
setup::Tracking tracking;
TrackingType tracking;
output.startOfLibrary();
auto const primaryProperties = std::make_tuple(
beamCode, calculate_kinetic_energy(plab.getNorm(), get_mass(beamCode)),
plab.normalized(), injectionPos, 0_ns);
// setup particle stack, and add primary particle
StackType stack;
stack.clear();
stack.addParticle(primaryProperties);
primaryWriter.recordPrimary(primaryProperties);
Cascade EAS(env, tracking, sequence, output, stack);
// to fix the point of first interaction, uncomment the following two lines:
// EAS.setNodes();
// EAS.forceInteraction();
EAS.run();
cut.showResults();
emContinuous.showResults();
observationLevel.showResults();
const HEPEnergyType Efinal = cut.getCutEnergy() + cut.getInvEnergy() +
cut.getEmEnergy() + emContinuous.getEnergyLost() +
observationLevel.getEnergyGround();
cout << "total cut energy (GeV): " << Efinal / 1_GeV << endl
<< "relative difference (%): " << (Efinal / E0 - 1) * 100 << endl;
observationLevel.reset();
cut.reset();
emContinuous.reset();
auto const hists = emCascadeCounted.getHistogram();
save_hist(hists.labHist(), "inthist_lab_emShower.npz", true);
save_hist(hists.CMSHist(), "inthist_cms_emShower.npz", true);
longprof.save("longprof_emShower.txt");
HEPEnergyType const Efinal =
energyloss.getEnergyLost() + observationLevel.getEnergyGround();
CORSIKA_LOG_INFO(
"total energy budget (GeV): {}, "
"relative difference (%): {}",
Efinal / 1_GeV, (Efinal / E0 - 1) * 100);
output.endOfLibrary();
return EXIT_SUCCESS;
}