Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4UniversalFluctuation.hh
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// GEANT4 Class header file
29//
30//
31// File name: G4UniversalFluctuation
32//
33// Author: V.Ivanchenko make a class with the Laszlo Urban model
34//
35// Creation date: 03.01.2002
36//
37// Modifications:
38//
39//
40// Class Description:
41//
42// Implementation of energy loss fluctuations made by L.Urban in 2021
43
44// -------------------------------------------------------------------
45//
46
47#ifndef G4UniversalFluctuation_h
48#define G4UniversalFluctuation_h 1
49
52#include "G4Poisson.hh"
54
56{
57
58public:
59
60 explicit G4UniversalFluctuation(const G4String& nam = "UniFluc");
61
62 ~G4UniversalFluctuation() override;
63
65 const G4DynamicParticle*,
66 const G4double, const G4double,
67 const G4double, const G4double) override;
68
70 const G4DynamicParticle*,
71 const G4double, const G4double,
72 const G4double) override;
73
74 // Initialisation for a new particle type
75 void InitialiseMe(const G4ParticleDefinition*) override;
76
77 // Initialisation prestep
79 G4double q2) override;
80
81 // hide assignment operator
83 (const G4UniversalFluctuation &right) = delete;
85
86protected:
87
89 const G4Material*, const G4double tcut);
90
91 inline void AddExcitation(CLHEP::HepRandomEngine* rndm,
92 const G4double ax, const G4double ex,
93 G4double& eav,
94 G4double& eloss, G4double& esig2);
95
96 inline void SampleGauss(CLHEP::HepRandomEngine* rndm,
97 const G4double eav, const G4double esig2,
98 G4double& eloss);
99
100 // particle properties
105
106 // material properties
110
111 // model parameters
117 G4double a0 = 42.0;
120
122 G4double* rndmarray = nullptr;
124};
125
126//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
127
128inline void
130 const G4double ax, const G4double ex,
131 G4double& eav,
132 G4double& eloss, G4double& esig2)
133{
134 if(ax > nmaxCont) {
135 eav += ax*ex;
136 esig2 += ax*ex*ex;
137 } else {
138 const G4int p = (G4int)G4Poisson(ax);
139 if(p > 0) { eloss += ((p + 1) - 2.*rndm->flat())*ex; }
140 }
141}
142
143//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
144
145inline void
147 const G4double eav, const G4double esig2,
148 G4double& eloss)
149{
150 G4double x = eav;
151 const G4double sig = std::sqrt(esig2);
152 if(eav < 0.25*sig) {
153 x += (2.*rndm->flat() - 1.)*eav;
154 } else {
155 do {
156 x = G4RandGauss::shoot(rndm, eav, sig);
157 } while (x < 0.0 || x > 2*eav);
158 // Loop checking, 23-Feb-2016, Vladimir Ivanchenko
159 }
160 eloss += x;
161}
162
163//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
164
165#endif
166
G4long G4Poisson(G4double mean)
Definition: G4Poisson.hh:50
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
virtual double flat()=0
const G4ParticleDefinition * particle
G4double SampleFluctuations(const G4MaterialCutsCouple *, const G4DynamicParticle *, const G4double, const G4double, const G4double, const G4double) override
void AddExcitation(CLHEP::HepRandomEngine *rndm, const G4double ax, const G4double ex, G4double &eav, G4double &eloss, G4double &esig2)
void InitialiseMe(const G4ParticleDefinition *) override
void SampleGauss(CLHEP::HepRandomEngine *rndm, const G4double eav, const G4double esig2, G4double &eloss)
G4double Dispersion(const G4Material *, const G4DynamicParticle *, const G4double, const G4double, const G4double) override
G4UniversalFluctuation(const G4UniversalFluctuation &)=delete
void SetParticleAndCharge(const G4ParticleDefinition *, G4double q2) override
virtual G4double SampleGlandz(CLHEP::HepRandomEngine *rndm, const G4Material *, const G4double tcut)
#define DBL_MAX
Definition: templates.hh:62