Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation 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 <functional>
5
6#include "Component.hh"
7
8namespace Garfield {
9
10/// Simple component with electric field given by a user function.
11
12class ComponentUser : public Component {
13 public:
14 /// Constructor
16 /// Destructor
18
19 Medium* GetMedium(const double x, const double y, const double z) override;
20 void ElectricField(const double x, const double y, const double z, double& ex,
21 double& ey, double& ez, Medium*& m, int& status) override;
22 void ElectricField(const double x, const double y, const double z, double& ex,
23 double& ey, double& ez, double& v, Medium*& m,
24 int& status) override;
25 bool GetVoltageRange(double& vmin, double& vmax) override;
26 void MagneticField(const double x, const double y, const double z, double& bx,
27 double& by, double& bz, int& status) 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 void DelayedWeightingField(const double x, const double y, const double z,
34 const double t, double& wx, double& wy, double& wz,
35 const std::string& label) override;
36 bool GetBoundingBox(double& xmin, double& ymin, double& zmin,
37 double& xmax, double& ymax, double& zmax) override;
38
39 /// Set the function to be called for calculating the electric field.
41 std::function<void(const double, const double, const double,
42 double&, double&, double&)>);
43 /// Set the function to be called for calculating the potential.
44 void SetPotential(
45 std::function<void(const double, const double, const double, double&)>);
46 /// Set the function to be called for calculating the weighting field.
48 std::function<void(const double, const double, const double,
49 double&, double&, double&, const std::string&)>);
50 /// Set the function to be called for calculating the weighting potential.
52 std::function<void(const double, const double, const double,
53 double&, const std::string&)>);
54 /// Set the function to be called for calculating the delayed weighting field.
56 std::function<void(const double, const double, const double, const double,
57 double&, double&, double&, const std::string&)>);
58 /// Set the function to be called for calculating the magnetic field.
60 std::function<void(const double, const double, const double,
61 double&, double&, double&)>);
62
63 /// Set the limits of the active area explicitly
64 /// (instead of using a Geometry object).
65 void SetArea(const double xmin, const double ymin, const double zmin,
66 const double xmax, const double ymax, const double zmax);
67 /// Remove the explicit limits of the active area.
68 void UnsetArea();
69 /// Set the medium in the active area.
70 void SetMedium(Medium* medium) { m_medium = medium; }
71 private:
72 /// Electric field function
73 std::function<void(const double, const double, const double,
74 double&, double&, double&)> m_efield;
75 /// Potential function
76 std::function<void(const double, const double, const double,
77 double&)> m_potential;
78
79 /// Weighting field function
80 std::function<void(const double, const double, const double,
81 double&, double&, double&, const std::string&)> m_wfield;
82
83 /// Weighting potential function
84 std::function<void(const double, const double, const double,
85 double&, const std::string&)> m_wpot;
86
87 /// Delayed weighting field function
88 std::function<void(const double, const double, const double, const double,
89 double&, double&, double&, const std::string&)> m_dwfield;
90
91 /// Magnetic field function
92 std::function<void(const double, const double, const double,
93 double&, double&, double&)> m_bfield;
94
95 // Active area.
96 std::array<double, 3> m_xmin = {{0., 0., 0.}};
97 std::array<double, 3> m_xmax = {{0., 0., 0.}};
98 // Did we specify the active area explicitly?
99 bool m_hasArea = false;
100 // Medium in the active area.
101 Medium* m_medium = nullptr;
102
103 /// Reset the component
104 void Reset() override;
105 // Verify periodicities
106 void UpdatePeriodicity() override;
107
108 bool InArea(const double x, const double y, const double z) {
109 if (x < m_xmin[0] || x > m_xmax[0] ||
110 y < m_xmin[1] || y > m_xmax[1] ||
111 z < m_xmin[2] || z > m_xmax[2]) {
112 return false;
113 }
114 return true;
115 }
116
117};
118}
119#endif
Simple component with electric field given by a user function.
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
double WeightingPotential(const double x, const double y, const double z, const std::string &label) override
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
Get the bounding box coordinates.
void UnsetArea()
Remove the explicit limits of the active area.
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
void SetMedium(Medium *medium)
Set the medium in the active area.
void SetWeightingPotential(std::function< void(const double, const double, const double, double &, const std::string &)>)
Set the function to be called for calculating the weighting potential.
ComponentUser()
Constructor.
Definition: ComponentUser.cc:7
void MagneticField(const double x, const double y, const double z, double &bx, double &by, double &bz, int &status) override
void SetPotential(std::function< void(const double, const double, const double, double &)>)
Set the function to be called for calculating the potential.
Medium * GetMedium(const double x, const double y, const double z) override
Get the medium at a given location (x, y, z).
Definition: ComponentUser.cc:9
void SetArea(const double xmin, const double ymin, const double zmin, const double xmax, const double ymax, const double zmax)
bool GetVoltageRange(double &vmin, double &vmax) override
Calculate the voltage range [V].
void SetWeightingField(std::function< void(const double, const double, const double, double &, double &, double &, const std::string &)>)
Set the function to be called for calculating the weighting field.
void SetDelayedWeightingField(std::function< void(const double, const double, const double, const double, double &, double &, double &, const std::string &)>)
Set the function to be called for calculating the delayed weighting field.
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.
~ComponentUser()
Destructor.
Abstract base class for components.
Definition: Component.hh:13
Abstract base class for media.
Definition: Medium.hh:13