17 #include <DD4hep/DD4hepUnits.h>
22 using namespace SurfaceOrientation;
24 using namespace magneticfield;
34 :
BaseVolumeHandle(expand2Pi, debugVal), theShape(fv.legacyShape(fv.shape())), solid(fv) {
37 const auto *
const transArray = fv.
trans();
40 center_ =
GlobalPoint(transArray[0] / dd4hep::cm, transArray[1] / dd4hep::cm, transArray[2] / dd4hep::cm);
43 string volName =
name;
44 volName.erase(0, volName.rfind(
'_') + 1);
45 volumeno =
static_cast<unsigned short>(std::atoi(volName.c_str()));
47 for (
int i = 0;
i < 6; ++
i) {
55 double halfX = box.x() / dd4hep::cm;
56 double halfY = box.y() / dd4hep::cm;
57 double halfZ = box.z() / dd4hep::cm;
62 double x1 = trap.bottomLow1() / dd4hep::cm;
63 double x2 = trap.topLow1() / dd4hep::cm;
64 double x3 = trap.bottomLow2() / dd4hep::cm;
65 double x4 = trap.topLow2() / dd4hep::cm;
66 double y1 = trap.high1() / dd4hep::cm;
67 double y2 = trap.high2() / dd4hep::cm;
68 double theta = trap.theta();
69 double phi = trap.phi();
70 double halfZ = trap.dZ() / dd4hep::cm;
71 double alpha1 = trap.alpha1();
72 double alpha2 = trap.alpha2();
73 buildTrap(x1, x2, x3, x4, y1, y2, theta, phi, halfZ, alpha1, alpha2);
78 double zhalf = cons.dZ() / dd4hep::cm;
79 double rInMinusZ = cons.rMin1() / dd4hep::cm;
80 double rOutMinusZ = cons.rMax1() / dd4hep::cm;
81 double rInPlusZ = cons.rMin2() / dd4hep::cm;
82 double rOutPlusZ = cons.rMax2() / dd4hep::cm;
83 double startPhi = cons.startPhi();
85 buildCons(zhalf, rInMinusZ, rOutMinusZ, rInPlusZ, rOutPlusZ, startPhi, deltaPhi);
89 double zhalf = tubs.dZ() / dd4hep::cm;
90 double rIn = tubs.rMin() / dd4hep::cm;
91 double rOut = tubs.rMax() / dd4hep::cm;
93 double deltaPhi = tubs.endPhi() - startPhi;
94 buildTubs(zhalf, rIn, rOut, startPhi, deltaPhi);
111 LogTrace(
"MagGeoBuilder") <<
" Pseudo trap params raw = " << d[0] <<
", " << d[1] <<
", " << d[2] <<
", "
112 << d[3] <<
", " << d[4] <<
", " << d[5] <<
", " << d[6];
115 transform(d.begin(), --(d.end()), d.begin(), [](
double val) {
return val / dd4hep::cm; });
118 LogTrace(
"MagGeoBuilder") <<
" Pseudo trap params converted = " << d[0] <<
", " << d[1] <<
", " << d[2] <<
", "
119 << d[3] <<
", " << d[4] <<
", " << d[5] <<
", " << d[6];
121 buildPseudoTrap(d[0], d[1], d[2], d[3], d[4], d[5], static_cast<bool>(d[6]));
125 double zhalf = tubs.dZ() / dd4hep::cm;
126 double rIn = tubs.rMin() / dd4hep::cm;
127 double rOut = tubs.rMax() / dd4hep::cm;
130 double cutAtStart = tubs.cutAtStart() / dd4hep::cm;
131 double cutAtDelta = tubs.cutAtDelta() / dd4hep::cm;
132 bool cutInside = tubs.cutInside();
133 buildTruncTubs(zhalf, rIn, rOut, startPhi, deltaPhi, cutAtStart, cutAtDelta, cutInside);
136 LogError(
"magneticfield::volumeHandle")
137 <<
"ctor: Unexpected shape # " <<
static_cast<int>(
theShape) <<
" for vol " <<
name;
141 if (fv.
volume().material().density() > 3.)
148 LogTrace(
"MagGeoBuilder") <<
"*** WARNING: wrong RMin/RN/RMax";
155 LogTrace(
"MagGeoBuilder") <<
" Orientation of surfaces:";
156 std::string sideName[3] = {
"positiveSide",
"negativeSide",
"onSurface"};
157 for (
int i = 0;
i < 6; ++
i) {
198 dd4hep::Rotation3D refRot;
200 refRot.GetComponents(x, y, z);
202 if (x.Cross(y).Dot(z) < 0.5) {
203 LogTrace(
"MagGeoBuilder") <<
"*** WARNING: Rotation is not RH ";
232 globalZdir = -globalZdir;
236 LogTrace(
"MagGeoBuilder") <<
"*** WARNING RefPlane check failed!***" << chk;
241 std::vector<VolumeSide>
result;
242 for (
int i = 0;
i < 6; ++
i) {
258 #include "buildBox.icc"
259 #include "buildTrap.icc"
260 #include "buildTubs.icc"
261 #include "buildCons.icc"
262 #include "buildPseudoTrap.icc"
263 #include "buildTruncTubs.icc"
constexpr double deltaPhi(double phi1, double phi2)
void buildBox(double halfX, double halfY, double halfZ)
MagGeoBuilderFromDDD::volumeHandle volumeHandle
A truncated tube section.
Surface::LocalVector LocalVector
std::string_view materialName() const
Geom::Phi< T > phi() const
Geom::Theta< T > theta() const
Log< level::Error, false > LogError
const PlacedVolume volume() const
The physical volume of the current node.
unsigned short volumeno
volume number
unsigned short copyno
copy number
unsigned short copyNum() const
GloballyPositioned< float > * refPlane
void referencePlane(const cms::DDFilteredView &fv)
const DDSolidShape theShape
double startPhi(void) const
Surface::GlobalPoint GlobalPoint
void buildTrap(double x1, double x2, double x3, double x4, double y1, double y2, double theta, double phi, double halfZ, double alpha1, double alpha2)
const Double_t * rot() const
The absolute rotation of the current node.
void buildTruncTubs(double zhalf, double rIn, double rOut, double startPhi, double deltaPhi, double cutAtStart, double cutAtDelta, bool cutInside)
Interface to a Trapezoid.
int masterSector
The sector for which an interpolator for this class of volumes should be built.
std::string_view name() const
void buildPseudoTrap(double x1, double x2, double y1, double y2, double halfZ, double radius, bool atMinusZ)
const GlobalPoint & center() const
Return the center of the volume.
GlobalPoint toGlobal(const LocalPoint &lp) const
const Double_t * trans() const
The absolute translation of the current node.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
std::string name
Name of the volume.
void buildCons(double zhalf, double rInMinusZ, double rOutMinusZ, double rInPlusZ, double rOutPlusZ, double startPhi, double deltaPhi)
double startPhi(void) const
angular start of the tube-section
std::vector< VolumeSide > sides() const override
The surfaces and they orientation, as required to build a MagVolume.
const std::vector< double > parameters() const
extract shape parameters
const PositionType & position() const
dd4hep::Solid solid() const
std::string magFile
Name of magnetic field table file.
const cms::DDFilteredView & solid
Global3DVector GlobalVector
void buildTubs(double zhalf, double rIn, double rOut, double startPhi, double deltaPhi)