11 const double& lx,
const double& ly,
const double& lz)
13 m_cX(cx), m_cY(cy), m_cZ(cz),
14 m_lX(lx), m_lY(ly), m_lZ(lz),
15 m_dX(0.), m_dY(0.), m_dZ(1.),
16 m_cPhi(1.), m_sPhi(0.),
17 m_cTheta(1.), m_sTheta(0.) {
19 std::cout <<
"SolidBox:\n";
20 std::cout <<
" " << cx - lx <<
" < x [cm] < " << cx + lx <<
"\n";
21 std::cout <<
" " << cy - ly <<
" < y [cm] < " << cy + ly <<
"\n";
22 std::cout <<
" " << cz - lz <<
" < z [cm] < " << cz + lz <<
"\n";
26 const double& lx,
const double& ly,
const double& lz,
27 const double& dx,
const double& dy,
const double& dz)
29 m_cX(cx), m_cY(cy), m_cZ(cz),
30 m_lX(lx), m_lY(ly), m_lZ(lz),
31 m_dX(0.), m_dY(0.), m_dZ(1.),
32 m_cPhi(1.), m_sPhi(0.),
33 m_cTheta(1.), m_sTheta(0.) {
35 const double d =
sqrt(dx * dx + dy * dy + dz * dz);
37 std::cerr <<
"SolidBox: Direction vector has zero norm.\n";
43 const double dt =
sqrt(m_dX * m_dX + m_dY * m_dY);
52 phi = atan2(m_dY, m_dX);
53 theta = atan2(dt, m_dZ);
55 m_cTheta =
cos(theta);
56 m_sTheta =
sin(theta);
63 const double& z)
const {
66 const double dx = x - m_cX;
67 const double dy = y - m_cY;
68 const double dz = z - m_cZ;
69 const double u = m_cPhi * m_cTheta * dx + m_sPhi * m_cTheta * dy - m_sTheta * dz;
70 const double v = -m_sPhi * dx + m_cPhi * dy;
71 const double w = m_cPhi * m_sTheta * dx + m_sPhi * m_sTheta * dy + m_cTheta * dz;
74 if (
fabs(u) > m_lX ||
fabs(v) > m_lY ||
fabs(w) > m_lZ) {
76 std::cout <<
"SolidBox::IsInside:\n";
77 std::cout <<
" (" << x <<
", " << y <<
", " << z <<
") "
84 std::cout <<
"SolidBox::IsInside:\n";
85 std::cout <<
" (" << x <<
", " << y <<
", " << z <<
") "
93 double& xmax,
double& ymax,
double& zmax)
const {
95 if (m_cTheta == 1. && m_cPhi == 1.) {
105 const double dd =
sqrt(m_lX * m_lX + m_lY * m_lY + m_lZ * m_lZ);
132 double& sphi)
const {
146 std::cerr <<
"SolidBox::SetHalfLengthX:\n";
147 std::cerr <<
" Half-length must be > 0.\n";
156 std::cerr <<
"SolidBox::SetHalfLengthY:\n";
157 std::cerr <<
" Half-length must be > 0.\n";
166 std::cerr <<
"SolidBox::SetHalfLengthZ:\n";
167 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 SetHalfLengthY(const double &ly)
void SetHalfLengthX(const double &lx)
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
virtual bool GetCenter(double &x, double &y, double &z) const
SolidBox(const double &cx, const double &cy, const double &cz, const double &lx, const double &ly, const double &lz)
void SetHalfLengthZ(const double &lz)
virtual bool GetBoundingBox(double &xmin, double &ymin, double &zmin, double &xmax, double &ymax, double &zmax) const