Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
lPoPs.cc File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "PoPs.h"
#include "PoPs_mass.h"

Go to the source code of this file.

Classes

struct  ZLabels
 

Functions

int lPoPs_addParticleIfNeeded (statusMessageReporting *smr, char const *name, char const *special)
 

Function Documentation

◆ lPoPs_addParticleIfNeeded()

int lPoPs_addParticleIfNeeded ( statusMessageReporting * smr,
char const * name,
char const * special )

Definition at line 36 of file lPoPs.cc.

36 {
37
38 int index = PoPs_particleIndex( name ), ZA, Z = 0, A = 0,/* level = 0,*/ ispecial;
39 char *endptr, name_[256], AStr[32];
40 char const *ZStr, *alias = NULL;
41 PoP *pop, *pop_;
42 /* enum PoPs_genre genre = PoPs_genre_unknown; */
43 char const *yiNames[] = { "p", "h2", "h3", "he3", "he4", "photon" };
44 char const *yiAliases[] = { "h1", "d", "t", "he3", "a", "g" };
45 /* enum PoPs_genre yiGenres[] = { PoPs_genre_baryon, PoPs_genre_nucleus, PoPs_genre_nucleus, PoPs_genre_nucleus,
46 PoPs_genre_nucleus, PoPs_genre_photon }; */
47
48 if( special == NULL ) special = "";
49 if( index < 0 ) {
50 if( isdigit( name[0] ) ) {
51 ZA = (int) strtol( name, &endptr, 10 );
52 if( *endptr != 0 ) {
53 smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badName, "string '%s' not a value ZA", name );
54 return( -1 );
55 }
56 Z = ZA / 1000;
57 A = ZA % 1000;
58 /*level = 0;*/
59 ispecial = 0;
60 if( strcmp( special, "LLNL" ) == 0 ) {
61 if( ( ZA > 1 ) && ( ZA < 8 ) ) {
62 strcpy( name_, yiNames[ZA-2] );
63 alias = yiAliases[ZA-2];
64 /* genre = yiGenres[ZA-2];*/
65 ispecial = 1; }
66 else if( ( ZA == 1801 ) || ( ZA == 1901 ) ) {
67 strcpy( name_, yiNames[0] );
68 alias = yiAliases[0];
69 /* genre = yiGenres[0]; */
70 ispecial = 1; }
71 else if( ZA == 1902 ) {
72 strcpy( name_, yiNames[1] );
73 alias = yiAliases[1];
74 /* genre = yiGenres[1]; */
75 ispecial = 1; }
76 else if( ZA == 4809 ) {
77 strcpy( name_, "Be9" );
78 /* genre = PoPs_genre_atom; */
79 ispecial = 1; }
80 else if( ZA == 4909 ) {
81 strcpy( name_, "Be9" );
82 /* genre = PoPs_genre_atom; */
83 ispecial = 1; }
84 else if( ZA == 6912 ) {
85 strcpy( name_, "C12" );
86 /* genre = PoPs_genre_atom; */
87 ispecial = 1; }
88 else if( ZA == 8916 ) {
89 strcpy( name_, "O16" );
90 /* genre = PoPs_genre_atom; */
91 ispecial = 1; }
92 else if( ZA == 95242 ) {
93 strcpy( name_, "Am242_e2" );
94 /*level = 2;*/
95 /* genre = PoPs_genre_atom; */
96 ispecial = 1; }
97 else if( Z == 99 ) {
98 if( ( 120 <= A ) && ( A < 126 ) ) {
99 snprintf( name_, sizeof name_, "FissionProductENDL99%d", A );
100 /* genre = PoPs_genre_atom; */
101 ispecial = 1;
102 }
103 }
104 }
105 if( ispecial == 0 ) {
106 if( ZA == 1 ) {
107 AStr[0] = 0; }
108 else if( A == 0 ) {
109 strcpy( AStr, "_natural" ); }
110 else {
111 snprintf( AStr, sizeof AStr, "%d", A );
112 }
113 if( ( ZStr = lPoPs_ZSymbol( Z ) ) == NULL ) {
114 smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badName, "string '%s' not a value ZA; Z = %d is not supported", name, Z );
115 return( -1 );
116 }
117 snprintf( name_, sizeof name_, "%s%s", ZStr, AStr );
118 /* genre = PoPs_genre_atom; */
119 /* if( ZA == 1 ) genre = PoPs_genre_baryon; */
120 } }
121 else {
122 strcpy( name_, name );
123 ZA = -1;
124 if( strcmp( name, "neutron" ) == 0 ) {
125 strcpy( name_, "n" );
126 alias = name;
127 /* genre = PoPs_genre_baryon; */ }
128 else if( strcmp( name, "electron" ) == 0 ) {
129 strcpy( name_, "e-" );
130 alias = name;
131 /* genre = PoPs_genre_lepton; */ }
132 else if( strcmp( name, "positron" ) == 0 ) {
133 strcpy( name_, "e+" );
134 alias = name;
135 /* genre = PoPs_genre_lepton; */ }
136 else if( ( strcmp( name, "h1" ) == 0 ) || ( strcmp( name, "proton" ) == 0 ) ) {
137 ZA = 2; }
138 else if( ( strcmp( name, "d" ) == 0 ) || ( strcmp( name, "deuteron" ) == 0 ) ) {
139 ZA = 3; }
140 else if( ( strcmp( name, "t" ) == 0 ) || ( strcmp( name, "triton" ) == 0 ) ) {
141 ZA = 4; }
142 else if( strcmp( name, "helium3" ) == 0 ) {
143 ZA = 5; }
144 else if( ( strcmp( name, "a" ) == 0 ) || ( strcmp( name, "alpha" ) == 0 ) || ( strcmp( name, "helium4" ) == 0 ) ) {
145 ZA = 6; }
146 else if( ( strcmp( name, "g" ) == 0 ) || ( strcmp( name, "gamma" ) == 0 ) ) {
147 ZA = 7; }
148 else if( strcmp( name, "FP" ) == 0 ) {
149 strcpy( name_, "FissionProductENDL99120" );
150 /* genre = PoPs_genre_atom; */
151 }
152 if( ZA != -1 ) {
153 strcpy( name_, yiNames[ZA-2] );
154 alias = name;
155 /* genre = yiGenres[ZA-2]; */
156 }
157 }
158
159 if( ( pop = PoPs_particleCreateLoadInfo( smr, name_ ) ) == NULL ) {
160 smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badName, "particle '%s' converted to name '%s' not in database", name, name_ );
161 return( -1 );
162 }
163 if( ( pop_ = PoPs_addParticleIfNeeded( smr, pop ) ) != pop ) PoP_free( pop ); /* Still need to add alias as index was < 0. */
164 index = pop_->index;
165
166 if( PoPs_particleIndex( name ) < 0 ) {
167 if( ( pop = PoP_makeAlias( smr, name_, name ) ) == NULL ) return( -1 );
168 if( ( pop_ = PoPs_addParticleIfNeeded( smr, pop ) ) != pop ) return( -1 ); /* pop_ should be pop as index was < 0. */
169 }
170
171 if( alias != NULL ) {
172 if( PoPs_particleIndex( alias ) < 0 ) {
173 if( ( pop = PoP_makeAlias( smr, name_, alias ) ) == NULL ) return( -1 );
174 if( ( pop_ = PoPs_addParticleIfNeeded( smr, pop ) ) != pop ) return( -1 ); /* Required for some yis. */
175 }
176 }
177 }
178 return( index );
179}
const G4double A[17]
@ PoPs_errorToken_badName
Definition PoPs.h:35
int PoPs_particleIndex(char const *name)
Definition PoPs.cc:204
PoP * PoPs_particleCreateLoadInfo(statusMessageReporting *smr, const char *name)
Definition PoPs_data.cc:61
PoP * PoP_makeAlias(statusMessageReporting *smr, char const *name, char const *alias)
Definition PoPs.cc:647
int PoPs_smr_ID
Definition PoPs.cc:35
PoP * PoPs_addParticleIfNeeded(statusMessageReporting *smr, PoP *pop)
Definition PoPs.cc:113
PoP * PoP_free(PoP *pop)
Definition PoPs.cc:558
const char * name(G4int ptype)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
Definition PoPs.h:45
int index
Definition PoPs.h:46

Referenced by MCGIDI_map_findAllOfTarget(), MCGIDI_map_findTarget(), MCGIDI_map_initialize(), MCGIDI_POPs_addParticleIfNeeded(), and PoPs_particleReadDatabase().