tpia_channel.cc File Reference

#include <string.h>
#include <tpia_target.h>
#include <tpia_misc.h>

Go to the source code of this file.

Functions

tpia_channel * tpia_channel_create (statusMessageReporting *smr)
int tpia_channel_initialize (statusMessageReporting *, tpia_channel *channel)
tpia_channel * tpia_channel_createGetFromElement (statusMessageReporting *smr, tpia_target_heated *target, xData_element *channelElement, int pointwiseRequired)
tpia_channel * tpia_channel_free (statusMessageReporting *smr, tpia_channel *channel)
int tpia_channel_release (statusMessageReporting *smr, tpia_channel *channel)
int tpia_channel_getFromElement (statusMessageReporting *smr, tpia_target_heated *target, xData_element *channelElement, tpia_channel *channel, int pointwiseRequired)
tpia_product * tpia_channel_getFirstProduct (tpia_channel *channel)
tpia_product * tpia_channel_getProductByIndex (statusMessageReporting *, tpia_channel *channel, int index)
int tpia_channel_numberOfProducts (statusMessageReporting *, tpia_channel *channel)
int tpia_channel_isProduction (statusMessageReporting *, tpia_channel *channel)
double tpia_channel_getCrossSectionAtE (statusMessageReporting *smr, tpia_channel *channel, xData_Int, double e_in, int crossSectionType)


Function Documentation

tpia_channel* tpia_channel_create ( statusMessageReporting *  smr  ) 

Definition at line 50 of file tpia_channel.cc.

References tpia_channel_free(), and tpia_channel_initialize().

Referenced by tpia_channel_createGetFromElement().

00050                                                                  {
00051 
00052     tpia_channel *channel;
00053 
00054     //if( ( channel = xData_malloc2( smr, sizeof( tpia_channel ), 0, "channel" ) ) == NULL ) return( NULL );
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 }

tpia_channel* tpia_channel_createGetFromElement ( statusMessageReporting *  smr,
tpia_target_heated *  target,
xData_element *  channelElement,
int  pointwiseRequired 
)

Definition at line 71 of file tpia_channel.cc.

References tpia_channel_create(), tpia_channel_free(), and tpia_channel_getFromElement().

Referenced by tpia_target_heated_read().

00072                             {
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 }

tpia_channel* tpia_channel_free ( statusMessageReporting *  smr,
tpia_channel *  channel 
)

Definition at line 83 of file tpia_channel.cc.

References tpia_channel_release(), and xData_free().

Referenced by tpia_channel_create(), tpia_channel_createGetFromElement(), and tpia_target_heated_release().

00083                                                                                       {
00084 
00085     tpia_channel_release( smr, channel );
00086     xData_free( smr, channel );
00087     return( NULL );
00088 }

double tpia_channel_getCrossSectionAtE ( statusMessageReporting *  smr,
tpia_channel *  channel,
xData_Int  ,
double  e_in,
int  crossSectionType 
)

Definition at line 222 of file tpia_channel.cc.

References tpia_misc_getPointwiseCrossSectionAtE(), and tpia_target_heated_getEIndex().

Referenced by tpia_target_heated_getIndexChannelCrossSectionAtE().

00223                                {
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 }

tpia_product* tpia_channel_getFirstProduct ( tpia_channel *  channel  ) 

Definition at line 185 of file tpia_channel.cc.

References tpia_decayChannel_getFirstProduct().

Referenced by G4GIDI_Misc_channelProductsCompare(), and tpia_channel_getProductByIndex().

00185                                                                     {
00186 
00187     return( tpia_decayChannel_getFirstProduct( &(channel->decayChannel) ) );
00188 }

int tpia_channel_getFromElement ( statusMessageReporting *  smr,
tpia_target_heated *  target,
xData_element *  channelElement,
tpia_channel *  channel,
int  pointwiseRequired 
)

Definition at line 114 of file tpia_channel.cc.

References smr_isOk(), tpia_channel_isProduction(), tpia_frame_setFromElement(), tpia_misc_get2d_xShared_yHistogram_data_Grouped(), tpia_misc_get2dxindex_y_data(), xData_addToAccessed(), xData_convertAttributeTo_xData_Int(), xData_copyAttributionList(), and xData_getOneElementByTagName().

Referenced by tpia_channel_createGetFromElement().

00115                             {
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 );      /* Q string may be something like "notApplicable". */
00139         if( *p != 0 ) {                                     /* In that case set QIsFloat to false. */
00140             channel->QIsFloat = 0;
00141             channel->Q = 0.;
00142         }
00143         //if( ( element = xData_getOneElementByTagName( smr, channelElement, "crossSection", 1 ) ) != NULL ) {
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                 //if( ( pElement = xData_getOneElementByTagName( smr, element, "indexed", 1 ) ) != NULL ) {
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 ) {                /* Only supported "crossSection" currently. */
00157                         if( !tpia_channel_isProduction( smr, channel ) ) {
00158                             //if( ( eElement = xData_getOneElementByTagName( smr, channelElement, "availableEnergy", 1 ) ) != NULL ) {
00159                             if( ( eElement = xData_getOneElementByTagName( smr, channelElement, (char*) "availableEnergy", 1 ) ) != NULL ) {
00160                                 xData_addToAccessed( smr, eElement, 1 );
00161                                 //if( ( gElement = xData_getOneElementByTagName( smr, eElement, "grouped", 1 ) ) != NULL ) {
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 }

tpia_product* tpia_channel_getProductByIndex ( statusMessageReporting *  ,
tpia_channel *  channel,
int  index 
)

Definition at line 193 of file tpia_channel.cc.

References tpia_channel_getFirstProduct(), and tpia_decayChannel_getNextProduct().

00193                                                                                                            {
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 }

int tpia_channel_initialize ( statusMessageReporting *  ,
tpia_channel *  channel 
)

Definition at line 63 of file tpia_channel.cc.

Referenced by tpia_channel_create().

00063                                                                                {
00064 
00065     memset( channel, 0, sizeof( tpia_channel ) );
00066     return( 0 );
00067 }

int tpia_channel_isProduction ( statusMessageReporting *  ,
tpia_channel *  channel 
)

Definition at line 214 of file tpia_channel.cc.

Referenced by tpia_channel_getFromElement().

00214                                                                                  {
00215 
00216     return( strcmp( channel->genre, "production" ) == 0 );
00217 }

int tpia_channel_numberOfProducts ( statusMessageReporting *  ,
tpia_channel *  channel 
)

Definition at line 206 of file tpia_channel.cc.

00206                                                                                      {
00207 
00208     return( channel->decayChannel.numberOfProducts );
00209 }

int tpia_channel_release ( statusMessageReporting *  smr,
tpia_channel *  channel 
)

Definition at line 92 of file tpia_channel.cc.

References tpia_product_free(), xData_free(), and xData_releaseAttributionList().

Referenced by tpia_channel_free().

00092                                                                                {
00093 
00094     tpia_product *product, *nextProduct;
00095 
00096     xData_releaseAttributionList( smr, &(channel->attributes) );
00097     //channel->crossSectionPointwise.data = xData_free( smr, channel->crossSectionPointwise.data );
00098     channel->crossSectionPointwise.data = (double*) xData_free( smr, channel->crossSectionPointwise.data );
00099     //channel->crossSectionGrouped.data = xData_free( smr, channel->crossSectionGrouped.data );
00100     channel->crossSectionGrouped.data = (double*) xData_free( smr, channel->crossSectionGrouped.data );
00101     //channel->availableEnergyGrouped.data = xData_free( smr, channel->availableEnergyGrouped.data );
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 }


Generated on Mon May 27 17:51:16 2013 for Geant4 by  doxygen 1.4.7