Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MCGIDI_pop.cc File Reference
#include <string.h>
#include <PoPs.h>
#include "MCGIDI.h"
Include dependency graph for MCGIDI_pop.cc:

Go to the source code of this file.

Functions

MCGIDI_POPsMCGIDI_POPs_new (statusMessageReporting *smr, int size)
 
int MCGIDI_POPs_initial (statusMessageReporting *, MCGIDI_POPs *pops, int size)
 
voidMCGIDI_POPs_free (MCGIDI_POPs *pops)
 
int MCGIDI_POPs_release (MCGIDI_POPs *pops)
 
MCGIDI_POPMCGIDI_POPs_addParticleIfNeeded (statusMessageReporting *smr, MCGIDI_POPs *pops, char const *name, double mass_MeV, double level_MeV, MCGIDI_POP *parent, int globalParticle)
 
int MCGIDI_POPs_findParticleIndex (MCGIDI_POPs *pops, char const *name)
 
MCGIDI_POPMCGIDI_POPs_findParticle (MCGIDI_POPs *pops, char const *name)
 
void MCGIDI_POPs_writeSortedList (MCGIDI_POPs *pops, FILE *f)
 
void MCGIDI_POPs_printSortedList (MCGIDI_POPs *pops)
 
MCGIDI_POPMCGIDI_POP_new (statusMessageReporting *smr, char const *name, double mass_MeV, double level_MeV, MCGIDI_POP *parent)
 
MCGIDI_POPMCGIDI_POP_free (MCGIDI_POP *pop)
 
MCGIDI_POPMCGIDI_POP_release (MCGIDI_POP *pop)
 
double MCGIDI_POP_getMass_MeV (MCGIDI_POP *pop)
 

Function Documentation

MCGIDI_POP* MCGIDI_POP_free ( MCGIDI_POP pop)

Definition at line 191 of file MCGIDI_pop.cc.

191  {
192 
193  if( pop == NULL ) return( NULL );
194  MCGIDI_POP_release( pop );
195  smr_freeMemory( (void **) &pop );
196  return( NULL );
197 }
MCGIDI_POP * MCGIDI_POP_release(MCGIDI_POP *pop)
Definition: MCGIDI_pop.cc:201
void * smr_freeMemory(void **p)

Here is the call graph for this function:

Here is the caller graph for this function:

double MCGIDI_POP_getMass_MeV ( MCGIDI_POP pop)

Definition at line 212 of file MCGIDI_pop.cc.

212  {
213 
214  return( pop->mass_MeV );
215 }
double mass_MeV
Definition: MCGIDI.h:235

Here is the caller graph for this function:

MCGIDI_POP* MCGIDI_POP_new ( statusMessageReporting smr,
char const *  name,
double  mass_MeV,
double  level_MeV,
MCGIDI_POP parent 
)

Definition at line 165 of file MCGIDI_pop.cc.

165  {
166 
167  int Z, A, m, level;
168  MCGIDI_POP *pop = (MCGIDI_POP *) smr_malloc2( smr, sizeof( MCGIDI_POP ), 0, "pop" );
169 
170  if( pop == NULL ) return( NULL );
171  pop->next = NULL;
172  pop->parent = parent;
173  if( ( pop->name = smr_allocateCopyString2( smr, name, "pop->name" ) ) == NULL ) {
174  smr_freeMemory( (void **) &pop );
175  return( NULL );
176  }
177  MCGIDI_miscNameToZAm( smr, name, &Z, &A, &m, &level );
178  pop->Z = Z;
179  pop->A = A;
180  pop->level = level;
181  pop->m = m;
182  pop->mass_MeV = mass_MeV;
183  pop->level_MeV = level_MeV;
184  pop->numberOfGammaBranchs = 0;
185  pop->gammas = NULL;
186  return( pop );
187 }
const XML_Char * name
Definition: expat.h:151
#define smr_allocateCopyString2(smr, s, forItem)
char * name
Definition: MCGIDI.h:232
double A(double temperature)
static constexpr double m
Definition: G4SIunits.hh:129
MCGIDI_GammaBranching * gammas
Definition: MCGIDI.h:238
#define smr_malloc2(smr, size, zero, forItem)
int MCGIDI_miscNameToZAm(statusMessageReporting *smr, const char *name, int *Z, int *A, int *m, int *level)
Definition: MCGIDI_misc.cc:81
double mass_MeV
Definition: MCGIDI.h:235
void * smr_freeMemory(void **p)
double level_MeV
Definition: MCGIDI.h:236
int level
Definition: MCGIDI.h:234
MCGIDI_POP * parent
Definition: MCGIDI.h:231
int numberOfGammaBranchs
Definition: MCGIDI.h:237
MCGIDI_POP * next
Definition: MCGIDI.h:230

Here is the call graph for this function:

Here is the caller graph for this function:

MCGIDI_POP* MCGIDI_POP_release ( MCGIDI_POP pop)

Definition at line 201 of file MCGIDI_pop.cc.

201  {
202 
203  if( pop == NULL ) return( NULL );
204  smr_freeMemory( (void **) &(pop->name) );
205  pop->numberOfGammaBranchs = 0;
206  if( pop->gammas != NULL ) smr_freeMemory( (void **) &(pop->gammas) );
207  return( NULL );
208 }
char * name
Definition: MCGIDI.h:232
MCGIDI_GammaBranching * gammas
Definition: MCGIDI.h:238
void * smr_freeMemory(void **p)
int numberOfGammaBranchs
Definition: MCGIDI.h:237

Here is the call graph for this function:

Here is the caller graph for this function:

MCGIDI_POP* MCGIDI_POPs_addParticleIfNeeded ( statusMessageReporting smr,
MCGIDI_POPs pops,
char const *  name,
double  mass_MeV,
double  level_MeV,
MCGIDI_POP parent,
int  globalParticle 
)

Definition at line 67 of file MCGIDI_pop.cc.

68  {
69 
70  int i, index;
71  MCGIDI_POP *pop;
72 
73  if( ( index = MCGIDI_POPs_findParticleIndex( pops, name ) ) >= 0 ) return( pops->sorted[index] );
74  if( pops->size == pops->numberOfPOPs ) {
75  int size = pops->size + pops->increment;
76  MCGIDI_POP **sorted = (MCGIDI_POP **) smr_malloc2( smr, size * sizeof( MCGIDI_POP * ), 0, "sorted" );
77 
78  if( sorted == NULL ) return( NULL );
79  for( i = 0; i < pops->numberOfPOPs; i++ ) sorted[i] = pops->sorted[i];
80  smr_freeMemory( (void **) &(pops->sorted) );
81  pops->sorted = sorted;
82  pops->size = size;
83  }
84  index = -index - 1;
85  if( ( pop = MCGIDI_POP_new( smr, name, mass_MeV, level_MeV, parent ) ) == NULL ) return( NULL );
86  for( i = pops->numberOfPOPs; i > index; i-- ) pops->sorted[i] = pops->sorted[i-1];
87  pops->sorted[index] = pop;
88  if( pops->first == NULL ) {
89  pops->first = pop; }
90  else {
91  pops->last->next = pop;
92  }
93  pops->last = pop;
94  pops->numberOfPOPs++;
95  pop->globalPoPsIndex = -1;
96  if( globalParticle ) {
97  if( ( pop->globalPoPsIndex = lPoPs_addParticleIfNeeded( smr, name, "LLNL" ) ) < 0 ) return( NULL );
98  }
99  return( pop );
100 }
const XML_Char * name
Definition: expat.h:151
int MCGIDI_POPs_findParticleIndex(MCGIDI_POPs *pops, char const *name)
Definition: MCGIDI_pop.cc:104
MCGIDI_POP ** sorted
Definition: MCGIDI.h:243
MCGIDI_POP * first
Definition: MCGIDI.h:243
int numberOfPOPs
Definition: MCGIDI.h:242
int lPoPs_addParticleIfNeeded(statusMessageReporting *smr, char const *name, char const *special)
Definition: lPoPs.cc:36
int globalPoPsIndex
Definition: MCGIDI.h:233
int increment
Definition: MCGIDI.h:242
#define smr_malloc2(smr, size, zero, forItem)
MCGIDI_POP * last
Definition: MCGIDI.h:243
void * smr_freeMemory(void **p)
MCGIDI_POP * MCGIDI_POP_new(statusMessageReporting *smr, char const *name, double mass_MeV, double level_MeV, MCGIDI_POP *parent)
Definition: MCGIDI_pop.cc:165
MCGIDI_POP * next
Definition: MCGIDI.h:230

Here is the call graph for this function:

Here is the caller graph for this function:

MCGIDI_POP* MCGIDI_POPs_findParticle ( MCGIDI_POPs pops,
char const *  name 
)

Definition at line 133 of file MCGIDI_pop.cc.

133  {
134 
135  int index = MCGIDI_POPs_findParticleIndex( pops, name );
136 
137  if( index < 0 ) return( NULL );
138  return( pops->sorted[index] );
139 }
const XML_Char * name
Definition: expat.h:151
int MCGIDI_POPs_findParticleIndex(MCGIDI_POPs *pops, char const *name)
Definition: MCGIDI_pop.cc:104
MCGIDI_POP ** sorted
Definition: MCGIDI.h:243

Here is the call graph for this function:

Here is the caller graph for this function:

int MCGIDI_POPs_findParticleIndex ( MCGIDI_POPs pops,
char const *  name 
)

Definition at line 104 of file MCGIDI_pop.cc.

104  {
105 
106  int iCmp = 0, min = 0, mid = 0, max = pops->numberOfPOPs;
107 
108  if( max == 0 ) return( -1 );
109  while( ( max - min ) > 1 ) {
110  mid = ( min + max ) / 2;
111  iCmp = strcmp( name, pops->sorted[mid]->name );
112  if( iCmp == 0 ) return( mid );
113  if( iCmp < 0 ) {
114  max = mid; }
115  else {
116  min = mid;
117  }
118  } // Loop checking, 11.05.2015, T. Koi
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]->name ) == 0 ) return( 0 );
121  }
122  if( max < pops->numberOfPOPs ) {
123  if( strcmp( name, pops->sorted[max]->name ) == 0 ) return( max );
124  }
125  if( max == 1 ) {
126  if( strcmp( name, pops->sorted[0]->name ) < 0 ) return( -1 );
127  }
128  return( -max - 1 );
129 }
const XML_Char * name
Definition: expat.h:151
MCGIDI_POP ** sorted
Definition: MCGIDI.h:243
int numberOfPOPs
Definition: MCGIDI.h:242
char * name
Definition: MCGIDI.h:232
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

Here is the call graph for this function:

Here is the caller graph for this function:

void* MCGIDI_POPs_free ( MCGIDI_POPs pops)

Definition at line 41 of file MCGIDI_pop.cc.

41  {
42 
43  if( pops == NULL ) return( NULL );
44  MCGIDI_POPs_release( pops );
45  smr_freeMemory( (void **) &pops );
46  return( NULL );
47 }
int MCGIDI_POPs_release(MCGIDI_POPs *pops)
Definition: MCGIDI_pop.cc:51
void * smr_freeMemory(void **p)

Here is the call graph for this function:

int MCGIDI_POPs_initial ( statusMessageReporting ,
MCGIDI_POPs pops,
int  size 
)

Definition at line 30 of file MCGIDI_pop.cc.

30  {
31 
32  memset( pops, 0, sizeof( MCGIDI_POPs ) );
33  if( size < 10 ) size = 10;
34  pops->increment = size;
35 
36  return( 0 );
37 }
int increment
Definition: MCGIDI.h:242

Here is the caller graph for this function:

MCGIDI_POPs* MCGIDI_POPs_new ( statusMessageReporting smr,
int  size 
)

Definition at line 19 of file MCGIDI_pop.cc.

19  {
20 
21  MCGIDI_POPs *pops;
22 
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 ) ) smr_freeMemory( (void **) &pops );
25  return( pops );
26 }
#define smr_malloc2(smr, size, zero, forItem)
void * smr_freeMemory(void **p)
int MCGIDI_POPs_initial(statusMessageReporting *smr, MCGIDI_POPs *pops, int size)
Definition: MCGIDI_pop.cc:30

Here is the call graph for this function:

void MCGIDI_POPs_printSortedList ( MCGIDI_POPs pops)

Definition at line 153 of file MCGIDI_pop.cc.

153  {
154 
155  MCGIDI_POPs_writeSortedList( pops, stdout );
156 }
void MCGIDI_POPs_writeSortedList(MCGIDI_POPs *pops, FILE *f)
Definition: MCGIDI_pop.cc:143

Here is the call graph for this function:

int MCGIDI_POPs_release ( MCGIDI_POPs pops)

Definition at line 51 of file MCGIDI_pop.cc.

51  {
52 
53  MCGIDI_POP *pop, *next;
54 
55  if( pops == NULL ) return( 0 );
56  for( pop = pops->first; pop != NULL; pop = next ) {
57  next = pop->next;
58  MCGIDI_POP_free( pop );
59  }
60  smr_freeMemory( (void **) &(pops->sorted) );
61  MCGIDI_POPs_initial( NULL, pops, 0 );
62  return( 0 );
63 }
MCGIDI_POP ** sorted
Definition: MCGIDI.h:243
MCGIDI_POP * first
Definition: MCGIDI.h:243
MCGIDI_POP * MCGIDI_POP_free(MCGIDI_POP *pop)
Definition: MCGIDI_pop.cc:191
void * smr_freeMemory(void **p)
int MCGIDI_POPs_initial(statusMessageReporting *smr, MCGIDI_POPs *pops, int size)
Definition: MCGIDI_pop.cc:30
MCGIDI_POP * next
Definition: MCGIDI.h:230

Here is the call graph for this function:

Here is the caller graph for this function:

void MCGIDI_POPs_writeSortedList ( MCGIDI_POPs pops,
FILE *  f 
)

Definition at line 143 of file MCGIDI_pop.cc.

143  {
144 
145  int i;
146 
147  fprintf( f, "POPs Information: n = %d\n", pops->numberOfPOPs );
148  for( i = 0; i < pops->numberOfPOPs; i++ ) fprintf( f, " %-20s %e\n", pops->sorted[i]->name, pops->sorted[i]->mass_MeV );
149 }
MCGIDI_POP ** sorted
Definition: MCGIDI.h:243
int numberOfPOPs
Definition: MCGIDI.h:242
char * name
Definition: MCGIDI.h:232
double mass_MeV
Definition: MCGIDI.h:235

Here is the caller graph for this function: