92 #include "G4String.hh"
108 std::vector<double> G4GoudsmitSaundersonTable::gMoliereBc;
109 std::vector<double> G4GoudsmitSaundersonTable::gMoliereXc2;
127 fMottCorrection =
nullptr;
151 if (fMottCorrection) {
152 delete fMottCorrection;
153 fMottCorrection =
nullptr;
188 if (!fMottCorrection) {
191 fMottCorrection->Initialise();
195 if (fMottCorrection) {
229 if (rand0<(1.+lambdaval)*expn) {
233 if (cost<-1.0) cost = -1.0;
234 if (cost>1.0) cost = 1.0;
237 sint = std::sqrt(dum0*(2.0-dum0));
256 prob = cumprob = expn;
261 for (
G4int iel=1; iel<10; ++iel) {
270 cursint = dum0*(2.0-dum0);
274 if (cursint>1.0
e-20) {
275 cursint = std::sqrt(cursint);
277 cost = cost*curcost-sint*cursint*std::cos(curphi);
278 sint = std::sqrt(
std::max(0.0, (1.0-cost)*(1.0+cost)));
294 cost =
SampleCosTheta(lambdaval, qval, scra, lekin, beta2, matindx, gsDtr, mcekini, mcdelti, transfPar, isfirst);
296 if (cost<-1.0) cost = -1.0;
297 if (cost> 1.0) cost = 1.0;
300 sint = std::sqrt(dum0*(2.0-dum0));
323 G4double val = fMottCorrection->GetMottRejectionValue(lekin, beta2, qval, cost, matindx, mcekini, mcdelti);
327 val = fMottCorrection->GetMottRejectionValue(lekin, beta2, qval, cost, matindx, mcekini, mcdelti);
346 G4int indxl = rndm*ndatm1;
355 return 1.-(2.0*transfpar*sample)/(1.0-sample+transfpar);
398 lamIndx = (
G4int)(pIndxH);
399 pIndxH = pIndxH-lamIndx;
407 pIndxH = (qval-minQVal)*invDelQ;
408 qIndx = (
G4int)(pIndxH);
409 pIndxH = pIndxH-qIndx;
415 G4int indx = lamIndx*numQVal+qIndx;
426 if (lambdaval>10.0) {
427 transfpar = 0.5*(-2.77164+lLambda*( 2.94874-lLambda*(0.1535754-lLambda*0.00552888) ));
429 transfpar = 0.5*(1.347+lLambda*(0.209364-lLambda*(0.45525-lLambda*(0.50142-lLambda*0.081234))));
431 transfpar *= (lambdaval+4.0)*scra;
439 char* path = getenv(
"G4LEDATA");
441 G4Exception(
"G4GoudsmitSaundersonTable::LoadMSCData()",
"em0006",
443 "Environment variable G4LEDATA not defined");
450 G4String fname = str1 + std::to_string(il);
452 if (!infile.is_open()) {
453 G4String msgc =
"Cannot open file: " + fname;
454 G4Exception(
"G4GoudsmitSaundersonTable::LoadMSCData()",
"em0006",
465 infile >> ddummy; infile >> ddummy;
480 G4String fname = str2 + std::to_string(il);
482 if (!infile.is_open()) {
483 G4String msgc =
"Cannot open file: " + fname;
484 G4Exception(
"G4GoudsmitSaundersonTable::LoadMSCData()",
"em0006",
498 infile >> ddummy; infile >> ddummy;
520 G4double cost = 1.-2.0*scra*rand1/(1.0-rand1+scra);
529 G4double val = fMottCorrection->GetMottRejectionValue(lekin, beta2, q1, cost,
530 matindx, ekindx, deltindx);
534 cost = 1.-2.0*scra*rand1/(1.0-rand1+scra);
536 val = fMottCorrection->GetMottRejectionValue(lekin, beta2, q1, cost, matindx,
548 fMottCorrection->GetMottCorrectionFactors(logekin, beta2, matindx, mcToScr, mcToQ1, mcToG2PerG1);
557 const G4double finstrc2 = 5.325135453E-5;
561 size_t numMaterials = theMaterialTable->size();
563 if(gMoliereBc.size()<numMaterials) {
564 gMoliereBc.resize(numMaterials);
565 gMoliereXc2.resize(numMaterials);
574 for (
size_t imat=0; imat<numMaterials; ++imat) {
575 const G4Material* theMaterial = (*theMaterialTable)[imat];
587 for(
G4int ielem = 0; ielem < numelems; ielem++) {
588 G4double zet = (*theElemVect)[ielem]->GetZ();
592 G4double iwa = (*theElemVect)[ielem]->GetN();
593 G4double ipz = theNbAtomsPerVolVect[ielem]/theTotNbAtomsPerVol;
596 ze += dum*(-2.0/3.0)*
G4Log(zet);
597 zx += dum*
G4Log(1.0+3.34*finstrc2*zet*zet);
603 gMoliereXc2[theMaterial->
GetIndex()] = const2*density*zs/sa;
649 for (
size_t imc=0; imc<numMatCuts; ++imc) {
679 for (
G4int ie=0; ie<numEbins; ++ie) {
692 G4double gm =
G4Log(0.5*tau/tauCut) + (1.+dum0*dum0)*
G4Log(2.*(tau-tauCut+2.)/(tau+4.))
693 - 0.25*(tau+2.)*( tau+2.+2.*(2.*tau+1.)/(dum1*dum1))*
694 G4Log((tau+4.)*(tau-tauCut)/tau/(tau-tauCut+2.))
695 + 0.5*(tau-2*tauCut)*(tau+2.)*(1./(tau-tauCut)-1./(dum1*dum1));
702 scpCorr = 1.-gm*z0/(z0*(z0+1.));
static constexpr G4int gQNUM2
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
T max(const T t1, const T t2)
brief Return the largest of the two arguments
std::vector< SCPCorrection * > fSCPCPerMatCuts
void GetMottCorrectionFactors(G4double logekin, G4double beta2, G4int matindx, G4double &mcToScr, G4double &mcToQ1, G4double &mcToG2PerG1)
static constexpr G4double gQMIN1
static constexpr double cm3
G4double fInvLogDeltaLambda
static G4MaterialTable * GetMaterialTable()
static constexpr G4double gQMAX1
static constexpr G4int gQNUM1
static constexpr double g
G4double SingleScattering(G4double lambdaval, G4double scra, G4double lekin, G4double beta2, G4int matindx)
static constexpr G4double gLAMBMIN
static G4bool gIsInitialised
G4bool Sampling(G4double lambdaval, G4double qval, G4double scra, G4double &cost, G4double &sint, G4double lekin, G4double beta2, G4int matindx, GSMSCAngularDtr **gsDtr, G4int &mcekini, G4int &mcdelti, G4double &transfPar, G4bool isfirst)
const G4ElementVector * GetElementVector() const
G4GoudsmitSaundersonTable(G4bool iselectron)
const G4double * GetVecNbOfAtomsPerVolume() const
void Initialise(G4double lownergylimit, G4double highenergylimit)
G4double GetMoliereBc(G4int matindx)
const std::vector< G4double > * GetEnergyCutsVector(size_t pcIdx) const
~G4GoudsmitSaundersonTable()
G4double G4Log(G4double x)
GSMSCAngularDtr * GetGSAngularDtr(G4double scra, G4double &lambdaval, G4double &qval, G4double &transfpar)
static constexpr double cm
G4double GetMoliereXc2(G4int matindx)
static constexpr G4double gLAMBMAX
static constexpr double electron_mass_c2
G4double SampleGSSRCosTheta(const GSMSCAngularDtr *gsDrt, G4double transfpar)
static constexpr double MeV
double A(double temperature)
static const G4int nlooplim
static std::vector< GSMSCAngularDtr * > gGSMSCAngularDistributions1
size_t GetTableSize() const
std::vector< G4Material * > G4MaterialTable
G4double ComputeScatteringPowerCorrection(const G4MaterialCutsCouple *matcut, G4double ekin)
static constexpr G4double gQMIN2
static constexpr double twopi
static G4ProductionCutsTable * GetProductionCutsTable()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::vector< G4Element * > G4ElementVector
static constexpr G4int gLAMBNUM
G4IonisParamMat * GetIonisation() const
G4double GetZeffective() const
static std::vector< GSMSCAngularDtr * > gGSMSCAngularDistributions2
void InitMoliereMSCParams()
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
const G4Material * GetMaterial() const
G4double SampleCosTheta(G4double lambdaval, G4double qval, G4double scra, G4double lekin, G4double beta2, G4int matindx, GSMSCAngularDtr **gsDtr, G4int &mcekini, G4int &mcdelti, G4double &transfPar, G4bool isfirst)
G4double fHighEnergyLimit
G4double GetTotNbOfAtomsPerVolume() const
static constexpr G4double gQMAX2
static constexpr double keV
size_t GetNumberOfElements() const
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4double GetDensity() const