Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
MCGIDI_nuclideGammaBranching.cc
Go to the documentation of this file.
1/*
2# <<BEGIN-copyright>>
3# Copyright 2019, Lawrence Livermore National Security, LLC.
4# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
5# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
6# SPDX-License-Identifier: MIT
7# <<END-copyright>>
8*/
9
10#include <string.h>
11#include <iomanip>
12
13#include "MCGIDI.hpp"
14
15namespace MCGIDI {
16
17/*
18============================================================
19================== NuclideGammaBranchInfo ==================
20============================================================
21*/
22
23/* *********************************************************************************************************//**
24 ***********************************************************************************************************/
25
27 m_probability( 0.0 ),
28 m_photonEmissionProbability( 0.0 ),
29 m_gammaEnergy( 0.0 ),
30 m_residualStateIndex( -1 ),
31 m_residualStateKindIsContinuum( false ) {
32
33}
34
35/* *********************************************************************************************************//**
36 ***********************************************************************************************************/
37
39 std::map<std::string, int> &a_stateNamesToIndices, bool a_makePhotonEmissionProbabilitiesOne ) :
40 m_probability( a_nuclideGammaBranchInfo.probability( ) ),
41 m_photonEmissionProbability( a_nuclideGammaBranchInfo.photonEmissionProbability( ) ),
42 m_gammaEnergy( a_nuclideGammaBranchInfo.gammaEnergy( ) ),
43 m_residualStateIndex( -1 ),
44 m_residualStateKindIsContinuum( false ) {
45
46 if( a_makePhotonEmissionProbabilitiesOne ) m_photonEmissionProbability = 1.0;
47 std::map<std::string,int>::iterator iter = a_stateNamesToIndices.find( a_nuclideGammaBranchInfo.residualState( ) );
48 if( iter != a_stateNamesToIndices.end( ) ) m_residualStateIndex = iter->second;
49}
50
51/* *********************************************************************************************************//**
52 * This method serializes *this* for broadcasting as needed for MPI and GPUs. The method can count the number of required
53 * bytes, pack *this* or unpack *this* depending on *a_mode*.
54 *
55 * @param a_buffer [in] The buffer to read or write data to depending on *a_mode*.
56 * @param a_mode [in] Specifies the action of this method.
57 ***********************************************************************************************************/
58
60
61 DATA_MEMBER_DOUBLE( m_probability, a_buffer, a_mode );
62 DATA_MEMBER_DOUBLE( m_photonEmissionProbability, a_buffer, a_mode );
63 DATA_MEMBER_DOUBLE( m_gammaEnergy, a_buffer, a_mode );
64 DATA_MEMBER_INT( m_residualStateIndex, a_buffer, a_mode );
65 DATA_MEMBER_CAST( m_residualStateKindIsContinuum, a_buffer, a_mode, bool );
66}
67
68/* *********************************************************************************************************//**
69 * Print to *std::cout* the content of *this*. This is mainly meant for debugging.
70 *
71 * @param a_protareSingle [in] The ProtareSingle instance *this* resides in.
72 * @param a_indent [in] The buffer to read or write data to depending on *a_mode*.
73 * @param a_iFormat [in] C printf format specifier for any interger that is printed (e.g., "%3d").
74 * @param a_energyFormat [in] C printf format specifier for any interger that is printed (e.g., "%20.12e").
75 * @param a_dFormat [in] C printf format specifier for any interger that is printed (e.g., "%14.7e").
76 ***********************************************************************************************************/
77LUPI_HOST void NuclideGammaBranchInfo::print( LUPI_maybeUnused ProtareSingle const *a_protareSingle, std::string const &a_indent, std::string const &a_iFormat,
78 LUPI_maybeUnused std::string const &a_energyFormat, std::string const &a_dFormat ) const {
79
80 std::cout << a_indent << std::left << std::setw( 17 ) << LUPI::Misc::argumentsToString( a_dFormat.c_str( ), m_probability )
81 << LUPI::Misc::argumentsToString( a_dFormat.c_str( ), m_photonEmissionProbability )
82 << LUPI::Misc::argumentsToString( a_dFormat.c_str( ), m_gammaEnergy )
83 << LUPI::Misc::argumentsToString( a_iFormat.c_str( ), m_residualStateIndex ) << std::endl;
84}
85
86/*
87============================================================
88============== NuclideGammaBranchStateInfo =================
89============================================================
90*/
91
92/* *********************************************************************************************************//**
93 ***********************************************************************************************************/
94
96 m_intid( -1 ),
97 m_nuclearLevelEnergy( 0.0 ),
98 m_nuclearLevelEnergyWidth( 0.0 ),
99 m_multiplicity( 0.0 ),
100 m_averageGammaEnergy( 0.0 ) {
101
102 m_state[0] = 0;
103}
104
105/* *********************************************************************************************************//**
106 ***********************************************************************************************************/
107
109 std::vector<NuclideGammaBranchInfo *> &a_nuclideGammaBranchInfos,
110 std::map<std::string, int> &a_stateNamesToIndices, bool a_makePhotonEmissionProbabilitiesOne,
111 bool a_zeroNuclearLevelEnergyWidth ) :
112 m_intid( a_nuclideGammaBranchingInfo.intid( ) ),
113 m_nuclearLevelEnergy( a_nuclideGammaBranchingInfo.nuclearLevelEnergy( ) ),
114 m_nuclearLevelEnergyWidth( a_nuclideGammaBranchingInfo.nuclearLevelEnergyWidth( ) ),
115 m_multiplicity( a_nuclideGammaBranchingInfo.multiplicity( ) ),
116 m_averageGammaEnergy( a_nuclideGammaBranchingInfo.averageGammaEnergy( ) ) {
117
118 if( a_zeroNuclearLevelEnergyWidth ) m_nuclearLevelEnergyWidth = 0.0;
119
120 strncpy( m_state, a_nuclideGammaBranchingInfo.state( ).c_str( ), sizeof( m_state ) );
121 m_state[sizeof( m_state )-1] = 0;
122
123 std::vector<PoPI::NuclideGammaBranchInfo> const &branches = a_nuclideGammaBranchingInfo.branches( );
124 m_branchIndices.reserve( branches.size( ) );
125
126 for( std::size_t i1 = 0; i1 < branches.size( ); ++i1 ) {
127 m_branchIndices.push_back( a_nuclideGammaBranchInfos.size( ) );
128 a_nuclideGammaBranchInfos.push_back( new NuclideGammaBranchInfo( branches[i1], a_stateNamesToIndices, a_makePhotonEmissionProbabilitiesOne ) );
129 }
130}
131
132/* *********************************************************************************************************//**
133 * This method serializes *this* for broadcasting as needed for MPI and GPUs. The method can count the number of required
134 * bytes, pack *this* or unpack *this* depending on *a_mode*.
135 *
136 * @param a_buffer [in] The buffer to read or write data to depending on *a_mode*.
137 * @param a_mode [in] Specifies the action of this method.
138 ***********************************************************************************************************/
139
141
142 DATA_MEMBER_CHAR_ARRAY( m_state, a_buffer, a_mode );
143 DATA_MEMBER_INT( m_intid, a_buffer, a_mode );
144 DATA_MEMBER_DOUBLE( m_nuclearLevelEnergy, a_buffer, a_mode );
145 DATA_MEMBER_DOUBLE( m_nuclearLevelEnergyWidth, a_buffer, a_mode );
146 DATA_MEMBER_DOUBLE( m_multiplicity, a_buffer, a_mode );
147 DATA_MEMBER_DOUBLE( m_averageGammaEnergy, a_buffer, a_mode );
148 DATA_MEMBER_VECTOR_SIZE_T( m_branchIndices, a_buffer, a_mode );
149}
150
151/* *********************************************************************************************************//**
152 * Print to *std::cout* the content of *this*. This is mainly meant for debugging.
153 *
154 * @param a_protareSingle [in] The ProtareSingle instance *this* resides in.
155 * @param a_indent [in] The buffer to read or write data to depending on *a_mode*.
156 * @param a_iFormat [in] C printf format specifier for any interger that is printed (e.g., "%3d").
157 * @param a_energyFormat [in] C printf format specifier for any interger that is printed (e.g., "%20.12e").
158 * @param a_dFormat [in] C printf format specifier for any interger that is printed (e.g., "%14.7e").
159 ***********************************************************************************************************/
160LUPI_HOST void NuclideGammaBranchStateInfo::print( LUPI_maybeUnused ProtareSingle const *a_protareSingle, std::string const &a_indent, std::string const &a_iFormat,
161 LUPI_maybeUnused std::string const &a_energyFormat, std::string const &a_dFormat ) const {
162
163 std::cout << a_indent << std::left << std::setw( 17 ) << m_state << LUPI::Misc::argumentsToString( a_dFormat.c_str( ), m_multiplicity ) <<
164 LUPI::Misc::argumentsToString( a_dFormat.c_str( ), m_averageGammaEnergy );
165 for( auto branchIter = m_branchIndices.begin( ); branchIter != m_branchIndices.end( ); ++branchIter ) {
166 std::cout << LUPI::Misc::argumentsToString( a_iFormat.c_str( ), (*branchIter) );
167 }
168 std::cout << std::endl;
169}
170
171}
#define DATA_MEMBER_CAST(member, buf, mode, someType)
#define DATA_MEMBER_VECTOR_SIZE_T(member, buf, mode)
#define DATA_MEMBER_CHAR_ARRAY(member, buf, mode)
#define DATA_MEMBER_DOUBLE(member, buf, mode)
#define DATA_MEMBER_INT( member, buf, mode)
#define LUPI_HOST_DEVICE
#define LUPI_HOST
#define LUPI_maybeUnused
LUPI_HOST_DEVICE double probability() const
Definition MCGIDI.hpp:952
LUPI_HOST_DEVICE void serialize(LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
LUPI_HOST void print(ProtareSingle const *a_protareSingle, std::string const &a_indent, std::string const &a_iFormat, std::string const &a_energyFormat, std::string const &a_dFormat) const
LUPI_HOST_DEVICE double gammaEnergy() const
Definition MCGIDI.hpp:954
LUPI_HOST_DEVICE double photonEmissionProbability() const
Definition MCGIDI.hpp:953
LUPI_HOST void print(ProtareSingle const *a_protareSingle, std::string const &a_indent, std::string const &a_iFormat, std::string const &a_energyFormat, std::string const &a_dFormat) const
LUPI_HOST_DEVICE void serialize(LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode)
LUPI_HOST_DEVICE double nuclearLevelEnergy() const
Definition MCGIDI.hpp:988
LUPI_HOST_DEVICE double averageGammaEnergy() const
Definition MCGIDI.hpp:992
LUPI_HOST_DEVICE double multiplicity() const
Definition MCGIDI.hpp:991
LUPI_HOST_DEVICE int intid() const
Definition MCGIDI.hpp:987
LUPI_HOST_DEVICE double nuclearLevelEnergyWidth() const
Definition MCGIDI.hpp:989
std::string const & residualState() const
Definition PoPI.hpp:564
std::string const & state() const
Definition PoPI.hpp:589
std::vector< NuclideGammaBranchInfo > const & branches() const
Definition PoPI.hpp:600
std::string argumentsToString(char const *a_format,...)
Definition LUPI_misc.cc:305
Simple C++ string class, useful as replacement for std::string if this cannot be used,...
Definition MCGIDI.hpp:43