Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
MCGIDI::Probabilities::WeightedFunctionals2d Class Reference

#include <MCGIDI_functions.hpp>

Inheritance diagram for MCGIDI::Probabilities::WeightedFunctionals2d:

Public Member Functions

LUPI_HOST_DEVICE WeightedFunctionals2d ()
LUPI_HOST WeightedFunctionals2d (GIDI::Functions::WeightedFunctionals2d const &a_weightedFunctionals2d)
LUPI_HOST_DEVICE ~WeightedFunctionals2d ()
LUPI_HOST_DEVICE double evaluate (double a_x2, double a_x1) const
template<typename RNG>
LUPI_HOST_DEVICE double sample (double a_x2, double a_rngValue, RNG &&a_rng) const
LUPI_HOST_DEVICE void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
Public Member Functions inherited from MCGIDI::Probabilities::ProbabilityBase2d
LUPI_HOST_DEVICE ProbabilityBase2d ()
LUPI_HOST ProbabilityBase2d (GIDI::Functions::FunctionForm const &a_probabilty)
LUPI_HOST ProbabilityBase2d (GIDI::Functions::FunctionForm const &a_probabilty, Vector< double > const &a_Xs)
LUPI_HOST_DEVICE ~ProbabilityBase2d ()
LUPI_HOST_DEVICE ProbabilityBase2dType type () const
LUPI_HOST_DEVICE String typeString () const
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION double evaluate (double a_x2, double a_x1) const MCGIDI_TRUE_VIRTUAL
template<typename RNG>
LUPI_HOST_DEVICE MCGIDI_VIRTUAL_FUNCTION double sample (double a_x2, double a_rngValue, RNG &&a_rng) const MCGIDI_TRUE_VIRTUAL
LUPI_HOST_DEVICE void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
template<typename RNG>
LUPI_HOST_DEVICE double sample (double a_x2, double a_rngValue, RNG &&a_rng) const
Public Member Functions inherited from MCGIDI::Probabilities::ProbabilityBase
LUPI_HOST_DEVICE ProbabilityBase ()
LUPI_HOST ProbabilityBase (GIDI::Functions::FunctionForm const &a_probabilty)
LUPI_HOST ProbabilityBase (GIDI::Functions::FunctionForm const &a_probabilty, Vector< double > const &a_Xs)
LUPI_HOST_DEVICE ~ProbabilityBase ()
LUPI_HOST_DEVICE void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
Public Member Functions inherited from MCGIDI::Functions::FunctionBase
LUPI_HOST_DEVICE FunctionBase ()
LUPI_HOST FunctionBase (GIDI::Functions::FunctionForm const &a_function)
LUPI_HOST_DEVICE FunctionBase (int a_dimension, double a_domainMin, double a_domainMax, Interpolation a_interpolation, double a_outerDomainValue=0)
virtual LUPI_HOST_DEVICE ~FunctionBase ()=0
LUPI_HOST_DEVICE Interpolation interpolation () const
LUPI_HOST_DEVICE double domainMin () const
LUPI_HOST_DEVICE double domainMax () const
LUPI_HOST_DEVICE double outerDomainValue () const
LUPI_HOST_DEVICE void serialize (LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)

Additional Inherited Members

Protected Attributes inherited from MCGIDI::Probabilities::ProbabilityBase2d
ProbabilityBase2dType m_type
Protected Attributes inherited from MCGIDI::Probabilities::ProbabilityBase
Vector< double > m_Xs

Detailed Description

Definition at line 713 of file MCGIDI_functions.hpp.

Constructor & Destructor Documentation

◆ WeightedFunctionals2d() [1/2]

LUPI_HOST_DEVICE MCGIDI::Probabilities::WeightedFunctionals2d::WeightedFunctionals2d ( )

Definition at line 2272 of file MCGIDI_functions.cc.

2272 :
2273 m_weight( ),
2274 m_energy( ) {
2275
2277}

◆ WeightedFunctionals2d() [2/2]

LUPI_HOST MCGIDI::Probabilities::WeightedFunctionals2d::WeightedFunctionals2d ( GIDI::Functions::WeightedFunctionals2d const & a_weightedFunctionals2d)

Definition at line 2281 of file MCGIDI_functions.cc.

2281 :
2282 ProbabilityBase2d( a_weightedFunctionals2d ) {
2283
2285
2286 Vector<GIDI::Functions::Weighted_function2d *> const &weighted_function2d = a_weightedFunctionals2d.weighted_function2d( );
2287 m_weight.resize( weighted_function2d.size( ) );
2288 m_energy.resize( weighted_function2d.size( ) );
2289 for( std::size_t i1 = 0; i1 < weighted_function2d.size( ); ++i1 ) {
2290 m_weight[i1] = Functions::parseFunction1d_d1( weighted_function2d[i1]->weight( ) );
2291 m_energy[i1] = parseProbability2d_d1( weighted_function2d[i1]->energy( ), nullptr );
2292 }
2293}
G4double energy(const ThreeVector &p, const G4double m)
@ weighted_function2d
Definition GIDI.hpp:129
LUPI_HOST Function1d_d1 * parseFunction1d_d1(Transporting::MC const &a_settings, GIDI::Suite const &a_suite)
LUPI_HOST ProbabilityBase2d_d1 * parseProbability2d_d1(GIDI::Functions::Function2dForm const *form2d, SetupInfo *a_setupInfo)

◆ ~WeightedFunctionals2d()

LUPI_HOST_DEVICE MCGIDI::Probabilities::WeightedFunctionals2d::~WeightedFunctionals2d ( )

Definition at line 2298 of file MCGIDI_functions.cc.

2298 {
2299
2300 for( std::size_t i1 = 0; i1 < m_weight.size( ); ++i1 ) delete m_weight[i1];
2301 for( std::size_t i1 = 0; i1 < m_energy.size( ); ++i1 ) delete m_energy[i1];
2302}

Member Function Documentation

◆ evaluate()

LUPI_HOST_DEVICE double MCGIDI::Probabilities::WeightedFunctionals2d::evaluate ( double a_x2,
double a_x1 ) const

Definition at line 2306 of file MCGIDI_functions.cc.

2306 {
2307
2308 std::size_t n1 = m_weight.size( );
2309 double evaluatedValue = 0;
2310
2311 for( std::size_t i1 = 0; i1 < n1; ++i1 ) {
2312 evaluatedValue += m_weight[i1]->evaluate( a_x2 ) * m_energy[i1]->evaluate( a_x2, a_x1 );
2313 }
2314 return( evaluatedValue );
2315}

◆ sample()

template<typename RNG>
LUPI_HOST_DEVICE double MCGIDI::Probabilities::WeightedFunctionals2d::sample ( double a_x2,
double a_rngValue,
RNG && a_rng ) const

Definition at line 2096 of file MCGIDI_headerSource.hpp.

2096 {
2097/*
2098c This routine assumes that the weights sum to 1.
2099*/
2100 std::size_t i1;
2101 std::size_t n1 = m_weight.size( ) - 1; // Take last point if others do not add to randomWeight.
2102 double randomWeight = a_rng( ), cumulativeWeight = 0.;
2103
2104 for( i1 = 0; i1 < n1; ++i1 ) {
2105 cumulativeWeight += m_weight[i1]->evaluate( a_x2 );
2106 if( cumulativeWeight >= randomWeight ) break;
2107 }
2108 return( m_energy[i1]->sample( a_x2, a_rngValue, a_rng) );
2109}
LUPI_HOST_DEVICE double sample(double a_x2, double a_rngValue, RNG &&a_rng) const

Referenced by sample().

◆ serialize()

LUPI_HOST_DEVICE void MCGIDI::Probabilities::WeightedFunctionals2d::serialize ( LUPI::DataBuffer & a_buffer,
LUPI::DataBuffer::Mode a_mode )

This method serializes this for broadcasting as needed for MPI and GPUs. The method can count the number of required bytes, pack this or unpack this depending on a_mode.

Parameters
a_buffer[in] The buffer to read or write data to depending on a_mode.
a_mode[in] Specifies the action of this method.

Definition at line 2325 of file MCGIDI_functions.cc.

2325 {
2326
2327 ProbabilityBase2d::serialize( a_buffer, a_mode );
2328
2329 std::size_t vectorSize = m_weight.size( );
2330 int vectorSizeInt = (int) vectorSize;
2331 DATA_MEMBER_INT( vectorSizeInt, a_buffer, a_mode );
2332 vectorSize = (std::size_t) vectorSizeInt;
2333 if( a_mode == LUPI::DataBuffer::Mode::Unpack ) m_weight.resize( vectorSize, &a_buffer.m_placement );
2334 if( a_mode == LUPI::DataBuffer::Mode::Memory ) a_buffer.m_placement += m_weight.internalSize();
2335 for( std::size_t vectorIndex = 0; vectorIndex < vectorSize; ++vectorIndex ) {
2336 m_weight[vectorIndex] = serializeFunction1d_d1( a_buffer, a_mode, m_weight[vectorIndex] );
2337 }
2338
2339 vectorSize = m_energy.size( );
2340 vectorSizeInt = (int) vectorSize;
2341 DATA_MEMBER_INT( vectorSizeInt, a_buffer, a_mode );
2342 vectorSize = (std::size_t) vectorSizeInt;
2343 if( a_mode == LUPI::DataBuffer::Mode::Unpack ) m_energy.resize( vectorSize, &a_buffer.m_placement );
2344 if( a_mode == LUPI::DataBuffer::Mode::Memory ) a_buffer.m_placement += m_energy.internalSize();
2345 for( std::size_t vectorIndex = 0; vectorIndex < vectorSize; ++vectorIndex ) {
2346 m_energy[vectorIndex] = serializeProbability2d_d1( a_buffer, a_mode, m_energy[vectorIndex] );
2347 }
2348}
#define DATA_MEMBER_INT( member, buf, mode)
LUPI_HOST_DEVICE void serialize(LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
LUPI_HOST_DEVICE Probabilities::ProbabilityBase2d_d1 * serializeProbability2d_d1(LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode, Probabilities::ProbabilityBase2d_d1 *a_probability2d)
LUPI_HOST_DEVICE Functions::Function1d_d1 * serializeFunction1d_d1(LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode, Functions::Function1d_d1 *a_function1d)

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