Garfield++ 3.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
74 /** Simulate a delta electron.
75 * \param x0,y0,z0 initial position of the delta electron
76 * \param t0 initial time
77 * \param e0 initial kinetic energy of the delta electron
78 * \param dx0,dy0,dz0 initial direction of the delta electron
79 * \param ne,ni number of electrons/ions produced by the delta electron
80 **/
81 void TransportDeltaElectron(const double x0, const double y0, const double z0,
82 const double t0, const double e0,
83 const double dx0, const double dy0,
84 const double dz0, int& ne, int& ni);
85 /** Simulate a delta electron.
86 * \param x0,y0,z0 initial position of the delta electron
87 * \param t0 initial time
88 * \param e0 initial kinetic energy of the delta electron
89 * \param dx0,dy0,dz0 initial direction of the delta electron
90 * \param ne number of electrons produced by the delta electron
91 **/
92 void TransportDeltaElectron(const double x0, const double y0, const double z0,
93 const double t0, const double e0,
94 const double dx0, const double dy0,
95 const double dz0, int& ne);
96
97 /** Simulate a photon.
98 * \param x0,y0,z0 initial position of the photon
99 * \param t0 initial time
100 * \param e0 initial energy of the photon
101 * \param dx0,dy0,dz0 initial direction of the photon
102 * \param ne,ni number of electrons/ions produced by the photon
103 **/
104 void TransportPhoton(const double x0, const double y0, const double z0,
105 const double t0, const double e0, const double dx0,
106 const double dy0, const double dz0, int& ne, int& ni);
107 /** Simulate a photon.
108 * \param x0,y0,z0 initial position of the photon
109 * \param t0 initial time
110 * \param e0 initial energy of the photon
111 * \param dx0,dy0,dz0 initial direction of the photon
112 * \param ne number of electrons produced by the photon
113 **/
114 void TransportPhoton(const double x0, const double y0, const double z0,
115 const double t0, const double e0, const double dx0,
116 const double dy0, const double dz0, int& ne);
117
118 /// Take the electric field into account in the stepping algorithm.
119 void EnableElectricField();
120 /// Do not take the electric field into account in the stepping algorithm.
122 /// Take the magnetic field into account in the stepping algorithm.
123 void EnableMagneticField();
124 /// Do not take the magnetic field into account in the stepping algorithm.
126
127 /** Set parameters for calculating the particle trajectory.
128 * \param maxStep
129 * maximum step length
130 * \param radStraight
131 * radius beyond which to approximate circles by polylines.
132 * \param stepAngleStraight
133 * max. angular step (in radian) when using polyline steps.
134 * \param stepAngleCurved
135 * max. angular step (in radian) when using circular steps.
136 **/
137 void SetSteppingLimits(const double maxStep, const double radStraight,
138 const double stepAngleStraight,
139 const double stepAngleCurved) {
140 m_maxStep = maxStep;
141 m_radStraight = radStraight;
142 m_stepAngleStraight = stepAngleStraight;
143 m_stepAngleCurved = stepAngleCurved;
144 }
145 void GetSteppingLimits(double& maxStep, double& radStraight,
146 double& stepAngleStraight, double& stepAngleCurved) {
147 maxStep = m_maxStep;
148 radStraight = m_radStraight;
149 stepAngleStraight = m_stepAngleStraight;
150 stepAngleCurved = m_stepAngleCurved;
151 }
152
153 /// Switch simulation of delta electrons on.
154 void EnableDeltaElectronTransport() { m_doDeltaTransport = true; }
155 /// Switch simulation of delta electrons off.
156 void DisableDeltaElectronTransport() { m_doDeltaTransport = false; }
157
158 /// Simulate (or not) the photons produced in the atomic relaxation cascade.
159 void EnablePhotonReabsorption(const bool on = true) {
160 m_usePhotonReabsorption = on;
161 }
162
163 /// Write the photoabsorption cross-sections used to a text file.
165 m_usePacsOutput = on;
166 }
167 /** Specify the energy mesh to be used.
168 * \param e0,e1 lower/higher limit of the energy range [eV]
169 * \param nsteps number of intervals
170 **/
171 void SetEnergyMesh(const double e0, const double e1, const int nsteps);
172
173 /// Define particle mass and charge (for exotic particles).
174 /// For standard particles Track::SetParticle should be used.
175 void SetParticleUser(const double m, const double z);
176
177 private:
178 // Prevent usage of copy constructor and assignment operator
179 TrackHeed(const TrackHeed& heed);
180 TrackHeed& operator=(const TrackHeed& heed);
181
182 bool m_ready = false;
183 bool m_hasActiveTrack = false;
184
185 double m_mediumDensity = -1.;
186 std::string m_mediumName = "";
187
188 bool m_usePhotonReabsorption = true;
189 bool m_usePacsOutput = false;
190
191 bool m_doDeltaTransport = true;
192 struct deltaElectron {
193 double x, y, z, t;
194 double e;
195 double dx, dy, dz;
196 };
197 std::vector<deltaElectron> m_deltaElectrons;
198 std::vector<Heed::HeedCondElectron> m_conductionElectrons;
199 std::vector<Heed::HeedCondElectron> m_conductionIons;
200
201 // Material properties
202 std::unique_ptr<Heed::HeedMatterDef> m_matter;
203 std::unique_ptr<Heed::GasDef> m_gas;
204 std::unique_ptr<Heed::MatterDef> m_material;
205
206 // Energy mesh
207 double m_emin = 2.e-6;
208 double m_emax = 2.e-1;
209 unsigned int m_nEnergyIntervals = 200;
210 std::unique_ptr<Heed::EnergyMesh> m_energyMesh;
211
212 // Cross-sections
213 std::unique_ptr<Heed::EnTransfCS> m_transferCs;
214 std::unique_ptr<Heed::ElElasticScat> m_elScat;
215 std::unique_ptr<Heed::ElElasticScatLowSigma> m_lowSigma;
216 std::unique_ptr<Heed::PairProd> m_pairProd;
217 std::unique_ptr<Heed::HeedDeltaElectronCS> m_deltaCs;
218
219 // Interface classes
220 std::unique_ptr<HeedChamber> m_chamber;
221 std::unique_ptr<Heed::HeedFieldMap> m_fieldMap;
222
223 // Bounding box
224 double m_lX = 0., m_lY = 0., m_lZ = 0.;
225 double m_cX = 0., m_cY = 0., m_cZ = 0.;
226
227 // Stepping parameters.
228 /// Max. step length.
229 double m_maxStep = 100.;
230 /// Bending radius beyond which to use straight-line approximation.
231 double m_radStraight = 1000.;
232 /// Angular step for curved trajectories approximated by straight-line steps.
233 double m_stepAngleStraight = 0.1;
234 /// Angular step for curved lines.
235 double m_stepAngleCurved = 0.2;
236
237#ifndef __CINT__
238 std::vector<Heed::gparticle*> m_particleBank;
239 std::vector<Heed::gparticle*>::iterator m_bankIterator;
240#endif /* __CINT __ */
241 bool Setup(Medium* medium);
242 bool SetupGas(Medium* medium);
243 bool SetupMaterial(Medium* medium);
244 bool SetupDelta(const std::string& databasePath);
245 std::string FindUnusedMaterialName(const std::string& namein);
246 void ClearParticleBank();
247 bool IsInside(const double x, const double y, const double z);
248 bool UpdateBoundingBox(bool& update);
249};
250}
251
252#endif
Generate tracks using Heed++.
Definition: TrackHeed.hh:35
void EnableMagneticField()
Take the magnetic field into account in the stepping algorithm.
Definition: TrackHeed.cc:682
void SetEnergyMesh(const double e0, const double e1, const int nsteps)
Definition: TrackHeed.cc:685
bool GetCluster(double &xcls, double &ycls, double &zcls, double &tcls, int &n, double &e, double &extra) override
Definition: TrackHeed.cc:227
void EnablePhotonReabsorption(const bool on=true)
Simulate (or not) the photons produced in the atomic relaxation cascade.
Definition: TrackHeed.hh:159
void EnablePhotoAbsorptionCrossSectionOutput(const bool on)
Write the photoabsorption cross-sections used to a text file.
Definition: TrackHeed.hh:164
void EnableElectricField()
Take the electric field into account in the stepping algorithm.
Definition: TrackHeed.cc:680
void DisableMagneticField()
Do not take the magnetic field into account in the stepping algorithm.
Definition: TrackHeed.cc:683
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:426
void DisableDeltaElectronTransport()
Switch simulation of delta electrons off.
Definition: TrackHeed.hh:156
double GetFanoFactor() const
Return the Fano factor of the medium (of the last simulated track).
Definition: TrackHeed.cc:1047
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:137
void EnableDeltaElectronTransport()
Switch simulation of delta electrons on.
Definition: TrackHeed.hh:154
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:358
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:539
bool GetIon(const unsigned int i, double &x, double &y, double &z, double &t) const
Definition: TrackHeed.cc:402
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:1046
void SetParticleUser(const double m, const double z)
Definition: TrackHeed.cc:707
double GetClusterDensity() override
Definition: TrackHeed.cc:195
void DisableElectricField()
Do not take the electric field into account in the stepping algorithm.
Definition: TrackHeed.cc:681
void GetSteppingLimits(double &maxStep, double &radStraight, double &stepAngleStraight, double &stepAngleCurved)
Definition: TrackHeed.hh:145
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