From 898b13022de692ac56adfe99cb7a0abf18428e25 Mon Sep 17 00:00:00 2001 From: Maximilian Reininghaus <maximilian.reininghaus@tu-dortmund.de> Date: Sun, 14 Apr 2019 01:04:52 -0300 Subject: [PATCH] coding style --- Environment/BaseExponential.h | 61 +++++++++++++------------- Environment/FlatExponential.h | 30 ++++++------- Environment/SlidingPlanarExponential.h | 33 +++++++------- 3 files changed, 64 insertions(+), 60 deletions(-) diff --git a/Environment/BaseExponential.h b/Environment/BaseExponential.h index ba9f85d5..15585b6a 100644 --- a/Environment/BaseExponential.h +++ b/Environment/BaseExponential.h @@ -38,75 +38,76 @@ namespace corsika::environment { // clang-format off /** * For a (normalized) axis \f$ \vec{a} \f$, the grammage along a non-orthogonal line with (normalized) - * direction \f$ \vec{v} \f$ is given by + * direction \f$ \vec{u} \f$ is given by * \f[ - * X = \frac{\varrho_0 \lambda}{\vec{v} \cdot \vec{a}} \left( \exp\left( \vec{v} \cdot \vec{a} \frac{l}{\lambda} \right) - 1 \right) + * X = \frac{\varrho_0 \lambda}{\vec{u} \cdot \vec{a}} \left( \exp\left( \vec{u} \cdot \vec{a} \frac{l}{\lambda} \right) - 1 \right) * \f], where \f$ \varrho_0 \f$ is the density at the starting point. * - * If \f$ \vec{v} \cdot \vec{a} = 0 \f$, the calculation is just like with a homogeneous density: + * If \f$ \vec{u} \cdot \vec{a} = 0 \f$, the calculation is just like with a homogeneous density: * \f[ * X = \varrho_0 l; * \f] */ // clang-format on units::si::GrammageType IntegratedGrammage( - geometry::Trajectory<geometry::Line> const& line, units::si::LengthType to, - geometry::Vector<units::si::dimensionless_d> const& axis) const { - auto const vDotA = line.NormalizedDirection().dot(axis).magnitude(); - auto const rhoStart = GetImplementation().GetMassDensity(line.GetR0()); + geometry::Trajectory<geometry::Line> const& vLine, units::si::LengthType vL, + geometry::Vector<units::si::dimensionless_d> const& vAxis) const { + auto const uDotA = vLine.NormalizedDirection().dot(vAxis).magnitude(); + auto const rhoStart = GetImplementation().GetMassDensity(vLine.GetR0()); - if (vDotA == 0) { - return to * rhoStart; + if (uDotA == 0) { + return vL * rhoStart; } else { - return rhoStart * (fLambda / vDotA) * (exp(vDotA * to * fInvLambda) - 1); + return rhoStart * (fLambda / uDotA) * (exp(uDotA * vL * fInvLambda) - 1); } } // clang-format off /** * For a (normalized) axis \f$ \vec{a} \f$, the length of a non-orthogonal line with (normalized) - * direction \f$ \vec{v} \f$ corresponding to grammage \f$ X \f$ is given by + * direction \f$ \vec{u} \f$ corresponding to grammage \f$ X \f$ is given by * \f[ * l = \begin{cases} - * \frac{\lambda}{\vec{v} \cdot \vec{a}} \log\left(Y \right), & \text{if} Y := 0 > 1 + - * \vec{v} \cdot \vec{a} \frac{X}{\rho_0 \lambda} + * \frac{\lambda}{\vec{u} \cdot \vec{a}} \log\left(Y \right), & \text{if} Y := 0 > 1 + + * \vec{u} \cdot \vec{a} \frac{X}{\rho_0 \lambda} * \infty & \text{else,} * \end{cases} * \f] where \f$ \varrho_0 \f$ is the density at the starting point. * - * If \f$ \vec{v} \cdot \vec{a} = 0 \f$, the calculation is just like with a homogeneous density: + * If \f$ \vec{u} \cdot \vec{a} = 0 \f$, the calculation is just like with a homogeneous density: * \f[ * l = \frac{X}{\varrho_0} * \f] */ // clang-format on units::si::LengthType ArclengthFromGrammage( - geometry::Trajectory<corsika::geometry::Line> const& line, - units::si::GrammageType grammage, - geometry::Vector<units::si::dimensionless_d> const& axis) const { - auto const vDotA = line.NormalizedDirection().dot(axis).magnitude(); - auto const rhoStart = GetImplementation().GetMassDensity(line.GetR0()); + geometry::Trajectory<geometry::Line> const& vLine, + units::si::GrammageType vGrammage, + geometry::Vector<units::si::dimensionless_d> const& vAxis) const { + auto const uDotA = vLine.NormalizedDirection().dot(vAxis).magnitude(); + auto const rhoStart = GetImplementation().GetMassDensity(vLine.GetR0()); - if (vDotA == 0) { - return grammage / rhoStart; + if (uDotA == 0) { + return vGrammage / rhoStart; } else { - auto const logArg = grammage * fInvLambda * vDotA / rhoStart + 1; + auto const logArg = vGrammage * fInvLambda * uDotA / rhoStart + 1; if (logArg > 0) { - return fLambda / vDotA * log(logArg); + return fLambda / uDotA * log(logArg); } else { - return std::numeric_limits<units::si::GrammageType::value_type>::infinity() * + return std::numeric_limits<typename decltype( + vGrammage)::value_type>::infinity() * units::si::meter; } } } public: - BaseExponential(geometry::Point const& p0, units::si::MassDensityType rho, - units::si::LengthType lambda) - : fRho0(rho) - , fLambda(lambda) - , fInvLambda(1 / lambda) - , fP0(p0) {} + BaseExponential(geometry::Point const& vP0, units::si::MassDensityType vRho, + units::si::LengthType vLambda) + : fRho0(vRho) + , fLambda(vLambda) + , fInvLambda(1 / vLambda) + , fP0(vP0) {} }; } // namespace corsika::environment diff --git a/Environment/FlatExponential.h b/Environment/FlatExponential.h index 123d0d0d..c6255f93 100644 --- a/Environment/FlatExponential.h +++ b/Environment/FlatExponential.h @@ -40,30 +40,30 @@ namespace corsika::environment { using Base = BaseExponential<FlatExponential<T>>; public: - FlatExponential(geometry::Point const& p0, - geometry::Vector<units::si::dimensionless_d> const& axis, - units::si::MassDensityType rho, units::si::LengthType lambda, - NuclearComposition nuclComp) - : Base(p0, rho, lambda) - , fAxis(axis) - , fNuclComp(nuclComp) {} + FlatExponential(geometry::Point const& vP0, + geometry::Vector<units::si::dimensionless_d> const& vAxis, + units::si::MassDensityType vRho, units::si::LengthType vLambda, + NuclearComposition vNuclComp) + : Base(vP0, vRho, vLambda) + , fAxis(vAxis) + , fNuclComp(vNuclComp) {} - units::si::MassDensityType GetMassDensity(geometry::Point const& p) const override { - return Base::fRho0 * exp(Base::fInvLambda * (p - Base::fP0).dot(fAxis)); + units::si::MassDensityType GetMassDensity(geometry::Point const& vP) const override { + return Base::fRho0 * exp(Base::fInvLambda * (vP - Base::fP0).dot(fAxis)); } NuclearComposition const& GetNuclearComposition() const override { return fNuclComp; } units::si::GrammageType IntegratedGrammage( - geometry::Trajectory<geometry::Line> const& line, - units::si::LengthType to) const override { - return Base::IntegratedGrammage(line, to, fAxis); + geometry::Trajectory<geometry::Line> const& vLine, + units::si::LengthType vTo) const override { + return Base::IntegratedGrammage(vLine, vTo, fAxis); } units::si::LengthType ArclengthFromGrammage( - geometry::Trajectory<geometry::Line> const& line, - units::si::GrammageType grammage) const override { - return Base::ArclengthFromGrammage(line, grammage, fAxis); + geometry::Trajectory<geometry::Line> const& vLine, + units::si::GrammageType vGrammage) const override { + return Base::ArclengthFromGrammage(vLine, vGrammage, fAxis); } }; } // namespace corsika::environment diff --git a/Environment/SlidingPlanarExponential.h b/Environment/SlidingPlanarExponential.h index 476bb016..3cffa3af 100644 --- a/Environment/SlidingPlanarExponential.h +++ b/Environment/SlidingPlanarExponential.h @@ -11,11 +11,13 @@ #ifndef _include_Environment_SlidingPlanarExponential_h_ #define _include_Environment_SlidingPlanarExponential_h_ -#include <corsika/environment/BaseExponential.h> +#include <corsika/environment/FlatExponential.h> #include <corsika/environment/NuclearComposition.h> #include <corsika/geometry/Line.h> #include <corsika/geometry/Point.h> #include <corsika/geometry/Trajectory.h> +#include <corsika/particles/ParticleProperties.h> +#include <corsika/random/RNGManager.h> #include <corsika/units/PhysicalUnits.h> namespace corsika::environment { @@ -40,30 +42,31 @@ namespace corsika::environment { using Base = BaseExponential<SlidingPlanarExponential<T>>; public: - SlidingPlanarExponential(geometry::Point const& p0, units::si::MassDensityType rho, - units::si::LengthType lambda, NuclearComposition nuclComp) - : Base(p0, rho, lambda) - , fNuclComp(nuclComp) {} + SlidingPlanarExponential(geometry::Point const& vP0, units::si::MassDensityType vRho, + units::si::LengthType vLambda, NuclearComposition vNuclComp) + : Base(vP0, vRho, vLambda) + , fNuclComp(vNuclComp) {} - units::si::MassDensityType GetMassDensity(geometry::Point const& p) const override { - auto const height = (p - Base::fP0).norm(); + units::si::MassDensityType GetMassDensity( + geometry::Point const& vP) const override { + auto const height = (vP - Base::fP0).norm(); return Base::fRho0 * exp(Base::fInvLambda * height); } NuclearComposition const& GetNuclearComposition() const override { return fNuclComp; } units::si::GrammageType IntegratedGrammage( - geometry::Trajectory<geometry::Line> const& line, - units::si::LengthType to) const override { - auto const axis = (line.GetR0() - Base::fP0).normalized(); - return Base::IntegratedGrammage(line, to, axis); + geometry::Trajectory<geometry::Line> const& vLine, + units::si::LengthType vL) const override { + auto const axis = (vLine.GetR0() - Base::fP0).normalized(); + return Base::IntegratedGrammage(vLine, vL, axis); } units::si::LengthType ArclengthFromGrammage( - geometry::Trajectory<geometry::Line> const& line, - units::si::GrammageType grammage) const override { - auto const axis = (line.GetR0() - Base::fP0).normalized(); - return Base::ArclengthFromGrammage(line, grammage, axis); + geometry::Trajectory<geometry::Line> const& vLine, + units::si::GrammageType vGrammage) const override { + auto const axis = (vLine.GetR0() - Base::fP0).normalized(); + return Base::ArclengthFromGrammage(vLine, vGrammage, axis); } }; -- GitLab