CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
InteractionModel.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/process/InteractionProcess.hpp>
17 #include <corsika/framework/random/RNGManager.hpp>
18 #include <corsika/framework/random/UniformRealDistribution.hpp>
19 #include <corsika/modules/proposal/ProposalProcessBase.hpp>
20 #include <corsika/modules/proposal/HadronicPhotonModel.hpp>
21 
22 namespace corsika::proposal {
23 
35 
36  template <class THadronicLEModel, class THadronicHEModel>
38  : public ProposalProcessBase,
39  public HadronicPhotonModel<THadronicLEModel, THadronicHEModel> {
40 
41  enum { eSECONDARIES, eINTERACTION, eLPM_SUPPRESSION };
42  struct LPM_calculator;
43  using calculator_t = std::tuple<std::unique_ptr<PROPOSAL::SecondariesCalculator>,
44  std::unique_ptr<PROPOSAL::Interaction>,
45  std::unique_ptr<LPM_calculator>>;
46 
47  std::unordered_map<calc_key_t, calculator_t, hash>
48  calc_;
49 
53  void buildCalculator(Code, NuclearComposition const&) final;
54 
55  inline static auto logger_{get_logger("corsika_proposal_InteractionModel")};
56 
57  // Calculators for the LPM effect
58  struct LPM_calculator {
59  std::unique_ptr<PROPOSAL::crosssection::PhotoPairLPM> photo_pair_lpm_ = nullptr;
60  std::unique_ptr<PROPOSAL::crosssection::BremsLPM> brems_lpm_ = nullptr;
61  std::unique_ptr<PROPOSAL::crosssection::EpairLPM> epair_lpm_ = nullptr;
62 
63  const double mass_density_baseline_; // base mass density, note PROPOSAL units
64  const double particle_mass_; // particle mass, note PROPOSAL units
65 
66  LPM_calculator(const PROPOSAL::Medium& medium, const Code code,
67  std::vector<PROPOSAL::InteractionType> inter_types)
68  : mass_density_baseline_(medium.GetMassDensity())
69  , particle_mass_(particle[code].mass) {
70  // at the moment, we always calculate the LPM effect based on the default cross
71  // sections. one could check for the parametrizations used in the other
72  // calculators.
73  if (std::find(inter_types.begin(), inter_types.end(),
74  PROPOSAL::InteractionType::Photopair) != inter_types.end())
75  photo_pair_lpm_ = std::make_unique<PROPOSAL::crosssection::PhotoPairLPM>(
76  particle[code], medium, PROPOSAL::crosssection::PhotoPairKochMotz());
77  if (std::find(inter_types.begin(), inter_types.end(),
78  PROPOSAL::InteractionType::Brems) != inter_types.end())
79  brems_lpm_ = std::make_unique<PROPOSAL::crosssection::BremsLPM>(
80  particle[code], medium, PROPOSAL::crosssection::BremsElectronScreening());
81  if (std::find(inter_types.begin(), inter_types.end(),
82  PROPOSAL::InteractionType::Epair) != inter_types.end())
83  epair_lpm_ =
84  std::make_unique<PROPOSAL::crosssection::EpairLPM>(particle[code], medium);
85  }
86  };
87 
91  bool CheckForLPM(const LPM_calculator&, const HEPEnergyType,
92  const PROPOSAL::InteractionType,
93  const std::vector<PROPOSAL::ParticleState>&, const MassDensityType,
94  const PROPOSAL::Component&, const double v);
95 
96  public:
101  template <typename TEnvironment>
102  InteractionModel(TEnvironment const& env, THadronicLEModel&, THadronicHEModel&,
103  HEPEnergyType const&);
104 
129  template <typename TSecondaryView>
130  ProcessReturn doInteraction(TSecondaryView&, Code const projectileId,
131  FourMomentum const& projectileP4);
132 
136  template <typename TParticle>
137  CrossSectionType getCrossSection(TParticle const& p, Code const projectileId,
138  FourMomentum const& projectileP4);
139  };
140 
141 } // namespace corsika::proposal
142 
143 #include <corsika/detail/modules/proposal/InteractionModel.inl>
PROPOSAL base process which handels mapping of particle codes to stored interpolation tables...
InteractionModel(TEnvironment const &env, THadronicLEModel &, THadronicHEModel &, HEPEnergyType const &)
Produces the stoachastic loss calculator for leptons based on nuclear compositions and stochastic des...
ProcessReturn doInteraction(TSecondaryView &, Code const projectileId, FourMomentum const &projectileP4)
Calculate the rates for the different targets and interactions. Sample a pair of interaction-type, component and rate, followed by sampling a loss and produce the corresponding secondaries and store them on the particle stack. interactions in PROPOSAL are:
std::shared_ptr< spdlog::logger > get_logger(std::string const &name, bool const defaultlog=false)
Get a smart pointer to an existing logger.
Electro-magnetic and photon stochastic losses produced by proposal. It makes use of interpolation tab...
Description of physical four-vectors.
Definition: FourVector.hpp:51
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 "|="
Implements the production of secondary hadrons for the hadronic interaction of real and virtual photo...
Describes the composition of matter Allowes and handles the creation of custom matter compositions...
Interface to particle properties.
General FourVector object.
CrossSectionType getCrossSection(TParticle const &p, Code const projectileId, FourMomentum const &projectileP4)
Calculates and returns the cross section.