1 #include "DD4hep/DetFactoryHelper.h" 19 string genMat = args.
str(
"GeneralMaterial");
20 int detectorN = args.
integer(
"DetectorNumber");
21 double moduleThick = args.
dble(
"ModuleThick");
22 double detTilt = args.
dble(
"DetTilt");
23 double fullHeight = args.
dble(
"FullHeight");
24 double dlTop = args.
dble(
"DlTop");
25 double dlBottom = args.
dble(
"DlBottom");
26 double dlHybrid = args.
dble(
"DlHybrid");
27 bool doComponents = ::toupper(args.
str(
"DoComponents")[0]) !=
'N';
29 string boxFrameName = args.
str(
"BoxFrameName");
30 string boxFrameMat = args.
str(
"BoxFrameMaterial");
31 double boxFrameHeight = args.
dble(
"BoxFrameHeight");
32 double boxFrameThick = args.
dble(
"BoxFrameThick");
33 double boxFrameWidth = args.
dble(
"BoxFrameWidth");
34 double bottomFrameHeight = args.
dble(
"BottomFrameHeight");
35 double bottomFrameOver = args.
dble(
"BottomFrameOver");
36 double topFrameHeight = args.
dble(
"TopFrameHeight");
37 double topFrameOver = args.
dble(
"TopFrameOver");
38 vector<string> sideFrameName = args.
vecStr(
"SideFrameName");
39 string sideFrameMat = args.
str(
"SideFrameMaterial");
40 double sideFrameWidth = args.
dble(
"SideFrameWidth");
41 double sideFrameThick = args.
dble(
"SideFrameThick");
42 double sideFrameOver = args.
dble(
"SideFrameOver");
43 vector<string> holeFrameName = args.
vecStr(
"HoleFrameName");
44 vector<string> holeFrameRot = args.
vecStr(
"HoleFrameRotation");
46 vector<string> kaptonName = args.
vecStr(
"KaptonName");
47 string kaptonMat = args.
str(
"KaptonMaterial");
48 double kaptonThick = args.
dble(
"KaptonThick");
49 double kaptonOver = args.
dble(
"KaptonOver");
50 vector<string> holeKaptonName = args.
vecStr(
"HoleKaptonName");
51 vector<string> holeKaptonRot = args.
vecStr(
"HoleKaptonRotation");
53 vector<string> waferName = args.
vecStr(
"WaferName");
54 string waferMat = args.
str(
"WaferMaterial");
55 double sideWidthTop = args.
dble(
"SideWidthTop");
56 double sideWidthBottom = args.
dble(
"SideWidthBottom");
57 vector<string> activeName = args.
vecStr(
"ActiveName");
58 string activeMat = args.
str(
"ActiveMaterial");
59 double activeHeight = args.
dble(
"ActiveHeight");
60 vector<double> waferThick = args.
vecDble(
"WaferThick");
61 string activeRot = args.
str(
"ActiveRotation");
62 vector<double> backplaneThick = args.
vecDble(
"BackPlaneThick");
63 string hybridName = args.
str(
"HybridName");
64 string hybridMat = args.
str(
"HybridMaterial");
65 double hybridHeight = args.
dble(
"HybridHeight");
66 double hybridWidth = args.
dble(
"HybridWidth");
67 double hybridThick = args.
dble(
"HybridThick");
68 vector<string> pitchName = args.
vecStr(
"PitchName");
69 string pitchMat = args.
str(
"PitchMaterial");
70 double pitchHeight = args.
dble(
"PitchHeight");
71 double pitchThick = args.
dble(
"PitchThick");
72 double pitchStereoTol = args.
dble(
"PitchStereoTolerance");
73 string coolName = args.
str(
"CoolInsertName");
74 string coolMat = args.
str(
"CoolInsertMaterial");
75 double coolHeight = args.
dble(
"CoolInsertHeight");
76 double coolThick = args.
dble(
"CoolInsertThick");
77 double coolWidth = args.
dble(
"CoolInsertWidth");
79 LogDebug(
"TIDGeom") <<
"Parent " << mother
80 <<
" General Material " << genMat
81 <<
" Detector Planes " << detectorN;
83 LogDebug(
"TIDGeom") <<
"ModuleThick " 85 <<
" Height " << fullHeight <<
" dl(Top) " << dlTop
86 <<
" dl(Bottom) " << dlBottom <<
" dl(Hybrid) " 87 << dlHybrid <<
" doComponents " << doComponents;
88 LogDebug(
"TIDGeom") <<
"" << boxFrameName
89 <<
" Material " << boxFrameMat <<
" Thickness " 90 << boxFrameThick <<
" width " << boxFrameWidth
91 <<
" height " << boxFrameHeight
92 <<
" Extra Height at Bottom " << bottomFrameHeight
93 <<
" Overlap " << bottomFrameOver;
95 for (
int i = 0;
i < detectorN;
i++)
97 <<
" Material " << sideFrameMat <<
" Width " 98 << sideFrameWidth <<
" Thickness " << sideFrameThick
99 <<
" Overlap " << sideFrameOver <<
" Hole " 102 for (
int i = 0;
i < detectorN;
i++)
104 <<
" Material " << kaptonMat
105 <<
" Thickness " << kaptonThick
106 <<
" Overlap " << kaptonOver <<
" Hole " 107 << holeKaptonName[
i];
109 LogDebug(
"TIDGeom") <<
"Wafer Material " 110 << waferMat <<
" Side Width Top " << sideWidthTop
111 <<
" Side Width Bottom " << sideWidthBottom;
112 for (
int i = 0;
i < detectorN;
i++)
113 LogDebug(
"TIDGeom") <<
"\twaferName[" <<
i <<
"] = " << waferName[
i];
115 LogDebug(
"TIDGeom") <<
"Active Material " 116 << activeMat <<
" Height " << activeHeight
117 <<
" rotated by " << activeRot;
118 for (
int i = 0;
i < detectorN;
i++)
119 LogDebug(
"TIDGeom") <<
" translated by (0," << -0.5*backplaneThick[
i]
120 <<
",0)\tactiveName[" <<
i <<
"] = " << activeName[
i]
121 <<
" of thickness " << waferThick[
i]-backplaneThick[
i];
123 LogDebug(
"TIDGeom") <<
"" << hybridName
124 <<
" Material " << hybridMat <<
" Height " 125 << hybridHeight <<
" Width " << hybridWidth
126 <<
" Thickness " << hybridThick;
127 LogDebug(
"TIDGeom") <<
"Pitch Adapter Material " 128 << pitchMat <<
" Height " << pitchHeight
129 <<
" Thickness " << pitchThick;
130 for (
int i = 0;
i < detectorN;
i++)
131 LogDebug(
"TIDGeom") <<
"\tpitchName[" <<
i <<
"] = " << pitchName[
i];
132 LogDebug(
"TIDGeom") <<
"Cool Element Material " 133 << coolMat <<
" Height " << coolHeight
134 <<
" Thickness " << coolThick <<
" Width " << coolWidth;
136 string name = mother;
137 double sidfr = sideFrameWidth - sideFrameOver;
141 if (dlHybrid > dlTop) {
143 topfr = topFrameHeight - pitchHeight - topFrameOver;
144 botfr = bottomFrameHeight - bottomFrameOver;
145 kaptonHeight = fullHeight + botfr;
148 topfr = topFrameHeight - topFrameOver;
149 botfr = bottomFrameHeight - bottomFrameOver - pitchHeight;
150 kaptonHeight = fullHeight + topfr;
153 double sideFrameHeight = fullHeight + pitchHeight + botfr + topfr;
154 double kaptonWidth = sidfr + kaptonOver;
156 double dxbot = 0.5*dlBottom + sidfr;
157 double dxtop = 0.5*dlTop + sidfr;
158 double dxtopenv, dxbotenv;
161 if (dlHybrid > dlTop) {
163 dxtopenv = dxbot + (dxtop-dxbot)*(fullHeight+pitchHeight+topfr+hybridHeight)/fullHeight;
164 dxbotenv = dxtop - (dxtop-dxbot)*(fullHeight+botfr)/fullHeight;
167 dxtopenv = dxbot + (dxtop-dxbot)*(fullHeight+topfr)/fullHeight;
170 double bl1 = dxbotenv;
171 double bl2 = dxtopenv;
172 double h1 = 0.5 * moduleThick;
174 double dz = 0.5 * (boxFrameHeight + sideFrameHeight);
176 Solid solid = ns.
addSolidNS(name,Trap(dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0));
179 <<
" Trap made of " << genMat <<
" of dimensions " << dz
180 <<
", 0, 0, " << h1 <<
", " << bl1 <<
", " << bl1
181 <<
", 0, " << h1 <<
", " << bl2 <<
", " << bl2
188 dx = 0.5 * boxFrameWidth;
189 dy = 0.5 * boxFrameThick;
190 dz = 0.5 * boxFrameHeight;
193 <<
" Box made of " << boxFrameMat <<
" of dimensions " 194 << dx <<
", " << dy <<
", " <<
dz;
200 dx = 0.5 * hybridWidth;
201 dy = 0.5 * hybridThick;
202 dz = 0.5 * hybridHeight;
205 <<
" Box made of " << hybridMat <<
" of dimensions " 206 << dx <<
", " << dy <<
", " <<
dz;
211 dx = 0.5 * coolWidth;
212 dy = 0.5 * coolThick;
213 dz = 0.5 * coolHeight;
216 <<
" Box made of " << coolMat <<
" of dimensions " 217 << dx <<
", " << dy <<
", " <<
dz;
221 for (
int k = 0;
k < detectorN;
k++) {
224 name = sideFrameName[
k];
225 if (dlHybrid > dlTop) {
227 bbl1 = dxtop - (dxtop-dxbot)*(fullHeight+botfr)/fullHeight;
228 bbl2 = dxbot + (dxtop-dxbot)*(fullHeight+pitchHeight+topfr)/fullHeight;
231 bbl1 = dxtop - (dxtop-dxbot)*(fullHeight+pitchHeight+botfr)/fullHeight;
232 bbl2 = dxbot + (dxtop-dxbot)*(fullHeight+topfr)/fullHeight;
234 h1 = 0.5 * sideFrameThick;
235 dz = 0.5 * sideFrameHeight;
236 solid = ns.
addSolidNS(name,Trap(dz, 0., 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0.));
238 <<
" Trap made of " << sideFrameMat <<
" of dimensions " 239 << dz <<
", 0, 0, " << h1 <<
", " << bbl1 <<
", " 240 << bbl1 <<
", 0, " << h1 <<
", " << bbl2 <<
", " 248 name = holeFrameName[
k];
250 dz = fullHeight - bottomFrameOver - topFrameOver;
251 bbl1 = dxbot - sideFrameWidth + bottomFrameOver*(dxtop-dxbot)/fullHeight;
252 bbl2 = dxtop - sideFrameWidth - topFrameOver*(dxtop-dxbot)/fullHeight;
253 if (dlHybrid > dlTop) {
255 zpos = -(topFrameHeight+0.5*dz-0.5*sideFrameHeight);
258 zpos = bottomFrameHeight+0.5*dz-0.5*sideFrameHeight;
261 solid = ns.
addSolidNS(name,Trap(dz, 0,0, h1,bbl1,bbl1, 0, h1,bbl2,bbl2, 0));
263 <<
" Trap made of " << genMat <<
" of dimensions " 264 << dz <<
", 0, 0, " << h1 <<
", " << bbl1 <<
", " 265 << bbl1 <<
", 0, " << h1 <<
", " << bbl2 <<
", " 270 sideFrame.placeVolume(holeFrame,1,Transform3D(rot,Position(0e0,0e0,zpos)));
271 LogDebug(
"TIDGeom") << holeFrame.name()
272 <<
" number 1 positioned in " << sideFrame.name()
273 <<
" at (0,0," << zpos <<
") with no rotation";
276 double kaptonExtraHeight=0;
277 if (dlHybrid > dlTop) {
279 bbl1 = dxtop - (dxtop-dxbot)*(fullHeight+botfr)/fullHeight;
281 kaptonExtraHeight = dlTop*
sin(detTilt)-fullHeight*(1-
cos(detTilt));
282 kaptonExtraHeight = 0.5*fabs(kaptonExtraHeight);
283 bbl2 = dxbot + (dxtop-dxbot)*(fullHeight+kaptonExtraHeight)/fullHeight;
290 bbl2 = dxbot + (dxtop-dxbot)*(fullHeight+topfr)/fullHeight;
292 kaptonExtraHeight = dlBottom*
sin(detTilt)-fullHeight*(1-
cos(detTilt));
293 kaptonExtraHeight = 0.5*fabs(kaptonExtraHeight);
294 bbl1 = dxtop - (dxtop-dxbot)*(fullHeight+kaptonExtraHeight)/fullHeight;
299 h1 = 0.5 * kaptonThick;
300 dz = 0.5 * (kaptonHeight+kaptonExtraHeight);
305 Solid solidUncut = ns.
addSolidNS(kaptonName[k]+
"Uncut",Trap(dz, 0., 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0));
308 dz = (dlHybrid > dlTop) ? 0.5 * dlTop : 0.5 * dlBottom;
309 h1 = 0.5 * kaptonThick;
310 bbl1 = fabs(dz*
sin(detTilt));
311 bbl2 = bbl1*0.000001;
312 double thet = atan((bbl1-bbl2)/(2*dz));
313 Solid solidCut = ns.
addSolidNS(kaptonName[k]+
"Cut",Trap(dz, thet, 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0));
316 name = kaptonName[
k];
317 rot = ns.
rotation(
"tidmodpar:9PYX");
318 xpos = -0.5 * fullHeight *
sin(detTilt);
319 zpos = 0.5 * kaptonHeight - bbl2;
320 solid = ns.
addSolidNS(name,SubtractionSolid(solidUncut, solidCut, Transform3D(rot,Position(xpos,0.0,zpos))));
322 name = kaptonName[
k];
323 solid = ns.
addSolidNS(name,Trap(dz, 0., 0., h1, bbl1, bbl1, 0., h1, bbl2, bbl2, 0.));
328 <<
" SUBTRACTION SOLID Trap made of " << kaptonMat
329 <<
" of dimensions " << dz <<
", 0, 0, " << h1
330 <<
", " << bbl1 <<
", " << bbl1 <<
", 0, " << h1
331 <<
", " << bbl2 <<
", " << bbl2 <<
", 0";
334 name = holeKaptonName[
k];
335 dz = fullHeight - kaptonOver;
337 if (dlHybrid > dlTop) {
339 bbl1 = dxbot - kaptonWidth + kaptonOver*(dxtop-dxbot)/fullHeight;
340 bbl2 = dxtop - kaptonWidth;
341 zpos = 0.5*(kaptonHeight-kaptonExtraHeight-
dz);
343 zpos -= 0.5*kaptonOver*(1-
cos(detTilt));
344 xpos = -0.5*kaptonOver*
sin(detTilt);
348 bbl1 = dxbot - kaptonWidth;
349 bbl2 = dxtop - kaptonWidth - kaptonOver*(dxtop-dxbot)/fullHeight;
350 zpos = -0.5*(kaptonHeight-kaptonExtraHeight-
dz);
353 solid = ns.
addSolidNS(name,Trap(dz,0.,0., h1,bbl1,bbl1, 0., h1,bbl2,bbl2, 0.));
355 <<
" Trap made of " << genMat <<
" of dimensions " 356 << dz <<
", 0, 0, " << h1 <<
", " << bbl1 <<
", " 357 << bbl1 <<
", 0, " << h1 <<
", " << bbl2 <<
", " 361 rot = ns.
rotation(holeKaptonRot[k]);
362 kapton.placeVolume(holeKapton, 1, Transform3D(rot,Position(xpos, 0.0, zpos)));
363 LogDebug(
"TIDGeom") << holeKapton.name()
364 <<
" number 1 positioned in " << kapton.name()
365 <<
" at (0,0," << zpos <<
") with no rotation";
369 if (k == 0 && dlHybrid < dlTop) {
371 bl2 = 0.5 * dlBottom;
373 bl1 = 0.5 * dlBottom;
376 h1 = 0.5 * waferThick[
k];
377 dz = 0.5 * fullHeight;
378 solid = ns.
addSolidNS(name,Trap(dz, 0,0, h1,bl1,bl1,0, h1,bl2,bl2,0));
380 <<
" Trap made of " << waferMat <<
" of dimensions " 381 << dz <<
", 0, 0, " << h1 <<
", " << bl1 <<
", " 382 << bl1 <<
", 0, " << h1 <<
", " << bl2 <<
", " 387 name = activeName[
k];
388 if (k == 0 && dlHybrid < dlTop) {
390 bl2 -= sideWidthBottom;
393 bl1 -= sideWidthBottom;
396 dz = 0.5 * (waferThick[
k] - backplaneThick[
k]);
397 h1 = 0.5 * activeHeight;
398 solid = ns.
addSolidNS(name,Trap(dz, 0,0, h1,bl2,bl1,0, h1,bl2,bl1,0));
400 <<
" Trap made of " << activeMat <<
" of dimensions " 401 << dz <<
", 0, 0, " << h1 <<
", " << bl2 <<
", " 402 << bl1 <<
", 0, " << h1 <<
", " << bl2 <<
", " 406 Position tran(0.0,-0.5 * backplaneThick[k],0.0);
407 wafer.placeVolume(active, 1, Transform3D(rot,tran));
408 LogDebug(
"TIDGeom") <<
"DDTIDModuleAlgo test: " << active.name()
409 <<
" number 1 positioned in " << wafer.name()
410 <<
" at " << tran <<
" with " <<
rot;
414 if (dlHybrid > dlTop) {
421 dy = 0.5 * pitchThick;
422 dz = 0.5 * pitchHeight;
425 <<
" Box made of " << pitchMat <<
" of dimensions" 426 <<
" " << dx <<
", " << dy <<
", " <<
dz;
428 h1 = 0.5 * pitchThick;
429 bl1 = 0.5 * pitchHeight + 0.5 * dz *
sin(detTilt);
430 bl2 = 0.5 * pitchHeight - 0.5 * dz *
sin(detTilt);
432 dz -=0.5*pitchStereoTol;
436 double thet = atan((bl1-bl2)/(2.*dz));
437 solid = ns.
addSolidNS(name,Trap(dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0));
439 <<
" Trap made of " << pitchMat <<
" of " 441 <<
", 0, " << h1 <<
", " << bl1 <<
", " << bl1
442 <<
", 0, " << h1 <<
", " << bl2 <<
", " << bl2
448 LogDebug(
"TIDGeom") <<
"<<== End of DDTIDModuleAlgo construction ...";
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
Sin< T >::type sin(const T &t)
constexpr NumType convertRadToDeg(NumType radians)
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e, SensitiveDetector &)
int integer(const std::string &nam) const
Shortcut to access integer arguments.
Cos< T >::type cos(const T &t)
dd4hep::Material material(const std::string &name) const
Namespace of DDCMS conversion namespace.
#define DECLARE_DDCMS_DETELEMENT(name, func)
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.