IAP GITLAB

Skip to content
Snippets Groups Projects
Commit dc17fba5 authored by ralfulrich's avatar ralfulrich Committed by Maximilian Reininghaus
Browse files

improved class doc

parent 4756a808
No related branches found
No related tags found
No related merge requests found
......@@ -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,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
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