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 10.5 ] [ 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/MCGIDI_pop.cc (Version 11.3.0) and /processes/hadronic/models/lend/src/MCGIDI_pop.cc (Version 11.0.p1)


  1 /*                                                  1 /*
  2 # <<BEGIN-copyright>>                               2 # <<BEGIN-copyright>>
  3 # <<END-copyright>>                                 3 # <<END-copyright>>
  4 */                                                  4 */
  5                                                     5 
  6 #include <string.h>                                 6 #include <string.h>
  7 #include <PoPs.h>                                   7 #include <PoPs.h>
  8                                                     8 
  9 #include "MCGIDI.h"                                 9 #include "MCGIDI.h"
 10                                                    10 
 11 #if defined __cplusplus                            11 #if defined __cplusplus
 12 namespace GIDI {                                   12 namespace GIDI {
 13 using namespace GIDI;                              13 using namespace GIDI;
 14 #endif                                             14 #endif
 15                                                    15 
 16 /*                                                 16 /*
 17 **********************************************     17 ************************************************************
 18 */                                                 18 */
 19 MCGIDI_POPs *MCGIDI_POPs_new( statusMessageRep     19 MCGIDI_POPs *MCGIDI_POPs_new( statusMessageReporting *smr, int size ) {
 20                                                    20 
 21     MCGIDI_POPs *pops;                             21     MCGIDI_POPs *pops;
 22                                                    22 
 23     if( ( pops = (MCGIDI_POPs *) smr_malloc2(      23     if( ( pops = (MCGIDI_POPs *) smr_malloc2( smr, sizeof( MCGIDI_POPs ), 0, "pops->sorted" ) ) == NULL ) return( NULL );
 24     if( MCGIDI_POPs_initial( smr, pops, size )     24     if( MCGIDI_POPs_initial( smr, pops, size ) ) smr_freeMemory( (void **) &pops );
 25     return( pops );                                25     return( pops );
 26 }                                                  26 }
 27 /*                                                 27 /*
 28 **********************************************     28 ************************************************************
 29 */                                                 29 */
 30 int MCGIDI_POPs_initial( statusMessageReportin     30 int MCGIDI_POPs_initial( statusMessageReporting * /*smr*/, MCGIDI_POPs *pops, int size ) {
 31                                                    31 
 32     memset( pops, 0, sizeof( MCGIDI_POPs ) );      32     memset( pops, 0, sizeof( MCGIDI_POPs ) );
 33     if( size < 10 ) size = 10;                     33     if( size < 10 ) size = 10;
 34     pops->increment = size;                        34     pops->increment = size;
 35                                                    35     
 36     return( 0 );                                   36     return( 0 );
 37 }                                                  37 }
 38 /*                                                 38 /*
 39 **********************************************     39 ************************************************************
 40 */                                                 40 */
 41 void *MCGIDI_POPs_free( MCGIDI_POPs *pops ) {      41 void *MCGIDI_POPs_free( MCGIDI_POPs *pops ) {
 42                                                    42 
 43     if( pops == NULL ) return( NULL );             43     if( pops == NULL ) return( NULL );
 44     MCGIDI_POPs_release( pops );                   44     MCGIDI_POPs_release( pops );
 45     smr_freeMemory( (void **) &pops );             45     smr_freeMemory( (void **) &pops );
 46     return( NULL );                                46     return( NULL );
 47 }                                                  47 }
 48 /*                                                 48 /*
 49 **********************************************     49 ************************************************************
 50 */                                                 50 */
 51 int MCGIDI_POPs_release( MCGIDI_POPs *pops ) {     51 int MCGIDI_POPs_release( MCGIDI_POPs *pops ) {
 52                                                    52 
 53     MCGIDI_POP *pop, *next;                        53     MCGIDI_POP *pop, *next;
 54                                                    54 
 55     if( pops == NULL ) return( 0 );                55     if( pops == NULL ) return( 0 );
 56     for( pop = pops->first; pop != NULL; pop =     56     for( pop = pops->first; pop != NULL; pop = next ) {
 57         next = pop->next;                          57         next = pop->next;
 58         MCGIDI_POP_free( pop );                    58         MCGIDI_POP_free( pop );
 59     }                                              59     }
 60     smr_freeMemory( (void **) &(pops->sorted)      60     smr_freeMemory( (void **) &(pops->sorted) );
 61     MCGIDI_POPs_initial( NULL, pops, 0 );          61     MCGIDI_POPs_initial( NULL, pops, 0 );
 62     return( 0 );                                   62     return( 0 );
 63 }                                                  63 }
 64 /*                                                 64 /*
 65 **********************************************     65 ************************************************************
 66 */                                                 66 */
 67 MCGIDI_POP *MCGIDI_POPs_addParticleIfNeeded( s     67 MCGIDI_POP *MCGIDI_POPs_addParticleIfNeeded( statusMessageReporting *smr, MCGIDI_POPs *pops, char const *name, double mass_MeV, 
 68         double level_MeV, MCGIDI_POP *parent,      68         double level_MeV, MCGIDI_POP *parent, int globalParticle ) {
 69                                                    69 
 70     int i, index;                                  70     int i, index;
 71     MCGIDI_POP *pop;                               71     MCGIDI_POP *pop;
 72                                                    72 
 73     if( ( index = MCGIDI_POPs_findParticleInde     73     if( ( index = MCGIDI_POPs_findParticleIndex( pops, name ) ) >= 0 ) return( pops->sorted[index] );
 74     if( pops->size == pops->numberOfPOPs ) {       74     if( pops->size == pops->numberOfPOPs ) {
 75         int size = pops->size + pops->incremen     75         int size = pops->size + pops->increment;
 76         MCGIDI_POP **sorted = (MCGIDI_POP **)      76         MCGIDI_POP **sorted = (MCGIDI_POP **) smr_malloc2( smr, size * sizeof( MCGIDI_POP * ), 0, "sorted" );
 77                                                    77 
 78         if( sorted == NULL ) return( NULL );       78         if( sorted == NULL ) return( NULL );
 79         for( i = 0; i < pops->numberOfPOPs; i+     79         for( i = 0; i < pops->numberOfPOPs; i++ ) sorted[i] = pops->sorted[i];
 80         smr_freeMemory( (void **) &(pops->sort     80         smr_freeMemory( (void **) &(pops->sorted) );
 81         pops->sorted = sorted;                     81         pops->sorted = sorted;
 82         pops->size = size;                         82         pops->size = size;
 83     }                                              83     }
 84     index = -index - 1;                            84     index = -index - 1;
 85     if( ( pop = MCGIDI_POP_new( smr, name, mas     85     if( ( pop = MCGIDI_POP_new( smr, name, mass_MeV, level_MeV, parent ) ) == NULL ) return( NULL );
 86     for( i = pops->numberOfPOPs; i > index; i-     86     for( i = pops->numberOfPOPs; i > index; i-- ) pops->sorted[i] = pops->sorted[i-1];
 87     pops->sorted[index] = pop;                     87     pops->sorted[index] = pop;
 88     if( pops->first == NULL ) {                    88     if( pops->first == NULL ) {
 89         pops->first = pop; }                       89         pops->first = pop; }
 90     else {                                         90     else {
 91         pops->last->next = pop;                    91         pops->last->next = pop;
 92     }                                              92     }
 93     pops->last = pop;                              93     pops->last = pop;
 94     pops->numberOfPOPs++;                          94     pops->numberOfPOPs++;
 95     pop->globalPoPsIndex = -1;                     95     pop->globalPoPsIndex = -1;
 96     if( globalParticle ) {                         96     if( globalParticle ) {
 97         if( ( pop->globalPoPsIndex = lPoPs_add     97         if( ( pop->globalPoPsIndex = lPoPs_addParticleIfNeeded( smr, name, "LLNL" ) ) < 0 ) return( NULL );
 98     }                                              98     }
 99     return( pop );                                 99     return( pop );
100 }                                                 100 }
101 /*                                                101 /*
102 **********************************************    102 ************************************************************
103 */                                                103 */
104 int MCGIDI_POPs_findParticleIndex( MCGIDI_POPs    104 int MCGIDI_POPs_findParticleIndex( MCGIDI_POPs *pops, char const *name ) {
105                                                   105 
106     int iCmp = 0, min = 0, mid = 0, max = pops    106     int iCmp = 0, min = 0, mid = 0, max = pops->numberOfPOPs;
107                                                   107 
108     if( max == 0 ) return( -1 );                  108     if( max == 0 ) return( -1 );
109     while( ( max - min ) > 1 ) {                  109     while( ( max - min ) > 1 ) {
110         mid = ( min + max ) / 2;                  110         mid = ( min + max ) / 2;
111         iCmp = strcmp( name, pops->sorted[mid]    111         iCmp = strcmp( name, pops->sorted[mid]->name );
112         if( iCmp == 0 ) return( mid );            112         if( iCmp == 0 ) return( mid );
113         if( iCmp < 0 ) {                          113         if( iCmp < 0 ) {
114             max = mid; }                          114             max = mid; }
115         else {                                    115         else {
116             min = mid;                            116             min = mid;
117         }                                         117         }
118     }  // Loop checking, 11.05.2015, T. Koi       118     }  // Loop checking, 11.05.2015, T. Koi
119     if( max == 1 ) {            /* First point    119     if( max == 1 ) {            /* First point is not checked as loop exits when ( max = 1 ) - ( min = 0 ) !> 1 ). */
120         if( strcmp( name, pops->sorted[0]->nam    120         if( strcmp( name, pops->sorted[0]->name ) == 0 ) return( 0 );
121     }                                             121     }
122     if( max < pops->numberOfPOPs ) {              122     if( max < pops->numberOfPOPs ) {
123         if( strcmp( name, pops->sorted[max]->n    123         if( strcmp( name, pops->sorted[max]->name ) == 0 ) return( max );
124     }                                             124     }
125     if( max == 1 ) {                              125     if( max == 1 ) {
126         if( strcmp( name, pops->sorted[0]->nam    126         if( strcmp( name, pops->sorted[0]->name ) < 0 ) return( -1 );
127     }                                             127     }
128     return( -max - 1 );                           128     return( -max - 1 );
129 }                                                 129 }
130 /*                                                130 /*
131 **********************************************    131 ************************************************************
132 */                                                132 */
133 MCGIDI_POP *MCGIDI_POPs_findParticle( MCGIDI_P    133 MCGIDI_POP *MCGIDI_POPs_findParticle( MCGIDI_POPs *pops, char const *name ) {
134                                                   134 
135     int index = MCGIDI_POPs_findParticleIndex(    135     int index = MCGIDI_POPs_findParticleIndex( pops, name );
136                                                   136 
137     if( index < 0 ) return( NULL );               137     if( index < 0 ) return( NULL );
138     return( pops->sorted[index] );                138     return( pops->sorted[index] );
139 }                                                 139 }
140 /*                                                140 /*
141 **********************************************    141 ************************************************************
142 */                                                142 */
143 void MCGIDI_POPs_writeSortedList( MCGIDI_POPs     143 void MCGIDI_POPs_writeSortedList( MCGIDI_POPs *pops, FILE *f ) {
144                                                   144 
145     int i;                                        145     int i;
146                                                   146 
147     fprintf( f, "POPs Information: n = %d\n",     147     fprintf( f, "POPs Information: n = %d\n", pops->numberOfPOPs );
148     for( i = 0; i < pops->numberOfPOPs; i++ )     148     for( i = 0; i < pops->numberOfPOPs; i++ ) fprintf( f, "    %-20s  %e\n", pops->sorted[i]->name, pops->sorted[i]->mass_MeV );
149 }                                                 149 }
150 /*                                                150 /*
151 **********************************************    151 ************************************************************
152 */                                                152 */
153 void MCGIDI_POPs_printSortedList( MCGIDI_POPs     153 void MCGIDI_POPs_printSortedList( MCGIDI_POPs *pops ) {
154                                                   154 
155     MCGIDI_POPs_writeSortedList( pops, stdout     155     MCGIDI_POPs_writeSortedList( pops, stdout );
156 }                                                 156 }
157                                                   157 
158                                                   158 
159 /*                                                159 /*
160 ********* MCGIDI_POP routines *********           160 ********* MCGIDI_POP routines *********
161 */                                                161 */
162 /*                                                162 /*
163 **********************************************    163 ************************************************************
164 */                                                164 */
165 MCGIDI_POP *MCGIDI_POP_new( statusMessageRepor    165 MCGIDI_POP *MCGIDI_POP_new( statusMessageReporting *smr, char const *name, double mass_MeV, double level_MeV, MCGIDI_POP *parent ) {
166                                                   166 
167     int Z, A, m, level;                           167     int Z, A, m, level;
168     MCGIDI_POP *pop = (MCGIDI_POP *) smr_mallo    168     MCGIDI_POP *pop = (MCGIDI_POP *) smr_malloc2( smr, sizeof( MCGIDI_POP ), 0, "pop" );
169                                                   169 
170     if( pop == NULL ) return( NULL );             170     if( pop == NULL ) return( NULL );
171     pop->next = NULL;                             171     pop->next = NULL;
172     pop->parent = parent;                         172     pop->parent = parent;
173     if( ( pop->name = smr_allocateCopyString2(    173     if( ( pop->name = smr_allocateCopyString2( smr, name, "pop->name" ) ) == NULL ) {
174         smr_freeMemory( (void **) &pop );         174         smr_freeMemory( (void **) &pop );
175         return( NULL );                           175         return( NULL );
176     }                                             176     }
177     MCGIDI_miscNameToZAm( smr, name, &Z, &A, &    177     MCGIDI_miscNameToZAm( smr, name, &Z, &A, &m, &level );
178     pop->Z = Z;                                   178     pop->Z = Z;
179     pop->A = A;                                   179     pop->A = A;
180     pop->level = level;                           180     pop->level = level;
181     pop->m = m;                                   181     pop->m = m;
182     pop->mass_MeV = mass_MeV;                     182     pop->mass_MeV = mass_MeV;
183     pop->level_MeV = level_MeV;                   183     pop->level_MeV = level_MeV;
184     pop->numberOfGammaBranchs = 0;                184     pop->numberOfGammaBranchs = 0;
185     pop->gammas = NULL;                           185     pop->gammas = NULL;
186     return( pop );                                186     return( pop );
187 }                                                 187 }
188 /*                                                188 /*
189 **********************************************    189 ************************************************************
190 */                                                190 */
191 MCGIDI_POP *MCGIDI_POP_free( MCGIDI_POP *pop )    191 MCGIDI_POP *MCGIDI_POP_free( MCGIDI_POP *pop ) {
192                                                   192 
193     if( pop == NULL ) return( NULL );             193     if( pop == NULL ) return( NULL );
194     MCGIDI_POP_release( pop );                    194     MCGIDI_POP_release( pop );
195     smr_freeMemory( (void **) &pop );             195     smr_freeMemory( (void **) &pop );
196     return( NULL );                               196     return( NULL );
197 }                                                 197 }
198 /*                                                198 /*
199 **********************************************    199 ************************************************************
200 */                                                200 */
201 MCGIDI_POP *MCGIDI_POP_release( MCGIDI_POP *po    201 MCGIDI_POP *MCGIDI_POP_release( MCGIDI_POP *pop ) {
202                                                   202 
203     if( pop == NULL ) return( NULL );             203     if( pop == NULL ) return( NULL );
204     smr_freeMemory( (void **) &(pop->name) );     204     smr_freeMemory( (void **) &(pop->name) );
205     pop->numberOfGammaBranchs = 0;                205     pop->numberOfGammaBranchs = 0;
206     if( pop->gammas != NULL ) smr_freeMemory(     206     if( pop->gammas != NULL ) smr_freeMemory( (void **) &(pop->gammas) );
207     return( NULL );                               207     return( NULL );
208 }                                                 208 }
209 /*                                                209 /*
210 **********************************************    210 ************************************************************
211 */                                                211 */
212 double MCGIDI_POP_getMass_MeV( MCGIDI_POP *pop    212 double MCGIDI_POP_getMass_MeV( MCGIDI_POP *pop ) {
213                                                   213 
214     return( pop->mass_MeV );                      214     return( pop->mass_MeV );
215 }                                                 215 }
216                                                   216 
217 #if defined __cplusplus                           217 #if defined __cplusplus
218 }                                                 218 }
219 #endif                                            219 #endif
220                                                   220 
221                                                   221