Geant4-11
G4UrbanFluctuation.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// -------------------------------------------------------------------
28//
29// GEANT4 Class file
30//
31//
32// File name: G4UrbanFluctuation
33//
34// Author: V. Ivanchenko for Laszlo Urban
35//
36// Creation date: 14.02.2022
37//
38// Modifications:
39//
40//
41
42//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44
45#include "G4UrbanFluctuation.hh"
47#include "G4SystemOfUnits.hh"
48#include "Randomize.hh"
49#include "G4Poisson.hh"
50#include "G4Material.hh"
51#include "G4Log.hh"
52
53//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54
57{}
58
59//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
60
62{}
63
64//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65
67 const G4Material* material,
68 const G4double tcut)
69{
70 if (material != lastMaterial) {
71 auto ioni = material->GetIonisation();
72 f1Fluct = ioni->GetF1fluct();
73 f2Fluct = ioni->GetF2fluct();
74 e1Fluct = ioni->GetEnergy1fluct();
75 e2Fluct = ioni->GetEnergy2fluct();
76 e1LogFluct = ioni->GetLogEnergy1fluct();
77 e2LogFluct = ioni->GetLogEnergy2fluct();
78 esmall = 0.5*std::sqrt(e0*ipotFluct);
80 }
81
82 G4double a1(0.0), a2(0.0), a3(0.0);
83 G4double loss = 0.0;
86
87 if(tcut > ipotFluct) {
88 if(w2 > ipotLogFluct) {
89 if(w2 > e2LogFluct) {
90 const G4double C = meanLoss*(1.-rate)/(w2-ipotLogFluct);
93 } else {
94 a1 = meanLoss*(1.-rate)/e1;
95 }
96 if(a1 < a0) {
97 const G4double fwnow = 0.5+(fw-0.5)*std::sqrt(a1/a0);
98 a1 /= fwnow;
99 e1 *= fwnow;
100 } else {
101 a1 /= fw;
102 e1 *= fw;
103 }
104 }
105 }
106
107 const G4double w1 = tcut/e0;
108 a3 = rate*meanLoss*(tcut-e0)/(e0*tcut*G4Log(w1));
109 if(a1+a2 <= 0.) { a3 /= rate; }
110
111 //'nearly' Gaussian fluctuation if a1>nmaxCont&&a2>nmaxCont&&a3>nmaxCont
112 G4double emean = 0.;
113 G4double sig2e = 0.;
114
115 // excitation of type 1
116 if(a1 > 0.0) { AddExcitation(rndmEngineF, a1, e1, emean, loss, sig2e); }
117
118 // excitation of type 2
119 if(a2 > 0.0) { AddExcitation(rndmEngineF, a2, e2, emean, loss, sig2e); }
120
121 if(sig2e > 0.0) { SampleGauss(rndmEngineF, emean, sig2e, loss); }
122
123 // ionisation
124 if(a3 > 0.) {
125 emean = 0.;
126 sig2e = 0.;
127 G4double p3 = a3;
128 G4double alfa = 1.;
129 if(a3 > nmaxCont) {
130 alfa = w1*(nmaxCont+a3)/(w1*nmaxCont+a3);
131 const G4double alfa1 = alfa*G4Log(alfa)/(alfa-1.);
132 const G4double namean = a3*w1*(alfa-1.)/((w1-1.)*alfa);
133 emean += namean*e0*alfa1;
134 sig2e += e0*e0*namean*(alfa-alfa1*alfa1);
135 p3 -= namean;
136 }
137
138 const G4double w3 = alfa*e0;
139 if(tcut > w3) {
140 const G4double w = (tcut-w3)/tcut;
141 const G4int nnb = G4Poisson(p3);
142 if(nnb > 0) {
143 if(nnb > sizearray) {
144 sizearray = nnb;
145 delete [] rndmarray;
146 rndmarray = new G4double[nnb];
147 }
148 rndmEngineF->flatArray(nnb, rndmarray);
149 for (G4int k=0; k<nnb; ++k) { loss += w3/(1.-w*rndmarray[k]); }
150 }
151 }
152 if(sig2e > 0.0) { SampleGauss(rndmEngineF, emean, sig2e, loss); }
153 }
154 //G4cout << "### loss=" << loss << G4endl;
155 return loss;
156}
157
158//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static const G4double e1[44]
static const G4double e2[44]
G4double C(G4double temp)
G4double G4Log(G4double x)
Definition: G4Log.hh:226
G4long G4Poisson(G4double mean)
Definition: G4Poisson.hh:50
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
virtual void flatArray(const int size, double *vect)=0
void AddExcitation(CLHEP::HepRandomEngine *rndm, const G4double ax, const G4double ex, G4double &eav, G4double &eloss, G4double &esig2)
void SampleGauss(CLHEP::HepRandomEngine *rndm, const G4double eav, const G4double esig2, G4double &eloss)
~G4UrbanFluctuation() override
const G4Material * lastMaterial
G4UrbanFluctuation(const G4String &nam="UrbanFluc")
G4double SampleGlandz(CLHEP::HepRandomEngine *rndm, const G4Material *, const G4double tcut) override
string material
Definition: eplot.py:19