Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
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 /// Constructor
14 TrackSrim();
15 /// Destructor
16 virtual ~TrackSrim() {}
17
18 /// Set the W value [eV].
19 void SetWorkFunction(const double w) { m_work = w; }
20 /// Get the W value [eV].
21 double GetWorkFunction() const { return m_work; }
22 /// Set the Fano factor.
23 void SetFanoFactor(const double f) { m_fano = f; }
24 /// Get the Fano factor.
25 double GetFanoFactor() const { return m_fano; }
26 /// Set the density [g/cm3] of the target medium.
27 void SetDensity(const double density) { m_density = density; }
28 /// Get the density [g/cm3] of the target medium.
29 double GetDensity() const { return m_density; }
30 /// Set A and Z of the target medium.
31 void SetAtomicMassNumbers(const double a, const double z) {
32 m_a = a;
33 m_z = z;
34 }
35 /// Get A and Z of the target medium.
36 void GetAtomicMassMumbers(double& a, double& z) const {
37 a = m_a;
38 z = m_z;
39 }
40
41 /// Set the fluctuation model
42 /// (0 = none, 1 = Landau, 2 = Vavilov, 3 = Gaussian, 4 = Combined).
43 /// By default, the combined model (4) is used.
44 void SetModel(const int m) { m_model = m; }
45 /// Get the fluctuation model.
46 int GetModel() const { return m_model; }
47
48 /// Simulate transverse straggling (default: on).
49 void EnableTransverseStraggling(const bool on = true) {
51 }
52 /// Simulate longitudinal straggling (default: off).
53 void EnableLongitudinalStraggling(const bool on = true) {
55 }
56
57 /// Specify how many electrons should be grouped to a cluster.
58 void SetTargetClusterSize(const int n) { m_nsize = n; }
59 /// Retrieve the target cluster size.
60 int GetTargetClusterSize() const { return m_nsize; }
61
62 /// Set the max. number of clusters on a track.
63 void SetClustersMaximum(const int n) { m_maxclusters = n; }
64 /// Retrieve the max. number of clusters on a track.
65 int GetClustersMaximum() const { return m_maxclusters; }
66
67 /// Load data from a SRIM file.
68 bool ReadFile(const std::string& file);
69 /// Print the energy loss table.
70 void Print();
71 /// Make a plot of the electromagnetic, hadronic, and total energy loss
72 /// as function of the projectile energy.
73 void PlotEnergyLoss();
74 /// Make a plot of the projected range as function of the projectile energy.
75 void PlotRange();
76 /// Make a plot of the transverse and longitudinal straggling as function
77 /// of the projectile energy.
78 void PlotStraggling();
79
80 bool NewTrack(const double x0, const double y0, const double z0,
81 const double t0, const double dx0, const double dy0,
82 const double dz0) override;
83 bool GetCluster(double& xcls, double& ycls, double& zcls,
84 double& tcls, int& n, double& e, double& extra) override;
85
86 protected:
87 /// Include transverse straggling
88 bool m_useTransStraggle = true;
89 /// Include longitudinal straggling
90 bool m_useLongStraggle = false;
91
92 /// Charge gas been defined
93 bool m_chargeset = false;
94 /// Density [g/cm3]
95 double m_density = -1.;
96 /// Work function [eV]
97 double m_work = -1.;
98 /// Fano factor [-]
99 double m_fano = -1.;
100 /// Charge of ion
101 double m_qion = 1.;
102 /// Mass of ion [MeV]
103 double m_mion = -1.;
104 /// Effective A of the gas
105 double m_a = -1.;
106 /// Effective Z of the gas
107 double m_z = -1.;
108
109 /// Maximum number of clusters allowed (infinite if 0)
111 /// Energy in energy loss table [MeV]
112 std::vector<double> m_ekin;
113 /// EM energy loss [MeV cm2/g]
114 std::vector<double> m_emloss;
115 /// Hadronic energy loss [MeV cm2/g]
116 std::vector<double> m_hdloss;
117 /// Projected range [cm]
118 std::vector<double> m_range;
119 /// Transverse straggling [cm]
120 std::vector<double> m_transstraggle;
121 /// Longitudinal straggling [cm]
122 std::vector<double> m_longstraggle;
123
124 /// Index of the next cluster to be returned
125 size_t m_currcluster = 0;
126 /// Fluctuation model (0 = none, 1 = Landau, 2 = Vavilov,
127 /// 3 = Gaussian, 4 = Combined)
128 unsigned int m_model = 4;
129 /// Targeted cluster size
130 int m_nsize = -1;
131 struct Cluster {
132 double x, y, z, t; ///< Cluster location and time
133 double ec; ///< Energy spent to make the cluster
134 double kinetic; ///< Ion energy when cluster was created
135 int electrons; ///< Number of electrons in this cluster
136 };
137 std::vector<Cluster> m_clusters;
138
139 double Xi(const double x, const double beta2) const;
140 double DedxEM(const double e) const;
141 double DedxHD(const double e) const;
142 bool PreciseLoss(const double step, const double estart, double& deem,
143 double& dehd) const;
144 bool EstimateRange(const double ekin, const double step, double& stpmax);
145 bool SmallestStep(double ekin, double de, double step, double& stpmin);
146
147 double RndmEnergyLoss(const double ekin, const double de,
148 const double step) const;
149};
150}
151
152#endif
std::vector< double > m_longstraggle
Longitudinal straggling [cm].
Definition: TrackSrim.hh:122
double RndmEnergyLoss(const double ekin, const double de, const double step) const
Definition: TrackSrim.cc:1157
void SetClustersMaximum(const int n)
Set the max. number of clusters on a track.
Definition: TrackSrim.hh:63
void GetAtomicMassMumbers(double &a, double &z) const
Get A and Z of the target medium.
Definition: TrackSrim.hh:36
void Print()
Print the energy loss table.
Definition: TrackSrim.cc:286
double m_qion
Charge of ion.
Definition: TrackSrim.hh:101
double m_z
Effective Z of the gas.
Definition: TrackSrim.hh:107
std::vector< double > m_hdloss
Hadronic energy loss [MeV cm2/g].
Definition: TrackSrim.hh:116
void SetDensity(const double density)
Set the density [g/cm3] of the target medium.
Definition: TrackSrim.hh:27
bool GetCluster(double &xcls, double &ycls, double &zcls, double &tcls, int &n, double &e, double &extra) override
Definition: TrackSrim.cc:1256
std::vector< double > m_range
Projected range [cm].
Definition: TrackSrim.hh:118
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:622
double DedxHD(const double e) const
Definition: TrackSrim.cc:434
std::vector< Cluster > m_clusters
Definition: TrackSrim.hh:137
size_t m_currcluster
Index of the next cluster to be returned.
Definition: TrackSrim.hh:125
double GetFanoFactor() const
Get the Fano factor.
Definition: TrackSrim.hh:25
void EnableTransverseStraggling(const bool on=true)
Simulate transverse straggling (default: on).
Definition: TrackSrim.hh:49
std::vector< double > m_emloss
EM energy loss [MeV cm2/g].
Definition: TrackSrim.hh:114
void SetTargetClusterSize(const int n)
Specify how many electrons should be grouped to a cluster.
Definition: TrackSrim.hh:58
bool m_chargeset
Charge gas been defined.
Definition: TrackSrim.hh:93
bool SmallestStep(double ekin, double de, double step, double &stpmin)
Definition: TrackSrim.cc:984
int GetModel() const
Get the fluctuation model.
Definition: TrackSrim.hh:46
double m_fano
Fano factor [-].
Definition: TrackSrim.hh:99
void SetModel(const int m)
Definition: TrackSrim.hh:44
void EnableLongitudinalStraggling(const bool on=true)
Simulate longitudinal straggling (default: off).
Definition: TrackSrim.hh:53
TrackSrim()
Constructor.
Definition: TrackSrim.cc:77
double m_mion
Mass of ion [MeV].
Definition: TrackSrim.hh:103
bool PreciseLoss(const double step, const double estart, double &deem, double &dehd) const
Definition: TrackSrim.cc:446
double m_work
Work function [eV].
Definition: TrackSrim.hh:97
unsigned int m_model
Definition: TrackSrim.hh:128
double m_density
Density [g/cm3].
Definition: TrackSrim.hh:95
bool m_useTransStraggle
Include transverse straggling.
Definition: TrackSrim.hh:88
int m_nsize
Targeted cluster size.
Definition: TrackSrim.hh:130
void SetAtomicMassNumbers(const double a, const double z)
Set A and Z of the target medium.
Definition: TrackSrim.hh:31
std::vector< double > m_ekin
Energy in energy loss table [MeV].
Definition: TrackSrim.hh:112
std::vector< double > m_transstraggle
Transverse straggling [cm].
Definition: TrackSrim.hh:120
double GetDensity() const
Get the density [g/cm3] of the target medium.
Definition: TrackSrim.hh:29
int GetClustersMaximum() const
Retrieve the max. number of clusters on a track.
Definition: TrackSrim.hh:65
virtual ~TrackSrim()
Destructor.
Definition: TrackSrim.hh:16
void SetWorkFunction(const double w)
Set the W value [eV].
Definition: TrackSrim.hh:19
bool EstimateRange(const double ekin, const double step, double &stpmax)
Definition: TrackSrim.cc:525
bool m_useLongStraggle
Include longitudinal straggling.
Definition: TrackSrim.hh:90
double m_a
Effective A of the gas.
Definition: TrackSrim.hh:105
void PlotRange()
Make a plot of the projected range as function of the projectile energy.
Definition: TrackSrim.cc:363
int m_maxclusters
Maximum number of clusters allowed (infinite if 0)
Definition: TrackSrim.hh:110
double DedxEM(const double e) const
Definition: TrackSrim.cc:430
void SetFanoFactor(const double f)
Set the Fano factor.
Definition: TrackSrim.hh:23
double GetWorkFunction() const
Get the W value [eV].
Definition: TrackSrim.hh:21
int GetTargetClusterSize() const
Retrieve the target cluster size.
Definition: TrackSrim.hh:60
bool ReadFile(const std::string &file)
Load data from a SRIM file.
Definition: TrackSrim.cc:79
double Xi(const double x, const double beta2) const
Definition: TrackSrim.cc:438
Abstract base class for track generation.
Definition: Track.hh:14
int electrons
Number of electrons in this cluster.
Definition: TrackSrim.hh:135
double kinetic
Ion energy when cluster was created.
Definition: TrackSrim.hh:134
double ec
Energy spent to make the cluster.
Definition: TrackSrim.hh:133
double t
Cluster location and time.
Definition: TrackSrim.hh:132