Garfield++ 5.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TrackSrim.hh
Go to the documentation of this file.
1#ifndef G_TRACK_SRIM_H
2#define G_TRACK_SRIM_H
3#include <vector>
4#include "Track.hh"
5
6namespace Garfield {
7
8/// Generate tracks based on SRIM energy loss, range and straggling tables.
9/// - http://www.srim.org
10
11class TrackSrim : public Track {
12 public:
13 /// Default constructor
14 TrackSrim() : TrackSrim(nullptr) {}
15 /// Constructor
16 TrackSrim(Sensor* sensor);
17 /// Destructor
18 virtual ~TrackSrim() {}
19
20 /// Load data from a SRIM file.
21 bool ReadFile(const std::string& file);
22 /// Print the energy loss table.
23 void Print();
24 /// Plot the electromagnetic, hadronic, and total energy loss
25 /// as function of the projectile energy.
26 void PlotEnergyLoss();
27 /// Plot the projected range as function of the projectile energy.
28 void PlotRange();
29 /// Plot the transverse and longitudinal straggling as function
30 /// of the projectile energy.
31 void PlotStraggling();
32
33 /// Set the fluctuation model
34 /// (0 = none, 1 = Landau, 2 = Vavilov, 3 = Gaussian, 4 = Combined).
35 /// By default, the combined model (4) is used.
36 void SetModel(const int m) { m_model = m; }
37 /// Get the fluctuation model.
38 int GetModel() const { return m_model; }
39
40 /// Specify how many electrons should be grouped to a cluster.
41 void SetTargetClusterSize(const int n) { m_nsize = n; }
42 /// Retrieve the target cluster size.
43 int GetTargetClusterSize() const { return m_nsize; }
44
45 /// Set the max. number of clusters on a track.
46 void SetClustersMaximum(const int n) { m_maxclusters = n; }
47 /// Retrieve the max. number of clusters on a track.
48 int GetClustersMaximum() const { return m_maxclusters; }
49
50 /// Set the W value [eV].
51 void SetWorkFunction(const double w) { m_work = w; }
52 /// Get the W value [eV].
53 double GetWorkFunction() const { return m_work; }
54 /// Set the Fano factor.
55 void SetFanoFactor(const double f) {
56 m_fano = f;
57 m_fset = true;
58 }
59 /// Use the default Fano factor.
60 void UnsetFanoFactor() { m_fset = false; }
61 /// Get the Fano factor.
62 double GetFanoFactor() const { return m_fano; }
63 /// Set the density [g/cm3] of the target medium.
64 void SetDensity(const double density) { m_rho = density; }
65 /// Get the density [g/cm3] of the target medium.
66 double GetDensity() const { return m_rho; }
67 /// Set A and Z of the target medium.
68 void SetAtomicMassNumbers(const double a, const double z) {
69 m_a = a;
70 m_z = z;
71 }
72 /// Get A and Z of the target medium.
73 void GetAtomicMassMumbers(double& a, double& z) const {
74 a = m_a;
75 z = m_z;
76 }
77
78 /// Simulate transverse straggling (default: on).
79 void EnableTransverseStraggling(const bool on = true) {
81 }
82 /// Simulate longitudinal straggling (default: off).
83 void EnableLongitudinalStraggling(const bool on = true) {
85 }
86
87 struct Cluster {
88 double x, y, z, t; ///< Cluster location and time
89 double energy; ///< Energy spent to make the cluster
90 double kinetic; ///< Ion energy when cluster was created
91 int n; ///< Number of electrons in this cluster
92 };
93
94 bool NewTrack(const double x0, const double y0, const double z0,
95 const double t0, const double dx0, const double dy0,
96 const double dz0) override;
97 bool GetCluster(double& xc, double& yc, double& zc, double& tc, int& nc,
98 double& ec, double& extra) override;
99 const std::vector<Cluster>& GetClusters() const { return m_clusters; }
100
101 protected:
102 /// Include transverse straggling
104 /// Include longitudinal straggling
105 bool m_useLongStraggle = false;
106
107 /// Has the charge been defined?
108 bool m_chargeset = false;
109 /// Charge of the projectile
110 double m_qion = 1.;
111 /// Mass [MeV] of the projectile
112 double m_mion = -1.;
113 /// Mass density [g/cm3] of the target
114 double m_rho = -1.;
115 /// Work function [eV] of the target
116 double m_work = -1.;
117 /// Has the Fano factor been set?
118 bool m_fset = false;
119 /// Fano factor [-] of the target
120 double m_fano = -1.;
121 /// Effective A of the target
122 double m_a = -1.;
123 /// Effective Z of the target
124 double m_z = -1.;
125
126 /// Maximum number of clusters allowed (infinite if 0)
128 /// Energy in energy loss table [MeV]
129 std::vector<double> m_ekin;
130 /// EM energy loss [MeV cm2/g]
131 std::vector<double> m_emloss;
132 /// Hadronic energy loss [MeV cm2/g]
133 std::vector<double> m_hdloss;
134 /// Projected range [cm]
135 std::vector<double> m_range;
136 /// Transverse straggling [cm]
137 std::vector<double> m_transstraggle;
138 /// Longitudinal straggling [cm]
139 std::vector<double> m_longstraggle;
140
141 /// Index of the next cluster to be returned
142 size_t m_currcluster = 0;
143 /// Fluctuation model (0 = none, 1 = Landau, 2 = Vavilov,
144 /// 3 = Gaussian, 4 = Combined)
145 unsigned int m_model = 4;
146 /// Targeted cluster size
147 int m_nsize = -1;
148 std::vector<Cluster> m_clusters;
149
150 double Xi(const double x, const double beta2, const double edens) const;
151 double DedxEM(const double e) const;
152 double DedxHD(const double e) const;
153 bool PreciseLoss(const double step, const double estart, double& deem,
154 double& dehd) const;
155 bool EstimateRange(const double ekin, const double step,
156 double& stpmax) const;
157 bool SmallestStep(const double ekin, const double edens,
158 double de, double step, double& stpmin);
159 Medium* GetMedium(const std::array<double, 3>& x) const;
160 double Terminate(const std::array<double, 3>& x0,
161 const std::array<double, 3>& v0, const double step0) const;
162 double TerminateBfield(const std::array<double, 3>& x0,
163 const std::array<double, 3>& v0,
164 const double dt0, const double vmag) const;
165 double RndmEnergyLoss(const double ekin, const double de,
166 const double step, const double edens) const;
167};
168}
169
170#endif
Abstract base class for media.
Definition Medium.hh:16
std::vector< double > m_longstraggle
Longitudinal straggling [cm].
Definition TrackSrim.hh:139
void SetClustersMaximum(const int n)
Set the max. number of clusters on a track.
Definition TrackSrim.hh:46
void GetAtomicMassMumbers(double &a, double &z) const
Get A and Z of the target medium.
Definition TrackSrim.hh:73
void Print()
Print the energy loss table.
Definition TrackSrim.cc:287
double Xi(const double x, const double beta2, const double edens) const
Definition TrackSrim.cc:451
double m_qion
Charge of the projectile.
Definition TrackSrim.hh:110
double m_z
Effective Z of the target.
Definition TrackSrim.hh:124
std::vector< double > m_hdloss
Hadronic energy loss [MeV cm2/g].
Definition TrackSrim.hh:133
void SetDensity(const double density)
Set the density [g/cm3] of the target medium.
Definition TrackSrim.hh:64
const std::vector< Cluster > & GetClusters() const
Definition TrackSrim.hh:99
std::vector< double > m_range
Projected range [cm].
Definition TrackSrim.hh:135
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 TrackSrim.cc:639
double DedxHD(const double e) const
Definition TrackSrim.cc:447
bool EstimateRange(const double ekin, const double step, double &stpmax) const
Definition TrackSrim.cc:534
std::vector< Cluster > m_clusters
Definition TrackSrim.hh:148
size_t m_currcluster
Index of the next cluster to be returned.
Definition TrackSrim.hh:142
double GetFanoFactor() const
Get the Fano factor.
Definition TrackSrim.hh:62
void EnableTransverseStraggling(const bool on=true)
Simulate transverse straggling (default: on).
Definition TrackSrim.hh:79
std::vector< double > m_emloss
EM energy loss [MeV cm2/g].
Definition TrackSrim.hh:131
void SetTargetClusterSize(const int n)
Specify how many electrons should be grouped to a cluster.
Definition TrackSrim.hh:41
bool m_chargeset
Has the charge been defined?
Definition TrackSrim.hh:108
int GetModel() const
Get the fluctuation model.
Definition TrackSrim.hh:38
double m_fano
Fano factor [-] of the target.
Definition TrackSrim.hh:120
void SetModel(const int m)
Definition TrackSrim.hh:36
void EnableLongitudinalStraggling(const bool on=true)
Simulate longitudinal straggling (default: off).
Definition TrackSrim.hh:83
TrackSrim()
Default constructor.
Definition TrackSrim.hh:14
Medium * GetMedium(const std::array< double, 3 > &x) const
Definition TrackSrim.cc:631
double RndmEnergyLoss(const double ekin, const double de, const double step, const double edens) const
double m_mion
Mass [MeV] of the projectile.
Definition TrackSrim.hh:112
bool PreciseLoss(const double step, const double estart, double &deem, double &dehd) const
Definition TrackSrim.cc:460
void UnsetFanoFactor()
Use the default Fano factor.
Definition TrackSrim.hh:60
double m_work
Work function [eV] of the target.
Definition TrackSrim.hh:116
unsigned int m_model
Definition TrackSrim.hh:145
bool m_useTransStraggle
Include transverse straggling.
Definition TrackSrim.hh:103
int m_nsize
Targeted cluster size.
Definition TrackSrim.hh:147
void SetAtomicMassNumbers(const double a, const double z)
Set A and Z of the target medium.
Definition TrackSrim.hh:68
std::vector< double > m_ekin
Energy in energy loss table [MeV].
Definition TrackSrim.hh:129
std::vector< double > m_transstraggle
Transverse straggling [cm].
Definition TrackSrim.hh:137
double Terminate(const std::array< double, 3 > &x0, const std::array< double, 3 > &v0, const double step0) const
double GetDensity() const
Get the density [g/cm3] of the target medium.
Definition TrackSrim.hh:66
int GetClustersMaximum() const
Retrieve the max. number of clusters on a track.
Definition TrackSrim.hh:48
double m_rho
Mass density [g/cm3] of the target.
Definition TrackSrim.hh:114
virtual ~TrackSrim()
Destructor.
Definition TrackSrim.hh:18
void SetWorkFunction(const double w)
Set the W value [eV].
Definition TrackSrim.hh:51
bool m_useLongStraggle
Include longitudinal straggling.
Definition TrackSrim.hh:105
double m_a
Effective A of the target.
Definition TrackSrim.hh:122
bool GetCluster(double &xc, double &yc, double &zc, double &tc, int &nc, double &ec, double &extra) override
void PlotRange()
Plot the projected range as function of the projectile energy.
Definition TrackSrim.cc:376
bool m_fset
Has the Fano factor been set?
Definition TrackSrim.hh:118
int m_maxclusters
Maximum number of clusters allowed (infinite if 0)
Definition TrackSrim.hh:127
double DedxEM(const double e) const
Definition TrackSrim.cc:443
bool SmallestStep(const double ekin, const double edens, double de, double step, double &stpmin)
void SetFanoFactor(const double f)
Set the Fano factor.
Definition TrackSrim.hh:55
double GetWorkFunction() const
Get the W value [eV].
Definition TrackSrim.hh:53
double TerminateBfield(const std::array< double, 3 > &x0, const std::array< double, 3 > &v0, const double dt0, const double vmag) const
int GetTargetClusterSize() const
Retrieve the target cluster size.
Definition TrackSrim.hh:43
bool ReadFile(const std::string &file)
Load data from a SRIM file.
Definition TrackSrim.cc:79
Track()=delete
Default constructor.
int n
Number of electrons in this cluster.
Definition TrackSrim.hh:91
double kinetic
Ion energy when cluster was created.
Definition TrackSrim.hh:90
double t
Cluster location and time.
Definition TrackSrim.hh:88
double energy
Energy spent to make the cluster.
Definition TrackSrim.hh:89