#include <SimTracker/Common/interface/SiG4UniversalFluctuation.h>
Public Member Functions | |
double | SampleFluctuations (const double momentum, const double mass, double &tmax, const double length, const double meanLoss) |
SiG4UniversalFluctuation (CLHEP::HepRandomEngine &) | |
~SiG4UniversalFluctuation () | |
Private Attributes | |
double | alim |
double | chargeSquare |
double | e0 |
double | e1Fluct |
double | e1LogFluct |
double | e2Fluct |
double | e2LogFluct |
double | electronDensity |
double | f1Fluct |
double | f2Fluct |
CLHEP::RandFlat * | flatDistribution |
CLHEP::RandGaussQ * | gaussQDistribution |
double | ipotFluct |
double | ipotLogFluct |
double | minLoss |
double | minNumberInteractionsBohr |
double | nmaxCont1 |
double | nmaxCont2 |
double | particleMass |
CLHEP::RandPoisson * | poissonDistribution |
double | problim |
double | rateFluct |
CLHEP::HepRandomEngine & | rndEngine |
double | sumalim |
double | theBohrBeta2 |
Definition at line 67 of file SiG4UniversalFluctuation.h.
SiG4UniversalFluctuation::SiG4UniversalFluctuation | ( | CLHEP::HepRandomEngine & | eng | ) |
Definition at line 74 of file SiG4UniversalFluctuation.cc.
References chargeSquare, e0, e1Fluct, e1LogFluct, e2Fluct, e2LogFluct, electronDensity, f1Fluct, f2Fluct, flatDistribution, gaussQDistribution, ipotFluct, ipotLogFluct, funct::log(), poissonDistribution, problim, rateFluct, rndEngine, and sumalim.
00075 :rndEngine(eng), 00076 gaussQDistribution(0), 00077 poissonDistribution(0), 00078 flatDistribution(0), 00079 minNumberInteractionsBohr(10.0), 00080 theBohrBeta2(50.0*keV/proton_mass_c2), 00081 minLoss(10.*eV), 00082 problim(5.e-3), 00083 alim(10.), 00084 nmaxCont1(4.), 00085 nmaxCont2(16.) 00086 { 00087 sumalim = -log(problim); 00088 //lastMaterial = 0; 00089 00090 // Add these definitions d.k. 00091 chargeSquare = 1.; //Assume all particles have charge 1 00092 // Taken from Geant4 printout, HARDWIRED for Silicon. 00093 ipotFluct = 0.0001736; //material->GetIonisation()->GetMeanExcitationEnergy(); 00094 electronDensity = 6.797E+20; // material->GetElectronDensity(); 00095 f1Fluct = 0.8571; // material->GetIonisation()->GetF1fluct(); 00096 f2Fluct = 0.1429; //material->GetIonisation()->GetF2fluct(); 00097 e1Fluct = 0.000116;// material->GetIonisation()->GetEnergy1fluct(); 00098 e2Fluct = 0.00196; //material->GetIonisation()->GetEnergy2fluct(); 00099 e1LogFluct = -9.063; //material->GetIonisation()->GetLogEnergy1fluct(); 00100 e2LogFluct = -6.235; //material->GetIonisation()->GetLogEnergy2fluct(); 00101 rateFluct = 0.4; //material->GetIonisation()->GetRateionexcfluct(); 00102 ipotLogFluct = -8.659; //material->GetIonisation()->GetLogMeanExcEnergy(); 00103 e0 = 1.E-5; //material->GetIonisation()->GetEnergy0fluct(); 00104 00105 gaussQDistribution = new CLHEP::RandGaussQ(rndEngine); 00106 poissonDistribution = new CLHEP::RandPoisson(rndEngine); 00107 flatDistribution = new CLHEP::RandFlat(rndEngine); 00108 00109 //cout << " init new fluct +++++++++++++++++++++++++++++++++++++++++"<<endl; 00110 }
SiG4UniversalFluctuation::~SiG4UniversalFluctuation | ( | ) |
Definition at line 117 of file SiG4UniversalFluctuation.cc.
References flatDistribution, gaussQDistribution, and poissonDistribution.
00118 { 00119 delete gaussQDistribution; 00120 delete poissonDistribution; 00121 delete flatDistribution; 00122 00123 }
double SiG4UniversalFluctuation::SampleFluctuations | ( | const double | momentum, | |
const double | mass, | |||
double & | tmax, | |||
const double | length, | |||
const double | meanLoss | |||
) |
Definition at line 126 of file SiG4UniversalFluctuation.cc.
References a1, a2, a3, alim, funct::C, chargeSquare, e0, e1Fluct, e1LogFluct, e2Fluct, e2LogFluct, electronDensity, f1Fluct, f2Fluct, flatDistribution, gaussQDistribution, i, int, ipotFluct, ipotLogFluct, k, funct::log(), max, minLoss, minNumberInteractionsBohr, nmaxCont1, nmaxCont2, p1, p2, p3, particleMass, poissonDistribution, rateFluct, funct::sqrt(), sumalim, w, w1, w2, and x.
Referenced by SiPixelDigitizerAlgorithm::fluctuateEloss(), and SiLinearChargeDivider::fluctuateEloss().
00131 { 00132 // Calculate actual loss from the mean loss. 00133 // The model used to get the fluctuations is essentially the same 00134 // as in Glandz in Geant3 (Cern program library W5013, phys332). 00135 // L. Urban et al. NIM A362, p.416 (1995) and Geant4 Physics Reference Manual 00136 00137 // shortcut for very very small loss (out of validity of the model) 00138 // 00139 if (meanLoss < minLoss) return meanLoss; 00140 00141 //if(!particle) InitialiseMe(dp->GetDefinition()); 00142 //G4double tau = dp->GetKineticEnergy()/particleMass; 00143 //G4double gam = tau + 1.0; 00144 //G4double gam2 = gam*gam; 00145 //G4double beta2 = tau*(tau + 2.0)/gam2; 00146 00147 particleMass = mass; // dp->GetMass(); 00148 double gam2 = (momentum*momentum)/(particleMass*particleMass) + 1.0; 00149 double beta2 = 1.0 - 1.0/gam2; 00150 double gam = sqrt(gam2); 00151 00152 double loss(0.), siga(0.); 00153 00154 // Gaussian regime 00155 // for heavy particles only and conditions 00156 // for Gauusian fluct. has been changed 00157 // 00158 if ((particleMass > electron_mass_c2) && 00159 (meanLoss >= minNumberInteractionsBohr*tmax)) 00160 { 00161 double massrate = electron_mass_c2/particleMass ; 00162 double tmaxkine = 2.*electron_mass_c2*beta2*gam2/ 00163 (1.+massrate*(2.*gam+massrate)) ; 00164 if (tmaxkine <= 2.*tmax) 00165 { 00166 //electronDensity = material->GetElectronDensity(); 00167 siga = (1.0/beta2 - 0.5) * twopi_mc2_rcl2 * tmax * length 00168 * electronDensity * chargeSquare; 00169 siga = sqrt(siga); 00170 double twomeanLoss = meanLoss + meanLoss; 00171 if (twomeanLoss < siga) { 00172 double x; 00173 do { 00174 loss = twomeanLoss*flatDistribution->fire(); 00175 x = (loss - meanLoss)/siga; 00176 } while (1.0 - 0.5*x*x < flatDistribution->fire()); 00177 } else { 00178 do { 00179 loss = gaussQDistribution->fire(meanLoss,siga); 00180 } while (loss < 0. || loss > twomeanLoss); 00181 } 00182 return loss; 00183 } 00184 } 00185 00186 // Glandz regime : initialisation 00187 // 00188 // if (material != lastMaterial) { 00189 // f1Fluct = material->GetIonisation()->GetF1fluct(); 00190 // f2Fluct = material->GetIonisation()->GetF2fluct(); 00191 // e1Fluct = material->GetIonisation()->GetEnergy1fluct(); 00192 // e2Fluct = material->GetIonisation()->GetEnergy2fluct(); 00193 // e1LogFluct = material->GetIonisation()->GetLogEnergy1fluct(); 00194 // e2LogFluct = material->GetIonisation()->GetLogEnergy2fluct(); 00195 // rateFluct = material->GetIonisation()->GetRateionexcfluct(); 00196 // ipotFluct = material->GetIonisation()->GetMeanExcitationEnergy(); 00197 // ipotLogFluct = material->GetIonisation()->GetLogMeanExcEnergy(); 00198 // lastMaterial = material; 00199 // } 00200 00201 double a1 = 0. , a2 = 0., a3 = 0. ; 00202 double p1,p2,p3; 00203 double rate = rateFluct ; 00204 00205 double w1 = tmax/ipotFluct; 00206 double w2 = log(2.*electron_mass_c2*beta2*gam2)-beta2; 00207 00208 if(w2 > ipotLogFluct) 00209 { 00210 double C = meanLoss*(1.-rateFluct)/(w2-ipotLogFluct); 00211 a1 = C*f1Fluct*(w2-e1LogFluct)/e1Fluct; 00212 a2 = C*f2Fluct*(w2-e2LogFluct)/e2Fluct; 00213 if(a2 < 0.) 00214 { 00215 a1 = 0. ; 00216 a2 = 0. ; 00217 rate = 1. ; 00218 } 00219 } 00220 else 00221 { 00222 rate = 1. ; 00223 } 00224 00225 a3 = rate*meanLoss*(tmax-ipotFluct)/(ipotFluct*tmax*log(w1)); 00226 00227 double suma = a1+a2+a3; 00228 00229 // Glandz regime 00230 // 00231 if (suma > sumalim) 00232 { 00233 p1 = 0., p2 = 0 ; 00234 if((a1+a2) > 0.) 00235 { 00236 // excitation type 1 00237 if (a1>alim) { 00238 siga=sqrt(a1) ; 00239 p1 = max(0.,gaussQDistribution->fire(a1,siga)+0.5); 00240 } else { 00241 p1 = double(poissonDistribution->fire(a1)); 00242 } 00243 00244 // excitation type 2 00245 if (a2>alim) { 00246 siga=sqrt(a2) ; 00247 p2 = max(0.,gaussQDistribution->fire(a2,siga)+0.5); 00248 } else { 00249 p2 = double(poissonDistribution->fire(a2)); 00250 } 00251 00252 loss = p1*e1Fluct+p2*e2Fluct; 00253 00254 // smearing to avoid unphysical peaks 00255 if (p2 > 0.) 00256 loss += (1.-2.*flatDistribution->fire())*e2Fluct; 00257 else if (loss>0.) 00258 loss += (1.-2.*flatDistribution->fire())*e1Fluct; 00259 if (loss < 0.) loss = 0.0; 00260 } 00261 00262 // ionisation 00263 if (a3 > 0.) { 00264 if (a3>alim) { 00265 siga=sqrt(a3) ; 00266 p3 = max(0.,gaussQDistribution->fire(a3,siga)+0.5); 00267 } else { 00268 p3 = double(poissonDistribution->fire(a3)); 00269 } 00270 double lossc = 0.; 00271 if (p3 > 0) { 00272 double na = 0.; 00273 double alfa = 1.; 00274 if (p3 > nmaxCont2) { 00275 double rfac = p3/(nmaxCont2+p3); 00276 double namean = p3*rfac; 00277 double sa = nmaxCont1*rfac; 00278 na = gaussQDistribution->fire(namean,sa); 00279 if (na > 0.) { 00280 alfa = w1*(nmaxCont2+p3)/(w1*nmaxCont2+p3); 00281 double alfa1 = alfa*log(alfa)/(alfa-1.); 00282 double ea = na*ipotFluct*alfa1; 00283 double sea = ipotFluct*sqrt(na*(alfa-alfa1*alfa1)); 00284 lossc += gaussQDistribution->fire(ea,sea); 00285 } 00286 } 00287 00288 if (p3 > na) { 00289 w2 = alfa*ipotFluct; 00290 double w = (tmax-w2)/tmax; 00291 int nb = int(p3-na); 00292 for (int k=0; k<nb; k++) lossc += w2/(1.-w*flatDistribution->fire()); 00293 } 00294 } 00295 loss += lossc; 00296 } 00297 return loss; 00298 } 00299 00300 // suma < sumalim; very small energy loss; 00301 // 00302 //double e0 = material->GetIonisation()->GetEnergy0fluct(); 00303 00304 a3 = meanLoss*(tmax-e0)/(tmax*e0*log(tmax/e0)); 00305 if (a3 > alim) 00306 { 00307 siga=sqrt(a3); 00308 p3 = max(0.,gaussQDistribution->fire(a3,siga)+0.5); 00309 } else { 00310 p3 = double(poissonDistribution->fire(a3)); 00311 } 00312 if (p3 > 0.) { 00313 double w = (tmax-e0)/tmax; 00314 double corrfac = 1.; 00315 if (p3 > nmaxCont2) { 00316 corrfac = p3/nmaxCont2; 00317 p3 = nmaxCont2; 00318 } 00319 int ip3 = (int)p3; 00320 for (int i=0; i<ip3; i++) loss += 1./(1.-w*flatDistribution->fire()); 00321 loss *= e0*corrfac; 00322 // smearing for losses near to e0 00323 if(p3 <= 2.) 00324 loss += e0*(1.-2.*flatDistribution->fire()) ; 00325 } 00326 00327 return loss; 00328 }
double SiG4UniversalFluctuation::alim [private] |
double SiG4UniversalFluctuation::chargeSquare [private] |
Definition at line 110 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), and SiG4UniversalFluctuation().
double SiG4UniversalFluctuation::e0 [private] |
Definition at line 125 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), and SiG4UniversalFluctuation().
double SiG4UniversalFluctuation::e1Fluct [private] |
Definition at line 119 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), and SiG4UniversalFluctuation().
double SiG4UniversalFluctuation::e1LogFluct [private] |
Definition at line 122 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), and SiG4UniversalFluctuation().
double SiG4UniversalFluctuation::e2Fluct [private] |
Definition at line 120 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), and SiG4UniversalFluctuation().
double SiG4UniversalFluctuation::e2LogFluct [private] |
Definition at line 123 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), and SiG4UniversalFluctuation().
double SiG4UniversalFluctuation::electronDensity [private] |
Definition at line 114 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), and SiG4UniversalFluctuation().
double SiG4UniversalFluctuation::f1Fluct [private] |
Definition at line 117 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), and SiG4UniversalFluctuation().
double SiG4UniversalFluctuation::f2Fluct [private] |
Definition at line 118 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), and SiG4UniversalFluctuation().
CLHEP::RandFlat* SiG4UniversalFluctuation::flatDistribution [private] |
Definition at line 101 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), SiG4UniversalFluctuation(), and ~SiG4UniversalFluctuation().
CLHEP::RandGaussQ* SiG4UniversalFluctuation::gaussQDistribution [private] |
Definition at line 99 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), SiG4UniversalFluctuation(), and ~SiG4UniversalFluctuation().
double SiG4UniversalFluctuation::ipotFluct [private] |
Definition at line 113 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), and SiG4UniversalFluctuation().
double SiG4UniversalFluctuation::ipotLogFluct [private] |
Definition at line 124 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), and SiG4UniversalFluctuation().
double SiG4UniversalFluctuation::minLoss [private] |
double SiG4UniversalFluctuation::minNumberInteractionsBohr [private] |
double SiG4UniversalFluctuation::nmaxCont1 [private] |
double SiG4UniversalFluctuation::nmaxCont2 [private] |
double SiG4UniversalFluctuation::particleMass [private] |
CLHEP::RandPoisson* SiG4UniversalFluctuation::poissonDistribution [private] |
Definition at line 100 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), SiG4UniversalFluctuation(), and ~SiG4UniversalFluctuation().
double SiG4UniversalFluctuation::problim [private] |
Definition at line 130 of file SiG4UniversalFluctuation.h.
Referenced by SiG4UniversalFluctuation().
double SiG4UniversalFluctuation::rateFluct [private] |
Definition at line 121 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), and SiG4UniversalFluctuation().
CLHEP::HepRandomEngine& SiG4UniversalFluctuation::rndEngine [private] |
double SiG4UniversalFluctuation::sumalim [private] |
Definition at line 131 of file SiG4UniversalFluctuation.h.
Referenced by SampleFluctuations(), and SiG4UniversalFluctuation().
double SiG4UniversalFluctuation::theBohrBeta2 [private] |
Definition at line 128 of file SiG4UniversalFluctuation.h.