CORSIKA8  0.0.0
The framework to simulate particle cascades for astroparticle physics
NuclearComposition.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 
14 #include <cassert>
15 #include <functional>
16 #include <numeric>
17 #include <random>
18 #include <stdexcept>
19 #include <vector>
20 
21 namespace corsika {
22 
27  public:
36  NuclearComposition(std::vector<Code> const& pComponents,
37  std::vector<float> const& pFractions);
38 
48  template <typename TFunction>
49  auto getWeightedSum(TFunction const& func) const;
50 
54  size_t getSize() const;
55 
57  std::vector<float> const& getFractions() const;
59  std::vector<Code> const& getComponents() const;
60  double const getAverageMassNumber() const;
61 
62  template <class TRNG>
63  Code sampleTarget(std::vector<CrossSectionType> const& sigma,
64  TRNG& randomStream) const;
65 
66  // Note: when this class ever modifies its internal data, the hash
67  // must be updated, too!
68  size_t getHash() const;
69 
71  bool operator==(NuclearComposition const& v) const;
72 
73  private:
74  void updateHash();
75 
76  std::vector<float> const numberFractions_;
77  std::vector<Code> const components_;
78 
79  double const avgMassNumber_;
80 
81  std::size_t hash_;
82  };
83 
84 } // namespace corsika
85 
86 #include <corsika/detail/media/NuclearComposition.inl>
Import and extend the phys::units package.
auto getWeightedSum(TFunction const &func) const
Sum all all relative composition weighted by func(element) This function sums all relative compositio...
std::vector< float > const & getFractions() const
Returns a const reference to the fraction.
The cascade namespace assembles all objects needed to simulate full particles cascades.
std::vector< Code > const & getComponents() const
Returns a const reference to the fraction.
size_t getSize() const
Number of elements in the composition array.
bool operator==(NuclearComposition const &v) const
based on hash value
Describes the composition of matter Allowes and handles the creation of custom matter compositions...
Interface to particle properties.
NuclearComposition(std::vector< Code > const &pComponents, std::vector< float > const &pFractions)
Constructor The constructore takes a list of elements and a list which describe the relative amount...