Garfield++ 5.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
TrackHeed.hh
Go to the documentation of this file.
1#ifndef G_TRACK_HEED_H
2#define G_TRACK_HEED_H
3
4#include <list>
5#include <memory>
6#include <vector>
7
8#include "Track.hh"
9
10namespace Heed {
11class gparticle;
12class particle_def;
13class HeedParticle;
15class HeedMatterDef;
16class GasDef;
17class MatterDef;
18class EnergyMesh;
19class EnTransfCS;
20class ElElasticScat;
22class PairProd;
24class HeedFieldMap;
25class HeedPhoton;
26}
27
28namespace Garfield {
29
30class HeedChamber;
31class Medium;
32
33/// Generate tracks using Heed++.
34
35class TrackHeed : public Track {
36 public:
37 struct Electron {
38 double x = 0.;
39 double y = 0.;
40 double z = 0.;
41 double t = 0.;
42 double e = 0.;
43 double dx = 0.;
44 double dy = 0.;
45 double dz = 0.;
46 };
47
48 struct Photon {
49 double x = 0.;
50 double y = 0.;
51 double z = 0.;
52 double t = 0.;
53 double e = 0.;
54 double dx = 0.;
55 double dy = 0.;
56 double dz = 0.;
57 };
58
59 struct Cluster {
60 double x, y, z, t;
61 double energy;
62 double extra;
63 std::vector<Photon> photons;
64 std::vector<Electron> electrons;
65 std::vector<Electron> ions;
66 };
67
68 /// Default constructor
69 TrackHeed() : TrackHeed(nullptr) {}
70 /// Constructor
71 TrackHeed(Sensor* sensor);
72 /// Destructor
73 virtual ~TrackHeed();
74
75 bool NewTrack(const double x0, const double y0, const double z0,
76 const double t0, const double dx0, const double dy0,
77 const double dz0) override;
78 bool GetCluster(double& xc, double& yc, double& zc, double& tc, int& nc,
79 double& ec, double& extra) override;
80 const std::vector<Cluster>& GetClusters() const {
81 return m_clusters;
82 }
83 bool GetCluster(double& xc, double& yc, double& zc, double& tc,
84 int& ne, int& ni, double& ec, double& extra);
85 /** Get the next "cluster" (ionising collision of the charged particle).
86 * \param xc,yc,zc coordinates of the collision
87 * \param tc time of the collision
88 * \param ne number of electrons
89 * \param ni number of ions
90 * \param np number of fluorescence photons
91 * \param ec deposited energy
92 * \param extra additional information (not always implemented)
93 */
94 bool GetCluster(double& xc, double& yc, double& zc, double& tc,
95 int& ne, int& ni, int& np, double& ec, double& extra);
96 /** Retrieve the properties of a conduction or delta electron
97 * in the current cluster.
98 * \param i index of the electron
99 * \param x,y,z coordinates of the electron
100 * \param t time
101 * \param e kinetic energy (only meaningful for delta-electrons)
102 * \param dx,dy,dz direction vector (only meaningful for delta-electrons)
103 **/
104 bool GetElectron(const unsigned int i, double& x, double& y, double& z,
105 double& t, double& e, double& dx, double& dy, double& dz);
106 /** Retrieve the properties of an ion in the current cluster.
107 * \param i index of the ion
108 * \param x,y,z coordinates of the ion
109 * \param t time
110 **/
111 bool GetIon(const unsigned int i, double& x, double& y, double& z,
112 double& t) const;
113
114 /** Retrieve the properties of an unabsorbed photon.
115 * \param i index of the photon
116 * \param x,y,z coordinates of the photon
117 * \param t time
118 * \param e photon energy
119 * \param dx,dy,dz direction vector
120 **/
121 bool GetPhoton(const unsigned int i, double& x, double& y, double& z,
122 double& t, double& e, double& dx, double& dy,
123 double& dz) const;
124
125 double GetClusterDensity() override;
126 double GetStoppingPower() override;
127 /// Return the W value of the medium (of the last simulated track).
128 double GetW() const;
129 /// Return the Fano factor of the medium (of the last simulated track).
130 double GetFanoFactor() const;
131 /// Return the photoabsorption cross-section at a given energy.
132 double GetPhotoAbsorptionCrossSection(const double e) const;
133
134 /// Compute the differential cross-section for a given medium.
135 bool Initialise(Medium* medium, const bool verbose = false);
136
137 /** Simulate a delta electron.
138 * \param x0,y0,z0 initial position of the delta electron
139 * \param t0 initial time
140 * \param e0 initial kinetic energy of the delta electron
141 * \param dx0,dy0,dz0 initial direction of the delta electron
142 * \param ne,ni number of electrons/ions produced by the delta electron
143 **/
144 void TransportDeltaElectron(const double x0, const double y0, const double z0,
145 const double t0, const double e0,
146 const double dx0, const double dy0,
147 const double dz0, int& ne, int& ni);
148 /** Simulate a delta electron.
149 * \param x0,y0,z0 initial position of the delta electron
150 * \param t0 initial time
151 * \param e0 initial kinetic energy of the delta electron
152 * \param dx0,dy0,dz0 initial direction of the delta electron
153 * \param ne number of electrons produced by the delta electron
154 **/
155 void TransportDeltaElectron(const double x0, const double y0, const double z0,
156 const double t0, const double e0,
157 const double dx0, const double dy0,
158 const double dz0, int& ne);
159
160 /** Simulate a photon.
161 * \param x0,y0,z0 initial position of the photon
162 * \param t0 initial time
163 * \param e0 initial energy of the photon
164 * \param dx0,dy0,dz0 initial direction of the photon
165 * \param ne number of electrons produced by the photon
166 * \param ni number of ions produced by the photon
167 * \param np number of fluorescence photons
168 **/
169 void TransportPhoton(const double x0, const double y0, const double z0,
170 const double t0, const double e0, const double dx0,
171 const double dy0, const double dz0,
172 int& ne, int& ni, int& np);
173
174 /** Simulate a photon.
175 * \param x0,y0,z0 initial position of the photon
176 * \param t0 initial time
177 * \param e0 initial energy of the photon
178 * \param dx0,dy0,dz0 initial direction of the photon
179 * \param ne number of electrons produced by the photon
180 * \param ni number of ions produced by the photon
181 **/
182 void TransportPhoton(const double x0, const double y0, const double z0,
183 const double t0, const double e0, const double dx0,
184 const double dy0, const double dz0, int& ne, int& ni);
185 /** Simulate a photon.
186 * \param x0,y0,z0 initial position of the photon
187 * \param t0 initial time
188 * \param e0 initial energy of the photon
189 * \param dx0,dy0,dz0 initial direction of the photon
190 * \param ne number of electrons produced by the photon
191 **/
192 void TransportPhoton(const double x0, const double y0, const double z0,
193 const double t0, const double e0, const double dx0,
194 const double dy0, const double dz0, int& ne);
195
196 /// Take the electric field into account in the stepping algorithm.
197 void EnableElectricField();
198 /// Do not take the electric field into account in the stepping algorithm.
200 /// Take the magnetic field into account in the stepping algorithm.
201 void EnableMagneticField();
202 /// Do not take the magnetic field into account in the stepping algorithm.
204
205 /** Set parameters for calculating the particle trajectory.
206 * \param maxStep
207 * maximum step length
208 * \param radStraight
209 * radius beyond which to approximate circles by polylines.
210 * \param stepAngleStraight
211 * max. angular step (in radian) when using polyline steps.
212 * \param stepAngleCurved
213 * max. angular step (in radian) when using circular steps.
214 **/
215 void SetSteppingLimits(const double maxStep, const double radStraight,
216 const double stepAngleStraight,
217 const double stepAngleCurved) {
218 m_maxStep = maxStep;
219 m_radStraight = radStraight;
220 m_stepAngleStraight = stepAngleStraight;
221 m_stepAngleCurved = stepAngleCurved;
222 }
223 void GetSteppingLimits(double& maxStep, double& radStraight,
224 double& stepAngleStraight, double& stepAngleCurved) {
225 maxStep = m_maxStep;
226 radStraight = m_radStraight;
227 stepAngleStraight = m_stepAngleStraight;
228 stepAngleCurved = m_stepAngleCurved;
229 }
230
231 void EnableCoulombScattering(const bool on = true) {
232 m_coulombScattering = on;
233 }
234 /// Switch simulation of delta electrons on.
235 void EnableDeltaElectronTransport() { m_doDeltaTransport = true; }
236 /// Switch simulation of delta electrons off.
237 void DisableDeltaElectronTransport() { m_doDeltaTransport = false; }
238
239 /// Simulate (or not) the photons produced in the atomic relaxation cascade.
240 void EnablePhotonReabsorption(const bool on = true) {
241 m_doPhotonReabsorption = on;
242 }
243
244 /// Write the photoabsorption cross-sections used to a text file.
246 m_usePacsOutput = on;
247 }
248 /** Specify the energy mesh to be used.
249 * \param e0,e1 lower/higher limit of the energy range [eV]
250 * \param nsteps number of intervals
251 **/
252 void SetEnergyMesh(const double e0, const double e1, const int nsteps);
253
254 /// Define particle mass and charge (for exotic particles).
255 /// For standard particles Track::SetParticle should be used.
256 void SetParticleUser(const double m, const double z);
257
258 void EnableOneStepFly(const bool on) { m_oneStepFly = on; }
259 private:
260 // Prevent usage of copy constructor and assignment operator
261 TrackHeed(const TrackHeed& heed);
262 TrackHeed& operator=(const TrackHeed& heed);
263
264 bool m_oneStepFly = false;
265
266 bool m_ready = false;
267 bool m_hasActiveTrack = false;
268
269 double m_mediumDensity = -1.;
270 std::string m_mediumName = "";
271
272 bool m_usePacsOutput = false;
273
274 bool m_doPhotonReabsorption = true;
275 bool m_coulombScattering = false;
276 bool m_useBfieldAuto = true;
277 bool m_doDeltaTransport = true;
278
279 std::vector<Cluster> m_clusters;
280 size_t m_cluster = 0;
281
282 // Particle properties
283 std::unique_ptr<Heed::particle_def> m_particle_def;
284 // Material properties
285 std::unique_ptr<Heed::HeedMatterDef> m_matter;
286 std::unique_ptr<Heed::GasDef> m_gas;
287 std::unique_ptr<Heed::MatterDef> m_material;
288
289 // Energy mesh
290 double m_emin = 2.e-6;
291 double m_emax = 2.e-1;
292 unsigned int m_nEnergyIntervals = 200;
293 std::unique_ptr<Heed::EnergyMesh> m_energyMesh;
294
295 // Cross-sections
296 std::unique_ptr<Heed::EnTransfCS> m_transferCs;
297 std::unique_ptr<Heed::ElElasticScat> m_elScat;
298 std::unique_ptr<Heed::ElElasticScatLowSigma> m_lowSigma;
299 std::unique_ptr<Heed::PairProd> m_pairProd;
300 std::unique_ptr<Heed::HeedDeltaElectronCS> m_deltaCs;
301
302 // Interface classes
303 std::unique_ptr<HeedChamber> m_chamber;
304 std::unique_ptr<Heed::HeedFieldMap> m_fieldMap;
305
306 // Bounding box
307 double m_lX = 0., m_lY = 0., m_lZ = 0.;
308 double m_cX = 0., m_cY = 0., m_cZ = 0.;
309
310 // Stepping parameters.
311 /// Max. step length.
312 double m_maxStep = 100.;
313 /// Bending radius beyond which to use straight-line approximation.
314 double m_radStraight = 1000.;
315 /// Angular step for curved trajectories approximated by straight-line steps.
316 double m_stepAngleStraight = 0.1;
317 /// Angular step for curved lines.
318 double m_stepAngleCurved = 0.2;
319
320 bool SetupGas(Medium* medium);
321 bool SetupMaterial(Medium* medium);
322 bool SetupDelta(const std::string& databasePath);
323 bool AddCluster(Heed::HeedPhoton* virtualPhoton,
324 std::vector<Cluster>& clusters);
325 void AddElectrons(
326 const std::vector<Heed::HeedCondElectron>& conductionElectrons,
327 std::vector<Electron>& electrons);
328 bool IsInside(const double x, const double y, const double z);
329 bool UpdateBoundingBox(bool& update);
330};
331}
332
333#endif
Abstract base class for media.
Definition Medium.hh:16
Generate tracks using Heed++.
Definition TrackHeed.hh:35
void EnableMagneticField()
Take the magnetic field into account in the stepping algorithm.
Definition TrackHeed.cc:724
void SetEnergyMesh(const double e0, const double e1, const int nsteps)
Definition TrackHeed.cc:734
void EnablePhotonReabsorption(const bool on=true)
Simulate (or not) the photons produced in the atomic relaxation cascade.
Definition TrackHeed.hh:240
void EnablePhotoAbsorptionCrossSectionOutput(const bool on)
Write the photoabsorption cross-sections used to a text file.
Definition TrackHeed.hh:245
void EnableElectricField()
Take the electric field into account in the stepping algorithm.
Definition TrackHeed.cc:721
void DisableMagneticField()
Do not take the magnetic field into account in the stepping algorithm.
Definition TrackHeed.cc:729
double GetPhotoAbsorptionCrossSection(const double e) const
Return the photoabsorption cross-section at a given energy.
void EnableOneStepFly(const bool on)
Definition TrackHeed.hh:258
void TransportDeltaElectron(const double x0, const double y0, const double z0, const double t0, const double e0, const double dx0, const double dy0, const double dz0, int &ne, int &ni)
Definition TrackHeed.cc:478
void DisableDeltaElectronTransport()
Switch simulation of delta electrons off.
Definition TrackHeed.hh:237
double GetFanoFactor() const
Return the Fano factor of the medium (of the last simulated track).
void EnableCoulombScattering(const bool on=true)
Definition TrackHeed.hh:231
bool GetPhoton(const unsigned int i, double &x, double &y, double &z, double &t, double &e, double &dx, double &dy, double &dz) const
Definition TrackHeed.cc:448
bool NewTrack(const double x0, const double y0, const double z0, const double t0, const double dx0, const double dy0, const double dz0) override
Definition TrackHeed.cc:87
bool Initialise(Medium *medium, const bool verbose=false)
Compute the differential cross-section for a given medium.
Definition TrackHeed.cc:771
void SetSteppingLimits(const double maxStep, const double radStraight, const double stepAngleStraight, const double stepAngleCurved)
Definition TrackHeed.hh:215
void EnableDeltaElectronTransport()
Switch simulation of delta electrons on.
Definition TrackHeed.hh:235
bool GetElectron(const unsigned int i, double &x, double &y, double &z, double &t, double &e, double &dx, double &dy, double &dz)
Definition TrackHeed.cc:410
bool GetIon(const unsigned int i, double &x, double &y, double &z, double &t) const
Definition TrackHeed.cc:432
const std::vector< Cluster > & GetClusters() const
Definition TrackHeed.hh:80
virtual ~TrackHeed()
Destructor.
Definition TrackHeed.cc:85
TrackHeed()
Default constructor.
Definition TrackHeed.hh:69
void TransportPhoton(const double x0, const double y0, const double z0, const double t0, const double e0, const double dx0, const double dy0, const double dz0, int &ne, int &ni, int &np)
Definition TrackHeed.cc:583
double GetW() const
Return the W value of the medium (of the last simulated track).
void SetParticleUser(const double m, const double z)
Definition TrackHeed.cc:754
bool GetCluster(double &xc, double &yc, double &zc, double &tc, int &nc, double &ec, double &extra) override
Definition TrackHeed.cc:368
double GetClusterDensity() override
Definition TrackHeed.cc:232
void DisableElectricField()
Do not take the electric field into account in the stepping algorithm.
Definition TrackHeed.cc:722
void GetSteppingLimits(double &maxStep, double &radStraight, double &stepAngleStraight, double &stepAngleCurved)
Definition TrackHeed.hh:223
double GetStoppingPower() override
Get the stopping power (mean energy loss [eV] per cm).
Definition TrackHeed.cc:242
Track()=delete
Default constructor.
Retrieve electric and magnetic field from Sensor.
Definition BGMesh.cpp:6
std::vector< Electron > ions
Definition TrackHeed.hh:65
std::vector< Photon > photons
Definition TrackHeed.hh:63
std::vector< Electron > electrons
Definition TrackHeed.hh:64