Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
PoPI_intId.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 <climits>
11#include <PoPI.hpp>
12
13namespace PoPI {
14
15/* *********************************************************************************************************//**
16 * Returns an integer representing the particle's famuly *a_family*.
17 *
18 * @param a_isAnti [in] If **true** particle is an anti-particle and otherwise its a particle.
19 ***********************************************************************************************************/
20
22
23 if( a_family == Particle_class::nucleus ) return( -1 );
24 if( a_family == Particle_class::nuclide ) return( -2 );
25 if( a_family == Particle_class::gaugeBoson ) return( 0 );
26 if( a_family == Particle_class::lepton ) return( 1 );
27 if( a_family == Particle_class::baryon ) return( 2 );
28 if( a_family == Particle_class::nuclideMetaStable ) return( 50 );
29 if( a_family == Particle_class::nucleusMetaStable ) return( 60 );
30 if( a_family == Particle_class::ENDL_fissionProduct ) return( 99 );
31
32 return( -3 );
33}
34
35/* *********************************************************************************************************//**
36 * This function is for internal use.
37 * Returns the intid for the particle of family *a_family* with family indentifier *a_SSSSSSS*. If the return value is -1
38 * the family is not supported by this function.
39 *
40 * @param a_isAnti [in] If **true** particle is an anti-particle and otherwise its a particle.
41 * @param a_family [in] The particle's family.
42 * @param a_SSSSSSS [in] The particle's indentifier within its family.
43 *
44 * @return The intid for the particle.
45 ***********************************************************************************************************/
46
47int intidHelper( bool a_isAnti, Particle_class a_family, int a_SSSSSSS ) {
48
49 int sign = a_isAnti ? -1 : 1;
50
51 int intid = family2Integer( a_family );
52 if( intid < 0 ) return( -1 );
53 intid += 100;
54 intid *= 10000000;
55
56 return( sign * ( intid + a_SSSSSSS ) );
57}
58
59/*! \class ParseIntidInfo
60 * This class represents **PoPs** nucleus instance.
61 */
62
63/* *********************************************************************************************************//**
64 * Constructor that parses *a_intid* into its components and sets members per *a_intid*. If *m_III*, *m_ZZZ*, *m_AAA* and
65 * *m_metaStableIndex* are positive (greater than or equal to 0), then the particle is a nuclear particle and
66 * *m_isNuclear* is *true*, otherwise the particle is not a nuclear particle and *m_isNuclear* is *false*.
67 * Note, even if *m_metaStableIndex* > 0 (i.e., particle is a nuclear meta-stable), *m_III* is as expected. For
68 * example, for intid = 481095242, *m_metaStableIndex* is 1 and *m_III* is 481.
69 *
70 * If *m_family* is **Particle_class::unknown** then all other members are undefined.
71 *
72 * @param a_intid [in] The intid for the particle to parse.
73 * @param a_GRIN_mode [in] For the GRIN project, nuclear levels go beyond 499, so this flag causes III >= 500 to be treated as a nuclide.
74 ***********************************************************************************************************/
75
76ParseIntidInfo::ParseIntidInfo( int a_intid, bool a_GRIN_mode ) :
77 m_intid( a_intid ),
78 m_family( Particle_class::unknown ),
79 m_isAnti( a_intid < 0 ),
80 m_isNuclear( false ),
81 m_AAA( -1 ),
82 m_ZZZ( -1 ),
83 m_III( -1 ),
84 m_nuclearLevelIndex( -1 ),
85 m_metaStableIndex( -1 ),
86 m_generation( -1 ),
87 m_isNeutrino( false ),
88 m_baryonGroup( -1 ),
89 m_baryonId( -1 ),
90 m_familyId( -1 ) {
91
92 int intidAbs = std::abs( a_intid );
93
94 bool nuclearLike = intidAbs / 1000000000 == 0;
95 int family = (intidAbs / 10000000) % 100;
96 int SSSSSSS = intidAbs % 10000000;
97
98 if( nuclearLike ) {
99 m_AAA = intidAbs % 1000;
100 m_ZZZ = intidAbs % 1000000 / 1000;
101 m_III = intidAbs % 1000000000 / 1000000;
102
103 m_nuclearLevelIndex = m_III;
104 if( ( m_III < 500 ) || a_GRIN_mode ) {
105 m_family = Particle_class::nuclide; }
106 else {
107 m_nuclearLevelIndex -= 500;
108 m_family = Particle_class::nucleus;
109 } }
110 else {
111 int topFamilyDigid = family / 10;
112 if( ( topFamilyDigid == 5 ) || ( topFamilyDigid == 6 ) ) {
114 m_AAA = intidAbs % 1000;
115 m_ZZZ = intidAbs % 1000000 / 1000;
116 m_metaStableIndex = intidAbs % 100000000 / 1000000; }
117 else {
118 m_familyId = SSSSSSS;
119 if( family == 0 ) {
120 m_family = Particle_class::gaugeBoson; }
121 else if( family == 1 ) {
122 int neutronoFlag = ( SSSSSSS % 100 ) / 10;
123 if( neutronoFlag > 1 ) return; // Invalid particle.
124
125 m_family = Particle_class::lepton;
126 m_generation = SSSSSSS % 10;
127 m_isNeutrino = neutronoFlag != 0; }
128 else if( family == 2 ) {
129 m_family = Particle_class::baryon;
130 m_baryonGroup = SSSSSSS / 1000000;
131 m_baryonId = SSSSSSS % 1000000; }
132 else if( family == 98 ) {
133 m_family = Particle_class::TNSL; }
134 else if( family == 99 ) {
136 }
137 }
138 }
139}
140
141/* *********************************************************************************************************//**
142 * Returns the GNDS PoPs id for *this*. If particles is unknown, an empty string is returned.
143 *
144 ***********************************************************************************************************/
145
146std::string ParseIntidInfo::id( ) {
147
148 std::string pid;
149
150 if( ( m_family == Particle_class::nuclide ) || ( m_family == Particle_class::nucleus ) || ( m_family == Particle_class::nuclideMetaStable ) ||
151 ( m_family == Particle_class::nucleusMetaStable ) ) {
152 bool isNucleus = ( m_family == Particle_class::nucleus ) || ( m_family == Particle_class::nucleusMetaStable );
153 pid = chemicalElementInfoFromZ( m_ZZZ, true, isNucleus );
154 if( pid != "" ) {
155 pid += LUPI::Misc::argumentsToString( "%d", m_AAA );
156
157 if( ( m_family == Particle_class::nuclideMetaStable ) || ( m_family == Particle_class::nucleusMetaStable ) ) {
158 pid += LUPI::Misc::argumentsToString( "_m%d", m_metaStableIndex ); }
159 else {
160 int III = m_III;
161 if( m_family == Particle_class::nucleus ) III -= 500;
162 if( III != 0 ) pid += LUPI::Misc::argumentsToString( "_e%d", III );
163 }
164 } }
165 else if( m_family == Particle_class::gaugeBoson ) {
166 if( m_familyId == 0 ) pid = IDs::photon; }
167 else if( m_family == Particle_class::lepton ) {
168 if( m_generation == 0 ) {
169 if( !m_isNeutrino ) pid = IDs::electron;
170 } }
171 else if( m_family == Particle_class::baryon ) {
172 if( m_baryonGroup == 0 ) {
173 switch( m_baryonId ) {
174 case 0:
175 pid = IDs::neutron;
176 break;
177 case 1:
178 pid = IDs::proton;
179 break;
180 default:
181 break;
182 }
183 } }
184 else if( m_family == Particle_class::ENDL_fissionProduct ) {
185 if( m_familyId == 99120 ) {
187 else if( m_familyId == 99125 ) {
189 }
190 }
191
192 if( ( pid.size( ) > 0 ) && m_isAnti ) pid += IDs::anti;
193
194 return( pid );
195}
196
197}
ParseIntidInfo(int a_intid, bool a_GRIN_mode=false)
Definition PoPI_intId.cc:76
Particle_class family()
Definition PoPI.hpp:234
std::string argumentsToString(char const *a_format,...)
Definition LUPI_misc.cc:305
Definition PoPI.hpp:28
int intidHelper(bool a_isAnti, Particle_class a_family, int a_SSSSSSS)
Definition PoPI_intId.cc:47
std::string chemicalElementInfoFromZ(int a_Z, bool a_wantSymbol, bool a_asNucleus=false)
int family2Integer(Particle_class a_family)
Definition PoPI_intId.cc:21
Particle_class
Definition PoPI.hpp:58
static std::string const anti
Definition PoPI.hpp:173
static std::string const photon
Definition PoPI.hpp:162
static std::string const neutron
Definition PoPI.hpp:164
static std::string const FissionProductENDL99125
Definition PoPI.hpp:172
static std::string const FissionProductENDL99120
Definition PoPI.hpp:171
static std::string const proton
Definition PoPI.hpp:165
static std::string const electron
Definition PoPI.hpp:163