CORSIKA8  0.0.0
The framework to simulate particle cascades for astroparticle physics
corsika::NuclearComposition Class Reference

Describes the composition of matter Allowes and handles the creation of custom matter compositions. More...

#include <NuclearComposition.hpp>

Public Member Functions

 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. More...
 
template<typename TFunction >
auto getWeightedSum (TFunction const &func) const
 Sum all all relative composition weighted by func(element) This function sums all relative compositions given during this classes construction. More...
 
size_t getSize () const
 Number of elements in the composition array. More...
 
std::vector< float > const & getFractions () const
 Returns a const reference to the fraction.
 
std::vector< Code > const & getComponents () const
 Returns a const reference to the fraction.
 
double const getAverageMassNumber () const
 
template<class TRNG >
Code sampleTarget (std::vector< CrossSectionType > const &sigma, TRNG &randomStream) const
 
size_t getHash () const
 
bool operator== (NuclearComposition const &v) const
 based on hash value
 

Detailed Description

Describes the composition of matter Allowes and handles the creation of custom matter compositions.

Definition at line 26 of file NuclearComposition.hpp.

Constructor & Destructor Documentation

◆ NuclearComposition()

corsika::NuclearComposition::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.

Booth lists need to have the same length and the sum all of fractions should be 1. Otherwise an exception is thrown

Parameters
pComponentsList of particle types
pFractionsList of fractions how much each particle contributes. The sum needs to add up to 1

Member Function Documentation

◆ getSize()

size_t corsika::NuclearComposition::getSize ( ) const

Number of elements in the composition array.

Return values
returnsthe number of elements in the composition array

◆ getWeightedSum()

template<typename TFunction >
auto corsika::NuclearComposition::getWeightedSum ( TFunction const &  func) const

Sum all all relative composition weighted by func(element) This function sums all relative compositions given during this classes construction.

Each entry is weighted by the user defined function func given to this function.

Template Parameters
TFunctionType of functions for the weights. The type should be Code -> float
Parameters
funcFunctions for reweighting specific elements
Return values
returnsthe weighted sum with the type defined by the return type of func

The documentation for this class was generated from the following file: