CMS 3D CMS Logo

DDTECModuleAlgo.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
5 
6 using namespace std;
7 using namespace dd4hep;
8 using namespace cms;
9 using namespace cms_units::operators;
10 
11 static long algorithm(Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e, SensitiveDetector& /* sens */) {
12  cms::DDNamespace ns(ctxt, e, true);
13  DDAlgoArguments args(ctxt, e);
14  Volume mother = ns.volume(args.parentName());
15 
16  //variables:
17  //double noOverlapShift = args.value<double>("NoOverlapShift");
18  int ringNo = args.value<int>("RingNo");
19  bool isStereo = args.value<int>("isStereo") == 1;
20  bool isRing6 = (ringNo == 6);
21  double rPos =
22  args.value<double>("RPos"); //Position in R relativ to the center of the TEC ( this is the coord-sys of Tubs)
23  double posCorrectionPhi = isStereo ? args.value<double>("PosCorrectionPhi")
24  : 0e0; // the Phi position of the stereo Modules has to be corrected
25  string standardRot = args.value<string>(
26  "StandardRotation"); //Rotation that aligns the mother(Tub ) coordinate System with the components
27  string genMat = args.value<string>("GeneralMaterial"); //General material name
28  double moduleThick = args.value<double>("ModuleThick"); //Module thickness
29  double detTilt = args.value<double>("DetTilt"); //Tilt of stereo detector
30  double fullHeight = args.value<double>("FullHeight"); //Height
31  double dlTop = args.value<double>("DlTop"); //Width at top of wafer
32  double dlBottom = args.value<double>("DlBottom"); //Width at bottom of wafer
33  double dlHybrid = args.value<double>("DlHybrid"); //Width at the hybrid end
34  double frameWidth = args.value<double>("FrameWidth"); //Frame width
35  double frameThick = args.value<double>("FrameThick"); // thickness
36  double frameOver = args.value<double>("FrameOver"); // overlap (on sides)
37  string topFrameMat = args.value<string>("TopFrameMaterial"); //Top frame material
38  double topFrameHeight = args.value<double>("TopFrameHeight"); // height
39  double topFrameThick = args.value<double>("TopFrameThick"); // thickness
40  double topFrameTopWidth = args.value<double>("TopFrameTopWidth"); // Width at the top
41  double topFrameBotWidth = args.value<double>("TopFrameBotWidth"); // Width at the bottom
42  double topFrame2Width = isStereo ? args.value<double>("TopFrame2Width") : 0e0; // Stereo:2ndPart Width
43  double topFrame2LHeight = isStereo ? args.value<double>("TopFrame2LHeight") : 0e0; // left height
44  double topFrame2RHeight = isStereo ? args.value<double>("TopFrame2RHeight") : 0e0; // right height
45  double topFrameZ = args.value<double>("TopFrameZ"); // z-positions
46 
47  double resizeH = 0.96;
48  string sideFrameMat = args.value<string>("SideFrameMaterial"); //Side frame material
49  double sideFrameThick = args.value<double>("SideFrameThick"); // thickness
50  double sideFrameLWidth = args.value<double>("SideFrameLWidth"); // Left Width (for stereo modules upper one)
51  double sideFrameLWidthLow = isStereo ? args.value<double>("SideFrameLWidthLow")
52  : 0e0; // Width (only for stereo modules: lower Width)
53  double sideFrameLHeight = resizeH * args.value<double>("SideFrameLHeight"); // Height
54  double sideFrameLtheta = args.value<double>("SideFrameLtheta"); // angle of the trapezoid shift
55  double sideFrameRWidth = args.value<double>("SideFrameRWidth"); // Right Width (for stereo modules upper one)
56  double sideFrameRWidthLow = isStereo ? args.value<double>("SideFrameRWidthLow")
57  : 0e0; // Width (only for stereo modules: lower Width)
58  double sideFrameRHeight = resizeH * args.value<double>("SideFrameRHeight"); // Height
59  double sideFrameRtheta = args.value<double>("SideFrameRtheta"); // angle of the trapezoid shift
60  vector<double> siFrSuppBoxWidth = args.value<vector<double> >("SiFrSuppBoxWidth"); // Supp.Box Width
61  vector<double> siFrSuppBoxHeight = args.value<vector<double> >("SiFrSuppBoxHeight"); // Height
62  vector<double> siFrSuppBoxYPos = args.value<vector<double> >(
63  "SiFrSuppBoxYPos"); // y-position of the supplies box (with HV an thermal sensor...)
64  double sideFrameZ = args.value<double>("SideFrameZ"); // z-positions
65  double siFrSuppBoxThick = args.value<double>("SiFrSuppBoxThick"); // thickness
66  string siFrSuppBoxMat = args.value<string>("SiFrSuppBoxMaterial"); // material
67  string waferMat = args.value<string>("WaferMaterial"); //Wafer material
68  double waferPosition = args.value<double>(
69  "WaferPosition"); // position of the wafer (was formaly done by adjusting topFrameHeigt)
70  double sideWidthTop = args.value<double>("SideWidthTop"); // widths on the side Top
71  double sideWidthBottom = args.value<double>("SideWidthBottom"); // Bottom
72  string waferRot = args.value<string>("WaferRotation"); // rotation matrix
73  string activeMat = args.value<string>("ActiveMaterial"); //Sensitive material
74  double activeHeight = args.value<double>("ActiveHeight"); // height
75  double waferThick = args.value<double>("WaferThick"); // wafer thickness (active = wafer - backplane)
76  string activeRot = args.value<string>("ActiveRotation"); // Rotation matrix
77  double activeZ = args.value<double>("ActiveZ"); // z-positions
78  double backplaneThick = args.value<double>("BackPlaneThick"); // thickness
79  double inactiveDy = ringNo > 3 ? args.value<double>("InactiveDy") : 0e0; //InactiveStrip Hight of ( rings > 3)
80  double inactivePos = ringNo > 3 ? args.value<double>("InactivePos") : 0e0; // y-Position
81  string inactiveMat = ringNo > 3 ? args.value<string>("InactiveMaterial") : string(); // material
82  string hybridMat = args.value<string>("HybridMaterial"); //Hybrid material
83  double hybridHeight = args.value<double>("HybridHeight"); // height
84  double hybridWidth = args.value<double>("HybridWidth"); // width
85  double hybridThick = args.value<double>("HybridThick"); // thickness
86  double hybridZ = args.value<double>("HybridZ"); // z-positions
87  string pitchMat = args.value<string>("PitchMaterial"); //Pitch adapter material
88  double pitchWidth = args.value<double>("PitchWidth"); // width
89  double pitchHeight = args.value<double>("PitchHeight"); // height
90  double pitchThick = args.value<double>("PitchThick"); // thickness
91  double pitchZ = args.value<double>("PitchZ"); // z-positions
92  string pitchRot = args.value<string>("PitchRotation"); // rotation matrix
93  string bridgeMat = args.value<string>("BridgeMaterial"); //Bridge material
94  double bridgeWidth = args.value<double>("BridgeWidth"); // width
95  double bridgeThick = args.value<double>("BridgeThick"); // thickness
96  double bridgeHeight = args.value<double>("BridgeHeight"); // height
97  double bridgeSep = args.value<double>("BridgeSeparation"); // separation
98  vector<double> siReenforceHeight = args.value<vector<double> >("SiReenforcementHeight"); // SiReenforcement Height
99  vector<double> siReenforceWidth = args.value<vector<double> >("SiReenforcementWidth"); // Width
100  vector<double> siReenforceYPos = args.value<vector<double> >("SiReenforcementPosY"); // Y - Position
101  double siReenforceThick = args.value<double>("SiReenforcementThick"); // Thick
102  string siReenforceMat = args.value<string>("SiReenforcementMaterial"); // Materieal
103 
104  edm::LogVerbatim("TECGeom") << "debug: ModuleThick " << moduleThick << " Detector Tilt " << convertRadToDeg(detTilt)
105  << " Height " << fullHeight << " dl(Top) " << dlTop << " dl(Bottom) " << dlBottom
106  << " dl(Hybrid) " << dlHybrid << " rPos " << rPos << " standrad rotation " << standardRot;
107  edm::LogVerbatim("TECGeom") << "debug: Frame Width " << frameWidth << " Thickness " << frameThick << " Overlap "
108  << frameOver;
109  edm::LogVerbatim("TECGeom") << "debug: Top Frame Material " << topFrameMat << " Height " << topFrameHeight
110  << " Top Width " << topFrameTopWidth << " Bottom Width " << topFrameTopWidth
111  << " Thickness " << topFrameThick << " positioned at" << topFrameZ;
112  edm::LogVerbatim("TECGeom") << "debug : Side Frame Material " << sideFrameMat << " Thickness " << sideFrameThick
113  << " left Leg's Width: " << sideFrameLWidth << " left Leg's Height: " << sideFrameLHeight
114  << " left Leg's tilt(theta): " << sideFrameLtheta
115  << " right Leg's Width: " << sideFrameRWidth
116  << " right Leg's Height: " << sideFrameRHeight
117  << " right Leg's tilt(theta): " << sideFrameRtheta
118  << "Supplies Box's Material: " << siFrSuppBoxMat << " positioned at" << sideFrameZ;
119  for (int i = 0; i < (int)(siFrSuppBoxWidth.size()); i++)
120  edm::LogVerbatim("TECGeom") << " Supplies Box" << i << "'s Width: " << siFrSuppBoxWidth[i] << " Supplies Box" << i
121  << "'s Height: " << siFrSuppBoxHeight[i] << " Supplies Box" << i
122  << "'s y Position: " << siFrSuppBoxYPos[i];
123  edm::LogVerbatim("TECGeom") << "debug: Wafer Material " << waferMat << " Side Width Top" << sideWidthTop
124  << " Side Width Bottom" << sideWidthBottom << " and positioned at " << waferPosition
125  << " positioned with rotation"
126  << " matrix:" << waferRot;
127  edm::LogVerbatim("TECGeom") << "debug: Active Material " << activeMat << " Height " << activeHeight << " rotated by "
128  << activeRot << " translated by (0,0," << -0.5 * backplaneThick << ")"
129  << " Thickness/Z" << waferThick - backplaneThick << "/" << activeZ;
130  edm::LogVerbatim("TECGeom") << "debug: Hybrid Material " << hybridMat << " Height " << hybridHeight << " Width "
131  << hybridWidth << " Thickness " << hybridThick << " Z" << hybridZ;
132  edm::LogVerbatim("TECGeom") << "debug: Pitch Adapter Material " << pitchMat << " Height " << pitchHeight
133  << " Thickness " << pitchThick << " position with "
134  << " rotation " << pitchRot << " at Z" << pitchZ;
135  edm::LogVerbatim("TECGeom") << "debug: Bridge Material " << bridgeMat << " Width " << bridgeWidth << " Thickness "
136  << bridgeThick << " Height " << bridgeHeight << " Separation " << bridgeSep;
137  edm::LogVerbatim("TECGeom") << "FALTBOOT DDTECModuleAlgo debug : Si-Reenforcement Material " << sideFrameMat
138  << " Thickness " << siReenforceThick;
139  for (int i = 0; i < (int)(siReenforceWidth.size()); i++)
140  edm::LogVerbatim("TECGeom") << " SiReenforcement" << i << "'s Width: " << siReenforceWidth[i] << " SiReenforcement"
141  << i << "'s Height: " << siReenforceHeight[i] << " SiReenforcement" << i
142  << "'s y Position: " << siReenforceYPos[i];
143 
144  if (!isStereo) {
145  edm::LogVerbatim("TECGeom") << "This is a normal module, in ring " << ringNo << "!";
146  } else {
147  edm::LogVerbatim("TECGeom") << "This is a stereo module, in ring " << ringNo << "!";
148  edm::LogVerbatim("TECGeom") << "Phi Position corrected by " << posCorrectionPhi << "*rad";
149  edm::LogVerbatim("TECGeom") << "debug: stereo Top Frame 2nd Part left Heigt " << topFrame2LHeight
150  << " right Height " << topFrame2RHeight << " Width " << topFrame2Width;
151  edm::LogVerbatim("TECGeom") << " left Leg's lower Width: " << sideFrameLWidthLow
152  << " right Leg's lower Width: " << sideFrameRWidthLow;
153  }
154 
155  // Execution part:
156 
157  edm::LogVerbatim("TECGeom") << "==>> Constructing DDTECModuleAlgo: ";
158  //declarations
159  double tmp;
160  //names
161  string name;
162  string tag("Rphi");
163  if (isStereo)
164  tag = "Stereo";
165  //usefull constants
166  const double topFrameEndZ = 0.5 * (-waferPosition + fullHeight) + pitchHeight + hybridHeight - topFrameHeight;
167  string idName = ns.prepend(ns.realName(mother.name()));
168  edm::LogVerbatim("TECGeom") << "idName: " << idName << " parent " << mother.name() << " namespace " << ns.name();
169  Solid solid;
170 
171  //set global parameters
172  Material matter = ns.material(genMat);
173  double dzdif = fullHeight + topFrameHeight;
174  if (isStereo)
175  dzdif += 0.5 * (topFrame2LHeight + topFrame2RHeight);
176 
177  double dxbot = 0.5 * dlBottom + frameWidth - frameOver;
178  double dxtop = 0.5 * dlHybrid + frameWidth - frameOver;
179  // topfr = 0.5*dlBottom * sin(detTilt);
180  if (isRing6) {
181  dxbot = dxtop;
182  dxtop = 0.5 * dlTop + frameWidth - frameOver;
183  // topfr = 0.5*dlTop * sin(detTilt);
184  }
185  double dxdif = dxtop - dxbot;
186 
187  //Frame Sides
188  // left Frame
189  name = idName + "SideFrameLeft";
190  double h1 = 0.5 * sideFrameThick;
191  double dz = 0.5 * sideFrameLHeight;
192  double bl1 = 0.5 * sideFrameLWidth;
193  double bl2 = bl1;
194  double thet = sideFrameLtheta;
195  //for stereo modules
196  if (isStereo)
197  bl1 = 0.5 * sideFrameLWidthLow;
198  solid = Trap(dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
199  ns.addSolidNS(name, solid);
200  edm::LogVerbatim("TECGeom") << "Solid: " << name << " " << solid.name() << " Trap made of " << sideFrameMat
201  << " of dimensions " << dz << ", " << thet << ", 0, " << h1 << ", " << bl1 << ", " << bl1
202  << ", 0, " << h1 << ", " << bl2 << ", " << bl2 << ", 0";
203  Volume sideFrameLeft(name, solid, ns.material(sideFrameMat));
204  ns.addVolumeNS(sideFrameLeft);
205  //translate
206  double xpos = -0.5 * topFrameBotWidth + bl2 + tan(fabs(thet)) * dz;
207  double ypos = sideFrameZ;
208  double zpos = topFrameEndZ - dz;
209  //flip ring 6
210  if (isRing6) {
211  zpos *= -1;
212  xpos -= 2 * tan(fabs(thet)) * dz; // because of the flip the tan(..) to be in the other direction
213  }
214  //the stereo modules are on the back of the normal ones...
215  if (isStereo) {
216  xpos = -0.5 * topFrameBotWidth + bl2 * cos(detTilt) + dz * sin(fabs(thet) + detTilt) / cos(fabs(thet));
217  xpos = -xpos;
218  zpos = topFrameEndZ - topFrame2LHeight - 0.5 * sin(detTilt) * (topFrameBotWidth - topFrame2Width) -
219  dz * cos(detTilt + fabs(thet)) / cos(fabs(thet)) + bl2 * sin(detTilt) - 0.1_mm;
220  }
221  //position
222  mother.placeVolume(
223  sideFrameLeft,
224  isStereo ? 2 : 1,
225  dd4hep::Transform3D(ns.rotation(waferRot),
226  dd4hep::Position(zpos + rPos, isStereo ? xpos + rPos * sin(posCorrectionPhi) : xpos, ypos)));
227 
228  //right Frame
229  name = idName + "SideFrameRight";
230  h1 = 0.5 * sideFrameThick;
231  dz = 0.5 * sideFrameRHeight;
232  bl1 = bl2 = 0.5 * sideFrameRWidth;
233  thet = sideFrameRtheta;
234  if (isStereo)
235  bl1 = 0.5 * sideFrameRWidthLow;
236  solid = Trap(dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
237  ns.addSolidNS(name, solid);
238  edm::LogVerbatim("TECGeom") << "Solid:\t" << name << " " << solid.name() << " Trap made of " << sideFrameMat
239  << " of dimensions " << dz << ", " << thet << ", 0, " << h1 << ", " << bl1 << ", " << bl1
240  << ", 0, " << h1 << ", " << bl2 << ", " << bl2 << ", 0";
241  Volume sideFrameRight(name, solid, ns.material(sideFrameMat));
242  ns.addVolumeNS(sideFrameRight);
243  //translate
244  xpos = 0.5 * topFrameBotWidth - bl2 - tan(fabs(thet)) * dz;
245  ypos = sideFrameZ;
246  zpos = topFrameEndZ - dz;
247  if (isRing6) {
248  zpos *= -1;
249  xpos += 2 * tan(fabs(thet)) * dz; // because of the flip the tan(..) has to be in the other direction
250  }
251  if (isStereo) {
252  xpos = 0.5 * topFrameBotWidth - bl2 * cos(detTilt) - dz * sin(fabs(detTilt - fabs(thet))) / cos(fabs(thet));
253  xpos = -xpos;
254  zpos = topFrameEndZ - topFrame2RHeight + 0.5 * sin(detTilt) * (topFrameBotWidth - topFrame2Width) -
255  dz * cos(detTilt - fabs(thet)) / cos(fabs(thet)) - bl2 * sin(detTilt) - 0.1_mm;
256  }
257  //position it
258  mother.placeVolume(
259  sideFrameRight,
260  isStereo ? 2 : 1,
261  dd4hep::Transform3D(ns.rotation(waferRot),
262  dd4hep::Position(zpos + rPos, isStereo ? xpos + rPos * sin(posCorrectionPhi) : xpos, ypos)));
263  //Supplies Box(es)
264  matter = ns.material(siFrSuppBoxMat);
265  for (int i = 0; i < (int)(siFrSuppBoxWidth.size()); i++) {
266  name = idName + "SuppliesBox" + std::to_string(i);
267 
268  h1 = 0.5 * siFrSuppBoxThick;
269  dz = 0.5 * siFrSuppBoxHeight[i];
270  bl1 = bl2 = 0.5 * siFrSuppBoxWidth[i];
271  thet = sideFrameRtheta;
272  if (isStereo)
273  thet = -atan(fabs(sideFrameRWidthLow - sideFrameRWidth) / (2 * sideFrameRHeight) - tan(fabs(thet)));
274  // ^-- this calculates the lower left angel of the tipped trapezoid, which is the SideFframe...
275 
276  solid = Trap(dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
277  edm::LogVerbatim("TECGeom") << "Solid:\t" << name << " " << solid.name() << " Trap made of " << siFrSuppBoxMat
278  << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, "
279  << h1 << ", " << bl2 << ", " << bl2 << ", 0";
280  Volume siFrSuppBox(name, solid, matter);
281  ns.addVolumeNS(siFrSuppBox);
282  //translate
283  xpos = 0.5 * topFrameBotWidth - sideFrameRWidth - bl1 - siFrSuppBoxYPos[i] * tan(fabs(thet));
284  ypos = sideFrameZ *
285  (0.5 + (siFrSuppBoxThick / sideFrameThick)); //via * so I do not have to worry about the sign of sideFrameZ
286  zpos = topFrameEndZ - siFrSuppBoxYPos[i];
287  if (isRing6) {
288  xpos += 2 * fabs(tan(thet)) * siFrSuppBoxYPos[i]; // the flipped issue again
289  zpos *= -1;
290  }
291  if (isStereo) {
292  xpos = 0.5 * topFrameBotWidth - (sideFrameRWidth + bl1) * cos(detTilt) -
293  sin(fabs(detTilt - fabs(thet))) *
294  (siFrSuppBoxYPos[i] + dz * (1 / cos(thet) - cos(detTilt)) + bl1 * sin(detTilt));
295  xpos = -xpos;
296  zpos = topFrameEndZ - topFrame2RHeight - 0.5 * sin(detTilt) * (topFrameBotWidth - topFrame2Width) -
297  siFrSuppBoxYPos[i] - sin(detTilt) * sideFrameRWidth;
298  }
299  //position it;
300  mother.placeVolume(siFrSuppBox,
301  isStereo ? 2 : 1,
302  dd4hep::Transform3D(
303  ns.rotation(waferRot),
304  dd4hep::Position(zpos + rPos, isStereo ? xpos + rPos * sin(posCorrectionPhi) : xpos, ypos)));
305  }
306 
307  //The Hybrid
308  name = idName + "Hybrid";
309  double dx = 0.5 * hybridWidth;
310  double dy = 0.5 * hybridThick;
311  dz = 0.5 * hybridHeight;
312  solid = Box(dx, dy, dz);
313  ns.addSolidNS(name, solid);
314  edm::LogVerbatim("TECGeom") << "Solid:\t" << name << " " << solid.name() << " Box made of " << hybridMat
315  << " of dimensions " << dx << ", " << dy << ", " << dz;
316  Volume hybrid(name, solid, ns.material(hybridMat));
317  ns.addVolumeNS(hybrid);
318 
319  ypos = hybridZ;
320  zpos = 0.5 * (-waferPosition + fullHeight + hybridHeight) + pitchHeight;
321  if (isRing6)
322  zpos *= -1;
323  //position it
324  mother.placeVolume(
325  hybrid,
326  isStereo ? 2 : 1,
327  dd4hep::Transform3D(ns.rotation(standardRot),
328  dd4hep::Position(zpos + rPos, isStereo ? rPos * sin(posCorrectionPhi) : 0., ypos)));
329 
330  // Wafer
331  name = idName + tag + "Wafer";
332  bl1 = 0.5 * dlBottom;
333  bl2 = 0.5 * dlTop;
334  h1 = 0.5 * waferThick;
335  dz = 0.5 * fullHeight;
336  solid = Trap(dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
337  ns.addSolidNS(name, solid);
338  edm::LogVerbatim("TECGeom") << "Solid:\t" << name << " " << solid.name() << " Trap made of " << waferMat
339  << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, "
340  << h1 << ", " << bl2 << ", " << bl2 << ", 0";
341  Volume wafer(name, solid, ns.material(waferMat));
342 
343  ypos = activeZ;
344  zpos = -0.5 * waferPosition; // former and incorrect topFrameHeight;
345  if (isRing6)
346  zpos *= -1;
347 
348  mother.placeVolume(
349  wafer,
350  isStereo ? 2 : 1,
351  dd4hep::Transform3D(ns.rotation(waferRot),
352  dd4hep::Position(zpos + rPos, isStereo ? rPos * sin(posCorrectionPhi) : 0., ypos)));
353 
354  // Active
355  name = idName + tag + "Active";
356  bl1 -= sideWidthBottom;
357  bl2 -= sideWidthTop;
358  dz = 0.5 * (waferThick - backplaneThick); // inactive backplane
359  h1 = 0.5 * activeHeight;
360  if (isRing6) { //switch bl1 <->bl2
361  tmp = bl2;
362  bl2 = bl1;
363  bl1 = tmp;
364  }
365  solid = Trap(dz, 0, 0, h1, bl2, bl1, 0, h1, bl2, bl1, 0);
366  ns.addSolidNS(name, solid);
367  edm::LogVerbatim("TECGeom") << "Solid:\t" << name << " " << solid.name() << " Trap made of " << activeMat
368  << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl2 << ", " << bl1 << ", 0, "
369  << h1 << ", " << bl2 << ", " << bl1 << ", 0";
370  Volume active(name, solid, ns.material(activeMat));
371  ns.addVolumeNS(active);
372 
373  wafer.placeVolume(
374  active, 1, dd4hep::Transform3D(ns.rotation(activeRot), dd4hep::Position(0., -0.5 * backplaneThick, 0.)));
375 
376  //inactive part in rings > 3
377  if (ringNo > 3) {
378  inactivePos -= fullHeight - activeHeight; //inactivePos is measured from the beginning of the _wafer_
379  name = idName + tag + "Inactive";
380  bl1 = 0.5 * dlBottom - sideWidthBottom +
381  ((0.5 * dlTop - sideWidthTop - 0.5 * dlBottom + sideWidthBottom) / activeHeight) *
382  (activeHeight - inactivePos - inactiveDy);
383  bl2 = 0.5 * dlBottom - sideWidthBottom +
384  ((0.5 * dlTop - sideWidthTop - 0.5 * dlBottom + sideWidthBottom) / activeHeight) *
385  (activeHeight - inactivePos + inactiveDy);
386  dz = 0.5 * (waferThick - backplaneThick); // inactive backplane
387  h1 = inactiveDy;
388  if (isRing6) { //switch bl1 <->bl2
389  tmp = bl2;
390  bl2 = bl1;
391  bl1 = tmp;
392  }
393  solid = Trap(dz, 0, 0, h1, bl2, bl1, 0, h1, bl2, bl1, 0);
394  ns.addSolidNS(name, solid);
395  edm::LogVerbatim("TECGeom") << "Solid:\t" << name << " " << solid.name() << " Trap made of " << inactiveMat
396  << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl2 << ", " << bl1 << ", 0, "
397  << h1 << ", " << bl2 << ", " << bl1 << ", 0";
398  Volume inactive(name, solid, ns.material(inactiveMat));
399  ns.addVolumeNS(inactive);
400  ypos = inactivePos - 0.5 * activeHeight;
401 
402  active.placeVolume(inactive, 1, dd4hep::Position(0., ypos, 0.));
403  }
404  //Pitch Adapter
405  name = idName + "PA";
406  if (!isStereo) {
407  dx = 0.5 * pitchWidth;
408  dy = 0.5 * pitchThick;
409  dz = 0.5 * pitchHeight;
410  solid = Box(dx, dy, dz);
411  ns.addSolidNS(name, solid);
412  edm::LogVerbatim("TECGeom") << "Solid:\t" << name << " " << solid.name() << " Box made of " << pitchMat
413  << " of dimensions " << dx << ", " << dy << ", " << dz;
414  } else {
415  dz = 0.5 * pitchWidth;
416  h1 = 0.5 * pitchThick;
417  bl1 = 0.5 * pitchHeight + 0.5 * dz * sin(detTilt);
418  bl2 = 0.5 * pitchHeight - 0.5 * dz * sin(detTilt);
419  thet = atan((bl1 - bl2) / (2. * dz));
420  solid = Trap(dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
421  ns.addSolidNS(name, solid);
422  edm::LogVerbatim("TECGeom") << "Solid:\t" << name << " " << solid.name() << " Trap made of " << pitchMat
423  << " of dimensions " << dz << ", " << convertRadToDeg(thet) << ", 0, " << h1 << ", "
424  << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2 << ", 0";
425  }
426  xpos = 0;
427  ypos = pitchZ;
428  zpos = 0.5 * (-waferPosition + fullHeight + pitchHeight);
429  if (isRing6)
430  zpos *= -1;
431  if (isStereo)
432  xpos = 0.5 * fullHeight * sin(detTilt);
433 
434  Volume pa(name, solid, ns.material(pitchMat));
435  if (isStereo)
436  mother.placeVolume(pa,
437  2,
438  dd4hep::Transform3D(ns.rotation(pitchRot),
439  dd4hep::Position(zpos + rPos, xpos + rPos * sin(posCorrectionPhi), ypos)));
440  else
441  mother.placeVolume(pa, 1, dd4hep::Transform3D(ns.rotation(standardRot), dd4hep::Position(zpos + rPos, xpos, ypos)));
442 
443  //Top of the frame
444  name = idName + "TopFrame";
445  h1 = 0.5 * topFrameThick;
446  dz = 0.5 * topFrameHeight;
447  bl1 = 0.5 * topFrameBotWidth;
448  bl2 = 0.5 * topFrameTopWidth;
449  if (isRing6) { // ring 6 faces the other way!
450  bl1 = 0.5 * topFrameTopWidth;
451  bl2 = 0.5 * topFrameBotWidth;
452  }
453 
454  solid = Trap(dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
455  ns.addSolid(name, solid);
456  edm::LogVerbatim("TECGeom") << "Solid:\t" << name << " " << solid.name() << " Trap made of " << topFrameMat
457  << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, "
458  << h1 << ", " << bl2 << ", " << bl2 << ", 0";
459  Volume topFrame(name, solid, ns.material(topFrameMat));
460  ns.addVolumeNS(topFrame);
461 
462  if (isStereo) {
463  name = idName + "TopFrame2";
464  //additional object to build the not trapzoid geometry of the stereo topframes
465  dz = 0.5 * topFrame2Width;
466  h1 = 0.5 * topFrameThick;
467  bl1 = 0.5 * topFrame2LHeight;
468  bl2 = 0.5 * topFrame2RHeight;
469  thet = atan((bl1 - bl2) / (2. * dz));
470 
471  solid = Trap(dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
472  ns.addSolid(name, solid);
473  edm::LogVerbatim("TECGeom") << "Solid:\t" << name << " " << solid.name() << " Trap made of " << topFrameMat
474  << " of dimensions " << dz << ", " << convertRadToDeg(thet) << ", 0, " << h1 << ", "
475  << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", " << bl2 << ", 0";
476  }
477 
478  // Position the topframe
479  ypos = topFrameZ;
480  zpos = 0.5 * (-waferPosition + fullHeight - topFrameHeight) + pitchHeight + hybridHeight;
481  if (isRing6) {
482  zpos *= -1;
483  }
484 
485  mother.placeVolume(
486  topFrame,
487  isStereo ? 2 : 1,
488  dd4hep::Transform3D(ns.rotation(standardRot),
489  dd4hep::Position(zpos + rPos, isStereo ? rPos * sin(posCorrectionPhi) : 0., ypos)));
490  if (isStereo) {
491  //create
492  Volume topFrame2(name, solid, ns.material(topFrameMat));
493  zpos -= 0.5 * (topFrameHeight + 0.5 * (topFrame2LHeight + topFrame2RHeight));
494  mother.placeVolume(
495  topFrame2,
496  2,
497  dd4hep::Transform3D(ns.rotation(pitchRot), dd4hep::Position(zpos + rPos, rPos * sin(posCorrectionPhi), ypos)));
498  }
499 
500  //Si - Reencorcement
501  matter = ns.material(siReenforceMat);
502  for (int i = 0; i < (int)(siReenforceWidth.size()); i++) {
503  name = idName + "SiReenforce" + std::to_string(i);
504  h1 = 0.5 * siReenforceThick;
505  dz = 0.5 * siReenforceHeight[i];
506  bl1 = bl2 = 0.5 * siReenforceWidth[i];
507  solid = Trap(dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
508  edm::LogVerbatim("TECGeom") << "Solid:\t" << name << " " << solid.name() << " Trap made of " << matter.name()
509  << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, "
510  << h1 << ", " << bl2 << ", " << bl2 << ", 0";
511  Volume siReenforce(name, solid, matter);
512  ns.addVolumeNS(siReenforce);
513  //translate
514  xpos = 0;
515  ypos = sideFrameZ;
516  zpos = topFrameEndZ - dz - siReenforceYPos[i];
517 
518  if (isRing6)
519  zpos *= -1;
520  if (isStereo) {
521  xpos = (-siReenforceYPos[i] + 0.5 * fullHeight) * sin(detTilt);
522  // thet = detTilt;
523  // if(topFrame2RHeight > topFrame2LHeight) thet *= -1;
524  // zpos -= topFrame2RHeight + sin(thet)*(sideFrameRWidth + 0.5*dlTop);
525  zpos -= topFrame2RHeight + sin(fabs(detTilt)) * 0.5 * topFrame2Width;
526  }
527 
528  mother.placeVolume(siReenforce,
529  isStereo ? 2 : 1,
530  dd4hep::Transform3D(
531  ns.rotation(waferRot),
532  dd4hep::Position(zpos + rPos, isStereo ? xpos + rPos * sin(posCorrectionPhi) : xpos, ypos)));
533  }
534 
535  //Bridge
536  if (bridgeMat != "None") {
537  name = idName + "Bridge";
538  bl2 = 0.5 * bridgeSep + bridgeWidth;
539  bl1 = bl2 - bridgeHeight * dxdif / dzdif;
540  h1 = 0.5 * bridgeThick;
541  dz = 0.5 * bridgeHeight;
542  solid = Trap(dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
543  edm::LogVerbatim("TECGeom") << "Solid:\t" << name << " " << solid.name() << " Trap made of " << bridgeMat
544  << " of dimensions " << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, "
545  << h1 << ", " << bl2 << ", " << bl2 << ", 0";
546  Volume bridge(name, solid, ns.material(bridgeMat));
547  ns.addVolumeNS(bridge);
548 
549  name = idName + "BridgeGap";
550  bl1 = 0.5 * bridgeSep;
551  solid = Box(bl1, h1, dz);
552  edm::LogVerbatim("TECGeom") << "Solid:\t" << name << " " << solid.name() << " Box made of " << genMat
553  << " of dimensions " << bl1 << ", " << h1 << ", " << dz;
554  Volume bridgeGap(name, solid, ns.material(genMat));
555  ns.addVolumeNS(bridgeGap);
556  /* PlacedVolume pv = */ bridge.placeVolume(bridgeGap, 1);
557  edm::LogVerbatim("TECGeom") << "Solid: " << bridgeGap.name() << " number 1 positioned in " << bridge.name()
558  << " at (0,0,0) with no rotation";
559  }
560  edm::LogVerbatim("TECGeom") << "<<== End of DDTECModuleAlgo construction ...";
561  return 1;
562 }
563 
564 // first argument is the type from the xml file
565 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTECModuleAlgo, algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
cms::DDNamespace::realName
std::string realName(const std::string &) const
Definition: DDNamespace.cc:73
mps_fire.i
i
Definition: mps_fire.py:355
cms_units::operators
Definition: CMSUnits.h:13
g4SimHits_cfi.Material
Material
Definition: g4SimHits_cfi.py:547
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:30
cms::DDNamespace::material
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:121
cms::DDParsingContext
Definition: DDParsingContext.h:14
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:16
versionedElectronIDProducer_cfi.idName
idName
Definition: versionedElectronIDProducer_cfi.py:11
SensitiveDetector
Definition: SensitiveDetector.h:25
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
algorithm
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e, SensitiveDetector &)
Definition: DDTECModuleAlgo.cc:11
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:66
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:62
cms::DDNamespace::rotation
const dd4hep::Rotation3D & rotation(const std::string &name) const
Definition: DDNamespace.cc:130
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
DDPlugins.h
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
createfilelist.int
int
Definition: createfilelist.py:10
edm::LogVerbatim
Definition: MessageLogger.h:297
cms::DDNamespace::addSolidNS
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:206
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
cms::DDNamespace::addSolid
dd4hep::Solid addSolid(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:221
PVValHelper::dy
Definition: PVValidationHelpers.h:49
cms::DDNamespace::addVolumeNS
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
Definition: DDNamespace.cc:150
align::Detector
Definition: StructureType.h:86
std
Definition: JetResolutionObject.h:76
PVValHelper::dz
Definition: PVValidationHelpers.h:50
dd4hep
Definition: DDPlugins.h:8
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
CMSUnits.h
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:68
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:190
PVValHelper::dx
Definition: PVValidationHelpers.h:48
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37