00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include <string.h>
00037
00038 #include <tpia_target.h>
00039 #include <tpia_misc.h>
00040
00041 #if defined __cplusplus
00042 namespace GIDI {
00043 using namespace GIDI;
00044 #endif
00045
00046 static int _tpia_channel_getProductData( statusMessageReporting *smr, xData_element *channelElement, tpia_channel *channel );
00047
00048
00049
00050 tpia_channel *tpia_channel_create( statusMessageReporting *smr ) {
00051
00052 tpia_channel *channel;
00053
00054
00055 if( ( channel = (tpia_channel*) xData_malloc2( smr, sizeof( tpia_channel ), 0, "channel" ) ) == NULL ) return( NULL );
00056 if( tpia_channel_initialize( smr, channel ) ) channel = tpia_channel_free( smr, channel );
00057 return( channel );
00058 }
00059
00060
00061
00062
00063 int tpia_channel_initialize( statusMessageReporting *, tpia_channel *channel ) {
00064
00065 memset( channel, 0, sizeof( tpia_channel ) );
00066 return( 0 );
00067 }
00068
00069
00070
00071 tpia_channel *tpia_channel_createGetFromElement( statusMessageReporting *smr, tpia_target_heated *target, xData_element *channelElement,
00072 int pointwiseRequired ) {
00073
00074 tpia_channel *channel;
00075
00076 if( ( channel = tpia_channel_create( smr ) ) == NULL ) return( NULL );
00077 if( tpia_channel_getFromElement( smr, target, channelElement, channel, pointwiseRequired ) != 0 ) channel = tpia_channel_free( smr, channel );
00078 return( channel );
00079 }
00080
00081
00082
00083 tpia_channel *tpia_channel_free( statusMessageReporting *smr, tpia_channel *channel ) {
00084
00085 tpia_channel_release( smr, channel );
00086 xData_free( smr, channel );
00087 return( NULL );
00088 }
00089
00090
00091
00092 int tpia_channel_release( statusMessageReporting *smr, tpia_channel *channel ) {
00093
00094 tpia_product *product, *nextProduct;
00095
00096 xData_releaseAttributionList( smr, &(channel->attributes) );
00097
00098 channel->crossSectionPointwise.data = (double*) xData_free( smr, channel->crossSectionPointwise.data );
00099
00100 channel->crossSectionGrouped.data = (double*) xData_free( smr, channel->crossSectionGrouped.data );
00101
00102 channel->availableEnergyGrouped.data = (double*) xData_free( smr, channel->availableEnergyGrouped.data );
00103 for( product = channel->decayChannel.products; product != NULL; product = nextProduct ) {
00104 nextProduct = product->next;
00105 tpia_product_free( smr, product );
00106 }
00107 channel->decayChannel.numberOfProducts = 0;
00108 channel->decayChannel.products = NULL;
00109 return( 0 );
00110 }
00111
00112
00113
00114 int tpia_channel_getFromElement( statusMessageReporting *smr, tpia_target_heated *target, xData_element *channelElement, tpia_channel *channel,
00115 int pointwiseRequired ) {
00116
00117 xData_Int ll;
00118 char *p;
00119 xData_element *element, *pElement, *gElement, *eElement;
00120
00121 xData_addToAccessed( smr, channelElement, 1 );
00122 channel->target = target;
00123 xData_copyAttributionList( smr, &(channel->attributes), &(channelElement->attributes) );
00124 channel->outputChannel = tpia_misc_pointerToAttributeIfAllOk2(smr, channelElement, 1, &(channel->attributes), "outputChannel" );
00125 channel->genre = tpia_misc_pointerToAttributeIfAllOk2( smr, channelElement, 1, &(channel->attributes), "genre" );
00126 channel->QString = tpia_misc_pointerToAttributeIfAllOk2( smr, channelElement, 1, &(channel->attributes), "Q" );
00127 channel->fission = tpia_misc_pointerToAttributeIfAllOk2( smr, channelElement, 0, &(channel->attributes), "fission" );
00128 if( smr_isOk( smr ) ) {
00129 ll = 0;
00130 if( xData_convertAttributeTo_xData_Int( smr, channelElement, "ENDL_C", &ll ) >= 0 ) channel->ENDL_C = (int) ll;
00131 }
00132 if( smr_isOk( smr ) ) {
00133 ll = 0;
00134 if( xData_convertAttributeTo_xData_Int( smr, channelElement, "ENDF_MT2", &ll ) >= 0 ) channel->ENDF_MT = (int) ll;
00135 }
00136 if( smr_isOk( smr ) ) {
00137 channel->QIsFloat = 1;
00138 channel->Q = strtod( channel->QString, &p );
00139 if( *p != 0 ) {
00140 channel->QIsFloat = 0;
00141 channel->Q = 0.;
00142 }
00143
00144 if( ( element = xData_getOneElementByTagName( smr, channelElement, (char*) "crossSection", 1 ) ) != NULL ) {
00145 if( ( tpia_frame_setFromElement( smr, element, 2, &channel->crossSectionFrame ) ) == 0 ) {
00146 xData_addToAccessed( smr, element, 1 );
00147
00148 if( ( pElement = xData_getOneElementByTagName( smr, element, (char*) "indexed", 1 ) ) != NULL ) {
00149 channel->crossSectionPointwise.data = tpia_misc_get2dxindex_y_data( smr, pElement,
00150 &(channel->crossSectionPointwise.start), &(channel->crossSectionPointwise.end), target->energyGrid );
00151 }
00152 if( ( gElement = xData_getOneElementByTagName( smr, element, (char*) "grouped", 1 ) ) != NULL ) {
00153 tpia_misc_get2d_xShared_yHistogram_data_Grouped( smr, gElement, &(channel->crossSectionGrouped) );
00154 }
00155 if( ( channel->crossSectionGrouped.data != NULL ) && ( ( channel->crossSectionPointwise.data != NULL ) || !pointwiseRequired ) ) {
00156 if( target->contents == NULL ) {
00157 if( !tpia_channel_isProduction( smr, channel ) ) {
00158
00159 if( ( eElement = xData_getOneElementByTagName( smr, channelElement, (char*) "availableEnergy", 1 ) ) != NULL ) {
00160 xData_addToAccessed( smr, eElement, 1 );
00161
00162 if( ( gElement = xData_getOneElementByTagName( smr, eElement, (char*) "grouped", 1 ) ) != NULL ) {
00163 tpia_misc_get2d_xShared_yHistogram_data_Grouped( smr, gElement, &(channel->availableEnergyGrouped) );
00164 }
00165 }
00166 }
00167 }
00168 if( smr_isOk( smr ) ) _tpia_channel_getProductData( smr, channelElement, channel );
00169 }
00170 }
00171 }
00172 }
00173 return( !smr_isOk( smr ) );
00174 }
00175
00176
00177
00178 static int _tpia_channel_getProductData( statusMessageReporting *smr, xData_element *channelElement, tpia_channel *channel ) {
00179
00180 return( tpia_product_getDecayChannelFromElement( smr, channelElement, channel, NULL, &(channel->decayChannel.products) ) );
00181 }
00182
00183
00184
00185 tpia_product *tpia_channel_getFirstProduct( tpia_channel *channel ) {
00186
00187 return( tpia_decayChannel_getFirstProduct( &(channel->decayChannel) ) );
00188 }
00189
00190
00191
00192
00193 tpia_product *tpia_channel_getProductByIndex( statusMessageReporting *, tpia_channel *channel, int index ) {
00194
00195 int i = 0;
00196 tpia_product *p;
00197
00198 if( index < 0 ) return( NULL );
00199 for( p = tpia_channel_getFirstProduct( channel ); ( p != NULL ) && ( i < index ); p = tpia_decayChannel_getNextProduct( p ), i++ ) ;
00200 return( p );
00201 }
00202
00203
00204
00205
00206 int tpia_channel_numberOfProducts( statusMessageReporting *, tpia_channel *channel ) {
00207
00208 return( channel->decayChannel.numberOfProducts );
00209 }
00210
00211
00212
00213
00214 int tpia_channel_isProduction( statusMessageReporting *, tpia_channel *channel ) {
00215
00216 return( strcmp( channel->genre, "production" ) == 0 );
00217 }
00218
00219
00220
00221
00222 double tpia_channel_getCrossSectionAtE( statusMessageReporting *smr, tpia_channel *channel, xData_Int , double e_in,
00223 int crossSectionType ) {
00224
00225 double xsec = 0.;
00226
00227 if( crossSectionType == tpia_crossSectionType_grouped ) {
00228 xsec = 0; }
00229 else if( crossSectionType == tpia_crossSectionType_pointwise ) {
00230 xsec = tpia_misc_getPointwiseCrossSectionAtE( smr, &(channel->crossSectionPointwise), channel->target->energyGrid,
00231 tpia_target_heated_getEIndex( channel->target, e_in ), e_in );
00232 }
00233 return( xsec );
00234 }
00235
00236 }