Garfield 0.3
Toolkit for the detailed simulation of particle detectors based on ionization measurement in gases and semiconductors
Loading...
Searching...
No Matches
Garfield::ViewField Class Reference

Visualize the potential or electric field of a component or sensor. More...

#include <ViewField.hh>

Inheritance diagram for Garfield::ViewField:
Garfield::ViewBase

Public Member Functions

 ViewField ()
 Default constructor.
 ViewField (Sensor *sensor)
 Constructor from sensor.
 ViewField (Component *component)
 Constructor from component.
 ~ViewField ()=default
 Destructor.
void SetSensor (Sensor *s)
 Set the sensor for which to plot the field.
void SetComponent (Component *c)
 Set the component for which to plot the field.
void SetVoltageRange (const double vmin, const double vmax)
 Set the plot limits for the potential.
void SetElectricFieldRange (const double emin, const double emax)
 Set the plot limits for the electric field.
void SetWeightingFieldRange (const double wmin, const double wmax)
 Set the plot limits for the weighting field.
void SetMagneticFieldRange (const double bmin, const double bmax)
 Set the plot limits for the magnetic field.
void SetNumberOfContours (const unsigned int n)
 Set the number of contour levels.
void SetNumberOfSamples1d (const unsigned int n)
 Set the number of points used for drawing 1D functions.
void SetNumberOfSamples2d (const unsigned int nx, const unsigned int ny)
 Set the number of points used for drawing 2D functions.
void PlotContour (const std::string &option="v")
 Make a contour plot of the electric potential, electric field, or magnetic field.
void Plot (const std::string &option="v", const std::string &drawopt="arr")
 Make a 2D plot of the electric potential, electric field or magnetic field.
void PlotProfile (const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, const std::string &option="v", const bool normalised=true)
 Make a 1D plot of the potential or field along a line.
void PlotContourWeightingField (const std::string &label, const std::string &option)
 Make a contour plot of the weighting potential or field.
void PlotWeightingField (const std::string &label, const std::string &option, const std::string &drawopt, const double t=0.)
 Make a 2D plot of the weighting potential or field.
void PlotProfileWeightingField (const std::string &label, const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, const std::string &option="v", const bool normalised=true)
 Make a 1D plot of the weighting potential or field along a line.
void EnableAutoRange (const bool on=true, const bool samplePotential=true)
 Determine the range of the potential/field automatically (true) or set it explicitly (false).
void AcknowledgeStatus (const bool on, const double v0=0.)
 Make use (or not) of the status flag returned by the sensor/component.
void PlotFieldLines (const std::vector< double > &x0, const std::vector< double > &y0, const std::vector< double > &z0, const bool electron=true, const bool axis=true, const short col=kOrange - 3)
 Draw electric field lines from a set of starting points.
bool EqualFluxIntervals (const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, std::vector< double > &xf, std::vector< double > &yf, std::vector< double > &zf, const unsigned int nPoints=20) const
 Generates point along a line, spaced by equal flux intervals.
bool FixedFluxIntervals (const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, std::vector< double > &xf, std::vector< double > &yf, std::vector< double > &zf, const double interval=10.) const
 Generate points along a line, spaced by a given flux interval.
Public Member Functions inherited from Garfield::ViewBase
 ViewBase ()=delete
 Default constructor.
 ViewBase (const std::string &name)
 Constructor.
virtual ~ViewBase ()=default
 Destructor.
void SetCanvas (TPad *pad)
 Set the canvas to be painted on.
void SetCanvas ()
 Unset an external canvas.
TPad * GetCanvas ()
 Retrieve the canvas.
void SetArea (const double xmin, const double ymin, const double xmax, const double ymax)
 Set the x- and y-axis limits (in local coordinates of the current viewing plane, if applicable).
virtual void SetArea (const double xmin, const double ymin, const double zmin, const double xmax, const double ymax, const double zmax)
 Set a bounding box (if applicable).
void SetArea ()
 Use default x- and y-axis limits (based on the bounding box of the sensor/component, if applicable).
virtual void SetPlane (const double fx, const double fy, const double fz, const double x0, const double y0, const double z0)
 Set the projection (viewing plane), if applicable.
virtual void SetPlane (const double fx, const double fy, const double fz, const double x0, const double y0, const double z0, const double hx, const double hy, const double hz)
 Set the projection plane specifying a hint for the in-plane x axis.
void Rotate (const double angle)
 Rotate the viewing plane (angle in radian).
void SetPlaneXY ()
 Set the viewing plane to x-y.
void SetPlaneXZ ()
 Set the viewing plane to x-z.
void SetPlaneYZ ()
 Set the viewing plane to y-z.
void SetPlaneZX ()
 Set the viewing plane to z-x.
void SetPlaneZY ()
 Set the viewing plane to z-y.
void EnableDebugging (const bool on=true)
 Switch on/off debugging output.

Private Types

enum class  Parameter {
  Potential = 0 , Emag , Ex , Ey ,
  Ez , Bmag , Bx , By ,
  Bz , Unknown
}

Private Member Functions

bool SetPlotLimits ()
void Draw2d (const std::string &option, const bool contour, const bool wfield, const std::string &electrode, const std::string &drawopt, const double t=0.)
void DrawProfile (const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, const std::string &option, const bool wfield, const std::string &electrode, const bool normalised)
Parameter GetPar (const std::string &option, std::string &title, bool &bfield) const
double Efield (const double x, const double y, const double z, const Parameter par) const
double Wfield (const double x, const double y, const double z, const Parameter par, const std::string &electrode, const double t=0.) const
double Bfield (const double x, const double y, const double z, const Parameter par) const

Private Attributes

bool m_useAutoRange = true
bool m_samplePotential = true
bool m_useStatus = false
double m_vBkg = 0.
Sensor * m_sensor = nullptr
Component * m_component = nullptr
double m_vmin = 0.
double m_vmax = 100.
double m_emin = 0.
double m_emax = 10000.
double m_wmin = 0.
double m_wmax = 100.
double m_bmin = 0.
double m_bmax = 10.
unsigned int m_nContours = 20
unsigned int m_nSamples1d = 1000
unsigned int m_nSamples2dX = 200
unsigned int m_nSamples2dY = 200

Additional Inherited Members

Static Public Member Functions inherited from Garfield::ViewBase
static std::string FindUnusedFunctionName (const std::string &s)
 Find an unused function name.
static std::string FindUnusedHistogramName (const std::string &s)
 Find an unused histogram name.
static std::string FindUnusedCanvasName (const std::string &s)
 Find an unused canvas name.
Protected Member Functions inherited from Garfield::ViewBase
void UpdateProjectionMatrix ()
template<typename T>
void ToPlane (const T x, const T y, const T z, T &xp, T &yp) const
template<typename T>
bool InBox (const std::array< T, 3 > &x) const
void Clip (const std::array< float, 3 > &x0, const std::array< float, 3 > &x1, std::array< float, 3 > &xc) const
void DrawLine (const std::vector< std::array< float, 3 > > &xl, const short col, const short lw)
std::string LabelX ()
std::string LabelY ()
std::string PlaneDescription ()
bool PlotLimits (Sensor *sensor, double &xmin, double &ymin, double &xmax, double &ymax) const
bool PlotLimits (Component *cmp, double &xmin, double &ymin, double &xmax, double &ymax) const
bool PlotLimitsFromUserBox (double &xmin, double &ymin, double &xmax, double &ymax) const
bool PlotLimits (std::array< double, 3 > &bbmin, std::array< double, 3 > &bbmax, double &xmin, double &ymin, double &xmax, double &ymax) const
Static Protected Member Functions inherited from Garfield::ViewBase
static bool RangeSet (TVirtualPad *)
static void SetRange (TVirtualPad *pad, const double x0, const double y0, const double x1, const double y1)
Protected Attributes inherited from Garfield::ViewBase
std::string m_className = "ViewBase"
bool m_debug = false
bool m_userPlotLimits = false
double m_xMinPlot = -1.
double m_xMaxPlot = 1.
double m_yMinPlot = -1.
double m_yMaxPlot = 1.
bool m_userBox = false
double m_xMinBox = -1.
double m_xMaxBox = 1.
double m_yMinBox = -1.
double m_yMaxBox = 1.
double m_zMinBox = -1.
double m_zMaxBox = 1.
std::array< std::array< double, 3 >, 3 > m_proj
std::array< double, 4 > m_plane {{0, 0, 1, 0}}
std::array< std::array< double, 3 >, 3 > m_prmat

Detailed Description

Visualize the potential or electric field of a component or sensor.

Definition at line 15 of file ViewField.hh.

Member Enumeration Documentation

◆ Parameter

enum class Garfield::ViewField::Parameter
strongprivate
Enumerator
Potential 
Emag 
Ex 
Ey 
Ez 
Bmag 
Bx 
By 
Bz 
Unknown 

Definition at line 143 of file ViewField.hh.

143 {
144 Potential = 0,
145 Emag,
146 Ex,
147 Ey,
148 Ez,
149 Bmag,
150 Bx,
151 By,
152 Bz,
153 Unknown
154 };

Constructor & Destructor Documentation

◆ ViewField() [1/3]

Garfield::ViewField::ViewField ( )

Default constructor.

◆ ViewField() [2/3]

Garfield::ViewField::ViewField ( Sensor * sensor)

Constructor from sensor.

◆ ViewField() [3/3]

Garfield::ViewField::ViewField ( Component * component)

Constructor from component.

◆ ~ViewField()

Garfield::ViewField::~ViewField ( )
default

Destructor.

Member Function Documentation

◆ AcknowledgeStatus()

void Garfield::ViewField::AcknowledgeStatus ( const bool on,
const double v0 = 0. )
inline

Make use (or not) of the status flag returned by the sensor/component.

Parameters
onTake status flag into account (true) or ignore it (false).
v0Value to be used for regions with status != 0.

Definition at line 119 of file ViewField.hh.

119 {
120 m_useStatus = on;
121 m_vBkg = v0;
122 }

◆ Bfield()

double Garfield::ViewField::Bfield ( const double x,
const double y,
const double z,
const Parameter par ) const
private

◆ Draw2d()

void Garfield::ViewField::Draw2d ( const std::string & option,
const bool contour,
const bool wfield,
const std::string & electrode,
const std::string & drawopt,
const double t = 0. )
private

◆ DrawProfile()

void Garfield::ViewField::DrawProfile ( const double x0,
const double y0,
const double z0,
const double x1,
const double y1,
const double z1,
const std::string & option,
const bool wfield,
const std::string & electrode,
const bool normalised )
private

◆ Efield()

double Garfield::ViewField::Efield ( const double x,
const double y,
const double z,
const Parameter par ) const
private

◆ EnableAutoRange()

void Garfield::ViewField::EnableAutoRange ( const bool on = true,
const bool samplePotential = true )
inline

Determine the range of the potential/field automatically (true) or set it explicitly (false).

Definition at line 109 of file ViewField.hh.

110 {
111 m_useAutoRange = on;
112 m_samplePotential = samplePotential;
113 }

◆ EqualFluxIntervals()

bool Garfield::ViewField::EqualFluxIntervals ( const double x0,
const double y0,
const double z0,
const double x1,
const double y1,
const double z1,
std::vector< double > & xf,
std::vector< double > & yf,
std::vector< double > & zf,
const unsigned int nPoints = 20 ) const

Generates point along a line, spaced by equal flux intervals.

◆ FixedFluxIntervals()

bool Garfield::ViewField::FixedFluxIntervals ( const double x0,
const double y0,
const double z0,
const double x1,
const double y1,
const double z1,
std::vector< double > & xf,
std::vector< double > & yf,
std::vector< double > & zf,
const double interval = 10. ) const

Generate points along a line, spaced by a given flux interval.

◆ GetPar()

Parameter Garfield::ViewField::GetPar ( const std::string & option,
std::string & title,
bool & bfield ) const
private

◆ Plot()

void Garfield::ViewField::Plot ( const std::string & option = "v",
const std::string & drawopt = "arr" )

Make a 2D plot of the electric potential, electric field or magnetic field.

Parameters
optionquantity to be plotted (see PlotContour)
drawoptoption string passed to TF2::Draw

◆ PlotContour()

void Garfield::ViewField::PlotContour ( const std::string & option = "v")

Make a contour plot of the electric potential, electric field, or magnetic field.

Parameters
optionquantity to be plotted
  • potential: "v", "voltage", "p", "potential"
  • magnitude of the electric field: "emag", "field"
  • x-component of the electric field: "ex"
  • y-component of the electric field: "ey"
  • z-component of the electric field: "ez"
  • magnitude of the magnetic field: "bmag"
  • x-component of the magnetic field: "bx"
  • y-component of the magnetic field: "by"
  • z-component of the magnetic field: "bz"

◆ PlotContourWeightingField()

void Garfield::ViewField::PlotContourWeightingField ( const std::string & label,
const std::string & option )

Make a contour plot of the weighting potential or field.

Parameters
labelidentifier of the electrode
optionquantity to be plotted (see PlotContour)

◆ PlotFieldLines()

void Garfield::ViewField::PlotFieldLines ( const std::vector< double > & x0,
const std::vector< double > & y0,
const std::vector< double > & z0,
const bool electron = true,
const bool axis = true,
const short col = kOrange - 3 )

Draw electric field lines from a set of starting points.

◆ PlotProfile()

void Garfield::ViewField::PlotProfile ( const double x0,
const double y0,
const double z0,
const double x1,
const double y1,
const double z1,
const std::string & option = "v",
const bool normalised = true )

Make a 1D plot of the potential or field along a line.

Parameters
x0,y0,z0starting point
x1,y1,z1end point
optionquantity to be plotted (see PlotContour)
normalisedflag whether to use normalised x-axis coordinates

◆ PlotProfileWeightingField()

void Garfield::ViewField::PlotProfileWeightingField ( const std::string & label,
const double x0,
const double y0,
const double z0,
const double x1,
const double y1,
const double z1,
const std::string & option = "v",
const bool normalised = true )

Make a 1D plot of the weighting potential or field along a line.

Parameters
labelidentifier of the electrode
x0,y0,z0starting point
x1,y1,z1end point
optionquantity to be plotted (see PlotContour)
normalisedflag whether to use normalised x-axis coordinates

◆ PlotWeightingField()

void Garfield::ViewField::PlotWeightingField ( const std::string & label,
const std::string & option,
const std::string & drawopt,
const double t = 0. )

Make a 2D plot of the weighting potential or field.

Parameters
labelidentifier of the electrode
optionquantity to be plotted (see PlotContour)
drawoptoption string passed to TF2::Draw
ttime slice of dynamic weighting potential [ns].

◆ SetComponent()

void Garfield::ViewField::SetComponent ( Component * c)

Set the component for which to plot the field.

◆ SetElectricFieldRange()

void Garfield::ViewField::SetElectricFieldRange ( const double emin,
const double emax )

Set the plot limits for the electric field.

◆ SetMagneticFieldRange()

void Garfield::ViewField::SetMagneticFieldRange ( const double bmin,
const double bmax )

Set the plot limits for the magnetic field.

◆ SetNumberOfContours()

void Garfield::ViewField::SetNumberOfContours ( const unsigned int n)

Set the number of contour levels.

◆ SetNumberOfSamples1d()

void Garfield::ViewField::SetNumberOfSamples1d ( const unsigned int n)

Set the number of points used for drawing 1D functions.

◆ SetNumberOfSamples2d()

void Garfield::ViewField::SetNumberOfSamples2d ( const unsigned int nx,
const unsigned int ny )

Set the number of points used for drawing 2D functions.

◆ SetPlotLimits()

bool Garfield::ViewField::SetPlotLimits ( )
private

◆ SetSensor()

void Garfield::ViewField::SetSensor ( Sensor * s)

Set the sensor for which to plot the field.

◆ SetVoltageRange()

void Garfield::ViewField::SetVoltageRange ( const double vmin,
const double vmax )

Set the plot limits for the potential.

◆ SetWeightingFieldRange()

void Garfield::ViewField::SetWeightingFieldRange ( const double wmin,
const double wmax )

Set the plot limits for the weighting field.

◆ Wfield()

double Garfield::ViewField::Wfield ( const double x,
const double y,
const double z,
const Parameter par,
const std::string & electrode,
const double t = 0. ) const
private

Member Data Documentation

◆ m_bmax

double Garfield::ViewField::m_bmax = 10.
private

Definition at line 169 of file ViewField.hh.

◆ m_bmin

double Garfield::ViewField::m_bmin = 0.
private

Definition at line 169 of file ViewField.hh.

◆ m_component

Component* Garfield::ViewField::m_component = nullptr
private

Definition at line 163 of file ViewField.hh.

◆ m_emax

double Garfield::ViewField::m_emax = 10000.
private

Definition at line 167 of file ViewField.hh.

◆ m_emin

double Garfield::ViewField::m_emin = 0.
private

Definition at line 167 of file ViewField.hh.

◆ m_nContours

unsigned int Garfield::ViewField::m_nContours = 20
private

Definition at line 172 of file ViewField.hh.

◆ m_nSamples1d

unsigned int Garfield::ViewField::m_nSamples1d = 1000
private

Definition at line 174 of file ViewField.hh.

◆ m_nSamples2dX

unsigned int Garfield::ViewField::m_nSamples2dX = 200
private

Definition at line 175 of file ViewField.hh.

◆ m_nSamples2dY

unsigned int Garfield::ViewField::m_nSamples2dY = 200
private

Definition at line 176 of file ViewField.hh.

◆ m_samplePotential

bool Garfield::ViewField::m_samplePotential = true
private

Definition at line 157 of file ViewField.hh.

◆ m_sensor

Sensor* Garfield::ViewField::m_sensor = nullptr
private

Definition at line 162 of file ViewField.hh.

◆ m_useAutoRange

bool Garfield::ViewField::m_useAutoRange = true
private

Definition at line 156 of file ViewField.hh.

◆ m_useStatus

bool Garfield::ViewField::m_useStatus = false
private

Definition at line 158 of file ViewField.hh.

◆ m_vBkg

double Garfield::ViewField::m_vBkg = 0.
private

Definition at line 159 of file ViewField.hh.

◆ m_vmax

double Garfield::ViewField::m_vmax = 100.
private

Definition at line 166 of file ViewField.hh.

◆ m_vmin

double Garfield::ViewField::m_vmin = 0.
private

Definition at line 166 of file ViewField.hh.

◆ m_wmax

double Garfield::ViewField::m_wmax = 100.
private

Definition at line 168 of file ViewField.hh.

◆ m_wmin

double Garfield::ViewField::m_wmin = 0.
private

Definition at line 168 of file ViewField.hh.


The documentation for this class was generated from the following file:
  • /builds/garfield/docs/source/Include/Garfield/ViewField.hh