77 singleScatteringMode(false)
79 invsqrt12 = 1./sqrt(12.);
80 tlimitminfix = 1.e-6*mm;
81 lowEnergyLimit = 1.0*eV;
84 xsecn.resize(nelments);
85 prob.resize(nelments);
91 preKinEnergy = tPathLength = zPathLength = lambdaeff = currentRange = xtsec = 0;
92 currentMaterialIndex = 0;
93 cosThetaMax = cosTetMaxNuc = 1.0;
138 if(p != particle) { SetupParticle(p); }
139 if(kinEnergy < lowEnergyLimit) {
return cross; }
141 G4Exception(
"G4WentzelVIRelModel::ComputeCrossSectionPerAtom",
"em0011",
147 if(cosTetMaxNuc < 1.0) {
174 G4double tlimit = currentMinimalStep;
178 singleScatteringMode =
false;
187 currentRange =
GetRange(particle,preKinEnergy,currentCouple);
188 cosTetMaxNuc = wokvi->
SetupKinematic(preKinEnergy, currentMaterial);
192 if(tlimit > currentRange) { tlimit = currentRange; }
195 if(inside || tlimit < tlimitminfix) {
200 G4double presafety = sp->GetSafety();
202 if(currentRange < presafety) {
209 if(stepStatus !=
fGeomBoundary && presafety < tlimitminfix) {
211 if(currentRange < presafety) {
227 0.7*(1.0 - cosTetMaxNuc)*lambdaeff);
230 if(cosThetaMax > cosTetMaxNuc) {
231 rlimit = std::min(rlimit,
facsafety*presafety);
239 if(rcut > rlimit) { rlimit = std::min(rlimit, rcut*sqrt(rlimit/rcut)); }
241 if(rlimit < tlimit) { tlimit = rlimit; }
243 tlimit = std::max(tlimit, tlimitminfix);
252 tlimit = std::min(tlimit, geomlimit/
facgeom);
268 tPathLength = truelength;
269 zPathLength = tPathLength;
271 if(lambdaeff > 0.0 && lambdaeff !=
DBL_MAX) {
272 G4double tau = tPathLength/lambdaeff;
277 zPathLength *= (1.0 - 0.5*tau + tau*tau/6.0);
282 if(currentRange > tPathLength) {
283 e1 =
GetEnergy(particle,currentRange-tPathLength,currentCouple);
285 e1 = 0.5*(e1 + preKinEnergy);
288 zPathLength = lambdaeff*(1.0 - exp(-tPathLength/lambdaeff));
290 }
else { lambdaeff =
DBL_MAX; }
301 cosThetaMin = cosTetMaxNuc;
307 singleScatteringMode =
true;
308 zPathLength = geomStepLength;
309 tPathLength = geomStepLength;
316 const G4double singleScatLimit = 1.0e-7;
317 if(geomStepLength < lambdaeff*singleScatLimit*(1.0 - cosTetMaxNuc)) {
318 singleScatteringMode =
true;
320 zPathLength = geomStepLength;
321 tPathLength = geomStepLength;
324 }
else if(geomStepLength != zPathLength) {
327 zPathLength = geomStepLength;
328 G4double tau = geomStepLength/lambdaeff;
329 tPathLength = zPathLength*(1.0 + 0.5*tau + tau*tau/3.0);
334 if(currentRange > tPathLength) {
335 e1 =
GetEnergy(particle,currentRange-tPathLength,currentCouple);
337 e1 = 0.5*(e1 + preKinEnergy);
340 tau = zPathLength/lambdaeff;
342 if(tau < 0.999999) { tPathLength = -lambdaeff*log(1.0 - tau); }
343 else { tPathLength = currentRange; }
350 if(!singleScatteringMode) { cosThetaMin = 1.0 - 1.5*tPathLength/lambdaeff; }
354 if(cosThetaMin > cosTetMaxNuc) {
357 G4double cross = ComputeXSectionPerVolume();
360 singleScatteringMode =
true;
361 tPathLength = zPathLength;
363 }
else if(xtsec > 0.0) {
365 lambdaeff = 1./cross;
367 if(tau < numlimit) { tPathLength = zPathLength*(1.0 + 0.5*tau + tau*tau/3.0); }
368 else if(tau < 0.999999) { tPathLength = -lambdaeff*log(1.0 - tau); }
369 else { tPathLength = currentRange; }
371 if(tPathLength > currentRange) { tPathLength = currentRange; }
397 if(tkin < lowEnergyLimit || tPathLength <= 0.0)
401 if(lambdaeff <
DBL_MAX) { invlambda = 0.5/lambdaeff; }
404 G4double cut = (*currentCuts)[currentMaterialIndex];
417 if(tPathLength*invlambda > thinlimit && safety > tlimitminfix) {
440 G4double mscfac = zPathLength/tPathLength;
471 for (; i<nelm; ++i) {
if(xsecn[i] >= qsec) {
break; } }
485 if(x2 <= 0.0) { --nMscSteps; }
494 if(!singleScatteringMode) {
503 if(z0 > 0.01) { zzz = exp(-1.0/z0); }
509 if(cost > 1.0) { cost = 1.0; }
510 else if(cost < -1.0) { cost =-1.0; }
511 sint = sqrt((1.0 - cost)*(1.0 + cost));
517 temp.
set(vx1,vy1,cost);
523 G4double rms = invsqrt12*sqrt(2*z0);
525 G4double dx = r*(0.5*vx1 + rms*G4RandGauss::shoot(0.0,1.0));
526 G4double dy = r*(0.5*vy1 + rms*G4RandGauss::shoot(0.0,1.0));
529 if(d >= 0.0) { dz = sqrt(d) - r; }
530 else { dx = dy = dz = 0.0; }
539 }
while (0 < nMscSteps);
568G4double G4WentzelVIRelModel::ComputeXSectionPerVolume()
572 const G4double* theAtomNumDensityVector =
575 if(nelm > nelments) {
580 G4double cut = (*currentCuts)[currentMaterialIndex];
585 if(cosTetMaxNuc > cosThetaMin) {
return 0.0; }
589 for (
G4int i=0; i<nelm; ++i) {
592 G4double density = theAtomNumDensityVector[i];
595 if(costm < cosThetaMin) {
598 if(1.0 > cosThetaMin) {
605 if(nucsec > 0.0) { esec /= nucsec; }
606 xtsec += nucsec*density;
std::vector< G4Element * > G4ElementVector
void set(double x, double y, double z)
Hep3Vector & rotateUz(const Hep3Vector &)
const G4ThreeVector & GetMomentumDirection() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
static G4LossTableManager * Instance()
G4ProductionCuts * GetProductionCuts() const
const G4ElementVector * GetElementVector() const
size_t GetNumberOfElements() const
G4double GetRadlen() const
const G4double * GetVecNbOfAtomsPerVolume() const
static G4NistManager * Instance()
void ProposeMomentumDirection(const G4ThreeVector &Pfinal)
static G4Pow * GetInstance()
G4double GetProductionCut(G4int index) const
G4StepPoint * GetPreStepPoint() const
const G4DynamicParticle * GetDynamicParticle() const
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
const G4Step * GetStep() const
G4double PolarAngleLimit() const
const G4MaterialCutsCouple * CurrentCouple() const
G4double ComputeGeomLimit(const G4Track &, G4double &presafety, G4double limit)
G4double GetTransportMeanFreePath(const G4ParticleDefinition *part, G4double kinEnergy)
G4double GetEnergy(const G4ParticleDefinition *part, G4double range, const G4MaterialCutsCouple *couple)
G4double GetRange(const G4ParticleDefinition *part, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
G4double ComputeSafety(const G4ThreeVector &position, G4double limit)
G4MscStepLimitType steppingAlgorithm
G4ParticleChangeForMSC * GetParticleChangeForMSC(const G4ParticleDefinition *p=0)
G4double ConvertTrueToGeom(G4double &tLength, G4double &gLength)
G4ThreeVector fDisplacement
virtual G4double ComputeGeomPathLength(G4double truePathLength)
virtual G4double ComputeTrueStepLength(G4double geomStepLength)
G4WentzelVIRelModel(const G4String &nam="WentzelVIUni")
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
virtual ~G4WentzelVIRelModel()
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double KineticEnergy, G4double AtomicNumber, G4double AtomicWeight=0., G4double cut=DBL_MAX, G4double emax=DBL_MAX)
virtual G4ThreeVector & SampleScattering(const G4DynamicParticle *, G4double safety)
virtual G4double ComputeTruePathLengthLimit(const G4Track &track, G4double ¤tMinimalStep)
void StartTracking(G4Track *)
G4double ComputeTransportCrossSectionPerAtom(G4double CosThetaMax)
G4double SetupTarget(G4int Z, G4double cut=DBL_MAX)
G4ThreeVector SampleSingleScattering(G4double CosThetaMin, G4double CosThetaMax, G4double elecRatio=0.0)
void Initialise(const G4ParticleDefinition *, G4double CosThetaLim)
G4double SetupKinematic(G4double kinEnergy, const G4Material *mat)
G4double ComputeNuclearCrossSection(G4double CosThetaMin, G4double CosThetaMax)
G4double ComputeElectronCrossSection(G4double CosThetaMin, G4double CosThetaMax)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)