Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
MCGIDI::Sampling Namespace Reference

Namespaces

namespace  Upscatter

Classes

class  ClientRandomNumberGenerator
class  ClientCodeRNGData
class  Input
class  Product
class  ProductHandler
class  StdVectorProductHandler
class  MCGIDIVectorProductHandler

Enumerations

enum class  SampledType {
  firstTwoBody , secondTwoBody , uncorrelatedBody , unspecified ,
  photon
}

Functions

LUPI_HOST_DEVICE std::size_t evaluationForHashIndex (std::size_t a_hashIndex, Vector< std::size_t > const &a_hashIndices, double a_energy, Vector< double > const &a_energies, double *a_energyFraction)

Enumeration Type Documentation

◆ SampledType

enum class MCGIDI::Sampling::SampledType
strong
Enumerator
firstTwoBody 
secondTwoBody 
uncorrelatedBody 
unspecified 
photon 

Definition at line 56 of file MCGIDI_sampling.hpp.

Function Documentation

◆ evaluationForHashIndex()

LUPI_HOST_DEVICE std::size_t MCGIDI::Sampling::evaluationForHashIndex ( std::size_t a_hashIndex,
Vector< std::size_t > const & a_hashIndices,
double a_energy,
Vector< double > const & a_energies,
double * a_energyFraction )

This function returns the index in a_energies where a_energy lies between the returned index and the next index. The returned index must lie between a_hashIndices[a_hashIndex] and a_hashIndices[a_hashIndex+1]. If a_energy is below the domain of a_energies, 0 is returned. If a_energy is above the domain of a_energies, the size of a_energies minus 2 is returned. The argument a_energyFraction the weight for the energy at the returned index with the next index getting weighting 1 minus a_energyFraction.

Parameters
a_hashIndex[in] The index in a_hashIndices where the index in a_energy must be bound by it and the next index in a_hashIndex.
a_hashIndices[in] The list of hash indices.
a_energies[in] The list of energies.
a_energy[in] The energy whose index is requested.
a_energyFraction[in] This represents the weighting to apply to the two bounding energies.
Returns
The index bounding a_energy in the member a_energies.

Definition at line 39 of file MCGIDI_sampling.cc.

40 {
41
42 *a_energyFraction = 1.0;
43
44 if( a_energy <= a_energies[0] ) return( 0 );
45 if( a_energy >= a_energies.back( ) ) {
46 *a_energyFraction = 0.0;
47 return( ( a_energies.size( ) - 2 ) );
48 }
49
50 std::size_t index1 = a_hashIndices[a_hashIndex];
51
52#ifdef MCGIDI_CrossSectionLinearSubSearch
53 while( a_energies[index1] > a_energy ) --index1; // Make sure the calls gave the correct *a_hashIndex*.
54 while( a_energies[index1] < a_energy ) ++index1;
55 --index1;
56#endif
57
58#ifdef MCGIDI_CrossSectionBinarySubSearch
59 std::size_t index2 = a_hashIndices[a_hashIndex];
60 std::size_t index3 = a_energies.size( ) - 1;
61 if( ( a_hashIndex + 1 ) < a_hashIndices.size( ) ) index3 = a_hashIndices[a_hashIndex+1] + 1;
62 if( index3 == a_energies.size( ) ) --index3;
63 if( index2 != index3 ) index2 = static_cast<std::size_t>( binarySearchVectorBounded( a_energy, a_energies, index2, index3, false ) );
64#endif
65
66#ifdef MCGIDI_CrossSectionBinarySubSearch
67 #ifdef MCGIDI_CrossSectionLinearSubSearch
68 if( index1 != index2 ) {
69 std::cerr << "Help " << index1 << " " << index2 << std::endl;
70 }
71 #endif
72 index1 = index2;
73#endif
74
75 *a_energyFraction = ( a_energies[index1+1] - a_energy ) / ( a_energies[index1+1] - a_energies[index1] );
76
77 return( index1 );
78}
LUPI_HOST_DEVICE std::size_t size() const
LUPI_HOST_DEVICE T & back()
LUPI_HOST_DEVICE int binarySearchVectorBounded(double a_x, Vector< double > const &a_Xs, std::size_t a_lower, std::size_t a_upper, bool a_boundIndex)
Definition MCGIDI.hpp:347

Referenced by MCGIDI::Sampling::Upscatter::ModelDBRC_data::crossSectionMax(), MCGIDI::Sampling::Upscatter::ModelDBRC_data::evaluate(), and MCGIDI::HeatedCrossSectionContinuousEnergy::evaluationInfo().