From 2077c0d636f1db08567c6177da194ac3e0532397 Mon Sep 17 00:00:00 2001 From: ralfulrich <ralf.ulrich@kit.edu> Date: Sat, 3 Apr 2021 18:23:41 +0200 Subject: [PATCH] stray static --- .../process/BoundaryCrossingProcess.hpp | 8 +- .../framework/process/ContinuousProcess.hpp | 9 +- .../detail/framework/process/DecayProcess.hpp | 15 +- .../framework/process/InteractionProcess.hpp | 10 +- .../framework/process/SecondariesProcess.hpp | 8 +- .../detail/framework/process/StackProcess.hpp | 10 +- corsika/framework/core/Cascade.hpp | 3 +- corsika/framework/core/ParticleProperties.hpp | 67 +++-- corsika/framework/process/BaseProcess.hpp | 6 +- .../process/BoundaryCrossingProcess.hpp | 7 +- .../framework/process/ContinuousProcess.hpp | 16 +- .../process/ContinuousProcessIndex.hpp | 2 +- .../process/ContinuousProcessStepLength.hpp | 2 +- corsika/framework/process/DecayProcess.hpp | 16 +- .../framework/process/InteractionCounter.hpp | 4 +- .../process/InteractionHistogram.hpp | 4 +- .../framework/process/InteractionProcess.hpp | 25 +- corsika/framework/process/ProcessReturn.hpp | 2 +- corsika/framework/process/ProcessSequence.hpp | 229 +++++++++--------- corsika/framework/process/ProcessTraits.hpp | 1 - .../framework/process/SecondariesProcess.hpp | 10 +- corsika/framework/process/StackProcess.hpp | 19 +- .../process/SwitchProcessSequence.hpp | 19 +- corsika/media/MediumProperties.hpp | 61 +++-- corsika/modules/conex/CONEXhybrid.hpp | 2 +- .../tracking/TrackingLeapFrogCurved.hpp | 3 +- .../tracking/TrackingLeapFrogStraight.hpp | 2 +- corsika/modules/tracking/TrackingStraight.hpp | 2 +- corsika/modules/urqmd/UrQMD.hpp | 2 +- corsika/setup/SetupTrajectory.hpp | 4 +- tests/framework/testProcessSequence.cpp | 19 +- 31 files changed, 293 insertions(+), 294 deletions(-) diff --git a/corsika/detail/framework/process/BoundaryCrossingProcess.hpp b/corsika/detail/framework/process/BoundaryCrossingProcess.hpp index caf268523..929bc95f7 100644 --- a/corsika/detail/framework/process/BoundaryCrossingProcess.hpp +++ b/corsika/detail/framework/process/BoundaryCrossingProcess.hpp @@ -13,9 +13,10 @@ namespace corsika { // test for doBoundaryCrossing method - + template <class TProcess, typename TReturn, typename... TArg> - struct has_method_doBoundaryCrossing : public detail::has_method_signature<TReturn, TArg...> { + struct has_method_doBoundaryCrossing + : public detail::has_method_signature<TReturn, TArg...> { using detail::has_method_signature<TReturn, TArg...>::testSignature; @@ -39,7 +40,6 @@ namespace corsika { template <class TProcess, typename TReturn, typename... TArg> bool constexpr has_method_doBoundaryCrossing_v = - has_method_doBoundaryCrossing<TProcess, TReturn, TArg...>::value; - + has_method_doBoundaryCrossing<TProcess, TReturn, TArg...>::value; } // namespace corsika diff --git a/corsika/detail/framework/process/ContinuousProcess.hpp b/corsika/detail/framework/process/ContinuousProcess.hpp index c91805914..b119e8194 100644 --- a/corsika/detail/framework/process/ContinuousProcess.hpp +++ b/corsika/detail/framework/process/ContinuousProcess.hpp @@ -13,9 +13,10 @@ namespace corsika { // test for doContinuous method - + template <class TProcess, typename TReturn, typename TArg1, typename TArg2> - struct has_method_doContinuous : public detail::has_method_signature<TReturn, TArg1, TArg2, bool> { + struct has_method_doContinuous + : public detail::has_method_signature<TReturn, TArg1, TArg2, bool> { using detail::has_method_signature<TReturn, TArg1, TArg2, bool>::testSignature; @@ -39,10 +40,10 @@ namespace corsika { template <class TProcess, typename TReturn, typename TArg1, typename TArg2> bool constexpr has_method_doContinuous_v = - has_method_doContinuous<TProcess, TReturn, TArg1, TArg2>::value; + has_method_doContinuous<TProcess, TReturn, TArg1, TArg2>::value; // test for getMaxStepLength method - + template <class TProcess, typename TReturn, typename... TArgs> struct has_method_getMaxStepLength : public detail::has_method_signature<TReturn, TArgs...> { diff --git a/corsika/detail/framework/process/DecayProcess.hpp b/corsika/detail/framework/process/DecayProcess.hpp index 661d0aeb1..e61d1c6e7 100644 --- a/corsika/detail/framework/process/DecayProcess.hpp +++ b/corsika/detail/framework/process/DecayProcess.hpp @@ -13,12 +13,12 @@ namespace corsika { // doDecay - + template <class TProcess, typename TReturn, typename... TArgs> struct has_method_doDecay : public detail::has_method_signature<TReturn, TArgs...> { typedef std::decay_t<TProcess> process_type; - + using detail::has_method_signature<TReturn, TArgs...>::testSignature; // the default value @@ -27,9 +27,8 @@ namespace corsika { // signature of templated method template <class T> - static decltype(testSignature(&T::template doDecay<TArgs...>)) test( - std::nullptr_t); - + static decltype(testSignature(&T::template doDecay<TArgs...>)) test(std::nullptr_t); + // signature of non-templated method template <class T> static decltype(testSignature(&T::doDecay)) test(std::nullptr_t); @@ -43,12 +42,10 @@ namespace corsika { bool constexpr has_method_doDecay_v = has_method_doDecay<TProcess, TReturn, TArgs...>::value; - // getLifetime - + template <class TProcess, typename TReturn, typename... TArgs> - struct has_method_getLifetime - : public detail::has_method_signature<TReturn, TArgs...> { + struct has_method_getLifetime : public detail::has_method_signature<TReturn, TArgs...> { using detail::has_method_signature<TReturn, TArgs...>::testSignature; diff --git a/corsika/detail/framework/process/InteractionProcess.hpp b/corsika/detail/framework/process/InteractionProcess.hpp index f97fd4e4e..faa6d5cc4 100644 --- a/corsika/detail/framework/process/InteractionProcess.hpp +++ b/corsika/detail/framework/process/InteractionProcess.hpp @@ -12,9 +12,8 @@ namespace corsika { - // doInteract - + template <class TProcess, typename TReturn, typename... TArgs> struct has_method_doInteract : public detail::has_method_signature<TReturn, TArgs...> { @@ -23,7 +22,7 @@ namespace corsika { // the default value template <class T> static std::false_type test(...); - + // signature of templated method template <class T> static decltype(testSignature(&T::template doInteraction<TArgs...>)) test( @@ -37,14 +36,13 @@ namespace corsika { using type = decltype(test<std::decay_t<TProcess>>(nullptr)); static const bool value = type::value; }; - + template <class TProcess, typename TReturn, typename... TArgs> bool constexpr has_method_doInteract_v = has_method_doInteract<TProcess, TReturn, TArgs...>::value; - // getInteractionLength - + template <class TProcess, typename TReturn, typename... TArgs> struct has_method_getInteractionLength : public detail::has_method_signature<TReturn, TArgs...> { diff --git a/corsika/detail/framework/process/SecondariesProcess.hpp b/corsika/detail/framework/process/SecondariesProcess.hpp index 26990ce68..c4d9bb5cc 100644 --- a/corsika/detail/framework/process/SecondariesProcess.hpp +++ b/corsika/detail/framework/process/SecondariesProcess.hpp @@ -13,9 +13,10 @@ namespace corsika { // test for doSecondaries method - + template <class TProcess, typename TReturn, typename... TArg> - struct has_method_doSecondaries : public detail::has_method_signature<TReturn, TArg...> { + struct has_method_doSecondaries + : public detail::has_method_signature<TReturn, TArg...> { using detail::has_method_signature<TReturn, TArg...>::testSignature; @@ -39,7 +40,6 @@ namespace corsika { template <class TProcess, typename TReturn, typename... TArg> bool constexpr has_method_doSecondaries_v = - has_method_doSecondaries<TProcess, TReturn, TArg...>::value; - + has_method_doSecondaries<TProcess, TReturn, TArg...>::value; } // namespace corsika diff --git a/corsika/detail/framework/process/StackProcess.hpp b/corsika/detail/framework/process/StackProcess.hpp index 1eea73409..a847d0ccd 100644 --- a/corsika/detail/framework/process/StackProcess.hpp +++ b/corsika/detail/framework/process/StackProcess.hpp @@ -13,7 +13,7 @@ namespace corsika { // test method doStack - + template <class TProcess, typename TReturn, typename... TArgs> struct has_method_doStack : public detail::has_method_signature<TReturn, TArgs...> { @@ -22,16 +22,14 @@ namespace corsika { // the default value template <class T> static std::false_type test(...); - + // templated parameter option template <class T> - static decltype(testSignature(&T::template doStack<TArgs...>)) test( - std::nullptr_t); + static decltype(testSignature(&T::template doStack<TArgs...>)) test(std::nullptr_t); // non-templated parameter option template <template <typename> typename T> - static decltype(testSignature(&T<TArgs...>::template doStack)) test( - std::nullptr_t); + static decltype(testSignature(&T<TArgs...>::template doStack)) test(std::nullptr_t); template <class T> static decltype(testSignature(&T::doStack)) test(std::nullptr_t); diff --git a/corsika/framework/core/Cascade.hpp b/corsika/framework/core/Cascade.hpp index 4b2b1b990..7ee12186a 100644 --- a/corsika/framework/core/Cascade.hpp +++ b/corsika/framework/core/Cascade.hpp @@ -90,7 +90,8 @@ namespace corsika { , sequence_(pl) , stack_(stack) { CORSIKA_LOG_INFO(c8_ascii_); - CORSIKA_LOG_INFO("Tracking algorithm: {} (version {})", TTracking::getName(), TTracking::getVersion()); + CORSIKA_LOG_INFO("Tracking algorithm: {} (version {})", TTracking::getName(), + TTracking::getVersion()); if constexpr (TStackView::has_event) { CORSIKA_LOG_INFO("Stack - with full cascade HISTORY."); } diff --git a/corsika/framework/core/ParticleProperties.hpp b/corsika/framework/core/ParticleProperties.hpp index 51f2b4a78..d0d17d264 100644 --- a/corsika/framework/core/ParticleProperties.hpp +++ b/corsika/framework/core/ParticleProperties.hpp @@ -24,46 +24,46 @@ #include <corsika/framework/core/PhysicalUnits.hpp> - namespace corsika { -/** - @defgroup Particles Particle Properties - - The properties of all particles are saved in static and flat - arrays. There is a enum corsika::Code to identify each - particles, and each individual particles has its own static class, - which can be used to retrieve its physical properties. - - The properties of all elementary particles are accessible here. The data - are taken from the Pythia ParticleData.xml file. - - Particle data can be accessed via global function in namespace corsika, or via - static classes for each particle type. These classes all have the interface (example for - the class corsika::Electron): - - @code{.cpp} - static constexpr Code code{Code::Electron}; - static constexpr Code anti_code{Code::Positron}; - static constexpr HEPMassType mass{corsika::get_mass(code)}; - static constexpr ElectricChargeType charge{corsika::get_charge(code)}; - static constexpr int charge_number{corsika::get_charge_number(code)}; - static constexpr std::string_view name{corsika::get_name(code)}; - static constexpr bool is_nucleus{corsika::is_nucleus(code)}; - @endcode - - The names, relations and properties of all particles known to CORSIKA 8 are listed below. - - @addtogroup Particles - @{ - */ + /** + @defgroup Particles Particle Properties + + The properties of all particles are saved in static and flat + arrays. There is a enum corsika::Code to identify each + particles, and each individual particles has its own static class, + which can be used to retrieve its physical properties. + + The properties of all elementary particles are accessible here. The data + are taken from the Pythia ParticleData.xml file. + + Particle data can be accessed via global function in namespace corsika, or via + static classes for each particle type. These classes all have the interface (example + for the class corsika::Electron): + + @code{.cpp} + static constexpr Code code{Code::Electron}; + static constexpr Code anti_code{Code::Positron}; + static constexpr HEPMassType mass{corsika::get_mass(code)}; + static constexpr ElectricChargeType charge{corsika::get_charge(code)}; + static constexpr int charge_number{corsika::get_charge_number(code)}; + static constexpr std::string_view name{corsika::get_name(code)}; + static constexpr bool is_nucleus{corsika::is_nucleus(code)}; + @endcode + + The names, relations and properties of all particles known to CORSIKA 8 are listed + below. + + @addtogroup Particles + @{ + */ /** The Code enum is the actual place to define CORSIKA 8 particle codes. */ enum class Code : int16_t; - + /** Specifically for PDG ids */ enum class PDGCode : int32_t; - + using CodeIntType = std::underlying_type<Code>::type; using PDGCodeType = std::underlying_type<PDGCode>::type; @@ -124,4 +124,3 @@ namespace corsika { // constants in namespaces-like static classes, generated automatically #include <corsika/framework/core/GeneratedParticleClasses.inc> - diff --git a/corsika/framework/process/BaseProcess.hpp b/corsika/framework/process/BaseProcess.hpp index 47f2a8eaa..56b8b38f2 100644 --- a/corsika/framework/process/BaseProcess.hpp +++ b/corsika/framework/process/BaseProcess.hpp @@ -46,7 +46,7 @@ namespace corsika { // BaseProcess itself /** @name getRef Return reference to underlying type - @{ + @{ */ TDerived& ref() { return static_cast<TDerived&>(*this); } const TDerived& ref() const { return static_cast<const TDerived&>(*this); } @@ -72,7 +72,7 @@ namespace corsika { /** count_processes traits specialization to increase process count by one. - */ + */ template <typename TProcess, int N> struct count_processes<TProcess, N, typename std::enable_if_t<is_process_v<TProcess> && @@ -81,5 +81,5 @@ namespace corsika { }; //! @} - + } // namespace corsika diff --git a/corsika/framework/process/BoundaryCrossingProcess.hpp b/corsika/framework/process/BoundaryCrossingProcess.hpp index 044106762..70771e68a 100644 --- a/corsika/framework/process/BoundaryCrossingProcess.hpp +++ b/corsika/framework/process/BoundaryCrossingProcess.hpp @@ -24,7 +24,7 @@ namespace corsika { Processes acting on the particles traversion from one volume into another volume. - Create a new BoundaryCrossingProcess, e.g. for XYModel, via + Create a new BoundaryCrossingProcess, e.g. for XYModel, via @code{.cpp} class XYModel : public BoundaryCrossingProcess<XYModel> {}; @endcode @@ -41,13 +41,12 @@ namespace corsika { Stack. The volume the particle is originating from is `from`, the volume where it goes to is `to`. */ - - + template <typename TDerived> class BoundaryCrossingProcess : public BaseProcess<TDerived> { public: }; //! @} - + } // namespace corsika diff --git a/corsika/framework/process/ContinuousProcess.hpp b/corsika/framework/process/ContinuousProcess.hpp index e8280f78c..2fa5cac74 100644 --- a/corsika/framework/process/ContinuousProcess.hpp +++ b/corsika/framework/process/ContinuousProcess.hpp @@ -23,7 +23,7 @@ namespace corsika { Processes with continuous effects along a particle Trajectory - Create a new ContinuousProcess, e.g. for XYModel, via + Create a new ContinuousProcess, e.g. for XYModel, via @code{.cpp} class XYModel : public ContinuousProcess<XYModel> {}; @endcode @@ -38,13 +38,14 @@ namespace corsika { allowed step length. Such step-length limitation, if it turns out to be smaller/sooner than any other limit (decay length, interaction length, other continuous processes, geometry, etc.) - will lead to a limited step length. + will lead to a limited step length. @code{.cpp} template <typename TParticle, typename TTrack> - ProcessReturn doContinuous(TParticle& p, TTrack const& t, bool const stepLimit) const; + ProcessReturn doContinuous(TParticle& p, TTrack const& t, bool const stepLimit) + const; @endcode - + which applied any continuous effects on Particle p along Trajectory t. The particle in all typical scenarios will be altered by a doContinuous. The flag stepLimit will be true if the @@ -52,7 +53,7 @@ namespace corsika { particular ContinuousProcess to be responsible for the step length limit on the current track t. This information can be expoited and avoid e.g. any uncessary calculations. - + Particle and Track are the valid classes to access particles and track (Trajectory) data on the Stack. Those two methods do not need to be templated, they could use the types @@ -62,8 +63,7 @@ namespace corsika { */ template <typename TDerived> - class ContinuousProcess : public BaseProcess<TDerived> { - }; + class ContinuousProcess : public BaseProcess<TDerived> {}; /** * ProcessTraits specialization to flag ContinuousProcess objects @@ -76,5 +76,5 @@ namespace corsika { : std::true_type {}; /** @} */ - + } // namespace corsika diff --git a/corsika/framework/process/ContinuousProcessIndex.hpp b/corsika/framework/process/ContinuousProcessIndex.hpp index e74f0844b..e36bf2812 100644 --- a/corsika/framework/process/ContinuousProcessIndex.hpp +++ b/corsika/framework/process/ContinuousProcessIndex.hpp @@ -15,7 +15,7 @@ namespace corsika { To index individual processes (continuous processes) inside a ProcessSequence. - + **/ class ContinuousProcessIndex { diff --git a/corsika/framework/process/ContinuousProcessStepLength.hpp b/corsika/framework/process/ContinuousProcessStepLength.hpp index 201e20783..575be9063 100644 --- a/corsika/framework/process/ContinuousProcessStepLength.hpp +++ b/corsika/framework/process/ContinuousProcessStepLength.hpp @@ -18,7 +18,7 @@ namespace corsika { To store step length in LengthType and unique index in ProcessSequence of shortest step ContinuousProcess. - + **/ class ContinuousProcessStepLength { diff --git a/corsika/framework/process/DecayProcess.hpp b/corsika/framework/process/DecayProcess.hpp index d2ff357dd..2c66b9c6e 100644 --- a/corsika/framework/process/DecayProcess.hpp +++ b/corsika/framework/process/DecayProcess.hpp @@ -21,25 +21,25 @@ namespace corsika { Process decribing the decay of particles - Create a new DecayProcess, e.g. for XYModel, via + Create a new DecayProcess, e.g. for XYModel, via @code class XYModel : public DecayProcess<XYModel> {}; @endcode and provide the two necessary interface methods @code - template <typename TSecondaryView> + template <typename TSecondaryView> void XYModel::doDecay(TSecondaryView&); template <typename TParticle> TimeType getLifetime(TParticle const&) @endcode - + Where, of course, SecondaryView and Particle are the valid classes to access particles on the Stack. Those two methods do not need to be templated, they could use the types e.g. corsika::setup::Stack::particle_type -- but by the cost of - loosing all flexibility otherwise provided. + loosing all flexibility otherwise provided. SecondaryView allows to retrieve the properties of the projectile particles, AND to store new particles (secondaries) which then @@ -57,14 +57,14 @@ namespace corsika { // interface checking on TProcess1 static_assert(has_method_getLifetime_v<TDerived, TimeType, TParticle const&>, - "TDerived has no method with correct signature \"GrammageType " - "getInteractionLength(TParticle const&)\" required for " - "InteractionProcess<TDerived>. "); + "TDerived has no method with correct signature \"GrammageType " + "getInteractionLength(TParticle const&)\" required for " + "InteractionProcess<TDerived>. "); return 1. / ref().getLifetime(particle); } }; /** @} */ - + } // namespace corsika diff --git a/corsika/framework/process/InteractionCounter.hpp b/corsika/framework/process/InteractionCounter.hpp index 265987382..e4e84b051 100644 --- a/corsika/framework/process/InteractionCounter.hpp +++ b/corsika/framework/process/InteractionCounter.hpp @@ -37,14 +37,14 @@ namespace corsika { InteractionHistogram const& getHistogram() const; void blob(int) {} - + private: TCountedProcess& process_; InteractionHistogram histogram_; }; //! @} - + } // namespace corsika #include <corsika/detail/framework/process/InteractionCounter.inl> diff --git a/corsika/framework/process/InteractionHistogram.hpp b/corsika/framework/process/InteractionHistogram.hpp index 2138eb154..77e402d55 100644 --- a/corsika/framework/process/InteractionHistogram.hpp +++ b/corsika/framework/process/InteractionHistogram.hpp @@ -26,7 +26,7 @@ namespace corsika { /** @ingroup Processes @{ */ - + class InteractionHistogram { static double constexpr lower_edge_cms = 1e3, upper_edge_cms = 1e17; // eV sqrt s static double constexpr lower_edge_lab = 1e3, upper_edge_lab = 1e21; // eV lab @@ -52,7 +52,7 @@ namespace corsika { }; /** @} */ - + } // namespace corsika #include <corsika/detail/framework/process/InteractionHistogram.inl> // for implementation diff --git a/corsika/framework/process/InteractionProcess.hpp b/corsika/framework/process/InteractionProcess.hpp index 614224f0b..f6df9ede7 100644 --- a/corsika/framework/process/InteractionProcess.hpp +++ b/corsika/framework/process/InteractionProcess.hpp @@ -16,30 +16,30 @@ namespace corsika { /** - @ingroup Processes + @ingroup Processes @{ Process describing the interaction of particles - Create a new InteractionProcess, e.g. for XYModel, via + Create a new InteractionProcess, e.g. for XYModel, via @code class XYModel : public InteractionProcess<XYModel> {}; @endcode and provide the two necessary interface methods @code - template <typename TSecondaryView> + template <typename TSecondaryView> void XYModel::doInteraction(TSecondaryView&); template <typename TParticle> GrammageType XYModel::getInteractionLength(TParticle const&) @endcode - + Where, of course, SecondaryView and Particle are the valid classes to access particles on the Stack. Those two methods do not need to be templated, they could use the types e.g. corsika::setup::Stack::particle_type -- but by the cost of - loosing all flexibility otherwise provided. + loosing all flexibility otherwise provided. SecondaryView allows to retrieve the properties of the projectile particles, AND to store new particles (secondaries) which then @@ -56,17 +56,18 @@ namespace corsika { template <typename TParticle> InverseGrammageType getInverseInteractionLength(TParticle const& particle) { - + // interface checking on TProcess1 - static_assert(has_method_getInteractionLength_v<TDerived, GrammageType, TParticle const&>, - "TDerived has no method with correct signature \"GrammageType " - "getInteractionLength(TParticle const&)\" required for " - "InteractionProcess<TDerived>. "); - + static_assert( + has_method_getInteractionLength_v<TDerived, GrammageType, TParticle const&>, + "TDerived has no method with correct signature \"GrammageType " + "getInteractionLength(TParticle const&)\" required for " + "InteractionProcess<TDerived>. "); + return 1. / ref().getInteractionLength(particle); } }; /** @} */ - + } // namespace corsika diff --git a/corsika/framework/process/ProcessReturn.hpp b/corsika/framework/process/ProcessReturn.hpp index a7d522195..35c4096e5 100644 --- a/corsika/framework/process/ProcessReturn.hpp +++ b/corsika/framework/process/ProcessReturn.hpp @@ -63,5 +63,5 @@ namespace corsika { } //! @} - + } // namespace corsika diff --git a/corsika/framework/process/ProcessSequence.hpp b/corsika/framework/process/ProcessSequence.hpp index 0c375beec..df6f50a56 100644 --- a/corsika/framework/process/ProcessSequence.hpp +++ b/corsika/framework/process/ProcessSequence.hpp @@ -28,10 +28,9 @@ namespace corsika { - /** - count_processes traits specialization to increase process count by getNumberOfProcesses(). - This is used to statically count processes in the sequence + count_processes traits specialization to increase process count by + getNumberOfProcesses(). This is used to statically count processes in the sequence */ template <typename TProcess, int N> struct count_processes<TProcess, N, @@ -41,108 +40,112 @@ namespace corsika { N + std::decay_t<TProcess>::getNumberOfProcesses(); }; + /** + @defgroup Processes Physics Processes and Modules -/** - @defgroup Processes Physics Processes and Modules - - Physics processes in CORSIKA 8 are clustered in ProcessSequence and SwitchProcessSequence containers. - The former is a mere (ordered) collection, while the latter has the option to switch between two - alternative ProcessSequences. - - Depending on the type of data to act on and on the allowed actions of processes there are several - interface options: - - InteractionProcess - - DecayProcess - - ContinuousProcess - - StackProcess - - SecondariesProcess - - BoundaryCrossingProcess - - And all processes (including ProcessSequence and SwitchProcessSequence) are derived from BaseProcess. - - Processes of any type (e.g. p1, p2, p3,...) can be assembled into a ProcessSequence using the `make_sequence` factory function. - - @code{.cpp} - auto sequence1 = make_sequence(p1, p2, p3); - auto sequence2 = make_sequence(p4, p5, p6, p7); - auto sequence3 = make_sequence(sequence1, sequemce2, p8, p9); - @endcode - - Note, if the order of processes - matters, the order of occurence - in the ProcessSequence determines - the executiion order. - - SecondariesProcess alyways act on - new secondaries produced (i.e. in - InteractionProcess and - DecayProcess) in the scope of - their ProcessSequence. For - example if i1 and i2 are - InteractionProcesses and s1 is a - SecondariesProcess, then - - @code{.cpp} - auto sequence = make_sequence(i1, make_sequence(i2, s1)) - @endcode - - will result in s1 acting only on - the particles produced by i2 and - not by i1. This can be very - useful, e.g. to fine tune thinning. - - A special type of ProcessSequence - is SwitchProcessSequence, which - has two branches and a functor - that can select between these two - branches. - - @code{.cpp} - auto sequence = make_switch(sequence1, sequence2, selector); - @endcode - - where the only requirement to - `selector` is that it - provides a `SwitchResult operator()(Particle const& particle) const` method. Thus, - based on the dynamic properties - of `particle` the functor - can make its decision. This is - clearly important for switching - between low-energy and - high-energy models, but not - limited to this. The selection - can even be done with a lambda - function. - - - - @ingroup Processes - @{ - - Definition of a static process list/sequence - - A compile time static list of processes. The compiler will - generate a new type based on template logic containing all the - elements provided by the user. - - TProcess1 and TProcess2 must both be derived from BaseProcess, - and are both references if possible (lvalue), otherwise (rvalue) - they are just classes. This allows us to handle both, rvalue as - well as lvalue Processes in the ProcessSequence. - - (For your potential interest, - the static version of the - ProcessSequence and all Process - types are based on the CRTP C++ - design pattern) - - Template parameters: - @tparam TProcess1 is of type BaseProcess, either a dedicatd process, or a ProcessSequence - @tparam TProcess2 is of type BaseProcess, either a dedicatd process, or a ProcessSequence - @tparam ProcessIndexOffset to count and index each ContinuousProcess in the entire process-chain - @tparam IndexOfProcess1 - @tparam IndexOfProcess2 - */ + Physics processes in CORSIKA 8 are clustered in ProcessSequence and + SwitchProcessSequence containers. The former is a mere (ordered) collection, while + the latter has the option to switch between two alternative ProcessSequences. + + Depending on the type of data to act on and on the allowed actions of processes there + are several interface options: + - InteractionProcess + - DecayProcess + - ContinuousProcess + - StackProcess + - SecondariesProcess + - BoundaryCrossingProcess + + And all processes (including ProcessSequence and SwitchProcessSequence) are derived + from BaseProcess. + + Processes of any type (e.g. p1, p2, p3,...) can be assembled into a ProcessSequence + using the `make_sequence` factory function. + + @code{.cpp} + auto sequence1 = make_sequence(p1, p2, p3); + auto sequence2 = make_sequence(p4, p5, p6, p7); + auto sequence3 = make_sequence(sequence1, sequemce2, p8, p9); + @endcode + + Note, if the order of processes + matters, the order of occurence + in the ProcessSequence determines + the executiion order. + + SecondariesProcess alyways act on + new secondaries produced (i.e. in + InteractionProcess and + DecayProcess) in the scope of + their ProcessSequence. For + example if i1 and i2 are + InteractionProcesses and s1 is a + SecondariesProcess, then + + @code{.cpp} + auto sequence = make_sequence(i1, make_sequence(i2, s1)) + @endcode + + will result in s1 acting only on + the particles produced by i2 and + not by i1. This can be very + useful, e.g. to fine tune thinning. + + A special type of ProcessSequence + is SwitchProcessSequence, which + has two branches and a functor + that can select between these two + branches. + + @code{.cpp} + auto sequence = make_switch(sequence1, sequence2, selector); + @endcode + + where the only requirement to + `selector` is that it + provides a `SwitchResult operator()(Particle const& particle) const` method. Thus, + based on the dynamic properties + of `particle` the functor + can make its decision. This is + clearly important for switching + between low-energy and + high-energy models, but not + limited to this. The selection + can even be done with a lambda + function. + + + + @ingroup Processes + @{ + + Definition of a static process list/sequence + + A compile time static list of processes. The compiler will + generate a new type based on template logic containing all the + elements provided by the user. + + TProcess1 and TProcess2 must both be derived from BaseProcess, + and are both references if possible (lvalue), otherwise (rvalue) + they are just classes. This allows us to handle both, rvalue as + well as lvalue Processes in the ProcessSequence. + + (For your potential interest, + the static version of the + ProcessSequence and all Process + types are based on the CRTP C++ + design pattern) + + Template parameters: + @tparam TProcess1 is of type BaseProcess, either a dedicatd process, or a + ProcessSequence + @tparam TProcess2 is of type BaseProcess, either a dedicatd process, or a + ProcessSequence + @tparam ProcessIndexOffset to count and index each ContinuousProcess in the entire + process-chain + @tparam IndexOfProcess1 + @tparam IndexOfProcess2 + */ template <typename TProcess1, typename TProcess2 = NullModel, int ProcessIndexOffset = 0, @@ -276,10 +279,10 @@ namespace corsika { @fn make_sequence Factory function to create a ProcessSequence - + to construct ProcessSequences in a flexible and dynamic way the `sequence` factory functions are provided - + Any objects of type - BaseProcess - ContinuousProcess and @@ -294,7 +297,7 @@ namespace corsika { The sequence function checks that all its arguments are all of types derived from BaseProcess. Also the ProcessSequence itself is derived from type BaseProcess - + @tparam TProcesses parameter pack with objects of type BaseProcess @tparam TProcess1 another BaseProcess @param vA needs to derive from BaseProcess or ProcessSequence @@ -312,11 +315,11 @@ namespace corsika { /** @fn make_sequence - + Factory function to create ProcessSequence - + specialization for two input objects (no paramter pack in vB). - + @tparam TProcess1 another BaseProcess @tparam TProcess2 another BaseProcess @param vA needs to derive from BaseProcess or ProcessSequence @@ -334,10 +337,10 @@ namespace corsika { @fn make_sequence Factory function to create ProcessSequence from a single BaseProcess - + also allow a single Process in ProcessSequence, accompany by `NullModel` - + @tparam TProcess1 another BaseProcess @param vA needs to derive from BaseProcess or ProcessSequence */ @@ -363,7 +366,7 @@ namespace corsika { }; /** @} */ - + } // namespace corsika #include <corsika/detail/framework/process/ProcessSequence.inl> diff --git a/corsika/framework/process/ProcessTraits.hpp b/corsika/framework/process/ProcessTraits.hpp index 74a301e2c..5fe3600c0 100644 --- a/corsika/framework/process/ProcessTraits.hpp +++ b/corsika/framework/process/ProcessTraits.hpp @@ -95,7 +95,6 @@ namespace corsika { // the const version template <class T> static std::true_type testSignature(TReturn (T::*)(TArgs...) const); - }; } // namespace detail diff --git a/corsika/framework/process/SecondariesProcess.hpp b/corsika/framework/process/SecondariesProcess.hpp index ed0b92662..8dd9c1541 100644 --- a/corsika/framework/process/SecondariesProcess.hpp +++ b/corsika/framework/process/SecondariesProcess.hpp @@ -19,9 +19,9 @@ namespace corsika { @ingroup Processes @{ - Processes acting on the secondaries produced by other processes. + Processes acting on the secondaries produced by other processes. - Create a new SecondariesProcess, e.g. for XYModel, via + Create a new SecondariesProcess, e.g. for XYModel, via @code{.cpp} class XYModel : public SecondariesProcess<XYModel> {}; @endcode @@ -33,16 +33,14 @@ namespace corsika { @endcode where StackView is an object that can store secondaries on a - stack and also iterate over these secondaries. + stack and also iterate over these secondaries. */ template <typename TDerived> class SecondariesProcess : public BaseProcess<TDerived> { public: - - static }; //! @} - + } // namespace corsika diff --git a/corsika/framework/process/StackProcess.hpp b/corsika/framework/process/StackProcess.hpp index 752040bf0..b8770579e 100644 --- a/corsika/framework/process/StackProcess.hpp +++ b/corsika/framework/process/StackProcess.hpp @@ -16,12 +16,12 @@ namespace corsika { /** - @ingroup Processes + @ingroup Processes @{ Process to act on the entire particle stack - Create a new StackProcess, e.g. for XYModel, via + Create a new StackProcess, e.g. for XYModel, via @code{.cpp} class XYModel : public StackProcess<XYModel> {}; @endcode @@ -36,12 +36,12 @@ namespace corsika { class to access particles on the Stack. This methods does not need to be templated, they could use the types e.g. corsika::setup::Stack directly -- but by the cost of - loosing all flexibility otherwise provided. + loosing all flexibility otherwise provided. - A StackProcess has only one constructor `StackProcess::StackProcess(unsigned int const nStep)` - where nStep is the number of steps of the cascade stepping after which the stack process should be - run. Good values are on the order of 1000, which will not compromise run time in the end, but - provide all the benefits of the StackProcess. + A StackProcess has only one constructor `StackProcess::StackProcess(unsigned int + const nStep)` where nStep is the number of steps of the cascade stepping after which + the stack process should be run. Good values are on the order of 1000, which will not + compromise run time in the end, but provide all the benefits of the StackProcess. */ template <typename TDerived> @@ -56,7 +56,8 @@ namespace corsika { //! return the current Cascade step counter int getStep() const { return iStep_; } - //! check if current step is where StackProcess should be executed, this also increases the internal step counter implicitly + //! check if current step is where StackProcess should be executed, this also + //! increases the internal step counter implicitly bool checkStep() { return !((++iStep_) % nStep_); } private: @@ -72,5 +73,5 @@ namespace corsika { }; //! @} - + } // namespace corsika diff --git a/corsika/framework/process/SwitchProcessSequence.hpp b/corsika/framework/process/SwitchProcessSequence.hpp index 585f55d4e..2a29cd710 100644 --- a/corsika/framework/process/SwitchProcessSequence.hpp +++ b/corsika/framework/process/SwitchProcessSequence.hpp @@ -39,10 +39,8 @@ namespace corsika { @var SwitchResult::First Follow first branch in SwitchProcessSequence @var SwitchResult::Second Follow second branch in SwitchProcessSequence */ - enum class SwitchResult { First, - Second - }; - + enum class SwitchResult { First, Second }; + /** @ingroup Processes @{ @@ -69,10 +67,13 @@ namespace corsika { particle stack and not on indiviidual particles. Template parameters: - @tparam TProcess1 is of type BaseProcess, either a dedicatd process, or a ProcessSequence - @tparam TProcess2 is of type BaseProcess, either a dedicatd process, or a ProcessSequence - @tparam TSelect selector functor/function - @tparam IndexFirstProcess to count and index each ContinuousProcess in the entire process-chain + @tparam TProcess1 is of type BaseProcess, either a dedicatd process, or a + ProcessSequence + @tparam TProcess2 is of type BaseProcess, either a dedicatd process, or a + ProcessSequence + @tparam TSelect selector functor/function + @tparam IndexFirstProcess to count and index each ContinuousProcess in the entire + process-chain @tparam IndexOfProcess1 index of TProcess1 (counting of ContinuousProcess) @tparam IndexOfProcess2 index of TProcess2 (counting of ContinuousProcess) @@ -215,7 +216,7 @@ namespace corsika { } //! @} - + } // namespace corsika #include <corsika/detail/framework/process/SwitchProcessSequence.inl> diff --git a/corsika/media/MediumProperties.hpp b/corsika/media/MediumProperties.hpp index ec1348c02..8d20fd248 100644 --- a/corsika/media/MediumProperties.hpp +++ b/corsika/media/MediumProperties.hpp @@ -17,12 +17,13 @@ namespace corsika { like energy losses. a particular medium (mixture of components) may have specif properties not reflected by its mixture of components. - + The data provided here is automatically parsed from the file properties8.dat from NIST. - The data of each known medium can be access via the global functions in namespace corsika, - or via a static class object with the following interface (here at the example of the class HydrogenGas): + The data of each known medium can be access via the global functions in namespace + corsika, or via a static class object with the following interface (here at the + example of the class HydrogenGas): @code{.cpp} static constexpr Medium medium() { return Medium::HydrogenGas; } @@ -53,12 +54,12 @@ namespace corsika { MediumType::Element, "H", 19.2, 9.5835, 1.8639, 3.2718, 0.14092, 5.7273, 0.0 }; @endcode - The numeric data known to CORSIKA 8 (and obtained from NIST) can be browsed below. + The numeric data known to CORSIKA 8 (and obtained from NIST) can be browsed below. @ingroup MediaProperties @{ */ - + //! General type of medium enum class MediumType { Unknown, @@ -75,10 +76,10 @@ namespace corsika { enum class State { Unknown, Solid, Liquid, Gas, DiatomicGas }; enum class Medium : int16_t; - + using MediumIntType = std::underlying_type<Medium>::type; - /** + /** * * Simple object to group together the properties of a medium. * @@ -106,27 +107,35 @@ namespace corsika { //! @name MediumDataInterface Interface methods //! Interface functions for MediumData //! @{ - std::string getName() const { return name_; } /// returns name + std::string getName() const { return name_; } /// returns name std::string getPrettyName() const { return pretty_name_; } /// returns pretty name - double getWeight() const { return weight_; } /// return weight - const int& weight_significant_figure() const { return weight_significant_figure_; } /// return significnat figures of weight - const int& weight_error_last_digit() const { return weight_error_last_digit_; } /// return error of weight + double getWeight() const { return weight_; } /// return weight + const int& weight_significant_figure() const { + return weight_significant_figure_; + } /// return significnat figures of weight + const int& weight_error_last_digit() const { + return weight_error_last_digit_; + } /// return error of weight const double& Z_over_A() const { return Z_over_A_; } /// Z_over_A_ - double getSternheimerDensity() const { return sternheimer_density_; } /// Sternheimer density - double getCorrectedDensity() const { return corrected_density_; } /// corrected density - State getState() const { return state_; } /// state - MediumType getType() const { return type_; } /// type + double getSternheimerDensity() const { + return sternheimer_density_; + } /// Sternheimer density + double getCorrectedDensity() const { + return corrected_density_; + } /// corrected density + State getState() const { return state_; } /// state + MediumType getType() const { return type_; } /// type std::string getSymbol() const { return symbol_; } /// symbol - double getIeff() const { return Ieff_; } /// Ieff - double getCbar() const { return Cbar_; } /// Cbar - double getX0() const { return x0_; } /// X0 - double getX1() const { return x1_; } /// X1 - double getAA() const { return aa_; } /// AA - double getSK() const { return sk_; } /// Sk - double getDlt0() const { return dlt0_; } /// Delta0 + double getIeff() const { return Ieff_; } /// Ieff + double getCbar() const { return Cbar_; } /// Cbar + double getX0() const { return x0_; } /// X0 + double getX1() const { return x1_; } /// X1 + double getAA() const { return aa_; } /// AA + double getSK() const { return sk_; } /// Sk + double getDlt0() const { return dlt0_; } /// Delta0 //! @} }; - + //! @} } // namespace corsika @@ -137,17 +146,17 @@ namespace corsika { /** @file MediaProperties.hpp - + @ingroup MediaProperties @{ Returns MediumData object for medium identifed by enum Medium. */ - + constexpr MediumData const& mediumData(Medium const m) { return corsika::detail::medium_data[static_cast<MediumIntType>(m)]; } //! @} - + } // namespace corsika diff --git a/corsika/modules/conex/CONEXhybrid.hpp b/corsika/modules/conex/CONEXhybrid.hpp index d5480d9db..299f85cbd 100644 --- a/corsika/modules/conex/CONEXhybrid.hpp +++ b/corsika/modules/conex/CONEXhybrid.hpp @@ -41,7 +41,7 @@ namespace corsika { HEPEnergyType getEnergyEM() const; void reset(); - + private: // data members //! CONEX e.m. particle codes diff --git a/corsika/modules/tracking/TrackingLeapFrogCurved.hpp b/corsika/modules/tracking/TrackingLeapFrogCurved.hpp index d341559e7..513ffbaf5 100644 --- a/corsika/modules/tracking/TrackingLeapFrogCurved.hpp +++ b/corsika/modules/tracking/TrackingLeapFrogCurved.hpp @@ -53,7 +53,8 @@ namespace corsika { using Intersect<Tracking>::nextIntersect; public: - Tracking() : straightTracking_{tracking_line::Tracking()} {} + Tracking() + : straightTracking_{tracking_line::Tracking()} {} template <typename TParticle> auto getTrack(TParticle const& particle); diff --git a/corsika/modules/tracking/TrackingLeapFrogStraight.hpp b/corsika/modules/tracking/TrackingLeapFrogStraight.hpp index a57c68eb5..2ea6ebd34 100644 --- a/corsika/modules/tracking/TrackingLeapFrogStraight.hpp +++ b/corsika/modules/tracking/TrackingLeapFrogStraight.hpp @@ -60,7 +60,7 @@ namespace corsika { template <typename Particle> auto getTrack(Particle& particle); - + static std::string getName() { return "LeapFrogStraight"; } static std::string getVersion() { return "1.0.0"; } diff --git a/corsika/modules/tracking/TrackingStraight.hpp b/corsika/modules/tracking/TrackingStraight.hpp index 2ca9dce6d..a5800cd7e 100644 --- a/corsika/modules/tracking/TrackingStraight.hpp +++ b/corsika/modules/tracking/TrackingStraight.hpp @@ -54,7 +54,7 @@ namespace corsika::tracking_line { static std::string getName() { return "Tracking-Straight"; } static std::string getVersion() { return "1.0.0"; } -}; + }; } // namespace corsika::tracking_line diff --git a/corsika/modules/urqmd/UrQMD.hpp b/corsika/modules/urqmd/UrQMD.hpp index 9d4a0c7d2..8f2fd8ede 100644 --- a/corsika/modules/urqmd/UrQMD.hpp +++ b/corsika/modules/urqmd/UrQMD.hpp @@ -36,7 +36,7 @@ namespace corsika::urqmd { bool canInteract(Code) const; void blob(int) {} - + private: static CrossSectionType getCrossSection(Code, Code, HEPEnergyType, int); diff --git a/corsika/setup/SetupTrajectory.hpp b/corsika/setup/SetupTrajectory.hpp index 8d8dd92bd..95a91115b 100644 --- a/corsika/setup/SetupTrajectory.hpp +++ b/corsika/setup/SetupTrajectory.hpp @@ -40,13 +40,13 @@ namespace corsika::setup { typedef corsika::tracking_leapfrog_curved::Tracking Tracking; // typedef corsika::tracking_leapfrog_straight::Tracking Tracking; - //typedef corsika::tracking_line::Tracking Tracking; + // typedef corsika::tracking_line::Tracking Tracking; /** The default trajectory. */ /// definition of Trajectory base class, to be used in tracking and cascades - //typedef StraightTrajectory Trajectory; + // typedef StraightTrajectory Trajectory; typedef corsika::LeapFrogTrajectory Trajectory; } // namespace corsika::setup diff --git a/tests/framework/testProcessSequence.cpp b/tests/framework/testProcessSequence.cpp index e2dfbdbf0..78af81d43 100644 --- a/tests/framework/testProcessSequence.cpp +++ b/tests/framework/testProcessSequence.cpp @@ -26,7 +26,6 @@ using namespace std; static int const nData = 10; - // The stack is non-existent for this example struct DummyStack {}; // our data object (particle) is a simple arrary of doubles @@ -44,8 +43,6 @@ struct DummyView { DummyData& parent() { return p_; } }; - - int globalCount = 0; // simple counter int checkDecay = 0; // use this as a bit field @@ -301,9 +298,7 @@ public: TimeType getLifetime(Particle&) const { return 2_s; } - void doDecay(DummyView&) const { - checkDecay |= 2; - } + void doDecay(DummyView&) const { checkDecay |= 2; } }; class Stack1 : public StackProcess<Stack1> { @@ -320,7 +315,6 @@ private: int count_ = 0; }; - TEST_CASE("ProcessSequence General", "ProcessSequence") { logging::set_level(logging::level::info); @@ -732,19 +726,18 @@ TEST_CASE("ProcessSequence Indexing", "ProcessSequence") { int const n0 = count_processes<Decay2>::count; int const n1 = count_processes<ContinuousProcess3>::count; int const n2 = count_processes<ContinuousProcess2, - count_processes<ContinuousProcess3>::count>::count; + count_processes<ContinuousProcess3>::count>::count; int const n1_b = count_processes<Process2, count_processes<ContinuousProcess3>::count>::count; int const n1_c = count_processes<ContinuousProcess3, count_processes<Process2>::count>::count; int const n12 = count_processes<ContinuousProcess2, - count_processes<ContinuousProcess3, 10>::count>::count; + count_processes<ContinuousProcess3, 10>::count>::count; int const n11_b = - count_processes<Process1, - count_processes<ContinuousProcess3, 10>::count>::count; - int const n11_c = count_processes<ContinuousProcess3, - count_processes<Process1, 10>::count>::count; + count_processes<Process1, count_processes<ContinuousProcess3, 10>::count>::count; + int const n11_c = + count_processes<ContinuousProcess3, count_processes<Process1, 10>::count>::count; CHECK(n0 == 1); CHECK(n1 == 1); -- GitLab