37 #include <tpia_target.h>
40 #if defined __cplusplus
55 tpia_particle *particle = (tpia_particle*) xData_malloc2( smr,
sizeof( tpia_particle ), 0,
"particle" );
57 if( particle == NULL )
return( NULL );
67 memset( particle, 0,
sizeof( tpia_particle ) );
79 if( *p == particle ) {
85 if( particle == particleListEnd ) particleListEnd = particle->prior;
86 if( particle == particleList ) particleList = particle->next;
87 if( particle->prior != NULL ) particle->prior->next = particle->next;
88 if( particle->next != NULL ) particle->next->prior = particle->prior;
108 particleSortedList = (tpia_particle**)
xData_free( smr, particleSortedList );
116 int i, iCmp,
min, mid,
max, Z,
A,
m;
117 tpia_particle *particle;
123 while( min != max ) {
124 mid = ( min +
max ) / 2;
125 iCmp = strcmp( name, particleSortedList[mid]->name );
126 if( iCmp == 0 )
return( particleSortedList[mid] );
129 if( mid == 0 ) max = 0; }
132 if( min > max ) min =
max;
136 if( numberOfParticles > 0 ) {
137 iCmp = strcmp( name, particleSortedList[mid]->name );
138 if( iCmp == 0 )
return( particleSortedList[mid] );
139 if( ( iCmp < 0 ) && ( mid != 0 ) ) {
141 iCmp = strcmp( name, particleSortedList[mid]->name );
147 particle->name = particle->spectralID->name;
149 particle->prior = NULL;
150 particle->next = NULL;
156 particle->fullMass_MeV = tpia_AMU2MeV * particle->mass + particle->spectralID->level;
165 if( ( particleSortedList = (tpia_particle** ) xData_realloc2( smr, particleSortedList,
sizeOfParticleSortedList *
sizeof( tpia_particle * ),
169 if( particleList == NULL ) {
170 particle->ordinal = 0;
171 particleListEnd = particleList = particle; }
173 particle->ordinal = particleListEnd->ordinal + 1;
175 particleListEnd->next = particle;
176 particleListEnd = particle;
179 if( ( mid != 0 ) || ( iCmp > 0 ) ) mid++;
180 for( i = numberOfParticles; i > mid; i-- ) particleSortedList[i] = particleSortedList[i-1];
181 particleSortedList[mid] = particle;
198 #if defined __cplusplus
static G4ThreadLocal int incrementalSizeOfList
int tpia_particle_freeInternalList(statusMessageReporting *smr)
static G4ThreadLocal tpia_particle * particleListEnd
int tpia_particle_printInternalSortedList(statusMessageReporting *)
tpi_spectralID * tpi_spectralID_parse(statusMessageReporting *smr, char const *str, char **EOP)
static G4ThreadLocal tpia_particle ** particleSortedList
static G4ThreadLocal tpia_particle * particleList
int smr_isOk(statusMessageReporting *smr)
int tpia_miscNameToZAm(statusMessageReporting *smr, const char *name, int *Z, int *A, int *m)
static G4ThreadLocal int sizeOfParticleSortedList
static G4ThreadLocal int numberOfParticles
void * tpi_spectralID_free(statusMessageReporting *smr, tpi_spectralID *spectralID)
static const G4double A[nN]
int tpia_particle_initialize(statusMessageReporting *, tpia_particle *particle)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void * xData_free(statusMessageReporting *, void *p)
static G4ThreadLocal int initialSizeOfList
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
tpia_particle * tpia_particle_create(statusMessageReporting *smr)
int tpia_particle_release(statusMessageReporting *smr, tpia_particle *particle)
double tpia_particleMass_AMU(statusMessageReporting *smr, const char *name)
tpia_particle * tpia_particle_free(statusMessageReporting *smr, tpia_particle *particle)
tpia_particle * tpia_particle_getInternalID(statusMessageReporting *smr, const char *const name)