diff --git a/corsika/detail/framework/process/BoundaryCrossingProcess.hpp b/corsika/detail/framework/process/BoundaryCrossingProcess.hpp index caf26852393b1bb01a522c4d7f7afe5ec7ded85e..929bc95f7e27999d171c2555722dfcd37a8243fc 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 c9180591417d1cd17010306c5489a32dd0aff0b5..b119e8194f1155e7f9fe8157ed6dc67f3b62d094 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 661d0aeb1132637dd3d202f8730b6f013b92dab9..e61d1c6e7494e036b562b1e77cc619768a06d341 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 f97fd4e4e9534241fe378f80814f37fd860502ad..faa6d5cc438fb00022722bd68e162b5830a49f6a 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 26990ce68a185dbb31a77f86b2f7e76843200116..c4d9bb5cc5b717cc6cc59a660aff4041d8e2ef2a 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 1eea73409e5edfbbe8b5d0c69a7fd76f7ed65571..a847d0ccd43ca4888de7060ec5e60f39558fd1cd 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 4b2b1b99093e8f28e84201f8ac9409376f765eeb..7ee12186ace6f189b2c375b8e1a04e502a3cf06f 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 51f2b4a785121b5f814c9ed6ea28766997e48d8a..d0d17d264d0dbe8e7a7338ecce743482d0e700c1 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 47f2a8eaabcd8d034b16940b279ada6627807201..56b8b38f25d5b551c57ba3580f4ab6925c7c7080 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 04410676248bae89f7b1ee995b3fec78bceec812..70771e68a9d9a010c00e9b331e607a7fcf11c503 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 e8280f78c48419ceb0dd4faac5eb10d90f2cc4f8..2fa5cac743bd82e1fff850bb3e86f6c759c7c6ea 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 e74f0844b369a9003f46167a937165f5a5c4a231..e36bf2812a33c6f03e4058033585f846a871b897 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 201e20783d8551c0fe2de42b487eeaa242ec2488..575be9063d49a32b5853320dc9d25bac40a7b9d8 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 d2ff357dde90d1c1adb5b3171a168d12fc480ff5..2c66b9c6e24f27f18593624b80cc4cbd98aa20b4 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 2659873824bbb22e4cd096a615b1fafac293daf1..e4e84b051c8ae57519ca9baa32a490a4976f17d1 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 2138eb1541c03a482a4a5b48be49466cf6ff0614..77e402d55f6777e2955d066e1060e2540a35a67d 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 614224f0b08f8003d485fb0619d6543f77059f1a..f6df9ede713c041d78506d544d5d0b8167ea4f71 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 a7d522195d84ffa5a41dbd0637327cdf2345f3e9..35c4096e53bdb8caba3727ff96c58bb159a361db 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 0c375beecb583da4cdce7bb61c728bc0a1e3d620..df6f50a56a6cdb5d20240d770dccebbabe7d54ed 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 74a301e2c451023626faafa4d398157d063cf812..5fe3600c09aa4a0865a480e868d5b47f74e74e2c 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 ed0b92662b2b35b7b2883dc959450a5e303acb0e..8dd9c154168c678d9653d4a762c7ba5ac6fba8b5 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 752040bf0639c912ed059e5ea6974c2607f41681..b8770579e958b3d7c4a6b351c17f05804da38ef2 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 585f55d4eeeefda031e5e10cb334e610b96475e2..2a29cd710b61fca0cba81073ba2e5579f5415148 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 ec1348c023666997978e8e5312ff7002178c39c2..8d20fd248bf1b2c1703410124abb3b3a91ad4dbe 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 d5480d9db0ca6ec97e0be7965565172078053c7f..299f85cbda7ae0298002ae8213ae5c8065950735 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 d341559e7368a0fd940c30ad18bbe5a43e152662..513ffbaf509d2c05a7020f038d0ab320592c4712 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 a57c68eb580656284556b0d11b7a4d6089e43234..2ea6ebd34ee3d9b0eaa48563cae7c8a41aed1df9 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 2ca9dce6dd5605fcc827be83584db96602e5391f..a5800cd7ed64fa4fee8afe89a32fe927366ad1de 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 9d4a0c7d2251372cd5b084d9972d5a8bf3b079b3..8f2fd8edeed26f84be2b6049fb760c26b4729ac4 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 8d8dd92bdb92a9c4ba4a5975eb74d36ff7cae8ba..95a91115b0aa422c860448fa8057d70c35f95456 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 e2dfbdbf07ec92427dc1c78f1be2e1320226b15d..78af81d435252b27480fb2bee9206af9bdbbe230 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);