Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
ComponentConstant.hh
Go to the documentation of this file.
1#ifndef G_COMPONENT_CONSTANT_H
2#define G_COMPONENT_CONSTANT_H
3
4#include <array>
5#include <string>
6
7#include "Component.hh"
8#include "Medium.hh"
9
10namespace Garfield {
11
12/// Component with constant electric field.
13
15 public:
16 /// Constructor
18 /// Destructor
20
21 Medium* GetMedium(const double x, const double y, const double z) override;
22 void ElectricField(const double x, const double y, const double z, double& ex,
23 double& ey, double& ez, Medium*& m, int& status) override;
24 void ElectricField(const double x, const double y, const double z, double& ex,
25 double& ey, double& ez, double& v, Medium*& m,
26 int& status) override;
27 bool GetVoltageRange(double& vmin, double& vmax) override;
28 void WeightingField(const double x, const double y, const double z,
29 double& wx, double& wy, double& wz,
30 const std::string& label) override;
31 double WeightingPotential(const double x, const double y, const double z,
32 const std::string& label) override;
33
34 bool GetBoundingBox(double& xmin, double& ymin, double& zmin,
35 double& xmax, double& ymax, double& zmax) override;
36
37 /// Set the components of the electric field [V / cm].
38 void SetElectricField(const double ex, const double ey, const double ez);
39 /// Specify the potential at a given point.
40 void SetPotential(const double x, const double y, const double z,
41 const double v = 0.);
42
43 /// Set the components of the weighting field [1 / cm].
44 void SetWeightingField(const double wx, const double wy, const double wz,
45 const std::string label);
46 /// Specify the weighting potential at a given point.
47 void SetWeightingPotential(const double x, const double y, const double z,
48 const double v = 0.);
49
50 /// Set the limits of the active area explicitly
51 /// (instead of using a Geometry object).
52 void SetArea(const double xmin, const double ymin, const double zmin,
53 const double xmax, const double ymax, const double zmax);
54 /// Remove the explicit limits of the active area.
55 void UnsetArea();
56 /// Set the medium in the active area.
57 void SetMedium(Medium* medium) { m_medium = medium; }
58
59 private:
60 // Electric field.
61 std::array<double, 3> m_efield = {{0., 0., 0.}};
62
63 // Is the potential defined?
64 bool m_hasPotential = false;
65 // Point where potential was specified.
66 double m_x0 = 0., m_y0 = 0., m_z0 = 0.;
67 // Potential at this point.
68 double m_v0 = 0.;
69
70 // Is the weighting field defined?
71 bool m_hasWeightingField = false;
72 // Identifier of the weighting field.
73 std::string m_label = "";
74 // Weighting field.
75 std::array<double, 3> m_wfield = {{0., 0., 0.}};
76 // Is the weighting potential defined?
77 bool m_hasWeightingPotential = false;
78 // Point where the weighting potential was specified.
79 double m_wx0 = 0., m_wy0 = 0., m_wz0 = 0.;
80 // Weighting potential at this point.
81 double m_w0 = 0.;
82
83 // Active area.
84 std::array<double, 3> m_xmin = {{0., 0., 0.}};
85 std::array<double, 3> m_xmax = {{0., 0., 0.}};
86 // Did we specify the active area explicitly?
87 bool m_hasArea = false;
88 // Medium in the active area.
89 Medium* m_medium = nullptr;
90
91 void Reset() override;
92 void UpdatePeriodicity() override;
93
94 bool InArea(const double x, const double y, const double z) {
95 if (x < m_xmin[0] || x > m_xmax[0] ||
96 y < m_xmin[1] || y > m_xmax[1] ||
97 z < m_xmin[2] || z > m_xmax[2]) {
98 return false;
99 }
100 return true;
101 }
102};
103}
104#endif
Component with constant electric field.
double WeightingPotential(const double x, const double y, const double z, const std::string &label) override
bool GetVoltageRange(double &vmin, double &vmax) override
Calculate the voltage range [V].
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status) override
Medium * GetMedium(const double x, const double y, const double z) override
Get the medium at a given location (x, y, z).
void SetElectricField(const double ex, const double ey, const double ez)
Set the components of the electric field [V / cm].
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label) override
void UnsetArea()
Remove the explicit limits of the active area.
void SetArea(const double xmin, const double ymin, const double zmin, const double xmax, const double ymax, const double zmax)
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
Get the bounding box coordinates.
void SetPotential(const double x, const double y, const double z, const double v=0.)
Specify the potential at a given point.
void SetWeightingPotential(const double x, const double y, const double z, const double v=0.)
Specify the weighting potential at a given point.
void SetWeightingField(const double wx, const double wy, const double wz, const std::string label)
Set the components of the weighting field [1 / cm].
void SetMedium(Medium *medium)
Set the medium in the active area.
Abstract base class for components.
Definition: Component.hh:13
Abstract base class for media.
Definition: Medium.hh:13