CORSIKA  @c8_version@
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 
11 #include <corsika/corsika.hpp>
12 
16 #include <corsika/framework/random/ExponentialDistribution.hpp>
17 #include <corsika/framework/random/RNGManager.hpp>
18 #include <corsika/framework/random/UniformRealDistribution.hpp>
19 #include <corsika/framework/stack/SecondaryView.hpp>
21 
22 #include <corsika/media/Environment.hpp>
23 
24 #include <corsika/stack/history/HistoryStackExtension.hpp>
25 
26 #include <cassert>
27 #include <cmath>
28 #include <limits>
29 #include <type_traits>
30 
31 namespace corsika {
32 
51  template <typename TTracking, typename TProcessList, typename TOutput, typename TStack>
52  class Cascade {
53 
54  typedef typename TStack::stack_view_type stack_view_type;
55 
56  typedef typename TStack::particle_type particle_type;
57 
58  typedef std::remove_pointer_t<decltype(std::declval<particle_type>().getNode())>
59  volume_tree_node_type;
60 
61  typedef typename volume_tree_node_type::IModelProperties medium_interface_type;
62 
63  public:
70  Cascade() = delete;
71  Cascade(Cascade const&) = default;
72  Cascade(Cascade&&) = default;
73  ~Cascade() = default;
74  Cascade& operator=(Cascade const&) = default;
75  Cascade(Environment<medium_interface_type> const& env, TTracking& tr,
76  TProcessList& pl, TOutput& out, TStack& stack);
78 
83  void setNodes();
84 
89  void run();
90 
96  void forceInteraction();
97 
98  private:
109  void step(particle_type& vParticle);
110 
111  ProcessReturn decay(stack_view_type& view, InverseTimeType initial_inv_decay_time);
112  ProcessReturn interaction(stack_view_type& view, FourMomentum const& projectileP4,
113  NuclearComposition const& composition,
114  CrossSectionType const initial_cross_section);
115  void setEventType(stack_view_type& view, history::EventType);
116 
117  // data members
118  Environment<medium_interface_type> const& environment_;
119  TTracking& tracking_;
120  TProcessList& sequence_;
121  TOutput& output_;
122  TStack& stack_;
123  default_prng_type& rng_ = RNGManager<>::getInstance().getRandomStream("cascade");
124  bool forceInteraction_;
125  unsigned int count_ = 0;
126 
127  // but this here temporarily. Should go into dedicated file later:
128  const char* c8_ascii_ =
129  R"V0G0N(
130  ,ad8888ba, ,ad8888ba, 88888888ba ad88888ba 88 88 a8P db ad88888ba
131  d8"' `"8b d8"' `"8b 88 "8b d8" "8b 88 88 ,88' d88b d8" "8b
132 d8' d8' `8b 88 ,8P Y8, 88 88 ,88" d8'`8b Y8a a8P
133 88 88 88 88aaaaaa8P' `Y8aaaaa, 88 88,d88' d8' `8b "Y8aaa8P"
134 88 88 88 88""""88' `"""""8b, 88 8888"88, d8YaaaaY8b ,d8"""8b,
135 Y8, Y8, ,8P 88 `8b `8b 88 88P Y8b d8""""""""8b d8" "8b
136  Y8a. .a8P Y8a. .a8P 88 `8b Y8a a8P 88 88 "88, d8' `8b Y8a a8P
137  `"Y8888Y"' `"Y8888Y"' 88 `8b "Y88888P" 88 88 Y8b d8' `8b "Y88888P"
138  )V0G0N";
139  };
140 
141 } // namespace corsika
142 
143 #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:52
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...
Description of physical four-vectors.
Definition: FourVector.hpp:51
`, since they are used everywhere as integral part of the framework.
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 "|="
Describes the composition of matter Allowes and handles the creation of custom matter compositions...
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.
General FourVector object.
prng_type & getRandomStream(string_type const &streamName)