Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PoPs.cc File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "PoPs.h"
#include "PoPs_private.h"
Include dependency graph for PoPs.cc:

Go to the source code of this file.

Classes

struct  unitConversions_s
 

Macros

#define incrementalSize   1000
 
#define MeV2eV   1e6
 
#define MeV2keV   1e3
 
#define AMU2MeV   931.494028
 
#define AMU2eV   ( MeV2eV * 931.494028 )
 
#define K2MeV   8.6173856922566752e-11
 
#define K2eV   ( MeV2eV * K2MeV )
 

Typedefs

typedef struct unitConversions_s unitConversions
 

Functions

static int PoPs_particleProperIndex (int index)
 
static int PoPs_sortedParticleIndex (char const *name)
 
static int unitsDB_release (void)
 
const char * PoPs_version (void)
 
int PoPs_versionMajor (void)
 
int PoPs_versionMinor (void)
 
int PoPs_versionPatchLevel (void)
 
int PoPs_register (void)
 
int PoPs_readDatabase (statusMessageReporting *smr, char const *fileName)
 
int PoPs_release (statusMessageReporting *smr)
 
int PoPs_releasePrivate (statusMessageReporting *)
 
PoPPoPs_addParticleIfNeeded (statusMessageReporting *smr, PoP *pop)
 
PoPPoPs_copyAddParticleIfNeeded (statusMessageReporting *smr, PoP *pop)
 
PoPPoPs_addAliasIfNeeded (statusMessageReporting *smr, char const *name, char const *alias)
 
int PoPs_numberOfParticle (void)
 
int PoPs_particleIndex (char const *name)
 
int PoPs_particleIndex_smr (statusMessageReporting *smr, char const *name, char const *file, int line, char const *func)
 
double PoPs_getMassInUnitOf (statusMessageReporting *smr, char const *name, char const *unit)
 
char const * PoPs_getName_atIndex (statusMessageReporting *smr, int index)
 
double PoPs_getMassInUnitOf_atIndex (statusMessageReporting *smr, int index, char const *unit)
 
enum PoPs_genre PoPs_getGenre (statusMessageReporting *smr, char const *name)
 
enum PoPs_genre PoPs_getGenre_atIndex (statusMessageReporting *smr, int index)
 
int PoPs_getZ_A_l (statusMessageReporting *smr, char const *name, int *Z, int *A, int *l)
 
int PoPs_getZ_A_l_atIndex (statusMessageReporting *smr, int index, int *Z, int *A, int *l)
 
int PoPs_hasNucleus (statusMessageReporting *smr, char const *name, int protonIsNucleus)
 
int PoPs_hasNucleus_atIndex (statusMessageReporting *smr, int index, int protonIsNucleus)
 
char const * PoPs_getAtomsName (statusMessageReporting *smr, char const *name)
 
char const * PoPs_getAtomsName_atIndex (statusMessageReporting *smr, int index)
 
int PoPs_getAtomsIndex (statusMessageReporting *smr, char const *name)
 
int PoPs_getAtomsIndex_atIndex (statusMessageReporting *smr, int index)
 
PoPPoPs_getParticle_atIndex (int index)
 
char const * PoPs_genreTokenToString (enum PoPs_genre genre)
 
void PoPs_print (int sorted)
 
void PoPs_write (FILE *f, int sorted)
 
PoPPoP_new (statusMessageReporting *smr)
 
int PoP_initialize (statusMessageReporting *, PoP *pop)
 
int PoP_release (PoP *pop)
 
PoPPoP_free (PoP *pop)
 
int PoP_copyParticle (statusMessageReporting *smr, PoP *desc, PoP *src)
 
PoPPoP_makeParticle (statusMessageReporting *smr, enum PoPs_genre genre, char const *name, double mass, char const *massUnit)
 
int PoP_setZ_A_l (statusMessageReporting *, PoP *pop, int Z, int A, int l)
 
int PoP_getIndex (PoP *pop)
 
char const * PoP_getName (PoP *pop)
 
double PoP_getMassInUnitOf (statusMessageReporting *smr, PoP *pop, char const *unit)
 
PoPPoP_makeAlias (statusMessageReporting *smr, char const *name, char const *alias)
 
char const * unitsDB_addUnitIfNeeded (statusMessageReporting *smr, char const *unit)
 
int unitsDB_index (statusMessageReporting *, char const *unit)
 
char const * unitsDB_stringFromIndex (statusMessageReporting *smr, int index)
 
int PoPs_unitConversionRatio (char const *_from, char const *_to, double *ratio)
 

Variables

int PoPs_smr_ID = smr_unknownID
 
static int referenceCount = 0
 
static char versionStr [64] = ""
 
static unitsDB unitsRoot = { 0, 0, NULL }
 
static PoPs popsRoot = { 0, 0, NULL, NULL }
 
static unitConversions conversions []
 
static char const * PoPs_genreStrings [] = { "invalid", "unknown", "alias", "photon", "lepton", "quark", "meson", "baryon", "nucleus", "atom" }
 

Macro Definition Documentation

#define AMU2eV   ( MeV2eV * 931.494028 )

Definition at line 23 of file PoPs.cc.

#define AMU2MeV   931.494028

Definition at line 22 of file PoPs.cc.

#define incrementalSize   1000

Definition at line 18 of file PoPs.cc.

#define K2eV   ( MeV2eV * K2MeV )

Definition at line 25 of file PoPs.cc.

#define K2MeV   8.6173856922566752e-11

Definition at line 24 of file PoPs.cc.

#define MeV2eV   1e6

Definition at line 20 of file PoPs.cc.

#define MeV2keV   1e3

Definition at line 21 of file PoPs.cc.

Typedef Documentation

Definition at line 27 of file PoPs.cc.

Function Documentation

int PoP_copyParticle ( statusMessageReporting smr,
PoP desc,
PoP src 
)

Definition at line 567 of file PoPs.cc.

567  {
568 
569  desc->index = -1;
570  desc->properIndex = src->properIndex;
571  desc->aliasIndex = src->aliasIndex;
572  desc->genre = src->genre;
573  if( ( desc->name = smr_allocateCopyString2( smr, src->name, "desc->name" ) ) == NULL ) return( 1 );
574  desc->Z = src->Z;
575  desc->A = src->A;
576  desc->l = src->l;
577  desc->mass = src->mass;
578  desc->massUnit = src->massUnit;
579 
580  return( 0 );
581 }
#define smr_allocateCopyString2(smr, s, forItem)
int l
Definition: PoPs.h:49
int A
Definition: PoPs.h:49
char const * massUnit
Definition: PoPs.h:51
enum PoPs_genre genre
Definition: PoPs.h:47
int index
Definition: PoPs.h:46
double mass
Definition: PoPs.h:50
int aliasIndex
Definition: PoPs.h:46
char const * name
Definition: PoPs.h:48
int properIndex
Definition: PoPs.h:46
int Z
Definition: PoPs.h:49

Here is the caller graph for this function:

PoP* PoP_free ( PoP pop)

Definition at line 558 of file PoPs.cc.

558  {
559 
560  PoP_release( pop );
561  smr_freeMemory( (void **) &pop );
562  return( NULL );
563 }
int PoP_release(PoP *pop)
Definition: PoPs.cc:549
void * smr_freeMemory(void **p)

Here is the call graph for this function:

Here is the caller graph for this function:

int PoP_getIndex ( PoP pop)

Definition at line 612 of file PoPs.cc.

612  {
613 
614  return( pop->index );
615 }
int index
Definition: PoPs.h:46
double PoP_getMassInUnitOf ( statusMessageReporting smr,
PoP pop,
char const *  unit 
)

Definition at line 626 of file PoPs.cc.

626  {
627 
628  double mass = -1., ratio;
629  /* PoP *pop_ = pop;*/
630 
631  /*if( pop->genre == PoPs_genre_alias ) pop_ = popsRoot.pops[PoPs_particleProperIndex( pop->index )];*/
632  if( PoPs_unitConversionRatio( pop->massUnit, unit, &ratio ) != 0 ) {
633  smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badUnitConversion, "could not convert unit '%s' to '%s'", pop->massUnit, unit ); }
634  else {
635  mass = pop->mass * ratio;
636  }
637 
638  return( mass );
639 }
char const * massUnit
Definition: PoPs.h:51
int PoPs_smr_ID
Definition: PoPs.cc:35
#define smr_setReportError2(smr, libraryID, code, fmt,...)
int PoPs_unitConversionRatio(char const *_from, char const *_to, double *ratio)
Definition: PoPs.cc:748
double mass
Definition: PoPs.h:50

Here is the call graph for this function:

Here is the caller graph for this function:

char const* PoP_getName ( PoP pop)

Definition at line 619 of file PoPs.cc.

619  {
620 
621  return( pop->name );
622 }
char const * name
Definition: PoPs.h:48
int PoP_initialize ( statusMessageReporting ,
PoP pop 
)

Definition at line 533 of file PoPs.cc.

533  {
534 
535  pop->index = -1;
536  pop->properIndex = -1;
537  pop->aliasIndex = -1;
538  pop->genre = PoPs_genre_unknown;
539  pop->name = NULL;
540  pop->Z = 0;
541  pop->A = 0;
542  pop->mass = 0.0;
543  pop->massUnit = NULL;
544  return( 0 );
545 }
int A
Definition: PoPs.h:49
char const * massUnit
Definition: PoPs.h:51
enum PoPs_genre genre
Definition: PoPs.h:47
int index
Definition: PoPs.h:46
double mass
Definition: PoPs.h:50
int aliasIndex
Definition: PoPs.h:46
char const * name
Definition: PoPs.h:48
int properIndex
Definition: PoPs.h:46
int Z
Definition: PoPs.h:49

Here is the caller graph for this function:

PoP* PoP_makeAlias ( statusMessageReporting smr,
char const *  name,
char const *  alias 
)

Definition at line 647 of file PoPs.cc.

647  {
648 
649  int properIndex = PoPs_particleIndex( name ), aliasIndex = PoPs_particleIndex( alias );
650  PoP *pop;
651 
652  if( properIndex < 0 ) {
653  smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badName, "proper particle '%s' not in PoPs for alias '%s'", name, alias );
654  return( NULL );
655  }
656  if( aliasIndex >= 0 ) { /* alias has already been defined. */
657  PoP *truePop = popsRoot.pops[aliasIndex];
658 
659  for( pop = truePop; strcmp( alias, pop->name ); pop = popsRoot.pops[aliasIndex] ) aliasIndex = pop->aliasIndex;
660  if( pop->genre != PoPs_genre_alias ) {
661  smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badName, "particle '%s' already in PoPs and not an alias", alias );
662  return( NULL );
663  }
664  if( pop->properIndex != properIndex ) {
665  smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badName, "particle '%s' already an alias for '%s', cannot re-alias to '%s'",
666  alias, truePop->name, name );
667  return( NULL );
668  } }
669  else {
670  if( ( pop = PoP_new( smr ) ) == NULL ) return( NULL );
671  if( ( pop->name = smr_allocateCopyString2( smr, alias, "name" ) ) == NULL ) {
672  PoP_free( pop );
673  return( NULL );
674  }
675  pop->properIndex = properIndex;
676  pop->genre = PoPs_genre_alias;
677  }
678  return( pop );
679 }
const XML_Char * name
Definition: expat.h:151
PoP * PoP_new(statusMessageReporting *smr)
Definition: PoPs.cc:522
#define smr_allocateCopyString2(smr, s, forItem)
enum PoPs_genre genre
Definition: PoPs.h:47
int PoPs_smr_ID
Definition: PoPs.cc:35
#define smr_setReportError2(smr, libraryID, code, fmt,...)
PoP * PoP_free(PoP *pop)
Definition: PoPs.cc:558
int aliasIndex
Definition: PoPs.h:46
char const * name
Definition: PoPs.h:48
Definition: PoPs.h:45
int properIndex
Definition: PoPs.h:46
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43
int PoPs_particleIndex(char const *name)
Definition: PoPs.cc:204

Here is the call graph for this function:

Here is the caller graph for this function:

PoP* PoP_makeParticle ( statusMessageReporting smr,
enum PoPs_genre  genre,
char const *  name,
double  mass,
char const *  massUnit 
)

Definition at line 585 of file PoPs.cc.

585  {
586 
587  PoP *pop;
588 
589  if( ( pop = PoP_new( smr ) ) == NULL ) return( NULL );
590  if( ( pop->name = smr_allocateCopyString2( smr, name, "name" ) ) == NULL ) {
591  PoP_free( pop );
592  return( NULL );
593  }
594  pop->genre = genre;
595  pop->mass = mass;
596  if( ( pop->massUnit = unitsDB_addUnitIfNeeded( smr, massUnit ) ) == NULL ) pop = PoP_free( pop );
597  return( pop );
598 }
const XML_Char * name
Definition: expat.h:151
PoP * PoP_new(statusMessageReporting *smr)
Definition: PoPs.cc:522
#define smr_allocateCopyString2(smr, s, forItem)
char const * massUnit
Definition: PoPs.h:51
enum PoPs_genre genre
Definition: PoPs.h:47
double mass
Definition: PoPs.h:50
PoP * PoP_free(PoP *pop)
Definition: PoPs.cc:558
char const * unitsDB_addUnitIfNeeded(statusMessageReporting *smr, char const *unit)
Definition: PoPs.cc:700
char const * name
Definition: PoPs.h:48
Definition: PoPs.h:45

Here is the call graph for this function:

PoP* PoP_new ( statusMessageReporting smr)

Definition at line 522 of file PoPs.cc.

522  {
523 
524  PoP *pop;
525 
526  if( ( pop = (PoP *) smr_malloc2( smr, sizeof( PoP ), 0, "pop" ) ) == NULL ) return( NULL );
527  if( PoP_initialize( smr, pop ) != 0 ) pop = PoP_free( pop );
528  return( pop );
529 }
int PoP_initialize(statusMessageReporting *smr, PoP *pop)
Definition: PoPs.cc:533
#define smr_malloc2(smr, size, zero, forItem)
PoP * PoP_free(PoP *pop)
Definition: PoPs.cc:558
Definition: PoPs.h:45

Here is the call graph for this function:

Here is the caller graph for this function:

int PoP_release ( PoP pop)

Definition at line 549 of file PoPs.cc.

549  {
550 
551  if( pop->name != NULL ) smr_freeMemory( (void **) &(pop->name ) );
552  PoP_initialize( NULL, pop ); /* Make it clean in case someone trys to use if. */
553  return( 0 );
554 }
int PoP_initialize(statusMessageReporting *smr, PoP *pop)
Definition: PoPs.cc:533
void * smr_freeMemory(void **p)
char const * name
Definition: PoPs.h:48

Here is the call graph for this function:

Here is the caller graph for this function:

int PoP_setZ_A_l ( statusMessageReporting ,
PoP pop,
int  Z,
int  A,
int  l 
)

Definition at line 602 of file PoPs.cc.

602  {
603 
604  pop->Z = Z;
605  pop->A = A;
606  pop->l = l;
607  return( 0 );
608 }
int l
Definition: PoPs.h:49
int A
Definition: PoPs.h:49
double A(double temperature)
int Z
Definition: PoPs.h:49

Here is the call graph for this function:

PoP* PoPs_addAliasIfNeeded ( statusMessageReporting smr,
char const *  name,
char const *  alias 
)

Definition at line 179 of file PoPs.cc.

179  {
180 
181  PoP *pop = PoP_makeAlias( smr, name, alias );
182 
183  if( pop != NULL ) {
184  if( pop->index < 0 ) {
185  if( PoPs_addParticleIfNeeded( smr, pop ) == NULL ) {
186  PoP_free( pop );
187  return( NULL );
188  }
189  }
190  }
191 
192  return( pop );
193 }
const XML_Char * name
Definition: expat.h:151
PoP * PoP_makeAlias(statusMessageReporting *smr, char const *name, char const *alias)
Definition: PoPs.cc:647
int index
Definition: PoPs.h:46
PoP * PoPs_addParticleIfNeeded(statusMessageReporting *smr, PoP *pop)
Definition: PoPs.cc:113
PoP * PoP_free(PoP *pop)
Definition: PoPs.cc:558
Definition: PoPs.h:45

Here is the call graph for this function:

Here is the caller graph for this function:

PoP* PoPs_addParticleIfNeeded ( statusMessageReporting smr,
PoP pop 
)

Definition at line 113 of file PoPs.cc.

113  {
114 /*
115  If particle with name pop->name is already in popsRoot, returns the pointer to the existing particle.
116  A NULL is returned if adding particle to popsRoot fails.
117 */
118  int i, index = PoPs_sortedParticleIndex( pop->name );
119 
120  if( index >= 0 ) return( popsRoot.pops[PoPs_particleProperIndex( popsRoot.sorted[index]->index )] );
122  int size = popsRoot.allocated + incrementalSize;
123  PoP **sorted, **pops = (PoP **) smr_malloc2( smr, 2 * size * sizeof( PoPs * ), 0, "pops" );
124 
125  if( pops == NULL ) return( NULL );
126  sorted = &(pops[size]);
127  for( i = 0; i < popsRoot.numberOfParticles; i++ ) {
128  pops[i] = popsRoot.pops[i];
129  sorted[i] = popsRoot.sorted[i];
130  }
131  smr_freeMemory( (void **) &(popsRoot.pops) );
132  popsRoot.pops = pops;
133  popsRoot.sorted = sorted;
134  popsRoot.allocated = size;
135  }
137  index = -index - 1;
138  for( i = popsRoot.numberOfParticles; i > index; i-- ) popsRoot.sorted[i] = popsRoot.sorted[i-1];
139  popsRoot.sorted[index] = pop;
142  if( pop->genre == PoPs_genre_alias ) { /* Add pop->index to end of list of particles aliased by pop->properIndex. */
143  PoP *pop2;
144 
145  for( pop2 = popsRoot.pops[pop->properIndex]; pop2->aliasIndex >= 0; pop2 = popsRoot.pops[pop2->aliasIndex] ) ;
146  pop2->aliasIndex = pop->index;
147  }
148  return( pop );
149 }
int allocated
Definition: PoPs_private.h:25
PoP ** sorted
Definition: PoPs_private.h:27
static int PoPs_particleProperIndex(int index)
Definition: PoPs.cc:227
static int PoPs_sortedParticleIndex(char const *name)
Definition: PoPs.cc:235
enum PoPs_genre genre
Definition: PoPs.h:47
#define incrementalSize
Definition: PoPs.cc:18
int index
Definition: PoPs.h:46
#define smr_malloc2(smr, size, zero, forItem)
int aliasIndex
Definition: PoPs.h:46
void * smr_freeMemory(void **p)
char const * name
Definition: PoPs.h:48
Definition: PoPs.h:45
int properIndex
Definition: PoPs.h:46
int numberOfParticles
Definition: PoPs_private.h:24
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43

Here is the call graph for this function:

Here is the caller graph for this function:

PoP* PoPs_copyAddParticleIfNeeded ( statusMessageReporting smr,
PoP pop 
)

Definition at line 153 of file PoPs.cc.

153  {
154 /*
155  If particle with name pop->name is already in popsRoot, return the address of the existing particle.
156  If particle is not in popsRoot then copy particle to a new 'PoP *', add the copied PoP to popsRoot and return its address.
157  A NULL is return if particle coping fails or adding particle to popsRoot fails.
158 */
159 
160  int index = PoPs_particleIndex( pop->name );
161  PoP *newPoP;
162 
163  if( index >= 0 ) return( popsRoot.pops[index] );
164 
165  if( ( newPoP = (PoP *) smr_malloc2( smr, sizeof( PoP ), 0, "newPoP" ) ) == NULL ) return( NULL );
166  if( PoP_copyParticle( smr, newPoP, pop ) ) {
167  smr_freeMemory( (void **) &newPoP );
168  return( NULL );
169  }
170  if( PoPs_addParticleIfNeeded( smr, newPoP ) == NULL ) {
171  PoP_free( newPoP );
172  return( NULL );
173  }
174  return( newPoP );
175 }
int PoP_copyParticle(statusMessageReporting *smr, PoP *desc, PoP *src)
Definition: PoPs.cc:567
#define smr_malloc2(smr, size, zero, forItem)
PoP * PoPs_addParticleIfNeeded(statusMessageReporting *smr, PoP *pop)
Definition: PoPs.cc:113
PoP * PoP_free(PoP *pop)
Definition: PoPs.cc:558
void * smr_freeMemory(void **p)
char const * name
Definition: PoPs.h:48
Definition: PoPs.h:45
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43
int PoPs_particleIndex(char const *name)
Definition: PoPs.cc:204

Here is the call graph for this function:

char const* PoPs_genreTokenToString ( enum PoPs_genre  genre)

Definition at line 446 of file PoPs.cc.

446  {
447 
448  if( genre < PoPs_genre_invalid ) return( NULL );
449  if( genre > PoPs_genre_atom ) return( NULL );
450  return( PoPs_genreStrings[genre] );
451 }
static char const * PoPs_genreStrings[]
Definition: PoPs.cc:51

Here is the caller graph for this function:

int PoPs_getAtomsIndex ( statusMessageReporting smr,
char const *  name 
)

Definition at line 397 of file PoPs.cc.

397  {
398 
399  int index = PoPs_particleIndex_smr( smr, name, __FILE__, __LINE__, __func__ );
400 
401  if( index < 0 ) return( index );
402  return( PoPs_getAtomsIndex_atIndex( smr, index ) );
403 }
const XML_Char * name
Definition: expat.h:151
int PoPs_particleIndex_smr(statusMessageReporting *smr, char const *name, char const *file, int line, char const *func)
Definition: PoPs.cc:216
int PoPs_getAtomsIndex_atIndex(statusMessageReporting *smr, int index)
Definition: PoPs.cc:407

Here is the call graph for this function:

int PoPs_getAtomsIndex_atIndex ( statusMessageReporting smr,
int  index 
)

Definition at line 407 of file PoPs.cc.

407  {
408 
409  char const *p = NULL;
410 
411  if( ( index < 0 ) || ( index >= popsRoot.numberOfParticles ) ) {
412  smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badIndex, "index %d not in PoPs", index );
413  return( -1 );
414  }
415 
416  if( popsRoot.pops[index]->genre == PoPs_genre_atom ) return( index );
417 
418  if( strcmp( "p", popsRoot.pops[index]->name ) == 0 ) {
419  p = "H1"; }
420  else {
421  if( popsRoot.pops[index]->genre != PoPs_genre_nucleus ) return( -1 );
422  else if( strcmp( "h2", popsRoot.pops[index]->name ) == 0 ) {
423  p = "H2"; }
424  else if( strcmp( "h3", popsRoot.pops[index]->name ) == 0 ) {
425  p = "H3"; }
426  else if( strcmp( "he3", popsRoot.pops[index]->name ) == 0 ) {
427  p = "He3"; }
428  else if( strcmp( "he4", popsRoot.pops[index]->name ) == 0 ) {
429  p = "He4";
430  }
431  }
432  if( p != NULL ) return( PoPs_particleIndex_smr( smr, p, __FILE__, __LINE__, __func__ ) );
433  return( -1 );
434 }
const char * p
Definition: xmltok.h:285
int PoPs_particleIndex_smr(statusMessageReporting *smr, char const *name, char const *file, int line, char const *func)
Definition: PoPs.cc:216
enum PoPs_genre genre
Definition: PoPs.h:47
int PoPs_smr_ID
Definition: PoPs.cc:35
#define smr_setReportError2(smr, libraryID, code, fmt,...)
char const * name
Definition: PoPs.h:48
int numberOfParticles
Definition: PoPs_private.h:24
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43

Here is the call graph for this function:

Here is the caller graph for this function:

char const* PoPs_getAtomsName ( statusMessageReporting smr,
char const *  name 
)

Definition at line 377 of file PoPs.cc.

377  {
378 
379  int index = PoPs_particleIndex_smr( smr, name, __FILE__, __LINE__, __func__ );
380 
381  if( index < 0 ) return( NULL );
382  return( PoPs_getAtomsName_atIndex( smr, index ) );
383 }
const XML_Char * name
Definition: expat.h:151
int PoPs_particleIndex_smr(statusMessageReporting *smr, char const *name, char const *file, int line, char const *func)
Definition: PoPs.cc:216
char const * PoPs_getAtomsName_atIndex(statusMessageReporting *smr, int index)
Definition: PoPs.cc:387

Here is the call graph for this function:

char const* PoPs_getAtomsName_atIndex ( statusMessageReporting smr,
int  index 
)

Definition at line 387 of file PoPs.cc.

387  {
388 
389  int atomIndex = PoPs_getAtomsIndex_atIndex( smr, index );
390 
391  if( atomIndex < 0 ) return( NULL );
392  return( popsRoot.pops[atomIndex]->name );
393 }
int PoPs_getAtomsIndex_atIndex(statusMessageReporting *smr, int index)
Definition: PoPs.cc:407
char const * name
Definition: PoPs.h:48
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43

Here is the call graph for this function:

Here is the caller graph for this function:

enum PoPs_genre PoPs_getGenre ( statusMessageReporting smr,
char const *  name 
)

Definition at line 301 of file PoPs.cc.

301  {
302 
303  int index = PoPs_particleIndex_smr( smr, name, __FILE__, __LINE__, __func__ );
304 
305  if( index < 0 ) return( PoPs_genre_invalid );
306  return( popsRoot.pops[index]->genre );
307 }
const XML_Char * name
Definition: expat.h:151
int PoPs_particleIndex_smr(statusMessageReporting *smr, char const *name, char const *file, int line, char const *func)
Definition: PoPs.cc:216
enum PoPs_genre genre
Definition: PoPs.h:47
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43

Here is the call graph for this function:

enum PoPs_genre PoPs_getGenre_atIndex ( statusMessageReporting smr,
int  index 
)

Definition at line 311 of file PoPs.cc.

311  {
312 
313  enum PoPs_genre genre = PoPs_genre_invalid;
314 
315  if( ( index < 0 ) || ( index >= popsRoot.numberOfParticles ) ) {
316  smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badIndex, "index %d not in PoPs", index ); }
317  else {
318  genre = popsRoot.pops[index]->genre;
319  }
320  return( genre );
321 }
PoPs_genre
Definition: PoPs.h:36
enum PoPs_genre genre
Definition: PoPs.h:47
int PoPs_smr_ID
Definition: PoPs.cc:35
#define smr_setReportError2(smr, libraryID, code, fmt,...)
int numberOfParticles
Definition: PoPs_private.h:24
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43
double PoPs_getMassInUnitOf ( statusMessageReporting smr,
char const *  name,
char const *  unit 
)

Definition at line 265 of file PoPs.cc.

265  {
266 
267  int index = PoPs_particleIndex_smr( smr, name, __FILE__, __LINE__, __func__ );
268 
269  if( index < 0 ) return( -1. );
270  return( PoPs_getMassInUnitOf_atIndex( smr, index, unit ) );
271 }
const XML_Char * name
Definition: expat.h:151
double PoPs_getMassInUnitOf_atIndex(statusMessageReporting *smr, int index, char const *unit)
Definition: PoPs.cc:286
int PoPs_particleIndex_smr(statusMessageReporting *smr, char const *name, char const *file, int line, char const *func)
Definition: PoPs.cc:216

Here is the call graph for this function:

double PoPs_getMassInUnitOf_atIndex ( statusMessageReporting smr,
int  index,
char const *  unit 
)

Definition at line 286 of file PoPs.cc.

286  {
287 
288  double mass = -1.;
289 
290  if( ( index < 0 ) || ( index >= popsRoot.numberOfParticles ) ) {
291  smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badIndex, "index %d not in PoPs", index ); }
292  else {
293  mass = PoP_getMassInUnitOf( smr, popsRoot.pops[index], unit );
294  }
295 
296  return( mass );
297 }
int PoPs_smr_ID
Definition: PoPs.cc:35
#define smr_setReportError2(smr, libraryID, code, fmt,...)
int numberOfParticles
Definition: PoPs_private.h:24
double PoP_getMassInUnitOf(statusMessageReporting *smr, PoP *pop, char const *unit)
Definition: PoPs.cc:626
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43

Here is the call graph for this function:

Here is the caller graph for this function:

char const* PoPs_getName_atIndex ( statusMessageReporting smr,
int  index 
)

Definition at line 275 of file PoPs.cc.

275  {
276 
277  if( ( index < 0 ) || ( index >= popsRoot.numberOfParticles ) ) {
278  smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badIndex, "index %d not in PoPs", index );
279  return( NULL );
280  }
281  return( popsRoot.pops[index]->name );
282 }
int PoPs_smr_ID
Definition: PoPs.cc:35
#define smr_setReportError2(smr, libraryID, code, fmt,...)
char const * name
Definition: PoPs.h:48
int numberOfParticles
Definition: PoPs_private.h:24
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43

Here is the caller graph for this function:

PoP* PoPs_getParticle_atIndex ( int  index)

Definition at line 438 of file PoPs.cc.

438  {
439 
440  if( ( index < 0 ) || ( index >= popsRoot.numberOfParticles ) ) return( NULL );
441  return( popsRoot.pops[index] );
442 }
int numberOfParticles
Definition: PoPs_private.h:24
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43
int PoPs_getZ_A_l ( statusMessageReporting smr,
char const *  name,
int Z,
int A,
int l 
)

Definition at line 325 of file PoPs.cc.

325  {
326 
327  int index = PoPs_particleIndex_smr( smr, name, __FILE__, __LINE__, __func__ );
328 
329  if( index < 0 ) return( -1 );
330  return( PoPs_getZ_A_l_atIndex( smr, index, Z, A, l ) );
331 }
const XML_Char * name
Definition: expat.h:151
int PoPs_getZ_A_l_atIndex(statusMessageReporting *smr, int index, int *Z, int *A, int *l)
Definition: PoPs.cc:335
int PoPs_particleIndex_smr(statusMessageReporting *smr, char const *name, char const *file, int line, char const *func)
Definition: PoPs.cc:216
double A(double temperature)

Here is the call graph for this function:

int PoPs_getZ_A_l_atIndex ( statusMessageReporting smr,
int  index,
int Z,
int A,
int l 
)

Definition at line 335 of file PoPs.cc.

335  {
336 
337  if( ( index < 0 ) || ( index >= popsRoot.numberOfParticles ) ) {
338  smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badIndex, "index %d not in PoPs", index );
339  return( -1 );
340  }
341  *Z = popsRoot.pops[index]->Z;
342  *A = popsRoot.pops[index]->A;
343  *l = 0;
344  return( 0 );
345 }
int A
Definition: PoPs.h:49
int PoPs_smr_ID
Definition: PoPs.cc:35
double A(double temperature)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
int numberOfParticles
Definition: PoPs_private.h:24
int Z
Definition: PoPs.h:49
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43

Here is the caller graph for this function:

int PoPs_hasNucleus ( statusMessageReporting smr,
char const *  name,
int  protonIsNucleus 
)

Definition at line 349 of file PoPs.cc.

349  {
350 
351  int index = PoPs_particleIndex_smr( smr, name, __FILE__, __LINE__, __func__ );
352 
353  if( index < 0 ) return( -1 );
354  return( PoPs_hasNucleus_atIndex( smr, index, protonIsNucleus ) );
355 }
const XML_Char * name
Definition: expat.h:151
int PoPs_particleIndex_smr(statusMessageReporting *smr, char const *name, char const *file, int line, char const *func)
Definition: PoPs.cc:216
int PoPs_hasNucleus_atIndex(statusMessageReporting *smr, int index, int protonIsNucleus)
Definition: PoPs.cc:359

Here is the call graph for this function:

Here is the caller graph for this function:

int PoPs_hasNucleus_atIndex ( statusMessageReporting smr,
int  index,
int  protonIsNucleus 
)

Definition at line 359 of file PoPs.cc.

359  {
360 /*
361 * If an error is encountered, a negative value is returned. A value greater than 0 means the particle
362 * contains a nucleus (is an atom, ion or nucleus). Otherwise, a 0 is returned.
363 */
364  if( ( index < 0 ) || ( index >= popsRoot.numberOfParticles ) ) {
365  smr_setReportError2( smr, PoPs_smr_ID, PoPs_errorToken_badIndex, "index %d not in PoPs", index );
366  return( -1 );
367  }
368  if( ( popsRoot.pops[index]->genre == PoPs_genre_nucleus ) || ( popsRoot.pops[index]->genre == PoPs_genre_atom ) ) return( 1 );
369  if( protonIsNucleus ) {
370  if( strcmp( "p", popsRoot.pops[index]->name ) == 0 ) return( 1 );
371  }
372  return( 0 );
373 }
enum PoPs_genre genre
Definition: PoPs.h:47
int PoPs_smr_ID
Definition: PoPs.cc:35
#define smr_setReportError2(smr, libraryID, code, fmt,...)
char const * name
Definition: PoPs.h:48
int numberOfParticles
Definition: PoPs_private.h:24
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43

Here is the caller graph for this function:

int PoPs_numberOfParticle ( void  )

Definition at line 197 of file PoPs.cc.

197  {
198 
199  return( popsRoot.numberOfParticles );
200 }
int numberOfParticles
Definition: PoPs_private.h:24
static PoPs popsRoot
Definition: PoPs.cc:43
int PoPs_particleIndex ( char const *  name)

Definition at line 204 of file PoPs.cc.

204  {
205 /*
206  A negative number is return if particle is not in popsRoot. Else, the Id of the real (not aliased) particle is returned.
207 */
208  int index = PoPs_sortedParticleIndex( name );
209 
210  if( index >= 0 ) index = PoPs_particleProperIndex( popsRoot.sorted[index]->index );
211  return( index );
212 }
const XML_Char * name
Definition: expat.h:151
PoP ** sorted
Definition: PoPs_private.h:27
static int PoPs_particleProperIndex(int index)
Definition: PoPs.cc:227
static int PoPs_sortedParticleIndex(char const *name)
Definition: PoPs.cc:235
int index
Definition: PoPs.h:46
static PoPs popsRoot
Definition: PoPs.cc:43

Here is the call graph for this function:

Here is the caller graph for this function:

int PoPs_particleIndex_smr ( statusMessageReporting smr,
char const *  name,
char const *  file,
int  line,
char const *  func 
)

Definition at line 216 of file PoPs.cc.

216  {
217 
218  int index = PoPs_particleIndex( name );
219 
220  if( index < 0 )
221  smr_setReportError( smr, NULL, file, line, func, PoPs_smr_ID, PoPs_errorToken_badName, "particle '%s' not in PoPs", name );
222  return( index );
223 }
const XML_Char * name
Definition: expat.h:151
int PoPs_smr_ID
Definition: PoPs.cc:35
int smr_setReportError(statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt,...)
int PoPs_particleIndex(char const *name)
Definition: PoPs.cc:204

Here is the call graph for this function:

Here is the caller graph for this function:

static int PoPs_particleProperIndex ( int  index)
static

Definition at line 227 of file PoPs.cc.

227  {
228 
229  while( popsRoot.pops[index]->properIndex >= 0 ) index = popsRoot.pops[index]->properIndex; /* For alias particles. */ // Loop checking, 11.05.2015, T. Koi
230  return( index );
231 }
int properIndex
Definition: PoPs.h:46
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43

Here is the caller graph for this function:

void PoPs_print ( int  sorted)

Definition at line 455 of file PoPs.cc.

455  {
456 
457  PoPs_write( stdout, sorted );
458 }
void PoPs_write(FILE *f, int sorted)
Definition: PoPs.cc:462

Here is the call graph for this function:

int PoPs_readDatabase ( statusMessageReporting smr,
char const *  fileName 
)

Definition at line 81 of file PoPs.cc.

81  {
82 
83  return( PoPs_particleReadDatabase( smr, fileName ) );
84 }
int PoPs_particleReadDatabase(statusMessageReporting *smr, char const *name)
Definition: PoPs_data.cc:36

Here is the call graph for this function:

int PoPs_register ( void  )

Definition at line 73 of file PoPs.cc.

73  {
74 
75  if( referenceCount < 0 ) return( -1 );
76  return( ++referenceCount );
77 }
static int referenceCount
Definition: PoPs.cc:36
int PoPs_release ( statusMessageReporting smr)

Definition at line 88 of file PoPs.cc.

88  {
89 
91  if( referenceCount != 0 ) return( referenceCount );
92  PoPs_releasePrivate( smr );
93  return( 0 );
94 }
static int referenceCount
Definition: PoPs.cc:36
int PoPs_releasePrivate(statusMessageReporting *smr)
Definition: PoPs.cc:98

Here is the call graph for this function:

int PoPs_releasePrivate ( statusMessageReporting )

Definition at line 98 of file PoPs.cc.

98  {
99 
100  int i;
101 
102  for( i = 0; i < popsRoot.numberOfParticles; i++ ) PoP_free( popsRoot.pops[i] );
103  smr_freeMemory( (void **) &(popsRoot.pops) );
104  popsRoot.sorted = NULL;
106  popsRoot.allocated = 0;
107  unitsDB_release( );
108  return( 0 );
109 }
int allocated
Definition: PoPs_private.h:25
PoP ** sorted
Definition: PoPs_private.h:27
static int unitsDB_release(void)
Definition: PoPs.cc:687
PoP * PoP_free(PoP *pop)
Definition: PoPs.cc:558
void * smr_freeMemory(void **p)
int numberOfParticles
Definition: PoPs_private.h:24
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43

Here is the call graph for this function:

Here is the caller graph for this function:

static int PoPs_sortedParticleIndex ( char const *  name)
static

Definition at line 235 of file PoPs.cc.

235  {
236 /*
237  If name is a particle in popsRoot, its index in the sorted list is returned; otherwise,
238  a negative number is returned. For a particle not found, its index would be -returnValue + 1 if added;
239 */
240  int low = 0, mid, high = popsRoot.numberOfParticles, iCmp;
241 
242  if( high == 0 ) return( -1 );
243  while( ( high - low ) > 1 ) {
244  mid = ( low + high ) >> 1;
245  iCmp = strcmp( name, popsRoot.sorted[mid]->name );
246  if( iCmp == 0 ) return( mid );
247  if( iCmp > 0 ) {
248  low = mid; }
249  else {
250  high = mid;
251  }
252  } // Loop checking, 11.05.2015, T. Koi
253  if( high == 1 ) { /* First point is not checked as loop exits when ( high = 1 ) - ( low = 0 ) <= 1 ). */
254  if( !strcmp( name, popsRoot.sorted[0]->name ) ) return( 0 ); /* First name is a match. */
255  if( strcmp( name, popsRoot.sorted[0]->name ) < 0 ) return( -1 ); /* name is less than first name. */
256  }
257  if( high < popsRoot.numberOfParticles ) {
258  if( strcmp( name, popsRoot.sorted[high]->name ) == 0 ) return( high );
259  }
260  return( -high - 1 );
261 }
const XML_Char * name
Definition: expat.h:151
PoP ** sorted
Definition: PoPs_private.h:27
char const * name
Definition: PoPs.h:48
int numberOfParticles
Definition: PoPs_private.h:24
static PoPs popsRoot
Definition: PoPs.cc:43

Here is the caller graph for this function:

int PoPs_unitConversionRatio ( char const *  _from,
char const *  _to,
double *  ratio 
)

Definition at line 748 of file PoPs.cc.

748  {
749 
750  int i, n = sizeof( conversions ) / sizeof( conversions[0] );
751 
752  *ratio = 1.;
753  if( strcmp( _from, _to ) == 0 ) return( 0 );
754  for( i = 0; i < n; i++ ) {
755  if( strcmp( conversions[i]._from, _from ) == 0 ) {
756  if( strcmp( conversions[i]._to, _to ) == 0 ) {
757  *ratio = conversions[i].ratio;
758  return( 0 );
759  } }
760  else if( strcmp( conversions[i]._to, _from ) == 0 ) {
761  if( strcmp( conversions[i]._from, _to ) == 0 ) {
762  *ratio = 1. / conversions[i].ratio;
763  return( 0 );
764  }
765  }
766  }
767  return( 1 );
768 }
double ratio
Definition: PoPs.cc:32
static unitConversions conversions[]
Definition: PoPs.cc:48
const G4int n

Here is the caller graph for this function:

const char* PoPs_version ( void  )

Definition at line 59 of file PoPs.cc.

59  {
60 
61  if( versionStr[0] == 0 ) sprintf( versionStr, "PoPs version %d.%d.%d", POPS_VERSION_MAJOR, POPS_VERSION_MINOR, POPS_VERSION_PATCHLEVEL );
62  return( versionStr );
63 }
#define POPS_VERSION_PATCHLEVEL
Definition: PoPs.h:29
static char versionStr[64]
Definition: PoPs.cc:37
#define POPS_VERSION_MINOR
Definition: PoPs.h:28
#define POPS_VERSION_MAJOR
Definition: PoPs.h:27
int PoPs_versionMajor ( void  )

Definition at line 67 of file PoPs.cc.

67 { return( POPS_VERSION_MAJOR ); }
#define POPS_VERSION_MAJOR
Definition: PoPs.h:27
int PoPs_versionMinor ( void  )

Definition at line 68 of file PoPs.cc.

68 { return( POPS_VERSION_MINOR ); }
#define POPS_VERSION_MINOR
Definition: PoPs.h:28
int PoPs_versionPatchLevel ( void  )

Definition at line 69 of file PoPs.cc.

69 { return( POPS_VERSION_PATCHLEVEL ); }
#define POPS_VERSION_PATCHLEVEL
Definition: PoPs.h:29
void PoPs_write ( FILE *  f,
int  sorted 
)

Definition at line 462 of file PoPs.cc.

462  {
463 
464  int i1, properIndex;
465  PoP *pop;
466 
467  fprintf( f, "Mass units: number of units = %d\n", unitsRoot.numberOfUnits );
468  for( i1 = 0; i1 < unitsRoot.numberOfUnits; i1++ ) {
469  fprintf( f, " %s", unitsRoot.unsorted[i1] );
470  }
471  fprintf( f, "\n\n" );
472  fprintf( f, "Particles: number of particles = %d\n", popsRoot.numberOfParticles );
473  fprintf( f, " name index genre mass hasNucleus alias info\n" );
474  fprintf( f, " Z A l\n" );
475  fprintf( f, " --------------------------------------------------------------------------------------------\n" );
476  for( i1 = 0; i1 < popsRoot.numberOfParticles; i1++ ) {
477  if( sorted ) {
478  pop = popsRoot.sorted[i1]; }
479  else {
480  pop = popsRoot.pops[i1];
481  }
482  properIndex = PoPs_particleProperIndex( pop->index );
483  fprintf( f, " %-24s %6d %-10s %15.8e %-6s", pop->name, pop->index, PoPs_genreTokenToString( pop->genre ),
484  popsRoot.pops[properIndex]->mass, popsRoot.pops[properIndex]->massUnit );
485  if( PoPs_hasNucleus( NULL, pop->name, 0 ) ) {
486  fprintf( f, " T" ); }
487  else {
488  fprintf( f, " " );
489  }
490  if( PoPs_hasNucleus( NULL, pop->name, 1 ) ) {
491  fprintf( f, " T" ); }
492  else {
493  fprintf( f, " " );
494  }
495  if( pop->Z + pop->A > 0 ) {
496  fprintf( f, " %3d %3d", pop->Z, pop->A );
497  if( pop->l > 0 ) {
498  fprintf( f, " %d", pop->l ); }
499  else {
500  fprintf( f, " " );
501  } }
502  else {
503  fprintf( f, " " );
504  }
505  if( pop->genre == PoPs_genre_alias ) {
506  fprintf( f, " %s (%d)", popsRoot.pops[properIndex]->name, popsRoot.pops[properIndex]->index ); }
507  else {
508  int aliasIndex;
509 
510  for( aliasIndex = pop->aliasIndex; aliasIndex >= 0; aliasIndex = popsRoot.pops[aliasIndex]->aliasIndex ) fprintf( f, " %d", aliasIndex );
511  }
512  fprintf( f, "\n" );
513  }
514 }
char const * PoPs_genreTokenToString(enum PoPs_genre genre)
Definition: PoPs.cc:446
PoP ** sorted
Definition: PoPs_private.h:27
int l
Definition: PoPs.h:49
int numberOfUnits
Definition: PoPs_private.h:18
int A
Definition: PoPs.h:49
static int PoPs_particleProperIndex(int index)
Definition: PoPs.cc:227
char const * massUnit
Definition: PoPs.h:51
enum PoPs_genre genre
Definition: PoPs.h:47
int index
Definition: PoPs.h:46
double mass
Definition: PoPs.h:50
int aliasIndex
Definition: PoPs.h:46
char const ** unsorted
Definition: PoPs_private.h:20
char const * name
Definition: PoPs.h:48
Definition: PoPs.h:45
static unitsDB unitsRoot
Definition: PoPs.cc:42
int numberOfParticles
Definition: PoPs_private.h:24
int Z
Definition: PoPs.h:49
int PoPs_hasNucleus(statusMessageReporting *smr, char const *name, int protonIsNucleus)
Definition: PoPs.cc:349
PoP ** pops
Definition: PoPs_private.h:26
static PoPs popsRoot
Definition: PoPs.cc:43

Here is the call graph for this function:

Here is the caller graph for this function:

char const* unitsDB_addUnitIfNeeded ( statusMessageReporting smr,
char const *  unit 
)

Definition at line 700 of file PoPs.cc.

700  {
701 
702  int i;
703 
704  for( i = 0; i < unitsRoot.numberOfUnits; i++ ) {
705  if( strcmp( unit, unitsRoot.unsorted[i] ) == 0 ) return( unitsRoot.unsorted[i] );
706  }
708  int size = unitsRoot.allocated + 20;
709  char const **unsorted = (char const **) smr_malloc2( smr, size * sizeof( char * ), 0, "unsorted" );
710 
711  if( unsorted == NULL ) return( NULL );
712  for( i = 0; i < unitsRoot.numberOfUnits; i++ ) unsorted[i] = unitsRoot.unsorted[i];
713  smr_freeMemory( (void **) &(unitsRoot.unsorted) );
714  unitsRoot.unsorted = unsorted;
715  unitsRoot.allocated = size;
716  }
717  if( ( unitsRoot.unsorted[unitsRoot.numberOfUnits] = smr_allocateCopyString2( smr, unit, "unitsRoot.unsorted[unitsRoot.numberOfUnits]" ) ) == NULL )
718  return( NULL );
720  return( unitsRoot.unsorted[unitsRoot.numberOfUnits - 1] );
721 }
#define smr_allocateCopyString2(smr, s, forItem)
int allocated
Definition: PoPs_private.h:19
int numberOfUnits
Definition: PoPs_private.h:18
#define smr_malloc2(smr, size, zero, forItem)
char const ** unsorted
Definition: PoPs_private.h:20
void * smr_freeMemory(void **p)
static unitsDB unitsRoot
Definition: PoPs.cc:42

Here is the call graph for this function:

Here is the caller graph for this function:

int unitsDB_index ( statusMessageReporting ,
char const *  unit 
)

Definition at line 725 of file PoPs.cc.

725  {
726 
727  int i;
728 
729  for( i = 0; i < unitsRoot.numberOfUnits; i++ ) {
730  if( !strcmp( unit, unitsRoot.unsorted[i] ) ) return( i );
731  }
732  return( -1 );
733 }
int numberOfUnits
Definition: PoPs_private.h:18
char const ** unsorted
Definition: PoPs_private.h:20
static unitsDB unitsRoot
Definition: PoPs.cc:42
static int unitsDB_release ( void  )
static

Definition at line 687 of file PoPs.cc.

687  {
688 
689  int i;
690 
691  for( i = 0; i < unitsRoot.numberOfUnits; i++ ) smr_freeMemory( (void **) &(unitsRoot.unsorted[i]) );
692  smr_freeMemory( (void **) &(unitsRoot.unsorted) );
694  unitsRoot.allocated = 0;
695  return( 0 );
696 }
int allocated
Definition: PoPs_private.h:19
int numberOfUnits
Definition: PoPs_private.h:18
char const ** unsorted
Definition: PoPs_private.h:20
void * smr_freeMemory(void **p)
static unitsDB unitsRoot
Definition: PoPs.cc:42

Here is the call graph for this function:

Here is the caller graph for this function:

char const* unitsDB_stringFromIndex ( statusMessageReporting smr,
int  index 
)

Definition at line 737 of file PoPs.cc.

737  {
738 
739  if( ( index < 0 ) || ( index >= unitsRoot.numberOfUnits ) ) {
740  smr_setReportError2( smr, PoPs_smr_ID, 1, "index = %d out of baounds [0 to %d)", index, unitsRoot.numberOfUnits );
741  return( NULL );
742  }
743  return( unitsRoot.unsorted[index] );
744 }
int numberOfUnits
Definition: PoPs_private.h:18
int PoPs_smr_ID
Definition: PoPs.cc:35
#define smr_setReportError2(smr, libraryID, code, fmt,...)
char const ** unsorted
Definition: PoPs_private.h:20
static unitsDB unitsRoot
Definition: PoPs.cc:42

Variable Documentation

unitConversions conversions[]
static
Initial value:
= { { "amu", "eV/c**2", AMU2eV }, { "amu", "MeV/c**2", AMU2MeV }, { "MeV/c**2", "eV/c**2", MeV2eV },
{ "MeV", "eV", MeV2eV }, { "MeV", "keV", MeV2keV }, { "K", "MeV", K2MeV }, { "K", "eV", K2eV } }
#define AMU2MeV
Definition: PoPs.cc:22
#define MeV2keV
Definition: PoPs.cc:21
#define MeV2eV
Definition: PoPs.cc:20
#define AMU2eV
Definition: PoPs.cc:23
#define K2eV
Definition: PoPs.cc:25
#define K2MeV
Definition: PoPs.cc:24

Definition at line 48 of file PoPs.cc.

char const* PoPs_genreStrings[] = { "invalid", "unknown", "alias", "photon", "lepton", "quark", "meson", "baryon", "nucleus", "atom" }
static

Definition at line 51 of file PoPs.cc.

int PoPs_smr_ID = smr_unknownID

Definition at line 35 of file PoPs.cc.

PoPs popsRoot = { 0, 0, NULL, NULL }
static

Definition at line 43 of file PoPs.cc.

int referenceCount = 0
static

Definition at line 36 of file PoPs.cc.

unitsDB unitsRoot = { 0, 0, NULL }
static

Definition at line 42 of file PoPs.cc.

char versionStr[64] = ""
static

Definition at line 37 of file PoPs.cc.