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
@@ -29,10 +29,17 @@
// File name: G4MuBetheBlochModel
//
// Author: Vladimir Ivanchenko on base of Laszlo Urban code
//
//
// Creation date: 09.08.2002
//
// Modifications: 04.12.2002 VI Fix problem of G4DynamicParticle constructor
// Modifications:
//
// 04-12-02 Fix problem of G4DynamicParticle constructor (V.Ivanchenko)
// 23-12-02 Change interface in order to move to cut per region (V.Ivanchenko)
// 27-01-03 Make models region aware (V.Ivanchenko)
// 13-02-03 Add name (V.Ivanchenko)
//
//
// -------------------------------------------------------------------
//
@@ -47,13 +54,14 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4MuBetheBlochModel::G4MuBetheBlochModel(const G4ParticleDefinition* p)
: G4VEmModel(),
G4MuBetheBlochModel::G4MuBetheBlochModel(const G4ParticleDefinition* p,
const G4String& nam)
: G4VEmModel(nam),
particle(0),
highKinEnergy(100.*TeV),
lowKinEnergy(2.0*MeV),
twoln10(2.0*log(10.0)),
bg2lim(0.0169),
bg2lim(0.0169),
taulim(8.4146e-3)
{
if(p) SetParticle(p);
@@ -61,12 +69,12 @@ G4MuBetheBlochModel::G4MuBetheBlochModel(const G4ParticleDefinition* p)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4MuBetheBlochModel::~G4MuBetheBlochModel()
G4MuBetheBlochModel::~G4MuBetheBlochModel()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4MuBetheBlochModel::SetParticle(const G4ParticleDefinition* p)
void G4MuBetheBlochModel::SetParticle(const G4ParticleDefinition* p)
{
particle = p;
mass = particle->GetPDGMass();
@@ -79,17 +87,15 @@ void G4MuBetheBlochModel::SetParticle(const G4ParticleDefinition* p)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuBetheBlochModel::HighEnergyLimit(const G4ParticleDefinition* p,
const G4Material*)
G4double G4MuBetheBlochModel::HighEnergyLimit(const G4ParticleDefinition* p)
{
if(!particle) SetParticle(p);
return highKinEnergy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuBetheBlochModel::LowEnergyLimit(const G4ParticleDefinition* p,
const G4Material*)
G4double G4MuBetheBlochModel::LowEnergyLimit(const G4ParticleDefinition* p)
{
if(!particle) SetParticle(p);
return lowKinEnergy;
@@ -98,33 +104,40 @@ G4double G4MuBetheBlochModel::LowEnergyLimit(const G4ParticleDefinition* p,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuBetheBlochModel::MinEnergyCut(const G4ParticleDefinition* p,
const G4Material* material)
const G4MaterialCutsCouple* couple)
{
return material->GetIonisation()->GetMeanExcitationEnergy();
return couple->GetMaterial()->GetIonisation()->GetMeanExcitationEnergy();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4bool G4MuBetheBlochModel::IsInCharge(const G4ParticleDefinition* p,
const G4Material*)
G4bool G4MuBetheBlochModel::IsInCharge(const G4ParticleDefinition* p)
{
return (p->GetPDGCharge() != 0.0 && p->GetPDGMass() > 10.*MeV
if(!particle) SetParticle(p);
return (p->GetPDGCharge() != 0.0 && p->GetPDGMass() > 10.*MeV
&& p->GetPDGSpin() == 0.5);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4MuBetheBlochModel::Initialise(const G4ParticleDefinition* p,
const G4DataVector&)
{
if(!particle) SetParticle(p);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuBetheBlochModel::ComputeDEDX(const G4Material* material,
const G4ParticleDefinition* p,
G4double kineticEnergy,
G4double cutEnergy)
G4double cutEnergy)
{
if(!particle) SetParticle(p);
G4double tmax = MaxSecondaryEnergy(p, kineticEnergy);
G4double tau = kineticEnergy/mass;
G4double x = 1.0;
if(cutEnergy < tmax) x = cutEnergy/tmax;
G4double gam = tau + 1.0;
G4double gam = tau + 1.0;
G4double beta2 = 1. - 1./(gam*gam);
G4double bg2 = tau * (tau+2.0);
@@ -139,14 +152,14 @@ G4double G4MuBetheBlochModel::ComputeDEDX(const G4Material* material,
G4double* shellCorrectionVector =
material->GetIonisation()->GetShellCorrectionVector();
G4double eDensity = material->GetElectronDensity();
G4double dedx = log(2.0*electron_mass_c2*bg2*tmax*x/eexc2)-(1.0 + x)*beta2;
G4double totEnergy = kineticEnergy + mass;
G4double del = 0.5*x*tmax/totEnergy;
dedx += del*del;
// density correction
// density correction
x = log(bg2)/twoln10;
if ( x >= x0den ) {
dedx -= twoln10*x - cden ;
@@ -194,20 +207,19 @@ G4double G4MuBetheBlochModel::CrossSection(const G4Material* material,
G4double cutEnergy,
G4double maxEnergy)
{
if(!particle) SetParticle(p);
G4double cross = 0.0;
G4double tmaxSecondary = MaxSecondaryEnergy(p, kineticEnergy);
G4double tmax = G4std::min(tmaxSecondary, maxEnergy);
if(cutEnergy < tmax) {
const G4ElementVector* theElementVector = material->GetElementVector();
const G4double* NbOfAtomsPerVolume = material->GetVecNbOfAtomsPerVolume();
G4int NumberOfElements = material->GetNumberOfElements();
for (G4int iel=0; iel<NumberOfElements; iel++ ) {
cross += NbOfAtomsPerVolume[iel]* CrossSectionPerAtom(
(*theElementVector)[iel]->GetZ(),
cross += NbOfAtomsPerVolume[iel]* CrossSectionPerAtom(
(*theElementVector)[iel]->GetZ(),
kineticEnergy, cutEnergy, tmax, tmaxSecondary);
}
@@ -227,7 +239,7 @@ G4double G4MuBetheBlochModel::CrossSectionPerAtom(
G4double tmax,
G4double tmaxSecondary)
{
G4double cross = 0.;
const G4double xgi[] = {0.06943,0.33001,0.66999,0.93057};
@@ -279,18 +291,18 @@ G4double G4MuBetheBlochModel::DifCrossSectionPerAtom(G4double kineticEnergy,
(beta2*knockonEnergy*knockonEnergy);
G4double a1 = log(1.+2.*knockonEnergy/electron_mass_c2);
G4double a3 = log(4.*totalEnergy*(totalEnergy-knockonEnergy)/(mass*mass));
cross *= (1.+alphaprime*a1*(a3-a1));
cross *= (1.+alphaprime*a1*(a3-a1));
return cross;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4std::vector<G4DynamicParticle*>* G4MuBetheBlochModel::SampleSecondary(
const G4Material* material,
G4DynamicParticle* G4MuBetheBlochModel::SampleSecondary(
const G4MaterialCutsCouple*,
const G4DynamicParticle* dp,
G4double tmin,
G4double maxEnergy)
G4double maxEnergy)
{
G4double tmax = MaxSecondaryEnergy(dp);
G4double xmin = tmin/tmax;
@@ -304,21 +316,21 @@ G4std::vector<G4DynamicParticle*>* G4MuBetheBlochModel::SampleSecondary(
G4double beta2 = 1. - mass*mass/(totEnergy*totEnergy);
G4double x = 0.5*tmax*tmax/(totEnergy*totEnergy);
const G4double alphaprime = fine_structure_const/twopi;
G4double a0=log(2.*totEnergy/mass);
const G4double alphaprime = fine_structure_const/twopi;
G4double a0=log(2.*totEnergy/mass);
G4double grej = (1.0 - beta2*xmin + xmax*xmax*x)*(1. + alphaprime*a0*a0);
G4double z, f, a1, twoep;
// sampling follows ...
// sampling follows ...
do {
G4double q = G4UniformRand();
z = xmin*xmax/(xmin*(1.0 - q) + xmax*q);
twoep = 2.0*z*tmax;
a1= log(1.0 + twoep/electron_mass_c2);
a1= log(1.0 + twoep/electron_mass_c2);
f = (1.0 - beta2 * z + z*z*x)
* (1. + alphaprime*a1*(a0 + log((2.0*totEnergy-twoep)/mass) - a1));
@@ -326,23 +338,23 @@ G4std::vector<G4DynamicParticle*>* G4MuBetheBlochModel::SampleSecondary(
G4cout << "G4MuBetheBlochModel::SampleSecondary Warning! "
<< "Majorant " << grej << " < "
<< f << " for x= " << z
<< G4endl;
<< G4endl;
}
} while( grej*G4UniformRand() >= f );
G4double deltaKinEnergy = z * tmax;
G4double deltaMomentum =
G4double deltaMomentum =
sqrt(deltaKinEnergy * (deltaKinEnergy + 2.0*electron_mass_c2));
G4double totMomentum = sqrt(totEnergy*totEnergy - mass*mass);
G4double cost = deltaKinEnergy * (totEnergy + electron_mass_c2) /
(deltaMomentum * totMomentum);
G4double sint = sqrt(1.0 - cost*cost);
G4double phi = twopi * G4UniformRand() ;
G4double phi = twopi * G4UniformRand() ;
G4ThreeVector deltaDirection(sint*cos(phi),sint*sin(phi), cost) ;
deltaDirection.rotateUz(momentum);
@@ -353,7 +365,19 @@ G4std::vector<G4DynamicParticle*>* G4MuBetheBlochModel::SampleSecondary(
delta->SetKineticEnergy(deltaKinEnergy);
delta->SetMomentumDirection(deltaDirection);
return delta;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4std::vector<G4DynamicParticle*>* G4MuBetheBlochModel::SampleSecondaries(
const G4MaterialCutsCouple* couple,
const G4DynamicParticle* dp,
G4double tmin,
G4double maxEnergy)
{
G4std::vector<G4DynamicParticle*>* vdp = new G4std::vector<G4DynamicParticle*>;
G4DynamicParticle* delta = SampleSecondary(couple,dp,tmin,maxEnergy);
vdp->push_back(delta);
return vdp;
@@ -21,10 +21,10 @@
// ********************************************************************
//
//
// $Id: G4MuBremsstrahlung.cc,v 1.22 2001/11/09 13:52:31 maire Exp $
// GEANT4 tag $Name: geant4-05-00 $
// $Id: G4MuBremsstrahlung.cc,v 1.27 2003/04/29 04:58:32 kurasige Exp $
// GEANT4 tag $Name: geant4-05-01 $
//
//
//
//--------------- G4MuBremsstrahlung physics process ---------------------------
// by Laszlo Urban, September 1997
//
@@ -37,15 +37,18 @@
// 26-09-01 completion of store/retrieve PhysicsTable (mma)
// 28-09-01 suppression of theMuonPlus ..etc..data members (mma)
// 29-10-01 all static functions no more inlined (mma)
// 08-11-01 particleMass becomes a local variable (mma)
// 08-11-01 particleMass becomes a local variable (mma)
// 16-01-03 Migrade to cut per region (V.Ivanchenko)
// 26-04-03 fix problems of retrieve tables (V.Ivanchenko)
//------------------------------------------------------------------------------
#include "G4MuBremsstrahlung.hh"
#include "G4UnitsTable.hh"
#include "G4ProductionCutsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// static members
// static members
//
G4int G4MuBremsstrahlung::nzdat = 5 ;
G4double G4MuBremsstrahlung::zdat[]={1.,4.,13.,29.,92.};
@@ -64,14 +67,14 @@ G4int G4MuBremsstrahlung::NbinLambda = 150;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// constructor
G4MuBremsstrahlung::G4MuBremsstrahlung(const G4String& processName)
: G4VMuEnergyLoss(processName),
: G4VMuEnergyLoss(processName),
theMeanFreePathTable(NULL)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4MuBremsstrahlung::~G4MuBremsstrahlung()
{
if (theMeanFreePathTable) {
@@ -79,53 +82,52 @@ G4MuBremsstrahlung::~G4MuBremsstrahlung()
delete theMeanFreePathTable;
}
if (&PartialSumSigma) {
PartialSumSigma.clearAndDestroy();
}
PartialSumSigma.clearAndDestroy();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuBremsstrahlung::SetLowerBoundLambda(G4double val)
{LowerBoundLambda = val;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuBremsstrahlung::SetUpperBoundLambda(G4double val)
{UpperBoundLambda = val;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuBremsstrahlung::SetNbinLambda(G4int n)
{NbinLambda = n;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuBremsstrahlung::GetLowerBoundLambda()
{ return LowerBoundLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuBremsstrahlung::GetUpperBoundLambda()
{ return UpperBoundLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4int G4MuBremsstrahlung::GetNbinLambda()
{return NbinLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuBremsstrahlung::BuildPhysicsTable(
const G4ParticleDefinition& aParticleType)
{
// get bining from EnergyLoss
LowestKineticEnergy = GetLowerBoundEloss() ;
HighestKineticEnergy = GetUpperBoundEloss() ;
TotBin = GetNbinEloss() ;
if( !CutsWhereModified() && theLossTable) return;
LowestKineticEnergy = GetLowerBoundEloss() ;
HighestKineticEnergy = GetUpperBoundEloss() ;
TotBin = GetNbinEloss() ;
BuildLossTable(aParticleType) ;
if(&aParticleType==G4MuonMinus::MuonMinus())
{
RecorderOfmuminusProcess[CounterOfmuminusProcess] = (*this).theLossTable;
@@ -137,13 +139,10 @@ void G4MuBremsstrahlung::BuildPhysicsTable(
CounterOfmuplusProcess++;
}
if(theMeanFreePathTable == NULL)
MakeSamplingTables(&aParticleType) ;
if( !theMeanFreePathTable ) MakeSamplingTables(&aParticleType) ;
BuildLambdaTable(aParticleType) ;
G4double* gammaCutInRange = G4Gamma::Gamma()->GetLengthCuts();
if( !EqualCutVectors(gammaCutInRange,lastgammaCutInRange))
BuildLambdaTable(aParticleType) ;
G4VMuEnergyLoss::BuildDEDXTable(aParticleType);
if(&aParticleType == G4MuonPlus::MuonPlus()) PrintInfoDefinition();
@@ -155,42 +154,44 @@ void G4MuBremsstrahlung::BuildLossTable(
const G4ParticleDefinition& aParticleType)
{
G4double KineticEnergy,TotalEnergy,bremloss,Z,
loss,natom,Cut ;
loss,natom ;
const G4MaterialTable* theMaterialTable =
G4Material::GetMaterialTable();
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
if (theLossTable) {theLossTable->clearAndDestroy(); delete theLossTable;}
theLossTable = new G4PhysicsTable(numOfCouples);
secondaryEnergyCuts = theCoupleTable->GetEnergyCutsVector(0);
G4double particleMass = aParticleType.GetPDGMass();
GammaCutInKineticEnergy = G4Gamma::Gamma()->GetEnergyCuts() ;
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
// loop for materials
//
for (size_t J=0; J<numOfCouples; J++)
{
if (theLossTable) {
theLossTable->clearAndDestroy();
delete theLossTable;
}
theLossTable = new G4PhysicsTable(numOfMaterials) ;
for (G4int J=0; J<numOfMaterials; J++)
{
G4PhysicsLogVector* aVector = new G4PhysicsLogVector(
LowestKineticEnergy,HighestKineticEnergy,TotBin);
GammaCutInKineticEnergyNow = GammaCutInKineticEnergy[J] ;
const G4Material* material = (*theMaterialTable)[J] ;
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(J);
const G4Material* material= couple->GetMaterial();
G4double Cut = SecondaryEnergyThreshold(J);
const G4ElementVector* theElementVector =
material->GetElementVector() ;
const G4double* theAtomicNumDensityVector =
material->GetAtomicNumDensityVector() ;
const G4int NumberOfElements =
material->GetNumberOfElements() ;
const G4int NumberOfElements = material->GetNumberOfElements() ;
for (G4int i=0; i<TotBin; i++)
{
KineticEnergy = aVector->GetLowEdgeEnergy(i) ;
TotalEnergy = KineticEnergy+particleMass ;
Cut = GammaCutInKineticEnergyNow ;
if(Cut>KineticEnergy) Cut = KineticEnergy ;
bremloss = 0.;
bremloss = 0.;
for (G4int iel=0; iel<NumberOfElements; iel++)
{
@@ -198,11 +199,11 @@ void G4MuBremsstrahlung::BuildLossTable(
natom = theAtomicNumDensityVector[iel] ;
loss = ComputeBremLoss((&aParticleType),Z,
(*theElementVector)[iel]->GetA(),
KineticEnergy,Cut) ;
KineticEnergy,Cut) ;
bremloss += natom*loss ;
}
if(bremloss<0.) bremloss = 0. ;
}
if(bremloss<0.) bremloss = 0. ;
aVector->PutValue(i,bremloss);
}
theLossTable->insert(aVector);
@@ -223,7 +224,7 @@ G4double G4MuBremsstrahlung::ComputeBremLoss(
G4double xgi[]={0.03377,0.16940,0.38069,0.61931,0.83060,0.96623};
G4double wgi[]={0.08566,0.18038,0.23396,0.23396,0.18038,0.08566};
G4double loss = 0. ;
G4double particleMass = aParticleType->GetPDGMass();
TotalEnergy=KineticEnergy+particleMass ;
vcut = GammaEnergyCut/TotalEnergy ;
@@ -231,7 +232,7 @@ G4double G4MuBremsstrahlung::ComputeBremLoss(
aaa=0.;
bbb=vcut ;
if(vcut>vmax) bbb=vmax ;
if(vcut>vmax) bbb=vmax ;
kkk=int((bbb-aaa)/ak1)+k2 ;
hhh=(bbb-aaa)/float(kkk) ;
@@ -262,36 +263,40 @@ void G4MuBremsstrahlung::BuildLambdaTable(
G4double LowEdgeEnergy , Value;
G4double FixedEnergy = (LowestKineticEnergy + HighestKineticEnergy)/2. ;
const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable() ;
//create table
//
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
//create table
if (theMeanFreePathTable) {theMeanFreePathTable->clearAndDestroy();
delete theMeanFreePathTable;
}
theMeanFreePathTable = new G4PhysicsTable(numOfCouples);
if (theMeanFreePathTable) {
theMeanFreePathTable->clearAndDestroy();
delete theMeanFreePathTable;
}
theMeanFreePathTable = new G4PhysicsTable(G4Material::GetNumberOfMaterials());
PartialSumSigma.clearAndDestroy();
PartialSumSigma.resize(G4Material::GetNumberOfMaterials());
PartialSumSigma.resize(numOfCouples);
G4PhysicsLogVector* ptrVector;
for ( size_t J=0 ; J < G4Material::GetNumberOfMaterials(); J++ )
{
for ( size_t J=0; J<numOfCouples; J++ )
{
ptrVector = new G4PhysicsLogVector(
LowerBoundLambda,UpperBoundLambda,NbinLambda);
const G4Material* material= (*theMaterialTable)[J];
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(J);
for ( G4int i = 0 ; i < NbinLambda ; i++ )
for ( G4int i = 0 ; i < NbinLambda ; i++ )
{
LowEdgeEnergy = ptrVector->GetLowEdgeEnergy( i ) ;
Value = ComputeMeanFreePath( &ParticleType, LowEdgeEnergy,
material );
Value = ComputeMeanFreePath( &ParticleType, LowEdgeEnergy, couple);
ptrVector->PutValue( i , Value ) ;
}
theMeanFreePathTable->insertAt( J , ptrVector );
// Compute the PartialSumSigma table at a given fixed energy
ComputePartialSumSigma( &ParticleType, FixedEnergy, material) ;
ComputePartialSumSigma( &ParticleType, FixedEnergy, couple) ;
}
}
@@ -300,31 +305,32 @@ void G4MuBremsstrahlung::BuildLambdaTable(
void G4MuBremsstrahlung::ComputePartialSumSigma(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy,
const G4Material* aMaterial)
const G4MaterialCutsCouple* couple)
// Build the table of cross section per element.
// The table is built for MATERIALS.
// This table is used by DoIt to select randomly an element in the material.
// This table is used by DoIt to select randomly an element in the material.
{
G4int Imate = aMaterial->GetIndex();
G4int NbOfElements = aMaterial->GetNumberOfElements();
const G4ElementVector* theElementVector = aMaterial->GetElementVector();
const G4double* theAtomNumDensityVector =
const G4Material* aMaterial = couple->GetMaterial();
size_t index = couple->GetIndex();
G4int NbOfElements = aMaterial->GetNumberOfElements();
const G4ElementVector* theElementVector = aMaterial->GetElementVector();
const G4double* theAtomNumDensityVector =
aMaterial->GetAtomicNumDensityVector();
G4double GammaEnergyCut = (G4Gamma::Gamma()->GetEnergyCuts())[Imate];
G4double GammaEnergyCut = SecondaryEnergyThreshold(index);
PartialSumSigma[Imate] = new G4DataVector();
PartialSumSigma[index] = new G4DataVector();
G4double SIGMA = 0. ;
G4double SIGMA = 0. ;
for ( G4int Ielem=0 ; Ielem < NbOfElements ; Ielem++ )
{
SIGMA += theAtomNumDensityVector[Ielem] *
for ( G4int Ielem=0 ; Ielem < NbOfElements ; Ielem++ )
{
SIGMA += theAtomNumDensityVector[Ielem] *
ComputeMicroscopicCrossSection( ParticleType, KineticEnergy,
(*theElementVector)[Ielem]->GetZ(),
(*theElementVector)[Ielem]->GetA(),
(*theElementVector)[Ielem]->GetZ(),
(*theElementVector)[Ielem]->GetA(),
GammaEnergyCut );
PartialSumSigma[Imate]->push_back(SIGMA);
}
PartialSumSigma[index]->push_back(SIGMA);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -344,7 +350,7 @@ G4double G4MuBremsstrahlung::ComputeMicroscopicCrossSection(
G4double xgi[]={0.03377,0.16940,0.38069,0.61931,0.83060,0.96623};
G4double wgi[]={0.08566,0.18038,0.23396,0.23396,0.18038,0.08566};
G4double CrossSection = 0. ;
G4double particleMass = ParticleType->GetPDGMass();
TotalEnergy=KineticEnergy+particleMass ;
vcut = GammaEnergyCut/TotalEnergy ;
@@ -370,24 +376,24 @@ G4double G4MuBremsstrahlung::ComputeMicroscopicCrossSection(
}
}
CrossSection *= hhh ;
CrossSection *= hhh ;
return CrossSection;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuBremsstrahlung::GetDMicroscopicCrossSection(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy,
G4double AtomicNumber,
G4double AtomicMass,
G4double AtomicMass,
G4double GammaEnergy)
// get differential cross section
{
return ComputeDMicroscopicCrossSection(ParticleType,KineticEnergy,
AtomicNumber,AtomicMass,GammaEnergy);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -395,12 +401,12 @@ G4double G4MuBremsstrahlung::ComputeDMicroscopicCrossSection(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy,
G4double AtomicNumber,
G4double AtomicMass,
G4double AtomicMass,
G4double GammaEnergy)
// differential cross section
{
G4double particleMass = ParticleType->GetPDGMass();
static const G4double sqrte=sqrt(exp(1.)) ;
static const G4double bh=202.4,bh1=446.,btf=183.,btf1=1429. ;
static const G4double rmass=particleMass/electron_mass_c2 ;
@@ -433,7 +439,7 @@ G4double G4MuBremsstrahlung::ComputeDMicroscopicCrossSection(
b=btf;
b1=btf1;
dnstar = exp((1.-1./AtomicNumber)*log(dn)) ;
}
}
// nucleus contribution logarithm
G4double rab1=b*z13;
@@ -441,7 +447,7 @@ G4double G4MuBremsstrahlung::ComputeDMicroscopicCrossSection(
(particleMass+delta*(dnstar*sqrte-2.))) ;
if(fn <0.) fn = 0. ;
// electron contribution logarithm
G4double epmax1=E/(1.+0.5*particleMass*rmass/E) ;
G4double epmax1=E/(1.+0.5*particleMass*rmass/E) ;
G4double fe=0.;
if(GammaEnergy<epmax1)
{
@@ -450,7 +456,7 @@ G4double G4MuBremsstrahlung::ComputeDMicroscopicCrossSection(
(electron_mass_c2+rab0*rab2))) ;
if(fe<0.) fe=0. ;
}
dxsection = coeff*(1.-v*(1.-0.75*v))*AtomicNumber*(fn*AtomicNumber+fe)/
GammaEnergy ;
return dxsection ;
@@ -532,31 +538,30 @@ void G4MuBremsstrahlung::MakeSamplingTables(
G4VParticleChange* G4MuBremsstrahlung::PostStepDoIt(const G4Track& trackData,
const G4Step& stepData)
const G4Step& stepData)
{
static G4double ysmall = -100. ;
static G4double ytablelow = -5. ;
aParticleChange.Initialize(trackData);
G4Material* aMaterial=trackData.GetMaterial() ;
const G4DynamicParticle* aDynamicParticle=trackData.GetDynamicParticle();
aParticleChange.Initialize(trackData);
const G4MaterialCutsCouple* couple = trackData.GetMaterialCutsCouple();
const G4DynamicParticle* aDynamicParticle=trackData.GetDynamicParticle();
G4double KineticEnergy = aDynamicParticle->GetKineticEnergy();
G4ParticleMomentum ParticleDirection =
G4ParticleMomentum ParticleDirection =
aDynamicParticle->GetMomentumDirection();
// Gamma cut in this material
G4double GammaEnergyCut =
G4Gamma::Gamma()->GetEnergyThreshold(aMaterial);
G4double GammaEnergyCut = SecondaryEnergyThreshold(couple->GetIndex());
// check against insufficient energy
if(KineticEnergy < GammaEnergyCut)
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
// select randomly one element constituing the material
G4Element* anElement = SelectRandomAtom(aMaterial);
// select randomly one element constituing the material
const G4Element* anElement = SelectRandomAtom(couple);
G4double TotalEnergy=KineticEnergy+aDynamicParticle->
GetDefinition()->GetPDGMass() ;
@@ -565,10 +570,10 @@ G4VParticleChange* G4MuBremsstrahlung::PostStepDoIt(const G4Track& trackData,
G4double ymin=log(log(GammaEnergyCut/CutFixed)/log(KineticEnergy/CutFixed)) ;
if(ymin < ysmall)
if(ymin < ysmall)
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
// sampling using tables
// sampling using tables
//G4double v,xc,x,yc,y ;
//G4int iZ,iT,iy ;
G4double v,x,y ;
@@ -601,7 +606,7 @@ G4VParticleChange* G4MuBremsstrahlung::PostStepDoIt(const G4Track& trackData,
itt=it ;
}
}
G4int iymin = G4int((ymin+5.)/dy+0.5) ;
G4int iymin = G4int((ymin+5.)/dy+0.5) ;
if(ymin < ytablelow)
{
@@ -624,12 +629,12 @@ G4VParticleChange* G4MuBremsstrahlung::PostStepDoIt(const G4Track& trackData,
x = exp(y) ;
v = CutFixed*exp(x*log(KineticEnergy/CutFixed)) ;
v = CutFixed*exp(x*log(KineticEnergy/CutFixed)) ;
if( v <= 0.)
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
// create G4DynamicParticle object for the Gamma
G4double GammaEnergy = v;
// create G4DynamicParticle object for the Gamma
G4double GammaEnergy = v;
// angles of the emitted gamma. ( Z - axis along the parent particle)
// Teta = electron_mass_c2/TotalEnergy for the moment .....
@@ -640,21 +645,21 @@ G4VParticleChange* G4MuBremsstrahlung::PostStepDoIt(const G4Track& trackData,
dirz = cos(Teta) ;
G4ThreeVector GammaDirection ( dirx, diry, dirz);
GammaDirection.rotateUz(ParticleDirection);
GammaDirection.rotateUz(ParticleDirection);
G4DynamicParticle* aGamma= new G4DynamicParticle (G4Gamma::Gamma(),
GammaDirection, GammaEnergy);
aParticleChange.SetNumberOfSecondaries(1);
aParticleChange.AddSecondary(aGamma);
aParticleChange.AddSecondary(aGamma);
// Update the incident particle
// Update the incident particle
G4double NewKinEnergy = KineticEnergy - GammaEnergy;
if (NewKinEnergy > 0.)
if (NewKinEnergy > 0.)
{
aParticleChange.SetMomentumChange(ParticleDirection);
aParticleChange.SetEnergyChange(NewKinEnergy);
aParticleChange.SetLocalEnergyDeposit (0.);
aParticleChange.SetLocalEnergyDeposit (0.);
}
else
{
@@ -668,18 +673,19 @@ G4VParticleChange* G4MuBremsstrahlung::PostStepDoIt(const G4Track& trackData,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Element* G4MuBremsstrahlung::SelectRandomAtom(G4Material* aMaterial) const
const G4Element* G4MuBremsstrahlung::SelectRandomAtom(
const G4MaterialCutsCouple* couple) const
{
// select randomly 1 element within the material
const G4int Index = aMaterial->GetIndex();
size_t index = couple->GetIndex();
const G4Material* aMaterial = couple->GetMaterial();
const G4int NumberOfElements = aMaterial->GetNumberOfElements();
const G4ElementVector* theElementVector = aMaterial->GetElementVector();
G4double rval = G4UniformRand()
*((*PartialSumSigma[Index])[NumberOfElements-1]);
*((*PartialSumSigma[index])[NumberOfElements-1]);
for ( G4int i=0; i < NumberOfElements; i++ )
if (rval <= (*PartialSumSigma[Index])[i]) return ((*theElementVector)[i]);
if (rval <= (*PartialSumSigma[index])[i]) return ((*theElementVector)[i]);
G4cout << " WARNING !!! - The Material " << aMaterial->GetName()
<< " has no elements, NULL pointer returned." << G4endl;
return NULL;
@@ -688,11 +694,11 @@ G4Element* G4MuBremsstrahlung::SelectRandomAtom(G4Material* aMaterial) const
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool G4MuBremsstrahlung::StorePhysicsTable(G4ParticleDefinition* particle,
const G4String& directory,
const G4String& directory,
G4bool ascii)
{
G4String filename;
// store stopping power table
filename = GetPhysicsTableFileName(particle,directory,"StoppingPower",ascii);
if ( !theLossTable->StorePhysicsTable(filename, ascii) ){
@@ -715,68 +721,74 @@ G4bool G4MuBremsstrahlung::StorePhysicsTable(G4ParticleDefinition* particle,
<< G4endl;
return false;
}
G4cout << GetProcessName() << " for " << particle->GetParticleName()
<< ": Success to store the PhysicsTables in "
<< ": Success to store the PhysicsTables in "
<< directory << G4endl;
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool G4MuBremsstrahlung::RetrievePhysicsTable(G4ParticleDefinition* particle,
const G4String& directory,
const G4String& directory,
G4bool ascii)
{
// delete theLossTable and theMeanFreePathTable
if (theLossTable != 0) {
theLossTable->clearAndDestroy();
delete theLossTable;
}
delete theLossTable;
}
if (theMeanFreePathTable != 0) {
theMeanFreePathTable->clearAndDestroy();
delete theMeanFreePathTable;
}
if (&PartialSumSigma != 0) PartialSumSigma.clear();
// get bining from EnergyLoss
LowestKineticEnergy = GetLowerBoundEloss();
HighestKineticEnergy = GetUpperBoundEloss();
TotBin = GetNbinEloss();
G4String filename;
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
secondaryEnergyCuts = theCoupleTable->GetEnergyCutsVector(0);
PartialSumSigma.clearAndDestroy();
PartialSumSigma.reserve(numOfCouples);
// retreive stopping power table
filename = GetPhysicsTableFileName(particle,directory,"StoppingPower",ascii);
theLossTable = new G4PhysicsTable(G4Material::GetNumberOfMaterials());
theLossTable = new G4PhysicsTable(numOfCouples);
if ( !theLossTable->RetrievePhysicsTable(filename, ascii) ){
G4cout << " FAIL theLossTable->RetrievePhysicsTable in " << filename
<< G4endl;
<< G4endl;
return false;
}
// 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;
}
// retrieve PartialSumSigma table (G4OrderedTable)
filename = GetPhysicsTableFileName(particle,directory,"PartSumSigma",ascii);
if ( !PartialSumSigma.Retrieve(filename, ascii) ){
G4cout << " FAIL PartialSumSigma.retrieve in " << filename
<< G4endl;
return false;
return false;
}
G4cout << GetProcessName() << " for " << particle->GetParticleName()
<< ": Success to retrieve the PhysicsTables from "
<< directory << G4endl;
if (particle->GetPDGCharge() < 0.)
{
RecorderOfmuminusProcess[CounterOfmuminusProcess] = (*this).theLossTable;
@@ -788,15 +800,17 @@ G4bool G4MuBremsstrahlung::RetrievePhysicsTable(G4ParticleDefinition* particle,
CounterOfmuplusProcess++;
}
secondaryEnergyCuts = theCoupleTable->GetEnergyCutsVector(0);
MakeSamplingTables(particle);
G4VMuEnergyLoss::BuildDEDXTable(*particle);
if(particle==G4MuonPlus::MuonPlus()) PrintInfoDefinition();
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuBremsstrahlung::PrintInfoDefinition()
{
G4String comments = "theoretical cross section \n ";
@@ -29,14 +29,22 @@
// File name: G4MuBremsstrahlungModel
//
// Author: Vladimir Ivanchenko on base of Laszlo Urban code
//
//
// Creation date: 24.06.2002
//
// Modifications: 04.12.02 (VI) Change G4DynamicParticle constructor in PostStepDoIt
// Modifications:
//
// 04-12-02 Change G4DynamicParticle constructor in PostStepDoIt (V.Ivanchenko)
// 23-12-02 Change interface in order to move to cut per region (V.Ivanchenko)
// 24-01-03 Fix for compounds (V.Ivanchenko)
// 27-01-03 Make models region aware (V.Ivanchenko)
// 13-02-03 Add name (V.Ivanchenko)
//
//
// Class Description:
//
// Class Description:
//
//
// -------------------------------------------------------------------
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -50,10 +58,11 @@
#include "G4Material.hh"
#include "G4Element.hh"
#include "G4ElementVector.hh"
#include "G4ProductionCutsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// static members
// static members
//
G4double G4MuBremsstrahlungModel::zdat[]={1.,4.,13.,29.,92.};
G4double G4MuBremsstrahlungModel::adat[]={1.01,9.01,26.98,63.55,238.03};
@@ -61,8 +70,9 @@ G4double G4MuBremsstrahlungModel::tdat[]={1.e3,1.e4,1.e5,1.e6,1.e7,1.e8,1.e9,1.e
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4MuBremsstrahlungModel::G4MuBremsstrahlungModel(const G4ParticleDefinition* p)
: G4VEmModel(),
G4MuBremsstrahlungModel::G4MuBremsstrahlungModel(const G4ParticleDefinition* p,
const G4String& nam)
: G4VEmModel(nam),
highKinEnergy(100.*TeV),
lowKinEnergy(1.0*keV),
minThreshold(1.0*keV),
@@ -70,11 +80,8 @@ G4MuBremsstrahlungModel::G4MuBremsstrahlungModel(const G4ParticleDefinition* p)
ntdat(8),
NBIN(1000),
cutFixed(0.98*keV),
oldMaterial(0),
samplingTablesAreFilled(false)
{
partialSumSigma.clear();
}
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -90,48 +97,70 @@ G4MuBremsstrahlungModel::~G4MuBremsstrahlungModel()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuBremsstrahlungModel::HighEnergyLimit(const G4ParticleDefinition* p,
const G4Material*)
G4double G4MuBremsstrahlungModel::HighEnergyLimit(const G4ParticleDefinition*)
{
return highKinEnergy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuBremsstrahlungModel::LowEnergyLimit(const G4ParticleDefinition* p,
const G4Material*)
G4double G4MuBremsstrahlungModel::LowEnergyLimit(const G4ParticleDefinition*)
{
return lowKinEnergy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuBremsstrahlungModel::MinEnergyCut(const G4ParticleDefinition* p,
const G4Material*)
G4double G4MuBremsstrahlungModel::MinEnergyCut(const G4ParticleDefinition*,
const G4MaterialCutsCouple*)
{
return minThreshold;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4bool G4MuBremsstrahlungModel::IsInCharge(const G4ParticleDefinition* p,
const G4Material*)
G4bool G4MuBremsstrahlungModel::IsInCharge(const G4ParticleDefinition* p)
{
return (p == G4MuonMinus::MuonMinus() || p == G4MuonPlus::MuonPlus());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuBremsstrahlungModel::ComputeDEDX(const G4Material* material,
const G4ParticleDefinition* p,
G4double kineticEnergy,
G4double cutEnergy)
void G4MuBremsstrahlungModel::Initialise(const G4ParticleDefinition*,
const G4DataVector& cuts)
{
if(kineticEnergy < lowKinEnergy) return 0.0;
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
G4double fixedEnergy = 0.5*highKinEnergy;
// G4double fixedEnergy = 500000.*TeV;
for (size_t ii=0; ii<partialSumSigma.size(); ii++){
G4DataVector* a=partialSumSigma[ii];
if ( a ) delete a;
}
partialSumSigma.clear();
for (size_t i=0; i<numOfCouples; i++) {
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i);
const G4Material* material = couple->GetMaterial();
G4DataVector* dv = ComputePartialSumSigma(material, fixedEnergy,cuts[i]);
partialSumSigma.push_back(dv);
}
if(!samplingTablesAreFilled) MakeSamplingTables();
G4double cut = G4std::min(G4std::max(cutEnergy, minThreshold), kineticEnergy);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuBremsstrahlungModel::ComputeDEDX(const G4Material* material,
const G4ParticleDefinition*,
G4double kineticEnergy,
G4double cutEnergy)
{
if(kineticEnergy < lowKinEnergy) return 0.0;
G4double cut = G4std::min(cutEnergy, kineticEnergy);
const G4ElementVector* theElementVector = material->GetElementVector();
const G4double* theAtomicNumDensityVector = material->GetAtomicNumDensityVector();
@@ -141,7 +170,7 @@ G4double G4MuBremsstrahlungModel::ComputeDEDX(const G4Material* material,
for (size_t i=0; i<material->GetNumberOfElements(); i++) {
G4double Z = (*theElementVector)[i]->GetZ();
G4double A = (*theElementVector)[i]->GetA()/(g/mole) ;
G4double A = (*theElementVector)[i]->GetA()/(g/mole) ;
G4double loss = ComputMuBremLoss(Z, A, kineticEnergy, cut);
@@ -162,13 +191,13 @@ G4double G4MuBremsstrahlungModel::ComputMuBremLoss(G4double Z, G4double A,
G4double xgi[]={0.03377,0.16940,0.38069,0.61931,0.83060,0.96623};
G4double wgi[]={0.08566,0.18038,0.23396,0.23396,0.18038,0.08566};
G4double loss = 0.;
G4double vcut = cut/totalEnergy;
G4double vmax = tkin/totalEnergy;
G4double aaa = 0.;
G4double bbb = vcut;
if(vcut>vmax) bbb=vmax ;
if(vcut>vmax) bbb=vmax ;
G4int kkk = (G4int)((bbb-aaa)/ak1)+k2 ;
G4double hhh=(bbb-aaa)/float(kkk) ;
@@ -193,7 +222,7 @@ G4double G4MuBremsstrahlungModel::ComputMuBremLoss(G4double Z, G4double A,
G4double G4MuBremsstrahlungModel::ComputeMicroscopicCrossSection(
G4double tkin,
G4double Z,
G4double A,
G4double A,
G4double cut)
{
G4double totalEnergy = (G4MuonPlus::MuonPlus())->GetPDGMass() + tkin;
@@ -203,8 +232,8 @@ G4double G4MuBremsstrahlungModel::ComputeMicroscopicCrossSection(
G4double wgi[]={0.08566,0.18038,0.23396,0.23396,0.18038,0.08566};
G4double cross = 0.;
if(cut >= tkin) return cross;
if(cut >= tkin) return cross;
G4double vcut = cut/totalEnergy;
G4double vmax = tkin/totalEnergy;
@@ -235,12 +264,12 @@ G4double G4MuBremsstrahlungModel::ComputeMicroscopicCrossSection(
G4double G4MuBremsstrahlungModel::ComputeDMicroscopicCrossSection(
G4double tkin,
G4double Z,
G4double A,
G4double A,
G4double gammaEnergy)
// differential cross section
{
G4double particleMass = (G4MuonPlus::MuonPlus())->GetPDGMass();
static const G4double sqrte=sqrt(exp(1.)) ;
static const G4double bh=202.4,bh1=446.,btf=183.,btf1=1429. ;
static const G4double rmass=particleMass/electron_mass_c2 ;
@@ -272,7 +301,7 @@ G4double G4MuBremsstrahlungModel::ComputeDMicroscopicCrossSection(
b=btf;
b1=btf1;
dnstar = exp((1.-1./Z)*log(dn)) ;
}
}
// nucleus contribution logarithm
G4double rab1=b*z13;
@@ -280,7 +309,7 @@ G4double G4MuBremsstrahlungModel::ComputeDMicroscopicCrossSection(
(particleMass+delta*(dnstar*sqrte-2.))) ;
if(fn <0.) fn = 0. ;
// electron contribution logarithm
G4double epmax1=E/(1.+0.5*particleMass*rmass/E) ;
G4double epmax1=E/(1.+0.5*particleMass*rmass/E) ;
G4double fe=0.;
if(gammaEnergy<epmax1)
{
@@ -289,7 +318,7 @@ G4double G4MuBremsstrahlungModel::ComputeDMicroscopicCrossSection(
(electron_mass_c2+rab0*rab2))) ;
if(fe<0.) fe=0. ;
}
dxsection = coeff*(1.-v*(1. - 0.75*v))*Z*(fn*Z + fe)/gammaEnergy;
return dxsection;
@@ -298,80 +327,62 @@ G4double G4MuBremsstrahlungModel::ComputeDMicroscopicCrossSection(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuBremsstrahlungModel::CrossSection(const G4Material* material,
const G4ParticleDefinition* p,
const G4ParticleDefinition*,
G4double kineticEnergy,
G4double cutEnergy,
G4double maxEnergy)
G4double maxEnergy)
{
G4double cross = 0.0;
G4double tmax = G4std::min(maxEnergy, kineticEnergy);
G4double cut = G4std::max(cutEnergy, minThreshold);
G4double cut = cutEnergy;
if(cut >= tmax) return cross;
if(!samplingTablesAreFilled) MakeSamplingTables();
const G4ElementVector* theElementVector = material->GetElementVector() ;
const G4double* theAtomNumDensityVector = material->GetAtomicNumDensityVector();
if(material != oldMaterial) {
oldMaterial = material;
G4double fixedEnergy = sqrt(lowKinEnergy*highKinEnergy);
ComputePartialSumSigma(material, fixedEnergy, cutEnergy);
}
for (size_t i=0; i<material->GetNumberOfElements(); i++) {
G4double Z = (*theElementVector)[i]->GetZ();
G4double A = (*theElementVector)[i]->GetA()/(g/mole) ;
G4double cr = ComputeMicroscopicCrossSection(kineticEnergy, Z, A, cut);
if(tmax < kineticEnergy) {
cr -= ComputeMicroscopicCrossSection(kineticEnergy, Z, A, tmax);
}
cross += theAtomNumDensityVector[i] * cr;
}
cross += theAtomNumDensityVector[i] * cr;
}
return cross;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4MuBremsstrahlungModel::ComputePartialSumSigma(const G4Material* material,
G4double kineticEnergy,
G4double cut)
G4DataVector* G4MuBremsstrahlungModel::ComputePartialSumSigma(
const G4Material* material,
G4double kineticEnergy,
G4double cut)
// Build the table of cross section per element. The table is built for MATERIALS.
// This table is used by DoIt to select randomly an element in the material.
// This table is used by DoIt to select randomly an element in the material.
{
size_t index = material->GetIndex();
G4int nElements = material->GetNumberOfElements();
const G4ElementVector* theElementVector = material->GetElementVector();
const G4ElementVector* theElementVector = material->GetElementVector();
const G4double* theAtomNumDensityVector = material->GetAtomicNumDensityVector();
G4DataVector* dv;
if (index >= partialSumSigma.size()) {
dv = new G4DataVector();
partialSumSigma.push_back(dv);
} else {
dv = partialSumSigma[index];
dv->clear();
if(0 == index) samplingTablesAreFilled = false;
}
G4DataVector* dv = new G4DataVector();
G4double cross = 0.0;
for (G4int i=0; i<nElements; i++ ) {
G4double Z = (*theElementVector)[i]->GetZ();
G4double A = (*theElementVector)[i]->GetA()/(g/mole) ;
cross += theAtomNumDensityVector[i] * ComputeMicroscopicCrossSection(kineticEnergy,
Z, A, cut);
dv->push_back(cross);
}
return dv;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -422,7 +433,7 @@ void G4MuBremsstrahlungModel::MakeSamplingTables()
AtomicWeight,ep) ;
ya[i]=y ;
proba[iz][it][i] = CrossSection ;
}
proba[iz][it][NBIN] = CrossSection ;
@@ -442,35 +453,35 @@ void G4MuBremsstrahlungModel::MakeSamplingTables()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4std::vector<G4DynamicParticle*>* G4MuBremsstrahlungModel::SampleSecondary(
const G4Material* material,
G4DynamicParticle* G4MuBremsstrahlungModel::SampleSecondary(
const G4MaterialCutsCouple* couple,
const G4DynamicParticle* dp,
G4double tmin,
G4double maxEnergy)
G4double maxEnergy)
{
G4double kineticEnergy = dp->GetKineticEnergy();
// check against insufficient energy
if(tmin >= maxEnergy) return 0;
G4double tmax = G4std::min(kineticEnergy, maxEnergy);
if(tmin >= tmax) return 0;
static G4double ysmall = -100. ;
static G4double ytablelow = -5. ;
G4double kineticEnergy = dp->GetKineticEnergy();
G4ParticleMomentum ParticleDirection = dp->GetMomentumDirection();
// select randomly one element constituing the material
const G4Element* anElement = SelectRandomAtom(material);
// select randomly one element constituing the material
const G4Element* anElement = SelectRandomAtom(couple);
G4double totalEnergy = kineticEnergy + dp->GetMass();
G4double dy = 5./G4float(NBIN);
// This sampling should be checked!!! VI
G4double ymin=log(log(tmin/cutFixed)/log(maxEnergy/cutFixed));
G4double ymin=log(log(tmin/cutFixed)/log(tmax/cutFixed));
if(ymin < ysmall) return 0;
// sampling using tables
// sampling using tables
G4double v,x,y ;
G4int iy;
@@ -495,41 +506,43 @@ G4std::vector<G4DynamicParticle*>* G4MuBremsstrahlungModel::SampleSecondary(
delmin = 1.e10 ;
for (G4int it=0; it<ntdat; it++)
{
del = abs(log(maxEnergy)-log(tdat[it])) ;
del = abs(log(tmax)-log(tdat[it])) ;
if(del<delmin)
{
delmin=del;
itt=it ;
}
}
G4int iymin = G4int((ymin+5.)/dy+0.5) ;
G4int iymin = G4int((ymin+5.)/dy+0.5) ;
if(ymin < ytablelow)
{
y = ymin + G4UniformRand()*(ytablelow-ymin) ;
}
else
{
G4double r = G4UniformRand() ;
do {
if(ymin < ytablelow)
{
y = ymin + G4UniformRand()*(ytablelow-ymin) ;
}
else
{
G4double r = G4UniformRand() ;
iy = iymin-1 ;
delmin = proba[izz][itt][NBINminus1]-proba[izz][itt][iymin] ;
do {
iy = iymin-1 ;
delmin = proba[izz][itt][NBINminus1]-proba[izz][itt][iymin] ;
do {
iy += 1 ;
} while ((r > (proba[izz][itt][iy]-proba[izz][itt][iymin])/delmin)
} while ((r > (proba[izz][itt][iy]-proba[izz][itt][iymin])/delmin)
&&(iy < NBINminus1)) ;
//sampling is Done uniformly in y in the bin
y = ya[iy] + G4UniformRand() * ( ya[iy+1] - ya[iy] ) ;
}
//sampling is Done uniformly in y in the bin
y = ya[iy] + G4UniformRand() * ( ya[iy+1] - ya[iy] ) ;
}
x = exp(y) ;
x = exp(y) ;
v = cutFixed*exp(x*log(maxEnergy/cutFixed)) ;
if( v <= 0.) return 0;
v = cutFixed*exp(x*log(tmax/cutFixed)) ;
} while ( v <= 0.);
// create G4DynamicParticle object for the Gamma
G4double GammaEnergy = v;
// create G4DynamicParticle object for the Gamma
G4double GammaEnergy = v;
// angles of the emitted gamma. ( Z - axis along the parent particle)
// Teta = electron_mass_c2/TotalEnergy for the moment .....
@@ -540,14 +553,26 @@ G4std::vector<G4DynamicParticle*>* G4MuBremsstrahlungModel::SampleSecondary(
dirz = cos(Teta) ;
G4ThreeVector GammaDirection ( dirx, diry, dirz);
GammaDirection.rotateUz(ParticleDirection);
GammaDirection.rotateUz(ParticleDirection);
G4DynamicParticle* aGamma = new G4DynamicParticle();
aGamma->SetDefinition(G4Gamma::Gamma());
aGamma->SetKineticEnergy(GammaEnergy);
aGamma->SetMomentumDirection(GammaDirection);
return aGamma;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4std::vector<G4DynamicParticle*>* G4MuBremsstrahlungModel::SampleSecondaries(
const G4MaterialCutsCouple* couple,
const G4DynamicParticle* dp,
G4double tmin,
G4double maxEnergy)
{
G4std::vector<G4DynamicParticle*>* vdp = new G4std::vector<G4DynamicParticle*>;
G4DynamicParticle* aGamma = SampleSecondary(couple,dp,tmin,maxEnergy);
vdp->push_back(aGamma);
return vdp;
@@ -556,16 +581,17 @@ G4std::vector<G4DynamicParticle*>* G4MuBremsstrahlungModel::SampleSecondary(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
const G4Element* G4MuBremsstrahlungModel::SelectRandomAtom(
const G4Material* material) const
const G4MaterialCutsCouple* couple) const
{
// select randomly 1 element within the material
const G4Material* material = couple->GetMaterial();
G4int nElements = material->GetNumberOfElements();
const G4ElementVector* theElementVector = material->GetElementVector();
if(1 == nElements) return (*theElementVector)[0];
else if(1 > nElements) return 0;
else if(1 > nElements) return 0;
G4DataVector* dv = partialSumSigma[material->GetIndex()];
G4DataVector* dv = partialSumSigma[couple->GetIndex()];
G4double rval = G4UniformRand()*((*dv)[nElements-1]);
for (G4int i=0; i<nElements; i++) {
if (rval <= (*dv)[i]) return (*theElementVector)[i];
@@ -574,5 +600,3 @@ const G4Element* G4MuBremsstrahlungModel::SelectRandomAtom(
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -35,16 +35,18 @@
// Modifications:
//
// 08-04-98 remove 'tracking cut' of muon in oIt, MMa
// 26/10/98 new cross section of R.Kokoulin,cleanup , L.Urban
// 10/02/00 modifications , new e.m. structure, L.Urban
// 29/05/01 V.Ivanchenko minor changes to provide ANSI -wall compilation
// 26-10-98 new cross section of R.Kokoulin,cleanup , L.Urban
// 10-02-00 modifications , new e.m. structure, L.Urban
// 29-05-01 V.Ivanchenko minor changes to provide ANSI -wall compilation
// 09-08-01 new methods Store/Retrieve PhysicsTable (mma)
// 17-09-01 migration of Materials to pure STL (mma)
// 26-09-01 completion of store/retrieve PhysicsTable (mma)
// 28-09-01 suppression of theMuonPlus ..etc..data members (mma)
// 29-10-01 all static functions no more inlined (mma)
// 08-11-01 particleMass becomes a local variable (mma)
// 08-11-01 particleMass becomes a local variable (mma)
// 19-08-02 V.Ivanchenko update to new design
// 23-12-02 Change interface in order to move to cut per region (V.Ivanchenko)
// 26-12-02 Secondary production moved to derived classes (V.Ivanchenko)
//
// -------------------------------------------------------------------
//
@@ -78,7 +80,6 @@ G4MuBremsstrahlungSTD::~G4MuBremsstrahlungSTD()
void G4MuBremsstrahlungSTD::InitialiseProcess()
{
SetSecondaryParticle(G4Gamma::Gamma());
SetSubCutoffIsDesired(false);
SetDEDXBinning(120);
SetLambdaBinning(120);
@@ -86,11 +87,9 @@ void G4MuBremsstrahlungSTD::InitialiseProcess()
SetMaxKinEnergy(100.0*TeV);
G4VEmModel* em = new G4MuBremsstrahlungModel();
em->SetLowEnergyLimit(0, 0.1*keV);
em->SetHighEnergyLimit(0, 100.0*TeV);
AddEmModel(em, 0);
G4VEmFluctuationModel* fm = new G4UniversalFluctuation();
AddEmFluctuationModel(fm);
em->SetLowEnergyLimit(0.1*keV);
em->SetHighEnergyLimit(100.0*TeV);
AddEmModel(1, em);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -21,11 +21,11 @@
// ********************************************************************
//
//
// $Id: G4MuIonisation.cc,v 1.26 2002/12/04 15:45:53 vnivanch Exp $
// GEANT4 tag $Name: geant4-05-00 $
// $Id: G4MuIonisation.cc,v 1.31 2003/04/26 11:38:05 vnivanch Exp $
// GEANT4 tag $Name: geant4-05-01 $
//
// --------------- G4MuIonisation physics process ------------------------------
// by Laszlo Urban, September 1997
// by Laszlo Urban, September 1997
// -----------------------------------------------------------------------------
//
// 08-04-98 remove 'tracking cut' of the ionizing particle (mma)
@@ -33,21 +33,24 @@
// 10-02-00 modifications , new e.m. structure, L.Urban
// 23-03-01 R.Kokoulin's correction is commented out, L.Urban
// 29-05-01 V.Ivanchenko minor changes to provide ANSI -wall compilation
// 10-08-01 new methods Store/Retrieve PhysicsTable (mma)
// 10-08-01 new methods Store/Retrieve PhysicsTable (mma)
// 28-08-01 new function ComputeRestrictedMeandEdx() + 'cleanup' (mma)
// 17-09-01 migration of Materials to pure STL (mma)
// 26-09-01 completion of RetrievePhysicsTable (mma)
// 29-10-01 all static functions no more inlined (mma)
// 29-10-01 all static functions no more inlined (mma)
// 07-11-01 correction(Tmax+xsection computation) L.Urban
// 08-11-01 particleMass becomes a local variable (mma)
// 04-12-02 fix misprint in majorant in PostStep (VI)
// 16-01-03 Migrade to cut per region (V.Ivanchenko)
// 26-04-03 fix problems of retrieve tables (V.Ivanchenko)
// -----------------------------------------------------------------------------
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "G4MuIonisation.hh"
#include "G4UnitsTable.hh"
#include "G4ProductionCutsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -56,15 +59,15 @@ G4double G4MuIonisation::UpperBoundLambda = 1000000.*TeV;
G4int G4MuIonisation::NbinLambda = 150;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4MuIonisation::G4MuIonisation(const G4String& processName)
: G4VMuEnergyLoss(processName),
theMeanFreePathTable(0)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4MuIonisation::~G4MuIonisation()
G4MuIonisation::~G4MuIonisation()
{
if (theMeanFreePathTable) {
theMeanFreePathTable->clearAndDestroy(); delete theMeanFreePathTable;}
@@ -86,7 +89,7 @@ void G4MuIonisation::SetNbinLambda(G4int n)
{NbinLambda = n;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuIonisation::GetLowerBoundLambda()
{ return LowerBoundLambda;}
@@ -105,6 +108,8 @@ G4int G4MuIonisation::GetNbinLambda()
void G4MuIonisation::BuildPhysicsTable(const G4ParticleDefinition& ParticleType)
// just call BuildLossTable+BuildLambdaTable
{
if( !CutsWhereModified() && theLossTable) return;
// get bining from EnergyLoss
LowestKineticEnergy = GetLowerBoundEloss();
HighestKineticEnergy = GetUpperBoundEloss();
@@ -122,11 +127,9 @@ void G4MuIonisation::BuildPhysicsTable(const G4ParticleDefinition& ParticleType)
RecorderOfmuminusProcess[CounterOfmuminusProcess] = (*this).theLossTable;
CounterOfmuminusProcess++;
}
if( !EqualCutVectors(G4Electron::Electron()
->GetLengthCuts(), lastelectronCutInRange))
BuildLambdaTable(ParticleType);
BuildLambdaTable(ParticleType);
G4VMuEnergyLoss::BuildDEDXTable(ParticleType);
if(&ParticleType == G4MuonPlus::MuonPlus()) PrintInfoDefinition();
@@ -136,44 +139,42 @@ void G4MuIonisation::BuildPhysicsTable(const G4ParticleDefinition& ParticleType)
void G4MuIonisation::BuildLossTable(const G4ParticleDefinition& aParticleType)
{
// Build tables of dE/dx due to the ionization process
// the tables are built for *MATERIALS*
// 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* DeltaCutInKineticEnergy = (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 = DeltaCutInKineticEnergy[J];
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++)
{
G4double dEdx = ComputeRestrictedMeandEdx(aParticleType,
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);
aVector->PutValue(i,dEdx);
}
theLossTable->insert(aVector);
}
}
@@ -181,47 +182,52 @@ void G4MuIonisation::BuildLossTable(const G4ParticleDefinition& aParticleType)
void G4MuIonisation::BuildLambdaTable(const G4ParticleDefinition& aParticleType)
{
// Build mean free path tables for the delta ray production process
// tables are built for MATERIALS
//create table
//
const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable();
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
if(0 < verboseLevel) {
G4cout << "G4MuIonisation::BuildLambdaTable() for process "
<< GetProcessName() << " and particle "
<< aParticleType.GetParticleName() << G4endl;
}
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* DeltaCutInKineticEnergy = (G4Electron::Electron())->GetEnergyCuts();
// loop for materials
theMeanFreePathTable = new G4PhysicsTable(numOfCouples);
secondaryEnergyCuts = theCoupleTable->GetEnergyCutsVector(1);
// loop for materials
for (size_t J=0 ; J < numOfCouples; J++)
{
for (G4int J=0 ; J < numOfMaterials; 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();
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 =DeltaCutInKineticEnergy[J];
G4double DeltaThreshold = SecondaryEnergyThreshold(J);
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]*
@@ -232,11 +238,11 @@ void G4MuIonisation::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);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -250,12 +256,12 @@ G4double G4MuIonisation::ComputeRestrictedMeandEdx (
// calculate the dE/dx due to the ionization process (Geant4 internal units)
// Bethe-Bloch formula
//
G4double particleMass = aParticleType.GetPDGMass();
G4double particleMass = aParticleType.GetPDGMass();
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;
@@ -265,30 +271,30 @@ G4double G4MuIonisation::ComputeRestrictedMeandEdx (
G4double dEdx = 0.;
//
// high energy part , Bethe-Bloch formula
//
// 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;
@@ -297,38 +303,38 @@ G4double G4MuIonisation::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
dEdx -= (delta + sh); dEdx /= beta2;
// correction of R. Kokoulin // has been taken out ***************
// correction of R. Kokoulin // has been taken out ***************
// G4double E = KineticEnergy+particleMass;
// G4double epmax = RateMass*E*E/(RateMass*E+particleMass);
// G4double apar = log(2.*epmax/electron_mass_c2);
// dEdx += fine_structure_const*(log(2.*E/particleMass)-apar/3.)*
// apar*apar/twopi;
// apar*apar/twopi;
dEdx *= twopi_mc2_rcl2*ElectronDensity;
if (dEdx < 0.) dEdx = 0.;
}
//
//
// low energy part , parametrized energy loss formulae
//
//
if (tau <= taul)
{
// get elements in the actual material,
{
// 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);
@@ -340,7 +346,7 @@ G4double G4MuIonisation::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);
@@ -363,8 +369,8 @@ G4double G4MuIonisation::ComputeCrossSectionPerAtom(
// calculates the totalcross section per atom in GEANT4 internal units
// ( it is called for elements , AtomicNumber = Z )
//
G4double particleMass = aParticleType.GetPDGMass();
G4double particleMass = aParticleType.GetPDGMass();
G4double TotalEnergy = KineticEnergy + particleMass;
G4double tempvar = particleMass+electron_mass_c2;
G4double KnockonMaxEnergy = 2.*electron_mass_c2*KineticEnergy
@@ -373,7 +379,7 @@ G4double G4MuIonisation::ComputeCrossSectionPerAtom(
G4double TotalCrossSection = 0.;
if (KnockonMaxEnergy <= DeltaThreshold) return TotalCrossSection;
const G4double xgi[] = {0.06943,0.33001,0.66999,0.93057};
const G4double wgi[] = {0.17393,0.32607,0.32607,0.17393};
const G4double ak1 = 4.6;
@@ -385,7 +391,7 @@ G4double G4MuIonisation::ComputeCrossSectionPerAtom(
G4double hhh = (bbb-aaa)/kkk;
G4double step = exp(hhh);
G4double ymax = 1./KnockonMaxEnergy;
for (G4int k=0; k<kkk; k++)
{
G4double ymin = ymax;
@@ -414,7 +420,7 @@ G4double G4MuIonisation::ComputeDifCrossSectionPerAtom(
// using the cross section formula of R.P. Kokoulin (10/98)
{
const G4double alphaprime = fine_structure_const/twopi;
G4double particleMass = ParticleType.GetPDGMass();
G4double particleMass = ParticleType.GetPDGMass();
G4double TotalEnergy = KineticEnergy + particleMass;
G4double betasquare = KineticEnergy*(TotalEnergy+particleMass)
/(TotalEnergy*TotalEnergy);
@@ -433,19 +439,19 @@ G4double G4MuIonisation::ComputeDifCrossSectionPerAtom(
G4double a1 = log(1.+2.*KnockonEnergy/electron_mass_c2);
G4double a3 = log(4.*TotalEnergy*(TotalEnergy-KnockonEnergy)/
(particleMass*particleMass));
DifCrossSection *= (1.+alphaprime*a1*(a3-a1));
DifCrossSection *= (1.+alphaprime*a1*(a3-a1));
return DifCrossSection;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange* G4MuIonisation::PostStepDoIt(const G4Track& trackData,
const G4Step& stepData)
G4VParticleChange* G4MuIonisation::PostStepDoIt(const G4Track& trackData,
const G4Step& stepData)
{
aParticleChange.Initialize(trackData);
G4Material* aMaterial = trackData.GetMaterial();
const G4MaterialCutsCouple* couple = trackData.GetMaterialCutsCouple();
const G4DynamicParticle* aParticle = trackData.GetDynamicParticle();
G4double particleMass = aParticle->GetDefinition()->GetPDGMass();
@@ -453,31 +459,30 @@ G4VParticleChange* G4MuIonisation::PostStepDoIt(const G4Track& trackData,
G4double TotalEnergy = KineticEnergy + particleMass;
G4double Psquare = KineticEnergy*(TotalEnergy+particleMass);
G4double Esquare = TotalEnergy*TotalEnergy;
G4double betasquare=Psquare/Esquare;
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* DeltaCutInKineticEnergy = (G4Electron::Electron())->GetEnergyCuts();
G4double DeltaThreshold = DeltaCutInKineticEnergy[aMaterial->GetIndex()];
// 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
// normal case
G4double xc = DeltaThreshold/MaxKineticEnergyTransfer;
G4double rate = MaxKineticEnergyTransfer/TotalEnergy;
G4double te2 = 0.5*rate*rate;
// sampling follows ...
G4double x,twoep,a1,grej;
const G4double alphaprime = fine_structure_const/twopi;
G4double a0=log(2.*TotalEnergy/particleMass);
const G4double alphaprime = fine_structure_const/twopi;
G4double a0=log(2.*TotalEnergy/particleMass);
G4double grejc=(1.-xc*betasquare+te2)*(1.+ alphaprime*a0*a0);
do { x=xc/(1.-(1.-xc)*G4UniformRand());
twoep = 2.*x*MaxKineticEnergyTransfer;
@@ -485,7 +490,7 @@ G4VParticleChange* G4MuIonisation::PostStepDoIt(const G4Track& trackData,
grej = (1.-x*(betasquare-x*te2))*(1.+alphaprime*a1*
(a0+log((2.*TotalEnergy-twoep)/particleMass)-a1))/grejc ;
} while(G4UniformRand() > grej);
G4double DeltaKineticEnergy = x * MaxKineticEnergyTransfer;
if (DeltaKineticEnergy <= 0.)
@@ -501,8 +506,8 @@ G4VParticleChange* G4MuIonisation::PostStepDoIt(const G4Track& trackData,
if (costheta > +1.) costheta = +1.;
// direction of the delta electron
//
G4double phi = twopi * G4UniformRand();
//
G4double phi = twopi * G4UniformRand();
G4double sintheta = sqrt((1.+costheta)*(1.-costheta));
G4double dirx = sintheta*cos(phi), diry = sintheta*sin(phi), dirz = costheta;
@@ -514,11 +519,11 @@ G4VParticleChange* G4MuIonisation::PostStepDoIt(const G4Track& trackData,
G4DynamicParticle *theDeltaRay = new G4DynamicParticle;
theDeltaRay->SetKineticEnergy( DeltaKineticEnergy );
theDeltaRay->SetMomentumDirection(
DeltaDirection.x(),DeltaDirection.y(),DeltaDirection.z());
DeltaDirection.x(),DeltaDirection.y(),DeltaDirection.z());
theDeltaRay->SetDefinition(G4Electron::Electron());
// fill aParticleChange
//
//
G4double finalKineticEnergy = KineticEnergy - DeltaKineticEnergy;
if (finalKineticEnergy > 0.)
@@ -543,10 +548,10 @@ G4VParticleChange* G4MuIonisation::PostStepDoIt(const G4Track& trackData,
}
aParticleChange.SetEnergyChange( finalKineticEnergy );
aParticleChange.SetNumberOfSecondaries(1);
aParticleChange.SetNumberOfSecondaries(1);
aParticleChange.AddSecondary(theDeltaRay);
aParticleChange.SetLocalEnergyDeposit (0.);
//ResetNumberOfInteractionLengthLeft();
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
}
@@ -554,11 +559,11 @@ return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool G4MuIonisation::StorePhysicsTable(G4ParticleDefinition* particle,
const G4String& directory,
const G4String& directory,
G4bool ascii)
{
G4String filename;
// store stopping power table
filename = GetPhysicsTableFileName(particle,directory,"StoppingPower",ascii);
if ( !theLossTable->StorePhysicsTable(filename, ascii) ){
@@ -573,59 +578,65 @@ G4bool G4MuIonisation::StorePhysicsTable(G4ParticleDefinition* particle,
<< G4endl;
return false;
}
G4cout << GetProcessName() << " for " << particle->GetParticleName()
<< ": Success to store the PhysicsTables in "
<< ": Success to store the PhysicsTables in "
<< directory << G4endl;
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool G4MuIonisation::RetrievePhysicsTable(G4ParticleDefinition* particle,
const G4String& directory,
const G4String& directory,
G4bool ascii)
{
// 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 filename;
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
secondaryEnergyCuts = theCoupleTable->GetEnergyCutsVector(1);
// retreive stopping power table
filename = GetPhysicsTableFileName(particle,directory,"StoppingPower",ascii);
theLossTable = new G4PhysicsTable(G4Material::GetNumberOfMaterials());
theLossTable = new G4PhysicsTable(numOfCouples);
if ( !theLossTable->RetrievePhysicsTable(filename, ascii) ){
G4cout << " FAIL theLossTable0->RetrievePhysicsTable in " << filename
<< G4endl;
<< G4endl;
return false;
}
// 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;
}
G4cout << GetProcessName() << " for " << particle->GetParticleName()
<< ": Success to retrieve the PhysicsTables from "
<< directory << G4endl;
if (particle->GetPDGCharge() > 0.)
{
RecorderOfmuplusProcess[CounterOfmuplusProcess] = (*this).theLossTable;
@@ -636,13 +647,14 @@ G4bool G4MuIonisation::RetrievePhysicsTable(G4ParticleDefinition* particle,
RecorderOfmuminusProcess[CounterOfmuminusProcess] = (*this).theLossTable;
CounterOfmuminusProcess++;
}
G4VMuEnergyLoss::BuildDEDXTable(*particle);
if(particle==G4MuonPlus::MuonPlus()) PrintInfoDefinition();
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuIonisation::PrintInfoDefinition()
@@ -32,22 +32,25 @@
//
// Creation date: 30.09.1997
//
// Modifications:
// Modifications:
//
// 08-04-98 remove 'tracking cut' of the ionizing particle (mma)
// 26-10-98 new stuff from R.Kokoulin + cleanup , L.Urban
// 10-02-00 modifications , new e.m. structure, L.Urban
// 23-03-01 R.Kokoulin's correction is commented out, L.Urban
// 29-05-01 V.Ivanchenko minor changes to provide ANSI -wall compilation
// 10-08-01 new methods Store/Retrieve PhysicsTable (mma)
// 10-08-01 new methods Store/Retrieve PhysicsTable (mma)
// 28-08-01 new function ComputeRestrictedMeandEdx() + 'cleanup' (mma)
// 17-09-01 migration of Materials to pure STL (mma)
// 26-09-01 completion of RetrievePhysicsTable (mma)
// 29-10-01 all static functions no more inlined (mma)
// 29-10-01 all static functions no more inlined (mma)
// 07-11-01 correction(Tmax+xsection computation) L.Urban
// 08-11-01 particleMass becomes a local variable (mma)
// 10-05-02 V.Ivanchenko update to new design
// 04-12-02 V.Ivanchenko the low energy limit for Kokoulin model to 10 GeV
// 04-12-02 V.Ivanchenko the low energy limit for Kokoulin model to 10 GeV
// 23-12-02 Change interface in order to move to cut per region (V.Ivanchenko)
// 26-12-02 Secondary production moved to derived classes (V.Ivanchenko)
// 13-02-03 SubCutoff regime is assigned to a region (V.Ivanchenko)
//
// -------------------------------------------------------------------
//
@@ -66,45 +69,45 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4MuIonisationSTD::G4MuIonisationSTD(const G4String& name)
G4MuIonisationSTD::G4MuIonisationSTD(const G4String& name)
: G4VEnergyLossSTD(name),
theParticle(0),
theBaseParticle(0)
theBaseParticle(0),
subCutoff(false)
{
InitialiseProcess();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4MuIonisationSTD::~G4MuIonisationSTD()
G4MuIonisationSTD::~G4MuIonisationSTD()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4MuIonisationSTD::InitialiseProcess()
void G4MuIonisationSTD::InitialiseProcess()
{
SetSecondaryParticle(G4Electron::Electron());
SetSubCutoffIsDesired(true);
SetDEDXBinning(120);
SetLambdaBinning(120);
SetMinKinEnergy(0.1*keV);
SetMaxKinEnergy(100.0*TeV);
G4VEmModel* em = new G4BraggModel();
em->SetLowEnergyLimit(0, 0.1*keV);
em->SetHighEnergyLimit(0, 2.*MeV);
AddEmModel(em, 0);
G4VEmModel* em1 = new G4BetheBlochModel();
em1->SetLowEnergyLimit(0, 2.*MeV);
em1->SetHighEnergyLimit(0, 10.0*GeV);
AddEmModel(em1, 1);
G4VEmModel* em2 = new G4MuBetheBlochModel();
em2->SetLowEnergyLimit(0, 10.0*GeV);
em2->SetHighEnergyLimit(0, 100.0*TeV);
AddEmModel(em2, 2);
G4VEmFluctuationModel* fm = new G4UniversalFluctuation();
AddEmFluctuationModel(fm);
G4VEmModel* em = new G4BraggModel();
em->SetLowEnergyLimit(0.1*keV);
em->SetHighEnergyLimit(2.*MeV);
AddEmModel(1, em, fm);
G4VEmModel* em1 = new G4BetheBlochModel();
em1->SetLowEnergyLimit(2.*MeV);
em1->SetHighEnergyLimit(10.0*GeV);
AddEmModel(2, em1, fm);
G4VEmModel* em2 = new G4MuBetheBlochModel();
em2->SetLowEnergyLimit(10.0*GeV);
em2->SetHighEnergyLimit(100.0*TeV);
AddEmModel(3, em2, fm);
mass = (G4MuonPlus::MuonPlus())->GetPDGMass();
ratio = electron_mass_c2/mass;
@@ -126,11 +129,18 @@ void G4MuIonisationSTD::PrintInfoDefinition() const
{
G4VEnergyLossSTD::PrintInfoDefinition();
G4cout << " Bether-Bloch model for E > 0.2 MeV "
G4cout << " Bether-Bloch model for E > 0.2 MeV "
<< "parametrisation of Bragg peak below."
<< G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4MuIonisationSTD::SetSubCutoff(G4bool val)
{
subCutoff = val;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -21,11 +21,11 @@
// ********************************************************************
//
//
// $Id: G4MuPairProduction.cc,v 1.26 2001/11/09 13:52:32 maire Exp $
// GEANT4 tag $Name: geant4-05-00 $
// $Id: G4MuPairProduction.cc,v 1.33 2003/04/29 04:58:33 kurasige Exp $
// GEANT4 tag $Name: geant4-05-01 $
//
//--------------- G4MuPairProduction physics process ---------------------------
// by Laszlo Urban, May 1998
// by Laszlo Urban, May 1998
//------------------------------------------------------------------------------
// 04-06-98 in DoIt,secondary production condition:
// range>G4std::min(threshold,safety)
@@ -40,15 +40,19 @@
// 26-09-01 completion of store/retrieve PhysicsTable
// 28-09-01 suppression of theMuonPlus ..etc..data members (mma)
// 29-10-01 all static functions no more inlined (mma)
// 07-11-01 particleMass becomes a local variable (mma)
// 07-11-01 particleMass becomes a local variable (mma)
// 08-01-03 DoIt: no more 'tracking cut' for the muon (mma)
// 16-01-03 Migrade to cut per region (V.Ivanchenko)
// 26-04-03 fix problems of retrieve tables (V.Ivanchenko)
//------------------------------------------------------------------------------
#include "G4MuPairProduction.hh"
#include "G4EnergyLossTables.hh"
#include "G4UnitsTable.hh"
#include "G4ProductionCutsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// static members
G4int G4MuPairProduction::nzdat = 5 ;
@@ -67,12 +71,12 @@ G4int G4MuPairProduction::NbinLambda = 150;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4MuPairProduction::G4MuPairProduction(const G4String& processName)
: G4VMuEnergyLoss(processName),
: G4VMuEnergyLoss(processName),
theMeanFreePathTable(NULL)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4MuPairProduction::~G4MuPairProduction()
{
if (theMeanFreePathTable) {
@@ -80,9 +84,7 @@ G4MuPairProduction::~G4MuPairProduction()
delete theMeanFreePathTable;
}
if (&PartialSumSigma) {
PartialSumSigma.clearAndDestroy();
}
PartialSumSigma.clearAndDestroy();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -91,27 +93,27 @@ void G4MuPairProduction::SetLowerBoundLambda(G4double val)
{LowerBoundLambda = val;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuPairProduction::SetUpperBoundLambda(G4double val)
{UpperBoundLambda = val;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuPairProduction::SetNbinLambda(G4int n)
{NbinLambda = n;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuPairProduction::GetLowerBoundLambda()
{ return LowerBoundLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuPairProduction::GetUpperBoundLambda()
{ return UpperBoundLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4int G4MuPairProduction::GetNbinLambda()
{return NbinLambda;}
@@ -121,14 +123,14 @@ void G4MuPairProduction::BuildPhysicsTable(
const G4ParticleDefinition& aParticleType)
// just call BuildLossTable+BuildLambdaTable
{
// get bining from EnergyLoss
LowestKineticEnergy = GetLowerBoundEloss() ;
HighestKineticEnergy = GetUpperBoundEloss() ;
TotBin = GetNbinEloss() ;
if( !CutsWhereModified() && theLossTable) return;
LowestKineticEnergy = GetLowerBoundEloss() ;
HighestKineticEnergy = GetUpperBoundEloss() ;
TotBin = GetNbinEloss() ;
BuildLossTable(aParticleType) ;
if(&aParticleType==G4MuonMinus::MuonMinus())
{
RecorderOfmuminusProcess[CounterOfmuminusProcess] = (*this).theLossTable ;
@@ -141,12 +143,9 @@ void G4MuPairProduction::BuildPhysicsTable(
}
// sampling table should be made only once !
if(theMeanFreePathTable == NULL)
MakeSamplingTables(&aParticleType);
if( !theMeanFreePathTable ) MakeSamplingTables(&aParticleType);
G4double* electronCutInRange = G4Electron::Electron()->GetLengthCuts();
if( !EqualCutVectors(electronCutInRange, lastelectronCutInRange))
BuildLambdaTable(aParticleType) ;
BuildLambdaTable(aParticleType) ;
G4VMuEnergyLoss::BuildDEDXTable(aParticleType);
@@ -161,28 +160,31 @@ void G4MuPairProduction::BuildLossTable(
G4double KineticEnergy,TotalEnergy,pairloss,Z,
loss,natom,eCut,pCut ;
const G4MaterialTable* theMaterialTable =
G4Material::GetMaterialTable();
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
if (theLossTable) {theLossTable->clearAndDestroy(); delete theLossTable;}
theLossTable = new G4PhysicsTable(numOfCouples);
electronEnergyCuts = theCoupleTable->GetEnergyCutsVector(1);
positronEnergyCuts = theCoupleTable->GetEnergyCutsVector(2);
G4double particleMass = aParticleType.GetPDGMass();
ElectronCutInKineticEnergy = G4Electron::Electron()->GetEnergyCuts();
PositronCutInKineticEnergy = G4Positron::Positron()->GetEnergyCuts();
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
if (theLossTable) {
theLossTable->clearAndDestroy();
delete theLossTable;
}
theLossTable = new G4PhysicsTable(numOfMaterials) ;
for (G4int J=0; J<numOfMaterials; J++)
// loop for materials
//
for (size_t J=0; J<numOfCouples; J++)
{
G4PhysicsLogVector* aVector = new G4PhysicsLogVector(
LowestKineticEnergy,HighestKineticEnergy,TotBin);
ElectronCutInKineticEnergyNow = ElectronCutInKineticEnergy[J] ;
PositronCutInKineticEnergyNow = PositronCutInKineticEnergy[J] ;
const G4Material* material = (*theMaterialTable)[J] ;
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(J);
const G4Material* material= couple->GetMaterial();
G4double electronCut = (*electronEnergyCuts)[J] ;
G4double positronCut = (*positronEnergyCuts)[J] ;
const G4ElementVector* theElementVector =
material->GetElementVector() ;
const G4double* theAtomicNumDensityVector =
@@ -194,8 +196,9 @@ void G4MuPairProduction::BuildLossTable(
{
KineticEnergy = aVector->GetLowEdgeEnergy(i) ;
TotalEnergy = KineticEnergy+particleMass ;
eCut = ElectronCutInKineticEnergyNow ;
pCut = PositronCutInKineticEnergyNow ;
eCut = electronCut;
pCut = positronCut;
if(eCut>KineticEnergy)
eCut = KineticEnergy ;
@@ -208,7 +211,7 @@ void G4MuPairProduction::BuildLossTable(
Z=(*theElementVector)[iel]->GetZ();
natom = theAtomicNumDensityVector[iel] ;
loss = ComputePairLoss(&aParticleType,
Z,KineticEnergy,eCut,pCut) ;
Z,KineticEnergy,eCut,pCut) ;
pairloss += natom*loss ;
}
if(pairloss<0.)
@@ -226,8 +229,8 @@ G4double G4MuPairProduction::ComputePairLoss(
const G4ParticleDefinition* ParticleType,
G4double AtomicNumber,
G4double KineticEnergy,
G4double ElectronEnergyCut,
G4double PositronEnergyCut)
G4double ElectronEnergyCut,
G4double PositronEnergyCut)
{
static const G4double
xgi[] ={ 0.0199,0.1017,0.2372,0.4083,0.5917,0.7628,0.8983,0.9801 };
@@ -245,26 +248,26 @@ G4double G4MuPairProduction::ComputePairLoss(
G4double CutInPairEnergy = ElectronEnergyCut+PositronEnergyCut
+2.*electron_mass_c2 ;
if( CutInPairEnergy <= MinPairEnergy ) return loss ;
G4double particleMass = ParticleType->GetPDGMass();
G4double MaxPairEnergy = KineticEnergy+particleMass*(1.-0.75*sqrte*z13) ;
if(MaxPairEnergy < MinPairEnergy)
MaxPairEnergy = MinPairEnergy ;
if( CutInPairEnergy >= MaxPairEnergy )
if( CutInPairEnergy >= MaxPairEnergy )
CutInPairEnergy = MaxPairEnergy ;
if(CutInPairEnergy <= MinPairEnergy) return loss ;
G4double aaa,bbb,hhh,x,epln,ep ;
G4int kkk ;
// calculate the rectricted loss
// calculate the rectricted loss
// numerical integration in log(PairEnergy)
aaa = log(MinPairEnergy) ;
bbb = log(CutInPairEnergy) ;
kkk = int((bbb-aaa)/ak1+ak2) ;
hhh = (bbb-aaa)/kkk ;
for (G4int l=0 ; l<kkk; l++)
{
x = aaa+hhh*l ;
@@ -289,69 +292,73 @@ void G4MuPairProduction::BuildLambdaTable(
{
G4double LowEdgeEnergy , Value;
G4double FixedEnergy = (LowestKineticEnergy + HighestKineticEnergy)/2. ;
const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable() ;
if (theMeanFreePathTable) {
theMeanFreePathTable->clearAndDestroy();
delete theMeanFreePathTable;
}
theMeanFreePathTable = new
G4PhysicsTable( G4Material::GetNumberOfMaterials() ) ;
//create table
//
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
//create table
if (theMeanFreePathTable) {theMeanFreePathTable->clearAndDestroy();
delete theMeanFreePathTable;
}
theMeanFreePathTable = new G4PhysicsTable(numOfCouples);
PartialSumSigma.clearAndDestroy();
PartialSumSigma.resize(G4Material::GetNumberOfMaterials());
PartialSumSigma.resize(numOfCouples);
G4PhysicsLogVector* ptrVector;
for ( size_t J=0 ; J < G4Material::GetNumberOfMaterials(); J++ )
{
ptrVector = new G4PhysicsLogVector(
G4PhysicsLogVector* ptrVector;
for ( size_t J=0; J<numOfCouples; J++ )
{
ptrVector = new G4PhysicsLogVector(
LowerBoundLambda,UpperBoundLambda,NbinLambda);
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(J);
const G4Material* material= (*theMaterialTable)[J];
for ( G4int i = 0 ; i < NbinLambda ; i++ )
{
for ( G4int i = 0 ; i < NbinLambda ; i++ )
{
LowEdgeEnergy = ptrVector->GetLowEdgeEnergy( i ) ;
Value = ComputeMeanFreePath( &ParticleType, LowEdgeEnergy,
material );
Value = ComputeMeanFreePath( &ParticleType, LowEdgeEnergy, couple);
ptrVector->PutValue( i , Value ) ;
}
}
theMeanFreePathTable->insertAt( J , ptrVector );
theMeanFreePathTable->insertAt( J , ptrVector );
// Compute the PartialSumSigma table at a given fixed energy
ComputePartialSumSigma( &ParticleType, FixedEnergy, material) ;
}
ComputePartialSumSigma( &ParticleType, FixedEnergy, couple) ;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuPairProduction::ComputePartialSumSigma(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy,
const G4Material* aMaterial)
G4double KineticEnergy,
const G4MaterialCutsCouple* couple)
{
G4int Imate = aMaterial->GetIndex();
const G4Material* aMaterial = couple->GetMaterial();
size_t index = couple->GetIndex();
G4int NbOfElements = aMaterial->GetNumberOfElements();
const G4ElementVector* theElementVector = aMaterial->GetElementVector();
const G4ElementVector* theElementVector = aMaterial->GetElementVector();
const G4double* theAtomNumDensityVector = aMaterial->
GetAtomicNumDensityVector();
G4double ElectronEnergyCut = (G4Electron::Electron()->GetEnergyCuts())[Imate];
G4double PositronEnergyCut = (G4Positron::Positron()->GetEnergyCuts())[Imate];
G4double eCut = (*electronEnergyCuts)[index] ;
G4double pCut = (*positronEnergyCuts)[index] ;
PartialSumSigma[Imate] = new G4DataVector();
PartialSumSigma[index] = new G4DataVector();
G4double SIGMA = 0. ;
for ( G4int Ielem=0 ; Ielem < NbOfElements ; Ielem++ )
{
SIGMA += theAtomNumDensityVector[Ielem] *
{
SIGMA += theAtomNumDensityVector[Ielem] *
ComputeMicroscopicCrossSection( ParticleType, KineticEnergy,
(*theElementVector)[Ielem]->GetZ(),
ElectronEnergyCut,PositronEnergyCut );
(*theElementVector)[Ielem]->GetZ(),
eCut,pCut );
PartialSumSigma[Imate]->push_back(SIGMA);
PartialSumSigma[index]->push_back(SIGMA);
}
}
@@ -363,7 +370,7 @@ G4double G4MuPairProduction::ComputeMicroscopicCrossSection(
G4double AtomicNumber,
G4double ElectronEnergyCut,
G4double PositronEnergyCut)
{
static const G4double
xgi[] ={ 0.0199,0.1017,0.2372,0.4083,0.5917,0.7628,0.8983,0.9801 };
@@ -384,7 +391,7 @@ G4double G4MuPairProduction::ComputeMicroscopicCrossSection(
if( CutInPairEnergy < 4.*electron_mass_c2 )
CutInPairEnergy = 4.*electron_mass_c2 ;
G4double particleMass = ParticleType->GetPDGMass();
G4double MaxPairEnergy = KineticEnergy+particleMass*(1.-0.75*sqrte*z13) ;
if( CutInPairEnergy >= MaxPairEnergy ) return CrossSection ;
@@ -422,11 +429,11 @@ void G4MuPairProduction::MakeSamplingTables(
const G4ParticleDefinition* ParticleType)
{
G4int nbin;
G4double AtomicNumber,KineticEnergy ;
G4double AtomicNumber,KineticEnergy ;
G4double c,y,ymin,ymax,dy,yy,dx,x,ep ;
static const G4double sqrte = sqrt(exp(1.)) ;
G4double particleMass = ParticleType->GetPDGMass();
G4double particleMass = ParticleType->GetPDGMass();
for (G4int iz=0; iz<nzdat; iz++)
{
@@ -445,8 +452,8 @@ void G4MuPairProduction::MakeSamplingTables(
ymin = -5. ;
ymax = 0. ;
dy = (ymax-ymin)/NBIN ;
nbin=-1;
dy = (ymax-ymin)/NBIN ;
nbin=-1;
y = ymin - 0.5*dy ;
yy = ymin - dy ;
for (G4int i=0 ; i<NBIN; i++)
@@ -477,7 +484,7 @@ void G4MuPairProduction::MakeSamplingTables(
}
}
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -485,18 +492,18 @@ G4double G4MuPairProduction::ComputeDDMicroscopicCrossSection(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy, G4double AtomicNumber,
G4double PairEnergy,G4double asymmetry)
// Calculates the double differential (DD) microscopic cross section
// Calculates the double differential (DD) microscopic cross section
// using the cross section formula of R.P. Kokoulin (18/01/98)
{
static const G4double sqrte = sqrt(exp(1.)) ;
G4double bbbtf= 183. ;
G4double bbbh = 202.4 ;
G4double bbbh = 202.4 ;
G4double g1tf = 1.95e-5 ;
G4double g2tf = 5.3e-5 ;
G4double g1h = 4.4e-5 ;
G4double g2h = 4.8e-5 ;
G4double particleMass = ParticleType->GetPDGMass();
G4double massratio = particleMass/electron_mass_c2 ;
G4double massratio2 = massratio*massratio ;
@@ -508,7 +515,7 @@ G4double G4MuPairProduction::ComputeDDMicroscopicCrossSection(
G4double c3 = 3.*sqrte*particleMass/4. ;
G4double DDCrossSection = 0. ;
if(EnergyLoss <= c3*z13)
return DDCrossSection ;
@@ -552,8 +559,8 @@ G4double G4MuPairProduction::ComputeDDMicroscopicCrossSection(
G4double a1 = PairEnergy*PairEnergy/a0 ;
G4double bet = 0.5*a1 ;
G4double xi0 = 0.25*massratio2*a1 ;
G4double del = c8/a0 ;
G4double del = c8/a0 ;
G4double romin = 0. ;
G4double romax = (1.-del)*sqrt(1.-c7/PairEnergy) ;
@@ -569,7 +576,7 @@ G4double G4MuPairProduction::ComputeDDMicroscopicCrossSection(
G4double xii = 1./xi ;
G4double xi1 = 1.+xi ;
G4double screen = screen0*xi1/a5 ;
G4double yeu = 5.-a6+4.*bet*a7 ;
G4double yed = 2.*(1.+3.*bet)*log(3.+xii)-a6-a1*(2.-a6) ;
G4double yel = 1.+yeu/yed ;
@@ -604,16 +611,16 @@ G4double G4MuPairProduction::ComputeDDMicroscopicCrossSection(
DDCrossSection *= 4.*fine_structure_const*fine_structure_const
*classic_electr_radius*classic_electr_radius/(3.*pi) ;
DDCrossSection *= z2*EnergyLoss/(TotalEnergy*PairEnergy) ;
return DDCrossSection ;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuPairProduction::GetDMicroscopicCrossSection(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy, G4double AtomicNumber,
@@ -629,7 +636,7 @@ G4double G4MuPairProduction::ComputeDMicroscopicCrossSection(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy, G4double AtomicNumber,
G4double PairEnergy)
// Calculates the differential (D) microscopic cross section
// Calculates the differential (D) microscopic cross section
// using the cross section formula of R.P. Kokoulin (18/01/98)
{
@@ -657,7 +664,7 @@ G4double G4MuPairProduction::ComputeDMicroscopicCrossSection(
for (G4int i=0; i<7; i++)
{
ro = 1.-exp(tmn*xgi[i]) ;
DCrossSection += (1.-ro)*ComputeDDMicroscopicCrossSection(
ParticleType,KineticEnergy,
AtomicNumber,PairEnergy,ro)
@@ -671,26 +678,26 @@ G4double G4MuPairProduction::ComputeDMicroscopicCrossSection(
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange* G4MuPairProduction::PostStepDoIt(const G4Track& trackData,
const G4Step& stepData)
const G4Step& stepData)
{
static const G4double esq = sqrt(exp(1.));
aParticleChange.Initialize(trackData);
G4Material* aMaterial=trackData.GetMaterial() ;
const G4DynamicParticle* aDynamicParticle=trackData.GetDynamicParticle();
const G4MaterialCutsCouple* couple = trackData.GetMaterialCutsCouple();
size_t index = couple->GetIndex();
const G4DynamicParticle* aDynamicParticle=trackData.GetDynamicParticle();
G4double KineticEnergy = aDynamicParticle->GetKineticEnergy();
G4double particleMass = aDynamicParticle->GetDefinition()->GetPDGMass();
G4ParticleMomentum ParticleDirection =
G4double particleMass = aDynamicParticle->GetDefinition()->GetPDGMass();
G4ParticleMomentum ParticleDirection =
aDynamicParticle->GetMomentumDirection();
// e-e+ cut in this material
G4double ElectronEnergyCut = electron_mass_c2+
G4Electron::Electron()->GetEnergyThreshold(aMaterial);
G4double PositronEnergyCut = electron_mass_c2+
G4Positron::Positron()->GetEnergyThreshold(aMaterial);
G4double CutInPairEnergy = ElectronEnergyCut + PositronEnergyCut ;
G4double eCut = (*electronEnergyCuts)[index] ;
G4double pCut = (*positronEnergyCuts)[index] ;
G4double CutInPairEnergy = eCut + pCut + 2.0*electron_mass_c2;
if (CutInPairEnergy < MinPairEnergy) CutInPairEnergy = MinPairEnergy ;
@@ -698,8 +705,8 @@ G4VParticleChange* G4MuPairProduction::PostStepDoIt(const G4Track& trackData,
if(KineticEnergy < CutInPairEnergy )
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
// select randomly one element constituing the material
G4Element* anElement = SelectRandomAtom(aMaterial);
// select randomly one element constituing the material
const G4Element* anElement = SelectRandomAtom(couple);
// limits of the energy sampling
G4double TotalEnergy = KineticEnergy + particleMass ;
@@ -748,7 +755,7 @@ G4VParticleChange* G4MuPairProduction::PostStepDoIt(const G4Track& trackData,
{
xc = log(CutInPairEnergy/MinPairEnergy)/log(MaxPairEnergy/MinPairEnergy) ;
yc = log(xc) ;
iy = -1 ;
do {
iy += 1 ;
@@ -756,153 +763,124 @@ G4VParticleChange* G4MuPairProduction::PostStepDoIt(const G4Track& trackData,
}
G4double norm = proba[izz][itt][iy] ;
G4double r = norm + G4UniformRand()*(1.-norm);
G4double r = norm+G4UniformRand()*(1.-norm) ;
iy -= 1 ;
do {
iy += 1 ;
} while ((proba[izz][itt][iy] < r)&&(iy < NBINminus1)) ;
do { iy += 1; } while ((proba[izz][itt][iy] < r) && (iy < NBINminus1));
//sampling is uniformly in y in the bin
if( iy < NBIN )
y = ya[iy] + G4UniformRand() * ( ya[iy+1] - ya[iy]) ;
else
y = ya[iy] ;
if (iy < NBIN) y = ya[iy] + G4UniformRand()*(ya[iy+1] - ya[iy]);
else y = ya[iy];
x = exp(y) ;
x = exp(y);
PairEnergy = MinPairEnergy*exp(x*log(MaxPairEnergy/MinPairEnergy)) ;
PairEnergy = MinPairEnergy*exp(x*log(MaxPairEnergy/MinPairEnergy));
// sample r=(E+-E-)/PairEnergy ( uniformly .....)
G4double rmax = (1.-6.*particleMass*particleMass/(TotalEnergy*
(TotalEnergy-PairEnergy)))
*sqrt(1.-MinPairEnergy/PairEnergy) ;
r = rmax * (-1.+2.*G4UniformRand()) ;
// sample r=(E+-E-)/PairEnergy ( uniformly .....)
G4double rmax =
(1.-6.*particleMass*particleMass/(TotalEnergy*(TotalEnergy-PairEnergy)))
*sqrt(1.-MinPairEnergy/PairEnergy);
r = rmax * (-1.+2.*G4UniformRand());
// compute energies from PairEnergy,r
G4double ElectronEnergy = (1-r)*PairEnergy/2.;
G4double PositronEnergy = (1+r)*PairEnergy/2.;
// compute energies from PairEnergy,r
G4double ElectronEnergy=(1.-r)*PairEnergy/2. ;
G4double PositronEnergy=(1.+r)*PairEnergy/2. ;
// angles of the emitted particles ( Z - axis along the parent particle)
// (mean theta for the moment)
G4double Teta = electron_mass_c2/TotalEnergy ;
G4double Teta = electron_mass_c2/TotalEnergy;
G4double Phi = twopi * G4UniformRand() ;
G4double Phi = twopi * G4UniformRand();
G4double dirx = sin(Teta)*cos(Phi) , diry = sin(Teta)*sin(Phi) ,
dirz = cos(Teta) ;
dirz = cos(Teta);
G4double LocalEnerDeposit = 0. ;
G4int numberofsecondaries = 1 ;
G4int flagelectron = 0 ;
G4int flagpositron = 1 ;
G4double LocalEnerDeposit = 0.;
G4int numberofsecondaries = 1;
G4int flagelectron = 0;
G4int flagpositron = 1;
G4DynamicParticle* aParticle1 = 0;
G4DynamicParticle* aParticle2 = 0;
G4double ElectronMomentum , PositronMomentum ;
//G4double finalPx,finalPy,finalPz ;
// e-
//
G4double ElectKineEnergy = ElectronEnergy - electron_mass_c2 ;
if((ElectKineEnergy > ElectronEnergyCut) ||
(G4EnergyLossTables::GetRange(
G4Electron::Electron(),ElectKineEnergy,aMaterial) >=
stepData.GetPostStepPoint()->GetSafety()))
{
numberofsecondaries += 1 ;
flagelectron = 1 ;
ElectronMomentum = sqrt(ElectKineEnergy*
(ElectronEnergy+electron_mass_c2));
G4ThreeVector ElectDirection ( dirx, diry, dirz );
ElectDirection.rotateUz(ParticleDirection);
// create G4DynamicParticle object for the particle1
aParticle1= new G4DynamicParticle (G4Electron::Electron(),
ElectDirection, ElectKineEnergy);
}
else
{ LocalEnerDeposit += ElectKineEnergy ; }
if (ElectKineEnergy > eCut)
{
numberofsecondaries += 1;
flagelectron = 1;
G4ThreeVector ElectDirection ( dirx, diry, dirz );
ElectDirection.rotateUz(ParticleDirection);
// create G4DynamicParticle object for the particle1
aParticle1 = new G4DynamicParticle (G4Electron::Electron(),
ElectDirection, ElectKineEnergy);
}
else { LocalEnerDeposit += ElectKineEnergy;}
// the e+ is always created (even with Ekine=0) for further annihilation.
G4double PositKineEnergy = PositronEnergy - electron_mass_c2 ;
PositronMomentum = sqrt(PositKineEnergy*(PositronEnergy+electron_mass_c2));
if((PositKineEnergy < PositronEnergyCut) &&
(G4EnergyLossTables::GetRange(
G4Positron::Positron(),PositKineEnergy,aMaterial) <=
stepData.GetPostStepPoint()->GetSafety()))
{
LocalEnerDeposit += PositKineEnergy ;
PositKineEnergy = 0. ;
}
//
G4double PositKineEnergy = PositronEnergy - electron_mass_c2;
if (PositKineEnergy < pCut)
{
LocalEnerDeposit += PositKineEnergy;
PositKineEnergy = 0.;
}
G4ThreeVector PositDirection ( -dirx, -diry, dirz );
PositDirection.rotateUz(ParticleDirection);
// create G4DynamicParticle object for the particle2
PositDirection.rotateUz(ParticleDirection);
// create G4DynamicParticle object for the particle2
aParticle2= new G4DynamicParticle (G4Positron::Positron(),
PositDirection, PositKineEnergy);
PositDirection, PositKineEnergy);
// fill particle change and update initial particle
aParticleChange.SetNumberOfSecondaries(numberofsecondaries) ;
if(flagelectron==1)
aParticleChange.AddSecondary( aParticle1 ) ;
if(flagpositron==1)
aParticleChange.AddSecondary( aParticle2 ) ;
aParticleChange.SetNumberOfSecondaries(numberofsecondaries) ;
if (flagelectron==1) aParticleChange.AddSecondary(aParticle1);
if (flagpositron==1) aParticleChange.AddSecondary(aParticle2);
G4double NewKinEnergy = KineticEnergy - ElectronEnergy - PositronEnergy ;
//G4double finalMomentum=sqrt(NewKinEnergy*(NewKinEnergy+2.*particleMass));
G4double NewKinEnergy = KineticEnergy - ElectronEnergy - PositronEnergy;
aParticleChange.SetMomentumChange( ParticleDirection );
aParticleChange.SetMomentumChange(ParticleDirection);
G4double KinEnergyCut = (aDynamicParticle->GetDefinition()->
GetEnergyCuts())[aMaterial->GetIndex()];
if (NewKinEnergy > 0.) aParticleChange.SetEnergyChange(NewKinEnergy);
else { aParticleChange.SetEnergyChange(0.);
aParticleChange.SetStatusChange(fStopButAlive);
}
if (NewKinEnergy > KinEnergyCut)
{
aParticleChange.SetEnergyChange( NewKinEnergy );
}
else
{
aParticleChange.SetEnergyChange(0.);
LocalEnerDeposit += NewKinEnergy ;
aParticleChange.SetStatusChange(fStopButAlive);
}
aParticleChange.SetLocalEnergyDeposit( LocalEnerDeposit ) ;
aParticleChange.SetLocalEnergyDeposit(LocalEnerDeposit);
//reset NumberOfinteractionLengthLeft()
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Element* G4MuPairProduction::SelectRandomAtom(G4Material* aMaterial) const
G4Element* G4MuPairProduction::SelectRandomAtom(const G4MaterialCutsCouple* couple) const
{
// select randomly 1 element within the material
size_t index = couple->GetIndex();
const G4Material* aMaterial = couple->GetMaterial();
const G4int Index = aMaterial->GetIndex();
const G4int NumberOfElements = aMaterial->GetNumberOfElements();
const G4ElementVector* theElementVector = aMaterial->GetElementVector();
G4double rval = G4UniformRand()*((*PartialSumSigma[Index])
G4double rval = G4UniformRand()*((*PartialSumSigma[index])
[NumberOfElements-1]);
for ( G4int i=0; i < NumberOfElements; i++ )
{
if (rval <= (*PartialSumSigma[Index])[i]) return ((*theElementVector)[i]);
if (rval <= (*PartialSumSigma[index])[i]) return ((*theElementVector)[i]);
}
G4cout << " WARNING !!! - The Material '"<< aMaterial->GetName()
<< "' has no elements, NULL pointer returned." << G4endl;
return NULL;
return 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool G4MuPairProduction::StorePhysicsTable(G4ParticleDefinition* particle,
const G4String& directory,
const G4String& directory,
G4bool ascii)
{
G4String filename;
// store stopping power table
filename = GetPhysicsTableFileName(particle,directory,"StoppingPower",ascii);
if ( !theLossTable->StorePhysicsTable(filename, ascii) ){
@@ -917,75 +895,81 @@ G4bool G4MuPairProduction::StorePhysicsTable(G4ParticleDefinition* particle,
<< G4endl;
return false;
}
// store PartialSumSigma table (G4OrderedTable)
filename = GetPhysicsTableFileName(particle,directory,"PartSumSigma",ascii);
if ( !PartialSumSigma.Store(filename, ascii) ){
G4cout << " FAIL PartialSumSigma.store in " << filename
<< G4endl;
return false;
}
}
G4cout << GetProcessName() << "for " << particle->GetParticleName()
<< ": Success to store the PhysicsTables in "
<< ": Success to store the PhysicsTables in "
<< directory << G4endl;
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool G4MuPairProduction::RetrievePhysicsTable(G4ParticleDefinition* particle,
const G4String& directory,
const G4String& directory,
G4bool ascii)
{
// delete theLossTable and theMeanFreePathTable
if (theLossTable != 0) {
theLossTable->clearAndDestroy();
delete theLossTable;
}
delete theLossTable;
}
if (theMeanFreePathTable != 0) {
theMeanFreePathTable->clearAndDestroy();
delete theMeanFreePathTable;
}
if (&PartialSumSigma != 0) PartialSumSigma.clear();
// get bining from EnergyLoss
LowestKineticEnergy = GetLowerBoundEloss();
HighestKineticEnergy = GetUpperBoundEloss();
TotBin = GetNbinEloss();
G4String filename;
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
electronEnergyCuts = theCoupleTable->GetEnergyCutsVector(1);
positronEnergyCuts = theCoupleTable->GetEnergyCutsVector(2);
// retreive stopping power table
filename = GetPhysicsTableFileName(particle,directory,"StoppingPower",ascii);
theLossTable = new G4PhysicsTable(G4Material::GetNumberOfMaterials());
theLossTable = new G4PhysicsTable(numOfCouples);
if ( !theLossTable->RetrievePhysicsTable(filename, ascii) ){
G4cout << " FAIL theLossTable0->RetrievePhysicsTable in " << filename
<< G4endl;
<< G4endl;
return false;
}
// 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;
}
// retrieve PartialSumSigma table (G4OrderedTable)
PartialSumSigma.clearAndDestroy();
PartialSumSigma.reserve(numOfCouples);
filename = GetPhysicsTableFileName(particle,directory,"PartSumSigma",ascii);
if ( !PartialSumSigma.Retrieve(filename, ascii) ){
G4cout << " FAIL PartialSumSigma.retrieve in " << filename
<< G4endl;
return false;
}
G4cout << GetProcessName() << "for " << particle->GetParticleName()
<< ": Success to retrieve the PhysicsTables from "
<< directory << G4endl;
if (particle->GetPDGCharge() < 0.)
{
RecorderOfmuminusProcess[CounterOfmuminusProcess] = (*this).theLossTable;
@@ -996,14 +980,14 @@ G4bool G4MuPairProduction::RetrievePhysicsTable(G4ParticleDefinition* particle,
RecorderOfmuplusProcess[CounterOfmuplusProcess] = (*this).theLossTable;
CounterOfmuplusProcess++;
}
MakeSamplingTables(particle);
G4VMuEnergyLoss::BuildDEDXTable(*particle);
if(particle==G4MuonPlus::MuonPlus()) PrintInfoDefinition();
return true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuPairProduction::PrintInfoDefinition()
@@ -29,14 +29,21 @@
// File name: G4MuPairProductionModel
//
// Author: Vladimir Ivanchenko on base of Laszlo Urban code
//
//
// Creation date: 24.06.2002
//
// Modifications: 04.12.2002 Change G4DynamicParticle constructor in PostStep (VI)
// Modifications:
//
// 04-12-02 Change G4DynamicParticle constructor in PostStep (V.Ivanchenko)
// 23-12-02 Change interface in order to move to cut per region (V.Ivanchenko)
// 24-01-03 Fix for compounds (V.Ivanchenko)
// 27-01-03 Make models region aware (V.Ivanchenko)
// 13-02-03 Add model (V.Ivanchenko)
//
// Class Description:
//
// Class Description:
//
//
// -------------------------------------------------------------------
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -51,10 +58,11 @@
#include "G4Material.hh"
#include "G4Element.hh"
#include "G4ElementVector.hh"
#include "G4ProductionCutsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// static members
// static members
//
G4double G4MuPairProductionModel::zdat[]={1.,4.,13.,29.,92.};
G4double G4MuPairProductionModel::adat[]={1.01,9.01,26.98,63.55,238.03};
@@ -62,24 +70,21 @@ G4double G4MuPairProductionModel::tdat[]={1.e3,1.e4,1.e5,1.e6,1.e7,1.e8,1.e9,1.e
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4MuPairProductionModel::G4MuPairProductionModel(const G4ParticleDefinition* p)
: G4VEmModel(),
G4MuPairProductionModel::G4MuPairProductionModel(const G4ParticleDefinition* p,
const G4String& nam)
: G4VEmModel(nam),
minPairEnergy(4.*electron_mass_c2),
highKinEnergy(1000000.*TeV),
lowKinEnergy(minPairEnergy),
minThreshold(minPairEnergy),
nzdat(5),
ntdat(8),
NBIN(1000),
oldMaterial(0),
samplingTablesAreFilled(false)
{
partialSumSigma.clear();
}
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4MuPairProductionModel::~G4MuPairProductionModel()
G4MuPairProductionModel::~G4MuPairProductionModel()
{
size_t n = partialSumSigma.size();
if(n > 0) {
@@ -91,58 +96,87 @@ G4MuPairProductionModel::~G4MuPairProductionModel()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuPairProductionModel::HighEnergyLimit(const G4ParticleDefinition* p,
const G4Material*)
G4double G4MuPairProductionModel::HighEnergyLimit(const G4ParticleDefinition*)
{
return highKinEnergy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuPairProductionModel::LowEnergyLimit(const G4ParticleDefinition* p,
const G4Material*)
G4double G4MuPairProductionModel::LowEnergyLimit(const G4ParticleDefinition*)
{
return lowKinEnergy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuPairProductionModel::MinEnergyCut(const G4ParticleDefinition* p,
const G4Material* material)
G4double G4MuPairProductionModel::MinEnergyCut(const G4ParticleDefinition*,
const G4MaterialCutsCouple* couple)
{
G4double eCut = (G4Electron::Electron())->GetEnergyThreshold(material);
G4double pCut = (G4Positron::Positron())->GetEnergyThreshold(material);
G4double x = minPairEnergy;
size_t index = couple->GetIndex();
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
G4double eCut = (*(theCoupleTable->GetEnergyCutsVector(1)))[index];
G4double pCut = (*(theCoupleTable->GetEnergyCutsVector(2)))[index];
G4double x = 2.0*electron_mass_c2 + eCut + pCut;
if(x < minPairEnergy) x = minPairEnergy;
/*
if(eCut < highKinEnergy && pCut < highKinEnergy) {
x += eCut + pCut;
} else {
x = 0.5*highKinEnergy;
}
*/
return x;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4bool G4MuPairProductionModel::IsInCharge(const G4ParticleDefinition* p,
const G4Material*)
G4bool G4MuPairProductionModel::IsInCharge(const G4ParticleDefinition* p)
{
return (p == G4MuonMinus::MuonMinus() || p == G4MuonPlus::MuonPlus());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4MuPairProductionModel::Initialise(const G4ParticleDefinition*,
const G4DataVector& cuts)
{
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
G4double fixedEnergy = sqrt(lowKinEnergy*highKinEnergy);
for (size_t ii=0; ii<partialSumSigma.size(); ii++){
G4DataVector* a=partialSumSigma[ii];
if ( a ) delete a;
}
partialSumSigma.clear();
for (size_t i=0; i<numOfCouples; i++) {
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i);
const G4Material* material = couple->GetMaterial();
G4DataVector* dv = ComputePartialSumSigma(material, fixedEnergy,
G4std::min(cuts[i], 0.25*highKinEnergy));
partialSumSigma.push_back(dv);
}
if(!samplingTablesAreFilled) MakeSamplingTables();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuPairProductionModel::ComputeDEDX(const G4Material* material,
const G4ParticleDefinition* p,
G4double kineticEnergy,
G4double cutEnergy)
G4double cutEnergy)
{
G4double dedx = 0.0;
if(!samplingTablesAreFilled) {
minThreshold = MinEnergyCut(p, material);
MakeSamplingTables();
}
if(kineticEnergy < minPairEnergy) return dedx;
if(minPairEnergy >= cutEnergy) return dedx;
G4double cut = cutEnergy;
if(kineticEnergy <= cutEnergy) cut = kineticEnergy;
const G4ElementVector* theElementVector = material->GetElementVector();
const G4double* theAtomicNumDensityVector = material->GetAtomicNumDensityVector();
@@ -151,7 +185,7 @@ G4double G4MuPairProductionModel::ComputeDEDX(const G4Material* material,
G4double Z = (*theElementVector)[i]->GetZ();
G4double loss = ComputMuPairLoss(Z, kineticEnergy, cutEnergy);
G4double loss = ComputMuPairLoss(Z, kineticEnergy, cut);
dedx += loss*theAtomicNumDensityVector[i];
}
@@ -161,12 +195,12 @@ G4double G4MuPairProductionModel::ComputeDEDX(const G4Material* material,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4double G4MuPairProductionModel::ComputMuPairLoss(G4double Z,
G4double G4MuPairProductionModel::ComputMuPairLoss(G4double Z,
G4double tkin, G4double cutEnergy)
{
static const
static const
G4double xgi[] ={ 0.0199,0.1017,0.2372,0.4083,0.5917,0.7628,0.8983,0.9801};
static const
static const
G4double wgi[] ={ 0.0506,0.1112,0.1569,0.1813,0.1813,0.1569,0.1112,0.0506};
static const G4double ak1=6.9;
static const G4double ak2=1.0;
@@ -176,20 +210,16 @@ G4double G4MuPairProductionModel::ComputMuPairLoss(G4double Z,
G4double loss = 0.0 ;
if (Z < 1. || cutEnergy < minPairEnergy) return loss;
G4double particleMass = (G4MuonPlus::MuonPlus())->GetPDGMass();
G4double tmax = tkin + particleMass*(1.-0.75*sqrte*z13);
// G4cout << "###DEDX tkin= " << tkin << " tmax= " << tmax << " tmin= " << minPairEnergy << G4endl;
if(tmax < minPairEnergy) tmax = minPairEnergy;
G4double cut = cutEnergy;
if(cut >= tmax) cut = tmax;
if(tmax <= cutEnergy) cut = tmax;
if(cut <= minPairEnergy) return loss;
// calculate the rectricted loss
// calculate the rectricted loss
// numerical integration in log(PairEnergy)
G4double bbb = log(cut) ;
G4int kkk = (G4int)((bbb-aaa)/ak1+ak2);
@@ -201,7 +231,7 @@ G4double G4MuPairProductionModel::ComputMuPairLoss(G4double Z,
for (G4int l=0 ; l<kkk; l++)
{
for (G4int ll=0; ll<8; ll++)
{
G4double ep = exp(x+xgi[ll]*hhh);
@@ -221,25 +251,23 @@ G4double G4MuPairProductionModel::ComputMuPairLoss(G4double Z,
G4double G4MuPairProductionModel::ComputeMicroscopicCrossSection(
G4double tkin,
G4double Z,
G4double A,
G4double A,
G4double cut)
{
{
static const G4double ak1=6.9 ;
static const G4double ak2=1.0 ;
static const G4double sqrte = sqrt(exp(1.)) ;
static const G4double
static const G4double
xgi[]={ 0.0199,0.1017,0.2372,0.4083,0.5917,0.7628,0.8983,0.9801 };
static const G4double
static const G4double
wgi[]={ 0.0506,0.1112,0.1569,0.1813,0.1813,0.1569,0.1112,0.0506 };
G4double z13 = pow(Z,0.333333333);
G4double cross = 0. ;
if(Z < 1.) return cross;
G4double particleMass = (G4MuonPlus::MuonPlus())->GetPDGMass();
G4double tmax = tkin + particleMass*(1.-0.75*sqrte*z13);
if(tmax < minPairEnergy) tmax = minPairEnergy;
if(tmax <= cut) return cross;
@@ -258,13 +286,13 @@ G4double G4MuPairProductionModel::ComputeMicroscopicCrossSection(
for(G4int i=0; i<8; i++)
{
G4double ep = exp(x + xgi[i]*hhh);
cross += ep*wgi[i]*ComputeDMicroscopicCrossSection(tkin, Z, ep);
}
aaa += hhh;
}
cross *=hhh;
cross *=hhh;
if(cross < 0.0) cross = 0.0;
return cross;
@@ -274,9 +302,9 @@ G4double G4MuPairProductionModel::ComputeMicroscopicCrossSection(
G4double G4MuPairProductionModel::ComputeDMicroscopicCrossSection(
G4double tkin,
G4double Z,
G4double Z,
G4double pairEnergy)
// Calculates the differential (D) microscopic cross section
// Calculates the differential (D) microscopic cross section
// using the cross section formula of R.P. Kokoulin (18/01/98)
{
@@ -310,7 +338,7 @@ G4double G4MuPairProductionModel::ComputeDMicroscopicCrossSection(
for (G4int i=0; i<7; i++)
{
G4double ro = 1.-exp(tmn*xgi[i]) ;
cross += wgi[i]*(1.-ro)*ComputeDDMicroscopicCrossSection(tkin,Z,pairEnergy,ro);
// cout << "ro= " << ro << " cross= " << cross << endl;
}
@@ -324,34 +352,34 @@ G4double G4MuPairProductionModel::ComputeDMicroscopicCrossSection(
G4double G4MuPairProductionModel::ComputeDDMicroscopicCrossSection(
G4double tkin,
G4double Z,
G4double Z,
G4double pairEnergy,
G4double asymmetry)
// Calculates the differential (D) microscopic cross section
// Calculates the differential (D) microscopic cross section
// using the cross section formula of R.P. Kokoulin (18/01/98)
{
static const G4double sqrte = sqrt(exp(1.)) ;
G4double bbbtf= 183. ;
G4double bbbh = 202.4 ;
G4double bbbh = 202.4 ;
G4double g1tf = 1.95e-5 ;
G4double g2tf = 5.3e-5 ;
G4double g1h = 4.4e-5 ;
G4double g2h = 4.8e-5 ;
G4double particleMass = (G4MuonPlus::MuonPlus())->GetPDGMass();
G4double totalEnergy = tkin + particleMass;
G4double energyLoss = totalEnergy - pairEnergy;
G4double massratio = particleMass/electron_mass_c2 ;
G4double massratio2 = massratio*massratio ;
G4double z13 = pow(Z,0.333333333);
G4double z23 = z13*z13 ;
G4double c3 = 3.*sqrte*particleMass/4. ;
G4double DDCrossSection = 0. ;
if(energyLoss <= c3*z13) return DDCrossSection ;
G4double c7 = 4.*electron_mass_c2 ;
@@ -393,8 +421,8 @@ G4double G4MuPairProductionModel::ComputeDDMicroscopicCrossSection(
G4double a1 = pairEnergy*pairEnergy/a0 ;
G4double bet = 0.5*a1 ;
G4double xi0 = 0.25*massratio2*a1 ;
G4double del = c8/a0 ;
G4double del = c8/a0 ;
G4double romin = 0. ;
G4double romax = (1.-del)*sqrt(1.-c7/pairEnergy) ;
@@ -409,7 +437,7 @@ G4double G4MuPairProductionModel::ComputeDDMicroscopicCrossSection(
G4double xii = 1./xi ;
G4double xi1 = 1.+xi ;
G4double screen = screen0*xi1/a5 ;
G4double yeu = 5.-a6+4.*bet*a7 ;
G4double yed = 2.*(1.+3.*bet)*log(3.+xii)-a6-a1*(2.-a6) ;
G4double yel = 1.+yeu/yed ;
@@ -444,10 +472,10 @@ G4double G4MuPairProductionModel::ComputeDDMicroscopicCrossSection(
DDCrossSection *= 4.*fine_structure_const*fine_structure_const
*classic_electr_radius*classic_electr_radius/(3.*pi) ;
DDCrossSection *= z2*energyLoss/(totalEnergy*pairEnergy) ;
return DDCrossSection ;
}
@@ -458,74 +486,52 @@ G4double G4MuPairProductionModel::CrossSection(const G4Material* material,
const G4ParticleDefinition* p,
G4double kineticEnergy,
G4double cutEnergy,
G4double maxEnergy)
G4double maxEnergy)
{
G4double cross = 0.0;
if(!samplingTablesAreFilled) {
minThreshold = MinEnergyCut(p, material);
MakeSamplingTables();
}
G4double tmax = G4std::min(maxEnergy, kineticEnergy);
G4double cut = G4std::max(cutEnergy, minThreshold);
if(cut >= tmax) return cross;
if(cutEnergy >= tmax) return cross;
const G4ElementVector* theElementVector = material->GetElementVector() ;
const G4double* theAtomNumDensityVector = material->GetAtomicNumDensityVector();
if(material != oldMaterial) {
oldMaterial = material;
G4double fixedEnergy = sqrt(lowKinEnergy*highKinEnergy);
ComputePartialSumSigma(material, fixedEnergy, cutEnergy);
}
for (size_t i=0; i<material->GetNumberOfElements(); i++) {
G4double Z = (*theElementVector)[i]->GetZ();
G4double A = (*theElementVector)[i]->GetA()/(g/mole) ;
G4double cr = ComputeMicroscopicCrossSection(kineticEnergy, Z, A, cutEnergy);
if(maxEnergy < kineticEnergy) {
cr -= ComputeMicroscopicCrossSection(kineticEnergy, Z, A, maxEnergy);
}
cross += theAtomNumDensityVector[i] * cr;
}
cross += theAtomNumDensityVector[i] * cr;
}
return cross;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4MuPairProductionModel::ComputePartialSumSigma(const G4Material* material,
G4double kineticEnergy,
G4double cut)
G4DataVector* G4MuPairProductionModel::ComputePartialSumSigma(
const G4Material* material,
G4double kineticEnergy,
G4double cut)
// Build the table of cross section per element. The table is built for MATERIALS.
// This table is used by DoIt to select randomly an element in the material.
// This table is used by DoIt to select randomly an element in the material.
{
size_t index = material->GetIndex();
G4int nElements = material->GetNumberOfElements();
const G4ElementVector* theElementVector = material->GetElementVector();
const G4ElementVector* theElementVector = material->GetElementVector();
const G4double* theAtomNumDensityVector = material->GetAtomicNumDensityVector();
G4DataVector* dv;
if (index >= partialSumSigma.size()) {
dv = new G4DataVector();
partialSumSigma.push_back(dv);
} else {
dv = partialSumSigma[index];
dv->clear();
if(0 == index) samplingTablesAreFilled = false;
}
G4DataVector* dv = new G4DataVector();
G4double cross = 0.0;
for (G4int i=0; i<nElements; i++ ) {
G4double Z = (*theElementVector)[i]->GetZ();
G4double A = (*theElementVector)[i]->GetA()/(g/mole) ;
@@ -533,6 +539,7 @@ void G4MuPairProductionModel::ComputePartialSumSigma(const G4Material* material,
Z, A, cut);
dv->push_back(cross);
}
return dv;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -556,28 +563,28 @@ void G4MuPairProductionModel::MakeSamplingTables()
G4double ymin = -5. ;
G4double ymax = 0. ;
G4double dy = (ymax-ymin)/NBIN ;
G4double dy = (ymax-ymin)/NBIN ;
G4double y = ymin - 0.5*dy ;
G4double yy = ymin - dy ;
G4double x = exp(y);
G4double fac = exp(dy);
G4double dx = exp(yy)*(fac - 1.0);
if(maxPairEnergy > minThreshold) {
G4double c = log(maxPairEnergy/minThreshold) ;
if(maxPairEnergy > minPairEnergy) {
G4double c = log(maxPairEnergy/minPairEnergy) ;
for (G4int i=0 ; i<NBIN; i++)
{
y += dy ;
x *= fac;
dx*= fac;
G4double ep = minThreshold*exp(c*x) ;
G4double ep = minPairEnergy*exp(c*x) ;
CrossSection += ep*dx*ComputeDMicroscopicCrossSection(
kineticEnergy, atomicNumber, ep);
ya[i]=y ;
proba[iz][it][i] = CrossSection ;
}
} else {
@@ -588,9 +595,9 @@ void G4MuPairProductionModel::MakeSamplingTables()
proba[iz][it][i] = 0.0 ;
}
}
ya[NBIN]=0. ;
proba[iz][it][NBIN] = CrossSection ;
if(CrossSection > 0.)
@@ -608,27 +615,38 @@ void G4MuPairProductionModel::MakeSamplingTables()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4std::vector<G4DynamicParticle*>* G4MuPairProductionModel::SampleSecondary(
const G4Material* aMaterial,
G4DynamicParticle* G4MuPairProductionModel::SampleSecondary(
const G4MaterialCutsCouple*,
const G4DynamicParticle*,
G4double,
G4double)
{
return 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4std::vector<G4DynamicParticle*>* G4MuPairProductionModel::SampleSecondaries(
const G4MaterialCutsCouple* couple,
const G4DynamicParticle* aDynamicParticle,
G4double minEnergy,
G4double maxEnergy)
G4double maxEnergy)
{
static const G4double esq = sqrt(exp(1.));
G4double kineticEnergy = aDynamicParticle->GetKineticEnergy();
G4double particleMass = aDynamicParticle->GetDefinition()->GetPDGMass();
G4ParticleMomentum ParticleDirection =
G4double particleMass = aDynamicParticle->GetDefinition()->GetPDGMass();
G4ParticleMomentum ParticleDirection =
aDynamicParticle->GetMomentumDirection();
// select randomly one element constituing the material
const G4Element* anElement = SelectRandomAtom(aMaterial);
// select randomly one element constituing the material
const G4Element* anElement = SelectRandomAtom(couple);
// limits of the energy sampling
G4double totalEnergy = kineticEnergy + particleMass ;
//G4double TotalMomentum = sqrt(KineticEnergy*(TotalEnergy+particleMass)) ;
G4double Z3 = anElement->GetIonisation()->GetZ3() ;
G4double maxPairEnergy = totalEnergy-0.75*esq*particleMass*Z3 ;
if(maxPairEnergy > maxEnergy) maxPairEnergy = maxEnergy;
if(maxPairEnergy > maxEnergy) maxPairEnergy = maxEnergy;
// check against insufficient energy
if(minEnergy >= maxPairEnergy) return 0;
@@ -671,7 +689,7 @@ G4std::vector<G4DynamicParticle*>* G4MuPairProductionModel::SampleSecondary(
{
G4double xc = log(minEnergy/minPairEnergy)/log(maxPairEnergy/minPairEnergy) ;
yc = log(xc) ;
iy = -1 ;
do {
iy += 1 ;
@@ -681,7 +699,7 @@ G4std::vector<G4DynamicParticle*>* G4MuPairProductionModel::SampleSecondary(
G4double norm = proba[izz][itt][iy] ;
G4double r = norm+G4UniformRand()*(1.-norm) ;
iy -= 1 ;
do {
iy += 1 ;
@@ -704,9 +722,9 @@ G4std::vector<G4DynamicParticle*>* G4MuPairProductionModel::SampleSecondary(
r = rmax * (-1.+2.*G4UniformRand()) ;
// compute energies from PairEnergy,r
G4double ElectronEnergy=(1.-r)*PairEnergy/2. ;
G4double ElectronEnergy=(1.-r)*PairEnergy/2. ;
G4double PositronEnergy=(1.+r)*PairEnergy/2. ;
// angles of the emitted particles ( Z - axis along the parent particle)
// (mean theta for the moment)
G4double Teta = electron_mass_c2/totalEnergy ;
@@ -721,12 +739,12 @@ G4std::vector<G4DynamicParticle*>* G4MuPairProductionModel::SampleSecondary(
ElectronMomentum = sqrt(ElectKineEnergy*(ElectronEnergy+electron_mass_c2));
G4ThreeVector ElectDirection ( dirx, diry, dirz );
ElectDirection.rotateUz(ParticleDirection);
// create G4DynamicParticle object for the particle1
ElectDirection.rotateUz(ParticleDirection);
// create G4DynamicParticle object for the particle1
G4DynamicParticle* aParticle1= new G4DynamicParticle();
aParticle1->SetDefinition(G4Electron::Electron());
aParticle1->SetMomentumDirection(ElectDirection);
aParticle1->SetMomentumDirection(ElectDirection);
aParticle1->SetKineticEnergy(ElectKineEnergy);
@@ -734,12 +752,12 @@ G4std::vector<G4DynamicParticle*>* G4MuPairProductionModel::SampleSecondary(
PositronMomentum = sqrt(PositKineEnergy*(PositronEnergy+electron_mass_c2));
G4ThreeVector PositDirection ( -dirx, -diry, dirz );
PositDirection.rotateUz(ParticleDirection);
// create G4DynamicParticle object for the particle2
PositDirection.rotateUz(ParticleDirection);
// create G4DynamicParticle object for the particle2
G4DynamicParticle* aParticle2= new G4DynamicParticle();
aParticle2->SetDefinition(G4Positron::Positron());
aParticle2->SetMomentumDirection(PositDirection);
aParticle2->SetMomentumDirection(PositDirection);
aParticle2->SetKineticEnergy(PositKineEnergy);
@@ -753,16 +771,17 @@ G4std::vector<G4DynamicParticle*>* G4MuPairProductionModel::SampleSecondary(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
const G4Element* G4MuPairProductionModel::SelectRandomAtom(
const G4Material* material) const
const G4MaterialCutsCouple* couple) const
{
// select randomly 1 element within the material
const G4Material* material = couple->GetMaterial();
G4int nElements = material->GetNumberOfElements();
const G4ElementVector* theElementVector = material->GetElementVector();
if(1 == nElements) return (*theElementVector)[0];
else if(1 > nElements) return 0;
else if(1 > nElements) return 0;
G4DataVector* dv = partialSumSigma[material->GetIndex()];
G4DataVector* dv = partialSumSigma[couple->GetIndex()];
G4double rval = G4UniformRand()*((*dv)[nElements-1]);
for (G4int i=0; i<nElements; i++) {
if (rval <= (*dv)[i]) return (*theElementVector)[i];
@@ -36,10 +36,10 @@
//
// 04-06-98 in DoIt,secondary production condition:
// range>G4std::min(threshold,safety)
// 26/10/98 new stuff from R. Kokoulin + cleanup , L.Urban
// 06/05/99 bug fixed , L.Urban
// 10/02/00 modifications+bug fix , new e.m. structure, L.Urban
// 29/05/01 V.Ivanchenko minor changes to provide ANSI -wall compilation
// 26-10-98 new stuff from R. Kokoulin + cleanup , L.Urban
// 06-05-99 bug fixed , L.Urban
// 10-02-00 modifications+bug fix , new e.m. structure, L.Urban
// 29-05-01 V.Ivanchenko minor changes to provide ANSI -wall compilation
// 10-08-01 new methods Store/Retrieve PhysicsTable (mma)
// 17-09-01 migration of Materials to pure STL (mma)
// 20-09-01 (L.Urban) in ComputeMicroscopicCrossSection, remove:
@@ -49,6 +49,9 @@
// 29-10-01 all static functions no more inlined (mma)
// 07-11-01 particleMass becomes a local variable (mma)
// 19-08-02 V.Ivanchenko update to new design
// 23-12-02 Change interface in order to move to cut per region (V.Ivanchenko)
// 26-12-02 Secondary production moved to derived classes (V.Ivanchenko)
// 13-02-03 SubCutoff regime is assigned to a region (V.Ivanchenko)
//
// -------------------------------------------------------------------
//
@@ -67,22 +70,22 @@
G4MuPairProductionSTD::G4MuPairProductionSTD(const G4String& name)
: G4VEnergyLossSTD(name),
theParticle(0),
theBaseParticle(0)
theBaseParticle(0),
subCutoff(false)
{
InitialiseProcess();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4MuPairProductionSTD::~G4MuPairProductionSTD()
G4MuPairProductionSTD::~G4MuPairProductionSTD()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4MuPairProductionSTD::InitialiseProcess()
void G4MuPairProductionSTD::InitialiseProcess()
{
SetSecondaryParticle(G4Electron::Electron());
SetSubCutoffIsDesired(true);
SetDEDXBinning(120);
SetLambdaBinning(120);
@@ -90,11 +93,9 @@ void G4MuPairProductionSTD::InitialiseProcess()
SetMaxKinEnergy(100.0*TeV);
G4VEmModel* em = new G4MuPairProductionModel();
em->SetLowEnergyLimit(0, 0.1*keV);
em->SetHighEnergyLimit(0, 100.0*TeV);
AddEmModel(em, 0);
G4VEmFluctuationModel* fm = new G4UniversalFluctuation();
AddEmFluctuationModel(fm);
em->SetLowEnergyLimit(0.1*keV);
em->SetHighEnergyLimit(100.0*TeV);
AddEmModel(1, em);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -116,7 +117,14 @@ void G4MuPairProductionSTD::PrintInfoDefinition() const
<< G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4MuPairProductionSTD::SetSubCutoff(G4bool val)
{
subCutoff = val;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4VMuEnergyLoss.cc,v 1.22 2002/05/29 12:26:29 vnivanch Exp $
// GEANT4 tag $Name: geant4-05-00 $
// $Id: G4VMuEnergyLoss.cc,v 1.28 2003/04/26 12:11:14 vnivanch Exp $
// GEANT4 tag $Name: geant4-05-01 $
// --------------------------------------------------------------
// GEANT 4 class implementation file
//
@@ -39,16 +39,19 @@
// cleanup L.Urban on 23/10/98
// corrections due to new e.m. structure L.Urban 10/02/00
// signature in GetLossWithFluct changed L.Urban 30/10/00
// 29/05/01 V.Ivanchenko minor changes to provide ANSI -wall compilation
// 29/05/01 V.Ivanchenko minor changes to provide ANSI -wall compilation
// 10/09/01 L.Urban : loss+ mechanism (subcutoff delta rays) implemented
// 12/09/01 min.delta cut is set as rcut/100 + some optimisation, L.Urban
// 17-09-01 migration of Materials to pure STL (mma)
// 28-09-01 suppression of theMuonPlus ..etc..data members (mma)
// 29-10-01 all static functions no more inlined (mma)
// 29-10-01 all static functions no more inlined (mma)
// 08-11-01 some small cosmetics , L.Urban
// 06-02-02 bug fixed at subcutoff definition, L.Urban
// 26-02-02 bug fixed in TouchebleHandle definition, V.Ivanchenko
// 29-05-02 bug fixed in N of subcutoff delta, V.Ivanchenko
// 16-01-03 Migrade to cut per region (V.Ivanchenko)
// 25-03-03 add finalRangeRequested (mma)
// 09-04-03 finalRange is region aware (V.Ivanchenko)
// --------------------------------------------------------------
@@ -57,6 +60,7 @@
#include "G4Poisson.hh"
#include "G4Navigator.hh"
#include "G4TransportationManager.hh"
#include "G4ProductionCutsTable.hh"
// Initialisation of static members *******************************************
@@ -87,7 +91,7 @@ G4PhysicsTable* G4VMuEnergyLoss::themuplusRangeCoeffCTable = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::themuminusRangeCoeffATable = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::themuminusRangeCoeffBTable = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::themuminusRangeCoeffCTable = 0 ;
G4double G4VMuEnergyLoss::LowerBoundEloss = 1.*keV ;
G4double G4VMuEnergyLoss::UpperBoundEloss = 1000000.*TeV ;
G4int G4VMuEnergyLoss::NbinEloss = 150 ;
@@ -100,23 +104,21 @@ G4int G4VMuEnergyLoss::Ndeltamax = 100 ;
G4EnergyLossMessenger* G4VMuEnergyLoss::eLossMessenger = 0 ;
// constructor and destructor
G4VMuEnergyLoss::G4VMuEnergyLoss(const G4String& processName)
: G4VEnergyLoss (processName),
theLossTable(0),
lastgammaCutInRange(0),
lastelectronCutInRange(0),
theRangeCoeffATable(0),
theRangeCoeffBTable(0),
theRangeCoeffCTable(0)
{
{
}
G4VMuEnergyLoss::~G4VMuEnergyLoss()
G4VMuEnergyLoss::~G4VMuEnergyLoss()
{
if(theLossTable) {
theLossTable->clearAndDestroy();
delete theLossTable; theLossTable = 0;
delete theLossTable; theLossTable = 0;
}
}
@@ -141,7 +143,7 @@ void G4VMuEnergyLoss::SetNbinEloss(G4int nb) {NbinEloss=nb;}
G4double G4VMuEnergyLoss::GetLowerBoundEloss() {return LowerBoundEloss;}
G4double G4VMuEnergyLoss::GetUpperBoundEloss() {return UpperBoundEloss;}
G4int G4VMuEnergyLoss::GetNbinEloss() {return NbinEloss;}
void G4VMuEnergyLoss::BuildDEDXTable(
const G4ParticleDefinition& aParticleType)
{
@@ -151,50 +153,32 @@ void G4VMuEnergyLoss::BuildDEDXTable(
LOGRTable=lrate/NbinEloss;
RTable =exp(LOGRTable);
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
//set physically consistent value for finalRange
// and parameters for en.loss step limit
for (size_t idxMate=0; idxMate<G4Material::GetNumberOfMaterials(); idxMate++){
if(finalRange > (G4Electron::Electron()->GetLengthCuts())[idxMate])
finalRange = (G4Electron::Electron()->GetLengthCuts())[idxMate];
}
c1lim = dRoverRange ;
c2lim = 2.*(1.-dRoverRange)*finalRange ;
c3lim = -(1.-dRoverRange)*finalRange*finalRange;
if (finalRangeRequested > 0.) { finalRange = finalRangeRequested;}
G4bool MakeTable ;
ParticleMass = aParticleType.GetPDGMass() ;
ParticleMass = aParticleType.GetPDGMass() ;
G4double Charge = aParticleType.GetPDGCharge()/eplus ;
G4double* gammaCutInRange = G4Gamma::Gamma()->GetLengthCuts();
G4double* electronCutInRange = G4Electron::Electron()->GetLengthCuts();
MakeTable = false ;
// Create tables only if there are new cut values
if(EqualCutVectors(gammaCutInRange,lastgammaCutInRange) &&
EqualCutVectors(electronCutInRange,lastelectronCutInRange))
{
;
}
else
{
lastgammaCutInRange = CopyCutVectors(lastgammaCutInRange,gammaCutInRange);
lastelectronCutInRange = CopyCutVectors(lastelectronCutInRange,electronCutInRange);
if((Charge > 0.)&&(CounterOfmuplusProcess==NbOfProcesses))
MakeTable = true ;
if((Charge < 0.)&&(CounterOfmuminusProcess==NbOfProcesses))
MakeTable = true ;
}
const G4MaterialTable* theMaterialTable=
G4Material::GetMaterialTable();
G4int numOfMaterials = G4Material::GetNumberOfMaterials();
if ( (Charge > 0.) && (CounterOfmuplusProcess==NbOfProcesses) )
MakeTable = true ;
else if ( (Charge < 0.) && (CounterOfmuminusProcess==NbOfProcesses) )
MakeTable = true ;
if( MakeTable )
{
// Build energy loss table as a sum of the energy loss due to the
// different processes.
// different processes.
if( Charge >0.)
if( Charge >0.)
{
RecorderOfProcess=RecorderOfmuplusProcess;
CounterOfProcess=CounterOfmuplusProcess;
@@ -205,7 +189,7 @@ void G4VMuEnergyLoss::BuildDEDXTable(
{ theDEDXmuplusTable->clearAndDestroy();
delete theDEDXmuplusTable; }
theDEDXmuplusTable = new G4PhysicsTable(numOfMaterials);
theDEDXmuplusTable = new G4PhysicsTable(numOfCouples);
theDEDXTable = theDEDXmuplusTable;
}
}
@@ -219,7 +203,7 @@ void G4VMuEnergyLoss::BuildDEDXTable(
if(theDEDXmuminusTable)
{ theDEDXmuminusTable->clearAndDestroy();
delete theDEDXmuminusTable; }
theDEDXmuminusTable = new G4PhysicsTable(numOfMaterials);
theDEDXmuminusTable = new G4PhysicsTable(numOfCouples);
theDEDXTable = theDEDXmuminusTable;
}
}
@@ -229,18 +213,17 @@ void G4VMuEnergyLoss::BuildDEDXTable(
// loop for materials
G4double LowEdgeEnergy , Value ;
G4bool isOutRange ;
G4int J;
G4PhysicsTable* pointer ;
for (J=0; J<numOfMaterials; J++)
for (size_t J=0; J<numOfCouples; J++)
{
// create physics vector and fill it
G4PhysicsLogVector* aVector = new G4PhysicsLogVector(
LowerBoundEloss, UpperBoundEloss, NbinEloss);
LowerBoundEloss, UpperBoundEloss, NbinEloss);
// loop for the kinetic energy
for (G4int i=0; i<NbinEloss; i++)
{
LowEdgeEnergy = aVector->GetLowEdgeEnergy(i) ;
LowEdgeEnergy = aVector->GetLowEdgeEnergy(i) ;
Value = 0. ;
for (G4int process=0; process < NbOfProcesses; process++)
{
@@ -248,13 +231,13 @@ void G4VMuEnergyLoss::BuildDEDXTable(
Value += (*pointer)[J]->
GetValue(LowEdgeEnergy,isOutRange) ;
}
aVector->PutValue(i,Value) ;
aVector->PutValue(i,Value) ;
}
theDEDXTable->insert(aVector) ;
}
}
// reset counter to zero ..................
if( Charge >0.)
if( Charge >0.)
CounterOfmuplusProcess=0 ;
else
CounterOfmuminusProcess=0 ;
@@ -265,7 +248,7 @@ void G4VMuEnergyLoss::BuildDEDXTable(
{
// Build range table
theRangemuplusTable = BuildRangeTable(
theDEDXmuplusTable,theRangemuplusTable,
theDEDXmuplusTable,theRangemuplusTable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
// Build lab/proper time tables
@@ -301,7 +284,7 @@ void G4VMuEnergyLoss::BuildDEDXTable(
{
// Build range table
theRangemuminusTable = BuildRangeTable(
theDEDXmuminusTable,theRangemuminusTable,
theDEDXmuminusTable,theRangemuminusTable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
// Build lab/proper time tables
@@ -338,7 +321,7 @@ void G4VMuEnergyLoss::BuildDEDXTable(
}
// make the energy loss and the range table available
G4EnergyLossTables::Register(&aParticleType,
G4EnergyLossTables::Register(&aParticleType,
(Charge > 0)? theDEDXmuplusTable: theDEDXmuminusTable,
(Charge > 0)? theRangemuplusTable: theRangemuminusTable,
(Charge > 0)? theInverseRangemuplusTable: theInverseRangemuminusTable,
@@ -359,25 +342,26 @@ void G4VMuEnergyLoss::BuildDEDXTable(
// }
if(MinDeltaEnergy) {delete [] MinDeltaEnergy; MinDeltaEnergy=0;}
MinDeltaEnergy = new G4double [numOfMaterials];
MinDeltaEnergy = new G4double [numOfCouples];
if(LowerLimitForced) {delete [] LowerLimitForced; LowerLimitForced=0;}
LowerLimitForced = new G4bool [numOfMaterials];
LowerLimitForced = new G4bool [numOfCouples];
G4double Tlowerlimit = 1.*keV ;
for(G4int mat=0; mat<numOfMaterials; mat++)
{
LowerLimitForced[mat] = false ;
for (size_t mat=0; mat<numOfCouples; mat++)
{
LowerLimitForced[mat] = false ;
// create array for the min. delta cuts in kinetic energy
if(!setMinDeltaCutInRange)
MinDeltaCutInRange = (G4Electron::Electron()->GetLengthCuts())[mat]/10.;
// create array for the min. delta cuts in kinetic energy
G4double rcut = (*(theCoupleTable->GetRangeCutsVector(1)))[mat];
if(!setMinDeltaCutInRange) MinDeltaCutInRange = rcut/10.0;
MinDeltaEnergy[mat] = G4EnergyLossTables::GetPreciseEnergyFromRange(
G4Electron::Electron(),
MinDeltaCutInRange,
theCoupleTable->GetMaterialCutsCouple(mat));
MinDeltaEnergy[mat] = G4EnergyLossTables::GetPreciseEnergyFromRange(
G4Electron::Electron(),MinDeltaCutInRange,
(*theMaterialTable)[mat]) ;
if(MinDeltaEnergy[mat]<Tlowerlimit) MinDeltaEnergy[mat]=Tlowerlimit ;
if(MinDeltaEnergy[mat]<Tlowerlimit) MinDeltaEnergy[mat] = Tlowerlimit ;
if(MinDeltaEnergy[mat]>G4Electron::Electron()->GetEnergyCuts()[mat])
MinDeltaEnergy[mat]=G4Electron::Electron()->GetEnergyCuts()[mat] ;
G4double ecut = (*(theCoupleTable->GetEnergyCutsVector(1)))[mat];
if(MinDeltaEnergy[mat]>ecut) MinDeltaEnergy[mat] = ecut;
// if((subSecFlag) && (aParticleType.GetParticleName()=="mu+"))
// {
@@ -388,14 +372,13 @@ void G4VMuEnergyLoss::BuildDEDXTable(
// else
// G4cout << G4endl ;
// }
}
}
}
}
G4double G4VMuEnergyLoss::GetConstraints(const G4DynamicParticle *aParticle,
G4Material *aMaterial)
const G4MaterialCutsCouple* couple)
{
// returns the Step limit
@@ -404,7 +387,7 @@ G4double G4VMuEnergyLoss::GetConstraints(const G4DynamicParticle *aParticle,
G4double KineticEnergy,StepLimit;
G4bool isOutRange ;
G4int index,bin ;
G4int bin ;
if(aParticle->GetDefinition()->GetPDGCharge()>0.)
{
@@ -430,7 +413,7 @@ G4double G4VMuEnergyLoss::GetConstraints(const G4DynamicParticle *aParticle,
bin = G4int(log(KineticEnergy/LowerBoundEloss)/LOGRTable) ;
EnergyBinNumber = bin ;
index = aMaterial->GetIndex() ;
size_t index = couple->GetIndex() ;
if( KineticEnergy < LowerBoundEloss )
{
@@ -461,15 +444,16 @@ G4double G4VMuEnergyLoss::GetConstraints(const G4DynamicParticle *aParticle,
fRangeNow = (RangeCoeffA*KineticEnergy+RangeCoeffB)
*KineticEnergy+RangeCoeffC ;
// compute the (random) Step limit ..............
if(fRangeNow>finalRange)
// compute the Step limit ..............
G4double r = G4std::min(finalRange, couple->GetProductionCuts()
->GetProductionCut(idxG4ElectronCut));
if(fRangeNow>r)
{
StepLimit = c1lim*fRangeNow+c2lim+c3lim/fRangeNow ;
StepLimit = dRoverRange*fRangeNow + r*(1.0 - dRoverRange)*(2.0 - r/fRangeNow);
// randomise this value
if(rndmStepFlag) StepLimit = finalRange+(StepLimit-finalRange)*
G4UniformRand() ;
if(StepLimit > fRangeNow) StepLimit = fRangeNow ;
if(rndmStepFlag) StepLimit = r+(StepLimit-r)*G4UniformRand() ;
if(StepLimit > fRangeNow) StepLimit = fRangeNow ;
}
else
StepLimit = fRangeNow ;
@@ -479,10 +463,10 @@ G4double G4VMuEnergyLoss::GetConstraints(const G4DynamicParticle *aParticle,
}
G4VParticleChange* G4VMuEnergyLoss::AlongStepDoIt(
const G4Track& trackData,const G4Step& stepData)
G4VParticleChange* G4VMuEnergyLoss::AlongStepDoIt(
const G4Track& trackData,const G4Step& stepData)
{
// compute the energy loss after a Step
// compute the energy loss after a Step
static const G4double faclow = 1.5 ;
@@ -490,247 +474,247 @@ G4VParticleChange* G4VMuEnergyLoss::AlongStepDoIt(
const G4DynamicParticle* aParticle = trackData.GetDynamicParticle();
G4double E = aParticle->GetKineticEnergy() ;
G4double Charge = aParticle->GetDefinition()->GetPDGCharge();
G4Material* aMaterial = trackData.GetMaterial();
G4int index = aMaterial->GetIndex();
const G4MaterialCutsCouple* couple = trackData.GetMaterialCutsCouple();
const G4Material* aMaterial = couple->GetMaterial();
size_t index = couple->GetIndex();
G4double Step = stepData.GetStepLength();
aParticleChange.Initialize(trackData);
// do not track further if kin.energy < 1. eV
const G4double MinKineticEnergy = 1.*eV;
const G4double linLossLimit = 0.05 ;
const G4double MinKineticEnergy = 1.*eV;
const G4double linLossLimit = 0.05 ;
G4double MeanLoss, finalT;
if (E < MinKineticEnergy) finalT = 0.;
if (E < MinKineticEnergy) finalT = 0.;
else if ( E< faclow*LowerBoundEloss)
{
if (Step >= fRangeNow) finalT = 0.;
else finalT = E*(1.-Step/fRangeNow) ;
else finalT = E*(1.-Step/fRangeNow) ;
}
else if (E>=UpperBoundEloss) finalT = E - Step*fdEdx;
else if (Step >= fRangeNow) finalT = 0.;
else
{
if(Step/fRangeNow < linLossLimit) finalT = E-Step*fdEdx ;
else
{
if (Charge<0.) finalT = G4EnergyLossTables::GetPreciseEnergyFromRange(
G4MuonMinus::MuonMinus(),fRangeNow-Step,aMaterial);
G4MuonMinus::MuonMinus(),fRangeNow-Step,couple);
else finalT = G4EnergyLossTables::GetPreciseEnergyFromRange(
G4MuonPlus::MuonPlus(),fRangeNow-Step,aMaterial);
}
G4MuonPlus::MuonPlus(),fRangeNow-Step,couple);
}
}
if(finalT < MinKineticEnergy) finalT = 0. ;
MeanLoss = E-finalT ;
MeanLoss = E-finalT ;
// subcutoff delta ray production start
if((subSecFlag) && (trackData.GetCurrentStepNumber() > 1))
{
G4double MinDeltaEnergyNow,Tc,TmintoProduceDelta,w,ww ;
G4double rcut,T0,presafety,postsafety,safety,delta,Tmax,mass ;
G4double fragment = Step;
G4double frperstep = 1.0;
G4double x1,y1,z1,dx,dy,dz,dTime,time0,DeltaTime;
//G4double epsil = MinKineticEnergy/2. ;
// subcutoff delta ray production start
if((subSecFlag) && (trackData.GetCurrentStepNumber() > 1))
{
G4double MinDeltaEnergyNow,Tc,TmintoProduceDelta,w,ww ;
G4double rcut,T0,presafety,postsafety,safety,delta,Tmax,mass ;
G4double fragment = Step;
G4double frperstep = 1.0;
G4double x1,y1,z1,dx,dy,dz,dTime,time0,DeltaTime;
//G4double epsil = MinKineticEnergy/2. ;
MinDeltaEnergyNow = MinDeltaEnergy[index] ;
Tc=G4Electron::Electron()->GetEnergyCuts()[index];
const G4ParticleDefinition* aParticleType=aParticle->GetDefinition() ;
mass=aParticleType->GetPDGMass() ;
w=mass+electron_mass_c2 ;
ww=2.*mass-MinDeltaEnergyNow ;
TmintoProduceDelta=0.5*(sqrt(ww*ww+2.*w*w*MinDeltaEnergyNow/
MinDeltaEnergyNow = MinDeltaEnergy[index] ;
Tc=SecondaryEnergyThreshold(index);
const G4ParticleDefinition* aParticleType=aParticle->GetDefinition() ;
mass=aParticleType->GetPDGMass() ;
w=mass+electron_mass_c2 ;
ww=2.*mass-MinDeltaEnergyNow ;
TmintoProduceDelta=0.5*(sqrt(ww*ww+2.*w*w*MinDeltaEnergyNow/
electron_mass_c2)-ww) ;
if((E > TmintoProduceDelta) && (MeanLoss > MinDeltaEnergyNow)
if((E > TmintoProduceDelta) && (MeanLoss > MinDeltaEnergyNow)
&& (finalT > MinKineticEnergy))
{
{
// max. possible delta energy
Tmax = 2.*electron_mass_c2*E*(E+2.*mass)/
Tmax = 2.*electron_mass_c2*E*(E+2.*mass)/
(mass*mass+2.*electron_mass_c2*(E+mass)+
electron_mass_c2*electron_mass_c2) ;
rcut=(G4Electron::Electron()->GetLengthCuts())[index];
rcut=couple->GetProductionCuts()->GetProductionCut(1);
if(Tc > Tmax) Tc=Tmax ;
if (Tc > Tmax) Tc=Tmax ;
// generate subcutoff delta rays only if Tc>MinDeltaEnergyNow!
if((Tc > MinDeltaEnergyNow) && (Tmax > MinDeltaEnergyNow))
{
presafety = stepData.GetPreStepPoint()->GetSafety() ;
if ((Tc > MinDeltaEnergyNow) && (Tmax > MinDeltaEnergyNow))
{
presafety = stepData.GetPreStepPoint()->GetSafety() ;
// postsafety = stepData.GetPostStepPoint()->GetSafety() ;
G4Navigator *navigator=
G4Navigator *navigator=
G4TransportationManager::GetTransportationManager()
->GetNavigatorForTracking();
postsafety =
postsafety =
navigator->ComputeSafety(stepData.GetPostStepPoint()->GetPosition());
safety = G4std::min(presafety,postsafety) ;
if(safety < rcut)
{
x1=stepData.GetPreStepPoint()->GetPosition().x();
y1=stepData.GetPreStepPoint()->GetPosition().y();
z1=stepData.GetPreStepPoint()->GetPosition().z();
dx=stepData.GetPostStepPoint()->GetPosition().x()-x1 ;
dy=stepData.GetPostStepPoint()->GetPosition().y()-y1 ;
dz=stepData.GetPostStepPoint()->GetPosition().z()-z1 ;
time0=stepData.GetPreStepPoint()->GetGlobalTime();
dTime=stepData.GetPostStepPoint()->GetGlobalTime()-time0;
if((presafety<rcut)&&(postsafety<rcut))
safety = G4std::min(presafety,postsafety) ;
if (safety < rcut)
{
fragment = Step ;
frperstep=1. ;
}
else if(presafety<rcut)
{
delta=presafety*Step/(postsafety-presafety) ;
fragment=rcut*(Step+delta)/postsafety-delta ;
frperstep=fragment/Step;
}
else if(postsafety<rcut)
{
delta=postsafety*Step/(presafety-postsafety) ;
fragment=rcut*(Step+delta)/presafety-delta ;
x1 += dx;
y1 += dy;
z1 += dz;
time0 += dTime ;
frperstep=-fragment/Step;
}
if(fragment>0.)
{
T0=G4EnergyLossTables::GetPreciseEnergyFromRange(
x1=stepData.GetPreStepPoint()->GetPosition().x();
y1=stepData.GetPreStepPoint()->GetPosition().y();
z1=stepData.GetPreStepPoint()->GetPosition().z();
dx=stepData.GetPostStepPoint()->GetPosition().x()-x1 ;
dy=stepData.GetPostStepPoint()->GetPosition().y()-y1 ;
dz=stepData.GetPostStepPoint()->GetPosition().z()-z1 ;
time0=stepData.GetPreStepPoint()->GetGlobalTime();
dTime=stepData.GetPostStepPoint()->GetGlobalTime()-time0;
if ((presafety<rcut)&&(postsafety<rcut))
{
fragment = Step ;
frperstep=1. ;
}
else if(presafety<rcut)
{
delta=presafety*Step/(postsafety-presafety) ;
fragment=rcut*(Step+delta)/postsafety-delta ;
frperstep=fragment/Step;
}
else if(postsafety<rcut)
{
delta=postsafety*Step/(presafety-postsafety) ;
fragment=rcut*(Step+delta)/presafety-delta ;
x1 += dx;
y1 += dy;
z1 += dz;
time0 += dTime ;
frperstep=-fragment/Step;
}
if(fragment>0.)
{
T0=G4EnergyLossTables::GetPreciseEnergyFromRange(
G4Electron::Electron(),
G4std::min(presafety,postsafety),
aMaterial) ;
couple) ;
// absolute lower limit for T0
// if(T0<MinDeltaEnergyNow) T0=MinDeltaEnergyNow ;
if((T0<MinDeltaEnergyNow)||(LowerLimitForced[aMaterial->GetIndex()]))
if((T0<MinDeltaEnergyNow)||(LowerLimitForced[index]))
T0=MinDeltaEnergyNow ;
// compute nb of delta rays to be generated
// approximate value based on Bethe-Bloch and
// assuming an 1/E**2 delta spectrum
G4double deldedx=cN*aMaterial->GetDensity()*
// approximate value based on Bethe-Bloch and
// assuming an 1/E**2 delta spectrum
G4double deldedx=cN*aMaterial->GetDensity()*
((E+mass)*(E+mass)*log(Tc/T0)/(E*(E+mass))) ;
G4double delToverTc=1.-T0/Tc ;
G4int N = G4int(deldedx*fragment*delToverTc/(T0*log(Tc/T0))+0.5) ;
if(N > Ndeltamax) N = Ndeltamax ;
G4double Px,Py,Pz ;
G4ThreeVector ParticleDirection ;
ParticleDirection=aParticle->
G4double delToverTc=1.-T0/Tc ;
G4int N = G4int(deldedx*fragment*delToverTc/(T0*log(Tc/T0))+0.5) ;
if(N > Ndeltamax) N = Ndeltamax ;
G4double Px,Py,Pz ;
G4ThreeVector ParticleDirection ;
ParticleDirection=aParticle->
GetMomentumDirection() ;
Px =ParticleDirection.x() ;
Py =ParticleDirection.y() ;
Pz =ParticleDirection.z() ;
Px =ParticleDirection.x() ;
Py =ParticleDirection.y() ;
Pz =ParticleDirection.z() ;
G4int subdelta = 0;
G4int subdelta = 0;
if(N > 0)
{
G4double Tkin,Etot,P,T,p,costheta,sintheta,phi,dirx,diry,dirz,
if (N > 0)
{
G4double Tkin,Etot,P,T,p,costheta,sintheta,phi,dirx,diry,dirz,
Pnew,urandom;
//delTkin,delLoss,rate,
//G4StepPoint *point ;
Tkin = E ;
Etot = Tkin+mass ;
P = sqrt(Tkin*(Etot+mass)) ;
Tkin = E ;
Etot = Tkin+mass ;
P = sqrt(Tkin*(Etot+mass)) ;
aParticleChange.SetNumberOfSecondaries(N);
do {
subdelta += 1 ;
aParticleChange.SetNumberOfSecondaries(N);
do {
subdelta += 1 ;
Tmax = 2.*electron_mass_c2*Tkin*(Tkin+2.*mass)/
Tmax = 2.*electron_mass_c2*Tkin*(Tkin+2.*mass)/
(mass*mass+2.*electron_mass_c2*(Tkin+mass)+
electron_mass_c2*electron_mass_c2) ;
if(Tc>Tmax) Tc = Tmax ;
if(Tc>Tmax) Tc = Tmax ;
//check if there is enough energy ....
if((Tkin>TmintoProduceDelta)&&(Tc > T0)&&(MeanLoss>0.))
{
T=T0/(1.-delToverTc*G4UniformRand()) ;
if(T > MeanLoss) T=MeanLoss ;
MeanLoss -= T ;
p=sqrt(T*(T+2.*electron_mass_c2)) ;
if((Tkin>TmintoProduceDelta)&&(Tc > T0)&&(MeanLoss>0.))
{
T=T0/(1.-delToverTc*G4UniformRand()) ;
if(T > MeanLoss) T=MeanLoss ;
MeanLoss -= T ;
p=sqrt(T*(T+2.*electron_mass_c2)) ;
costheta = T*(Etot+electron_mass_c2)/(P*p) ;
if(costheta<-1.) costheta=-1.;
if(costheta> 1.) costheta= 1.;
costheta = T*(Etot+electron_mass_c2)/(P*p) ;
if(costheta<-1.) costheta=-1.;
if(costheta> 1.) costheta= 1.;
phi=twopi*G4UniformRand() ;
sintheta=sqrt(1.-costheta*costheta);
dirx=sintheta*cos(phi);
diry=sintheta*sin(phi);
dirz=costheta;
phi=twopi*G4UniformRand() ;
sintheta=sqrt(1.-costheta*costheta);
dirx=sintheta*cos(phi);
diry=sintheta*sin(phi);
dirz=costheta;
urandom = G4UniformRand() ;
urandom = G4UniformRand() ;
// distribute x,y,z along Pre-Post !
G4double xd,yd,zd ;
xd=x1+frperstep*dx*urandom ;
yd=y1+frperstep*dy*urandom ;
zd=z1+frperstep*dz*urandom ;
G4ThreeVector DeltaPosition(xd,yd,zd) ;
DeltaTime=time0+frperstep*dTime*urandom ;
G4double xd,yd,zd ;
xd=x1+frperstep*dx*urandom ;
yd=y1+frperstep*dy*urandom ;
zd=z1+frperstep*dz*urandom ;
G4ThreeVector DeltaPosition(xd,yd,zd) ;
DeltaTime=time0+frperstep*dTime*urandom ;
G4ThreeVector DeltaDirection(dirx,diry,dirz) ;
DeltaDirection.rotateUz(ParticleDirection);
G4ThreeVector DeltaDirection(dirx,diry,dirz) ;
DeltaDirection.rotateUz(ParticleDirection);
G4DynamicParticle* theDelta = new G4DynamicParticle ;
theDelta->SetDefinition(G4Electron::Electron());
theDelta->SetKineticEnergy(T);
G4DynamicParticle* theDelta = new G4DynamicParticle ;
theDelta->SetDefinition(G4Electron::Electron());
theDelta->SetKineticEnergy(T);
theDelta->SetMomentumDirection(DeltaDirection.x(),
theDelta->SetMomentumDirection(DeltaDirection.x(),
DeltaDirection.y(),DeltaDirection.z());
// update initial particle,fill ParticleChange
Tkin -= T ;
Px =(P*ParticleDirection.x()-p*DeltaDirection.x()) ;
Py =(P*ParticleDirection.y()-p*DeltaDirection.y()) ;
Pz =(P*ParticleDirection.z()-p*DeltaDirection.z()) ;
Pnew = sqrt(Px*Px+Py*Py+Pz*Pz) ;
Px /= Pnew ;
Py /= Pnew ;
Pz /= Pnew ;
P = Pnew ;
G4ThreeVector ParticleDirectionnew(Px,Py,Pz) ;
ParticleDirection = ParticleDirectionnew;
Tkin -= T ;
Px =(P*ParticleDirection.x()-p*DeltaDirection.x()) ;
Py =(P*ParticleDirection.y()-p*DeltaDirection.y()) ;
Pz =(P*ParticleDirection.z()-p*DeltaDirection.z()) ;
Pnew = sqrt(Px*Px+Py*Py+Pz*Pz) ;
Px /= Pnew ;
Py /= Pnew ;
Pz /= Pnew ;
P = Pnew ;
G4ThreeVector ParticleDirectionnew(Px,Py,Pz) ;
ParticleDirection = ParticleDirectionnew;
G4Track* deltaTrack =
G4Track* deltaTrack =
new G4Track(theDelta,DeltaTime,DeltaPosition);
deltaTrack->
deltaTrack->
SetTouchableHandle(stepData.GetPreStepPoint()->GetTouchableHandle()) ;
deltaTrack->SetParentID(trackData.GetTrackID()) ;
aParticleChange.AddSecondary(deltaTrack) ;
deltaTrack->SetParentID(trackData.GetTrackID()) ;
aParticleChange.AddSecondary(deltaTrack) ;
}
}
} while (subdelta<N) ;
} while (subdelta<N) ;
// update the particle direction and kinetic energy
if(subdelta > 0)
aParticleChange.SetMomentumChange(Px,Py,Pz) ;
E = Tkin ;
}
if(subdelta > 0)
aParticleChange.SetMomentumChange(Px,Py,Pz) ;
E = Tkin ;
}
}
}
}
}
}
}
}
}
// end of subcutoff business
@@ -741,16 +725,16 @@ G4VParticleChange* G4VMuEnergyLoss::AlongStepDoIt(
if ((EnlossFlucFlag) && (finalT > 0.) && (finalT < E)&&(E > LowerBoundEloss))
{
finalT = E-GetLossWithFluct(aParticle,aMaterial,1.,MeanLoss,Step);
finalT = E-GetLossWithFluct(aParticle,couple,1.,MeanLoss,Step);
if (finalT < 0.) finalT = 0. ;
}
// kill the particle if the kinetic energy <= 0
if (finalT <= 0. )
{
{
finalT = 0.;
aParticleChange.SetStatusChange(fStopButAlive);
}
}
// aParticleChange.SetNumberOfSecondaries(0);
aParticleChange.SetEnergyChange(finalT);
@@ -758,6 +742,3 @@ G4VParticleChange* G4VMuEnergyLoss::AlongStepDoIt(
return &aParticleChange;
}