diff --git a/Environment/ShowerAxis.h b/Environment/ShowerAxis.h index a771e177da6644dfb429fee00db63459919ad240..6279c36b80b6e63d950d8768c24ff8add4898cd3 100644 --- a/Environment/ShowerAxis.h +++ b/Environment/ShowerAxis.h @@ -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> diff --git a/Processes/LongitudinalProfile/LongitudinalProfile.cc b/Processes/LongitudinalProfile/LongitudinalProfile.cc index 08d7e3076138b32e2887bf6f81aaf34de11156ee..0e174ee7338dfe2f5fb47bbbf6facfe811fe2ced 100644 --- a/Processes/LongitudinalProfile/LongitudinalProfile.cc +++ b/Processes/LongitudinalProfile/LongitudinalProfile.cc @@ -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; } diff --git a/Processes/LongitudinalProfile/LongitudinalProfile.h b/Processes/LongitudinalProfile/LongitudinalProfile.h index 0e155a70c60abc84a6fb0e7132fba9d9fbbd802a..a9a1cfa0d481f1e93254d14bd1ef6c558c842367 100644 --- a/Processes/LongitudinalProfile/LongitudinalProfile.h +++ b/Processes/LongitudinalProfile/LongitudinalProfile.h @@ -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