88 G4cout <<
"### G4VEnergyLoss class is obsolete "
89 <<
"and will be removed for the next release." <<
G4endl;
94 f1Fluct = f2Fluct = e1Fluct = e2Fluct = rateFluct = ipotFluct = e1LogFluct
95 = e2LogFluct = ipotLogFluct = taulow = tauhigh = ltaulow = ltauhigh
138 size_t numOfMaterials = theDEDXTable->
length();
142 delete theRangeTable; }
147 for (
size_t J=0; J<numOfMaterials; J++)
151 HighestKineticEnergy,TotBin);
153 BuildRangeVector(theDEDXTable,LowestKineticEnergy,HighestKineticEnergy,
155 theRangeTable->
insert(aVector);
157 return theRangeTable ;
171 const G4double masslimit = 0.52*MeV ;
173 G4double tlim=2.*MeV,t1=0.1*MeV,t2=0.025*MeV ;
174 G4double tlime=0.2*keV,factor=2.*electron_mass_c2 ;
178 LowEdgeEnergy,tau,Value,tau1,sqtau1 ;
185 for (
G4int i1=0; i1<TotBin; i1++)
188 Value = physicsVector->
GetValue(LowEdgeEnergy,isOut);
189 if((Value < lossmin)&&(Value > 0.))
192 for (
G4int i2=0; i2<TotBin; i2++)
195 Value = physicsVector->
GetValue(LowEdgeEnergy,isOut);
197 physicsVector->
PutValue(i2,small*lossmin) ;
204 loss1 = physicsVector->
GetValue(t1,isOut);
205 loss2 = physicsVector->
GetValue(t2,isOut);
207 sqtau1 = std::sqrt(tau1) ;
208 ca = (4.*loss2-loss1)/sqtau1 ;
209 cb = (2.*loss1-4.*loss2)/tau1 ;
212 ltaulim = std::log(taulim) ;
225 Value = 2.*
ParticleMass*std::log(1.+cba*std::sqrt(tau))/cb ;
234 Value += RangeIntLin(physicsVector,nbin);
241 Value += RangeIntLin(physicsVector,nbin) ;
243 ltauhigh = std::log(tau) ;
244 Value += RangeIntLog(physicsVector,nbin);
251 }
while (tau<=taulim) ;
256 losslim = physicsVector->
GetValue(tlime,isOut) ;
258 taulim = tlime/electron_mass_c2;
260 ltaulim = std::log(taulim);
270 tau = LowEdgeEnergy/electron_mass_c2;
271 if (tau <= taulim) Value = factor*std::sqrt(tau*taulim)/clim;
273 rangelim = factor*taulim/losslim ;
274 ltaulow = std::log(taulim);
275 ltauhigh = std::log(tau);
276 Value = rangelim+RangeIntLog(physicsVector,nbin);
282 }
while (tau<=taulim);
287 for (
G4int j=i; j<TotBin; j++)
291 ltaulow = std::log(tauold);
292 ltauhigh = std::log(tau);
293 Value = oldValue+RangeIntLog(physicsVector,nbin);
307 G4double dtau,Value,taui,ti,lossi,ci;
309 dtau = (tauhigh-taulow)/nbin;
312 for (
G4int i=0; i<=nbin; i++)
314 taui = taulow + dtau*i ;
316 lossi = physicsVector->
GetValue(ti,isOut);
338 G4double ltt,dltau,Value,ui,taui,ti,lossi,ci;
340 ltt = ltauhigh-ltaulow;
344 for (
G4int i=0; i<=nbin; i++)
346 ui = ltaulow+dltau*i;
349 lossi = physicsVector->
GetValue(ti,isOut);
359 Value += ci*taui/lossi;
373 size_t numOfMaterials = theDEDXTable->
length();
377 delete theLabTimeTable; }
381 for (
size_t J=0; J<numOfMaterials; J++)
386 HighestKineticEnergy,TotBin);
388 BuildLabTimeVector(theDEDXTable,
389 LowestKineticEnergy,HighestKineticEnergy,TotBin,J,aVector);
390 theLabTimeTable->
insert(aVector);
394 return theLabTimeTable ;
405 size_t numOfMaterials = theDEDXTable->
length();
407 if(theProperTimeTable)
409 delete theProperTimeTable; }
413 for (
size_t J=0; J<numOfMaterials; J++)
418 HighestKineticEnergy,TotBin);
420 BuildProperTimeVector(theDEDXTable,
421 LowestKineticEnergy,HighestKineticEnergy,TotBin,J,aVector);
422 theProperTimeTable->
insert(aVector);
426 return theProperTimeTable ;
431void G4VEnergyLoss::BuildLabTimeVector(
G4PhysicsTable* theDEDXTable,
440 G4double tlim=5.*keV,parlowen=0.4,ppar=0.5-parlowen ;
441 G4double losslim,clim,taulim,timelim,
442 LowEdgeEnergy,tau,Value ;
447 losslim = physicsVector->
GetValue(tlim,isOut);
449 clim=std::sqrt(
ParticleMass*tlim/2.)/(c_light*losslim*ppar) ;
463 Value = clim*std::exp(ppar*std::log(tau/taulim)) ;
468 ltaulow = std::log(taulim);
469 ltauhigh = std::log(tau);
470 Value = timelim+LabTimeIntLog(physicsVector,nbin);
475 }
while (tau<=taulim) ;
477 for (
G4int j=i; j<TotBin; j++)
481 ltaulow = std::log(tauold);
482 ltauhigh = std::log(tau);
483 Value = oldValue+LabTimeIntLog(physicsVector,nbin);
492void G4VEnergyLoss::BuildProperTimeVector(
G4PhysicsTable* theDEDXTable,
500 G4double tlim=5.*keV,parlowen=0.4,ppar=0.5-parlowen ;
501 G4double losslim,clim,taulim,timelim,
502 LowEdgeEnergy,tau,Value ;
507 losslim = physicsVector->
GetValue(tlim,isOut);
509 clim=std::sqrt(
ParticleMass*tlim/2.)/(c_light*losslim*ppar) ;
523 Value = clim*std::exp(ppar*std::log(tau/taulim)) ;
528 ltaulow = std::log(taulim);
529 ltauhigh = std::log(tau);
530 Value = timelim+ProperTimeIntLog(physicsVector,nbin);
535 }
while (tau<=taulim) ;
537 for (
G4int j=i; j<TotBin; j++)
541 ltaulow = std::log(tauold);
542 ltauhigh = std::log(tau);
543 Value = oldValue+ProperTimeIntLog(physicsVector,nbin);
556 G4double ltt,dltau,Value,ui,taui,ti,lossi,ci;
558 ltt = ltauhigh-ltaulow;
562 for (
G4int i=0; i<=nbin; i++)
564 ui = ltaulow+dltau*i;
567 lossi = physicsVector->
GetValue(ti,isOut);
589 G4double ltt,dltau,Value,ui,taui,ti,lossi,ci;
591 ltt = ltauhigh-ltaulow;
595 for (
G4int i=0; i<=nbin; i++)
597 ui = ltaulow+dltau*i;
600 lossi = physicsVector->
GetValue(ti,isOut);
627 G4double SmallestRange,BiggestRange ;
629 size_t numOfMaterials = theRangeTable->
length();
631 if(theInverseRangeTable)
633 delete theInverseRangeTable; }
637 for (
size_t J=0; J<numOfMaterials; J++)
639 SmallestRange = (*theRangeTable)(J)->
640 GetValue(LowestKineticEnergy,isOut) ;
641 BiggestRange = (*theRangeTable)(J)->
642 GetValue(HighestKineticEnergy,isOut) ;
645 BiggestRange,TotBin);
647 InvertRangeVector(theRangeTable,
651 LowestKineticEnergy,HighestKineticEnergy,TotBin,J, aVector);
653 theInverseRangeTable->
insert(aVector);
655 return theInverseRangeTable ;
660void G4VEnergyLoss::InvertRangeVector(
G4PhysicsTable* theRangeTable,
669 G4double LowEdgeRange,A,B,C,discr,KineticEnergy ;
670 G4double RTable = std::exp(std::log(HighestKineticEnergy/LowestKineticEnergy)/TotBin) ;
671 G4double Tbin = LowestKineticEnergy/RTable ;
673 G4int binnumber = -1 ;
677 for(
G4int i=0; i<TotBin; i++)
680 if( rangebin < LowEdgeRange )
686 rangebin = (*theRangeTable)(materialIndex)->GetValue(Tbin,isOut) ;
688 while ((rangebin < LowEdgeRange) && (binnumber < TotBin )) ;
692 KineticEnergy = LowestKineticEnergy ;
693 else if(binnumber == TotBin-1)
694 KineticEnergy = HighestKineticEnergy ;
697 A = (*(*theRangeCoeffATable)(materialIndex))(binnumber-1) ;
698 B = (*(*theRangeCoeffBTable)(materialIndex))(binnumber-1) ;
699 C = (*(*theRangeCoeffCTable)(materialIndex))(binnumber-1) ;
701 KineticEnergy = (LowEdgeRange -C )/B ;
704 discr = B*B - 4.*A*(C-LowEdgeRange);
705 discr = discr>0. ? std::sqrt(discr) : 0.;
706 KineticEnergy = 0.5*(discr-B)/A ;
710 aVector->
PutValue(i,KineticEnergy) ;
725 if(theRangeCoeffATable)
727 delete theRangeCoeffATable; }
730 G4double RTable = std::exp(std::log(HighestKineticEnergy/LowestKineticEnergy)/TotBin) ;
733 G4double w = R1*(RTable-1.)*(RTable-1.);
734 G4double w1 = RTable/w , w2 = -RTable*R1/w , w3 = R2/w ;
735 G4double Ti , Tim , Tip , Ri , Rim , Rip , Value ;
739 for (
G4int J=0; J<numOfMaterials; J++)
741 G4int binmax=TotBin ;
744 Ti = LowestKineticEnergy ;
747 for (
G4int i=0; i<TotBin; i++)
749 Ri = rangeVector->
GetValue(Ti,isOut) ;
755 Rim = rangeVector->
GetValue(Tim,isOut);
762 Rip = rangeVector->
GetValue(Tip,isOut);
764 Value = (w1*Rip + w2*Ri + w3*Rim)/(Ti*Ti) ;
770 theRangeCoeffATable->
insert(aVector);
772 return theRangeCoeffATable ;
786 if(theRangeCoeffBTable)
788 delete theRangeCoeffBTable; }
791 G4double RTable = std::exp(std::log(HighestKineticEnergy/LowestKineticEnergy)/TotBin) ;
794 G4double w = R1*(RTable-1.)*(RTable-1.);
795 G4double w1 = -R1/w , w2 = R1*(R2+1.)/w , w3 = -R2*R1/w ;
796 G4double Ti , Tim , Tip , Ri , Rim , Rip , Value ;
800 for (
G4int J=0; J<numOfMaterials; J++)
802 G4int binmax=TotBin ;
805 Ti = LowestKineticEnergy ;
808 for (
G4int i=0; i<TotBin; i++)
810 Ri = rangeVector->
GetValue(Ti,isOut) ;
816 Rim = rangeVector->
GetValue(Tim,isOut);
823 Rip = rangeVector->
GetValue(Tip,isOut);
825 Value = (w1*Rip + w2*Ri + w3*Rim)/Ti;
830 theRangeCoeffBTable->
insert(aVector);
832 return theRangeCoeffBTable ;
846 if(theRangeCoeffCTable)
848 delete theRangeCoeffCTable; }
851 G4double RTable = std::exp(std::log(HighestKineticEnergy/LowestKineticEnergy)/TotBin) ;
854 G4double w = R1*(RTable-1.)*(RTable-1.);
855 G4double w1 = 1./w , w2 = -RTable*R1/w , w3 = RTable*R2/w ;
856 G4double Ti , Tim , Tip , Ri , Rim , Rip , Value ;
860 for (
G4int J=0; J<numOfMaterials; J++)
862 G4int binmax=TotBin ;
865 Ti = LowestKineticEnergy ;
868 for (
G4int i=0; i<TotBin; i++)
870 Ri = rangeVector->
GetValue(Ti,isOut) ;
876 Rim = rangeVector->
GetValue(Tim,isOut);
883 Rip = rangeVector->
GetValue(Tip,isOut);
885 Value = w1*Rip + w2*Ri + w3*Rim ;
890 theRangeCoeffCTable->
insert(aVector);
892 return theRangeCoeffCTable ;
907 const G4double sumaLim = -std::log(probLim) ;
910 const G4double factor = twopi_mc2_rcl2 ;
915 if (aMaterial != lastMaterial)
917 lastMaterial = aMaterial;
930 beta2,suma,e0,loss,lossc ,w,electronDensity;
934 G4double Corrfac, na,alfa,rfac,namean,sa,alfa1,ea,sea;
939 if(MeanLoss < minLoss)
return MeanLoss ;
946 ->GetEnergyCutsVector(1)))[imat];
949 G4double Tm = 2.*electron_mass_c2*tau2/(1.+2.*tau1*rmass+rmass*rmass);
951 if(Tm > threshold) Tm = threshold;
953 beta2 = tau2/(tau1*tau1);
956 if(MeanLoss >= kappa*Tm || Tm < kappa*ipotFluct)
959 siga = std::sqrt(Tm*(1.0-0.5*beta2)*step*
960 factor*electronDensity*ChargeSquare/beta2) ;
962 loss = G4RandGauss::shoot(MeanLoss,siga) ;
963 }
while (loss < 0. || loss > 2.*MeanLoss);
968 w2 = std::log(2.*electron_mass_c2*tau2);
970 C = MeanLoss*(1.-rateFluct)/(w2-ipotLogFluct-beta2);
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));
994 p3 = std::max(0.,G4RandGauss::shoot(a3,siga)+0.5);
1007 Tm = Tm-ipotFluct+e0 ;
1008 a3 = MeanLoss*(Tm-e0)/(Tm*e0*std::log(Tm/e0));
1012 siga=std::sqrt(a3) ;
1013 p3 = std::max(0.,G4RandGauss::shoot(a3,siga)+0.5);
1024 Corrfac = dp3/
G4float(nmaxCont2) ;
1031 loss *= e0*Corrfac ;
1041 siga=std::sqrt(a1) ;
1042 p1 = std::max(0.,G4RandGauss::shoot(a1,siga)+0.5);
1050 siga=std::sqrt(a2) ;
1051 p2 = std::max(0.,G4RandGauss::shoot(a2,siga)+0.5);
1056 loss = p1*e1Fluct+p2*e2Fluct;
1068 siga=std::sqrt(a3) ;
1069 p3 = std::max(0.,G4RandGauss::shoot(a3,siga)+0.5);
1082 rfac = dp3/(
G4float(nmaxCont2)+dp3);
1085 na = G4RandGauss::shoot(namean,sa);
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);
1099 w2 = alfa*ipotFluct;
1118 if ( (vec1==0 ) || (vec2==0) )
return false;
1123 flag = (vec1[j] == vec2[j]);
1133 if ( dest != 0)
delete [] dest;
1136 dest[j] = source[j];
1145 G4bool wasModified =
false;
1150 for (
size_t j=0; j<numOfCouples; j++){
G4long G4Poisson(G4double mean)
G4DLLIMPORT std::ostream G4cout
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
G4bool IsRecalcNeeded() const
const G4Material * GetMaterial() const
static size_t GetNumberOfMaterials()
G4IonisParamMat * GetIonisation() const
G4double GetElectronDensity() const
void insert(G4PhysicsVector *)
G4double GetValue(G4double theEnergy, G4bool &isOutRange)
virtual G4double GetLowEdgeEnergy(size_t binNumber) const
void PutValue(size_t index, G4double theValue)
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()
G4double GetLossWithFluct(const G4DynamicParticle *aParticle, const G4MaterialCutsCouple *couple, G4double ChargeSquare, G4double MeanLoss, G4double step)
static G4double finalRange
G4PhysicsTable * BuildProperTimeTable(G4PhysicsTable *theDEDXTable, G4PhysicsTable *ProperTimeTable, G4double Tmin, G4double Tmax, G4int nbin)
static G4double * MinDeltaEnergy
static void SetMinDeltaCutInRange(G4double value)
static G4double dRoverRange
G4VEnergyLoss(const G4String &, G4ProcessType aType=fNotDefined)
G4PhysicsTable * BuildRangeTable(G4PhysicsTable *theDEDXTable, G4PhysicsTable *theRangeTable, G4double Tmin, G4double Tmax, G4int nbin)
G4PhysicsTable * BuildInverseRangeTable(G4PhysicsTable *theRangeTable, G4PhysicsTable *theRangeCoeffATable, G4PhysicsTable *theRangeCoeffBTable, G4PhysicsTable *theRangeCoeffCTable, G4PhysicsTable *theInverseRangeTable, G4double Tmin, G4double Tmax, G4int nbin)
static G4double * CopyCutVectors(G4double *dest, G4double *source)
static void SetRndmStep(G4bool value)
static void SetEnlossFluc(G4bool value)
G4bool CutsWhereModified()
G4PhysicsTable * BuildRangeCoeffCTable(G4PhysicsTable *theRangeTable, G4PhysicsTable *theCoeffCTable, G4double Tmin, G4double Tmax, G4int nbin)
static G4bool EnlossFlucFlag
static G4bool setMinDeltaCutInRange
static G4EnergyLossMessenger * ELossMessenger
static G4bool EqualCutVectors(G4double *vec1, G4double *vec2)
static G4double MinDeltaCutInRange
static G4bool * LowerLimitForced
static G4double finalRangeRequested
G4PhysicsTable * BuildRangeCoeffBTable(G4PhysicsTable *theRangeTable, G4PhysicsTable *theCoeffBTable, G4double Tmin, G4double Tmax, G4int nbin)
static G4bool rndmStepFlag
static void SetStepFunction(G4double c1, G4double c2)
G4PhysicsTable * BuildLabTimeTable(G4PhysicsTable *theDEDXTable, G4PhysicsTable *theLabTimeTable, G4double Tmin, G4double Tmax, G4int nbin)
static void SetSubSec(G4bool value)
G4PhysicsTable * BuildRangeCoeffATable(G4PhysicsTable *theRangeTable, G4PhysicsTable *theCoeffATable, G4double Tmin, G4double Tmax, G4int nbin)