CORSIKA  @c8_version@
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< double > const &pFractions)
 Constructor The constructore takes a list of elements and a list which describe the relative amount. More...
 
template<typename TFunction >
auto getWeighted (TFunction func) const
 Returns a vector of the same length as elements in the material with the weighted return of "func". More...
 
template<typename TFunction >
auto getWeightedSum (TFunction func) const -> decltype(func(std::declval< Code >()))
 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< double > 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 28 of file NuclearComposition.hpp.

Constructor & Destructor Documentation

◆ NuclearComposition()

corsika::NuclearComposition::NuclearComposition ( std::vector< Code > const &  pComponents,
std::vector< double > 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.

◆ getWeighted()

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

Returns a vector of the same length as elements in the material with the weighted return of "func".

The typical default application is for cross section weighted with fraction in the material.

Template Parameters
TFunctionType of functions for the weights. The type should be Code -> CrossSectionType.
Parameters
funcFunctions for reweighting specific elements.
Return values
returnsthe vector with weighted return types of func.

◆ getWeightedSum()

template<typename TFunction >
auto corsika::NuclearComposition::getWeightedSum ( TFunction  func) const -> decltype(func(std::declval< Code >()))

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 -> double.
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: