Import Geant4 11.0.1 source tree

This commit is contained in:
Gabriele Cosmo
2022-03-23 08:25:50 +01:00
parent 84f33a068c
commit de4f28d823
234 changed files with 61815 additions and 61766 deletions
@@ -16,6 +16,23 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
22 January 22: V.Ivanchenko (emutils-V10-07-39)
- G4EmParametersMessenger - added forgotten UI command to enable polarisation
08 January 22: V.Ivanchenko
- G4VEmProcess - fixed methods, which implementation based on assumption that
the lambda table defined for full energy range: LambdaPhysicsVector(..),
CrossSEctionPerVolume(...), FindLambdaMax(...). No change is expected for
the default physics configuration, fix mainly affect positron annihilation
processes at high energies.
05 January 22: V.Ivanchenko
- G4VMscModel, G4VEmProcess - move few methods and header files from header to
source in order to reduce dependencies between packages.
17 December 21: I.Hrivnacova
- Added info in setMaxBetaChange command description.
19 November 21: V.Ivanchenko (emutils-V10-07-38)
- G4EmCalculator - fixed computation of dedx for He3 and alpha
(complete fix of #2440)
@@ -97,6 +97,7 @@ private:
G4UIcmdWithABool* mottCmd;
G4UIcmdWithABool* birksCmd;
G4UIcmdWithABool* sharkCmd;
G4UIcmdWithABool* poCmd;
G4UIcmdWithABool* onIsolatedCmd;
G4UIcmdWithABool* sampleTCmd;
G4UIcmdWithABool* icru90Cmd;
@@ -53,13 +53,13 @@
#include "G4Material.hh"
#include "G4MaterialCutsCouple.hh"
#include "G4Track.hh"
#include "G4EmModelManager.hh"
#include "G4UnitsTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleChangeForGamma.hh"
#include "G4EmParameters.hh"
#include "G4EmDataHandler.hh"
#include "G4EmTableType.hh"
#include "G4EmModelManager.hh"
#include "G4EmSecondaryParticleType.hh"
class G4Step;
@@ -184,6 +184,9 @@ public:
// Max kinetic energy for tables
void SetMaxKinEnergy(G4double e);
// for cross section with one peak
void SetEnergyOfCrossSectionMax(std::vector<G4double>*);
// Cross section table pointers
inline G4PhysicsTable* LambdaTable() const;
inline G4PhysicsTable* LambdaTablePrim() const;
@@ -223,12 +226,12 @@ public:
// return a model from the local list
inline G4VEmModel* EmModel(size_t index = 0) const;
// Access to models
inline G4VEmModel* GetModelByIndex(G4int idx = 0, G4bool ver = false) const;
// Access to active model
inline const G4VEmModel* GetCurrentModel() const;
// Access to models
G4VEmModel* GetModelByIndex(G4int idx = 0, G4bool ver = false) const;
// Access to the current G4Element
const G4Element* GetCurrentElement() const;
@@ -244,6 +247,8 @@ public:
void ActivateSecondaryBiasing(const G4String& region, G4double factor,
G4double energyLimit);
std::vector<G4double>* FindLambdaMax();
inline void SetEmMasterProcess(const G4VEmProcess*);
inline void SetCrossSectionType(G4CrossSectionType val);
@@ -324,8 +329,6 @@ private:
void StreamInfo(std::ostream& outFile, const G4ParticleDefinition&,
G4bool rst=false) const;
void FindLambdaMax();
void PrintWarning(G4String tit, G4double val);
void ComputeIntegralLambda(G4double kinEnergy, G4double logKinEnergy);
@@ -806,11 +809,4 @@ inline G4VEmModel* G4VEmProcess::EmModel(size_t index) const
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
inline G4VEmModel* G4VEmProcess::GetModelByIndex(G4int idx, G4bool ver) const
{
return modelManager->GetModel(idx, ver);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
#endif
@@ -55,13 +55,13 @@
#include "G4ThreeVector.hh"
#include "G4Track.hh"
#include "G4SafetyHelper.hh"
#include "G4VEnergyLossProcess.hh"
#include "G4PhysicsTable.hh"
#include "G4ThreeVector.hh"
#include <vector>
class G4ParticleChangeForMSC;
class G4ParticleDefinition;
class G4VEnergyLossProcess;
class G4VMscModel : public G4VEmModel
{
@@ -145,25 +145,25 @@ public:
inline G4double ComputeGeomLimit(const G4Track&, G4double& presafety,
G4double limit);
inline G4double GetDEDX(const G4ParticleDefinition* part,
G4double GetDEDX(const G4ParticleDefinition* part,
G4double kineticEnergy,
const G4MaterialCutsCouple* couple);
inline G4double GetDEDX(const G4ParticleDefinition* part,
G4double GetDEDX(const G4ParticleDefinition* part,
G4double kineticEnergy,
const G4MaterialCutsCouple* couple,
G4double logKineticEnergy);
inline G4double GetRange(const G4ParticleDefinition* part,
G4double GetRange(const G4ParticleDefinition* part,
G4double kineticEnergy,
const G4MaterialCutsCouple* couple);
inline G4double GetRange(const G4ParticleDefinition* part,
G4double GetRange(const G4ParticleDefinition* part,
G4double kineticEnergy,
const G4MaterialCutsCouple* couple,
G4double logKineticEnergy);
inline G4double GetEnergy(const G4ParticleDefinition* part,
G4double GetEnergy(const G4ParticleDefinition* part,
G4double range,
const G4MaterialCutsCouple* couple);
@@ -299,99 +299,6 @@ inline G4double G4VMscModel::ComputeGeomLimit(const G4Track& track,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline G4double
G4VMscModel::GetDEDX(const G4ParticleDefinition* part, G4double kinEnergy,
const G4MaterialCutsCouple* couple)
{
G4double x;
if (nullptr != ionisation) {
x = ionisation->GetDEDX(kinEnergy, couple);
} else {
const G4double q = part->GetPDGCharge()*inveplus;
x = dedx*q*q;
}
return x;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline G4double
G4VMscModel::GetDEDX(const G4ParticleDefinition* part, G4double kinEnergy,
const G4MaterialCutsCouple* couple, G4double logKinEnergy)
{
G4double x;
if (nullptr != ionisation) {
x = ionisation->GetDEDX(kinEnergy, couple, logKinEnergy);
} else {
const G4double q = part->GetPDGCharge()*inveplus;
x = dedx*q*q;
}
return x;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline G4double
G4VMscModel::GetRange(const G4ParticleDefinition* part, G4double kinEnergy,
const G4MaterialCutsCouple* couple)
{
//G4cout << "G4VMscModel::GetRange E(MeV)= " << kinEnergy << " "
// << ionisation << " " << part->GetParticleName()
// << G4endl;
localtkin = kinEnergy;
if (nullptr != ionisation) {
localrange = ionisation->GetRange(kinEnergy, couple);
} else {
const G4double q = part->GetPDGCharge()*inveplus;
localrange = kinEnergy/(dedx*q*q*couple->GetMaterial()->GetDensity());
}
//G4cout << "R(mm)= " << localrange << " " << ionisation << G4endl;
return localrange;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline G4double
G4VMscModel::GetRange(const G4ParticleDefinition* part,G4double kinEnergy,
const G4MaterialCutsCouple* couple, G4double logKinEnergy)
{
//G4cout << "G4VMscModel::GetRange E(MeV)= " << kinEnergy << " "
// << ionisation << " " << part->GetParticleName()
// << G4endl;
localtkin = kinEnergy;
if (nullptr != ionisation) {
localrange = ionisation->GetRange(kinEnergy, couple, logKinEnergy);
} else {
const G4double q = part->GetPDGCharge()*inveplus;
localrange = kinEnergy/(dedx*q*q*couple->GetMaterial()->GetDensity());
}
//G4cout << "R(mm)= " << localrange << " " << ionisation << G4endl;
return localrange;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline G4double
G4VMscModel::GetEnergy(const G4ParticleDefinition* part,
G4double range, const G4MaterialCutsCouple* couple)
{
G4double e;
//G4cout << "G4VMscModel::GetEnergy R(mm)= " << range << " " << ionisation
// << " Rlocal(mm)= " << localrange << " Elocal(MeV)= " << localtkin
// << G4endl;
if(nullptr != ionisation) { e = ionisation->GetKineticEnergy(range, couple); }
else {
e = localtkin;
if(localrange > range) {
G4double q = part->GetPDGCharge()*inveplus;
e -= (localrange - range)*dedx*q*q*couple->GetMaterial()->GetDensity();
}
}
return e;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
inline G4VEnergyLossProcess* G4VMscModel::GetIonisation() const
{
return ionisation;
@@ -156,6 +156,11 @@ G4EmParametersMessenger::G4EmParametersMessenger(G4EmParameters* ptr)
sharkCmd->AvailableForStates(G4State_PreInit);
sharkCmd->SetToBeBroadcasted(false);
poCmd = new G4UIcmdWithABool("/process/em/Polarisation",this);
poCmd->SetGuidance("Enable polarisation");
poCmd->AvailableForStates(G4State_PreInit);
poCmd->SetToBeBroadcasted(false);
sampleTCmd = new G4UIcmdWithABool("/process/em/enableSamplingTable",this);
sampleTCmd->SetGuidance("Enable usage of sampling table for secondary generation");
sampleTCmd->SetParameterName("sampleT",true);
@@ -436,6 +441,7 @@ G4EmParametersMessenger::~G4EmParametersMessenger()
delete sharkCmd;
delete onIsolatedCmd;
delete sampleTCmd;
delete poCmd;
delete icru90Cmd;
delete mudatCmd;
@@ -515,6 +521,8 @@ void G4EmParametersMessenger::SetNewValue(G4UIcommand* command,
theParameters->SetUseICRU90Data(icru90Cmd->GetNewBoolValue(newValue));
} else if (command == sharkCmd) {
theParameters->SetGeneralProcessActive(sharkCmd->GetNewBoolValue(newValue));
} else if (command == poCmd) {
theParameters->SetEnablePolarisation(poCmd->GetNewBoolValue(newValue));
} else if (command == sampleTCmd) {
theParameters->SetEnableSamplingTable(sampleTCmd->GetNewBoolValue(newValue));
} else if (command == mudatCmd) {
@@ -123,7 +123,7 @@ G4OpticalParametersMessenger::G4OpticalParametersMessenger(
fCerenkovMaxBetaChangeCmd =
new G4UIcmdWithADouble("/process/optical/cerenkov/setMaxBetaChange", this);
fCerenkovMaxBetaChangeCmd->SetGuidance(
"Set maximum change of beta of parent particle per step");
"Set maximum change of beta of parent particle per step (in percent)");
fCerenkovMaxBetaChangeCmd->SetParameterName("CerenkovMaxBetaChange", false);
fCerenkovMaxBetaChangeCmd->SetRange("CerenkovMaxBetaChange>=0");
fCerenkovMaxBetaChangeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
@@ -165,6 +165,13 @@ void G4VEmProcess::SetEmModel(G4VEmModel* ptr, G4int)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4VEmModel* G4VEmProcess::GetModelByIndex(G4int idx, G4bool ver) const
{
return modelManager->GetModel(idx, ver);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::PreparePhysicsTable(const G4ParticleDefinition& part)
{
isTheMaster = lManager->IsMaster();
@@ -321,7 +328,9 @@ void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part)
if(!isTheMaster) {
theLambdaTable = masterProc->LambdaTable();
theLambdaTablePrim = masterProc->LambdaTablePrim();
theEnergyOfCrossSectionMax = masterProc->EnergyOfCrossSectionMax();
if(fXSType == fEmOnePeak) {
SetEnergyOfCrossSectionMax(masterProc->EnergyOfCrossSectionMax());
}
baseMat = masterProc->UseBaseMaterial();
// local initialisation of models
@@ -339,6 +348,11 @@ void G4VEmProcess::BuildPhysicsTable(const G4ParticleDefinition& part)
if(buildLambdaTable || minKinEnergyPrim < maxKinEnergy) {
BuildLambdaTable();
}
if(fXSType == fEmOnePeak) {
delete theEnergyOfCrossSectionMax;
theEnergyOfCrossSectionMax = nullptr;
SetEnergyOfCrossSectionMax(FindLambdaMax());
}
}
}
// protection against double printout
@@ -451,8 +465,6 @@ void G4VEmProcess::BuildLambdaTable()
}
}
if(buildLambdaTable && fXSType == fEmOnePeak) { FindLambdaMax(); }
if(1 < verboseLevel) {
G4cout << "Lambda table is built for "
<< particle->GetParticleName()
@@ -963,25 +975,11 @@ G4bool G4VEmProcess::RetrievePhysicsTable(const G4ParticleDefinition* part,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double
G4VEmProcess::CrossSectionPerVolume(G4double kineticEnergy,
const G4MaterialCutsCouple* couple,
G4double logKinEnergy)
G4double G4VEmProcess::CrossSectionPerVolume(G4double kinEnergy,
const G4MaterialCutsCouple* couple,
G4double)
{
// Cross section per atom is calculated
DefineMaterial(couple);
G4double cross = 0.0;
if(buildLambdaTable) {
cross = GetCurrentLambda(kineticEnergy,
(logKinEnergy < DBL_MAX) ? logKinEnergy : G4Log(kineticEnergy));
} else {
SelectModel(kineticEnergy, currentCoupleIndex);
if(currentModel) {
cross = fFactor*currentModel->CrossSectionPerVolume(currentMaterial,
currentParticle,
kineticEnergy);
}
}
G4double cross = RecalculateLambda(kinEnergy, couple);
return std::max(cross, 0.0);
}
@@ -1020,54 +1018,73 @@ G4VEmProcess::ComputeCrossSectionPerAtom(G4double kinEnergy,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::FindLambdaMax()
std::vector<G4double>* G4VEmProcess::FindLambdaMax()
{
if(1 < verboseLevel) {
G4cout << "### G4VEmProcess::FindLambdaMax: "
<< particle->GetParticleName()
<< " and process " << GetProcessName() << " " << G4endl;
}
size_t n = theLambdaTable->length();
G4PhysicsVector* pv;
G4double e, ss, emax, smax;
std::vector<G4double>* ptr = nullptr;
if(fXSType != fEmOnePeak) { return ptr; }
size_t i;
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t n = theCoupleTable->GetTableSize();
ptr = new std::vector<G4double>;
ptr->resize(n, DBL_MAX);
// first loop on existing vectors
for (i=0; i<n; ++i) {
pv = (*theLambdaTable)[i];
if(nullptr != pv) {
size_t nb = pv->GetVectorLength();
emax = DBL_MAX;
smax = 0.0;
if(nb > 0) {
for (size_t j=0; j<nb; ++j) {
e = pv->Energy(j);
ss = (*pv)(j);
if(ss > smax) {
smax = ss;
emax = e;
} else {
break;
}
}
}
(*theEnergyOfCrossSectionMax)[i] = emax;
if(1 < verboseLevel) {
G4cout << "For " << particle->GetParticleName()
<< " Max CS at i= " << i << " emax(MeV)= " << emax/MeV
<< " lambda= " << smax << G4endl;
G4bool isPeak = false;
const G4double g4log10 = G4Log(10.);
const G4double scale = theParameters->NumberOfBinsPerDecade()/g4log10;
for(size_t i=0; i<n; ++i) {
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i);
G4double emin = std::max(minKinEnergy, MinPrimaryEnergy(particle, couple->GetMaterial()));
G4double emax = std::max(maxKinEnergy, emin + emin);
G4double ee = G4Log(emax/emin);
G4int nbin = G4lrint(ee*scale);
if(nbin < 4) { nbin = 4; }
G4double x = G4Exp(ee/nbin);
G4double sm = 0.0;
G4double em = emin;
G4double e = emin;
for(G4int j=0; j<=nbin; ++j) {
G4double sig = RecalculateLambda(e, couple);
//G4cout << j << " E=" << e << " Lambda=" << sig << G4endl;
if(sig >= sm) {
em = e;
sm = sig;
e *= x;
} else {
isPeak = true;
(*ptr)[i] = em;
break;
}
}
if(1 < verboseLevel) {
G4cout << " " << i << ". Epeak(GeV)=" << em/GeV
<< " SigmaMax(1/mm)=" << sm
<< " Emin(GeV)=" << emin/GeV << " Emax(GeV)=" << emax/GeV
<< " " << couple->GetMaterial()->GetName() << G4endl;
}
}
// second loop using base materials
for (i=0; i<n; ++i) {
pv = (*theLambdaTable)[i];
if(nullptr == pv) {
G4int j = (*theDensityIdx)[i];
(*theEnergyOfCrossSectionMax)[i] = (*theEnergyOfCrossSectionMax)[j];
}
// there is no peak for any material
if(!isPeak) {
delete ptr;
ptr = nullptr;
}
return ptr;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4VEmProcess::SetEnergyOfCrossSectionMax(std::vector<G4double>* ptr)
{
if(nullptr == ptr) {
fXSType = fEmIncreasing;
} else {
theEnergyOfCrossSectionMax = ptr;
}
}
@@ -1077,13 +1094,8 @@ G4PhysicsVector*
G4VEmProcess::LambdaPhysicsVector(const G4MaterialCutsCouple* couple)
{
DefineMaterial(couple);
G4PhysicsVector* newv = nullptr;
if(nullptr == theLambdaTable) {
newv = new G4PhysicsLogVector(minKinEnergy, maxKinEnergy,
nLambdaBins, splineFlag);
} else {
newv = new G4PhysicsVector(*((*theLambdaTable)[basedCoupleIndex]));
}
G4PhysicsVector* newv = new G4PhysicsLogVector(minKinEnergy, maxKinEnergy,
nLambdaBins, splineFlag);
return newv;
}
@@ -154,4 +154,88 @@ void G4VMscModel::SampleSecondaries(std::vector<G4DynamicParticle*>*,
G4double, G4double)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VMscModel::GetDEDX(const G4ParticleDefinition* part, G4double kinEnergy,
const G4MaterialCutsCouple* couple)
{
G4double x;
if (nullptr != ionisation) {
x = ionisation->GetDEDX(kinEnergy, couple);
} else {
const G4double q = part->GetPDGCharge()*inveplus;
x = dedx*q*q;
}
return x;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VMscModel::GetDEDX(const G4ParticleDefinition* part, G4double kinEnergy,
const G4MaterialCutsCouple* couple, G4double logKinEnergy)
{
G4double x;
if (nullptr != ionisation) {
x = ionisation->GetDEDX(kinEnergy, couple, logKinEnergy);
} else {
const G4double q = part->GetPDGCharge()*inveplus;
x = dedx*q*q;
}
return x;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VMscModel::GetRange(const G4ParticleDefinition* part, G4double kinEnergy,
const G4MaterialCutsCouple* couple)
{
// << ionisation << " " << part->GetParticleName() << G4endl;
localtkin = kinEnergy;
if (nullptr != ionisation) {
localrange = ionisation->GetRange(kinEnergy, couple);
} else {
const G4double q = part->GetPDGCharge()*inveplus;
localrange = kinEnergy/(dedx*q*q*couple->GetMaterial()->GetDensity());
}
//G4cout << "R(mm)= " << localrange << " " << ionisation << G4endl;
return localrange;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VMscModel::GetRange(const G4ParticleDefinition* part,G4double kinEnergy,
const G4MaterialCutsCouple* couple, G4double logKinEnergy)
{
//G4cout << "G4VMscModel::GetRange E(MeV)= " << kinEnergy << " "
// << ionisation << " " << part->GetParticleName() << G4endl;
localtkin = kinEnergy;
if (nullptr != ionisation) {
localrange = ionisation->GetRange(kinEnergy, couple, logKinEnergy);
} else {
const G4double q = part->GetPDGCharge()*inveplus;
localrange = kinEnergy/(dedx*q*q*couple->GetMaterial()->GetDensity());
}
//G4cout << "R(mm)= " << localrange << " " << ionisation << G4endl;
return localrange;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4VMscModel::GetEnergy(const G4ParticleDefinition* part,
G4double range, const G4MaterialCutsCouple* couple)
{
G4double e;
//G4cout << "G4VMscModel::GetEnergy R(mm)= " << range << " " << ionisation
// << " Rlocal(mm)= " << localrange << " Elocal(MeV)= " << localtkin << G4endl;
if(nullptr != ionisation) { e = ionisation->GetKineticEnergy(range, couple); }
else {
e = localtkin;
if(localrange > range) {
G4double q = part->GetPDGCharge()*inveplus;
e -= (localrange - range)*dedx*q*q*couple->GetMaterial()->GetDensity();
}
}
return e;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......