Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
tpia_product.cc File Reference
#include <string.h>
#include <ctype.h>
#include <gString.h>
#include <tpia_target.h>
#include <tpia_misc.h>

Go to the source code of this file.

Functions

tpia_producttpia_product_create (statusMessageReporting *smr)
 
int tpia_product_initialize (statusMessageReporting *smr, tpia_product *product)
 
tpia_producttpia_product_createGetFromElement (statusMessageReporting *smr, tpia_channel *channel, tpia_product *parentProduct, xData_element *productElement)
 
tpia_producttpia_product_free (statusMessageReporting *smr, tpia_product *product)
 
int tpia_product_release (statusMessageReporting *smr, tpia_product *product)
 
int tpia_product_getFromElement (statusMessageReporting *smr, tpia_channel *channel, tpia_product *parentProduct, xData_element *productElement, tpia_product *product)
 
int tpia_product_getDecayChannelFromElement (statusMessageReporting *smr, xData_element *parentElement, tpia_channel *channel, tpia_product *parentProduct, tpia_product **priorProductNext)
 
long tpia_product_dataRequired (statusMessageReporting *, tpia_product *product)
 
tpia_producttpia_product_getFirstProduct (tpia_product *product)
 
tpia_producttpia_product_getProductByIndex (statusMessageReporting *, tpia_product *product, int index)
 
int tpia_product_doesDecay (statusMessageReporting *, tpia_product *product)
 
int tpia_product_numberOfProducts (statusMessageReporting *, tpia_product *product)
 
int tpia_product_isDataPresent (statusMessageReporting *, tpia_product *product, int b_data)
 
int tpia_product_sampleMultiplicity (statusMessageReporting *, tpia_product *product, double e_in, double r)
 

Variables

const char * tpia_productGenre_unknown = "unknown"
 
const char * tpia_productGenre_twoBody_angular = "twoBody_angular"
 
const char * tpia_productGenre_twoBody_formFactor = "twoBody_formFactor"
 
const char * tpia_productGenre_NBody_Legendre = "NBody_Legendre"
 
const char * tpia_productGenre_NBody_angular_energy = "NBody_angular_energy"
 
const char * tpia_productGenre_NBody_uncorrelate_Legendre = "NBody_uncorrelate_Legendre"
 
const char * tpia_productGenre_NBody_pairProduction = "NBody_pairProduction"
 

Function Documentation

◆ tpia_product_create()

tpia_product * tpia_product_create ( statusMessageReporting smr)

Definition at line 71 of file tpia_product.cc.

71 {
72
73 tpia_product *product;
74
75 //if( ( product = xData_malloc2( smr, sizeof( tpia_product ), 0, "product" ) ) == NULL ) return( NULL );
76 if( ( product = (tpia_product*) xData_malloc2( smr, sizeof( tpia_product ), 0, "product" ) ) == NULL ) return( NULL );
77 if( tpia_product_initialize( smr, product ) ) product = tpia_product_free( smr, product );
78 return( product );
79}
int tpia_product_initialize(statusMessageReporting *smr, tpia_product *product)
Definition: tpia_product.cc:83
tpia_product * tpia_product_free(statusMessageReporting *smr, tpia_product *product)
#define xData_malloc2(smr, size, zero, forItem)
Definition: xData.h:313

Referenced by tpia_product_createGetFromElement().

◆ tpia_product_createGetFromElement()

tpia_product * tpia_product_createGetFromElement ( statusMessageReporting smr,
tpia_channel channel,
tpia_product parentProduct,
xData_element productElement 
)

Definition at line 93 of file tpia_product.cc.

94 {
95
96 tpia_product *product;
97
98 if( ( product = tpia_product_create( smr ) ) == NULL ) return( NULL );
99 if( tpia_product_getFromElement( smr, channel, parentProduct, productElement, product ) != 0 ) product = tpia_product_free( smr, product );
100 return( product );
101}
tpia_product * tpia_product_create(statusMessageReporting *smr)
Definition: tpia_product.cc:71
int tpia_product_getFromElement(statusMessageReporting *smr, tpia_channel *channel, tpia_product *parentProduct, xData_element *productElement, tpia_product *product)

Referenced by tpia_product_getDecayChannelFromElement().

◆ tpia_product_dataRequired()

long tpia_product_dataRequired ( statusMessageReporting smr,
tpia_product product 
)

Definition at line 359 of file tpia_product.cc.

359 {
360
361 return( product->b_dataRequired );
362}

◆ tpia_product_doesDecay()

int tpia_product_doesDecay ( statusMessageReporting smr,
tpia_product product 
)

Definition at line 387 of file tpia_product.cc.

387 {
388
389 return( product->decayChannel.products != NULL );
390}
tpia_product * products
Definition: tpia_target.h:211
tpia_decayChannel decayChannel
Definition: tpia_target.h:247

◆ tpia_product_free()

tpia_product * tpia_product_free ( statusMessageReporting smr,
tpia_product product 
)

Definition at line 105 of file tpia_product.cc.

105 {
106
107 tpia_product_release( smr, product );
108 xData_free( smr, product );
109 return( NULL );
110}
int tpia_product_release(statusMessageReporting *smr, tpia_product *product)
void * xData_free(statusMessageReporting *smr, void *p)
Definition: xDataMisc.cc:89

Referenced by tpia_channel_release(), tpia_product_create(), tpia_product_createGetFromElement(), and tpia_product_release().

◆ tpia_product_getDecayChannelFromElement()

int tpia_product_getDecayChannelFromElement ( statusMessageReporting smr,
xData_element parentElement,
tpia_channel channel,
tpia_product parentProduct,
tpia_product **  priorProductNext 
)

Definition at line 268 of file tpia_product.cc.

269 {
270
271 xData_elementList *list;
272 tpia_product *product;
273 int i, status = 0;
274
275 list = xData_getElementsByTagName( smr, parentElement, "product" );
276 for( i = 0; i < list->n; i++ ) {
277 if( ( product = tpia_product_createGetFromElement( smr, channel, parentProduct, list->items[i].element ) ) == NULL ) {
278 status = 1;
279 break;
280 }
281 if( parentProduct == NULL ) {
284 channel->decayChannel.numberOfProducts++; }
285 else {
286 channel->decayChannel.m1_fullMass_MeV = parentProduct->productID->fullMass_MeV;
287 channel->decayChannel.m2_fullMass_MeV = 0.;
288 parentProduct->decayChannel.numberOfProducts++;
289 }
290 *priorProductNext = product;
291 priorProductNext = &(product->next);
292 }
293 xData_freeElementList( smr, list );
294 return( status );
295}
tpia_target_heated * target
Definition: tpia_target.h:251
tpia_decayChannel decayChannel
Definition: tpia_target.h:264
double fullMass_MeV
Definition: tpia_target.h:130
tpia_product * next
Definition: tpia_target.h:232
tpia_particle * productID
Definition: tpia_target.h:236
tpia_particle * targetID
Definition: tpia_target.h:272
tpia_particle * projectileID
Definition: tpia_target.h:271
xData_element * element
Definition: xData.h:145
xData_elementListItem * items
Definition: xData.h:151
tpia_product * tpia_product_createGetFromElement(statusMessageReporting *smr, tpia_channel *channel, tpia_product *parentProduct, xData_element *productElement)
Definition: tpia_product.cc:93
void xData_freeElementList(statusMessageReporting *smr, xData_elementList *list)
Definition: xData.cc:832
xData_elementList * xData_getElementsByTagName(statusMessageReporting *smr, xData_element *element, const char *tagName)
Definition: xData.cc:761

◆ tpia_product_getFirstProduct()

tpia_product * tpia_product_getFirstProduct ( tpia_product product)

Definition at line 366 of file tpia_product.cc.

366 {
367
368 return( tpia_decayChannel_getFirstProduct( &(product->decayChannel) ) );
369}
tpia_product * tpia_decayChannel_getFirstProduct(tpia_decayChannel *decayChannel)

Referenced by tpia_product_getProductByIndex().

◆ tpia_product_getFromElement()

int tpia_product_getFromElement ( statusMessageReporting smr,
tpia_channel channel,
tpia_product parentProduct,
xData_element productElement,
tpia_product product 
)

Definition at line 142 of file tpia_product.cc.

143 {
144
145 char const *productGenre;
146 char *name, *multiplicity, *e;
147
148 xData_addToAccessed( smr, productElement, 1 );
149 product->channel = channel;
150 product->parentProduct = parentProduct;
151 if( xData_copyAttributionList( smr, &(product->attributes), &(productElement->attributes) ) != 0 ) return( 0 );
152 name = tpia_misc_pointerToAttributeIfAllOk2( smr, productElement, 1, &(product->attributes), "particle" );
153 if( name != NULL ) {
154 product->productID = tpia_particle_getInternalID( smr, name );
155 multiplicity = tpia_misc_pointerToAttributeIfAllOk2( smr, productElement, 1, &(product->attributes), "multiplicity" );
156 if( multiplicity != NULL ) {
157 if( strcmp( multiplicity, "energyDependent" ) && strcmp( multiplicity, "partialProduction" ) ) { /* Must be an integer. */
158 product->multiplicity = strtol( multiplicity, &e, 10 );
159 while( isspace( *e ) ) e++;
160 if( *e != 0 ) tpia_misc_setMessageError_Element( smr, NULL, productElement, __FILE__, __LINE__, 1, "bad multiplicity = %s", multiplicity );
161 }
162 }
163 }
164 if( ( productGenre = tpia_misc_pointerToAttributeIfAllOk2( smr, productElement, 1, &(product->attributes), "genre" ) ) != NULL ) {
165 if( strcmp( productGenre, tpia_productGenre_unknown ) == 0 ) {
166 product->b_dataRequired = 0;
167 product->genre = tpia_productGenre_unknown; }
168 else if( strcmp( productGenre, tpia_productGenre_twoBody_angular ) == 0 ) {
169 product->b_dataRequired = tpia_b_twoBody_angular;
171 else if( strcmp( productGenre, tpia_productGenre_twoBody_formFactor ) == 0 ) {
172 product->b_dataRequired = tpia_b_twoBody_formFactor;
174 else if( strcmp( productGenre, tpia_productGenre_NBody_Legendre ) == 0 ) {
175 product->b_dataRequired = tpia_b_NBody_Legendre;
177 else if( strcmp( productGenre, tpia_productGenre_NBody_angular_energy ) == 0 ) {
178 product->b_dataRequired = tpia_b_NBody_angular_energy;
180 else if( strcmp( productGenre, tpia_productGenre_NBody_uncorrelate_Legendre ) == 0 ) {
181 product->b_dataRequired = tpia_b_NBody_uncorrelate_Legendre;
183 else if( strcmp( productGenre, tpia_productGenre_NBody_pairProduction ) == 0 ) {
184 product->b_dataRequired = tpia_b_NBody_pairProduction;
186 else {
187 tpia_misc_setMessageError_Element( smr, NULL, productElement, __FILE__, __LINE__, 1, "unsupported product genre = %s", productGenre );
188 }
189 if( smr_isOk( smr ) ) _tpia_product_getProductOutgoingData( smr, productElement, product );
190 }
191 return( !smr_isOk( smr ) );
192}
int smr_isOk(statusMessageReporting *smr)
tpia_product * parentProduct
Definition: tpia_target.h:234
xData_attributionList attributes
Definition: tpia_target.h:235
tpia_channel * channel
Definition: tpia_target.h:233
char const * genre
Definition: tpia_target.h:237
xData_attributionList attributes
Definition: xData.h:186
int tpia_misc_setMessageError_Element(statusMessageReporting *smr, void *userInterface, xData_element *element, const char *file, int line, int code, const char *fmt,...)
Definition: tpia_misc.cc:183
#define tpia_misc_pointerToAttributeIfAllOk2(smr, element, required, attributes, name)
Definition: tpia_misc.h:42
const char * tpia_productGenre_twoBody_angular
Definition: tpia_product.cc:57
const char * tpia_productGenre_NBody_uncorrelate_Legendre
Definition: tpia_product.cc:61
const char * tpia_productGenre_NBody_pairProduction
Definition: tpia_product.cc:62
const char * tpia_productGenre_twoBody_formFactor
Definition: tpia_product.cc:58
const char * tpia_productGenre_NBody_Legendre
Definition: tpia_product.cc:59
const char * tpia_productGenre_NBody_angular_energy
Definition: tpia_product.cc:60
const char * tpia_productGenre_unknown
Definition: tpia_product.cc:56
tpia_particle * tpia_particle_getInternalID(statusMessageReporting *smr, const char *const name)
int xData_copyAttributionList(statusMessageReporting *smr, xData_attributionList *dest, xData_attributionList *src)
Definition: xData.cc:564
int xData_addToAccessed(statusMessageReporting *smr, xData_element *element, int increment)
Definition: xData.cc:1078

Referenced by tpia_product_createGetFromElement().

◆ tpia_product_getProductByIndex()

tpia_product * tpia_product_getProductByIndex ( statusMessageReporting smr,
tpia_product product,
int  index 
)

Definition at line 374 of file tpia_product.cc.

374 {
375
376 int i = 0;
377 tpia_product *p;
378
379 if( index < 0 ) return( NULL );
380 for( p = tpia_product_getFirstProduct( product ); ( p != NULL ) && ( i < index ); p = tpia_decayChannel_getNextProduct( p ), i++ ) ;
381 return( p );
382}
tpia_product * tpia_product_getFirstProduct(tpia_product *product)
tpia_product * tpia_decayChannel_getNextProduct(tpia_product *product)

◆ tpia_product_initialize()

int tpia_product_initialize ( statusMessageReporting smr,
tpia_product product 
)

Definition at line 83 of file tpia_product.cc.

83 {
84
85 memset( product, 0, sizeof( tpia_product ) );
86 if( tpia_angular_initialize( smr, &(product->angular) ) ) return( 1 );
87 if( tpia_Legendre_initialize( smr, &(product->Legendre) ) ) return( 1 );
88 return( 0 );
89}
tpia_angular angular
Definition: tpia_target.h:244
tpia_Legendre Legendre
Definition: tpia_target.h:245
int tpia_Legendre_initialize(statusMessageReporting *smr, tpia_Legendre *Legendre)
int tpia_angular_initialize(statusMessageReporting *smr, tpia_angular *angular)
Definition: tpia_angular.cc:49

Referenced by tpia_product_create().

◆ tpia_product_isDataPresent()

int tpia_product_isDataPresent ( statusMessageReporting smr,
tpia_product product,
int  b_data 
)

Definition at line 403 of file tpia_product.cc.

403 {
404
405 return( product->b_dataPresent && b_data );
406}

◆ tpia_product_numberOfProducts()

int tpia_product_numberOfProducts ( statusMessageReporting smr,
tpia_product product 
)

Definition at line 395 of file tpia_product.cc.

395 {
396
397 return( product->decayChannel.numberOfProducts );
398}

◆ tpia_product_release()

int tpia_product_release ( statusMessageReporting smr,
tpia_product product 
)

Definition at line 114 of file tpia_product.cc.

114 {
115
116 tpia_multiplicity *multiplicity, *multiplicity_next;
117 tpia_product *decayProduct, *nextProduct;
118
119 xData_releaseAttributionList( smr, &(product->attributes) );
120 //product->depositionEnergyGrouped.data = xData_free( smr, product->depositionEnergyGrouped.data );
121 product->depositionEnergyGrouped.data = (double*) xData_free( smr, product->depositionEnergyGrouped.data );
122
123 if( product->multiplicityVsEnergy != NULL ) tpia_multiplicity_free( smr, product->multiplicityVsEnergy );
124 for( multiplicity = product->delayedNeutronMultiplicityVsEnergy; multiplicity != NULL; multiplicity = multiplicity_next ) {
125 multiplicity_next = multiplicity->next;
126 tpia_multiplicity_free( smr, multiplicity );
127 }
128 tpia_angular_release( smr, &(product->angular) );
129 tpia_Legendre_release( smr, &(product->Legendre ) );
130 tpia_angularEnergy_release( smr, &(product->angularEnergy) );
131 for( decayProduct = product->decayChannel.products; decayProduct != NULL; decayProduct = nextProduct ) {
132 nextProduct = decayProduct->next;
133 tpia_product_free( smr, decayProduct );
134 }
135 product->decayChannel.numberOfProducts = 0;
136 product->decayChannel.products = NULL;
137 return( 0 );
138}
double * data
Definition: tpia_target.h:145
tpia_multiplicity * next
Definition: tpia_target.h:174
tpia_multiplicity * multiplicityVsEnergy
Definition: tpia_target.h:242
tpia_1dData depositionEnergyGrouped
Definition: tpia_target.h:240
tpia_angularEnergy angularEnergy
Definition: tpia_target.h:246
tpia_multiplicity * delayedNeutronMultiplicityVsEnergy
Definition: tpia_target.h:243
int tpia_angularEnergy_release(statusMessageReporting *smr, tpia_angularEnergy *angularEnergy)
tpia_multiplicity * tpia_multiplicity_free(statusMessageReporting *smr, tpia_multiplicity *multiplicity)
int tpia_Legendre_release(statusMessageReporting *smr, tpia_Legendre *Legendre)
int tpia_angular_release(statusMessageReporting *smr, tpia_angular *angular)
Definition: tpia_angular.cc:60
int xData_releaseAttributionList(statusMessageReporting *smr, xData_attributionList *attributes)
Definition: xData.cc:611

Referenced by tpia_product_free().

◆ tpia_product_sampleMultiplicity()

int tpia_product_sampleMultiplicity ( statusMessageReporting smr,
tpia_product product,
double  e_in,
double  r 
)

Definition at line 411 of file tpia_product.cc.

411 {
412
413 int i, multiplicity;
414 tpia_multiplicity *multiplicityVsEnergy = product->multiplicityVsEnergy;
415 double *p = multiplicityVsEnergy->pointwise, dMult;
416
417 if( e_in <= p[0] ) {
418 dMult = p[1]; }
419 else if( e_in >= p[2 * ( multiplicityVsEnergy->numberOfPointwise - 1 )] ) {
420 dMult = p[2 * multiplicityVsEnergy->numberOfPointwise - 1]; }
421 else {
422 for( i = 0; i < multiplicityVsEnergy->numberOfPointwise - 1; i++, p += 2 ) if( e_in < p[2] ) break;
423 dMult = ( e_in - p[0] ) / ( p[2] - p[0] );
424 dMult = dMult * p[3] + ( 1. - dMult ) * p[1];
425 }
426 multiplicity = (int) dMult;
427 if( r < ( dMult - multiplicity ) ) multiplicity++;
428
429 return( multiplicity );
430}
xData_Int numberOfPointwise
Definition: tpia_target.h:177

Referenced by tpia_decayChannel_sampleProductsAtE().

Variable Documentation

◆ tpia_productGenre_NBody_angular_energy

const char * tpia_productGenre_NBody_angular_energy = "NBody_angular_energy"

Definition at line 60 of file tpia_product.cc.

◆ tpia_productGenre_NBody_Legendre

const char * tpia_productGenre_NBody_Legendre = "NBody_Legendre"

Definition at line 59 of file tpia_product.cc.

◆ tpia_productGenre_NBody_pairProduction

const char * tpia_productGenre_NBody_pairProduction = "NBody_pairProduction"

Definition at line 62 of file tpia_product.cc.

◆ tpia_productGenre_NBody_uncorrelate_Legendre

const char * tpia_productGenre_NBody_uncorrelate_Legendre = "NBody_uncorrelate_Legendre"

Definition at line 61 of file tpia_product.cc.

◆ tpia_productGenre_twoBody_angular

const char * tpia_productGenre_twoBody_angular = "twoBody_angular"

Definition at line 57 of file tpia_product.cc.

◆ tpia_productGenre_twoBody_formFactor

const char * tpia_productGenre_twoBody_formFactor = "twoBody_formFactor"

Definition at line 58 of file tpia_product.cc.

◆ tpia_productGenre_unknown

const char* tpia_productGenre_unknown = "unknown"

Definition at line 56 of file tpia_product.cc.

Referenced by tpia_product_getFromElement().