5 #include "DD4hep/DetFactoryHelper.h"
8 using namespace angle_units::operators;
37 int nsectors = args.
value<
int>(
"NSector");
38 int nsectortot = args.
value<
int>(
"NSectorTot");
39 int nhalf = args.
value<
int>(
"NHalf");
40 double rin = args.
value<
double>(
"RIn");
41 std::vector<double>
theta = args.
value<std::vector<double> >(
"Theta");
42 std::vector<double> rmax = args.
value<std::vector<double> >(
"RMax");
43 std::vector<double> zoff = args.
value<std::vector<double> >(
"ZOff");
45 double thick = args.
value<
double>(
"Thickness");
46 double width1 = args.
value<
double>(
"Width1");
47 double length1 = args.
value<
double>(
"Length1");
48 double width2 = args.
value<
double>(
"Width2");
49 double length2 = args.
value<
double>(
"Length2");
50 double gap2 = args.
value<
double>(
"Gap2");
53 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: General material " << genMat <<
"\tSectors " << nsectors <<
", "
54 << nsectortot <<
"\tHalves " << nhalf <<
"\tRin " <<
cms::convert2mm(rin);
55 for (
unsigned int i = 0;
i < theta.size();
i++)
63 <<
" NameSpace " << ns.
name() <<
" for solids";
66 double alpha = 1._pi / nsectors;
67 double dphi = nsectortot * 2._pi / nsectors;
68 double zstep0 = zoff[1] + rmax[1] *
tan(theta[1]) + (rin - rmax[1]) *
tan(theta[2]);
69 double zstep1 = zstep0 + thick /
cos(theta[2]);
70 double zstep2 = zoff[3];
71 double rstep0 = rin + (zstep2 - zstep1) /
tan(theta[2]);
72 double rstep1 = rin + (zstep1 - zstep0) /
tan(theta[2]);
74 std::vector<double> pgonZ = {zstep0, zstep1, zstep2, zstep2 + thick /
cos(theta[2])};
75 std::vector<double> pgonRmin = {rin, rin, rstep0, rmax[2]};
76 std::vector<double> pgonRmax = {rin, rstep1, rmax[2], rmax[2]};
79 dd4hep::Material matter = ns.
material(genMat);
82 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: " << solid.name() <<
" Polyhedra made of " << genMat <<
" with "
84 <<
convertRadToDeg(-alpha + dphi) <<
" and with " << pgonZ.size() <<
" sections";
85 for (
unsigned int i = 0; i < pgonZ.size(); i++)
92 dd4hep::Rotation3D
rot;
93 parent.placeVolume(genlogic, 1);
95 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: " << genlogic.name() <<
" number 1 positioned in "
96 << parent.name() <<
" at (0, 0, 0) with no rotation";
100 parent.placeVolume(genlogic, 2, rot);
102 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: " << genlogic.name() <<
" number 2 positioned in "
103 << parent.name() <<
" at (0, 0, 0) with rotation: " <<
rot;
112 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: " << solid.name() <<
" Polyhedra made of " << genMat
114 <<
" and with " << pgonZ.size() <<
" sections";
115 for (
unsigned int i = 0; i < pgonZ.size(); i++)
121 for (
int ii = 0;
ii < nsectortot; ++
ii) {
125 rotation = dd4hep::RotationZ(phi);
127 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: Creating a new rotation "
132 genlogic.placeVolume(seclogic,
ii + 1, rotation);
134 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: " << seclogic.name() <<
" number " <<
ii + 1
135 <<
" positioned in " << genlogic.name() <<
" at (0, 0, 0) with rotation: " <<
rotation;
140 double rinl = pgonRmin[0] + thick *
sin(theta[2]);
141 double routl = pgonRmax[2] - thick *
sin(theta[2]);
142 double dx1 = rinl *
tan(alpha);
143 double dx2 = 0.90 * routl *
tan(alpha);
144 double dy = 0.50 * thick;
145 double dz = 0.50 * (routl - rinl);
146 name = idName +
"Trap";
147 solid = dd4hep::Trap(ns.
prepend(name),
dz, 0, 0,
dy, dx1, dx1, 0,
dy, dx2, dx2, 0);
150 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: " << solid.name() <<
" Trap made of " << genMat
156 rot =
cms::makeRotation3D(90._deg, 270._deg, (180._deg - theta[2]), 0, (90._deg - theta[2]), 0);
158 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: Creating a rotation: \t90, 270, "
163 seclogic.placeVolume(glog, 1, dd4hep::Transform3D(rot, r1));
165 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: " << glog.name() <<
" number 1 positioned in " << seclogic.name()
170 name = idName +
"Cable1";
171 double phi = atan((dx2 - dx1) / (2 * dz));
172 double xmid = 0.5 * (dx1 + dx2) - 1.0;
173 solid = dd4hep::Box(ns.
prepend(name), 0.5 * width1, 0.5 * thick, 0.5 * length1);
174 dd4hep::Material absmatter = ns.
material(absMat);
177 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: " << solid.name() <<
" Box made of " << absMat <<
" of dimension "
182 dd4hep::Rotation3D rot2 =
cms::makeRotation3D((90._deg + phi), 0.0, 90._deg, 90._deg, phi, 0.0);
188 glog.placeVolume(cablog1, 1, dd4hep::Transform3D(rot2, r2));
190 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: " << cablog1.name() <<
" number 1 positioned in " << glog.name()
192 <<
", 0, 0) with rotation: " << rot2;
194 dd4hep::Rotation3D rot3 =
cms::makeRotation3D((90._deg - phi), 0, 90._deg, 90._deg, -phi, 0);
200 glog.placeVolume(cablog1, 2, dd4hep::Transform3D(rot3, r3));
202 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: " << cablog1.name() <<
" number 2 positioned in " << glog.name()
204 <<
", 0, 0) with rotation: " << rot3;
207 name = idName +
"Cable2";
208 solid = dd4hep::Box(ns.
prepend(name), 0.5 * width2, 0.5 * thick, 0.5 * length2);
211 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: " << solid.name() <<
" Box made of " << absMat <<
" of dimension "
216 glog.placeVolume(cablog2, 1,
dd4hep::Position(0.5 * (width2 + gap2), 0, 0));
218 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: " << cablog2.name() <<
" number 1 positioned in " << glog.name()
219 <<
" at (" <<
cms::convert2mm(0.5 * (width2 + gap2)) <<
", 0, 0) with no rotation";
221 glog.placeVolume(cablog2, 2,
dd4hep::Position(-0.5 * (width2 + gap2), 0, 0));
223 edm::LogVerbatim(
"HCalGeom") <<
"DDHCalTBCableAlgo: " << cablog2.name() <<
" number 2 positioned in " << glog.name()
224 <<
" at " <<
cms::convert2mm(-0.5 * (width2 + gap2)) <<
", 0, 0) with no rotation";
226 edm::LogVerbatim(
"HCalGeom") <<
"<<== End of DDHCalTBCableAlgo construction";
Log< level::Info, true > LogVerbatim
dd4hep::Volume volume(const std::string &name, bool exc=true) const
constexpr NumType convertRadToDeg(NumType radians)
constexpr NumType convert2mm(NumType length)
Sin< T >::type sin(const T &t)
T value(const std::string &name) const
Geom::Theta< T > theta() const
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
std::string_view name() const
#define DECLARE_DDCMS_DETELEMENT(name, func)
static constexpr long s_executed
Cos< T >::type cos(const T &t)
Tan< T >::type tan(const T &t)
dd4hep::Material material(const std::string &name) const
std::string prepend(const std::string &) const
std::string parentName() const
Access value of rParent child node.