IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 7e5bc6f2 authored by Maximilian Reininghaus's avatar Maximilian Reininghaus :vulcan:
Browse files

fixed handling of SwitchProcess inside ProcessSequence

parent d83a2fd8
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment