1 #include "DD4hep/DetFactoryHelper.h" 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");
56 vector<double> waferThick =
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 LogDebug(
"TIDGeom") <<
"Parent " << mother <<
" General Material " << genMat <<
" Detector Planes " << detectorN;
78 LogDebug(
"TIDGeom") <<
"ModuleThick " << moduleThick <<
" Detector Tilt " <<
convertRadToDeg(detTilt) <<
" Height " 79 << fullHeight <<
" dl(Top) " << dlTop <<
" dl(Bottom) " << dlBottom <<
" dl(Hybrid) " << dlHybrid
80 <<
" doComponents " << doComponents;
81 LogDebug(
"TIDGeom") <<
"" << boxFrameName <<
" Material " << boxFrameMat <<
" Thickness " << boxFrameThick
82 <<
" width " << boxFrameWidth <<
" height " << boxFrameHeight <<
" Extra Height at Bottom " 83 << bottomFrameHeight <<
" Overlap " << bottomFrameOver;
85 for (
int i = 0;
i < detectorN;
i++)
86 LogDebug(
"TIDGeom") << sideFrameName[
i] <<
" Material " << sideFrameMat <<
" Width " << sideFrameWidth
87 <<
" Thickness " << sideFrameThick <<
" Overlap " << sideFrameOver <<
" Hole " 90 for (
int i = 0;
i < detectorN;
i++)
91 LogDebug(
"TIDGeom") << kaptonName[
i] <<
" Material " << kaptonMat <<
" Thickness " << kaptonThick <<
" Overlap " 92 << kaptonOver <<
" Hole " << holeKaptonName[
i];
94 LogDebug(
"TIDGeom") <<
"Wafer Material " << waferMat <<
" Side Width Top " << sideWidthTop <<
" Side Width Bottom " 96 for (
int i = 0;
i < detectorN;
i++)
97 LogDebug(
"TIDGeom") <<
"\twaferName[" <<
i <<
"] = " << waferName[
i];
99 LogDebug(
"TIDGeom") <<
"Active Material " << activeMat <<
" Height " << activeHeight <<
" rotated by " << activeRot;
100 for (
int i = 0;
i < detectorN;
i++)
101 LogDebug(
"TIDGeom") <<
" translated by (0," << -0.5 * backplaneThick[
i] <<
",0)\tactiveName[" <<
i 102 <<
"] = " << activeName[
i] <<
" of thickness " << waferThick[
i] - backplaneThick[
i];
104 LogDebug(
"TIDGeom") <<
"" << hybridName <<
" Material " << hybridMat <<
" Height " << hybridHeight <<
" Width " 105 << hybridWidth <<
" Thickness " << hybridThick;
106 LogDebug(
"TIDGeom") <<
"Pitch Adapter Material " << pitchMat <<
" Height " << pitchHeight <<
" Thickness " 108 for (
int i = 0;
i < detectorN;
i++)
109 LogDebug(
"TIDGeom") <<
"\tpitchName[" <<
i <<
"] = " << pitchName[
i];
110 LogDebug(
"TIDGeom") <<
"Cool Element Material " << coolMat <<
" Height " << coolHeight <<
" Thickness " << coolThick
111 <<
" Width " << coolWidth;
113 string name = mother;
114 double sidfr = sideFrameWidth - sideFrameOver;
118 if (dlHybrid > dlTop) {
120 topfr = topFrameHeight - pitchHeight - topFrameOver;
121 botfr = bottomFrameHeight - bottomFrameOver;
122 kaptonHeight = fullHeight + botfr;
125 topfr = topFrameHeight - topFrameOver;
126 botfr = bottomFrameHeight - bottomFrameOver - pitchHeight;
127 kaptonHeight = fullHeight + topfr;
130 double sideFrameHeight = fullHeight + pitchHeight + botfr + topfr;
131 double kaptonWidth = sidfr + kaptonOver;
133 double dxbot = 0.5 * dlBottom + sidfr;
134 double dxtop = 0.5 * dlTop + sidfr;
135 double dxtopenv, dxbotenv;
138 if (dlHybrid > dlTop) {
140 dxtopenv = dxbot + (dxtop - dxbot) * (fullHeight + pitchHeight + topfr + hybridHeight) / fullHeight;
141 dxbotenv = dxtop - (dxtop - dxbot) * (fullHeight + botfr) / fullHeight;
144 dxtopenv = dxbot + (dxtop - dxbot) * (fullHeight + topfr) / fullHeight;
147 double bl1 = dxbotenv;
148 double bl2 = dxtopenv;
149 double h1 = 0.5 * moduleThick;
151 double dz = 0.5 * (boxFrameHeight + sideFrameHeight);
153 Solid solid = ns.
addSolidNS(name, Trap(dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0));
155 LogDebug(
"TIDGeom") << solid.name() <<
" Trap made of " << genMat <<
" of dimensions " << dz <<
", 0, 0, " << h1
156 <<
", " << bl1 <<
", " << bl1 <<
", 0, " << h1 <<
", " << bl2 <<
", " << bl2 <<
", 0";
161 dx = 0.5 * boxFrameWidth;
162 dy = 0.5 * boxFrameThick;
163 dz = 0.5 * boxFrameHeight;
165 LogDebug(
"TIDGeom") << solid.name() <<
" Box made of " << boxFrameMat <<
" of dimensions " << dx <<
", " << dy
171 dx = 0.5 * hybridWidth;
172 dy = 0.5 * hybridThick;
173 dz = 0.5 * hybridHeight;
175 LogDebug(
"TIDGeom") << solid.name() <<
" Box made of " << hybridMat <<
" of dimensions " << dx <<
", " << dy <<
", " 181 dx = 0.5 * coolWidth;
182 dy = 0.5 * coolThick;
183 dz = 0.5 * coolHeight;
185 LogDebug(
"TIDGeom") << solid.name() <<
" Box made of " << coolMat <<
" of dimensions " << dx <<
", " << dy <<
", " 190 for (
int k = 0;
k < detectorN;
k++) {
193 name = sideFrameName[
k];
194 if (dlHybrid > dlTop) {
196 bbl1 = dxtop - (dxtop - dxbot) * (fullHeight + botfr) / fullHeight;
197 bbl2 = dxbot + (dxtop - dxbot) * (fullHeight + pitchHeight + topfr) / fullHeight;
200 bbl1 = dxtop - (dxtop - dxbot) * (fullHeight + pitchHeight + botfr) / fullHeight;
201 bbl2 = dxbot + (dxtop - dxbot) * (fullHeight + topfr) / fullHeight;
203 h1 = 0.5 * sideFrameThick;
204 dz = 0.5 * sideFrameHeight;
205 solid = ns.
addSolidNS(name, Trap(dz, 0., 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0.));
206 LogDebug(
"TIDGeom") << solid.name() <<
" Trap made of " << sideFrameMat <<
" of dimensions " << dz <<
", 0, 0, " 207 << h1 <<
", " << bbl1 <<
", " << bbl1 <<
", 0, " << h1 <<
", " << bbl2 <<
", " << bbl2
215 name = holeFrameName[
k];
217 dz = fullHeight - bottomFrameOver - topFrameOver;
218 bbl1 = dxbot - sideFrameWidth + bottomFrameOver * (dxtop - dxbot) / fullHeight;
219 bbl2 = dxtop - sideFrameWidth - topFrameOver * (dxtop - dxbot) / fullHeight;
220 if (dlHybrid > dlTop) {
222 zpos = -(topFrameHeight + 0.5 * dz - 0.5 * sideFrameHeight);
225 zpos = bottomFrameHeight + 0.5 * dz - 0.5 * sideFrameHeight;
228 solid = ns.
addSolidNS(name, Trap(dz, 0, 0, h1, bbl1, bbl1, 0, h1, bbl2, bbl2, 0));
229 LogDebug(
"TIDGeom") << solid.name() <<
" Trap made of " << genMat <<
" of dimensions " << dz <<
", 0, 0, " << h1
230 <<
", " << bbl1 <<
", " << bbl1 <<
", 0, " << h1 <<
", " << bbl2 <<
", " << bbl2 <<
", 0";
234 sideFrame.placeVolume(holeFrame, 1, Transform3D(rot, Position(0e0, 0e0, zpos)));
235 LogDebug(
"TIDGeom") << holeFrame.name() <<
" number 1 positioned in " << sideFrame.name() <<
" at (0,0," << zpos
236 <<
") with no rotation";
239 double kaptonExtraHeight = 0;
240 if (dlHybrid > dlTop) {
242 bbl1 = dxtop - (dxtop - dxbot) * (fullHeight + botfr) / fullHeight;
244 kaptonExtraHeight = dlTop *
sin(detTilt) - fullHeight * (1 -
cos(detTilt));
245 kaptonExtraHeight = 0.5 * fabs(kaptonExtraHeight);
246 bbl2 = dxbot + (dxtop - dxbot) * (fullHeight + kaptonExtraHeight) / fullHeight;
252 bbl2 = dxbot + (dxtop - dxbot) * (fullHeight + topfr) / fullHeight;
254 kaptonExtraHeight = dlBottom *
sin(detTilt) - fullHeight * (1 -
cos(detTilt));
255 kaptonExtraHeight = 0.5 * fabs(kaptonExtraHeight);
256 bbl1 = dxtop - (dxtop - dxbot) * (fullHeight + kaptonExtraHeight) / fullHeight;
261 h1 = 0.5 * kaptonThick;
262 dz = 0.5 * (kaptonHeight + kaptonExtraHeight);
268 ns.
addSolidNS(kaptonName[k] +
"Uncut", Trap(dz, 0., 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0));
271 dz = (dlHybrid > dlTop) ? 0.5 * dlTop : 0.5 * dlBottom;
272 h1 = 0.5 * kaptonThick;
273 bbl1 = fabs(dz *
sin(detTilt));
274 bbl2 = bbl1 * 0.000001;
275 double thet = atan((bbl1 - bbl2) / (2 * dz));
277 ns.
addSolidNS(kaptonName[k] +
"Cut", Trap(dz, thet, 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0));
280 name = kaptonName[
k];
281 rot = ns.
rotation(
"tidmodpar:9PYX");
282 xpos = -0.5 * fullHeight *
sin(detTilt);
283 zpos = 0.5 * kaptonHeight - bbl2;
285 ns.
addSolidNS(name, SubtractionSolid(solidUncut, solidCut, Transform3D(rot, Position(xpos, 0.0, zpos))));
287 name = kaptonName[
k];
288 solid = ns.
addSolidNS(name, Trap(dz, 0., 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0.));
292 LogDebug(
"TIDGeom") << solid.name() <<
" SUBTRACTION SOLID Trap made of " << kaptonMat <<
" of dimensions " << dz
293 <<
", 0, 0, " << h1 <<
", " << bbl1 <<
", " << bbl1 <<
", 0, " << h1 <<
", " << bbl2 <<
", " 297 name = holeKaptonName[
k];
298 dz = fullHeight - kaptonOver;
300 if (dlHybrid > dlTop) {
302 bbl1 = dxbot - kaptonWidth + kaptonOver * (dxtop - dxbot) / fullHeight;
303 bbl2 = dxtop - kaptonWidth;
304 zpos = 0.5 * (kaptonHeight - kaptonExtraHeight -
dz);
306 zpos -= 0.5 * kaptonOver * (1 -
cos(detTilt));
307 xpos = -0.5 * kaptonOver *
sin(detTilt);
311 bbl1 = dxbot - kaptonWidth;
312 bbl2 = dxtop - kaptonWidth - kaptonOver * (dxtop - dxbot) / fullHeight;
313 zpos = -0.5 * (kaptonHeight - kaptonExtraHeight -
dz);
316 solid = ns.
addSolidNS(name, Trap(dz, 0., 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0.));
317 LogDebug(
"TIDGeom") << solid.name() <<
" Trap made of " << genMat <<
" of dimensions " << dz <<
", 0, 0, " << h1
318 <<
", " << bbl1 <<
", " << bbl1 <<
", 0, " << h1 <<
", " << bbl2 <<
", " << bbl2 <<
", 0";
321 rot = ns.
rotation(holeKaptonRot[k]);
322 kapton.placeVolume(holeKapton, 1, Transform3D(rot, Position(xpos, 0.0, zpos)));
323 LogDebug(
"TIDGeom") << holeKapton.name() <<
" number 1 positioned in " << kapton.name() <<
" at (0,0," << zpos
324 <<
") with no rotation";
328 if (k == 0 && dlHybrid < dlTop) {
330 bl2 = 0.5 * dlBottom;
332 bl1 = 0.5 * dlBottom;
335 h1 = 0.5 * waferThick[
k];
336 dz = 0.5 * fullHeight;
337 solid = ns.
addSolidNS(name, Trap(dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0));
338 LogDebug(
"TIDGeom") << solid.name() <<
" Trap made of " << waferMat <<
" of dimensions " << dz <<
", 0, 0, " << h1
339 <<
", " << bl1 <<
", " << bl1 <<
", 0, " << h1 <<
", " << bl2 <<
", " << bl2 <<
", 0";
343 name = activeName[
k];
344 if (k == 0 && dlHybrid < dlTop) {
346 bl2 -= sideWidthBottom;
348 bl1 -= sideWidthBottom;
351 dz = 0.5 * (waferThick[
k] - backplaneThick[
k]);
352 h1 = 0.5 * activeHeight;
353 solid = ns.
addSolidNS(name, Trap(dz, 0, 0, h1, bl2, bl1, 0, h1, bl2, bl1, 0));
354 LogDebug(
"TIDGeom") << solid.name() <<
" Trap made of " << activeMat <<
" of dimensions " << dz <<
", 0, 0, " 355 << h1 <<
", " << bl2 <<
", " << bl1 <<
", 0, " << h1 <<
", " << bl2 <<
", " << bl1 <<
", 0";
358 Position tran(0.0, -0.5 * backplaneThick[k], 0.0);
359 wafer.placeVolume(active, 1, Transform3D(rot, tran));
360 LogDebug(
"TIDGeom") <<
"DDTIDModuleAlgo test: " << active.name() <<
" number 1 positioned in " << wafer.name()
361 <<
" at " << tran <<
" with " <<
rot;
365 if (dlHybrid > dlTop) {
372 dy = 0.5 * pitchThick;
373 dz = 0.5 * pitchHeight;
375 LogDebug(
"TIDGeom") << solid.name() <<
" Box made of " << pitchMat <<
" of dimensions" 376 <<
" " << dx <<
", " << dy <<
", " <<
dz;
378 h1 = 0.5 * pitchThick;
379 bl1 = 0.5 * pitchHeight + 0.5 * dz *
sin(detTilt);
380 bl2 = 0.5 * pitchHeight - 0.5 * dz *
sin(detTilt);
382 dz -= 0.5 * pitchStereoTol;
383 bl1 -= pitchStereoTol;
384 bl2 -= pitchStereoTol;
386 double thet = atan((bl1 - bl2) / (2. * dz));
387 solid = ns.
addSolidNS(name, Trap(dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0));
388 LogDebug(
"TIDGeom") << solid.name() <<
" Trap made of " << pitchMat <<
" of " 389 <<
"dimensions " << dz <<
", " <<
convertRadToDeg(thet) <<
", 0, " << h1 <<
", " << bl1
390 <<
", " << bl1 <<
", 0, " << h1 <<
", " << bl2 <<
", " << bl2 <<
", 0";
395 LogDebug(
"TIDGeom") <<
"<<== End of DDTIDModuleAlgo construction ...";
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
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.
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e, SensitiveDetector &)
Cos< T >::type cos(const T &t)
dd4hep::Material material(const std::string &name) const
Namespace of DDCMS conversion namespace.
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.
#define DECLARE_DDCMS_DETELEMENT(name, func)
std::string parentName() const
Access value of rParent child node.
std::string str(const std::string &nam) const
Shortcut to access string arguments.