63 G4cout <<
"RPWBA ionisation model is constructed " <<
G4endl;
80 if(lowEnergyLimit == highEnergyLimit)
82 G4Exception(
"G4DNARPWBAIonisationModel::InEnergyLimit",
"em0102",
85 if(k >= lowEnergyLimit && k <= highEnergyLimit)
96void G4DNARPWBAIonisationModel::InitialiseForProton(
99 if(part != fProtonDef)
101 G4Exception(
"G4DNARPWBAIonisationModel::InitialiseForProton",
"em0002",
105 G4String fileProton(
"dna/sigma_ionisation_p_RPWBA");
108 lowEnergyLimit = 100. * MeV;
109 highEnergyLimit = 300. * MeV;
114 ed <<
"Model is applicable from "<<lowEnergyLimit<<
" to "<<highEnergyLimit;
115 G4Exception(
"G4DNARPWBAIonisationModel::InitialiseForProton",
"em0004",
119 fpTotalCrossSection = make_unique<G4DNACrossSectionDataSet>(
121 fpTotalCrossSection->LoadData(fileProton);
125 std::ostringstream pFullFileName;
126 fasterCode ? pFullFileName
127 << path <<
"/dna/sigmadiff_cumulated_ionisation_p_RPWBA.dat"
128 : pFullFileName << path <<
"/dna/sigmadiff_ionisation_p_RPWBA.dat";
129 std::ifstream pDiffCrossSection(pFullFileName.str().c_str());
130 if(!pDiffCrossSection)
133 exceptionDescription <<
"Missing data file: " + pFullFileName.str();
134 G4Exception(
"G4DNARPWBAIonisationModel::InitialiseForProton",
"em0003",
138 pTdummyVec.push_back(0.);
139 while(!pDiffCrossSection.eof())
143 pDiffCrossSection >> tDummy >> eDummy;
144 if(tDummy != pTdummyVec.back())
146 pTdummyVec.push_back(tDummy);
149 for(
G4int j = 0; j < 5; j++)
151 pDiffCrossSection >> pDiffCrossSectionData[j][tDummy][eDummy];
155 pNrjTransfData[j][tDummy][pDiffCrossSectionData[j][tDummy][eDummy]] =
157 pProbaShellMap[j][tDummy].push_back(
158 pDiffCrossSectionData[j][tDummy][eDummy]);
162 if(!pDiffCrossSection.eof() && !fasterCode)
164 pDiffCrossSectionData[j][tDummy][eDummy] *= scaleFactor;
169 pVecm[tDummy].push_back(eDummy);
188 G4cout <<
"Calling G4DNARPWBAIonisationModel::Initialise()"
192 InitialiseForProton(particle);
196 G4cout <<
"RPWBA ionisation model is initialized " <<
G4endl
212 exceptionDescription <<
"G4_WATER does not exist :";
213 G4Exception(
"G4DNARPWBAIonisationModel::Initialise",
"em00020",
218 isInitialised =
true;
227 if(particleDefinition != fProtonDef)
229 G4Exception(
"G4DNARPWBAIonisationModel::CrossSectionPerVolume",
"em0402",
234 G4cout <<
"Calling CrossSectionPerVolume() of G4DNARPWBAIonisationModel"
240 if(InEnergyLimit(ekin))
242 sigma = fpTotalCrossSection->FindValue(ekin);
253 G4cout <<
"__________________________________" <<
G4endl;
254 G4cout <<
"G4DNARPWBAIonisationModel - XS INFO START" <<
G4endl;
255 G4cout <<
"Kinetic energy(eV)=" << ekin / eV
257 G4cout <<
"Cross section per water molecule (cm^2)=" << sigma / cm / cm
259 G4cout <<
"Cross section per water molecule (cm^-1)="
260 << sigma * waterDensity / (1. / cm) <<
G4endl;
261 G4cout <<
"G4DNARPWBAIonisationModel - XS INFO END" <<
G4endl;
264 return sigma * waterDensity;
275 G4cout <<
"Calling SampleSecondaries() of G4DNARPWBAIonisationModel"
283 G4double totalEnergy = k + particleMass;
284 G4double pSquare = k * (totalEnergy + particleMass);
285 G4double totalMomentum = std::sqrt(pSquare);
286 G4int ionizationShell;
290 ionizationShell = RandomSelect(k);
297 ionizationShell = RandomSelect(k);
298 }
while(k < 19 * eV && ionizationShell == 2 &&
305 if(k < bindingEnergy)
313 secondaryKinetic = RandomizeEjectedElectronEnergy(k, ionizationShell);
318 RandomizeEjectedElectronEnergyFromCumulatedDcs(k, ionizationShell);
324 particle, secondaryKinetic,
Z, ionizationShell, couple->
GetMaterial());
326 if(secondaryKinetic > 0){
329 fvect->push_back(dp);
333 G4double deltaTotalMomentum = std::sqrt(
334 secondaryKinetic * (secondaryKinetic + 2. * electron_mass_c2));
336 G4double finalPx = totalMomentum * primaryDirection.
x() -
337 deltaTotalMomentum * deltaDirection.
x();
338 G4double finalPy = totalMomentum * primaryDirection.
y() -
339 deltaTotalMomentum * deltaDirection.
y();
340 G4double finalPz = totalMomentum * primaryDirection.
z() -
341 deltaTotalMomentum * deltaDirection.
z();
343 std::sqrt(finalPx * finalPx + finalPy * finalPy + finalPz * finalPz);
344 finalPx /= finalMomentum;
345 finalPy /= finalMomentum;
346 finalPz /= finalMomentum;
348 direction.
set(finalPx, finalPy, finalPz);
360 size_t secNumberInit;
365 G4double scatteredEnergy = k - bindingEnergy - secondaryKinetic;
368 if((fAtomDeexcitation !=
nullptr) && ionizationShell == 4)
372 secNumberInit = fvect->size();
374 secNumberFinal = fvect->size();
376 if(secNumberFinal > secNumberInit){
377 for(
size_t i = secNumberInit; i < secNumberFinal; ++i){
378 if(bindingEnergy >= ((*fvect)[i])->GetKineticEnergy())
380 bindingEnergy -= ((*fvect)[i])->GetKineticEnergy();
383 (*fvect)[i] =
nullptr;
390 if(bindingEnergy < 0.0)
392 G4Exception(
"G4DNARPWBAIonisatioModel::SampleSecondaries()",
"em2050",
405 const G4Track* theIncomingTrack =
414G4double G4DNARPWBAIonisationModel::RandomizeEjectedElectronEnergy(
417 G4double maximumKineticEnergyTransfer =
418 4. * (electron_mass_c2 / proton_mass_c2) * k;
423 for(
G4double value = IonisationEnergyInShell;
424 value <= 4. * IonisationEnergyInShell; value += 0.1 * eV)
428 if(differentialCrossSection >= crossSectionMaximum)
430 crossSectionMaximum = differentialCrossSection;
434 G4double secondaryElectronKineticEnergy;
437 secondaryElectronKineticEnergy =
441 (secondaryElectronKineticEnergy +
442 IonisationEnergyInShell) / eV, shell));
444 return secondaryElectronKineticEnergy;
450 const G4int& ionizationLevelIndex)
471 if(k == pTdummyVec.back())
473 k = k * (1. - 1e-12);
476 auto t2 = std::upper_bound(pTdummyVec.begin(), pTdummyVec.end(), k);
479 auto e12 = std::upper_bound(pVecm[(*t1)].begin(), pVecm[(*t1)].end(),
483 auto e22 = std::upper_bound(pVecm[(*t2)].begin(), pVecm[(*t2)].end(),
494 xs11 = pDiffCrossSectionData[ionizationLevelIndex][valueT1][valueE11];
495 xs12 = pDiffCrossSectionData[ionizationLevelIndex][valueT1][valueE12];
496 xs21 = pDiffCrossSectionData[ionizationLevelIndex][valueT2][valueE21];
497 xs22 = pDiffCrossSectionData[ionizationLevelIndex][valueT2][valueE22];
499 G4double xsProduct = xs11 * xs12 * xs21 * xs22;
503 QuadInterpolator(valueE11, valueE12, valueE21, valueE22, xs11, xs12,
504 xs21, xs22, valueT1, valueT2, k, energyTransfer);
522 if(e1 != 0 && e2 != 0 && (std::log10(e2) - std::log10(e1)) != 0 &&
526 (std::log10(xs2) - std::log10(xs1)) / (std::log10(e2) - std::log10(e1));
527 G4double b = std::log10(xs2) - a * std::log10(e2);
528 G4double sigma = a * std::log10(e) + b;
529 value = (std::pow(10., sigma));
542 if((e2 - e1) != 0 && xs1 != 0 && xs2 != 0 && fasterCode)
546 value = std::pow(10., (d1 + (d2 - d1) * (e - e1) / (e2 - e1)));
552 if((e2 - e1) != 0 && (xs1 == 0 || xs2 == 0) && fasterCode)
556 value = (d1 + (d2 - d1) * (e - e1) / (e2 - e1));
563G4double G4DNARPWBAIonisationModel::QuadInterpolator(
569 G4double interpolatedvalue1 = Interpolate(e11, e12, e, xs11, xs12);
570 G4double interpolatedvalue2 = Interpolate(e21, e22, e, xs21, xs22);
572 Interpolate(t1, t2, t, interpolatedvalue1, interpolatedvalue2);
581 if(fpTotalCrossSection !=
nullptr && particle != fProtonDef)
583 G4Exception(
"G4DNARPWBAIonisationModel::GetPartialCrossSection",
"em0010",
586 return fpTotalCrossSection->GetComponent(level)->FindValue(kineticEnergy);
593 if(fpTotalCrossSection ==
nullptr)
595 G4Exception(
"G4DNARPWBAIonisationModel::RandomSelect",
"em0010",
600 auto valuesBuffer =
new G4double[fpTotalCrossSection->NumberOfComponents()];
601 const G4int n = (
G4int)fpTotalCrossSection->NumberOfComponents();
607 valuesBuffer[i] = fpTotalCrossSection->GetComponent(i)->FindValue(k);
608 value += valuesBuffer[i];
616 if(valuesBuffer[i] > value)
618 delete[] valuesBuffer;
621 value -= valuesBuffer[i];
623 delete[] valuesBuffer;
631G4DNARPWBAIonisationModel::RandomizeEjectedElectronEnergyFromCumulatedDcs(
638 if(secondaryKineticEnergy < 0.)
642 return secondaryKineticEnergy;
648 G4int ionizationLevelIndex,
663 if(k == pTdummyVec.back())
665 k = k * (1. - 1e-12);
669 auto k2 = std::upper_bound(pTdummyVec.begin(), pTdummyVec.end(), k);
675 if(random <= pProbaShellMap[ionizationLevelIndex][(*k1)].back() &&
676 random <= pProbaShellMap[ionizationLevelIndex][(*k2)].back())
678 auto prob12 = std::upper_bound(
679 pProbaShellMap[ionizationLevelIndex][(*k1)].begin(),
680 pProbaShellMap[ionizationLevelIndex][(*k1)].end(), random);
681 auto prob11 = prob12 - 1;
682 auto prob22 = std::upper_bound(
683 pProbaShellMap[ionizationLevelIndex][(*k2)].begin(),
684 pProbaShellMap[ionizationLevelIndex][(*k2)].end(), random);
686 auto prob21 = prob22 - 1;
690 valuePROB21 = *prob21;
691 valuePROB22 = *prob22;
692 valuePROB12 = *prob12;
693 valuePROB11 = *prob11;
695 nrjTransf11 = pNrjTransfData[ionizationLevelIndex][valueK1][valuePROB11];
696 nrjTransf12 = pNrjTransfData[ionizationLevelIndex][valueK1][valuePROB12];
697 nrjTransf21 = pNrjTransfData[ionizationLevelIndex][valueK2][valuePROB21];
698 nrjTransf22 = pNrjTransfData[ionizationLevelIndex][valueK2][valuePROB22];
704 if(random > pProbaShellMap[ionizationLevelIndex][(*k1)].back())
706 auto prob22 = std::upper_bound(
707 pProbaShellMap[ionizationLevelIndex][(*k2)].begin(),
708 pProbaShellMap[ionizationLevelIndex][(*k2)].end(), random);
709 auto prob21 = prob22 - 1;
713 valuePROB21 = *prob21;
714 valuePROB22 = *prob22;
715 nrjTransf21 = pNrjTransfData[ionizationLevelIndex][valueK2][valuePROB21];
716 nrjTransf22 = pNrjTransfData[ionizationLevelIndex][valueK2][valuePROB22];
719 Interpolate(valuePROB21, valuePROB22, random, nrjTransf21, nrjTransf22);
721 G4double value = Interpolate(valueK1, valueK2, k, 0., interpolatedvalue2);
725 nrjTransf11 * nrjTransf12 * nrjTransf21 * nrjTransf22;
727 if(nrjTransfProduct != 0.)
729 nrj = QuadInterpolator(valuePROB11, valuePROB12, valuePROB21, valuePROB22,
730 nrjTransf11, nrjTransf12, nrjTransf21, nrjTransf22,
731 valueK1, valueK2, k, random);
const char * G4FindDataDir(const char *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
static G4DNAChemistryManager * Instance()
void CreateWaterMolecule(ElectronicModification, G4int, const G4Track *)
const std::vector< G4double > * GetNumMolPerVolTableFor(const G4Material *) const
Retrieve a table of molecular densities (number of molecules per unit volume) in the G4 unit system f...
static G4DNAMolecularMaterial * Instance()
G4DNARPWBAIonisationModel(const G4ParticleDefinition *p=nullptr, const G4String &nam="DNARPWBAIonisationModel")
~G4DNARPWBAIonisationModel() override
G4ParticleChangeForGamma * fParticleChangeForGamma
void Initialise(const G4ParticleDefinition *, const G4DataVector &= *(new G4DataVector())) override
void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy) override
G4double TransferedEnergy(G4double incomingParticleEnergy, G4int shell, const G4double &random)
G4double DifferentialCrossSection(const G4double &k, const G4double &energyTransfer, const G4int &shell)
G4double GetPartialCrossSection(const G4Material *, G4int, const G4ParticleDefinition *, G4double) override
G4double CrossSectionPerVolume(const G4Material *material, const G4ParticleDefinition *p, G4double ekin, G4double emin, G4double emax) override
G4double IonisationEnergy(G4int level)
const G4ThreeVector & GetMomentumDirection() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
static G4Electron * ElectronDefinition()
static G4Electron * Electron()
static G4LossTableManager * Instance()
G4VAtomDeexcitation * AtomDeexcitation()
const G4Material * GetMaterial() const
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
void SetProposedKineticEnergy(G4double proposedKinEnergy)
void ProposeMomentumDirection(const G4ThreeVector &Pfinal)
G4double GetPDGMass() const
const G4String & GetParticleName() const
virtual const G4AtomicShell * GetAtomicShell(G4int Z, G4AtomicShellEnumerator shell)=0
void GenerateParticles(std::vector< G4DynamicParticle * > *secVect, const G4AtomicShell *, G4int Z, G4int coupleIndex)
virtual G4ThreeVector & SampleDirectionForShell(const G4DynamicParticle *dp, G4double finalTotalEnergy, G4int Z, G4int shellID, const G4Material *)
G4VEmAngularDistribution * GetAngularDistribution()
G4ParticleChangeForGamma * GetParticleChangeForGamma()
G4double LowEnergyLimit() const
G4double HighEnergyLimit() const
void SetDeexcitationFlag(G4bool val)
void SetAngularDistribution(G4VEmAngularDistribution *)
const G4Track * GetCurrentTrack() const
void ProposeLocalEnergyDeposit(G4double anEnergyPart)