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

Component for interpolating field maps stored in a regular mesh. More...

#include <ComponentVoxel.hh>

+ Inheritance diagram for Garfield::ComponentVoxel:

Public Member Functions

 ComponentVoxel ()
 Constructor.
 
 ~ComponentVoxel ()
 Destructor.
 
void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status)
 
void ElectricField (const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)
 
void WeightingField (const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label)
 
void MagneticField (const double x, const double y, const double z, double &bx, double &by, double &bz, int &status)
 
void SetWeightingFieldOffset (const double x, const double y, const double z)
 
MediumGetMedium (const double x, const double y, const double z)
 Get the medium at a given location (x, y, z).
 
bool GetVoltageRange (double &vmin, double &vmax)
 Calculate the voltage range [V].
 
bool GetElectricFieldRange (double &exmin, double &exmax, double &eymin, double &eymax, double &ezmin, double &ezmax)
 
bool GetBoundingBox (double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
 Get the bounding box coordinates.
 
void SetMesh (const unsigned int nx, const unsigned int ny, const unsigned int nz, const double xmin, const double xmax, const double ymin, const double ymax, const double zmin, const double zmax)
 
bool LoadElectricField (const std::string &filename, const std::string &format, const bool withPotential, const bool withRegion, const double scaleX=1., const double scaleE=1., const double scaleP=1.)
 
bool LoadMagneticField (const std::string &filename, const std::string &format, const double scaleX=1., const double scaleB=1.)
 Import magnetic field values from a file.
 
bool GetElement (const double xi, const double yi, const double zi, unsigned int &i, unsigned int &j, unsigned int &k, bool &xMirrored, bool &yMirrored, bool &zMirrored) const
 Return the indices of the element at a given point.
 
bool GetElement (const unsigned int i, const unsigned int j, const unsigned int k, double &v, double &ex, double &ey, double &ez) const
 Return the field for an element with given index.
 
void SetMedium (const unsigned int i, Medium *m)
 Set the medium in region i.
 
MediumGetMedium (const unsigned int i) const
 Get the medium in region i.
 
void PrintRegions () const
 Print all regions.
 
- Public Member Functions inherited from Garfield::ComponentBase
 ComponentBase ()
 Constructor.
 
virtual ~ComponentBase ()
 Destructor.
 
virtual void SetGeometry (GeometryBase *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
 
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 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 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)
 
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 DisablePeriodicityX ()
 
void EnablePeriodicityY (const bool on=true)
 Enable simple periodicity in the $y$ direction.
 
void DisablePeriodicityY ()
 
void EnablePeriodicityZ (const bool on=true)
 Enable simple periodicity in the $z$ direction.
 
void DisablePeriodicityZ ()
 
void EnableMirrorPeriodicityX (const bool on=true)
 Enable mirror periodicity in the $x$ direction.
 
void DisableMirrorPeriodicityX ()
 
void EnableMirrorPeriodicityY (const bool on=true)
 Enable mirror periodicity in the $y$ direction.
 
void DisableMirrorPeriodicityY ()
 
void EnableMirrorPeriodicityZ (const bool on=true)
 Enable mirror periodicity in the $y$ direction.
 
void DisableMirrorPeriodicityZ ()
 
void EnableAxialPeriodicityX (const bool on=true)
 Enable axial periodicity in the $x$ direction.
 
void DisableAxialPeriodicityX ()
 
void EnableAxialPeriodicityY (const bool on=true)
 Enable axial periodicity in the $y$ direction.
 
void DisableAxialPeriodicityY ()
 
void EnableAxialPeriodicityZ (const bool on=true)
 Enable axial periodicity in the $z$ direction.
 
void DisableAxialPeriodicityZ ()
 
void EnableRotationSymmetryX (const bool on=true)
 Enable rotation symmetry around the $x$ axis.
 
void DisableRotationSymmetryX ()
 
void EnableRotationSymmetryY (const bool on=true)
 Enable rotation symmetry around the $y$ axis.
 
void DisableRotationSymmetryY ()
 
void EnableRotationSymmetryZ (const bool on=true)
 Enable rotation symmetry around the $z$ axis.
 
void DisableRotationSymmetryZ ()
 
void EnableDebugging ()
 Switch on debugging messages.
 
void DisableDebugging ()
 Switch off debugging messages.
 
void ActivateTraps ()
 Request trapping to be taken care of by the component (for TCAD).
 
void DeactivateTraps ()
 
bool IsTrapActive ()
 
void ActivateVelocityMap ()
 Request velocity to be taken care of by the component (for TCAD).
 
void DectivateVelocityMap ()
 
bool IsVelocityActive ()
 
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 void ElectronVelocity (const double, const double, const double, double &vx, double &vy, double &vz, Medium *&, int &status)
 Get the electron drift velocity.
 
virtual void HoleVelocity (const double, const double, const double, double &vx, double &vy, double &vz, Medium *&, int &status)
 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
 Geometry checks.
 
virtual void UpdatePeriodicity ()=0
 Verify periodicities.
 
- Protected Attributes inherited from Garfield::ComponentBase
std::string m_className
 Class name.
 
GeometryBasem_geometry
 Pointer to the geometry.
 
bool m_ready
 Ready for use?
 
bool m_activeTraps
 Does the component have traps?
 
bool m_hasVelocityMap
 Does the component have velocity maps?
 
bool m_xPeriodic
 Simple periodicity in x.
 
bool m_yPeriodic
 Simple periodicity in y.
 
bool m_zPeriodic
 Simple periodicity in z.
 
bool m_xMirrorPeriodic
 Mirror periodicity in x.
 
bool m_yMirrorPeriodic
 Mirror periodicity in y.
 
bool m_zMirrorPeriodic
 Mirror periodicity in z.
 
bool m_xAxiallyPeriodic
 Axial periodicity in x.
 
bool m_yAxiallyPeriodic
 Axial periodicity in y.
 
bool m_zAxiallyPeriodic
 Axial periodicity in z.
 
bool m_xRotationSymmetry
 Rotation symmetry around x-axis.
 
bool m_yRotationSymmetry
 Rotation symmetry around y-axis.
 
bool m_zRotationSymmetry
 Rotation symmetry around z-axis.
 
double m_bx0
 
double m_by0
 
double m_bz0
 
bool m_debug
 Switch on/off debugging messages.
 

Detailed Description

Component for interpolating field maps stored in a regular mesh.

Definition at line 10 of file ComponentVoxel.hh.

Constructor & Destructor Documentation

◆ ComponentVoxel()

Garfield::ComponentVoxel::ComponentVoxel ( )

Constructor.

Definition at line 12 of file ComponentVoxel.cc.

13 : ComponentBase(),
14 m_nX(0),
15 m_nY(0),
16 m_nZ(0),
17 m_xMin(0.),
18 m_yMin(0.),
19 m_zMin(0.),
20 m_xMax(0.),
21 m_yMax(0.),
22 m_zMax(0.),
23 m_hasMesh(false),
24 m_hasPotential(false),
25 m_hasEfield(false),
26 m_hasBfield(false),
27 m_pMin(0.),
28 m_pMax(0.) {
29
30 m_className = "ComponentVoxel";
31}
ComponentBase()
Constructor.
Definition: ComponentBase.cc:6
std::string m_className
Class name.

◆ ~ComponentVoxel()

Garfield::ComponentVoxel::~ComponentVoxel ( )
inline

Destructor.

Definition at line 16 of file ComponentVoxel.hh.

16{}

Member Function Documentation

◆ ElectricField() [1/2]

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

Implements Garfield::ComponentBase.

Definition at line 33 of file ComponentVoxel.cc.

36 {
37
38 m = NULL;
39 // Make sure the field map has been loaded.
40 if (!m_ready) {
41 std::cerr << m_className << "::ElectricField:\n"
42 << " Field map is not available for interpolation.\n";
43 status = -10;
44 return;
45 }
46
47 // Get the mesh element.
48 unsigned int i = 0, j = 0, k = 0;
49 bool xMirrored = false, yMirrored = false, zMirrored = false;
50 if (!GetElement(x, y, z, i, j, k, xMirrored, yMirrored, zMirrored)) {
51 status = -11;
52 return;
53 }
54 status = 0;
55 // Get the electric field and potential.
56 const Element& element = m_efields[i][j][k];
57 ex = element.fx;
58 ey = element.fy;
59 ez = element.fz;
60 if (xMirrored) ex = -ex;
61 if (yMirrored) ey = -ey;
62 if (zMirrored) ez = -ez;
63 p = element.v;
64 // Get the medium.
65 const int region = m_regions[i][j][k];
66 if (region < 0 || region > (int)m_media.size()) {
67 m = NULL;
68 status = -5;
69 return;
70 }
71 m = m_media[region];
72 if (!m) status = -5;
73}
bool m_ready
Ready for use?
bool GetElement(const double xi, const double yi, const double zi, unsigned int &i, unsigned int &j, unsigned int &k, bool &xMirrored, bool &yMirrored, bool &zMirrored) const
Return the indices of the element at a given point.

Referenced by ElectricField(), and WeightingField().

◆ ElectricField() [2/2]

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

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::ComponentBase.

Definition at line 75 of file ComponentVoxel.cc.

77 {
78
79 double v = 0.;
80 ElectricField(x, y, z, ex, ey, ez, v, m, status);
81}
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status)

◆ GetBoundingBox()

bool Garfield::ComponentVoxel::GetBoundingBox ( double &  xmin,
double &  ymin,
double &  zmin,
double &  xmax,
double &  ymax,
double &  zmax 
)
virtual

Get the bounding box coordinates.

Reimplemented from Garfield::ComponentBase.

Definition at line 529 of file ComponentVoxel.cc.

530 {
531
532 if (!m_ready) return false;
534 xmin = -INFINITY;
535 xmax = +INFINITY;
536 } else {
537 xmin = m_xMin;
538 xmax = m_xMax;
539 }
540
542 ymin = -INFINITY;
543 ymax = +INFINITY;
544 } else {
545 ymin = m_yMin;
546 ymax = m_yMax;
547 }
548
550 zmin = -INFINITY;
551 zmax = +INFINITY;
552 } else {
553 zmin = m_zMin;
554 zmax = m_zMax;
555 }
556 return true;
557}
bool m_zMirrorPeriodic
Mirror periodicity in z.
bool m_yPeriodic
Simple periodicity in y.
bool m_yMirrorPeriodic
Mirror periodicity in y.
bool m_xPeriodic
Simple periodicity in x.
bool m_zPeriodic
Simple periodicity in z.
bool m_xMirrorPeriodic
Mirror periodicity in x.

◆ GetElectricFieldRange()

bool Garfield::ComponentVoxel::GetElectricFieldRange ( double &  exmin,
double &  exmax,
double &  eymin,
double &  eymax,
double &  ezmin,
double &  ezmax 
)

Definition at line 567 of file ComponentVoxel.cc.

569 {
570
571 if (!m_ready) {
572 std::cerr << m_className << "::GetElectricFieldRange:\n";
573 std::cerr << " Field map not available.\n";
574 return false;
575 }
576
577 exmin = exmax = m_efields[0][0][0].fx;
578 eymin = eymax = m_efields[0][0][0].fy;
579 ezmin = ezmax = m_efields[0][0][0].fz;
580 for (unsigned int i = 0; i < m_nX; ++i) {
581 for (unsigned int j = 0; j < m_nY; ++j) {
582 for (unsigned int k = 0; k < m_nZ; ++k) {
583 const Element& element = m_efields[i][j][k];
584 if (element.fx < exmin) exmin = element.fx;
585 if (element.fx > exmax) exmax = element.fx;
586 if (element.fy < eymin) eymin = element.fy;
587 if (element.fy > eymax) eymax = element.fy;
588 if (element.fz < ezmin) ezmin = element.fz;
589 if (element.fz > ezmax) ezmax = element.fz;
590 }
591 }
592 }
593 return true;
594}

◆ GetElement() [1/2]

bool Garfield::ComponentVoxel::GetElement ( const double  xi,
const double  yi,
const double  zi,
unsigned int &  i,
unsigned int &  j,
unsigned int &  k,
bool &  xMirrored,
bool &  yMirrored,
bool &  zMirrored 
) const

Return the indices of the element at a given point.

Definition at line 638 of file ComponentVoxel.cc.

642 {
643
644 if (!m_hasMesh) {
645 std::cerr << m_className << "::GetElement:\n Mesh is not set.\n";
646 return false;
647 }
648
649 // Reduce the point to the basic cell (in case of periodicity) and
650 // check if it is inside the mesh.
651 const double x = Reduce(xi, m_xMin, m_xMax, m_xPeriodic,
652 m_xMirrorPeriodic, xMirrored);
653 if (x < m_xMin || x > m_xMax) return false;
654 const double y = Reduce(yi, m_yMin, m_yMax, m_yPeriodic,
655 m_yMirrorPeriodic, yMirrored);
656 if (y < m_yMin || y > m_yMax) return false;
657 const double z = Reduce(zi, m_zMin, m_zMax, m_zPeriodic,
658 m_zMirrorPeriodic, zMirrored);
659 if (z < m_zMin || z > m_zMax) return false;
660
661 // Get the indices.
662 const double dx = (m_xMax - m_xMin) / m_nX;
663 const double dy = (m_yMax - m_yMin) / m_nY;
664 const double dz = (m_zMax - m_zMin) / m_nZ;
665 i = (unsigned int)((x - m_xMin) / dx);
666 j = (unsigned int)((y - m_yMin) / dy);
667 k = (unsigned int)((z - m_zMin) / dz);
668 if (i >= m_nX) i = m_nX - 1;
669 if (j >= m_nY) j = m_nY - 1;
670 if (k >= m_nZ) k = m_nZ - 1;
671 return true;
672}

Referenced by ElectricField(), GetMedium(), and MagneticField().

◆ GetElement() [2/2]

bool Garfield::ComponentVoxel::GetElement ( const unsigned int  i,
const unsigned int  j,
const unsigned int  k,
double &  v,
double &  ex,
double &  ey,
double &  ez 
) const

Return the field for an element with given index.

Definition at line 674 of file ComponentVoxel.cc.

676 {
677
678 v = ex = ey = ez = 0.;
679 if (!m_ready) {
680 if (!m_hasMesh) {
681 std::cerr << m_className << "::GetElement:\n Mesh not set.\n";
682 return false;
683 }
684 std::cerr << m_className << "::GetElement:\n Field map not set.\n";
685 return false;
686 }
687 if (i >= m_nX || j >= m_nY || k >= m_nZ) {
688 std::cerr << m_className << "::GetElement:\n Index out of range.\n";
689 return false;
690 }
691 const Element& element = m_efields[i][j][k];
692 v = element.v;
693 ex = element.fx;
694 ey = element.fy;
695 ez = element.fz;
696 return true;
697}

◆ GetMedium() [1/2]

Medium * Garfield::ComponentVoxel::GetMedium ( const double  x,
const double  y,
const double  z 
)
virtual

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

Reimplemented from Garfield::ComponentBase.

Definition at line 129 of file ComponentVoxel.cc.

130 {
131
132 // Make sure the field map has been loaded.
133 if (!m_ready) {
134 std::cerr << m_className << "::GetMedium:\n"
135 << " Field map is not available for interpolation.\n";
136 return NULL;
137 }
138
139 unsigned int i, j, k;
140 bool xMirrored, yMirrored, zMirrored;
141 if (!GetElement(x, y, z, i, j, k, xMirrored, yMirrored, zMirrored)) {
142 return NULL;
143 }
144 const int region = m_regions[i][j][k];
145 if (region < 0 || region > (int)m_media.size()) return NULL;
146 return m_media[region];
147}

◆ GetMedium() [2/2]

Medium * Garfield::ComponentVoxel::GetMedium ( const unsigned int  i) const

Get the medium in region i.

Definition at line 629 of file ComponentVoxel.cc.

629 {
630
631 if (i > m_media.size()) {
632 std::cerr << m_className << "::GetMedium:\n Index out of range.\n";
633 return NULL;
634 }
635 return m_media[i];
636}

◆ GetVoltageRange()

bool Garfield::ComponentVoxel::GetVoltageRange ( double &  vmin,
double &  vmax 
)
virtual

Calculate the voltage range [V].

Implements Garfield::ComponentBase.

Definition at line 559 of file ComponentVoxel.cc.

559 {
560
561 if (!m_ready) return false;
562 vmin = m_pMin;
563 vmax = m_pMax;
564 return true;
565}

◆ LoadElectricField()

bool Garfield::ComponentVoxel::LoadElectricField ( const std::string &  filename,
const std::string &  format,
const bool  withPotential,
const bool  withRegion,
const double  scaleX = 1.,
const double  scaleE = 1.,
const double  scaleP = 1. 
)

Import electric field and potential values from a file. The file is supposed to contain one line for each mesh point starting with

  • either two or three floating point numbers, specifying the coordinates (in cm) of the element centre or
  • two or three integers specifying the index of the element in the mesh,

followed by

  • two or three floating point numbers for the electric field (in V/cm), and (depending on the values of withPotential and withRegion),
  • a floating point number specifying the potential (in V), and
  • an integer specifying the "region" of the element.

Format types are:

  • "xy", "xyz": elements are specified by the coordinates of their centres
  • "ij", "ijk": elements are specified by their indices

Definition at line 183 of file ComponentVoxel.cc.

189 {
190
191 m_ready = false;
192 m_hasPotential = m_hasEfield = false;
193 if (!m_hasMesh) {
194 std::cerr << m_className << "::LoadElectricField:\n"
195 << " Mesh is not set. Call SetMesh first.\n";
196 return false;
197 }
198
199 // Set up the grid.
200 m_efields.resize(m_nX);
201 m_regions.resize(m_nX);
202 for (unsigned int i = 0; i < m_nX; ++i) {
203 m_efields[i].resize(m_nY);
204 m_regions[i].resize(m_nY);
205 for (unsigned int j = 0; j < m_nY; ++j) {
206 m_efields[i][j].resize(m_nZ);
207 m_regions[i][j].resize(m_nZ);
208 for (unsigned int k = 0; k < m_nZ; ++k) {
209 m_efields[i][j][k].fx = 0.;
210 m_efields[i][j][k].fy = 0.;
211 m_efields[i][j][k].fz = 0.;
212 m_efields[i][j][k].v = 0.;
213 m_regions[i][j][k] = 0;
214 }
215 }
216 }
217
218 m_pMin = m_pMax = 0.;
219 if (withPotential) {
220 m_pMin = 1.;
221 m_pMax = -1.;
222 }
223 return LoadData(filename, format, withPotential, withRegion,
224 scaleX, scaleE, scaleP, 'e');
225}

◆ LoadMagneticField()

bool Garfield::ComponentVoxel::LoadMagneticField ( const std::string &  filename,
const std::string &  format,
const double  scaleX = 1.,
const double  scaleB = 1. 
)

Import magnetic field values from a file.

Definition at line 227 of file ComponentVoxel.cc.

230 {
231
232 m_hasBfield = false;
233 if (!m_hasMesh) {
234 std::cerr << m_className << "::LoadMagneticField:\n"
235 << " Mesh is not set. Call SetMesh first.\n";
236 return false;
237 }
238
239 // Set up the grid.
240 m_bfields.resize(m_nX);
241 for (unsigned int i = 0; i < m_nX; ++i) {
242 m_bfields[i].resize(m_nY);
243 for (unsigned int j = 0; j < m_nY; ++j) {
244 m_bfields[i][j].resize(m_nZ);
245 for (unsigned int k = 0; k < m_nZ; ++k) {
246 m_bfields[i][j][k].fx = 0.;
247 m_bfields[i][j][k].fy = 0.;
248 m_bfields[i][j][k].fz = 0.;
249 m_bfields[i][j][k].v = 0.;
250 }
251 }
252 }
253
254 return LoadData(filename, format, false, false, scaleX, scaleB, 1., 'b');
255}

◆ MagneticField()

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

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::ComponentBase.

Definition at line 102 of file ComponentVoxel.cc.

105 {
106
107 if (!m_hasBfield) {
108 return ComponentBase::MagneticField(x, y, z, bx, by, bz, status);
109 }
110
111 // Get the mesh element.
112 unsigned int i = 0, j = 0, k = 0;
113 bool xMirrored = false, yMirrored = false, zMirrored = false;
114 if (!GetElement(x, y, z, i, j, k, xMirrored, yMirrored, zMirrored)) {
115 status = -11;
116 return;
117 }
118 status = 0;
119 // Get the field.
120 const Element& element = m_bfields[i][j][k];
121 bx = element.fx;
122 by = element.fy;
123 bz = element.fz;
124 if (xMirrored) bx = -bx;
125 if (yMirrored) by = -by;
126 if (zMirrored) bz = -bz;
127}
virtual void MagneticField(const double x, const double y, const double z, double &bx, double &by, double &bz, int &status)

◆ PrintRegions()

void Garfield::ComponentVoxel::PrintRegions ( ) const

Print all regions.

Definition at line 596 of file ComponentVoxel.cc.

596 {
597
598 // Do not proceed if not properly initialised.
599 if (!m_ready) {
600 std::cerr << m_className << "::PrintRegions:\n";
601 std::cerr << " Field map not yet initialised.\n";
602 return;
603 }
604
605 if (m_media.empty()) {
606 std::cerr << m_className << "::PrintRegions:\n No regions defined.\n";
607 return;
608 }
609
610 std::cout << m_className << "::PrintRegions:\n";
611 std::cout << " Index Medium\n";
612 const unsigned int nMedia = m_media.size();
613 for (unsigned int i = 0; i < nMedia; ++i) {
614 const std::string name = m_media[i] ? m_media[i]->GetName() : "none";
615 std::cout << " " << i << " " << name << "\n";
616 }
617}

◆ SetMedium()

void Garfield::ComponentVoxel::SetMedium ( const unsigned int  i,
Medium m 
)

Set the medium in region i.

Definition at line 619 of file ComponentVoxel.cc.

619 {
620
621 if (!m) {
622 std::cerr << m_className << "::SetMedium:\n Null pointer.\n";
623 if (m_media.empty()) return;
624 }
625 if (i >= m_media.size()) m_media.resize(i + 1, NULL);
626 m_media[i] = m;
627}

◆ SetMesh()

void Garfield::ComponentVoxel::SetMesh ( const unsigned int  nx,
const unsigned int  ny,
const unsigned int  nz,
const double  xmin,
const double  xmax,
const double  ymin,
const double  ymax,
const double  zmin,
const double  zmax 
)

Define the grid.

Parameters
nx,ny,nznumber of bins along x, y, z.
xmin,xmaxrange along $x$.
ymin,ymaxrange along $y$.
zmin,zmaxrange along $z$.

Definition at line 149 of file ComponentVoxel.cc.

153 {
154
155 Reset();
156 if (nx == 0 || ny == 0 || nz == 0) {
157 std::cerr << m_className << "::SetMesh:\n"
158 << " Number of mesh elements must be positive.\n";
159 return;
160 }
161 if (xmin >= xmax) {
162 std::cerr << m_className << "::SetMesh:\n Invalid x range.\n";
163 return;
164 } else if (ymin >= ymax) {
165 std::cerr << m_className << "::SetMesh:\n Invalid y range.\n";
166 return;
167 } else if (zmin >= zmax) {
168 std::cerr << m_className << "::SetMesh:\n Invalid z range.\n";
169 return;
170 }
171 m_nX = nx;
172 m_nY = ny;
173 m_nZ = nz;
174 m_xMin = xmin;
175 m_yMin = ymin;
176 m_zMin = zmin;
177 m_xMax = xmax;
178 m_yMax = ymax;
179 m_zMax = zmax;
180 m_hasMesh = true;
181}

◆ SetWeightingFieldOffset()

void Garfield::ComponentVoxel::SetWeightingFieldOffset ( const double  x,
const double  y,
const double  z 
)

Offset coordinates in the weighting field, such that the same numerical weighting field map can be used for electrodes at different positions.

Definition at line 95 of file ComponentVoxel.cc.

96 {
97 m_wField_xOffset = x;
98 m_wField_yOffset = y;
99 m_wField_zOffset = z;
100}

◆ WeightingField()

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

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::ComponentBase.

Definition at line 83 of file ComponentVoxel.cc.

85 {
86 int status = 0;
87 Medium* med = NULL;
88 double v = 0.;
89 double x1 = x - m_wField_xOffset;
90 double y1 = y - m_wField_yOffset;
91 double z1 = z - m_wField_zOffset;
92 ElectricField(x1, y1, z1, wx, wy, wz, v, med, status);
93}

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