Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
Garfield::ComponentUser Class Reference

Simple component with electric field given by a user function. More...

#include <ComponentUser.hh>

+ Inheritance diagram for Garfield::ComponentUser:

Public Member Functions

 ComponentUser ()
 Constructor.
 
 ~ComponentUser ()
 Destructor.
 
MediumGetMedium (const double x, const double y, const double z) override
 Get the medium at a given location (x, y, z).
 
void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status) override
 
void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status) override
 Calculate the drift field [V/cm] and potential [V] at (x, y, z).
 
bool GetVoltageRange (double &vmin, double &vmax) override
 Calculate the voltage range [V].
 
void MagneticField (const double x, const double y, const double z, double &bx, double &by, double &bz, int &status) override
 
void WeightingField (const double x, const double y, const double z, 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
 
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
 
bool GetBoundingBox (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) override
 Get the bounding box coordinates.
 
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 SetPotential (std::function< void(const double, const double, const double, double &)>)
 Set the function to be called for calculating the potential.
 
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 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.
 
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 SetMagneticField (std::function< void(const double, const double, const double, double &, double &, double &)>)
 Set the function to be called for calculating the magnetic field.
 
void SetArea (const double xmin, const double ymin, const double zmin, const double xmax, const double ymax, const double zmax)
 
void UnsetArea ()
 Remove the explicit limits of the active area.
 
void SetMedium (Medium *medium)
 Set the medium in the active area.
 
- Public Member Functions inherited from Garfield::Component
 Component ()=delete
 Default constructor.
 
 Component (const std::string &name)
 Constructor.
 
virtual ~Component ()
 Destructor.
 
virtual void SetGeometry (Geometry *geo)
 Define the geometry.
 
virtual void Clear ()
 Reset.
 
virtual MediumGetMedium (const double x, const double y, const double z)
 Get the medium at a given location (x, y, z).
 
virtual void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)=0
 
virtual void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status)=0
 Calculate the drift field [V/cm] and potential [V] at (x, y, z).
 
virtual bool GetVoltageRange (double &vmin, double &vmax)=0
 Calculate the voltage range [V].
 
virtual void WeightingField (const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label)
 
virtual double WeightingPotential (const double x, const double y, const double z, const std::string &label)
 
virtual void DelayedWeightingField (const double x, const double y, const double z, const double t, double &wx, double &wy, double &wz, const std::string &label)
 
virtual double DelayedWeightingPotential (const double x, const double y, const double z, const double t, const std::string &label)
 
virtual void MagneticField (const double x, const double y, const double z, double &bx, double &by, double &bz, int &status)
 
void SetMagneticField (const double bx, const double by, const double bz)
 Set a constant magnetic field.
 
virtual bool IsReady ()
 Ready for use?
 
virtual bool GetBoundingBox (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
 Get the bounding box coordinates.
 
virtual bool GetElementaryCell (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
 Get the coordinates of the elementary cell.
 
double IntegrateFluxCircle (const double xc, const double yc, const double r, const unsigned int nI=50)
 
double IntegrateFluxSphere (const double xc, const double yc, const double zc, const double r, const unsigned int nI=20)
 
double IntegrateFluxParallelogram (const double x0, const double y0, const double z0, const double dx1, const double dy1, const double dz1, const double dx2, const double dy2, const double dz2, const unsigned int nU=20, const unsigned int nV=20)
 
double IntegrateWeightingFluxParallelogram (const std::string &label, const double x0, const double y0, const double z0, const double dx1, const double dy1, const double dz1, const double dx2, const double dy2, const double dz2, const unsigned int nU=20, const unsigned int nV=20)
 
double IntegrateFluxLine (const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, const double xp, const double yp, const double zp, const unsigned int nI, const int isign=0)
 
virtual bool IsWireCrossed (const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, double &xc, double &yc, double &zc, const bool centre, double &rc)
 
virtual bool IsInTrapRadius (const double q0, const double x0, const double y0, const double z0, double &xw, double &yw, double &rw)
 
void EnablePeriodicityX (const bool on=true)
 Enable simple periodicity in the $x$ direction.
 
void EnablePeriodicityY (const bool on=true)
 Enable simple periodicity in the $y$ direction.
 
void EnablePeriodicityZ (const bool on=true)
 Enable simple periodicity in the $z$ direction.
 
void IsPeriodic (bool &perx, bool &pery, bool &perz)
 Return periodicity flags.
 
void EnableMirrorPeriodicityX (const bool on=true)
 Enable mirror periodicity in the $x$ direction.
 
void EnableMirrorPeriodicityY (const bool on=true)
 Enable mirror periodicity in the $y$ direction.
 
void EnableMirrorPeriodicityZ (const bool on=true)
 Enable mirror periodicity in the $y$ direction.
 
void IsMirrorPeriodic (bool &perx, bool &pery, bool &perz)
 Return mirror periodicity flags.
 
void EnableAxialPeriodicityX (const bool on=true)
 Enable axial periodicity in the $x$ direction.
 
void EnableAxialPeriodicityY (const bool on=true)
 Enable axial periodicity in the $y$ direction.
 
void EnableAxialPeriodicityZ (const bool on=true)
 Enable axial periodicity in the $z$ direction.
 
void IsAxiallyPeriodic (bool &perx, bool &pery, bool &perz)
 Return axial periodicity flags.
 
void EnableRotationSymmetryX (const bool on=true)
 Enable rotation symmetry around the $x$ axis.
 
void EnableRotationSymmetryY (const bool on=true)
 Enable rotation symmetry around the $y$ axis.
 
void EnableRotationSymmetryZ (const bool on=true)
 Enable rotation symmetry around the $z$ axis.
 
void IsRotationSymmetric (bool &rotx, bool &roty, bool &rotz)
 Return rotation symmetry flags.
 
void EnableDebugging ()
 Switch on debugging messages.
 
void DisableDebugging ()
 Switch off debugging messages.
 
virtual bool HasAttachmentMap () const
 Does the component have attachment maps?
 
virtual bool HasVelocityMap () const
 Does the component have velocity maps?
 
virtual bool ElectronAttachment (const double, const double, const double, double &eta)
 Get the electron attachment coefficient.
 
virtual bool HoleAttachment (const double, const double, const double, double &eta)
 Get the hole attachment coefficient.
 
virtual bool ElectronVelocity (const double, const double, const double, double &vx, double &vy, double &vz)
 Get the electron drift velocity.
 
virtual bool HoleVelocity (const double, const double, const double, double &vx, double &vy, double &vz)
 Get the hole drift velocity.
 
virtual bool GetElectronLifetime (const double, const double, const double, double &etau)
 
virtual bool GetHoleLifetime (const double, const double, const double, double &htau)
 

Additional Inherited Members

virtual void Reset ()=0
 Reset the component.
 
virtual void UpdatePeriodicity ()=0
 Verify periodicities.
 
- Protected Attributes inherited from Garfield::Component
std::string m_className = "Component"
 Class name.
 
Geometrym_geometry = nullptr
 Pointer to the geometry.
 
std::array< double, 3 > m_b0 = {{0., 0., 0.}}
 Constant magnetic field.
 
bool m_ready = false
 Ready for use?
 
bool m_debug = false
 Switch on/off debugging messages.
 
std::array< bool, 3 > m_periodic = {{false, false, false}}
 Simple periodicity in x, y, z.
 
std::array< bool, 3 > m_mirrorPeriodic = {{false, false, false}}
 Mirror periodicity in x, y, z.
 
std::array< bool, 3 > m_axiallyPeriodic = {{false, false, false}}
 Axial periodicity in x, y, z.
 
std::array< bool, 3 > m_rotationSymmetric = {{false, false, false}}
 Rotation symmetry around x-axis, y-axis, z-axis.
 

Detailed Description

Simple component with electric field given by a user function.

Definition at line 12 of file ComponentUser.hh.

Constructor & Destructor Documentation

◆ ComponentUser()

Garfield::ComponentUser::ComponentUser ( )

Constructor.

Definition at line 7 of file ComponentUser.cc.

7: Component("User") {}
Component()=delete
Default constructor.

◆ ~ComponentUser()

Garfield::ComponentUser::~ComponentUser ( )
inline

Destructor.

Definition at line 17 of file ComponentUser.hh.

17{}

Member Function Documentation

◆ DelayedWeightingField()

void Garfield::ComponentUser::DelayedWeightingField ( const double  x,
const double  y,
const double  z,
const double  t,
double &  wx,
double &  wy,
double &  wz,
const std::string &  label 
)
overridevirtual

Calculate the delayed weighting field at a given point and time and for a given electrode.

Parameters
x,y,zcoordinates [cm].
ttime [ns].
wx,wy,wzcomponents of the weighting field [1/cm].
labelname of the electrode

Reimplemented from Garfield::Component.

Definition at line 104 of file ComponentUser.cc.

107 {
108 wx = wy = wz = 0.;
109 if (m_dwfield) m_dwfield(x, y, z, t, wx, wy, wz, label);
110}

◆ ElectricField() [1/2]

void Garfield::ComponentUser::ElectricField ( const double  x,
const double  y,
const double  z,
double &  ex,
double &  ey,
double &  ez,
double &  v,
Medium *&  m,
int &  status 
)
overridevirtual

Calculate the drift field [V/cm] and potential [V] at (x, y, z).

Implements Garfield::Component.

Definition at line 40 of file ComponentUser.cc.

43 {
44 if (!m_efield) {
45 ex = ey = ez = v = 0.;
46 m = nullptr;
47 status = -10;
48 return;
49 }
50 m_efield(x, y, z, ex, ey, ez);
51
52 if (m_potential) {
53 m_potential(x, y, z, v);
54 } else {
55 v = 0.;
56 }
57
58 m = GetMedium(x, y, z);
59 if (!m) {
60 if (m_debug) {
61 std::cerr << m_className << "::ElectricField:\n (" << x << ", " << y
62 << ", " << z << ") is not inside a medium.\n";
63 }
64 status = -6;
65 return;
66 }
67
68 status = m->IsDriftable() ? 0 : -5;
69}
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
bool m_debug
Switch on/off debugging messages.
Definition: Component.hh:341
std::string m_className
Class name.
Definition: Component.hh:329

◆ ElectricField() [2/2]

void Garfield::ComponentUser::ElectricField ( const double  x,
const double  y,
const double  z,
double &  ex,
double &  ey,
double &  ez,
Medium *&  m,
int &  status 
)
overridevirtual

Calculate the drift field at given point.

Parameters
x,y,zcoordinates [cm].
ex,ey,ezcomponents of the electric field [V/cm].
mpointer to the medium at this location.
statusstatus flag

Status flags:

        0: Inside an active medium
      > 0: Inside a wire of type X
-4 ... -1: On the side of a plane where no wires are
       -5: Inside the mesh but not in an active medium
       -6: Outside the mesh
      -10: Unknown potential type (should not occur)
    other: Other cases (should not occur)

Implements Garfield::Component.

Definition at line 16 of file ComponentUser.cc.

18 {
19 if (!m_efield) {
20 ex = ey = ez = 0.;
21 m = nullptr;
22 status = -10;
23 return;
24 }
25
26 m_efield(x, y, z, ex, ey, ez);
27 m = GetMedium(x, y, z);
28 if (!m) {
29 if (m_debug) {
30 std::cerr << m_className << "::ElectricField:\n (" << x << ", " << y
31 << ", " << z << ") is not inside a medium.\n";
32 }
33 status = -6;
34 return;
35 }
36
37 status = m->IsDriftable() ? 0 : -5;
38}

◆ GetBoundingBox()

bool Garfield::ComponentUser::GetBoundingBox ( double &  xmin,
double &  ymin,
double &  zmin,
double &  xmax,
double &  ymax,
double &  zmax 
)
overridevirtual

Get the bounding box coordinates.

Reimplemented from Garfield::Component.

Definition at line 112 of file ComponentUser.cc.

114 {
115
116 if (!m_hasArea) {
117 return Component::GetBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax);
118 }
119 xmin = m_xmin[0];
120 ymin = m_xmin[1];
121 zmin = m_xmin[2];
122 xmax = m_xmax[0];
123 ymax = m_xmax[1];
124 zmax = m_xmax[2];
125 return true;
126}
virtual bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
Get the bounding box coordinates.
Definition: Component.cc:99

◆ GetMedium()

Medium * Garfield::ComponentUser::GetMedium ( const double  x,
const double  y,
const double  z 
)
overridevirtual

Get the medium at a given location (x, y, z).

Reimplemented from Garfield::Component.

Definition at line 9 of file ComponentUser.cc.

10 {
11
12 if (!m_hasArea) return Component::GetMedium(x, y, z);
13 return InArea(x, y, z) ? m_medium : nullptr;
14}
virtual Medium * GetMedium(const double x, const double y, const double z)
Get the medium at a given location (x, y, z).
Definition: Component.cc:22

Referenced by ElectricField().

◆ GetVoltageRange()

bool Garfield::ComponentUser::GetVoltageRange ( double &  vmin,
double &  vmax 
)
overridevirtual

Calculate the voltage range [V].

Implements Garfield::Component.

Definition at line 71 of file ComponentUser.cc.

71 {
72 vmin = vmax = 0.;
73 return false;
74}

◆ MagneticField()

void Garfield::ComponentUser::MagneticField ( const double  x,
const double  y,
const double  z,
double &  bx,
double &  by,
double &  bz,
int &  status 
)
overridevirtual

Calculate the magnetic field at a given point.

Parameters
x,y,zcoordinates [cm].
bx,by,bzcomponents of the magnetic field [Tesla].
statusstatus flag.

Reimplemented from Garfield::Component.

Definition at line 76 of file ComponentUser.cc.

78 {
79 if (!m_bfield) {
80 bx = by = bz = 0.;
81 status = -10;
82 return;
83 }
84 m_bfield(x, y, z, bx, by, bz);
85 status = 0;
86}

◆ SetArea()

void Garfield::ComponentUser::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).

Definition at line 190 of file ComponentUser.cc.

192 {
193
194 m_xmin[0] = std::min(xmin, xmax);
195 m_xmin[1] = std::min(ymin, ymax);
196 m_xmin[2] = std::min(zmin, zmax);
197 m_xmax[0] = std::max(xmin, xmax);
198 m_xmax[1] = std::max(ymin, ymax);
199 m_xmax[2] = std::max(zmin, zmax);
200 m_hasArea = true;
201}

◆ SetDelayedWeightingField()

void Garfield::ComponentUser::SetDelayedWeightingField ( std::function< void(const double, const double, const double, const double, double &, double &, double &, const std::string &)>  f)

Set the function to be called for calculating the delayed weighting field.

Definition at line 169 of file ComponentUser.cc.

171 {
172
173 if (!f) {
174 std::cerr << m_className << "::SetDelayedWeightingField: Function is empty.\n";
175 return;
176 }
177 m_dwfield = f;
178}

◆ SetElectricField()

void Garfield::ComponentUser::SetElectricField ( std::function< void(const double, const double, const double, double &, double &, double &)>  f)

Set the function to be called for calculating the electric field.

Definition at line 128 of file ComponentUser.cc.

130 {
131 if (!f) {
132 std::cerr << m_className << "::SetElectricField: Function is empty.\n";
133 return;
134 }
135 m_efield = f;
136 m_ready = true;
137}
bool m_ready
Ready for use?
Definition: Component.hh:338

◆ SetMagneticField()

void Garfield::ComponentUser::SetMagneticField ( std::function< void(const double, const double, const double, double &, double &, double &)>  f)

Set the function to be called for calculating the magnetic field.

Definition at line 180 of file ComponentUser.cc.

182 {
183 if (!f) {
184 std::cerr << m_className << "::SetMagneticField: Function is empty.\n";
185 return;
186 }
187 m_bfield = f;
188}

◆ SetMedium()

void Garfield::ComponentUser::SetMedium ( Medium medium)
inline

Set the medium in the active area.

Definition at line 70 of file ComponentUser.hh.

70{ m_medium = medium; }

◆ SetPotential()

void Garfield::ComponentUser::SetPotential ( std::function< void(const double, const double, const double, double &)>  f)

Set the function to be called for calculating the potential.

Definition at line 139 of file ComponentUser.cc.

141 {
142 if (!f) {
143 std::cerr << m_className << "::SetPotential: Function is empty.\n";
144 return;
145 }
146 m_potential = f;
147}

◆ SetWeightingField()

void Garfield::ComponentUser::SetWeightingField ( std::function< void(const double, const double, const double, double &, double &, double &, const std::string &)>  f)

Set the function to be called for calculating the weighting field.

Definition at line 149 of file ComponentUser.cc.

151 {
152 if (!f) {
153 std::cerr << m_className << "::SetWeightingField: Function is empty.\n";
154 return;
155 }
156 m_wfield = f;
157}

◆ SetWeightingPotential()

void Garfield::ComponentUser::SetWeightingPotential ( std::function< void(const double, const double, const double, double &, const std::string &)>  f)

Set the function to be called for calculating the weighting potential.

Definition at line 159 of file ComponentUser.cc.

161 {
162 if (!f) {
163 std::cerr << m_className << "::SetWeightingPotential: Function is empty.\n";
164 return;
165 }
166 m_wpot = f;
167}

◆ UnsetArea()

void Garfield::ComponentUser::UnsetArea ( )

Remove the explicit limits of the active area.

Definition at line 203 of file ComponentUser.cc.

203 {
204 m_xmin.fill(0.);
205 m_xmax.fill(0.);
206 m_hasArea = false;
207}

◆ WeightingField()

void Garfield::ComponentUser::WeightingField ( const double  x,
const double  y,
const double  z,
double &  wx,
double &  wy,
double &  wz,
const std::string &  label 
)
overridevirtual

Calculate the weighting field at a given point and for a given electrode.

Parameters
x,y,zcoordinates [cm].
wx,wy,wzcomponents of the weighting field [1/cm].
labelname of the electrode

Reimplemented from Garfield::Component.

Definition at line 88 of file ComponentUser.cc.

90 {
91 wx = wy = wz = 0.;
92 if (!m_wfield) return;
93 m_wfield(x, y, z, wx, wy, wz, label);
94}

◆ WeightingPotential()

double Garfield::ComponentUser::WeightingPotential ( const double  x,
const double  y,
const double  z,
const std::string &  label 
)
overridevirtual

Calculate the weighting potential at a given point.

Parameters
x,y,zcoordinates [cm].
labelname of the electrode.
Returns
weighting potential [dimensionless].

Reimplemented from Garfield::Component.

Definition at line 96 of file ComponentUser.cc.

98 {
99 double v = 0.;
100 if (m_wpot) m_wpot(x, y, z, v, label);
101 return v;
102}

The documentation for this class was generated from the following files: