CORSIKA8  0.0.0
The framework to simulate particle cascades for astroparticle physics
ProposalProcessBase.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 <PROPOSAL/PROPOSAL.h>
12 
14 #include <corsika/framework/random/RNGManager.hpp>
15 
16 #include <array>
17 
18 namespace corsika::proposal {
19 
24  static constexpr std::array<Code, 7> tracked{
25  Code::Photon, Code::Electron, Code::Positron, Code::MuMinus,
26  Code::MuPlus, Code::TauPlus, Code::TauMinus,
27  };
28 
34  static std::map<Code, PROPOSAL::ParticleDef> particle = {
35  {Code::Photon, PROPOSAL::GammaDef()}, {Code::Electron, PROPOSAL::EMinusDef()},
36  {Code::Positron, PROPOSAL::EPlusDef()}, {Code::MuMinus, PROPOSAL::MuMinusDef()},
37  {Code::MuPlus, PROPOSAL::MuPlusDef()}, {Code::TauMinus, PROPOSAL::TauMinusDef()},
38  {Code::TauPlus, PROPOSAL::TauPlusDef()}};
39 
43  template <typename T>
44  static auto cross_builder =
45  [](PROPOSAL::Medium& m,
47  emCut) {
48  auto p_cut = std::make_shared<const PROPOSAL::EnergyCutSettings>(
50  0.5 * emCut / 1_MeV, 1, false);
51  return PROPOSAL::GetStdCrossSections(T(), m, p_cut, true);
52  };
53 
58  static std::map<Code, std::function<PROPOSAL::crosssection_list_t(
59  PROPOSAL::Medium&, corsika::units::si::HEPEnergyType)>>
60  cross = {{Code::Photon, cross_builder<PROPOSAL::GammaDef>},
61  {Code::Electron, cross_builder<PROPOSAL::EMinusDef>},
62  {Code::Positron, cross_builder<PROPOSAL::EPlusDef>},
63  {Code::MuMinus, cross_builder<PROPOSAL::MuMinusDef>},
64  {Code::MuPlus, cross_builder<PROPOSAL::MuPlusDef>},
65  {Code::TauMinus, cross_builder<PROPOSAL::TauMinusDef>},
66  {Code::TauPlus, cross_builder<PROPOSAL::TauPlusDef>}};
67 
73  protected:
74  default_prng_type& RNG_ = RNGManager<>::getInstance().getRandomStream("proposal");
75 
76  std::unordered_map<std::size_t, PROPOSAL::Medium>
78 
84  template <typename TEnvironment>
85  ProposalProcessBase(TEnvironment const& _env);
86 
90  bool canInteract(Code pcode) const;
91 
92  using calc_key_t = std::pair<std::size_t, Code>;
93 
98  struct hash {
99  size_t operator()(const calc_key_t& p) const noexcept;
100  };
101 
105  virtual void buildCalculator(Code, NuclearComposition const&) = 0;
106 
112  template <typename Particle, typename Calculators>
113  auto getCalculator(Particle& vP, Calculators& calc) {
114  const auto& comp = vP.getNode()->getModelProperties().getNuclearComposition();
115  auto calc_it = calc.find(std::make_pair(comp.getHash(), vP.getPID()));
116  if (calc_it != calc.end()) return calc_it;
117  buildCalculator(vP.getPID(), comp);
118  return getCalculator(vP, calc);
119  }
120  };
121 } // namespace corsika::proposal
122 
123 #include <corsika/detail/modules/proposal/ProposalProcessBase.inl>
PROPOSAL base process which handels mapping of particle codes to stored interpolation tables...
auto getCalculator(Particle &vP, Calculators &calc)
Searches the particle dependet calculator dependent of actuall medium composition and particle type...
bool canInteract(Code pcode) const
Checks if a particle can be processed by proposal.
virtual void buildCalculator(Code, NuclearComposition const &)=0
Builds the calculator to the corresponding class.
std::unordered_map< std::size_t, PROPOSAL::Medium > media
maps nuclear composition from univers to media to produce crosssections, which requires further ioniz...
Hash to store interpolation tables related to a pair of particle and nuclear composition.
Describes the composition of matter Allowes and handles the creation of custom matter compositions...
Interface to particle properties.
ProposalProcessBase(TEnvironment const &_env)
Store cut and nuclear composition of the whole universe in media which are required for creating cros...
prng_type & getRandomStream(string_type const &streamName)