IAP GITLAB

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • AirShowerPhysics/corsika
  • rulrich/corsika
  • AAAlvesJr/corsika
  • Andre/corsika
  • arrabito/corsika
  • Nikos/corsika
  • olheiser73/corsika
  • AirShowerPhysics/papers/corsika
  • pranav/corsika
9 results
Show changes
Showing
with 778 additions and 317 deletions
/*
* (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
#pragma once
......@@ -14,10 +13,10 @@
namespace corsika {
/**
traits test for InteractionProcess::doInteraction method
*/
* traits test for InteractionProcess::doInteraction method.
*/
template <class TProcess, typename TReturn, typename... TArgs>
template <class TProcess, typename TReturn, typename TTemplate, typename... TArgs>
struct has_method_doInteract : public detail::has_method_signature<TReturn, TArgs...> {
///! method signature
......@@ -29,7 +28,7 @@ namespace corsika {
//! signature of templated method
template <class T>
static decltype(testSignature(&T::template doInteraction<TArgs...>)) test(
static decltype(testSignature(&T::template doInteraction<TTemplate>)) test(
std::nullptr_t);
//! signature of non-templated method
......@@ -38,26 +37,25 @@ namespace corsika {
public:
/**
@name traits results
@{
*/
* @name traits results
* @{
*/
using type = decltype(test<std::decay_t<TProcess>>(nullptr));
static const bool value = type::value;
//! @}
};
//! @file InteractionProcess.hpp
//! value traits type
template <class TProcess, typename TReturn, typename... TArgs>
template <class TProcess, typename TReturn, typename TTemplate, typename... TArgs>
bool constexpr has_method_doInteract_v =
has_method_doInteract<TProcess, TReturn, TArgs...>::value;
has_method_doInteract<TProcess, TReturn, TTemplate, TArgs...>::value;
/**
traits test for InteractionProcess::getInteractionLength method
*/
* traits test for TEMPLATED InteractionProcess::getCrossSection method (PROPOSAL).
*/
template <class TProcess, typename TReturn, typename... TArgs>
struct has_method_getInteractionLength
template <class TProcess, typename TReturn, typename TTemplate, typename... TArgs>
struct has_method_getCrossSectionTemplate
: public detail::has_method_signature<TReturn, TArgs...> {
///! method signature
......@@ -69,28 +67,65 @@ namespace corsika {
//! templated parameter option
template <class T>
static decltype(testSignature(&T::template getInteractionLength<TArgs...>)) test(
static decltype(testSignature(&T::template getCrossSection<TTemplate>)) test(
std::nullptr_t);
//! non templated parameter option
template <class T>
static decltype(testSignature(&T::getInteractionLength)) test(std::nullptr_t);
static decltype(testSignature(&T::getCrossSection)) test(std::nullptr_t);
public:
/**
@name traits results
@{
*/
* @name traits results
* @{
*/
using type = decltype(test<std::decay_t<TProcess>>(nullptr));
static const bool value = type::value;
//! @}
};
//! @file InteractionProcess.hpp
//! value traits type
//! value traits type shortcut
template <class TProcess, typename TReturn, typename TTemplate, typename... TArgs>
bool constexpr has_method_getCrossSectionTemplate_v =
has_method_getCrossSectionTemplate<TProcess, TReturn, TTemplate, TArgs...>::value;
/**
* traits test for InteractionProcess::getCrossSection method.
*/
template <class TProcess, typename TReturn, typename... TArgs>
struct has_method_getCrossSection
: public detail::has_method_signature<TReturn, TArgs...> {
///! method signature
using detail::has_method_signature<TReturn, TArgs...>::testSignature;
//! the default value
template <class T>
static std::false_type test(...);
//! templated parameter option
template <class T>
static decltype(testSignature(&T::template getCrossSection<TArgs...>)) test(
std::nullptr_t);
//! non templated parameter option
template <class T>
static decltype(testSignature(&T::getCrossSection)) test(std::nullptr_t);
public:
/**
* @name traits results
* @{
*/
using type = decltype(test<std::decay_t<TProcess>>(nullptr));
static const bool value = type::value;
//! @}
};
//! value traits type shortcut
template <class TProcess, typename TReturn, typename... TArgs>
bool constexpr has_method_getInteractionLength_v =
has_method_getInteractionLength<TProcess, TReturn, TArgs...>::value;
bool constexpr has_method_getCrossSection_v =
has_method_getCrossSection<TProcess, TReturn, TArgs...>::value;
} // namespace corsika
/*
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
#pragma once
#include <corsika/framework/core/PhysicalUnits.hpp>
#include <corsika/framework/process/BaseProcess.hpp>
#include <corsika/framework/process/BoundaryCrossingProcess.hpp>
#include <corsika/framework/process/ContinuousProcess.hpp>
......@@ -19,6 +19,8 @@
#include <corsika/framework/process/ProcessReturn.hpp>
#include <corsika/framework/process/SecondariesProcess.hpp>
#include <corsika/framework/process/StackProcess.hpp>
#include <corsika/framework/process/CascadeEquationsProcess.hpp>
#include <corsika/framework/core/Step.hpp>
#include <cmath>
#include <limits>
......@@ -93,10 +95,10 @@ namespace corsika {
template <typename TProcess1, typename TProcess2, int IndexStart, int IndexProcess1,
int IndexProcess2>
template <typename TParticle, typename TTrack>
template <typename TParticle>
inline ProcessReturn
ProcessSequence<TProcess1, TProcess2, IndexStart, IndexProcess1, IndexProcess2>::
doContinuous(TParticle& particle, TTrack& vT,
doContinuous(Step<TParticle>& step,
[[maybe_unused]] ContinuousProcessIndex const limitId) {
ProcessReturn ret = ProcessReturn::Ok;
......@@ -104,44 +106,46 @@ namespace corsika {
// errors if process1_type is invalid
if constexpr (process1_type::is_process_sequence) {
ret |= A_.doContinuous(particle, vT, limitId);
ret |= A_.doContinuous(step, limitId);
} else if constexpr (is_continuous_process_v<process1_type>) {
// interface checking on TProcess1
static_assert(
has_method_doContinuous_v<TProcess1, ProcessReturn, TParticle&, TTrack&> ||
has_method_doContinuous_v<TProcess1, ProcessReturn, TParticle&,
TTrack const&> ||
has_method_doContinuous_v<TProcess1, ProcessReturn, TParticle const&,
TTrack const&>,
"TDerived has no method with correct signature \"ProcessReturn "
"doContinuous(TParticle [const]&,TTrack [const]&,bool)\" required for "
"ContinuousProcess<TDerived>. ");
ret |= A_.doContinuous(particle, vT,
limitId == ContinuousProcessIndex(IndexProcess1));
//~ static_assert(
//~ has_method_doContinuous_v<TProcess1, ProcessReturn, TParticle&, TTrack&> ||
//~ has_method_doContinuous_v<TProcess1, ProcessReturn, TParticle&,
//~ TTrack const&> ||
//~ has_method_doContinuous_v<TProcess1, ProcessReturn, TParticle const&,
//~ TTrack const&>,
//~ "TDerived has no method with correct signature \"ProcessReturn "
//~ "doContinuous(TParticle [const]&,TTrack [const]&,bool)\" required for "
//~ "ContinuousProcess<TDerived>. ");
ret |= A_.doContinuous(
step, limitId == ContinuousProcessIndex(
static_cast<void const*>(std::addressof(A_))));
}
}
if constexpr (is_process_v<process2_type>) { // to protect from further compiler
// errors if process2_type is invalid
if constexpr (process2_type::is_process_sequence) {
ret |= B_.doContinuous(particle, vT, limitId);
ret |= B_.doContinuous(step, limitId);
} else if constexpr (is_continuous_process_v<process2_type>) {
// interface checking on TProcess2
static_assert(
has_method_doContinuous_v<TProcess2, ProcessReturn, TParticle&, TTrack&> ||
has_method_doContinuous_v<TProcess2, ProcessReturn, TParticle&,
TTrack const&> ||
has_method_doContinuous_v<TProcess2, ProcessReturn, TParticle const&,
TTrack const&>,
"TDerived has no method with correct signature \"ProcessReturn "
"doContinuous(TParticle [const]&,TTrack [const]&,bool)\" required for "
"ContinuousProcess<TDerived>. ");
ret |= B_.doContinuous(particle, vT,
limitId == ContinuousProcessIndex(IndexProcess2));
//~ static_assert(
//~ has_method_doContinuous_v<TProcess2, ProcessReturn, TParticle&, TTrack&> ||
//~ has_method_doContinuous_v<TProcess2, ProcessReturn, TParticle&,
//~ TTrack const&> ||
//~ has_method_doContinuous_v<TProcess2, ProcessReturn, TParticle const&,
//~ TTrack const&>,
//~ "TDerived has no method with correct signature \"ProcessReturn "
//~ "doContinuous(TParticle [const]&,TTrack [const]&,bool)\" required for "
//~ "ContinuousProcess<TDerived>. ");
ret |= B_.doContinuous(
step, limitId == ContinuousProcessIndex(
static_cast<void const*>(std::addressof(B_))));
}
}
......@@ -258,7 +262,8 @@ namespace corsika {
template <typename TParticle, typename TTrack>
inline ContinuousProcessStepLength
ProcessSequence<TProcess1, TProcess2, IndexStart, IndexProcess1,
IndexProcess2>::getMaxStepLength(TParticle& particle, TTrack& vTrack) {
IndexProcess2>::getMaxStepLength(TParticle&& particle,
TTrack&& vTrack) {
// if no other process in the sequence implements it
ContinuousProcessStepLength max_length(std::numeric_limits<double>::infinity() *
meter);
......@@ -277,8 +282,9 @@ namespace corsika {
"getMaxStepLength(TParticle const&, TTrack const&)\" required for "
"ContinuousProcess<TDerived>. ");
ContinuousProcessStepLength const step(A_.getMaxStepLength(particle, vTrack),
ContinuousProcessIndex(IndexProcess1));
ContinuousProcessStepLength const step(
A_.getMaxStepLength(particle, vTrack),
ContinuousProcessIndex(static_cast<void const*>(std::addressof(A_))));
max_length = std::min(max_length, step);
}
}
......@@ -297,8 +303,9 @@ namespace corsika {
"getMaxStepLength(TParticle const&, TTrack const&)\" required for "
"ContinuousProcess<TDerived>. ");
ContinuousProcessStepLength const step(B_.getMaxStepLength(particle, vTrack),
ContinuousProcessIndex(IndexProcess2));
ContinuousProcessStepLength const step(
B_.getMaxStepLength(particle, vTrack),
ContinuousProcessIndex(static_cast<void const*>(std::addressof(B_))));
max_length = std::min(max_length, step);
}
}
......@@ -308,24 +315,58 @@ namespace corsika {
template <typename TProcess1, typename TProcess2, int IndexStart, int IndexProcess1,
int IndexProcess2>
template <typename TParticle>
inline InverseGrammageType
ProcessSequence<TProcess1, TProcess2, IndexStart, IndexProcess1,
IndexProcess2>::getInverseInteractionLength(TParticle&& particle) {
inline CrossSectionType
ProcessSequence<TProcess1, TProcess2, IndexStart, IndexProcess1, IndexProcess2>::
getCrossSection([[maybe_unused]] TParticle const& projectile,
[[maybe_unused]] Code const targetId,
[[maybe_unused]] FourMomentum const& targetP4) const {
InverseGrammageType tot = 0 * meter * meter / gram; // default value
CrossSectionType tot = CrossSectionType::zero();
if constexpr (is_process_v<process1_type>) { // to protect from further compiler
// errors if process1_type is invalid
if constexpr (is_interaction_process_v<process1_type> ||
process1_type::is_process_sequence) {
tot += A_.getInverseInteractionLength(particle);
if constexpr (is_interaction_process_v<process1_type>) {
bool constexpr has_signature_cx1 =
has_method_getCrossSection_v<TProcess1, // process object
CrossSectionType, // return type
Code, Code, // parameters
FourMomentum const&, FourMomentum const&>;
if constexpr (has_signature_cx1) {
tot += A_.getCrossSection(projectile.getPID(), targetId,
{projectile.getEnergy(), projectile.getMomentum()},
targetP4);
} else { // for PROPOSAL
tot += A_.getCrossSection(projectile, projectile.getPID(),
{projectile.getEnergy(), projectile.getMomentum()});
}
} else if constexpr (process1_type::is_process_sequence) {
tot += A_.getCrossSection(projectile, targetId, targetP4);
}
}
if constexpr (is_process_v<process2_type>) { // to protect from further compiler
// errors if process2_type is invalid
if constexpr (is_interaction_process_v<process2_type> ||
process2_type::is_process_sequence) {
tot += B_.getInverseInteractionLength(particle);
if constexpr (is_interaction_process_v<process2_type>) {
bool constexpr has_signature_cx1 =
has_method_getCrossSection_v<TProcess2, // process object
CrossSectionType, // return type
Code, Code, // parameters
FourMomentum const&, FourMomentum const&>;
if constexpr (has_signature_cx1) {
tot += B_.getCrossSection(projectile.getPID(), targetId,
{projectile.getEnergy(), projectile.getMomentum()},
targetP4);
} else { // for PROPOSAL
tot += B_.getCrossSection(projectile, projectile.getPID(),
{projectile.getEnergy(), projectile.getMomentum()});
}
} else if constexpr (process2_type::is_process_sequence) {
tot += B_.getCrossSection(projectile, targetId, targetP4);
}
}
return tot;
......@@ -333,65 +374,263 @@ namespace corsika {
template <typename TProcess1, typename TProcess2, int IndexStart, int IndexProcess1,
int IndexProcess2>
template <typename TSecondaryView>
template <typename TStack>
void ProcessSequence<TProcess1, TProcess2, IndexStart, IndexProcess1,
IndexProcess2>::doCascadeEquations(TStack& stack) {
if constexpr (is_process_v<process1_type>) { // to protect from further compiler
// errors if process1_type is invalid
if constexpr (process1_type::is_process_sequence &&
!process1_type::is_switch_process_sequence) {
A_.doCascadeEquations(stack);
} else if constexpr (is_cascade_equations_process_v<process1_type>) {
// interface checking on TProcess1
static_assert(has_method_doCascadeEquations_v<TProcess1,
void, // return type
TStack&>, // parameter
"TDerived has no method with correct signature \"void "
"doCascadeEquations(TStack&)\" required for "
"CascadeEquationsProcess<TDerived>. ");
A_.doCascadeEquations(stack);
}
}
if constexpr (is_process_v<process2_type>) { // to protect from further compiler
// errors if process2_type is invalid
if constexpr (process2_type::is_process_sequence &&
!process2_type::is_switch_process_sequence) {
B_.doCascadeEquations(stack);
} else if constexpr (is_cascade_equations_process_v<process2_type>) {
// interface checking on TProcess2
static_assert(has_method_doCascadeEquations_v<TProcess2,
void, // return type
TStack&>, // parameter
"TDerived has no method with correct signature \"void "
"doCascadeEquations(TStack&)\" required for "
"CascadeEquationsProcess<TDerived>. ");
B_.doCascadeEquations(stack);
}
}
}
template <typename TProcess1, typename TProcess2, int IndexStart, int IndexProcess1,
int IndexProcess2>
void ProcessSequence<TProcess1, TProcess2, IndexStart, IndexProcess1,
IndexProcess2>::initCascadeEquations() {
if constexpr (is_process_v<process1_type>) { // to protect from further compiler
// errors if process1_type is invalid
if constexpr ((process1_type::is_process_sequence &&
!process1_type::is_switch_process_sequence) ||
is_cascade_equations_process_v<process1_type>) {
A_.initCascadeEquations();
}
}
if constexpr (is_process_v<process2_type>) { // to protect from further compiler
// errors if process2_type is invalid
if constexpr ((process2_type::is_process_sequence &&
!process2_type::is_switch_process_sequence) ||
is_cascade_equations_process_v<process2_type>) {
B_.initCascadeEquations();
}
}
} // namespace corsika
template <typename TProcess1, typename TProcess2, int IndexStart, int IndexProcess1,
int IndexProcess2>
template <typename TSecondaryView, typename TRNG>
inline ProcessReturn
ProcessSequence<TProcess1, TProcess2, IndexStart, IndexProcess1, IndexProcess2>::
selectInteraction(TSecondaryView& view,
[[maybe_unused]] InverseGrammageType lambda_inv_select,
[[maybe_unused]] InverseGrammageType lambda_inv_sum) {
selectInteraction(TSecondaryView&& view, FourMomentum const& projectileP4,
[[maybe_unused]] NuclearComposition const& composition,
[[maybe_unused]] TRNG&& rng,
[[maybe_unused]] CrossSectionType const cx_select,
[[maybe_unused]] CrossSectionType cx_sum) {
// TODO: add check for lambda_inv_select > lambda_inv_tot
// TODO: add check for cx_select > cx_tot
if constexpr (is_process_v<process1_type>) { // to protect from further compiler
// errors if process1_type is invalid
if constexpr (process1_type::is_process_sequence) {
// if A is a process sequence --> check inside
ProcessReturn const ret =
A_.selectInteraction(view, lambda_inv_select, lambda_inv_sum);
A_.selectInteraction(view, projectileP4, composition, rng, cx_select, cx_sum);
// if A_ did succeed, stop routine. Not checking other static branch B_.
if (ret != ProcessReturn::Ok) { return ret; }
} else if constexpr (is_interaction_process_v<process1_type>) {
// if this is not a ContinuousProcess --> evaluate probability
lambda_inv_sum += A_.getInverseInteractionLength(view.parent());
// check if we should execute THIS process and then EXIT
if (lambda_inv_select <= lambda_inv_sum) {
// interface checking on TProcess1
static_assert(has_method_doInteract_v<TProcess1, void, TSecondaryView&>,
"TDerived has no method with correct signature \"void "
"doInteraction(TSecondaryView&)\" required for "
"InteractionProcess<TDerived>. ");
auto const& projectile = view.parent();
Code const projectileId = projectile.getPID();
// get cross section vector for all material components
// for selected process A
bool constexpr has_signature_cx1 =
has_method_getCrossSection_v<TProcess1, // process object
CrossSectionType, // return type
Code, Code, // parameters
FourMomentum const&, FourMomentum const&>;
bool constexpr has_signature_cx2 = // needed for PROPOSAL interface
has_method_getCrossSectionTemplate_v<
TProcess1, // process object
CrossSectionType, // return type
decltype(projectile) const&, // template argument
decltype(projectile) const&, // parameters
Code, FourMomentum const&>;
static_assert((has_signature_cx1 || has_signature_cx2),
"TProcess1 has no method with correct signature \"CrossSectionType "
"getCrossSection(Code, Code, FourMomentum const&, FourMomentum "
"const&)\" required by "
"InteractionProcess<TProcess1>. ");
std::vector<CrossSectionType> weightedCrossSections;
if constexpr (has_signature_cx1) {
/*std::vector<CrossSectionType> const*/ weightedCrossSections =
composition.getWeighted([=](Code const targetId) -> CrossSectionType {
FourMomentum const targetP4(
get_mass(targetId),
MomentumVector(projectile.getMomentum().getCoordinateSystem(),
{0_GeV, 0_GeV, 0_GeV}));
return A_.getCrossSection(projectileId, targetId, projectileP4, targetP4);
});
cx_sum +=
std::accumulate(weightedCrossSections.cbegin(),
weightedCrossSections.cend(), CrossSectionType::zero());
} else { // this is for PROPOSAL
cx_sum += A_.template getCrossSection(projectile, projectileId, projectileP4);
}
// check if we should execute THIS process and then EXIT
if (cx_select < cx_sum) {
if constexpr (has_signature_cx1) {
// now also sample targetId from weighted cross sections
Code const targetId = composition.sampleTarget(weightedCrossSections, rng);
FourMomentum const targetP4(
get_mass(targetId),
MomentumVector(projectile.getMomentum().getCoordinateSystem(),
{0_GeV, 0_GeV, 0_GeV}));
// interface checking on TProcess1
static_assert(
has_method_doInteract_v<TProcess1, // process object
void, // return type
TSecondaryView, // template argument
TSecondaryView&, // method parameters
Code, Code, FourMomentum const&,
FourMomentum const&>,
"TProcess1 has no method with correct signature \"void "
"doInteraction<TSecondaryView>(TSecondaryView&, "
"Code, Code, FourMomentum const&, FourMomentum const&)\" required for "
"InteractionProcess<TProcess1>. ");
A_.template doInteraction(view, projectileId, targetId, projectileP4,
targetP4);
} else { // this is for PROPOSAL
A_.template doInteraction(view, projectileId, projectileP4);
}
A_.template doInteraction(view);
return ProcessReturn::Interacted;
}
} // end branch A
}
}
} // end branch A
if constexpr (is_process_v<process2_type>) { // to protect from further compiler
// errors if process2_type is invalid
if constexpr (process2_type::is_process_sequence) {
// if B_ is a process sequence --> check inside
return B_.selectInteraction(view, lambda_inv_select, lambda_inv_sum);
return B_.selectInteraction(view, projectileP4, composition, rng, cx_select,
cx_sum);
} else if constexpr (is_interaction_process_v<process2_type>) {
// if this is not a ContinuousProcess --> evaluate probability
lambda_inv_sum += B_.getInverseInteractionLength(view.parent());
// soon as SecondaryView::parent() is migrated!
// check if we should execute THIS process and then EXIT
if (lambda_inv_select <= lambda_inv_sum) {
// interface checking on TProcess1
static_assert(has_method_doInteract_v<TProcess2, void, TSecondaryView&>,
"TDerived has no method with correct signature \"void "
"doInteraction(TSecondaryView&)\" required for "
"InteractionProcess<TDerived>. ");
auto const& projectile = view.parent();
Code const projectileId = projectile.getPID();
// get cross section vector for all material components, for selected process B
bool constexpr has_signature_cx1 =
has_method_getCrossSection_v<TProcess2, // process object
CrossSectionType, // return type
Code, Code, // parameters
FourMomentum const&, FourMomentum const&>;
bool constexpr has_signature_cx2 = // needed for PROPOSAL interface
has_method_getCrossSectionTemplate_v<
TProcess2, // process object
CrossSectionType, // return type
decltype(*projectile) const&, // template argument
decltype(*projectile) const&, // parameters
Code, // parameters
FourMomentum const&>;
static_assert((has_signature_cx1 || has_signature_cx2),
"TProcess2 has no method with correct signature \"CrossSectionType "
"getCrossSection(Code, Code, FourMomentum const&, FourMomentum "
"const&)\" required by "
"InteractionProcess<TProcess1>. ");
std::vector<CrossSectionType> weightedCrossSections;
if constexpr (has_signature_cx1) {
/* std::vector<CrossSectionType> const*/ weightedCrossSections =
composition.getWeighted([=](Code const targetId) -> CrossSectionType {
FourMomentum const targetP4(
get_mass(targetId),
MomentumVector(projectile.getMomentum().getCoordinateSystem(),
{0_GeV, 0_GeV, 0_GeV}));
return B_.getCrossSection(projectileId, targetId, projectileP4, targetP4);
});
cx_sum +=
std::accumulate(weightedCrossSections.begin(), weightedCrossSections.end(),
CrossSectionType::zero());
} else { // this is for PROPOSAL
cx_sum += B_.template getCrossSection(projectile, projectileId, projectileP4);
}
B_.doInteraction(view);
// check if we should execute THIS process and then EXIT
if (cx_select < cx_sum) {
if constexpr (has_signature_cx1) {
// now also sample targetId from weighted cross sections
Code const targetId = composition.sampleTarget(weightedCrossSections, rng);
FourMomentum const targetP4(
get_mass(targetId),
MomentumVector(projectile.getMomentum().getCoordinateSystem(),
{0_GeV, 0_GeV, 0_GeV}));
// interface checking on TProcess2
static_assert(
has_method_doInteract_v<TProcess2, // process object
void, // return type
TSecondaryView, // template argument
TSecondaryView&, // method parameters
Code, Code, FourMomentum const&,
FourMomentum const&>,
"TProcess1 has no method with correct signature \"void "
"doInteraction<TSecondaryView>(TSecondaryView&, "
"Code, Code, FourMomentum const&, FourMomentum const&)\" required for "
"InteractionProcess<TProcess2>. ");
B_.doInteraction(view, projectileId, targetId, projectileP4, targetP4);
} else { // this is for PROPOSAL
B_.doInteraction(view, projectileId, projectileP4);
}
return ProcessReturn::Interacted;
}
} // end branch B_
}
}
} // end branch B_
return ProcessReturn::Ok;
}
......@@ -427,7 +666,7 @@ namespace corsika {
template <typename TSecondaryView>
inline ProcessReturn ProcessSequence<
TProcess1, TProcess2, IndexStart, IndexProcess1,
IndexProcess2>::selectDecay(TSecondaryView& view,
IndexProcess2>::selectDecay(TSecondaryView&& view,
[[maybe_unused]] InverseTimeType decay_inv_select,
[[maybe_unused]] InverseTimeType decay_inv_sum) {
......@@ -444,8 +683,8 @@ namespace corsika {
// if this is not a ContinuousProcess --> evaluate probability
decay_inv_sum += A_.getInverseLifetime(view.parent());
// check if we should execute THIS process and then EXIT
if (decay_inv_select <= decay_inv_sum) { // more pedagogical: rndm_select <
// decay_inv_sum / decay_inv_tot
if (decay_inv_select < decay_inv_sum) { // more pedagogical: rndm_select <
// decay_inv_sum / decay_inv_tot
// interface checking on TProcess1
static_assert(has_method_doDecay_v<TProcess1, void, TSecondaryView&>,
"TDerived has no method with correct signature \"void "
......@@ -467,7 +706,7 @@ namespace corsika {
// if this is not a ContinuousProcess --> evaluate probability
decay_inv_sum += B_.getInverseLifetime(view.parent());
// check if we should execute THIS process and then EXIT
if (decay_inv_select <= decay_inv_sum) {
if (decay_inv_select < decay_inv_sum) {
// interface checking on TProcess1
static_assert(has_method_doDecay_v<TProcess2, void, TSecondaryView&>,
......@@ -485,8 +724,8 @@ namespace corsika {
}
/**
* traits marker to identify objects containing any StackProcesses
**/
* traits marker to identify objects containing any StackProcesses.
*/
namespace detail {
// need helper alias to achieve this:
template <
......
/*
* (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
#pragma once
......@@ -14,8 +13,8 @@
namespace corsika {
/**
traits test for SecondariesProcess::doSecondaries method
*/
* traits test for SecondariesProcess::doSecondaries method.
*/
template <class TProcess, typename TReturn, typename... TArg>
struct has_method_doSecondaries
: public detail::has_method_signature<TReturn, TArg...> {
......@@ -38,16 +37,19 @@ namespace corsika {
public:
/**
@name traits results
@{
*/
* @name traits results
* @{
*/
using type = decltype(test<std::decay_t<TProcess>>(nullptr));
static const bool value = type::value;
//! @}
};
//! @file DecayProcess.hpp
//! value traits type
/**
* @file SecondariesProcess.hpp
*
* @brief value traits type.
*/
template <class TProcess, typename TReturn, typename... TArg>
bool constexpr has_method_doSecondaries_v =
has_method_doSecondaries<TProcess, TReturn, TArg...>::value;
......
/*
* (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
#pragma once
......
/*
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
#pragma once
......@@ -76,49 +75,55 @@ namespace corsika {
template <typename TCondition, typename TSequence, typename USequence, int IndexStart,
int IndexProcess1, int IndexProcess2>
template <typename TParticle, typename TTrack>
inline ProcessReturn SwitchProcessSequence<
TCondition, TSequence, USequence, IndexStart, IndexProcess1,
IndexProcess2>::doContinuous(TParticle& particle, TTrack& vT,
ContinuousProcessIndex const idLimit) {
if (select_(particle)) {
template <typename TParticle>
inline ProcessReturn SwitchProcessSequence<TCondition, TSequence, USequence, IndexStart,
IndexProcess1, IndexProcess2>::
doContinuous(Step<TParticle>& step,
[[maybe_unused]] ContinuousProcessIndex const idLimit) {
if (select_(step.getParticlePre())) {
if constexpr (process1_type::is_process_sequence) {
return A_.doContinuous(particle, vT, idLimit);
return A_.doContinuous(step, idLimit);
}
if constexpr (is_continuous_process_v<process1_type>) {
static_assert(
has_method_doContinuous_v<TSequence, ProcessReturn, TParticle&, TTrack&> ||
has_method_doContinuous_v<TSequence, ProcessReturn, TParticle&,
TTrack const&> ||
has_method_doContinuous_v<TSequence, ProcessReturn, TParticle const&,
TTrack const&>,
"TDerived has no method with correct signature \"ProcessReturn "
"doContinuous(TParticle[const]&,TTrack[const]&,bool)\" required for "
"ContinuousProcess<TDerived>. ");
return A_.doContinuous(particle, vT,
idLimit == ContinuousProcessIndex(IndexProcess1));
// static_assert(
// has_method_doContinuous_v<TSequence, ProcessReturn, TParticle&,
// TTrack&> ||
// has_method_doContinuous_v<TSequence, ProcessReturn, TParticle&,
// TTrack const&> ||
// has_method_doContinuous_v<TSequence, ProcessReturn, TParticle
// const&,
// TTrack const&>,
// "TDerived has no method with correct signature \"ProcessReturn "
// "doContinuous(TParticle[const]&,TTrack[const]&,bool)\" required for
// " "ContinuousProcess<TDerived>. ");
return A_.doContinuous(
step, idLimit == ContinuousProcessIndex(
static_cast<void const*>(std::addressof(A_))));
}
} else {
if constexpr (process2_type::is_process_sequence) {
return B_.doContinuous(particle, vT, idLimit);
return B_.doContinuous(step, idLimit);
}
if constexpr (is_continuous_process_v<process2_type>) {
// interface checking on USequence
static_assert(
has_method_doContinuous_v<USequence, ProcessReturn, TParticle&, TTrack&> ||
has_method_doContinuous_v<USequence, ProcessReturn, TParticle&,
TTrack const&> ||
has_method_doContinuous_v<USequence, ProcessReturn, TParticle const&,
TTrack const&>,
"TDerived has no method with correct signature \"ProcessReturn "
"doContinuous(TParticle [const]&,TTrack[const]&,bool)\" required for "
"ContinuousProcess<TDerived>. ");
return B_.doContinuous(particle, vT,
idLimit == ContinuousProcessIndex(IndexProcess2));
// static_assert(
// has_method_doContinuous_v<USequence, ProcessReturn, TParticle&,
// TTrack&> ||
// has_method_doContinuous_v<USequence, ProcessReturn, TParticle&,
// TTrack const&> ||
// has_method_doContinuous_v<USequence, ProcessReturn, TParticle
// const&,
// TTrack const&>,
// "TDerived has no method with correct signature \"ProcessReturn "
// "doContinuous(TParticle [const]&,TTrack[const]&,bool)\" required for
// " "ContinuousProcess<TDerived>. ");
return B_.doContinuous(
step, idLimit == ContinuousProcessIndex(
static_cast<void const*>(std::addressof(B_))));
}
}
return ProcessReturn::Ok;
......@@ -182,8 +187,9 @@ namespace corsika {
"getMaxStepLength(TParticle const&, TTrack const&)\" required for "
"ContinuousProcess<TDerived>. ");
return ContinuousProcessStepLength(A_.getMaxStepLength(particle, vTrack),
ContinuousProcessIndex(IndexProcess1));
return ContinuousProcessStepLength(
A_.getMaxStepLength(particle, vTrack),
ContinuousProcessIndex(static_cast<void const*>(std::addressof(A_))));
}
} else {
if constexpr (process2_type::is_process_sequence) {
......@@ -198,8 +204,9 @@ namespace corsika {
"getMaxStepLength(TParticle const&, TTrack const&)\" required for "
"ContinuousProcess<TDerived>. ");
return ContinuousProcessStepLength(B_.getMaxStepLength(particle, vTrack),
ContinuousProcessIndex(IndexProcess2));
return ContinuousProcessStepLength(
B_.getMaxStepLength(particle, vTrack),
ContinuousProcessIndex(static_cast<void const*>(std::addressof(B_))));
}
}
......@@ -210,82 +217,233 @@ namespace corsika {
template <typename TCondition, typename TSequence, typename USequence, int IndexStart,
int IndexProcess1, int IndexProcess2>
template <typename TParticle>
inline InverseGrammageType SwitchProcessSequence<
TCondition, TSequence, USequence, IndexStart, IndexProcess1,
IndexProcess2>::getInverseInteractionLength(TParticle&& particle) {
if (select_(particle)) {
if constexpr (is_interaction_process_v<process1_type> ||
process1_type::is_process_sequence) {
return A_.getInverseInteractionLength(particle);
CrossSectionType SwitchProcessSequence<TCondition, TSequence, USequence, IndexStart,
IndexProcess1, IndexProcess2>::
getCrossSection(TParticle const& projectile, [[maybe_unused]] Code const targetId,
[[maybe_unused]] FourMomentum const& targetP4) const {
if (select_(projectile)) {
if constexpr (is_interaction_process_v<process1_type>) {
bool constexpr has_signature_cx1 =
has_method_getCrossSection_v<TSequence, // process object
CrossSectionType, // return type
Code, Code, // parameters
FourMomentum const&, FourMomentum const&>;
if constexpr (has_signature_cx1) {
return A_.getCrossSection(projectile.getPID(), targetId,
{projectile.getEnergy(), projectile.getMomentum()},
targetP4);
} else {
return A_.getCrossSection(projectile, projectile.getPID(),
{projectile.getEnergy(), projectile.getMomentum()});
}
} else if constexpr (process1_type::is_process_sequence) {
return A_.getCrossSection(projectile, targetId, targetP4);
}
} else {
if constexpr (is_interaction_process_v<process2_type> ||
process2_type::is_process_sequence) {
return B_.getInverseInteractionLength(particle);
if constexpr (is_interaction_process_v<process2_type>) {
bool constexpr has_signature_cx1 =
has_method_getCrossSection_v<USequence, // process object
CrossSectionType, // return type
Code, Code, // parameters
FourMomentum const&, FourMomentum const&>;
if constexpr (has_signature_cx1) {
return B_.getCrossSection(projectile.getPID(), targetId,
{projectile.getEnergy(), projectile.getMomentum()},
targetP4);
} else {
return B_.getCrossSection(projectile, targetId, targetP4);
}
} else if constexpr (process2_type::is_process_sequence) {
return B_.getCrossSection(projectile, targetId, targetP4);
}
}
return 0 * meter * meter / gram; // default value
return CrossSectionType::zero(); // default value
}
template <typename TCondition, typename TSequence, typename USequence, int IndexStart,
int IndexProcess1, int IndexProcess2>
template <typename TSecondaryView>
inline ProcessReturn SwitchProcessSequence<TCondition, TSequence, USequence, IndexStart,
IndexProcess1, IndexProcess2>::
selectInteraction(TSecondaryView& view,
[[maybe_unused]] InverseGrammageType lambda_inv_select,
[[maybe_unused]] InverseGrammageType lambda_inv_sum) {
template <typename TSecondaryView, typename TRNG>
inline ProcessReturn SwitchProcessSequence<
TCondition, TSequence, USequence, IndexStart, IndexProcess1,
IndexProcess2>::selectInteraction(TSecondaryView& view,
FourMomentum const& projectileP4,
NuclearComposition const& composition, TRNG& rng,
[[maybe_unused]] CrossSectionType const cx_select,
[[maybe_unused]] CrossSectionType cx_sum) {
if (select_(view.parent())) {
if constexpr (process1_type::is_process_sequence) {
// if A_ is a process sequence --> check inside
ProcessReturn const ret =
A_.selectInteraction(view, lambda_inv_select, lambda_inv_sum);
// if A_ did succeed, stop routine. Not checking other static branch B_.
if (ret != ProcessReturn::Ok) { return ret; }
return A_.selectInteraction(view, projectileP4, composition, rng, cx_select,
cx_sum);
} else if constexpr (is_interaction_process_v<process1_type>) {
// if this is not a ContinuousProcess --> evaluate probability
lambda_inv_sum += A_.getInverseInteractionLength(view.parent());
// check if we should execute THIS process and then EXIT
if (lambda_inv_select < lambda_inv_sum) {
// interface checking on TSequence
static_assert(has_method_doInteract_v<TSequence, void, TSecondaryView&>,
"TDerived has no method with correct signature \"void "
"doInteraction(TSecondaryView&)\" required for "
"InteractionProcess<TDerived>. ");
auto const& projectile = view.parent();
Code const projectileId = projectile.getPID();
// get cross section vector for all material components
// for selected process A
bool constexpr has_signature_cx1 =
has_method_getCrossSection_v<TSequence, // process object
CrossSectionType, // return type
Code, Code, // parameters
FourMomentum const&, FourMomentum const&>;
bool constexpr has_signature_cx2 = // needed for PROPOSAL interface
has_method_getCrossSectionTemplate_v<
TSequence, // process object
CrossSectionType, // return type
decltype(projectile) const&, // template argument
decltype(projectile) const&, // parameters
Code, FourMomentum const&>;
static_assert((has_signature_cx1 || has_signature_cx2),
"TSequence has no method with correct signature \"CrossSectionType "
"getCrossSection(Code, Code, FourMomentum const&, FourMomentum "
"const&)\" required by "
"InteractionProcess<TSequence>. ");
std::vector<CrossSectionType> weightedCrossSections;
if constexpr (has_signature_cx1) {
/*std::vector<CrossSectionType> const*/ weightedCrossSections =
composition.getWeighted([=](Code const targetId) -> CrossSectionType {
FourMomentum const targetP4(
get_mass(targetId),
MomentumVector(projectile.getMomentum().getCoordinateSystem(),
{0_GeV, 0_GeV, 0_GeV}));
return A_.getCrossSection(projectileId, targetId, projectileP4, targetP4);
});
cx_sum +=
std::accumulate(weightedCrossSections.cbegin(),
weightedCrossSections.cend(), CrossSectionType::zero());
} else { // this is for PROPOSAL
cx_sum += A_.template getCrossSection(projectile, projectileId, projectileP4);
}
if (cx_select < cx_sum) {
if constexpr (has_signature_cx1) {
// now also sample targetId from weighted cross sections
Code const targetId = composition.sampleTarget(weightedCrossSections, rng);
FourMomentum const targetP4(
get_mass(targetId),
MomentumVector(projectile.getMomentum().getCoordinateSystem(),
{0_GeV, 0_GeV, 0_GeV}));
// interface checking on TProcess1
static_assert(
has_method_doInteract_v<TSequence, // process object
void, // return type
TSecondaryView, // template argument
TSecondaryView&, // method parameters
Code, Code, FourMomentum const&,
FourMomentum const&>,
"TSequence has no method with correct signature \"void "
"doInteraction<TSecondaryView>(TSecondaryView&, "
"Code, Code, FourMomentum const&, FourMomentum const&)\" required for "
"InteractionProcess<TSequence>. ");
A_.template doInteraction(view, projectileId, targetId, projectileP4,
targetP4);
} else { // this is for PROPOSAL
A_.template doInteraction(view, projectileId, projectileP4);
}
A_.doInteraction(view);
return ProcessReturn::Interacted;
}
} // end branch A_
} // end collision branch A
}
} else {
} else { // selection: end branch A, start branch B
if constexpr (process2_type::is_process_sequence) {
// if B_ is a process sequence --> check inside
return B_.selectInteraction(view, lambda_inv_select, lambda_inv_sum);
return B_.selectInteraction(view, projectileP4, composition, rng, cx_select,
cx_sum);
} else if constexpr (is_interaction_process_v<process2_type>) {
// if this is not a ContinuousProcess --> evaluate probability
lambda_inv_sum += B_.getInverseInteractionLength(view.parent());
// check if we should execute THIS process and then EXIT
if (lambda_inv_select < lambda_inv_sum) {
// interface checking on TSequence
static_assert(has_method_doInteract_v<USequence, void, TSecondaryView&>,
"TDerived has no method with correct signature \"void "
"doInteraction(TSecondaryView&)\" required for "
"InteractionProcess<TDerived>. ");
auto const& projectile = view.parent();
Code const projectileId = projectile.getPID();
// get cross section vector for all material components, for selected process B
bool constexpr has_signature_cx1 =
has_method_getCrossSection_v<USequence, // process object
CrossSectionType, // return type
Code, Code, // parameters
FourMomentum const&, FourMomentum const&>;
bool constexpr has_signature_cx2 = // needed for PROPOSAL interface
has_method_getCrossSectionTemplate_v<
USequence, // process object
CrossSectionType, // return type
decltype(projectile) const&, // template argument
decltype(projectile) const&, // parameters
Code, FourMomentum const&>;
static_assert((has_signature_cx1 || has_signature_cx2),
"USequence has no method with correct signature \"CrossSectionType "
"getCrossSection(Code, Code, FourMomentum const&, FourMomentum "
"const&)\" required by "
"InteractionProcess<USequence>. ");
std::vector<CrossSectionType> weightedCrossSections;
if constexpr (has_signature_cx1) {
/* std::vector<CrossSectionType> const*/ weightedCrossSections =
composition.getWeighted([=](Code const targetId) -> CrossSectionType {
FourMomentum const targetP4(
get_mass(targetId),
MomentumVector(projectile.getMomentum().getCoordinateSystem(),
{0_GeV, 0_GeV, 0_GeV}));
return B_.getCrossSection(projectileId, targetId, projectileP4, targetP4);
});
cx_sum +=
std::accumulate(weightedCrossSections.begin(), weightedCrossSections.end(),
CrossSectionType::zero());
} else { // this is for PROPOSAL
cx_sum += B_.template getCrossSection(projectile, projectileId, projectileP4);
}
// check if we should execute THIS process and then EXIT
if (cx_select < cx_sum) {
if constexpr (has_signature_cx1) {
// now also sample targetId from weighted cross sections
Code const targetId = composition.sampleTarget(weightedCrossSections, rng);
FourMomentum const targetP4(
get_mass(targetId),
MomentumVector(projectile.getMomentum().getCoordinateSystem(),
{0_GeV, 0_GeV, 0_GeV}));
// interface checking on TProcess2
static_assert(
has_method_doInteract_v<USequence, // process object
void, // return type
TSecondaryView, // template argument
TSecondaryView&, // method parameters
Code, Code, FourMomentum const&,
FourMomentum const&>,
"USequence has no method with correct signature \"void "
"doInteraction<TSecondaryView>(TSecondaryView&, "
"Code, Code, FourMomentum const&, FourMomentum const&)\" required for "
"InteractionProcess<USequence>. ");
B_.doInteraction(view, projectileId, targetId, projectileP4, targetP4);
} else { // this is for PROPOSAL
B_.doInteraction(view, projectileId, projectileP4);
}
B_.doInteraction(view);
return ProcessReturn::Interacted;
}
} // end branch B_
}
} // end collision in branch B
}
} // end branch B_
return ProcessReturn::Ok;
}
} // namespace corsika
template <typename TCondition, typename TSequence, typename USequence, int IndexStart,
int IndexProcess1, int IndexProcess2>
......
/*
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
* (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
#pragma once
......
/*----------------------------------------------------------------------------
*
* Copyright (C) 2021 Antonio Augusto Alves Junior
*
* This file is part of RandomIterator.
*
* RandomIterator is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RandomIterator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RandomIterator. If not, see <http://www.gnu.org/licenses/>.
*
*---------------------------------------------------------------------------*/
*
* Copyright (C) 2021 - 2024 Antonio Augusto Alves Junior
*
* This file is part of RandomIterator.
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ----------------------------------------------------------------------------*/
/*
* RandomIterator.h
......
/*
* (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
/*
......
/*
* (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
/*
......
/*
* (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
/*
......
/*----------------------------------------------------------------------------
*
* Copyright (C) 2021 Antonio Augusto Alves Junior
*
* This file is part of RandomIterator.
*
* RandomIterator is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RandomIterator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RandomIterator. If not, see <http://www.gnu.org/licenses/>.
*
*---------------------------------------------------------------------------*/
*
* Copyright (C) 2021 - 2024 Antonio Augusto Alves Junior
*
* This file is part of RandomIterator.
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ----------------------------------------------------------------------------*/
/*
* Macros.h
*
......
......@@ -286,7 +286,7 @@ namespace random_iterator_r123 {
static inline std::array<Ftype, CollType::static_size> u01all(CollType in) {
std::array<Ftype, CollType::static_size> ret;
size_t i = 0;
for (auto e : in) { ret[i++] = u01<Ftype>(e); }
for (auto const e : in) { ret[i++] = u01<Ftype>(e); }
return ret;
}
......@@ -300,7 +300,7 @@ namespace random_iterator_r123 {
static inline std::array<Ftype, CollType::static_size> uneg11all(CollType in) {
std::array<Ftype, CollType::static_size> ret;
size_t i = 0;
for (auto e : in) { ret[i++] = uneg11<Ftype>(e); }
for (auto const e : in) { ret[i++] = uneg11<Ftype>(e); }
return ret;
}
......@@ -314,7 +314,7 @@ namespace random_iterator_r123 {
static inline std::array<Ftype, CollType::static_size> u01fixedptall(CollType in) {
std::array<Ftype, CollType::static_size> ret;
size_t i = 0;
for (auto e : in) { ret[i++] = u01fixedpt<Ftype>(e); }
for (auto const e : in) { ret[i++] = u01fixedpt<Ftype>(e); }
return ret;
}
#endif // __cplusplus >= 201103L
......
/*
* (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
/*
......
/*
* (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
/*
......
/*
* (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
/*
......
/*
* (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
/*
......
/*
* (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
/*
......
/*
* (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
 
/*
......
/*
* (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
* This software is distributed under the terms of the 3-clause BSD license.
* See file LICENSE for a full version of the license.
*/
/*
......
/*----------------------------------------------------------------------------
*
* Copyright (C) 2021 Antonio Augusto Alves Junior
*
* This file is part of RandomIterator.
*
* RandomIterator is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RandomIterator is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RandomIterator. If not, see <http://www.gnu.org/licenses/>.
*
*---------------------------------------------------------------------------*/
*
* Copyright (C) 2021 - 2024 Antonio Augusto Alves Junior
*
* This file is part of RandomIterator.
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ----------------------------------------------------------------------------*/
/*
* mulhilo64.h
*
......