#include <string.h>
#include <tpia_target.h>
#include <tpia_misc.h>
Go to the source code of this file.
Functions | |
tpia_target_heated * | tpia_target_heated_create (statusMessageReporting *smr) |
int | tpia_target_heated_initialize (statusMessageReporting *, tpia_target_heated *target) |
tpia_target_heated * | tpia_target_heated_createRead (statusMessageReporting *smr, const char *fileName, int checkElememtsForAccess) |
tpia_target_heated * | tpia_target_heated_free (statusMessageReporting *smr, tpia_target_heated *target) |
int | tpia_target_heated_release (statusMessageReporting *smr, tpia_target_heated *target) |
int | tpia_target_heated_read (statusMessageReporting *smr, tpia_target_heated *target, const char *fileName, int checkElememtsForAccess) |
int | tpia_target_heated_numberOfChannels (statusMessageReporting *, tpia_target_heated *target) |
int | tpia_target_heated_numberOfProductionChannels (statusMessageReporting *, tpia_target_heated *target) |
tpia_channel * | tpia_target_heated_getChannelAtIndex (tpia_target_heated *target, int index) |
tpia_channel * | tpia_target_heated_getChannelAtIndex_smr (statusMessageReporting *smr, tpia_target_heated *target, int index) |
tpia_channel * | tpia_target_heated_getProductionChannelAtIndex (tpia_target_heated *target, int index) |
xData_Int | tpia_target_heated_getEnergyGrid (statusMessageReporting *, tpia_target_heated *target, double **energyGrid) |
xData_Int | tpia_target_heated_getEIndex (tpia_target_heated *target, double e_in) |
double | tpia_target_heated_getTotalCrossSectionAtE (statusMessageReporting *smr, tpia_target_heated *target, xData_Int, double e_in, int crossSectionType) |
double | tpia_target_heated_getIndexChannelCrossSectionAtE (statusMessageReporting *smr, tpia_target_heated *target, int index, xData_Int iEg, double e_in, int crossSectionType) |
int | tpia_target_heated_sampleIndexChannelProductsAtE (statusMessageReporting *smr, tpia_target_heated *target, int index, tpia_decaySamplingInfo *decaySamplingInfo, int nProductData, tpia_productOutgoingData *productDatas) |
tpia_target_heated* tpia_target_heated_create | ( | statusMessageReporting * | smr | ) |
Definition at line 52 of file tpia_target_heated.cc.
References tpia_target_heated_initialize(), and xData_free().
Referenced by tpia_target_heated_createRead().
00052 { 00053 00054 tpia_target_heated *target; 00055 00056 //if( ( target = xData_malloc2( smr, sizeof( tpia_target_heated ), 0, "target" ) ) == NULL ) return( NULL ); 00057 if( ( target = (tpia_target_heated*) xData_malloc2( smr, sizeof( tpia_target_heated ), 0, "target" ) ) == NULL ) return( NULL ); 00058 //if( tpia_target_heated_initialize( smr, target ) ) target = xData_free( smr, target ); 00059 if( tpia_target_heated_initialize( smr, target ) ) target = (tpia_target_heated*) xData_free( smr, target ); 00060 return( target ); 00061 }
tpia_target_heated* tpia_target_heated_createRead | ( | statusMessageReporting * | smr, | |
const char * | fileName, | |||
int | checkElememtsForAccess | |||
) |
Definition at line 74 of file tpia_target_heated.cc.
References tpia_target_heated_create(), tpia_target_heated_read(), and xData_free().
Referenced by tpia_target_readHeatedTarget().
00074 { 00075 00076 tpia_target_heated *target; 00077 00078 if( ( target = tpia_target_heated_create( smr ) ) == NULL ) return( NULL ); 00079 //if( tpia_target_heated_read( smr, target, fileName, checkElememtsForAccess ) != 0 ) target = xData_free( smr, target ); 00080 if( tpia_target_heated_read( smr, target, fileName, checkElememtsForAccess ) != 0 ) target = (tpia_target_heated*) xData_free( smr, target ); 00081 return( target ); 00082 }
tpia_target_heated* tpia_target_heated_free | ( | statusMessageReporting * | smr, | |
tpia_target_heated * | target | |||
) |
Definition at line 86 of file tpia_target_heated.cc.
References tpia_target_heated_release(), and xData_free().
Referenced by tpia_target_release().
00086 { 00087 00088 tpia_target_heated_release( smr, target ); 00089 xData_free( smr, target ); 00090 return( NULL ); 00091 }
tpia_channel* tpia_target_heated_getChannelAtIndex | ( | tpia_target_heated * | target, | |
int | index | |||
) |
Definition at line 263 of file tpia_target_heated.cc.
Referenced by G4GIDI_target::init(), and tpia_target_heated_getChannelAtIndex_smr().
00263 { 00264 00265 tpia_channel *channel = NULL; 00266 00267 if( ( index >= 0 ) && ( index < target->nChannels ) ) channel = target->channels[index]; 00268 return( channel ); 00269 }
tpia_channel* tpia_target_heated_getChannelAtIndex_smr | ( | statusMessageReporting * | smr, | |
tpia_target_heated * | target, | |||
int | index | |||
) |
Definition at line 273 of file tpia_target_heated.cc.
References smr_setMessageError(), and tpia_target_heated_getChannelAtIndex().
Referenced by G4GIDI_target::getElasticFinalState(), tpia_target_heated_getIndexChannelCrossSectionAtE(), and tpia_target_heated_sampleIndexChannelProductsAtE().
00273 { 00274 00275 tpia_channel *channel = tpia_target_heated_getChannelAtIndex( target, index ); 00276 00277 if( channel == NULL ) { 00278 smr_setMessageError( smr, NULL, __FILE__, __LINE__, 1, "bad channel index = %d for %s + %s", index, 00279 target->projectileID->name, target->targetID->name ); 00280 } 00281 return( channel ); 00282 }
xData_Int tpia_target_heated_getEIndex | ( | tpia_target_heated * | target, | |
double | e_in | |||
) |
Definition at line 305 of file tpia_target_heated.cc.
References tpia_misc_binarySearch().
Referenced by tpia_channel_getCrossSectionAtE(), and tpia_target_heated_getTotalCrossSectionAtE().
00305 { 00306 00307 return( tpia_misc_binarySearch( target->energyGridLength, target->energyGrid, e_in ) ); 00308 }
xData_Int tpia_target_heated_getEnergyGrid | ( | statusMessageReporting * | , | |
tpia_target_heated * | target, | |||
double ** | energyGrid | |||
) |
Definition at line 297 of file tpia_target_heated.cc.
Referenced by tpia_target_getEnergyGridAtTIndex().
00297 { 00298 00299 if( energyGrid != NULL ) *energyGrid = target->energyGrid; 00300 return( target->energyGridLength ); 00301 }
double tpia_target_heated_getIndexChannelCrossSectionAtE | ( | statusMessageReporting * | smr, | |
tpia_target_heated * | target, | |||
int | index, | |||
xData_Int | iEg, | |||
double | e_in, | |||
int | crossSectionType | |||
) |
Definition at line 329 of file tpia_target_heated.cc.
References tpia_channel_getCrossSectionAtE(), and tpia_target_heated_getChannelAtIndex_smr().
Referenced by tpia_target_getIndexChannelCrossSectionAtE().
00330 { 00331 00332 double xsec = 0.; 00333 tpia_channel *channel = tpia_target_heated_getChannelAtIndex_smr( smr, target, index ); 00334 00335 if( channel != NULL ) xsec = tpia_channel_getCrossSectionAtE( smr, channel, iEg, e_in, crossSectionType ); 00336 return( xsec ); 00337 }
tpia_channel* tpia_target_heated_getProductionChannelAtIndex | ( | tpia_target_heated * | target, | |
int | index | |||
) |
Definition at line 286 of file tpia_target_heated.cc.
00286 { 00287 00288 tpia_channel *channel = NULL; 00289 00290 if( ( index >= 0 ) && ( index < target->nProductionChannels ) ) channel = target->productionChannels[index]; 00291 return( channel ); 00292 }
double tpia_target_heated_getTotalCrossSectionAtE | ( | statusMessageReporting * | smr, | |
tpia_target_heated * | target, | |||
xData_Int | , | |||
double | e_in, | |||
int | crossSectionType | |||
) |
Definition at line 313 of file tpia_target_heated.cc.
References tpia_misc_getPointwiseCrossSectionAtE(), and tpia_target_heated_getEIndex().
Referenced by tpia_target_getTotalCrossSectionAtTAndE().
00314 { 00315 00316 double xsec = 0.; 00317 00318 if( crossSectionType == tpia_crossSectionType_grouped ) { 00319 xsec = 0; } 00320 else if( crossSectionType == tpia_crossSectionType_pointwise ) { 00321 xsec = tpia_misc_getPointwiseCrossSectionAtE( smr, &(target->totalCrossSectionPointwise), target->energyGrid, 00322 tpia_target_heated_getEIndex( target, e_in ), e_in ); 00323 } 00324 return( xsec ); 00325 }
int tpia_target_heated_initialize | ( | statusMessageReporting * | , | |
tpia_target_heated * | target | |||
) |
Definition at line 66 of file tpia_target_heated.cc.
Referenced by tpia_target_heated_create(), and tpia_target_heated_read().
int tpia_target_heated_numberOfChannels | ( | statusMessageReporting * | , | |
tpia_target_heated * | target | |||
) |
int tpia_target_heated_numberOfProductionChannels | ( | statusMessageReporting * | , | |
tpia_target_heated * | target | |||
) |
Definition at line 256 of file tpia_target_heated.cc.
Referenced by tpia_target_numberOfProductionChannels().
int tpia_target_heated_read | ( | statusMessageReporting * | smr, | |
tpia_target_heated * | target, | |||
const char * | fileName, | |||
int | checkElememtsForAccess | |||
) |
Definition at line 126 of file tpia_target_heated.cc.
References smr_isOk(), tpia_channel_createGetFromElement(), tpia_misc_setMessageError_Element(), tpia_particle_getInternalID(), tpia_target_heated_initialize(), tpia_target_heated_release(), xData_addToAccessed(), xData_convertAttributeTo_xData_Int(), xData_copyAttributionList(), xData_getAttributesValue(), xData_getDocumentsElement(), xData_getFirstElement(), xData_getNextElement(), xData_getOneElementByTagName(), xData_numberOfElementsByTagName(), xData_parseFree(), xData_parseReadFile(), and xDataMisc_getAbsPath().
Referenced by tpia_target_heated_createRead().
00126 { 00127 /* 00128 * If a target has already been read into this target, user must have called tpia_target_heated_release before calling this routine. 00129 * Otherwise, there will be memory leaks. 00130 */ 00131 xData_document *doc = NULL; 00132 xData_element *element, *channelElement, *channels; 00133 int nChannels; 00134 tpia_channel *channel; 00135 char *name; 00136 xData_Int i, j; 00137 00138 tpia_target_heated_initialize( smr, target ); 00139 if( ( target->path = xDataMisc_allocateCopyString2( smr, fileName, "path" ) ) == NULL ) return( 1 ); 00140 if( ( target->absPath = xDataMisc_getAbsPath( smr, fileName ) ) == NULL ) return( _tpia_target_heated_releaseAndReturnOne( smr, doc, target ) ); 00141 if( ( doc = xData_parseReadFile( smr, fileName, NULL, NULL ) ) == NULL ) return( _tpia_target_heated_releaseAndReturnOne( smr, doc, target ) ); 00142 element = xData_getDocumentsElement( doc ); 00143 xData_addToAccessed( smr, element, 1 ); 00144 if( xData_convertAttributeTo_xData_Int( smr, element, "nGroups", &i ) != 0 ) return( _tpia_target_heated_releaseAndReturnOne( smr, doc, target ) ); 00145 target->nGroups = (int) i; 00146 if( strcmp( element->name, "xTargetHeated" ) != 0 ) { 00147 tpia_misc_setMessageError_Element( smr, NULL, element, __FILE__, __LINE__, 1, "input file's top element must be xTargetHeated and not %s", 00148 element->name ); } 00149 else { 00150 xData_copyAttributionList( smr, &(target->attributes), &(element->attributes) ); 00151 if( smr_isOk( smr ) ) target->contents = xData_getAttributesValue( &(target->attributes), "contents" ); 00152 if( ( name = tpia_misc_pointerToAttributeIfAllOk3( smr, target->absPath, 1, &(target->attributes), "projectile" ) ) != NULL ) 00153 target->projectileID = tpia_particle_getInternalID( smr, name ); 00154 if( ( name = tpia_misc_pointerToAttributeIfAllOk3( smr, target->absPath, 1, &(target->attributes), "target" ) ) != NULL ) 00155 target->targetID = tpia_particle_getInternalID( smr, name ); 00156 if( smr_isOk( smr ) ) _tpia_target_heated_getEnergyGridAndAllocateTotalCrossSections( smr, target, element ); 00157 if( smr_isOk( smr ) ) { /* Get channels. */ 00158 //if( ( channels = xData_getOneElementByTagName( smr, element, "channels", 1 ) ) == NULL ) 00159 if( ( channels = xData_getOneElementByTagName( smr, element, (char*)"channels", 1 ) ) == NULL ) 00160 return( _tpia_target_heated_releaseAndReturnOne( smr, doc, target ) ); 00161 xData_addToAccessed( smr, channels, 1 ); 00162 if( ( nChannels = xData_numberOfElementsByTagName( smr, channels, "channel" ) ) > 0 ) { 00163 //if( ( target->channels = xData_malloc2( smr, nChannels * sizeof( tpia_channel * ), 1, "channels" ) ) == NULL ) 00164 if( ( target->channels = (tpia_channel**) xData_malloc2( smr, nChannels * sizeof( tpia_channel * ), 1, "channels" ) ) == NULL ) 00165 return( _tpia_target_heated_releaseAndReturnOne( smr, doc, target ) ); 00166 for( channelElement = xData_getFirstElement( channels ); channelElement != NULL; channelElement = xData_getNextElement( channelElement ) ) { 00167 if( !strcmp( channelElement->name, "channel" ) ) { 00168 if( ( channel = tpia_channel_createGetFromElement( smr, target, channelElement, 1 ) ) == NULL ) break; 00169 target->channels[target->nChannels] = channel; 00170 target->nChannels++; 00171 for( i = channel->crossSectionPointwise.start, j = 0; i < channel->crossSectionPointwise.end; i++, j++ ) 00172 target->totalCrossSectionPointwise.data[i] += channel->crossSectionPointwise.data[j]; 00173 for( i = channel->crossSectionGrouped.start, j = 0; i < channel->crossSectionGrouped.end; i++, j++ ) 00174 target->totalCrossSectionGrouped.data[i] += channel->crossSectionGrouped.data[j]; 00175 } 00176 } 00177 } 00178 } 00179 if( smr_isOk( smr ) ) { /* Get production channels. */ 00180 //if( ( channels = xData_getOneElementByTagName( smr, element, "productionChannels", 0 ) ) == NULL ) { 00181 if( ( channels = xData_getOneElementByTagName( smr, element, (char*) "productionChannels", 0 ) ) == NULL ) { 00182 if( !smr_isOk( smr ) ) return( _tpia_target_heated_releaseAndReturnOne( smr, doc, target ) ); } 00183 else { 00184 xData_addToAccessed( smr, channels, 1 ); 00185 if( ( nChannels = xData_numberOfElementsByTagName( smr, channels, "channel" ) ) > 0 ) { 00186 //if( ( target->productionChannels = xData_malloc2( smr, nChannels * sizeof( tpia_channel * ), 1, "channels" ) ) != NULL ) { 00187 if( ( target->productionChannels = (tpia_channel**) xData_malloc2( smr, nChannels * sizeof( tpia_channel * ), 1, "channels" ) ) != NULL ) { 00188 for( channelElement = xData_getFirstElement(channels); channelElement != NULL; channelElement = xData_getNextElement(channelElement) ) { 00189 if( !strcmp( channelElement->name, "channel" ) ) { 00190 channel = tpia_channel_createGetFromElement( smr, target, channelElement, 1 ); 00191 if( channel == NULL ) break; 00192 target->productionChannels[target->nProductionChannels] = channel; 00193 target->nProductionChannels++; 00194 } 00195 } 00196 } 00197 } 00198 } 00199 } 00200 } 00201 if( smr_isOk( smr ) && checkElememtsForAccess ) _tpia_target_heated_checkElememtsForAccess( smr, doc ); 00202 xData_parseFree( smr, doc ); 00203 if( !smr_isOk( smr ) ) tpia_target_heated_release( smr, target ); 00204 return( !smr_isOk( smr ) ); 00205 }
int tpia_target_heated_release | ( | statusMessageReporting * | smr, | |
tpia_target_heated * | target | |||
) |
Definition at line 95 of file tpia_target_heated.cc.
References tpia_channel_free(), xData_free(), and xData_releaseAttributionList().
Referenced by tpia_target_heated_free(), and tpia_target_heated_read().
00095 { 00096 00097 int i; 00098 00099 //target->path = xData_free( smr, target->path ); 00100 target->path = (char*) xData_free( smr, target->path ); 00101 //target->absPath = xData_free( smr, target->absPath ); 00102 target->absPath = (char*) xData_free( smr, target->absPath ); 00103 target->energyGridLength = 0; 00104 //target->energyGrid = xData_free( smr, target->energyGrid ); 00105 target->energyGrid = (double*) xData_free( smr, target->energyGrid ); 00106 //target->kerma = xData_free( smr, target->kerma ); 00107 target->kerma = (double*) xData_free( smr, target->kerma ); 00108 //target->totalCrossSectionPointwise.data = xData_free( smr, target->totalCrossSectionPointwise.data ); 00109 target->totalCrossSectionPointwise.data = (double*) xData_free( smr, target->totalCrossSectionPointwise.data ); 00110 //target->totalCrossSectionGrouped.data = xData_free( smr, target->totalCrossSectionGrouped.data ); 00111 target->totalCrossSectionGrouped.data = (double*) xData_free( smr, target->totalCrossSectionGrouped.data ); 00112 xData_releaseAttributionList( smr, &(target->attributes) ); 00113 for( i = 0; i < target->nChannels; i++ ) tpia_channel_free( smr, target->channels[i] ); 00114 target->nChannels = 0; 00115 //target->channels = xData_free( smr, target->channels ); 00116 target->channels = (tpia_channel**) xData_free( smr, target->channels ); 00117 for( i = 0; i < target->nProductionChannels; i++ ) tpia_channel_free( smr, target->productionChannels[i] ); 00118 target->nProductionChannels = 0; 00119 //target->productionChannels = xData_free( smr, target->productionChannels ); 00120 target->productionChannels = (tpia_channel**) xData_free( smr, target->productionChannels ); 00121 return( 0 ); 00122 }
int tpia_target_heated_sampleIndexChannelProductsAtE | ( | statusMessageReporting * | smr, | |
tpia_target_heated * | target, | |||
int | index, | |||
tpia_decaySamplingInfo * | decaySamplingInfo, | |||
int | nProductData, | |||
tpia_productOutgoingData * | productDatas | |||
) |
Definition at line 341 of file tpia_target_heated.cc.
References tpia_decayChannel_sampleProductsAtE(), and tpia_target_heated_getChannelAtIndex_smr().
Referenced by G4GIDI_target::getFinalState(), and tpia_target_sampleIndexChannelProductsAtE().
00342 { 00343 00344 tpia_channel *channel = tpia_target_heated_getChannelAtIndex_smr( smr, target, index ); 00345 00346 if( channel == NULL ) return( -1 ); 00347 return( tpia_decayChannel_sampleProductsAtE( smr, &(channel->decayChannel), decaySamplingInfo, nProductData, productDatas ) ); 00348 }