40 #include <tpia_target.h>
41 #include <tpia_misc.h>
43 #if defined __cplusplus
65 static int _tpia_product_checkRequiredData( statusMessageReporting *smr,
int allowMany,
int m, xData_element *productElement, tpia_product *product,
char *str );
73 tpia_product *product;
76 if( ( product = (tpia_product*) xData_malloc2( smr,
sizeof( tpia_product ), 0,
"product" ) ) == NULL )
return( NULL );
85 memset( product, 0,
sizeof( tpia_product ) );
94 xData_element *productElement ) {
96 tpia_product *product;
116 tpia_multiplicity *multiplicity, *multiplicity_next;
117 tpia_product *decayProduct, *nextProduct;
121 product->depositionEnergyGrouped.data = (
double*)
xData_free( smr, product->depositionEnergyGrouped.data );
124 for( multiplicity = product->delayedNeutronMultiplicityVsEnergy; multiplicity != NULL; multiplicity = multiplicity_next ) {
125 multiplicity_next = multiplicity->next;
131 for( decayProduct = product->decayChannel.products; decayProduct != NULL; decayProduct = nextProduct ) {
132 nextProduct = decayProduct->next;
135 product->decayChannel.numberOfProducts = 0;
136 product->decayChannel.products = NULL;
143 tpia_product *product ) {
145 char const *productGenre;
146 char *
name, *multiplicity, *e;
149 product->channel = channel;
150 product->parentProduct = parentProduct;
152 name = tpia_misc_pointerToAttributeIfAllOk2( smr, productElement, 1, &(product->attributes),
"particle" );
155 multiplicity = tpia_misc_pointerToAttributeIfAllOk2( smr, productElement, 1, &(product->attributes),
"multiplicity" );
156 if( multiplicity != NULL ) {
157 if( strcmp( multiplicity,
"energyDependent" ) && strcmp( multiplicity,
"partialProduction" ) ) {
158 product->multiplicity = strtol( multiplicity, &e, 10 );
159 while( isspace( *e ) ) e++;
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;
202 if( strcmp( data->name,
"depositionEnergy" ) == 0 ) {
206 else if( strcmp( data->name,
"multiplicity" ) == 0 ) {
207 allowMany = ( product->channel->fission != NULL ) && ( strcmp( product->productID->name,
"n_1" ) == 0 );
211 else if( strcmp( data->name,
"angular" ) == 0 ) {
215 else if( strcmp( data->name,
"Legendre" ) == 0 ) {
219 else if( strcmp( data->name,
"angularEnergy" ) == 0 ) {
222 else if( strcmp( data->name,
"decayChannel" ) == 0 ) {
226 printf(
" %s\n", data->name );
229 if( ( product->b_dataPresent >> tpia_m_commonShift ) != ( product->b_dataRequired >> tpia_m_commonShift ) ) {
231 int missing = ~product->b_dataPresent & product->b_dataRequired;
232 char const *str =
"";
234 if( missing & tpia_m_angular )
gString_addTo( NULL, &gStr,
"angular " );
235 if( missing & tpia_m_formFactor )
gString_addTo( NULL, &gStr,
"formFactor " );
236 if( missing & tpia_m_Legendre )
gString_addTo( NULL, &gStr,
"Legendre " );
237 if( missing & tpia_m_angular_energy )
gString_addTo( NULL, &gStr,
"angular_energy " );
241 product->productID->name );
252 if( !allowMany && ( product->b_dataPresent & m ) ) {
256 if( ( m & ( tpia_m_depositionEnergy | tpia_m_multiplicity | tpia_m_decayChannel ) ) == 0 ) {
257 if( ( product->b_dataRequired & m ) == 0 ) {
262 product->b_dataPresent +=
m;
269 tpia_product **priorProductNext ) {
271 xData_elementList *list;
272 tpia_product *product;
276 for( i = 0; i < list->n; i++ ) {
281 if( parentProduct == NULL ) {
282 channel->decayChannel.m1_fullMass_MeV = channel->target->projectileID->fullMass_MeV;
283 channel->decayChannel.m2_fullMass_MeV = channel->target->targetID->fullMass_MeV;
284 channel->decayChannel.numberOfProducts++; }
286 channel->decayChannel.m1_fullMass_MeV = parentProduct->productID->fullMass_MeV;
287 channel->decayChannel.m2_fullMass_MeV = 0.;
288 parentProduct->decayChannel.numberOfProducts++;
290 *priorProductNext = product;
291 priorProductNext = &(product->next);
305 if( strcmp( data->name,
"grouped" ) == 0 ) {
319 tpia_multiplicity *multiplicity, *prior, *current;
320 const char *timeScale;
321 int isDelayedNeutrons;
325 if( ( isDelayedNeutrons == 0 ) && ( product->multiplicityVsEnergy != NULL ) ) {
330 if( isDelayedNeutrons == 0 ) {
331 product->multiplicityVsEnergy = multiplicity; }
333 if( product->delayedNeutronMultiplicityVsEnergy == NULL ) {
334 product->delayedNeutronMultiplicityVsEnergy = multiplicity; }
336 if( product->delayedNeutronMultiplicityVsEnergy->timeScale > multiplicity->timeScale ) {
337 multiplicity->next = product->delayedNeutronMultiplicityVsEnergy;
338 product->delayedNeutronMultiplicityVsEnergy = multiplicity; }
340 for( current = product->delayedNeutronMultiplicityVsEnergy->next, prior = product->delayedNeutronMultiplicityVsEnergy; current != NULL;
341 current = current->next ) {
342 if( current->timeScale > multiplicity->timeScale ) {
343 multiplicity->next = current;
344 prior->next = multiplicity;
349 if( current == NULL ) prior->next = multiplicity;
361 return( product->b_dataRequired );
379 if( index < 0 )
return( NULL );
389 return( product->decayChannel.products != NULL );
397 return( product->decayChannel.numberOfProducts );
405 return( product->b_dataPresent && b_data );
414 tpia_multiplicity *multiplicityVsEnergy = product->multiplicityVsEnergy;
415 double *p = multiplicityVsEnergy->pointwise, dMult;
419 else if( e_in >= p[2 * ( multiplicityVsEnergy->numberOfPointwise - 1 )] ) {
420 dMult = p[2 * multiplicityVsEnergy->numberOfPointwise - 1]; }
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];
426 multiplicity = (int) dMult;
427 if( r < ( dMult - multiplicity ) ) multiplicity++;
429 return( multiplicity );
432 #if defined __cplusplus
const char * tpia_productGenre_NBody_angular_energy
int tpia_angular_release(statusMessageReporting *smr, tpia_angular *angular)
tpia_product * tpia_product_free(statusMessageReporting *smr, tpia_product *product)
int xData_addToAccessed(statusMessageReporting *, xData_element *element, int increment)
const char * tpia_productGenre_twoBody_formFactor
int tpia_Legendre_getFromElement(statusMessageReporting *smr, xData_element *LegendreElement, tpia_Legendre *Legendre)
int tpia_misc_get2d_xShared_yHistogram_data_Grouped(statusMessageReporting *smr, xData_element *element, tpia_1dData *group)
static const int tpia_b_NBody_angular_energy
tpia_multiplicity * tpia_multiplicity_free(statusMessageReporting *smr, tpia_multiplicity *multiplicity)
static const int tpia_b_twoBody_formFactor
int tpia_product_getDecayChannelFromElement(statusMessageReporting *smr, xData_element *parentElement, tpia_channel *channel, tpia_product *parentProduct, tpia_product **priorProductNext)
const char * tpia_productGenre_NBody_Legendre
static const int tpia_b_NBody_uncorrelate_Legendre
tpia_multiplicity * tpia_multiplicity_createGetFromElement(statusMessageReporting *smr, xData_element *multiplicityElement, int nGroups)
xData_element * xData_getNextElement(xData_element *element)
static int _tpia_product_getProductOutgoingData(statusMessageReporting *smr, xData_element *productElement, tpia_product *product)
tpia_product * tpia_decayChannel_getNextProduct(tpia_product *product)
tpia_product * tpia_product_create(statusMessageReporting *smr)
int tpia_misc_setMessageError_Element(statusMessageReporting *smr, void *userInterface, xData_element *element, const char *file, int line, int code, const char *fmt,...)
int tpia_Legendre_initialize(statusMessageReporting *smr, tpia_Legendre *Legendre)
const char * tpia_productGenre_twoBody_angular
int tpia_angularEnergy_release(statusMessageReporting *smr, tpia_angularEnergy *angularEnergy)
int tpia_angular_getFromElement(statusMessageReporting *smr, xData_element *angularElement, tpia_angular *angular)
int gString_addTo(statusMessageReporting *smr, gString *gStr, char const *str)
static int _tpia_product_checkRequiredData(statusMessageReporting *smr, int allowMany, int m, xData_element *productElement, tpia_product *product, char *str)
const char * tpia_productGenre_unknown
int tpia_product_doesDecay(statusMessageReporting *, tpia_product *product)
static const int tpia_b_NBody_pairProduction
int tpia_angular_initialize(statusMessageReporting *smr, tpia_angular *angular)
tpia_product * tpia_product_createGetFromElement(statusMessageReporting *smr, tpia_channel *channel, tpia_product *parentProduct, xData_element *productElement)
int tpia_product_getFromElement(statusMessageReporting *smr, tpia_channel *channel, tpia_product *parentProduct, xData_element *productElement, tpia_product *product)
xData_element * xData_getFirstElement(xData_element *element)
int gString_release(statusMessageReporting *smr, gString *gStr)
int smr_isOk(statusMessageReporting *smr)
int tpia_multiplicity_getTimeScaleFromElement(statusMessageReporting *smr, xData_element *element, const char **timeScale, int *isDelayedNeutrons, double *dTimeScale)
int tpia_product_numberOfProducts(statusMessageReporting *, tpia_product *product)
long tpia_product_dataRequired(statusMessageReporting *, tpia_product *product)
int tpia_product_sampleMultiplicity(statusMessageReporting *, tpia_product *product, double e_in, double r)
static int _tpia_product_getMultiplicityFromElement(statusMessageReporting *smr, xData_element *data, tpia_product *product)
static const int tpia_b_NBody_Legendre
xData_elementList * xData_getElementsByTagName(statusMessageReporting *smr, xData_element *element, const char *tagName)
const char * tpia_productGenre_NBody_uncorrelate_Legendre
static const int tpia_b_twoBody_angular
int xData_releaseAttributionList(statusMessageReporting *smr, xData_attributionList *attributes)
int tpia_angularEnergy_getFromElement(statusMessageReporting *smr, xData_element *angularEnergyElement, tpia_angularEnergy *angularEnergy)
void * xData_free(statusMessageReporting *, void *p)
char const * gString_string(statusMessageReporting *, gString *gStr)
int tpia_product_release(statusMessageReporting *smr, tpia_product *product)
int xData_copyAttributionList(statusMessageReporting *smr, xData_attributionList *dest, xData_attributionList *src)
static const int tpia_b_unknown
tpia_product * tpia_product_getFirstProduct(tpia_product *product)
int gString_initialize(statusMessageReporting *smr, gString *gStr, int size, int increment)
int tpia_product_isDataPresent(statusMessageReporting *, tpia_product *product, int b_data)
int tpia_Legendre_release(statusMessageReporting *smr, tpia_Legendre *Legendre)
int tpia_product_initialize(statusMessageReporting *smr, tpia_product *product)
tpia_product * tpia_decayChannel_getFirstProduct(tpia_decayChannel *decayChannel)
tpia_product * tpia_product_getProductByIndex(statusMessageReporting *, tpia_product *product, int index)
tpia_particle * tpia_particle_getInternalID(statusMessageReporting *smr, const char *const name)
const char * tpia_productGenre_NBody_pairProduction
static int _tpia_product_getDepositionEnergy(statusMessageReporting *smr, xData_element *depositionEnergy, tpia_product *product)
void xData_freeElementList(statusMessageReporting *smr, xData_elementList *list)