1 #include "DD4hep/DetFactoryHelper.h"
9 using namespace cms_units::operators;
15 string genMat = args.
str(
"GeneralMaterial");
16 int detectorN = args.
integer(
"DetectorNumber");
17 double moduleThick = args.
dble(
"ModuleThick");
18 double detTilt = args.
dble(
"DetTilt");
19 double fullHeight = args.
dble(
"FullHeight");
20 double dlTop = args.
dble(
"DlTop");
21 double dlBottom = args.
dble(
"DlBottom");
22 double dlHybrid = args.
dble(
"DlHybrid");
23 bool doComponents = ::toupper(args.
str(
"DoComponents")[0]) !=
'N';
25 string boxFrameName = args.
str(
"BoxFrameName");
26 string boxFrameMat = args.
str(
"BoxFrameMaterial");
27 double boxFrameHeight = args.
dble(
"BoxFrameHeight");
28 double boxFrameThick = args.
dble(
"BoxFrameThick");
29 double boxFrameWidth = args.
dble(
"BoxFrameWidth");
30 double bottomFrameHeight = args.
dble(
"BottomFrameHeight");
31 double bottomFrameOver = args.
dble(
"BottomFrameOver");
32 double topFrameHeight = args.
dble(
"TopFrameHeight");
33 double topFrameOver = args.
dble(
"TopFrameOver");
34 vector<string> sideFrameName = args.
vecStr(
"SideFrameName");
35 string sideFrameMat = args.
str(
"SideFrameMaterial");
36 double sideFrameWidth = args.
dble(
"SideFrameWidth");
37 double sideFrameThick = args.
dble(
"SideFrameThick");
38 double sideFrameOver = args.
dble(
"SideFrameOver");
39 vector<string> holeFrameName = args.
vecStr(
"HoleFrameName");
40 vector<string> holeFrameRot = args.
vecStr(
"HoleFrameRotation");
42 vector<string> kaptonName = args.
vecStr(
"KaptonName");
43 string kaptonMat = args.
str(
"KaptonMaterial");
44 double kaptonThick = args.
dble(
"KaptonThick");
45 double kaptonOver = args.
dble(
"KaptonOver");
46 vector<string> holeKaptonName = args.
vecStr(
"HoleKaptonName");
47 vector<string> holeKaptonRot = args.
vecStr(
"HoleKaptonRotation");
49 vector<string> waferName = args.
vecStr(
"WaferName");
50 string waferMat = args.
str(
"WaferMaterial");
51 double sideWidthTop = args.
dble(
"SideWidthTop");
52 double sideWidthBottom = args.
dble(
"SideWidthBottom");
53 vector<string> activeName = args.
vecStr(
"ActiveName");
54 string activeMat = args.
str(
"ActiveMaterial");
55 double activeHeight = args.
dble(
"ActiveHeight");
58 string activeRot = args.
str(
"ActiveRotation");
59 vector<double> backplaneThick = args.
vecDble(
"BackPlaneThick");
60 string hybridName = args.
str(
"HybridName");
61 string hybridMat = args.
str(
"HybridMaterial");
62 double hybridHeight = args.
dble(
"HybridHeight");
63 double hybridWidth = args.
dble(
"HybridWidth");
64 double hybridThick = args.
dble(
"HybridThick");
65 vector<string> pitchName = args.
vecStr(
"PitchName");
66 string pitchMat = args.
str(
"PitchMaterial");
67 double pitchHeight = args.
dble(
"PitchHeight");
68 double pitchThick = args.
dble(
"PitchThick");
69 double pitchStereoTol = args.
dble(
"PitchStereoTolerance");
70 string coolName = args.
str(
"CoolInsertName");
71 string coolMat = args.
str(
"CoolInsertMaterial");
72 double coolHeight = args.
dble(
"CoolInsertHeight");
73 double coolThick = args.
dble(
"CoolInsertThick");
74 double coolWidth = args.
dble(
"CoolInsertWidth");
76 edm::LogVerbatim(
"TIDGeom") <<
"Parent " << mother <<
" General Material " << genMat <<
" Detector Planes "
80 <<
" Height " << fullHeight <<
" dl(Top) " << dlTop <<
" dl(Bottom) " << dlBottom
81 <<
" dl(Hybrid) " << dlHybrid <<
" doComponents " << doComponents;
82 edm::LogVerbatim(
"TIDGeom") <<
"" << boxFrameName <<
" Material " << boxFrameMat <<
" Thickness " << boxFrameThick
83 <<
" width " << boxFrameWidth <<
" height " << boxFrameHeight
84 <<
" Extra Height at Bottom " << bottomFrameHeight <<
" Overlap " << bottomFrameOver;
86 for (
int i = 0;
i < detectorN;
i++)
87 edm::LogVerbatim(
"TIDGeom") << sideFrameName[
i] <<
" Material " << sideFrameMat <<
" Width " << sideFrameWidth
88 <<
" Thickness " << sideFrameThick <<
" Overlap " << sideFrameOver <<
" Hole "
91 for (
int i = 0;
i < detectorN;
i++)
92 edm::LogVerbatim(
"TIDGeom") << kaptonName[
i] <<
" Material " << kaptonMat <<
" Thickness " << kaptonThick
93 <<
" Overlap " << kaptonOver <<
" Hole " << holeKaptonName[
i];
95 edm::LogVerbatim(
"TIDGeom") <<
"Wafer Material " << waferMat <<
" Side Width Top " << sideWidthTop
96 <<
" Side Width Bottom " << sideWidthBottom;
97 for (
int i = 0;
i < detectorN;
i++)
100 edm::LogVerbatim(
"TIDGeom") <<
"Active Material " << activeMat <<
" Height " << activeHeight <<
" rotated by "
102 for (
int i = 0;
i < detectorN;
i++)
103 edm::LogVerbatim(
"TIDGeom") <<
" translated by (0," << -0.5 * backplaneThick[
i] <<
",0)\tactiveName[" <<
i
104 <<
"] = " << activeName[
i] <<
" of thickness " << waferThick[
i] - backplaneThick[
i];
106 edm::LogVerbatim(
"TIDGeom") <<
"" << hybridName <<
" Material " << hybridMat <<
" Height " << hybridHeight
107 <<
" Width " << hybridWidth <<
" Thickness " << hybridThick;
108 edm::LogVerbatim(
"TIDGeom") <<
"Pitch Adapter Material " << pitchMat <<
" Height " << pitchHeight <<
" Thickness "
110 for (
int i = 0;
i < detectorN;
i++)
112 edm::LogVerbatim(
"TIDGeom") <<
"Cool Element Material " << coolMat <<
" Height " << coolHeight <<
" Thickness "
113 << coolThick <<
" Width " << coolWidth;
115 string name = mother;
116 double sidfr = sideFrameWidth - sideFrameOver;
120 if (dlHybrid > dlTop) {
122 topfr = topFrameHeight - pitchHeight - topFrameOver;
123 botfr = bottomFrameHeight - bottomFrameOver;
124 kaptonHeight = fullHeight + botfr;
127 topfr = topFrameHeight - topFrameOver;
128 botfr = bottomFrameHeight - bottomFrameOver - pitchHeight;
129 kaptonHeight = fullHeight + topfr;
132 double sideFrameHeight = fullHeight + pitchHeight + botfr + topfr;
133 double kaptonWidth = sidfr + kaptonOver;
135 double dxbot = 0.5 * dlBottom + sidfr;
136 double dxtop = 0.5 * dlTop + sidfr;
137 double dxtopenv, dxbotenv;
140 if (dlHybrid > dlTop) {
142 dxtopenv = dxbot + (dxtop - dxbot) * (fullHeight + pitchHeight + topfr + hybridHeight) / fullHeight;
143 dxbotenv = dxtop - (dxtop - dxbot) * (fullHeight + botfr) / fullHeight;
146 dxtopenv = dxbot + (dxtop - dxbot) * (fullHeight + topfr) / fullHeight;
149 double bl1 = dxbotenv;
150 double bl2 = dxtopenv;
151 double h1 = 0.5 * moduleThick;
153 double dz = 0.5 * (boxFrameHeight + sideFrameHeight);
155 Solid solid = ns.
addSolidNS(ns.
prepend(name), Trap(dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0));
157 edm::LogVerbatim(
"TIDGeom") << solid.name() <<
" Trap made of " << genMat <<
" of dimensions " << dz <<
", 0, 0, "
158 << h1 <<
", " << bl1 <<
", " << bl1 <<
", 0, " << h1 <<
", " << bl2 <<
", " << bl2
164 dx = 0.5 * boxFrameWidth;
165 dy = 0.5 * boxFrameThick;
166 dz = 0.5 * boxFrameHeight;
168 edm::LogVerbatim(
"TIDGeom") << solid.name() <<
" Box made of " << boxFrameMat <<
" of dimensions " << dx <<
", "
174 dx = 0.5 * hybridWidth;
175 dy = 0.5 * hybridThick;
176 dz = 0.5 * hybridHeight;
178 edm::LogVerbatim(
"TIDGeom") << solid.name() <<
" Box made of " << hybridMat <<
" of dimensions " << dx <<
", " << dy
184 dx = 0.5 * coolWidth;
185 dy = 0.5 * coolThick;
186 dz = 0.5 * coolHeight;
188 edm::LogVerbatim(
"TIDGeom") << solid.name() <<
" Box made of " << coolMat <<
" of dimensions " << dx <<
", " << dy
193 for (
int k = 0;
k < detectorN;
k++) {
196 name = sideFrameName[
k];
197 if (dlHybrid > dlTop) {
199 bbl1 = dxtop - (dxtop - dxbot) * (fullHeight + botfr) / fullHeight;
200 bbl2 = dxbot + (dxtop - dxbot) * (fullHeight + pitchHeight + topfr) / fullHeight;
203 bbl1 = dxtop - (dxtop - dxbot) * (fullHeight + pitchHeight + botfr) / fullHeight;
204 bbl2 = dxbot + (dxtop - dxbot) * (fullHeight + topfr) / fullHeight;
206 h1 = 0.5 * sideFrameThick;
207 dz = 0.5 * sideFrameHeight;
208 solid = ns.
addSolidNS(ns.
prepend(name), Trap(dz, 0., 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0.));
209 edm::LogVerbatim(
"TIDGeom") << solid.name() <<
" Trap made of " << sideFrameMat <<
" of dimensions " << dz
210 <<
", 0, 0, " << h1 <<
", " << bbl1 <<
", " << bbl1 <<
", 0, " << h1 <<
", " << bbl2
211 <<
", " << bbl2 <<
", 0";
218 name = holeFrameName[
k];
220 dz = fullHeight - bottomFrameOver - topFrameOver;
221 bbl1 = dxbot - sideFrameWidth + bottomFrameOver * (dxtop - dxbot) / fullHeight;
222 bbl2 = dxtop - sideFrameWidth - topFrameOver * (dxtop - dxbot) / fullHeight;
223 if (dlHybrid > dlTop) {
225 zpos = -(topFrameHeight + 0.5 * dz - 0.5 * sideFrameHeight);
228 zpos = bottomFrameHeight + 0.5 * dz - 0.5 * sideFrameHeight;
231 solid = ns.
addSolidNS(ns.
prepend(name), Trap(dz, 0, 0, h1, bbl1, bbl1, 0, h1, bbl2, bbl2, 0));
232 edm::LogVerbatim(
"TIDGeom") << solid.name() <<
" Trap made of " << genMat <<
" of dimensions " << dz <<
", 0, 0, "
233 << h1 <<
", " << bbl1 <<
", " << bbl1 <<
", 0, " << h1 <<
", " << bbl2 <<
", " << bbl2
238 sideFrame.placeVolume(holeFrame, 1, Transform3D(rot,
Position(0e0, 0e0, zpos)));
239 edm::LogVerbatim(
"TIDGeom") << holeFrame.name() <<
" number 1 positioned in " << sideFrame.name() <<
" at (0,0,"
240 << zpos <<
") with no rotation";
243 double kaptonExtraHeight = 0;
244 if (dlHybrid > dlTop) {
246 bbl1 = dxtop - (dxtop - dxbot) * (fullHeight + botfr) / fullHeight;
248 kaptonExtraHeight = dlTop *
sin(detTilt) - fullHeight * (1 -
cos(detTilt));
249 kaptonExtraHeight = 0.5 * fabs(kaptonExtraHeight);
250 bbl2 = dxbot + (dxtop - dxbot) * (fullHeight + kaptonExtraHeight) / fullHeight;
256 bbl2 = dxbot + (dxtop - dxbot) * (fullHeight + topfr) / fullHeight;
258 kaptonExtraHeight = dlBottom *
sin(detTilt) - fullHeight * (1 -
cos(detTilt));
259 kaptonExtraHeight = 0.5 * fabs(kaptonExtraHeight);
260 bbl1 = dxtop - (dxtop - dxbot) * (fullHeight + kaptonExtraHeight) / fullHeight;
265 h1 = 0.5 * kaptonThick;
266 dz = 0.5 * (kaptonHeight + kaptonExtraHeight);
272 ns.
addSolidNS(ns.
prepend(kaptonName[k] +
"Uncut"), Trap(dz, 0., 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0));
275 dz = (dlHybrid > dlTop) ? 0.5 * dlTop : 0.5 * dlBottom;
276 h1 = 0.5 * kaptonThick;
277 bbl1 = fabs(dz *
sin(detTilt));
278 bbl2 = bbl1 * 0.000001;
279 double thet = atan((bbl1 - bbl2) / (2 * dz));
281 ns.
addSolidNS(ns.
prepend(kaptonName[k] +
"Cut"), Trap(dz, thet, 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0));
284 name = kaptonName[
k];
285 rot = ns.
rotation(
"tidmodpar:9PYX");
286 xpos = -0.5 * fullHeight *
sin(detTilt);
287 zpos = 0.5 * kaptonHeight - bbl2;
289 SubtractionSolid(solidUncut, solidCut, Transform3D(rot,
Position(xpos, 0.0, zpos))));
291 name = kaptonName[
k];
292 solid = ns.
addSolidNS(ns.
prepend(name), Trap(dz, 0., 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0.));
296 edm::LogVerbatim(
"TIDGeom") << solid.name() <<
" SUBTRACTION SOLID Trap made of " << kaptonMat
297 <<
" of dimensions " << dz <<
", 0, 0, " << h1 <<
", " << bbl1 <<
", " << bbl1
298 <<
", 0, " << h1 <<
", " << bbl2 <<
", " << bbl2 <<
", 0";
301 name = holeKaptonName[
k];
302 dz = fullHeight - kaptonOver;
304 if (dlHybrid > dlTop) {
306 bbl1 = dxbot - kaptonWidth + kaptonOver * (dxtop - dxbot) / fullHeight;
307 bbl2 = dxtop - kaptonWidth;
308 zpos = 0.5 * (kaptonHeight - kaptonExtraHeight -
dz);
310 zpos -= 0.5 * kaptonOver * (1 -
cos(detTilt));
311 xpos = -0.5 * kaptonOver *
sin(detTilt);
315 bbl1 = dxbot - kaptonWidth;
316 bbl2 = dxtop - kaptonWidth - kaptonOver * (dxtop - dxbot) / fullHeight;
317 zpos = -0.5 * (kaptonHeight - kaptonExtraHeight -
dz);
320 solid = ns.
addSolidNS(ns.
prepend(name), Trap(dz, 0., 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0.));
321 edm::LogVerbatim(
"TIDGeom") << solid.name() <<
" Trap made of " << genMat <<
" of dimensions " << dz <<
", 0, 0, "
322 << h1 <<
", " << bbl1 <<
", " << bbl1 <<
", 0, " << h1 <<
", " << bbl2 <<
", " << bbl2
326 rot = ns.
rotation(holeKaptonRot[k]);
327 kapton.placeVolume(holeKapton, 1, Transform3D(rot,
Position(xpos, 0.0, zpos)));
328 edm::LogVerbatim(
"TIDGeom") << holeKapton.name() <<
" number 1 positioned in " << kapton.name() <<
" at (0,0,"
329 << zpos <<
") with no rotation";
333 if (k == 0 && dlHybrid < dlTop) {
335 bl2 = 0.5 * dlBottom;
337 bl1 = 0.5 * dlBottom;
340 h1 = 0.5 * waferThick[
k];
341 dz = 0.5 * fullHeight;
342 solid = ns.
addSolidNS(ns.
prepend(name), Trap(dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0));
343 edm::LogVerbatim(
"TIDGeom") << solid.name() <<
" Trap made of " << waferMat <<
" of dimensions " << dz
344 <<
", 0, 0, " << h1 <<
", " << bl1 <<
", " << bl1 <<
", 0, " << h1 <<
", " << bl2
345 <<
", " << bl2 <<
", 0";
349 name = activeName[
k];
350 if (k == 0 && dlHybrid < dlTop) {
352 bl2 -= sideWidthBottom;
354 bl1 -= sideWidthBottom;
357 dz = 0.5 * (waferThick[
k] - backplaneThick[
k]);
358 h1 = 0.5 * activeHeight;
359 solid = ns.
addSolidNS(ns.
prepend(name), Trap(dz, 0, 0, h1, bl2, bl1, 0, h1, bl2, bl1, 0));
360 edm::LogVerbatim(
"TIDGeom") << solid.name() <<
" Trap made of " << activeMat <<
" of dimensions " << dz
361 <<
", 0, 0, " << h1 <<
", " << bl2 <<
", " << bl1 <<
", 0, " << h1 <<
", " << bl2
362 <<
", " << bl1 <<
", 0";
365 Position tran(0.0, -0.5 * backplaneThick[k], 0.0);
366 wafer.placeVolume(active, 1, Transform3D(rot, tran));
367 edm::LogVerbatim(
"TIDGeom") <<
"DDTIDModuleAlgo test: " << active.name() <<
" number 1 positioned in "
368 << wafer.name() <<
" at " << tran <<
" with " <<
rot;
372 if (dlHybrid > dlTop) {
379 dy = 0.5 * pitchThick;
380 dz = 0.5 * pitchHeight;
382 edm::LogVerbatim(
"TIDGeom") << solid.name() <<
" Box made of " << pitchMat <<
" of dimensions"
383 <<
" " << dx <<
", " << dy <<
", " <<
dz;
385 h1 = 0.5 * pitchThick;
386 bl1 = 0.5 * pitchHeight + 0.5 * dz *
sin(detTilt);
387 bl2 = 0.5 * pitchHeight - 0.5 * dz *
sin(detTilt);
389 dz -= 0.5 * pitchStereoTol;
390 bl1 -= pitchStereoTol;
391 bl2 -= pitchStereoTol;
393 double thet = atan((bl1 - bl2) / (2. * dz));
394 solid = ns.
addSolidNS(ns.
prepend(name), Trap(dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0));
395 edm::LogVerbatim(
"TIDGeom") << solid.name() <<
" Trap made of " << pitchMat <<
" of "
396 <<
"dimensions " << dz <<
", " <<
convertRadToDeg(thet) <<
", 0, " << h1 <<
", "
397 << bl1 <<
", " << bl1 <<
", 0, " << h1 <<
", " << bl2 <<
", " << bl2 <<
", 0";
402 edm::LogVerbatim(
"TIDGeom") <<
"<<== End of DDTIDModuleAlgo construction ...";
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Log< level::Info, true > LogVerbatim
constexpr NumType convertRadToDeg(NumType radians)
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
Sin< T >::type sin(const T &t)
int integer(const std::string &nam) const
Shortcut to access integer arguments.
#define DECLARE_DDCMS_DETELEMENT(name, func)
Cos< T >::type cos(const T &t)
dd4hep::Material material(const std::string &name) const
int32_t waferThick(const int32_t property)
std::string prepend(const std::string &) const
const dd4hep::Rotation3D & rotation(const std::string &name) const
std::vector< double > vecDble(const std::string &nam) const
Shortcut to access vector<double> arguments.
double dble(const std::string &nam) const
Shortcut to access double arguments.
std::vector< std::string > vecStr(const std::string &nam) const
Shortcut to access vector<string> arguments.
std::string parentName() const
Access value of rParent child node.
std::string str(const std::string &nam) const
Shortcut to access string arguments.