Geant4  10.02.p03
G4GoudsmitSaundersonTable Class Reference

#include <G4GoudsmitSaundersonTable.hh>

Collaboration diagram for G4GoudsmitSaundersonTable:

Public Member Functions

 G4GoudsmitSaundersonTable ()
 
 ~G4GoudsmitSaundersonTable ()
 
void Initialise ()
 
G4double SampleCosTheta (G4double, G4double, G4double, G4double, G4double, G4double)
 
G4double SampleCosThetaII (G4double, G4double, G4double, G4double, G4double, G4double)
 
G4double GetScreeningParam (G4double)
 
void Sampling (G4double, G4double, G4double, G4double &, G4double &)
 
G4double GetMoliereBc (G4int matindx)
 
G4double GetMoliereXc2 (G4int matindx)
 

Private Member Functions

G4GoudsmitSaundersonTableoperator= (const G4GoudsmitSaundersonTable &right)
 
 G4GoudsmitSaundersonTable (const G4GoudsmitSaundersonTable &)
 
void LoadMSCData ()
 
void LoadMSCDataII ()
 
void InitMoliereMSCParams ()
 

Static Private Attributes

static G4bool fgIsInitialised = FALSE
 
static const G4int fgNumLambdas = 76
 
static const G4int fgNumLamG1II = 22
 
static const G4double fgLambdaValues []
 
static std::vector< G4double > * fgMoliereBc = 0
 
static std::vector< G4double > * fgMoliereXc2 = 0
 

Detailed Description

Definition at line 72 of file G4GoudsmitSaundersonTable.hh.

Constructor & Destructor Documentation

◆ G4GoudsmitSaundersonTable() [1/2]

G4GoudsmitSaundersonTable::G4GoudsmitSaundersonTable ( )
inline

Definition at line 76 of file G4GoudsmitSaundersonTable.hh.

76 {};
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~G4GoudsmitSaundersonTable()

G4GoudsmitSaundersonTable::~G4GoudsmitSaundersonTable ( )

Definition at line 299 of file G4GoudsmitSaundersonTable.cc.

299  {
300  if(fgMoliereBc){
301  delete fgMoliereBc;
302  fgMoliereBc = 0;
303  }
304  if(fgMoliereXc2){
305  delete fgMoliereXc2;
306  fgMoliereXc2 = 0;
307  }
309 }
#define FALSE
Definition: globals.hh:52
static std::vector< G4double > * fgMoliereBc
static std::vector< G4double > * fgMoliereXc2
Here is the caller graph for this function:

◆ G4GoudsmitSaundersonTable() [2/2]

G4GoudsmitSaundersonTable::G4GoudsmitSaundersonTable ( const G4GoudsmitSaundersonTable )
private

Member Function Documentation

◆ GetMoliereBc()

G4double G4GoudsmitSaundersonTable::GetMoliereBc ( G4int  matindx)
inline

Definition at line 104 of file G4GoudsmitSaundersonTable.hh.

104 {return (*fgMoliereBc)[matindx];}
static std::vector< G4double > * fgMoliereBc
Here is the caller graph for this function:

◆ GetMoliereXc2()

G4double G4GoudsmitSaundersonTable::GetMoliereXc2 ( G4int  matindx)
inline

Definition at line 105 of file G4GoudsmitSaundersonTable.hh.

105 {return (*fgMoliereXc2)[matindx];}
static std::vector< G4double > * fgMoliereXc2
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetScreeningParam()

G4double G4GoudsmitSaundersonTable::GetScreeningParam ( G4double  G1)

Definition at line 563 of file G4GoudsmitSaundersonTable.cc.

563  {
564  if(G1<fgG1Values[0]) return fgScreeningParam[0];
565  if(G1>fgG1Values[fgNumScreeningParams-1]) return fgScreeningParam[fgNumScreeningParams-1];
566  // normal case
567  const G4double lng10 = -2.30258509299405e+01; //log(fgG1Values[0]);
568  const G4double invlng1 = 6.948711710452e+00; //1./log(fgG1Values[i+1]/fgG1Values[i])
569  G4double logG1 = G4Log(G1);
570  G4int k = (G4int)((logG1-lng10)*invlng1);
571  return G4Exp(logG1*fgSrcAValues[k])*fgSrcBValues[k]; // log-log linear
572 }
int G4int
Definition: G4Types.hh:78
G4double G4Log(G4double x)
Definition: G4Log.hh:230
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:183
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Initialise()

void G4GoudsmitSaundersonTable::Initialise ( )

Definition at line 288 of file G4GoudsmitSaundersonTable.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitMoliereMSCParams()

void G4GoudsmitSaundersonTable::InitMoliereMSCParams ( )
private

Definition at line 747 of file G4GoudsmitSaundersonTable.cc.

747  {
748  const G4double const1 = 7821.6; // [cm2/g]
749  const G4double const2 = 0.1569; // [cm2 MeV2 / g]
750  const G4double finstrc2 = 5.325135453E-5; // fine-structure const. square
751 
752  G4MaterialTable *theMaterialTable = G4Material::GetMaterialTable();
753  // get number of materials in the table
754  unsigned int numMaterials = theMaterialTable->size();
755  // make sure that we have long enough vectors
756  if(!fgMoliereBc) {
757  fgMoliereBc = new std::vector<G4double>(numMaterials);
758  fgMoliereXc2 = new std::vector<G4double>(numMaterials);
759  } else {
760  fgMoliereBc->resize(numMaterials);
761  fgMoliereXc2->resize(numMaterials);
762  }
763 
764  const G4double xims = 0.0; // use xi_MS = 0.0 value now. We will see later on.
765  for(unsigned int imat = 0; imat < numMaterials; ++imat) {
766  const G4Material *theMaterial = (*theMaterialTable)[imat];
767  const G4ElementVector *theElemVect = theMaterial->GetElementVector();
768 
769  const G4int numelems = theMaterial->GetNumberOfElements();
770  const G4double* theFractionVect = theMaterial->GetFractionVector();
771  G4double zs = 0.0;
772  G4double zx = 0.0;
773  G4double ze = 0.0;
774 
775  for(G4int ielem = 0; ielem < numelems; ielem++) {
776  G4double izet = (*theElemVect)[ielem]->GetZ();
777  G4double iwa = (*theElemVect)[ielem]->GetN();
778 // G4int ipz = theAtomsVect[ielem];
779  G4double ipz = theFractionVect[ielem];
780 
781  G4double dum = ipz/iwa*izet*(izet+xims);
782  zs += dum;
783  ze += dum*(-2.0/3.0)*G4Log(izet);
784  zx += dum*G4Log(1.0+3.34*finstrc2*izet*izet);
785 // wa += ipz*iwa;
786  }
787  G4double density = theMaterial->GetDensity()*CLHEP::cm3/CLHEP::g; // [g/cm3]
788 
789  (*fgMoliereBc)[theMaterial->GetIndex()] = const1*density*zs*G4Exp(ze/zs)/G4Exp(zx/zs); //[1/cm]
790  (*fgMoliereXc2)[theMaterial->GetIndex()] = const2*density*zs; // [MeV2/cm]
791 
792  // change to Geant4 internal units of 1/length and energ2/length
793  (*fgMoliereBc)[theMaterial->GetIndex()] *= 1.0/CLHEP::cm;
794  (*fgMoliereXc2)[theMaterial->GetIndex()] *= CLHEP::MeV*CLHEP::MeV/CLHEP::cm;
795  }
796 
797 }
std::vector< G4Element * > G4ElementVector
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:589
std::vector< G4Material * > G4MaterialTable
const G4double * GetFractionVector() const
Definition: G4Material.hh:194
G4double GetDensity() const
Definition: G4Material.hh:180
size_t GetIndex() const
Definition: G4Material.hh:262
int G4int
Definition: G4Types.hh:78
static const double cm
Definition: SystemOfUnits.h:98
G4double density
Definition: TRTMaterials.hh:39
static const double g
static std::vector< G4double > * fgMoliereBc
G4double G4Log(G4double x)
Definition: G4Log.hh:230
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:183
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
static std::vector< G4double > * fgMoliereXc2
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
double G4double
Definition: G4Types.hh:76
static const double cm3
static const double MeV
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadMSCData()

void G4GoudsmitSaundersonTable::LoadMSCData ( )
private

Definition at line 575 of file G4GoudsmitSaundersonTable.cc.

575  {
576  G4double dum;
577  char basename[512];
578  char* path = getenv("G4LEDATA");
579  if (!path) {
580  G4Exception("G4GoudsmitSaundersonTable::LoadMSCData()","em0006",
582  "Environment variable G4LEDATA not defined");
583  return;
584  }
585 
586  std::string pathString(path);
587  sprintf(basename,"inverseq2CDF");
588  for(int k = 0; k < fgNumLambdas; ++k){
589  char fname[512];
590  sprintf(fname,"%s/msc_GS/%s_%d",path,basename,k);
591  std::ifstream infile(fname,std::ios::in);
592  if(!infile.is_open()){
593  char msgc[512];
594  sprintf(msgc,"Cannot open file: %s .",fname);
595  G4Exception("G4GoudsmitSaundersonTable::LoadMSCData()","em0006",
597  msgc);
598  return;
599  }
600 
601  int limk = k*fgNumUvalues*fgNumLamG1;
602  for(int i = 0; i < fgNumUvalues; ++i)
603  for(int j = 0; j < fgNumLamG1+1; ++j)
604  if(j==0) infile >> dum;
605  else infile >> fgInverseQ2CDFs[limk+(j-1)*fgNumUvalues+i];
606 
607  infile.close();
608  }
609 
610 
611  sprintf(basename,"inverseq2CDFRatInterpPA");
612  for(int k = 0; k < fgNumLambdas; ++k){
613  char fname[512];
614  sprintf(fname,"%s/msc_GS/%s_%d",path,basename,k);
615  std::ifstream infile(fname,std::ios::in);
616  if(!infile.is_open()){
617  char msgc[512];
618  sprintf(msgc,"Cannot open file: %s .",fname);
619  G4Exception("G4GoudsmitSaundersonTable::LoadMSCData()","em0006",
621  msgc);
622  return;
623  }
624 
625  int limk = k*fgNumUvalues*fgNumLamG1;
626  for(int i = 0; i < fgNumUvalues; ++i)
627  for(int j = 0; j < fgNumLamG1+1; ++j)
628  if(j==0) infile >> dum;
629  else infile >> fgInterParamsA2[limk+(j-1)*fgNumUvalues+i];
630 
631  infile.close();
632  }
633 
634  sprintf(basename,"inverseq2CDFRatInterpPB");
635  for(int k = 0; k < fgNumLambdas; ++k){
636  char fname[512];
637  sprintf(fname,"%s/msc_GS/%s_%d",path,basename,k);
638  std::ifstream infile(fname,std::ios::in);
639  if(!infile.is_open()){
640  char msgc[512];
641  sprintf(msgc,"Cannot open file: %s .",fname);
642  G4Exception("G4GoudsmitSaundersonTable::LoadMSCData()","em0006",
644  msgc);
645  return;
646  }
647 
648  int limk = k*fgNumUvalues*fgNumLamG1;
649  for(int i = 0; i < fgNumUvalues; ++i)
650  for(int j = 0; j < fgNumLamG1+1; ++j)
651  if(j==0) infile >> dum;
652  else infile >> fgInterParamsB2[limk+(j-1)*fgNumUvalues+i];
653 
654  infile.close();
655  }
656 }
ifstream in
Definition: comparison.C:7
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadMSCDataII()

void G4GoudsmitSaundersonTable::LoadMSCDataII ( )
private

Definition at line 661 of file G4GoudsmitSaundersonTable.cc.

661  {
662 G4double dum;
663 char basename[512];
664 char* path = getenv("G4LEDATA");
665 if (!path) {
666  G4Exception("G4GoudsmitSaundersonTable::LoadMSCDataII()","em0006",
668  "Environment variable G4LEDATA not defined");
669  return;
670 }
671 
672 
673  std::string pathString(path);
674  sprintf(basename,"inverseq2CDFII");
675  for(int k = 0; k < fgNumLambdas; ++k){
676  char fname[512];
677  sprintf(fname,"%s/msc_GS/%s_%d",path,basename,k);
678  std::ifstream infile(fname,std::ios::in);
679  if(!infile.is_open()){
680  char msgc[512];
681  sprintf(msgc,"Cannot open file: %s .",fname);
682  G4Exception("G4GoudsmitSaundersonTable::LoadMSCDataII()","em0006",
684  msgc);
685  return;
686  }
687 
688  int limk = k*fgNumUvalues*fgNumLamG1II;
689  for(int i = 0; i < fgNumUvalues; ++i)
690  for(int j = 0; j < fgNumLamG1II+1; ++j)
691  if(j==0) infile >> dum;
692  else infile >> fgInverseQ2CDFsII[limk+(j-1)*fgNumUvalues+i];
693 
694  infile.close();
695  }
696 
697 
698  sprintf(basename,"inverseq2CDFRatInterpPAII");
699  for(int k = 0; k < fgNumLambdas; ++k){
700  char fname[512];
701  sprintf(fname,"%s/msc_GS/%s_%d",path,basename,k);
702  std::ifstream infile(fname,std::ios::in);
703  if(!infile.is_open()){
704  char msgc[512];
705  sprintf(msgc,"Cannot open file: %s .",fname);
706  G4Exception("G4GoudsmitSaundersonTable::LoadMSCDataII()","em0006",
708  msgc);
709  return;
710  }
711 
712  int limk = k*fgNumUvalues*fgNumLamG1II;
713  for(int i = 0; i < fgNumUvalues; ++i)
714  for(int j = 0; j < fgNumLamG1II+1; ++j)
715  if(j==0) infile >> dum;
716  else infile >> fgInterParamsA2II[limk+(j-1)*fgNumUvalues+i];
717 
718  infile.close();
719  }
720 
721  sprintf(basename,"inverseq2CDFRatInterpPBII");
722  for(int k = 0; k < fgNumLambdas; ++k){
723  char fname[512];
724  sprintf(fname,"%s/msc_GS/%s_%d",path,basename,k);
725  std::ifstream infile(fname,std::ios::in);
726  if(!infile.is_open()){
727  char msgc[512];
728  sprintf(msgc,"Cannot open file: %s .",fname);
729  G4Exception("G4GoudsmitSaundersonTable::LoadMSCDataII()","em0006",
731  msgc);
732  return;
733  }
734 
735  int limk = k*fgNumUvalues*fgNumLamG1II;
736  for(int i = 0; i < fgNumUvalues; ++i)
737  for(int j = 0; j < fgNumLamG1II+1; ++j)
738  if(j==0) infile >> dum;
739  else infile >> fgInterParamsB2II[limk+(j-1)*fgNumUvalues+i];
740 
741  infile.close();
742  }
743 }
ifstream in
Definition: comparison.C:7
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

G4GoudsmitSaundersonTable& G4GoudsmitSaundersonTable::operator= ( const G4GoudsmitSaundersonTable right)
private
Here is the caller graph for this function:

◆ SampleCosTheta()

G4double G4GoudsmitSaundersonTable::SampleCosTheta ( G4double  lambdavalue,
G4double  lamG1value,
G4double  screeningparam,
G4double  rndm1,
G4double  rndm2,
G4double  rndm3 
)

Definition at line 314 of file G4GoudsmitSaundersonTable.cc.

316  {
317  const G4double lnl0 = 0.0; //log(fgLambdaValues[0]);
318  const G4double invlnl = 6.5144172285e+00; //1./log(fgLambdaValues[i+1]/fgLambdaValues[i])
319  G4double logLambdaVal = G4Log(lambdavalue);
320  G4int lambdaindx = (G4int)((logLambdaVal-lnl0)*invlnl);
321 
322  const G4double dd = 1.0/0.0499; // delta
323  G4int lamg1indx = (G4int)((lamG1value-fgLamG1Values[0])*dd);
324 
325  G4double probOfLamJ = G4Log(fgLambdaValues[lambdaindx+1]/lambdavalue)*invlnl;
326  if(rndm1 > probOfLamJ)
327  ++lambdaindx;
328 
329  // store 1.0/(fgLamG1Values[lamg1indx+1]-fgLamG1Values[lamg1indx]) const value
330  const G4double onePerLamG1Diff = dd;
331  G4double probOfLamG1J = (fgLamG1Values[lamg1indx+1]-lamG1value)*onePerLamG1Diff;
332  if(rndm2 > probOfLamG1J)
333  ++lamg1indx;
334 
335  G4int begin = lambdaindx*(fgNumLamG1*fgNumUvalues)+lamg1indx*fgNumUvalues;
336 
337  // sample bin
338  G4int indx = (G4int)(rndm3*100); // value/delatU ahol deltaU = 0.01; find u-indx
339  G4double cp1 = fgUValues[indx];
340 // G4double cp2 = fgUValues[indx+1];
341  indx +=begin;
342 
343  G4double u1 = fgInverseQ2CDFs[indx];
344  G4double u2 = fgInverseQ2CDFs[indx+1];
345 
346  G4double dum1 = rndm3 - cp1;
347  const G4double dum2 = 0.01;//cp2-cp1; // this is constans 0.01
348  const G4double dum22 = 0.0001;
349  // rational interpolation of the inverse CDF
350  G4double sample= u1+(1.0+fgInterParamsA2[indx]+fgInterParamsB2[indx])*dum1*dum2/(dum22+
351  dum1*dum2*fgInterParamsA2[indx]+fgInterParamsB2[indx]*dum1*dum1)*(u2-u1);
352 
353  // transform back u to cos(theta) :
354  // -compute parameter value a = w2*screening_parameter
355  G4double t = logLambdaVal;
356  G4double dum;
357  if(lambdavalue >= 10.0)
358  dum = 0.5*(-2.77164+t*( 2.94874-t*(0.1535754-t*0.00552888) ));
359  else
360  dum = 0.5*(1.347+t*(0.209364-t*(0.45525-t*(0.50142-t*0.081234))));
361 
362  G4double a = dum*(lambdavalue+4.0)*screeningparam;
363 
364  // this is the sampled cos(theta)
365  return (2.0*a*sample)/(1.0-sample+a);
366 }
static const G4double fgLambdaValues[]
int G4int
Definition: G4Types.hh:78
G4double G4Log(G4double x)
Definition: G4Log.hh:230
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SampleCosThetaII()

G4double G4GoudsmitSaundersonTable::SampleCosThetaII ( G4double  lambdavalue,
G4double  lamG1value,
G4double  screeningparam,
G4double  rndm1,
G4double  rndm2,
G4double  rndm3 
)

Definition at line 371 of file G4GoudsmitSaundersonTable.cc.

373  {
374  const G4double lnl0 = 0.0; //log(fgLambdaValues[0]);
375  const G4double invlnl = 6.5144172285e+00; //1./log(fgLambdaValues[i+1]/fgLambdaValues[i])
376  G4double logLambdaVal = G4Log(lambdavalue);
377  G4int lambdaindx = (G4int)((logLambdaVal-lnl0)*invlnl);
378 
379  const G4double dd = 1.0/0.333; // delta
380  G4int lamg1indx = (G4int)((lamG1value-fgLamG1ValuesII[0])*dd);
381 
382  G4double probOfLamJ = G4Log(fgLambdaValues[lambdaindx+1]/lambdavalue)*invlnl;
383  if(rndm1 > probOfLamJ)
384  ++lambdaindx;
385 
386  // store 1.0/(fgLamG1Values[lamg1indx+1]-fgLamG1Values[lamg1indx]) const value
387  const G4double onePerLamG1Diff = dd;
388  G4double probOfLamG1J = (fgLamG1ValuesII[lamg1indx+1]-lamG1value)*onePerLamG1Diff;
389  if(rndm2 > probOfLamG1J)
390  ++lamg1indx;
391 
392  // protection against cases when the sampled lamG1 values are not possible due
393  // to the fact that G1<=1 (G1 = lam_el/lam_tr1)
394  // -- in theory it should never happen when lamg1indx=0 but check it just to be sure
395  if(fgLamG1ValuesII[lamg1indx]>lambdavalue && lamg1indx>0)
396  --lamg1indx;
397 
398 
399  G4int begin = lambdaindx*(fgNumLamG1II*fgNumUvalues)+lamg1indx*fgNumUvalues;
400 
401  // sample bin
402  G4int indx = (G4int)(rndm3*100); // value/delatU ahol deltaU = 0.01; find u-indx
403  G4double cp1 = fgUValues[indx];
404 // G4double cp2 = fgUValues[indx+1];
405  indx +=begin;
406 
407  G4double u1 = fgInverseQ2CDFsII[indx];
408  G4double u2 = fgInverseQ2CDFsII[indx+1];
409 
410  G4double dum1 = rndm3 - cp1;
411  const G4double dum2 = 0.01;//cp2-cp1; // this is constans 0.01
412  const G4double dum22 = 0.0001;
413  // rational interpolation of the inverse CDF
414  G4double sample= u1+(1.0+fgInterParamsA2II[indx]+fgInterParamsB2II[indx])*dum1*dum2/(dum22+
415  dum1*dum2*fgInterParamsA2II[indx]+fgInterParamsB2II[indx]*dum1*dum1)*(u2-u1);
416 
417  // transform back u to cos(theta) :
418  // -compute parameter value a = w2*screening_parameter
419  G4double t = logLambdaVal;
420  G4double dum = 0.;
421  if(lambdavalue >= 10.0)
422  dum = 0.5*(-2.77164+t*( 2.94874-t*(0.1535754-t*0.00552888) ));
423  else
424  dum = 0.5*(1.347+t*(0.209364-t*(0.45525-t*(0.50142-t*0.081234))));
425 
426  G4double a = dum*(lambdavalue+4.0)*screeningparam;
427 
428  // this is the sampled cos(theta)
429  return (2.0*a*sample)/(1.0-sample+a);
430 }
static const G4double fgLambdaValues[]
int G4int
Definition: G4Types.hh:78
G4double G4Log(G4double x)
Definition: G4Log.hh:230
double G4double
Definition: G4Types.hh:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Sampling()

void G4GoudsmitSaundersonTable::Sampling ( G4double  lambdavalue,
G4double  lamG1value,
G4double  scrPar,
G4double cost,
G4double sint 
)

**** let it izotropic if we are above the grid i.e. true path length is long

Definition at line 435 of file G4GoudsmitSaundersonTable.cc.

436  {
437  G4double rand0 = G4UniformRand();
438  G4double expn = G4Exp(-lambdavalue);
439 
440  //
441  // no scattering case
442  //
443  if(rand0 < expn) {
444  cost = 1.0;
445  sint = 0.0;
446  return;
447  }
448 
449  //
450  // single scattering case : sample (analitically) from the single scattering PDF
451  // that corresponds to the modified-Wentzel DCS i.e.
452  // Wentzel DCS that gives back the PWA first-transport mfp
453  //
454  if( rand0 < (1.+lambdavalue)*expn) {
455  G4double rand1 = G4UniformRand();
456  // sampling 1-cos(theta)
457  G4double dum0 = 2.0*scrPar*rand1/(1.0 - rand1 + scrPar);
458  // add protections
459  if(dum0 < 0.0) dum0 = 0.0;
460  else if(dum0 > 2.0 ) dum0 = 2.0;
461  // compute cos(theta) and sin(theta)
462  cost = 1.0 - dum0;
463  sint = std::sqrt(dum0*(2.0 - dum0));
464  return;
465  }
466 
467  //
468  // handle this case:
469  // -lambdavalue < 1 i.e. mean #elastic events along the step is < 1 but
470  // the currently sampled case is not 0 or 1 scattering. [Our minimal
471  // lambdavalue (that we have precomputed, transformed angular distributions
472  // stored in a form of equally probabe intervalls together with rational
473  // interp. parameters) is 1.]
474  // -probability of having n elastic events follows Poisson stat. with
475  // lambdavalue parameter.
476  // -the max. probability (when lambdavalue=1) of having more than one
477  // elastic events is 0.2642411 and the prob of having 2,3,..,n elastic
478  // events decays rapidly with n. So set a max n to 10.
479  // -sampling of this cases is done in a one-by-one single elastic event way
480  // where the current #elastic event is sampled from the Poisson distr.
481  // -(other possibility would be to use lambdavalue=1 distribution because
482  // they are very close)
483  if(lambdavalue < 1.0) {
484  G4double prob, cumprob;
485  prob = cumprob = expn;
486  G4double curcost,cursint;
487  // init cos(theta) and sin(theta) to the zero scattering values
488  cost = 1.0;
489  sint = 0.0;
490 
491  for(G4int iel = 1; iel < 10; ++iel){
492  // prob of having iel scattering from Poisson
493  prob *= lambdavalue/(G4double)iel;
494  cumprob += prob;
495  //
496  //sample cos(theta) from the singe scattering pdf
497  //
498  G4double rand1 = G4UniformRand();
499  // sampling 1-cos(theta)
500  G4double dum0 = 2.0*scrPar*rand1/(1.0 - rand1 + scrPar);
501  // compute cos(theta) and sin(theta)
502  curcost = 1.0 - dum0;
503  cursint = dum0*(2.0 - dum0);
504  //
505  // if we got current deflection that is not too small
506  // then update cos(theta) sin(theta)
507  if(cursint > 1.0e-20){
508  cursint = std::sqrt(cursint);
510  cost = cost*curcost - sint*cursint*std::cos(curphi);
511  sint = std::sqrt(std::max(0.0, (1.0-cost)*(1.0+cost)));
512  }
513  //
514  // check if we have done enough scattering i.e. sampling from the Poisson
515  if( rand0 < cumprob)
516  return;
517  }
518  // if reached the max iter i.e. 10
519  return;
520  }
521 
522 
524  // IT IS DONE NOW IN THE MODEL
525  //if(lamG1value>fgLamG1Values[fgNumLamG1-1]) {
526  // cost = 1.-2.*G4UniformRand();
527  // sint = std::sqrt((1.-cost)*(1.+cost));
528  // return;
529  //}
530 
531 
532  //
533  // multiple scattering case with lambdavalue >= 1:
534  // - use the precomputed and transformed Goudsmit-Saunderson angular
535  // distributions that are stored in a form of equally probabe intervalls
536  // together with the corresponding rational interp. parameters
537  //
538  // add protections
539  if(lamG1value<fgLamG1Values[0]) lamG1value = fgLamG1Values[0];
540  if(lamG1value>fgLamG1ValuesII[fgNumLamG1II-1]) lamG1value = fgLamG1ValuesII[fgNumLamG1II-1];
541 
542  // sample 1-cos(theta) :: depending on the grids
543  G4double dum0 = 0.0;
544  if(lamG1value<fgLamG1Values[fgNumLamG1-1]) {
545  dum0 = SampleCosTheta(lambdavalue, lamG1value, scrPar, G4UniformRand(),
547 
548  } else {
549  dum0 = SampleCosThetaII(lambdavalue, lamG1value, scrPar, G4UniformRand(),
551  }
552 
553  // add protections
554  if(dum0 < 0.0) dum0 = 0.0;
555  if(dum0 > 2.0 ) dum0 = 2.0;
556 
557  // compute cos(theta) and sin(theta)
558  cost = 1.0-dum0;
559  sint = std::sqrt(dum0*(2.0 - dum0));
560 }
int G4int
Definition: G4Types.hh:78
G4double SampleCosThetaII(G4double, G4double, G4double, G4double, G4double, G4double)
#define G4UniformRand()
Definition: Randomize.hh:97
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
Definition: G4Exp.hh:183
double G4double
Definition: G4Types.hh:76
static const double twopi
Definition: SystemOfUnits.h:54
G4double SampleCosTheta(G4double, G4double, G4double, G4double, G4double, G4double)
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ fgIsInitialised

G4bool G4GoudsmitSaundersonTable::fgIsInitialised = FALSE
staticprivate

Definition at line 178 of file G4GoudsmitSaundersonTable.hh.

◆ fgLambdaValues

const G4double G4GoudsmitSaundersonTable::fgLambdaValues
staticprivate
Initial value:
={
1.000000000000e+00, 1.165914401180e+00, 1.359356390879e+00, 1.584893192461e+00,
1.847849797422e+00, 2.154434690032e+00, 2.511886431510e+00, 2.928644564625e+00,
3.414548873834e+00, 3.981071705535e+00, 4.641588833613e+00, 5.411695265465e+00,
6.309573444802e+00, 7.356422544596e+00, 8.576958985909e+00, 1.000000000000e+01,
1.165914401180e+01, 1.359356390879e+01, 1.584893192461e+01, 1.847849797422e+01,
2.154434690032e+01, 2.511886431510e+01, 2.928644564625e+01, 3.414548873834e+01,
3.981071705535e+01, 4.641588833613e+01, 5.411695265465e+01, 6.309573444802e+01,
7.356422544596e+01, 8.576958985909e+01, 1.000000000000e+02, 1.165914401180e+02,
1.359356390879e+02, 1.584893192461e+02, 1.847849797422e+02, 2.154434690032e+02,
2.511886431510e+02, 2.928644564625e+02, 3.414548873834e+02, 3.981071705535e+02,
4.641588833613e+02, 5.411695265465e+02, 6.309573444802e+02, 7.356422544596e+02,
8.576958985909e+02, 1.000000000000e+03, 1.165914401180e+03, 1.359356390879e+03,
1.584893192461e+03, 1.847849797422e+03, 2.154434690032e+03, 2.511886431510e+03,
2.928644564625e+03, 3.414548873834e+03, 3.981071705535e+03, 4.641588833613e+03,
5.411695265465e+03, 6.309573444802e+03, 7.356422544596e+03, 8.576958985909e+03,
1.000000000000e+04, 1.165914401180e+04, 1.359356390879e+04, 1.584893192461e+04,
1.847849797422e+04, 2.154434690032e+04, 2.511886431510e+04, 2.928644564625e+04,
3.414548873834e+04, 3.981071705535e+04, 4.641588833613e+04, 5.411695265465e+04,
6.309573444802e+04, 7.356422544596e+04, 8.576958985909e+04, 1.000000000000e+05
}

number of $ s/\lambda_{e}G_{1} $\f-values */ static const G4int fgNumUvalues = 101; /** number of u-vaues */ static const G4int fgNumScreeningParams = 160; /** number of A-vaues */ //@} //@{ /** girds of fixed parameter values */ /** the grid $ s/{e} $-values; size = fgNumLambdas = 76

Definition at line 135 of file G4GoudsmitSaundersonTable.hh.

◆ fgMoliereBc

std::vector< G4double > * G4GoudsmitSaundersonTable::fgMoliereBc = 0
staticprivate

the grid of $ s/\lambda_{e}G_{1} $\f-values; size = fgNumLamG1 = 11 */ static const G4double fgLamG1Values[]; static const G4double fgLamG1ValuesII[]; /** the grid of u-values; size = fgNumUvalues = 101 */ static const G4double fgUValues[]; //@} // precomputed G1(A) function as a table -> run time interpolation to determine // the screening parameter value A that gives back the given first transport // coefficient G1 static const G4double fgG1Values[]; static const G4double fgScreeningParam[]; static const G4double fgSrcAValues[]; static const G4double fgSrcBValues[]; //@{ /** Precomputed equaly probable inverse CDF-s over the 3D parameter grid plus precomputed parameters necessary for proper rational interpolation of the inverse CDF. */ static G4double fgInverseQ2CDFs[fgNumLambdas*fgNumLamG1*fgNumUvalues]; static G4double fgInterParamsA2[fgNumLambdas*fgNumLamG1*fgNumUvalues]; static G4double fgInterParamsB2[fgNumLambdas*fgNumLamG1*fgNumUvalues]; static G4double fgInverseQ2CDFsII[fgNumLambdas*fgNumLamG1II*fgNumUvalues]; static G4double fgInterParamsA2II[fgNumLambdas*fgNumLamG1II*fgNumUvalues]; static G4double fgInterParamsB2II[fgNumLambdas*fgNumLamG1II*fgNumUvalues]; //@} //@{ /** Precomputed $ b_lambda_{c} $ and $ \chi_c^{2} $\f material dependent Moliere parameters that can be used to compute the screening parameter, the elastic scattering cross section (or $ {e} $) under the screened Rutherford cross section approximation. (These are used in G4GoudsmitSaundersonMscModel if fgIsUsePWATotalXsecData is FALSE.)

Definition at line 173 of file G4GoudsmitSaundersonTable.hh.

◆ fgMoliereXc2

std::vector< G4double > * G4GoudsmitSaundersonTable::fgMoliereXc2 = 0
staticprivate

Definition at line 174 of file G4GoudsmitSaundersonTable.hh.

◆ fgNumLambdas

const G4int G4GoudsmitSaundersonTable::fgNumLambdas = 76
staticprivate

size of grids of some parameters

Definition at line 125 of file G4GoudsmitSaundersonTable.hh.

◆ fgNumLamG1II

const G4int G4GoudsmitSaundersonTable::fgNumLamG1II = 22
staticprivate

number of $ s/\lambda_{e} $\f-values */ static const G4int fgNumLamG1 = 21; /** number of $ s/{e}G_{1} $-values

Definition at line 127 of file G4GoudsmitSaundersonTable.hh.


The documentation for this class was generated from the following files: