37 #include <tpia_target.h>
38 #include <tpia_misc.h>
40 #if defined __cplusplus
54 tpia_target_heated *target;
57 if( ( target = (tpia_target_heated*) xData_malloc2( smr,
sizeof( tpia_target_heated ), 0,
"target" ) ) == NULL )
return( NULL );
68 memset( target, 0,
sizeof( tpia_target_heated ) );
76 tpia_target_heated *target;
100 target->path = (
char*)
xData_free( smr, target->path );
102 target->absPath = (
char*)
xData_free( smr, target->absPath );
103 target->energyGridLength = 0;
105 target->energyGrid = (
double*)
xData_free( smr, target->energyGrid );
107 target->kerma = (
double*)
xData_free( smr, target->kerma );
109 target->totalCrossSectionPointwise.data = (
double*)
xData_free( smr, target->totalCrossSectionPointwise.data );
111 target->totalCrossSectionGrouped.data = (
double*)
xData_free( smr, target->totalCrossSectionGrouped.data );
113 for( i = 0; i < target->nChannels; i++ )
tpia_channel_free( smr, target->channels[i] );
114 target->nChannels = 0;
116 target->channels = (tpia_channel**)
xData_free( smr, target->channels );
117 for( i = 0; i < target->nProductionChannels; i++ )
tpia_channel_free( smr, target->productionChannels[i] );
118 target->nProductionChannels = 0;
120 target->productionChannels = (tpia_channel**)
xData_free( smr, target->productionChannels );
126 int tpia_target_heated_read( statusMessageReporting *smr, tpia_target_heated *target,
const char *fileName,
int checkElememtsForAccess ) {
131 xData_document *doc = NULL;
132 xData_element *element, *channelElement, *channels;
134 tpia_channel *channel;
139 if( ( target->path = xDataMisc_allocateCopyString2( smr, fileName,
"path" ) ) == NULL )
return( 1 );
145 target->nGroups = (int) i;
146 if( strcmp( element->name,
"xTargetHeated" ) != 0 ) {
152 if( ( name = tpia_misc_pointerToAttributeIfAllOk3( smr, target->absPath, 1, &(target->attributes),
"projectile" ) ) != NULL )
154 if( ( name = tpia_misc_pointerToAttributeIfAllOk3( smr, target->absPath, 1, &(target->attributes),
"target" ) ) != NULL )
164 if( ( target->channels = (tpia_channel**) xData_malloc2( smr, nChannels *
sizeof( tpia_channel * ), 1,
"channels" ) ) == NULL )
167 if( !strcmp( channelElement->name,
"channel" ) ) {
169 target->channels[target->nChannels] = channel;
171 for( i = channel->crossSectionPointwise.start, j = 0; i < channel->crossSectionPointwise.end; i++, j++ )
172 target->totalCrossSectionPointwise.data[i] += channel->crossSectionPointwise.data[j];
173 for( i = channel->crossSectionGrouped.start, j = 0; i < channel->crossSectionGrouped.end; i++, j++ )
174 target->totalCrossSectionGrouped.data[i] += channel->crossSectionGrouped.data[j];
187 if( ( target->productionChannels = (tpia_channel**) xData_malloc2( smr, nChannels *
sizeof( tpia_channel * ), 1,
"channels" ) ) != NULL ) {
189 if( !strcmp( channelElement->name,
"channel" ) ) {
191 if( channel == NULL )
break;
192 target->productionChannels[target->nProductionChannels] = channel;
193 target->nProductionChannels++;
211 xData_Int i, energyGridIndex, energyGridStart, energyGridEnd, energyGridLength;
212 xData_element *energyGrid, *kerma;
220 xData_getCommonData( smr, energyGrid, &energyGridIndex, &energyGridStart, &energyGridEnd, &energyGridLength );
222 target->energyGridLength = energyGridLength;
223 target->totalCrossSectionPointwise.start = 0;
224 target->totalCrossSectionPointwise.end = energyGridLength;
225 target->totalCrossSectionPointwise.length = energyGridLength;
227 if( ( target->totalCrossSectionPointwise.data = (
double*) xData_malloc2( smr, energyGridLength *
sizeof(
double ), 0,
"totalCrossSectionPointwise" ) ) == NULL )
229 for( i = 0; i < energyGridLength; i++ ) target->totalCrossSectionPointwise.data[i] = 0.;
230 target->totalCrossSectionGrouped.start = 0;
231 target->totalCrossSectionGrouped.end = energyGridLength;
232 target->totalCrossSectionGrouped.length = energyGridLength;
234 if( ( target->totalCrossSectionGrouped.data = (
double*) xData_malloc2( smr, target->nGroups *
sizeof(
double ), 0,
"totalCrossSectionGrouped" ) ) == NULL )
return;
235 for( i = 0; i < target->nGroups; i++ ) target->totalCrossSectionGrouped.data[i] = 0.;
250 return( target->nChannels );
258 return( target->nProductionChannels );
265 tpia_channel *channel = NULL;
267 if( ( index >= 0 ) && ( index < target->nChannels ) ) channel = target->channels[index];
277 if( channel == NULL ) {
278 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1,
"bad channel index = %d for %s + %s", index,
279 target->projectileID->name, target->targetID->name );
288 tpia_channel *channel = NULL;
290 if( ( index >= 0 ) && ( index < target->nProductionChannels ) ) channel = target->productionChannels[index];
299 if( energyGrid != NULL ) *energyGrid = target->energyGrid;
300 return( target->energyGridLength );
314 int crossSectionType ) {
318 if( crossSectionType == tpia_crossSectionType_grouped ) {
320 else if( crossSectionType == tpia_crossSectionType_pointwise ) {
330 int crossSectionType ) {
342 tpia_decaySamplingInfo *decaySamplingInfo,
int nProductData, tpia_productOutgoingData *productDatas ) {
346 if( channel == NULL )
return( -1 );
373 xData_element *child;
381 #if defined __cplusplus
int tpia_target_heated_numberOfChannels(statusMessageReporting *, tpia_target_heated *target)
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)
tpia_target_heated * tpia_target_heated_create(statusMessageReporting *smr)
static int _tpia_target_heated_checkElememtsForAccess(statusMessageReporting *smr, xData_document *doc)
xData_Int tpia_target_heated_getEnergyGrid(statusMessageReporting *, tpia_target_heated *target, double **energyGrid)
xData_element * xData_getElements_xDataElement(statusMessageReporting *smr, xData_element *element)
int xData_getCommonData(statusMessageReporting *smr, xData_element *element, xData_Int *index, xData_Int *start, xData_Int *end, xData_Int *length)
xData_element * xData_getNextElement(xData_element *element)
xData_document * xData_parseReadFile(statusMessageReporting *smr, const char *fileName, xData_xDataTypeOk func, void *userData)
xData_Int tpia_target_heated_getEIndex(tpia_target_heated *target, double e_in)
int tpia_misc_setMessageError_Element(statusMessageReporting *smr, void *userInterface, xData_element *element, const char *file, int line, int code, const char *fmt,...)
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
static int _tpia_target_heated_checkElememtsForAccess2(statusMessageReporting *smr, xData_element *element)
char * xData_getAttributesValue(xData_attributionList *attributes, const char *name)
double * xData_1d_x_allocateCopyData(statusMessageReporting *smr, xData_element *element)
int xData_getAccessed(statusMessageReporting *, xData_element *element)
tpia_channel * tpia_target_heated_getChannelAtIndex_smr(statusMessageReporting *smr, tpia_target_heated *target, int index)
int tpia_target_heated_numberOfProductionChannels(statusMessageReporting *, tpia_target_heated *target)
char * xDataMisc_getAbsPath(statusMessageReporting *smr, const char *fileName)
xData_element * xData_getFirstElement(xData_element *element)
tpia_channel * tpia_target_heated_getChannelAtIndex(tpia_target_heated *target, int index)
xData_element * xData_getDocumentsElement(xData_document *doc)
int tpia_decayChannel_sampleProductsAtE(statusMessageReporting *smr, tpia_decayChannel *decayChannel, tpia_decaySamplingInfo *decaySamplingInfo, int nProductData, tpia_productOutgoingData *productDatas)
static int _tpia_target_heated_releaseAndReturnOne(statusMessageReporting *smr, xData_document *doc, tpia_target_heated *target)
void * xData_parseFree(statusMessageReporting *smr, xData_document *doc)
tpia_channel * tpia_target_heated_getProductionChannelAtIndex(tpia_target_heated *target, int index)
int smr_isOk(statusMessageReporting *smr)
xData_Int tpia_misc_binarySearch(xData_Int n, double *ds, double d)
double tpia_target_heated_getIndexChannelCrossSectionAtE(statusMessageReporting *smr, tpia_target_heated *target, int index, xData_Int iEg, double e_in, int crossSectionType)
tpia_channel * tpia_channel_createGetFromElement(statusMessageReporting *smr, tpia_target_heated *target, xData_element *channelElement, int pointwiseRequired)
int xData_numberOfElementsByTagName(statusMessageReporting *, xData_element *element, const char *tagName)
int xData_releaseAttributionList(statusMessageReporting *smr, xData_attributionList *attributes)
tpia_channel * tpia_channel_free(statusMessageReporting *smr, tpia_channel *channel)
double tpia_target_heated_getTotalCrossSectionAtE(statusMessageReporting *smr, tpia_target_heated *target, xData_Int, double e_in, int crossSectionType)
void * xData_free(statusMessageReporting *, void *p)
int tpia_target_heated_sampleIndexChannelProductsAtE(statusMessageReporting *smr, tpia_target_heated *target, int index, tpia_decaySamplingInfo *decaySamplingInfo, int nProductData, tpia_productOutgoingData *productDatas)
int xData_copyAttributionList(statusMessageReporting *smr, xData_attributionList *dest, xData_attributionList *src)
double tpia_channel_getCrossSectionAtE(statusMessageReporting *smr, tpia_channel *channel, xData_Int, double e_in, int crossSectionType)
double tpia_misc_getPointwiseCrossSectionAtE(statusMessageReporting *, tpia_1dData *crossSection, double *energyGrid, xData_Int index, double e_in)
int tpia_target_heated_read(statusMessageReporting *smr, tpia_target_heated *target, const char *fileName, int checkElememtsForAccess)
static void _tpia_target_heated_getEnergyGridAndAllocateTotalCrossSections(statusMessageReporting *smr, tpia_target_heated *target, xData_element *element)
tpia_target_heated * tpia_target_heated_createRead(statusMessageReporting *smr, const char *fileName, int checkElememtsForAccess)
int tpia_target_heated_initialize(statusMessageReporting *, tpia_target_heated *target)
int tpia_target_heated_release(statusMessageReporting *smr, tpia_target_heated *target)
tpia_target_heated * tpia_target_heated_free(statusMessageReporting *smr, tpia_target_heated *target)
tpia_particle * tpia_particle_getInternalID(statusMessageReporting *smr, const char *const name)