Import Geant4 11.1.2 source tree

This commit is contained in:
Gabriele Cosmo
2023-06-19 17:17:14 +02:00
parent 84a556a9dc
commit aef78ca386
309 changed files with 35572 additions and 34678 deletions
@@ -225,20 +225,22 @@ void G4EmExtraParameters::AddPAIModel(const G4String& particle,
{
G4String r = CheckRegion(region);
std::size_t nreg = m_regnamesPAI.size();
for(std::size_t i=0; i<nreg; ++i) {
if((m_particlesPAI[i] == particle ||
m_particlesPAI[i] == "all" ||
particle == "all") &&
(m_regnamesPAI[i] == r ||
m_regnamesPAI[i] == "DefaultRegionForTheWorld" ||
r == "DefaultRegionForTheWorld") ) {
m_typesPAI[i] = type;
if(particle == "all") { m_particlesPAI[i] = particle; }
if(r == "DefaultRegionForTheWorld") { m_regnamesPAI[i] = r; }
return;
// in previously defined region other particles may be already defined
// type should be overrided for the same region and particle
for(std::size_t i=0; i<nreg; ++i) {
if(m_regnamesPAI[i] == r) {
if (particle == "all") {
m_particlesPAI[i] = particle;
m_typesPAI[i] = type;
return;
} else if(m_particlesPAI[i] == particle || m_particlesPAI[i] == "all") {
m_typesPAI[i] = type;
return;
}
}
}
// new regions and/or particles
m_particlesPAI.push_back(particle);
m_regnamesPAI.push_back(r);
m_typesPAI.push_back(type);
@@ -81,6 +81,7 @@ G4EmExtraParametersMessenger::G4EmExtraParametersMessenger(G4EmExtraParameters*
mscoCmd->SetGuidance(" regName : G4Region name");
mscoCmd->SetGuidance(" emType : G4EmStandard, G4EmStandard_opt1, ...");
mscoCmd->AvailableForStates(G4State_PreInit);
mscoCmd->SetToBeBroadcasted(false);
auto mregName = new G4UIparameter("regName",'s',false);
mscoCmd->SetParameter(mregName);
@@ -250,7 +251,7 @@ G4EmExtraParametersMessenger::G4EmExtraParametersMessenger(G4EmExtraParameters*
qeCmd = new G4UIcmdWithABool("/process/em/QuantumEntanglement",this);
qeCmd->SetGuidance("Enable quantum entanglement");
qeCmd->AvailableForStates(G4State_PreInit);
qeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
qeCmd->SetToBeBroadcasted(false);
dirSplitTargetCmd = new G4UIcmdWith3VectorAndUnit("/process/em/setDirectionalSplittingTarget",this);
@@ -98,7 +98,7 @@ G4EmTableUtil::PrepareEmProcess(G4VEmProcess* proc,
const G4DataVector* cuts = modelManager->Initialise(part, secPart, verb);
if(1 < verb) {
G4cout << "### G4VEmProcess::PreparePhysicsTable() done for "
G4cout << "### G4EmTableUtil::PreparePhysicsTable() done for "
<< proc->GetProcessName()
<< " and particle " << part->GetParticleName()
<< G4endl;
@@ -118,7 +118,7 @@ void G4EmTableUtil::BuildEmProcess(G4VEmProcess* proc,
{
G4String num = part->GetParticleName();
if(1 < verb) {
G4cout << "### G4VEmProcess::BuildPhysicsTable() for "
G4cout << "### G4EmTableUtil::BuildPhysicsTable() for "
<< proc->GetProcessName() << " and particle " << num
<< " buildLambdaTable=" << toBuild << " master= " << master
<< G4endl;
@@ -178,7 +178,7 @@ void G4EmTableUtil::BuildEmProcess(G4VEmProcess* proc,
}
if(1 < verb) {
G4cout << "### G4VEmProcess::BuildPhysicsTable() done for "
G4cout << "### G4EmTableUtil::BuildPhysicsTable() done for "
<< proc->GetProcessName() << " and particle " << num
<< " baseMat=" << baseMat << G4endl;
}
@@ -201,7 +201,7 @@ void G4EmTableUtil::BuildLambdaTable(G4VEmProcess* proc,
const G4bool splineFlag)
{
if(1 < verboseLevel) {
G4cout << "G4EmProcess::BuildLambdaTable() for process "
G4cout << "G4EmTableUtil::BuildLambdaTable() for process "
<< proc->GetProcessName() << " and particle "
<< part->GetParticleName() << G4endl;
}
@@ -290,7 +290,7 @@ void G4EmTableUtil::BuildLambdaTable(G4VEnergyLossProcess* proc,
const G4bool splineFlag)
{
if(1 < verboseLevel) {
G4cout << "G4EnergyLossProcess::BuildLambdaTable() for process "
G4cout << "G4EmTableUtil::BuildLambdaTable() for process "
<< proc->GetProcessName() << " and particle "
<< part->GetParticleName() << G4endl;
}
@@ -340,8 +340,9 @@ G4EmTableUtil::CheckIon(G4VEnergyLossProcess* proc,
const G4int verb, G4bool& isIon)
{
if(1 < verb) {
G4cout << "G4VEnergyLossProcess::PreparePhysicsTable for "
G4cout << "G4EmTableUtil::CheckIon for "
<< proc->GetProcessName() << " for " << part->GetParticleName()
<< " should be called from G4VEnergyLossProcess::PreparePhysicsTable"
<< G4endl;
}
const G4ParticleDefinition* particle = partLocal;
@@ -356,6 +357,8 @@ G4EmTableUtil::CheckIon(G4VEnergyLossProcess* proc,
const G4ParticleDefinition* theGIon = G4GenericIon::GenericIon();
isIon = true;
// this is a loop to compare pointers of G4GenericIon processes in order
// to confirm that for given particle the G4GenericIon physics is used
if(particle != theGIon) {
G4ProcessManager* pm = theGIon->GetProcessManager();
G4ProcessVector* v = pm->GetAlongStepProcessVector();
@@ -465,7 +468,7 @@ void G4EmTableUtil::BuildDEDXTable(G4VEnergyLossProcess* proc,
for(std::size_t i=0; i<numOfCouples; ++i) {
if(1 < verbose) {
G4cout << "G4VEnergyLossProcess::BuildDEDXVector idx= " << i
G4cout << "G4EmTableUtil::BuildDEDXVector idx= " << i
<< " flagTable=" << table->GetFlag(i)
<< " flagBuilder=" << bld->GetFlag(i) << G4endl;
}
@@ -491,7 +494,7 @@ void G4EmTableUtil::BuildDEDXTable(G4VEnergyLossProcess* proc,
}
if(1 < verbose) {
G4cout << "G4VEnergyLossProcess::BuildDEDXTable(): table is built for "
G4cout << "G4EmTableUtil::BuildDEDXTable(): table is built for "
<< part->GetParticleName()
<< " and process " << proc->GetProcessName()
<< G4endl;
@@ -517,7 +520,7 @@ void G4EmTableUtil::PrepareMscProcess(G4VMultipleScattering* proc,
part.GetParticleName() == "GenericIon") { isIon = true; }
if(1 < verb) {
G4cout << "### G4VMultipleScattering::PrepearPhysicsTable() for "
G4cout << "### G4EmTableUtil::PrepearPhysicsTable() for "
<< proc->GetProcessName()
<< " and particle " << part.GetParticleName()
<< " isIon: " << isIon << " isMaster: " << master
@@ -590,7 +593,7 @@ void G4EmTableUtil::BuildMscProcess(G4VMultipleScattering* proc,
}
}
if(1 < verb) {
G4cout << "### G4VMultipleScattering::BuildPhysicsTable() done for "
G4cout << "### G4EmTableUtil::BuildPhysicsTable() done for "
<< proc->GetProcessName()
<< " and particle " << part.GetParticleName() << G4endl;
}
@@ -651,7 +654,7 @@ G4bool G4EmTableUtil::StoreTable(G4VProcess* ptr,
if (1 < verb) G4cout << "Stored: " << name << G4endl;
} else {
res = false;
G4cout << "Fail to store: " << name << G4endl;
G4cout << "G4EmTableUtil::StoreTable fail to store: " << name << G4endl;
}
}
return res;
@@ -668,8 +671,10 @@ G4bool G4EmTableUtil::RetrieveTable(G4VProcess* ptr,
{
G4bool res = true;
if (nullptr == aTable) { return res; }
G4cout << tname << " table for " << part->GetParticleName()
<< " will be retrieved " << G4endl;
if (0 < verb) {
G4cout << tname << " table for " << part->GetParticleName()
<< " will be retrieved " << G4endl;
}
const G4String& name =
ptr->GetPhysicsTableFileName(part, dir, tname, ascii);
if(G4PhysicsTableHelper::RetrievePhysicsTable(aTable, name, ascii, spline)) {
@@ -685,8 +690,8 @@ G4bool G4EmTableUtil::RetrieveTable(G4VProcess* ptr,
}
} else {
res = false;
G4cout << "Fail to retrieve: " << tname << " from " << name << " for "
<< part->GetParticleName() << G4endl;
G4cout << "G4EmTableUtil::RetrieveTable fail to retrieve: " << tname
<< " from " << name << " for " << part->GetParticleName() << G4endl;
}
return res;
}
@@ -667,11 +667,6 @@ void G4LossTableManager::BuildPhysicsTable(
base_part_vector[i] = el->BaseParticle();
tables_are_built[i] = false;
all_tables_are_built= false;
if(!isActive[i]) {
el->SetIonisation(false);
tables_are_built[i] = true;
}
if(1 < verbose) {
G4cout << i <<". "<< el->GetProcessName();
if(el->Particle()) {
@@ -900,7 +895,6 @@ G4VEnergyLossProcess* G4LossTableManager::BuildTables(
// if(1<verbose) G4cout << *range << G4endl;
std::vector<G4PhysicsTable*> listSub;
std::vector<G4PhysicsTable*> listCSDA;
for (i=0; i<n_dedx; ++i) {
@@ -44,6 +44,8 @@
#include "G4EmConfigurator.hh"
#include "G4VMscModel.hh"
#include "G4ParticleChangeForMSC.hh"
#include "G4DynamicParticle.hh"
#include "G4Step.hh"
#include "G4StepPoint.hh"
@@ -72,6 +74,11 @@ G4TransportationWithMsc::G4TransportationWithMsc(ScatteringType type,
fEmManager = G4LossTableManager::Instance();
fModelManager = new G4EmModelManager;
if(type == ScatteringType::MultipleScattering)
{
fParticleChangeForMSC = new G4ParticleChangeForMSC;
}
G4ThreeVector zero;
fSubStepDynamicParticle =
new G4DynamicParticle(G4Electron::Definition(), zero);
@@ -85,6 +92,8 @@ G4TransportationWithMsc::G4TransportationWithMsc(ScatteringType type,
G4TransportationWithMsc::~G4TransportationWithMsc()
{
delete fModelManager;
delete fParticleChangeForMSC;
// fSubStepDynamicParticle is owned and also deleted by fSubStepTrack!
delete fSubStepTrack;
delete fSubStep;
@@ -103,7 +112,7 @@ void G4TransportationWithMsc::AddMscModel(G4VMscModel* mscModel, G4int order,
}
fModelManager->AddEmModel(order, mscModel, nullptr, region);
mscModel->SetParticleChange(&fParticleChange);
mscModel->SetParticleChange(fParticleChangeForMSC);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -136,15 +145,18 @@ void G4TransportationWithMsc::PreparePhysicsTable(
}
const G4int numberOfModels = fModelManager->NumberOfModels();
for(G4int i = 0; i < numberOfModels; ++i)
if(fType == ScatteringType::MultipleScattering)
{
auto msc = static_cast<G4VMscModel*>(fModelManager->GetModel(i));
msc->SetMasterThread(master);
msc->SetPolarAngleLimit(theParameters->MscThetaLimit());
G4double emax =
std::min(msc->HighEnergyLimit(), theParameters->MaxKinEnergy());
msc->SetHighEnergyLimit(emax);
msc->SetUseBaseMaterials(baseMat);
for(G4int i = 0; i < numberOfModels; ++i)
{
auto msc = static_cast<G4VMscModel*>(fModelManager->GetModel(i));
msc->SetMasterThread(master);
msc->SetPolarAngleLimit(theParameters->MscThetaLimit());
G4double emax =
std::min(msc->HighEnergyLimit(), theParameters->MaxKinEnergy());
msc->SetHighEnergyLimit(emax);
msc->SetUseBaseMaterials(baseMat);
}
}
fModelManager->Initialise(fFirstParticle, G4Electron::Electron(),
@@ -168,13 +180,16 @@ void G4TransportationWithMsc::BuildPhysicsTable(
// Initialisation of models.
const G4int numberOfModels = fModelManager->NumberOfModels();
for(G4int i = 0; i < numberOfModels; ++i)
if(fType == ScatteringType::MultipleScattering)
{
auto msc = static_cast<G4VMscModel*>(fModelManager->GetModel(i));
auto msc0 =
static_cast<G4VMscModel*>(masterProcess->fModelManager->GetModel(i));
msc->SetCrossSectionTable(msc0->GetCrossSectionTable(), false);
msc->InitialiseLocal(fFirstParticle, msc0);
for(G4int i = 0; i < numberOfModels; ++i)
{
auto msc = static_cast<G4VMscModel*>(fModelManager->GetModel(i));
auto msc0 =
static_cast<G4VMscModel*>(masterProcess->fModelManager->GetModel(i));
msc->SetCrossSectionTable(msc0->GetCrossSectionTable(), false);
msc->InitialiseLocal(fFirstParticle, msc0);
}
}
}
}
@@ -202,11 +217,14 @@ void G4TransportationWithMsc::StartTracking(G4Track* track)
fSubStepDynamicParticle->SetDefinition(currParticle);
const G4int numberOfModels = fModelManager->NumberOfModels();
for(G4int i = 0; i < numberOfModels; ++i)
if(fType == ScatteringType::MultipleScattering)
{
auto msc = static_cast<G4VMscModel*>(fModelManager->GetModel(i));
msc->StartTracking(track);
msc->SetIonisation(ionisation, currParticle);
for(G4int i = 0; i < numberOfModels; ++i)
{
auto msc = static_cast<G4VMscModel*>(fModelManager->GetModel(i));
msc->StartTracking(track);
msc->SetIonisation(ionisation, currParticle);
}
}
// Ensure that field propagation state is also cleared / prepared
@@ -348,15 +366,15 @@ G4double G4TransportationWithMsc::AlongStepGetPhysicalInteractionLength(
static constexpr G4double sFact = 0.99;
// The call to SampleScattering() *may* directly fill in the changed
// direction into fParticleChange, so we have to:
// direction into fParticleChangeForMSC, so we have to:
// 1) Make sure the momentum direction is initialized.
fParticleChange.ProposeMomentumDirection(fTransportEndMomentumDir);
fParticleChangeForMSC->ProposeMomentumDirection(fTransportEndMomentumDir);
// 2) Call SampleScattering(), which *may* change it.
const G4ThreeVector displacement =
mscModel->SampleScattering(fTransportEndMomentumDir, minSafety);
// 3) Get the changed direction and inform G4Transportation.
fMomentumChanged = true;
fTransportEndMomentumDir = *fParticleChange.GetMomentumDirection();
fTransportEndMomentumDir = *fParticleChangeForMSC->GetProposedMomentumDirection();
const G4double r2 = displacement.mag2();
if(r2 > kMinDisplacement2)
@@ -551,13 +551,10 @@ void G4VEnergyLossProcess::StartTracking(G4Track* track)
if(nullptr != baseParticle) {
massRatio = baseParticle->GetPDGMass()/newmass;
logMassRatio = G4Log(massRatio);
} else if(isIon) {
} else {
massRatio = CLHEP::proton_mass_c2/newmass;
logMassRatio = G4Log(massRatio);
} else {
massRatio = 1.0;
logMassRatio = 0.0;
}
}
}
// forced biasing only for primary particles
if(nullptr != biasManager) {