CORSIKA8  0.0.0
The framework to simulate particle cascades for astroparticle physics
Cascade.hpp
1 /*
2  * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
3  *
4  * This software is distributed under the terms of the GNU General Public
5  * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
6  * the license.
7  */
8 
9 #pragma once
10 
13 #include <corsika/framework/random/ExponentialDistribution.hpp>
14 #include <corsika/framework/random/RNGManager.hpp>
15 #include <corsika/framework/random/UniformRealDistribution.hpp>
16 #include <corsika/framework/stack/SecondaryView.hpp>
18 
19 #include <corsika/media/Environment.hpp>
20 
21 #include <corsika/stack/history/HistoryStackExtension.hpp>
22 
23 #include <cassert>
24 #include <cmath>
25 #include <limits>
26 #include <type_traits>
27 
32 namespace corsika {
33 
53  template <typename TTracking, typename TProcessList, typename TOutput, typename TStack>
54  class Cascade {
55 
56  typedef typename TStack::stack_view_type stack_view_type;
57 
58  typedef typename TStack::particle_type particle_type;
59 
60  typedef std::remove_pointer_t<decltype(((particle_type*)nullptr)->getNode())>
61  volume_tree_node_type;
62 
63  typedef typename volume_tree_node_type::IModelProperties medium_interface_type;
64 
65  public:
72  Cascade() = delete;
73  Cascade(Cascade const&) = default;
74  Cascade(Cascade&&) = default;
75  ~Cascade() = default;
76  Cascade& operator=(Cascade const&) = default;
77  Cascade(Environment<medium_interface_type> const& env, TTracking& tr,
78  TProcessList& pl, TOutput& out, TStack& stack)
79  : environment_(env)
80  , tracking_(tr)
81  , sequence_(pl)
82  , output_(out)
83  , stack_(stack) {
84  CORSIKA_LOG_INFO(c8_ascii_);
85  CORSIKA_LOG_INFO("Tracking algorithm: {} (version {})", TTracking::getName(),
86  TTracking::getVersion());
87  if constexpr (stack_view_type::has_event) {
88  CORSIKA_LOG_INFO("Stack - with full cascade HISTORY.");
89  }
90  }
92 
97  void setNodes();
98 
103  void run();
104 
110  void forceInteraction();
111 
112  private:
123  void step(particle_type& vParticle);
124 
125  ProcessReturn decay(stack_view_type& view, InverseTimeType initial_inv_decay_time);
126  ProcessReturn interaction(stack_view_type& view,
127  InverseGrammageType initial_inv_int_length);
128  void setEventType(stack_view_type& view, history::EventType);
129 
130  // data members
131  Environment<medium_interface_type> const& environment_;
132  TTracking& tracking_;
133  TProcessList& sequence_;
134  TOutput& output_;
135  TStack& stack_;
136  default_prng_type& rng_ = RNGManager<>::getInstance().getRandomStream("cascade");
137  unsigned int count_ = 0;
138 
139  // but this here temporarily. Should go into dedicated file later:
140  const char* c8_ascii_ =
141  R"V0G0N(
142  ,ad8888ba, ,ad8888ba, 88888888ba ad88888ba 88 88 a8P db ad88888ba
143  d8"' `"8b d8"' `"8b 88 "8b d8" "8b 88 88 ,88' d88b d8" "8b
144 d8' d8' `8b 88 ,8P Y8, 88 88 ,88" d8'`8b Y8a a8P
145 88 88 88 88aaaaaa8P' `Y8aaaaa, 88 88,d88' d8' `8b "Y8aaa8P"
146 88 88 88 88""""88' `"""""8b, 88 8888"88, d8YaaaaY8b ,d8"""8b,
147 Y8, Y8, ,8P 88 `8b `8b 88 88P Y8b d8""""""""8b d8" "8b
148  Y8a. .a8P Y8a. .a8P 88 `8b Y8a a8P 88 88 "88, d8' `8b Y8a a8P
149  `"Y8888Y"' `"Y8888Y"' 88 `8b "Y88888P" 88 88 Y8b d8' `8b "Y88888P"
150  )V0G0N";
151  };
152 
153 } // namespace corsika
154 
155 #include <corsika/detail/framework/core/Cascade.inl>
Import and extend the phys::units package.
The Cascade class is constructed from template arguments making it very versatile.
Definition: Cascade.hpp:54
CORSIKA8 logging utilities.
class "quantity" is the heart of the library.
Definition: quantity.hpp:54
void run()
The Run function is the main simulation loop, which processes particles from the Stack until the Stac...
The cascade namespace assembles all objects needed to simulate full particles cascades.
ProcessReturn
since in a process sequence many status updates can accumulate for a single particle, this enum should define only bit-flags that can be accumulated easily with "|="
Cascade()=delete
constructorsCascade class cannot be default constructed, but needs a valid list of physics processes ...
void setNodes()
set the nodes for all particles on the stack according to their numerical position ...
void forceInteraction()
Force an interaction of the top particle of the stack at its current position.
prng_type & getRandomStream(string_type const &streamName)