Import Geant4 9.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 15:16:48 +02:00
parent 75c7fd177d
commit a8e9364cea
6592 changed files with 84274 additions and 69292 deletions
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4EnergyLossForExtrapolator.cc,v 1.10 2007/02/16 16:03:18 vnivanch Exp $
// GEANT4 tag $Name: geant4-08-03 $
// $Id: G4EnergyLossForExtrapolator.cc,v 1.12 2007/05/29 04:43:31 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
//---------------------------------------------------------------------------
//
@@ -41,6 +41,7 @@
// 21-03-06 Add verbosity defined in the constructor and Initialisation
// start only when first public method is called (V.Ivanchenko)
// 03-05-06 Remove unused pointer G4Material* from number of methods (VI)
// 12-05-06 SEt linLossLimit=0.001 (VI)
//
//----------------------------------------------------------------------------
//
@@ -201,10 +202,10 @@ void G4EnergyLossForExtrapolator::Initialisation()
currentParticleName = "";
linLossLimit = 1.e-6;
linLossLimit = 0.001;
emin = 1.*MeV;
emax = 100.*GeV;
nbins = 50;
emax = 10.*TeV;
nbins = 70;
nmat = G4Material::GetNumberOfMaterials();
const G4MaterialTable* mtable = G4Material::GetMaterialTable();
@@ -0,0 +1,177 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
#include "G4ErrorEnergyLoss.hh"
#include "G4ErrorPropagatorData.hh"
#include "G4EnergyLossForExtrapolator.hh"
//-------------------------------------------------------------------
G4ErrorEnergyLoss::G4ErrorEnergyLoss(const G4String& processName,
G4ProcessType type)
: G4VContinuousProcess(processName, type)
{
if (verboseLevel>2) {
G4cout << GetProcessName() << " is created " << G4endl;
}
InstantiateEforExtrapolator();
theStepLimit = 1.;
}
//-------------------------------------------------------------------
void G4ErrorEnergyLoss::InstantiateEforExtrapolator()
{
if( theELossForExtrapolator == 0 ) {
theELossForExtrapolator = new G4EnergyLossForExtrapolator;
}
}
//-------------------------------------------------------------------
G4ErrorEnergyLoss::~G4ErrorEnergyLoss()
{
if( theELossForExtrapolator != 0 ) {
delete theELossForExtrapolator;
}
}
//-------------------------------------------------------------------
G4VParticleChange*
G4ErrorEnergyLoss::AlongStepDoIt(const G4Track& aTrack, const G4Step& aStep)
{
aParticleChange.Initialize(aTrack);
G4ErrorPropagatorData* g4edata = G4ErrorPropagatorData::GetErrorPropagatorData();
G4double kinEnergyStart = aTrack.GetKineticEnergy();
G4double step_length = aStep.GetStepLength();
const G4Material* aMaterial = aTrack.GetMaterial();
const G4ParticleDefinition* aParticleDef = aTrack.GetDynamicParticle()->GetDefinition();
G4double kinEnergyEnd = kinEnergyStart;
if( g4edata->GetMode() == G4ErrorMode(G4ErrorMode_PropBackwards) ) {
kinEnergyEnd = theELossForExtrapolator->EnergyBeforeStep( kinEnergyStart,
step_length,
aMaterial,
aParticleDef );
G4double kinEnergyHalfStep = kinEnergyStart - (kinEnergyStart-kinEnergyEnd)/2.;
#ifdef G4VERBOSE
if(G4ErrorPropagatorData::verbose() >= 3 )
G4cout << " G4ErrorEnergyLoss FWD end " << kinEnergyEnd
<< " halfstep " << kinEnergyHalfStep << G4endl;
#endif
//--- rescale to energy lost at 1/2 step
kinEnergyEnd = theELossForExtrapolator->EnergyBeforeStep( kinEnergyHalfStep,
step_length,
aMaterial,
aParticleDef );
kinEnergyEnd = kinEnergyStart - (kinEnergyHalfStep - kinEnergyEnd );
}else if( g4edata->GetMode() == G4ErrorMode(G4ErrorMode_PropForwards) ) {
kinEnergyEnd = theELossForExtrapolator->EnergyAfterStep( kinEnergyStart,
step_length,
aMaterial,
aParticleDef );
G4double kinEnergyHalfStep = kinEnergyStart - (kinEnergyStart-kinEnergyEnd)/2.;
#ifdef G4VERBOSE
if(G4ErrorPropagatorData::verbose() >= 3 )
G4cout << " G4ErrorEnergyLoss BCKD end " << kinEnergyEnd
<< " halfstep " << kinEnergyHalfStep << G4endl;
#endif
//--- rescale to energy lost at 1/2 step
kinEnergyEnd = theELossForExtrapolator->EnergyAfterStep( kinEnergyHalfStep,
step_length,
aMaterial,
aParticleDef );
kinEnergyEnd = kinEnergyStart - (kinEnergyHalfStep - kinEnergyEnd );
}
G4double edepo = kinEnergyEnd - kinEnergyStart;
#ifdef G4VERBOSE
if( G4ErrorPropagatorData::verbose() >= 2 )
G4cout << "AlongStepDoIt Estart= " << kinEnergyStart << " Eend " << kinEnergyEnd
<< " Ediff " << kinEnergyStart-kinEnergyEnd << " step= " << step_length
<< " mate= " << aMaterial->GetName()
<< " particle= " << aParticleDef->GetParticleName() << G4endl;
#endif
aParticleChange.ClearDebugFlag();
aParticleChange.ProposeLocalEnergyDeposit( edepo );
aParticleChange.SetNumberOfSecondaries(0);
aParticleChange.ProposeEnergy( kinEnergyEnd );
return &aParticleChange;
}
//-------------------------------------------------------------------
G4double G4ErrorEnergyLoss::GetContinuousStepLimit(const G4Track& aTrack,
G4double ,
G4double currentMinimumStep,
G4double& )
{
G4double Step = DBL_MAX;
if( theStepLimit != 1. ) {
G4double kinEnergyStart = aTrack.GetKineticEnergy();
G4double kinEnergyLoss = kinEnergyStart;
const G4Material* aMaterial = aTrack.GetMaterial();
const G4ParticleDefinition* aParticleDef = aTrack.GetDynamicParticle()->GetDefinition();
G4ErrorPropagatorData* g4edata = G4ErrorPropagatorData::GetErrorPropagatorData();
if( g4edata->GetMode() == G4ErrorMode(G4ErrorMode_PropBackwards) ) {
kinEnergyLoss = - kinEnergyStart +
theELossForExtrapolator->EnergyBeforeStep( kinEnergyStart, currentMinimumStep,
aMaterial, aParticleDef );
}else if( g4edata->GetMode() == G4ErrorMode(G4ErrorMode_PropForwards) ) {
kinEnergyLoss = kinEnergyStart -
theELossForExtrapolator->EnergyAfterStep( kinEnergyStart, currentMinimumStep,
aMaterial, aParticleDef );
}
#ifdef G4VERBOSE
if(G4ErrorPropagatorData::verbose() >= 3 )
G4cout << " G4ErrorEnergyLoss: currentMinimumStep " <<currentMinimumStep
<< " kinEnergyLoss " << kinEnergyLoss
<< " kinEnergyStart " << kinEnergyStart << G4endl;
#endif
if( kinEnergyLoss / kinEnergyStart > theStepLimit ) {
Step = theStepLimit / (kinEnergyLoss / kinEnergyStart) * currentMinimumStep;
#ifdef G4VERBOSE
if(G4ErrorPropagatorData::verbose() >= 2 )
G4cout << " G4ErrorEnergyLoss: limiting Step " << Step
<< " energy loss fraction " << kinEnergyLoss / kinEnergyStart
<< " > " << theStepLimit << G4endl;
#endif
}
}
return Step;
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4MuBetheBlochModel.cc,v 1.22 2006/06/29 19:49:36 gunter Exp $
// GEANT4 tag $Name: geant4-08-02 $
// $Id: G4MuBetheBlochModel.cc,v 1.23 2007/05/22 17:35:58 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// -------------------------------------------------------------------
//
@@ -281,15 +281,15 @@ G4double G4MuBetheBlochModel::ComputeDEDXPerVolume(const G4Material* material,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
vector<G4DynamicParticle*>* G4MuBetheBlochModel::SampleSecondaries(
const G4MaterialCutsCouple*,
const G4DynamicParticle* dp,
G4double minKinEnergy,
G4double maxEnergy)
void G4MuBetheBlochModel::SampleSecondaries(vector<G4DynamicParticle*>* vdp,
const G4MaterialCutsCouple*,
const G4DynamicParticle* dp,
G4double minKinEnergy,
G4double maxEnergy)
{
G4double tmax = MaxSecondaryKinEnergy(dp);
G4double maxKinEnergy = min(maxEnergy,tmax);
if(minKinEnergy >= maxKinEnergy) return 0;
if(minKinEnergy >= maxKinEnergy) return;
G4double kineticEnergy = dp->GetKineticEnergy();
G4double totEnergy = kineticEnergy + mass;
@@ -355,10 +355,7 @@ vector<G4DynamicParticle*>* G4MuBetheBlochModel::SampleSecondaries(
// create G4DynamicParticle object for delta ray
G4DynamicParticle* delta = new G4DynamicParticle(theElectron,
deltaDirection,deltaKinEnergy);
vector<G4DynamicParticle*>* vdp = new vector<G4DynamicParticle*>;
vdp->push_back(delta);
return vdp;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4MuBremsstrahlung.cc,v 1.37 2006/06/29 19:49:38 gunter Exp $
// GEANT4 tag $Name: geant4-08-02 $
// $Id: G4MuBremsstrahlung.cc,v 1.38 2007/05/22 17:35:58 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// -------------------------------------------------------------------
//
@@ -81,12 +81,7 @@ G4MuBremsstrahlung::G4MuBremsstrahlung(const G4String& name)
theBaseParticle(0),
lowestKinEnergy(1.*GeV),
isInitialised(false)
{
SetDEDXBinning(120);
SetLambdaBinning(120);
SetMinKinEnergy(0.1*keV);
SetMaxKinEnergy(100.0*TeV);
}
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -1,716 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4MuBremsstrahlung52.cc,v 1.6 2006/10/16 15:31:01 vnivanch Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
//
//--------------- G4MuBremsstrahlung52 physics process ---------------------------
// by Laszlo Urban, September 1997
//
// 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
// 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)
// 16-01-03 Migrade to cut per region (V.Ivanchenko)
// 26-04-03 fix problems of retrieve tables (V.Ivanchenko)
// 08-08-03 This class is frozen at the release 5.2 (V.Ivanchenko)
// 08-11-04 Remove interface of Store/Retrieve tables (V.Ivantchenko)
//------------------------------------------------------------------------------
#include "G4MuBremsstrahlung52.hh"
#include "G4UnitsTable.hh"
#include "G4ProductionCutsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// static members
//
G4int G4MuBremsstrahlung52::nzdat = 5 ;
G4double G4MuBremsstrahlung52::zdat[]={1.,4.,13.,29.,92.};
G4double G4MuBremsstrahlung52::adat[]={1.01,9.01,26.98,63.55,238.03};
G4int G4MuBremsstrahlung52::ntdat = 8 ;
G4double G4MuBremsstrahlung52::tdat[]={1.e3,1.e4,1.e5,1.e6,1.e7,1.e8,1.e9,1.e10};
G4int G4MuBremsstrahlung52::NBIN = 1000; // 100 ;
G4double G4MuBremsstrahlung52::ya[1001];
G4double G4MuBremsstrahlung52::proba[5][8][1001];
G4double G4MuBremsstrahlung52::CutFixed=0.98*keV;
G4double G4MuBremsstrahlung52::LowerBoundLambda = 1.*keV;
G4double G4MuBremsstrahlung52::UpperBoundLambda = 1000000.*TeV;
G4int G4MuBremsstrahlung52::NbinLambda = 150;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
using namespace std;
G4MuBremsstrahlung52::G4MuBremsstrahlung52(const G4String& processName)
: G4VMuEnergyLoss(processName),
theMeanFreePathTable(NULL)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4MuBremsstrahlung52::~G4MuBremsstrahlung52()
{
if (theMeanFreePathTable) {
theMeanFreePathTable->clearAndDestroy();
delete theMeanFreePathTable;
}
PartialSumSigma.clearAndDestroy();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuBremsstrahlung52::SetLowerBoundLambda(G4double val)
{LowerBoundLambda = val;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuBremsstrahlung52::SetUpperBoundLambda(G4double val)
{UpperBoundLambda = val;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuBremsstrahlung52::SetNbinLambda(G4int n)
{NbinLambda = n;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuBremsstrahlung52::GetLowerBoundLambda()
{ return LowerBoundLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuBremsstrahlung52::GetUpperBoundLambda()
{ return UpperBoundLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4int G4MuBremsstrahlung52::GetNbinLambda()
{return NbinLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuBremsstrahlung52::BuildPhysicsTable(
const G4ParticleDefinition& aParticleType)
{
if( !CutsWhereModified() && theLossTable) return;
LowestKineticEnergy = GetLowerBoundEloss() ;
HighestKineticEnergy = GetUpperBoundEloss() ;
TotBin = GetNbinEloss() ;
BuildLossTable(aParticleType) ;
if(&aParticleType==G4MuonMinus::MuonMinus())
{
RecorderOfmuminusProcess[CounterOfmuminusProcess] = (*this).theLossTable;
CounterOfmuminusProcess++;
}
else
{
RecorderOfmuplusProcess[CounterOfmuplusProcess] = (*this).theLossTable;
CounterOfmuplusProcess++;
}
if( !theMeanFreePathTable ) MakeSamplingTables(&aParticleType) ;
BuildLambdaTable(aParticleType) ;
G4VMuEnergyLoss::BuildDEDXTable(aParticleType);
if(&aParticleType == G4MuonPlus::MuonPlus()) PrintInfoDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuBremsstrahlung52::BuildLossTable(
const G4ParticleDefinition& aParticleType)
{
G4double KineticEnergy,TotalEnergy,bremloss,Z,
loss,natom ;
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();
// loop for materials
//
for (size_t J=0; J<numOfCouples; J++)
{
G4PhysicsLogVector* aVector = new G4PhysicsLogVector(
LowestKineticEnergy,HighestKineticEnergy,TotBin);
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() ;
for (G4int i=0; i<TotBin; i++)
{
KineticEnergy = aVector->GetLowEdgeEnergy(i) ;
TotalEnergy = KineticEnergy+particleMass ;
if(Cut>KineticEnergy) Cut = KineticEnergy ;
bremloss = 0.;
for (G4int iel=0; iel<NumberOfElements; iel++)
{
Z=(*theElementVector)[iel]->GetZ();
natom = theAtomicNumDensityVector[iel] ;
loss = ComputeBremLoss((&aParticleType),Z,
(*theElementVector)[iel]->GetA(),
KineticEnergy,Cut) ;
bremloss += natom*loss ;
}
if(bremloss<0.) bremloss = 0. ;
aVector->PutValue(i,bremloss);
}
theLossTable->insert(aVector);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuBremsstrahlung52::ComputeBremLoss(
const G4ParticleDefinition* aParticleType,
G4double AtomicNumber,G4double AtomicMass,
G4double KineticEnergy,G4double GammaEnergyCut)
{
G4double TotalEnergy,vcut,vmax,aaa,bbb,hhh,aa,x,ep ;
G4int kkk ;
G4double ak1=0.05 ;
G4int k2=5 ;
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 ;
vmax = KineticEnergy/TotalEnergy ;
aaa=0.;
bbb=vcut ;
if(vcut>vmax) bbb=vmax ;
kkk=int((bbb-aaa)/ak1)+k2 ;
hhh=(bbb-aaa)/float(kkk) ;
for(G4int l=0; l<kkk; l++)
{
aa=aaa+hhh*float(l) ;
for(G4int i=0; i<6; i++)
{
x=aa+xgi[i]*hhh ;
ep=x*TotalEnergy ;
loss += ep*wgi[i]*ComputeDMicroscopicCrossSection(
aParticleType,KineticEnergy,
AtomicNumber,AtomicMass,ep) ;
}
}
loss *=hhh*TotalEnergy ;
return loss ;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuBremsstrahlung52::BuildLambdaTable(
const G4ParticleDefinition& ParticleType)
{
G4double LowEdgeEnergy , Value;
G4double FixedEnergy = (LowestKineticEnergy + HighestKineticEnergy)/2. ;
//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(numOfCouples);
G4PhysicsLogVector* ptrVector;
for ( size_t J=0; J<numOfCouples; J++ )
{
ptrVector = new G4PhysicsLogVector(
LowerBoundLambda,UpperBoundLambda,NbinLambda);
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(J);
for ( G4int i = 0 ; i < NbinLambda ; i++ )
{
LowEdgeEnergy = ptrVector->GetLowEdgeEnergy( i ) ;
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, couple) ;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuBremsstrahlung52::ComputePartialSumSigma(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy,
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.
{
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 = SecondaryEnergyThreshold(index);
PartialSumSigma[index] = new G4DataVector();
G4double SIGMA = 0. ;
for ( G4int Ielem=0 ; Ielem < NbOfElements ; Ielem++ )
{
SIGMA += theAtomNumDensityVector[Ielem] *
ComputeMicroscopicCrossSection( ParticleType, KineticEnergy,
(*theElementVector)[Ielem]->GetZ(),
(*theElementVector)[Ielem]->GetA(),
GammaEnergyCut );
PartialSumSigma[index]->push_back(SIGMA);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuBremsstrahlung52::ComputeMicroscopicCrossSection(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy,
G4double AtomicNumber,
G4double AtomicMass,
G4double GammaEnergyCut)
// Cross section is calculated according to a formula of R.Kokoulin.
{
G4double TotalEnergy,vcut,vmax,aaa,bbb,hhh,aa,x,ep ;
G4int kkk ;
G4double ak1=2.3 ;
G4int k2=4 ;
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 ;
vmax = KineticEnergy/TotalEnergy ;
if(vmax <= vcut) return CrossSection;
// numerical integration
aaa=log(vcut) ;
bbb=log(vmax);
kkk=int((bbb-aaa)/ak1)+k2 ;
hhh=(bbb-aaa)/float(kkk) ;
for(G4int l=0; l<kkk; l++)
{
aa=aaa+hhh*float(l) ;
for(G4int i=0; i<6; i++)
{
x=aa+xgi[i]*hhh ;
ep=exp(x)*TotalEnergy ;
CrossSection += ep*wgi[i]*ComputeDMicroscopicCrossSection(
ParticleType,KineticEnergy,
AtomicNumber,AtomicMass,ep) ;
}
}
CrossSection *= hhh ;
return CrossSection;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuBremsstrahlung52::GetDMicroscopicCrossSection(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy,
G4double AtomicNumber,
G4double AtomicMass,
G4double GammaEnergy)
// get differential cross section
{
return ComputeDMicroscopicCrossSection(ParticleType,KineticEnergy,
AtomicNumber,AtomicMass,GammaEnergy);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuBremsstrahlung52::ComputeDMicroscopicCrossSection(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy,
G4double AtomicNumber,
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 ;
static const G4double cc=classic_electr_radius/rmass ;
static const G4double coeff= 16.*fine_structure_const*cc*cc/3. ;
G4double dxsection = 0.;
if( GammaEnergy > KineticEnergy) return dxsection ;
G4double A = AtomicMass/(g/mole) ; // !!!!!!!!!!!!!!!!!!!
G4double E=KineticEnergy+particleMass ;
G4double v=GammaEnergy/E ;
G4double delta=0.5*particleMass*particleMass*v/(E-GammaEnergy) ;
G4double rab0=delta*sqrte ;
G4double z13=exp(-log(AtomicNumber)/3.) ;
G4double dn=1.54*exp(0.27*log(A)) ;
G4double b,b1,dnstar ;
if(AtomicNumber<1.5)
{
b=bh;
b1=bh1;
dnstar=dn ;
}
else
{
b=btf;
b1=btf1;
dnstar = exp((1.-1./AtomicNumber)*log(dn)) ;
}
// nucleus contribution logarithm
G4double rab1=b*z13;
G4double fn=log(rab1/(dnstar*(electron_mass_c2+rab0*rab1))*
(particleMass+delta*(dnstar*sqrte-2.))) ;
if(fn <0.) fn = 0. ;
// electron contribution logarithm
G4double epmax1=E/(1.+0.5*particleMass*rmass/E) ;
G4double fe=0.;
if(GammaEnergy<epmax1)
{
G4double rab2=b1*z13*z13 ;
fe=log(rab2*particleMass/((1.+delta*rmass/(electron_mass_c2*sqrte))*
(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 ;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuBremsstrahlung52::MakeSamplingTables(
const G4ParticleDefinition* ParticleType)
{
G4int nbin;
G4double AtomicNumber,AtomicWeight,KineticEnergy,
TotalEnergy,Maxep ;
G4double particleMass = ParticleType->GetPDGMass() ;
for (G4int iz=0; iz<nzdat; iz++)
{
AtomicNumber = zdat[iz];
AtomicWeight = adat[iz]*g/mole ;
for (G4int it=0; it<ntdat; it++)
{
KineticEnergy = tdat[it];
TotalEnergy = KineticEnergy + particleMass;
Maxep = KineticEnergy ;
G4double CrossSection = 0.0 ;
G4double c,y,ymin,ymax,dy,yy,dx,x,ep;
//G4int NbofIntervals ;
// calculate the differential cross section
// numerical integration in
// log ...............
c = log(Maxep/CutFixed) ;
ymin = -5. ;
ymax = 0. ;
dy = (ymax-ymin)/NBIN ;
nbin=-1;
y = ymin - 0.5*dy ;
yy = ymin - dy ;
for (G4int i=0 ; i<NBIN; i++)
{
y += dy ;
x = exp(y) ;
yy += dy ;
dx = exp(yy+dy)-exp(yy) ;
ep = CutFixed*exp(c*x) ;
CrossSection += ep*dx*ComputeDMicroscopicCrossSection(ParticleType,
KineticEnergy,AtomicNumber,
AtomicWeight,ep) ;
if(nbin<NBIN)
{
nbin += 1 ;
ya[nbin]=y ;
proba[iz][it][nbin] = CrossSection ;
}
}
ya[NBIN] = 0. ; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if(CrossSection > 0.)
{
for(G4int ib=0; ib<=nbin; ib++)
{
proba[iz][it][ib] /= CrossSection ;
}
}
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange* G4MuBremsstrahlung52::PostStepDoIt(const G4Track& trackData,
const G4Step& stepData)
{
static G4double ysmall = -100. ;
static G4double ytablelow = -5. ;
aParticleChange.Initialize(trackData);
const G4MaterialCutsCouple* couple = trackData.GetMaterialCutsCouple();
const G4DynamicParticle* aDynamicParticle=trackData.GetDynamicParticle();
G4double KineticEnergy = aDynamicParticle->GetKineticEnergy();
G4ParticleMomentum ParticleDirection =
aDynamicParticle->GetMomentumDirection();
// Gamma cut in this material
G4double GammaEnergyCut = SecondaryEnergyThreshold(couple->GetIndex());
// check against insufficient energy
if(KineticEnergy < GammaEnergyCut)
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
// select randomly one element constituing the material
const G4Element* anElement = SelectRandomAtom(couple);
G4double TotalEnergy=KineticEnergy+aDynamicParticle->
GetDefinition()->GetPDGMass() ;
G4double dy = 5./G4float(NBIN) ;
G4double ymin=log(log(GammaEnergyCut/CutFixed)/log(KineticEnergy/CutFixed)) ;
if(ymin < ysmall)
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
// sampling using tables
//G4double v,xc,x,yc,y ;
//G4int iZ,iT,iy ;
G4double v,x,y ;
G4int iy;
// select sampling table ;
G4double lnZ = log(anElement->GetZ()) ;
G4double delmin = 1.e10 ;
G4double del ;
G4int izz = 0;
G4int itt = 0;
G4int NBINminus1;
NBINminus1 = NBIN-1 ;
for (G4int iz=0; iz<nzdat; iz++)
{
del = fabs(lnZ-log(zdat[iz])) ;
if(del<delmin)
{
delmin=del ;
izz=iz ;
}
}
delmin = 1.e10 ;
for (G4int it=0; it<ntdat; it++)
{
del = fabs(log(KineticEnergy)-log(tdat[it])) ;
if(del<delmin)
{
delmin=del;
itt=it ;
}
}
G4int iymin = G4int((ymin+5.)/dy+0.5) ;
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 += 1 ;
} 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] ) ;
}
x = exp(y) ;
v = CutFixed*exp(x*log(KineticEnergy/CutFixed)) ;
if( v <= 0.)
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
// 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 .....
G4double Teta = electron_mass_c2/TotalEnergy ;
G4double Phi = twopi * G4UniformRand() ;
G4double dirx = sin(Teta)*cos(Phi) , diry = sin(Teta)*sin(Phi) ,
dirz = cos(Teta) ;
G4ThreeVector GammaDirection ( dirx, diry, dirz);
GammaDirection.rotateUz(ParticleDirection);
G4DynamicParticle* aGamma= new G4DynamicParticle (G4Gamma::Gamma(),
GammaDirection, GammaEnergy);
aParticleChange.SetNumberOfSecondaries(1);
aParticleChange.AddSecondary(aGamma);
// Update the incident particle
G4double NewKinEnergy = KineticEnergy - GammaEnergy;
if (NewKinEnergy > 0.)
{
aParticleChange.ProposeMomentumDirection(ParticleDirection);
aParticleChange.ProposeEnergy(NewKinEnergy);
aParticleChange.ProposeLocalEnergyDeposit (0.);
}
else
{
aParticleChange.ProposeEnergy(0.);
aParticleChange.ProposeLocalEnergyDeposit (0.);
aParticleChange.ProposeTrackStatus(fStopButAlive);
}
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const G4Element* G4MuBremsstrahlung52::SelectRandomAtom(
const G4MaterialCutsCouple* couple) const
{
// select randomly 1 element within the material
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]);
for ( G4int i=0; i < NumberOfElements; i++ )
if (rval <= (*PartialSumSigma[index])[i]) return ((*theElementVector)[i]);
G4cout << " WARNING !!! - The Material " << aMaterial->GetName()
<< " has no elements, NULL pointer returned." << G4endl;
return NULL;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuBremsstrahlung52::PrintInfoDefinition()
{
G4String comments = "theoretical cross section \n ";
comments += " Good description up to 1000 PeV.";
G4cout << G4endl << GetProcessName() << ": " << comments
<< "\n PhysicsTables from " << G4BestUnit(LowerBoundLambda,
"Energy")
<< " to " << G4BestUnit(UpperBoundLambda,"Energy")
<< " in " << NbinLambda << " bins. \n";
G4cout << " WARNING: This process is obsolete and will be soon removed"
<< G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4MuBremsstrahlungModel.cc,v 1.21 2006/06/29 19:49:42 gunter Exp $
// GEANT4 tag $Name: geant4-08-02 $
// $Id: G4MuBremsstrahlungModel.cc,v 1.22 2007/05/22 17:35:58 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// -------------------------------------------------------------------
//
@@ -497,17 +497,17 @@ void G4MuBremsstrahlungModel::MakeSamplingTables()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
vector<G4DynamicParticle*>* G4MuBremsstrahlungModel::SampleSecondaries(
const G4MaterialCutsCouple* couple,
const G4DynamicParticle* dp,
G4double tmin,
G4double maxEnergy)
void G4MuBremsstrahlungModel::SampleSecondaries(std::vector<G4DynamicParticle*>* vdp,
const G4MaterialCutsCouple* couple,
const G4DynamicParticle* dp,
G4double tmin,
G4double maxEnergy)
{
G4double kineticEnergy = dp->GetKineticEnergy();
// check against insufficient energy
G4double tmax = min(kineticEnergy, maxEnergy);
if(tmin >= tmax) return 0;
if(tmin >= tmax) return;
static const G4double ysmall = -100. ;
static const G4double ytablelow = -5. ;
@@ -525,7 +525,7 @@ vector<G4DynamicParticle*>* G4MuBremsstrahlungModel::SampleSecondaries(
// This sampling should be checked!!! VI
G4double ymin=log(log(tmin/cutFixed)/log(tmax/cutFixed));
if(ymin < ysmall) return 0;
if(ymin < ysmall) return;
// sampling using tables
@@ -614,11 +614,8 @@ vector<G4DynamicParticle*>* G4MuBremsstrahlungModel::SampleSecondaries(
fParticleChange->SetProposedMomentumDirection(partDirection);
// save secondary
G4DynamicParticle* aGamma = new G4DynamicParticle(theGamma,gDirection,gEnergy);
vector<G4DynamicParticle*>* vdp = new vector<G4DynamicParticle*>;
G4DynamicParticle* aGamma = new G4DynamicParticle(theGamma,gDirection,gEnergy);
vdp->push_back(aGamma);
return vdp;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4MuIonisation.cc,v 1.53 2006/06/29 19:49:44 gunter Exp $
// GEANT4 tag $Name: geant4-08-02 $
// $Id: G4MuIonisation.cc,v 1.54 2007/05/22 17:35:58 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// -------------------------------------------------------------------
//
@@ -98,10 +98,6 @@ G4MuIonisation::G4MuIonisation(const G4String& name)
theBaseParticle(0),
isInitialised(false)
{
SetDEDXBinning(120);
SetLambdaBinning(120);
SetMinKinEnergy(0.1*keV);
SetMaxKinEnergy(100.0*TeV);
SetStepFunction(0.2, 1*mm);
SetIntegral(true);
SetVerboseLevel(1);
@@ -1,583 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4MuIonisation52.cc,v 1.6 2006/10/16 15:31:01 vnivanch Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
// --------------- G4MuIonisation52 physics process ------------------------------
// by Laszlo Urban, September 1997
// -----------------------------------------------------------------------------
//
// 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)
// 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)
// 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)
// 08-08-03 This class is frozen at the release 5.2 (V.Ivanchenko)
// 08-11-04 Remove interface of Store/Retrieve tables (V.Ivantchenko)
// -----------------------------------------------------------------------------
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "G4MuIonisation52.hh"
#include "G4UnitsTable.hh"
#include "G4ProductionCutsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuIonisation52::LowerBoundLambda = 1.*keV;
G4double G4MuIonisation52::UpperBoundLambda = 1000000.*TeV;
G4int G4MuIonisation52::NbinLambda = 150;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
using namespace std;
G4MuIonisation52::G4MuIonisation52(const G4String& processName)
: G4VMuEnergyLoss(processName),
theMeanFreePathTable(0)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4MuIonisation52::~G4MuIonisation52()
{
if (theMeanFreePathTable) {
theMeanFreePathTable->clearAndDestroy(); delete theMeanFreePathTable;}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuIonisation52::SetLowerBoundLambda(G4double val)
{LowerBoundLambda = val;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuIonisation52::SetUpperBoundLambda(G4double val)
{UpperBoundLambda = val;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuIonisation52::SetNbinLambda(G4int n)
{NbinLambda = n;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuIonisation52::GetLowerBoundLambda()
{ return LowerBoundLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuIonisation52::GetUpperBoundLambda()
{ return UpperBoundLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4int G4MuIonisation52::GetNbinLambda()
{return NbinLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuIonisation52::BuildPhysicsTable(const G4ParticleDefinition& ParticleType)
// just call BuildLossTable+BuildLambdaTable
{
if( !CutsWhereModified() && theLossTable) return;
// get bining from EnergyLoss
LowestKineticEnergy = GetLowerBoundEloss();
HighestKineticEnergy = GetUpperBoundEloss();
TotBin = GetNbinEloss();
BuildLossTable(ParticleType);
if (ParticleType.GetPDGCharge() > 0.)
{
RecorderOfmuplusProcess[CounterOfmuplusProcess] = (*this).theLossTable;
CounterOfmuplusProcess++;
}
else
{
RecorderOfmuminusProcess[CounterOfmuminusProcess] = (*this).theLossTable;
CounterOfmuminusProcess++;
}
BuildLambdaTable(ParticleType);
G4VMuEnergyLoss::BuildDEDXTable(ParticleType);
if(&ParticleType == G4MuonPlus::MuonPlus()) PrintInfoDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuIonisation52::BuildLossTable(const G4ParticleDefinition& aParticleType)
{
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
if (theLossTable) {theLossTable->clearAndDestroy(); delete theLossTable;}
theLossTable = new G4PhysicsTable(numOfCouples);
secondaryEnergyCuts = theCoupleTable->GetEnergyCutsVector(1);
// loop for materials
//
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);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuIonisation52::BuildLambdaTable(const G4ParticleDefinition& aParticleType)
{
if(0 < verboseLevel) {
G4cout << "G4MuIonisation52::BuildLambdaTable() for process "
<< GetProcessName() << " and particle "
<< aParticleType.GetParticleName() << G4endl;
}
//create table
//
const G4ProductionCutsTable* theCoupleTable=
G4ProductionCutsTable::GetProductionCutsTable();
size_t numOfCouples = theCoupleTable->GetTableSize();
if (theMeanFreePathTable)
{ theMeanFreePathTable->clearAndDestroy(); delete theMeanFreePathTable;}
theMeanFreePathTable = new G4PhysicsTable(numOfCouples);
secondaryEnergyCuts = theCoupleTable->GetEnergyCutsVector(1);
// loop for materials
for (size_t J=0 ; J < numOfCouples; J++)
{
//create physics vector then fill it ....
G4PhysicsLogVector* aVector = new G4PhysicsLogVector(
LowerBoundLambda,UpperBoundLambda,NbinLambda);
// compute the (macroscopic) cross section first
const 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 = SecondaryEnergyThreshold(J);
for ( G4int i = 0 ; i < NbinLambda ; i++ )
{
G4double LowEdgeEnergy = aVector->GetLowEdgeEnergy(i);
G4double sigma = 0.;
for (G4int iel=0; iel<NumberOfElements; iel++ )
{
sigma += NbOfAtomsPerVolume[iel]*
ComputeCrossSectionPerAtom(aParticleType,
LowEdgeEnergy,
(*theElementVector)[iel]->GetZ(),
DeltaThreshold);
}
// mean free path = 1./macroscopic cross section
G4double Value = sigma > DBL_MIN ? 1./sigma : DBL_MAX;
aVector->PutValue(i, Value);
}
theMeanFreePathTable->insert(aVector);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuIonisation52::ComputeRestrictedMeandEdx (
const G4ParticleDefinition& aParticleType,
G4double KineticEnergy,
const G4Material* material,
G4double DeltaThreshold)
{
// calculate the dE/dx due to the ionization process (Geant4 internal units)
// Bethe-Bloch formula
//
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;
G4double Tmax=2.*electron_mass_c2*bg2/(1.+2.*gamma*RateMass+RateMass*RateMass);
G4double taul = material->GetIonisation()->GetTaul();
G4double dEdx = 0.;
//
// high energy part , Bethe-Bloch formula
//
if (tau > taul)
{
G4double rcut = min(DeltaThreshold/Tmax, 1.);
dEdx = log(2.*electron_mass_c2*bg2*Tmax/Eexc2)
+log(rcut)-(1.+rcut)*beta2;
//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.);
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
G4double* ShellCorrectionVector = material->GetIonisation()->
GetShellCorrectionVector();
const G4double bg2lim = 0.0169, taulim = 8.4146e-3;
G4double sh = 0., xs = 1.;
if (bg2 > bg2lim) for (G4int k=0; k<3; k++)
{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);
}
// now you can compute the total ionization loss
dEdx -= (delta + sh); dEdx /= beta2;
// 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;
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,
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())
dEdx += NbOfAtomsPerVolume[iel]
*(element->GetIonisation()->GetAlow()*sqrt(tau)
+ element->GetIonisation()->GetBlow()*tau);
else
dEdx += NbOfAtomsPerVolume[iel]
* element->GetIonisation()->GetClow()/sqrt(tau);
}
G4double deltaloss = 0.;
if (DeltaThreshold < Tmax)
{
deltaloss = log(Tmax/DeltaThreshold)-
beta2*(1.-DeltaThreshold/Tmax) ;
if (aParticleType.GetPDGSpin() == 0.5)
deltaloss += 0.25*(Tmax-DeltaThreshold)*(Tmax-DeltaThreshold)/
(KineticEnergy*KineticEnergy+proton_mass_c2*proton_mass_c2);
deltaloss *= twopi_mc2_rcl2*ElectronDensity/beta2;
}
dEdx -= deltaloss;
if (dEdx < 0.) dEdx = 0.;
}
return dEdx;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuIonisation52::ComputeCrossSectionPerAtom(
const G4ParticleDefinition& aParticleType,
G4double KineticEnergy,
G4double AtomicNumber,
G4double DeltaThreshold)
{
// calculates the totalcross section per atom in GEANT4 internal units
// ( it is called for elements , AtomicNumber = Z )
//
G4double particleMass = aParticleType.GetPDGMass();
G4double TotalEnergy = KineticEnergy + particleMass;
G4double tempvar = particleMass+electron_mass_c2;
G4double KnockonMaxEnergy = 2.*electron_mass_c2*KineticEnergy
*(TotalEnergy+particleMass)
/(tempvar*tempvar+2.*electron_mass_c2*KineticEnergy);
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;
const G4int k2 = 2;
G4double aaa = log(DeltaThreshold);
G4double bbb = log(KnockonMaxEnergy);
G4int kkk = int((bbb-aaa)/ak1)+k2;
G4double hhh = (bbb-aaa)/kkk;
G4double step = exp(hhh);
G4double ymax = 1./KnockonMaxEnergy;
for (G4int k=0; k<kkk; k++)
{
G4double ymin = ymax;
ymax = ymin*step;
G4double hhy = ymax-ymin;
for (G4int i=0; i<4; i++)
{
G4double y = ymin+hhy*xgi[i];
G4double ep = 1./y ;
TotalCrossSection += ep*ep*wgi[i]*hhy*
ComputeDifCrossSectionPerAtom(
aParticleType,KineticEnergy,
AtomicNumber,ep);
}
}
return TotalCrossSection;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuIonisation52::ComputeDifCrossSectionPerAtom(
const G4ParticleDefinition& ParticleType,
G4double KineticEnergy, G4double AtomicNumber,
G4double KnockonEnergy)
// Calculates the differential cross section per atom
// using the cross section formula of R.P. Kokoulin (10/98)
{
const G4double alphaprime = fine_structure_const/twopi;
G4double particleMass = ParticleType.GetPDGMass();
G4double TotalEnergy = KineticEnergy + particleMass;
G4double betasquare = KineticEnergy*(TotalEnergy+particleMass)
/(TotalEnergy*TotalEnergy);
G4double tempvar = particleMass+electron_mass_c2;
G4double KnockonMaxEnergy = 2.*electron_mass_c2*KineticEnergy
*(TotalEnergy+particleMass)
/(tempvar*tempvar+2.*electron_mass_c2*KineticEnergy);
G4double DifCrossSection = 0.;
if(KnockonEnergy >= KnockonMaxEnergy) return DifCrossSection;
G4double v = KnockonEnergy/TotalEnergy;
DifCrossSection = twopi_mc2_rcl2*AtomicNumber*
(1.-betasquare*KnockonEnergy/KnockonMaxEnergy+0.5*v*v)/
(betasquare*KnockonEnergy*KnockonEnergy);
G4double a1 = log(1.+2.*KnockonEnergy/electron_mass_c2);
G4double a3 = log(4.*TotalEnergy*(TotalEnergy-KnockonEnergy)/
(particleMass*particleMass));
DifCrossSection *= (1.+alphaprime*a1*(a3-a1));
return DifCrossSection;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange* G4MuIonisation52::PostStepDoIt(const G4Track& trackData,
const G4Step& stepData)
{
aParticleChange.Initialize(trackData);
const G4MaterialCutsCouple* couple = trackData.GetMaterialCutsCouple();
const G4DynamicParticle* aParticle = trackData.GetDynamicParticle();
G4double particleMass = aParticle->GetDefinition()->GetPDGMass();
G4double KineticEnergy = aParticle->GetKineticEnergy();
G4double TotalEnergy = KineticEnergy + particleMass;
G4double Psquare = KineticEnergy*(TotalEnergy+particleMass);
G4double Esquare = TotalEnergy*TotalEnergy;
G4double betasquare=Psquare/Esquare;
G4double summass = particleMass + electron_mass_c2;
G4double MaxKineticEnergyTransfer = 2.*electron_mass_c2*Psquare
/(summass*summass+2.*electron_mass_c2*KineticEnergy);
G4ParticleMomentum ParticleDirection = aParticle->GetMomentumDirection();
// get electron cut in kinetic energy
G4double DeltaThreshold = SecondaryEnergyThreshold(couple->GetIndex());
// sampling kinetic energy of the delta ray
//
if (MaxKineticEnergyTransfer <= DeltaThreshold)
// pathological case (it should not happen, there is no change at all)
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
// normal case
G4double xc = DeltaThreshold/MaxKineticEnergyTransfer;
G4double rate = MaxKineticEnergyTransfer/TotalEnergy;
G4double te2 = 0.5*rate*rate;
// sampling follows ...
G4double x,twoep,a1,grej;
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;
a1 = log(1.+twoep/electron_mass_c2);
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.)
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
G4double DeltaTotalMomentum = sqrt(DeltaKineticEnergy * (DeltaKineticEnergy +
2. * electron_mass_c2 ));
G4double TotalMomentum = sqrt(Psquare);
G4double costheta = DeltaKineticEnergy * (TotalEnergy + electron_mass_c2)
/(DeltaTotalMomentum * TotalMomentum);
if (costheta < -1.) costheta = -1.;
if (costheta > +1.) costheta = +1.;
// direction of the delta electron
//
G4double phi = twopi * G4UniformRand();
G4double sintheta = sqrt((1.+costheta)*(1.-costheta));
G4double dirx = sintheta*cos(phi), diry = sintheta*sin(phi), dirz = costheta;
G4ThreeVector DeltaDirection(dirx,diry,dirz);
DeltaDirection.rotateUz(ParticleDirection);
// create G4DynamicParticle object for delta ray
//
G4DynamicParticle *theDeltaRay = new G4DynamicParticle;
theDeltaRay->SetKineticEnergy( DeltaKineticEnergy );
theDeltaRay->SetMomentumDirection(
DeltaDirection.x(),DeltaDirection.y(),DeltaDirection.z());
theDeltaRay->SetDefinition(G4Electron::Electron());
// fill aParticleChange
//
G4double finalKineticEnergy = KineticEnergy - DeltaKineticEnergy;
if (finalKineticEnergy > 0.)
{
G4double finalPx = TotalMomentum*ParticleDirection.x()
- DeltaTotalMomentum*DeltaDirection.x();
G4double finalPy = TotalMomentum*ParticleDirection.y()
- DeltaTotalMomentum*DeltaDirection.y();
G4double finalPz = TotalMomentum*ParticleDirection.z()
- DeltaTotalMomentum*DeltaDirection.z();
G4double finalMomentum =
sqrt(finalPx*finalPx+finalPy*finalPy+finalPz*finalPz);
finalPx /= finalMomentum;
finalPy /= finalMomentum;
finalPz /= finalMomentum;
aParticleChange.ProposeMomentumDirection(finalPx,finalPy,finalPz);
}
else
{
finalKineticEnergy = 0.;
aParticleChange.ProposeTrackStatus(fStopButAlive);
}
aParticleChange.ProposeEnergy( finalKineticEnergy );
aParticleChange.SetNumberOfSecondaries(1);
aParticleChange.AddSecondary(theDeltaRay);
aParticleChange.ProposeLocalEnergyDeposit (0.);
//ResetNumberOfInteractionLengthLeft();
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuIonisation52::PrintInfoDefinition()
{
G4String comments = " Knock-on electron cross sections . "
"\n Good description above the mean excitation energy.\n"
" delta ray energy sampled from differential Xsection.";
G4cout << G4endl << GetProcessName() << ": " << comments
<< "\n PhysicsTables from " << G4BestUnit(LowerBoundLambda,
"Energy")
<< " to " << G4BestUnit(UpperBoundLambda,"Energy")
<< " in " << NbinLambda << " bins. \n";
G4cout << " WARNING: This process is obsolete and will be soon removed"
<< G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4MuPairProduction.cc,v 1.47 2006/06/29 19:49:48 gunter Exp $
// GEANT4 tag $Name: geant4-08-02 $
// $Id: G4MuPairProduction.cc,v 1.48 2007/05/22 17:35:58 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// -------------------------------------------------------------------
//
@@ -88,12 +88,7 @@ G4MuPairProduction::G4MuPairProduction(const G4String& name)
theBaseParticle(0),
lowestKinEnergy(1.*GeV),
isInitialised(false)
{
SetDEDXBinning(120);
SetLambdaBinning(120);
SetMinKinEnergy(0.1*keV);
SetMaxKinEnergy(100.0*TeV);
}
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
@@ -1,922 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4MuPairProduction52.cc,v 1.6 2006/10/16 15:31:01 vnivanch Exp $
// GEANT4 tag $Name: geant4-08-02 $
//
//--------------- G4MuPairProduction52 physics process ---------------------------
// by Laszlo Urban, May 1998
//------------------------------------------------------------------------------
// 04-06-98 in DoIt,secondary production condition:
// range>std::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
// 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:
// if(MaxPairEnergy<CutInPairEnergy) MaxPairEnergy=CutInPairEnergy
// 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)
// 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)
// 08-08-03 This class is frozen at the release 5.2 (V.Ivanchenko)
// 08-11-04 Remove interface of Store/Retrieve tables (V.Ivantchenko)
//------------------------------------------------------------------------------
#include "G4MuPairProduction52.hh"
#include "G4EnergyLossTables.hh"
#include "G4UnitsTable.hh"
#include "G4ProductionCutsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// static members
G4int G4MuPairProduction52::nzdat = 5 ;
G4double G4MuPairProduction52::zdat[]={1.,4.,13.,26.,92.};
G4int G4MuPairProduction52::ntdat = 8 ;
G4double G4MuPairProduction52::tdat[]={1.e3,1.e4,1.e5,1.e6,1.e7,1.e8,1.e9,1.e10};
G4int G4MuPairProduction52::NBIN = 1000 ; //100 ;
G4double G4MuPairProduction52::ya[1001];
G4double G4MuPairProduction52::proba[5][8][1001];
G4double G4MuPairProduction52::MinPairEnergy = 4.*electron_mass_c2;
G4double G4MuPairProduction52::LowerBoundLambda = 1.*keV;
G4double G4MuPairProduction52::UpperBoundLambda = 1000000.*TeV;
G4int G4MuPairProduction52::NbinLambda = 150;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
using namespace std;
G4MuPairProduction52::G4MuPairProduction52(const G4String& processName)
: G4VMuEnergyLoss(processName),
theMeanFreePathTable(NULL)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4MuPairProduction52::~G4MuPairProduction52()
{
if (theMeanFreePathTable) {
theMeanFreePathTable->clearAndDestroy();
delete theMeanFreePathTable;
}
PartialSumSigma.clearAndDestroy();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuPairProduction52::SetLowerBoundLambda(G4double val)
{LowerBoundLambda = val;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuPairProduction52::SetUpperBoundLambda(G4double val)
{UpperBoundLambda = val;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuPairProduction52::SetNbinLambda(G4int n)
{NbinLambda = n;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuPairProduction52::GetLowerBoundLambda()
{ return LowerBoundLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuPairProduction52::GetUpperBoundLambda()
{ return UpperBoundLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4int G4MuPairProduction52::GetNbinLambda()
{return NbinLambda;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuPairProduction52::BuildPhysicsTable(
const G4ParticleDefinition& aParticleType)
// just call BuildLossTable+BuildLambdaTable
{
/*
G4cout << "G4MuPairProduction52: theLossTable= " << theLossTable
<< " for " << aParticleType.GetParticleName()
<< " cutsWereMod= " << CutsWhereModified()
<< G4endl;
*/
if( !CutsWhereModified() && theLossTable) return;
LowestKineticEnergy = GetLowerBoundEloss() ;
HighestKineticEnergy = GetUpperBoundEloss() ;
TotBin = GetNbinEloss() ;
BuildLossTable(aParticleType) ;
if(&aParticleType==G4MuonMinus::MuonMinus())
{
RecorderOfmuminusProcess[CounterOfmuminusProcess] = (*this).theLossTable ;
CounterOfmuminusProcess++;
}
else
{
RecorderOfmuplusProcess[CounterOfmuplusProcess] = (*this).theLossTable ;
CounterOfmuplusProcess++;
}
// sampling table should be made only once !
if( !theMeanFreePathTable ) MakeSamplingTables(&aParticleType);
BuildLambdaTable(aParticleType) ;
G4VMuEnergyLoss::BuildDEDXTable(aParticleType);
if(&aParticleType==G4MuonPlus::MuonPlus()) PrintInfoDefinition();
/*
G4cout << "G4MuPairProduction52: theLossTable= " << theLossTable
<< " theLambda= " << theMeanFreePathTable
<< " for " << aParticleType.GetParticleName()
<< G4endl;
*/
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuPairProduction52::BuildLossTable(
const G4ParticleDefinition& aParticleType)
{
G4double KineticEnergy,TotalEnergy,pairloss,Z,
loss,natom,eCut,pCut ;
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();
// loop for materials
//
for (size_t J=0; J<numOfCouples; J++)
{
G4PhysicsLogVector* aVector = new G4PhysicsLogVector(
LowestKineticEnergy,HighestKineticEnergy,TotBin);
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 =
material->GetAtomicNumDensityVector() ;
const G4int NumberOfElements =
material->GetNumberOfElements() ;
for (G4int i=0; i<TotBin; i++)
{
KineticEnergy = aVector->GetLowEdgeEnergy(i) ;
TotalEnergy = KineticEnergy+particleMass ;
eCut = electronCut;
pCut = positronCut;
if(eCut>KineticEnergy)
eCut = KineticEnergy ;
if(pCut>KineticEnergy)
pCut = KineticEnergy ;
pairloss = 0.;
for (G4int iel=0; iel<NumberOfElements; iel++)
{
Z=(*theElementVector)[iel]->GetZ();
natom = theAtomicNumDensityVector[iel] ;
loss = ComputePairLoss(&aParticleType,
Z,KineticEnergy,eCut,pCut) ;
pairloss += natom*loss ;
}
if(pairloss<0.)
pairloss = 0. ;
aVector->PutValue(i,pairloss);
}
theLossTable->insert(aVector);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuPairProduction52::ComputePairLoss(
const G4ParticleDefinition* ParticleType,
G4double AtomicNumber,
G4double KineticEnergy,
G4double ElectronEnergyCut,
G4double PositronEnergyCut)
{
static const G4double
xgi[] ={ 0.0199,0.1017,0.2372,0.4083,0.5917,0.7628,0.8983,0.9801 };
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 ;
static const G4double sqrte = sqrt(exp(1.)) ;
G4double z13 = exp(log(AtomicNumber)/3.) ;
G4double loss = 0.0 ;
if ( AtomicNumber < 1. ) return loss;
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 )
CutInPairEnergy = MaxPairEnergy ;
if(CutInPairEnergy <= MinPairEnergy) return loss ;
G4double aaa,bbb,hhh,x,epln,ep ;
G4int kkk ;
// 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 ;
for (G4int ll=0; ll<8; ll++)
{
epln=x+xgi[ll]*hhh ;
ep = exp(epln) ;
loss += wgi[ll]*ep*ep*ComputeDMicroscopicCrossSection(ParticleType,
KineticEnergy,AtomicNumber,
ep) ;
}
}
loss *= hhh ;
if (loss < 0.) loss = 0.;
return loss ;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuPairProduction52::BuildLambdaTable(
const G4ParticleDefinition& aParticleType)
{
/*
G4cout << "G4MuPairProduction52::BuildLambdaTable= " << theMeanFreePathTable
<< " for " << aParticleType.GetParticleName()
<< G4endl;
*/
G4double LowEdgeEnergy , Value;
G4double FixedEnergy = (LowestKineticEnergy + HighestKineticEnergy)/2. ;
//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(numOfCouples);
G4PhysicsLogVector* ptrVector;
for ( size_t J=0; J<numOfCouples; J++ )
{
ptrVector = new G4PhysicsLogVector(
LowerBoundLambda,UpperBoundLambda,NbinLambda);
const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(J);
for ( G4int i = 0 ; i < NbinLambda ; i++ )
{
LowEdgeEnergy = ptrVector->GetLowEdgeEnergy( i ) ;
Value = ComputeMeanFreePath( &aParticleType, LowEdgeEnergy, couple);
ptrVector->PutValue( i , Value ) ;
}
theMeanFreePathTable->insertAt( J , ptrVector );
// Compute the PartialSumSigma table at a given fixed energy
ComputePartialSumSigma( &aParticleType, FixedEnergy, couple) ;
}
/*
G4cout << "Is done theTable= " << theMeanFreePathTable
<< " for " << aParticleType.GetParticleName()
<< G4endl;
*/
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuPairProduction52::ComputePartialSumSigma(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy,
const G4MaterialCutsCouple* couple)
{
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 eCut = (*electronEnergyCuts)[index] ;
G4double pCut = (*positronEnergyCuts)[index] ;
PartialSumSigma[index] = new G4DataVector();
G4double SIGMA = 0. ;
for ( G4int Ielem=0 ; Ielem < NbOfElements ; Ielem++ )
{
SIGMA += theAtomNumDensityVector[Ielem] *
ComputeMicroscopicCrossSection( ParticleType, KineticEnergy,
(*theElementVector)[Ielem]->GetZ(),
eCut,pCut );
PartialSumSigma[index]->push_back(SIGMA);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuPairProduction52::ComputeMicroscopicCrossSection(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy,
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 };
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 ;
static const G4double sqrte = sqrt(exp(1.)) ;
G4double z13 = exp(log(AtomicNumber)/3.) ;
G4double CrossSection = 0.0 ;
if ( AtomicNumber < 1. ) return CrossSection;
G4double CutInPairEnergy = ElectronEnergyCut+PositronEnergyCut
+2.*electron_mass_c2 ;
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 ;
G4double aaa,bbb,hhh,x,epln,ep ;
G4int kkk ;
// calculate the total cross section
// numerical integration in log(PairEnergy)
aaa = log(CutInPairEnergy) ;
bbb = log(MaxPairEnergy) ;
kkk = int((bbb-aaa)/ak1+ak2) ;
hhh = (bbb-aaa)/kkk ;
for (G4int l=0 ; l<kkk; l++)
{
x = aaa+hhh*l ;
for (G4int ll=0; ll<8; ll++)
{
epln = x+xgi[ll]*hhh;
ep = exp(epln) ;
CrossSection += wgi[ll]*ep*ComputeDMicroscopicCrossSection(ParticleType,
KineticEnergy,AtomicNumber,
ep) ;
}
}
CrossSection *= hhh ;
if (CrossSection < 0.) CrossSection = 0.;
return CrossSection;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuPairProduction52::MakeSamplingTables(
const G4ParticleDefinition* ParticleType)
{
G4int nbin;
G4double AtomicNumber,KineticEnergy ;
G4double c,y,ymin,ymax,dy,yy,dx,x,ep ;
static const G4double sqrte = sqrt(exp(1.)) ;
G4double particleMass = ParticleType->GetPDGMass();
for (G4int iz=0; iz<nzdat; iz++)
{
AtomicNumber = zdat[iz];
G4double z13 = exp(log(AtomicNumber)/3.) ;
for (G4int it=0; it<ntdat; it++)
{
KineticEnergy = tdat[it];
G4double MaxPairEnergy = KineticEnergy+particleMass*(1.-0.75*sqrte*z13) ;
G4double CrossSection = 0.0 ;
//G4int NbofIntervals ;
c = log(MaxPairEnergy/MinPairEnergy) ;
ymin = -5. ;
ymax = 0. ;
dy = (ymax-ymin)/NBIN ;
nbin=-1;
y = ymin - 0.5*dy ;
yy = ymin - dy ;
for (G4int i=0 ; i<NBIN; i++)
{
y += dy ;
x = exp(y) ;
yy += dy ;
dx = exp(yy+dy)-exp(yy) ;
ep = MinPairEnergy*exp(c*x) ;
CrossSection += ep*dx*ComputeDMicroscopicCrossSection(ParticleType,
KineticEnergy,AtomicNumber,ep);
if(nbin<NBIN)
{
nbin += 1 ;
ya[nbin]=y ;
proba[iz][it][nbin] = CrossSection ;
}
}
ya[NBIN]=0. ;
if(CrossSection > 0.)
{
for(G4int ib=0; ib<=nbin; ib++)
{
proba[iz][it][ib] /= CrossSection ;
}
}
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuPairProduction52::ComputeDDMicroscopicCrossSection(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy, G4double AtomicNumber,
G4double PairEnergy,G4double asymmetry)
// 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 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 ;
G4double TotalEnergy = KineticEnergy + particleMass ;
G4double z13 = exp(log(AtomicNumber)/3.) ;
G4double z23 = z13*z13 ;
G4double EnergyLoss = TotalEnergy - PairEnergy ;
G4double c3 = 3.*sqrte*particleMass/4. ;
G4double DDCrossSection = 0. ;
if(EnergyLoss <= c3*z13)
return DDCrossSection ;
G4double c7 = 4.*electron_mass_c2 ;
G4double c8 = 6.*particleMass*particleMass ;
G4double alf = c7/PairEnergy ;
G4double a3 = 1. - alf ;
if(a3 <= 0.)
return DDCrossSection ;
// zeta calculation
G4double bbb,g1,g2,zeta1,zeta2,zeta,z2 ;
if( AtomicNumber < 1.5 )
{
bbb = bbbh ;
g1 = g1h ;
g2 = g2h ;
}
else
{
bbb = bbbtf ;
g1 = g1tf ;
g2 = g2tf ;
}
zeta1 = 0.073 * log(TotalEnergy/(particleMass+g1*z23*TotalEnergy))-0.26 ;
if( zeta1 > 0.)
{
zeta2 = 0.058*log(TotalEnergy/(particleMass+g2*z13*TotalEnergy))-0.14 ;
zeta = zeta1/zeta2 ;
}
else
{
zeta = 0. ;
}
z2 = AtomicNumber*(AtomicNumber+zeta) ;
G4double screen0 = 2.*electron_mass_c2*sqrte*bbb/(z13*PairEnergy) ;
G4double a0 = TotalEnergy*EnergyLoss ;
G4double a1 = PairEnergy*PairEnergy/a0 ;
G4double bet = 0.5*a1 ;
G4double xi0 = 0.25*massratio2*a1 ;
G4double del = c8/a0 ;
G4double romin = 0. ;
G4double romax = (1.-del)*sqrt(1.-c7/PairEnergy) ;
if((asymmetry < romin) || (asymmetry > romax))
return DDCrossSection ;
G4double a4 = 1.-asymmetry ;
G4double a5 = a4*(2.-a4) ;
G4double a6 = 1.-a5 ;
G4double a7 = 1.+a6 ;
G4double a9 = 3.+a6 ;
G4double xi = xi0*a5 ;
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 ;
G4double ale=log(bbb/z13*sqrt(xi1*yel)/(1.+screen*yel)) ;
G4double cre = 0.5*log(1.+2.25/(massratio2*z23)*xi1*yel) ;
G4double be ;
if(xi <= 1.e3)
be = ((2.+a6)*(1.+bet)+xi*a9)*log(1.+xii)+(a5-bet)/xi1-a9;
else
be = (3.-a6+a1*a7)/(2.+xi) ;
G4double fe = (ale-cre)*be ;
if( fe < 0.)
fe = 0. ;
G4double ymu = 4.+a6 +3.*bet*a7 ;
G4double ymd = a7*(1.5+a1)*log(3.+xi)+1.-1.5*a6 ;
G4double ym1 = 1.+ymu/ymd ;
G4double alm_crm = log(bbb*massratio/(1.5*z23*(1.+screen*ym1))) ;
G4double a10,bm ;
if( xi >= 1.e-3)
{
a10 = (1.+a1)*a5 ;
bm = (a7*(1.+1.5*bet)-a10*xii)*log(xi1)+xi*(a5-bet)/xi1+a10 ;
}
else
bm = (5.-a6+bet*a9)*(xi/2.) ;
G4double fm = alm_crm*bm ;
if( fm < 0.)
fm = 0. ;
DDCrossSection = (fe+fm/massratio2) ;
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 G4MuPairProduction52::GetDMicroscopicCrossSection(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy, G4double AtomicNumber,
G4double PairEnergy)
{
return ComputeDMicroscopicCrossSection(ParticleType,KineticEnergy,
AtomicNumber,PairEnergy) ;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuPairProduction52::ComputeDMicroscopicCrossSection(
const G4ParticleDefinition* ParticleType,
G4double KineticEnergy, G4double AtomicNumber,
G4double PairEnergy)
// Calculates the differential (D) microscopic cross section
// using the cross section formula of R.P. Kokoulin (18/01/98)
{
static const G4double
xgi[] ={ 0.0199,0.1017,0.2372,0.4083,0.5917,0.7628,0.8983,0.9801 };
static const G4double
wgi[] ={ 0.0506,0.1112,0.1569,0.1813,0.1813,0.1569,0.1112,0.0506 };
G4double DCrossSection = 0. ;
G4double particleMass = ParticleType->GetPDGMass();
G4double TotalEnergy = KineticEnergy + particleMass;
G4double EnergyLoss = TotalEnergy - PairEnergy ;
G4double a = 6.*particleMass*particleMass/(TotalEnergy*EnergyLoss) ;
G4double b = 4.*electron_mass_c2/PairEnergy ;
if((b+2.*a*(1.-b))/(1.+(1.-a)*sqrt(1.-b)) <= 0.) return DCrossSection ;
G4double tmn=log((b+2.*a*(1.-b))/(1.+(1.-a)*sqrt(1.-b))) ;
// G4double DCrossSection = 0. ;
G4double ro ;
// Gaussian integration in ln(1-ro) ( with 8 points)
for (G4int i=0; i<7; i++)
{
ro = 1.-exp(tmn*xgi[i]) ;
DCrossSection += (1.-ro)*ComputeDDMicroscopicCrossSection(
ParticleType,KineticEnergy,
AtomicNumber,PairEnergy,ro)
*wgi[i] ;
}
DCrossSection *= -tmn ;
return DCrossSection ;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VParticleChange* G4MuPairProduction52::PostStepDoIt(const G4Track& trackData,
const G4Step& stepData)
{
static const G4double esq = sqrt(exp(1.));
aParticleChange.Initialize(trackData);
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 =
aDynamicParticle->GetMomentumDirection();
// e-e+ cut in this material
G4double eCut = (*electronEnergyCuts)[index] ;
G4double pCut = (*positronEnergyCuts)[index] ;
G4double CutInPairEnergy = eCut + pCut + 2.0*electron_mass_c2;
if (CutInPairEnergy < MinPairEnergy) CutInPairEnergy = MinPairEnergy ;
// check against insufficient energy
if(KineticEnergy < CutInPairEnergy )
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
// 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(MinPairEnergy >= MaxPairEnergy)
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
// sample e-e+ energy, pair energy first
G4double PairEnergy,xc,x,yc,y ;
// G4int iZ,iT;
G4int iy ;
// select sampling table ;
G4double lnZ = log(anElement->GetZ()) ;
G4double delmin = 1.e10 ;
G4double del ;
G4int izz = 0;
G4int itt = 0;
G4int NBINminus1 = NBIN-1;
for (G4int iz=0; iz<nzdat; iz++)
{
del = fabs(lnZ-log(zdat[iz])) ;
if(del<delmin)
{
delmin=del ;
izz=iz ;
}
}
delmin = 1.e10 ;
for (G4int it=0; it<ntdat; it++)
{
del = fabs(log(KineticEnergy)-log(tdat[it])) ;
if(del<delmin)
{
delmin=del;
itt=it ;
}
}
if( CutInPairEnergy <= MinPairEnergy)
iy = 0 ;
else
{
xc = log(CutInPairEnergy/MinPairEnergy)/log(MaxPairEnergy/MinPairEnergy) ;
yc = log(xc) ;
iy = -1 ;
do {
iy += 1 ;
} while ((ya[iy] < yc )&&(iy < NBINminus1)) ;
}
G4double norm = proba[izz][itt][iy] ;
G4double r = norm + G4UniformRand()*(1.-norm);
iy -= 1 ;
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];
x = exp(y);
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());
// 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 Phi = twopi * G4UniformRand();
G4double dirx = sin(Teta)*cos(Phi) , diry = sin(Teta)*sin(Phi) ,
dirz = cos(Teta);
G4double LocalEnerDeposit = 0.;
G4int numberofsecondaries = 1;
G4int flagelectron = 0;
G4int flagpositron = 1;
G4DynamicParticle* aParticle1 = 0;
G4DynamicParticle* aParticle2 = 0;
// e-
//
G4double ElectKineEnergy = ElectronEnergy - electron_mass_c2 ;
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;
if (PositKineEnergy < pCut)
{
LocalEnerDeposit += PositKineEnergy;
PositKineEnergy = 0.;
}
G4ThreeVector PositDirection ( -dirx, -diry, dirz );
PositDirection.rotateUz(ParticleDirection);
// create G4DynamicParticle object for the particle2
aParticle2= new G4DynamicParticle (G4Positron::Positron(),
PositDirection, PositKineEnergy);
// fill particle change and update initial particle
aParticleChange.SetNumberOfSecondaries(numberofsecondaries) ;
if (flagelectron==1) aParticleChange.AddSecondary(aParticle1);
if (flagpositron==1) aParticleChange.AddSecondary(aParticle2);
G4double NewKinEnergy = KineticEnergy - ElectronEnergy - PositronEnergy;
aParticleChange.ProposeMomentumDirection(ParticleDirection);
if (NewKinEnergy > 0.) aParticleChange.ProposeEnergy(NewKinEnergy);
else { aParticleChange.ProposeEnergy(0.);
aParticleChange.ProposeTrackStatus(fStopButAlive);
}
aParticleChange.ProposeLocalEnergyDeposit(LocalEnerDeposit);
//reset NumberOfinteractionLengthLeft()
return G4VContinuousDiscreteProcess::PostStepDoIt(trackData,stepData);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Element* G4MuPairProduction52::SelectRandomAtom(const G4MaterialCutsCouple* couple) const
{
// select randomly 1 element within the material
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]);
for ( G4int i=0; i < NumberOfElements; i++ )
{
if (rval <= (*PartialSumSigma[index])[i]) return ((*theElementVector)[i]);
}
G4cout << " WARNING !!! - The Material '"<< aMaterial->GetName()
<< "' has no elements, NULL pointer returned." << G4endl;
return 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuPairProduction52::PrintInfoDefinition()
{
G4String comments = "theoretical cross sections \n ";
comments += " Good description up to 1000 PeV.";
G4cout << G4endl << GetProcessName() << ": " << comments
<< "\n PhysicsTables from " << G4BestUnit(LowerBoundLambda,
"Energy")
<< " to " << G4BestUnit(UpperBoundLambda,"Energy")
<< " in " << NbinLambda << " bins. \n";
G4cout << " WARNING: This process is obsolete and will be soon removed"
<< G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4MuPairProductionModel.cc,v 1.31 2007/04/24 11:51:52 vnivanch Exp $
// GEANT4 tag $Name: geant4-08-03 $
// $Id: G4MuPairProductionModel.cc,v 1.33 2007/05/22 17:35:58 vnivanch Exp $
// GEANT4 tag $Name: geant4-09-00 $
//
// -------------------------------------------------------------------
//
@@ -56,8 +56,9 @@
// 03-08-05 Add SetParticle method (V.Ivantchenko)
// 23-10-05 Add protection in sampling of e+e- pair energy needed for
// low cuts (V.Ivantchenko)
// 13-02-06 add ComputeCrossSectionPerAtom (mma)
// 24-04-07 add protection in SelectAtom method (V.Ivantchenko)
// 13-02-06 Add ComputeCrossSectionPerAtom (mma)
// 24-04-07 Add protection in SelectRandomAtom method (V.Ivantchenko)
// 12-05-06 Updated sampling (use cut) in SelectRandomAtom (A.Bogdanov)
//
// Class Description:
@@ -470,11 +471,11 @@ void G4MuPairProductionModel::MakeSamplingTables()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
vector<G4DynamicParticle*>* G4MuPairProductionModel::SampleSecondaries(
const G4MaterialCutsCouple* couple,
const G4DynamicParticle* aDynamicParticle,
G4double tmin,
G4double tmax)
void G4MuPairProductionModel::SampleSecondaries(std::vector<G4DynamicParticle*>* vdp,
const G4MaterialCutsCouple* couple,
const G4DynamicParticle* aDynamicParticle,
G4double tmin,
G4double tmax)
{
G4double kineticEnergy = aDynamicParticle->GetKineticEnergy();
G4double totalEnergy = kineticEnergy + particleMass ;
@@ -487,13 +488,13 @@ vector<G4DynamicParticle*>* G4MuPairProductionModel::SampleSecondaries(
G4double dt = log(kineticEnergy/tdat[it-1])/log(tdat[it]/tdat[it-1]);
// select randomly one element constituing the material
const G4Element* anElement = SelectRandomAtom(kineticEnergy, dt, it, couple);
const G4Element* anElement = SelectRandomAtom(kineticEnergy, dt, it, couple, tmin);
SetCurrentElement(anElement->GetZ());
G4double maxPairEnergy = MaxSecondaryEnergy(particle,kineticEnergy);
G4double maxEnergy = std::min(tmax, maxPairEnergy);
G4double minEnergy = std::max(tmin, minPairEnergy);
if(minEnergy >= maxEnergy) return 0;
if(minEnergy >= maxEnergy) return;
//G4cout << "emin= " << minEnergy << " emax= " << maxEnergy
// << " minPair= " << minPairEnergy << " maxpair= " << maxPairEnergy
// << " ymin= " << ymin << " dy= " << dy << G4endl;
@@ -594,18 +595,15 @@ vector<G4DynamicParticle*>* G4MuPairProductionModel::SampleSecondaries(
kineticEnergy -= (ElectronEnergy + PositronEnergy);
fParticleChange->SetProposedKineticEnergy(kineticEnergy);
vector<G4DynamicParticle*>* vdp = new vector<G4DynamicParticle*>;
vdp->push_back(aParticle1);
vdp->push_back(aParticle2);
return vdp;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const G4Element* G4MuPairProductionModel::SelectRandomAtom(
G4double kinEnergy, G4double dt, G4int it,
const G4MaterialCutsCouple* couple)
const G4MaterialCutsCouple* couple, G4double tmin)
{
// select randomly 1 element within the material
@@ -628,18 +626,26 @@ const G4Element* G4MuPairProductionModel::SelectRandomAtom(
G4double Z = ((*theElementVector)[i])->GetZ();
SetCurrentElement(Z);
G4double maxPairEnergy = MaxSecondaryEnergy(particle,kinEnergy);
G4double minEnergy = std::max(tmin, minPairEnergy);
G4int iz;
for(iz=1; iz<nzdat; iz++) {if(Z <= zdat[iz]) break;}
if(iz == nzdat) iz--;
G4double dz = log(Z/zdat[iz-1])/log(zdat[iz]/zdat[iz-1]);
G4double xc = log(kinEnergy/minPairEnergy)/log(maxPairEnergy/minPairEnergy);
G4int iy = (G4int)((log(xc) - ymin)/dy);
if(iy >= nbiny) iy = nbiny-1;
G4double sigcut;
if(minEnergy <= minPairEnergy)
sigcut = 0.;
else
{
G4double xc = log(minEnergy/minPairEnergy)/log(maxPairEnergy/minPairEnergy);
G4int iy = (G4int)((log(xc) - ymin)/dy);
if(iy < 0) iy = 0;
if(iy >= nbiny) iy = nbiny-1;
sigcut = InterpolatedIntegralCrossSection(dt,dz,iz,it,iy, Z);
}
G4double sigtot = InterpolatedIntegralCrossSection(dt,dz,iz,it,nbiny,Z);
G4double sigcut = InterpolatedIntegralCrossSection(dt,dz,iz,it,iy, Z);
G4double dl = (sigtot - sigcut)*theAtomNumDensityVector[i];
// protection
@@ -1,747 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: G4VMuEnergyLoss.cc,v 1.32 2006/06/29 19:49:54 gunter Exp $
// GEANT4 tag $Name: geant4-08-02 $
// --------------------------------------------------------------
// GEANT 4 class implementation file
//
// History: first implementation, based on object model of
// 2nd December 1995, G.Cosmo
// ---------- G4VMuEnergyLoss physics process -----------
// by Laszlo Urban, September 1997
// **************************************************************
// It is the implementation of the NEW UNIFIED ENERGY LOSS PROCESS.
// It calculates the energy loss of muons.
// **************************************************************
//
// corrections by L.Urban on 27/05/98 (other corrs come soon!)
// 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
// 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)
// 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)
// --------------------------------------------------------------
#include "G4VMuEnergyLoss.hh"
#include "G4EnergyLossTables.hh"
#include "G4Poisson.hh"
#include "G4Navigator.hh"
#include "G4TransportationManager.hh"
#include "G4ProductionCutsTable.hh"
// Initialisation of static members *******************************************
G4int G4VMuEnergyLoss::NbOfProcesses = 3 ;
G4PhysicsTable** G4VMuEnergyLoss::RecorderOfmuplusProcess =
new G4PhysicsTable*[10] ;
G4PhysicsTable** G4VMuEnergyLoss::RecorderOfmuminusProcess =
new G4PhysicsTable*[10] ;
G4int G4VMuEnergyLoss::CounterOfmuplusProcess = 0 ;
G4int G4VMuEnergyLoss::CounterOfmuminusProcess = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::theDEDXmuplusTable = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::theRangemuplusTable = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::theInverseRangemuplusTable = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::theLabTimemuplusTable = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::theProperTimemuplusTable = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::theDEDXmuminusTable = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::theRangemuminusTable = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::theInverseRangemuminusTable = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::theLabTimemuminusTable = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::theProperTimemuminusTable = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::themuplusRangeCoeffATable = 0 ;
G4PhysicsTable* G4VMuEnergyLoss::themuplusRangeCoeffBTable = 0 ;
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 ;
G4double G4VMuEnergyLoss::RTable,G4VMuEnergyLoss::LOGRTable;
G4double G4VMuEnergyLoss::cN = 0.077*MeV*cm2/g ;
G4int G4VMuEnergyLoss::Ndeltamax = 100 ;
G4EnergyLossMessenger* G4VMuEnergyLoss::eLossMessenger = 0 ;
using namespace std;
G4VMuEnergyLoss::G4VMuEnergyLoss(const G4String& processName)
: G4VEnergyLoss (processName),
theLossTable(0),
theRangeCoeffATable(0),
theRangeCoeffBTable(0),
theRangeCoeffCTable(0)
{
}
G4VMuEnergyLoss::~G4VMuEnergyLoss()
{
if(theLossTable) {
theLossTable->clearAndDestroy();
delete theLossTable; theLossTable = 0;
}
}
void G4VMuEnergyLoss::SetNbOfProcesses(G4int nb) {NbOfProcesses=nb;}
// Sets number of processes giving contribution to the energy loss
void G4VMuEnergyLoss::PlusNbOfProcesses() {NbOfProcesses++ ;}
// Increases number of processes giving contribution to the energy loss
void G4VMuEnergyLoss::MinusNbOfProcesses() {NbOfProcesses-- ;}
// Decreases number of processes giving contribution to the energy loss
G4int G4VMuEnergyLoss::GetNbOfProcesses() {return NbOfProcesses;}
// Gets number of processes giving contribution to the energy loss
// ( default value = 3)
void G4VMuEnergyLoss::SetLowerBoundEloss(G4double val) {LowerBoundEloss=val;}
void G4VMuEnergyLoss::SetUpperBoundEloss(G4double val) {UpperBoundEloss=val;}
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)
{
// calculate data members LOGRTable,RTable first
G4double lrate = log(UpperBoundEloss/LowerBoundEloss);
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
if (finalRangeRequested > 0.) { finalRange = finalRangeRequested;}
G4bool MakeTable ;
ParticleMass = aParticleType.GetPDGMass() ;
G4double Charge = aParticleType.GetPDGCharge()/eplus ;
MakeTable = false ;
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.
if( Charge >0.)
{
RecorderOfProcess=RecorderOfmuplusProcess;
CounterOfProcess=CounterOfmuplusProcess;
if(CounterOfProcess == NbOfProcesses)
{
if(theDEDXmuplusTable)
{ theDEDXmuplusTable->clearAndDestroy();
delete theDEDXmuplusTable; }
theDEDXmuplusTable = new G4PhysicsTable(numOfCouples);
theDEDXTable = theDEDXmuplusTable;
}
}
else
{
RecorderOfProcess=RecorderOfmuminusProcess;
CounterOfProcess=CounterOfmuminusProcess;
if(CounterOfProcess == NbOfProcesses)
{
if(theDEDXmuminusTable)
{ theDEDXmuminusTable->clearAndDestroy();
delete theDEDXmuminusTable; }
theDEDXmuminusTable = new G4PhysicsTable(numOfCouples);
theDEDXTable = theDEDXmuminusTable;
}
}
if(CounterOfProcess == NbOfProcesses)
{
// loop for materials
G4double LowEdgeEnergy , Value ;
G4bool isOutRange ;
G4PhysicsTable* pointer ;
for (size_t J=0; J<numOfCouples; J++)
{
// create physics vector and fill it
G4PhysicsLogVector* aVector = new G4PhysicsLogVector(
LowerBoundEloss, UpperBoundEloss, NbinEloss);
// loop for the kinetic energy
for (G4int i=0; i<NbinEloss; i++)
{
LowEdgeEnergy = aVector->GetLowEdgeEnergy(i) ;
Value = 0. ;
for (G4int process=0; process < NbOfProcesses; process++)
{
pointer= RecorderOfProcess[process];
Value += (*pointer)[J]->
GetValue(LowEdgeEnergy,isOutRange) ;
}
aVector->PutValue(i,Value) ;
}
theDEDXTable->insert(aVector) ;
}
// reset counter to zero ..................
if( Charge >0.)
CounterOfmuplusProcess=0 ;
else
CounterOfmuminusProcess=0 ;
ParticleMass = aParticleType.GetPDGMass() ;
if(Charge > 0.)
{
// Build range table
theRangemuplusTable = BuildRangeTable(
theDEDXmuplusTable,theRangemuplusTable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
// Build lab/proper time tables
theLabTimemuplusTable = BuildLabTimeTable(theDEDXmuplusTable,
theLabTimemuplusTable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
theProperTimemuplusTable = BuildProperTimeTable(theDEDXmuplusTable,
theProperTimemuplusTable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
// Build coeff tables for the energy loss calculation
themuplusRangeCoeffATable = BuildRangeCoeffATable(theRangemuplusTable,
themuplusRangeCoeffATable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
themuplusRangeCoeffBTable = BuildRangeCoeffBTable(theRangemuplusTable,
themuplusRangeCoeffBTable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
themuplusRangeCoeffCTable = BuildRangeCoeffCTable(theRangemuplusTable,
themuplusRangeCoeffCTable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
// invert the range table
theInverseRangemuplusTable = BuildInverseRangeTable(theRangemuplusTable,
themuplusRangeCoeffATable,
themuplusRangeCoeffBTable,
themuplusRangeCoeffCTable,
theInverseRangemuplusTable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
}
else
{
// Build range table
theRangemuminusTable = BuildRangeTable(
theDEDXmuminusTable,theRangemuminusTable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
// Build lab/proper time tables
theLabTimemuminusTable = BuildLabTimeTable(theDEDXmuminusTable,
theLabTimemuminusTable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
theProperTimemuminusTable = BuildProperTimeTable(theDEDXmuminusTable,
theProperTimemuminusTable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
// Build coeff tables for the energy loss calculation
themuminusRangeCoeffATable = BuildRangeCoeffATable(theRangemuminusTable,
themuminusRangeCoeffATable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
themuminusRangeCoeffBTable = BuildRangeCoeffBTable(theRangemuminusTable,
themuminusRangeCoeffBTable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
themuminusRangeCoeffCTable = BuildRangeCoeffCTable(theRangemuminusTable,
themuminusRangeCoeffCTable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
// invert the range table
theInverseRangemuminusTable = BuildInverseRangeTable(theRangemuminusTable,
themuminusRangeCoeffATable,
themuminusRangeCoeffBTable,
themuminusRangeCoeffCTable,
theInverseRangemuminusTable,
LowerBoundEloss,UpperBoundEloss,NbinEloss);
// invert the range table
}
}
// make the energy loss and the range table available
G4EnergyLossTables::Register(&aParticleType,
(Charge > 0)? theDEDXmuplusTable: theDEDXmuminusTable,
(Charge > 0)? theRangemuplusTable: theRangemuminusTable,
(Charge > 0)? theInverseRangemuplusTable: theInverseRangemuminusTable,
(Charge > 0)? theLabTimemuplusTable: theLabTimemuminusTable,
(Charge > 0)? theProperTimemuplusTable: theProperTimemuminusTable,
LowerBoundEloss, UpperBoundEloss, 1.,NbinEloss);
// if((subSecFlag) && (aParticleType.GetParticleName()=="mu+"))
// {
// G4cout << G4endl;
// G4cout.precision(5) ;
// G4cout << " hIoni Minimum Delta cut in range=" << MinDeltaCutInRange/mm
// << " mm." << G4endl;
// G4cout << G4endl;
// G4cout << " material min.delta energy(keV) " << G4endl;
// G4cout << G4endl;
// }
if(MinDeltaEnergy) {delete [] MinDeltaEnergy; MinDeltaEnergy=0;}
MinDeltaEnergy = new G4double [numOfCouples];
if(LowerLimitForced) {delete [] LowerLimitForced; LowerLimitForced=0;}
LowerLimitForced = new G4bool [numOfCouples];
G4double Tlowerlimit = 1.*keV ;
for (size_t mat=0; mat<numOfCouples; mat++)
{
LowerLimitForced[mat] = false ;
// 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));
if(MinDeltaEnergy[mat]<Tlowerlimit) MinDeltaEnergy[mat] = Tlowerlimit ;
G4double ecut = (*(theCoupleTable->GetEnergyCutsVector(1)))[mat];
if(MinDeltaEnergy[mat]>ecut) MinDeltaEnergy[mat] = ecut;
// if((subSecFlag) && (aParticleType.GetParticleName()=="mu+"))
// {
// G4cout << setw(20) << (*theMaterialTable)[mat]->GetName()
// << setw(15) << MinDeltaEnergy[mat]/keV ;
// if(LowerLimitForced[mat])
// G4cout << " lower limit forced." << G4endl;
// else
// G4cout << G4endl ;
// }
}
}
}
G4double G4VMuEnergyLoss::GetConstraints(const G4DynamicParticle *aParticle,
const G4MaterialCutsCouple* couple)
{
// returns the Step limit
// dRoverRange is the max. allowed relative range loss in one Step
// it calculates dEdx and the range as well....
G4double KineticEnergy,StepLimit;
G4bool isOutRange ;
G4int bin ;
if(aParticle->GetDefinition()->GetPDGCharge()>0.)
{
theDEDXTable = theDEDXmuplusTable ;
theRangeTable = theRangemuplusTable ;
theRangeCoeffATable=themuplusRangeCoeffATable ;
theRangeCoeffBTable=themuplusRangeCoeffBTable ;
theRangeCoeffCTable=themuplusRangeCoeffCTable ;
}
else
{
theDEDXTable = theDEDXmuminusTable ;
theRangeTable = theRangemuminusTable ;
theRangeCoeffATable=themuminusRangeCoeffATable ;
theRangeCoeffBTable=themuminusRangeCoeffBTable ;
theRangeCoeffCTable=themuminusRangeCoeffCTable ;
}
G4double Thigh = UpperBoundEloss/RTable ;
KineticEnergy = aParticle->GetKineticEnergy();
bin = G4int(log(KineticEnergy/LowerBoundEloss)/LOGRTable) ;
EnergyBinNumber = bin ;
size_t index = couple->GetIndex() ;
if( KineticEnergy < LowerBoundEloss )
{
fdEdx = sqrt(KineticEnergy/LowerBoundEloss)*
(*theDEDXTable)(index)->GetValue(LowerBoundEloss,isOutRange) ;
fRangeNow = sqrt(KineticEnergy/LowerBoundEloss)*
(*theRangeTable)(index)->GetValue(LowerBoundEloss,isOutRange) ;
StepLimit = fRangeNow ;
}
else if (KineticEnergy > Thigh )
{
fdEdx = (*theDEDXTable)(index)->GetValue(Thigh,isOutRange);
fRangeNow = (*theRangeTable)(index)->GetValue(Thigh,isOutRange);
if (fdEdx > 0.) fRangeNow += (KineticEnergy-Thigh)/fdEdx;
StepLimit = c1lim*fRangeNow;
}
else
{
fdEdx = (*theDEDXTable)(index)->
GetValue(KineticEnergy,isOutRange) ;
RangeCoeffA = (*(*theRangeCoeffATable)(index))(EnergyBinNumber) ;
RangeCoeffB = (*(*theRangeCoeffBTable)(index))(EnergyBinNumber) ;
RangeCoeffC = (*(*theRangeCoeffCTable)(index))(EnergyBinNumber) ;
fRangeNow = (RangeCoeffA*KineticEnergy+RangeCoeffB)
*KineticEnergy+RangeCoeffC ;
// compute the Step limit ..............
G4double r = min(finalRange, couple->GetProductionCuts()
->GetProductionCut(idxG4ElectronCut));
if(fRangeNow>r)
{
StepLimit = dRoverRange*fRangeNow + r*(1.0 - dRoverRange)*(2.0 - r/fRangeNow);
// randomise this value
if(rndmStepFlag) StepLimit = r+(StepLimit-r)*G4UniformRand() ;
if(StepLimit > fRangeNow) StepLimit = fRangeNow ;
}
else
StepLimit = fRangeNow ;
}
return StepLimit ;
}
G4VParticleChange* G4VMuEnergyLoss::AlongStepDoIt(
const G4Track& trackData,const G4Step& stepData)
{
// compute the energy loss after a Step
static const G4double faclow = 1.5 ;
// get particle and material pointers from trackData
const G4DynamicParticle* aParticle = trackData.GetDynamicParticle();
G4double E = aParticle->GetKineticEnergy() ;
G4double Charge = aParticle->GetDefinition()->GetPDGCharge();
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 ;
G4double MeanLoss, finalT;
if (E < MinKineticEnergy) finalT = 0.;
else if ( E< faclow*LowerBoundEloss)
{
if (Step >= fRangeNow) finalT = 0.;
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,couple);
else finalT = G4EnergyLossTables::GetPreciseEnergyFromRange(
G4MuonPlus::MuonPlus(),fRangeNow-Step,couple);
}
}
if(finalT < MinKineticEnergy) finalT = 0. ;
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. ;
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)
&& (finalT > MinKineticEnergy))
{
// max. possible delta energy
Tmax = 2.*electron_mass_c2*E*(E+2.*mass)/
(mass*mass+2.*electron_mass_c2*(E+mass)+
electron_mass_c2*electron_mass_c2) ;
rcut=couple->GetProductionCuts()->GetProductionCut(1);
if (Tc > Tmax) Tc=Tmax ;
// generate subcutoff delta rays only if Tc>MinDeltaEnergyNow!
if ((Tc > MinDeltaEnergyNow) && (Tmax > MinDeltaEnergyNow))
{
presafety = stepData.GetPreStepPoint()->GetSafety() ;
// postsafety = stepData.GetPostStepPoint()->GetSafety() ;
G4Navigator *navigator=
G4TransportationManager::GetTransportationManager()
->GetNavigatorForTracking();
postsafety =
navigator->ComputeSafety(stepData.GetPostStepPoint()->GetPosition());
safety = 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))
{
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(),
min(presafety,postsafety),
couple) ;
// absolute lower limit for T0
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()*
((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->
GetMomentumDirection() ;
Px =ParticleDirection.x() ;
Py =ParticleDirection.y() ;
Pz =ParticleDirection.z() ;
G4int subdelta = 0;
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)) ;
aParticleChange.SetNumberOfSecondaries(N);
do {
subdelta += 1 ;
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 ;
//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)) ;
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;
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 ;
G4ThreeVector DeltaDirection(dirx,diry,dirz) ;
DeltaDirection.rotateUz(ParticleDirection);
G4DynamicParticle* theDelta = new G4DynamicParticle ;
theDelta->SetDefinition(G4Electron::Electron());
theDelta->SetKineticEnergy(T);
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;
G4Track* deltaTrack =
new G4Track(theDelta,DeltaTime,DeltaPosition);
deltaTrack->
SetTouchableHandle(stepData.GetPreStepPoint()->GetTouchableHandle()) ;
deltaTrack->SetParentID(trackData.GetTrackID()) ;
aParticleChange.AddSecondary(deltaTrack) ;
}
} while (subdelta<N) ;
// update the particle direction and kinetic energy
if(subdelta > 0)
aParticleChange.ProposeMomentumDirection(Px,Py,Pz) ;
E = Tkin ;
}
}
}
}
}
}
// end of subcutoff business
finalT = E - MeanLoss ;
if(finalT < MinKineticEnergy) finalT = 0. ;
//now the loss with fluctuation
if ((EnlossFlucFlag) && (finalT > 0.) && (finalT < E)&&(E > LowerBoundEloss))
{
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.ProposeTrackStatus(fStopButAlive);
}
// aParticleChange.SetNumberOfSecondaries(0);
aParticleChange.ProposeEnergy(finalT);
aParticleChange.ProposeLocalEnergyDeposit(E-finalT);
return &aParticleChange;
}