Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/hadronic/models/lend/src/MCGIDI_target_heated.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/hadronic/models/lend/src/MCGIDI_target_heated.cc (Version 11.3.0) and /processes/hadronic/models/lend/src/MCGIDI_target_heated.cc (Version 10.2)


  1 /*                                                  1 /*
  2 # <<BEGIN-copyright>>                               2 # <<BEGIN-copyright>>
  3 # <<END-copyright>>                                 3 # <<END-copyright>>
  4 */                                                  4 */
  5                                                     5 
  6 #include <map>                                      6 #include <map>
  7 #include <string.h>                                 7 #include <string.h>
  8 #include <cmath>                                    8 #include <cmath>
  9                                                     9 
 10 #include <xDataTOM.h>                              10 #include <xDataTOM.h>
 11 #include "MCGIDI.h"                                11 #include "MCGIDI.h"
 12 #include "MCGIDI_misc.h"                           12 #include "MCGIDI_misc.h"
 13 #include "MCGIDI_private.h"                        13 #include "MCGIDI_private.h"
 14                                                    14 
 15 #if defined __cplusplus                            15 #if defined __cplusplus
 16 namespace GIDI {                                   16 namespace GIDI {
 17 using namespace GIDI;                              17 using namespace GIDI;
 18 #endif                                             18 #endif
 19                                                    19 
 20 static int MCGIDI_target_heated_parsePOPs( sta     20 static int MCGIDI_target_heated_parsePOPs( statusMessageReporting *smr, MCGIDI_target_heated *target, xDataTOM_element *element,
 21     xDataTOM_element *particleAliases );           21     xDataTOM_element *particleAliases );
 22 static int MCGIDI_target_heated_parseParticle(     22 static int MCGIDI_target_heated_parseParticle( statusMessageReporting *smr, MCGIDI_target_heated *target, xDataTOM_element *element,
 23     xDataTOM_element *particleAliases );           23     xDataTOM_element *particleAliases );
 24 static int MCGIDI_target_heated_parseParticleL     24 static int MCGIDI_target_heated_parseParticleLevel( statusMessageReporting *smr, MCGIDI_target_heated *target, xDataTOM_element *element, MCGIDI_POP *parent,
 25     double mass_MeV, xDataTOM_element *particl     25     double mass_MeV, xDataTOM_element *particleAliases );
 26 static int MCGIDI_target_heated_parseParticleG     26 static int MCGIDI_target_heated_parseParticleGammas( statusMessageReporting *smr, MCGIDI_target_heated *target, xDataTOM_element *element, char const *name );
 27 static int MCGIDI_target_heated_parseReaction(     27 static int MCGIDI_target_heated_parseReaction( statusMessageReporting *smr, xDataTOM_element *child, MCGIDI_target_heated *target, 
 28     MCGIDI_POPs *pops, MCGIDI_reaction *reacti     28     MCGIDI_POPs *pops, MCGIDI_reaction *reaction );
 29 /*                                                 29 /*
 30 **********************************************     30 ************************************************************
 31 */                                                 31 */
 32 MCGIDI_target_heated *MCGIDI_target_heated_new     32 MCGIDI_target_heated *MCGIDI_target_heated_new( statusMessageReporting *smr ) {
 33                                                    33 
 34     MCGIDI_target_heated *target;                  34     MCGIDI_target_heated *target;
 35                                                    35 
 36     if( ( target = (MCGIDI_target_heated *) sm     36     if( ( target = (MCGIDI_target_heated *) smr_malloc2( smr, sizeof( MCGIDI_target_heated ), 0, "target" ) ) == NULL ) return( NULL );
 37     if( MCGIDI_target_heated_initialize( smr,      37     if( MCGIDI_target_heated_initialize( smr, target ) ) target = (MCGIDI_target_heated *) smr_freeMemory( (void **) &target );
 38     return( target );                              38     return( target );
 39 }                                                  39 }
 40 /*                                                 40 /*
 41 **********************************************     41 ************************************************************
 42 */                                                 42 */
 43 int MCGIDI_target_heated_initialize( statusMes     43 int MCGIDI_target_heated_initialize( statusMessageReporting *smr, MCGIDI_target_heated *target ) {
 44                                                    44 
 45     memset( target, 0, sizeof( MCGIDI_target_h     45     memset( target, 0, sizeof( MCGIDI_target_heated ) );
 46     MCGIDI_POPs_initial( smr, &(target->pops),     46     MCGIDI_POPs_initial( smr, &(target->pops), 100 );
 47     target->transportabilities = new transport     47     target->transportabilities = new transportabilitiesMap( );
 48     return( 0 );                                   48     return( 0 );
 49 }                                                  49 }
 50 /*                                                 50 /*
 51 **********************************************     51 ************************************************************
 52 */                                                 52 */
 53 MCGIDI_target_heated *MCGIDI_target_heated_new     53 MCGIDI_target_heated *MCGIDI_target_heated_newRead( statusMessageReporting *smr, const char *fileName ) {
 54                                                    54 
 55     MCGIDI_target_heated *target;                  55     MCGIDI_target_heated *target;
 56                                                    56 
 57     if( ( target = MCGIDI_target_heated_new( s     57     if( ( target = MCGIDI_target_heated_new( smr ) ) == NULL ) return( NULL );
 58     if( MCGIDI_target_heated_read( smr, target     58     if( MCGIDI_target_heated_read( smr, target, fileName ) != 0 ) target = (MCGIDI_target_heated *) smr_freeMemory( (void **) &target );
 59     return( target );                              59     return( target );
 60 }                                                  60 }
 61 /*                                                 61 /*
 62 **********************************************     62 ************************************************************
 63 */                                                 63 */
 64 MCGIDI_target_heated *MCGIDI_target_heated_fre     64 MCGIDI_target_heated *MCGIDI_target_heated_free( statusMessageReporting *smr, MCGIDI_target_heated *target ) {
 65                                                    65 
 66     MCGIDI_target_heated_release( smr, target      66     MCGIDI_target_heated_release( smr, target );
 67     smr_freeMemory( (void **) &target );           67     smr_freeMemory( (void **) &target );
 68     return( NULL );                                68     return( NULL );
 69 }                                                  69 }
 70 /*                                                 70 /*
 71 **********************************************     71 ************************************************************
 72 */                                                 72 */
 73 int MCGIDI_target_heated_release( statusMessag     73 int MCGIDI_target_heated_release( statusMessageReporting * /*smr*/, MCGIDI_target_heated *target ) {
 74                                                    74 
 75     int ir;                                        75     int ir;
 76                                                    76 
 77     ptwXY_free( target->crossSection );            77     ptwXY_free( target->crossSection );
 78     ptwX_free( target->crossSectionGrouped );      78     ptwX_free( target->crossSectionGrouped );
 79     ptwX_free( target->crossSectionGroupedForS     79     ptwX_free( target->crossSectionGroupedForSampling );
 80     for( ir = 0; ir < target->numberOfReaction     80     for( ir = 0; ir < target->numberOfReactions; ir++ ) MCGIDI_reaction_release( NULL, &(target->reactions[ir]) );
 81     smr_freeMemory( (void **) &(target->reacti     81     smr_freeMemory( (void **) &(target->reactions) );
 82     MCGIDI_POPs_release( &(target->pops) );        82     MCGIDI_POPs_release( &(target->pops) );
 83     smr_freeMemory( (void **) &(target->path)      83     smr_freeMemory( (void **) &(target->path) );
 84     smr_freeMemory( (void **) &(target->absPat     84     smr_freeMemory( (void **) &(target->absPath) );
 85     xDataTOMAL_release( &(target->attributes)      85     xDataTOMAL_release( &(target->attributes) );
 86     delete target->transportabilities;             86     delete target->transportabilities;
 87     return( 0 );                                   87     return( 0 );
 88 }                                                  88 }
 89 /*                                                 89 /*
 90 **********************************************     90 ************************************************************
 91 */                                                 91 */
 92 int MCGIDI_target_heated_read( statusMessageRe     92 int MCGIDI_target_heated_read( statusMessageReporting *smr, MCGIDI_target_heated *target, const char *fileName ) {
 93 /*                                                 93 /*
 94 *   If a target has already been read into thi     94 *   If a target has already been read into this target, user must have called MCGIDI_target_heated_release before calling this routine.
 95 *   Otherwise, there will be memory leaks.         95 *   Otherwise, there will be memory leaks.
 96 */                                                 96 */
 97     int n, ir;                                     97     int n, ir;
 98     xDataTOM_TOM *doc = NULL;                      98     xDataTOM_TOM *doc = NULL;
 99     xDataTOM_element *element, *child, *partic     99     xDataTOM_element *element, *child, *particles, *particleAliases;
100     char const *name, *version, *temperatureSt    100     char const *name, *version, *temperatureStr;
101     char *e1;                                     101     char *e1;
102     MCGIDI_reaction *reaction;                    102     MCGIDI_reaction *reaction;
103     double crossSectionInit[4] = { 0., 0., 0.,    103     double crossSectionInit[4] = { 0., 0., 0., 0., };
104     nfu_status status;                            104     nfu_status status;
105     ptwXYPoints *crossSection;                    105     ptwXYPoints *crossSection;
106 int subtag1_Notice = 0;                           106 int subtag1_Notice = 0;
107                                                   107 
108     if( ( target->path = smr_allocateCopyStrin    108     if( ( target->path = smr_allocateCopyString2( smr, fileName, "path" ) ) == NULL ) goto err;
109     if( ( target->absPath = xDataTOMMisc_getAb    109     if( ( target->absPath = xDataTOMMisc_getAbsPath( smr, fileName ) ) == NULL ) goto err;
110     if( ( doc = xDataTOM_importFile( smr, file    110     if( ( doc = xDataTOM_importFile( smr, fileName ) ) == NULL ) goto err;
111     element = xDataTOM_getDocumentsElement( do    111     element = xDataTOM_getDocumentsElement( doc );
112     if( ( version = xDataTOM_getAttributesValu    112     if( ( version = xDataTOM_getAttributesValueInElement( element, "version" ) ) == NULL ) {
113             smr_setReportError2( smr, smr_unkn    113             smr_setReportError2( smr, smr_unknownID, 1, "version attribute missing from element '%s'", element->name );
114             goto err; }                           114             goto err; }
115     else {                                        115     else {
116         if( strcmp( version, "GND 1.3" ) != 0     116         if( strcmp( version, "GND 1.3" ) != 0 ) {
117             smr_setReportError2( smr, smr_unkn    117             smr_setReportError2( smr, smr_unknownID, 1, "Unsupported version '%s' for element %s", version, element->name );
118             goto err;                             118             goto err;
119         }                                         119         }
120     }                                             120     }
121     if( strcmp( element->name, "reactionSuite"    121     if( strcmp( element->name, "reactionSuite" ) != 0 ) {
122         smr_setReportError2( smr, smr_unknownI    122         smr_setReportError2( smr, smr_unknownID, 1, "input file's top element must be reactionSuite and not %s", element->name );
123         goto err; }                               123         goto err; }
124     else {                                        124     else {
125         xDataTOMAL_copyAttributionList( smr, &    125         xDataTOMAL_copyAttributionList( smr, &(target->attributes), &(element->attributes) );
126         particleAliases = xDataTOME_getOneElem    126         particleAliases = xDataTOME_getOneElementByName( smr, element, "aliases", 0 );
127         if( ( particles = xDataTOME_getOneElem    127         if( ( particles = xDataTOME_getOneElementByName( smr, element, "particles", 1 ) ) == NULL ) goto err;
128         if( MCGIDI_target_heated_parsePOPs( sm    128         if( MCGIDI_target_heated_parsePOPs( smr, target, particles, particleAliases ) != 0 ) goto err;
129                                                   129 
130         if( ( temperatureStr = MCGIDI_misc_poi    130         if( ( temperatureStr = MCGIDI_misc_pointerToTOMAttributeIfAllOk3( smr, target->absPath, 1, &(target->attributes), "temperature" ) ) == NULL ) goto err;
131         target->temperature_MeV = strtod( temp    131         target->temperature_MeV = strtod( temperatureStr, &e1 );
132         while( isspace( *e1 ) ) ++e1; // Loop     132         while( isspace( *e1 ) ) ++e1; // Loop checking, 11.06.2015, T. Koi
133         target->temperature_MeV *= MCGIDI_misc    133         target->temperature_MeV *= MCGIDI_misc_getUnitConversionFactor( smr, e1, "MeV/k" );
134         if( !smr_isOk( smr ) ) goto err;          134         if( !smr_isOk( smr ) ) goto err;
135                                                   135 
136         if( ( name = MCGIDI_misc_pointerToTOMA    136         if( ( name = MCGIDI_misc_pointerToTOMAttributeIfAllOk3( smr, target->absPath, 1, &(target->attributes), "projectile" ) ) != NULL )
137             target->projectilePOP = MCGIDI_POP    137             target->projectilePOP = MCGIDI_POPs_findParticle( &(target->pops), name );
138         if( !smr_isOk( smr ) ) goto err;          138         if( !smr_isOk( smr ) ) goto err;
139                                                   139 
140         if( ( name = MCGIDI_misc_pointerToTOMA    140         if( ( name = MCGIDI_misc_pointerToTOMAttributeIfAllOk3( smr, target->absPath, 1, &(target->attributes), "target" ) ) != NULL )
141         if( !smr_isOk( smr ) ) goto err;          141         if( !smr_isOk( smr ) ) goto err;
142             target->targetPOP = MCGIDI_POPs_fi    142             target->targetPOP = MCGIDI_POPs_findParticle( &(target->pops), name );
143                                                   143 
144         n = xDataTOM_numberOfElementsByName( s    144         n = xDataTOM_numberOfElementsByName( smr, element, "reaction" );
145         if( n == 0 ) {                            145         if( n == 0 ) {
146             smr_setReportError2( smr, smr_unkn    146             smr_setReportError2( smr, smr_unknownID, 1, "target does not have any reactions: file = '%s'", fileName );
147             goto err;                             147             goto err;
148         }                                         148         }
149         if( ( target->reactions = (MCGIDI_reac    149         if( ( target->reactions = (MCGIDI_reaction *) smr_malloc2( smr, n * sizeof( MCGIDI_reaction ), 1, "target->reactions" ) ) == NULL ) goto err;
150                                                   150 
151         for( ir = 0, child = xDataTOME_getFirs    151         for( ir = 0, child = xDataTOME_getFirstElement( element ); child != NULL; child = xDataTOME_getNextElement( child ) ) {
152             if( strcmp( child->name, "particle    152             if( strcmp( child->name, "particles" ) == 0 ) continue;
153             if( strcmp( child->name, "styles"     153             if( strcmp( child->name, "styles" ) == 0 ) continue;
154             if( strcmp( child->name, "document    154             if( strcmp( child->name, "documentations" ) == 0 ) continue;
155             if( strcmp( child->name, "resonanc    155             if( strcmp( child->name, "resonances" ) == 0 ) continue;
156             if( strcmp( child->name, "summedRe    156             if( strcmp( child->name, "summedReaction" ) == 0 ) continue;
157             if( strcmp( child->name, "fissionC    157             if( strcmp( child->name, "fissionComponent" ) == 0 ) continue;
158             if( strcmp( child->name, "reaction    158             if( strcmp( child->name, "reaction" ) == 0 ) {
159                 double EMin, EMax;                159                 double EMin, EMax;
160                                                   160 
161                 reaction =  &(target->reaction    161                 reaction =  &(target->reactions[ir]);
162                 if( MCGIDI_target_heated_parse    162                 if( MCGIDI_target_heated_parseReaction( smr, child, target, &(target->pops), reaction ) ) goto err;
163                 if( MCGIDI_reaction_getDomain(    163                 if( MCGIDI_reaction_getDomain( smr, reaction, &EMin, &EMax ) ) goto err;
164                 if( ir == 0 ) { target->EMin =    164                 if( ir == 0 ) { target->EMin = EMin; target->EMax = EMax; }
165                 if( EMin < target->EMin ) targ    165                 if( EMin < target->EMin ) target->EMin = EMin;
166                 if( EMax > target->EMax ) targ    166                 if( EMax > target->EMax ) target->EMax = EMax;
167                 for( transportabilitiesMap::co    167                 for( transportabilitiesMap::const_iterator iter = reaction->transportabilities->begin( ); 
168                             iter != reaction->    168                             iter != reaction->transportabilities->end( ); ++iter ) {
169                     MCGIDI_misc_updateTranspor    169                     MCGIDI_misc_updateTransportabilitiesMap( target->transportabilities, iter->first, iter->second );
170                 }                                 170                 }
171                 ir++; }                           171                 ir++; }
172             else if( strcmp( child->name, "pro    172             else if( strcmp( child->name, "production" ) == 0 ) {
173                 continue; }                       173                 continue; }
174             else if( strcmp( child->name, "ali    174             else if( strcmp( child->name, "aliases" ) == 0 ) {
175                 continue; }                       175                 continue; }
176             else if( strcmp( child->name, "par    176             else if( strcmp( child->name, "partialGammaProduction" ) == 0 ) {
177                 if( subtag1_Notice == 0 ) prin    177                 if( subtag1_Notice == 0 ) printf( "Unsupported reactionSuite sub-tag = '%s'\n", child->name );
178                 subtag1_Notice++; }               178                 subtag1_Notice++; }
179             else {                                179             else {
180                 printf( "Unsupported reactionS    180                 printf( "Unsupported reactionSuite sub-tag = '%s'\n", child->name );
181             }                                     181             }
182         }                                         182         }
183         crossSectionInit[0] = target->EMin;       183         crossSectionInit[0] = target->EMin;
184         crossSectionInit[2] = target->EMax;       184         crossSectionInit[2] = target->EMax;
185         if( ( target->crossSection = ptwXY_cre    185         if( ( target->crossSection = ptwXY_create( ptwXY_interpolationLinLin, NULL, 2., 1e-3, 2, 10, 2, crossSectionInit, &status, 0 ) ) == NULL ) {
186             smr_setReportError2( smr, smr_unkn    186             smr_setReportError2( smr, smr_unknownID, 1, "ptwXY_create err = %d: %s\n", status, nfu_statusMessage( status ) );
187             goto err;                             187             goto err;
188         }                                         188         }
189         for( ir = 0; ir < target->numberOfReac    189         for( ir = 0; ir < target->numberOfReactions; ir++ ) {
190             reaction =  &(target->reactions[ir    190             reaction =  &(target->reactions[ir]);
191             if( MCGIDI_reaction_fixDomains( sm    191             if( MCGIDI_reaction_fixDomains( smr, reaction, target->EMin, target->EMax, &status ) ) {
192                 smr_setReportError2( smr, smr_    192                 smr_setReportError2( smr, smr_unknownID, 1, "ptwXY_add_ptwXY err = %d: %s\n", status, nfu_statusMessage( status ) );
193                 goto err;                         193                 goto err;
194             }                                     194             }
195             if( ( crossSection = ptwXY_add_ptw    195             if( ( crossSection = ptwXY_add_ptwXY( target->crossSection, reaction->crossSection, &status ) ) == NULL ) {
196                 smr_setReportError2( smr, smr_    196                 smr_setReportError2( smr, smr_unknownID, 1, "ptwXY_add_ptwXY err = %d: %s\n", status, nfu_statusMessage( status ) );
197                 goto err;                         197                 goto err;
198             }                                     198             }
199             target->crossSection = ptwXY_free(    199             target->crossSection = ptwXY_free( target->crossSection );
200             target->crossSection = crossSectio    200             target->crossSection = crossSection;
201         }                                         201         }
202     }                                             202     }
203     xDataTOM_freeTOM( smr, &doc );                203     xDataTOM_freeTOM( smr, &doc );
204     return( 0 );                                  204     return( 0 );
205                                                   205 
206 err:                                              206 err:
207     smr_setReportError2( smr, smr_unknownID, 1    207     smr_setReportError2( smr, smr_unknownID, 1, "Sub-error while reading file '%s'", fileName );
208     if( doc != NULL ) xDataTOM_freeTOM( smr, &    208     if( doc != NULL ) xDataTOM_freeTOM( smr, &doc );
209     MCGIDI_target_heated_release( smr, target     209     MCGIDI_target_heated_release( smr, target );
210     return( 1 );                                  210     return( 1 );
211 }                                                 211 }
212 /*                                                212 /*
213 **********************************************    213 ************************************************************
214 */                                                214 */
215 static int MCGIDI_target_heated_parsePOPs( sta    215 static int MCGIDI_target_heated_parsePOPs( statusMessageReporting *smr, MCGIDI_target_heated *target, xDataTOM_element *element,
216         xDataTOM_element *particleAliases ) {     216         xDataTOM_element *particleAliases ) {
217                                                   217 
218     xDataTOM_element *child;                      218     xDataTOM_element *child;
219                                                   219 
220     for( child = xDataTOME_getFirstElement( el    220     for( child = xDataTOME_getFirstElement( element ); child != NULL; child = xDataTOME_getNextElement( child ) ) {
221         if( strcmp( child->name, "particle" )     221         if( strcmp( child->name, "particle" ) ) {
222             smr_setReportError2( smr, smr_unkn    222             smr_setReportError2( smr, smr_unknownID, 1, "invalid element '%s' in %s", child->name, element->name );
223             goto err;                             223             goto err;
224         }                                         224         }
225         if( MCGIDI_target_heated_parseParticle    225         if( MCGIDI_target_heated_parseParticle( smr, target, child, particleAliases ) ) goto err;
226     }                                             226     }
227     return( 0 );                                  227     return( 0 );
228                                                   228 
229 err:                                              229 err:
230     return( 1 );                                  230     return( 1 );
231 }                                                 231 }
232 /*                                                232 /*
233 **********************************************    233 ************************************************************
234 */                                                234 */
235 static int MCGIDI_target_heated_parseParticle(    235 static int MCGIDI_target_heated_parseParticle( statusMessageReporting *smr, MCGIDI_target_heated *target, xDataTOM_element *element,
236         xDataTOM_element *particleAliases ) {     236         xDataTOM_element *particleAliases ) {
237 /*                                                237 /*
238     This routine, MCGIDI_target_heated_parsePa    238     This routine, MCGIDI_target_heated_parseParticleLevel, MCGIDI_target_heated_parseParticleGammas handle the parsing of a
239     particle which can have one of the followi    239     particle which can have one of the following three forms:
240                                                   240 
241 1)                                                241 1)
242     <particle name="Sc47" genre="nucleus" mass    242     <particle name="Sc47" genre="nucleus" mass="46.9524440292728 amu"/>
243 2)                                                243 2)
244     <particle name="Sc46" genre="nucleus" mass    244     <particle name="Sc46" genre="nucleus" mass="45.9551770270807 amu">
245         <level name="Sc46_e0" label="0" energy    245         <level name="Sc46_e0" label="0" energy="0 eV"/>
246         <level name="Sc46_e1" label="1" energy    246         <level name="Sc46_e1" label="1" energy="142500 eV"/></particle>
247 3)                                                247 3)
248     <particle name="S36" genre="nucleus" mass=    248     <particle name="S36" genre="nucleus" mass="35.9669735654569 amu">
249         <level name="S36_e0" label="0" energy=    249         <level name="S36_e0" label="0" energy="0 eV" spin="0"/>
250         <level name="S36_e1" label="1" energy=    250         <level name="S36_e1" label="1" energy="3.291e6 eV">
251             <gamma finalLevel="S36_e0" probabi    251             <gamma finalLevel="S36_e0" probability="1.0"/></level>
252         <level name="S36_e2" label="2" energy=    252         <level name="S36_e2" label="2" energy="3.346e6 eV">
253             <gamma finalLevel="S36_e0" probabi    253             <gamma finalLevel="S36_e0" probability="1.0"/></level>
254         <level name="S36_e3" label="3" energy=    254         <level name="S36_e3" label="3" energy="4191990 eV">
255             <gamma finalLevel="S36_e1" probabi    255             <gamma finalLevel="S36_e1" probability="1.0"/></level>
256         <level name="S36_e4" label="4" energy=    256         <level name="S36_e4" label="4" energy="4522990 eV">
257             <gamma finalLevel="S36_e1" probabi    257             <gamma finalLevel="S36_e1" probability="0.248"/>
258             <gamma finalLevel="S36_e0" probabi    258             <gamma finalLevel="S36_e0" probability="0.752"/></level>
259         <level name="S36_e5" label="5" energy=    259         <level name="S36_e5" label="5" energy="4574990 eV">
260             <gamma finalLevel="S36_e1" probabi    260             <gamma finalLevel="S36_e1" probability="1.0"/></level>
261         <level name="S36_c" label="c" energy="    261         <level name="S36_c" label="c" energy="u:4999990 eV"/></particle>
262 */                                                262 */
263     int globalParticle = 1;                       263     int globalParticle = 1;
264     char const *name = NULL, *mass = NULL;        264     char const *name = NULL, *mass = NULL;      /* Do not free name or mass, do not own them. */
265     double mass_MeV;                              265     double mass_MeV;
266     xDataTOM_element *child;                      266     xDataTOM_element *child;
267     MCGIDI_POP *pop;                              267     MCGIDI_POP *pop;
268                                                   268 
269     if( ( name = xDataTOM_getAttributesValueIn    269     if( ( name = xDataTOM_getAttributesValueInElement( element, "name" ) ) == NULL ) {
270         smr_setReportError2p( smr, smr_unknown    270         smr_setReportError2p( smr, smr_unknownID, 1, "particle missing name attribute" );
271         goto err;                                 271         goto err;
272     }                                             272     }
273     if( ( mass = xDataTOM_getAttributesValueIn    273     if( ( mass = xDataTOM_getAttributesValueInElement( element, "mass" ) ) == NULL ) {
274         smr_setReportError2( smr, smr_unknownI    274         smr_setReportError2( smr, smr_unknownID, 1, "particle '%s' missing mass attribute", name );
275         goto err;                                 275         goto err;
276     }                                             276     }
277     if( MCGIDI_misc_PQUStringToDouble( smr, ma    277     if( MCGIDI_misc_PQUStringToDouble( smr, mass, "amu", MCGIDI_AMU2MeV, &mass_MeV ) ) goto err;
278     if( ( pop = MCGIDI_POPs_addParticleIfNeede    278     if( ( pop = MCGIDI_POPs_addParticleIfNeeded( smr, &(target->pops), name, mass_MeV, 0., NULL, globalParticle ) ) == NULL ) goto err;
279                                                   279 
280     for( child = xDataTOME_getFirstElement( el    280     for( child = xDataTOME_getFirstElement( element ); child != NULL; child = xDataTOME_getNextElement( child ) ) {
281         if( strcmp( child->name, "level" ) ) {    281         if( strcmp( child->name, "level" ) ) {
282             smr_setReportError2( smr, smr_unkn    282             smr_setReportError2( smr, smr_unknownID, 1, "invalid element '%s' in %s", child->name, element->name );
283             goto err;                             283             goto err;
284         }                                         284         }
285         if( MCGIDI_target_heated_parseParticle    285         if( MCGIDI_target_heated_parseParticleLevel( smr, target, child, pop, mass_MeV, particleAliases ) ) goto err;
286     }                                             286     }
287                                                   287 
288     return( 0 );                                  288     return( 0 );
289                                                   289 
290 err:                                              290 err:
291     return( 1 );                                  291     return( 1 );
292 }                                                 292 }
293 /*                                                293 /*
294 **********************************************    294 ************************************************************
295 */                                                295 */
296 static int MCGIDI_target_heated_parseParticleL    296 static int MCGIDI_target_heated_parseParticleLevel( statusMessageReporting *smr, MCGIDI_target_heated *target, xDataTOM_element *element, MCGIDI_POP *parent,
297     double mass_MeV, xDataTOM_element *particl    297     double mass_MeV, xDataTOM_element *particleAliases ) {
298                                                   298 
299     int globalParticle = 0;                       299     int globalParticle = 0;
300     char const *name, *level, *aliasValue;        300     char const *name, *level, *aliasValue;     /* Do not free any of these as they are owned by called routine. */
301     double level_MeV = 0.;                        301     double level_MeV = 0.;
302     xDataTOM_element *alias;                      302     xDataTOM_element *alias;
303                                                   303 
304     if( ( name = xDataTOM_getAttributesValueIn    304     if( ( name = xDataTOM_getAttributesValueInElement( element, "name" ) ) == NULL ) {
305         smr_setReportError2p( smr, smr_unknown    305         smr_setReportError2p( smr, smr_unknownID, 1, "particle missing name attribute" );
306         goto err;                                 306         goto err;
307     }                                             307     }
308     if( ( level = xDataTOM_getAttributesValueI    308     if( ( level = xDataTOM_getAttributesValueInElement( element, "energy" ) ) == NULL ) {
309         smr_setReportError2( smr, smr_unknownI    309         smr_setReportError2( smr, smr_unknownID, 1, "particle '%s' level missing energy attribute", name );
310         goto err;                                 310         goto err;
311     }                                             311     }
312         /* Special case for 'c' labels. Correc    312         /* Special case for 'c' labels. Correct mass is only needed for two-body. */
313     if( level[0] != 'u' ) if( MCGIDI_misc_PQUS    313     if( level[0] != 'u' ) if( MCGIDI_misc_PQUStringToDoubleInUnitOf( smr, level, "MeV", &level_MeV ) ) goto err;
314     for( alias = xDataTOME_getFirstElement( pa    314     for( alias = xDataTOME_getFirstElement( particleAliases ); alias != NULL; alias = xDataTOME_getNextElement( alias ) ) {
315         if( ( aliasValue = xDataTOM_getAttribu    315         if( ( aliasValue = xDataTOM_getAttributesValueInElement( alias, "value" ) ) == NULL ) {
316             smr_setReportError2p( smr, smr_unk    316             smr_setReportError2p( smr, smr_unknownID, 1, "particle missing name attribute" );
317             goto err;                             317             goto err;
318         }                                         318         }
319         if( strcmp( aliasValue, name ) == 0 )     319         if( strcmp( aliasValue, name ) == 0 ) globalParticle = 1;
320     }                                             320     }
321     if( MCGIDI_POPs_addParticleIfNeeded( smr,     321     if( MCGIDI_POPs_addParticleIfNeeded( smr, &(target->pops), name, mass_MeV + level_MeV, level_MeV, parent, globalParticle ) == NULL ) goto err;
322                                                   322 
323     return( MCGIDI_target_heated_parseParticle    323     return( MCGIDI_target_heated_parseParticleGammas( smr, target, element, name ) );
324                                                   324 
325 err:                                              325 err:
326     return( 1 );                                  326     return( 1 );
327 }                                                 327 }
328 /*                                                328 /*
329 **********************************************    329 ************************************************************
330 */                                                330 */
331 static int MCGIDI_target_heated_parseParticleG    331 static int MCGIDI_target_heated_parseParticleGammas( statusMessageReporting *smr, MCGIDI_target_heated *target, xDataTOM_element *element, char const *name ) {
332                                                   332 
333     int gammaCounts = 0;                          333     int gammaCounts = 0;
334     MCGIDI_POP *pop = MCGIDI_POPs_findParticle    334     MCGIDI_POP *pop = MCGIDI_POPs_findParticle( &(target->pops), name );
335     xDataTOM_element *child;                      335     xDataTOM_element *child;
336     MCGIDI_GammaBranching *gammas = NULL;         336     MCGIDI_GammaBranching *gammas = NULL;
337     char const *finalLevelString;                 337     char const *finalLevelString;
338     double probability;                           338     double probability;
339                                                   339 
340     for( child = xDataTOME_getFirstElement( el    340     for( child = xDataTOME_getFirstElement( element ); child != NULL; child = xDataTOME_getNextElement( child ) ) {
341         if( strcmp( child->name, "gamma" ) ) {    341         if( strcmp( child->name, "gamma" ) ) {
342             smr_setReportError2( smr, smr_unkn    342             smr_setReportError2( smr, smr_unknownID, 1, "invalid element '%s' in %s", child->name, element->name );
343             goto err;                             343             goto err;
344         }                                         344         }
345         gammaCounts++;                            345         gammaCounts++;
346     }                                             346     }
347     if( gammaCounts > 0 ) {                       347     if( gammaCounts > 0 ) {
348         if( ( gammas = (MCGIDI_GammaBranching     348         if( ( gammas = (MCGIDI_GammaBranching *) smr_malloc2( smr, gammaCounts * sizeof( MCGIDI_GammaBranching), 0, "gammas" ) ) == NULL ) goto err;
349         for( child = xDataTOME_getFirstElement    349         for( child = xDataTOME_getFirstElement( element ); child != NULL; child = xDataTOME_getNextElement( child ) ) {
350             if( ( finalLevelString = xDataTOM_    350             if( ( finalLevelString = xDataTOM_getAttributesValueInElement( child, "finalLevel" ) ) == NULL ) {
351                 smr_setReportError2p( smr, smr    351                 smr_setReportError2p( smr, smr_unknownID, 1, "gamma missing 'finalLevel'" );
352                 goto err;                         352                 goto err;
353             }                                     353             }
354             if( xDataTOME_convertAttributeToDo    354             if( xDataTOME_convertAttributeToDouble( smr, child, "probability", &probability ) != 0 ) {
355                 smr_setReportError2p( smr, smr    355                 smr_setReportError2p( smr, smr_unknownID, 1, "gamma missing 'probability' attribute" );
356                 goto err;                         356                 goto err;
357             }                                     357             }
358         }                                         358         }
359     }                                             359     }
360     pop->numberOfGammaBranchs = gammaCounts;      360     pop->numberOfGammaBranchs = gammaCounts;
361     pop->gammas = gammas;                         361     pop->gammas = gammas;
362                                                   362 
363     return( 0 );                                  363     return( 0 );
364                                                   364 
365 err:                                              365 err:
366     if( gammas != NULL ) smr_freeMemory( (void    366     if( gammas != NULL ) smr_freeMemory( (void **) &gammas );
367     return( 1 );                                  367     return( 1 );
368 }                                                 368 }
369 /*                                                369 /*
370 **********************************************    370 ************************************************************
371 */                                                371 */
372 static int MCGIDI_target_heated_parseReaction(    372 static int MCGIDI_target_heated_parseReaction( statusMessageReporting *smr, xDataTOM_element *element, MCGIDI_target_heated *target, 
373         MCGIDI_POPs *pops, MCGIDI_reaction *re    373         MCGIDI_POPs *pops, MCGIDI_reaction *reaction ) {
374                                                   374 
375     if( MCGIDI_reaction_parseFromTOM( smr, ele    375     if( MCGIDI_reaction_parseFromTOM( smr, element, target, pops, reaction ) ) goto err;
376     target->numberOfReactions++;                  376     target->numberOfReactions++;
377                                                   377     
378     return( 0 );                                  378     return( 0 );
379                                                   379 
380 err:                                              380 err:
381     smr_setReportError2( smr, smr_unknownID, 1    381     smr_setReportError2( smr, smr_unknownID, 1, "%s\n", xDataTOM_getAttributesValueInElement( element, "outputChannel" ) );
382     return( 1 );                                  382     return( 1 );
383 }                                                 383 }
384 /*                                                384 /*
385 **********************************************    385 ************************************************************
386 */                                                386 */
387 int MCGIDI_target_heated_numberOfReactions( st    387 int MCGIDI_target_heated_numberOfReactions( statusMessageReporting * /*smr*/, MCGIDI_target_heated *target ) {
388                                                   388 
389     return( target->numberOfReactions );          389     return( target->numberOfReactions );
390 }                                                 390 }
391 /*                                                391 /*
392 **********************************************    392 ************************************************************
393 */                                                393 */
394 int MCGIDI_target_heated_numberOfProductionRea    394 int MCGIDI_target_heated_numberOfProductionReactions( statusMessageReporting * /*smr*/, MCGIDI_target_heated * /*target*/ ) {
395                                                   395 
396     return( 0 );                                  396     return( 0 );
397 }                                                 397 }
398 /*                                                398 /*
399 **********************************************    399 ************************************************************
400 */                                                400 */
401 MCGIDI_reaction *MCGIDI_target_heated_getReact    401 MCGIDI_reaction *MCGIDI_target_heated_getReactionAtIndex( MCGIDI_target_heated *target, int index ) {
402                                                   402 
403     if( ( index >= 0 ) && ( index < target->nu    403     if( ( index >= 0 ) && ( index < target->numberOfReactions ) ) return( &(target->reactions[index]) );
404     return( NULL );                               404     return( NULL );
405 }                                                 405 }
406 /*                                                406 /*
407 **********************************************    407 ************************************************************
408 */                                                408 */
409 MCGIDI_reaction *MCGIDI_target_heated_getReact    409 MCGIDI_reaction *MCGIDI_target_heated_getReactionAtIndex_smr( statusMessageReporting *smr, MCGIDI_target_heated *target, int index ) {
410                                                   410 
411     MCGIDI_reaction *reaction = MCGIDI_target_    411     MCGIDI_reaction *reaction = MCGIDI_target_heated_getReactionAtIndex( target, index );
412                                                   412 
413     if( reaction == NULL ) {                      413     if( reaction == NULL ) {
414         smr_setReportError2( smr, smr_unknownI    414         smr_setReportError2( smr, smr_unknownID, 1, "bad reaction index = %d for %s + %s", index, target->projectilePOP->name, target->targetPOP->name ); 
415     }                                             415     }
416     return( reaction );                           416     return( reaction );
417 }                                                 417 }
418 #if 0                                             418 #if 0
419 /*                                                419 /*
420 **********************************************    420 ************************************************************
421 */                                                421 */
422 MCGIDI_channel *MCGIDI_target_heated_getProduc    422 MCGIDI_channel *MCGIDI_target_heated_getProductionReactionAtIndex( MCGIDI_target_heated *target, int index ) {
423                                                   423 
424     MCGIDI_channel *channel = NULL;               424     MCGIDI_channel *channel = NULL;
425                                                   425 
426     if( ( index >= 0 ) && ( index < target->nP    426     if( ( index >= 0 ) && ( index < target->nProductionReactions ) ) channel = target->productionReactions[index];
427     return( channel );                            427     return( channel );
428 }                                                 428 }
429 #endif                                            429 #endif
430 /*                                                430 /*
431 **********************************************    431 ************************************************************
432 */                                                432 */
433 MCGIDI_POP *MCGIDI_target_heated_getPOPForProj    433 MCGIDI_POP *MCGIDI_target_heated_getPOPForProjectile( statusMessageReporting * /*smr*/, MCGIDI_target_heated *target ) {
434                                                   434 
435     return( target->projectilePOP );              435     return( target->projectilePOP );
436 }                                                 436 }
437 /*                                                437 /*
438 **********************************************    438 ************************************************************
439 */                                                439 */
440 MCGIDI_POP *MCGIDI_target_heated_getPOPForTarg    440 MCGIDI_POP *MCGIDI_target_heated_getPOPForTarget( statusMessageReporting * /*smr*/, MCGIDI_target_heated *target ) {
441                                                   441 
442     return( target->targetPOP );                  442     return( target->targetPOP );
443 }                                                 443 }
444 /*                                                444 /*
445 **********************************************    445 ************************************************************
446 */                                                446 */
447 double MCGIDI_target_heated_getProjectileMass_    447 double MCGIDI_target_heated_getProjectileMass_MeV( statusMessageReporting * /*smr*/, MCGIDI_target_heated *target ) {
448                                                   448 
449     return( MCGIDI_POP_getMass_MeV( target->pr    449     return( MCGIDI_POP_getMass_MeV( target->projectilePOP ) );
450 }                                                 450 }
451 /*                                                451 /*
452 **********************************************    452 ************************************************************
453 */                                                453 */
454 double MCGIDI_target_heated_getTargetMass_MeV(    454 double MCGIDI_target_heated_getTargetMass_MeV( statusMessageReporting * /*smr*/, MCGIDI_target_heated *target ) {
455                                                   455 
456     return( MCGIDI_POP_getMass_MeV( target->ta    456     return( MCGIDI_POP_getMass_MeV( target->targetPOP ) );
457 }                                                 457 }
458 /*                                                458 /*
459 **********************************************    459 ************************************************************
460 */                                                460 */
461 double MCGIDI_target_heated_getTotalCrossSecti    461 double MCGIDI_target_heated_getTotalCrossSectionAtE( statusMessageReporting *smr, MCGIDI_target_heated *target, 
462         MCGIDI_quantitiesLookupModes &modes, b    462         MCGIDI_quantitiesLookupModes &modes, bool sampling ) {
463                                                   463 
464     double xsec;                                  464     double xsec;
465                                                   465 
466     if( modes.getCrossSectionMode( ) == MCGIDI    466     if( modes.getCrossSectionMode( ) == MCGIDI_quantityLookupMode_pointwise ) {
467         double e_in = modes.getProjectileEnerg    467         double e_in = modes.getProjectileEnergy( );
468                                                   468 
469         if( e_in < target->EMin ) e_in = targe    469         if( e_in < target->EMin ) e_in = target->EMin;
470         if( e_in > target->EMax ) e_in = targe    470         if( e_in > target->EMax ) e_in = target->EMax;
471         ptwXY_getValueAtX( target->crossSectio    471         ptwXY_getValueAtX( target->crossSection, e_in, &xsec ); }
472     else if( modes.getCrossSectionMode( ) == M    472     else if( modes.getCrossSectionMode( ) == MCGIDI_quantityLookupMode_grouped ) {
473         int index = modes.getGroupIndex( );       473         int index = modes.getGroupIndex( );
474         double *xSecP;                            474         double *xSecP;
475                                                   475 
476         if( sampling ) {                          476         if( sampling ) {
477             xSecP = ptwX_getPointAtIndex( targ    477             xSecP = ptwX_getPointAtIndex( target->crossSectionGroupedForSampling, index ); }
478         else {                                    478         else {
479             xSecP = ptwX_getPointAtIndex( targ    479             xSecP = ptwX_getPointAtIndex( target->crossSectionGrouped, index );
480         }                                         480         }
481                                                   481 
482         if( xSecP != NULL ) {                     482         if( xSecP != NULL ) {
483             xsec = *xSecP; }                      483             xsec = *xSecP; }
484         else {                                    484         else {
485             xsec = 0.;                            485             xsec = 0.;
486             smr_setReportError2( smr, smr_unkn    486             smr_setReportError2( smr, smr_unknownID, 1, "Invalid cross section group index %d", index, (int) ptwX_length( target->crossSectionGrouped ) );
487         } }                                       487         } }
488     else {                                        488     else {
489         xsec = 0.;                                489         xsec = 0.;
490     }                                             490     }
491     return( xsec );                               491     return( xsec );
492 }                                                 492 }
493 /*                                                493 /*
494 **********************************************    494 ************************************************************
495 */                                                495 */
496 double MCGIDI_target_heated_getIndexReactionCr    496 double MCGIDI_target_heated_getIndexReactionCrossSectionAtE( statusMessageReporting *smr, MCGIDI_target_heated *target, int index, 
497         MCGIDI_quantitiesLookupModes &modes, b    497         MCGIDI_quantitiesLookupModes &modes, bool sampling ) {
498                                                   498 
499     double xsec = 0.;                             499     double xsec = 0.;
500     MCGIDI_reaction *reaction = MCGIDI_target_    500     MCGIDI_reaction *reaction = MCGIDI_target_heated_getReactionAtIndex_smr( smr, target, index );
501                                                   501 
502     if( reaction != NULL ) xsec = MCGIDI_react    502     if( reaction != NULL ) xsec = MCGIDI_reaction_getCrossSectionAtE( smr, reaction, modes, sampling );
503     return( xsec );                               503     return( xsec );
504 }                                                 504 }
505 /*                                                505 /*
506 **********************************************    506 ************************************************************
507 */                                                507 */
508 int MCGIDI_target_heated_sampleIndexReactionPr    508 int MCGIDI_target_heated_sampleIndexReactionProductsAtE( statusMessageReporting *smr, MCGIDI_target_heated *target, int index, 
509         MCGIDI_quantitiesLookupModes &modes, M    509         MCGIDI_quantitiesLookupModes &modes, MCGIDI_decaySamplingInfo *decaySamplingInfo, MCGIDI_sampledProductsDatas *productDatas ) {
510                                                   510 
511     MCGIDI_reaction *reaction = MCGIDI_target_    511     MCGIDI_reaction *reaction = MCGIDI_target_heated_getReactionAtIndex_smr( smr, target, index );
512                                                   512 
513     productDatas->numberOfProducts = 0;           513     productDatas->numberOfProducts = 0;
514     if( reaction == NULL ) return( -1 );          514     if( reaction == NULL ) return( -1 );
515     return( MCGIDI_outputChannel_sampleProduct    515     return( MCGIDI_outputChannel_sampleProductsAtE( smr, &(reaction->outputChannel), modes, decaySamplingInfo, productDatas, NULL ) );
516 }                                                 516 }
517 /*                                                517 /*
518 **********************************************    518 ************************************************************
519 */                                                519 */
520 double MCGIDI_target_heated_getReactionsThresh    520 double MCGIDI_target_heated_getReactionsThreshold( statusMessageReporting * /*smr*/, MCGIDI_target_heated *target, int index ) {
521                                                   521 
522     MCGIDI_reaction *reaction = MCGIDI_target_    522     MCGIDI_reaction *reaction = MCGIDI_target_heated_getReactionAtIndex( target, index );
523                                                   523 
524     if( reaction == NULL ) return( -1 );          524     if( reaction == NULL ) return( -1 );
525     return( reaction->EMin );                     525     return( reaction->EMin );
526 }                                                 526 }
527 /*                                                527 /*
528 **********************************************    528 ************************************************************
529 */                                                529 */
530 int MCGIDI_target_heated_getReactionsDomain( s    530 int MCGIDI_target_heated_getReactionsDomain( statusMessageReporting * /*smr*/, MCGIDI_target_heated *target, int index, double *EMin, double *EMax ) {
531                                                   531 
532     MCGIDI_reaction *reaction = MCGIDI_target_    532     MCGIDI_reaction *reaction = MCGIDI_target_heated_getReactionAtIndex( target, index );
533                                                   533 
534     if( reaction == NULL ) return( -1 );          534     if( reaction == NULL ) return( -1 );
535     *EMin = reaction->EMin;                       535     *EMin = reaction->EMin;
536     *EMax = reaction->EMax;                       536     *EMax = reaction->EMax;
537     return( 0 );                                  537     return( 0 );
538 }                                                 538 }
539 /*                                                539 /*
540 **********************************************    540 ************************************************************
541 */                                                541 */
542 double MCGIDI_target_heated_getIndexReactionFi    542 double MCGIDI_target_heated_getIndexReactionFinalQ( statusMessageReporting *smr, MCGIDI_target_heated *target, int index, 
543         MCGIDI_quantitiesLookupModes &modes )     543         MCGIDI_quantitiesLookupModes &modes ) {
544                                                   544 
545     MCGIDI_reaction *reaction = MCGIDI_target_    545     MCGIDI_reaction *reaction = MCGIDI_target_heated_getReactionAtIndex_smr( smr, target, index );
546                                                   546 
547     if( reaction == NULL ) return( 0. );          547     if( reaction == NULL ) return( 0. );
548     return( MCGIDI_reaction_getFinalQ( smr, re    548     return( MCGIDI_reaction_getFinalQ( smr, reaction, modes ) );
549 }                                                 549 }
550 /*                                                550 /*
551 **********************************************    551 ************************************************************
552 */                                                552 */
553 std::map<int, enum MCGIDI_transportability> co    553 std::map<int, enum MCGIDI_transportability> const *MCGIDI_target_heated_getUniqueProducts( statusMessageReporting * /*smr*/, MCGIDI_target_heated *target ) {
554                                                   554 
555     return( target->transportabilities );         555     return( target->transportabilities );
556 }                                                 556 }
557 /*                                                557 /*
558 **********************************************    558 ************************************************************
559 */                                                559 */
560 int MCGIDI_target_heated_recast( statusMessage    560 int MCGIDI_target_heated_recast( statusMessageReporting *smr, MCGIDI_target_heated *target, GIDI_settings &settings ) {
561                                                   561 
562     int ir, projectilePoPID = target->projecti    562     int ir, projectilePoPID = target->projectilePOP->globalPoPsIndex;
563     ptwXPoints *totalGroupedCrossSection = NUL    563     ptwXPoints *totalGroupedCrossSection = NULL;
564     GIDI_settings_particle const *projectileSe    564     GIDI_settings_particle const *projectileSettings = settings.getParticle( projectilePoPID );
565     nfu_status status_nf;                         565     nfu_status status_nf;
566                                                   566 
567     if( projectileSettings == NULL ) {            567     if( projectileSettings == NULL ) {
568         smr_setReportError2( smr, smr_unknownI    568         smr_setReportError2( smr, smr_unknownID, 1, "Settings missing for projectile %s", target->projectilePOP->name ); 
569         return( 1 );                              569         return( 1 );
570     }                                             570     }
571     target->crossSectionGrouped = ptwX_free( t    571     target->crossSectionGrouped = ptwX_free( target->crossSectionGrouped );
572     target->crossSectionGroupedForSampling = p    572     target->crossSectionGroupedForSampling = ptwX_free( target->crossSectionGroupedForSampling );
573     if( projectileSettings->isEnergyMode_group    573     if( projectileSettings->isEnergyMode_grouped( ) ) {
574         int64_t numberOfGroups = projectileSet    574         int64_t numberOfGroups = projectileSettings->getNumberOfGroups( );
575                                                   575 
576         if( ( totalGroupedCrossSection = ptwX_    576         if( ( totalGroupedCrossSection = ptwX_createLine( numberOfGroups, numberOfGroups, 0, 0, &status_nf ) ) == NULL ) {
577             smr_setReportError2( smr, smr_unkn    577             smr_setReportError2( smr, smr_unknownID, 1, "totalGroupedCrossSection allocation failed: status_nf = %d, '%s'", 
578                     status_nf, nfu_statusMessa    578                     status_nf, nfu_statusMessage( status_nf ) ); 
579             goto err;                             579             goto err;
580         }                                         580         }
581     }                                             581     }
582                                                   582 
583     for( ir = 0; ir < target->numberOfReaction    583     for( ir = 0; ir < target->numberOfReactions; ++ir ) {
584         if( MCGIDI_reaction_recast( smr, &(tar    584         if( MCGIDI_reaction_recast( smr, &(target->reactions[ir]), settings, projectileSettings, target->temperature_MeV, totalGroupedCrossSection ) != 0 ) goto err;
585     }                                             585     }
586     if( projectileSettings->isEnergyMode_group    586     if( projectileSettings->isEnergyMode_grouped( ) ) {
587         if( ( target->crossSectionGroupedForSa    587         if( ( target->crossSectionGroupedForSampling = ptwX_clone( totalGroupedCrossSection, &status_nf ) ) == NULL ) {
588             smr_setReportError2( smr, smr_unkn    588             smr_setReportError2( smr, smr_unknownID, 1, "totalGroupedCrossSection allocation failed: status_nf = %d, '%s'", 
589                     status_nf, nfu_statusMessa    589                     status_nf, nfu_statusMessage( status_nf ) ); 
590             goto err;                             590             goto err;
591         }                                         591         }
592         for( ir = 0; ir < target->numberOfReac    592         for( ir = 0; ir < target->numberOfReactions; ++ir ) {
593             int index = target->reactions[ir].    593             int index = target->reactions[ir].thresholdGroupIndex;
594                                                   594 
595             if( index > -1 ) {                    595             if( index > -1 ) {
596                 double xSec = target->reaction    596                 double xSec = target->reactions[ir].thresholdGroupedDeltaCrossSection +
597                         ptwX_getPointAtIndex_U    597                         ptwX_getPointAtIndex_Unsafely( target->crossSectionGroupedForSampling, index );
598                                                   598 
599                 ptwX_setPointAtIndex( target->    599                 ptwX_setPointAtIndex( target->crossSectionGroupedForSampling, index, xSec );
600             }                                     600             }
601         }                                         601         }
602     }                                             602     }
603     target->crossSectionGrouped = totalGrouped    603     target->crossSectionGrouped = totalGroupedCrossSection;
604     totalGroupedCrossSection = NULL;              604     totalGroupedCrossSection = NULL;
605                                                   605 
606     return( 0 );                                  606     return( 0 );
607                                                   607 
608 err:                                              608 err:
609     ptwX_free( totalGroupedCrossSection );        609     ptwX_free( totalGroupedCrossSection );
610     target->crossSectionGroupedForSampling = p    610     target->crossSectionGroupedForSampling = ptwX_free( target->crossSectionGroupedForSampling );
611     return( 1 );                                  611     return( 1 );
612 }                                                 612 }
613                                                   613 
614 #if defined __cplusplus                           614 #if defined __cplusplus
615 }                                                 615 }
616 #endif                                            616 #endif
617                                                   617