Import Geant4 10.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 11:51:14 +02:00
parent e2d2f9810a
commit 286caacf06
12421 changed files with 730077 additions and 502383 deletions
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: G4MuPairProductionModel.cc 74544 2013-10-14 12:40:29Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -83,19 +83,19 @@
#include "G4ProductionCutsTable.hh"
#include "G4ParticleChangeForLoss.hh"
#include "G4ParticleChangeForGamma.hh"
#include "G4Log.hh"
#include "G4Exp.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// static members
//
G4double G4MuPairProductionModel::zdat[]={1., 4., 13., 29., 92.};
G4double G4MuPairProductionModel::adat[]={1.01, 9.01, 26.98, 63.55, 238.03};
G4double G4MuPairProductionModel::tdat[]={1.e3, 1.e4, 1.e5, 1.e6, 1.e7, 1.e8,
1.e9, 1.e10};
G4double G4MuPairProductionModel::xgi[]={ 0.0199, 0.1017, 0.2372, 0.4083,
0.5917, 0.7628, 0.8983, 0.9801 };
G4double G4MuPairProductionModel::wgi[]={ 0.0506, 0.1112, 0.1569, 0.1813,
0.1813, 0.1569, 0.1112, 0.0506 };
const G4int G4MuPairProductionModel::zdat[]={1, 4, 13, 29, 92};
const G4double G4MuPairProductionModel::adat[]={1.01, 9.01,26.98, 63.55, 238.03};
const G4double G4MuPairProductionModel::xgi[]={ 0.0199, 0.1017, 0.2372, 0.4083,
0.5917, 0.7628, 0.8983, 0.9801 };
const G4double G4MuPairProductionModel::wgi[]={ 0.0506, 0.1112, 0.1569, 0.1813,
0.1813, 0.1569, 0.1112, 0.0506 };
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -107,21 +107,18 @@ G4MuPairProductionModel::G4MuPairProductionModel(const G4ParticleDefinition* p,
particle(0),
factorForCross(4.*fine_structure_const*fine_structure_const
*classic_electr_radius*classic_electr_radius/(3.*pi)),
sqrte(sqrt(exp(1.))),
sqrte(sqrt(G4Exp(1.))),
currentZ(0),
fParticleChange(0),
minPairEnergy(4.*electron_mass_c2),
lowestKinEnergy(GeV),
lowestKinEnergy(1.0*GeV),
nzdat(5),
ntdat(8),
nYBinPerDecade(4),
nbiny(1000),
nmaxElements(0),
nbine(0),
ymin(-5.),
ymax(0.),
dy((ymax-ymin)/nbiny),
samplingTablesAreFilled(false)
dy(0.005)
{
SetLowEnergyLimit(minPairEnergy);
nist = G4NistManager::Instance();
theElectron = G4Electron::Electron();
@@ -129,9 +126,14 @@ G4MuPairProductionModel::G4MuPairProductionModel(const G4ParticleDefinition* p,
particleMass = lnZ = z13 = z23 = 0;
for(size_t i=0; i<1001; ++i) { ya[i] = 0.0; }
if(p) { SetParticle(p); }
// setup lowest limit dependent on particle mass
if(p) {
SetParticle(p);
G4double limit = p->GetPDGMass()*8;
if(limit > lowestKinEnergy) { lowestKinEnergy = limit; }
}
emin = lowestKinEnergy;
emax = 10*TeV;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -141,33 +143,54 @@ G4MuPairProductionModel::~G4MuPairProductionModel()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuPairProductionModel::MinEnergyCut(const G4ParticleDefinition*,
const G4MaterialCutsCouple* )
G4double G4MuPairProductionModel::MinPrimaryEnergy(const G4Material*,
const G4ParticleDefinition*,
G4double cut)
{
return minPairEnergy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuPairProductionModel::MaxSecondaryEnergy(const G4ParticleDefinition*,
G4double kineticEnergy)
{
G4double maxPairEnergy = kineticEnergy + particleMass*(1.0 - 0.75*sqrte*z13);
return maxPairEnergy;
return std::max(lowestKinEnergy,cut);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4MuPairProductionModel::Initialise(const G4ParticleDefinition* p,
const G4DataVector&)
const G4DataVector& cuts)
{
if (!samplingTablesAreFilled) {
if(p) { SetParticle(p); }
MakeSamplingTables();
SetParticle(p);
// define scale of internal table for each thread only once
if(0 == nbine) {
emax = HighEnergyLimit();
emin = std::max(lowestKinEnergy, LowEnergyLimit());
nbine = size_t(nYBinPerDecade*std::log10(emax/emin));
if(nbine < 3) { nbine = 3; }
ymin = G4Log(minPairEnergy/emin);
dy = -ymin/G4double(nbiny);
}
if(IsMaster() && p == particle) {
if(!fElementData) {
fElementData = new G4ElementData();
MakeSamplingTables();
}
InitialiseElementSelectors(p, cuts);
}
if(!fParticleChange) { fParticleChange = GetParticleChangeForLoss(); }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
void G4MuPairProductionModel::InitialiseLocal(const G4ParticleDefinition* p,
G4VEmModel* masterModel)
{
if(p == particle) {
SetElementSelectors(masterModel->GetElementSelectors());
fElementData = masterModel->GetElementData();
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuPairProductionModel::ComputeDEDXPerVolume(
@@ -187,8 +210,7 @@ G4double G4MuPairProductionModel::ComputeDEDXPerVolume(
// loop for elements in the material
for (size_t i=0; i<material->GetNumberOfElements(); ++i) {
G4double Z = (*theElementVector)[i]->GetZ();
SetCurrentElement(Z);
G4double tmax = MaxSecondaryEnergy(particle, kineticEnergy);
G4double tmax = MaxSecondaryEnergyForElement(kineticEnergy, Z);
G4double loss = ComputMuPairLoss(Z, kineticEnergy, cutEnergy, tmax);
dedx += loss*theAtomicNumDensityVector[i];
}
@@ -203,7 +225,6 @@ G4double G4MuPairProductionModel::ComputMuPairLoss(G4double Z,
G4double cutEnergy,
G4double tmax)
{
SetCurrentElement(Z);
G4double loss = 0.0;
G4double cut = std::min(cutEnergy,tmax);
@@ -213,10 +234,13 @@ G4double G4MuPairProductionModel::ComputMuPairLoss(G4double Z,
// numerical integration in log(PairEnergy)
G4double ak1=6.9;
G4double ak2=1.0;
G4double aaa = log(minPairEnergy);
G4double bbb = log(cut);
G4double aaa = G4Log(minPairEnergy);
G4double bbb = G4Log(cut);
G4int kkk = (G4int)((bbb-aaa)/ak1+ak2);
if (kkk > 8) kkk = 8;
if (kkk > 8) { kkk = 8; }
else if (kkk < 1) { kkk = 1; }
G4double hhh = (bbb-aaa)/(G4double)kkk;
G4double x = aaa;
@@ -225,7 +249,7 @@ G4double G4MuPairProductionModel::ComputMuPairLoss(G4double Z,
for (G4int ll=0; ll<8; ll++)
{
G4double ep = exp(x+xgi[ll]*hhh);
G4double ep = G4Exp(x+xgi[ll]*hhh);
loss += wgi[ll]*ep*ep*ComputeDMicroscopicCrossSection(tkin, Z, ep);
}
x += hhh;
@@ -240,19 +264,21 @@ G4double G4MuPairProductionModel::ComputMuPairLoss(G4double Z,
G4double G4MuPairProductionModel::ComputeMicroscopicCrossSection(
G4double tkin,
G4double Z,
G4double cut)
G4double cutEnergy)
{
G4double cross = 0.;
SetCurrentElement(Z);
G4double tmax = MaxSecondaryEnergy(particle, tkin);
G4double tmax = MaxSecondaryEnergyForElement(tkin, Z);
G4double cut = std::max(cutEnergy, minPairEnergy);
if (tmax <= cut) { return cross; }
G4double ak1=6.9 ;
G4double ak2=1.0 ;
G4double aaa = log(cut);
G4double bbb = log(tmax);
G4double aaa = G4Log(cut);
G4double bbb = G4Log(tmax);
G4int kkk = (G4int)((bbb-aaa)/ak1 + ak2);
if(kkk > 8) { kkk = 8; }
else if (kkk < 1) { kkk = 1; }
G4double hhh = (bbb-aaa)/G4double(kkk);
G4double x = aaa;
@@ -260,7 +286,7 @@ G4double G4MuPairProductionModel::ComputeMicroscopicCrossSection(
{
for(G4int i=0; i<8; ++i)
{
G4double ep = exp(x + xgi[i]*hhh);
G4double ep = G4Exp(x + xgi[i]*hhh);
cross += ep*wgi[i]*ComputeDMicroscopicCrossSection(tkin, Z, ep);
}
x += hhh;
@@ -271,6 +297,8 @@ G4double G4MuPairProductionModel::ComputeMicroscopicCrossSection(
return cross;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double G4MuPairProductionModel::ComputeDMicroscopicCrossSection(
G4double tkin,
G4double Z,
@@ -279,12 +307,12 @@ G4double G4MuPairProductionModel::ComputeDMicroscopicCrossSection(
// using the cross section formula of R.P. Kokoulin (18/01/98)
// Code modified by R.P. Kokoulin, V.N. Ivanchenko (27/01/04)
{
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 ;
static const G4double bbbtf= 183. ;
static const G4double bbbh = 202.4 ;
static const G4double g1tf = 1.95e-5 ;
static const G4double g2tf = 5.3e-5 ;
static const G4double g1h = 4.4e-5 ;
static const G4double g2h = 4.8e-5 ;
G4double totalEnergy = tkin + particleMass;
G4double residEnergy = totalEnergy - pairEnergy;
@@ -292,12 +320,10 @@ G4double G4MuPairProductionModel::ComputeDMicroscopicCrossSection(
G4double massratio2 = massratio*massratio ;
G4double cross = 0.;
SetCurrentElement(Z);
G4double c3 = 0.75*sqrte*particleMass;
if (residEnergy <= c3*z13) { return cross; }
G4double c7 = 4.*electron_mass_c2;
G4double c7 = 4.*CLHEP::electron_mass_c2;
G4double c8 = 6.*particleMass*particleMass;
G4double alf = c7/pairEnergy;
G4double a3 = 1. - alf;
@@ -309,10 +335,12 @@ G4double G4MuPairProductionModel::ComputeDMicroscopicCrossSection(
else { bbb = bbbtf; g1 = g1tf; g2 = g2tf; }
G4double zeta = 0;
G4double zeta1 = 0.073*log(totalEnergy/(particleMass+g1*z23*totalEnergy))-0.26;
G4double zeta1 =
0.073*G4Log(totalEnergy/(particleMass+g1*z23*totalEnergy))-0.26;
if ( zeta1 > 0.)
{
G4double zeta2 = 0.058*log(totalEnergy/(particleMass+g2*z13*totalEnergy))-0.14;
G4double zeta2 =
0.058*G4Log(totalEnergy/(particleMass+g2*z13*totalEnergy))-0.14;
zeta = zeta1/zeta2 ;
}
@@ -326,15 +354,15 @@ G4double G4MuPairProductionModel::ComputeDMicroscopicCrossSection(
G4double rta3 = sqrt(a3);
G4double tmnexp = alf/(1. + rta3) + del*rta3;
if(tmnexp >= 1.0) return cross;
if(tmnexp >= 1.0) { return cross; }
G4double tmn = log(tmnexp);
G4double tmn = G4Log(tmnexp);
G4double sum = 0.;
// Gaussian integration in ln(1-ro) ( with 8 points)
for (G4int i=0; i<8; ++i)
{
G4double a4 = exp(tmn*xgi[i]); // a4 = (1.-asymmetry)
G4double a4 = G4Exp(tmn*xgi[i]); // a4 = (1.-asymmetry)
G4double a5 = a4*(2.-a4) ;
G4double a6 = 1.-a5 ;
G4double a7 = 1.+a6 ;
@@ -344,39 +372,41 @@ G4double G4MuPairProductionModel::ComputeDMicroscopicCrossSection(
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 yed = 2.*(1.+3.*bet)*G4Log(3.+xii)-a6-a1*(2.-a6) ;
G4double ye1 = 1.+yeu/yed ;
G4double ale=log(bbb/z13*sqrt(xi1*ye1)/(1.+screen*ye1)) ;
G4double cre = 0.5*log(1.+2.25*z23*xi1*ye1/massratio2) ;
G4double ale = G4Log(bbb/z13*sqrt(xi1*ye1)/(1.+screen*ye1)) ;
G4double cre = 0.5*G4Log(1.+2.25*z23*xi1*ye1/massratio2) ;
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);
if (xi <= 1.e3) {
be = ((2.+a6)*(1.+bet)+xi*a9)*G4Log(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 ymd = a7*(1.5+a1)*G4Log(3.+xi)+1.-1.5*a6 ;
G4double ym1 = 1.+ymu/ymd ;
G4double alm_crm = log(bbb*massratio/(1.5*z23*(1.+screen*ym1)));
G4double alm_crm = G4Log(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;
bm = (a7*(1.+1.5*bet)-a10*xii)*G4Log(xi1)+xi*(a5-bet)/xi1+a10;
} else {
bm = (5.-a6+bet*a9)*(xi/2.);
}
G4double fm = alm_crm*bm;
if ( fm < 0.) fm = 0. ;
if ( fm < 0.) { fm = 0.; }
sum += wgi[i]*a4*(fe+fm/massratio2);
}
cross = -tmn*sum*factorForCross*z2*residEnergy/(totalEnergy*pairEnergy);
if(cross < 0.0) { cross = 0.0; }
return cross;
}
@@ -392,14 +422,12 @@ G4double G4MuPairProductionModel::ComputeCrossSectionPerAtom(
G4double cross = 0.0;
if (kineticEnergy <= lowestKinEnergy) { return cross; }
SetCurrentElement(Z);
G4double maxPairEnergy = MaxSecondaryEnergy(particle,kineticEnergy);
G4double maxPairEnergy = MaxSecondaryEnergyForElement(kineticEnergy, Z);
G4double tmax = std::min(maxEnergy, maxPairEnergy);
G4double cut = std::max(cutEnergy, minPairEnergy);
if (cut >= tmax) return cross;
if (cut >= tmax) { return cross; }
cross = ComputeMicroscopicCrossSection (kineticEnergy, Z, cut);
cross = ComputeMicroscopicCrossSection(kineticEnergy, Z, cut);
if(tmax < kineticEnergy) {
cross -= ComputeMicroscopicCrossSection(kineticEnergy, Z, tmax);
}
@@ -410,138 +438,156 @@ G4double G4MuPairProductionModel::ComputeCrossSectionPerAtom(
void G4MuPairProductionModel::MakeSamplingTables()
{
for (G4int iz=0; iz<nzdat; ++iz)
{
G4double factore = G4Exp(G4Log(emax/emin)/G4double(nbine));
for (G4int iz=0; iz<nzdat; ++iz) {
G4double Z = zdat[iz];
SetCurrentElement(Z);
G4Physics2DVector* pv = new G4Physics2DVector(nbiny+1,nbine+1);
G4double kinEnergy = emin;
for (G4int it=0; it<ntdat; ++it) {
for (size_t it=0; it<=nbine; ++it) {
G4double kineticEnergy = tdat[it];
G4double maxPairEnergy = MaxSecondaryEnergy(particle,kineticEnergy);
// G4cout << "Z= " << currentZ << " z13= " << z13
//<< " mE= " << maxPairEnergy << G4endl;
G4double xSec = 0.0 ;
pv->PutY(it, G4Log(kinEnergy/MeV));
G4double maxPairEnergy = MaxSecondaryEnergyForElement(kinEnergy, Z);
/*
G4cout << "it= " << it << " E= " << kinEnergy
<< " " << particle->GetParticleName()
<< " maxE= " << maxPairEnergy << " minE= " << minPairEnergy
<< " ymin= " << ymin << G4endl;
*/
G4double coef = G4Log(minPairEnergy/kinEnergy)/ymin;
G4double ymax = G4Log(maxPairEnergy/kinEnergy)/coef;
G4double fac = (ymax - ymin)/dy;
size_t imax = (size_t)fac;
fac -= (G4double)imax;
G4double xSec = 0.0;
G4double x = ymin;
/*
G4cout << "Z= " << currentZ << " z13= " << z13
<< " mE= " << maxPairEnergy << " ymin= " << ymin
<< " dy= " << dy << " c= " << coef << G4endl;
*/
// start from zero
pv->PutValue(0, it, 0.0);
if(0 == it) { pv->PutX(nbiny, 0.0); }
if(maxPairEnergy > minPairEnergy) {
for (size_t i=0; i<nbiny; ++i) {
G4double y = ymin - 0.5*dy ;
G4double yy = ymin - dy ;
G4double x = exp(y);
G4double fac = exp(dy);
G4double dx = exp(yy)*(fac - 1.0);
if(0 == it) { pv->PutX(i, x); }
G4double c = log(maxPairEnergy/minPairEnergy);
if(i < imax) {
G4double ep = kinEnergy*G4Exp(coef*(x + dy*0.5));
for (G4int i=0 ; i<nbiny; ++i) {
y += dy ;
if(c > 0.0) {
x *= fac;
dx*= fac;
G4double ep = minPairEnergy*exp(c*x) ;
xSec +=
ep*dx*ComputeDMicroscopicCrossSection(kineticEnergy, Z, ep);
}
ya[i] = y;
proba[iz][it][i] = xSec;
// not multiplied by interval, because table
// will be used only for sampling
//G4cout << "i= " << i << " x= " << x << "E= " << kinEnergy
// << " Egamma= " << ep << G4endl;
xSec += ep*ComputeDMicroscopicCrossSection(kinEnergy, Z, ep);
// last bin before the kinematic limit
} else if(i == imax) {
G4double ep = kinEnergy*G4Exp(coef*(x + fac*dy*0.5));
xSec += ep*fac*ComputeDMicroscopicCrossSection(kinEnergy, Z, ep);
}
} else {
for (G4int i=0 ; i<nbiny; ++i) {
proba[iz][it][i] = xSec;
}
}
ya[nbiny]=ymax;
proba[iz][it][nbiny] = xSec;
pv->PutValue(i + 1, it, xSec);
x += dy;
}
kinEnergy *= factore;
// to avoid precision lost
if(it+1 == nbine) { kinEnergy = emax; }
}
fElementData->InitialiseForElement(zdat[iz], pv);
}
samplingTablesAreFilled = true;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void
G4MuPairProductionModel::SampleSecondaries(std::vector<G4DynamicParticle*>* vdp,
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();
//G4cout << "------- G4MuPairProductionModel::SampleSecondaries E(MeV)= "
// << kineticEnergy << " "
// << aDynamicParticle->GetDefinition()->GetParticleName() << G4endl;
G4double totalEnergy = kineticEnergy + particleMass;
G4double totalMomentum =
sqrt(kineticEnergy*(kineticEnergy + 2.0*particleMass));
G4ThreeVector partDirection = aDynamicParticle->GetMomentumDirection();
G4int it;
for(it=1; it<ntdat; ++it) { if(kineticEnergy <= tdat[it]) { break; } }
if(it == ntdat) { --it; }
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, tmin);
SetCurrentElement(anElement->GetZ());
const G4Element* anElement = SelectRandomAtom(couple,particle,kineticEnergy);
// define interval of enegry transfer
G4double maxPairEnergy = MaxSecondaryEnergy(particle,kineticEnergy);
// define interval of energy transfer
G4double maxPairEnergy = MaxSecondaryEnergyForElement(kineticEnergy,
anElement->GetZ());
G4double maxEnergy = std::min(tmax, maxPairEnergy);
G4double minEnergy = std::max(tmin, minPairEnergy);
if(minEnergy >= maxEnergy) { return; }
//G4cout << "emin= " << minEnergy << " emax= " << maxEnergy
// << " minPair= " << minPairEnergy << " maxpair= " << maxPairEnergy
// << " ymin= " << ymin << " dy= " << dy << G4endl;
// << " minPair= " << minPairEnergy << " maxpair= " << maxPairEnergy
// << " ymin= " << ymin << " dy= " << dy << G4endl;
G4double logmaxmin = log(maxPairEnergy/minPairEnergy);
G4double coeff = G4Log(minPairEnergy/kineticEnergy)/ymin;
// select bins
G4int iymin = 0;
G4int iymax = nbiny-1;
if( minEnergy > minPairEnergy)
{
G4double xc = log(minEnergy/minPairEnergy)/logmaxmin;
iymin = (G4int)((log(xc) - ymin)/dy);
if(iymin >= nbiny) iymin = nbiny-1;
else if(iymin < 0) iymin = 0;
xc = log(maxEnergy/minPairEnergy)/logmaxmin;
iymax = (G4int)((log(xc) - ymin)/dy) + 1;
if(iymax >= nbiny) iymax = nbiny-1;
else if(iymax < 0) iymax = 0;
}
// compute limits
G4double yymin = G4Log(minEnergy/kineticEnergy)/coeff;
G4double yymax = G4Log(maxEnergy/kineticEnergy)/coeff;
//G4cout << "yymin= " << yymin << " yymax= " << yymax << G4endl;
// units should not be used, bacause table was built without
G4double logTkin = G4Log(kineticEnergy/MeV);
// sample e-e+ energy, pair energy first
G4int iz, iy;
for(iz=1; iz<nzdat; ++iz) { if(currentZ <= zdat[iz]) { break; } }
if(iz == nzdat) { --iz; }
G4double dz = log(currentZ/zdat[iz-1])/log(zdat[iz]/zdat[iz-1]);
G4double pmin = InterpolatedIntegralCrossSection(dt,dz,iz,it,iymin,currentZ);
G4double pmax = InterpolatedIntegralCrossSection(dt,dz,iz,it,iymax,currentZ);
G4double p = pmin+G4UniformRand()*(pmax - pmin);
// interpolate sampling vector;
G4double p1 = pmin;
G4double p2 = pmin;
for(iy=iymin+1; iy<=iymax; ++iy) {
p1 = p2;
p2 = InterpolatedIntegralCrossSection(dt, dz, iz, it, iy, currentZ);
if(p <= p2) { break; }
// select sample table via Z
G4int iz1(0), iz2(0);
for(G4int iz=0; iz<nzdat; ++iz) {
if(currentZ == zdat[iz]) {
iz1 = iz2 = currentZ;
break;
} else if(currentZ < zdat[iz]) {
iz2 = zdat[iz];
if(iz > 0) { iz1 = zdat[iz-1]; }
else { iz1 = iz2; }
break;
}
}
// G4cout << "iy= " << iy << " iymin= " << iymin << " iymax= "
// << iymax << " Z= " << currentZ << G4endl;
G4double y = ya[iy-1] + dy*(p - p1)/(p2 - p1);
if(0 == iz1) { iz1 = iz2 = zdat[nzdat-1]; }
G4double PairEnergy = minPairEnergy*exp( exp(y)*logmaxmin );
if(PairEnergy < minEnergy) { PairEnergy = minEnergy; }
if(PairEnergy > maxEnergy) { PairEnergy = maxEnergy; }
G4double PairEnergy = 0.0;
G4int count = 0;
//G4cout << "start loop Z1= " << iz1 << " Z2= " << iz2 << G4endl;
do {
++count;
// sampling using only one random number
G4double rand = G4UniformRand();
G4double x = FindScaledEnergy(iz1, rand, logTkin, yymin, yymax);
if(iz1 != iz2) {
G4double x2 = FindScaledEnergy(iz2, rand, logTkin, yymin, yymax);
G4double lz1= nist->GetLOGZ(iz1);
G4double lz2= nist->GetLOGZ(iz2);
//G4cout << count << ". x= " << x << " x2= " << x2
// << " Z1= " << iz1 << " Z2= " << iz2 << G4endl;
x += (x2 - x)*(lnZ - lz1)/(lz2 - lz1);
}
//G4cout << "x= " << x << " coeff= " << coeff << G4endl;
PairEnergy = kineticEnergy*G4Exp(x*coeff);
} while((PairEnergy < minEnergy || PairEnergy > maxEnergy) && 10 > count);
//G4cout << "## PairEnergy(GeV)= " << PairEnergy/GeV
// << " Etot(GeV)= " << totalEnergy/GeV << G4endl;
// sample r=(E+-E-)/PairEnergy ( uniformly .....)
G4double rmax =
@@ -593,73 +639,20 @@ G4MuPairProductionModel::SampleSecondaries(std::vector<G4DynamicParticle*>* vdp,
// add secondary
vdp->push_back(aParticle1);
vdp->push_back(aParticle2);
//G4cout << "-- G4MuPairProductionModel::SampleSecondaries done" << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const G4Element* G4MuPairProductionModel::SelectRandomAtom(
G4double kinEnergy, G4double dt, G4int it,
const G4MaterialCutsCouple* couple, G4double tmin)
void G4MuPairProductionModel::DataCorrupted(G4int Z, G4double logTkin)
{
// select randomly 1 element within the material
const G4Material* material = couple->GetMaterial();
size_t nElements = material->GetNumberOfElements();
const G4ElementVector* theElementVector = material->GetElementVector();
if (nElements == 1) { return (*theElementVector)[0]; }
if(nElements > nmaxElements) {
nmaxElements = nElements;
partialSum.resize(nmaxElements);
}
const G4double* theAtomNumDensityVector=material->GetAtomicNumDensityVector();
G4double sum = 0.0;
G4double dl;
size_t i;
for (i=0; i<nElements; ++i) {
G4double Z = ((*theElementVector)[i])->GetZ();
SetCurrentElement(Z);
G4double maxPairEnergy = MaxSecondaryEnergy(particle,kinEnergy);
G4double minEnergy = std::max(tmin, minPairEnergy);
dl = 0.0;
if(minEnergy < maxPairEnergy) {
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 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);
dl = (sigtot - sigcut)*theAtomNumDensityVector[i];
}
// protection
if(dl < 0.0) { dl = 0.0; }
sum += dl;
partialSum[i] = sum;
}
G4double rval = G4UniformRand()*sum;
for (i=0; i<nElements; ++i) {
if(rval<=partialSum[i]) { return (*theElementVector)[i]; }
}
return (*theElementVector)[nElements - 1];
G4ExceptionDescription ed;
ed << "G4ElementData is not properly initialized Z= " << Z
<< " Ekin(MeV)= " << G4Exp(logTkin)
<< " IsMasterThread= " << IsMaster()
<< " Model " << GetName();
G4Exception("G4MuPairProductionModel::()","em0033",FatalException,
ed,"");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......