13#if defined __cplusplus
18#define incrementalSize 1000
22#define AMU2MeV 931.494028
23#define AMU2eV ( MeV2eV * 931.494028 )
24#define K2MeV 8.6173856922566752e-11
25#define K2eV ( MeV2eV * K2MeV )
49 {
"MeV",
"eV",
MeV2eV }, {
"MeV",
"keV",
MeV2keV }, {
"K",
"MeV",
K2MeV }, {
"K",
"eV",
K2eV } };
51static char const *
PoPs_genreStrings[] = {
"invalid",
"unknown",
"alias",
"photon",
"lepton",
"quark",
"meson",
"baryon",
"nucleus",
"atom" };
125 if( pops == NULL )
return( NULL );
126 sorted = &(pops[size]);
165 if( ( newPoP = (
PoP *)
smr_malloc2( smr,
sizeof(
PoP ), 0,
"newPoP" ) ) == NULL )
return( NULL );
184 if( pop->
index < 0 ) {
242 if( high == 0 )
return( -1 );
243 while( ( high - low ) > 1 ) {
244 mid = ( low + high ) >> 1;
246 if( iCmp == 0 )
return( mid );
269 if( index < 0 )
return( -1. );
329 if( index < 0 )
return( -1 );
353 if( index < 0 )
return( -1 );
369 if( protonIsNucleus ) {
381 if( index < 0 )
return( NULL );
391 if( atomIndex < 0 )
return( NULL );
401 if( index < 0 )
return( index );
409 char const *p = NULL;
471 fprintf( f,
"\n\n" );
473 fprintf( f,
" name index genre mass hasNucleus alias info\n" );
474 fprintf( f,
" Z A l\n" );
475 fprintf( f,
" --------------------------------------------------------------------------------------------\n" );
486 fprintf( f,
" T" ); }
491 fprintf( f,
" T" ); }
495 if( pop->
Z + pop->
A > 0 ) {
496 fprintf( f,
" %3d %3d", pop->
Z, pop->
A );
498 fprintf( f,
" %d", pop->
l ); }
526 if( ( pop = (
PoP *)
smr_malloc2( smr,
sizeof(
PoP ), 0,
"pop" ) ) == NULL )
return( NULL );
589 if( ( pop =
PoP_new( smr ) ) == NULL )
return( NULL );
614 return( pop->
index );
628 double mass = -1., ratio;
635 mass = pop->
mass * ratio;
652 if( properIndex < 0 ) {
656 if( aliasIndex >= 0 ) {
670 if( ( pop =
PoP_new( smr ) ) == NULL )
return( NULL );
709 char const **unsorted = (
char const **)
smr_malloc2( smr, size *
sizeof(
char * ), 0,
"unsorted" );
711 if( unsorted == NULL )
return( NULL );
753 if( strcmp( _from, _to ) == 0 )
return( 0 );
754 for( i = 0; i <
n; i++ ) {
760 else if( strcmp(
conversions[i]._to, _from ) == 0 ) {
780#if defined __cplusplus
static char versionStr[64]
char const * PoPs_getAtomsName_atIndex(statusMessageReporting *smr, int index)
int unitsDB_index(statusMessageReporting *, char const *unit)
int PoPs_particleIndex_smr(statusMessageReporting *smr, char const *name, char const *file, int line, char const *func)
void PoPs_write(FILE *f, int sorted)
PoP * PoP_new(statusMessageReporting *smr)
int PoPs_getAtomsIndex_atIndex(statusMessageReporting *smr, int index)
int PoPs_getZ_A_l(statusMessageReporting *smr, char const *name, int *Z, int *A, int *l)
static char const * PoPs_genreStrings[]
int PoP_getIndex(PoP *pop)
char const * PoPs_getName_atIndex(statusMessageReporting *smr, int index)
int PoPs_release(statusMessageReporting *smr)
int PoPs_particleIndex(char const *name)
int PoPs_versionMajor(void)
int PoP_release(PoP *pop)
char const * PoPs_genreTokenToString(enum PoPs_genre genre)
enum PoPs_genre PoPs_getGenre(statusMessageReporting *smr, char const *name)
static int PoPs_sortedParticleIndex(char const *name)
int PoP_copyParticle(statusMessageReporting *smr, PoP *desc, PoP *src)
int PoPs_getAtomsIndex(statusMessageReporting *smr, char const *name)
double PoPs_getMassInUnitOf_atIndex(statusMessageReporting *smr, int index, char const *unit)
int PoP_setZ_A_l(statusMessageReporting *, PoP *pop, int Z, int A, int l)
PoP * PoP_makeAlias(statusMessageReporting *smr, char const *name, char const *alias)
int PoPs_readDatabase(statusMessageReporting *smr, char const *fileName)
static int PoPs_particleProperIndex(int index)
int PoPs_versionMinor(void)
PoP * PoPs_addAliasIfNeeded(statusMessageReporting *smr, char const *name, char const *alias)
int PoPs_versionPatchLevel(void)
int PoPs_getZ_A_l_atIndex(statusMessageReporting *smr, int index, int *Z, int *A, int *l)
int PoPs_numberOfParticle(void)
char const * unitsDB_stringFromIndex(statusMessageReporting *smr, int index)
char const * PoPs_getAtomsName(statusMessageReporting *smr, char const *name)
PoP * PoPs_copyAddParticleIfNeeded(statusMessageReporting *smr, PoP *pop)
int PoPs_hasNucleus(statusMessageReporting *smr, char const *name, int protonIsNucleus)
static int unitsDB_release(void)
double PoP_getMassInUnitOf(statusMessageReporting *smr, PoP *pop, char const *unit)
static unitConversions conversions[]
const char * PoPs_version(void)
int PoP_initialize(statusMessageReporting *, PoP *pop)
PoP * PoPs_addParticleIfNeeded(statusMessageReporting *smr, PoP *pop)
int PoPs_unitConversionRatio(char const *_from, char const *_to, double *ratio)
enum PoPs_genre PoPs_getGenre_atIndex(statusMessageReporting *smr, int index)
PoP * PoPs_getParticle_atIndex(int index)
char const * PoP_getName(PoP *pop)
PoP * PoP_makeParticle(statusMessageReporting *smr, enum PoPs_genre genre, char const *name, double mass, char const *massUnit)
double PoPs_getMassInUnitOf(statusMessageReporting *smr, char const *name, char const *unit)
int PoPs_hasNucleus_atIndex(statusMessageReporting *smr, int index, int protonIsNucleus)
char const * unitsDB_addUnitIfNeeded(statusMessageReporting *smr, char const *unit)
void PoPs_print(int sorted)
int PoPs_releasePrivate(statusMessageReporting *)
static int referenceCount
#define POPS_VERSION_MAJOR
@ PoPs_errorToken_badIndex
@ PoPs_errorToken_badName
@ PoPs_errorToken_badUnitConversion
#define POPS_VERSION_MINOR
int PoPs_particleReadDatabase(statusMessageReporting *smr, char const *name)
#define POPS_VERSION_PATCHLEVEL
int PoPs_Bcast2(statusMessageReporting *smr, MPI_Comm comm, int bossRank, unitsDB *unitsRoot, PoPs *popsRoot)
void * MPI_Comm
to pass hd2mpi ////////////////////////////////////////////
const char * name(G4int ptype)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
#define smr_allocateCopyString2(smr, s, forItem)
void * smr_freeMemory(void **p)
int smr_setReportError(statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt,...)
#define smr_malloc2(smr, size, zero, forItem)