15 #include <DD4hep/detail/Handle.inl>
21 #define INFINITY (numeric_limits<double>::max())
25 #if defined __has_cpp_attribute
26 #if __has_cpp_attribute(fallthrough)
27 #define ATTR_FALLTHROUGH [[fallthrough]]
29 #define ATTR_FALLTHROUGH
32 #define ATTR_FALLTHROUGH
59 double radius = std::sqrt(pos[0] * pos[0] + pos[1] * pos[1]);
74 double z = pos[2], r = std::sqrt(pos[0] * pos[0] + pos[1] * pos[1]);
79 double abs_z = fabs(z);
94 constexpr
static unsigned char FIELD_INITIALIZED = 1<<0;
95 constexpr
static unsigned char FIELD_IDENTITY = 1<<1;
96 constexpr
static unsigned char FIELD_ROTATION_ONLY = 1<<2;
97 constexpr
static unsigned char FIELD_POSITION_ONLY = 1<<3;
108 constexpr
static double eps = 1e-10;
109 double xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz;
110 transform.GetComponents(xx, xy, xz, dx, yx, yy, yz, dy, zx, zy, zz, dz);
111 flag |= FIELD_INITIALIZED;
112 if ( (xx + yy + zz) < (3e0 - eps) ) {
113 flag |= FIELD_ROTATION_ONLY;
116 flag |= FIELD_POSITION_ONLY;
117 if ( (std::abs(dx) + std::abs(dy) + std::abs(dz)) < eps )
118 flag |= FIELD_IDENTITY;
124 Transform3D::Point p, p0(pos[0],pos[1],pos[2]);
125 if (
flag&FIELD_IDENTITY ) p = std::move(p0);
129 double x = p.X(), y = p.Y(), z = p.Z();
130 double coord[3] = {x, y, z};
143 by += (1./6.) * (
coefficents[3] * (x2*x - 3.0*x*y2) +
skews[3]*(y2*y - 3.0*x2*y) );
144 bx += (1./6.) * (
coefficents[3] * (3.0*x2*y - y2*y) +
skews[3]*(x2*x - 3.0*x*y2) );
161 throw std::runtime_error(
"Invalid multipole field definition!");
163 Transform3D::Point f = this->
rotation * Transform3D::Point(bx, by,
B_z);