336{
337
338
339
343
344 G4bool findThermalElement =
false;
347 for (
G4int i = 0; i <
n ; ++i )
348 {
350
351 if ( aNucleus.GetZ_asInt() == (
G4int)(theElement->
GetZ() + 0.5 ) )
352 {
353
354 if ( getTS_ID( nullptr , theElement ) != -1 )
355 {
356 ielement = getTS_ID( nullptr , theElement );
357 findThermalElement = true;
358 break;
359 }
360 else if ( getTS_ID( theMaterial , theElement ) != -1 )
361 {
362 ielement = getTS_ID( theMaterial , theElement );
363 findThermalElement = true;
364 break;
365 }
366 }
367 }
368
369 if ( findThermalElement == true )
370 {
371
372
377
379 if ( random <= inelastic/total )
380 {
381
382
383 std::vector<G4double> v_temp;
384 v_temp.clear();
385 for (auto it = inelasticFSs->find( ielement )->second->cbegin();
386 it != inelasticFSs->find( ielement )->second->cend() ; ++it )
387 {
388 v_temp.push_back( it->first );
389 }
390
391 std::pair < G4double , G4double > tempLH = find_LH ( aTemp , &v_temp );
392
393
394
395 std::vector< E_P_E_isoAng* >* vNEP_EPM_TL = nullptr;
396 std::vector< E_P_E_isoAng* >* vNEP_EPM_TH = nullptr;
397
398 if ( tempLH.first != 0.0 && tempLH.second != 0.0 )
399 {
400 vNEP_EPM_TL = inelasticFSs->find( ielement )->second->find ( tempLH.first/kelvin )->second;
401 vNEP_EPM_TH = inelasticFSs->find( ielement )->second->find ( tempLH.second/kelvin )->second;
402 }
403 else if ( tempLH.first == 0.0 )
404 {
405 auto itm = inelasticFSs->find( ielement )->second->cbegin();
406 vNEP_EPM_TL = itm->second;
407 ++itm;
408 vNEP_EPM_TH = itm->second;
409 tempLH.first = tempLH.second;
410 tempLH.second = itm->first;
411 }
412 else if ( tempLH.second == 0.0 )
413 {
414 auto itm = inelasticFSs->find( ielement )->second->cend();
415 --itm;
416 vNEP_EPM_TH = itm->second;
417 --itm;
418 vNEP_EPM_TL = itm->second;
419 tempLH.second = tempLH.first;
420 tempLH.first = itm->first;
421 }
422
424
425
426
427 std::pair< G4double , G4double > secondaryParam;
429 if ( rand_temp < (aTemp-tempLH.first)/(tempLH.second - tempLH.first) )
430 secondaryParam = sample_inelastic_E_mu( aTrack.
GetKineticEnergy() , vNEP_EPM_TH );
431 else
432 secondaryParam = sample_inelastic_E_mu( aTrack.
GetKineticEnergy() , vNEP_EPM_TL );
433
434 sE = secondaryParam.first;
435 mu = secondaryParam.second;
436
437
440 G4double sint= std::sqrt ( 1 - mu*mu );
442 }
443 else if ( random <= ( inelastic + theXSection->
GetCoherentCrossSection( dp , theElement , theMaterial ) ) / total )
444 {
445
446
448
449
450 std::vector<G4double> v_temp;
451 v_temp.clear();
452 for (auto it = coherentFSs->find(ielement)->second->cbegin();
453 it != coherentFSs->find(ielement)->second->cend(); ++it)
454 {
455 v_temp.push_back( it->first );
456 }
457
458
459 std::pair < G4double , G4double > tempLH = find_LH ( aTemp , &v_temp );
460
461
462
463
464 std::vector< std::pair< G4double , G4double >* >* pvE_p_TL = nullptr;
465 std::vector< std::pair< G4double , G4double >* >* pvE_p_TH = nullptr;
466
467 if ( tempLH.first != 0.0 && tempLH.second != 0.0 )
468 {
469 pvE_p_TL = coherentFSs->find( ielement )->second->find ( tempLH.first/kelvin )->second;
470 pvE_p_TH = coherentFSs->find( ielement )->second->find ( tempLH.first/kelvin )->second;
471 }
472 else if ( tempLH.first == 0.0 )
473 {
474 pvE_p_TL = coherentFSs->find( ielement )->second->find ( v_temp[ 0 ] )->second;
475 pvE_p_TH = coherentFSs->find( ielement )->second->find ( v_temp[ 1 ] )->second;
476 tempLH.first = tempLH.second;
477 tempLH.second = v_temp[ 1 ];
478 }
479 else if ( tempLH.second == 0.0 )
480 {
481 pvE_p_TH = coherentFSs->find( ielement )->second->find ( v_temp.back() )->second;
482 auto itv = v_temp.cend();
483 --itv;
484 --itv;
485 pvE_p_TL = coherentFSs->find( ielement )->second->find ( *itv )->second;
486 tempLH.second = tempLH.first;
487 tempLH.first = *itv;
488 }
489 else
490 {
491
492 throw G4HadronicException(__FILE__, __LINE__,
"A problem is found in Thermal Scattering Data! Unexpected temperature values in data");
493 }
494
495 std::vector< G4double > vE_T;
496 std::vector< G4double > vp_T;
497
499
500
501 std::vector< std::pair< G4double , G4double >* >* pvE_p_T_sampled;
503 if ( rand_temp < (aTemp-tempLH.first)/(tempLH.second - tempLH.first) )
504 pvE_p_T_sampled = pvE_p_TH;
505 else
506 pvE_p_T_sampled = pvE_p_TL;
507
508
509 for (
G4int i=0 ; i < n1 ; ++i )
510 {
511 vE_T.push_back ( (*pvE_p_T_sampled)[i]->first );
512 vp_T.push_back ( (*pvE_p_T_sampled)[i]->second );
513 }
514
516 for (
G4int i = 1 ; i < n1 ; ++i )
517 {
518 if ( E/eV < vE_T[ i ] )
519 {
520 j = i-1;
521 break;
522 }
523 }
524
526
528 for (
G4int i = 0 ; i <= j ; ++i )
529 {
530 G4double Pi = vp_T[ i ] / vp_T[ j ];
531 if ( rand_for_mu < Pi )
532 {
533 k = i;
534 break;
535 }
536 }
537
539
541
542 if ( mu < -1.0 ) mu = -1.0;
543
546 G4double sint= std::sqrt ( 1 - mu*mu );
548 }
549 else
550 {
551
552
553
554 std::vector<G4double> v_temp;
555 v_temp.clear();
556 for (auto it = incoherentFSs->find(ielement)->second->cbegin();
557 it != incoherentFSs->find(ielement)->second->cend(); ++it)
558 {
559 v_temp.push_back( it->first );
560 }
561
562
563 std::pair < G4double , G4double > tempLH = find_LH ( aTemp , &v_temp );
564
565
566
567
568
571
572 if ( tempLH.first != 0.0 && tempLH.second != 0.0 ) {
573
574 anEPM_TL_E = create_E_isoAng_from_energy ( aTrack.
GetKineticEnergy() , incoherentFSs->find( ielement )->second->find ( tempLH.first/kelvin )->second );
575 anEPM_TH_E = create_E_isoAng_from_energy ( aTrack.
GetKineticEnergy() , incoherentFSs->find( ielement )->second->find ( tempLH.second/kelvin )->second );
576 } else if ( tempLH.first == 0.0 ) {
577
578 anEPM_TL_E = create_E_isoAng_from_energy ( aTrack.
GetKineticEnergy() , incoherentFSs->find( ielement )->second->find ( v_temp[ 0 ] )->second );
579 anEPM_TH_E = create_E_isoAng_from_energy ( aTrack.
GetKineticEnergy() , incoherentFSs->find( ielement )->second->find ( v_temp[ 1 ] )->second );
580 tempLH.first = tempLH.second;
581 tempLH.second = v_temp[ 1 ];
582 } else if ( tempLH.second == 0.0 ) {
583
584 anEPM_TH_E = create_E_isoAng_from_energy ( aTrack.
GetKineticEnergy() , incoherentFSs->find( ielement )->second->find ( v_temp.back() )->second );
585 auto itv = v_temp.cend();
586 --itv;
587 --itv;
588 anEPM_TL_E = create_E_isoAng_from_energy ( aTrack.
GetKineticEnergy() , incoherentFSs->find( ielement )->second->find ( *itv )->second );
589 tempLH.second = tempLH.first;
590 tempLH.first = *itv;
591 }
592
593
595
596
599 if ( rand_temp < (aTemp-tempLH.first)/(tempLH.second - tempLH.first) )
600 anEPM_T_E_sampled = anEPM_TH_E;
601 else
602 anEPM_T_E_sampled = anEPM_TL_E;
603
604 mu = getMu ( &anEPM_T_E_sampled );
605
606
609 G4double sint= std::sqrt ( 1 - mu*mu );
611 }
612 delete dp;
613
615 }
616 else
617 {
618
619
621 }
622}
void SetEnergyChange(G4double anEnergy)
void SetMomentumChange(const G4ThreeVector &aV)
const G4Material * GetMaterial() const
const G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
const G4LorentzVector & Get4Momentum() const
G4HadFinalState theParticleChange
G4double GetTemperature() const
const G4Element * GetElement(G4int iel) const
size_t GetNumberOfElements() const
G4double GetCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
G4double GetCoherentCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
G4double GetInelasticCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &aTargetNucleus)
G4double total(Particle const *const p1, Particle const *const p2)