Garfield++ 5.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
TrackTrim.hh
Go to the documentation of this file.
1#ifndef G_TRACK_TRIM_H
2#define G_TRACK_TRIM_H
3
4#include <string>
5#include <vector>
6
7#include "Track.hh"
8
9namespace Garfield {
10
11/// Generate tracks based on TRIM output files.
12/// - http://www.srim.org
13
14class TrackTrim : public Track {
15 public:
16 /// Default constructor
17 TrackTrim() : TrackTrim(nullptr) {}
18 /// Constructor
19 TrackTrim(Sensor* sensor);
20 /// Destructor
21 virtual ~TrackTrim() {}
22
23 /// Load data from an EXYZ.txt file.
24 bool ReadFile(const std::string& file, const unsigned int nIons = 0,
25 const unsigned int nSkip = 0);
26 /// Print a summary of the available TRIM data.
27 void Print();
28
29 /// Set the projectile charge [-].
30 void SetCharge(const double q) { if (fabs(q) > 0.) m_q = q; }
31 /// Set the W value [eV].
32 void SetWorkFunction(const double w) { m_work = w; }
33 /// Get the W value [eV].
34 double GetWorkFunction() const { return m_work; }
35 /// Set the Fano factor.
36 void SetFanoFactor(const double f) {
37 m_fano = f;
38 m_fset = true;
39 }
40 /// Use the default Fano factor.
41 void UnsetFanoFactor() { m_fset = false; }
42 /// Get the Fano factor.
43 double GetFanoFactor() const { return m_fano; }
44
45 /// Set a max. distance between subsequent steps.
46 void EnableStepSizeLimit(const double dmax) { m_maxStepSize = dmax; }
47 /// Do not reduce the steps with respect to the TRIM input file (default).
49 /// Set a max. energy loss per cluster.
50 void EnableEnergyLossLimit(const double emax) { m_maxLossPerStep = emax; }
51 /// Do not limit the energy loss per cluster (default).
52 /// Each segment in the TRIM input file corresponds to one cluster.
54
55 void SetParticle(const std::string& part) override;
56
57 struct Cluster {
58 double x, y, z; ///< Location
59 double t; ///< Time
60 double energy; ///< Energy spent to make the cluster
61 double ekin; ///< Ion energy when cluster was created
62 int n; ///< Number of electrons in this cluster
63 };
64
65 bool NewTrack(const double x0, const double y0, const double z0,
66 const double t0, const double dx0, const double dy0,
67 const double dz0) override;
68 bool GetCluster(double& xc, double& yc, double& zc, double& tc, int& nc,
69 double& ec, double& extra) override;
70 const std::vector<Cluster>& GetClusters() const {
71 return m_clusters;
72 }
73
74 protected:
75 /// Work function [eV] of the target.
76 double m_work = -1.;
77 /// Has the Fano factor been set?
78 bool m_fset = false;
79 /// Fano factor [-] of the target.
80 double m_fano = -1.;
81
82 /// Projectile energy [eV].
83 double m_ekin = 0.;
84 /// List of tracks.
85 std::vector<std::vector<std::array<float, 6> > > m_ions;
86 /// Index of the current track.
87 size_t m_ion = 0;
88
89 /// Clusters on the current track.
90 std::vector<Cluster> m_clusters;
91 /// Index of the next cluster to be returned.
92 size_t m_cluster = 0;
93
94 /// Step size limit.
95 double m_maxStepSize = -1.;
96 /// Energy loss limit per step.
97 double m_maxLossPerStep = -1.;
98
99 void AddIon(const std::vector<float>& x, const std::vector<float>& y,
100 const std::vector<float>& z, const std::vector<float>& dedx,
101 const std::vector<float>& ekin);
102};
103}
104
105#endif
double m_ekin
Projectile energy [eV].
Definition TrackTrim.hh:83
void EnableStepSizeLimit(const double dmax)
Set a max. distance between subsequent steps.
Definition TrackTrim.hh:46
size_t m_cluster
Index of the next cluster to be returned.
Definition TrackTrim.hh:92
void SetParticle(const std::string &part) override
Definition TrackTrim.cc:95
void AddIon(const std::vector< float > &x, const std::vector< float > &y, const std::vector< float > &z, const std::vector< float > &dedx, const std::vector< float > &ekin)
Definition TrackTrim.cc:194
double GetWorkFunction() const
Get the W value [eV].
Definition TrackTrim.hh:34
TrackTrim()
Default constructor.
Definition TrackTrim.hh:17
void DisableStepSizeLimit()
Do not reduce the steps with respect to the TRIM input file (default).
Definition TrackTrim.hh:48
std::vector< Cluster > m_clusters
Clusters on the current track.
Definition TrackTrim.hh:90
bool m_fset
Has the Fano factor been set?
Definition TrackTrim.hh:78
double m_fano
Fano factor [-] of the target.
Definition TrackTrim.hh:80
void DisableEnergyLossLimit()
Definition TrackTrim.hh:53
void SetWorkFunction(const double w)
Set the W value [eV].
Definition TrackTrim.hh:32
size_t m_ion
Index of the current track.
Definition TrackTrim.hh:87
void EnableEnergyLossLimit(const double emax)
Set a max. energy loss per cluster.
Definition TrackTrim.hh:50
virtual ~TrackTrim()
Destructor.
Definition TrackTrim.hh:21
double m_work
Work function [eV] of the target.
Definition TrackTrim.hh:76
bool GetCluster(double &xc, double &yc, double &zc, double &tc, int &nc, double &ec, double &extra) override
Definition TrackTrim.cc:393
void Print()
Print a summary of the available TRIM data.
Definition TrackTrim.cc:222
const std::vector< Cluster > & GetClusters() const
Definition TrackTrim.hh:70
void SetFanoFactor(const double f)
Set the Fano factor.
Definition TrackTrim.hh:36
void SetCharge(const double q)
Set the projectile charge [-].
Definition TrackTrim.hh:30
void UnsetFanoFactor()
Use the default Fano factor.
Definition TrackTrim.hh:41
double m_maxLossPerStep
Energy loss limit per step.
Definition TrackTrim.hh:97
double GetFanoFactor() const
Get the Fano factor.
Definition TrackTrim.hh:43
bool ReadFile(const std::string &file, const unsigned int nIons=0, const unsigned int nSkip=0)
Load data from an EXYZ.txt file.
Definition TrackTrim.cc:99
double m_maxStepSize
Step size limit.
Definition TrackTrim.hh:95
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 TrackTrim.cc:243
std::vector< std::vector< std::array< float, 6 > > > m_ions
List of tracks.
Definition TrackTrim.hh:85
Track()=delete
Default constructor.
double energy
Energy spent to make the cluster.
Definition TrackTrim.hh:60
int n
Number of electrons in this cluster.
Definition TrackTrim.hh:62
double ekin
Ion energy when cluster was created.
Definition TrackTrim.hh:61