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..c5f01006a5f8585e78771bf989fc492725b576d0 100644 --- a/Processes/LongitudinalProfile/LongitudinalProfile.h +++ b/Processes/LongitudinalProfile/LongitudinalProfile.h @@ -20,27 +20,44 @@ namespace corsika::process::longitudinal_profile { + /** + * /class Longitudinal_Profile + * + * is a ContinuousProcess, which is constructed from a ShowerAxis + * object, and a dX in units of g/cm2 + * (corsika::units::si::GrammageType). The shower axis can convert + * location in the shower into a projected grammage along the shower + * axis. + * + * 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 +70,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