CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
ProcessSequence.hpp
Go to the documentation of this file.
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 
17 #include <corsika/framework/process/BoundaryCrossingProcess.hpp>
18 #include <corsika/framework/process/ContinuousProcess.hpp>
19 #include <corsika/framework/process/ContinuousProcessIndex.hpp>
20 #include <corsika/framework/process/ContinuousProcessStepLength.hpp>
21 #include <corsika/framework/process/DecayProcess.hpp>
22 #include <corsika/framework/process/InteractionProcess.hpp>
23 #include <corsika/framework/process/CascadeEquationsProcess.hpp>
25 #include <corsika/framework/process/SecondariesProcess.hpp>
26 #include <corsika/framework/process/StackProcess.hpp>
27 #include <corsika/framework/process/NullModel.hpp>
28 #include <corsika/framework/core/Step.hpp>
31 
33 
34 namespace corsika {
35 
36  class COMBoost; // fwd-decl
37  class NuclearComposition; // fwd-decl
38 
43  template <typename TProcess, int N>
45  TProcess, N,
46  typename std::enable_if_t<is_process_v<std::decay_t<TProcess>> &&
47  std::decay_t<TProcess>::is_process_sequence>> {
48  static size_t constexpr count = N + std::decay_t<TProcess>::getNumberOfProcesses();
49  };
50 
156  template <typename TProcess1, typename TProcess2 = NullModel,
157  int ProcessIndexOffset = 0,
158  int IndexOfProcess1 = corsika::count_processes<
159  TProcess1,
161  int IndexOfProcess2 =
163  class ProcessSequence : public BaseProcess<ProcessSequence<TProcess1, TProcess2>> {
164 
165  using process1_type = typename std::decay_t<TProcess1>;
166  using process2_type = typename std::decay_t<TProcess2>;
167 
168  public:
169  // resource management
170  ProcessSequence() = delete; // only initialized objects
171  ProcessSequence(ProcessSequence const&) = default;
172  ProcessSequence(ProcessSequence&&) = default;
173  ProcessSequence& operator=(ProcessSequence const&) = default;
174  ~ProcessSequence() = default;
175 
176  static bool const is_process_sequence = true;
177 
188  ProcessSequence(TProcess1 in_A, TProcess2 in_B);
189 
199  template <typename TParticle>
200  ProcessReturn doBoundaryCrossing(TParticle& particle,
201  typename TParticle::node_type const& from,
202  typename TParticle::node_type const& to);
203 
204  template <typename TParticle>
205  ProcessReturn doContinuous(Step<TParticle>& step,
206  ContinuousProcessIndex const limitID);
207 
217  template <typename TSecondaries>
218  void doSecondaries(TSecondaries& vS);
219 
228  bool checkStep();
229 
233  template <typename TStack>
234  void doStack(TStack& stack);
235 
239  template <typename TStack>
240  void doCascadeEquations(TStack& stack);
241 
245  void initCascadeEquations();
246 
262  template <typename TParticle, typename TTrack>
263  ContinuousProcessStepLength getMaxStepLength(TParticle&& particle, TTrack&& vTrack);
264 
274  template <typename TParticle>
275  CrossSectionType getCrossSection(TParticle const& projectile, Code const targetId,
276  FourMomentum const& targetP4) const;
277 
278  template <typename TParticle>
279  TimeType getLifetime(TParticle& particle) {
280  return 1. / getInverseLifetime(particle);
281  }
282 
309  template <typename TSecondaryView, typename TRNG>
310  inline ProcessReturn selectInteraction(
311  TSecondaryView&& view, FourMomentum const& projectileP4,
312  NuclearComposition const& composition, TRNG&& rng,
313  CrossSectionType const cx_select,
315 
316  template <typename TParticle>
317  InverseTimeType getInverseLifetime(TParticle&& particle);
318 
319  // select decay process
320  template <typename TSecondaryView>
321  ProcessReturn selectDecay(TSecondaryView&& view, InverseTimeType decay_inv_select,
322  InverseTimeType decay_inv_sum = InverseTimeType::zero());
323 
327  static size_t constexpr getNumberOfProcesses() { return numberOfProcesses_; }
328 
329 #ifdef CORSIKA_UNIT_TESTING
330  TProcess1 getProcess1() const { return A_; }
331  TProcess2 getProcess2() const { return B_; }
332 #endif
333 
334  private:
335  TProcess1 A_;
336  TProcess2 B_;
337 
338  static size_t constexpr numberOfProcesses_ = IndexOfProcess1; // static counter
339  };
340 
370  template <typename... TProcesses, typename TProcess1>
372  make_sequence(TProcess1&& vA, TProcesses&&... vBs) {
373  return ProcessSequence<TProcess1,
374  decltype(make_sequence(std::declval<TProcesses>()...))>(
375  vA, make_sequence(std::forward<TProcesses>(vBs)...));
376  }
377 
391  template <typename TProcess1, typename TProcess2>
392  ProcessSequence<TProcess1, TProcess2> make_sequence(TProcess1&& vA, TProcess2&& vB) {
394  }
395 
408  template <typename TProcess>
409  ProcessSequence<TProcess, NullModel> make_sequence(TProcess&& vA) {
411  }
412 
413 } // namespace corsika
414 
415 #include <corsika/detail/framework/process/ProcessSequence.inl>
traits class to count any type of Process, general version.
Import and extend the phys::units package.
Definition of a static process list/sequence.
STL namespace.
Each process in C8 must derive from BaseProcess.
Definition: BaseProcess.hpp:34
To index individual processes (continuous processes) inside a ProcessSequence.
Description of physical four-vectors.
Definition: FourVector.hpp:51
`, since they are used everywhere as integral part of the framework.
Process that does nothing.
Definition: NullModel.hpp:24
static constexpr quantity zero()
We need a "zero" of each type – for comparisons, to initialize running totals, etc.
Definition: quantity.hpp:359
static size_t constexpr getNumberOfProcesses()
static counter to uniquely index (count) all ContinuousProcess in switch sequence.
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...
Interface to particle properties.
To store step length in LengthType and unique index in ProcessSequence of shortest step ContinuousPro...
General FourVector object.