38 #include <tpia_target.h>
39 #include <tpia_misc.h>
41 #if defined __cplusplus
51 memset( angularEnergy, 0,
sizeof( tpia_angularEnergy ) );
53 angularEnergy->binned.numberOfEs = 0;
54 angularEnergy->binned.energies = NULL;
64 for( i = 0; i < angularEnergy->binned.numberOfEs; i++ )
xData_free( smr, angularEnergy->binned.energies[i].energies );
66 angularEnergy->binned.energies = (tpia_EqualProbableBinSpectra*)
xData_free( smr, angularEnergy->binned.energies );
76 xData_Int nBins, size,
n, index;
77 xData_element *epbElement, *element;
78 xData_elementList *list;
79 tpia_EqualProbableBinSpectra *mus;
94 size = list->n *
sizeof( tpia_EqualProbableBinSpectra );
95 angularEnergy->binned.nBins = (int) nBins;
97 if( ( angularEnergy->binned.energies = (tpia_EqualProbableBinSpectra*) xData_malloc2( smr, size, 1,
"energies" ) ) != NULL ) {
99 for( i = 0, mus = angularEnergy->binned.energies; i < list->n; i++, mus++ ) {
101 element = list->items[i].element;
127 angularEnergy->binned.numberOfEs++;
140 tpia_EqualProbableBinSpectra *energies = angularEnergy->binned.energies;
141 double Ep, Ep1, Ep2, f, e_in = decaySamplingInfo->e_in;
148 if( angularEnergy->binned.numberOfEs == 0 )
return( 1 );
149 for( iE2 = 0; iE2 < angularEnergy->binned.numberOfEs; iE2++ )
if( energies[iE2].dValue >= e_in )
break;
152 else if( iE2 == angularEnergy->binned.numberOfEs ) {
153 iE1 = iE2 = angularEnergy->binned.numberOfEs - 1; }
162 f = ( energies[iE2].dValue - e_in ) / ( energies[iE2].dValue - energies[iE1].dValue );
163 Ep = f * Ep1 + ( 1 - f ) * Ep2;
165 decaySamplingInfo->Ep = Ep;
170 #if defined __cplusplus
xData_Int xData_convertAttributeTo_xData_Int(statusMessageReporting *smr, xData_element *element, const char *name, xData_Int *n)
xData_element * xData_getOneElementByTagName(statusMessageReporting *smr, xData_element *element, char *name, int required)
int xData_addToAccessed(statusMessageReporting *, xData_element *element, int increment)
int tpia_misc_setMessageError_Element(statusMessageReporting *smr, void *userInterface, xData_element *element, const char *file, int line, int code, const char *fmt,...)
int tpia_angularEnergy_initialize(statusMessageReporting *smr, tpia_angularEnergy *angularEnergy)
int tpia_angularEnergy_release(statusMessageReporting *smr, tpia_angularEnergy *angularEnergy)
int tpia_frame_setFromString(statusMessageReporting *smr, const char *forItem, const char *value, int dimension, tpia_data_frame *frame)
xData_elementList * xData_getElementsByTagNameAndSort(statusMessageReporting *smr, xData_element *element, const char *tagName, const char *sortAttributeName, xData_sortElementFunc sortFunction)
int smr_isOk(statusMessageReporting *smr)
tpia_EqualProbableBinSpectrum * tpia_misc_getEqualProbableBins(statusMessageReporting *smr, xData_element *parent, const char *name, xData_Int nBins, xData_Int *n)
int tpia_angularEnergy_SampleEp(statusMessageReporting *smr, tpia_angularEnergy *angularEnergy, tpia_decaySamplingInfo *decaySamplingInfo)
int tpia_frame_setFromElement(statusMessageReporting *smr, xData_element *element, int dimension, tpia_data_frame *frame)
int tpia_angularEnergy_getFromElement(statusMessageReporting *smr, xData_element *angularEnergyElement, tpia_angularEnergy *angularEnergy)
void * xData_free(statusMessageReporting *, void *p)
int tpia_misc_sampleEqualProbableBin(statusMessageReporting *, tpia_decaySamplingInfo *decaySamplingInfo, double e_in, int nBins, tpia_EqualProbableBinSpectra *binned, double *value_)
int xData_convertAttributeToDouble(statusMessageReporting *smr, xData_element *element, const char *name, double *d)
void xData_freeElementList(statusMessageReporting *smr, xData_elementList *list)