11 const double& rmin,
const double& rmax,
const double& lz)
13 m_cX(cx), m_cY(cy), m_cZ(cz),
14 m_rMin(rmin), m_rMax(rmax),
16 m_dX(0.), m_dY(0.), m_dZ(1.),
17 m_cPhi(1.), m_sPhi(0.),
18 m_cTheta(1.), m_sTheta(0.) {}
21 const double& rmin,
const double& rmax,
const double& lz,
22 const double& dx,
const double& dy,
const double& dz)
24 m_cX(cx), m_cY(cy), m_cZ(cz),
25 m_rMin(rmin), m_rMax(rmax),
27 m_dX(0.), m_dY(0.), m_dZ(1.),
28 m_cPhi(1.), m_sPhi(0.),
29 m_cTheta(1.), m_sTheta(0.) {
31 const double d =
sqrt(dx * dx + dy * dy + dz * dz);
33 std::cerr <<
"SolidTube: Direction vector has zero norm.\n";
39 const double dt =
sqrt(m_dX * m_dX + m_dY * m_dY);
48 phi = atan2(m_dY, m_dX);
49 theta = atan2(dt, m_dZ);
51 m_cTheta =
cos(theta);
52 m_sTheta =
sin(theta);
61 const double dx = x - m_cX;
62 const double dy = y - m_cY;
63 const double dz = z - m_cZ;
64 const double u = m_cPhi * m_cTheta * dx + m_sPhi * m_cTheta * dy - m_sTheta * dz;
65 const double v = -m_sPhi * dx + m_cPhi * dy;
66 const double w = m_cPhi * m_sTheta * dx + m_sPhi * m_sTheta * dy + m_cTheta * dz;
70 std::cout <<
"SolidTube::IsInside:\n";
71 std::cout <<
" (" << x <<
", " << y <<
", " << z <<
")"
77 const double r =
sqrt(u * u + v * v);
78 if (r >= m_rMin && r <= m_rMax) {
80 std::cout <<
"SolidTube::IsInside:\n";
81 std::cout <<
" (" << x <<
", " << y <<
", " << z <<
")"
88 std::cout <<
"SolidTube::IsInside:\n";
89 std::cout <<
" (" << x <<
", " << y <<
", " << z <<
") "
96 double& xmax,
double& ymax,
double& zmax)
const {
98 if (m_cTheta == 1. && m_cPhi == 1.) {
100 xmax = m_cX + m_rMax;
101 ymin = m_cY - m_rMax;
102 ymax = m_cY + m_rMax;
108 const double dd =
sqrt(m_rMax * m_rMax + m_lZ * m_lZ);
135 double& sphi)
const {
147 std::cerr <<
"SolidTube::SetInnerRadius:\n";
148 std::cerr <<
" Radius must be > 0.\n";
151 if (rmin >= m_rMax) {
152 std::cerr <<
"SolidTube::SetInnerRadius:\n";
153 std::cerr <<
" Inner radius must be smaller than outer radius.\n";
162 std::cerr <<
"SolidTube::SetOuterRadius:\n";
163 std::cerr <<
" Radius must be > 0.\n";
166 if (rmax <= m_rMin) {
167 std::cerr <<
"SolidTube::SetOuterRadius:\n";
168 std::cerr <<
" Outer radius must be greater than inner radius.\n";
177 std::cerr <<
"SolidTube::SetHalfLengthZ:\n";
178 std::cerr <<
" Half-length must be > 0.\n";
DoubleAc cos(const DoubleAc &f)
DoubleAc sqrt(const DoubleAc &f)
DoubleAc sin(const DoubleAc &f)
DoubleAc fabs(const DoubleAc &f)
void SetInnerRadius(const double &rmin)
void SetHalfLengthZ(const double &lz)
virtual bool GetOrientation(double &ctheta, double &stheta, double &cphi, double &sphi) const
virtual bool GetDimensions(double &l1, double &l2, double &l3) const
virtual bool IsInside(const double &x, const double &y, const double &z) const
void SetOuterRadius(const double &rmax)
virtual bool GetCenter(double &x, double &y, double &z) const
virtual bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const
SolidTube(const double &cx, const double &cy, const double &cz, const double &rmin, const double &rmax, const double &lz)