IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 1d992916 authored by Maximilian Reininghaus's avatar Maximilian Reininghaus :vulcan: Committed by Maximilian Reininghaus
Browse files

setup::Stack with environment-type template

parent 340f0a1a
No related branches found
No related tags found
1 merge request!429Resolve "SetupStack.hpp depends on SetupEnvironment.hpp"
...@@ -20,61 +20,76 @@ ...@@ -20,61 +20,76 @@
namespace corsika { namespace corsika {
namespace setup::detail { namespace setup::detail {
template <typename TEnvironment = setup::Environment>
// ------------------------------------------ class StackGenerator {
// add geometry node data to stack. This is fundamentally needed private:
// for robust tracking through multiple volumes. using env_type = TEnvironment;
// the GeometryNode stack needs to know the type of geometry-nodes from the // ------------------------------------------
// environment: // add geometry node data to stack. This is fundamentally needed
template <typename TStackIter> // for robust tracking through multiple volumes.
using SetupGeometryDataInterface =
typename node::MakeGeometryDataInterface<TStackIter, setup::Environment>::type; // the GeometryNode stack needs to know the type of geometry-nodes from the
// environment:
// combine particle data stack with geometry information for tracking
template <typename TStackIter> template <typename TStackIter>
using StackWithGeometryInterface = using SetupGeometryDataInterface =
CombinedParticleInterface<VectorStack::pi_type, SetupGeometryDataInterface, typename node::MakeGeometryDataInterface<TStackIter, env_type>::type;
TStackIter>;
// combine particle data stack with geometry information for tracking
using StackWithGeometry = template <typename TStackIter>
CombinedStack<typename VectorStack::stack_data_type, using StackWithGeometryInterface =
node::GeometryData<setup::Environment>, StackWithGeometryInterface, CombinedParticleInterface<VectorStack::pi_type, SetupGeometryDataInterface,
DefaultSecondaryProducer>; TStackIter>;
// ------------------------------------------ using StackWithGeometry =
// add weight data to stack. This is fundamentally needed CombinedStack<typename VectorStack::stack_data_type,
// for thinning. node::GeometryData<env_type>, StackWithGeometryInterface,
DefaultSecondaryProducer>;
// the "pure" weight stack (interface)
template <typename TStackIter> template <class T>
using SetupWeightDataInterface = using StackWithGeometry_PI_type = typename StackWithGeometry::template pi_type<T>;
typename weights::MakeWeightDataInterface<TStackIter>::type;
// ------------------------------------------
// combine geometry-node-vector data stack with weight information for tracking // add weight data to stack. This is fundamentally needed
template <typename TStackIter> // for thinning.
using StackWithWeightInterface =
CombinedParticleInterface<StackWithGeometry::pi_type, SetupWeightDataInterface, // the "pure" weight stack (interface)
TStackIter>; template <typename TStackIter>
using SetupWeightDataInterface =
// the combined stack data: particle + geometry + weight typename weights::MakeWeightDataInterface<TStackIter>::type;
using StackWithWeight =
CombinedStack<typename StackWithGeometry::stack_data_type, weights::WeightData, // combine geometry-node-vector data stack with weight information for tracking
StackWithWeightInterface, DefaultSecondaryProducer>; template <typename TStackIter>
using StackWithWeightInterface =
// ------------------------------------------ CombinedParticleInterface<StackWithGeometry_PI_type, SetupWeightDataInterface,
// Add [OPTIONAL] history data to stack, too. TStackIter>;
// This keeps the entire lineage of particles in memory.
public:
template <typename TStackIter> // the combined stack data: particle + geometry + weight
using StackWithHistoryInterface = using StackWithWeight =
CombinedParticleInterface<StackWithWeight::pi_type, CombinedStack<typename StackWithGeometry::stack_data_type, weights::WeightData,
history::HistoryEventDataInterface, TStackIter>; StackWithWeightInterface, DefaultSecondaryProducer>;
using StackWithHistory = private:
CombinedStack<typename StackWithWeight::stack_data_type, template <typename T>
history::HistoryEventData, StackWithHistoryInterface, using StackWithWeight_PI_type = typename StackWithWeight::template pi_type<T>;
history::HistorySecondaryProducer>;
// ------------------------------------------
// Add [OPTIONAL] history data to stack, too.
// This keeps the entire lineage of particles in memory.
template <typename TStackIter>
using StackWithHistoryInterface =
CombinedParticleInterface<StackWithWeight_PI_type,
history::HistoryEventDataInterface, TStackIter>;
public:
using StackWithHistory =
CombinedStack<typename StackWithWeight::stack_data_type,
history::HistoryEventData, StackWithHistoryInterface,
history::HistorySecondaryProducer>;
};
} // namespace setup::detail } // namespace setup::detail
......
...@@ -24,18 +24,21 @@ namespace corsika::setup { ...@@ -24,18 +24,21 @@ namespace corsika::setup {
/* /*
* the version with history * the version with history
*/ */
using Stack = detail::StackWithHistory; template <typename TEnvironment>
using Stack = typename detail::StackGenerator<TEnvironment>::StackWithWeight;
#else // WITH_HISTORY #else // WITH_HISTORY
/* /*
* the version without history (and geometry data and weights) * the version without history (and geometry data and weights)
*/ */
using Stack = detail::StackWithWeight; template <typename TEnvironment>
using Stack = typename detail::StackGenerator<TEnvironment>::StackWithWeight;
#endif #endif
// the correct secondary stack view // the correct secondary stack view
using StackView = typename Stack::stack_view_type; template <typename TEnvironment>
using StackView = typename Stack<TEnvironment>::stack_view_type;
} // namespace corsika::setup } // namespace corsika::setup
...@@ -110,7 +110,7 @@ int main(int argc, char** argv) { ...@@ -110,7 +110,7 @@ int main(int argc, char** argv) {
set_energy_production_threshold(pcode, energy); set_energy_production_threshold(pcode, energy);
// setup particle stack, and add primary particle // setup particle stack, and add primary particle
setup::Stack stack; setup::Stack<EnvType> stack;
stack.clear(); stack.clear();
const Code beamCode = Code::Electron; const Code beamCode = Code::Electron;
auto const mass = get_mass(beamCode); auto const mass = get_mass(beamCode);
......
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