Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
SolidWire.cc
Go to the documentation of this file.
1#include <cmath>
2#include <iostream>
3
6
7namespace Garfield {
8
9SolidWire::SolidWire(const double cx, const double cy, const double cz,
10 const double rw, const double lz)
11 : Solid(cx, cy, cz, "SolidWire"),
12 m_r(rw),
13 m_lZ(lz) {}
14
15SolidWire::SolidWire(const double cx, const double cy, const double cz,
16 const double rw, const double lz,
17 const double dx, const double dy, const double dz)
18 : SolidWire(cx, cy, cz, rw, lz) {
19 SetDirection(dx, dy, dz);
20}
21
22bool SolidWire::IsInside(const double x, const double y, const double z,
23 const bool /*tesselated*/) const {
24 // Transform the point to local coordinates.
25 double u = x, v = y, w = z;
26 ToLocal(x, y, z, u, v, w);
27
28 if (fabs(w) > m_lZ) return false;
29
30 const double r = sqrt(u * u + v * v);
31 return r < m_r;
32}
33
34bool SolidWire::GetBoundingBox(double& xmin, double& ymin, double& zmin,
35 double& xmax, double& ymax, double& zmax) const {
36 if (m_cTheta == 1. && m_cPhi == 1.) {
37 xmin = m_cX - m_r;
38 xmax = m_cX + m_r;
39 ymin = m_cY - m_r;
40 ymax = m_cY + m_r;
41 zmin = m_cZ - m_lZ;
42 zmax = m_cZ + m_lZ;
43 return true;
44 }
45
46 const double dd = sqrt(m_r * m_r + m_lZ * m_lZ);
47 xmin = m_cX - dd;
48 xmax = m_cX + dd;
49 ymin = m_cY - dd;
50 ymax = m_cY + dd;
51 zmin = m_cZ - dd;
52 zmax = m_cZ + dd;
53 return true;
54}
55
56void SolidWire::SetRadius(const double r) {
57 if (r <= 0.) {
58 std::cerr << "SolidWire::SetRadius: Radius must be > 0.\n";
59 return;
60 }
61 m_r = r;
62}
63
64void SolidWire::SetHalfLength(const double lz) {
65 if (lz <= 0.) {
66 std::cerr << "SolidWire::SetHalfLength: Half-length must be > 0.\n";
67 return;
68 }
69 m_lZ = lz;
70}
71
72bool SolidWire::SolidPanels(std::vector<Panel>& /*panels*/) {
73 return true;
74}
75
76double SolidWire::GetDiscretisationLevel(const Panel& /*panel*/) {
77 return m_dis;
78}
79
81 const double /*x0*/, const double /*y0*/, const double /*z0*/,
82 const double /*xn*/, const double /*yn*/, const double /*zn*/,
83 std::vector<Panel>& /*panels*/) {
84
85}
86
87}
bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const override
Return the bounding box of the solid.
Definition: SolidWire.cc:34
bool SolidPanels(std::vector< Panel > &panels) override
Retrieve the surface panels of the solid.
Definition: SolidWire.cc:72
bool IsInside(const double x, const double y, const double z, const bool tesselated) const override
Definition: SolidWire.cc:22
void SetHalfLength(const double lz)
Definition: SolidWire.cc:64
SolidWire(const double cx, const double cy, const double cz, const double r, const double lz)
Constructor from centre, radius, and half-length.
Definition: SolidWire.cc:9
void SetRadius(const double r)
Definition: SolidWire.cc:56
void Cut(const double x0, const double y0, const double z0, const double xn, const double yn, const double zn, std::vector< Panel > &panels) override
Definition: SolidWire.cc:80
double GetDiscretisationLevel(const Panel &panel) override
Retrieve the discretisation level of a panel.
Definition: SolidWire.cc:76
Abstract base class for solids.
Definition: Solid.hh:28
double m_cZ
Definition: Solid.hh:202
double m_cTheta
Polar angle.
Definition: Solid.hh:209
void ToLocal(const double x, const double y, const double z, double &u, double &v, double &w) const
Definition: Solid.hh:234
void SetDirection(const double dx, const double dy, const double dz)
Definition: Solid.cc:12
double m_cY
Definition: Solid.hh:202
double m_cX
Centre of the solid.
Definition: Solid.hh:202
double m_cPhi
Azimuthal angle.
Definition: Solid.hh:207
Surface panel.
Definition: Solid.hh:11