Garfield++ 3.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 void SetClustersMaximum(const int n) { m_maxclusters = n; }
63 int GetClustersMaximum() const { return m_maxclusters; }
64
65 /// Load data from a SRIM file.
66 bool ReadFile(const std::string& file);
67 void Print();
68 /// Make a plot of the electromagnetic, hadronic, and total energy loss
69 /// as function of the projectile energy.
70 void PlotEnergyLoss();
71 /// Make a plot of the projected range as function of the projectile energy.
72 void PlotRange();
73 /// Make a plot of the transverse and longitudinal straggling as function
74 /// of the projectile energy.
75 void PlotStraggling();
76
77 bool NewTrack(const double x0, const double y0, const double z0,
78 const double t0, const double dx0, const double dy0,
79 const double dz0) override;
80 bool GetCluster(double& xcls, double& ycls, double& zcls,
81 double& tcls, int& n, double& e, double& extra) override;
82
83 protected:
84 /// Include transverse straggling
85 bool m_useTransStraggle = true;
86 /// Include longitudinal straggling
87 bool m_useLongStraggle = false;
88
89 /// Charge gas been defined
90 bool m_chargeset = false;
91 /// Density [g/cm3]
92 double m_density = -1.;
93 /// Work function [eV]
94 double m_work = -1.;
95 /// Fano factor [-]
96 double m_fano = -1.;
97 /// Charge of ion
98 double m_q;
99 /// Mass of ion [MeV]
100 double m_mass = -1.;
101 /// A and Z of the gas
102 double m_a = -1.;
103 double m_z = -1.;
104
105 /// Maximum number of clusters allowed (infinite if 0)
107 /// Energy in energy loss table [MeV]
108 std::vector<double> m_ekin;
109 /// EM energy loss [MeV cm2/g]
110 std::vector<double> m_emloss;
111 /// Hadronic energy loss [MeV cm2/g]
112 std::vector<double> m_hdloss;
113 /// Projected range [cm]
114 std::vector<double> m_range;
115 /// Transverse straggling [cm]
116 std::vector<double> m_transstraggle;
117 /// Longitudinal straggling [cm]
118 std::vector<double> m_longstraggle;
119
120 /// Index of the next cluster to be returned
121 unsigned int m_currcluster;
122 /// Fluctuation model (0 = none, 1 = Landau, 2 = Vavilov,
123 /// 3 = Gaussian, 4 = Combined)
124 unsigned int m_model = 4;
125 /// Targeted cluster size
126 int m_nsize = -1;
127 struct Cluster {
128 double x, y, z, t; ///< Cluster location and time
129 double ec; ///< Energy spent to make the cluster
130 double kinetic; ///< Ion energy when cluster was created
131 int electrons; ///< Number of electrons in this cluster
132 };
133 std::vector<Cluster> m_clusters;
134
135 double Xi(const double x, const double beta2) const;
136 double DedxEM(const double e) const;
137 double DedxHD(const double e) const;
138 bool PreciseLoss(const double step, const double estart, double& deem,
139 double& dehd) const;
140 bool EstimateRange(const double ekin, const double step, double& stpmax);
141 bool SmallestStep(double ekin, double de, double step, double& stpmin);
142
143 double RndmEnergyLoss(const double ekin, const double de,
144 const double step) const;
145};
146}
147
148#endif
std::vector< double > m_longstraggle
Longitudinal straggling [cm].
Definition: TrackSrim.hh:118
double RndmEnergyLoss(const double ekin, const double de, const double step) const
Definition: TrackSrim.cc:1144
double m_q
Charge of ion.
Definition: TrackSrim.hh:98
void SetClustersMaximum(const int n)
Definition: TrackSrim.hh:62
void GetAtomicMassMumbers(double &a, double &z) const
Get A and Z of the target medium.
Definition: TrackSrim.hh:36
unsigned int m_currcluster
Index of the next cluster to be returned.
Definition: TrackSrim.hh:121
std::vector< double > m_hdloss
Hadronic energy loss [MeV cm2/g].
Definition: TrackSrim.hh:112
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:1243
std::vector< double > m_range
Projected range [cm].
Definition: TrackSrim.hh:114
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:617
double DedxHD(const double e) const
Definition: TrackSrim.cc:431
std::vector< Cluster > m_clusters
Definition: TrackSrim.hh:133
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:110
void SetTargetClusterSize(const int n)
Specify how many electrons should be grouped to a cluster.
Definition: TrackSrim.hh:58
double m_mass
Mass of ion [MeV].
Definition: TrackSrim.hh:100
bool m_chargeset
Charge gas been defined.
Definition: TrackSrim.hh:90
bool SmallestStep(double ekin, double de, double step, double &stpmin)
Definition: TrackSrim.cc:971
int GetModel() const
Get the fluctuation model.
Definition: TrackSrim.hh:46
double m_fano
Fano factor [-].
Definition: TrackSrim.hh:96
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:76
bool PreciseLoss(const double step, const double estart, double &deem, double &dehd) const
Definition: TrackSrim.cc:443
double m_work
Work function [eV].
Definition: TrackSrim.hh:94
unsigned int m_model
Definition: TrackSrim.hh:124
double m_density
Density [g/cm3].
Definition: TrackSrim.hh:92
bool m_useTransStraggle
Include transverse straggling.
Definition: TrackSrim.hh:85
int m_nsize
Targeted cluster size.
Definition: TrackSrim.hh:126
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:108
std::vector< double > m_transstraggle
Transverse straggling [cm].
Definition: TrackSrim.hh:116
double GetDensity() const
Get the density [g/cm3] of the target medium.
Definition: TrackSrim.hh:29
int GetClustersMaximum() const
Definition: TrackSrim.hh:63
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:522
bool m_useLongStraggle
Include longitudinal straggling.
Definition: TrackSrim.hh:87
double m_a
A and Z of the gas.
Definition: TrackSrim.hh:102
void PlotRange()
Make a plot of the projected range as function of the projectile energy.
Definition: TrackSrim.cc:361
int m_maxclusters
Maximum number of clusters allowed (infinite if 0)
Definition: TrackSrim.hh:106
double DedxEM(const double e) const
Definition: TrackSrim.cc:427
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:78
double Xi(const double x, const double beta2) const
Definition: TrackSrim.cc:435
Abstract base class for track generation.
Definition: Track.hh:14
int electrons
Number of electrons in this cluster.
Definition: TrackSrim.hh:131
double kinetic
Ion energy when cluster was created.
Definition: TrackSrim.hh:130
double ec
Energy spent to make the cluster.
Definition: TrackSrim.hh:129
double t
Cluster location and time.
Definition: TrackSrim.hh:128