1 #include "DD4hep/DetFactoryHelper.h" 14 string parentName =
args.parentName();
15 int detectorN =
args.integer(
"DetectorNumber");
16 double detTilt =
args.dble(
"DetTilt");
17 double fullHeight =
args.dble(
"FullHeight");
18 string boxFrameName =
args.str(
"BoxFrameName");
19 double boxFrameHeight =
args.dble(
"BoxFrameHeight");
20 double boxFrameWidth =
args.dble(
"BoxFrameWidth");
21 double dlTop =
args.dble(
"DlTop");
22 double dlBottom =
args.dble(
"DlBottom");
23 double dlHybrid =
args.dble(
"DlHybrid");
24 vector<double> boxFrameZ =
args.vecDble(
"BoxFrameZ");
25 double bottomFrameHeight =
args.dble(
"BottomFrameHeight");
26 double bottomFrameOver =
args.dble(
"BottomFrameOver");
27 double topFrameHeight =
args.dble(
"TopFrameHeight");
28 double topFrameOver =
args.dble(
"TopFrameOver");
30 vector<string> sideFrameName =
args.vecStr(
"SideFrameName");
31 vector<double> sideFrameZ =
args.vecDble(
"SideFrameZ");
32 vector<string> sideFrameRot =
args.vecStr(
34 double sideFrameWidth =
args.dble(
"SideFrameWidth");
35 double sideFrameOver =
args.dble(
"SideFrameOver");
37 vector<string> kaptonName =
args.vecStr(
"KaptonName");
38 vector<double> kaptonZ =
args.vecDble(
"KaptonZ");
39 vector<string> kaptonRot =
args.vecStr(
41 vector<string> waferName =
args.vecStr(
"WaferName");
42 vector<double> waferZ =
args.vecDble(
"WaferZ");
43 vector<string> waferRot =
args.vecStr(
"WaferRotation");
44 string hybridName =
args.str(
"HybridName");
45 double hybridHeight =
args.dble(
"HybridHeight");
46 vector<double> hybridZ =
args.vecDble(
"HybridZ");
47 vector<string> pitchName =
args.vecStr(
"PitchName");
48 double pitchHeight =
args.dble(
"PitchHeight");
49 vector<double> pitchZ =
args.vecDble(
"PitchZ");
50 vector<string> pitchRot =
args.vecStr(
"PitchRotation");
51 string coolName =
args.str(
"CoolInsertName");
52 double coolHeight =
args.dble(
"CoolInsertHeight");
53 double coolZ =
args.dble(
"CoolInsertZ");
54 double coolWidth =
args.dble(
"CoolInsertWidth");
55 vector<double> coolRadShift =
args.vecDble(
"CoolInsertShift");
58 ::toupper(
args.str(
"DoSpacers")[0]) !=
'N';
59 string botSpacersName =
args.str(
"BottomSpacersName");
60 double botSpacersHeight =
args.dble(
"BottomSpacersHeight");
61 double botSpacersZ =
args.dble(
"BottomSpacersZ");
62 string sidSpacersName =
args.str(
"SideSpacersName");
63 double sidSpacersHeight =
args.dble(
"SideSpacersHeight");
64 double sidSpacersZ =
args.dble(
"SideSpacersZ");
65 double sidSpacersWidth =
args.dble(
"SideSpacersWidth");
66 double sidSpacersRadShift =
args.dble(
"SideSpacersShift");
68 edm::LogVerbatim(
"TIDGeom") <<
"Parent " << parentName <<
" Detector Planes " << detectorN;
70 << dlTop <<
" dl(Bottom) " << dlBottom <<
" dl(Hybrid) " << dlHybrid;
72 for (
int i = 0;
i < detectorN;
i++)
74 edm::LogVerbatim(
"TIDGeom") <<
"\t Extra Height at Bottom " << bottomFrameHeight <<
" Overlap " << bottomFrameOver;
75 for (
int i = 0;
i < detectorN;
i++)
76 edm::LogVerbatim(
"TIDGeom") <<
"\tsideFrame[" <<
i <<
"] = " << sideFrameName[
i] <<
" positioned at Z " 77 << sideFrameZ[
i] <<
" with rotation " << sideFrameRot[
i];
78 for (
int i = 0;
i < detectorN;
i++)
79 edm::LogVerbatim(
"TIDGeom") <<
"\tkapton[" <<
i <<
"] = " << kaptonName[
i] <<
" positioned at Z " << kaptonZ[
i]
80 <<
" with rotation " << kaptonRot[
i];
81 for (
int i = 0;
i < detectorN;
i++)
82 edm::LogVerbatim(
"TIDGeom") << waferName[
i] <<
" positioned at Z " << waferZ[
i] <<
" with rotation " << waferRot[
i];
83 edm::LogVerbatim(
"TIDGeom") << hybridName <<
" Height " << hybridHeight <<
" Z";
84 for (
int i = 0;
i < detectorN;
i++)
87 for (
int i = 0;
i < detectorN;
i++)
88 edm::LogVerbatim(
"TIDGeom") << pitchName[
i] <<
" position at Z " << pitchZ[
i] <<
" with rotation " << pitchRot[
i];
94 if (dlHybrid > dlTop) {
96 topfr = topFrameHeight - pitchHeight - topFrameOver;
97 botfr = bottomFrameHeight - bottomFrameOver;
98 kaptonHeight = fullHeight + botfr;
101 topfr = topFrameHeight - topFrameOver;
102 botfr = bottomFrameHeight - bottomFrameOver - pitchHeight;
103 kaptonHeight = fullHeight + topfr;
106 double sideFrameHeight = fullHeight + pitchHeight + botfr + topfr;
107 double zCenter = 0.5 * (sideFrameHeight + boxFrameHeight);
110 double sidfr = sideFrameWidth - sideFrameOver;
111 double dxbot = 0.5 * dlBottom + sidfr;
112 double dxtop = 0.5 * dlTop + sidfr;
113 double dxtopenv, dxbotenv;
115 double tanWafer = (dxtop - dxbot) / fullHeight;
116 double thetaWafer = atan(tanWafer);
118 if (dlHybrid > dlTop) {
120 dxtopenv = dxbot + (dxtop - dxbot) * (fullHeight + pitchHeight + topfr + hybridHeight) / fullHeight;
121 dxbotenv = dxtop - (dxtop - dxbot) * (fullHeight + botfr) / fullHeight;
124 dxtopenv = dxbot + (dxtop - dxbot) * (fullHeight + topfr) / fullHeight;
128 double tanEnv = (dxtopenv - dxbotenv) / (sideFrameHeight + boxFrameHeight);
143 for (
int j1 = 0; j1 < 2; j1++) {
145 if (dlHybrid > dlTop) {
146 zCool = sideFrameHeight + boxFrameHeight - coolRadShift[j1];
148 zCool -= 0.5 * coolHeight;
150 zCool = coolRadShift[j1];
152 zCool += 0.5 * coolHeight;
156 xpos = -0.5 * (boxFrameWidth - coolWidth);
158 xpos = -(dxbotenv + (zCool - 0.5 * coolHeight) * tanEnv - 0.5 * coolWidth);
161 zpos = zCool - zCenter;
162 for (
int j2 = 0; j2 < 2; j2++) {
173 name = botSpacersName;
176 if (dlHybrid > dlTop) {
177 zBotSpacers = sideFrameHeight + boxFrameHeight - 0.5 * botSpacersHeight;
179 zBotSpacers = 0.5 * botSpacersHeight;
181 zpos = zBotSpacers - zCenter;
183 edm::LogVerbatim(
"TIDGeom") <<
name <<
" number " << 1 <<
" positioned in " << parentName <<
" at " 184 <<
Position(0.0, ypos, zpos) <<
" with no rotation";
186 name = sidSpacersName;
189 if (dlHybrid > dlTop) {
190 zSideSpacers = sideFrameHeight + boxFrameHeight - sidSpacersRadShift;
192 zSideSpacers = sidSpacersRadShift;
194 zpos = zSideSpacers - zCenter;
197 xpos = dxbotenv + (zSideSpacers - 0.5 * sidSpacersHeight) * tanEnv - 0.5 * sidSpacersWidth + sideFrameOver;
199 double phiy = 0e0, phiz = 0e0;
200 double phix = 0._deg;
205 double thetay = 90._deg;
206 double thetaz = thetaWafer;
208 for (
int j1 = 0; j1 < 2; j1++) {
211 thetax = 90._deg + thetaz;
222 for (
int k = 0;
k < detectorN;
k++) {
228 if (dlHybrid > dlTop) {
229 zWafer = botfr + 0.5 * fullHeight;
231 zWafer = boxFrameHeight + botfr + pitchHeight + 0.5 * fullHeight;
233 zpos = zWafer - zCenter;
237 parentVol.placeVolume(ns.
volume(
name),
k + 1, Transform3D(
rot, tran));
238 edm::LogVerbatim(
"TIDGeom") <<
name <<
" number " <<
k + 1 <<
" positioned in " << parentName <<
" at " << tran
246 xpos = 0.5 * fullHeight *
sin(detTilt);
250 if (dlHybrid > dlTop) {
251 zPitch = botfr + fullHeight + 0.5 * pitchHeight;
253 zPitch = boxFrameHeight + botfr + 0.5 * pitchHeight;
255 zpos = zPitch - zCenter;
258 parentVol.placeVolume(ns.
volume(
name),
k + 1, Transform3D(
rot, tran));
259 edm::LogVerbatim(
"TIDGeom") <<
name <<
" number " <<
k + 1 <<
" positioned in " << parentName <<
" at " << tran
266 if (dlHybrid > dlTop) {
267 zHybrid = botfr + fullHeight + pitchHeight + 0.5 * hybridHeight;
269 zHybrid = 0.5 * hybridHeight;
271 zpos = zHybrid - zCenter;
273 parentVol.placeVolume(ns.
volume(
name),
k + 1, tran);
274 edm::LogVerbatim(
"TIDGeom") <<
name <<
" number " <<
k + 1 <<
" positioned in " << parentName <<
" at " << tran;
280 if (dlHybrid > dlTop) {
281 zBoxFrame = sideFrameHeight + 0.5 * boxFrameHeight;
283 zBoxFrame = 0.5 * boxFrameHeight;
285 zpos = zBoxFrame - zCenter;
287 parentVol.placeVolume(ns.
volume(
name),
k + 1, tran);
288 edm::LogVerbatim(
"TIDGeom") <<
name <<
" number " <<
k + 1 <<
" positioned in " << parentName <<
" at " << tran;
291 name = sideFrameName[
k];
292 ypos = sideFrameZ[
k];
294 if (dlHybrid > dlTop) {
295 zSideFrame = 0.5 * sideFrameHeight;
297 zSideFrame = boxFrameHeight + 0.5 * sideFrameHeight;
299 zpos = zSideFrame - zCenter;
302 parentVol.placeVolume(ns.
volume(
name),
k + 1, Transform3D(
rot, tran));
303 edm::LogVerbatim(
"TIDGeom") <<
name <<
" number " <<
k + 1 <<
" positioned in " << parentName <<
" at " << tran
306 name = kaptonName[
k];
309 double kaptonExtraHeight = 0;
310 if (dlHybrid > dlTop) {
312 kaptonExtraHeight = dlTop *
sin(detTilt) - fullHeight * (1 -
cos(detTilt));
313 kaptonExtraHeight = 0.5 * fabs(kaptonExtraHeight);
314 zKapton = 0.5 * (kaptonHeight + kaptonExtraHeight);
317 kaptonExtraHeight = dlBottom *
sin(detTilt) - fullHeight * (1 -
cos(detTilt));
318 kaptonExtraHeight = 0.5 * fabs(kaptonExtraHeight);
319 zKapton = boxFrameHeight + sideFrameHeight - 0.5 * (kaptonHeight + kaptonExtraHeight);
321 zpos = zKapton - zCenter;
324 parentVol.placeVolume(ns.
volume(
name),
k + 1, Transform3D(
rot, tran));
325 edm::LogVerbatim(
"TIDGeom") <<
name <<
" number " <<
k + 1 <<
" positioned in " << parentName <<
" at " << tran
328 edm::LogVerbatim(
"TIDGeom") <<
"<<== End of DDTIDModulePosAlgo positioning ...";
Log< level::Info, true > LogVerbatim
const dd4hep::Rotation3D & rotation(const std::string &name) const
constexpr NumType convertRadToDeg(NumType radians)
Sin< T >::type sin(const T &t)
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
#define DECLARE_DDCMS_DETELEMENT(name, func)
Cos< T >::type cos(const T &t)
Namespace of DDCMS conversion namespace.
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e)
dd4hep::Volume volume(const std::string &name, bool exc=true) const