82 currentCoupleIndex = 0;
83 currentCouple =
nullptr;
84 currentMaterial = cutMaterial =
nullptr;
85 currentParticle =
nullptr;
86 lambdaParticle =
nullptr;
87 baseParticle =
nullptr;
88 currentLambda =
nullptr;
89 currentModel =
nullptr;
90 currentProcess =
nullptr;
97 cutenergy[0] = cutenergy[1] = cutenergy[2] =
DBL_MAX;
98 currentParticleName=
"";
99 currentMaterialName=
"";
106 isApplicable =
false;
114 for (
G4int i=0; i<nLocalMaterials; ++i) {
115 delete localCouples[i];
128 if(couple && UpdateParticle(p, kinEnergy) ) {
129 res = manager->
GetDEDX(p, kinEnergy, couple);
132 if(FindEmModel(p, currentProcessName, kinEnergy)) {
148 G4cout <<
"G4EmCalculator::GetDEDX: E(MeV)= " << kinEnergy/MeV
149 <<
" DEDX(MeV/mm)= " << res*mm/MeV
150 <<
" DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->
GetDensity())
153 <<
" isIon= " << isIon
169 if(couple && UpdateParticle(p, kinEnergy)) {
172 G4cout <<
" G4EmCalculator::GetRangeFromRestrictedDEDX: E(MeV)= "
174 <<
" range(mm)= " << res/mm
193 ed <<
"G4EmCalculator::GetCSDARange: CSDA table is not built; "
194 <<
" use UI command: /process/eLoss/CSDARange true";
195 G4Exception(
"G4EmCalculator::GetCSDARange",
"em0077",
201 if(couple && UpdateParticle(p, kinEnergy)) {
204 G4cout <<
" G4EmCalculator::GetCSDARange: E(MeV)= " << kinEnergy/MeV
205 <<
" range(mm)= " << res/mm
239 if(couple && UpdateParticle(p, 1.0*GeV)) {
240 res = manager->
GetEnergy(p, range, couple);
242 G4cout <<
"G4EmCalculator::GetKinEnergy: Range(mm)= " << range/mm
243 <<
" KinE(MeV)= " << res/MeV
263 if(couple && UpdateParticle(p, kinEnergy)) {
264 if(FindEmModel(p, processName, kinEnergy)) {
267 FindLambdaTable(p, processName, kinEnergy, procType);
269 G4VEmProcess* emproc = FindDiscreteProcess(p, processName);
272 }
else if(currentLambda) {
283 res = (((*currentLambda)[idx])->Value(e))*chargeSquare;
289 G4cout <<
"G4EmCalculator::GetXSPerVolume: E(MeV)= " << kinEnergy/MeV
290 <<
" cross(cm-1)= " << res*cm
294 G4cout <<
" idx= " << idx <<
" Escaled((MeV)= "
295 << kinEnergy*massRatio
296 <<
" q2= " << chargeSquare;
331 if(x > 0.0) { res = 1.0/x; }
333 G4cout <<
"G4EmCalculator::GetMeanFreePath: E(MeV)= " << kinEnergy/MeV
334 <<
" MFP(mm)= " << res/mm
365 G4cout <<
"### G4EmCalculator: Inverse Range Table for "
382 <<
" in " << currentMaterialName
383 <<
" e(MeV)= " << kinEnergy/MeV <<
" cut(MeV)= " << cut/MeV
386 if(UpdateParticle(p, kinEnergy)) {
387 if(FindEmModel(p, processName, kinEnergy)) {
391 if(mname ==
"ParamICRU73" || mname ==
"LinhardSorensen" || mname ==
"Atima") {
394 G4cout << mname <<
" ion E(MeV)= " << kinEnergy <<
" ";
395 G4cout << currentModel->
GetName() <<
": DEDX(MeV/mm)= " << res*mm/MeV
396 <<
" DEDX(MeV*cm^2/g)= "
402 G4double escaled = kinEnergy*massRatio;
405 mat, baseParticle, escaled, cut) * chargeSquare;
408 <<
" Escaled(MeV)= " << escaled;
412 if(verbose > 1) {
G4cout <<
" no basePart E(MeV)= " << kinEnergy <<
" "; }
415 G4cout << currentModel->
GetName() <<
": DEDX(MeV/mm)= " << res*mm/MeV
416 <<
" DEDX(MeV*cm^2/g)= "
437 G4cout <<
"At boundary energy(MeV)= " << eth/MeV
438 <<
" DEDX(MeV/mm)= " << res1*mm/MeV
446 if(res1 > 0.0 && escaled > 0.0) {
447 res *= (1.0 + (res0/res1 - 1.0)*eth/escaled);
464 G4cout <<
"After Corrections: DEDX(MeV/mm)= " << res*mm/MeV
465 <<
" DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->
GetDensity())
472 G4cout <<
"Sum: E(MeV)= " << kinEnergy/MeV
473 <<
" DEDX(MeV/mm)= " << res*mm/MeV
474 <<
" DEDX(MeV*cm^2/g)= " << res*gram/(MeV*cm2*mat->
GetDensity())
475 <<
" cut(MeV)= " << cut/MeV
477 <<
" in " << currentMaterialName
478 <<
" Zi^2= " << chargeSquare
479 <<
" isIon=" << isIon
495 if(UpdateParticle(part, kinEnergy)) {
498 const std::vector<G4VEnergyLossProcess*> vel =
500 G4int n = vel.size();
505 for(
G4int i=0; i<n; ++i) {
508 if(ActiveForParticle(part, p)) {
511 dedx +=
ComputeDEDX(kinEnergy,part,(vel[i])->GetProcessName(),mat,cut);
528 if(UpdateParticle(part, kinEnergy)) {
531 const std::vector<G4VEnergyLossProcess*> vel =
533 G4int n = vel.size();
535 if(mat != cutMaterial) {
545 for(
G4int i=0; i<n; ++i) {
548 if(ActiveForParticle(part, p)) {
556 dedx +=
ComputeDEDX(kinEnergy,part,(vel[i])->GetProcessName(),
584 G4VEmProcess* nucst = FindDiscreteProcess(p,
"nuclearStopping");
595 <<
" NuclearDEDX(MeV/mm)= " << res*mm/MeV
596 <<
" NuclearDEDX(MeV*cm^2/g)= "
614 if(UpdateParticle(p, kinEnergy)) {
615 if(FindEmModel(p, processName, kinEnergy)) {
619 e *= kinEnergy*massRatio;
621 mat, baseParticle, e, aCut, e) * chargeSquare;
626 G4cout <<
"G4EmCalculator::ComputeXSPerVolume: E(MeV)= " << kinEnergy/MeV
627 <<
" cross(cm-1)= " << res*cm
628 <<
" cut(keV)= " << aCut/keV
648 if(UpdateParticle(p, kinEnergy)) {
651 if(FindEmModel(p, processName, kinEnergy)) {
655 e *= kinEnergy*massRatio;
658 baseParticle, e, Z,
A, aCut) * chargeSquare;
664 G4cout <<
"E(MeV)= " << kinEnergy/MeV
665 <<
" cross(barn)= " << res/barn
667 <<
" Z= " << Z <<
" A= " <<
A/(g/mole) <<
" g/mole"
668 <<
" cut(keV)= " << aCut/keV
685 if(UpdateParticle(p, kinEnergy)) {
687 if(FindEmModel(p, processName, kinEnergy)) {
691 e *= kinEnergy*massRatio;
694 e, aCut) * chargeSquare;
700 G4cout <<
"E(MeV)= " << kinEnergy/MeV
701 <<
" cross(barn)= " << res/barn
703 <<
" Z= " << Z <<
" shellIdx= " << shellIdx
704 <<
" cut(keV)= " << aCut/keV
724 if(res > 0.0) { res = 1.0/res; }
757 if(x > 0.0) { mfp = 1.0/x; }
759 G4cout <<
"E(MeV)= " << kinEnergy/MeV
760 <<
" MFP(mm)= " << mfp/mm
776 ConvertRangeToEnergy(part, mat, range);
784 if(p != currentParticle) {
795 currentProcess = FindEnergyLossProcess(p);
796 currentProcessName =
"";
812 && currentParticleName !=
"deuteron"
813 && currentParticleName !=
"triton"
814 && currentParticleName !=
"alpha+"
815 && currentParticleName !=
"helium"
816 && currentParticleName !=
"hydrogen"
820 baseParticle = theGenericIon;
822 G4cout <<
"\n G4EmCalculator::UpdateParticle: isIon 1 "
824 <<
" in " << currentMaterial->
GetName()
825 <<
" e= " << kinEnergy <<
G4endl;
839 G4cout <<
"\n NewIon: massR= "<< massRatio <<
" q2= "
840 << chargeSquare <<
" " << currentProcess <<
G4endl;
852 if(name != currentParticleName) {
855 G4cout <<
"### WARNING: G4EmCalculator::FindParticle fails to find "
876 if(name != currentMaterialName) {
878 if(!currentMaterial) {
879 G4cout <<
"### WARNING: G4EmCalculator::FindMaterial fails to find "
883 return currentMaterial;
891 if(reg !=
"" && reg !=
"world") {
907 if(currentMaterial) {
917 size_t nr = store->size();
919 for(
size_t i=0; i<nr; ++i) {
921 material, ((*store)[i])->GetProductionCuts());
922 if(couple) {
break; }
929 ed <<
"G4EmCalculator::FindCouple: fail for material <"
930 << currentMaterialName <<
">";
931 if(region) { ed <<
" and region " << region->
GetName(); }
932 G4Exception(
"G4EmCalculator::FindCouple",
"em0078",
943 if(!currentMaterial) {
return false; }
944 for (
G4int i=0; i<nLocalMaterials; ++i) {
945 if(material == localMaterials[i] && cut == localCuts[i]) {
946 currentCouple = localCouples[i];
947 currentCoupleIndex = currentCouple->
GetIndex();
953 localMaterials.push_back(material);
954 localCouples.push_back(cc);
955 localCuts.push_back(cut);
958 currentCoupleIndex = currentCouple->
GetIndex();
970 if (!currentLambda || p != lambdaParticle || processName != lambdaName) {
971 lambdaName = processName;
972 currentLambda =
nullptr;
976 if(isIon) { part = theGenericIon; }
979 currentName = processName;
980 currentModel =
nullptr;
990 G4cout <<
"G4VEnergyLossProcess is found out: " << currentName
999 G4VEmProcess* proc = FindDiscreteProcess(part, processName);
1004 isApplicable =
true;
1006 G4cout <<
"G4VEmProcess is found out: " << currentName <<
G4endl;
1021 isApplicable =
true;
1023 G4cout <<
"G4VMultipleScattering is found out: " << currentName
1039 isApplicable =
false;
1040 if(!p || !currentMaterial) {
1041 G4cout <<
"G4EmCalculator::FindEmModel WARNING: no particle"
1042 <<
" or materail defined; particle: " << p <<
G4endl;
1043 return isApplicable;
1047 G4double scaledEnergy = kinEnergy*massRatio;
1048 if(isIon) { part = theGenericIon; }
1051 G4cout <<
"## G4EmCalculator::FindEmModel for " << partname
1053 <<
") and " << processName <<
" at E(MeV)= " << scaledEnergy
1055 if(p != part) {
G4cout <<
" GenericIon is the base particle" <<
G4endl; }
1059 currentName = processName;
1060 currentModel =
nullptr;
1061 loweModel =
nullptr;
1072 if(loweModel == currentModel) { loweModel =
nullptr; }
1082 G4VEmProcess* proc = FindDiscreteProcess(part, processName);
1090 if(loweModel == currentModel) { loweModel =
nullptr; }
1104 loweModel =
nullptr;
1108 if(loweModel == currentModel) { loweModel =
nullptr; }
1109 isApplicable =
true;
1123 G4cout <<
" LowEnergy model <" << loweModel->
GetName() <<
">";
1128 return isApplicable;
1141 && currentParticleName !=
"deuteron"
1142 && currentParticleName !=
"triton"
1143 && currentParticleName !=
"He3"
1144 && currentParticleName !=
"alpha"
1145 && currentParticleName !=
"alpha+"
1146 && currentParticleName !=
"helium"
1147 && currentParticleName !=
"hydrogen"
1148 ) { part = theGenericIon; }
1166 const std::vector<G4VEnergyLossProcess*> v =
1169 for(
G4int i=0; i<
n; ++i) {
1170 if((v[i])->GetProcessName() == processName) {
1172 if(ActiveForParticle(part, p)) {
1190 for(
G4int i=0; i<
n; ++i) {
1191 auto pName = v[i]->GetProcessName();
1192 if(pName ==
"GammaGeneralProc") {
1195 }
else if(pName == processName) {
1197 if(ActiveForParticle(part, p)) {
1213 const std::vector<G4VMultipleScattering*> v =
1216 for(
G4int i=0; i<
n; ++i) {
1217 if((v[i])->GetProcessName() == processName) {
1219 if(ActiveForParticle(part, p)) {
1237 for(
G4int i=0; i<nproc; ++i) {
1238 if(processName == (*pv)[i]->GetProcessName()) {
1255 for(
G4int i=0; i<n; ++i) {
1256 if((*pv)[i] == proc) {
1269 currentMaterial = mat;
1270 currentMaterialName = mat->
GetName();
1272 currentMaterial = 0;
1273 currentMaterialName =
"";
1286void G4EmCalculator::CheckMaterial(
G4int Z)
1289 if(currentMaterial) {
1291 for(
size_t i=0; i<nn; ++i) {
double A(double temperature)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4GLOB_DLL std::ostream G4cout
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
void SetKineticEnergy(G4double aEnergy)
static G4Electron * Electron()
const G4ParticleDefinition * FindParticle(const G4String &)
G4double ComputeMeanFreePath(G4double kinEnergy, const G4ParticleDefinition *, const G4String &processName, const G4Material *, G4double cut=0.0)
G4double GetShellIonisationCrossSectionPerAtom(const G4String &part, G4int Z, G4AtomicShellEnumerator shell, G4double kinEnergy)
G4double GetDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
G4double ComputeTotalDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, G4double cut=DBL_MAX)
G4double GetCSDARange(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
G4double GetRange(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
G4double ComputeNuclearDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *)
const G4ParticleDefinition * FindIon(G4int Z, G4int A)
G4double ComputeGammaAttenuationLength(G4double kinEnergy, const G4Material *)
G4double ComputeDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4String &processName, const G4Material *, G4double cut=DBL_MAX)
void SetVerbose(G4int val)
G4double ComputeEnergyCutFromRangeCut(G4double range, const G4ParticleDefinition *, const G4Material *)
G4double GetKinEnergy(G4double range, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
G4double GetRangeFromRestricteDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
G4double ComputeCrossSectionPerVolume(G4double kinEnergy, const G4ParticleDefinition *, const G4String &processName, const G4Material *, G4double cut=0.0)
G4double ComputeCrossSectionPerAtom(G4double kinEnergy, const G4ParticleDefinition *, const G4String &processName, G4double Z, G4double A, G4double cut=0.0)
void PrintDEDXTable(const G4ParticleDefinition *)
const G4Region * FindRegion(const G4String &)
G4VProcess * FindProcess(const G4ParticleDefinition *part, const G4String &processName)
G4double GetCrossSectionPerVolume(G4double kinEnergy, const G4ParticleDefinition *, const G4String &processName, const G4Material *, const G4Region *r=nullptr)
G4double ComputeCrossSectionPerShell(G4double kinEnergy, const G4ParticleDefinition *, const G4String &processName, G4int Z, G4int shellIdx, G4double cut=0.0)
G4double ComputeShellIonisationCrossSectionPerAtom(const G4String &part, G4int Z, G4AtomicShellEnumerator shell, G4double kinEnergy, const G4Material *mat=nullptr)
const G4MaterialCutsCouple * FindCouple(const G4Material *, const G4Region *r=nullptr)
void SetupMaterial(const G4Material *)
void PrintRangeTable(const G4ParticleDefinition *)
void PrintInverseRangeTable(const G4ParticleDefinition *)
G4double ComputeDEDXForCutInRange(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *mat, G4double rangecut=DBL_MAX)
G4double GetMeanFreePath(G4double kinEnergy, const G4ParticleDefinition *, const G4String &processName, const G4Material *, const G4Region *r=nullptr)
G4double ComputeElectronicDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *mat, G4double cut=DBL_MAX)
const G4Material * FindMaterial(const G4String &)
G4double EffectiveChargeSquareRatio(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
G4double EffectiveChargeCorrection(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
static G4EmParameters * Instance()
G4bool BuildCSDARange() const
G4double LowestElectronEnergy() const
static G4GenericIon * GenericIon()
G4ParticleDefinition * GetIon(G4int Z, G4int A, G4int lvl=0)
static G4LossTableManager * Instance()
const std::vector< G4VEmProcess * > & GetEmProcessVector()
G4double GetCSDARange(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
G4VEnergyLossProcess * GetEnergyLossProcess(const G4ParticleDefinition *)
G4double GetEnergy(const G4ParticleDefinition *aParticle, G4double range, const G4MaterialCutsCouple *couple)
const std::vector< G4VMultipleScattering * > & GetMultipleScatteringVector()
const std::vector< G4VEnergyLossProcess * > & GetEnergyLossProcessVector()
G4VAtomDeexcitation * AtomDeexcitation()
G4double GetRangeFromRestricteDEDX(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
G4EmCorrections * EmCorrections()
G4double GetDEDX(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
G4double GetDensity() const
const G4Element * GetElement(G4int iel) const
size_t GetNumberOfElements() const
const G4String & GetName() const
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
G4Material * FindOrBuildSimpleMaterial(G4int Z, G4bool warning=false)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static G4NistManager * Instance()
G4ProcessManager * GetProcessManager() const
const G4String & GetParticleType() const
G4double GetPDGMass() const
G4double GetPDGCharge() const
const G4String & GetParticleName() const
G4IonTable * GetIonTable() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()
static G4Positron * Positron()
G4bool GetProcessActivation(G4VProcess *aProcess) const
G4ProcessVector * GetProcessList() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
static G4ProductionCutsTable * GetProductionCutsTable()
static G4RegionStore * GetInstance()
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
G4ProductionCuts * GetProductionCuts() const
const G4String & GetName() const
virtual G4double ComputeShellIonisationCrossSectionPerAtom(const G4ParticleDefinition *, G4int Z, G4AtomicShellEnumerator shell, G4double kinE, const G4Material *mat=nullptr)=0
virtual G4double GetShellIonisationCrossSectionPerAtom(const G4ParticleDefinition *, G4int Z, G4AtomicShellEnumerator shell, G4double kinE, const G4Material *mat=nullptr)=0
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double kinEnergy, G4double Z, G4double A=0., G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
virtual void CorrectionsAlongStep(const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double &eloss, G4double &niel, G4double length)
virtual void InitialiseForMaterial(const G4ParticleDefinition *, const G4Material *)
G4double LowEnergyLimit() const
virtual G4double CrossSectionPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
void SetCurrentCouple(const G4MaterialCutsCouple *)
void SetFluctuationFlag(G4bool val)
virtual void InitialiseForElement(const G4ParticleDefinition *, G4int Z)
virtual void SetupForMaterial(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
virtual G4double ComputeCrossSectionPerShell(const G4ParticleDefinition *, G4int Z, G4int shellIdx, G4double kinEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
virtual G4double GetChargeSquareRatio(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
const G4String & GetName() const
virtual G4double ComputeDEDXPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=DBL_MAX)
G4PhysicsTable * GetCrossSectionTable()
G4VEmModel * GetModelByIndex(G4int idx=0, G4bool ver=false) const
G4double CrossSectionPerVolume(G4double kineticEnergy, const G4MaterialCutsCouple *couple, G4double logKinEnergy=DBL_MAX)
G4PhysicsTable * LambdaTable() const
G4VEmModel * SelectModelForMaterial(G4double kinEnergy, size_t idxRegion) const
virtual G4VEmProcess * GetEmProcess(const G4String &name)
const G4ParticleDefinition * BaseParticle() const
G4PhysicsTable * RangeTableForLoss() const
G4PhysicsTable * InverseRangeTable() const
G4VEmModel * SelectModelForMaterial(G4double kinEnergy, size_t &idx) const
void SetDynamicMassCharge(G4double massratio, G4double charge2ratio)
G4PhysicsTable * LambdaTable() const
G4PhysicsTable * DEDXTable() const
G4double GetTransportMeanFreePath(const G4ParticleDefinition *part, G4double kinEnergy)
G4VEmModel * SelectModel(G4double kinEnergy, size_t idx)
const G4String & GetProcessName() const