Import Geant4 11.2.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2023-06-30 09:09:57 +02:00
parent aef78ca386
commit dd1f179cda
3780 changed files with 212808 additions and 142780 deletions
@@ -1,32 +0,0 @@
# --------------------------------------------------------------------
# GNUmakefile for electromagnetic sub-library. John Allison, 25/6/98.
# --------------------------------------------------------------------
name := G4emutils
ifndef G4INSTALL
G4INSTALL = ../../../..
endif
include $(G4INSTALL)/config/architecture.gmk
CPPFLAGS += -I$(G4BASE)/global/management/include \
-I$(G4BASE)/global/HEPRandom/include \
-I$(G4BASE)/global/HEPGeometry/include \
-I$(G4BASE)/geometry/management/include \
-I$(G4BASE)/geometry/volumes/include \
-I$(G4BASE)/geometry/navigation/include \
-I$(G4BASE)/track/include \
-I$(G4BASE)/processes/management/include \
-I$(G4BASE)/processes/cuts/include \
-I$(G4BASE)/processes/transportation/include \
-I$(G4BASE)/particles/management/include \
-I$(G4BASE)/particles/bosons/include \
-I$(G4BASE)/particles/leptons/include \
-I$(G4BASE)/particles/hadrons/barions/include \
-I$(G4BASE)/particles/hadrons/mesons/include \
-I$(G4BASE)/particles/hadrons/ions/include \
-I$(G4BASE)/intercoms/include \
-I$(G4BASE)/materials/include
include $(G4INSTALL)/config/common.gmk
+46 -8
View File
@@ -6,26 +6,64 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2023-06-02 J.Hahnfeld (emutils-V11-00-40)
## 2023-06-16 V.Ivanchenko (emutils-V11-01-13)
- G4LossTableManager - fixed trivial Coverity report
## 2023-06-04 V.Ivanchenko (emutils-V11-01-12)
- G4VEmModel - use LPM flag from G4EmParameters
## 2023-06-02 J.Hahnfeld (emutils-V11-01-11)
- Fixes to `G4TransportationWithMsc`:
* Protect code for MultipleScattering
* Fix type of particle change
## 2023-04-08 V.Ivanchenko
- G4LossTableManager - improved debug printout and removed unused lines of code
## 2023-06-01 V.Ivanchenko (emutils-V11-01-10)
- G4LossTableManager - reserve memory for internal vectors; simplified
destructor; move a part of initialisation of class members to header
- G4ionEffectiveCharge - minor optimisation
## 2023-03-20 V.Ivanchenko
## 2023-05-23 V.Ivanchenko (emutils-V11-01-09)
- G4VEnergyLossProcess - added extra protection excluding negative range;
rename class member; change condition to stop low-energy ion - use kinetic
energy and not scaled energy; is proposed to address git issue #168
- G4VMscModel - removed empty lines
## 2023-05-04 V.Ivanchenko (emutils-V11-01-08)
- G4VEnergyLossProcess - added extra protection for the case of negative
range of low-energy particle (problem #2542)
## 2023-04-20 V.Ivanchenko (emutils-V11-01-07)
- G4VEnergyLossProcess - make more straightforward computation of ion
effective charge
- G4VEmModel - trigger computation of ion effective charge for G4EmCalculator
- G4EmCalculator - improved printout
## 2023-04-08 V.Ivanchenko (emutils-V11-01-06)
- G4LossTableManager - improved debug printout and removed unused lines of code
- G4LossTableBuilder, G4VEnergyLossProcess - improved debug printout
## 2023-04-03 V.Ivanchenko (emutils-V11-01-05)
- G4VEnergyLossProcess, G4VEmProcess, G4VMultipleScattering - use flag of
master thread from G4LossTableManager
- G4EmCorrections - class format, removed lock of threads instead use
flag from G4LossTableManager
## 2023-03-20 V.Ivanchenko (emutils-V11-01-04)
- G4VEnergyLossProcess - fixed static analyzer warning
- G4EmTableUtil - fixed verbose output and class comments
## 2023-03-06 J.Allison
## 2023-03-06 J.Allison (emutils-V11-01-03)
- Allow /process/em/QuantumEntanglement in G4State_Idle.
## 2023-02-21 V.Ivanchenko
## 2023-02-21 V.Ivanchenko (emutils-V11-01-02)
- G4EmExtraParameters - fixed AddPAIModel(...) method and improved comments
- G4EmExtraParametersMessenger - fixed broadcasting
- G4EmExtraParametersMessenger - fixed broadcasting
## 2022-12-11 V.Ivanchenko (emutils-V11-00-39)
## 2023-01-10 V.Ivanchenko (emutils-V11-01-01)
- G4EmParameters - added extra member and access method to G4LEDATA path
allowing check environment variable for the EM data only once
## 2022-12-11 V.Ivanchenko (emutils-V11-01-00)
- G4EmParameters, G4EmParametersMessenger, added parameter, UI command,
GetSet methods - MscPositronCorrection
@@ -59,7 +59,6 @@
#include "G4ionEffectiveCharge.hh"
#include "G4Material.hh"
#include "G4ParticleDefinition.hh"
#include "G4Threading.hh"
class G4VEmModel;
class G4PhysicsVector;
@@ -73,7 +72,7 @@ class G4EmCorrections
public:
explicit G4EmCorrections(G4int verb);
explicit G4EmCorrections(G4int verb, G4bool master);
~G4EmCorrections();
@@ -194,63 +193,60 @@ private:
const G4ParticleDefinition* particle = nullptr;
const G4ParticleDefinition* curParticle = nullptr;
const G4Material* material = nullptr;
const G4Material* curMaterial = nullptr;
const G4ElementVector* theElementVector = nullptr;
const G4double* atomDensity = nullptr;
const G4Material* material = nullptr;
const G4Material* curMaterial = nullptr;
const G4ElementVector* theElementVector = nullptr;
const G4double* atomDensity = nullptr;
G4PhysicsVector* curVector = nullptr;
G4PhysicsVector* curVector = nullptr;
G4VEmModel* ionLEModel = nullptr;
G4VEmModel* ionHEModel = nullptr;
G4VEmModel* ionLEModel = nullptr;
G4VEmModel* ionHEModel = nullptr;
G4double kinEnergy = 0.0;
G4double mass = 0.0;
G4double massFactor = 1.0;
G4double eth;
G4double tau = 0.0;
G4double gamma = 1.0;
G4double bg2 = 0.0;
G4double beta2 = 0.0;
G4double beta = 0.0;
G4double ba2 = 0.0;
G4double tmax = 0.0;
G4double charge = 0.0;
G4double q2 = 0.0;
G4double eCorrMin;
G4double eCorrMax;
G4double kinEnergy = 0.0;
G4double mass = 0.0;
G4double massFactor = 1.0;
G4double tau = 0.0;
G4double gamma = 1.0;
G4double bg2 = 0.0;
G4double beta2 = 0.0;
G4double beta = 0.0;
G4double ba2 = 0.0;
G4double tmax = 0.0;
G4double charge = 0.0;
G4double q2 = 0.0;
G4double eth;
G4double eCorrMin;
G4double eCorrMax;
G4bool isMaster = false;
size_t ncouples = 0;
G4int verbose;
G4int nK;
G4int nL;
G4int nEtaK;
G4int nEtaL;
G4int nbinCorr = 52;
G4int numberOfElements = 0;
std::size_t ncouples = 0;
G4int nK = 20;
G4int nL = 26;
G4int nEtaK = 29;
G4int nEtaL = 28;
G4int nbinCorr = 52;
G4int numberOfElements = 0;
// Ion stopping data
G4int nIons = 0;
G4int idx = 0;
G4int currentZ = 0;
G4int nIons = 0;
G4int idx = 0;
G4int currentZ = 0;
std::vector<G4int> Zion;
std::vector<G4int> Aion;
std::vector<G4String> materialName;
G4int verbose;
G4bool isMaster;
std::vector<G4int> Zion;
std::vector<G4int> Aion;
std::vector<G4String> materialName;
std::vector<const G4ParticleDefinition*> ionList;
std::map< G4int, std::vector<G4double> > thcorr;
std::vector<const G4Material*> currmat;
std::vector<const G4Material*> materialList;
std::vector<G4PhysicsVector*> stopData;
std::vector<G4PhysicsVector*> stopData;
G4ionEffectiveCharge effCharge;
G4ionEffectiveCharge effCharge;
static const G4double ZD[11];
static const G4double UK[20];
@@ -265,10 +261,6 @@ private:
static G4PhysicsFreeVector* sBarkasCorr;
static G4PhysicsFreeVector* sThetaK;
static G4PhysicsFreeVector* sThetaL;
#ifdef G4MULTITHREADED
static G4Mutex theCorrMutex;
#endif
};
inline G4int
@@ -385,6 +385,8 @@ public:
void DefineRegParamForEM(G4VEmProcess*) const;
void DefineRegParamForDeex(G4VAtomDeexcitation*) const;
const G4String& GetDirLEDATA() const;
G4EmParameters(G4EmParameters &) = delete;
G4EmParameters & operator=(const G4EmParameters &right) = delete;
@@ -463,6 +465,8 @@ private:
G4NuclearFormfactorType nucFormfactor;
G4eSingleScatteringType fSStype;
G4EmFluctuationType fFluct;
G4String fDirLEDATA;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -90,13 +90,13 @@ public:
//-------------------------------------------------
void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
G4VEnergyLossProcess* p, G4bool theMaster);
G4VEnergyLossProcess* p);
void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
G4VEmProcess* p, G4bool theMaster);
G4VEmProcess* p);
void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
G4VMultipleScattering* p, G4bool theMaster);
G4VMultipleScattering* p);
void BuildPhysicsTable(const G4ParticleDefinition* aParticle);
@@ -255,49 +255,49 @@ private:
typedef const G4ParticleDefinition* PD;
std::map<PD,G4VEnergyLossProcess*,std::less<PD> > loss_map;
// cache
G4VEnergyLossProcess* currentLoss{nullptr};
PD currentParticle{nullptr};
PD theElectron;
PD theGenericIon{nullptr};
PD firstParticle{nullptr};
G4LossTableBuilder* tableBuilder;
G4EmCorrections* emCorrections;
G4EmConfigurator* emConfigurator{nullptr};
G4ElectronIonPair* emElectronIonPair{nullptr};
G4NIELCalculator* nielCalculator{nullptr};
G4VAtomDeexcitation* atomDeexcitation{nullptr};
G4VSubCutProducer* subcutProducer{nullptr};
G4EmParameters* theParameters;
G4VEmProcess* gGeneral{nullptr};
G4VEmProcess* eGeneral{nullptr};
G4VEmProcess* pGeneral{nullptr};
G4int verbose;
G4int n_loss{0};
G4int run{-1};
G4bool all_tables_are_built{false};
G4bool startInitialisation{false};
G4bool isMaster{true};
std::vector<G4VEnergyLossProcess*> loss_vector;
std::vector<PD> part_vector;
std::vector<PD> base_part_vector;
std::vector<G4bool> tables_are_built;
std::vector<G4bool> isActive;
std::vector<G4PhysicsTable*> dedx_vector;
std::vector<G4PhysicsTable*> range_vector;
std::vector<G4PhysicsTable*> inv_range_vector;
std::vector<G4bool> tables_are_built;
std::vector<G4bool> isActive;
std::vector<G4VMultipleScattering*> msc_vector;
std::vector<G4VEmProcess*> emp_vector;
std::vector<G4VEmModel*> mod_vector;
std::vector<G4VEmFluctuationModel*> fmod_vector;
std::vector<G4VProcess*> p_vector;
// cache
G4VEnergyLossProcess* currentLoss;
PD currentParticle;
PD theElectron;
PD theGenericIon;
PD firstParticle;
G4LossTableBuilder* tableBuilder;
G4EmCorrections* emCorrections;
G4EmConfigurator* emConfigurator;
G4ElectronIonPair* emElectronIonPair;
G4NIELCalculator* nielCalculator;
G4VAtomDeexcitation* atomDeexcitation;
G4VSubCutProducer* subcutProducer;
G4EmParameters* theParameters;
G4VEmProcess* gGeneral;
G4VEmProcess* eGeneral;
G4VEmProcess* pGeneral;
G4int verbose;
G4int n_loss;
G4int run;
G4bool all_tables_are_built;
G4bool startInitialisation;
G4bool isMaster;
std::map<PD,G4VEnergyLossProcess*,std::less<PD> > loss_map;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -317,6 +317,10 @@ public:
void SetCrossSectionTable(G4PhysicsTable*, G4bool isLocal);
G4bool LPMFlag() const;
void SetLPMFlag(G4bool val);
inline G4ElementData* GetElementData();
inline G4PhysicsTable* GetCrossSectionTable();
@@ -343,8 +347,6 @@ public:
inline G4double SecondaryThreshold() const;
inline G4bool LPMFlag() const;
inline G4bool DeexcitationFlag() const;
inline G4bool ForceBuildTableFlag() const;
@@ -367,8 +369,6 @@ public:
inline void SetSecondaryThreshold(G4double);
inline void SetLPMFlag(G4bool val);
inline void SetDeexcitationFlag(G4bool val);
inline void SetForceBuildTable(G4bool val);
@@ -447,7 +447,6 @@ protected:
private:
G4bool theLPMflag = false;
G4bool flagDeexcitation = false;
G4bool flagForceBuildTable = false;
G4bool isMaster = true;
@@ -673,13 +672,6 @@ inline G4double G4VEmModel::SecondaryThreshold() const
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
inline G4bool G4VEmModel::LPMFlag() const
{
return theLPMflag;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
inline G4bool G4VEmModel::DeexcitationFlag() const
{
return flagDeexcitation;
@@ -792,13 +784,6 @@ inline void G4VEmModel::SetSecondaryThreshold(G4double val)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
inline void G4VEmModel::SetLPMFlag(G4bool val)
{
theLPMflag = val;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
inline void G4VEmModel::SetDeexcitationFlag(G4bool val)
{
flagDeexcitation = val;
@@ -505,7 +505,7 @@ private:
G4CrossSectionType fXSType = fEmOnePeak;
G4bool lossFluctuationFlag = true;
G4bool rndmStepFlag = false;
G4bool useCutAsFinalRange = false;
G4bool tablesAreBuilt = false;
G4bool spline = true;
G4bool isIon = false;
@@ -616,7 +616,8 @@ inline G4double G4VEnergyLossProcess::GetScaledRangeForScaledEnergy(G4double e)
coupleIdxRange = currentCoupleIndex;
fRangeEnergy = e;
fRange = reduceFactor*((*theRangeTableForLoss)[basedCoupleIndex])->Value(e, idxRange);
if(e < minKinEnergy) { fRange *= std::sqrt(e/minKinEnergy); }
if (fRange < 0.0) { fRange = 0.0; }
else if (e < minKinEnergy) { fRange *= std::sqrt(e/minKinEnergy); }
}
//G4cout << "G4VEnergyLossProcess::GetScaledRange: Idx= "
// << basedCoupleIndex << " E(MeV)= " << e
@@ -634,7 +635,8 @@ G4VEnergyLossProcess::GetScaledRangeForScaledEnergy(G4double e, G4double loge)
coupleIdxRange = currentCoupleIndex;
fRangeEnergy = e;
fRange = reduceFactor*((*theRangeTableForLoss)[basedCoupleIndex])->LogVectorValue(e, loge);
if(e < minKinEnergy) { fRange *= std::sqrt(e/minKinEnergy); }
if (fRange < 0.0) { fRange = 0.0; }
else if (e < minKinEnergy) { fRange *= std::sqrt(e/minKinEnergy); }
}
//G4cout << "G4VEnergyLossProcess::GetScaledRange: Idx= "
// << basedCoupleIndex << " E(MeV)= " << e
@@ -648,7 +650,8 @@ inline G4double
G4VEnergyLossProcess::GetLimitScaledRangeForScaledEnergy(G4double e)
{
G4double x = ((*theCSDARangeTable)[basedCoupleIndex])->Value(e, idxCSDA);
if(e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); }
if (x < 0.0) { x = 0.0; }
else if (e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); }
return x;
}
@@ -659,7 +662,8 @@ G4VEnergyLossProcess::GetLimitScaledRangeForScaledEnergy(G4double e,
G4double loge)
{
G4double x = ((*theCSDARangeTable)[basedCoupleIndex])->LogVectorValue(e, loge);
if(e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); }
if (x < 0.0) { x = 0.0; }
else if (e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); }
return x;
}
@@ -1011,7 +1011,7 @@ G4bool G4EmCalculator::FindEmModel(const G4ParticleDefinition* p,
if(nullptr != elproc) {
currentModel = elproc->SelectModelForMaterial(scaledEnergy, idx);
currentModel->InitialiseForMaterial(part, currentMaterial);
currentModel->SetupForMaterial(part, currentMaterial, scaledEnergy);
currentModel->SetupForMaterial(part, currentMaterial, kinEnergy);
G4double eth = currentModel->LowEnergyLimit();
if(eth > 0.0) {
loweModel = elproc->SelectModelForMaterial(eth - CLHEP::eV, idx);
@@ -71,13 +71,14 @@
#include "G4Log.hh"
#include "G4Exp.hh"
#include "G4Pow.hh"
#include "G4Threading.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
const G4double inveplus = 1.0/CLHEP::eplus;
const G4double alpha2 = CLHEP::fine_structure_const*CLHEP::fine_structure_const;
namespace
{
constexpr G4double inveplus = 1.0/CLHEP::eplus;
constexpr G4double alpha2 = CLHEP::fine_structure_const*CLHEP::fine_structure_const;
}
const G4double G4EmCorrections::ZD[11] =
{0., 0., 0., 1.72, 2.09, 2.48, 2.82, 3.16, 3.53, 3.84, 4.15};
const G4double G4EmCorrections::UK[20] = {1.9999, 2.0134, 2.0258, 2.0478, 2.0662,
@@ -107,47 +108,25 @@ G4PhysicsFreeVector* G4EmCorrections::sBarkasCorr = nullptr;
G4PhysicsFreeVector* G4EmCorrections::sThetaK = nullptr;
G4PhysicsFreeVector* G4EmCorrections::sThetaL = nullptr;
#ifdef G4MULTITHREADED
G4Mutex G4EmCorrections::theCorrMutex = G4MUTEX_INITIALIZER;
#endif
G4EmCorrections::G4EmCorrections(G4int verb)
G4EmCorrections::G4EmCorrections(G4int verb, G4bool master)
: verbose(verb), isMaster(master)
{
verbose = verb;
eth = 2.0*CLHEP::MeV;
eth = 2.0*CLHEP::MeV;
eCorrMin = 25.*CLHEP::keV;
eCorrMax = 1.*CLHEP::GeV;
ionTable = G4ParticleTable::GetParticleTable()->GetIonTable();
g4calc = G4Pow::GetInstance();
// G.S. Khandelwal Nucl. Phys. A116(1968)97 - 111.
// "Shell corrections for K- and L- electrons
nK = 20;
nL = 26;
nEtaK = 29;
nEtaL = 28;
// fill vectors
if(sBarkasCorr == nullptr) {
#ifdef G4MULTITHREADED
G4MUTEXLOCK(&theCorrMutex);
if (sBarkasCorr == nullptr) {
#endif
Initialise();
isMaster = true;
#ifdef G4MULTITHREADED
}
G4MUTEXUNLOCK(&theCorrMutex);
#endif
}
if(isMaster) { Initialise(); }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4EmCorrections::~G4EmCorrections()
{
for(G4int i=0; i<nIons; ++i) {delete stopData[i];}
for(G4int i=0; i<nIons; ++i) { delete stopData[i]; }
if(isMaster) {
delete sBarkasCorr;
delete sThetaK;
@@ -924,6 +903,9 @@ void G4EmCorrections::Initialise()
// Z^3 Barkas effect in the stopping power of matter for charged particles
// J.C Ashley and R.H.Ritchie
// Physical review B Vol.5 No.7 1 April 1972 pagg. 2393-2397
// G.S. Khandelwal Nucl. Phys. A116(1968)97 - 111.
// "Shell corrections for K- and L- electrons
G4int i, j;
static const G4double fTable[47][2] = {
{ 0.02, 21.5},
@@ -172,6 +172,8 @@ void G4EmParameters::Initialise()
nucFormfactor = fExponentialNF;
fSStype = fWVI;
fFluct = fUniversalFluctuation;
fDirLEDATA = G4String(G4FindDataDir("G4LEDATA"));
}
void G4EmParameters::SetLossFluctuations(G4bool val)
@@ -1291,6 +1293,11 @@ void G4EmParameters::DefineRegParamForDeex(G4VAtomDeexcitation* ptr) const
fCParameters->DefineRegParamForDeex(ptr);
}
const G4String& G4EmParameters::GetDirLEDATA() const
{
return fDirLEDATA;
}
void G4EmParameters::StreamInfo(std::ostream& os) const
{
G4long prec = os.precision(5);
@@ -201,9 +201,6 @@ void G4LossTableBuilder::BuildRangeTable(const G4PhysicsTable* dedxTable,
G4double ehigh = pv->Energy(npoints-1);
G4double dedx1 = (*pv)[0];
//G4cout << "i= " << i << "npoints= " << npoints << " dedx1= "
//<< dedx1 << G4endl;
// protection for specific cases dedx=0
if(dedx1 == 0.0) {
for (std::size_t k=1; k<npoints; ++k) {
@@ -214,9 +211,6 @@ void G4LossTableBuilder::BuildRangeTable(const G4PhysicsTable* dedxTable,
}
npoints -= bin0;
}
//G4cout<<"New Range vector" << G4endl;
//G4cout<<"nbins= "<<npoints-1<<" elow= "<<elow<<" ehigh= "<<ehigh
// <<" bin0= " << bin0 <<G4endl;
// initialisation of a new vector
if(npoints < 3) { npoints = 3; }
@@ -229,7 +223,12 @@ void G4LossTableBuilder::BuildRangeTable(const G4PhysicsTable* dedxTable,
// assumed dedx proportional to beta
G4double energy1 = v->Energy(0);
G4double range = 2.*energy1/dedx1;
//G4cout << "range0= " << range << G4endl;
/*
G4cout << "New Range vector Npoints=" << v->GetVectorLength()
<< " coupleIdx=" << i << " spline=" << v->GetSpline()
<< " Elow=" << v->GetMinEnergy() <<" Ehigh=" << v->GetMinEnergy()
<< " DEDX(Elow)=" << dedx1 << " R(Elow)=" << range << G4endl;
*/
v->PutValue(0,range);
for (std::size_t j=1; j<npoints; ++j) {
@@ -239,14 +238,17 @@ void G4LossTableBuilder::BuildRangeTable(const G4PhysicsTable* dedxTable,
G4double energy = energy2 + de*0.5;
G4double sum = 0.0;
std::size_t idx = j - 1;
//G4cout << "j= " << j << " e1= " << energy1 << " e2= " << energy2
// << " n= " << n << G4endl;
for (std::size_t k=0; k<n; ++k) {
energy -= de;
dedx1 = pv->Value(energy, idx);
if(dedx1 > 0.0) { sum += de/dedx1; }
}
range += sum;
/*
if(energy < 10.)
G4cout << "j= " << j << " e1= " << energy1 << " e2= " << energy2
<< " n= " << n << " range=" << range<< G4endl;
*/
v->PutValue(j,range);
energy1 = energy2;
}
@@ -97,26 +97,14 @@ G4LossTableManager* G4LossTableManager::Instance()
G4LossTableManager::~G4LossTableManager()
{
for (G4int i=0; i<n_loss; ++i) {
delete loss_vector[i];
}
std::size_t msc = msc_vector.size();
for (std::size_t j=0; j<msc; ++j) {
delete msc_vector[j];
}
std::size_t emp = emp_vector.size();
for (std::size_t k=0; k<emp; ++k) {
delete emp_vector[k];
}
emp = p_vector.size();
for (std::size_t k=0; k<emp; ++k) {
delete p_vector[k];
}
for (auto const & p : loss_vector) { delete p; }
for (auto const & p : msc_vector) { delete p; }
for (auto const & p : emp_vector) { delete p; }
for (auto const & p : p_vector) { delete p; }
std::size_t mod = mod_vector.size();
std::size_t fmod = fmod_vector.size();
//G4cout << " Nmod" << mod << " Nfluc= " << fmod << G4endl;
for (std::size_t a=0; a<mod; ++a) {
//G4cout << "Delete model #" << a << " " << mod_vector[a] << G4endl;
if( nullptr != mod_vector[a] ) {
for (std::size_t b=0; b<fmod; ++b) {
if((G4VEmModel*)(fmod_vector[b]) == mod_vector[a]) {
@@ -127,9 +115,8 @@ G4LossTableManager::~G4LossTableManager()
mod_vector[a] = nullptr;
}
}
for (std::size_t b=0; b<fmod; ++b) {
delete fmod_vector[b];
}
for (auto const & p : fmod_vector) { delete p; }
Clear();
delete tableBuilder;
delete emCorrections;
@@ -145,30 +132,29 @@ G4LossTableManager::~G4LossTableManager()
G4LossTableManager::G4LossTableManager()
{
theParameters = G4EmParameters::Instance();
n_loss = 0;
run = -1;
startInitialisation = false;
all_tables_are_built = false;
currentLoss = nullptr;
currentParticle = nullptr;
firstParticle = nullptr;
isMaster = true;
verbose = theParameters->Verbose();
theElectron = G4Electron::Electron();
theElectron = G4Electron::Electron();
theGenericIon= nullptr;
if(G4Threading::IsWorkerThread()) {
verbose = theParameters->WorkerVerbose();
isMaster = false;
}
}
tableBuilder = new G4LossTableBuilder(isMaster);
emCorrections= new G4EmCorrections(verbose);
emConfigurator = nullptr;
emElectronIonPair = nullptr;
atomDeexcitation = nullptr;
subcutProducer = nullptr;
nielCalculator = nullptr;
gGeneral = nullptr;
eGeneral = pGeneral = nullptr;
emCorrections = new G4EmCorrections(verbose, isMaster);
std::size_t n = 70;
loss_vector.reserve(n);
part_vector.reserve(n);
base_part_vector.reserve(n);
dedx_vector.reserve(n);
range_vector.reserve(n);
inv_range_vector.reserve(n);
tables_are_built.reserve(n);
isActive.reserve(n);
msc_vector.reserve(10);
emp_vector.reserve(16);
mod_vector.reserve(150);
fmod_vector.reserve(60);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
@@ -436,8 +422,7 @@ G4LossTableManager::GetEnergyLossProcess(const G4ParticleDefinition *aParticle)
void
G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle,
G4VEnergyLossProcess* p,
G4bool theMaster)
G4VEnergyLossProcess* p)
{
if (1 < verbose) {
G4cout << "G4LossTableManager::PreparePhysicsTable for "
@@ -446,8 +431,6 @@ G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle,
<< " loss_vector " << loss_vector.size() << G4endl;
}
isMaster = theMaster;
if(!startInitialisation) {
ResetParameters();
if (1 < verbose) {
@@ -477,14 +460,13 @@ G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle,
void
G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle,
G4VEmProcess* p, G4bool theMaster)
G4VEmProcess* p)
{
if (1 < verbose) {
G4cout << "G4LossTableManager::PreparePhysicsTable for "
<< particle->GetParticleName()
<< " and " << p->GetProcessName() << G4endl;
}
isMaster = theMaster;
if(!startInitialisation) {
ResetParameters();
@@ -505,8 +487,7 @@ G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle,
void
G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle,
G4VMultipleScattering* p,
G4bool theMaster)
G4VMultipleScattering* p)
{
if (1 < verbose) {
G4cout << "G4LossTableManager::PreparePhysicsTable for "
@@ -514,8 +495,6 @@ G4LossTableManager::PreparePhysicsTable(const G4ParticleDefinition* particle,
<< " and " << p->GetProcessName() << G4endl;
}
isMaster = theMaster;
if(!startInitialisation) {
ResetParameters();
if (1 < verbose) {
@@ -589,8 +568,6 @@ void G4LossTableManager::LocalPhysicsTables(
inv_range_vector[i] = p->InverseRangeTable();
if(0 == run && p->IsIonisationProcess()) {
loss_map[part_vector[i]] = p;
//G4cout << "G4LossTableManager::LocalPhysicsTable " << part_vector[i]->GetParticleName()
// << " added to map " << p << G4endl;
}
if(1 < verbose) {
@@ -666,7 +643,7 @@ void G4LossTableManager::BuildPhysicsTable(
isActive[i] = true;
base_part_vector[i] = el->BaseParticle();
tables_are_built[i] = false;
all_tables_are_built= false;
all_tables_are_built= false;
if(1 < verbose) {
G4cout << i <<". "<< el->GetProcessName();
if(el->Particle()) {
@@ -819,8 +796,8 @@ G4VEnergyLossProcess* G4LossTableManager::BuildTables(
if (!tables_are_built[i]) {
val = true;
dedx = p->BuildDEDXTable(fRestricted);
//G4cout << "Build DEDX table for " << p->GetProcessName()
// << " idx= " << i << dedx << " " << dedx->length() << G4endl;
//G4cout << "===Build DEDX table for " << p->GetProcessName()
// << " idx= " << i << " dedx:" << dedx << " " << dedx->length() << G4endl;
p->SetDEDXTable(dedx,fRestricted);
tables_are_built[i] = true;
} else {
@@ -913,7 +890,6 @@ G4VEnergyLossProcess* G4LossTableManager::BuildTables(
if(theParameters->BuildCSDARange()) {
G4PhysicsTable* dedxCSDA = em->DEDXunRestrictedTable();
if (1 < n_dedx) {
dedxCSDA = nullptr;
dedxCSDA = G4PhysicsTableHelper::PreparePhysicsTable(dedxCSDA);
tableBuilder->BuildDEDXTable(dedxCSDA, listCSDA);
em->SetDEDXTable(dedxCSDA,fTotal);
@@ -380,9 +380,11 @@ G4double G4VEmModel::MaxSecondaryEnergy(const G4ParticleDefinition*,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4VEmModel::SetupForMaterial(const G4ParticleDefinition*,
const G4Material*, G4double)
{}
void G4VEmModel::SetupForMaterial(const G4ParticleDefinition* p,
const G4Material* mat, G4double ekin)
{
GetChargeSquareRatio(p, mat, ekin);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -407,6 +409,18 @@ void G4VEmModel::SetCrossSectionTable(G4PhysicsTable* p, G4bool isLocal)
localTable = isLocal;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4bool G4VEmModel::LPMFlag() const
{
return G4EmParameters::Instance()->LPM();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmModel::SetLPMFlag(G4bool val)
{
G4EmParameters::Instance()->SetLPM(val);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4VEmModel::ModelDescription(std::ostream& outFile) const
@@ -162,7 +162,7 @@ void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
}
if(particle != &part) { return; }
lManager->PreparePhysicsTable(&part, this, isTheMaster);
lManager->PreparePhysicsTable(&part, this);
// for new run
currentCouple = nullptr;
@@ -210,8 +210,9 @@ G4VEnergyLossProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
if(!isIon) { lManager->RegisterExtraParticle(&part, this); }
if(1 < verboseLevel) {
G4cout << "### G4VEnergyLossProcess::PreparePhysicsTable()"
<< " interrupted for "
<< part.GetParticleName() << " isIon=" << isIon << G4endl;
<< " interrupted for " << GetProcessName() << " and "
<< part.GetParticleName() << " isIon=" << isIon
<< " spline=" << spline << G4endl;
}
return;
}
@@ -219,14 +220,14 @@ G4VEnergyLossProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
tablesAreBuilt = false;
G4LossTableBuilder* bld = lManager->GetTableBuilder();
lManager->PreparePhysicsTable(&part, this, isMaster);
lManager->PreparePhysicsTable(&part, this);
// Base particle and set of models can be defined here
InitialiseEnergyLossProcess(particle, baseParticle);
// parameters of the process
if(!actLossFluc) { lossFluctuationFlag = theParameters->LossFluctuation(); }
rndmStepFlag = theParameters->UseCutAsFinalRange();
useCutAsFinalRange = theParameters->UseCutAsFinalRange();
if(!actMinKinEnergy) { minKinEnergy = theParameters->MinKinEnergy(); }
if(!actMaxKinEnergy) { maxKinEnergy = theParameters->MaxKinEnergy(); }
if(!actBinning) { nBins = theParameters->NumberOfBins(); }
@@ -318,11 +319,12 @@ G4VEnergyLossProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
if(1 < verboseLevel) {
G4cout << "G4VEnergyLossProcess::PrepearPhysicsTable() is done "
<< " for local " << particle->GetParticleName()
<< " isIon= " << isIon;
<< " for " << GetProcessName() << " and " << particle->GetParticleName()
<< " isIon= " << isIon << " spline=" << spline;
if(baseParticle) {
G4cout << "; base: " << baseParticle->GetParticleName();
}
G4cout << G4endl;
G4cout << " chargeSqRatio= " << chargeSqRatio
<< " massRatio= " << massRatio
<< " reduceFactor= " << reduceFactor << G4endl;
@@ -346,16 +348,16 @@ void G4VEnergyLossProcess::BuildPhysicsTable(const G4ParticleDefinition& part)
G4cout << "### G4VEnergyLossProcess::BuildPhysicsTable() for "
<< GetProcessName()
<< " and particle " << part.GetParticleName()
<< "; local: " << particle->GetParticleName();
<< "; the first particle " << particle->GetParticleName();
if(baseParticle) {
G4cout << "; base: " << baseParticle->GetParticleName();
}
G4cout << " TablesAreBuilt= " << tablesAreBuilt
<< " isIon= " << isIon << " " << this << G4endl;
G4cout << G4endl;
G4cout << " TablesAreBuilt= " << tablesAreBuilt << " isIon= " << isIon
<< " spline=" << spline << " ptr: " << this << G4endl;
}
if(&part == particle) {
if(isMaster) {
lManager->BuildPhysicsTable(particle, this);
@@ -428,7 +430,8 @@ G4PhysicsTable* G4VEnergyLossProcess::BuildDEDXTable(G4EmTableType tType)
if(1 < verboseLevel) {
G4cout << "G4VEnergyLossProcess::BuildDEDXTable() of type " << tType
<< " for " << GetProcessName()
<< " and " << particle->GetParticleName() << G4endl;
<< " and " << particle->GetParticleName()
<< "spline=" << spline << G4endl;
}
if(nullptr == table) { return table; }
@@ -548,13 +551,9 @@ void G4VEnergyLossProcess::StartTracking(G4Track* track)
// reset ion
if(isIon) {
const G4double newmass = track->GetDefinition()->GetPDGMass();
if(nullptr != baseParticle) {
massRatio = baseParticle->GetPDGMass()/newmass;
logMassRatio = G4Log(massRatio);
} else {
massRatio = CLHEP::proton_mass_c2/newmass;
logMassRatio = G4Log(massRatio);
}
massRatio = (nullptr == baseParticle) ? CLHEP::proton_mass_c2/newmass
: baseParticle->GetPDGMass()/newmass;
logMassRatio = G4Log(massRatio);
}
// forced biasing only for primary particles
if(nullptr != biasManager) {
@@ -575,13 +574,15 @@ G4double G4VEnergyLossProcess::AlongStepGetPhysicalInteractionLength(
*selection = aGPILSelection;
if(isIonisation && currentModel->IsActive(preStepScaledEnergy)) {
GetScaledRangeForScaledEnergy(preStepScaledEnergy, preStepLogScaledEnergy);
const G4double finR = (rndmStepFlag) ? std::min(finalRange,
x = (useCutAsFinalRange) ? std::min(finalRange,
currentCouple->GetProductionCuts()->GetProductionCut(1)) : finalRange;
x = (fRange > finR) ?
fRange*dRoverRange + finR*(1.0-dRoverRange)*(2.0-finR/fRange) : fRange;
x = (fRange > x) ? fRange*dRoverRange + x*(1.0 - dRoverRange)*(2.0 - x/fRange)
: fRange;
/*
G4cout<<"AlongStepGPIL: " << GetProcessName()<<": e="<<preStepKinEnergy
<< " fRange=" << fRange << " finR=" << finR <<" stepLimit="<<x<<G4endl;
*/
}
//G4cout<<"AlongStepGPIL: " << GetProcessName()<<": e= "<<preStepKinEnergy
//<<" stepLimit= "<<x<<G4endl;
return x;
}
@@ -614,11 +615,9 @@ G4double G4VEnergyLossProcess::PostStepGetPhysicalInteractionLength(
// change effective charge of a charged particle on fly
if(isIon) {
const G4double q2 = currentModel->ChargeSquareRatio(track);
if(q2 != chargeSqRatio) {
fFactor *= q2/chargeSqRatio;
reduceFactor = 1.0/(fFactor*massRatio);
chargeSqRatio = q2;
}
fFactor = q2*biasFactor;
if(baseMat) { fFactor *= (*theDensityFactor)[currentCoupleIndex]; }
reduceFactor = 1.0/(fFactor*massRatio);
if (lossFluctuationFlag) {
auto fluc = currentModel->GetModelOfFluctuations();
fluc->SetParticleAndCharge(track.GetDefinition(), q2);
@@ -779,12 +778,10 @@ G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track,
return &fParticleChange;
}
// Get the actual (true) Step length
G4double length = step.GetStepLength();
if(length <= 0.0) { return &fParticleChange; }
G4double eloss = 0.0;
/*
/*
if(-1 < verboseLevel) {
const G4ParticleDefinition* d = track.GetParticleDefinition();
G4cout << "AlongStepDoIt for "
@@ -805,7 +802,7 @@ G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track,
fParticleChange.ProposeWeight(weight);
}
// stopping
// stopping, check actual range and kinetic energy
if (length >= fRange || preStepKinEnergy <= lowestKinEnergy) {
eloss = preStepKinEnergy;
if (useDeexcitation) {
@@ -818,27 +815,34 @@ G4VParticleChange* G4VEnergyLossProcess::AlongStepDoIt(const G4Track& track,
fParticleChange.ProposeLocalEnergyDeposit(eloss);
return &fParticleChange;
}
// zero step length with non-zero range
if(length <= 0.0) { return &fParticleChange; }
// Short step
eloss = length*GetDEDXForScaledEnergy(preStepScaledEnergy,
preStepLogScaledEnergy);
//G4cout << "Short STEP: eloss= " << eloss << G4endl;
/*
G4cout << "##### Short STEP: eloss= " << eloss
<< " Escaled=" << preStepScaledEnergy
<< " R=" << fRange
<< " L=" << length
<< " fFactor=" << fFactor << " minE=" << minKinEnergy
<< " idxBase=" << basedCoupleIndex << G4endl;
*/
// Long step
if(eloss > preStepKinEnergy*linLossLimit) {
G4double x = (fRange - length)/reduceFactor;
//G4cout << "x= " << x << " " << theInverseRangeTable << G4endl;
eloss = preStepKinEnergy - ScaledKinEnergyForLoss(x)/massRatio;
const G4double x = (fRange - length)/reduceFactor;
const G4double de = preStepKinEnergy - ScaledKinEnergyForLoss(x)/massRatio;
if(de > 0.0) { eloss = de; }
/*
if(-1 < verboseLevel)
G4cout << "Long STEP: rPre(mm)= "
G4cout << " Long STEP: rPre(mm)="
<< GetScaledRangeForScaledEnergy(preStepScaledEnergy)/mm
<< " rPost(mm)= " << x/mm
<< " ePre(MeV)= " << preStepScaledEnergy/MeV
<< " eloss(MeV)= " << eloss/MeV << " eloss0(MeV)= "
<< GetDEDXForScaledEnergy(preStepScaledEnergy)*length/MeV
<< " lim(MeV)= " << preStepKinEnergy*linLossLimit/MeV
<< " x(mm)=" << x/mm
<< " eloss(MeV)=" << eloss/MeV
<< " rFactor=" << reduceFactor
<< " massRatio=" << massRatio
<< G4endl;
*/
}
@@ -153,7 +153,7 @@ void G4VMscModel::SampleSecondaries(std::vector<G4DynamicParticle*>*,
G4double, G4double)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VMscModel::GetDEDX(const G4ParticleDefinition* part, G4double kinEnergy,
const G4MaterialCutsCouple* couple)
@@ -166,9 +166,9 @@ G4double G4VMscModel::GetDEDX(const G4ParticleDefinition* part, G4double kinEner
x = dedx*q*q;
}
return x;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VMscModel::GetDEDX(const G4ParticleDefinition* part, G4double kinEnergy,
const G4MaterialCutsCouple* couple, G4double logKinEnergy)
@@ -198,9 +198,9 @@ G4double G4VMscModel::GetRange(const G4ParticleDefinition* part, G4double kinEne
}
//G4cout << "R(mm)= " << localrange << " " << ionisation << G4endl;
return localrange;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VMscModel::GetRange(const G4ParticleDefinition* part,G4double kinEnergy,
const G4MaterialCutsCouple* couple, G4double logKinEnergy)
@@ -216,7 +216,7 @@ G4double G4VMscModel::GetRange(const G4ParticleDefinition* part,G4double kinEner
}
//G4cout << "R(mm)= " << localrange << " " << ionisation << G4endl;
return localrange;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -143,7 +143,7 @@ G4VMultipleScattering::PreparePhysicsTable(const G4ParticleDefinition& part)
G4bool master = emManager->IsMaster();
if(nullptr == firstParticle) { firstParticle = &part; }
emManager->PreparePhysicsTable(&part, this, master);
emManager->PreparePhysicsTable(&part, this);
currParticle = nullptr;
if(firstParticle == &part) {
@@ -143,7 +143,7 @@ G4double G4ionEffectiveCharge::EffectiveCharge(const G4ParticleDefinition* p,
G4double eF = material->GetIonisation()->GetFermiEnergy();
G4double v1sq = reducedEnergy/eF;
G4double vFsq = eF/energyBohr;
G4double vF = std::sqrt(eF/energyBohr);
G4double vF = std::sqrt(vFsq);
G4double y = ( v1sq > 1.0 )
// Faster than Fermi velocity