9 #include "MCGIDI_misc.h"
10 #include "MCGIDI_fromTOM.h"
12 #if defined __cplusplus
26 ptwXYPoints **multiplicityVsEnergy, ptwXYPoints **norms );
33 MCGIDI_product *product;
35 if( ( product = (MCGIDI_product *) smr_malloc2( smr,
sizeof( MCGIDI_product ), 0,
"product" ) ) == NULL )
return( NULL );
44 memset( product, 0,
sizeof( MCGIDI_product ) );
45 product->delayedNeutronIndex = -1;
64 if( product->label != NULL )
smr_freeMemory( (
void **) &(product->label) );
66 if( product->multiplicityVsEnergy != NULL )
ptwXY_free( product->multiplicityVsEnergy );
67 if( product->piecewiseMultiplicities != NULL ) {
68 for( i = 0; i < product->numberOfPiecewiseMultiplicities; i++ )
ptwXY_free( product->piecewiseMultiplicities[i] );
71 if( product->norms != NULL )
ptwXY_free( product->norms );
83 MCGIDI_POPs *pops, MCGIDI_product *product,
int *delayedNeutronIndex ) {
85 char const *
name, *label, *delayedNeutron, *multiplicityStr, *multiplicityUnits[2] = {
"MeV",
"" };
86 xDataTOM_element *multiplicity, *multiplicityTOM, *decayChannelElement;
88 ptwXYPoints *multiplicityVsEnergy = NULL, *norms1 = NULL, *norms2 = NULL;
92 product->outputChannel = outputChannel;
95 smr_setReportError2( smr, smr_unknownID, 1,
"product '%s' not found in pops", name );
99 if( ( product->label = smr_allocateCopyString2( smr, label,
"product->label" ) ) == NULL )
goto err;
103 if( strcmp( delayedNeutron,
"delayed" ) == 0 ) {
108 product->delayedNeutronIndex = *delayedNeutronIndex;
109 (*delayedNeutronIndex)++;
115 if( strcmp( multiplicityStr,
"energyDependent" ) ) {
116 smr_setReportError2( smr, smr_unknownID, 1,
"invalid multiplicity '%s' for product '%s'", multiplicityStr, name );
133 if( strcmp( product->pop->name,
"gamma" ) == 0 ) {
134 if( ( norms2 =
ptwXY_new( ptwXY_interpolationLinLin, NULL, 2., 1e-3, 200, 10, &status, 0 ) ) == NULL ) {
135 smr_setReportError2( smr, smr_unknownID, 1,
"ptwXY_new err = %d: %s\n", status,
nfu_statusMessage( status ) );
140 if( norms2 != NULL ) {
148 if( ( norms1 != NULL ) && ( norms2 != NULL ) ) {
149 smr_setReportError2p( smr, smr_unknownID, 1,
"norm1 and norm2 are both not NULL" );
153 product->multiplicityVsEnergy = multiplicityVsEnergy;
154 product->norms = norms1;
155 if( norms2 != NULL ) product->norms = norms2;
164 if( multiplicityVsEnergy != NULL )
ptwXY_free( multiplicityVsEnergy );
177 xDataTOM_regionsXYs *regionsXYs = (xDataTOM_regionsXYs *) element->xDataInfo.data;
178 ptwXYPoints *multiplicityVsEnergy;
179 char const *multiplicityUnits[2] = {
"MeV",
"" };
181 if( ( product->piecewiseMultiplicities = (ptwXYPoints **) smr_malloc2( smr, regionsXYs->length *
sizeof( ptwXYPoints * ), 1,
"piecewiseMultiplicities" ) ) == NULL )
return( 1 );
183 for( i = 0; i < regionsXYs->length; i++ ) {
185 XYs = &(regionsXYs->XYs[i]);
187 ) == NULL )
return( 1 );
188 product->piecewiseMultiplicities[i] = multiplicityVsEnergy;
189 product->numberOfPiecewiseMultiplicities++;
200 double *coefficients;
201 char const *energyUnit;
202 ptwXYPoints *ptwXY = NULL;
210 if( ( ptwXY =
ptwXY_new( ptwXY_interpolationLinLin, NULL, 2., 1e-3, length, 10, &status, 0 ) ) == NULL ) {
211 smr_setReportError2( smr, smr_unknownID, 1,
"ptwXY_new err = %d: %s\n", status,
nfu_statusMessage( status ) );
224 int i,
n = 4 * length;
225 double E = EMin,
dE = ( EMax - EMin ) / n;
227 for( i = 1; i <
n; i++ ) {
255 ptwXYPoints **multiplicityVsEnergy, ptwXYPoints **norms ) {
257 char const *link, *energyInMWUnits[2] = {
"MeV",
"" };
258 xDataTOM_element *reference, *productTOM, *multiplicity, *weights, *pointwise;
275 if( *multiplicityVsEnergy != NULL ) *multiplicityVsEnergy =
ptwXY_free( *multiplicityVsEnergy );
276 if( *norms != NULL ) *norms =
ptwXY_free( *norms );
290 double productMass_MeV,
double residualMass_MeV ) {
292 return(
MCGIDI_angular_setTwoBodyMasses( smr, product->distribution.angular, projectileMass_MeV, targetMass_MeV, productMass_MeV, residualMass_MeV ) );
328 double y, norm = 1.0;
329 ptwXYPoints *ptwXY = product->multiplicityVsEnergy;
331 if( product->piecewiseMultiplicities != NULL ) {
332 for( i = 0; i < product->numberOfPiecewiseMultiplicities - 1; i++ ) {
333 if( e_in <
ptwXY_getXMax( product->piecewiseMultiplicities[i] ) )
break;
335 ptwXY = product->piecewiseMultiplicities[i];
340 multiplicity = (int) y;
341 if( r < ( y - multiplicity ) ) multiplicity++;
343 return( multiplicity );
349 MCGIDI_decaySamplingInfo *decaySamplingInfo ) {
351 if( product->distribution.type != MCGIDI_distributionType_angular_e ) {
352 smr_setReportError2( smr, smr_unknownID, 1,
"product distribution is not angular: type = %d", product->distribution.type );
364 if( incrementSize < 10 ) incrementSize = 10;
365 sampledProductsDatas->numberOfProducts = 0;
366 sampledProductsDatas->numberAllocated = 0;
367 sampledProductsDatas->incrementSize = incrementSize;
368 sampledProductsDatas->products = NULL;
384 int size = sampledProductsDatas->numberAllocated + sampledProductsDatas->incrementSize;
386 if( ( sampledProductsDatas->products = (MCGIDI_sampledProductsData *) smr_realloc2( smr, sampledProductsDatas->products,
387 size *
sizeof( MCGIDI_sampledProductsData ),
"products" ) ) != NULL ) {
388 sampledProductsDatas->numberAllocated = size;
391 sampledProductsDatas->numberOfProducts = 0;
392 sampledProductsDatas->numberAllocated = 0;
400 if( sampledProductsDatas->numberOfProducts == sampledProductsDatas->numberAllocated ) {
403 sampledProductsDatas->products[sampledProductsDatas->numberOfProducts] = *sampledProductsData;
404 sampledProductsDatas->numberOfProducts++;
412 return( sampledProductsDatas->numberOfProducts );
419 if( index < 0 )
return( NULL );
420 if( index >= sampledProductsDatas->numberOfProducts )
return( NULL );
421 return( &(sampledProductsDatas->products[index]) );
424 #if defined __cplusplus
xDataTOM_element * xDataTOME_getOneElementByName(statusMessageReporting *smr, xDataTOM_element *element, char const *name, int required)
int MCGIDI_product_parseFromTOM(statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_outputChannel *outputChannel, MCGIDI_POPs *pops, MCGIDI_product *product, int *delayedNeutronIndex)
int MCGIDI_angular_sampleMu(statusMessageReporting *smr, MCGIDI_angular *angular, MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo)
int MCGIDI_outputChannel_release(statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel)
int64_t ptwXY_length(ptwXYPoints *ptwXY)
int MCGIDI_product_sampleMultiplicity(statusMessageReporting *, MCGIDI_product *product, double e_in, double r)
int MCGIDI_sampledProducts_initialize(statusMessageReporting *smr, MCGIDI_sampledProductsDatas *sampledProductsDatas, int incrementSize)
int MCGIDI_sampledProducts_number(MCGIDI_sampledProductsDatas *sampledProductsDatas)
nfu_status ptwXY_simpleCoalescePoints(ptwXYPoints *ptwXY)
ptwXYPoints * ptwXY_free(ptwXYPoints *ptwXY)
MCGIDI_product * MCGIDI_product_new(statusMessageReporting *smr)
int MCGIDI_distribution_release(statusMessageReporting *smr, MCGIDI_distribution *distribution)
double MCGIDI_product_getTargetMass_MeV(statusMessageReporting *smr, MCGIDI_product *product)
const char * name(G4int ptype)
nfu_status ptwXY_setValueAtX(ptwXYPoints *ptwXY, double x, double y)
ptwXYPoints * MCGIDI_misc_dataFromXYs2ptwXYPointsInUnitsOf(statusMessageReporting *smr, xDataTOM_XYs *XYs, ptwXY_interpolation interpolation, char const *toUnits[2])
double ptwXY_getXMax(ptwXYPoints *ptwXY)
double MCGIDI_product_getMass_MeV(statusMessageReporting *, MCGIDI_product *product)
double MCGIDI_outputChannel_getTargetMass_MeV(statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel)
int xDataTOME_convertAttributeToInteger(statusMessageReporting *smr, xDataTOM_element *element, char const *name, int *n)
MCGIDI_product * MCGIDI_product_free(statusMessageReporting *smr, MCGIDI_product *product)
MCGIDI_POP * MCGIDI_POPs_findParticle(MCGIDI_POPs *pops, char const *name)
int MCGIDI_product_release(statusMessageReporting *smr, MCGIDI_product *product)
int smr_isOk(statusMessageReporting *smr)
int MCGIDI_outputChannel_parseFromTOM(statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_POPs *pops, MCGIDI_outputChannel *outputChannel, MCGIDI_reaction *reaction, MCGIDI_product *parent)
void * smr_freeMemory(void **p)
double MCGIDI_misc_getUnitConversionFactor(statusMessageReporting *smr, char const *fromUnit, char const *toUnit)
MCGIDI_target_heated * MCGIDI_outputChannel_getTargetHeated(statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel)
char const * xDataTOM_axes_getUnit(statusMessageReporting *smr, xDataTOM_axes *axes, int index)
double ptwXY_getYMax(ptwXYPoints *ptwXY)
static ptwXYPoints * MCGIDI_product_parsePolynomialMultiplicity(statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_product *product)
double MCGIDI_POP_getMass_MeV(MCGIDI_POP *pop)
int MCGIDI_product_sampleMu(statusMessageReporting *smr, MCGIDI_product *product, MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo)
int MCGIDI_sampledProducts_addProduct(statusMessageReporting *smr, MCGIDI_sampledProductsDatas *sampledProductsDatas, MCGIDI_sampledProductsData *sampledProductsData)
static double MCGIDI_product_evaluatePolynomial(double x, polynomialCallbackArgs *args)
double MCGIDI_product_getProjectileMass_MeV(statusMessageReporting *smr, MCGIDI_product *product)
int MCGIDI_angular_setTwoBodyMasses(statusMessageReporting *, MCGIDI_angular *angular, double projectileMass_MeV, double targetMass_MeV, double productMass_MeV, double residualMass_MeV)
int MCGIDI_misc_PQUStringToDoubleInUnitOf(statusMessageReporting *smr, char const *str, char const *toUnit, double *value)
MCGIDI_target_heated * MCGIDI_product_getTargetHeated(statusMessageReporting *smr, MCGIDI_product *product)
double ptwXY_getYMin(ptwXYPoints *ptwXY)
char const * xDataTOM_getAttributesValueInElement(xDataTOM_element *element, char const *name)
static int MCGIDI_product_parsePiecewiseMultiplicity(statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_product *product)
int MCGIDI_product_initialize(statusMessageReporting *, MCGIDI_product *product)
int MCGIDI_distribution_parseFromTOM(statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_product *product, MCGIDI_POPs *, ptwXYPoints *norms)
static int MCGIDI_product_parseWeightedReferenceMultiplicityFromTOM(statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_product *product, ptwXYPoints **multiplicityVsEnergy, ptwXYPoints **norms)
const char * nfu_statusMessage(nfu_status status)
double MCGIDI_sampling_ptwXY_getValueAtX(ptwXYPoints *ptwXY, double x1)
MCGIDI_sampledProductsData * MCGIDI_sampledProducts_getProductAtIndex(MCGIDI_sampledProductsDatas *sampledProductsDatas, int index)
ptwXYPoints * MCGIDI_misc_dataFromElement2ptwXYPointsInUnitsOf(statusMessageReporting *smr, xDataTOM_element *linear, char const *toUnits[2])
xDataTOM_element * xDataTOM_getLinksElement(statusMessageReporting *smr, xDataTOM_element *element, char const *link)
int xDataTOM_polynomial_getDataFromXDataInfo(xDataTOM_xDataInfo *xDI, double **data)
int MCGIDI_sampledProducts_remalloc(statusMessageReporting *smr, MCGIDI_sampledProductsDatas *sampledProductsDatas)
struct polynomialCallbackArgs_s polynomialCallbackArgs
int MCGIDI_outputChannel_getDomain(statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel, double *EMin, double *EMax)
ptwXYPoints * ptwXY_new(ptwXY_interpolation interpolation, ptwXY_interpolationOtherInfo const *interpolationOtherInfo, double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize, nfu_status *status, int userFlag)
int MCGIDI_product_getDomain(statusMessageReporting *smr, MCGIDI_product *product, double *EMin, double *EMax)
int MCGIDI_product_setTwoBodyMasses(statusMessageReporting *smr, MCGIDI_product *product, double projectileMass_MeV, double targetMass_MeV, double productMass_MeV, double residualMass_MeV)
double MCGIDI_outputChannel_getProjectileMass_MeV(statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel)
int MCGIDI_sampledProducts_release(statusMessageReporting *, MCGIDI_sampledProductsDatas *sampledProductsDatas)