101 currentCoupleIndex = 0;
102 currentCouple =
nullptr;
103 currentMaterial = cutMaterial =
nullptr;
104 currentParticle =
nullptr;
105 lambdaParticle =
nullptr;
106 baseParticle =
nullptr;
107 currentLambda =
nullptr;
108 currentModel =
nullptr;
109 currentProcess =
nullptr;
115 cutenergy[0] = cutenergy[1] = cutenergy[2] =
DBL_MAX;
116 currentParticleName=
"";
117 currentMaterialName=
"";
124 isApplicable =
false;
132 for (
G4int i=0; i<nLocalMaterials; ++i) {
133 delete localCouples[i];
146 if(couple && UpdateParticle(p, kinEnergy) ) {
147 res = manager->
GetDEDX(p, kinEnergy, couple);
150 if(FindEmModel(p, currentProcessName, kinEnergy)) {
166 G4cout <<
"G4EmCalculator::GetDEDX: E(MeV)= " << kinEnergy/
MeV
167 <<
" DEDX(MeV/mm)= " << res*
mm/
MeV
171 <<
" isIon= " << isIon
187 if(couple && UpdateParticle(p, kinEnergy)) {
190 G4cout <<
" G4EmCalculator::GetRangeFromRestrictedDEDX: E(MeV)= "
192 <<
" range(mm)= " << res/
mm
211 ed <<
"G4EmCalculator::GetCSDARange: CSDA table is not built; "
212 <<
" use UI command: /process/eLoss/CSDARange true";
213 G4Exception(
"G4EmCalculator::GetCSDARange",
"em0077",
219 if(couple && UpdateParticle(p, kinEnergy)) {
222 G4cout <<
" G4EmCalculator::GetCSDARange: E(MeV)= " << kinEnergy/
MeV
223 <<
" range(mm)= " << res/
mm
257 if(couple && UpdateParticle(p, 1.0*
GeV)) {
258 res = manager->
GetEnergy(p, range, couple);
260 G4cout <<
"G4EmCalculator::GetKinEnergy: Range(mm)= " << range/
mm
261 <<
" KinE(MeV)= " << res/
MeV
281 if(couple && UpdateParticle(p, kinEnergy)) {
283 FindLambdaTable(p, processName, kinEnergy);
287 res = (((*currentLambda)[idx])->Value(e))*chargeSquare;
293 G4cout <<
"G4EmCalculator::GetXSPerVolume: E(MeV)= " << kinEnergy/
MeV
294 <<
" cross(cm-1)= " << res*
cm
298 G4cout <<
" idx= " << idx <<
" Escaled((MeV)= "
299 << kinEnergy*massRatio
300 <<
" q2= " << chargeSquare;
334 if(x > 0.0) { res = 1.0/x; }
336 G4cout <<
"G4EmCalculator::GetMeanFreePath: E(MeV)= " << kinEnergy/
MeV
337 <<
" MFP(mm)= " << res/
mm
368 G4cout <<
"### G4EmCalculator: Inverse Range Table for "
385 <<
" in " << currentMaterialName
386 <<
" e(MeV)= " << kinEnergy/
MeV <<
" cut(MeV)= " << cut/
MeV
389 if(UpdateParticle(p, kinEnergy)) {
390 if(FindEmModel(p, processName, kinEnergy)) {
393 if(currentModel->
GetName() ==
"ParamICRU73") {
396 G4cout <<
" ICRU73 ion E(MeV)= " << kinEnergy <<
" ";
398 <<
" DEDX(MeV*cm^2/g)= "
404 G4double escaled = kinEnergy*massRatio;
407 mat, baseParticle, escaled, cut) * chargeSquare;
410 <<
" Escaled(MeV)= " << escaled;
414 if(verbose > 1) {
G4cout <<
" no basePart E(MeV)= " << kinEnergy <<
" "; }
418 <<
" DEDX(MeV*cm^2/g)= "
439 G4cout <<
"At boundary energy(MeV)= " << eth/
MeV
440 <<
" DEDX(MeV/mm)= " << res1*
mm/
MeV
448 if(res1 > 0.0 && escaled > 0.0) {
449 res *= (1.0 + (res0/res1 - 1.0)*eth/escaled);
466 G4cout <<
"After Corrections: DEDX(MeV/mm)= " << res*
mm/
MeV
474 G4cout <<
"Sum: E(MeV)= " << kinEnergy/
MeV
475 <<
" DEDX(MeV/mm)= " << res*
mm/
MeV
477 <<
" cut(MeV)= " << cut/
MeV
479 <<
" in " << currentMaterialName
480 <<
" Zi^2= " << chargeSquare
481 <<
" isIon=" << isIon
497 if(UpdateParticle(part, kinEnergy)) {
500 const std::vector<G4VEnergyLossProcess*> vel =
507 for(
G4int i=0; i<
n; ++i) {
510 if(ActiveForParticle(part, p)) {
513 dedx +=
ComputeDEDX(kinEnergy,part,(vel[i])->GetProcessName(),mat,cut);
530 if(UpdateParticle(part, kinEnergy)) {
533 const std::vector<G4VEnergyLossProcess*> vel =
537 if(mat != cutMaterial) {
547 for(
G4int i=0; i<
n; ++i) {
550 if(ActiveForParticle(part, p)) {
558 dedx +=
ComputeDEDX(kinEnergy,part,(vel[i])->GetProcessName(),
590 <<
" NuclearDEDX(MeV/mm)= " << res*
mm/
MeV
591 <<
" NuclearDEDX(MeV*cm^2/g)= "
609 if(UpdateParticle(p, kinEnergy)) {
610 if(FindEmModel(p, processName, kinEnergy)) {
614 e *= kinEnergy*massRatio;
616 mat, baseParticle, e, aCut, e) * chargeSquare;
621 G4cout <<
"G4EmCalculator::ComputeXSPerVolume: E(MeV)= " << kinEnergy/
MeV
622 <<
" cross(cm-1)= " << res*
cm
623 <<
" cut(keV)= " << aCut/
keV
643 if(UpdateParticle(p, kinEnergy)) {
646 if(FindEmModel(p, processName, kinEnergy)) {
650 e *= kinEnergy*massRatio;
653 baseParticle, e, Z, A, aCut) * chargeSquare;
660 <<
" cross(barn)= " << res/
barn
662 <<
" Z= " << Z <<
" A= " << A/(
g/
mole) <<
" g/mole"
663 <<
" cut(keV)= " << aCut/
keV
680 if(UpdateParticle(p, kinEnergy)) {
682 if(FindEmModel(p, processName, kinEnergy)) {
686 e *= kinEnergy*massRatio;
689 e, aCut) * chargeSquare;
696 <<
" cross(barn)= " << res/
barn
698 <<
" Z= " << Z <<
" shellIdx= " << shellIdx
699 <<
" cut(keV)= " << aCut/
keV
719 if(res > 0.0) { res = 1.0/res; }
752 if(x > 0.0) { mfp = 1.0/x; }
755 <<
" MFP(mm)= " << mfp/
mm
771 ConvertRangeToEnergy(part, mat, range);
779 if(p != currentParticle) {
783 dynParticle.
SetDefinition(const_cast<G4ParticleDefinition*>(p));
790 currentProcess = FindEnergyLossProcess(p);
791 currentProcessName =
"";
807 && currentParticleName !=
"deuteron"
808 && currentParticleName !=
"triton"
809 && currentParticleName !=
"alpha+"
810 && currentParticleName !=
"helium"
811 && currentParticleName !=
"hydrogen"
815 baseParticle = theGenericIon;
817 G4cout <<
"\n G4EmCalculator::UpdateParticle: isIon 1 "
819 <<
" in " << currentMaterial->
GetName()
820 <<
" e= " << kinEnergy <<
G4endl;
834 G4cout <<
"\n NewIon: massR= "<< massRatio <<
" q2= "
835 << chargeSquare <<
" " << currentProcess <<
G4endl;
847 if(name != currentParticleName) {
850 G4cout <<
"### WARNING: G4EmCalculator::FindParticle fails to find "
871 if(name != currentMaterialName) {
873 if(!currentMaterial) {
874 G4cout <<
"### WARNING: G4EmCalculator::FindMaterial fails to find "
878 return currentMaterial;
886 if(reg !=
"" && reg !=
"world") {
902 if(currentMaterial) {
912 size_t nr = store->size();
914 for(
size_t i=0; i<nr; ++i) {
916 material, ((*store)[i])->GetProductionCuts());
917 if(couple) {
break; }
924 ed <<
"G4EmCalculator::FindCouple: fail for material <"
925 << currentMaterialName <<
">";
926 if(region) { ed <<
" and region " << region->
GetName(); }
927 G4Exception(
"G4EmCalculator::FindCouple",
"em0078",
938 if(!currentMaterial) {
return false; }
939 for (
G4int i=0; i<nLocalMaterials; ++i) {
940 if(material == localMaterials[i] && cut == localCuts[i]) {
941 currentCouple = localCouples[i];
942 currentCoupleIndex = currentCouple->
GetIndex();
948 localMaterials.push_back(material);
949 localCouples.push_back(cc);
950 localCuts.push_back(cut);
953 currentCoupleIndex = currentCouple->
GetIndex();
965 if (!currentLambda || p != lambdaParticle || processName != lambdaName) {
966 lambdaName = processName;
971 if(isIon) { part = theGenericIon; }
974 currentName = processName;
984 G4cout <<
"G4VEnergyLossProcess is found out: " << currentName
992 G4VEmProcess* proc = FindDiscreteProcess(part, processName);
998 G4cout <<
"G4VEmProcess is found out: " << currentName <<
G4endl;
1011 isApplicable =
true;
1013 G4cout <<
"G4VMultipleScattering is found out: " << currentName
1028 isApplicable =
false;
1029 if(!p || !currentMaterial) {
1030 G4cout <<
"G4EmCalculator::FindEmModel WARNING: no particle"
1031 <<
" or materail defined; particle: " << p <<
G4endl;
1032 return isApplicable;
1036 G4double scaledEnergy = kinEnergy*massRatio;
1037 if(isIon) { part = theGenericIon; }
1040 G4cout <<
"## G4EmCalculator::FindEmModel for " << partname
1042 <<
") and " << processName <<
" at E(MeV)= " << scaledEnergy
1044 if(p != part) {
G4cout <<
" GenericIon is the base particle" <<
G4endl; }
1048 currentName = processName;
1061 if(loweModel == currentModel) { loweModel =
nullptr; }
1071 G4VEmProcess* proc = FindDiscreteProcess(part, processName);
1079 if(loweModel == currentModel) { loweModel = 0; }
1097 if(loweModel == currentModel) { loweModel = 0; }
1098 isApplicable =
true;
1112 G4cout <<
" LowEnergy model <" << loweModel->
GetName() <<
">";
1117 return isApplicable;
1130 && currentParticleName !=
"deuteron"
1131 && currentParticleName !=
"triton"
1132 && currentParticleName !=
"He3"
1133 && currentParticleName !=
"alpha"
1134 && currentParticleName !=
"alpha+"
1135 && currentParticleName !=
"helium"
1136 && currentParticleName !=
"hydrogen"
1137 ) { part = theGenericIon; }
1155 const std::vector<G4VEnergyLossProcess*> v =
1158 for(
G4int i=0; i<
n; ++i) {
1159 if((v[i])->GetProcessName() == processName) {
1161 if(ActiveForParticle(part, p)) {
1177 const std::vector<G4VEmProcess*> v =
1180 for(
G4int i=0; i<
n; ++i) {
1181 if((v[i])->GetProcessName() == processName) {
1183 if(ActiveForParticle(part, p)) {
1199 const std::vector<G4VMultipleScattering*> v =
1202 for(
G4int i=0; i<
n; ++i) {
1203 if((v[i])->GetProcessName() == processName) {
1205 if(ActiveForParticle(part, p)) {
1223 for(
G4int i=0; i<nproc; ++i) {
1224 if(processName == (*pv)[i]->GetProcessName()) {
1242 for(
G4int i=0; i<
n; ++i) {
1243 if((*pv)[i] == proc) {
1256 currentMaterial = mat;
1257 currentMaterialName = mat->
GetName();
1259 currentMaterial = 0;
1260 currentMaterialName =
"";
1273 void G4EmCalculator::CheckMaterial(
G4int Z)
1276 if(currentMaterial) {
1278 for(
size_t i=0; i<
nn; ++i) {
G4PhysicsTable * LambdaTable() const
G4ProductionCuts * GetProductionCuts() const
G4double LowEnergyLimit() const
virtual G4double CrossSectionPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
G4VEmModel * SelectModel(G4double kinEnergy, size_t idx)
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
virtual void InitialiseForElement(const G4ParticleDefinition *, G4int Z)
const G4String & GetName() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4LossTableManager * Instance()
const G4MaterialCutsCouple * FindCouple(const G4Material *, const G4Region *r=nullptr)
static constexpr double mm
virtual G4double GetShellIonisationCrossSectionPerAtom(const G4ParticleDefinition *, G4int Z, G4AtomicShellEnumerator shell, G4double kinE, const G4Material *mat=nullptr)=0
virtual void CorrectionsAlongStep(const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double &eloss, G4double &niel, G4double length)
void SetDynamicMassCharge(G4double massratio, G4double charge2ratio)
std::ostringstream G4ExceptionDescription
G4double GetDEDX(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
const G4Material * FindMaterial(const G4String &)
static constexpr double cm2
G4double GetRange(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
G4Material * FindOrBuildSimpleMaterial(G4int Z, G4bool warning=false)
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
G4double LowestElectronEnergy() const
G4PhysicsTable * RangeTableForLoss() const
G4double EffectiveChargeSquareRatio(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
const G4String & GetName() const
void PrintRangeTable(const G4ParticleDefinition *)
G4ParticleDefinition * GetIon(G4int Z, G4int A, G4int lvl=0)
virtual void SetupForMaterial(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
G4double GetDensity() const
G4double ComputeTotalDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, G4double cut=DBL_MAX)
G4double ComputeElectronicDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *mat, G4double cut=DBL_MAX)
G4double GetCSDARange(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
G4PhysicsTable * GetCrossSectionTable()
G4double EffectiveChargeCorrection(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
static constexpr double g
void SetupMaterial(const G4Material *)
void PrintInverseRangeTable(const G4ParticleDefinition *)
const G4Element * GetElement(G4int iel) const
const std::vector< G4VEmProcess * > & GetEmProcessVector()
G4double GetKinEnergy(G4double range, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
static G4NistManager * Instance()
const G4String & GetParticleName() const
G4double GetCSDARange(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
static const G4double reg
static constexpr double gram
static G4RegionStore * GetInstance()
G4bool BuildCSDARange() const
G4double GetShellIonisationCrossSectionPerAtom(const G4String &part, G4int Z, G4AtomicShellEnumerator shell, G4double kinEnergy)
G4PhysicsTable * LambdaTable() const
G4double ComputeShellIonisationCrossSectionPerAtom(const G4String &part, G4int Z, G4AtomicShellEnumerator shell, G4double kinEnergy, const G4Material *mat=nullptr)
G4IonTable * GetIonTable() const
virtual void InitialiseForMaterial(const G4ParticleDefinition *, const G4Material *)
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
G4PhysicsTable * DEDXTable() const
G4double ComputeDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4String &processName, const G4Material *, G4double cut=DBL_MAX)
G4double NuclearDEDX(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy, G4bool fluct=true)
virtual G4double ComputeShellIonisationCrossSectionPerAtom(const G4ParticleDefinition *, G4int Z, G4AtomicShellEnumerator shell, G4double kinE, const G4Material *mat=nullptr)=0
G4EmCorrections * EmCorrections()
G4double GetRangeFromRestricteDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
G4double GetDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *, const G4Region *r=nullptr)
G4double ComputeNuclearDEDX(G4double kinEnergy, const G4ParticleDefinition *, const G4Material *)
static constexpr double cm
const G4String & GetParticleType() const
const G4ParticleDefinition * BaseParticle() const
G4double GetEnergy(const G4ParticleDefinition *aParticle, G4double range, const G4MaterialCutsCouple *couple)
const G4String & GetProcessName() const
const std::vector< G4VEnergyLossProcess * > & GetEnergyLossProcessVector()
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double kinEnergy, G4double Z, G4double A=0., G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
void SetKineticEnergy(G4double aEnergy)
G4double GetRangeFromRestricteDEDX(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
static constexpr double eV
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4double GetCrossSectionPerVolume(G4double kinEnergy, const G4ParticleDefinition *, const G4String &processName, const G4Material *, const G4Region *r=nullptr)
virtual G4double GetChargeSquareRatio(const G4ParticleDefinition *, const G4Material *, G4double kineticEnergy)
G4VEnergyLossProcess * GetEnergyLossProcess(const G4ParticleDefinition *)
static G4ProductionCutsTable * GetProductionCutsTable()
static G4Positron * Positron()
static G4GenericIon * GenericIon()
virtual G4double ComputeDEDXPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=DBL_MAX)
G4VEmModel * SelectModelForMaterial(G4double kinEnergy, size_t &idxRegion) const
const G4ParticleDefinition * FindParticle(const G4String &)
G4PhysicsTable * InverseRangeTable() const
static constexpr double nm
G4double GetPDGMass() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
static G4ParticleTable * GetParticleTable()
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4double ComputeMeanFreePath(G4double kinEnergy, const G4ParticleDefinition *, const G4String &processName, const G4Material *, G4double cut=0.0)
G4ProcessManager * GetProcessManager() const
G4double ComputeCrossSectionPerShell(G4double kinEnergy, const G4ParticleDefinition *, const G4String &processName, G4int Z, G4int shellIdx, G4double cut=0.0)
const G4Region * FindRegion(const G4String &)
const G4ParticleDefinition * FindIon(G4int Z, G4int A)
static G4EmParameters * Instance()
G4double ComputeCrossSectionPerVolume(G4double kinEnergy, const G4ParticleDefinition *, const G4String &processName, const G4Material *, G4double cut=0.0)
static constexpr double GeV
virtual G4double ComputeCrossSectionPerShell(const G4ParticleDefinition *, G4int Z, G4int shellIdx, G4double kinEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
G4double ComputeGammaAttenuationLength(G4double kinEnergy, const G4Material *)
G4bool GetProcessActivation(G4VProcess *aProcess) const
static G4Electron * Electron()
static constexpr double MeV
G4double ComputeCrossSectionPerAtom(G4double kinEnergy, const G4ParticleDefinition *, const G4String &processName, G4double Z, G4double A, G4double cut=0.0)
const G4String & GetName() const
G4VProcess * FindProcess(const G4ParticleDefinition *part, const G4String &processName)
size_t GetNumberOfElements() const
void SetVerbose(G4int val)
void PrintDEDXTable(const G4ParticleDefinition *)
G4VAtomDeexcitation * AtomDeexcitation()
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
G4double ComputeEnergyCutFromRangeCut(G4double range, const G4ParticleDefinition *, const G4Material *)
static constexpr double barn
G4double GetPDGCharge() const
static constexpr double keV
static constexpr double mole
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)
const std::vector< G4VMultipleScattering * > & GetMultipleScatteringVector()
G4VEmModel * SelectModelForMaterial(G4double kinEnergy, size_t &idx) const
G4ProcessVector * GetProcessList() const