12 #include "MCGIDI_misc.h"
13 #include "MCGIDI_private.h"
15 #if defined __cplusplus
21 xDataTOM_element *particleAliases );
23 xDataTOM_element *particleAliases );
25 double mass_MeV, xDataTOM_element *particleAliases );
28 MCGIDI_POPs *pops, MCGIDI_reaction *reaction );
34 MCGIDI_target_heated *target;
36 if( ( target = (MCGIDI_target_heated *) smr_malloc2( smr,
sizeof( MCGIDI_target_heated ), 0,
"target" ) ) == NULL )
return( NULL );
45 memset( target, 0,
sizeof( MCGIDI_target_heated ) );
47 target->transportabilities =
new transportabilitiesMap( );
55 MCGIDI_target_heated *target;
79 ptwX_free( target->crossSectionGroupedForSampling );
86 delete target->transportabilities;
98 xDataTOM_TOM *doc = NULL;
99 xDataTOM_element *element, *child, *particles, *particleAliases;
100 char const *
name, *version, *temperatureStr;
102 MCGIDI_reaction *reaction;
103 double crossSectionInit[4] = { 0., 0., 0., 0., };
105 ptwXYPoints *crossSection;
106 int subtag1_Notice = 0;
108 if( ( target->path = smr_allocateCopyString2( smr, fileName,
"path" ) ) == NULL )
goto err;
113 smr_setReportError2( smr, smr_unknownID, 1,
"version attribute missing from element '%s'", element->name );
116 if( strcmp( version,
"GND 1.3" ) != 0 ) {
117 smr_setReportError2( smr, smr_unknownID, 1,
"Unsupported version '%s' for element %s", version, element->name );
121 if( strcmp( element->name,
"reactionSuite" ) != 0 ) {
122 smr_setReportError2( smr, smr_unknownID, 1,
"input file's top element must be reactionSuite and not %s", element->name );
130 if( ( temperatureStr = MCGIDI_misc_pointerToTOMAttributeIfAllOk3( smr, target->absPath, 1, &(target->attributes),
"temperature" ) ) == NULL )
goto err;
131 target->temperature_MeV = strtod( temperatureStr, &e1 );
132 while( isspace( *e1 ) ) ++e1;
136 if( ( name = MCGIDI_misc_pointerToTOMAttributeIfAllOk3( smr, target->absPath, 1, &(target->attributes),
"projectile" ) ) != NULL )
140 if( ( name = MCGIDI_misc_pointerToTOMAttributeIfAllOk3( smr, target->absPath, 1, &(target->attributes),
"target" ) ) != NULL )
146 smr_setReportError2( smr, smr_unknownID, 1,
"target does not have any reactions: file = '%s'", fileName );
149 if( ( target->reactions = (MCGIDI_reaction *) smr_malloc2( smr, n *
sizeof( MCGIDI_reaction ), 1,
"target->reactions" ) ) == NULL )
goto err;
152 if( strcmp( child->name,
"particles" ) == 0 )
continue;
153 if( strcmp( child->name,
"styles" ) == 0 )
continue;
154 if( strcmp( child->name,
"documentations" ) == 0 )
continue;
155 if( strcmp( child->name,
"resonances" ) == 0 )
continue;
156 if( strcmp( child->name,
"summedReaction" ) == 0 )
continue;
157 if( strcmp( child->name,
"fissionComponent" ) == 0 )
continue;
158 if( strcmp( child->name,
"reaction" ) == 0 ) {
161 reaction = &(target->reactions[ir]);
164 if( ir == 0 ) { target->EMin = EMin; target->EMax = EMax; }
165 if( EMin < target->EMin ) target->EMin = EMin;
166 if( EMax > target->EMax ) target->EMax = EMax;
167 for( transportabilitiesMap::const_iterator iter = reaction->transportabilities->begin( );
168 iter != reaction->transportabilities->end( ); ++iter ) {
172 else if( strcmp( child->name,
"production" ) == 0 ) {
174 else if( strcmp( child->name,
"aliases" ) == 0 ) {
176 else if( strcmp( child->name,
"partialGammaProduction" ) == 0 ) {
177 if( subtag1_Notice == 0 ) printf(
"Unsupported reactionSuite sub-tag = '%s'\n", child->name );
180 printf(
"Unsupported reactionSuite sub-tag = '%s'\n", child->name );
183 crossSectionInit[0] = target->EMin;
184 crossSectionInit[2] = target->EMax;
185 if( ( target->crossSection =
ptwXY_create( ptwXY_interpolationLinLin, NULL, 2., 1e-3, 2, 10, 2, crossSectionInit, &status, 0 ) ) == NULL ) {
186 smr_setReportError2( smr, smr_unknownID, 1,
"ptwXY_create err = %d: %s\n", status,
nfu_statusMessage( status ) );
189 for( ir = 0; ir < target->numberOfReactions; ir++ ) {
190 reaction = &(target->reactions[ir]);
192 smr_setReportError2( smr, smr_unknownID, 1,
"ptwXY_add_ptwXY err = %d: %s\n", status,
nfu_statusMessage( status ) );
195 if( ( crossSection =
ptwXY_add_ptwXY( target->crossSection, reaction->crossSection, &status ) ) == NULL ) {
196 smr_setReportError2( smr, smr_unknownID, 1,
"ptwXY_add_ptwXY err = %d: %s\n", status,
nfu_statusMessage( status ) );
199 target->crossSection =
ptwXY_free( target->crossSection );
200 target->crossSection = crossSection;
207 smr_setReportError2( smr, smr_unknownID, 1,
"Sub-error while reading file '%s'", fileName );
216 xDataTOM_element *particleAliases ) {
218 xDataTOM_element *child;
221 if( strcmp( child->name,
"particle" ) ) {
222 smr_setReportError2( smr, smr_unknownID, 1,
"invalid element '%s' in %s", child->name, element->name );
236 xDataTOM_element *particleAliases ) {
263 int globalParticle = 1;
264 char const *
name = NULL, *mass = NULL;
266 xDataTOM_element *child;
270 smr_setReportError2p( smr, smr_unknownID, 1,
"particle missing name attribute" );
274 smr_setReportError2( smr, smr_unknownID, 1,
"particle '%s' missing mass attribute", name );
281 if( strcmp( child->name,
"level" ) ) {
282 smr_setReportError2( smr, smr_unknownID, 1,
"invalid element '%s' in %s", child->name, element->name );
297 double mass_MeV, xDataTOM_element *particleAliases ) {
299 int globalParticle = 0;
300 char const *
name, *level, *aliasValue;
301 double level_MeV = 0.;
302 xDataTOM_element *alias;
305 smr_setReportError2p( smr, smr_unknownID, 1,
"particle missing name attribute" );
309 smr_setReportError2( smr, smr_unknownID, 1,
"particle '%s' level missing energy attribute", name );
316 smr_setReportError2p( smr, smr_unknownID, 1,
"particle missing name attribute" );
319 if( strcmp( aliasValue, name ) == 0 ) globalParticle = 1;
335 xDataTOM_element *child;
336 MCGIDI_GammaBranching *gammas = NULL;
337 char const *finalLevelString;
341 if( strcmp( child->name,
"gamma" ) ) {
342 smr_setReportError2( smr, smr_unknownID, 1,
"invalid element '%s' in %s", child->name, element->name );
347 if( gammaCounts > 0 ) {
348 if( ( gammas = (MCGIDI_GammaBranching *) smr_malloc2( smr, gammaCounts *
sizeof( MCGIDI_GammaBranching), 0,
"gammas" ) ) == NULL )
goto err;
351 smr_setReportError2p( smr, smr_unknownID, 1,
"gamma missing 'finalLevel'" );
355 smr_setReportError2p( smr, smr_unknownID, 1,
"gamma missing 'probability' attribute" );
360 pop->numberOfGammaBranchs = gammaCounts;
361 pop->gammas = gammas;
373 MCGIDI_POPs *pops, MCGIDI_reaction *reaction ) {
376 target->numberOfReactions++;
389 return( target->numberOfReactions );
403 if( ( index >= 0 ) && ( index < target->numberOfReactions ) )
return( &(target->reactions[index]) );
413 if( reaction == NULL ) {
414 smr_setReportError2( smr, smr_unknownID, 1,
"bad reaction index = %d for %s + %s", index, target->projectilePOP->name, target->targetPOP->name );
422 MCGIDI_channel *MCGIDI_target_heated_getProductionReactionAtIndex( MCGIDI_target_heated *target,
int index ) {
424 MCGIDI_channel *channel = NULL;
426 if( ( index >= 0 ) && ( index < target->nProductionReactions ) ) channel = target->productionReactions[index];
435 return( target->projectilePOP );
442 return( target->targetPOP );
462 MCGIDI_quantitiesLookupModes &modes,
bool sampling ) {
466 if( modes.getCrossSectionMode( ) == MCGIDI_quantityLookupMode_pointwise ) {
467 double e_in = modes.getProjectileEnergy( );
469 if( e_in < target->EMin ) e_in = target->EMin;
470 if( e_in > target->EMax ) e_in = target->EMax;
472 else if( modes.getCrossSectionMode( ) == MCGIDI_quantityLookupMode_grouped ) {
473 int index = modes.getGroupIndex( );
482 if( xSecP != NULL ) {
486 smr_setReportError2( smr, smr_unknownID, 1,
"Invalid cross section group index %d", index, (
int)
ptwX_length( target->crossSectionGrouped ) );
497 MCGIDI_quantitiesLookupModes &modes,
bool sampling ) {
509 MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo, MCGIDI_sampledProductsDatas *productDatas ) {
513 productDatas->numberOfProducts = 0;
514 if( reaction == NULL )
return( -1 );
524 if( reaction == NULL )
return( -1 );
525 return( reaction->EMin );
534 if( reaction == NULL )
return( -1 );
535 *EMin = reaction->EMin;
536 *EMax = reaction->EMax;
543 MCGIDI_quantitiesLookupModes &modes ) {
547 if( reaction == NULL )
return( 0. );
555 return( target->transportabilities );
562 int ir, projectilePoPID = target->projectilePOP->globalPoPsIndex;
563 ptwXPoints *totalGroupedCrossSection = NULL;
565 nfu_status status_nf;
567 if( projectileSettings == NULL ) {
568 smr_setReportError2( smr, smr_unknownID, 1,
"Settings missing for projectile %s", target->projectilePOP->name );
571 target->crossSectionGrouped =
ptwX_free( target->crossSectionGrouped );
572 target->crossSectionGroupedForSampling =
ptwX_free( target->crossSectionGroupedForSampling );
576 if( ( totalGroupedCrossSection =
ptwX_createLine( numberOfGroups, numberOfGroups, 0, 0, &status_nf ) ) == NULL ) {
577 smr_setReportError2( smr, smr_unknownID, 1,
"totalGroupedCrossSection allocation failed: status_nf = %d, '%s'",
583 for( ir = 0; ir < target->numberOfReactions; ++ir ) {
584 if(
MCGIDI_reaction_recast( smr, &(target->reactions[ir]), settings, projectileSettings, target->temperature_MeV, totalGroupedCrossSection ) != 0 )
goto err;
587 if( ( target->crossSectionGroupedForSampling =
ptwX_clone( totalGroupedCrossSection, &status_nf ) ) == NULL ) {
588 smr_setReportError2( smr, smr_unknownID, 1,
"totalGroupedCrossSection allocation failed: status_nf = %d, '%s'",
592 for( ir = 0; ir < target->numberOfReactions; ++ir ) {
593 int index = target->reactions[ir].thresholdGroupIndex;
596 double xSec = target->reactions[ir].thresholdGroupedDeltaCrossSection +
603 target->crossSectionGrouped = totalGroupedCrossSection;
604 totalGroupedCrossSection = NULL;
610 target->crossSectionGroupedForSampling =
ptwX_free( target->crossSectionGroupedForSampling );
614 #if defined __cplusplus
static int MCGIDI_target_heated_parseParticleLevel(statusMessageReporting *smr, MCGIDI_target_heated *target, xDataTOM_element *element, MCGIDI_POP *parent, double mass_MeV, xDataTOM_element *particleAliases)
xDataTOM_element * xDataTOME_getOneElementByName(statusMessageReporting *smr, xDataTOM_element *element, char const *name, int required)
int MCGIDI_reaction_fixDomains(statusMessageReporting *, MCGIDI_reaction *reaction, double EMin, double EMax, nfu_status *status)
int getNumberOfGroups(void) const
nfu_status ptwX_setPointAtIndex(ptwXPoints *ptwX, int64_t index, double x)
MCGIDI_POP * MCGIDI_target_heated_getPOPForProjectile(statusMessageReporting *, MCGIDI_target_heated *target)
xDataTOM_element * xDataTOME_getFirstElement(xDataTOM_element *element)
ptwXYPoints * ptwXY_create(ptwXY_interpolation interpolation, ptwXY_interpolationOtherInfo const *interpolationOtherInfo, double biSectionMax, double accuracy, int64_t primarySize, int64_t secondarySize, int64_t length, double const *xy, nfu_status *status, int userFlag)
static int MCGIDI_target_heated_parsePOPs(statusMessageReporting *smr, MCGIDI_target_heated *target, xDataTOM_element *element, xDataTOM_element *particleAliases)
double MCGIDI_target_heated_getIndexReactionCrossSectionAtE(statusMessageReporting *smr, MCGIDI_target_heated *target, int index, MCGIDI_quantitiesLookupModes &modes, bool sampling)
double MCGIDI_reaction_getCrossSectionAtE(statusMessageReporting *smr, MCGIDI_reaction *reaction, MCGIDI_quantitiesLookupModes &modes, bool sampling)
int MCGIDI_reaction_getDomain(statusMessageReporting *, MCGIDI_reaction *reaction, double *EMin, double *EMax)
int MCGIDI_POPs_release(MCGIDI_POPs *pops)
static int MCGIDI_target_heated_parseReaction(statusMessageReporting *smr, xDataTOM_element *child, MCGIDI_target_heated *target, MCGIDI_POPs *pops, MCGIDI_reaction *reaction)
int MCGIDI_reaction_release(statusMessageReporting *smr, MCGIDI_reaction *reaction)
int MCGIDI_target_heated_sampleIndexReactionProductsAtE(statusMessageReporting *smr, MCGIDI_target_heated *target, int index, MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo, MCGIDI_sampledProductsDatas *productDatas)
ptwXPoints * ptwX_clone(ptwXPoints *ptwX, nfu_status *status)
ptwXYPoints * ptwXY_free(ptwXYPoints *ptwXY)
int MCGIDI_target_heated_read(statusMessageReporting *smr, MCGIDI_target_heated *target, const char *fileName)
double MCGIDI_target_heated_getTotalCrossSectionAtE(statusMessageReporting *smr, MCGIDI_target_heated *target, MCGIDI_quantitiesLookupModes &modes, bool sampling)
void * xDataTOM_freeTOM(statusMessageReporting *, xDataTOM_TOM **TOM)
const char * name(G4int ptype)
MCGIDI_POP * MCGIDI_target_heated_getPOPForTarget(statusMessageReporting *, MCGIDI_target_heated *target)
char * xDataTOMMisc_getAbsPath(statusMessageReporting *smr, const char *fileName)
std::map< int, enum MCGIDI_transportability > const * MCGIDI_target_heated_getUniqueProducts(statusMessageReporting *, MCGIDI_target_heated *target)
int xDataTOM_numberOfElementsByName(statusMessageReporting *, xDataTOM_element *element, char const *name)
int MCGIDI_reaction_parseFromTOM(statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_target_heated *target, MCGIDI_POPs *pops, MCGIDI_reaction *reaction)
double ptwX_getPointAtIndex_Unsafely(ptwXPoints *ptwX, int64_t index)
GIDI_settings_particle const * getParticle(int PoPId) const
int MCGIDI_POPs_initial(statusMessageReporting *, MCGIDI_POPs *pops, int size)
double MCGIDI_target_heated_getProjectileMass_MeV(statusMessageReporting *, MCGIDI_target_heated *target)
int MCGIDI_reaction_recast(statusMessageReporting *smr, MCGIDI_reaction *reaction, GIDI_settings &, GIDI_settings_particle const *projectileSettings, double temperature_MeV, ptwXPoints *totalGroupedCrossSection)
double MCGIDI_target_heated_getReactionsThreshold(statusMessageReporting *, MCGIDI_target_heated *target, int index)
int MCGIDI_target_heated_getReactionsDomain(statusMessageReporting *, MCGIDI_target_heated *target, int index, double *EMin, double *EMax)
MCGIDI_target_heated * MCGIDI_target_heated_free(statusMessageReporting *smr, MCGIDI_target_heated *target)
MCGIDI_POP * MCGIDI_POPs_findParticle(MCGIDI_POPs *pops, char const *name)
int MCGIDI_target_heated_numberOfProductionReactions(statusMessageReporting *, MCGIDI_target_heated *)
int xDataTOMAL_copyAttributionList(statusMessageReporting *smr, xDataTOM_attributionList *desc, xDataTOM_attributionList *src)
int MCGIDI_misc_PQUStringToDouble(statusMessageReporting *smr, char const *str, char const *unit, double conversion, double *value)
ptwXPoints * ptwX_createLine(int64_t size, int64_t length, double slope, double offset, nfu_status *status)
int smr_isOk(statusMessageReporting *smr)
void MCGIDI_misc_updateTransportabilitiesMap(transportabilitiesMap *transportabilities, int PoPID, enum MCGIDI_transportability transportability)
void * smr_freeMemory(void **p)
double MCGIDI_misc_getUnitConversionFactor(statusMessageReporting *smr, char const *fromUnit, char const *toUnit)
MCGIDI_target_heated * MCGIDI_target_heated_newRead(statusMessageReporting *smr, const char *fileName)
xDataTOM_TOM * xDataTOM_importFile(statusMessageReporting *smr, const char *fileName)
double MCGIDI_POP_getMass_MeV(MCGIDI_POP *pop)
void xDataTOMAL_release(xDataTOM_attributionList *attributes)
int MCGIDI_misc_PQUStringToDoubleInUnitOf(statusMessageReporting *smr, char const *str, char const *toUnit, double *value)
ptwXPoints * ptwX_free(ptwXPoints *ptwX)
char const * xDataTOM_getAttributesValueInElement(xDataTOM_element *element, char const *name)
int MCGIDI_outputChannel_sampleProductsAtE(statusMessageReporting *smr, MCGIDI_outputChannel *outputChannel, MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo, MCGIDI_sampledProductsDatas *productDatas, double *masses_)
double * ptwX_getPointAtIndex(ptwXPoints *ptwX, int64_t index)
double MCGIDI_target_heated_getIndexReactionFinalQ(statusMessageReporting *smr, MCGIDI_target_heated *target, int index, MCGIDI_quantitiesLookupModes &modes)
double MCGIDI_target_heated_getTargetMass_MeV(statusMessageReporting *, MCGIDI_target_heated *target)
ptwXYPoints * ptwXY_add_ptwXY(ptwXYPoints *ptwXY1, ptwXYPoints *ptwXY2, nfu_status *status)
double MCGIDI_reaction_getFinalQ(statusMessageReporting *, MCGIDI_reaction *reaction, MCGIDI_quantitiesLookupModes &)
MCGIDI_reaction * MCGIDI_target_heated_getReactionAtIndex_smr(statusMessageReporting *smr, MCGIDI_target_heated *target, int index)
int64_t ptwX_length(ptwXPoints *ptwX)
static int MCGIDI_target_heated_parseParticle(statusMessageReporting *smr, MCGIDI_target_heated *target, xDataTOM_element *element, xDataTOM_element *particleAliases)
xDataTOM_element * xDataTOME_getNextElement(xDataTOM_element *element)
MCGIDI_POP * MCGIDI_POPs_addParticleIfNeeded(statusMessageReporting *smr, MCGIDI_POPs *pops, char const *name, double mass_MeV, double level_MeV, MCGIDI_POP *parent, int globalParticle)
nfu_status ptwXY_getValueAtX(ptwXYPoints *ptwXY, double x, double *y)
int MCGIDI_target_heated_recast(statusMessageReporting *smr, MCGIDI_target_heated *target, GIDI_settings &settings)
MCGIDI_target_heated * MCGIDI_target_heated_new(statusMessageReporting *smr)
xDataTOM_element * xDataTOM_getDocumentsElement(xDataTOM_TOM *TOM)
static int MCGIDI_target_heated_parseParticleGammas(statusMessageReporting *smr, MCGIDI_target_heated *target, xDataTOM_element *element, char const *name)
int MCGIDI_target_heated_initialize(statusMessageReporting *smr, MCGIDI_target_heated *target)
const char * nfu_statusMessage(nfu_status status)
int MCGIDI_target_heated_release(statusMessageReporting *, MCGIDI_target_heated *target)
bool isEnergyMode_grouped(void) const
int xDataTOME_convertAttributeToDouble(statusMessageReporting *smr, xDataTOM_element *element, char const *name, double *d)
MCGIDI_reaction * MCGIDI_target_heated_getReactionAtIndex(MCGIDI_target_heated *target, int index)
int MCGIDI_target_heated_numberOfReactions(statusMessageReporting *, MCGIDI_target_heated *target)