Garfield++ v2r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
ComponentBase.cc
Go to the documentation of this file.
1#include <iostream>
2#include "ComponentBase.hh"
3
4namespace Garfield {
5
7 : m_className("ComponentBase"),
8 m_geometry(NULL),
9 m_ready(false),
10 m_activeTraps(false),
11 m_xPeriodic(false),
12 m_yPeriodic(false),
13 m_zPeriodic(false),
14 m_xMirrorPeriodic(false),
15 m_yMirrorPeriodic(false),
16 m_zMirrorPeriodic(false),
17 m_xAxiallyPeriodic(false),
18 m_yAxiallyPeriodic(false),
19 m_zAxiallyPeriodic(false),
20 m_xRotationSymmetry(false),
21 m_yRotationSymmetry(false),
22 m_zRotationSymmetry(false),
23 m_bx0(0.),
24 m_by0(0.),
25 m_bz0(0.),
26 m_debug(false) {}
27
29
30 // Make sure the geometry is defined
31 if (!geo) {
32 std::cerr << "ComponentBase::SetGeometry:\n";
33 std::cerr << " Geometry pointer is null.\n";
34 return;
35 }
36
37 m_geometry = geo;
38}
39
40Medium* ComponentBase::GetMedium(const double x, const double y,
41 const double z) {
42
43 if (!m_geometry) return NULL;
44 return m_geometry->GetMedium(x, y, z);
45}
46
48
49 m_geometry = NULL;
50 Reset();
51}
52
53void ComponentBase::WeightingField(const double x, const double y,
54 const double z, double& wx, double& wy,
55 double& wz, const std::string& label) {
56 if (m_debug) {
57 std::cerr << m_className << "::WeightingField:\n";
58 std::cerr << " This function is not implemented.\n";
59 std::cerr << " Weighting field at (" << x << ", " << y << ", " << z
60 << ") for electrode " << label << " cannot be calculated.\n";
61 }
62 wx = wy = wz = 0.;
63}
64
65double ComponentBase::WeightingPotential(const double x, const double y,
66 const double z,
67 const std::string& label) {
68
69 if (m_debug) {
70 std::cerr << m_className << "::WeightingPotential:\n";
71 std::cerr << " This function is not implemented.\n";
72 std::cerr << " Weighting potential at (" << x << ", " << y << ", " << z
73 << ") for electrode " << label << " cannot be calculated.\n";
74 }
75 return 0.;
76}
77
78void ComponentBase::MagneticField(const double x, const double y,
79 const double z, double& bx, double& by,
80 double& bz, int& status) {
81 bx = m_bx0;
82 by = m_by0;
83 bz = m_bz0;
84 if (m_debug) {
85 std::cout << m_className << "::MagneticField:\n";
86 std::cout << " Magnetic field at (" << x << ", " << y << ", " << z
87 << ") is (" << bx << ", " << by << ", " << bz << ")\n";
88 }
89 status = 0;
90}
91
92void ComponentBase::SetMagneticField(const double bx, const double by,
93 const double bz) {
94
95 m_bx0 = bx;
96 m_by0 = by;
97 m_bz0 = bz;
98}
99
100bool ComponentBase::GetBoundingBox(double& xmin, double& ymin, double& zmin,
101 double& xmax, double& ymax, double& zmax) {
102
103 if (!m_geometry) return false;
104 return (m_geometry->GetBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax));
105}
106
107bool ComponentBase::IsWireCrossed(const double x0, const double y0,
108 const double z0,
109 const double /*x1*/, const double /*y1*/,
110 const double /*z1*/, double& xc,
111 double& yc, double& zc) {
112
113 xc = x0;
114 yc = y0;
115 zc = z0;
116 return false;
117
118}
119
120bool ComponentBase::IsInTrapRadius(const double /*q0*/, const double x0,
121 const double y0, const double /*z0*/,
122 double& xw, double& yw, double& rw) {
123
124 xw = x0;
125 yw = y0;
126 rw = 0.;
127 return false;
128
129}
130}
ComponentBase()
Constructor.
Definition: ComponentBase.cc:6
virtual double WeightingPotential(const double x, const double y, const double z, const std::string &label)
virtual void Clear()
Reset.
GeometryBase * m_geometry
Pointer to the geometry.
void SetMagneticField(const double bx, const double by, const double bz)
Set a constant magnetic field.
virtual void Reset()=0
Geometry checks.
virtual void MagneticField(const double x, const double y, const double z, double &bx, double &by, double &bz, int &status)
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 GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)
Get the bounding box coordinates.
virtual void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label)
std::string m_className
Class name.
virtual void SetGeometry(GeometryBase *geo)
Define the geometry.
virtual bool IsInTrapRadius(const double q0, const double x0, const double y0, const double z0, double &xw, double &yw, double &rw)
bool m_debug
Switch on/off debugging messages.
virtual Medium * GetMedium(const double x, const double y, const double z)
Get the medium at a given location (x, y, z).
Abstract base class for geometry classes.
Definition: GeometryBase.hh:12
virtual Medium * GetMedium(const double x, const double y, const double z) const =0
virtual bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax)=0
Abstract base class for media.
Definition: Medium.hh:11