#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_product * | tpia_product_create (statusMessageReporting *smr) |
int | tpia_product_initialize (statusMessageReporting *smr, tpia_product *product) |
tpia_product * | tpia_product_createGetFromElement (statusMessageReporting *smr, tpia_channel *channel, tpia_product *parentProduct, xData_element *productElement) |
tpia_product * | tpia_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_product * | tpia_product_getFirstProduct (tpia_product *product) |
tpia_product * | tpia_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" |
tpia_product* tpia_product_create | ( | statusMessageReporting * | smr | ) |
Definition at line 71 of file tpia_product.cc.
References tpia_product_free(), and tpia_product_initialize().
Referenced by tpia_product_createGetFromElement().
00071 { 00072 00073 tpia_product *product; 00074 00075 //if( ( product = xData_malloc2( smr, sizeof( tpia_product ), 0, "product" ) ) == NULL ) return( NULL ); 00076 if( ( product = (tpia_product*) xData_malloc2( smr, sizeof( tpia_product ), 0, "product" ) ) == NULL ) return( NULL ); 00077 if( tpia_product_initialize( smr, product ) ) product = tpia_product_free( smr, product ); 00078 return( product ); 00079 }
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.
References tpia_product_create(), tpia_product_free(), and tpia_product_getFromElement().
Referenced by tpia_product_getDecayChannelFromElement().
00094 { 00095 00096 tpia_product *product; 00097 00098 if( ( product = tpia_product_create( smr ) ) == NULL ) return( NULL ); 00099 if( tpia_product_getFromElement( smr, channel, parentProduct, productElement, product ) != 0 ) product = tpia_product_free( smr, product ); 00100 return( product ); 00101 }
long tpia_product_dataRequired | ( | statusMessageReporting * | , | |
tpia_product * | product | |||
) |
int tpia_product_doesDecay | ( | statusMessageReporting * | , | |
tpia_product * | product | |||
) |
tpia_product* tpia_product_free | ( | statusMessageReporting * | smr, | |
tpia_product * | product | |||
) |
Definition at line 105 of file tpia_product.cc.
References tpia_product_release(), and xData_free().
Referenced by tpia_channel_release(), tpia_product_create(), tpia_product_createGetFromElement(), and tpia_product_release().
00105 { 00106 00107 tpia_product_release( smr, product ); 00108 xData_free( smr, product ); 00109 return( NULL ); 00110 }
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.
References tpia_product_createGetFromElement(), and xData_getElementsByTagName().
00269 { 00270 00271 xData_elementList *list; 00272 tpia_product *product; 00273 int i, status = 0; 00274 00275 list = xData_getElementsByTagName( smr, parentElement, "product" ); 00276 for( i = 0; i < list->n; i++ ) { 00277 if( ( product = tpia_product_createGetFromElement( smr, channel, parentProduct, list->items[i].element ) ) == NULL ) { 00278 status = 1; 00279 break; 00280 } 00281 if( parentProduct == NULL ) { 00282 channel->decayChannel.m1_fullMass_MeV = channel->target->projectileID->fullMass_MeV; 00283 channel->decayChannel.m2_fullMass_MeV = channel->target->targetID->fullMass_MeV; 00284 channel->decayChannel.numberOfProducts++; } 00285 else { 00286 channel->decayChannel.m1_fullMass_MeV = parentProduct->productID->fullMass_MeV; 00287 channel->decayChannel.m2_fullMass_MeV = 0.; 00288 parentProduct->decayChannel.numberOfProducts++; 00289 } 00290 *priorProductNext = product; 00291 priorProductNext = &(product->next); 00292 } 00293 xData_freeElementList( smr, list ); 00294 return( status ); 00295 }
tpia_product* tpia_product_getFirstProduct | ( | tpia_product * | product | ) |
Definition at line 366 of file tpia_product.cc.
References tpia_decayChannel_getFirstProduct().
Referenced by tpia_product_getProductByIndex().
00366 { 00367 00368 return( tpia_decayChannel_getFirstProduct( &(product->decayChannel) ) ); 00369 }
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.
References smr_isOk(), tpia_misc_setMessageError_Element(), tpia_particle_getInternalID(), tpia_productGenre_NBody_angular_energy, tpia_productGenre_NBody_Legendre, tpia_productGenre_NBody_pairProduction, tpia_productGenre_NBody_uncorrelate_Legendre, tpia_productGenre_twoBody_angular, tpia_productGenre_twoBody_formFactor, tpia_productGenre_unknown, xData_addToAccessed(), and xData_copyAttributionList().
Referenced by tpia_product_createGetFromElement().
00143 { 00144 00145 char const *productGenre; 00146 char *name, *multiplicity, *e; 00147 00148 xData_addToAccessed( smr, productElement, 1 ); 00149 product->channel = channel; 00150 product->parentProduct = parentProduct; 00151 if( xData_copyAttributionList( smr, &(product->attributes), &(productElement->attributes) ) != 0 ) return( 0 ); 00152 name = tpia_misc_pointerToAttributeIfAllOk2( smr, productElement, 1, &(product->attributes), "particle" ); 00153 if( name != NULL ) { 00154 product->productID = tpia_particle_getInternalID( smr, name ); 00155 multiplicity = tpia_misc_pointerToAttributeIfAllOk2( smr, productElement, 1, &(product->attributes), "multiplicity" ); 00156 if( multiplicity != NULL ) { 00157 if( strcmp( multiplicity, "energyDependent" ) && strcmp( multiplicity, "partialProduction" ) ) { /* Must be an integer. */ 00158 product->multiplicity = strtol( multiplicity, &e, 10 ); 00159 while( isspace( *e ) ) e++; 00160 if( *e != 0 ) tpia_misc_setMessageError_Element( smr, NULL, productElement, __FILE__, __LINE__, 1, "bad multiplicity = %s", multiplicity ); 00161 } 00162 } 00163 } 00164 if( ( productGenre = tpia_misc_pointerToAttributeIfAllOk2( smr, productElement, 1, &(product->attributes), "genre" ) ) != NULL ) { 00165 if( strcmp( productGenre, tpia_productGenre_unknown ) == 0 ) { 00166 product->b_dataRequired = 0; 00167 product->genre = tpia_productGenre_unknown; } 00168 else if( strcmp( productGenre, tpia_productGenre_twoBody_angular ) == 0 ) { 00169 product->b_dataRequired = tpia_b_twoBody_angular; 00170 product->genre = tpia_productGenre_twoBody_angular; } 00171 else if( strcmp( productGenre, tpia_productGenre_twoBody_formFactor ) == 0 ) { 00172 product->b_dataRequired = tpia_b_twoBody_formFactor; 00173 product->genre = tpia_productGenre_twoBody_formFactor; } 00174 else if( strcmp( productGenre, tpia_productGenre_NBody_Legendre ) == 0 ) { 00175 product->b_dataRequired = tpia_b_NBody_Legendre; 00176 product->genre = tpia_productGenre_NBody_Legendre; } 00177 else if( strcmp( productGenre, tpia_productGenre_NBody_angular_energy ) == 0 ) { 00178 product->b_dataRequired = tpia_b_NBody_angular_energy; 00179 product->genre = tpia_productGenre_NBody_angular_energy; } 00180 else if( strcmp( productGenre, tpia_productGenre_NBody_uncorrelate_Legendre ) == 0 ) { 00181 product->b_dataRequired = tpia_b_NBody_uncorrelate_Legendre; 00182 product->genre = tpia_productGenre_NBody_uncorrelate_Legendre; } 00183 else if( strcmp( productGenre, tpia_productGenre_NBody_pairProduction ) == 0 ) { 00184 product->b_dataRequired = tpia_b_NBody_pairProduction; 00185 product->genre = tpia_productGenre_NBody_pairProduction; } 00186 else { 00187 tpia_misc_setMessageError_Element( smr, NULL, productElement, __FILE__, __LINE__, 1, "unsupported product genre = %s", productGenre ); 00188 } 00189 if( smr_isOk( smr ) ) _tpia_product_getProductOutgoingData( smr, productElement, product ); 00190 } 00191 return( !smr_isOk( smr ) ); 00192 }
tpia_product* tpia_product_getProductByIndex | ( | statusMessageReporting * | , | |
tpia_product * | product, | |||
int | index | |||
) |
Definition at line 374 of file tpia_product.cc.
References tpia_decayChannel_getNextProduct(), and tpia_product_getFirstProduct().
00374 { 00375 00376 int i = 0; 00377 tpia_product *p; 00378 00379 if( index < 0 ) return( NULL ); 00380 for( p = tpia_product_getFirstProduct( product ); ( p != NULL ) && ( i < index ); p = tpia_decayChannel_getNextProduct( p ), i++ ) ; 00381 return( p ); 00382 }
int tpia_product_initialize | ( | statusMessageReporting * | smr, | |
tpia_product * | product | |||
) |
Definition at line 83 of file tpia_product.cc.
References tpia_angular_initialize(), and tpia_Legendre_initialize().
Referenced by tpia_product_create().
00083 { 00084 00085 memset( product, 0, sizeof( tpia_product ) ); 00086 if( tpia_angular_initialize( smr, &(product->angular) ) ) return( 1 ); 00087 if( tpia_Legendre_initialize( smr, &(product->Legendre) ) ) return( 1 ); 00088 return( 0 ); 00089 }
int tpia_product_isDataPresent | ( | statusMessageReporting * | , | |
tpia_product * | product, | |||
int | b_data | |||
) |
int tpia_product_numberOfProducts | ( | statusMessageReporting * | , | |
tpia_product * | product | |||
) |
int tpia_product_release | ( | statusMessageReporting * | smr, | |
tpia_product * | product | |||
) |
Definition at line 114 of file tpia_product.cc.
References tpia_angular_release(), tpia_angularEnergy_release(), tpia_Legendre_release(), tpia_multiplicity_free(), tpia_product_free(), xData_free(), and xData_releaseAttributionList().
Referenced by tpia_product_free().
00114 { 00115 00116 tpia_multiplicity *multiplicity, *multiplicity_next; 00117 tpia_product *decayProduct, *nextProduct; 00118 00119 xData_releaseAttributionList( smr, &(product->attributes) ); 00120 //product->depositionEnergyGrouped.data = xData_free( smr, product->depositionEnergyGrouped.data ); 00121 product->depositionEnergyGrouped.data = (double*) xData_free( smr, product->depositionEnergyGrouped.data ); 00122 00123 if( product->multiplicityVsEnergy != NULL ) tpia_multiplicity_free( smr, product->multiplicityVsEnergy ); 00124 for( multiplicity = product->delayedNeutronMultiplicityVsEnergy; multiplicity != NULL; multiplicity = multiplicity_next ) { 00125 multiplicity_next = multiplicity->next; 00126 tpia_multiplicity_free( smr, multiplicity ); 00127 } 00128 tpia_angular_release( smr, &(product->angular) ); 00129 tpia_Legendre_release( smr, &(product->Legendre ) ); 00130 tpia_angularEnergy_release( smr, &(product->angularEnergy) ); 00131 for( decayProduct = product->decayChannel.products; decayProduct != NULL; decayProduct = nextProduct ) { 00132 nextProduct = decayProduct->next; 00133 tpia_product_free( smr, decayProduct ); 00134 } 00135 product->decayChannel.numberOfProducts = 0; 00136 product->decayChannel.products = NULL; 00137 return( 0 ); 00138 }
int tpia_product_sampleMultiplicity | ( | statusMessageReporting * | , | |
tpia_product * | product, | |||
double | e_in, | |||
double | r | |||
) |
Definition at line 411 of file tpia_product.cc.
Referenced by tpia_decayChannel_sampleProductsAtE().
00411 { 00412 00413 int i, multiplicity; 00414 tpia_multiplicity *multiplicityVsEnergy = product->multiplicityVsEnergy; 00415 double *p = multiplicityVsEnergy->pointwise, dMult; 00416 00417 if( e_in <= p[0] ) { 00418 dMult = p[1]; } 00419 else if( e_in >= p[2 * ( multiplicityVsEnergy->numberOfPointwise - 1 )] ) { 00420 dMult = p[2 * multiplicityVsEnergy->numberOfPointwise - 1]; } 00421 else { 00422 for( i = 0; i < multiplicityVsEnergy->numberOfPointwise - 1; i++, p += 2 ) if( e_in < p[2] ) break; 00423 dMult = ( e_in - p[0] ) / ( p[2] - p[0] ); 00424 dMult = dMult * p[3] + ( 1. - dMult ) * p[1]; 00425 } 00426 multiplicity = (int) dMult; 00427 if( r < ( dMult - multiplicity ) ) multiplicity++; 00428 00429 return( multiplicity ); 00430 }
const char * tpia_productGenre_NBody_angular_energy = "NBody_angular_energy" |
const char * tpia_productGenre_NBody_Legendre = "NBody_Legendre" |
const char * tpia_productGenre_NBody_pairProduction = "NBody_pairProduction" |
const char * tpia_productGenre_NBody_uncorrelate_Legendre = "NBody_uncorrelate_Legendre" |
const char * tpia_productGenre_twoBody_angular = "twoBody_angular" |
const char * tpia_productGenre_twoBody_formFactor = "twoBody_formFactor" |
const char* tpia_productGenre_unknown = "unknown" |