diff --git a/Framework/ProcessSequence/ProcessSequence.h b/Framework/ProcessSequence/ProcessSequence.h index 55eb43ba795c35d04654a5256232221fa4c900b5..e4108b95fd5067ddec1d2a1d8e0c1523e22e7305 100644 --- a/Framework/ProcessSequence/ProcessSequence.h +++ b/Framework/ProcessSequence/ProcessSequence.h @@ -57,9 +57,15 @@ namespace corsika::process { class SwitchProcess; // fwd-decl. } + // to detect SwitchProcesses inside the ProcessSequence + template <typename T> + struct is_switch_process : std::false_type {}; + template <typename A, typename B> - struct is_process_sequence<switch_process::SwitchProcess<A, B>> - : std::true_type {}; + struct is_switch_process<switch_process::SwitchProcess<A, B>> : std::true_type {}; + + template <typename T> + bool constexpr is_switch_process_v = is_switch_process<T>::value; /** T1 and T2 are both references if possible (lvalue), otherwise @@ -75,6 +81,9 @@ namespace corsika::process { static bool constexpr t1ProcSeq = is_process_sequence_v<T1type>; static bool constexpr t2ProcSeq = is_process_sequence_v<T2type>; + static bool constexpr t1SwitchProc = is_switch_process_v<T1type>; + static bool constexpr t2SwitchProc = is_switch_process_v<T2type>; + public: T1 A; // this is a reference, if possible T2 B; // this is a reference, if possible @@ -185,10 +194,12 @@ namespace corsika::process { InverseGrammageType tot = 0 * meter * meter / gram; - if constexpr (std::is_base_of_v<InteractionProcess<T1type>, T1type> || t1ProcSeq) { + if constexpr (std::is_base_of_v<InteractionProcess<T1type>, T1type> || t1ProcSeq || + t1SwitchProc) { tot += A.GetInverseInteractionLength(vP); } - if constexpr (std::is_base_of_v<InteractionProcess<T2type>, T2type> || t2ProcSeq) { + if constexpr (std::is_base_of_v<InteractionProcess<T2type>, T2type> || t2ProcSeq || + t2SwitchProc) { tot += B.GetInverseInteractionLength(vP); } return tot; @@ -200,7 +211,7 @@ namespace corsika::process { [[maybe_unused]] corsika::units::si::InverseGrammageType lambda_select, corsika::units::si::InverseGrammageType& lambda_inv_count) { - if constexpr (t1ProcSeq) { + if constexpr (t1ProcSeq || t1SwitchProc) { // if A is a process sequence --> check inside const EProcessReturn ret = A.SelectInteraction(vP, vS, lambda_select, lambda_inv_count); @@ -216,7 +227,7 @@ namespace corsika::process { } } // end branch A - if constexpr (t2ProcSeq) { + if constexpr (t2ProcSeq || t2SwitchProc) { // if A is a process sequence --> check inside const EProcessReturn ret = B.SelectInteraction(vP, vS, lambda_select, lambda_inv_count); diff --git a/Processes/SwitchProcess/SwitchProcess.h b/Processes/SwitchProcess/SwitchProcess.h index 31e59599bc6dceb68edf4ad030d284eb37c69bce..fd13021d23e72f7981968e2e0f16a9f47fc039fd 100644 --- a/Processes/SwitchProcess/SwitchProcess.h +++ b/Processes/SwitchProcess/SwitchProcess.h @@ -12,8 +12,8 @@ namespace corsika::process::switch_process { * This process provides an energy-based switch between two interaction processes P1 and * P1. For energies below the threshold, P1 is invoked, otherwise P2. Both can be either * single interaction processes or multiple ones combined in a ProcessSequence. A - * SwitchProcess itself will always be regarded as a ProcessSequence rather than an - * InteractionProcess when assembled into a greater ProcessSequence. + * SwitchProcess itself will always be regarded as a distinct case when assembled into a + * (greater) ProcessSequence. */ template <class TLowEProcess, class THighEProcess>