Geant4  10.01.p01
G4WentzelVIModel.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: G4WentzelVIModel.cc 88979 2015-03-17 10:10:21Z gcosmo $
27 //
28 // -------------------------------------------------------------------
29 //
30 // GEANT4 Class file
31 //
32 //
33 // File name: G4WentzelVIModel
34 //
35 // Author: V.Ivanchenko
36 //
37 // Creation date: 09.04.2008 from G4MuMscModel
38 //
39 // Modifications:
40 // 27-05-2010 V.Ivanchenko added G4WentzelOKandVIxSection class to
41 // compute cross sections and sample scattering angle
42 //
43 //
44 // Class Description:
45 //
46 // Implementation of the model of multiple scattering based on
47 // G.Wentzel, Z. Phys. 40 (1927) 590.
48 // H.W.Lewis, Phys Rev 78 (1950) 526.
49 // J.M. Fernandez-Varea et al., NIM B73 (1993) 447.
50 // L.Urban, CERN-OPEN-2006-077.
51 
52 // -------------------------------------------------------------------
53 //
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
58 #include "G4WentzelVIModel.hh"
59 #include "G4PhysicalConstants.hh"
60 #include "G4SystemOfUnits.hh"
61 #include "Randomize.hh"
63 #include "G4PhysicsTableHelper.hh"
64 #include "G4ElementVector.hh"
65 #include "G4ProductionCutsTable.hh"
66 #include "G4EmParameters.hh"
67 #include "G4Log.hh"
68 #include "G4Exp.hh"
69 
70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
71 
72 using namespace std;
73 
74 const G4int minNCollisions = 10;
75 
77  G4VMscModel(nam),
78  ssFactor(1.05),
79  invssFactor(1.0),
80  currentCouple(0),
81  inside(false),
82  singleScatteringMode(false),
83  cosThetaMin(1.0),
84  cosThetaMax(-1.0),
85  fSecondMoments(0),
86  idx2(0),
87  numlimit(0.1),
88  isCombined(combined),
89  useSecondMoment(false)
90 {
92  invsqrt12 = 1./sqrt(12.);
93  tlimitminfix = 1.e-6*mm;
94  lowEnergyLimit = 1.0*eV;
95  particle = 0;
96  nelments = 5;
97  xsecn.resize(nelments);
98  prob.resize(nelments);
99  wokvi = new G4WentzelOKandVIxSection(combined);
100  fixedCut = -1.0;
101 
103  = currentRange = xtsec = cosTetMaxNuc = 0.0;
105 
106  fParticleChange = 0;
107  currentCuts = 0;
108  currentMaterial = 0;
109 }
110 
111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
112 
114 {
115  delete wokvi;
116  if(fSecondMoments && IsMaster()) {
117  delete fSecondMoments;
118  fSecondMoments = 0;
119  }
120 }
121 
122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123 
125  const G4DataVector& cuts)
126 {
127  // reset parameters
128  SetupParticle(p);
129  currentRange = 0.0;
130 
131  if(isCombined) {
132  G4double tet = PolarAngleLimit();
133  if(tet <= 0.0) { cosThetaMax = 1.0; }
134  else if(tet < CLHEP::pi) { cosThetaMax = cos(tet); }
135  }
136 
137  //G4cout << "G4WentzelVIModel::Initialise " << p->GetParticleName() << G4endl;
139  /*
140  G4cout << "G4WentzelVIModel: " << particle->GetParticleName()
141  << " 1-cos(ThetaLimit)= " << 1 - cosThetaMax
142  << " SingScatFactor= " << ssFactor
143  << G4endl;
144  */
145  currentCuts = &cuts;
146 
147  // set values of some data members
149 
150  // build second moment table only if transport table is build
152  if(useSecondMoment && IsMaster() && table) {
153 
154  //G4cout << "### G4WentzelVIModel::Initialise: build 2nd moment table "
155  // << table << G4endl;
156  fSecondMoments =
158  // Access to materials
159  const G4ProductionCutsTable* theCoupleTable =
161  size_t numOfCouples = theCoupleTable->GetTableSize();
162 
163  G4bool splineFlag = true;
164  G4PhysicsVector* aVector = 0;
165  G4PhysicsVector* bVector = 0;
168  if(emin < emax) {
170  *G4lrint(std::log10(emax/emin));
171  if(n < 3) { n = 3; }
172 
173  for(size_t i=0; i<numOfCouples; ++i) {
174 
175  //G4cout<< "i= " << i << " Flag= " << fSecondMoments->GetFlag(i)
176  // << G4endl;
177  if(fSecondMoments->GetFlag(i)) {
178  DefineMaterial(theCoupleTable->GetMaterialCutsCouple(i));
179 
180  delete (*fSecondMoments)[i];
181  if(!aVector) {
182  aVector = new G4PhysicsLogVector(emin, emax, n);
183  bVector = aVector;
184  } else {
185  bVector = new G4PhysicsVector(*aVector);
186  }
187  for(size_t j=0; j<n; ++j) {
188  G4double e = bVector->Energy(j);
189  bVector->PutValue(j, ComputeSecondMoment(p, e)*e*e);
190  }
191  if(splineFlag) { bVector->FillSecondDerivatives(); }
192  (*fSecondMoments)[i] = bVector;
193  }
194  }
195  }
196  //G4cout << *fSecondMoments << G4endl;
197  }
198 }
199 
200 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
201 
203  G4VEmModel* masterModel)
204 {
205  fSecondMoments = static_cast<G4WentzelVIModel*>(masterModel)
207 }
208 
209 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
210 
212  const G4ParticleDefinition* p,
213  G4double kinEnergy,
214  G4double Z, G4double,
215  G4double cutEnergy, G4double)
216 {
217  G4double cross = 0.0;
218  if(p != particle) { SetupParticle(p); }
219  if(kinEnergy < lowEnergyLimit) { return cross; }
220  if(!CurrentCouple()) {
221  G4Exception("G4WentzelVIModel::ComputeCrossSectionPerAtom", "em0011",
222  FatalException, " G4MaterialCutsCouple is not defined");
223  return 0.0;
224  }
227  if(cosTetMaxNuc < 1.0) {
228  G4double cut = cutEnergy;
229  if(fixedCut > 0.0) { cut = fixedCut; }
230  G4double cost = wokvi->SetupTarget(G4lrint(Z), cut);
232  /*
233  if(p->GetParticleName() == "e-")
234  G4cout << "G4WentzelVIModel::CS: Z= " << G4int(Z) << " e(MeV)= "<<kinEnergy
235  << " 1-cosN= " << 1 - cosTetMaxNuc << " cross(bn)= " << cross/barn
236  << " " << particle->GetParticleName() << G4endl;
237  */
238  }
239  return cross;
240 }
241 
242 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
243 
245 {
247  inside = false;
249 }
250 
251 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
252 
254  const G4Track& track,
255  G4double& currentMinimalStep)
256 {
257  G4double tlimit = currentMinimalStep;
258  const G4DynamicParticle* dp = track.GetDynamicParticle();
259  G4StepPoint* sp = track.GetStep()->GetPreStepPoint();
260  G4StepStatus stepStatus = sp->GetStepStatus();
261  singleScatteringMode = false;
262 
263  //G4cout << "G4WentzelVIModel::ComputeTruePathLengthLimit stepStatus= "
264  // << stepStatus << " " << track.GetDefinition()->GetParticleName()
265  // << G4endl;
266 
267  // initialisation for each step, lambda may be computed from scratch
274 
275  //G4cout << "lambdaeff= " << lambdaeff << " Range= " << currentRange
276  // << " tlimit= " << tlimit << " 1-cost= " << 1 - cosTetMaxNuc << G4endl;
277 
278  // extra check for abnormal situation
279  // this check needed to run MSC with eIoni and eBrem inactivated
280  if(tlimit > currentRange) { tlimit = currentRange; }
281 
282  // stop here if small range particle
283  if(inside || tlimit < tlimitminfix) {
284  return ConvertTrueToGeom(tlimit, currentMinimalStep);
285  }
286 
287  // pre step
288  G4double presafety = sp->GetSafety();
289  // far from geometry boundary
290  if(currentRange < presafety) {
291  inside = true;
292  return ConvertTrueToGeom(tlimit, currentMinimalStep);
293  }
294 
295  // compute presafety again if presafety <= 0 and no boundary
296  // i.e. when it is needed for optimization purposes
297  if(stepStatus != fGeomBoundary && presafety < tlimitminfix) {
298  presafety = ComputeSafety(sp->GetPosition(), tlimit);
299  if(currentRange < presafety) {
300  inside = true;
301  return ConvertTrueToGeom(tlimit, currentMinimalStep);
302  }
303  }
304  /*
305  G4cout << "e(MeV)= " << preKinEnergy/MeV
306  << " " << particle->GetParticleName()
307  << " CurLimit(mm)= " << tlimit/mm <<" safety(mm)= " << presafety/mm
308  << " R(mm)= " <<currentRange/mm
309  << " L0(mm^-1)= " << lambdaeff*mm
310  << G4endl;
311  */
312  // natural limit for high energy
314  (1.0 - cosTetMaxNuc)*lambdaeff*invssFactor);
315 
316  // low-energy e-
317  if(cosThetaMax > cosTetMaxNuc) {
318  rlimit = std::min(rlimit, facsafety*presafety);
319  }
320 
321  // cut correction
323  //G4cout << "rcut= " << rcut << " rlimit= " << rlimit << " presafety= "
324  // << presafety << " 1-cosThetaMax= " <<1-cosThetaMax
325  //<< " 1-cosTetMaxNuc= " << 1-cosTetMaxNuc << G4endl;
326  if(rcut > rlimit) { rlimit = std::min(rlimit, rcut*sqrt(rlimit/rcut)); }
327 
328  tlimit = std::min(tlimit, rlimit);
329  tlimit = std::max(tlimit, tlimitminfix);
330 
331  // step limit in infinite media
332  tlimit = std::min(tlimit, 50*currentMaterial->GetRadlen()/facgeom);
333 
334  //compute geomlimit and force few steps within a volume
336  && stepStatus == fGeomBoundary) {
337 
338  G4double geomlimit = ComputeGeomLimit(track, presafety, currentRange);
339  tlimit = std::min(tlimit, geomlimit/facgeom);
340  }
341  /*
342  G4cout << particle->GetParticleName() << " e= " << preKinEnergy
343  << " L0= " << lambdaeff << " R= " << currentRange
344  << " tlimit= " << tlimit
345  << " currentMinimalStep= " << currentMinimalStep << G4endl;
346  */
347  return ConvertTrueToGeom(tlimit, currentMinimalStep);
348 }
349 
350 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
351 
353 {
354  zPathLength = tPathLength = truelength;
355 
356  // small step use only single scattering
357  cosThetaMin = 1.0;
359  //G4cout << "xtsec= " << xtsec << " Nav= "
360  // << zPathLength*xtsec << G4endl;
361  if(0.0 >= lambdaeff || G4int(zPathLength*xtsec) < minNCollisions) {
362  singleScatteringMode = true;
363  lambdaeff = DBL_MAX;
364 
365  } else {
366  //G4cout << "ComputeGeomPathLength: tLength= " << tPathLength
367  // << " Leff= " << lambdaeff << G4endl;
368  // small step
371  zPathLength *= (1.0 - 0.5*tau + tau*tau/6.0);
372 
373  // medium step
374  } else {
375  G4double e1 = 0.0;
376  if(currentRange > tPathLength) {
378  }
379  effKinEnergy = 0.5*(e1 + preKinEnergy);
382  //G4cout << " tLength= "<< tPathLength<< " Leff= " << lambdaeff << G4endl;
384  if(tPathLength*numlimit < lambdaeff) {
385  zPathLength *= (1.0 - G4Exp(-tPathLength/lambdaeff));
386  }
387  }
388  }
389  //G4cout << "Comp.geom: zLength= "<<zPathLength<<" tLength= "
390  // << tPathLength<< " Leff= " << lambdaeff << G4endl;
391  return zPathLength;
392 }
393 
394 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
395 
397 {
398  // initialisation of single scattering x-section
399  /*
400  G4cout << "ComputeTrueStepLength: Step= " << geomStepLength
401  << " geomL= " << zPathLength
402  << " Lambda= " << lambdaeff
403  << " 1-cosThetaMaxNuc= " << 1 - cosTetMaxNuc << G4endl;
404  */
406  zPathLength = tPathLength = geomStepLength;
407 
408  } else {
409 
410  // step defined by transportation
411  // change both geom and true step lengths
412  if(geomStepLength < zPathLength) {
413 
414  // single scattering
415  if(G4int(geomStepLength*xtsec) < minNCollisions) {
416  zPathLength = tPathLength = geomStepLength;
417  lambdaeff = DBL_MAX;
418  singleScatteringMode = true;
419 
420  // multiple scattering
421  } else {
422  // small step
423  if(geomStepLength < numlimit*lambdaeff) {
424  G4double tau = geomStepLength/lambdaeff;
425  tPathLength = geomStepLength*(1.0 + 0.5*tau + tau*tau/3.0);
426 
427  // energy correction for a big step
428  } else {
429  tPathLength *= geomStepLength/zPathLength;
430  G4double e1 = 0.0;
431  if(currentRange > tPathLength) {
433  }
434  effKinEnergy = 0.5*(e1 + preKinEnergy);
437  G4double tau = geomStepLength/lambdaeff;
438 
439  if(tau < 0.999999) { tPathLength = -lambdaeff*G4Log(1.0 - tau); }
440  else { tPathLength = currentRange; }
441  }
442  zPathLength = geomStepLength;
443  }
444  }
445  }
446  // check of step length
447  // define threshold angle between single and multiple scattering
448  if(!singleScatteringMode) {
450  xtsec = 0.0;
451 
452  // recompute transport cross section - do not change energy
453  // anymore - cannot be applied for big steps
454  if(cosThetaMin > cosTetMaxNuc) {
455  // new computation
457  //G4cout << "%%%% cross= " << cross << " xtsec= " << xtsec
458  // << " 1-cosTMin= " << 1.0 - cosThetaMin << G4endl;
459  if(cross <= 0.0) {
460  singleScatteringMode = true;
462  lambdaeff = DBL_MAX;
463  cosThetaMin = 1.0;
464  } else if(xtsec > 0.0) {
465 
466  lambdaeff = 1./cross;
467  G4double tau = zPathLength*cross;
468  if(tau < numlimit) {
469  tPathLength = zPathLength*(1.0 + 0.5*tau + tau*tau/3.0);
470  } else if(tau < 0.999999) {
471  tPathLength = -lambdaeff*G4Log(1.0 - tau);
472  } else {
474  }
475  }
476  }
477  }
479  /*
480  G4cout <<"Comp.true: zLength= "<<zPathLength<<" tLength= "<<tPathLength
481  <<" Leff(mm)= "<<lambdaeff/mm<<" sig0(1/mm)= " << xtsec <<G4endl;
482  G4cout << particle->GetParticleName() << " 1-cosThetaMin= " << 1-cosThetaMin
483  << " 1-cosTetMaxNuc= " << 1-cosTetMaxNuc
484  << " e(MeV)= " << preKinEnergy/MeV << " "
485  << " SSmode= " << singleScatteringMode << G4endl;
486  */
487  return tPathLength;
488 }
489 
490 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
491 
494  G4double /*safety*/)
495 {
496  fDisplacement.set(0.0,0.0,0.0);
497  //G4cout << "!##! G4WentzelVIModel::SampleScattering for "
498  // << particle->GetParticleName() << G4endl;
499 
500  // ignore scattering for zero step length and energy below the limit
501  if(preKinEnergy < lowEnergyLimit || tPathLength <= 0.0)
502  { return fDisplacement; }
503 
504  G4double invlambda = 0.0;
505  if(lambdaeff < DBL_MAX) { invlambda = 0.5/lambdaeff; }
506 
507  // use average kinetic energy over the step
508  G4double cut = (*currentCuts)[currentMaterialIndex];
509  if(fixedCut > 0.0) { cut = fixedCut; }
510  /*
511  G4cout <<"SampleScat: E0(MeV)= "<< preKinEnergy/MeV
512  << " Leff= " << lambdaeff <<" sig0(1/mm)= " << xtsec
513  << " xmsc= " << tPathLength*invlambda
514  << " safety= " << safety << G4endl;
515  */
516  // step limit due msc
517  G4int nMscSteps = 1;
518  G4double x0 = tPathLength;
519  G4double z0 = x0*invlambda;
520  //G4double zzz = 0.0;
521  G4double prob2 = 0.0;
522 
523  // large scattering angle case - two step approach
524 
525  if(!singleScatteringMode) {
526  static const G4double zzmin = 0.05;
527  if(useSecondMoment) {
528  G4double z1 = invlambda*invlambda;
530  prob2 = (z2 - z1)/(1.5*z1 - z2);
531  }
532  // if(z0 > zzmin && safety > tlimitminfix) {
533  if(z0 > zzmin) {
534  x0 *= 0.5;
535  z0 *= 0.5;
536  nMscSteps = 2;
537  }
538  //if(z0 > zzmin) { zzz = G4Exp(-1.0/z0); }
539  G4double zzz = 0.0;
540  if(z0 > zzmin) {
541  zzz = G4Exp(-1.0/z0);
542  z0 += zzz;
543  prob2 *= (1 + zzz);
544  }
545  prob2 /= (1 + prob2);
546  }
547 
548  // step limit due to single scattering
549  G4double x1 = 2*tPathLength;
550  if(0.0 < xtsec) { x1 = -G4Log(G4UniformRand())/xtsec; }
551 
552  // no scattering case
553  if(singleScatteringMode && x1 > tPathLength)
554  { return fDisplacement; }
555 
556  const G4ElementVector* theElementVector =
559 
560  // geometry
561  G4double sint, cost, phi;
562  G4ThreeVector temp(0.0,0.0,1.0);
563 
564  // current position and direction relative to the end point
565  // because of magnetic field geometry is computed relatively to the
566  // end point of the step
567  G4ThreeVector dir(0.0,0.0,1.0);
568  fDisplacement.set(0.0,0.0,-zPathLength);
569 
571 
572  // start a loop
573  G4double x2 = x0;
574  G4double step, z;
575  G4bool singleScat;
576  /*
577  G4cout << "Start of the loop x1(mm)= " << x1 << " x2(mm)= " << x2
578  << " 1-cost1= " << 1 - cosThetaMin << " SSmode= " << singleScatteringMode
579  << " xtsec= " << xtsec << " Nst= " << nMscSteps << G4endl;
580  */
581  do {
582 
583  //G4cout << "# x1(mm)= "<< x1<< " x2(mm)= "<< x2 << G4endl;
584  // single scattering case
585  if(singleScatteringMode && x1 > x2) {
586  fDisplacement += x2*mscfac*dir;
587  break;
588  }
589 
590  // what is next single of multiple?
591  if(x1 <= x2) {
592  step = x1;
593  singleScat = true;
594  } else {
595  step = x2;
596  singleScat = false;
597  }
598 
599  //G4cout << "# step(mm)= "<< step<< " singlScat= "<< singleScat << G4endl;
600 
601  // new position
602  fDisplacement += step*mscfac*dir;
603 
604  if(singleScat) {
605 
606  // select element
607  G4int i = 0;
608  if(nelm > 1) {
609  G4double qsec = G4UniformRand()*xtsec;
610  for (; i<nelm; ++i) { if(xsecn[i] >= qsec) { break; } }
611  }
612  G4double cosTetM =
613  wokvi->SetupTarget(G4lrint((*theElementVector)[i]->GetZ()), cut);
614  //G4cout << "!!! " << cosThetaMin << " " << cosTetM << " "
615  // << prob[i] << G4endl;
616  temp = wokvi->SampleSingleScattering(cosThetaMin, cosTetM, prob[i]);
617 
618  // direction is changed
619  temp.rotateUz(dir);
620  dir = temp;
621  //G4cout << dir << G4endl;
622 
623  // new proposed step length
624  x2 -= step;
625  x1 = -G4Log(G4UniformRand())/xtsec;
626 
627  // multiple scattering
628  } else {
629  --nMscSteps;
630  x1 -= step;
631  x2 = x0;
632 
633  // sample z in interval 0 - 1
634  G4bool isFirst = true;
635  if(prob2 > 0.0 && G4UniformRand() < prob2) { isFirst = false; }
636  do {
637  //z = -z0*G4Log(1.0 - (1.0 - zzz)*G4UniformRand());
638  if(isFirst) { z = -G4Log(G4UniformRand()); }
639  else { z = G4RandGamma::shoot(2.0,2.0); }
640  z *= z0;
641  } while(z > 1.0);
642 
643  cost = 1.0 - 2.0*z/*factCM*/;
644  if(cost > 1.0) { cost = 1.0; }
645  else if(cost < -1.0) { cost =-1.0; }
646  sint = sqrt((1.0 - cost)*(1.0 + cost));
647  phi = twopi*G4UniformRand();
648  G4double vx1 = sint*cos(phi);
649  G4double vy1 = sint*sin(phi);
650 
651  // lateral displacement
652  if (latDisplasment) {
653  G4double rms = invsqrt12*sqrt(2*z0);
654  G4double r = x0*mscfac;
655  G4double dx = r*(0.5*vx1 + rms*G4RandGauss::shoot(0.0,1.0));
656  G4double dy = r*(0.5*vy1 + rms*G4RandGauss::shoot(0.0,1.0));
657  G4double dz;
658  G4double d = r*r - dx*dx - dy*dy;
659 
660  // change position
661  if(d >= 0.0) {
662  dz = sqrt(d) - r;
663  temp.set(dx,dy,dz);
664  temp.rotateUz(dir);
665  fDisplacement += temp;
666  }
667  }
668  // change direction
669  temp.set(vx1,vy1,cost);
670  temp.rotateUz(dir);
671  dir = temp;
672  }
673  } while (0 < nMscSteps);
674 
675  dir.rotateUz(oldDirection);
676 
677  //G4cout<<"G4WentzelVIModel sampling is done 1-cost= "<< 1.-dir.z()<<G4endl;
678  // end of sampling -------------------------------
679 
681 
682  // lateral displacement
683  fDisplacement.rotateUz(oldDirection);
684 
685  /*
686  G4cout << " r(mm)= " << fDisplacement.mag()
687  << " safety= " << safety
688  << " trueStep(mm)= " << tPathLength
689  << " geomStep(mm)= " << zPathLength
690  << " x= " << fDisplacement.x()
691  << " y= " << fDisplacement.y()
692  << " z= " << fDisplacement.z()
693  << G4endl;
694  */
695 
696  //G4cout<< "G4WentzelVIModel::SampleScattering end NewDir= " << dir<< G4endl;
697  return fDisplacement;
698 }
699 
700 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
701 
703 {
704  // prepare recomputation of x-sections
705  const G4ElementVector* theElementVector = currentMaterial->GetElementVector();
706  const G4double* theAtomNumDensityVector =
709  if(nelm > nelments) {
710  nelments = nelm;
711  xsecn.resize(nelm);
712  prob.resize(nelm);
713  }
714 
715  // check consistency
716  xtsec = 0.0;
717  if(cosTetMaxNuc >= cosTheta) { return 0.0; }
718 
719  G4double cut = (*currentCuts)[currentMaterialIndex];
720  if(fixedCut > 0.0) { cut = fixedCut; }
721 
722  // loop over elements
723  G4double xs = 0.0;
724  for (G4int i=0; i<nelm; ++i) {
725  G4double costm =
726  wokvi->SetupTarget(G4lrint((*theElementVector)[i]->GetZ()), cut);
727  G4double density = theAtomNumDensityVector[i];
728 
729  G4double esec = 0.0;
730  if(costm < cosTheta) {
731 
732  // recompute the transport x-section
733  if(1.0 > cosTheta) {
734  xs += density*wokvi->ComputeTransportCrossSectionPerAtom(cosTheta);
735  }
736  // recompute the total x-section
737  G4double nucsec = wokvi->ComputeNuclearCrossSection(cosTheta, costm);
738  esec = wokvi->ComputeElectronCrossSection(cosTheta, costm);
739  nucsec += esec;
740  if(nucsec > 0.0) { esec /= nucsec; }
741  xtsec += nucsec*density;
742  }
743  xsecn[i] = xtsec;
744  prob[i] = esec;
745  //G4cout << i << " xs= " << xs << " xtsec= " << xtsec
746  // << " 1-cosTheta= " << 1-cosTheta
747  // << " 1-cosTetMaxNuc2= " <<1-cosTetMaxNuc2<< G4endl;
748  }
749 
750  //G4cout << "ComputeXS result: xsec(1/mm)= " << xs
751  // << " txsec(1/mm)= " << xtsec <<G4endl;
752  return xs;
753 }
754 
755 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
756 
758  G4double kinEnergy)
759 {
760  G4double xs = 0.0;
761 
762  SetupParticle(p);
764 
765  if(cosTetMaxNuc >= 1.0) { return xs; }
766 
767  const G4ElementVector* theElementVector = currentMaterial->GetElementVector();
768  const G4double* theAtomNumDensityVector =
771 
772  G4double cut = (*currentCuts)[currentMaterialIndex];
773  if(fixedCut > 0.0) { cut = fixedCut; }
774 
775  // loop over elements
776  for (G4int i=0; i<nelm; ++i) {
777  G4double costm =
778  wokvi->SetupTarget(G4lrint((*theElementVector)[i]->GetZ()), cut);
779  xs += theAtomNumDensityVector[i]
781  }
782  return xs;
783 }
784 
785 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
786 
788 {
789  if(val > 0.05) {
790  ssFactor = val;
791  invssFactor = 1.0/(val - 0.05);
792  }
793 }
794 
795 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double LowEnergyActivationLimit() const
Definition: G4VEmModel.hh:636
G4double HighEnergyActivationLimit() const
Definition: G4VEmModel.hh:629
virtual ~G4WentzelVIModel()
G4int NumberOfBinsPerDecade() const
void SetSingleScatteringFactor(G4double)
G4double facgeom
Definition: G4VMscModel.hh:178
ThreeVector shoot(const G4int Ap, const G4int Af)
G4WentzelOKandVIxSection * wokvi
G4double LowEnergyLimit() const
Definition: G4VEmModel.hh:622
std::vector< G4double > prob
virtual void StartTracking(G4Track *)
Definition: G4VEmModel.cc:284
std::vector< G4Element * > G4ElementVector
G4double GetKineticEnergy() const
CLHEP::Hep3Vector G4ThreeVector
G4double HighEnergyLimit() const
Definition: G4VEmModel.hh:615
const G4DynamicParticle * GetDynamicParticle() const
G4double facrange
Definition: G4VMscModel.hh:177
G4double z
Definition: TRTMaterials.hh:39
G4double GetProductionCut(G4int index) const
G4StepStatus GetStepStatus() const
virtual G4ThreeVector & SampleScattering(const G4ThreeVector &, G4double safety)
G4double ComputeSecondTransportMoment(G4double CosThetaMax)
const G4double pi
void DefineMaterial(const G4MaterialCutsCouple *)
G4double ConvertTrueToGeom(G4double &tLength, G4double &gLength)
Definition: G4VMscModel.hh:247
const G4MaterialCutsCouple * GetMaterialCutsCouple() const
G4bool latDisplasment
Definition: G4VMscModel.hh:190
const G4MaterialCutsCouple * currentCouple
G4bool IsMaster() const
Definition: G4VEmModel.hh:699
G4PhysicsTable * GetCrossSectionTable()
Definition: G4VEmModel.hh:807
G4ParticleChangeForMSC * fParticleChange
G4ParticleDefinition * GetDefinition() const
const G4Material * currentMaterial
G4WentzelVIModel(G4bool comb=true, const G4String &nam="WentzelVIUni")
const G4Step * GetStep() const
G4double ComputeSafety(const G4ThreeVector &position, G4double limit=DBL_MAX)
Definition: G4VMscModel.hh:239
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
int G4int
Definition: G4Types.hh:78
void FillSecondDerivatives()
G4double SetupTarget(G4int Z, G4double cut=DBL_MAX)
virtual G4double ComputeTruePathLengthLimit(const G4Track &track, G4double &currentMinimalStep)
static G4PhysicsTable * PreparePhysicsTable(G4PhysicsTable *physTable)
G4StepStatus
Definition: G4StepStatus.hh:49
G4StepPoint * GetPreStepPoint() const
G4double GetEnergy(const G4ParticleDefinition *part, G4double range, const G4MaterialCutsCouple *couple)
Definition: G4VMscModel.hh:309
G4double density
Definition: TRTMaterials.hh:39
G4double ComputeTransportCrossSectionPerAtom(G4double CosThetaMax)
std::vector< G4double > xsecn
const G4double * GetVecNbOfAtomsPerVolume() const
Definition: G4Material.hh:206
const G4MaterialCutsCouple * CurrentCouple() const
Definition: G4VEmModel.hh:433
#define G4UniformRand()
Definition: Randomize.hh:95
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double KineticEnergy, G4double AtomicNumber, G4double AtomicWeight=0., G4double cut=DBL_MAX, G4double emax=DBL_MAX)
const G4ThreeVector & GetPosition() const
G4double GetRange(const G4ParticleDefinition *part, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
Definition: G4VMscModel.hh:289
G4ParticleChangeForMSC * GetParticleChangeForMSC(const G4ParticleDefinition *p=0)
Definition: G4VMscModel.cc:89
bool G4bool
Definition: G4Types.hh:79
G4double SecondMoment(const G4ParticleDefinition *, const G4MaterialCutsCouple *, G4double kineticEnergy)
G4double SetupKinematic(G4double kinEnergy, const G4Material *mat)
void PutValue(size_t index, G4double theValue)
G4double ComputeTransportXSectionPerVolume(G4double cosTheta)
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
const G4int n
G4double Energy(size_t index) const
G4double ComputeGeomLimit(const G4Track &, G4double &presafety, G4double limit)
Definition: G4VMscModel.hh:257
G4ThreeVector fDisplacement
Definition: G4VMscModel.hh:186
G4double GetTransportMeanFreePath(const G4ParticleDefinition *part, G4double kinEnergy)
Definition: G4VMscModel.hh:346
G4double GetRadlen() const
Definition: G4Material.hh:220
static const G4double e1
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4double G4Log(G4double x)
Definition: G4Log.hh:230
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:183
void ProposeMomentumDirection(const G4ThreeVector &Pfinal)
static G4ProductionCutsTable * GetProductionCutsTable()
static const double eV
Definition: G4SIunits.hh:194
G4double ComputeElectronCrossSection(G4double CosThetaMin, G4double CosThetaMax)
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
const G4int minNCollisions
int G4lrint(double ad)
Definition: templates.hh:163
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4double facsafety
Definition: G4VMscModel.hh:179
void SetupParticle(const G4ParticleDefinition *)
const G4DataVector * currentCuts
void StartTracking(G4Track *)
G4PhysicsTable * GetSecondMomentTable()
G4double ComputeNuclearCrossSection(G4double CosThetaMin, G4double CosThetaMax)
static G4EmParameters * Instance()
G4double PolarAngleLimit() const
Definition: G4VEmModel.hh:643
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
const G4ParticleDefinition * particle
G4double GetSafety() const
G4double ComputeSecondMoment(const G4ParticleDefinition *, G4double kineticEnergy)
G4MscStepLimitType steppingAlgorithm
Definition: G4VMscModel.hh:187
G4PhysicsTable * fSecondMoments
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
G4bool GetFlag(size_t i) const
double G4double
Definition: G4Types.hh:76
virtual G4double ComputeTrueStepLength(G4double geomStepLength)
virtual void InitialiseLocal(const G4ParticleDefinition *, G4VEmModel *masterModel)
G4ProductionCuts * GetProductionCuts() const
#define DBL_MAX
Definition: templates.hh:83
static const double mm
Definition: G4SIunits.hh:102
void Initialise(const G4ParticleDefinition *, G4double CosThetaLim)
virtual G4double ComputeGeomPathLength(G4double truePathLength)
G4ThreeVector & SampleSingleScattering(G4double CosThetaMin, G4double CosThetaMax, G4double elecRatio=0.0)