Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Garfield::TrackElectron Class Reference

#include <TrackElectron.hh>

+ Inheritance diagram for Garfield::TrackElectron:

Public Member Functions

 TrackElectron ()
 
 ~TrackElectron ()
 
void SetParticle (std::string particle)
 
bool NewTrack (const double x0, const double y0, const double z0, const double t0, const double dx0, const double dy0, const double dz0)
 
bool GetCluster (double &xcls, double &ycls, double &zcls, double &tcls, int &ncls, double &ecls, double &extra)
 
double GetClusterDensity ()
 
double GetStoppingPower ()
 
- Public Member Functions inherited from Garfield::Track
 Track ()
 
virtual ~Track ()
 
virtual void SetParticle (std::string part)
 
void SetEnergy (const double e)
 
void SetBetaGamma (const double bg)
 
void SetBeta (const double beta)
 
void SetGamma (const double gamma)
 
void SetMomentum (const double p)
 
void SetKineticEnergy (const double ekin)
 
double GetEnergy () const
 
double GetBetaGamma () const
 
double GetBeta () const
 
double GetGamma () const
 
double GetMomentum () const
 
double GetKineticEnergy () const
 
void SetSensor (Sensor *s)
 
virtual bool NewTrack (const double x0, const double y0, const double z0, const double t0, const double dx0, const double dy0, const double dz0)=0
 
virtual bool GetCluster (double &xcls, double &ycls, double &zcls, double &tcls, int &n, double &e, double &extra)=0
 
virtual double GetClusterDensity ()
 
virtual double GetStoppingPower ()
 
void EnablePlotting (ViewDrift *viewer)
 
void DisablePlotting ()
 
void EnableDebugging ()
 
void DisableDebugging ()
 

Additional Inherited Members

- Protected Member Functions inherited from Garfield::Track
void PlotNewTrack (const double x0, const double y0, const double z0)
 
void PlotCluster (const double x0, const double y0, const double z0)
 
- Protected Attributes inherited from Garfield::Track
std::string className
 
double q
 
int spin
 
double mass
 
double energy
 
double beta2
 
bool isElectron
 
std::string particleName
 
Sensorsensor
 
bool isChanged
 
bool usePlotting
 
ViewDriftviewer
 
bool debug
 
int plotId
 

Detailed Description

Definition at line 13 of file TrackElectron.hh.

Constructor & Destructor Documentation

◆ TrackElectron()

Garfield::TrackElectron::TrackElectron ( )

Definition at line 12 of file TrackElectron.cc.

13 : ready(false),
14 x(0.),
15 y(0.),
16 z(0.),
17 t(0.),
18 dx(0.),
19 dy(0),
20 dz(1.),
21 nComponents(0),
22 nElectrons(0),
23 mediumName(""),
24 mediumDensity(0.),
25 mfp(0.) {
26
27 className = "TrackElectron";
28
29 // Setup the particle properties.
30 q = -1;
31 spin = 1;
32 mass = ElectronMass;
33 isElectron = true;
34 SetBetaGamma(3.);
35 particleName = "electron";
36
37 components.clear();
38 electrons.clear();
39}
void SetBetaGamma(const double bg)
Definition: Track.cc:116
std::string className
Definition: Track.hh:61
double mass
Definition: Track.hh:65
std::string particleName
Definition: Track.hh:69
double q
Definition: Track.hh:63
bool isElectron
Definition: Track.hh:68

◆ ~TrackElectron()

Garfield::TrackElectron::~TrackElectron ( )
inline

Definition at line 19 of file TrackElectron.hh.

19{}

Member Function Documentation

◆ GetCluster()

bool Garfield::TrackElectron::GetCluster ( double &  xcls,
double &  ycls,
double &  zcls,
double &  tcls,
int &  ncls,
double &  ecls,
double &  extra 
)
virtual

Implements Garfield::Track.

Definition at line 125 of file TrackElectron.cc.

127 {
128
129 edep = extra = 0.;
130 ncls = 0;
131
132 nElectrons = 0;
133 electrons.clear();
134
135 if (!ready) {
136 std::cerr << className << "::GetCluster:\n";
137 std::cerr << " Track not initialized.\n";
138 std::cerr << " Call NewTrack first.\n";
139 return false;
140 }
141
142 // Draw a step length and propagate the electron.
143 const double d = -mfp * log(RndmUniformPos());
144 x += d * dx;
145 y += d * dy;
146 z += d * dz;
147 t += d / (sqrt(beta2) * SpeedOfLight);
148
149 if (!sensor->IsInArea(x, y, z)) {
150 ready = false;
151 return false;
152 }
153
154 Medium* medium = 0;
155 if (!sensor->GetMedium(x, y, z, medium)) {
156 ready = false;
157 return false;
158 }
159
160 if (medium->GetName() != mediumName ||
161 medium->GetNumberDensity() != mediumDensity || !medium->IsIonisable()) {
162 ready = false;
163 return false;
164 }
165
166 xcls = x;
167 ycls = y;
168 zcls = z;
169 tcls = t;
170 const double r = RndmUniform();
171 int iComponent = 0;
172 for (int i = 0; i < nComponents; ++i) {
173 if (r <= RndmUniform()) {
174 iComponent = i;
175 break;
176 }
177 }
178
179 // Sample secondary electron energy according to
180 // Opal-Beaty-Peterson splitting function.
181 const double e0 = ElectronMass * (sqrt(1. / (1. - beta2)) - 1.);
182 double esec = components[iComponent].wSplit *
183 tan(RndmUniform() * atan((e0 - components[iComponent].ethr) /
184 (2. * components[iComponent].wSplit)));
185 esec = components[iComponent].wSplit *
186 pow(esec / components[iComponent].wSplit, 0.9524);
187 nElectrons = 1;
188 electrons.resize(nElectrons);
189 electrons[0].energy = esec;
190 electrons[0].x = xcls;
191 electrons[0].y = ycls;
192 electrons[0].z = zcls;
193
194 ncls = nElectrons;
195 edep = esec;
196
197 return true;
198}
DoubleAc pow(const DoubleAc &f, double p)
Definition: DoubleAc.cpp:336
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:313
virtual double GetNumberDensity() const
Definition: Medium.hh:47
bool IsIonisable() const
Definition: Medium.hh:59
std::string GetName() const
Definition: Medium.hh:22
bool IsInArea(const double x, const double y, const double z)
Definition: Sensor.cc:254
bool GetMedium(const double x, const double y, const double z, Medium *&medium)
Definition: Sensor.cc:141
double beta2
Definition: Track.hh:67
Sensor * sensor
Definition: Track.hh:71
double RndmUniform()
Definition: Random.hh:16
double RndmUniformPos()
Definition: Random.hh:19

◆ GetClusterDensity()

double Garfield::TrackElectron::GetClusterDensity ( )
virtual

Reimplemented from Garfield::Track.

Definition at line 200 of file TrackElectron.cc.

200 {
201
202 if (!ready) {
203 std::cerr << className << "::GetClusterDensity:\n";
204 std::cerr << " Track has not been initialized.\n";
205 return 0.;
206 }
207
208 if (mfp <= 0.) {
209 std::cerr << className << "::GetClusterDensity:\n";
210 std::cerr << " Mean free path is not available.\n";
211 return 0.;
212 }
213
214 return 1. / mfp;
215}

◆ GetStoppingPower()

double Garfield::TrackElectron::GetStoppingPower ( )
virtual

Reimplemented from Garfield::Track.

Definition at line 217 of file TrackElectron.cc.

217 {
218
219 if (!ready) {
220 std::cerr << className << "::GetStoppingPower:\n";
221 std::cerr << " Track has not been initialised.\n";
222 return 0.;
223 }
224
225 const double prefactor = 4 * Pi * pow(HbarC / ElectronMass, 2);
226 const double lnBg2 = log(beta2 / (1. - beta2));
227
228 double dedx = 0.;
229 // Primary energy
230 const double e0 = ElectronMass * (sqrt(1. / (1. - beta2)) - 1.);
231 for (int i = nComponents; i--;) {
232 // Calculate the mean number of clusters per cm.
233 const double cmean =
234 mediumDensity * components[i].fraction * (prefactor / beta2) *
235 (components[i].m2Ion * (lnBg2 - beta2) + components[i].cIon);
236 const double ew = (e0 - components[i].ethr) / (2 * components[i].wSplit);
237 // Calculate the mean secondary electron energy.
238 const double emean =
239 (components[i].wSplit / (2 * atan(ew))) * log(1. + ew * ew);
240 dedx += cmean * emean;
241 }
242
243 return dedx;
244}

◆ NewTrack()

bool Garfield::TrackElectron::NewTrack ( const double  x0,
const double  y0,
const double  z0,
const double  t0,
const double  dx0,
const double  dy0,
const double  dz0 
)
virtual

Implements Garfield::Track.

Definition at line 49 of file TrackElectron.cc.

51 {
52
53 ready = false;
54
55 // Make sure the sensor has been set.
56 if (sensor == 0) {
57 std::cerr << className << "::NewTrack:\n";
58 std::cerr << " Sensor is not defined.\n";
59 return false;
60 }
61
62 // Get the medium at this location and check if it is "ionisable".
63 Medium* medium = 0;
64 if (!sensor->GetMedium(x0, y0, z0, medium)) {
65 std::cerr << className << "::NewTrack:\n";
66 std::cerr << " No medium at initial position.\n";
67 return false;
68 }
69 if (!medium->IsIonisable()) {
70 std::cerr << className << "::NewTrack:\n";
71 std::cerr << " Medium at initial position is not ionisable.\n";
72 return false;
73 }
74
75 // Check if the medium is a gas.
76 if (!medium->IsGas()) {
77 std::cerr << className << "::NewTrack:\n";
78 std::cerr << " Medium at initial position is not a gas.\n";
79 return false;
80 }
81
82 if (!SetupGas(medium)) {
83 std::cerr << className << "::NewTrack:\n";
84 std::cerr << " Properties of medium " << medium->GetName()
85 << " are not available.\n";
86 return false;
87 }
88
89 if (!UpdateCrossSection()) {
90 std::cerr << className << "::NewTrack:\n";
91 std::cerr << " Cross-sections could not be calculated.\n";
92 return false;
93 }
94
95 mediumName = medium->GetName();
96
97 x = x0;
98 y = y0;
99 z = z0;
100 t = t0;
101 const double dd = sqrt(dx0 * dx0 + dy0 * dy0 + dz0 * dz0);
102 if (dd < Small) {
103 if (debug) {
104 std::cout << className << "::NewTrack:\n";
105 std::cout << " Direction vector has zero norm.\n";
106 std::cout << " Initial direction is randomized.\n";
107 }
108 const double ctheta = 1. - 2. * RndmUniform();
109 const double stheta = sqrt(1. - ctheta * ctheta);
110 const double phi = TwoPi * RndmUniform();
111 dx = cos(phi) * stheta;
112 dy = sin(phi) * stheta;
113 dz = ctheta;
114 } else {
115 // Normalize the direction vector.
116 dx = dx0 / dd;
117 dy = dy0 / dd;
118 dz = dz0 / dd;
119 }
120
121 ready = true;
122 return true;
123}
DoubleAc cos(const DoubleAc &f)
Definition: DoubleAc.cpp:431
DoubleAc sin(const DoubleAc &f)
Definition: DoubleAc.cpp:383
virtual bool IsGas() const
Definition: Medium.hh:23
bool debug
Definition: Track.hh:78

◆ SetParticle()

void Garfield::TrackElectron::SetParticle ( std::string  particle)
virtual

Reimplemented from Garfield::Track.

Definition at line 41 of file TrackElectron.cc.

41 {
42
43 if (particle != "electron" && particle != "e" && particle != "e-") {
44 std::cerr << className << "::SetParticle:\n";
45 std::cerr << " Only electrons can be transported.\n";
46 }
47}

The documentation for this class was generated from the following files: