IAP GITLAB

Skip to content
Snippets Groups Projects
Commit f3b6c1a7 authored by Ralf Ulrich's avatar Ralf Ulrich
Browse files

Merge branch '312-what-should-process-longitudinalprofile-count' into 'master'

Resolve "What should Process::LongitudinalProfile count?"

Closes #312

See merge request AirShowerPhysics/corsika!270
parents 4756a808 7f182a3f
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,21 @@
#include <boost/math/quadrature/gauss_kronrod.hpp>
namespace corsika::environment {
/**
* \class ShowerAxis
*
* The environment::ShowerAxis is created from a geometry::Point and
* a geometry::Vector and inside an Environment. It internally uses
* a table with steps=10000 (default) rows for interpolation.
*
* The shower axis can convert location in the shower into a
* projected grammage along the shower axis.
*
**/
class ShowerAxis {
public:
template <typename TEnvModel>
......
......@@ -25,8 +25,10 @@ using Track = Trajectory;
using namespace corsika::process::longitudinal_profile;
using namespace corsika::units::si;
LongitudinalProfile::LongitudinalProfile(environment::ShowerAxis const& shower_axis)
: shower_axis_{shower_axis}
LongitudinalProfile::LongitudinalProfile(environment::ShowerAxis const& shower_axis,
units::si::GrammageType dX)
: dX_(dX)
, shower_axis_{shower_axis}
, profiles_{static_cast<unsigned int>(shower_axis.maximumX() / dX_) + 1} {}
template <>
......@@ -59,13 +61,14 @@ corsika::process::EProcessReturn LongitudinalProfile::DoContinuous(Particle cons
return corsika::process::EProcessReturn::eOk;
}
void LongitudinalProfile::save(std::string const& filename) {
void LongitudinalProfile::save(std::string const& filename, const int width,
const int precision) {
std::ofstream f{filename};
f << "# X / g·cm¯², gamma, e+, e-, mu+, mu-, all hadrons" << std::endl;
for (size_t b = 0; b < profiles_.size(); ++b) {
f << std::setprecision(5) << std::setw(11) << b * (dX_ / (1_g / 1_cm / 1_cm));
for (auto const& N : profiles_.at(b)) {
f << std::setw(width_) << std::setprecision(precision_) << std::scientific << N;
f << std::setw(width) << std::setprecision(precision) << std::scientific << N;
}
f << std::endl;
}
......
......@@ -20,27 +20,42 @@
namespace corsika::process::longitudinal_profile {
/**
* \class LongitudinalProfile
*
* is a ContinuousProcess, which is constructed from an environment::ShowerAxis
* object, and a dX in units of g/cm2
* (corsika::units::si::GrammageType).
*
* LongitudinalProfile does then convert each single Track of the
* simulation into a projected grammage range and counts for
* different particle species when they cross dX (default: 10g/cm2)
* boundaries.
*
**/
class LongitudinalProfile
: public corsika::process::ContinuousProcess<LongitudinalProfile> {
public:
LongitudinalProfile(environment::ShowerAxis const&);
LongitudinalProfile(environment::ShowerAxis const&,
units::si::GrammageType dX = std::invoke([]() {
using namespace units::si;
return 10_g / square(1_cm);
})); // profile binning);
template <typename Particle, typename Track>
corsika::process::EProcessReturn DoContinuous(Particle const&, Track const&);
template <typename TParticle, typename TTrack>
corsika::process::EProcessReturn DoContinuous(TParticle const&, TTrack const&);
template <typename Particle, typename Track>
corsika::units::si::LengthType MaxStepLength(Particle const&, Track const&) {
template <typename TParticle, typename TTrack>
corsika::units::si::LengthType MaxStepLength(TParticle const&, TTrack const&) {
return units::si::meter * std::numeric_limits<double>::infinity();
}
void save(std::string const&);
void save(std::string const&, int const width = 14, int const precision = 6);
private:
units::si::GrammageType const dX_ = std::invoke([]() {
using namespace units::si;
return 10_g / square(1_cm);
}); // profile binning
units::si::GrammageType const dX_;
environment::ShowerAxis const& shower_axis_;
using ProfileEntry = std::array<uint32_t, 6>;
......@@ -53,9 +68,6 @@ namespace corsika::process::longitudinal_profile {
Hadron = 5
};
std::vector<ProfileEntry> profiles_; // longitudinal profile
static int const width_ = 14;
static int const precision_ = 6;
};
} // namespace corsika::process::longitudinal_profile
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