Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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_create()

tpia_channel * tpia_channel_create ( statusMessageReporting smr)

Definition at line 50 of file tpia_channel.cc.

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}
tpia_channel * tpia_channel_free(statusMessageReporting *smr, tpia_channel *channel)
Definition: tpia_channel.cc:83
int tpia_channel_initialize(statusMessageReporting *, tpia_channel *channel)
Definition: tpia_channel.cc:63
#define xData_malloc2(smr, size, zero, forItem)
Definition: xData.h:313

Referenced by tpia_channel_createGetFromElement().

◆ tpia_channel_createGetFromElement()

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.

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_create(statusMessageReporting *smr)
Definition: tpia_channel.cc:50

Referenced by tpia_target_heated_read().

◆ tpia_channel_free()

tpia_channel * tpia_channel_free ( statusMessageReporting smr,
tpia_channel channel 
)

Definition at line 83 of file tpia_channel.cc.

83 {
84
85 tpia_channel_release( smr, channel );
86 xData_free( smr, channel );
87 return( NULL );
88}
int tpia_channel_release(statusMessageReporting *smr, tpia_channel *channel)
Definition: tpia_channel.cc:92
void * xData_free(statusMessageReporting *smr, void *p)
Definition: xDataMisc.cc:89

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

◆ tpia_channel_getCrossSectionAtE()

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

Definition at line 222 of file tpia_channel.cc.

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
tpia_1dData crossSectionPointwise
Definition: tpia_target.h:261
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_grouped
Definition: tpia_target.h:88
xData_Int tpia_target_heated_getEIndex(tpia_target_heated *target, double e_in)
#define tpia_crossSectionType_pointwise
Definition: tpia_target.h:89

Referenced by tpia_target_heated_getIndexChannelCrossSectionAtE().

◆ tpia_channel_getFirstProduct()

tpia_product * tpia_channel_getFirstProduct ( tpia_channel channel)

Definition at line 185 of file tpia_channel.cc.

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)

Referenced by G4GIDI_Misc_channelProductsCompare(), and tpia_channel_getProductByIndex().

◆ tpia_channel_getFromElement()

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.

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 ) {
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}
int smr_isOk(statusMessageReporting *smr)
xData_Int start
Definition: tpia_target.h:144
double * data
Definition: tpia_target.h:145
xData_Int end
Definition: tpia_target.h:144
xData_attributionList attributes
Definition: tpia_target.h:254
tpia_1dData availableEnergyGrouped
Definition: tpia_target.h:263
tpia_1dData crossSectionGrouped
Definition: tpia_target.h:262
char * outputChannel
Definition: tpia_target.h:252
tpia_data_frame crossSectionFrame
Definition: tpia_target.h:260
xData_attributionList attributes
Definition: xData.h:186
int tpia_channel_isProduction(statusMessageReporting *, tpia_channel *channel)
#define tpia_misc_pointerToAttributeIfAllOk2(smr, element, required, attributes, name)
Definition: tpia_misc.h:42
int tpia_frame_setFromElement(statusMessageReporting *smr, xData_element *element, int dimension, tpia_data_frame *frame)
Definition: tpia_frame.cc:61
double * tpia_misc_get2dxindex_y_data(statusMessageReporting *smr, xData_element *element, xData_Int *start, xData_Int *end, double *xValues)
Definition: tpia_misc.cc:248
int tpia_misc_get2d_xShared_yHistogram_data_Grouped(statusMessageReporting *smr, xData_element *element, tpia_1dData *group)
Definition: tpia_misc.cc:289
int xData_copyAttributionList(statusMessageReporting *smr, xData_attributionList *dest, xData_attributionList *src)
Definition: xData.cc:564
xData_element * xData_getOneElementByTagName(statusMessageReporting *smr, xData_element *element, char *name, int required)
Definition: xData.cc:810
int xData_addToAccessed(statusMessageReporting *smr, xData_element *element, int increment)
Definition: xData.cc:1078
xData_Int xData_convertAttributeTo_xData_Int(statusMessageReporting *smr, xData_element *element, const char *name, xData_Int *n)
Definition: xData.cc:710
int xData_Int
Definition: xData.h:50

Referenced by tpia_channel_createGetFromElement().

◆ tpia_channel_getProductByIndex()

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

Definition at line 193 of file tpia_channel.cc.

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}
tpia_product * tpia_channel_getFirstProduct(tpia_channel *channel)
tpia_product * tpia_decayChannel_getNextProduct(tpia_product *product)

◆ tpia_channel_initialize()

int tpia_channel_initialize ( statusMessageReporting smr,
tpia_channel channel 
)

Definition at line 63 of file tpia_channel.cc.

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

Referenced by tpia_channel_create().

◆ tpia_channel_isProduction()

int tpia_channel_isProduction ( statusMessageReporting smr,
tpia_channel channel 
)

Definition at line 214 of file tpia_channel.cc.

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

Referenced by tpia_channel_getFromElement().

◆ tpia_channel_numberOfProducts()

int tpia_channel_numberOfProducts ( statusMessageReporting smr,
tpia_channel channel 
)

Definition at line 206 of file tpia_channel.cc.

206 {
207
208 return( channel->decayChannel.numberOfProducts );
209}

◆ tpia_channel_release()

int tpia_channel_release ( statusMessageReporting smr,
tpia_channel channel 
)

Definition at line 92 of file tpia_channel.cc.

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 * products
Definition: tpia_target.h:211
tpia_product * next
Definition: tpia_target.h:232
tpia_product * tpia_product_free(statusMessageReporting *smr, tpia_product *product)
int xData_releaseAttributionList(statusMessageReporting *smr, xData_attributionList *attributes)
Definition: xData.cc:611

Referenced by tpia_channel_free().