15 #include <DD4hep/detail/Handle.inl>
21 #define INFINITY (numeric_limits<double>::max())
38 Transform3D::Point p0(pos[0],pos[1],pos[2]);
40 const Double_t coords[3] = {p.x(), p.y(), p.z()};
41 if(
volume->Contains(coords) ) {
62 double radius = std::sqrt(pos[0] * pos[0] + pos[1] * pos[1]);
77 double z = pos[2], r = std::sqrt(pos[0] * pos[0] + pos[1] * pos[1]);
82 double abs_z = fabs(z);
97 constexpr
static unsigned char FIELD_INITIALIZED = 1<<0;
98 constexpr
static unsigned char FIELD_IDENTITY = 1<<1;
99 constexpr
static unsigned char FIELD_ROTATION_ONLY = 1<<2;
100 constexpr
static unsigned char FIELD_POSITION_ONLY = 1<<3;
101 constexpr
static unsigned char FIELD_HAS_AABB = 1<<4;
112 constexpr
static double eps = 1e-10;
113 double xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz;
114 transform.GetComponents(xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz);
115 flag |= FIELD_INITIALIZED;
116 if ( (xx + yy + zz) < (3e0 - eps) ) {
117 flag |= FIELD_ROTATION_ONLY;
120 flag |= FIELD_POSITION_ONLY;
121 if ( (std::abs(dx) + std::abs(dy) + std::abs(dz)) < eps )
122 flag |= FIELD_IDENTITY;
131 auto* bbox =
dynamic_cast<TGeoBBox*
>(shape);
134 const double* orig = bbox->GetOrigin();
135 double bdx = bbox->GetDX();
136 double bdy = bbox->GetDY();
137 double bdz = bbox->GetDZ();
139 Transform3D::Point world_center =
140 this->
transform * Transform3D::Point(orig[0], orig[1], orig[2]);
142 double hx = std::abs(xx)*bdx + std::abs(xy)*bdy + std::abs(xz)*bdz;
143 double hy = std::abs(yx)*bdx + std::abs(yy)*bdy + std::abs(yz)*bdz;
144 double hz = std::abs(zx)*bdx + std::abs(zy)*bdy + std::abs(zz)*bdz;
145 this->
aabb_min[0] = world_center.X() - hx;
146 this->
aabb_max[0] = world_center.X() + hx;
147 this->
aabb_min[1] = world_center.Y() - hy;
148 this->
aabb_max[1] = world_center.Y() + hy;
149 this->
aabb_min[2] = world_center.Z() - hz;
150 this->
aabb_max[2] = world_center.Z() + hz;
151 flag |= FIELD_HAS_AABB;
156 if ( (
flag&FIELD_HAS_AABB) &&
162 Transform3D::Point p, p0(pos[0],pos[1],pos[2]);
163 if (
flag&FIELD_IDENTITY ) p = std::move(p0);
167 double x = p.X(), y = p.Y(), z = p.Z();
168 double coord[3] = {x, y, z};
181 by += (1./6.) * (
coefficents[3] * (x2*x - 3.0*x*y2) +
skews[3]*(y2*y - 3.0*x2*y) );
182 bx += (1./6.) * (
coefficents[3] * (3.0*x2*y - y2*y) +
skews[3]*(x2*x - 3.0*x*y2) );
199 throw std::runtime_error(
"Invalid multipole field definition!");
201 Transform3D::Point f = this->
rotation * Transform3D::Point(bx, by,
B_z);