74void G4ParticleHPThermalScattering::clearCurrentFSData()
76 if (incoherentFSs !=
nullptr) {
77 for (
auto it = incoherentFSs->cbegin(); it != incoherentFSs->cend(); ++it) {
78 for (
auto itt = it->second->cbegin(); itt != it->second->cend(); ++itt) {
79 for (
auto ittt = itt->second->cbegin(); ittt != itt->second->cend(); ++ittt) {
88 if (coherentFSs !=
nullptr) {
89 for (
auto it = coherentFSs->cbegin(); it != coherentFSs->cend(); ++it) {
90 for (
auto itt = it->second->cbegin(); itt != it->second->cend(); ++itt) {
91 for (
auto ittt = itt->second->cbegin(); ittt != itt->second->cend(); ++ittt) {
100 if (inelasticFSs !=
nullptr) {
101 for (
auto it = inelasticFSs->cbegin(); it != inelasticFSs->cend(); ++it) {
102 for (
auto itt = it->second->cbegin(); itt != it->second->cend(); ++itt) {
103 for (
auto ittt = itt->second->cbegin(); ittt != itt->second->cend(); ++ittt) {
104 for (
auto it4 = (*ittt)->vE_isoAngle.cbegin(); it4 != (*ittt)->vE_isoAngle.cend(); ++it4)
116 incoherentFSs =
nullptr;
117 coherentFSs =
nullptr;
118 inelasticFSs =
nullptr;
124 theHPElastic->BuildPhysicsTable(particle);
127std::map<G4double, std::vector<std::pair<G4double, G4double>*>*>*
128G4ParticleHPThermalScattering::readACoherentFSDATA(
const G4String& name)
130 auto aCoherentFSDATA =
new std::map<G4double, std::vector<std::pair<G4double, G4double>*>*>;
132 std::istringstream theChannel(std::ios::in);
135 std::vector<G4double> vBraggE;
138 while (theChannel >> dummy)
143 auto anBragE_P =
new std::vector<std::pair<G4double, G4double>*>;
147 for (
G4int i = 0; i < n; ++i) {
150 if (aCoherentFSDATA->empty()) {
152 vBraggE.push_back(Ei);
158 anBragE_P->push_back(
new std::pair<G4double, G4double>(Ei, Pi));
160 aCoherentFSDATA->insert(
161 std::pair<
G4double, std::vector<std::pair<G4double, G4double>*>*>(temp, anBragE_P));
163 return aCoherentFSDATA;
166std::map<G4double, std::vector<E_P_E_isoAng*>*>*
167G4ParticleHPThermalScattering::readAnInelasticFSDATA(
const G4String& name)
169 auto anT_E_P_E_isoAng =
new std::map<G4double, std::vector<E_P_E_isoAng*>*>;
171 std::istringstream theChannel(std::ios::in);
175 while (theChannel >> dummy)
180 auto vE_P_E_isoAng =
new std::vector<E_P_E_isoAng*>;
183 for (
G4int i = 0; i <
n; ++i) {
184 vE_P_E_isoAng->push_back(readAnE_P_E_isoAng(&theChannel));
186 anT_E_P_E_isoAng->insert(std::pair<
G4double, std::vector<E_P_E_isoAng*>*>(temp, vE_P_E_isoAng));
189 return anT_E_P_E_isoAng;
193G4ParticleHPThermalScattering::readAnE_P_E_isoAng(std::istream* file)
195 auto aData =
new E_P_E_isoAng;
202 aData->energy =
energy * eV;
208 for (
G4int i = 0; i < aData->n; ++i) {
210 auto anE_isoAng =
new E_isoAng;
211 aData->vE_isoAngle.push_back(anE_isoAng);
213 anE_isoAng->energy =
energy * eV;
214 anE_isoAng->n = nl - 2;
215 anE_isoAng->isoAngle.resize(anE_isoAng->n);
217 aData->prob.push_back(prob);
220 for (
G4int j = 0; j < anE_isoAng->n; ++j) {
223 anE_isoAng->isoAngle[j] = x;
229 aData->secondary_energy_cdf.push_back(0.);
230 for (
G4int i = 0; i < aData->n - 1; ++i) {
231 G4double E_L = aData->vE_isoAngle[i]->energy / eV;
232 G4double E_H = aData->vE_isoAngle[i + 1]->energy / eV;
234 G4double pdf = (aData->prob[i] + aData->prob[i + 1]) / 2. * dE;
236 aData->secondary_energy_cdf.push_back(total);
237 aData->secondary_energy_pdf.push_back(pdf);
238 aData->secondary_energy_value.push_back(E_L);
241 aData->sum_of_probXdEs =
total;
245 aData->secondary_energy_cdf_size = (
G4int)aData->secondary_energy_cdf.size();
246 for (
G4int i = 0; i < aData->secondary_energy_cdf_size; ++i) {
247 aData->secondary_energy_cdf[i] *= norm;
253std::map<G4double, std::vector<E_isoAng*>*>*
254G4ParticleHPThermalScattering::readAnIncoherentFSDATA(
const G4String& name)
256 auto T_E =
new std::map<G4double, std::vector<E_isoAng*>*>;
259 std::istringstream theChannel(std::ios::in);
263 while (theChannel >> dummy)
268 auto vE_isoAng =
new std::vector<E_isoAng*>;
271 for (
G4int i = 0; i <
n; i++)
272 vE_isoAng->push_back(readAnE_isoAng(&theChannel));
273 T_E->insert(std::pair<
G4double, std::vector<E_isoAng*>*>(temp, vE_isoAng));
280E_isoAng* G4ParticleHPThermalScattering::readAnE_isoAng(std::istream* file)
282 auto aData =
new E_isoAng;
293 aData->energy =
energy * eV;
295 aData->isoAngle.resize(n);
299 for (
G4int i = 0; i < aData->n; i++)
300 *file >> aData->isoAngle[i];
314 G4bool findThermalElement =
false;
317 for (
G4int i = 0; i < n; ++i) {
322 if (getTS_ID(
nullptr, theElement) != -1) {
323 ielement = getTS_ID(
nullptr, theElement);
324 findThermalElement =
true;
327 if (getTS_ID(theMaterial, theElement) != -1) {
328 ielement = getTS_ID(theMaterial, theElement);
329 findThermalElement =
true;
335 if (findThermalElement) {
339 G4double total = theXSection->GetCrossSection(dp, theElement, theMaterial);
340 G4double inelastic = theXSection->GetInelasticCrossSection(dp, theElement, theMaterial);
342 auto inelELM = inelasticFSs->find(ielement);
343 G4bool mayBeInel = (inelELM != inelasticFSs->end());
344 auto coheELM = coherentFSs->find(ielement);
345 G4bool mayBeCohe = (coheELM != coherentFSs->end());
346 auto incoELM = incoherentFSs->find(ielement);
347 G4bool mayBeInco = (incoELM != incoherentFSs->end());
350 if ((total*random <= inelastic && mayBeInel) || (!mayBeCohe && !mayBeInco)) {
353 std::vector<G4double> v_temp;
355 for (
auto it = inelELM->second->begin(); it != inelELM->second->end(); ++it)
357 v_temp.push_back(it->first);
360 std::pair<G4double, G4double> tempLH = find_LH(aTemp, &v_temp);
364 std::vector<E_P_E_isoAng*>* vNEP_EPM_TL =
nullptr;
365 std::vector<E_P_E_isoAng*>* vNEP_EPM_TH =
nullptr;
367 if (tempLH.first != 0.0 && tempLH.second != 0.0) {
368 vNEP_EPM_TL = inelELM->second->find(tempLH.first / kelvin)->second;
369 vNEP_EPM_TH = inelELM->second->find(tempLH.second / kelvin)->second;
371 else if (tempLH.first == 0.0) {
372 auto itm = inelELM->second->begin();
373 vNEP_EPM_TL = itm->second;
375 vNEP_EPM_TH = itm->second;
376 tempLH.first = tempLH.second;
377 tempLH.second = itm->first;
379 else if (tempLH.second == 0.0) {
380 auto itm = inelELM->second->end();
382 vNEP_EPM_TH = itm->second;
384 vNEP_EPM_TL = itm->second;
385 tempLH.second = tempLH.first;
386 tempLH.first = itm->first;
393 std::pair<G4double, G4double> secondaryParam;
395 if (rand_temp < (aTemp - tempLH.first) / (tempLH.second - tempLH.first))
396 secondaryParam = sample_inelastic_E_mu(aTrack.
GetKineticEnergy(), vNEP_EPM_TH);
398 secondaryParam = sample_inelastic_E_mu(aTrack.
GetKineticEnergy(), vNEP_EPM_TL);
400 sE = secondaryParam.first;
401 mu = secondaryParam.second;
406 G4double sint = std::sqrt(1 - mu * mu);
407 theParticleChange.SetMomentumChange(sint * std::cos(phi), sint * std::sin(phi), mu);
409 else if (mayBeCohe &&
410 (!mayBeInco || random*total
411 <= (inelastic + theXSection->GetCoherentCrossSection(dp, theElement, theMaterial))))
418 std::vector<G4double> v_temp;
420 for (
auto it = coheELM->second->begin(); it != coheELM->second->end(); ++it)
422 v_temp.push_back(it->first);
426 std::pair<G4double, G4double> tempLH = find_LH(aTemp, &v_temp);
431 std::vector<std::pair<G4double, G4double>*>* pvE_p_TL =
nullptr;
432 std::vector<std::pair<G4double, G4double>*>* pvE_p_TH =
nullptr;
434 if (tempLH.first != 0.0 && tempLH.second != 0.0) {
435 pvE_p_TL = coheELM->second->find(tempLH.first / kelvin)->second;
436 pvE_p_TH = coheELM->second->find(tempLH.first / kelvin)->second;
438 else if (tempLH.first == 0.0) {
439 pvE_p_TL = coheELM->second->find(v_temp[0])->second;
440 pvE_p_TH = coheELM->second->find(v_temp[1])->second;
441 tempLH.first = tempLH.second;
442 tempLH.second = v_temp[1];
444 else if (tempLH.second == 0.0) {
445 pvE_p_TH = coheELM->second->find(v_temp.back())->second;
446 auto itv = v_temp.cend();
449 pvE_p_TL = coheELM->second->find(*itv)->second;
450 tempLH.second = tempLH.first;
457 "A problem is found in Thermal Scattering Data! Unexpected temperature values in data");
460 std::vector<G4double> vE_T;
461 std::vector<G4double> vp_T;
463 auto n1 = (
G4int)pvE_p_TL->size();
466 std::vector<std::pair<G4double, G4double>*>* pvE_p_T_sampled;
468 if (rand_temp < (aTemp - tempLH.first) / (tempLH.second - tempLH.first))
469 pvE_p_T_sampled = pvE_p_TH;
471 pvE_p_T_sampled = pvE_p_TL;
474 for (
G4int i = 0; i < n1; ++i) {
475 vE_T.push_back((*pvE_p_T_sampled)[i]->first);
476 vp_T.push_back((*pvE_p_T_sampled)[i]->second);
480 for (
G4int i = 1; i < n1; ++i) {
481 if (E / eV < vE_T[i]) {
490 for (
G4int i = 0; i <= j; ++i) {
492 if (rand_for_mu < Pi) {
500 G4double mu = 1 - 2 * Ei / (E / eV);
502 if (mu < -1.0) mu = -1.0;
506 G4double sint = std::sqrt(1 - mu * mu);
507 theParticleChange.SetMomentumChange(sint * std::cos(phi), sint * std::sin(phi), mu);
509 else if (mayBeInco) {
513 std::vector<G4double> v_temp;
515 for (
auto it = incoELM->second->cbegin(); it != incoELM->second->cend(); ++it)
517 v_temp.push_back(it->first);
521 std::pair<G4double, G4double> tempLH = find_LH(aTemp, &v_temp);
530 if (tempLH.first != 0.0 && tempLH.second != 0.0) {
532 anEPM_TL_E = create_E_isoAng_from_energy(
534 incoELM->second->find(tempLH.first / kelvin)->second);
535 anEPM_TH_E = create_E_isoAng_from_energy(
537 incoELM->second->find(tempLH.second / kelvin)->second);
539 else if (tempLH.first == 0.0) {
541 anEPM_TL_E = create_E_isoAng_from_energy(
543 incoELM->second->find(v_temp[0])->second);
544 anEPM_TH_E = create_E_isoAng_from_energy(
546 incoELM->second->find(v_temp[1])->second);
547 tempLH.first = tempLH.second;
548 tempLH.second = v_temp[1];
550 else if (tempLH.second == 0.0) {
552 std::size_t nn = v_temp.size();
554 anEPM_TL_E = create_E_isoAng_from_energy(
556 incoELM->second->find(v_temp[nn - 2])->second);
557 anEPM_TH_E = create_E_isoAng_from_energy(
559 incoELM->second->find(v_temp.back())->second);
568 if (rand_temp < (aTemp - tempLH.first) / (tempLH.second - tempLH.first))
569 anEPM_T_E_sampled = std::move(anEPM_TH_E);
571 anEPM_T_E_sampled = std::move(anEPM_TL_E);
573 mu = getMu(&anEPM_T_E_sampled);
578 G4double sint = std::sqrt(1 - mu * mu);
579 theParticleChange.SetMomentumChange(sint * std::cos(phi), sint * std::sin(phi), mu);
587 return theHPElastic->ApplyYourself(aTrack, aNucleus,
598std::pair<G4double, G4int>
599G4ParticleHPThermalScattering::sample_inelastic_E(
G4double rndm1,
G4double rndm2,
607 && rndm1 < anE_P_E_isoAng->secondary_energy_cdf[i + 1])
615 G4double alpha = (sE_pdf_i1 - sE_pdf_i) / (sE_pdf_i1 + sE_pdf_i);
618 if (std::fabs(alpha) < 1E-8) {
622 G4double beta = 2 * sE_pdf_i / (sE_pdf_i1 + sE_pdf_i);
627 if (delta < 0 && std::fabs(delta) < 1.E-8) delta = 0;
629 lambda = -beta + std::sqrt(delta);
638 sE_value = sE_value_i +
lambda * (sE_value_i1 - sE_value_i);
644 return std::pair<G4double, G4int>(sE_value, i);
650std::pair<G4double, G4double>
651G4ParticleHPThermalScattering::sample_inelastic_E_mu(
G4double pE,
652 std::vector<E_P_E_isoAng*>* vNEP_EPM)
655 std::map<G4double, G4int> map_energy;
657 std::vector<G4double> v_energy;
660 for (
auto itv = vNEP_EPM->cbegin(); itv != vNEP_EPM->cend(); ++itv) {
661 v_energy.push_back((*itv)->energy);
662 map_energy.insert(std::pair<G4double, G4int>((*itv)->energy, i));
666 std::pair<G4double, G4double> energyLH = find_LH(pE, &v_energy);
668 std::vector<E_P_E_isoAng*> pE_P_E_isoAng_limit(2,
nullptr);
670 if (energyLH.first != 0.0 && energyLH.second != 0.0) {
671 auto u = map_energy.find(energyLH.first);
672 if (u != map_energy.end())
673 pE_P_E_isoAng_limit[0] = (*vNEP_EPM)[u->second];
674 auto w = map_energy.find(energyLH.second);
675 if (w != map_energy.end())
676 pE_P_E_isoAng_limit[1] = (*vNEP_EPM)[w->second];
678 else if (energyLH.first == 0.0) {
679 pE_P_E_isoAng_limit[0] = (*vNEP_EPM)[0];
680 pE_P_E_isoAng_limit[1] = (*vNEP_EPM)[1];
682 if (energyLH.second == 0.0) {
683 pE_P_E_isoAng_limit[1] = (*vNEP_EPM).back();
684 auto itv = vNEP_EPM->cend();
687 pE_P_E_isoAng_limit[0] = *itv;
691 const G4double deltalim = 1.e-6*CLHEP::eV;
694 G4double factor = (std::abs(e2 - e1) > deltalim) ? (e2 - pE)/(e2 - e1) : 0.0;
695 factor = std::min(factor, 1.0);
701 std::pair<G4double, G4int> sE_lower = sample_inelastic_E(rndm1, rndm2, pE_P_E_isoAng_limit[0]);
702 std::pair<G4double, G4int> sE_upper = sample_inelastic_E(rndm1, rndm2, pE_P_E_isoAng_limit[1]);
703 G4double sE = factor * sE_lower.first + (1 - factor) * sE_upper.first;
709 G4double mu_lower = getMu(rndm1, rndm2, pE_P_E_isoAng_limit[0]->vE_isoAngle[sE_lower.second]);
710 G4double mu_upper = getMu(rndm1, rndm2, pE_P_E_isoAng_limit[1]->vE_isoAngle[sE_upper.second]);
711 G4double mu = factor * mu_lower + (1 - factor) * mu_upper;
713 return std::pair<G4double, G4double>(sE, mu);
723 auto in =
G4int(rndm1 * ((*anEPM).n));
726 G4double mu_l = (*anEPM).isoAngle[in - 1];
727 G4double mu_h = (*anEPM).isoAngle[in];
728 result = (mu_h - mu_l) * (rndm1 * ((*anEPM).n) - in) + mu_l;
735 G4double mu_h = (*anEPM).isoAngle[0];
736 result = (mu_h - mu_l) * rndm2 + mu_l;
739 G4double mu_l = (*anEPM).isoAngle[(*anEPM).n - 1];
741 result = (mu_h - mu_l) * rndm2 + mu_l;
757 auto in =
G4int(random * ((*anEPM).n));
760 G4double mu_l = (*anEPM).isoAngle[in - 1];
761 G4double mu_h = (*anEPM).isoAngle[in];
762 result = (mu_h - mu_l) * (random * ((*anEPM).n) - in) + mu_l;
771 G4double mu_h = (*anEPM).isoAngle[0];
772 result = (mu_h - mu_l) * xx + mu_l;
775 G4double mu_l = (*anEPM).isoAngle[(*anEPM).n - 1];
777 result = (mu_h - mu_l) * xx + mu_l;
783std::pair<G4double, G4double> G4ParticleHPThermalScattering::find_LH(
G4double x,
784 std::vector<G4double>* aVector)
790 if (aVector->size() == 1) {
791 LL = aVector->front();
792 H = aVector->front();
798 for (
auto it = aVector->cbegin(); it != aVector->cend(); ++it) {
801 if (it != aVector->cbegin()) {
814 if (H == 0.0) LL = aVector->back();
817 return std::pair<G4double, G4double>(LL, H);
821 std::pair<G4double, G4double> Low,
822 std::pair<G4double, G4double> High)
825 if (High.first - Low.first != 0) {
826 y = (High.second - Low.second) / (High.first - Low.first) * (x - Low.first) + Low.second;
829 if (High.second == Low.second) {
833 G4cout <<
"G4ParticleHPThermalScattering liner interpolation err!!" <<
G4endl;
840E_isoAng G4ParticleHPThermalScattering::create_E_isoAng_from_energy(
G4double energy,
841 std::vector<E_isoAng*>* vEPM)
845 std::vector<G4double> v_e;
847 for (
auto iv = vEPM->cbegin(); iv != vEPM->cend(); ++iv)
848 v_e.push_back((*iv)->energy);
850 std::pair<G4double, G4double> energyLH = find_LH(energy, &v_e);
853 E_isoAng* panEPM_T_EL =
nullptr;
854 E_isoAng* panEPM_T_EH =
nullptr;
856 if (energyLH.first != 0.0 && energyLH.second != 0.0) {
857 for (
auto iv = vEPM->begin(); iv != vEPM->end(); ++iv) {
858 if (energyLH.first == (*iv)->energy) {
866 else if (energyLH.first == 0.0) {
867 panEPM_T_EL = (*vEPM)[0];
868 panEPM_T_EH = (*vEPM)[1];
870 else if (energyLH.second == 0.0) {
871 panEPM_T_EH = (*vEPM).back();
872 auto iv = vEPM->cend();
878 if (panEPM_T_EL !=
nullptr && panEPM_T_EH !=
nullptr) {
881 if (!(check_E_isoAng(panEPM_T_EL))) panEPM_T_EL = panEPM_T_EH;
882 if (!(check_E_isoAng(panEPM_T_EH))) panEPM_T_EH = panEPM_T_EL;
884 if (panEPM_T_EL->
n == panEPM_T_EH->
n) {
886 anEPM_T_E.
n = panEPM_T_EL->
n;
888 for (
G4int i = 0; i < panEPM_T_EL->
n; ++i) {
890 angle = get_linear_interpolated(
891 energy, std::pair<G4double, G4double>(energyLH.first, panEPM_T_EL->
isoAngle[i]),
892 std::pair<G4double, G4double>(energyLH.second, panEPM_T_EH->
isoAngle[i]));
893 anEPM_T_E.
isoAngle.push_back(angle);
897 G4Exception(
"G4ParticleHPThermalScattering::create_E_isoAng_from_energy",
"NotSupported",
899 "G4ParticleHPThermalScattering does not support yet EL->n != EH->n.");
903 G4Exception(
"G4ParticleHPThermalScattering::create_E_isoAng_from_energy",
"HAD_THERM_000",
911G4ParticleHPThermalScattering::get_secondary_energy_from_E_P_E_isoAng(
G4double random,
937 for (
G4int i = 0; i <
n - 1; ++i) {
941 sum_p += ((anE_P_E_isoAng->
prob[i]) * dE);
943 if (random <= sum_p / total) {
945 get_linear_interpolated(random, std::pair<G4double, G4double>(sum_p_L / total, E_L),
946 std::pair<G4double, G4double>(sum_p / total, E_H));
947 secondary_energy = secondary_energy * eV;
953 return secondary_energy;
956std::pair<G4double, E_isoAng>
957G4ParticleHPThermalScattering::create_sE_and_EPM_from_pE_and_vE_P_E_isoAng(
960 std::map<G4double, G4int> map_energy;
962 std::vector<G4double> v_energy;
965 for (
auto itv = vNEP_EPM->begin(); itv != vNEP_EPM->end(); ++itv) {
966 v_energy.push_back((*itv)->energy);
967 map_energy.insert(std::pair<G4double, G4int>((*itv)->energy, i));
971 std::pair<G4double, G4double> energyLH = find_LH(pE, &v_energy);
973 E_P_E_isoAng* pE_P_E_isoAng_EL =
nullptr;
974 E_P_E_isoAng* pE_P_E_isoAng_EH =
nullptr;
976 if (energyLH.first != 0.0 && energyLH.second != 0.0) {
977 auto u = map_energy.find(energyLH.first);
978 if (u != map_energy.end())
979 pE_P_E_isoAng_EL = (*vNEP_EPM)[u->second];
980 auto w = map_energy.find(energyLH.second);
981 if (w != map_energy.end())
982 pE_P_E_isoAng_EH = (*vNEP_EPM)[w->second];
984 else if (energyLH.first == 0.0) {
985 pE_P_E_isoAng_EL = (*vNEP_EPM)[0];
986 pE_P_E_isoAng_EH = (*vNEP_EPM)[1];
988 else if (energyLH.second == 0.0 && i >= 2) {
989 pE_P_E_isoAng_EL = (*vNEP_EPM)[i - 2];
990 pE_P_E_isoAng_EH = (*vNEP_EPM).back();
999 if (
nullptr == pE_P_E_isoAng_EL ||
nullptr == pE_P_E_isoAng_EH) {
1001 anE_isoAng.
isoAngle.push_back(0.0);
1002 return std::pair<G4double, E_isoAng>(pE, anE_isoAng);
1005 sE_L = get_secondary_energy_from_E_P_E_isoAng(rand_for_sE, pE_P_E_isoAng_EL);
1006 sE_H = get_secondary_energy_from_E_P_E_isoAng(rand_for_sE, pE_P_E_isoAng_EH);
1008 sE = get_linear_interpolated(pE, std::pair<G4double, G4double>(energyLH.first, sE_L),
1009 std::pair<G4double, G4double>(energyLH.second, sE_H));
1011 E_isoAng E_isoAng_L = create_E_isoAng_from_energy(sE, &(pE_P_E_isoAng_EL->
vE_isoAngle));
1012 E_isoAng E_isoAng_H = create_E_isoAng_from_energy(sE, &(pE_P_E_isoAng_EH->
vE_isoAngle));
1017 if (E_isoAng_L.
n == E_isoAng_H.
n) {
1018 anE_isoAng.
n = E_isoAng_L.
n;
1019 for (
G4int j = 0; j < anE_isoAng.
n; ++j) {
1022 get_linear_interpolated(sE, std::pair<G4double, G4double>(sE_L, E_isoAng_L.
isoAngle[j]),
1023 std::pair<G4double, G4double>(sE_H, E_isoAng_H.
isoAngle[j]));
1024 anE_isoAng.
isoAngle.push_back(angle);
1028 throw G4HadronicException(__FILE__, __LINE__,
"Unexpected values!");
1031 return std::pair<G4double, E_isoAng>(sE, anE_isoAng);
1034void G4ParticleHPThermalScattering::buildPhysicsTable()
1039 if (nMaterial == numberOfMaterials && nElement == numberOfElements)
1045 nMaterial = numberOfMaterials;
1046 nElement = numberOfElements;
1049 std::map<G4String, G4int> co_dic;
1052 for (std::size_t i = 0; i < numberOfMaterials; ++i) {
1053 G4Material* material = (*theMaterialTable)[i];
1055 for (
G4int j = 0; j < nelm; ++j) {
1056 const G4Element* element = material->
GetElement(j);
1057 if (names.IsThisThermalElement(material->
GetName(), element->
GetName())) {
1058 G4int ts_ID_of_this_geometry;
1059 G4String ts_ndl_name = names.GetTS_NDL_Name(material->
GetName(), element->
GetName());
1060 if (co_dic.find(ts_ndl_name) != co_dic.cend()) {
1061 ts_ID_of_this_geometry = co_dic.find(ts_ndl_name)->second;
1064 ts_ID_of_this_geometry = (
G4int)co_dic.size();
1065 co_dic.insert(std::pair<G4String, G4int>(ts_ndl_name, ts_ID_of_this_geometry));
1073 dic.insert(std::pair<std::pair<G4Material*, const G4Element*>,
G4int>(
1074 std::pair<G4Material*, const G4Element*>(material, element), ts_ID_of_this_geometry));
1080 for (std::size_t i = 0; i < numberOfElements; ++i) {
1081 const G4Element* element = (*theElementTable)[i];
1082 if (names.IsThisThermalElement(element->
GetName())) {
1083 if (names.IsThisThermalElement(element->
GetName())) {
1084 G4int ts_ID_of_this_geometry;
1085 G4String ts_ndl_name = names.GetTS_NDL_Name(element->
GetName());
1086 if (co_dic.find(ts_ndl_name) != co_dic.cend()) {
1087 ts_ID_of_this_geometry = co_dic.find(ts_ndl_name)->second;
1090 ts_ID_of_this_geometry = (
G4int)co_dic.size();
1091 co_dic.insert(std::pair<G4String, G4int>(ts_ndl_name, ts_ID_of_this_geometry));
1093 dic.insert(std::pair<std::pair<const G4Material*, const G4Element*>,
G4int>(
1094 std::pair<const G4Material*, const G4Element*>((G4Material*)
nullptr, element),
1095 ts_ID_of_this_geometry));
1102 <<
"Neutron HP Thermal Scattering: Following material-element pairs or elements are registered."
1104 for (
const auto& it : dic) {
1105 if (it.first.first !=
nullptr) {
1106 G4cout <<
"Material " << it.first.first->GetName() <<
" - Element "
1107 << it.first.second->GetName() <<
", internal thermal scattering id " << it.second
1111 G4cout <<
"Element " << it.first.second->GetName() <<
", internal thermal scattering id "
1125 clearCurrentFSData();
1127 if (coherentFSs ==
nullptr)
1129 new std::map<G4int, std::map<G4double, std::vector<std::pair<G4double, G4double>*>*>*>;
1130 if (incoherentFSs ==
nullptr)
1131 incoherentFSs =
new std::map<G4int, std::map<G4double, std::vector<E_isoAng*>*>*>;
1132 if (inelasticFSs ==
nullptr)
1133 inelasticFSs =
new std::map<G4int, std::map<G4double, std::vector<E_P_E_isoAng*>*>*>;
1137 throw G4HadronicException(
1139 "Please setenv G4NEUTRONHPDATA to point to the neutron cross-section files.");
1142 for (
const auto& it : co_dic) {
1143 G4String tsndlName = it.first;
1144 G4int ts_ID = it.second;
1147 G4String fsName =
"/ThermalScattering/Coherent/FS/";
1148 G4String fileName = dirName + fsName + tsndlName;
1149 coherentFSs->insert(
1150 std::pair<
G4int, std::map<
G4double, std::vector<std::pair<G4double, G4double>*>*>*>(
1151 ts_ID, readACoherentFSDATA(fileName)));
1154 fsName =
"/ThermalScattering/Incoherent/FS/";
1155 fileName = dirName + fsName + tsndlName;
1156 incoherentFSs->insert(std::pair<
G4int, std::map<
G4double, std::vector<E_isoAng*>*>*>(
1157 ts_ID, readAnIncoherentFSDATA(fileName)));
1160 fsName =
"/ThermalScattering/Inelastic/FS/";
1161 fileName = dirName + fsName + tsndlName;
1162 inelasticFSs->insert(std::pair<
G4int, std::map<
G4double, std::vector<E_P_E_isoAng*>*>*>(
1163 ts_ID, readAnInelasticFSDATA(fileName)));
1177 if (dic.find(std::pair<const G4Material*, const G4Element*>(material, element)) != dic.end())
1178 result = dic.find(std::pair<const G4Material*, const G4Element*>(material, element))->second;
1185 return std::pair<G4double, G4double>(10.0 * perCent, 350.0 * CLHEP::GeV);
1191 names.AddThermalElement(nameG4Element, filename);
1192 theXSection->AddUserThermalScatteringFile(nameG4Element, filename);
1193 buildPhysicsTable();
1196G4bool G4ParticleHPThermalScattering::check_E_isoAng(
E_isoAng* anE_IsoAng)
1202 for (
G4int i = 0; i < n; ++i) {
1205 if (sum != 0.0) result =
true;
1212 outFile <<
"High Precision model based on thermal scattering data in\n"
1213 <<
"evaluated nuclear data libraries for neutrons below 5eV\n"
1214 <<
"on specific materials\n";
const char * G4FindDataDir(const char *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
G4GLOB_DLL std::ostream G4cout
static std::size_t GetNumberOfElements()
const G4String & GetName() const
static const G4ElementTable * GetElementTable()
const G4Material * GetMaterial() const
const G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
const G4LorentzVector & Get4Momentum() const
G4HadFinalState theParticleChange
void SetMinEnergy(G4double anEnergy)
G4HadronicInteraction(const G4String &modelName="HadronicModel")
void SetMaxEnergy(const G4double anEnergy)
G4double GetTemperature() const
const G4Element * GetElement(G4int iel) const
static std::size_t GetNumberOfMaterials()
static G4MaterialTable * GetMaterialTable()
std::size_t GetNumberOfElements() const
const G4String & GetName() const
static G4Neutron * Neutron()
std::map< G4int, std::map< G4double, std::vector< E_isoAng * > * > * > * GetThermalScatteringIncoherentFinalStates() const
void RegisterThermalScatteringCoherentFinalStates(std::map< G4int, std::map< G4double, std::vector< std::pair< G4double, G4double > * > * > * > *val)
void RegisterThermalScatteringIncoherentFinalStates(std::map< G4int, std::map< G4double, std::vector< E_isoAng * > * > * > *val)
void RegisterThermalScatteringInelasticFinalStates(std::map< G4int, std::map< G4double, std::vector< E_P_E_isoAng * > * > * > *val)
std::map< G4int, std::map< G4double, std::vector< E_P_E_isoAng * > * > * > * GetThermalScatteringInelasticFinalStates() const
void GetDataStream(const G4String &, std::istringstream &iss)
static G4ParticleHPManager * GetInstance()
std::map< G4int, std::map< G4double, std::vector< std::pair< G4double, G4double > * > * > * > * GetThermalScatteringCoherentFinalStates() const
void ModelDescription(std::ostream &outFile) const override
const std::pair< G4double, G4double > GetFatalEnergyCheckLevels() const override
~G4ParticleHPThermalScattering() override
G4ParticleHPThermalScattering()
G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &aTargetNucleus) override
void BuildPhysicsTable(const G4ParticleDefinition &) override
void AddUserThermalScatteringFile(const G4String &, const G4String &)
G4double total(Particle const *const p1, Particle const *const p2)
G4double energy(const ThreeVector &p, const G4double m)
std::vector< E_isoAng * > vE_isoAngle
std::vector< G4double > secondary_energy_pdf
std::vector< G4double > secondary_energy_value
std::vector< G4double > secondary_energy_cdf
std::vector< G4double > prob
G4int secondary_energy_cdf_size
std::vector< G4double > isoAngle