306{
307
308
312
313 G4bool findThermalElement =
false;
316 for (
G4int i = 0; i <
n; ++i) {
318
319 if (aNucleus.GetZ_asInt() == (
G4int)(theElement->
GetZ() + 0.5)) {
320
321 if (getTS_ID(nullptr, theElement) != -1) {
322 ielement = getTS_ID(nullptr, theElement);
323 findThermalElement = true;
324 break;
325 }
326 if (getTS_ID(theMaterial, theElement) != -1) {
327 ielement = getTS_ID(theMaterial, theElement);
328 findThermalElement = true;
329 break;
330 }
331 }
332 }
333
334 if (findThermalElement) {
335
340
342 if (random <= inelastic / total) {
343
344
345 std::vector<G4double> v_temp;
346 v_temp.clear();
347 for (auto it = inelasticFSs->find(ielement)->second->cbegin();
348 it != inelasticFSs->find(ielement)->second->cend(); ++it)
349 {
350 v_temp.push_back(it->first);
351 }
352
353 std::pair<G4double, G4double> tempLH = find_LH(aTemp, &v_temp);
354
355
356
357 std::vector<E_P_E_isoAng*>* vNEP_EPM_TL = nullptr;
358 std::vector<E_P_E_isoAng*>* vNEP_EPM_TH = nullptr;
359
360 if (tempLH.first != 0.0 && tempLH.second != 0.0) {
361 vNEP_EPM_TL = inelasticFSs->find(ielement)->second->find(tempLH.first / kelvin)->second;
362 vNEP_EPM_TH = inelasticFSs->find(ielement)->second->find(tempLH.second / kelvin)->second;
363 }
364 else if (tempLH.first == 0.0) {
365 auto itm = inelasticFSs->find(ielement)->second->cbegin();
366 vNEP_EPM_TL = itm->second;
367 ++itm;
368 vNEP_EPM_TH = itm->second;
369 tempLH.first = tempLH.second;
370 tempLH.second = itm->first;
371 }
372 else if (tempLH.second == 0.0) {
373 auto itm = inelasticFSs->find(ielement)->second->cend();
374 --itm;
375 vNEP_EPM_TH = itm->second;
376 --itm;
377 vNEP_EPM_TL = itm->second;
378 tempLH.second = tempLH.first;
379 tempLH.first = itm->first;
380 }
381
383
384
385
386 std::pair<G4double, G4double> secondaryParam;
388 if (rand_temp < (aTemp - tempLH.first) / (tempLH.second - tempLH.first))
389 secondaryParam = sample_inelastic_E_mu(aTrack.
GetKineticEnergy(), vNEP_EPM_TH);
390 else
391 secondaryParam = sample_inelastic_E_mu(aTrack.
GetKineticEnergy(), vNEP_EPM_TL);
392
393 sE = secondaryParam.first;
394 mu = secondaryParam.second;
395
396
399 G4double sint = std::sqrt(1 - mu * mu);
401 }
402 else if (random
404 / total)
405 {
406
407
409
410
411 std::vector<G4double> v_temp;
412 v_temp.clear();
413 for (auto it = coherentFSs->find(ielement)->second->cbegin();
414 it != coherentFSs->find(ielement)->second->cend(); ++it)
415 {
416 v_temp.push_back(it->first);
417 }
418
419
420 std::pair<G4double, G4double> tempLH = find_LH(aTemp, &v_temp);
421
422
423
424
425 std::vector<std::pair<G4double, G4double>*>* pvE_p_TL = nullptr;
426 std::vector<std::pair<G4double, G4double>*>* pvE_p_TH = nullptr;
427
428 if (tempLH.first != 0.0 && tempLH.second != 0.0) {
429 pvE_p_TL = coherentFSs->find(ielement)->second->find(tempLH.first / kelvin)->second;
430 pvE_p_TH = coherentFSs->find(ielement)->second->find(tempLH.first / kelvin)->second;
431 }
432 else if (tempLH.first == 0.0) {
433 pvE_p_TL = coherentFSs->find(ielement)->second->find(v_temp[0])->second;
434 pvE_p_TH = coherentFSs->find(ielement)->second->find(v_temp[1])->second;
435 tempLH.first = tempLH.second;
436 tempLH.second = v_temp[1];
437 }
438 else if (tempLH.second == 0.0) {
439 pvE_p_TH = coherentFSs->find(ielement)->second->find(v_temp.back())->second;
440 auto itv = v_temp.cend();
441 --itv;
442 --itv;
443 pvE_p_TL = coherentFSs->find(ielement)->second->find(*itv)->second;
444 tempLH.second = tempLH.first;
445 tempLH.first = *itv;
446 }
447 else {
448
450 __FILE__, __LINE__,
451 "A problem is found in Thermal Scattering Data! Unexpected temperature values in data");
452 }
453
454 std::vector<G4double> vE_T;
455 std::vector<G4double> vp_T;
456
457 auto n1 = (
G4int)pvE_p_TL->size();
458
459
460 std::vector<std::pair<G4double, G4double>*>* pvE_p_T_sampled;
462 if (rand_temp < (aTemp - tempLH.first) / (tempLH.second - tempLH.first))
463 pvE_p_T_sampled = pvE_p_TH;
464 else
465 pvE_p_T_sampled = pvE_p_TL;
466
467
468 for (
G4int i = 0; i < n1; ++i) {
469 vE_T.push_back((*pvE_p_T_sampled)[i]->first);
470 vp_T.push_back((*pvE_p_T_sampled)[i]->second);
471 }
472
474 for (
G4int i = 1; i < n1; ++i) {
475 if (E / eV < vE_T[i]) {
476 j = i - 1;
477 break;
478 }
479 }
480
482
484 for (
G4int i = 0; i <= j; ++i) {
486 if (rand_for_mu < Pi) {
487 k = i;
488 break;
489 }
490 }
491
493
494 G4double mu = 1 - 2 * Ei / (E / eV);
495
496 if (mu < -1.0) mu = -1.0;
497
500 G4double sint = std::sqrt(1 - mu * mu);
502 }
503 else {
504
505
506
507 std::vector<G4double> v_temp;
508 v_temp.clear();
509 for (auto it = incoherentFSs->find(ielement)->second->cbegin();
510 it != incoherentFSs->find(ielement)->second->cend(); ++it)
511 {
512 v_temp.push_back(it->first);
513 }
514
515
516 std::pair<G4double, G4double> tempLH = find_LH(aTemp, &v_temp);
517
518
519
520
521
524
525 if (tempLH.first != 0.0 && tempLH.second != 0.0) {
526
527 anEPM_TL_E = create_E_isoAng_from_energy(
529 incoherentFSs->find(ielement)->second->find(tempLH.first / kelvin)->second);
530 anEPM_TH_E = create_E_isoAng_from_energy(
532 incoherentFSs->find(ielement)->second->find(tempLH.second / kelvin)->second);
533 }
534 else if (tempLH.first == 0.0) {
535
536 anEPM_TL_E = create_E_isoAng_from_energy(
538 incoherentFSs->find(ielement)->second->find(v_temp[0])->second);
539 anEPM_TH_E = create_E_isoAng_from_energy(
541 incoherentFSs->find(ielement)->second->find(v_temp[1])->second);
542 tempLH.first = tempLH.second;
543 tempLH.second = v_temp[1];
544 }
545 else if (tempLH.second == 0.0) {
546
547 anEPM_TH_E = create_E_isoAng_from_energy(
549 incoherentFSs->find(ielement)->second->find(v_temp.back())->second);
550 auto itv = v_temp.cend();
551 --itv;
552 --itv;
553 anEPM_TL_E = create_E_isoAng_from_energy(
554 aTrack.
GetKineticEnergy(), incoherentFSs->find(ielement)->second->find(*itv)->second);
555 tempLH.second = tempLH.first;
556 tempLH.first = *itv;
557 }
558
559
561
562
565 if (rand_temp < (aTemp - tempLH.first) / (tempLH.second - tempLH.first))
566 anEPM_T_E_sampled = anEPM_TH_E;
567 else
568 anEPM_T_E_sampled = anEPM_TL_E;
569
570 mu = getMu(&anEPM_T_E_sampled);
571
572
575 G4double sint = std::sqrt(1 - mu * mu);
577 }
578 delete dp;
579
581 }
582
583
585 true);
586}
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
std::size_t GetNumberOfElements() const
G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &aTargetNucleus) override
G4double GetCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
G4double GetCoherentCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
G4double GetInelasticCrossSection(const G4DynamicParticle *, const G4Element *, const G4Material *)
G4double total(Particle const *const p1, Particle const *const p2)