40 #include <tpia_target.h> 
   41 #include <tpia_misc.h> 
   43 #if defined __cplusplus 
   66 static int _tpia_product_checkRequiredData( statusMessageReporting *smr, 
int allowMany, 
int m, xData_element *productElement, tpia_product *product, 
char *str );
 
   74     tpia_product *product;
 
   77     if( ( product = (tpia_product*) xData_malloc2( smr, 
sizeof( tpia_product ), 0, 
"product" ) ) == NULL ) 
return( NULL );
 
   86     memset( product, 0, 
sizeof( tpia_product ) );
 
   95     xData_element *productElement ) {
 
   97     tpia_product *product;
 
  117     tpia_multiplicity *multiplicity, *multiplicity_next;
 
  118     tpia_product *decayProduct, *nextProduct;
 
  122     product->depositionEnergyGrouped.data = (
double*) 
xData_free( smr, product->depositionEnergyGrouped.data );
 
  125     for( multiplicity = product->delayedNeutronMultiplicityVsEnergy; multiplicity != NULL; multiplicity = multiplicity_next ) {
 
  126         multiplicity_next = multiplicity->next;
 
  132     for( decayProduct = product->decayChannel.products; decayProduct != NULL; decayProduct = nextProduct ) {
 
  133         nextProduct = decayProduct->next;
 
  136     product->decayChannel.numberOfProducts = 0;
 
  137     product->decayChannel.products = NULL;
 
  144     tpia_product *product ) {
 
  146     char const *productGenre;
 
  147     char *
name, *multiplicity, *e;
 
  150     product->channel = channel;
 
  151     product->parentProduct = parentProduct;
 
  153     name = tpia_misc_pointerToAttributeIfAllOk2( smr, productElement, 1, &(product->attributes), 
"particle" );
 
  156         multiplicity = tpia_misc_pointerToAttributeIfAllOk2( smr, productElement, 1, &(product->attributes), 
"multiplicity" );
 
  157         if( multiplicity != NULL ) {
 
  158             if( strcmp( multiplicity, 
"energyDependent" ) && strcmp( multiplicity, 
"partialProduction" ) ) {    
 
  159                 product->multiplicity = strtol( multiplicity, &e, 10 );
 
  160                 while( isspace( *e ) ) e++;
 
  165     if( ( productGenre = tpia_misc_pointerToAttributeIfAllOk2( smr, productElement, 1, &(product->attributes), 
"genre" ) ) != NULL ) {
 
  166         if( strcmp( productGenre, tpia_productGenre_unknown ) == 0 ) {
 
  167             product->b_dataRequired = 0;
 
  203         if( strcmp( data->name, 
"depositionEnergy" ) == 0 ) {
 
  207         else if( strcmp( data->name, 
"multiplicity" ) == 0 ) {
 
  208             allowMany = ( product->channel->fission != NULL ) && ( strcmp( product->productID->name, 
"n_1" ) == 0 );
 
  212         else if( strcmp( data->name, 
"angular" ) == 0 ) {
 
  216         else if( strcmp( data->name, 
"Legendre" ) == 0 ) {
 
  220         else if( strcmp( data->name, 
"angularEnergy" ) == 0 ) {
 
  223         else if( strcmp( data->name, 
"decayChannel" ) == 0 ) {
 
  227             printf( 
"   %s\n", data->name );
 
  230     if( ( product->b_dataPresent >> tpia_m_commonShift ) != ( product->b_dataRequired >> tpia_m_commonShift ) ) {
 
  232         int missing = ~product->b_dataPresent & product->b_dataRequired;
 
  233         char const *str = 
"";
 
  235             if( missing & tpia_m_angular ) 
gString_addTo( NULL, &gStr, 
"angular " );
 
  236             if( missing & tpia_m_formFactor ) 
gString_addTo( NULL, &gStr, 
"formFactor " );
 
  237             if( missing & tpia_m_Legendre ) 
gString_addTo( NULL, &gStr, 
"Legendre " );
 
  238             if( missing & tpia_m_angular_energy ) 
gString_addTo( NULL, &gStr, 
"angular_energy " );
 
  242             product->productID->name );
 
  253     if( !allowMany && ( product->b_dataPresent & m ) ) {
 
  257     if( ( m & ( tpia_m_depositionEnergy | tpia_m_multiplicity | tpia_m_decayChannel ) ) == 0 ) {
 
  258         if( ( product->b_dataRequired & m ) == 0 ) {
 
  263     product->b_dataPresent += 
m;
 
  270     tpia_product **priorProductNext ) {
 
  272     xData_elementList *list;
 
  273     tpia_product *product;
 
  277     for( i = 0; i < list->n; i++ ) {
 
  282         if( parentProduct == NULL ) {
 
  283             channel->decayChannel.m1_fullMass_MeV = channel->target->projectileID->fullMass_MeV;
 
  284             channel->decayChannel.m2_fullMass_MeV = channel->target->targetID->fullMass_MeV;
 
  285             channel->decayChannel.numberOfProducts++; }
 
  287             channel->decayChannel.m1_fullMass_MeV = parentProduct->productID->fullMass_MeV;
 
  288             channel->decayChannel.m2_fullMass_MeV = 0.;
 
  289             parentProduct->decayChannel.numberOfProducts++;
 
  291         *priorProductNext = product;
 
  292         priorProductNext = &(product->next);
 
  306         if( strcmp( data->name, 
"grouped" ) == 0 ) {
 
  320     tpia_multiplicity *multiplicity, *prior, *current;
 
  321     const char *timeScale;
 
  322     int isDelayedNeutrons;
 
  326     if( ( isDelayedNeutrons == 0 ) && ( product->multiplicityVsEnergy != NULL ) ) {
 
  331     if( isDelayedNeutrons == 0 ) {
 
  332         product->multiplicityVsEnergy = multiplicity; }
 
  334         if( product->delayedNeutronMultiplicityVsEnergy == NULL ) {
 
  335             product->delayedNeutronMultiplicityVsEnergy = multiplicity; }
 
  337             if( product->delayedNeutronMultiplicityVsEnergy->timeScale > multiplicity->timeScale ) {
 
  338                 multiplicity->next = product->delayedNeutronMultiplicityVsEnergy;
 
  339                 product->delayedNeutronMultiplicityVsEnergy = multiplicity; }
 
  341                 for( current = product->delayedNeutronMultiplicityVsEnergy->next, prior = product->delayedNeutronMultiplicityVsEnergy; current != NULL; 
 
  342                     current = current->next ) {
 
  343                     if( current->timeScale > multiplicity->timeScale ) {
 
  344                         multiplicity->next = current;
 
  345                         prior->next = multiplicity;
 
  350                 if( current == NULL ) prior->next = multiplicity;
 
  362     return( product->b_dataRequired );
 
  380     if( index < 0 ) 
return( NULL );
 
  390     return( product->decayChannel.products != NULL );
 
  398     return( product->decayChannel.numberOfProducts );
 
  406     return( product->b_dataPresent && b_data );
 
  415     tpia_multiplicity *multiplicityVsEnergy = product->multiplicityVsEnergy;
 
  416     double *p = multiplicityVsEnergy->pointwise, dMult;
 
  420     else if( e_in >= p[2 * ( multiplicityVsEnergy->numberOfPointwise - 1 )] ) {
 
  421         dMult = p[2 * multiplicityVsEnergy->numberOfPointwise - 1]; }
 
  423         for( i = 0; i < multiplicityVsEnergy->numberOfPointwise - 1; i++, p += 2 ) 
if( e_in < p[2] ) 
break;
 
  424         dMult = ( e_in - p[0] ) / ( p[2] - p[0] );
 
  425         dMult = dMult * p[3] + ( 1. - dMult ) * p[1];
 
  427     multiplicity = (int) dMult;
 
  428     if( r < ( dMult - multiplicity ) ) multiplicity++;
 
  430     return( multiplicity );
 
  433 #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)
 
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)