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
@@ -97,7 +97,11 @@ void G4CoulombScattering::InitialiseProcess(const G4ParticleDefinition* p)
// restricted or non-restricted cross section table
G4bool yes = false;
if(theta == CLHEP::pi) { yes = true; }
if(theta == CLHEP::pi) {
yes = true;
// for restriced single scattering change cross section shape
SetCrossSectionType(fEmIncreasing);
}
SetStartFromNullFlag(yes);
/*
G4cout << "### G4CoulombScattering::InitialiseProcess: "
@@ -0,0 +1,90 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// -------------------------------------------------------------------
//
// GEANT4 Class file
//
//
// File name: G4LossFluctuationDummy
//
// Author: V. Ivanchenko
//
// Creation date: 14.02.2022
//
// Modifications:
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "G4LossFluctuationDummy.hh"
#include "G4MaterialCutsCouple.hh"
#include "G4DynamicParticle.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4LossFluctuationDummy::G4LossFluctuationDummy(const G4String& nam)
: G4VEmFluctuationModel(nam)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4LossFluctuationDummy::~G4LossFluctuationDummy()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double
G4LossFluctuationDummy::SampleFluctuations(const G4MaterialCutsCouple*,
const G4DynamicParticle*,
const G4double,
const G4double,
const G4double,
const G4double averageLoss)
{
return averageLoss;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4LossFluctuationDummy::Dispersion(const G4Material*,
const G4DynamicParticle*,
const G4double, const G4double,
const G4double)
{
return 0.0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void
G4LossFluctuationDummy::SetParticleAndCharge(const G4ParticleDefinition*,
G4double)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -47,13 +47,11 @@
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
#include "G4Poisson.hh"
#include "G4Step.hh"
#include "G4Material.hh"
#include "G4MaterialCutsCouple.hh"
#include "G4DynamicParticle.hh"
#include "G4ParticleDefinition.hh"
#include "G4Log.hh"
#include "G4Exp.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -104,7 +102,7 @@ G4UniversalFluctuation::SampleFluctuations(const G4MaterialCutsCouple* couple,
// (out of validity of the model)
//
if (averageLoss < minLoss) { return averageLoss; }
G4double meanLoss = averageLoss;
meanLoss = averageLoss;
const G4double tkin = dp->GetKineticEnergy();
//G4cout<< "Emean= "<< meanLoss<< " tmax= "<< tmax<< " L= "<<length<<G4endl;
@@ -151,38 +149,39 @@ G4UniversalFluctuation::SampleFluctuations(const G4MaterialCutsCouple* couple,
return loss;
}
// Glandz regime : initialisation
//
if (material != lastMaterial) {
ipotFluct = material->GetIonisation()->GetMeanExcitationEnergy();
ipotLogFluct = material->GetIonisation()->GetLogMeanExcEnergy();
e0 = material->GetIonisation()->GetEnergy0fluct();
lastMaterial = material;
}
auto ioni = material->GetIonisation();
e0 = ioni->GetEnergy0fluct();
// very small step or low-density material
if(tcut <= e0) { return meanLoss; }
ipotFluct = ioni->GetMeanExcitationEnergy();
ipotLogFluct = ioni->GetLogMeanExcEnergy();
// width correction for small cuts
const G4double scaling = std::min(1.+0.5*CLHEP::keV/tcut,1.50);
const G4double scaling = std::min(1.+0.5*CLHEP::keV/tcut, 1.50);
meanLoss /= scaling;
w2 = (tcut > ipotFluct) ?
G4Log(2.*CLHEP::electron_mass_c2*beta2*gam2)-beta2 : 0.0;
return SampleGlandz(rndmEngineF, material, tcut)*scaling;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double
G4UniversalFluctuation::SampleGlandz(CLHEP::HepRandomEngine* rndmEngineF,
const G4Material*,
const G4double tcut)
{
G4double a1(0.0), a3(0.0);
loss = 0.0;
G4double loss = 0.0;
G4double e1 = ipotFluct;
e1 = ipotFluct;
if(tcut > ipotFluct) {
const G4double w2 = G4Log(2.*CLHEP::electron_mass_c2*beta2*gam2)-beta2;
if(w2 > ipotLogFluct) {
const G4double C = meanLoss*(1.-rate)/(w2-ipotLogFluct);
a1 = C*(w2-ipotLogFluct)/ipotFluct;
} else {
a1 = meanLoss*(1.-rate)/e1;
}
if(tcut > e1) {
a1 = meanLoss*(1.-rate)/e1;
if(a1 < a0) {
const G4double fwnow = fw*a1/a0;
const G4double fwnow = 0.1+(fw-0.1)*std::sqrt(a1/a0);
a1 /= fwnow;
e1 *= fwnow;
} else {
@@ -192,12 +191,9 @@ G4UniversalFluctuation::SampleFluctuations(const G4MaterialCutsCouple* couple,
}
const G4double w1 = tcut/e0;
if(tcut > e0) {
a3 = rate*meanLoss*(tcut-e0)/(e0*tcut*G4Log(w1));
if(a1 <= 0.) {
a3 /= rate;
}
}
a3 = rate*meanLoss*(tcut - e0)/(e0*tcut*G4Log(w1));
if(a1 <= 0.) { a3 /= rate; }
//'nearly' Gaussian fluctuation if a1>nmaxCont&&a2>nmaxCont&&a3>nmaxCont
G4double emean = 0.;
G4double sig2e = 0.;
@@ -219,12 +215,12 @@ G4UniversalFluctuation::SampleFluctuations(const G4MaterialCutsCouple* couple,
const G4double namean = a3*w1*(alfa-1.)/((w1-1.)*alfa);
emean += namean*e0*alfa1;
sig2e += e0*e0*namean*(alfa-alfa1*alfa1);
p3 = a3-namean;
p3 = a3 - namean;
}
const G4double w2 = alfa*e0;
if(tcut > w2) {
const G4double w = (tcut-w2)/tcut;
const G4double w3 = alfa*e0;
if(tcut > w3) {
const G4double w = (tcut-w3)/tcut;
const G4int nnb = G4Poisson(p3);
if(nnb > 0) {
if(nnb > sizearray) {
@@ -233,13 +229,13 @@ G4UniversalFluctuation::SampleFluctuations(const G4MaterialCutsCouple* couple,
rndmarray = new G4double[nnb];
}
rndmEngineF->flatArray(nnb, rndmarray);
for (G4int k=0; k<nnb; ++k) { loss += w2/(1.-w*rndmarray[k]); }
for (G4int k=0; k<nnb; ++k) { loss += w3/(1.-w*rndmarray[k]); }
}
}
if(sig2e > 0.0) { SampleGauss(rndmEngineF, emean, sig2e, loss); }
}
//G4cout << "### loss=" << loss << " scaling=" << scaling << G4endl;
return loss*scaling;
//G4cout << "### loss=" << loss << G4endl;
return loss;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,158 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// -------------------------------------------------------------------
//
// GEANT4 Class file
//
//
// File name: G4UrbanFluctuation
//
// Author: V. Ivanchenko for Laszlo Urban
//
// Creation date: 14.02.2022
//
// Modifications:
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "G4UrbanFluctuation.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
#include "G4Poisson.hh"
#include "G4Material.hh"
#include "G4Log.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4UrbanFluctuation::G4UrbanFluctuation(const G4String& nam)
: G4UniversalFluctuation(nam)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4UrbanFluctuation::~G4UrbanFluctuation()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4UrbanFluctuation::SampleGlandz(CLHEP::HepRandomEngine* rndmEngineF,
const G4Material* material,
const G4double tcut)
{
if (material != lastMaterial) {
auto ioni = material->GetIonisation();
f1Fluct = ioni->GetF1fluct();
f2Fluct = ioni->GetF2fluct();
e1Fluct = ioni->GetEnergy1fluct();
e2Fluct = ioni->GetEnergy2fluct();
e1LogFluct = ioni->GetLogEnergy1fluct();
e2LogFluct = ioni->GetLogEnergy2fluct();
esmall = 0.5*std::sqrt(e0*ipotFluct);
lastMaterial = material;
}
G4double a1(0.0), a2(0.0), a3(0.0);
G4double loss = 0.0;
G4double e1 = e1Fluct;
G4double e2 = e2Fluct;
if(tcut > ipotFluct) {
if(w2 > ipotLogFluct) {
if(w2 > e2LogFluct) {
const G4double C = meanLoss*(1.-rate)/(w2-ipotLogFluct);
a1 = C*f1Fluct*(w2-e1LogFluct)/e1Fluct;
a2 = C*f2Fluct*(w2-e2LogFluct)/e2Fluct;
} else {
a1 = meanLoss*(1.-rate)/e1;
}
if(a1 < a0) {
const G4double fwnow = 0.5+(fw-0.5)*std::sqrt(a1/a0);
a1 /= fwnow;
e1 *= fwnow;
} else {
a1 /= fw;
e1 *= fw;
}
}
}
const G4double w1 = tcut/e0;
a3 = rate*meanLoss*(tcut-e0)/(e0*tcut*G4Log(w1));
if(a1+a2 <= 0.) { a3 /= rate; }
//'nearly' Gaussian fluctuation if a1>nmaxCont&&a2>nmaxCont&&a3>nmaxCont
G4double emean = 0.;
G4double sig2e = 0.;
// excitation of type 1
if(a1 > 0.0) { AddExcitation(rndmEngineF, a1, e1, emean, loss, sig2e); }
// excitation of type 2
if(a2 > 0.0) { AddExcitation(rndmEngineF, a2, e2, emean, loss, sig2e); }
if(sig2e > 0.0) { SampleGauss(rndmEngineF, emean, sig2e, loss); }
// ionisation
if(a3 > 0.) {
emean = 0.;
sig2e = 0.;
G4double p3 = a3;
G4double alfa = 1.;
if(a3 > nmaxCont) {
alfa = w1*(nmaxCont+a3)/(w1*nmaxCont+a3);
const G4double alfa1 = alfa*G4Log(alfa)/(alfa-1.);
const G4double namean = a3*w1*(alfa-1.)/((w1-1.)*alfa);
emean += namean*e0*alfa1;
sig2e += e0*e0*namean*(alfa-alfa1*alfa1);
p3 -= namean;
}
const G4double w3 = alfa*e0;
if(tcut > w3) {
const G4double w = (tcut-w3)/tcut;
const G4int nnb = G4Poisson(p3);
if(nnb > 0) {
if(nnb > sizearray) {
sizearray = nnb;
delete [] rndmarray;
rndmarray = new G4double[nnb];
}
rndmEngineF->flatArray(nnb, rndmarray);
for (G4int k=0; k<nnb; ++k) { loss += w3/(1.-w*rndmarray[k]); }
}
}
if(sig2e > 0.0) { SampleGauss(rndmEngineF, emean, sig2e, loss); }
}
//G4cout << "### loss=" << loss << G4endl;
return loss;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -70,11 +70,17 @@
#include "globals.hh"
#include "G4Log.hh"
#include "G4Exp.hh"
#include "G4Threading.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::vector<G4UrbanMscModel::mscData*> G4UrbanMscModel::msc;
namespace
{
G4Mutex theUrbanMutex = G4MUTEX_INITIALIZER;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4UrbanMscModel::G4UrbanMscModel(const G4String& nam)
@@ -135,7 +141,7 @@ G4UrbanMscModel::G4UrbanMscModel(const G4String& nam)
G4UrbanMscModel::~G4UrbanMscModel()
{
if(IsMaster()) {
if(isFirstInstance) {
for(auto & ptr : msc) { delete ptr; }
msc.clear();
}
@@ -153,7 +159,19 @@ void G4UrbanMscModel::Initialise(const G4ParticleDefinition* p,
latDisplasmentbackup = latDisplasment;
dispAlg96 = (G4EmParameters::Instance()->LateralDisplacementAlg96());
if(IsMaster() || msc.size() == 0) { InitialiseModelCache(); }
// initialise cache only once
if(0 == msc.size()) {
G4AutoLock l(&theUrbanMutex);
if(0 == msc.size()) {
isFirstInstance = true;
msc.resize(1, nullptr);
}
l.unlock();
}
// initialise cache for each new run
if(isFirstInstance) { InitialiseModelCache(); }
/*
G4cout << "### G4UrbanMscModel::Initialise done for "
<< p->GetParticleName() << " type= " << steppingAlgorithm << G4endl;
@@ -788,8 +806,9 @@ G4double G4UrbanMscModel::ComputeTrueStepLength(G4double geomStepLength)
if(par1 < 0.) {
tlength = -lambda0*G4Log(1.-geomStepLength/lambda0) ;
} else {
if(par1*par3*geomStepLength < 1.) {
tlength = (1.-G4Exp(G4Log(1.-par1*par3*geomStepLength)/par3))/par1 ;
const G4double par4 = par1*par3;
if(par4*geomStepLength < 1.) {
tlength = (1.-G4Exp(G4Log(1.-par4*geomStepLength)/par3))/par1;
} else {
tlength = currentRange;
}
@@ -1214,14 +1233,14 @@ void G4UrbanMscModel::InitialiseModelCache()
// of a new G4MaterialCutsCouple is possible
auto theCoupleTable = G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
if(numOfCouples != msc.size()) { msc.resize(numOfCouples); }
if(numOfCouples != msc.size()) { msc.resize(numOfCouples, nullptr); }
for(size_t j=0; j<numOfCouples; ++j) {
auto aCouple = theCoupleTable->GetMaterialCutsCouple(j);
// cut may be changed before runs
G4double cut = aCouple->GetProductionCuts()->GetProductionCut(1);
if(msc[j]) {
if(nullptr != msc[j]) {
msc[j]->ecut = cut;
continue;
}