Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
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_channeltpia_channel_create (statusMessageReporting *smr)
 
int tpia_channel_initialize (statusMessageReporting *, tpia_channel *channel)
 
tpia_channeltpia_channel_createGetFromElement (statusMessageReporting *smr, tpia_target_heated *target, xData_element *channelElement, int pointwiseRequired)
 
tpia_channeltpia_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_producttpia_channel_getFirstProduct (tpia_channel *channel)
 
tpia_producttpia_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(), tpia_channel_initialize(), and xData_malloc2.

Referenced by tpia_channel_createGetFromElement().

50  {
51 
52  tpia_channel *channel;
53 
54  //if( ( channel = xData_malloc2( smr, sizeof( tpia_channel ), 0, "channel" ) ) == NULL ) return( NULL );
55  if( ( channel = (tpia_channel*) xData_malloc2( smr, sizeof( tpia_channel ), 0, "channel" ) ) == NULL ) return( NULL );
56  if( tpia_channel_initialize( smr, channel ) ) channel = tpia_channel_free( smr, channel );
57  return( channel );
58 }
#define xData_malloc2(smr, size, zero, forItem)
Definition: xData.h:313
int tpia_channel_initialize(statusMessageReporting *, tpia_channel *channel)
Definition: tpia_channel.cc:63
tpia_channel * tpia_channel_free(statusMessageReporting *smr, tpia_channel *channel)
Definition: tpia_channel.cc:83
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().

72  {
73 
74  tpia_channel *channel;
75 
76  if( ( channel = tpia_channel_create( smr ) ) == NULL ) return( NULL );
77  if( tpia_channel_getFromElement( smr, target, channelElement, channel, pointwiseRequired ) != 0 ) channel = tpia_channel_free( smr, channel );
78  return( channel );
79 }
int tpia_channel_getFromElement(statusMessageReporting *smr, tpia_target_heated *target, xData_element *channelElement, tpia_channel *channel, int pointwiseRequired)
tpia_channel * tpia_channel_free(statusMessageReporting *smr, tpia_channel *channel)
Definition: tpia_channel.cc:83
tpia_channel * tpia_channel_create(statusMessageReporting *smr)
Definition: tpia_channel.cc:50
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().

83  {
84 
85  tpia_channel_release( smr, channel );
86  xData_free( smr, channel );
87  return( NULL );
88 }
void * xData_free(statusMessageReporting *smr, void *p)
Definition: xDataMisc.cc:89
int tpia_channel_release(statusMessageReporting *smr, tpia_channel *channel)
Definition: tpia_channel.cc:92
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_channel_s::crossSectionPointwise, tpia_target_heated_s::energyGrid, tpia_channel_s::target, tpia_crossSectionType_grouped, tpia_crossSectionType_pointwise, tpia_misc_getPointwiseCrossSectionAtE(), and tpia_target_heated_getEIndex().

Referenced by tpia_target_heated_getIndexChannelCrossSectionAtE().

223  {
224 
225  double xsec = 0.;
226 
227  if( crossSectionType == tpia_crossSectionType_grouped ) {
228  xsec = 0; }
229  else if( crossSectionType == tpia_crossSectionType_pointwise ) {
231  tpia_target_heated_getEIndex( channel->target, e_in ), e_in );
232  }
233  return( xsec );
234 }
tpia_target_heated * target
Definition: tpia_target.h:251
xData_Int tpia_target_heated_getEIndex(tpia_target_heated *target, double e_in)
double tpia_misc_getPointwiseCrossSectionAtE(statusMessageReporting *smr, tpia_1dData *crossSection, double *energyGrid, xData_Int index, double e_in)
Definition: tpia_misc.cc:298
#define tpia_crossSectionType_pointwise
Definition: tpia_target.h:89
tpia_1dData crossSectionPointwise
Definition: tpia_target.h:261
#define tpia_crossSectionType_grouped
Definition: tpia_target.h:88
tpia_product* tpia_channel_getFirstProduct ( tpia_channel channel)

Definition at line 185 of file tpia_channel.cc.

References tpia_channel_s::decayChannel, and tpia_decayChannel_getFirstProduct().

Referenced by G4GIDI_Misc_channelProductsCompare(), and tpia_channel_getProductByIndex().

185  {
186 
187  return( tpia_decayChannel_getFirstProduct( &(channel->decayChannel) ) );
188 }
tpia_decayChannel decayChannel
Definition: tpia_target.h:264
tpia_product * tpia_decayChannel_getFirstProduct(tpia_decayChannel *decayChannel)
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 xData_element_s::attributes, tpia_channel_s::attributes, tpia_channel_s::availableEnergyGrouped, tpia_target_heated_s::contents, tpia_channel_s::crossSectionFrame, tpia_channel_s::crossSectionGrouped, tpia_channel_s::crossSectionPointwise, tpia_1dData_s::data, tpia_1dData_s::end, tpia_channel_s::ENDF_MT, tpia_channel_s::ENDL_C, tpia_target_heated_s::energyGrid, tpia_channel_s::fission, tpia_channel_s::genre, int(), tpia_channel_s::outputChannel, tpia_channel_s::Q, tpia_channel_s::QIsFloat, tpia_channel_s::QString, smr_isOk(), tpia_1dData_s::start, tpia_channel_s::target, tpia_channel_isProduction(), tpia_frame_setFromElement(), tpia_misc_get2d_xShared_yHistogram_data_Grouped(), tpia_misc_get2dxindex_y_data(), tpia_misc_pointerToAttributeIfAllOk2, xData_addToAccessed(), xData_convertAttributeTo_xData_Int(), xData_copyAttributionList(), and xData_getOneElementByTagName().

Referenced by tpia_channel_createGetFromElement().

115  {
116 
117  xData_Int ll;
118  char *p;
119  xData_element *element, *pElement, *gElement, *eElement;
120 
121  xData_addToAccessed( smr, channelElement, 1 );
122  channel->target = target;
123  xData_copyAttributionList( smr, &(channel->attributes), &(channelElement->attributes) );
124  channel->outputChannel = tpia_misc_pointerToAttributeIfAllOk2(smr, channelElement, 1, &(channel->attributes), "outputChannel" );
125  channel->genre = tpia_misc_pointerToAttributeIfAllOk2( smr, channelElement, 1, &(channel->attributes), "genre" );
126  channel->QString = tpia_misc_pointerToAttributeIfAllOk2( smr, channelElement, 1, &(channel->attributes), "Q" );
127  channel->fission = tpia_misc_pointerToAttributeIfAllOk2( smr, channelElement, 0, &(channel->attributes), "fission" );
128  if( smr_isOk( smr ) ) {
129  ll = 0;
130  if( xData_convertAttributeTo_xData_Int( smr, channelElement, "ENDL_C", &ll ) >= 0 ) channel->ENDL_C = (int) ll;
131  }
132  if( smr_isOk( smr ) ) {
133  ll = 0;
134  if( xData_convertAttributeTo_xData_Int( smr, channelElement, "ENDF_MT2", &ll ) >= 0 ) channel->ENDF_MT = (int) ll;
135  }
136  if( smr_isOk( smr ) ) {
137  channel->QIsFloat = 1;
138  channel->Q = strtod( channel->QString, &p ); /* Q string may be something like "notApplicable". */
139  if( *p != 0 ) { /* In that case set QIsFloat to false. */
140  channel->QIsFloat = 0;
141  channel->Q = 0.;
142  }
143  //if( ( element = xData_getOneElementByTagName( smr, channelElement, "crossSection", 1 ) ) != NULL ) {
144  if( ( element = xData_getOneElementByTagName( smr, channelElement, (char*) "crossSection", 1 ) ) != NULL ) {
145  if( ( tpia_frame_setFromElement( smr, element, 2, &channel->crossSectionFrame ) ) == 0 ) {
146  xData_addToAccessed( smr, element, 1 );
147  //if( ( pElement = xData_getOneElementByTagName( smr, element, "indexed", 1 ) ) != NULL ) {
148  if( ( pElement = xData_getOneElementByTagName( smr, element, (char*) "indexed", 1 ) ) != NULL ) {
149  channel->crossSectionPointwise.data = tpia_misc_get2dxindex_y_data( smr, pElement,
150  &(channel->crossSectionPointwise.start), &(channel->crossSectionPointwise.end), target->energyGrid );
151  }
152  if( ( gElement = xData_getOneElementByTagName( smr, element, (char*) "grouped", 1 ) ) != NULL ) {
154  }
155  if( ( channel->crossSectionGrouped.data != NULL ) && ( ( channel->crossSectionPointwise.data != NULL ) || !pointwiseRequired ) ) {
156  if( target->contents == NULL ) { /* Only supported "crossSection" currently. */
157  if( !tpia_channel_isProduction( smr, channel ) ) {
158  //if( ( eElement = xData_getOneElementByTagName( smr, channelElement, "availableEnergy", 1 ) ) != NULL ) {
159  if( ( eElement = xData_getOneElementByTagName( smr, channelElement, (char*) "availableEnergy", 1 ) ) != NULL ) {
160  xData_addToAccessed( smr, eElement, 1 );
161  //if( ( gElement = xData_getOneElementByTagName( smr, eElement, "grouped", 1 ) ) != NULL ) {
162  if( ( gElement = xData_getOneElementByTagName( smr, eElement, (char*) "grouped", 1 ) ) != NULL ) {
164  }
165  }
166  }
167  }
168  if( smr_isOk( smr ) ) _tpia_channel_getProductData( smr, channelElement, channel );
169  }
170  }
171  }
172  }
173  return( !smr_isOk( smr ) );
174 }
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
const char * p
Definition: xmltok.h:285
xData_element * xData_getOneElementByTagName(statusMessageReporting *smr, xData_element *element, char *name, int required)
Definition: xData.cc:810
tpia_target_heated * target
Definition: tpia_target.h:251
int xData_copyAttributionList(statusMessageReporting *smr, xData_attributionList *dest, xData_attributionList *src)
Definition: xData.cc:564
double * tpia_misc_get2dxindex_y_data(statusMessageReporting *smr, xData_element *element, xData_Int *start, xData_Int *end, double *xValues)
Definition: tpia_misc.cc:248
const XML_Char * target
int tpia_frame_setFromElement(statusMessageReporting *smr, xData_element *element, int dimension, tpia_data_frame *frame)
Definition: tpia_frame.cc:62
tpia_1dData crossSectionGrouped
Definition: tpia_target.h:262
#define tpia_misc_pointerToAttributeIfAllOk2(smr, element, required, attributes, name)
Definition: tpia_misc.h:42
double * data
Definition: tpia_target.h:145
char * outputChannel
Definition: tpia_target.h:252
tpia_data_frame crossSectionFrame
Definition: tpia_target.h:260
int smr_isOk(statusMessageReporting *smr)
tpia_1dData crossSectionPointwise
Definition: tpia_target.h:261
xData_Int start
Definition: tpia_target.h:144
int tpia_misc_get2d_xShared_yHistogram_data_Grouped(statusMessageReporting *smr, xData_element *element, tpia_1dData *group)
Definition: tpia_misc.cc:289
xData_Int end
Definition: tpia_target.h:144
int xData_addToAccessed(statusMessageReporting *smr, xData_element *element, int increment)
Definition: xData.cc:1078
int xData_Int
Definition: xData.h:50
xData_attributionList attributes
Definition: xData.h:186
xData_attributionList attributes
Definition: tpia_target.h:254
xData_Int xData_convertAttributeTo_xData_Int(statusMessageReporting *smr, xData_element *element, const char *name, xData_Int *n)
Definition: xData.cc:710
tpia_1dData availableEnergyGrouped
Definition: tpia_target.h:263
int tpia_channel_isProduction(statusMessageReporting *, tpia_channel *channel)
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().

193  {
194 
195  int i = 0;
196  tpia_product *p;
197 
198  if( index < 0 ) return( NULL );
199  for( p = tpia_channel_getFirstProduct( channel ); ( p != NULL ) && ( i < index ); p = tpia_decayChannel_getNextProduct( p ), i++ ) ;
200  return( p );
201 }
const char * p
Definition: xmltok.h:285
tpia_product * tpia_decayChannel_getNextProduct(tpia_product *product)
tpia_product * tpia_channel_getFirstProduct(tpia_channel *channel)
int tpia_channel_initialize ( statusMessageReporting ,
tpia_channel channel 
)

Definition at line 63 of file tpia_channel.cc.

Referenced by tpia_channel_create().

63  {
64 
65  memset( channel, 0, sizeof( tpia_channel ) );
66  return( 0 );
67 }
int tpia_channel_isProduction ( statusMessageReporting ,
tpia_channel channel 
)

Definition at line 214 of file tpia_channel.cc.

References tpia_channel_s::genre.

Referenced by tpia_channel_getFromElement().

214  {
215 
216  return( strcmp( channel->genre, "production" ) == 0 );
217 }
int tpia_channel_numberOfProducts ( statusMessageReporting ,
tpia_channel channel 
)

Definition at line 206 of file tpia_channel.cc.

References tpia_channel_s::decayChannel, and tpia_decayChannel_s::numberOfProducts.

206  {
207 
208  return( channel->decayChannel.numberOfProducts );
209 }
tpia_decayChannel decayChannel
Definition: tpia_target.h:264
int tpia_channel_release ( statusMessageReporting smr,
tpia_channel channel 
)

Definition at line 92 of file tpia_channel.cc.

References tpia_channel_s::attributes, tpia_channel_s::availableEnergyGrouped, tpia_channel_s::crossSectionGrouped, tpia_channel_s::crossSectionPointwise, tpia_1dData_s::data, tpia_channel_s::decayChannel, tpia_product_s::next, tpia_decayChannel_s::numberOfProducts, tpia_decayChannel_s::products, tpia_product_free(), xData_free(), and xData_releaseAttributionList().

Referenced by tpia_channel_free().

92  {
93 
94  tpia_product *product, *nextProduct;
95 
96  xData_releaseAttributionList( smr, &(channel->attributes) );
97  //channel->crossSectionPointwise.data = xData_free( smr, channel->crossSectionPointwise.data );
98  channel->crossSectionPointwise.data = (double*) xData_free( smr, channel->crossSectionPointwise.data );
99  //channel->crossSectionGrouped.data = xData_free( smr, channel->crossSectionGrouped.data );
100  channel->crossSectionGrouped.data = (double*) xData_free( smr, channel->crossSectionGrouped.data );
101  //channel->availableEnergyGrouped.data = xData_free( smr, channel->availableEnergyGrouped.data );
102  channel->availableEnergyGrouped.data = (double*) xData_free( smr, channel->availableEnergyGrouped.data );
103  for( product = channel->decayChannel.products; product != NULL; product = nextProduct ) {
104  nextProduct = product->next;
105  tpia_product_free( smr, product );
106  }
107  channel->decayChannel.numberOfProducts = 0;
108  channel->decayChannel.products = NULL;
109  return( 0 );
110 }
tpia_product * next
Definition: tpia_target.h:232
tpia_decayChannel decayChannel
Definition: tpia_target.h:264
tpia_product * tpia_product_free(statusMessageReporting *smr, tpia_product *product)
void * xData_free(statusMessageReporting *smr, void *p)
Definition: xDataMisc.cc:89
tpia_product * products
Definition: tpia_target.h:211
tpia_1dData crossSectionGrouped
Definition: tpia_target.h:262
int xData_releaseAttributionList(statusMessageReporting *smr, xData_attributionList *attributes)
Definition: xData.cc:611
double * data
Definition: tpia_target.h:145
tpia_1dData crossSectionPointwise
Definition: tpia_target.h:261
xData_attributionList attributes
Definition: tpia_target.h:254
tpia_1dData availableEnergyGrouped
Definition: tpia_target.h:263