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