48#if defined __cplusplus
59static struct ZSymbol ZSymbols[] = { { 0,
"n" }, { 1,
"H" }, { 2,
"He" }, { 3,
"Li" }, { 4,
"Be" }, { 5,
"B" }, { 6,
"C" },
60 { 7,
"N" }, { 8,
"O" }, { 9,
"F" }, { 10,
"Ne" }, { 11,
"Na" }, { 12,
"Mg" }, { 13,
"Al" }, { 14,
"Si" }, { 15,
"P" },
61 { 16,
"S" }, { 17,
"Cl" }, { 18,
"Ar" }, { 19,
"K" }, { 20,
"Ca" }, { 21,
"Sc" }, { 22,
"Ti" }, { 23,
"V" }, { 24,
"Cr" },
62 { 25,
"Mn" }, { 26,
"Fe" }, { 27,
"Co" }, { 28,
"Ni" }, { 29,
"Cu" }, { 30,
"Zn" }, { 31,
"Ga" }, { 32,
"Ge" }, { 33,
"As" },
63 { 34,
"Se" }, { 35,
"Br" }, { 36,
"Kr" }, { 37,
"Rb" }, { 38,
"Sr" }, { 39,
"Y" }, { 40,
"Zr" }, { 41,
"Nb" }, { 42,
"Mo" },
64 { 43,
"Tc" }, { 44,
"Ru" }, { 45,
"Rh" }, { 46,
"Pd" }, { 47,
"Ag" }, { 48,
"Cd" }, { 49,
"In" }, { 50,
"Sn" }, { 51,
"Sb" },
65 { 52,
"Te" }, { 53,
"I" }, { 54,
"Xe" }, { 55,
"Cs" }, { 56,
"Ba" }, { 57,
"La" }, { 58,
"Ce" }, { 59,
"Pr" }, { 60,
"Nd" },
66 { 61,
"Pm" }, { 62,
"Sm" }, { 63,
"Eu" }, { 64,
"Gd" }, { 65,
"Tb" }, { 66,
"Dy" }, { 67,
"Ho" }, { 68,
"Er" }, { 69,
"Tm" },
67 { 70,
"Yb" }, { 71,
"Lu" }, { 72,
"Hf" }, { 73,
"Ta" }, { 74,
"W" }, { 75,
"Re" }, { 76,
"Os" }, { 77,
"Ir" }, { 78,
"Pt" },
68 { 79,
"Au" }, { 80,
"Hg" }, { 81,
"Tl" }, { 82,
"Pb" }, { 83,
"Bi" }, { 84,
"Po" }, { 85,
"At" }, { 86,
"Rn" }, { 87,
"Fr" },
69 { 88,
"Ra" }, { 89,
"Ac" }, { 90,
"Th" }, { 91,
"Pa" }, { 92,
"U" }, { 93,
"Np" }, { 94,
"Pu" }, { 95,
"Am" }, { 96,
"Cm" },
70 { 97,
"Bk" }, { 98,
"Cf" }, { 99,
"Es" }, { 100,
"Fm" }, { 101,
"Md" }, { 102,
"No" }, { 103,
"Lr" }, { 104,
"Rf" }, { 105,
"Db" },
71 { 106,
"Sg" }, { 107,
"Bh" }, { 108,
"Hs" }, { 109,
"Mt" } };
78 return(
sizeof( ZSymbols ) /
sizeof(
struct ZSymbol ) );
87 return( ZSymbols[iZ].symbol.c_str() );
96 for( i = 0; i < n; i++ ) {
98 if( !strcmp( Z, ZSymbols[i].symbol.c_str() ) )
return( ZSymbols[i].Z );
109 char s[1024] =
"", *q, *e;
114 if( !strncmp(
"FissionProduct", name, 14 ) ) {
119 if( !strcmp(
"gamma", name ) )
return( 0 );
120 for( p = name, q = s, i = 0; ( *p !=
'_' ) && ( i != n ); p++, q++, i++ ) *q = *p;
122 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Failed to find first '_' in particle name %s", name ); }
126 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Particle %s's symbol = '%s' not found", name, s ); }
128 for( p++, q = s; ( *p !=
'_' ) && ( *p != 0 ) && ( i != n ); p++, q++, i++ ) *q = *p;
130 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Failed to find second '_' in particle name %s", name ); }
133 if( strcmp( s,
"natural" ) == 0 ) {
137 *A = (int) strtol( s, &e, 10 );
140 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Failed to convert A to integer in particle name %s", name ); }
146 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Particle name %s missing meta-stable label 'm'", name ); }
149 *m = (int) strtol( p, &e, 10 );
150 if( *e != 0 )
smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"Failed to convert m to integer in particle name %s", name );
168 if( !
smr_isOk( smr ) )
return( NULL );
171 if( element != NULL ) {
174 smr_setMessageError( smr, NULL, file, line, 1,
"element does not have attribute named %s for file = %d", name, path );
184 const char *fmt, ... ) {
190 va_start( args, fmt );
195 va_start( args, fmt );
199 status =
smr_setMessageError( smr, userInterface, file, line, code,
"%s for element %s at line %d column %d", msg, element->
fullName,
212 if( d < ds[0] )
return( -2 );
213 if( d > ds[n-1] )
return( -1 );
215 imid = ( imin + imax ) >> 1;
216 if( imid == imin )
break;
300 double xsec = 0.0, e1, e2;
302 if( ( index >= crossSection->
start ) && ( index < crossSection->end ) ) {
303 e1 = energyGrid[index];
304 e2 = energyGrid[index + 1];
305 index -= crossSection->
start;
307 xsec = 0.5 * ( crossSection->
data[index] + crossSection->
data[index + 1] ); }
309 xsec = ( crossSection->
data[index] * ( e2 - e_in ) + crossSection->
data[index + 1] * ( e_in - e1 ) ) / ( e2 - e1 );
353 d = (
double *) &(epbs[list->
n]);
354 for( i = 0, epb = epbs; i < list->
n; i++, epb++ ) {
408 r = rng( rngState ); }
423 int i, j, index1, index2, method = 0;
424 double fE = 1., r, value1, value2, value3, P12, P23, value = -2.;
426 if( e_in <= binned->energies[0].value ) {
433 for( i = 0; i < binned->
numberOfEs - 1; i++ ) {
434 if( e_in <= binned->energies[i].value )
break;
445 j = (int) (r * nBins);
446 if( j >= nBins ) j = nBins - 1;
451 if( ( ( j == 0 ) && ( r <= 0.5 ) ) || ( j == ( nBins - 1 ) && r > 0.5 ) ) method = 0;
456 value = ( 1. - r ) * value1 + r * value2; }
462 P12 = 1. / ( value2 - value1 );
463 P23 = 1. / ( value3 - value2 );
465 if( 0.25 * ( 1.0 + 2.0 * ( value2 - value1 ) / ( value3 - value1 ) ) > r ) {
466 P23 = 2. / ( value3 - value1 );
469 P12 = 2. / ( value3 - value1 );
473 if( P23 != P12 ) r = ( -P12 + std::sqrt( P12 * P12 * ( 1. - r ) + r * P23 * P23 ) ) / ( P23 - P12 );
474 value = 0.5 * ( value1 + value2 + r * ( value3 - value1 ) );
480#if defined __cplusplus
static HepRandomEngine * getTheEngine()
int smr_vsetMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt, va_list *args)
char * smr_vallocateFormatMessage(const char *fmt, va_list *args)
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
int smr_isOk(statusMessageReporting *smr)
tpia_EqualProbableBinSpectrum * energies
tpia_samplingMethods * samplingMethods
const char * angular_equalProbableBinMethod
xData_elementListItem * items
char * tpia_misc_pointerToAttributeIfAllOk(statusMessageReporting *smr, xData_element *element, const char *path, int required, xData_attributionList *attributes, const char *name, const char *file, int line)
int tpia_misc_setMessageError_Element(statusMessageReporting *smr, void *userInterface, xData_element *element, const char *file, int line, int code, const char *fmt,...)
xData_Int tpia_misc_binarySearch(xData_Int n, double *ds, double d)
tpia_EqualProbableBinSpectrum * tpia_misc_getEqualProbableBin(statusMessageReporting *smr, xData_element *parent, xData_Int *n, xData_Int *nBins)
tpia_EqualProbableBinSpectrum * tpia_misc_getEqualProbableBins(statusMessageReporting *smr, xData_element *parent, const char *name, xData_Int nBins, xData_Int *n)
int tpia_misc_NumberOfZSymbols(void)
double tpia_misc_getPointwiseCrossSectionAtE(statusMessageReporting *smr, tpia_1dData *crossSection, double *energyGrid, xData_Int index, double e_in)
double * tpia_misc_get2d_xShared_yHistogram_data(statusMessageReporting *smr, xData_element *element, xData_Int *start, xData_Int *end, xData_Int *length)
int tpia_misc_symbolToZ(const char *Z)
#define tpia_samplingMethods_isLinear(method)
double * tpia_misc_get2dxindex_y_data(statusMessageReporting *smr, xData_element *element, xData_Int *start, xData_Int *end, double *xValues)
double tpia_misc_drng(double(*rng)(void *), void *rngState)
int tpia_miscNameToZAm(statusMessageReporting *smr, const char *name, int *Z, int *A, int *m)
int tpia_misc_sampleEqualProbableBin(statusMessageReporting *smr, tpia_decaySamplingInfo *decaySamplingInfo, double e_in, int nBins, tpia_EqualProbableBinSpectra *binned, double *value_)
struct tpia_EqualProbableBinSpectrum_s tpia_EqualProbableBinSpectrum
double * tpia_misc_get2dx_y_data(statusMessageReporting *smr, xData_element *element, xData_Int *length)
int tpia_misc_get2d_xShared_yHistogram_data_Grouped(statusMessageReporting *smr, xData_element *element, tpia_1dData *group)
const char * tpia_misc_ZToSymbol(int iZ)
int xData_is_2d_xindex_y(statusMessageReporting *smr, xDataType *xDT, int setMsg)
int xData_convertAttributeToDouble(statusMessageReporting *smr, xData_element *element, const char *name, double *d)
void * xData_free(statusMessageReporting *smr, void *p)
void xData_freeElementList(statusMessageReporting *smr, xData_elementList *list)
xData_elementList * xData_getElementsByTagNameAndSort(statusMessageReporting *smr, xData_element *element, const char *tagName, const char *sortAttributeName, xData_sortElementFunc sortFunction)
int xData_is_2d_xy(statusMessageReporting *smr, xDataType *xDT, int setMsg)
double * xData_2d_xindex_y_toFilledYs(statusMessageReporting *smr, xData_element *element, double *Xs)
int xData_1d_x_copyData(statusMessageReporting *smr, xData_element *element, xData_Int nAllocatedBytes, double *d)
xData_element * xData_getOneElementByTagName(statusMessageReporting *smr, xData_element *element, char *name, int required)
int xData_addToAccessed(statusMessageReporting *smr, xData_element *element, int increment)
xData_Int xData_convertAttributeTo_xData_Int(statusMessageReporting *smr, xData_element *element, const char *name, xData_Int *n)
double * xData_2d_xShared_yHistogram_copyData(statusMessageReporting *smr, xData_element *element, xData_Int *n)
char * xData_getAttributesValue(xData_attributionList *attributes, const char *name)
double * xData_2d_xy_allocateCopyData(statusMessageReporting *smr, xData_element *element, xData_Int *length)
#define xData_malloc2(smr, size, zero, forItem)
xData_element * xData_getElements_xDataElement(statusMessageReporting *smr, xData_element *element)