Garfield++ 4.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 HeedParticle;
13class HeedCondElectron;
14class HeedMatterDef;
15class GasDef;
16class MatterDef;
17class AtomPhotoAbsCS;
18class MolecPhotoAbsCS;
19class EnergyMesh;
20class EnTransfCS;
21class ElElasticScat;
22class ElElasticScatLowSigma;
23class PairProd;
24class HeedDeltaElectronCS;
25class HeedFieldMap;
26}
27
28namespace Garfield {
29
30class HeedChamber;
31class Medium;
32
33/// Generate tracks using Heed++.
34
35class TrackHeed : public Track {
36 public:
37 /// Constructor
38 TrackHeed();
39 /// Destructor
40 virtual ~TrackHeed();
41
42 bool NewTrack(const double x0, const double y0, const double z0,
43 const double t0, const double dx0, const double dy0,
44 const double dz0) override;
45 bool GetCluster(double& xcls, double& ycls, double& zcls, double& tcls,
46 int& n, double& e, double& extra) override;
47 bool GetCluster(double& xcls, double& ycls, double& zcls, double& tcls,
48 int& ne, int& ni, double& e, double& extra);
49 /** Retrieve the properties of a conduction or delta electron
50 * in the current cluster.
51 * \param i index of the electron
52 * \param x,y,z coordinates of the electron
53 * \param t time
54 * \param e kinetic energy (only meaningful for delta-electrons)
55 * \param dx,dy,dz direction vector (only meaningful for delta-electrons)
56 **/
57 bool GetElectron(const unsigned int i, double& x, double& y, double& z,
58 double& t, double& e, double& dx, double& dy, double& dz);
59 /** Retrieve the properties of an ion in the current cluster.
60 * \param i index of the ion
61 * \param x,y,z coordinates of the ion
62 * \param t time
63 **/
64 bool GetIon(const unsigned int i, double& x, double& y, double& z,
65 double& t) const;
66
67 double GetClusterDensity() override;
68 double GetStoppingPower() override;
69 /// Return the W value of the medium (of the last simulated track).
70 double GetW() const;
71 /// Return the Fano factor of the medium (of the last simulated track).
72 double GetFanoFactor() const;
73 /// Return the photoabsorption cross-section at a given energy.
74 double GetPhotoAbsorptionCrossSection(const double e) const;
75
76 /// Compute the differential cross-section for a given medium.
77 bool Initialise(Medium* medium);
78
79 /** Simulate a delta electron.
80 * \param x0,y0,z0 initial position of the delta electron
81 * \param t0 initial time
82 * \param e0 initial kinetic energy of the delta electron
83 * \param dx0,dy0,dz0 initial direction of the delta electron
84 * \param ne,ni number of electrons/ions produced by the delta electron
85 **/
86 void TransportDeltaElectron(const double x0, const double y0, const double z0,
87 const double t0, const double e0,
88 const double dx0, const double dy0,
89 const double dz0, int& ne, int& ni);
90 /** Simulate a delta electron.
91 * \param x0,y0,z0 initial position of the delta electron
92 * \param t0 initial time
93 * \param e0 initial kinetic energy of the delta electron
94 * \param dx0,dy0,dz0 initial direction of the delta electron
95 * \param ne number of electrons produced by the delta electron
96 **/
97 void TransportDeltaElectron(const double x0, const double y0, const double z0,
98 const double t0, const double e0,
99 const double dx0, const double dy0,
100 const double dz0, int& ne);
101
102 /** Simulate a photon.
103 * \param x0,y0,z0 initial position of the photon
104 * \param t0 initial time
105 * \param e0 initial energy of the photon
106 * \param dx0,dy0,dz0 initial direction of the photon
107 * \param ne,ni number of electrons/ions produced by the photon
108 **/
109 void TransportPhoton(const double x0, const double y0, const double z0,
110 const double t0, const double e0, const double dx0,
111 const double dy0, const double dz0, int& ne, int& ni);
112 /** Simulate a photon.
113 * \param x0,y0,z0 initial position of the photon
114 * \param t0 initial time
115 * \param e0 initial energy of the photon
116 * \param dx0,dy0,dz0 initial direction of the photon
117 * \param ne number of electrons produced by the photon
118 **/
119 void TransportPhoton(const double x0, const double y0, const double z0,
120 const double t0, const double e0, const double dx0,
121 const double dy0, const double dz0, int& ne);
122
123 /// Take the electric field into account in the stepping algorithm.
124 void EnableElectricField();
125 /// Do not take the electric field into account in the stepping algorithm.
127 /// Take the magnetic field into account in the stepping algorithm.
128 void EnableMagneticField();
129 /// Do not take the magnetic field into account in the stepping algorithm.
131
132 /** Set parameters for calculating the particle trajectory.
133 * \param maxStep
134 * maximum step length
135 * \param radStraight
136 * radius beyond which to approximate circles by polylines.
137 * \param stepAngleStraight
138 * max. angular step (in radian) when using polyline steps.
139 * \param stepAngleCurved
140 * max. angular step (in radian) when using circular steps.
141 **/
142 void SetSteppingLimits(const double maxStep, const double radStraight,
143 const double stepAngleStraight,
144 const double stepAngleCurved) {
145 m_maxStep = maxStep;
146 m_radStraight = radStraight;
147 m_stepAngleStraight = stepAngleStraight;
148 m_stepAngleCurved = stepAngleCurved;
149 }
150 void GetSteppingLimits(double& maxStep, double& radStraight,
151 double& stepAngleStraight, double& stepAngleCurved) {
152 maxStep = m_maxStep;
153 radStraight = m_radStraight;
154 stepAngleStraight = m_stepAngleStraight;
155 stepAngleCurved = m_stepAngleCurved;
156 }
157
158 /// Switch simulation of delta electrons on.
159 void EnableDeltaElectronTransport() { m_doDeltaTransport = true; }
160 /// Switch simulation of delta electrons off.
161 void DisableDeltaElectronTransport() { m_doDeltaTransport = false; }
162
163 /// Simulate (or not) the photons produced in the atomic relaxation cascade.
164 void EnablePhotonReabsorption(const bool on = true) {
165 m_usePhotonReabsorption = on;
166 }
167
168 /// Write the photoabsorption cross-sections used to a text file.
170 m_usePacsOutput = on;
171 }
172 /** Specify the energy mesh to be used.
173 * \param e0,e1 lower/higher limit of the energy range [eV]
174 * \param nsteps number of intervals
175 **/
176 void SetEnergyMesh(const double e0, const double e1, const int nsteps);
177
178 /// Define particle mass and charge (for exotic particles).
179 /// For standard particles Track::SetParticle should be used.
180 void SetParticleUser(const double m, const double z);
181
182 void EnableOneStepFly(const bool on) { m_useOneStepFly=on; }
183 private:
184 // Prevent usage of copy constructor and assignment operator
185 TrackHeed(const TrackHeed& heed);
186 TrackHeed& operator=(const TrackHeed& heed);
187
188 bool m_useOneStepFly = false;
189
190 bool m_ready = false;
191 bool m_hasActiveTrack = false;
192
193 double m_mediumDensity = -1.;
194 std::string m_mediumName = "";
195
196 bool m_usePhotonReabsorption = true;
197 bool m_usePacsOutput = false;
198
199 bool m_doDeltaTransport = true;
200 struct deltaElectron {
201 double x, y, z, t;
202 double e;
203 double dx, dy, dz;
204 };
205 std::vector<deltaElectron> m_deltaElectrons;
206 std::vector<Heed::HeedCondElectron> m_conductionElectrons;
207 std::vector<Heed::HeedCondElectron> m_conductionIons;
208
209 // Material properties
210 std::unique_ptr<Heed::HeedMatterDef> m_matter;
211 std::unique_ptr<Heed::GasDef> m_gas;
212 std::unique_ptr<Heed::MatterDef> m_material;
213
214 // Energy mesh
215 double m_emin = 2.e-6;
216 double m_emax = 2.e-1;
217 unsigned int m_nEnergyIntervals = 200;
218 std::unique_ptr<Heed::EnergyMesh> m_energyMesh;
219
220 // Cross-sections
221 std::unique_ptr<Heed::EnTransfCS> m_transferCs;
222 std::unique_ptr<Heed::ElElasticScat> m_elScat;
223 std::unique_ptr<Heed::ElElasticScatLowSigma> m_lowSigma;
224 std::unique_ptr<Heed::PairProd> m_pairProd;
225 std::unique_ptr<Heed::HeedDeltaElectronCS> m_deltaCs;
226
227 // Interface classes
228 std::unique_ptr<HeedChamber> m_chamber;
229 std::unique_ptr<Heed::HeedFieldMap> m_fieldMap;
230
231 // Bounding box
232 double m_lX = 0., m_lY = 0., m_lZ = 0.;
233 double m_cX = 0., m_cY = 0., m_cZ = 0.;
234
235 // Stepping parameters.
236 /// Max. step length.
237 double m_maxStep = 100.;
238 /// Bending radius beyond which to use straight-line approximation.
239 double m_radStraight = 1000.;
240 /// Angular step for curved trajectories approximated by straight-line steps.
241 double m_stepAngleStraight = 0.1;
242 /// Angular step for curved lines.
243 double m_stepAngleCurved = 0.2;
244
245 std::vector<Heed::gparticle*> m_particleBank;
246 std::vector<Heed::gparticle*>::iterator m_bankIterator;
247
248 bool SetupGas(Medium* medium);
249 bool SetupMaterial(Medium* medium);
250 bool SetupDelta(const std::string& databasePath);
251 std::string FindUnusedMaterialName(const std::string& namein);
252 void ClearParticleBank();
253 bool IsInside(const double x, const double y, const double z);
254 bool UpdateBoundingBox(bool& update);
255};
256}
257
258#endif
Abstract base class for media.
Definition: Medium.hh:13
Generate tracks using Heed++.
Definition: TrackHeed.hh:35
void EnableMagneticField()
Take the magnetic field into account in the stepping algorithm.
Definition: TrackHeed.cc:678
void SetEnergyMesh(const double e0, const double e1, const int nsteps)
Definition: TrackHeed.cc:681
bool GetCluster(double &xcls, double &ycls, double &zcls, double &tcls, int &n, double &e, double &extra) override
Definition: TrackHeed.cc:222
void EnablePhotonReabsorption(const bool on=true)
Simulate (or not) the photons produced in the atomic relaxation cascade.
Definition: TrackHeed.hh:164
void EnablePhotoAbsorptionCrossSectionOutput(const bool on)
Write the photoabsorption cross-sections used to a text file.
Definition: TrackHeed.hh:169
void EnableElectricField()
Take the electric field into account in the stepping algorithm.
Definition: TrackHeed.cc:676
void DisableMagneticField()
Do not take the magnetic field into account in the stepping algorithm.
Definition: TrackHeed.cc:679
double GetPhotoAbsorptionCrossSection(const double e) const
Return the photoabsorption cross-section at a given energy.
Definition: TrackHeed.cc:1050
void EnableOneStepFly(const bool on)
Definition: TrackHeed.hh:182
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:422
void DisableDeltaElectronTransport()
Switch simulation of delta electrons off.
Definition: TrackHeed.hh:161
double GetFanoFactor() const
Return the Fano factor of the medium (of the last simulated track).
Definition: TrackHeed.cc:1048
bool Initialise(Medium *medium)
Compute the differential cross-section for a given medium.
Definition: TrackHeed.cc:720
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:59
void SetSteppingLimits(const double maxStep, const double radStraight, const double stepAngleStraight, const double stepAngleCurved)
Definition: TrackHeed.hh:142
void EnableDeltaElectronTransport()
Switch simulation of delta electrons on.
Definition: TrackHeed.hh:159
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:354
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)
Definition: TrackHeed.cc:535
bool GetIon(const unsigned int i, double &x, double &y, double &z, double &t) const
Definition: TrackHeed.cc:398
virtual ~TrackHeed()
Destructor.
Definition: TrackHeed.cc:57
TrackHeed()
Constructor.
Definition: TrackHeed.cc:49
double GetW() const
Return the W value of the medium (of the last simulated track).
Definition: TrackHeed.cc:1047
void SetParticleUser(const double m, const double z)
Definition: TrackHeed.cc:703
double GetClusterDensity() override
Definition: TrackHeed.cc:200
void DisableElectricField()
Do not take the electric field into account in the stepping algorithm.
Definition: TrackHeed.cc:677
void GetSteppingLimits(double &maxStep, double &radStraight, double &stepAngleStraight, double &stepAngleCurved)
Definition: TrackHeed.hh:150
double GetStoppingPower() override
Get the stopping power (mean energy loss [eV] per cm).
Definition: TrackHeed.cc:211
Abstract base class for track generation.
Definition: Track.hh:14
Definition: BGMesh.cpp:6