Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 /* 27 # <<BEGIN-copyright>> 28 # <<END-copyright>> 29 */ 30 #include <iostream> 31 #include <stdlib.h> 32 #include <cmath> 33 34 #include "G4GIDI_target.hh" 35 #include "G4GIDI_mass.hh" 36 #include "G4GIDI_Misc.hh" 37 38 using namespace std; 39 using namespace GIDI; 40 41 /* 42 ********************************************** 43 */ 44 G4GIDI_target::G4GIDI_target( char const *file 45 46 init( fileName ); 47 } 48 /* 49 ********************************************** 50 */ 51 G4GIDI_target::G4GIDI_target( string const &fi 52 53 init( fileName.c_str( ) ); 54 } 55 /* 56 ********************************************** 57 */ 58 void G4GIDI_target::init( char const *fileName 59 60 int i, j, n, *p, *q, ir; 61 MCGIDI_reaction *reaction; 62 63 smr_initialize( &smr, smr_status_Ok, 1 ); 64 sourceFilename = fileName; 65 target = MCGIDI_target_newRead( &smr, file 66 if( !smr_isOk( &smr ) ) { 67 smr_print( &smr, 1 ); 68 throw 1; 69 } 70 projectilesPOPID = target->projectilePOP-> 71 name = target->targetPOP->name; 72 mass = G4GIDI_targetMass( target->targetPO 73 equalProbableBinSampleMethod = "constant"; 74 elasticIndices = NULL; 75 nElasticIndices = nCaptureIndices = nFissi 76 77 if( ( n = MCGIDI_target_numberOfReactions( 78 if( ( p = elasticIndices = (int *) smr 79 smr_print( &smr, 1 ); 80 throw 1; 81 } 82 for( i = 0; i < n; i++ ) { /* Fin 83 reaction = MCGIDI_target_heated_ge 84 if( MCGIDI_reaction_getENDF_MTNumb 85 *(p++) = i; 86 nElasticIndices++; 87 } 88 } 89 captureIndices = p; 90 for( i = 0; i < n; i++ ) { /* Fin 91 reaction = MCGIDI_target_heated_ge 92 if( MCGIDI_reaction_getENDF_MTNumb 93 *(p++) = i; 94 nCaptureIndices++; 95 } 96 } 97 98 fissionIndices = p; 99 for( i = 0; i < n; i++ ) { /* Fin 100 reaction = MCGIDI_target_heated_ge 101 ir = MCGIDI_reaction_getENDF_MTNum 102 if( ( ir != 18 ) && ( ir != 19 ) & 103 *(p++) = i; 104 nFissionIndices++; 105 } 106 othersIndices = p; 107 for( i = 0; i < n; i++ ) { /* Fin 108 for( j = 0, q = elasticIndices; j 109 if( j < nElasticIndices ) continue 110 for( j = 0, q = captureIndices; j 111 if( j < nCaptureIndices ) continue 112 for( j = 0, q = fissionIndices; j 113 if( j < nFissionIndices ) continue 114 *p = i; 115 p++; 116 nOthersIndices++; 117 } 118 #if 0 119 printf( "elastic %d: ", nElasticIndices ); 120 for( i = 0; i < nElasticIndices; i++ ) printf( 121 printf( "\ncapture %d: ", nCaptureIndices ); 122 for( i = 0; i < nCaptureIndices; i++ ) printf( 123 printf( "\nfission %d: ", nFissionIndices ); 124 for( i = 0; i < nFissionIndices; i++ ) printf( 125 printf( "\nothers %d: ", nOthersIndices ); 126 for( i = 0; i < nOthersIndices; i++ ) printf( 127 printf( "\n" ); 128 #endif 129 } 130 } 131 /* 132 ********************************************** 133 */ 134 G4GIDI_target::~G4GIDI_target( ) { 135 136 MCGIDI_target_free( &smr, target ); 137 smr_freeMemory( (void **) &elasticIndices 138 smr_release( &smr ); 139 } 140 /* 141 ********************************************** 142 */ 143 string *G4GIDI_target::getName( void ) { retur 144 /* 145 ********************************************** 146 */ 147 string *G4GIDI_target::getFilename( void ) { r 148 /* 149 ********************************************** 150 */ 151 int G4GIDI_target::getZ( void ) { 152 153 return( target->targetPOP->Z ); 154 } 155 /* 156 ********************************************** 157 */ 158 int G4GIDI_target::getA( void ) { 159 160 return( target->targetPOP->A ); 161 } 162 /* 163 ********************************************** 164 */ 165 int G4GIDI_target::getM( void ) { 166 167 return( target->targetPOP->m ); 168 } 169 /* 170 ********************************************** 171 */ 172 double G4GIDI_target::getMass( void ) { 173 174 return( mass ); 175 } 176 /* 177 ********************************************** 178 */ 179 int G4GIDI_target::getTemperatures( double *te 180 181 return( MCGIDI_target_getTemperatures( &sm 182 } 183 /* 184 ********************************************** 185 */ 186 int G4GIDI_target::readTemperature( int index 187 188 return( MCGIDI_target_readHeatedTarget( &s 189 } 190 /* 191 ********************************************** 192 */ 193 string G4GIDI_target::getEqualProbableBinSampl 194 195 return( equalProbableBinSampleMethod ); 196 } 197 /* 198 ********************************************** 199 */ 200 int G4GIDI_target::setEqualProbableBinSampleMe 201 202 if( method == "constant" ) { 203 equalProbableBinSampleMethod = "consta 204 if( method == "linear" ) { 205 equalProbableBinSampleMethod = "linear 206 else { 207 return( 1 ); 208 } 209 return( 0 ); 210 } 211 /* 212 ********************************************** 213 */ 214 int G4GIDI_target::getNumberOfChannels( void ) 215 216 return( MCGIDI_target_numberOfReactions( & 217 } 218 /* 219 ********************************************** 220 */ 221 int G4GIDI_target::getNumberOfProductionChanne 222 223 return( MCGIDI_target_numberOfProductionRe 224 } 225 /* 226 ********************************************** 227 */ 228 channelID G4GIDI_target::getChannelsID( int ch 229 230 MCGIDI_reaction *reaction; 231 232 if( ( reaction = MCGIDI_target_heated_getR 233 smr_print( &smr, 1 ); 234 throw 1; 235 } 236 return( string( reaction->outputChannelStr 237 } 238 /* 239 ********************************************** 240 */ 241 vector<channelID> *G4GIDI_target::getChannelID 242 243 int i, n = MCGIDI_target_numberOfReactions 244 MCGIDI_reaction *reaction; 245 vector<channelID> *listOfChannels; 246 247 listOfChannels = new vector<channelID>( n 248 for( i = 0; i < n; i++ ) { 249 reaction = MCGIDI_target_heated_getRea 250 (*listOfChannels)[i] = reaction->outpu 251 } 252 return( listOfChannels ); 253 } 254 /* 255 ********************************************** 256 */ 257 vector<channelID> *G4GIDI_target::getProductio 258 259 return( NULL ); 260 } 261 /* 262 ********************************************** 263 */ 264 double G4GIDI_target::getTotalCrossSectionAtE( 265 266 MCGIDI_quantitiesLookupModes mode( project 267 268 mode.setProjectileEnergy( e_in ); 269 mode.setCrossSectionMode( MCGIDI_quantityL 270 mode.setTemperature( temperature ); 271 272 return( MCGIDI_target_getTotalCrossSection 273 } 274 /* 275 ********************************************** 276 */ 277 double G4GIDI_target::getElasticCrossSectionAt 278 279 return( sumChannelCrossSectionAtE( nElasti 280 } 281 /* 282 ********************************************** 283 */ 284 double G4GIDI_target::getCaptureCrossSectionAt 285 286 return( sumChannelCrossSectionAtE( nCaptur 287 } 288 /* 289 ********************************************** 290 */ 291 double G4GIDI_target::getFissionCrossSectionAt 292 293 return( sumChannelCrossSectionAtE( nFissio 294 } 295 /* 296 ********************************************** 297 */ 298 double G4GIDI_target::getOthersCrossSectionAtE 299 300 return( sumChannelCrossSectionAtE( nOthers 301 } 302 /* 303 ********************************************** 304 */ 305 double G4GIDI_target::sumChannelCrossSectionAt 306 307 int i; 308 double xsec = 0.; 309 MCGIDI_quantitiesLookupModes mode( project 310 311 mode.setProjectileEnergy( e_in ); 312 mode.setCrossSectionMode( MCGIDI_quantityL 313 mode.setTemperature( temperature ); 314 315 for( i = 0; i < nIndices; i++ ) 316 xsec += MCGIDI_target_getIndexReaction 317 return( xsec ); 318 } 319 /* 320 ********************************************** 321 */ 322 int G4GIDI_target::sampleChannelCrossSectionAt 323 double (*rng)( void * ), void *rngStat 324 325 int i; 326 double xsec = 0., rxsec = sumChannelCrossS 327 MCGIDI_quantitiesLookupModes mode( project 328 329 mode.setProjectileEnergy( e_in ); 330 mode.setCrossSectionMode( MCGIDI_quantityL 331 mode.setTemperature( temperature ); 332 333 for( i = 0; i < nIndices - 1; i++ ) { 334 xsec += MCGIDI_target_getIndexReaction 335 if( xsec >= rxsec ) break; 336 } 337 return( indices[i] ); 338 } 339 /* 340 ********************************************** 341 */ 342 double G4GIDI_target::getElasticFinalState( do 343 344 MCGIDI_decaySamplingInfo decaySamplingInfo 345 MCGIDI_reaction *reaction = MCGIDI_target_ 346 MCGIDI_product *product; 347 MCGIDI_quantitiesLookupModes mode( project 348 349 if( ( product = MCGIDI_outputChannel_getPr 350 smr_print( &smr, 1 ); 351 throw 1; 352 } 353 354 mode.setProjectileEnergy( e_in ); 355 mode.setCrossSectionMode( MCGIDI_quantityL 356 mode.setTemperature( temperature ); 357 358 decaySamplingInfo.isVelocity = 0; 359 decaySamplingInfo.rng = rng; 360 decaySamplingInfo.rngState = rngState; 361 if( MCGIDI_product_sampleMu( &smr, product 362 smr_print( &smr, 1 ); 363 throw 1; 364 } 365 366 return( decaySamplingInfo.mu ); 367 } 368 /* 369 ********************************************** 370 */ 371 vector<G4GIDI_Product> *G4GIDI_target::getCapt 372 373 return( getFinalState( nCaptureIndices, ca 374 } 375 /* 376 ********************************************** 377 */ 378 vector<G4GIDI_Product> *G4GIDI_target::getFiss 379 380 return( getFinalState( nFissionIndices, fi 381 } 382 /* 383 ********************************************** 384 */ 385 vector<G4GIDI_Product> *G4GIDI_target::getOthe 386 387 return( getFinalState( nOthersIndices, oth 388 } 389 /* 390 ********************************************** 391 */ 392 vector<G4GIDI_Product> *G4GIDI_target::getFina 393 double (*rng)( void * ), void *rngState ) 394 395 int index = 0, i, n; 396 vector<G4GIDI_Product> *products = NULL; 397 MCGIDI_decaySamplingInfo decaySamplingInfo 398 MCGIDI_sampledProductsDatas sampledProduct 399 MCGIDI_sampledProductsData *productData; 400 MCGIDI_quantitiesLookupModes mode( project 401 402 decaySamplingInfo.isVelocity = 0; 403 decaySamplingInfo.rng = rng; 404 decaySamplingInfo.rngState = rngState; 405 406 if( nIndices == 0 ) { 407 return( NULL ); } 408 else { 409 if( nIndices == 1 ) { 410 index = indices[0]; } 411 else { 412 index = sampleChannelCrossSectionA 413 } 414 } 415 416 MCGIDI_sampledProducts_initialize( &smr, & 417 if( !smr_isOk( &smr ) ) { 418 smr_print( &smr, 1 ); 419 throw 1; 420 } 421 422 mode.setProjectileEnergy( e_in ); 423 mode.setCrossSectionMode( MCGIDI_quantityL 424 mode.setTemperature( temperature ); 425 426 n = MCGIDI_target_heated_sampleIndexReacti 427 &decaySamplingInfo, &sampledProduc 428 if( !smr_isOk( &smr ) ) { 429 smr_print( &smr, 1 ); 430 throw 1; 431 } 432 if( n > 0 ) { 433 if( ( products = new vector<G4GIDI_Pro 434 for( i = 0; i < n; i++ ) { 435 productData = &(sampledProduct 436 (*products)[i].A = productData 437 (*products)[i].Z = productData 438 (*products)[i].m = productData 439 (*products)[i].kineticEnergy = 440 (*products)[i].px = productDat 441 (*products)[i].py = productDat 442 (*products)[i].pz = productDat 443 (*products)[i].birthTimeSec = produc 444 } 445 } 446 } 447 MCGIDI_sampledProducts_release( &smr, &sam 448 449 return( products ); 450 } 451 /* 452 ********************************************** 453 */ 454 double G4GIDI_target::getReactionsThreshold( i 455 456 return( MCGIDI_target_heated_getReactionsT 457 } 458 /* 459 ********************************************** 460 */ 461 double G4GIDI_target::getReactionsDomain( int 462 463 return( MCGIDI_target_heated_getReactionsD 464 } 465