24#if defined __cplusplus
34static struct ZSymbol ZSymbols[] = { { 0,
"n" }, { 1,
"H" }, { 2,
"He" }, { 3,
"Li" }, { 4,
"Be" }, { 5,
"B" }, { 6,
"C" },
35 { 7,
"N" }, { 8,
"O" }, { 9,
"F" }, { 10,
"Ne" }, { 11,
"Na" }, { 12,
"Mg" }, { 13,
"Al" }, { 14,
"Si" }, { 15,
"P" },
36 { 16,
"S" }, { 17,
"Cl" }, { 18,
"Ar" }, { 19,
"K" }, { 20,
"Ca" }, { 21,
"Sc" }, { 22,
"Ti" }, { 23,
"V" }, { 24,
"Cr" },
37 { 25,
"Mn" }, { 26,
"Fe" }, { 27,
"Co" }, { 28,
"Ni" }, { 29,
"Cu" }, { 30,
"Zn" }, { 31,
"Ga" }, { 32,
"Ge" }, { 33,
"As" },
38 { 34,
"Se" }, { 35,
"Br" }, { 36,
"Kr" }, { 37,
"Rb" }, { 38,
"Sr" }, { 39,
"Y" }, { 40,
"Zr" }, { 41,
"Nb" }, { 42,
"Mo" },
39 { 43,
"Tc" }, { 44,
"Ru" }, { 45,
"Rh" }, { 46,
"Pd" }, { 47,
"Ag" }, { 48,
"Cd" }, { 49,
"In" }, { 50,
"Sn" }, { 51,
"Sb" },
40 { 52,
"Te" }, { 53,
"I" }, { 54,
"Xe" }, { 55,
"Cs" }, { 56,
"Ba" }, { 57,
"La" }, { 58,
"Ce" }, { 59,
"Pr" }, { 60,
"Nd" },
41 { 61,
"Pm" }, { 62,
"Sm" }, { 63,
"Eu" }, { 64,
"Gd" }, { 65,
"Tb" }, { 66,
"Dy" }, { 67,
"Ho" }, { 68,
"Er" }, { 69,
"Tm" },
42 { 70,
"Yb" }, { 71,
"Lu" }, { 72,
"Hf" }, { 73,
"Ta" }, { 74,
"W" }, { 75,
"Re" }, { 76,
"Os" }, { 77,
"Ir" }, { 78,
"Pt" },
43 { 79,
"Au" }, { 80,
"Hg" }, { 81,
"Tl" }, { 82,
"Pb" }, { 83,
"Bi" }, { 84,
"Po" }, { 85,
"At" }, { 86,
"Rn" }, { 87,
"Fr" },
44 { 88,
"Ra" }, { 89,
"Ac" }, { 90,
"Th" }, { 91,
"Pa" }, { 92,
"U" }, { 93,
"Np" }, { 94,
"Pu" }, { 95,
"Am" }, { 96,
"Cm" },
45 { 97,
"Bk" }, { 98,
"Cf" }, { 99,
"Es" }, { 100,
"Fm" }, { 101,
"Md" }, { 102,
"No" }, { 103,
"Lr" }, { 104,
"Rf" }, { 105,
"Db" },
46 { 106,
"Sg" }, { 107,
"Bh" }, { 108,
"Hs" }, { 109,
"Mt" } };
50 int length,
double *data,
char const *fromUnits[2],
char const *toUnits[2] );
56 return(
sizeof( ZSymbols ) /
sizeof(
struct ZSymbol ) );
64 return( ZSymbols[iZ].symbol );
73 for( i = 0; i < n; i++ ) {
74 if( strcmp( Z, ZSymbols[i].symbol ) == 0 )
return( ZSymbols[i].Z );
84 char s[1024] =
"", *q, *e;
86 if( strlen( name ) >= (
sizeof( s ) - 1 ) ) {
91 *Z = *
A = *m = *level = 0;
92 if( ( !strncmp(
"FissionProduct", name, 14 ) ) || !strncmp(
"99120", name, 5 ) ) {
97 if( strcmp(
"gamma", name ) == 0 )
return( 0 );
98 if( strcmp(
"n", name ) == 0 ) { *
A = 1;
return( 0 ); }
100 for( p = name, q = s; ( *p != 0 ) && !isdigit( *p ) && ( *p !=
'_' ); p++, q++ ) *q = *p;
110 if( strncmp( p,
"_natural", 8 ) == 0 ) {
112 if( *p ) *level = MCGIDI_miscNameToZAm_getLevel( smr, name, p ); }
117 for( q = s; isdigit( *p ); p++, q++ ) *q = *p;
119 if( strcmp( s,
"natural" ) == 0 ) {
123 *
A = (int) strtol( s, &e, 10 );
128 if( *p ) *level = MCGIDI_miscNameToZAm_getLevel( smr, name, p );
148 level = (int) strtol( p, &e, 10 );
173 if( !
smr_isOk( smr ) )
return( NULL );
189 if( !
smr_isOk( smr ) )
return( NULL );
192 if( element != NULL ) {
205 const char *fmt, ... ) {
211 va_start( args, fmt );
216 va_start( args, fmt );
234 if( d < ds[0] )
return( -2 );
235 if( d > ds[n-1] )
return( -1 );
237 imid = ( imin + imax ) >> 1;
238 if( imid == imin )
break;
254 int n = (int) strlen( fileName ) + 1, nCwd = 0;
255 char *absPath, cwd[4 * 1024] =
"", *p, *needle;
257 if( fileName[0] !=
'/' ) {
260 if( getcwd( cwd,
sizeof( cwd ) ) == NULL ) {
264 nCwd = (int) strlen( cwd );
267 if( ( absPath = (
char *)
smr_malloc2( smr, n, 0,
"absPath" ) ) == NULL )
return( NULL );
268 if( fileName[0] !=
'/' ) {
269 strcpy( absPath, cwd );
270 strcat( absPath,
"/" );
271 strcat( absPath, fileName ); }
273 strcpy( absPath, fileName );
277 if( ( needle = strstr( absPath,
"/./" ) ) == NULL )
break;
279 for( needle += 2; *needle; p++, needle++ ) *p = *needle;
283 if( ( needle = strstr( absPath,
"/../" ) ) == NULL )
break;
285 while( ( p > absPath ) && ( *p !=
'/' ) ) p--;
286 if( *p !=
'/' )
break;
287 if( p == absPath )
break;
288 for( needle += 3; *needle; p++, needle++ ) *p = *needle;
302 for( i = 0; ; i++ ) {
317 char const *frameString;
340 while( isspace( *s ) ) s++;
341 *value = strtod( s, &e ) * conversion;
346 while( isspace( *e ) ) e++;
347 if( strcmp( e, unit ) != 0 ) {
362 char const *s1 = str;
366 while( isspace( *s1 ) ) s1++;
367 *value = strtod( s1, &e1 );
372 while( isspace( *e1 ) ) e1++;
385 if( strcmp( fromUnit, toUnit ) == 0 )
return( 1.0 );
387 if( strcmp( fromUnit,
"eV" ) == 0 ) {
388 if( strcmp( toUnit,
"MeV" ) == 0 )
return( 1e-6 ); }
389 else if( strcmp( fromUnit,
"MeV" ) == 0 ) {
390 if( strcmp( toUnit,
"eV" ) == 0 )
return( 1e+6 ); }
391 else if( strcmp( fromUnit,
"1/eV" ) == 0 ) {
392 if( strcmp( toUnit,
"1/MeV" ) == 0 )
return( 1e+6 ); }
393 else if( strcmp( fromUnit,
"1/MeV" ) == 0 ) {
394 if( strcmp( toUnit,
"1/eV" ) == 0 )
return( 1e-6 ); }
395 else if( strcmp( fromUnit,
"K" ) == 0 ) {
396 if( strcmp( toUnit,
"MeV/k" ) == 0 )
return( 8.617343183775137e-11 );
410 char const *fromUnits[2];
413 if( !
smr_isOk( smr ) )
return( NULL );
415 if( !
smr_isOk( smr ) )
return( NULL );
419 return( MCGIDI_misc_Data2ptwXYPointsInUnitsOf( smr, interpolation, length, data, fromUnits, toUnits ) );
429 char const *fromUnits[2];
442 return( MCGIDI_misc_Data2ptwXYPointsInUnitsOf( smr, interpolation, length, data, fromUnits, toUnits ) );
448 int length,
double *data,
char const *fromUnits[2],
char const *toUnits[2] ) {
450 double xFactor, yFactor;
460 ptwXY =
ptwXY_create( interpolation, NULL, 2., 1e-3, length, 10, length, data, &status, 0 );
466 if( ( xFactor != 1. ) || ( yFactor != 1. ) ) {
484 transportabilitiesMap::iterator iter = transportabilities->find( PoPID );
486 if( iter != transportabilities->end( ) ) {
487 switch ( iter->second ) {
491 switch( transportability ) {
507 switch( transportability ) {
519 (*transportabilities)[PoPID] = transportability;
529#if defined __cplusplus
#define MCGIDI_particleLevel_sum
std::map< int, enum GIDI::MCGIDI_transportability > transportabilitiesMap
int MCGIDI_miscNameToZAm(statusMessageReporting *smr, const char *name, int *Z, int *A, int *m, int *level)
#define MCGIDI_particleLevel_continuum
int MCGIDI_misc_PQUStringToDouble(statusMessageReporting *smr, char const *str, char const *unit, double conversion, double *value)
xDataTOM_Int MCGIDI_misc_binarySearch(xDataTOM_Int n, double *ds, double d)
void MCGIDI_misc_updateTransportabilitiesMap2(transportabilitiesMap *transportabilities, int PoPID, int transportable)
@ MCGIDI_transportability_unknown
@ MCGIDI_transportability_none
@ MCGIDI_transportability_partial
@ MCGIDI_transportability_full
void MCGIDI_misc_updateTransportabilitiesMap(transportabilitiesMap *transportabilities, int PoPID, enum MCGIDI_transportability transportability)
int MCGIDI_misc_PQUStringToDoubleInUnitOf(statusMessageReporting *smr, char const *str, char const *toUnit, double *value)
const char * MCGIDI_misc_ZToSymbol(int iZ)
int MCGIDI_misc_symbolToZ(const char *Z)
int MCGIDI_misc_NumberOfZSymbols(void)
int MCGIDI_fromTOM_interpolation(statusMessageReporting *smr, xDataTOM_element *element, int index, enum ptwXY_interpolation_e *interpolation)
ptwXYPoints * MCGIDI_misc_dataFromXYs2ptwXYPointsInUnitsOf(statusMessageReporting *smr, xDataTOM_XYs *XYs, ptwXY_interpolation interpolation, char const *units[2])
ptwXYPoints * MCGIDI_misc_dataFromElement2ptwXYPointsInUnitsOf(statusMessageReporting *smr, xDataTOM_element *linear, char const *toUnits[2])
int MCGIDI_misc_setMessageError_Element(statusMessageReporting *smr, void *userInterface, xDataXML_element *element, char const *file, int line, int code, char const *fmt,...)
char * MCGIDI_misc_getAbsPath(statusMessageReporting *smr, char const *fileName)
double MCGIDI_misc_getUnitConversionFactor(statusMessageReporting *smr, char const *fromUnit, char const *toUnit)
char const * MCGIDI_misc_pointerToTOMAttributeIfAllOk(statusMessageReporting *smr, char const *path, int required, xDataTOM_attributionList *attributes, char const *name, char const *file, int line)
char const * MCGIDI_misc_pointerToAttributeIfAllOk(statusMessageReporting *smr, xDataXML_element *element, char const *path, int required, xDataTOM_attributionList *attributes, char const *name, char const *file, int line)
int MCGIDI_misc_copyXMLAttributesToTOM(statusMessageReporting *smr, xDataTOM_attributionList *TOM, xDataXML_attributionList *XML)
enum xDataTOM_frame MCGIDI_misc_getProductFrame(statusMessageReporting *smr, xDataTOM_element *frameElement)
#define MCGIDI_token_productFrame
enum nfu_status_e nfu_status
const char * nfu_statusMessage(nfu_status status)
nfu_status ptwXY_scaleOffsetXAndY(ptwXYPoints *ptwXY, double xScale, double xOffset, double yScale, double yOffset)
enum ptwXY_interpolation_e ptwXY_interpolation
ptwXYPoints * ptwXY_create(ptwXY_interpolation interpolation, ptwXY_interpolationOtherInfo const *interpolationOtherInfo, double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize, int64_t length, double const *xy, nfu_status *status, int userFlag)
ptwXYPoints * ptwXY_free(ptwXYPoints *ptwXY)
int smr_vsetReportError(statusMessageReporting *smr, void *userInterface, char const *file, int line, char const *function, int libraryID, int code, char const *fmt, va_list *args)
#define smr_setReportError2(smr, libraryID, code, fmt,...)
#define smr_setReportError2p(smr, libraryID, code, fmt)
char * smr_vallocateFormatMessage(char const *fmt, va_list *args)
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,...)
int smr_isOk(statusMessageReporting *smr)
#define smr_malloc2(smr, size, zero, forItem)
xDataTOM_xDataInfo xDataInfo
int xDataTOMAL_addAttribute(statusMessageReporting *smr, xDataTOM_attributionList *attributes, char const *name, char const *value)
enum xDataTOM_frame xDataTOM_axis_stringToFrame(statusMessageReporting *smr, char const *frame)
void xDataTOMAL_initial(statusMessageReporting *smr, xDataTOM_attributionList *attributes)
int xDataTOM_XYs_getData(xDataTOM_XYs *XYs, double **data)
char const * xDataTOMAL_getAttributesValue(xDataTOM_attributionList *attributes, char const *name)
char const * xDataTOM_getAttributesValueInElement(xDataTOM_element *element, char const *name)
char const * xDataTOM_subAxes_getUnit(statusMessageReporting *smr, xDataTOM_subAxes *subAxes, int index)
int xDataTOM_XYs_getDataFromXDataInfo(xDataTOM_xDataInfo *xDI, double **data)
void xDataTOMAL_release(xDataTOM_attributionList *attributes)
xDataXML_attribute * xDataXML_attributeByIndex(xDataXML_attributionList *attributes, int index)