Garfield 0.3
Toolkit for the detailed simulation of particle detectors based on ionization measurement in gases and semiconductors
Loading...
Searching...
No Matches
ComponentUser.hh
Go to the documentation of this file.
1#ifndef G_COMPONENT_USER_H
2#define G_COMPONENT_USER_H
3
4#include <array>
5#include <functional>
6#include <map>
7
9
10namespace Garfield {
11
13
14class ComponentUser : public Component {
15 public:
20
23 std::function<void(const double, const double, const double, double&,
24 double&, double&)>);
26 void SetElectricField(const std::string& expression);
27
30 std::function<double(const double, const double, const double)>);
32 void SetPotential(const std::string& expression);
33
36 std::function<void(const double, const double, const double, double&,
37 double&, double&)>,
38 const std::string& label);
40 void SetWeightingField(const std::string& expression,
41 const std::string& label);
42
45 std::function<double(const double, const double, const double)>,
46 const std::string& label);
48 void SetWeightingPotential(const std::string& expression,
49 const std::string& label);
50
53 std::function<void(const double, const double, const double, const double,
54 double&, double&, double&)>,
55 const std::string& label);
57 void SetDelayedWeightingField(const std::string& expression,
58 const std::string& label);
59
63 std::function<double(const double, const double, const double,
64 const double)>,
65 const std::string& label);
68 void SetDelayedWeightingPotential(const std::string& expression,
69 const std::string& label);
72 void SetDelayedSignalTimes(const std::vector<double>& ts);
75 std::function<void(const double, const double, const double, double&,
76 double&, double&)>);
78 void SetMagneticField(const std::string& expression);
79
82 void SetArea(const double xmin, const double ymin, const double zmin,
83 const double xmax, const double ymax, const double zmax);
85 void UnsetArea();
87 void SetMedium(Medium* medium) { m_medium = medium; }
88
89 Medium* GetMedium(const double x, const double y, const double z) override {
90 return !m_hasArea ? Component::GetMedium(x, y, z)
91 : InArea(x, y, z) ? m_medium
92 : nullptr;
93 }
94 void ElectricField(const double x, const double y, const double z, double& ex,
95 double& ey, double& ez, Medium*& m, int& status) override;
96 void ElectricField(const double x, const double y, const double z, double& ex,
97 double& ey, double& ez, double& v, Medium*& m,
98 int& status) override;
99 using Component::ElectricField;
100 bool GetVoltageRange(double& vmin, double& vmax) override;
101 void MagneticField(const double x, const double y, const double z, double& bx,
102 double& by, double& bz, int& status) override;
103 void WeightingField(const double x, const double y, const double z,
104 double& wx, double& wy, double& wz,
105 const std::string& label) override;
106 double WeightingPotential(const double x, const double y, const double z,
107 const std::string& label) override;
108 void DelayedWeightingField(const double x, const double y, const double z,
109 const double t, double& wx, double& wy, double& wz,
110 const std::string& label) override;
111 double DelayedWeightingPotential(const double x, const double y,
112 const double z, const double t,
113 const std::string& label) override;
114 bool GetBoundingBox(double& xmin, double& ymin, double& zmin, double& xmax,
115 double& ymax, double& zmax) override;
116
117 bool HasMagneticField() const override;
118
119 private:
121 std::function<void(const double, const double, const double, double&, double&,
122 double&)>
125 std::function<double(const double, const double, const double)> m_epot;
126
128 std::map<std::string,
129 std::function<void(const double, const double, const double, double&,
130 double&, double&)> >
132
134 std::map<std::string,
135 std::function<double(const double, const double, const double)> >
137
139 std::map<std::string,
140 std::function<void(const double, const double, const double,
141 const double, double&, double&, double&)> >
143
145 std::map<std::string, std::function<double(const double, const double,
146 const double, const double)> >
148
150 std::function<void(const double, const double, const double, double&, double&,
151 double&)>
153
154 // Active area.
155 std::array<double, 3> m_xmin = {{0., 0., 0.}};
156 std::array<double, 3> m_xmax = {{0., 0., 0.}};
157 // Did we specify the active area explicitly?
158 bool m_hasArea = false;
159 // Medium in the active area.
160 Medium* m_medium = nullptr;
161
163 void Reset() override;
164 // Verify periodicities
165 void UpdatePeriodicity() override;
166
167 bool InArea(const double x, const double y, const double z) {
168 return (x >= m_xmin[0] && x <= m_xmax[0] && y >= m_xmin[1] &&
169 y <= m_xmax[1] && z >= m_xmin[2] && z <= m_xmax[2]);
170 }
171};
172} // namespace Garfield
173#endif
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status) override
std::array< double, 3 > m_xmax
void DelayedWeightingField(const double x, const double y, const double z, const double t, double &wx, double &wy, double &wz, const std::string &label) override
void SetMagneticField(const std::string &expression)
Set the expression to be used for calculating the magnetic field.
std::function< double(const double, const double, const double)> m_epot
Electric potential function.
std::array< double, 3 > m_xmin
void SetDelayedWeightingPotential(std::function< double(const double, const double, const double, const double)>, const std::string &label)
Set the function to be called for calculating the delayed weighting potential.
std::map< std::string, std::function< void(const double, const double, const double, double &, double &, double &)> > m_wfield
Weighting field functions.
void SetDelayedWeightingPotential(const std::string &expression, const std::string &label)
Set the expression to be used for calculating the delayed weighting potential.
void SetWeightingField(const std::string &expression, const std::string &label)
Set the expression to be used for calculating the weighting field.
std::function< void(const double, const double, const double, double &, double &, double &)> m_efield
Electric field function.
double WeightingPotential(const double x, const double y, const double z, const std::string &label) override
void UpdatePeriodicity() override
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
void SetDelayedWeightingField(std::function< void(const double, const double, const double, const double, double &, double &, double &)>, const std::string &label)
Set the function to be called for calculating the delayed weighting field.
double DelayedWeightingPotential(const double x, const double y, const double z, const double t, const std::string &label) override
void SetElectricField(const std::string &expression)
Set the expression to be used for calculating the electric field.
void UnsetArea()
Remove the explicit limits of the active area.
void SetDelayedWeightingField(const std::string &expression, const std::string &label)
Set the expression to be used for calculating the delayed weighting field.
std::map< std::string, std::function< void(const double, const double, const double, const double, double &, double &, double &)> > m_dwfield
Delayed weighting field functions.
void SetElectricField(std::function< void(const double, const double, const double, double &, double &, double &)>)
Set the function to be called for calculating the electric field.
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label) override
std::map< std::string, std::function< double(const double, const double, const double, const double)> > m_dwpot
Delayed weighting potential functions.
std::function< void(const double, const double, const double, double &, double &, double &)> m_bfield
Magnetic field function.
void SetMedium(Medium *medium)
Set the medium in the active area.
bool InArea(const double x, const double y, const double z)
ComponentUser()
Constructor.
void SetWeightingPotential(const std::string &expression, const std::string &label)
Set the expression to be used for calculating the weighting potential.
void MagneticField(const double x, const double y, const double z, double &bx, double &by, double &bz, int &status) override
void SetDelayedSignalTimes(const std::vector< double > &ts)
Set the time steps at which to evaluate the delayed weighting potential/field.
void SetWeightingPotential(std::function< double(const double, const double, const double)>, const std::string &label)
Set the function to be called for calculating the weighting potential.
void SetPotential(std::function< double(const double, const double, const double)>)
Set the function to be called for calculating the electric potential.
void SetPotential(const std::string &expression)
Set the expression to be used for calculating the electric potential.
Medium * GetMedium(const double x, const double y, const double z) override
void SetArea(const double xmin, const double ymin, const double zmin, const double xmax, const double ymax, const double zmax)
Set the limits of the active area explicitly (instead of using a Geometry object).
bool GetVoltageRange(double &vmin, double &vmax) override
bool HasMagneticField() const override
void SetWeightingField(std::function< void(const double, const double, const double, double &, double &, double &)>, const std::string &label)
Set the function to be called for calculating the weighting field.
std::map< std::string, std::function< double(const double, const double, const double)> > m_wpot
Weighting potential functions.
void Reset() override
Reset the component.
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status) override
void SetMagneticField(std::function< void(const double, const double, const double, double &, double &, double &)>)
Set the function to be called for calculating the magnetic field.