Geant4
11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
PoPI_nucleus.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 <stdlib.h>
11
#include <stdexcept>
12
13
#include "
PoPI.hpp
"
14
15
namespace
PoPI
{
16
17
#define PoPI_energyChars "energy"
18
19
/*! \class Nucleus
20
* This class represents **PoPs** nucleus instance.
21
*/
22
23
/* *********************************************************************************************************/
/**
24
* Constructor that parses an **HAPI** instance to create a **PoPs** nucleus node.
25
*
26
* @param a_node [in] The **HAPI::Node** to be parsed.
27
* @param a_DB [in] The **PoPI::Database:: instance to add the constructed **Nucleus** to.
28
* @param a_nuclide [in] This nuclide instance that will contain *this*.
29
***********************************************************************************************************/
30
31
Nucleus::Nucleus
(
HAPI::Node
const
&a_node,
Database
*a_DB,
Nuclide
*a_nuclide ) :
32
Particle
( a_node,
Particle_class
::
nucleus
,
PoPI_nucleusChars
, -1 ),
33
m_nuclide( a_nuclide ),
34
m_Z( a_nuclide->
Z
( ) ),
35
m_A( a_nuclide->
A
( ) ),
36
m_levelName( a_node.attribute(
PoPI_indexChars
).value( ) ),
// The string version of m_levelIndex.
37
m_levelIndex( a_node.attribute(
PoPI_indexChars
).as_int( ) ),
// The int version of m_levelName.
38
m_energy( a_node.child(
PoPI_energyChars
) ) {
39
40
if
( a_node.
empty
( ) )
throw
Exception
(
"nuclide is missing nucleus"
);
41
42
int
sign = (
isAnti
( ) ? -1 : 1 );
43
setIntid( sign * ( 1000 * ( 1000 * (
levelIndex
( ) + 500) +
Z
( ) ) +
A
( ) ) );
44
45
addToDatabase
( a_DB );
46
}
47
48
/* *********************************************************************************************************/
/**
49
***********************************************************************************************************/
50
51
Nucleus::~Nucleus
( ) {
52
53
}
54
55
/* *********************************************************************************************************/
/**
56
* Returns the atomic ID of the parent nuclide.
57
*
58
* @return The atomic ID of the parent nuclide.
59
***********************************************************************************************************/
60
61
std::string
const
&
Nucleus::atomsID
(
void
)
const
{
62
63
return
( m_nuclide->atomsID( ) );
64
}
65
66
/* *********************************************************************************************************/
/**
67
* Returns the mass of the nucleus in units of *a_unit*. Currently not fully implement and does not support *a_unit*.
68
*
69
* @param a_unit [in] The unit to return the mass in.
70
*
71
* @return The mass in unit of *a_unit*.
72
***********************************************************************************************************/
73
74
double
Nucleus::massValue
(
char
const
*a_unit )
const
{
75
76
if
(
mass
( ).size( ) > 0 ) {
77
PQ_double
const
*pq_mass =
dynamic_cast<
PQ_double
const
*
>
(
mass
( )[0] );
78
79
if
( pq_mass ==
nullptr
)
throw
Exception
(
"Particle does not have a PoPI::PQ_double mass."
);
80
return
( pq_mass->
value
( a_unit ) );
81
}
82
83
// FIXME: still need to correct for electron masses and binding energy. Currently, an approximation is done.
84
double
bindingEnergy = 0.0;
85
if
( m_Z == 1 ) {
86
bindingEnergy = 13.5981e-6; }
87
else
if
( m_Z == 2 ) {
88
bindingEnergy = 79.005e-6;
89
}
90
91
return
( m_nuclide->massValue( a_unit ) - ( m_Z *
PoPI_electronMass_MeV_c2
- bindingEnergy ) /
PoPI_AMU2MeV_c2
);
92
}
93
94
/* *********************************************************************************************************/
/**
95
* Returns the excitation energy of the nucleus in units of *a_unit*. Currently not fully implement and does not support *a_unit*.
96
*
97
* @param a_unit [in] The unit to return the mass in.
98
*
99
* @return The mass in unit of *a_unit*.
100
***********************************************************************************************************/
101
102
double
Nucleus::energy
( std::string
const
&a_unit )
const
{
103
104
if
( m_energy.size( ) == 0 ) {
105
if
( m_levelIndex != 0 )
106
std::cerr << std::endl <<
"Particle "
<<
ID
( ) <<
" missing energy node, please report to PoPs maintainer. Using 0.0 and continuing."
<< std::endl;
107
return
( 0.0 );
108
}
109
PQ_double
*pq =
static_cast<
PQ_double
*
>
( m_energy[0] );
110
if
( pq->
unit
( ) ==
"eV"
)
return
( pq->
value
( ) * 1e-6 );
// Kludge until units are functional.
111
return
( pq->
value
( a_unit ) );
112
}
113
114
/* *********************************************************************************************************/
/**
115
* Returns the index attribute.
116
***********************************************************************************************************/
117
118
std::string
Nucleus::toXMLListExtraAttributes
(
void
)
const
{
119
120
return
( std::string(
" index=\""
+ m_levelName +
"\""
) );
121
}
122
123
/* *********************************************************************************************************/
/**
124
* Added the *m_energy* stuff to *a_XMLList*.
125
*
126
* @param a_XMLList [in] The list to add an XML output representation of *this* to.
127
* @param a_indent1 [in] The amount of indentation to added to each line added to *a_XMLList*.
128
***********************************************************************************************************/
129
130
void
Nucleus::toXMLListExtraElements
( std::vector<std::string> &a_XMLList, std::string
const
&a_indent1 )
const
{
131
132
m_energy.toXMLList( a_XMLList, a_indent1 );
133
}
134
135
}
PoPI.hpp
PoPI_AMU2MeV_c2
#define PoPI_AMU2MeV_c2
Definition
PoPI.hpp:30
PoPI_electronMass_MeV_c2
#define PoPI_electronMass_MeV_c2
Definition
PoPI.hpp:31
PoPI_nucleusChars
#define PoPI_nucleusChars
Definition
PoPI.hpp:50
PoPI_indexChars
#define PoPI_indexChars
Definition
PoPI.hpp:91
PoPI_energyChars
#define PoPI_energyChars
Definition
PoPI_nucleus.cc:17
HAPI::Node
Definition
HAPI.hpp:166
HAPI::Node::empty
bool empty() const
Definition
HAPI_Node.cc:150
PoPI::Base::Nucleus
friend Nucleus
Definition
PoPI.hpp:678
PoPI::Base::ID
std::string const & ID(void) const
Definition
PoPI.hpp:652
PoPI::Database
Definition
PoPI.hpp:1128
PoPI::Exception
Definition
PoPI.hpp:195
PoPI::IDBase::addToDatabase
std::size_t addToDatabase(Database *a_DB)
Definition
PoPI_base.cc:95
PoPI::Nucleus::atomsID
std::string const & atomsID(void) const
Definition
PoPI_nucleus.cc:61
PoPI::Nucleus::levelIndex
int levelIndex(void) const
Definition
PoPI.hpp:978
PoPI::Nucleus::A
int A(void) const
Definition
PoPI.hpp:976
PoPI::Nucleus::Z
int Z(void) const
Definition
PoPI.hpp:975
PoPI::Nucleus::~Nucleus
virtual ~Nucleus()
Definition
PoPI_nucleus.cc:51
PoPI::Nucleus::toXMLListExtraElements
virtual void toXMLListExtraElements(std::vector< std::string > &a_XMLList, std::string const &a_indent1) const
Definition
PoPI_nucleus.cc:130
PoPI::Nucleus::energy
PQ_suite const & energy(void) const
Definition
PoPI.hpp:982
PoPI::Nucleus::massValue
double massValue(char const *a_unit) const
Definition
PoPI_nucleus.cc:74
PoPI::Nucleus::toXMLListExtraAttributes
virtual std::string toXMLListExtraAttributes(void) const
Definition
PoPI_nucleus.cc:118
PoPI::Nuclide
Definition
PoPI.hpp:994
PoPI::PQ_double
Definition
PoPI.hpp:432
PoPI::PQ_double::value
double value(void) const
Definition
PoPI.hpp:443
PoPI::Particle::Particle
Particle(HAPI::Node const &a_node, Particle_class a_class, std::string const &a_family, int a_hasNucleus=0)
Definition
PoPI_particle.cc:25
PoPI::Particle::mass
virtual PQ_suite const & mass(void) const
Definition
PoPI.hpp:878
PoPI::Particle::isAnti
bool isAnti() const
Definition
PoPI.hpp:875
PoPI::PhysicalQuantity::unit
std::string const & unit(void) const
Definition
PoPI.hpp:420
PoPI
Definition
PoPI.hpp:28
PoPI::Particle_class
Particle_class
Definition
PoPI.hpp:58
PoPI::Particle_class::nucleus
@ nucleus
Definition
PoPI.hpp:59
geant4-v11.4.0
source
processes
hadronic
models
lend
src
PoPI_nucleus.cc
Generated by
1.16.1