Import Geant4 5.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 10:15:15 +02:00
parent 37fff30d2e
commit fbd4999cf7
4396 changed files with 56662 additions and 52446 deletions
@@ -21,11 +21,11 @@
// ********************************************************************
//
//
// $Id: G4hIonisation.cc,v 1.31 2002/10/11 16:39:09 vnivanch Exp $
// GEANT4 tag $Name: geant4-05-00 $
// $Id: G4hIonisation.cc,v 1.43 2003/04/26 20:04:57 vnivanch Exp $
// GEANT4 tag $Name: geant4-05-01 $
//
//---------------- G4hIonisation physics process -------------------------------
// by Laszlo Urban, 30 May 1997
// by Laszlo Urban, 30 May 1997
//------------------------------------------------------------------------------
//
// corrected by L.Urban on 24/09/97
@@ -35,7 +35,7 @@
// 02-02-99 bugs fixed , L.Urban
// 29-07-99 correction in BuildLossTable for low energy, L.Urban
// 10-02-00 modifications , new e.m. structure, L.Urban
// 10-08-00 V.Ivanchenko change BuildLambdaTable, in order to
// 10-08-00 V.Ivanchenko change BuildLambdaTable, in order to
// simulate energy losses of ions; correction to
// cross section for particles with spin 1 is inserted as well
// 28-05-01 V.Ivanchenko minor changes to provide ANSI -wall compilation
@@ -48,7 +48,13 @@
// 08-11-01 Charge renamed zparticle; added to the dedx
// 27-03-02 Bug fix in scaling of lambda table (V.Ivanchenko)
// 09-04-02 Update calculation of tables for GenericIons (V.Ivanchenko)
// 10-06-02 bug fixed for stopping hadrons, V.Ivanchenko
// 10-06-02 bug fixed for stopping hadrons (V.Ivanchenko)
// 15-01-03 Migrade to cut per region (V.Ivanchenko)
// 10-03-03 Use SubType for GenericIons (V.Ivanchenko)
// 07-04-03 Fix problem of several runs (V.Ivanchenko)
// 08-04-03 finalRange is region aware (V.Ivanchenko)
// 17-04-03 fix problem of hadron tests (V.Ivanchenko)
// 26-04-03 fix problems of retrieve tables (V.Ivanchenko)
//
//------------------------------------------------------------------------------
@@ -59,6 +65,7 @@
#include "G4ProcessManager.hh"
#include "G4UnitsTable.hh"
#include "G4EnergyLossTables.hh"
#include "G4ProductionCutsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -67,16 +74,18 @@ G4double G4hIonisation::UpperBoundLambda = 100.*TeV;
G4int G4hIonisation::NbinLambda = 100;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4hIonisation::G4hIonisation(const G4String& processName)
: G4VhEnergyLoss(processName),
theMeanFreePathTable(0),
Tmincut(1*keV)
{ }
{
verboseLevel = 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4hIonisation::~G4hIonisation()
G4hIonisation::~G4hIonisation()
{
if (theMeanFreePathTable) {
theMeanFreePathTable->clearAndDestroy(); delete theMeanFreePathTable;}
@@ -84,36 +93,36 @@ G4hIonisation::~G4hIonisation()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4hIonisation::SetLowerBoundLambda(G4double val)
void G4hIonisation::SetLowerBoundLambda(G4double val)
{LowerBoundLambda = val;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4hIonisation::SetUpperBoundLambda(G4double val)
void G4hIonisation::SetUpperBoundLambda(G4double val)
{UpperBoundLambda = val;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4hIonisation::SetNbinLambda(G4int n)
void G4hIonisation::SetNbinLambda(G4int n)
{NbinLambda = n;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4hIonisation::GetLowerBoundLambda()
G4double G4hIonisation::GetLowerBoundLambda()
{return LowerBoundLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4hIonisation::GetUpperBoundLambda()
G4double G4hIonisation::GetUpperBoundLambda()
{return UpperBoundLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4int G4hIonisation::GetNbinLambda()
G4int G4hIonisation::GetNbinLambda()
{return NbinLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4hIonisation::BuildPhysicsTable(const G4ParticleDefinition& aParticleType)
// just call BuildLossTable+BuildLambdaTable
{
@@ -134,11 +143,12 @@ void G4hIonisation::BuildPhysicsTable(const G4ParticleDefinition& aParticleType)
}
}
if(aParticleType.GetParticleType() == "nucleus" &&
if(aParticleType.GetParticleType() == "nucleus" &&
aParticleType.GetParticleName() != "GenericIon" &&
theMeanFreePathTable) {
aParticleType.GetParticleSubType() == "generic")
{
G4EnergyLossTables::Register(&aParticleType,
G4EnergyLossTables::Register(&aParticleType,
theDEDXpTable,
theRangepTable,
theInverseRangepTable,
@@ -151,43 +161,41 @@ void G4hIonisation::BuildPhysicsTable(const G4ParticleDefinition& aParticleType)
return;
}
// get bining from EnergyLoss
LowestKineticEnergy = GetLowerBoundEloss();
HighestKineticEnergy = GetUpperBoundEloss();
TotBin = GetNbinEloss();
const G4ParticleDefinition* theProton = G4Proton::Proton();
G4double* ElectronCutInRange = G4Electron::Electron()->GetLengthCuts();
G4bool makeTables = false;
if (aParticleType.GetPDGCharge() > 0.)
{
if( !EqualCutVectors(ptableElectronCutInRange,ElectronCutInRange)
|| (theDEDXpTable == NULL))
if( CutsWhereModified() || !theDEDXpTable )
{
BuildLossTable(*theProton);
RecorderOfpProcess[CounterOfpProcess] = theLossTable;
CounterOfpProcess++;
RecorderOfpProcess[0] = (*this).theLossTable;
// CounterOfpProcess++;
makeTables = true;
}
}
else
{
if( !EqualCutVectors(pbartableElectronCutInRange,ElectronCutInRange)
|| (theDEDXpbarTable == NULL))
if( CutsWhereModified() || !theDEDXpbarTable )
{
BuildLossTable(*(G4AntiProton::AntiProton())) ;
RecorderOfpbarProcess[CounterOfpbarProcess] = theLossTable;
CounterOfpbarProcess++;
RecorderOfpProcess[0] = (*this).theLossTable;
// CounterOfpbarProcess++;
makeTables = true;
}
}
BuildLambdaTable(aParticleType);
BuildDEDXTable(aParticleType);
if( makeTables ) BuildDEDXTable(aParticleType);
if(2 < verboseLevel) {
G4cout << "MeanFreePathTable is built for "
<< aParticleType.GetParticleName() << G4endl;
G4cout << "MeanFreePathTable is built for "
<< aParticleType.GetParticleName() << G4endl;
G4cout << (*theMeanFreePathTable) << G4endl;
}
@@ -200,44 +208,46 @@ void G4hIonisation::BuildPhysicsTable(const G4ParticleDefinition& aParticleType)
void G4hIonisation::BuildLossTable(const G4ParticleDefinition& aParticleType)
{
// Build tables of dE/dx due to the ionization process
// the tables are built for *MATERIALS*
if(0 < verboseLevel) {
G4cout << "G4hIonisation::BuildLossTable() for process "
<< GetProcessName() << " and particle "
<< aParticleType.GetParticleName() << G4endl;
}
// create table
//
const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
if (theLossTable) {theLossTable->clearAndDestroy(); delete theLossTable;}
theLossTable = new G4PhysicsTable(numOfMaterials);
// get delta cut in energy
G4double* DeltaCutInKinEnergy = (G4Electron::Electron())->GetEnergyCuts();
// loop for materials
//
for (G4int J=0; J<numOfMaterials; J++)
{
// create physics vector and fill it
G4PhysicsLogVector* aVector = new G4PhysicsLogVector(
LowestKineticEnergy, HighestKineticEnergy, TotBin);
const G4Material* material= (*theMaterialTable)[J];
// get electron cut in kinetic energy for the material
G4double DeltaThreshold = G4std::max(DeltaCutInKinEnergy[J],Tmincut);
if (theLossTable) {theLossTable->clearAndDestroy(); delete theLossTable;}
theLossTable = new G4PhysicsTable(numOfCouples);
// now comes the loop for the kinetic energy values
secondaryEnergyCuts = theCoupleTable->GetEnergyCutsVector(1);
// loop for materials
//
for (G4int i = 0 ; i < TotBin ; i++)
{
for (size_t J=0; J<numOfCouples; J++)
{
// create physics vector and fill it
G4PhysicsLogVector* aVector = new G4PhysicsLogVector(
LowestKineticEnergy, HighestKineticEnergy, TotBin);
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(J);
const G4Material* material= couple->GetMaterial();
// get electron cut in kinetic energy for the material
G4double DeltaThreshold = SecondaryEnergyThreshold(J);
// now comes the loop for the kinetic energy values
//
for (G4int i = 0 ; i < TotBin ; i++)
{
G4double dEdx = ComputeRestrictedMeandEdx(aParticleType,
aVector->GetLowEdgeEnergy(i),
material,
DeltaThreshold);
aVector->PutValue(i,dEdx);
}
theLossTable->insert(aVector);
}
theLossTable->insert(aVector);
}
}
@@ -245,49 +255,46 @@ void G4hIonisation::BuildLossTable(const G4ParticleDefinition& aParticleType)
void G4hIonisation::BuildLambdaTable(const G4ParticleDefinition& aParticleType)
{
// Build mean free path tables for the delta ray production process
// tables are built for MATERIALS
if(0 < verboseLevel) {
G4cout << "G4hIonisation::BuildLambdaTable() for process "
<< GetProcessName() << " and particle "
G4cout << "G4hIonisation::BuildLambdaTable() for process "
<< GetProcessName() << " and particle "
<< aParticleType.GetParticleName() << G4endl;
}
//create table
//
const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
if (theMeanFreePathTable)
{theMeanFreePathTable->clearAndDestroy(); delete theMeanFreePathTable;}
//create table
//
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
theMeanFreePathTable = new G4PhysicsTable(numOfMaterials);
if (theMeanFreePathTable)
{theMeanFreePathTable->clearAndDestroy(); delete theMeanFreePathTable;}
// get electron cut in kinetic energy
G4double* DeltaCutInKinEnergy = (G4Electron::Electron())->GetEnergyCuts();
// loop for materials
theMeanFreePathTable = new G4PhysicsTable(numOfCouples);
for (G4int J=0 ; J < numOfMaterials; J++)
{
// get electron cut in kinetic energy
secondaryEnergyCuts = theCoupleTable->GetEnergyCutsVector(1);
// loop for materials
for (size_t J=0 ; J < numOfCouples; J++)
{
//create physics vector then fill it ....
G4PhysicsLogVector* aVector = new G4PhysicsLogVector(
LowerBoundLambda,UpperBoundLambda,NbinLambda);
// compute the (macroscopic) cross section first
const G4Material* material= (*theMaterialTable)[J];
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(J);
const G4Material* material= couple->GetMaterial();
// get electron cut in kinetic energy for the material
G4double DeltaThreshold = SecondaryEnergyThreshold(J);
const G4ElementVector* theElementVector = material->GetElementVector();
const G4double* NbOfAtomsPerVolume = material->GetVecNbOfAtomsPerVolume();
G4int NumberOfElements = material->GetNumberOfElements();
// get the electron kinetic energy cut for the actual material,
// it will be used in ComputeCrossSectionPerAtom
// ( --> it will be the same for all the elements in this material)
G4double DeltaThreshold =G4std::max(DeltaCutInKinEnergy[J],Tmincut);
if(1 < verboseLevel) {
G4cout << "### For material " << material->GetName()
<< " Tcut(MeV)= " << DeltaThreshold/MeV
@@ -301,7 +308,7 @@ void G4hIonisation::BuildLambdaTable(const G4ParticleDefinition& aParticleType)
for ( G4int i = 0 ; i < NbinLambda ; i++ )
{
G4double LowEdgeEnergy = aVector->GetLowEdgeEnergy(i);
G4double sigma = 0.;
G4double sigma = 0.;
for (G4int iel=0; iel<NumberOfElements; iel++ )
{
sigma += NbOfAtomsPerVolume[iel]*
@@ -312,7 +319,7 @@ void G4hIonisation::BuildLambdaTable(const G4ParticleDefinition& aParticleType)
}
// mean free path = 1./macroscopic cross section
G4double Value = sigma > DBL_MIN ? 1./sigma : DBL_MAX;
G4double Value = sigma > DBL_MIN ? 1./sigma : DBL_MAX;
aVector->PutValue(i, Value) ;
}
theMeanFreePathTable->insert(aVector);
@@ -327,48 +334,48 @@ G4double G4hIonisation::ComputeRestrictedMeandEdx (
const G4Material* material,
G4double DeltaThreshold)
{
// calculate the dE/dx due to the ionization process (Geant4 internal units)
// Bethe-Bloch formula
//
G4double particleMass = proton_mass_c2;
G4double ElectronDensity = material->GetElectronDensity();
G4double Eexc = material->GetIonisation()->GetMeanExcitationEnergy();
G4double Eexc2 = Eexc*Eexc;
G4double tau = KineticEnergy/particleMass;
G4double gamma = tau + 1., bg2 = tau*(tau+2.), beta2 = bg2/(gamma*gamma);
G4double RateMass = electron_mass_c2/particleMass;
G4double Tmax=2.*electron_mass_c2*bg2/(1.+2.*gamma*RateMass+RateMass*RateMass);
// calculate the dE/dx due to the ionization process (Geant4 internal units)
// Bethe-Bloch formula
//
G4double particleMass = proton_mass_c2;
G4double taul = material->GetIonisation()->GetTaul();
G4double ElectronDensity = material->GetElectronDensity();
G4double Eexc = material->GetIonisation()->GetMeanExcitationEnergy();
G4double Eexc2 = Eexc*Eexc;
G4double dEdx = 0.;
//
// high energy part , Bethe-Bloch formula
//
if (tau > taul)
{
G4double tau = KineticEnergy/particleMass;
G4double gamma = tau + 1., bg2 = tau*(tau+2.), beta2 = bg2/(gamma*gamma);
G4double RateMass = electron_mass_c2/particleMass;
G4double Tmax=2.*electron_mass_c2*bg2/(1.+2.*gamma*RateMass+RateMass*RateMass);
G4double taul = material->GetIonisation()->GetTaul();
G4double dEdx = 0.;
//
// high energy part , Bethe-Bloch formula
//
if (tau > taul)
{
G4double rcut = G4std::min(DeltaThreshold/Tmax, 1.);
dEdx = log(2.*electron_mass_c2*bg2*Tmax/Eexc2)
+log(rcut)-(1.+rcut)*beta2;
//density correction
//density correction
G4double Cden = material->GetIonisation()->GetCdensity();
G4double Mden = material->GetIonisation()->GetMdensity();
G4double Aden = material->GetIonisation()->GetAdensity();
G4double X0den = material->GetIonisation()->GetX0density();
G4double X1den = material->GetIonisation()->GetX1density();
const G4double twoln10 = 2.*log(10.);
const G4double twoln10 = 2.*log(10.);
G4double x = log(bg2)/twoln10;
G4double delta;
if (x < X0den) delta = 0.;
else {delta = twoln10*x - Cden;
if (x < X1den) delta += Aden*pow((X1den-x),Mden);
}
}
// shell correction
// shell correction
G4double* ShellCorrectionVector = material->GetIonisation()->
GetShellCorrectionVector();
const G4double bg2lim = 0.0169, taulim = 8.4146e-3;
@@ -377,7 +384,7 @@ G4double G4hIonisation::ComputeRestrictedMeandEdx (
{xs *= bg2; sh += ShellCorrectionVector[k]/xs;}
else { for (G4int k=0; k<3; k++)
{xs *= bg2lim; sh += ShellCorrectionVector[k]/xs;}
sh *= log(tau/taul)/log(taulim/taul);
sh *= log(tau/taul)/log(taulim/taul);
}
// now you can compute the total ionization loss
@@ -385,22 +392,22 @@ G4double G4hIonisation::ComputeRestrictedMeandEdx (
dEdx *= twopi_mc2_rcl2*ElectronDensity/beta2;
if (dEdx < 0.) dEdx = 0.;
}
//
// low energy part , parametrized energy loss formulae
//
if (tau <= taul)
{
// get elements in the actual material,
//
// low energy part , parametrized energy loss formulae
//
if (tau <= taul)
{
// get elements in the actual material,
const G4ElementVector* theElementVector = material->GetElementVector();
const G4double* NbOfAtomsPerVolume=material->GetVecNbOfAtomsPerVolume();
G4int NumberOfElements = material->GetNumberOfElements();
// loop for the elements in the material
dEdx = 0.;
for (G4int iel=0; iel<NumberOfElements; iel++)
{
const G4Element* element = (*theElementVector)[iel];
if (tau < element->GetIonisation()->GetTau0())
const G4Element* element = (*theElementVector)[iel];
if (tau < element->GetIonisation()->GetTau0())
dEdx += NbOfAtomsPerVolume[iel]
*(element->GetIonisation()->GetAlow()*sqrt(tau)
+ element->GetIonisation()->GetBlow()*tau);
@@ -412,7 +419,7 @@ G4double G4hIonisation::ComputeRestrictedMeandEdx (
if (DeltaThreshold < Tmax)
{
deltaloss = log(Tmax/DeltaThreshold)-
beta2*(1.-DeltaThreshold/Tmax) ;
beta2*(1.-DeltaThreshold/Tmax) ;
if (aParticleType.GetPDGSpin() == 0.5)
deltaloss += 0.25*(Tmax-DeltaThreshold)*(Tmax-DeltaThreshold)/
(KineticEnergy*KineticEnergy+proton_mass_c2*proton_mass_c2);
@@ -432,25 +439,25 @@ G4double G4hIonisation::ComputeCrossSectionPerAtom(
G4double AtomicNumber,
G4double DeltaThreshold)
{
// calculates the totalcross section per atom in GEANT4 internal units
// ( it is called for elements , AtomicNumber = Z )
//
// nb: cross section formula is OK for spin=0 and 1/2 only !
initialMass = aParticleType.GetPDGMass();
G4double particleMass = initialMass;
G4double TotalEnergy = KineticEnergy + particleMass;
// calculates the totalcross section per atom in GEANT4 internal units
// ( it is called for elements , AtomicNumber = Z )
//
// nb: cross section formula is OK for spin=0 and 1/2 only !
G4double betasquare = KineticEnergy*(TotalEnergy+particleMass)
initialMass = aParticleType.GetPDGMass();
G4double particleMass = initialMass;
G4double TotalEnergy = KineticEnergy + particleMass;
G4double betasquare = KineticEnergy*(TotalEnergy+particleMass)
/(TotalEnergy*TotalEnergy);
G4double tempvar = particleMass+electron_mass_c2;
G4double MaxKineticEnergyTransfer = 2.*electron_mass_c2*KineticEnergy
G4double tempvar = particleMass+electron_mass_c2;
G4double MaxKineticEnergyTransfer = 2.*electron_mass_c2*KineticEnergy
*(TotalEnergy+particleMass)
/(tempvar*tempvar+2.*electron_mass_c2*KineticEnergy);
G4double TotalCrossSection = 0.;
if (MaxKineticEnergyTransfer > DeltaThreshold)
G4double TotalCrossSection = 0.;
if (MaxKineticEnergyTransfer > DeltaThreshold)
{
tempvar = DeltaThreshold/MaxKineticEnergyTransfer;
TotalCrossSection = (1.-tempvar*(1.-betasquare*log(tempvar)))
@@ -460,100 +467,99 @@ G4double G4hIonisation::ComputeCrossSectionPerAtom(
if (spin == 0.5) TotalCrossSection += 0.5
*(MaxKineticEnergyTransfer-DeltaThreshold)
/(TotalEnergy*TotalEnergy);
if (spin == 1.) TotalCrossSection +=
if (spin == 1.) TotalCrossSection +=
-log(tempvar)/(3.0*DeltaThreshold) +
(MaxKineticEnergyTransfer - DeltaThreshold) *
((5.0+ 1.0/tempvar)*0.25 / (TotalEnergy*TotalEnergy) -
betasquare /
(MaxKineticEnergyTransfer - DeltaThreshold) *
((5.0+ 1.0/tempvar)*0.25 / (TotalEnergy*TotalEnergy) -
betasquare /
(MaxKineticEnergyTransfer * DeltaThreshold)) / 3.0;
TotalCrossSection *= twopi_mc2_rcl2*AtomicNumber/betasquare;
}
return TotalCrossSection;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange* G4hIonisation::PostStepDoIt(const G4Track& trackData,
const G4Step& stepData)
G4VParticleChange* G4hIonisation::PostStepDoIt(const G4Track& trackData,
const G4Step& stepData)
{
aParticleChange.Initialize(trackData);
G4Material* aMaterial = trackData.GetMaterial();
const G4DynamicParticle* aParticle = trackData.GetDynamicParticle();
aParticleChange.Initialize(trackData);
G4double particleMass = aParticle->GetMass();
G4double KineticEnergy = aParticle->GetKineticEnergy();
G4double TotalEnergy = KineticEnergy + particleMass;
G4double Psquare = KineticEnergy*(TotalEnergy+particleMass);
G4double Esquare = TotalEnergy*TotalEnergy;
G4double betasquare=Psquare/Esquare;
G4double summass = particleMass + electron_mass_c2;
G4double MaxKineticEnergyTransfer = 2.*electron_mass_c2*Psquare
const G4MaterialCutsCouple* couple = trackData.GetMaterialCutsCouple();
const G4DynamicParticle* aParticle = trackData.GetDynamicParticle();
G4double particleMass = aParticle->GetMass();
G4double KineticEnergy = aParticle->GetKineticEnergy();
G4double TotalEnergy = KineticEnergy + particleMass;
G4double Psquare = KineticEnergy*(TotalEnergy+particleMass);
G4double Esquare = TotalEnergy*TotalEnergy;
G4double betasquare=Psquare/Esquare;
G4double summass = particleMass + electron_mass_c2;
G4double MaxKineticEnergyTransfer = 2.*electron_mass_c2*Psquare
/(summass*summass+2.*electron_mass_c2*KineticEnergy);
G4ParticleMomentum ParticleDirection = aParticle->GetMomentumDirection();
// get electron cut in kinetic energy
G4double* DeltaCutInKinEnergy = (G4Electron::Electron())->GetEnergyCuts();
G4double DeltaThreshold =
G4std::max(DeltaCutInKinEnergy[aMaterial->GetIndex()],Tmincut);
G4ParticleMomentum ParticleDirection = aParticle->GetMomentumDirection();
// sampling kinetic energy of the delta ray
//
// get electron cut in kinetic energy
G4double DeltaThreshold = SecondaryEnergyThreshold(couple->GetIndex());
// sampling kinetic energy of the delta ray
//
if (MaxKineticEnergyTransfer <= DeltaThreshold)
// pathological case (it should not happen, there is no change at all)
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
// normal case
G4double xc = DeltaThreshold/MaxKineticEnergyTransfer;
G4double rate = MaxKineticEnergyTransfer/TotalEnergy;
G4double te2 = 0.;
if (aParticle->GetDefinition()->GetPDGSpin() == 0.5) te2=0.5*rate*rate;
// sampling follows ...
G4double x,grej;
G4double grejc=1.-betasquare*xc+te2*xc*xc;
do { x=xc/(1.-(1.-xc)*G4UniformRand());
grej=(1.-x*(betasquare-x*te2))/grejc;
} while(G4UniformRand() > grej);
G4double DeltaKineticEnergy = x * MaxKineticEnergyTransfer;
// normal case
G4double xc = DeltaThreshold/MaxKineticEnergyTransfer;
G4double rate = MaxKineticEnergyTransfer/TotalEnergy;
G4double te2 = 0.;
if (aParticle->GetDefinition()->GetPDGSpin() == 0.5) te2=0.5*rate*rate;
if (DeltaKineticEnergy <= 0.)
// sampling follows ...
G4double x,grej;
G4double grejc=1.-betasquare*xc+te2*xc*xc;
do { x=xc/(1.-(1.-xc)*G4UniformRand());
grej=(1.-x*(betasquare-x*te2))/grejc;
} while(G4UniformRand() > grej);
G4double DeltaKineticEnergy = x * MaxKineticEnergyTransfer;
if (DeltaKineticEnergy <= 0.)
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
G4double DeltaTotalMomentum = sqrt(DeltaKineticEnergy * (DeltaKineticEnergy +
G4double DeltaTotalMomentum = sqrt(DeltaKineticEnergy * (DeltaKineticEnergy +
2. * electron_mass_c2 ));
G4double TotalMomentum = sqrt(Psquare);
G4double costheta = DeltaKineticEnergy * (TotalEnergy + electron_mass_c2)
G4double TotalMomentum = sqrt(Psquare);
G4double costheta = DeltaKineticEnergy * (TotalEnergy + electron_mass_c2)
/(DeltaTotalMomentum * TotalMomentum);
if (costheta < -1.) costheta = -1.;
if (costheta > +1.) costheta = +1.;
if (costheta < -1.) costheta = -1.;
if (costheta > +1.) costheta = +1.;
// direction of the delta electron
//
G4double phi = twopi*G4UniformRand();
G4double sintheta = sqrt((1.+costheta)*(1.-costheta));
G4double dirx = sintheta*cos(phi), diry = sintheta*sin(phi), dirz = costheta;
// direction of the delta electron
//
G4double phi = twopi*G4UniformRand();
G4double sintheta = sqrt((1.+costheta)*(1.-costheta));
G4double dirx = sintheta*cos(phi), diry = sintheta*sin(phi), dirz = costheta;
G4ThreeVector DeltaDirection(dirx,diry,dirz);
DeltaDirection.rotateUz(ParticleDirection);
G4ThreeVector DeltaDirection(dirx,diry,dirz);
DeltaDirection.rotateUz(ParticleDirection);
// create G4DynamicParticle object for delta ray
//
G4DynamicParticle *theDeltaRay = new G4DynamicParticle;
theDeltaRay->SetKineticEnergy( DeltaKineticEnergy );
theDeltaRay->SetMomentumDirection(
DeltaDirection.x(),DeltaDirection.y(),DeltaDirection.z());
theDeltaRay->SetDefinition(G4Electron::Electron());
// create G4DynamicParticle object for delta ray
//
G4DynamicParticle *theDeltaRay = new G4DynamicParticle;
theDeltaRay->SetKineticEnergy( DeltaKineticEnergy );
theDeltaRay->SetMomentumDirection(
DeltaDirection.x(),DeltaDirection.y(),DeltaDirection.z());
theDeltaRay->SetDefinition(G4Electron::Electron());
// fill aParticleChange
//
G4double finalKineticEnergy = KineticEnergy - DeltaKineticEnergy;
G4double Edep = 0;
// fill aParticleChange
//
G4double finalKineticEnergy = KineticEnergy - DeltaKineticEnergy;
G4double Edep = 0;
if (finalKineticEnergy > MinKineticEnergy)
if (finalKineticEnergy > MinKineticEnergy)
{
G4double finalPx = TotalMomentum*ParticleDirection.x()
- DeltaTotalMomentum*DeltaDirection.x();
@@ -569,7 +575,7 @@ G4VParticleChange* G4hIonisation::PostStepDoIt(const G4Track& trackData,
aParticleChange.SetMomentumChange( finalPx,finalPy,finalPz );
}
else
else
{
Edep = finalKineticEnergy;
finalKineticEnergy = 0.;
@@ -578,33 +584,34 @@ G4VParticleChange* G4hIonisation::PostStepDoIt(const G4Track& trackData,
else aParticleChange.SetStatusChange(fStopButAlive);
}
aParticleChange.SetEnergyChange( finalKineticEnergy );
aParticleChange.SetNumberOfSecondaries(1);
aParticleChange.AddSecondary(theDeltaRay);
aParticleChange.SetLocalEnergyDeposit (Edep);
//ResetNumberOfInteractionLengthLeft();
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
aParticleChange.SetEnergyChange( finalKineticEnergy );
aParticleChange.SetNumberOfSecondaries(1);
aParticleChange.AddSecondary(theDeltaRay);
aParticleChange.SetLocalEnergyDeposit (Edep);
//ResetNumberOfInteractionLengthLeft();
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool G4hIonisation::StorePhysicsTable(G4ParticleDefinition* particle,
const G4String& directory,
const G4String& directory,
G4bool ascii)
{
G4String particleName = particle->GetParticleName();
G4String filename;
// store stopping power table
if ((particleName == "proton")||(particleName == "anti_proton")){
filename = GetPhysicsTableFileName(particle,directory,"StoppingPower",ascii);
if ( !theLossTable->StorePhysicsTable(filename, ascii) ){
G4cout << " FAIL theLossTable->StorePhysicsTable in " << filename
<< G4endl;
return false;
}}
if ((particleName == "proton")||(particleName == "anti_proton")) {
filename = GetPhysicsTableFileName(particle,directory,"StoppingPower",ascii);
if ( !theLossTable->StorePhysicsTable(filename, ascii) ){
G4cout << " FAIL theLossTable->StorePhysicsTable in " << filename
<< G4endl;
return false;
}
}
// store mean free path table
filename = GetPhysicsTableFileName(particle,directory,"MeanFreePath",ascii);
if ( !theMeanFreePathTable->StorePhysicsTable(filename, ascii) ){
@@ -612,9 +619,9 @@ G4bool G4hIonisation::StorePhysicsTable(G4ParticleDefinition* particle,
<< G4endl;
return false;
}
G4cout << GetProcessName() << " for " << particleName
<< ": Success to store the PhysicsTables in "
G4cout << GetProcessName() << " for " << particleName
<< ": Success to store the PhysicsTables in "
<< directory << G4endl;
return true;
}
@@ -622,61 +629,86 @@ G4bool G4hIonisation::StorePhysicsTable(G4ParticleDefinition* particle,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool G4hIonisation::RetrievePhysicsTable(G4ParticleDefinition* particle,
const G4String& directory,
const G4String& directory,
G4bool ascii)
{
G4String particleName = particle->GetParticleName();
if(particle->GetParticleType() == "nucleus" &&
particleName != "GenericIon" &&
particle->GetParticleSubType() == "generic")
{
G4EnergyLossTables::Register(particle,
theDEDXpTable,
theRangepTable,
theInverseRangepTable,
theLabTimepTable,
theProperTimepTable,
LowestKineticEnergy, HighestKineticEnergy,
proton_mass_c2/particle->GetPDGMass(),
TotBin);
return true;
}
// delete theLossTable and theMeanFreePathTable
if (theLossTable != 0) {
theLossTable->clearAndDestroy();
delete theLossTable;
}
delete theLossTable;
}
if (theMeanFreePathTable != 0) {
theMeanFreePathTable->clearAndDestroy();
delete theMeanFreePathTable;
}
// get bining from EnergyLoss
LowestKineticEnergy = GetLowerBoundEloss();
HighestKineticEnergy = GetUpperBoundEloss();
TotBin = GetNbinEloss();
G4String particleName = particle->GetParticleName();
G4String filename;
// retreive stopping power table
if ((particleName == "proton")||(particleName == "anti_proton")){
filename = GetPhysicsTableFileName(particle,directory,"StoppingPower",ascii);
theLossTable = new G4PhysicsTable(G4Material::GetNumberOfMaterials());
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
secondaryEnergyCuts = theCoupleTable->GetEnergyCutsVector(1);
G4double charge = particle->GetPDGCharge()/eplus;
G4ParticleDefinition* basep = G4Proton::Proton();
if(charge < 0.0) basep = G4AntiProton::AntiProton();
filename = GetPhysicsTableFileName(basep,directory,"StoppingPower",ascii);
theLossTable = new G4PhysicsTable(numOfCouples);
if ( !theLossTable->RetrievePhysicsTable(filename, ascii) ){
G4cout << " FAIL theLossTable0->RetrievePhysicsTable in " << filename
<< G4endl;
return false;
G4cout << " FAIL theLossTable0->RetrievePhysicsTable in " << filename
<< G4endl;
BuildPhysicsTable(*particle);
return true;
}
if (particleName == "proton")
RecorderOfpProcess[CounterOfpProcess++] = theLossTable;
if (particleName == "anti_proton")
RecorderOfpbarProcess[CounterOfpbarProcess++] = theLossTable;
}
RecorderOfpProcess[0] = (*this).theLossTable;
// retreive mean free path table
filename = GetPhysicsTableFileName(particle,directory,"MeanFreePath",ascii);
theMeanFreePathTable = new G4PhysicsTable(G4Material::GetNumberOfMaterials());
theMeanFreePathTable = new G4PhysicsTable(numOfCouples);
if ( !theMeanFreePathTable->RetrievePhysicsTable(filename, ascii) ){
G4cout << " FAIL theMeanFreePathTable->RetrievePhysicsTable in " << filename
<< G4endl;
<< G4endl;
return false;
}
initialMass = particle->GetPDGMass();
G4cout << GetProcessName() << " for " << particleName
G4cout << GetProcessName() << " for " << particleName
<< ": Success to retrieve the PhysicsTables from "
<< directory << G4endl;
BuildDEDXTable(*particle);
if (particle == G4Proton::Proton()) PrintInfoDefinition();
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4hIonisation::PrintInfoDefinition()
@@ -689,7 +721,10 @@ void G4hIonisation::PrintInfoDefinition()
<< "\n PhysicsTables from " << G4BestUnit(LowestKineticEnergy,
"Energy")
<< " to " << G4BestUnit(HighestKineticEnergy,"Energy")
<< " in " << TotBin << " bins. \n";
<< " in " << TotBin << " bins. "
<< "\n Step function: finalRange(mm)= " << finalRange
<< ", dRoverRange= " << dRoverRange
<< G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......