904{
907 const G4double sumaLim = -std::log(probLim) ;
910 const G4double factor = twopi_mc2_rcl2 ;
912
913
914
915 if (aMaterial != lastMaterial)
916 {
917 lastMaterial = aMaterial;
928 }
930 beta2,suma,e0,loss,lossc ,w,electronDensity;
934 G4double Corrfac, na,alfa,rfac,namean,sa,alfa1,ea,sea;
937
938
939 if(MeanLoss < minLoss) return MeanLoss ;
940
941
944
946 ->GetEnergyCutsVector(1)))[imat];
949 G4double Tm = 2.*electron_mass_c2*tau2/(1.+2.*tau1*rmass+rmass*rmass);
950
951 if(Tm > threshold) Tm = threshold;
952
953 beta2 = tau2/(tau1*tau1);
954
955
956 if(MeanLoss >= kappa*Tm || Tm < kappa*ipotFluct)
957 {
959 siga = std::sqrt(Tm*(1.0-0.5*beta2)*step*
960 factor*electronDensity*ChargeSquare/beta2) ;
961 do {
962 loss = G4RandGauss::shoot(MeanLoss,siga) ;
963 } while (loss < 0. || loss > 2.*MeanLoss);
964 return loss;
965 }
966
967 w1 = Tm/ipotFluct;
968 w2 = std::log(2.*electron_mass_c2*tau2);
969
970 C = MeanLoss*(1.-rateFluct)/(w2-ipotLogFluct-beta2);
971
972 a1 = C*f1Fluct*(w2-e1LogFluct-beta2)/e1Fluct;
973 a2 = C*f2Fluct*(w2-e2LogFluct-beta2)/e2Fluct;
974 a3 = rateFluct*MeanLoss*(Tm-ipotFluct)/(ipotFluct*Tm*std::log(w1));
975 if(a1 < 0.) a1 = 0.;
976 if(a2 < 0.) a2 = 0.;
977 if(a3 < 0.) a3 = 0.;
978
979 suma = a1+a2+a3;
980
981 loss = 0. ;
982
983 if(suma < sumaLim)
984 {
986
987 if(Tm == ipotFluct)
988 {
989 a3 = MeanLoss/e0;
990
991 if(a3>alim)
992 {
993 siga=std::sqrt(a3) ;
994 p3 = std::max(0.,G4RandGauss::shoot(a3,siga)+0.5);
995 }
996 else
998
999 loss = p3*e0 ;
1000
1001 if(p3 > 0)
1003
1004 }
1005 else
1006 {
1007 Tm = Tm-ipotFluct+e0 ;
1008 a3 = MeanLoss*(Tm-e0)/(Tm*e0*std::log(Tm/e0));
1009
1010 if(a3>alim)
1011 {
1012 siga=std::sqrt(a3) ;
1013 p3 = std::max(0.,G4RandGauss::shoot(a3,siga)+0.5);
1014 }
1015 else
1017
1018 if(p3 > 0)
1019 {
1020 w = (Tm-e0)/Tm ;
1022 {
1023 dp3 = p3 ;
1024 Corrfac = dp3/
G4float(nmaxCont2) ;
1026 }
1027 else
1028 Corrfac = 1. ;
1029
1031 loss *= e0*Corrfac ;
1032 }
1033 }
1034 }
1035
1036 else
1037 {
1038
1039 if(a1>alim)
1040 {
1041 siga=std::sqrt(a1) ;
1042 p1 = std::max(0.,G4RandGauss::shoot(a1,siga)+0.5);
1043 }
1044 else
1046
1047
1048 if(a2>alim)
1049 {
1050 siga=std::sqrt(a2) ;
1051 p2 = std::max(0.,G4RandGauss::shoot(a2,siga)+0.5);
1052 }
1053 else
1055
1056 loss = p1*e1Fluct+p2*e2Fluct;
1057
1058 if(p2 > 0)
1060 else if (loss>0.)
1062
1063
1064 if(a3 > 0.)
1065 {
1066 if(a3>alim)
1067 {
1068 siga=std::sqrt(a3) ;
1069 p3 = std::max(0.,G4RandGauss::shoot(a3,siga)+0.5);
1070 }
1071 else
1073
1074 lossc = 0.;
1075 if(p3 > 0)
1076 {
1077 na = 0.;
1078 alfa = 1.;
1080 {
1081 dp3 = p3;
1082 rfac = dp3/(
G4float(nmaxCont2)+dp3);
1083 namean = p3*rfac;
1085 na = G4RandGauss::shoot(namean,sa);
1086 if (na > 0.)
1087 {
1089 alfa1 = alfa*std::log(alfa)/(alfa-1.);
1090 ea = na*ipotFluct*alfa1;
1091 sea = ipotFluct*std::sqrt(na*(alfa-alfa1*alfa1));
1092 lossc += G4RandGauss::shoot(ea,sea);
1093 }
1094 }
1095
1097 if (nb > 0)
1098 {
1099 w2 = alfa*ipotFluct;
1100 w = (Tm-w2)/Tm;
1102 }
1103 }
1104 loss += lossc;
1105 }
1106 }
1107
1108 if( loss < 0.)
1109 loss = 0.;
1110
1111 return loss ;
1112}
G4long G4Poisson(G4double mean)
G4double GetKineticEnergy() const
G4double GetF2fluct() const
G4double GetLogEnergy1fluct() const
G4double GetLogEnergy2fluct() const
G4double GetMeanExcitationEnergy() const
G4double GetF1fluct() const
G4double GetEnergy2fluct() const
G4double GetEnergy1fluct() const
G4double GetRateionexcfluct() const
G4double GetEnergy0fluct() const
G4double GetLogMeanExcEnergy() const
const G4Material * GetMaterial() const
G4IonisParamMat * GetIonisation() const
G4double GetElectronDensity() const