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 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/hadronic/models/lend/src/lPoPs.cc (Version 11.3.0) and /processes/hadronic/models/lend/src/lPoPs.cc (Version 10.5.p1)


  1 #include <stdio.h>                                  1 #include <stdio.h>
  2 #include <stdlib.h>                                 2 #include <stdlib.h>
  3 #include <string.h>                                 3 #include <string.h>
  4 #include <ctype.h>                                  4 #include <ctype.h>
  5                                                     5 
  6 #include "PoPs.h"                                   6 #include "PoPs.h"
  7 #include "PoPs_mass.h"                              7 #include "PoPs_mass.h"
  8                                                     8 
  9 #if defined __cplusplus                             9 #if defined __cplusplus
 10 namespace GIDI {                                   10 namespace GIDI {
 11 using namespace GIDI;                              11 using namespace GIDI;
 12 #endif                                             12 #endif
 13                                                    13 
 14 static struct ZLabels {                            14 static struct ZLabels {
 15     int Z;                                         15     int Z;
 16     char const *Symbol;                            16     char const *Symbol;
 17 } Zs[] = {  {   0,  "n" }, {   1,  "H" }, {        17 } Zs[] = {  {   0,  "n" }, {   1,  "H" }, {   2, "He" }, {   3, "Li" }, {   4, "Be" }, {   5,  "B" }, {   6,  "C" }, {   7,  "N" }, {   8,  "O" },
 18             {   9,  "F" }, {  10, "Ne" }, {  1     18             {   9,  "F" }, {  10, "Ne" }, {  11, "Na" }, {  12, "Mg" }, {  13, "Al" }, {  14, "Si" }, {  15,  "P" }, {  16,  "S" }, {  17, "Cl" },
 19             {  18, "Ar" }, {  19,  "K" }, {  2     19             {  18, "Ar" }, {  19,  "K" }, {  20, "Ca" }, {  21, "Sc" }, {  22, "Ti" }, {  23,  "V" }, {  24, "Cr" }, {  25, "Mn" }, {  26, "Fe" },
 20             {  27, "Co" }, {  28, "Ni" }, {  2     20             {  27, "Co" }, {  28, "Ni" }, {  29, "Cu" }, {  30, "Zn" }, {  31, "Ga" }, {  32, "Ge" }, {  33, "As" }, {  34, "Se" }, {  35, "Br" },
 21             {  36, "Kr" }, {  37, "Rb" }, {  3     21             {  36, "Kr" }, {  37, "Rb" }, {  38, "Sr" }, {  39,  "Y" }, {  40, "Zr" }, {  41, "Nb" }, {  42, "Mo" }, {  43, "Tc" }, {  44, "Ru" },
 22             {  45, "Rh" }, {  46, "Pd" }, {  4     22             {  45, "Rh" }, {  46, "Pd" }, {  47, "Ag" }, {  48, "Cd" }, {  49, "In" }, {  50, "Sn" }, {  51, "Sb" }, {  52, "Te" }, {  53,  "I" },
 23             {  54, "Xe" }, {  55, "Cs" }, {  5     23             {  54, "Xe" }, {  55, "Cs" }, {  56, "Ba" }, {  57, "La" }, {  58, "Ce" }, {  59, "Pr" }, {  60, "Nd" }, {  61, "Pm" }, {  62, "Sm" },
 24             {  63, "Eu" }, {  64, "Gd" }, {  6     24             {  63, "Eu" }, {  64, "Gd" }, {  65, "Tb" }, {  66, "Dy" }, {  67, "Ho" }, {  68, "Er" }, {  69, "Tm" }, {  70, "Yb" }, {  71, "Lu" },
 25             {  72, "Hf" }, {  73, "Ta" }, {  7     25             {  72, "Hf" }, {  73, "Ta" }, {  74,  "W" }, {  75, "Re" }, {  76, "Os" }, {  77, "Ir" }, {  78, "Pt" }, {  79, "Au" }, {  80, "Hg" },
 26             {  81, "Tl" }, {  82, "Pb" }, {  8     26             {  81, "Tl" }, {  82, "Pb" }, {  83, "Bi" }, {  84, "Po" }, {  85, "At" }, {  86, "Rn" }, {  87, "Fr" }, {  88, "Ra" }, {  89, "Ac" },
 27             {  90, "Th" }, {  91, "Pa" }, {  9     27             {  90, "Th" }, {  91, "Pa" }, {  92,  "U" }, {  93, "Np" }, {  94, "Pu" }, {  95, "Am" }, {  96, "Cm" }, {  97, "Bk" }, {  98, "Cf" },
 28             {  99, "Es" }, { 100, "Fm" }, { 10     28             {  99, "Es" }, { 100, "Fm" }, { 101, "Md" }, { 102, "No" }, { 103, "Lr" }, { 104, "Rf" }, { 105, "Db" }, { 106, "Sg" }, { 107, "Bh" },
 29             { 108, "Hs" }, { 109, "Mt" } };        29             { 108, "Hs" }, { 109, "Mt" } };
 30 static const int nZs = sizeof( Zs ) / sizeof(      30 static const int nZs = sizeof( Zs ) / sizeof( Zs[0] );
 31                                                    31 
 32 static char const *lPoPs_ZSymbol( int Z );         32 static char const *lPoPs_ZSymbol( int Z );
 33 /*                                                 33 /*
 34 ==============================================     34 ========================================================================
 35 */                                                 35 */
 36 int lPoPs_addParticleIfNeeded( statusMessageRe     36 int lPoPs_addParticleIfNeeded( statusMessageReporting *smr, char const *name, char const *special ) {
 37                                                    37 
 38     int index = PoPs_particleIndex( name ), ZA     38     int index = PoPs_particleIndex( name ), ZA, Z = 0, A = 0,/* level = 0,*/ ispecial;
 39     char *endptr, name_[256], AStr[32];            39     char *endptr, name_[256], AStr[32];
 40     char const *ZStr, *alias = NULL;               40     char const *ZStr, *alias = NULL;
 41     PoP *pop, *pop_;                               41     PoP *pop, *pop_;
 42  /* enum PoPs_genre genre = PoPs_genre_unknown     42  /* enum PoPs_genre genre = PoPs_genre_unknown; */
 43     char const *yiNames[]   = { "p",  "h2", "h     43     char const *yiNames[]   = { "p",  "h2", "h3", "he3", "he4", "photon" };
 44     char const *yiAliases[] = { "h1",  "d",  "     44     char const *yiAliases[] = { "h1",  "d",  "t", "he3",   "a", "g" };
 45  /* enum PoPs_genre yiGenres[] = { PoPs_genre_     45  /* enum PoPs_genre yiGenres[] = { PoPs_genre_baryon, PoPs_genre_nucleus, PoPs_genre_nucleus, PoPs_genre_nucleus,
 46         PoPs_genre_nucleus, PoPs_genre_photon      46         PoPs_genre_nucleus, PoPs_genre_photon }; */
 47                                                    47 
 48     if( special == NULL ) special = "";            48     if( special == NULL ) special = "";
 49     if( index < 0 ) {                              49     if( index < 0 ) {
 50         if( isdigit( name[0] ) ) {                 50         if( isdigit( name[0] ) ) {
 51             ZA = (int) strtol( name, &endptr,      51             ZA = (int) strtol( name, &endptr, 10 );
 52             if( *endptr != 0 ) {                   52             if( *endptr != 0 ) {
 53                 smr_setReportError2( smr, PoPs     53                 smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badName, "string '%s' not a value ZA", name );
 54                 return( -1 );                      54                 return( -1 );
 55             }                                      55             }
 56             Z = ZA / 1000;                         56             Z = ZA / 1000;
 57             A = ZA % 1000;                         57             A = ZA % 1000;
 58             /*level = 0;*/                         58             /*level = 0;*/
 59             ispecial = 0;                          59             ispecial = 0;
 60             if( strcmp( special, "LLNL" ) == 0     60             if( strcmp( special, "LLNL" ) == 0 ) {
 61                 if( ( ZA > 1 ) && ( ZA < 8 ) )     61                 if( ( ZA > 1 ) && ( ZA < 8 ) ) {
 62                     strcpy( name_, yiNames[ZA-     62                     strcpy( name_, yiNames[ZA-2] );
 63                     alias = yiAliases[ZA-2];       63                     alias = yiAliases[ZA-2];
 64                  /* genre = yiGenres[ZA-2];*/      64                  /* genre = yiGenres[ZA-2];*/
 65                     ispecial = 1; }                65                     ispecial = 1; }
 66                 else if( ( ZA == 1801 ) || ( Z     66                 else if( ( ZA == 1801 ) || ( ZA == 1901 ) ) {
 67                     strcpy( name_, yiNames[0]      67                     strcpy( name_, yiNames[0] );
 68                     alias = yiAliases[0];          68                     alias = yiAliases[0];
 69                  /* genre = yiGenres[0]; */        69                  /* genre = yiGenres[0]; */
 70                     ispecial = 1; }                70                     ispecial = 1; }
 71                 else if( ZA == 1902 ) {            71                 else if( ZA == 1902 ) {
 72                     strcpy( name_, yiNames[1]      72                     strcpy( name_, yiNames[1] );
 73                     alias = yiAliases[1];          73                     alias = yiAliases[1];
 74                  /* genre = yiGenres[1]; */        74                  /* genre = yiGenres[1]; */
 75                     ispecial = 1; }                75                     ispecial = 1; }
 76                 else if( ZA == 4809 ) {            76                 else if( ZA == 4809 ) {
 77                     strcpy( name_, "Be9" );        77                     strcpy( name_, "Be9" );
 78                  /* genre = PoPs_genre_atom; *     78                  /* genre = PoPs_genre_atom; */
 79                     ispecial = 1; }                79                     ispecial = 1; }
 80                 else if( ZA == 4909 ) {            80                 else if( ZA == 4909 ) {
 81                     strcpy( name_, "Be9" );        81                     strcpy( name_, "Be9" );
 82                  /* genre = PoPs_genre_atom; *     82                  /* genre = PoPs_genre_atom; */
 83                     ispecial = 1; }                83                     ispecial = 1; }
 84                 else if( ZA == 6912 ) {            84                 else if( ZA == 6912 ) {
 85                     strcpy( name_, "C12" );        85                     strcpy( name_, "C12" );
 86                  /* genre = PoPs_genre_atom; *     86                  /* genre = PoPs_genre_atom; */
 87                     ispecial = 1; }                87                     ispecial = 1; }
 88                 else if( ZA == 8916 ) {            88                 else if( ZA == 8916 ) {
 89                     strcpy( name_, "O16" );        89                     strcpy( name_, "O16" );
 90                  /* genre = PoPs_genre_atom; *     90                  /* genre = PoPs_genre_atom; */
 91                     ispecial = 1; }                91                     ispecial = 1; }
 92                 else if( ZA == 95242 ) {           92                 else if( ZA == 95242 ) {
 93                     strcpy( name_, "Am242_e2"      93                     strcpy( name_, "Am242_e2" );
 94                     /*level = 2;*/                 94                     /*level = 2;*/
 95                  /* genre = PoPs_genre_atom; *     95                  /* genre = PoPs_genre_atom; */
 96                     ispecial = 1; }                96                     ispecial = 1; }
 97                 else if( Z == 99 ) {               97                 else if( Z == 99 ) {
 98                     if( ( 120 <= A ) && ( A <      98                     if( ( 120 <= A ) && ( A < 126 ) ) {
 99                         snprintf( name_, sizeo <<  99                         sprintf( name_, "FissionProductENDL99%d", A );
100                      /* genre = PoPs_genre_ato    100                      /* genre = PoPs_genre_atom; */
101                         ispecial = 1;             101                         ispecial = 1;
102                     }                             102                     }
103                 }                                 103                 }
104             }                                     104             }
105             if( ispecial == 0 ) {                 105             if( ispecial == 0 ) {
106                 if( ZA == 1 ) {                   106                 if( ZA == 1 ) {
107                     AStr[0] = 0; }                107                     AStr[0] = 0; }
108                 else if( A == 0 ) {               108                 else if( A == 0 ) {
109                     strcpy( AStr, "_natural" )    109                     strcpy( AStr, "_natural" ); }
110                 else {                            110                 else {
111                     snprintf( AStr, sizeof ASt << 111                     sprintf( AStr, "%d", A );
112                 }                                 112                 }
113                 if( ( ZStr = lPoPs_ZSymbol( Z     113                 if( ( ZStr = lPoPs_ZSymbol( Z ) ) == NULL ) {
114                     smr_setReportError2( smr,     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 );                 115                     return( -1 );
116                 }                                 116                 }
117                 snprintf( name_, sizeof name_, << 117                 sprintf( name_, "%s%s", ZStr, AStr );
118               /* genre = PoPs_genre_atom; */      118               /* genre = PoPs_genre_atom; */
119               /* if( ZA == 1 ) genre = PoPs_ge    119               /* if( ZA == 1 ) genre = PoPs_genre_baryon; */
120             } }                                   120             } }
121         else {                                    121         else {
122             strcpy( name_, name );                122             strcpy( name_, name );
123             ZA = -1;                              123             ZA = -1;
124             if( strcmp( name, "neutron" ) == 0    124             if( strcmp( name, "neutron" ) == 0 ) {
125                 strcpy( name_, "n" );             125                 strcpy( name_, "n" );
126                 alias = name;                     126                 alias = name;
127             /*  genre = PoPs_genre_baryon; */     127             /*  genre = PoPs_genre_baryon; */ }
128             else if( strcmp( name, "electron"     128             else if( strcmp( name, "electron" ) == 0 ) {
129                 strcpy( name_, "e-" );            129                 strcpy( name_, "e-" );
130                 alias = name;                     130                 alias = name;
131             /*  genre = PoPs_genre_lepton; */     131             /*  genre = PoPs_genre_lepton; */ } 
132             else if( strcmp( name, "positron"     132             else if( strcmp( name, "positron" ) == 0 ) {
133                 strcpy( name_, "e+" );            133                 strcpy( name_, "e+" );
134                 alias = name;                     134                 alias = name;
135             /*  genre = PoPs_genre_lepton; */     135             /*  genre = PoPs_genre_lepton; */ } 
136             else if( ( strcmp( name, "h1" ) ==    136             else if( ( strcmp( name, "h1" ) == 0 ) || ( strcmp( name, "proton" ) == 0 ) ) {
137                 ZA = 2; }                         137                 ZA = 2; }
138             else if( ( strcmp( name, "d" ) ==     138             else if( ( strcmp( name, "d" ) == 0 ) || ( strcmp( name, "deuteron" ) == 0 ) ) {
139                 ZA = 3; }                         139                 ZA = 3; }
140             else if( ( strcmp( name, "t" ) ==     140             else if( ( strcmp( name, "t" ) == 0 ) || ( strcmp( name, "triton" ) == 0 ) ) {
141                 ZA = 4; }                         141                 ZA = 4; }
142             else if( strcmp( name, "helium3" )    142             else if( strcmp( name, "helium3" ) == 0 ) {
143                 ZA = 5; }                         143                 ZA = 5; }
144             else if( ( strcmp( name, "a" ) ==     144             else if( ( strcmp( name, "a" ) == 0 ) || ( strcmp( name, "alpha" ) == 0 ) || ( strcmp( name, "helium4" ) == 0 ) ) {
145                 ZA = 6; }                         145                 ZA = 6; }
146             else if( ( strcmp( name, "g" ) ==     146             else if( ( strcmp( name, "g" ) == 0 ) || ( strcmp( name, "gamma" ) == 0 ) ) {
147                 ZA = 7; }                         147                 ZA = 7; }
148             else if( strcmp( name, "FP" ) == 0    148             else if( strcmp( name, "FP" ) == 0 ) {
149                         strcpy( name_, "Fissio    149                         strcpy( name_, "FissionProductENDL99120" );
150                     /*  genre = PoPs_genre_ato    150                     /*  genre = PoPs_genre_atom; */
151             }                                     151             }
152             if( ZA != -1 ) {                      152             if( ZA != -1 ) {
153                 strcpy( name_, yiNames[ZA-2] )    153                 strcpy( name_, yiNames[ZA-2] );
154                 alias = name;                     154                 alias = name;
155              /* genre = yiGenres[ZA-2]; */        155              /* genre = yiGenres[ZA-2]; */
156             }                                     156             }
157         }                                         157         }
158                                                   158 
159         if( ( pop = PoPs_particleCreateLoadInf    159         if( ( pop = PoPs_particleCreateLoadInfo( smr, name_ ) ) == NULL ) {
160             smr_setReportError2( smr, PoPs_smr    160             smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badName, "particle '%s' converted to name '%s' not in database", name, name_ );
161             return( -1 );                         161             return( -1 );
162         }                                         162         }
163         if( ( pop_ = PoPs_addParticleIfNeeded(    163         if( ( pop_ = PoPs_addParticleIfNeeded( smr, pop ) ) != pop ) PoP_free( pop );       /* Still need to add alias as index was < 0. */
164         index = pop_->index;                      164         index = pop_->index;
165                                                   165 
166         if( PoPs_particleIndex( name ) < 0 ) {    166         if( PoPs_particleIndex( name ) < 0 ) {
167             if( ( pop = PoP_makeAlias( smr, na    167             if( ( pop = PoP_makeAlias( smr, name_, name ) ) == NULL ) return( -1 );
168             if( ( pop_ = PoPs_addParticleIfNee    168             if( ( pop_ = PoPs_addParticleIfNeeded( smr, pop ) ) != pop ) return( -1 );          /* pop_ should be pop as index was < 0. */
169         }                                         169         }
170                                                   170 
171         if( alias != NULL ) {                     171         if( alias != NULL ) {
172             if( PoPs_particleIndex( alias ) <     172             if( PoPs_particleIndex( alias ) < 0 ) {
173                 if( ( pop = PoP_makeAlias( smr    173                 if( ( pop = PoP_makeAlias( smr, name_, alias ) ) == NULL ) return( -1 );
174                 if( ( pop_ = PoPs_addParticleI    174                 if( ( pop_ = PoPs_addParticleIfNeeded( smr, pop ) ) != pop ) return( -1 );  /* Required for some yis. */
175             }                                     175             }
176         }                                         176         }
177     }                                             177     }
178     return( index );                              178     return( index );
179 }                                                 179 }
180 /*                                                180 /*
181 ==============================================    181 ========================================================================
182 */                                                182 */
183 static char const *lPoPs_ZSymbol( int Z ) {       183 static char const *lPoPs_ZSymbol( int Z ) {
184                                                   184 
185     //Coverity #63066                             185     //Coverity #63066
186     if( ( Z < 0 ) || ( Z >= nZs ) ) return( NU    186     if( ( Z < 0 ) || ( Z >= nZs ) ) return( NULL );
187     return( Zs[Z].Symbol );                       187     return( Zs[Z].Symbol );
188 }                                                 188 }
189                                                   189 
190 #if defined __cplusplus                           190 #if defined __cplusplus
191 }                                                 191 }
192 #endif                                            192 #endif
193                                                   193