CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DDTECModuleAlgo.cc
Go to the documentation of this file.
1 // File: DDTECModuleAlgo .cc
3 // Description: Creation of a TEC Test
5 
15 #include "CLHEP/Units/GlobalPhysicalConstants.h"
16 #include "CLHEP/Units/GlobalSystemOfUnits.h"
17 
18 #include <cmath>
19 #include <algorithm>
20 #include <cstdio>
21 #include <string>
22 #include <utility>
23 #include <map>
24 #include <string>
25 #include <vector>
26 
27 using namespace std;
28 
29 class DDTECModuleAlgo : public DDAlgorithm {
30 public:
31  //Constructor and Destructor
33  ~DDTECModuleAlgo() override;
34 
35  void initialize(const DDNumericArguments& nArgs,
36  const DDVectorArguments& vArgs,
37  const DDMapArguments& mArgs,
38  const DDStringArguments& sArgs,
39  const DDStringVectorArguments& vsArgs) override;
40 
41  void execute(DDCompactView& cpv) override;
42 
43 private:
44  //this positions toPos in mother
45  void doPos(const DDLogicalPart& toPos,
46  const DDLogicalPart& mother,
47  int copyNr,
48  double x,
49  double y,
50  double z,
51  const string& rotName,
52  DDCompactView& cpv);
53  void doPos(DDLogicalPart toPos, double x, double y, double z, string rotName, DDCompactView& cpv);
54  //variables:
56  int ringNo;
57  bool isStereo;
58  bool isRing6;
59  double rPos; //Position in R relativ to the center of the TEC ( this is the coord-sys of Tubs)
60  double posCorrectionPhi; // the Phi position of the stereo Modules has to be corrected
61  string standardRot; //Rotation that aligns the mother(Tub ) coordinate System with the components
62  string idNameSpace; //Namespace of this and ALL parts
63  string genMat; //General material name
64  double moduleThick; //Module thickness
65  double detTilt; //Tilt of stereo detector
66  double fullHeight; //Height
67  double dlTop; //Width at top of wafer
68  double dlBottom; //Width at bottom of wafer
69  double dlHybrid; //Width at the hybrid end
70  double frameWidth; //Frame width
71  double frameThick; // thickness
72  double frameOver; // overlap (on sides)
73  string topFrameMat; //Top frame material
74  double topFrameHeight; // height
75  double topFrameThick; // thickness
76  double topFrameTopWidth; // Width at the top
77  double topFrameBotWidth; // Width at the bottom
78  double topFrame2Width; // Stereo:2ndPart Width
79  double topFrame2LHeight; // left height
80  double topFrame2RHeight; // right height
81  double topFrameZ; // z-positions
82  string sideFrameMat; //Side frame material
83  double sideFrameThick; // thickness
84  double sideFrameLWidth; // Left Width (for stereo modules upper one)
85  double sideFrameLWidthLow; // Width (only for stereo modules: lower Width)
86  double sideFrameLHeight; // Height
87  double sideFrameLtheta; // angle of the trapezoid shift
88  double sideFrameRWidth; // Right Width (for stereo modules upper one)
89  double sideFrameRWidthLow; // Width (only for stereo modules: lower Width)
90  double sideFrameRHeight; // Height
91  double sideFrameRtheta; // angle of the trapezoid shift
92  vector<double> siFrSuppBoxWidth; // Supp.Box Width
93  vector<double> siFrSuppBoxHeight; // Height
94  vector<double> siFrSuppBoxYPos; // y-position of the supplies box (with HV an thermal sensor...)
95  double sideFrameZ; // z-positions
96  double siFrSuppBoxThick; // thickness
97  string siFrSuppBoxMat; // material
98  string waferMat; //Wafer material
99  double waferPosition; // position of the wafer (was formaly done by adjusting topFrameHeigt)
100  double sideWidthTop; // widths on the side Top
101  double sideWidthBottom; // Bottom
102  string waferRot; // rotation matrix
103  string activeMat; //Sensitive material
104  double activeHeight; // height
105  double waferThick; // wafer thickness (active = wafer - backplane)
106  string activeRot; // Rotation matrix
107  double activeZ; // z-positions
108  double backplaneThick; // thickness
109  double inactiveDy; //InactiveStrip Hight of ( rings > 3)
110  double inactivePos; // y-Position
111  string inactiveMat; // material
112  string hybridMat; //Hybrid material
113  double hybridHeight; // height
114  double hybridWidth; // width
115  double hybridThick; // thickness
116  double hybridZ; // z-positions
117  string pitchMat; //Pitch adapter material
118  double pitchWidth; // width
119  double pitchHeight; // height
120  double pitchThick; // thickness
121  double pitchZ; // z-positions
122  string pitchRot; // rotation matrix
123  string bridgeMat; //Bridge material
124  double bridgeWidth; // width
125  double bridgeThick; // thickness
126  double bridgeHeight; // height
127  double bridgeSep; // separation
128  vector<double> siReenforceHeight; // SiReenforcement Height
129  vector<double> siReenforceWidth; // Width
130  vector<double> siReenforceYPos; // Y - Position
131  // double siReenforceZPos;// Z - Position done by the side frames Z Position an t
132  double siReenforceThick; // Thick
133  string siReenforceMat; // Materieal
134  //double posCorrectionR; // Correct Positions of the Stereo Modules radial coordinate
135 };
136 
137 DDTECModuleAlgo::DDTECModuleAlgo() { LogDebug("TECGeom") << "DDTECModuleAlgo info: Creating an instance"; }
138 
140 
142  const DDVectorArguments& vArgs,
143  const DDMapArguments&,
144  const DDStringArguments& sArgs,
145  const DDStringVectorArguments& vsArgs) {
146  idNameSpace = DDCurrentNamespace::ns();
147  genMat = sArgs["GeneralMaterial"];
148 
149  DDName parentName = parent().name();
150 
151  LogDebug("TECGeom") << "DDTECModuleAlgo debug: Parent " << parentName << " NameSpace " << idNameSpace
152  << " General Material " << genMat;
153  ringNo = (int)nArgs["RingNo"];
154  moduleThick = nArgs["ModuleThick"];
155  detTilt = nArgs["DetTilt"];
156  fullHeight = nArgs["FullHeight"];
157  dlTop = nArgs["DlTop"];
158  dlBottom = nArgs["DlBottom"];
159  dlHybrid = nArgs["DlHybrid"];
160  rPos = nArgs["RPos"];
161  standardRot = sArgs["StandardRotation"];
162 
163  isRing6 = (ringNo == 6);
164 
165  LogDebug("TECGeom") << "DDTECModuleAlgo debug: ModuleThick " << moduleThick << " Detector Tilt "
166  << detTilt / CLHEP::deg << " Height " << fullHeight << " dl(Top) " << dlTop << " dl(Bottom) "
167  << dlBottom << " dl(Hybrid) " << dlHybrid << " rPos " << rPos << " standrad rotation "
168  << standardRot;
169 
170  frameWidth = nArgs["FrameWidth"];
171  frameThick = nArgs["FrameThick"];
172  frameOver = nArgs["FrameOver"];
173  LogDebug("TECGeom") << "DDTECModuleAlgo debug: Frame Width " << frameWidth << " Thickness " << frameThick
174  << " Overlap " << frameOver;
175 
176  topFrameMat = sArgs["TopFrameMaterial"];
177  topFrameHeight = nArgs["TopFrameHeight"];
178  topFrameTopWidth = nArgs["TopFrameTopWidth"];
179  topFrameBotWidth = nArgs["TopFrameBotWidth"];
180  topFrameThick = nArgs["TopFrameThick"];
181  topFrameZ = nArgs["TopFrameZ"];
182  LogDebug("TECGeom") << "DDTECModuleAlgo debug: Top Frame Material " << topFrameMat << " Height " << topFrameHeight
183  << " Top Width " << topFrameTopWidth << " Bottom Width " << topFrameTopWidth << " Thickness "
184  << topFrameThick << " positioned at" << topFrameZ;
185  double resizeH = 0.96;
186  sideFrameMat = sArgs["SideFrameMaterial"];
187  sideFrameThick = nArgs["SideFrameThick"];
188  sideFrameLWidth = nArgs["SideFrameLWidth"];
189  sideFrameLHeight = resizeH * nArgs["SideFrameLHeight"];
190  sideFrameLtheta = nArgs["SideFrameLtheta"];
191  sideFrameRWidth = nArgs["SideFrameRWidth"];
192  sideFrameRHeight = resizeH * nArgs["SideFrameRHeight"];
193  sideFrameRtheta = nArgs["SideFrameRtheta"];
194  siFrSuppBoxWidth = vArgs["SiFrSuppBoxWidth"];
195  siFrSuppBoxHeight = vArgs["SiFrSuppBoxHeight"];
196  siFrSuppBoxYPos = vArgs["SiFrSuppBoxYPos"];
197  siFrSuppBoxThick = nArgs["SiFrSuppBoxThick"];
198  siFrSuppBoxMat = sArgs["SiFrSuppBoxMaterial"];
199  sideFrameZ = nArgs["SideFrameZ"];
200  LogDebug("TECGeom") << "DDTECModuleAlgo debug : Side Frame Material " << sideFrameMat << " Thickness "
201  << sideFrameThick << " left Leg's Width: " << sideFrameLWidth
202  << " left Leg's Height: " << sideFrameLHeight << " left Leg's tilt(theta): " << sideFrameLtheta
203  << " right Leg's Width: " << sideFrameRWidth << " right Leg's Height: " << sideFrameRHeight
204  << " right Leg's tilt(theta): " << sideFrameRtheta
205  << "Supplies Box's Material: " << siFrSuppBoxMat << " positioned at" << sideFrameZ;
206  for (int i = 0; i < (int)(siFrSuppBoxWidth.size()); i++) {
207  LogDebug("TECGeom") << " Supplies Box" << i << "'s Width: " << siFrSuppBoxWidth[i] << " Supplies Box" << i
208  << "'s Height: " << siFrSuppBoxHeight[i] << " Supplies Box" << i
209  << "'s y Position: " << siFrSuppBoxYPos[i];
210  }
211  waferMat = sArgs["WaferMaterial"];
212  sideWidthTop = nArgs["SideWidthTop"];
213  sideWidthBottom = nArgs["SideWidthBottom"];
214  waferRot = sArgs["WaferRotation"];
215  waferPosition = nArgs["WaferPosition"];
216  LogDebug("TECGeom") << "DDTECModuleAlgo debug: Wafer Material " << waferMat << " Side Width Top" << sideWidthTop
217  << " Side Width Bottom" << sideWidthBottom << " and positioned at " << waferPosition
218  << " positioned with rotation"
219  << " matrix:" << waferRot;
220 
221  activeMat = sArgs["ActiveMaterial"];
222  activeHeight = nArgs["ActiveHeight"];
223  waferThick = nArgs["WaferThick"];
224  activeRot = sArgs["ActiveRotation"];
225  activeZ = nArgs["ActiveZ"];
226  backplaneThick = nArgs["BackPlaneThick"];
227  LogDebug("TECGeom") << "DDTECModuleAlgo debug: Active Material " << activeMat << " Height " << activeHeight
228  << " rotated by " << activeRot << " translated by (0,0," << -0.5 * backplaneThick << ")"
229  << " Thickness/Z" << waferThick - backplaneThick << "/" << activeZ;
230 
231  hybridMat = sArgs["HybridMaterial"];
232  hybridHeight = nArgs["HybridHeight"];
233  hybridWidth = nArgs["HybridWidth"];
234  hybridThick = nArgs["HybridThick"];
235  hybridZ = nArgs["HybridZ"];
236  LogDebug("TECGeom") << "DDTECModuleAlgo debug: Hybrid Material " << hybridMat << " Height " << hybridHeight
237  << " Width " << hybridWidth << " Thickness " << hybridThick << " Z" << hybridZ;
238 
239  pitchMat = sArgs["PitchMaterial"];
240  pitchHeight = nArgs["PitchHeight"];
241  pitchThick = nArgs["PitchThick"];
242  pitchWidth = nArgs["PitchWidth"];
243  pitchZ = nArgs["PitchZ"];
244  pitchRot = sArgs["PitchRotation"];
245  LogDebug("TECGeom") << "DDTECModuleAlgo debug: Pitch Adapter Material " << pitchMat << " Height " << pitchHeight
246  << " Thickness " << pitchThick << " position with "
247  << " rotation " << pitchRot << " at Z" << pitchZ;
248 
249  bridgeMat = sArgs["BridgeMaterial"];
250  bridgeWidth = nArgs["BridgeWidth"];
251  bridgeThick = nArgs["BridgeThick"];
252  bridgeHeight = nArgs["BridgeHeight"];
253  bridgeSep = nArgs["BridgeSeparation"];
254  LogDebug("TECGeom") << "DDTECModuleAlgo debug: Bridge Material " << bridgeMat << " Width " << bridgeWidth
255  << " Thickness " << bridgeThick << " Height " << bridgeHeight << " Separation " << bridgeSep;
256 
257  siReenforceWidth = vArgs["SiReenforcementWidth"];
258  siReenforceHeight = vArgs["SiReenforcementHeight"];
259  siReenforceYPos = vArgs["SiReenforcementPosY"];
260  siReenforceThick = nArgs["SiReenforcementThick"];
261  siReenforceMat = sArgs["SiReenforcementMaterial"];
262 
263  LogDebug("TECGeom") << "FALTBOOT DDTECModuleAlgo debug : Si-Reenforcement Material " << sideFrameMat << " Thickness "
264  << siReenforceThick;
265 
266  for (int i = 0; i < (int)(siReenforceWidth.size()); i++) {
267  LogDebug("TECGeom") << " SiReenforcement" << i << "'s Width: " << siReenforceWidth[i] << " SiReenforcement" << i
268  << "'s Height: " << siReenforceHeight[i] << " SiReenforcement" << i
269  << "'s y Position: " << siReenforceYPos[i];
270  }
271  inactiveDy = 0;
272  inactivePos = 0;
273  if (ringNo > 3) {
274  inactiveDy = nArgs["InactiveDy"];
275  inactivePos = nArgs["InactivePos"];
276  inactiveMat = sArgs["InactiveMaterial"];
277  }
278 
279  noOverlapShift = nArgs["NoOverlapShift"];
280  //Everything that is normal/stereo specific comes here
281  isStereo = (int)nArgs["isStereo"] == 1;
282  if (!isStereo) {
283  LogDebug("TECGeom") << "This is a normal module, in ring " << ringNo << "!";
284  } else {
285  LogDebug("TECGeom") << "This is a stereo module, in ring " << ringNo << "!";
286  posCorrectionPhi = nArgs["PosCorrectionPhi"];
287  topFrame2LHeight = nArgs["TopFrame2LHeight"];
288  topFrame2RHeight = nArgs["TopFrame2RHeight"];
289  topFrame2Width = nArgs["TopFrame2Width"];
290  LogDebug("TECGeom") << "Phi Position corrected by " << posCorrectionPhi << "*rad";
291  LogDebug("TECGeom") << "DDTECModuleAlgo debug: stereo Top Frame 2nd Part left Heigt " << topFrame2LHeight
292  << " right Height " << topFrame2RHeight << " Width " << topFrame2Width;
293 
294  sideFrameLWidthLow = nArgs["SideFrameLWidthLow"];
295  sideFrameRWidthLow = nArgs["SideFrameRWidthLow"];
296 
297  LogDebug("TECGeom") << " left Leg's lower Width: " << sideFrameLWidthLow
298  << " right Leg's lower Width: " << sideFrameRWidthLow;
299 
300  // posCorrectionR = nArgs["PosCorrectionR"];
301  //LogDebug("TECGeom") << "Stereo Module Position Correction with R = " << posCorrectionR;
302  }
303 }
304 
306  const DDLogicalPart& mother,
307  int copyNr,
308  double x,
309  double y,
310  double z,
311  const string& rotName,
312  DDCompactView& cpv) {
313  DDTranslation tran(z, x, y);
314  DDRotation rot;
315  string rotstr = DDSplit(rotName).first;
316  string rotns;
317  if (rotstr != "NULL") {
318  rotns = DDSplit(rotName).second;
319  rot = DDRotation(DDName(rotstr, rotns));
320  } else {
321  rot = DDRotation();
322  }
323 
324  cpv.position(toPos, mother, copyNr, tran, rot);
325  LogDebug("TECGeom") << "DDTECModuleAlgo test: " << toPos.name() << " positioned in " << mother.name() << " at "
326  << tran << " with " << rot;
327 }
328 
329 void DDTECModuleAlgo::doPos(DDLogicalPart toPos, double x, double y, double z, string rotName, DDCompactView& cpv) {
330  int copyNr = 1;
331  if (isStereo)
332  copyNr = 2;
333 
334  // This has to be done so that the Mother coordinate System of a Tub resembles
335  // the coordinate System of a Trap or Box.
336  z += rPos;
337 
338  if (isStereo) {
339  // z is x , x is y
340  //z+= rPos*sin(posCorrectionPhi); <<- this is already corrected with the r position!
341  x += rPos * sin(posCorrectionPhi);
342  }
343  if (rotName == "NULL")
344  rotName = standardRot;
345 
346  doPos(toPos, parent(), copyNr, x, y, z, rotName, cpv);
347 }
348 
350  LogDebug("TECGeom") << "==>> Constructing DDTECModuleAlgo...";
351  //declarations
352  double tmp;
353  double dxdif, dzdif;
354  double dxbot, dxtop; // topfr;
355  //positions
356  double xpos, ypos, zpos;
357  //dimensons
358  double bl1, bl2;
359  double h1;
360  double dx, dy, dz;
361  double thet;
362  //names
363  string idName;
364  string name;
365  string tag("Rphi");
366  if (isStereo)
367  tag = "Stereo";
368  //usefull constants
369  const double topFrameEndZ = 0.5 * (-waferPosition + fullHeight) + pitchHeight + hybridHeight - topFrameHeight;
370  DDName parentName = parent().name();
371  idName = parentName.name();
372  LogDebug("TECGeom") << "==>> " << idName << " parent " << parentName << " namespace " << idNameSpace;
373  DDSolid solid;
374 
375  //set global parameters
376  DDName matname(DDSplit(genMat).first, DDSplit(genMat).second);
377  DDMaterial matter(matname);
378  dzdif = fullHeight + topFrameHeight;
379  if (isStereo)
380  dzdif += 0.5 * (topFrame2LHeight + topFrame2RHeight);
381 
382  dxbot = 0.5 * dlBottom + frameWidth - frameOver;
383  dxtop = 0.5 * dlHybrid + frameWidth - frameOver;
384  // topfr = 0.5*dlBottom * sin(detTilt);
385  if (isRing6) {
386  dxbot = dxtop;
387  dxtop = 0.5 * dlTop + frameWidth - frameOver;
388  // topfr = 0.5*dlTop * sin(detTilt);
389  }
390  dxdif = dxtop - dxbot;
391 
392  //Frame Sides
393  // left Frame
394  name = idName + "SideFrameLeft";
395  matname = DDName(DDSplit(sideFrameMat).first, DDSplit(sideFrameMat).second);
396  matter = DDMaterial(matname);
397 
398  h1 = 0.5 * sideFrameThick;
399  dz = 0.5 * sideFrameLHeight;
400  bl1 = bl2 = 0.5 * sideFrameLWidth;
401  thet = sideFrameLtheta;
402  //for stereo modules
403  if (isStereo)
404  bl1 = 0.5 * sideFrameLWidthLow;
405  solid = DDSolidFactory::trap(DDName(name, idNameSpace), dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
406  LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() << " Trap made of " << matname << " of dimensions "
407  << dz << ", " << thet << ", 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", "
408  << bl2 << ", " << bl2 << ", 0";
409  DDLogicalPart sideFrameLeft(solid.ddname(), matter, solid);
410  //translate
411  xpos = -0.5 * topFrameBotWidth + bl2 + tan(fabs(thet)) * dz;
412  ypos = sideFrameZ;
413  zpos = topFrameEndZ - dz;
414  //flip ring 6
415  if (isRing6) {
416  zpos *= -1;
417  xpos -= 2 * tan(fabs(thet)) * dz; // because of the flip the tan(..) to be in the other direction
418  }
419  //the stereo modules are on the back of the normal ones...
420  if (isStereo) {
421  xpos = -0.5 * topFrameBotWidth + bl2 * cos(detTilt) + dz * sin(fabs(thet) + detTilt) / cos(fabs(thet));
422  xpos = -xpos;
423  zpos = topFrameEndZ - topFrame2LHeight - 0.5 * sin(detTilt) * (topFrameBotWidth - topFrame2Width) -
424  dz * cos(detTilt + fabs(thet)) / cos(fabs(thet)) + bl2 * sin(detTilt) - 0.1 * CLHEP::mm;
425  }
426  //position
427  doPos(sideFrameLeft, xpos, ypos, zpos, waferRot, cpv);
428 
429  //right Frame
430  name = idName + "SideFrameRight";
431  matname = DDName(DDSplit(sideFrameMat).first, DDSplit(sideFrameMat).second);
432  matter = DDMaterial(matname);
433 
434  h1 = 0.5 * sideFrameThick;
435  dz = 0.5 * sideFrameRHeight;
436  bl1 = bl2 = 0.5 * sideFrameRWidth;
437  thet = sideFrameRtheta;
438  if (isStereo)
439  bl1 = 0.5 * sideFrameRWidthLow;
440  solid = DDSolidFactory::trap(DDName(name, idNameSpace), dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
441  LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() << " Trap made of " << matname << " of dimensions "
442  << dz << ", " << thet << ", 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", "
443  << bl2 << ", " << bl2 << ", 0";
444  DDLogicalPart sideFrameRight(solid.ddname(), matter, solid);
445  //translate
446  xpos = 0.5 * topFrameBotWidth - bl2 - tan(fabs(thet)) * dz;
447  ypos = sideFrameZ;
448  zpos = topFrameEndZ - dz;
449  if (isRing6) {
450  zpos *= -1;
451  xpos += 2 * tan(fabs(thet)) * dz; // because of the flip the tan(..) has to be in the other direction
452  }
453  if (isStereo) {
454  xpos = 0.5 * topFrameBotWidth - bl2 * cos(detTilt) - dz * sin(fabs(detTilt - fabs(thet))) / cos(fabs(thet));
455  xpos = -xpos;
456  zpos = topFrameEndZ - topFrame2RHeight + 0.5 * sin(detTilt) * (topFrameBotWidth - topFrame2Width) -
457  dz * cos(detTilt - fabs(thet)) / cos(fabs(thet)) - bl2 * sin(detTilt) - 0.1 * CLHEP::mm;
458  }
459  //position it
460  doPos(sideFrameRight, xpos, ypos, zpos, waferRot, cpv);
461 
462  //Supplies Box(es)
463  for (int i = 0; i < (int)(siFrSuppBoxWidth.size()); i++) {
464  name = idName + "SuppliesBox" + to_string(i);
465  matname = DDName(DDSplit(siFrSuppBoxMat).first, DDSplit(siFrSuppBoxMat).second);
466  matter = DDMaterial(matname);
467 
468  h1 = 0.5 * siFrSuppBoxThick;
469  dz = 0.5 * siFrSuppBoxHeight[i];
470  bl1 = bl2 = 0.5 * siFrSuppBoxWidth[i];
471  thet = sideFrameRtheta;
472  if (isStereo)
473  thet = -atan(fabs(sideFrameRWidthLow - sideFrameRWidth) / (2 * sideFrameRHeight) - tan(fabs(thet)));
474  // ^-- this calculates the lower left angel of the tipped trapezoid, which is the SideFframe...
475 
476  solid = DDSolidFactory::trap(DDName(name, idNameSpace), dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
477  LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() << " Trap made of " << matname << " of dimensions "
478  << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", "
479  << bl2 << ", 0";
480  DDLogicalPart siFrSuppBox(solid.ddname(), matter, solid);
481  //translate
482  xpos = 0.5 * topFrameBotWidth - sideFrameRWidth - bl1 - siFrSuppBoxYPos[i] * tan(fabs(thet));
483  ypos = sideFrameZ *
484  (0.5 + (siFrSuppBoxThick / sideFrameThick)); //via * so I do not have to worry about the sign of sideFrameZ
485  zpos = topFrameEndZ - siFrSuppBoxYPos[i];
486  if (isRing6) {
487  xpos += 2 * fabs(tan(thet)) * siFrSuppBoxYPos[i]; // the flipped issue again
488  zpos *= -1;
489  }
490  if (isStereo) {
491  xpos = 0.5 * topFrameBotWidth - (sideFrameRWidth + bl1) * cos(detTilt) -
492  sin(fabs(detTilt - fabs(thet))) *
493  (siFrSuppBoxYPos[i] + dz * (1 / cos(thet) - cos(detTilt)) + bl1 * sin(detTilt));
494  xpos = -xpos;
495  zpos = topFrameEndZ - topFrame2RHeight - 0.5 * sin(detTilt) * (topFrameBotWidth - topFrame2Width) -
496  siFrSuppBoxYPos[i] - sin(detTilt) * sideFrameRWidth;
497  }
498  //position it;
499  doPos(siFrSuppBox, xpos, ypos, zpos, waferRot, cpv);
500  }
501  //The Hybrid
502  name = idName + "Hybrid";
503  matname = DDName(DDSplit(hybridMat).first, DDSplit(hybridMat).second);
504  matter = DDMaterial(matname);
505  dx = 0.5 * hybridWidth;
506  dy = 0.5 * hybridThick;
507  dz = 0.5 * hybridHeight;
508  solid = DDSolidFactory::box(DDName(name, idNameSpace), dx, dy, dz);
509  LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() << " Box made of " << matname << " of dimensions "
510  << dx << ", " << dy << ", " << dz;
511  DDLogicalPart hybrid(solid.ddname(), matter, solid);
512 
513  ypos = hybridZ;
514  zpos = 0.5 * (-waferPosition + fullHeight + hybridHeight) + pitchHeight;
515  if (isRing6)
516  zpos *= -1;
517  //position it
518  doPos(hybrid, 0, ypos, zpos, "NULL", cpv);
519 
520  // Wafer
521  name = idName + tag + "Wafer";
522  matname = DDName(DDSplit(waferMat).first, DDSplit(waferMat).second);
523  matter = DDMaterial(matname);
524  bl1 = 0.5 * dlBottom;
525  bl2 = 0.5 * dlTop;
526  h1 = 0.5 * waferThick;
527  dz = 0.5 * fullHeight;
528  solid = DDSolidFactory::trap(DDName(name, idNameSpace), dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
529  LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() << " Trap made of " << matname << " of dimensions "
530  << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", "
531  << bl2 << ", 0";
532  DDLogicalPart wafer(solid.ddname(), matter, solid);
533 
534  ypos = activeZ;
535  zpos = -0.5 * waferPosition; // former and incorrect topFrameHeight;
536  if (isRing6)
537  zpos *= -1;
538 
539  doPos(wafer, 0, ypos, zpos, waferRot, cpv);
540 
541  // Active
542  name = idName + tag + "Active";
543  matname = DDName(DDSplit(activeMat).first, DDSplit(activeMat).second);
544  matter = DDMaterial(matname);
545  bl1 -= sideWidthBottom;
546  bl2 -= sideWidthTop;
547  dz = 0.5 * (waferThick - backplaneThick); // inactive backplane
548  h1 = 0.5 * activeHeight;
549  if (isRing6) { //switch bl1 <->bl2
550  tmp = bl2;
551  bl2 = bl1;
552  bl1 = tmp;
553  }
554  solid = DDSolidFactory::trap(DDName(name, idNameSpace), dz, 0, 0, h1, bl2, bl1, 0, h1, bl2, bl1, 0);
555  LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() << " Trap made of " << matname << " of dimensions "
556  << dz << ", 0, 0, " << h1 << ", " << bl2 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", "
557  << bl1 << ", 0";
558  DDLogicalPart active(solid.ddname(), matter, solid);
559  doPos(active,
560  wafer,
561  1,
562  -0.5 * backplaneThick,
563  0,
564  0,
565  activeRot,
566  cpv); // from the definition of the wafer local axes and doPos() routine
567  //inactive part in rings > 3
568  if (ringNo > 3) {
569  inactivePos -= fullHeight - activeHeight; //inactivePos is measured from the beginning of the _wafer_
570  name = idName + tag + "Inactive";
571  matname = DDName(DDSplit(inactiveMat).first, DDSplit(inactiveMat).second);
572  matter = DDMaterial(matname);
573  bl1 = 0.5 * dlBottom - sideWidthBottom +
574  ((0.5 * dlTop - sideWidthTop - 0.5 * dlBottom + sideWidthBottom) / activeHeight) *
575  (activeHeight - inactivePos - inactiveDy);
576  bl2 = 0.5 * dlBottom - sideWidthBottom +
577  ((0.5 * dlTop - sideWidthTop - 0.5 * dlBottom + sideWidthBottom) / activeHeight) *
578  (activeHeight - inactivePos + inactiveDy);
579  dz = 0.5 * (waferThick - backplaneThick); // inactive backplane
580  h1 = inactiveDy;
581  if (isRing6) { //switch bl1 <->bl2
582  tmp = bl2;
583  bl2 = bl1;
584  bl1 = tmp;
585  }
586  solid = DDSolidFactory::trap(DDName(name, idNameSpace), dz, 0, 0, h1, bl2, bl1, 0, h1, bl2, bl1, 0);
587  LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() << " Trap made of " << matname << " of dimensions "
588  << dz << ", 0, 0, " << h1 << ", " << bl2 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", "
589  << bl1 << ", 0";
590  DDLogicalPart inactive(solid.ddname(), matter, solid);
591  ypos = inactivePos - 0.5 * activeHeight;
592  doPos(
593  inactive, active, 1, ypos, 0, 0, "NULL", cpv); // from the definition of the wafer local axes and doPos() routine
594  }
595  //Pitch Adapter
596  name = idName + "PA";
597  matname = DDName(DDSplit(pitchMat).first, DDSplit(pitchMat).second);
598  matter = DDMaterial(matname);
599 
600  if (!isStereo) {
601  dx = 0.5 * pitchWidth;
602  dy = 0.5 * pitchThick;
603  dz = 0.5 * pitchHeight;
604  solid = DDSolidFactory::box(DDName(name, idNameSpace), dx, dy, dz);
605  LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() << " Box made of " << matname << " of dimensions "
606  << dx << ", " << dy << ", " << dz;
607  } else {
608  dz = 0.5 * pitchWidth;
609  h1 = 0.5 * pitchThick;
610  bl1 = 0.5 * pitchHeight + 0.5 * dz * sin(detTilt);
611  bl2 = 0.5 * pitchHeight - 0.5 * dz * sin(detTilt);
612  double thet = atan((bl1 - bl2) / (2. * dz));
613  solid = DDSolidFactory::trap(DDName(name, idNameSpace), dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
614  LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() << " Trap made of " << matname << " of dimensions "
615  << dz << ", " << thet / CLHEP::deg << ", 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, "
616  << h1 << ", " << bl2 << ", " << bl2 << ", 0";
617  }
618  xpos = 0;
619  ypos = pitchZ;
620  zpos = 0.5 * (-waferPosition + fullHeight + pitchHeight);
621  if (isRing6)
622  zpos *= -1;
623  if (isStereo)
624  xpos = 0.5 * fullHeight * sin(detTilt);
625 
626  DDLogicalPart pa(solid.ddname(), matter, solid);
627  if (isStereo)
628  doPos(pa, xpos, ypos, zpos, pitchRot, cpv);
629  else
630  doPos(pa, xpos, ypos, zpos, "NULL", cpv);
631  //Top of the frame
632  name = idName + "TopFrame";
633  matname = DDName(DDSplit(topFrameMat).first, DDSplit(topFrameMat).second);
634  matter = DDMaterial(matname);
635 
636  h1 = 0.5 * topFrameThick;
637  dz = 0.5 * topFrameHeight;
638  bl1 = 0.5 * topFrameBotWidth;
639  bl2 = 0.5 * topFrameTopWidth;
640  if (isRing6) { // ring 6 faces the other way!
641  bl1 = 0.5 * topFrameTopWidth;
642  bl2 = 0.5 * topFrameBotWidth;
643  }
644 
645  solid = DDSolidFactory::trap(DDName(name, idNameSpace), dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
646  LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() << " Trap made of " << matname << " of dimensions "
647  << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", "
648  << bl2 << ", 0";
649  DDLogicalPart topFrame(solid.ddname(), matter, solid);
650 
651  if (isStereo) {
652  name = idName + "TopFrame2";
653  //additional object to build the not trapzoid geometry of the stereo topframes
654  dz = 0.5 * topFrame2Width;
655  h1 = 0.5 * topFrameThick;
656  bl1 = 0.5 * topFrame2LHeight;
657  bl2 = 0.5 * topFrame2RHeight;
658  double thet = atan((bl1 - bl2) / (2. * dz));
659 
660  solid = DDSolidFactory::trap(DDName(name, idNameSpace), dz, thet, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
661  LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() << " Trap made of " << matname << " of dimensions "
662  << dz << ", " << thet / CLHEP::deg << ", 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, "
663  << h1 << ", " << bl2 << ", " << bl2 << ", 0";
664  }
665 
666  // Position the topframe
667  ypos = topFrameZ;
668  zpos = 0.5 * (-waferPosition + fullHeight - topFrameHeight) + pitchHeight + hybridHeight;
669  if (isRing6) {
670  zpos *= -1;
671  }
672 
673  doPos(topFrame, 0, ypos, zpos, "NULL", cpv);
674  if (isStereo) {
675  //create
676  DDLogicalPart topFrame2(solid.ddname(), matter, solid);
677  zpos -= 0.5 * (topFrameHeight + 0.5 * (topFrame2LHeight + topFrame2RHeight));
678  doPos(topFrame2, 0, ypos, zpos, pitchRot, cpv);
679  }
680 
681  //Si - Reencorcement
682  for (int i = 0; i < (int)(siReenforceWidth.size()); i++) {
683  name = idName + "SiReenforce" + to_string(i);
684  matname = DDName(DDSplit(siReenforceMat).first, DDSplit(siReenforceMat).second);
685  matter = DDMaterial(matname);
686 
687  h1 = 0.5 * siReenforceThick;
688  dz = 0.5 * siReenforceHeight[i];
689  bl1 = bl2 = 0.5 * siReenforceWidth[i];
690 
691  solid = DDSolidFactory::trap(DDName(name, idNameSpace), dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
692  LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() << " Trap made of " << matname << " of dimensions "
693  << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", "
694  << bl2 << ", 0";
695  DDLogicalPart siReenforce(solid.ddname(), matter, solid);
696  //translate
697  xpos = 0;
698  ypos = sideFrameZ;
699  zpos = topFrameEndZ - dz - siReenforceYPos[i];
700 
701  if (isRing6)
702  zpos *= -1;
703  if (isStereo) {
704  xpos = (-siReenforceYPos[i] + 0.5 * fullHeight) * sin(detTilt);
705  // thet = detTilt;
706  // if(topFrame2RHeight > topFrame2LHeight) thet *= -1;
707  // zpos -= topFrame2RHeight + sin(thet)*(sideFrameRWidth + 0.5*dlTop);
708  zpos -= topFrame2RHeight + sin(fabs(detTilt)) * 0.5 * topFrame2Width;
709  }
710  doPos(siReenforce, xpos, ypos, zpos, waferRot, cpv);
711  }
712 
713  //Bridge
714  if (bridgeMat != "None") {
715  name = idName + "Bridge";
716  matname = DDName(DDSplit(bridgeMat).first, DDSplit(bridgeMat).second);
717  matter = DDMaterial(matname);
718  bl2 = 0.5 * bridgeSep + bridgeWidth;
719  bl1 = bl2 - bridgeHeight * dxdif / dzdif;
720  h1 = 0.5 * bridgeThick;
721  dz = 0.5 * bridgeHeight;
722  solid = DDSolidFactory::trap(DDName(name, idNameSpace), dz, 0, 0, h1, bl1, bl1, 0, h1, bl2, bl2, 0);
723  LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() << " Trap made of " << matname << " of dimensions "
724  << dz << ", 0, 0, " << h1 << ", " << bl1 << ", " << bl1 << ", 0, " << h1 << ", " << bl2 << ", "
725  << bl2 << ", 0";
726  DDLogicalPart bridge(solid.ddname(), matter, solid);
727 
728  name = idName + "BridgeGap";
729  matname = DDName(DDSplit(genMat).first, DDSplit(genMat).second);
730  matter = DDMaterial(matname);
731  bl1 = 0.5 * bridgeSep;
732  solid = DDSolidFactory::box(DDName(name, idNameSpace), bl1, h1, dz);
733  LogDebug("TECGeom") << "DDTECModuleAlgo test:\t" << solid.name() << " Box made of " << matname << " of dimensions "
734  << bl1 << ", " << h1 << ", " << dz;
735  DDLogicalPart bridgeGap(solid.ddname(), matter, solid);
736  cpv.position(bridgeGap, bridge, 1, DDTranslation(0.0, 0.0, 0.0), DDRotation());
737  LogDebug("TECGeom") << "DDTECModuleAlgo test: " << bridgeGap.name() << " number 1 positioned in " << bridge.name()
738  << " at (0,0,0) with no rotation";
739  }
740 
741  LogDebug("TECGeom") << "<<== End of DDTECModuleAlgo construction ...";
742 }
743 
744 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDTECModuleAlgo, "track:DDTECModuleAlgo");
static AlgebraicMatrix initialize()
const N & name() const
Definition: DDBase.h:59
vector< double > siReenforceYPos
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
std::string to_string(const V &value)
Definition: OMSAccess.h:71
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
static const std::string & rotName(const T &rot, const cms::DDParsingContext &context)
U second(std::pair< T, U > const &p)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
int32_t waferThick(const int32_t property)
Definition: HGCalProperty.cc:9
static DDSolid trap(const DDName &name, double pDz, double pTheta, double pPhi, double pDy1, double pDx1, double pDx2, double pAlp1, double pDy2, double pDx3, double pDx4, double pAlp2)
Definition: DDSolid.cc:609
static DDSolid box(const DDName &name, double xHalf, double yHalf, double zHalf)
Creates a box with side length 2*xHalf, 2*yHalf, 2*zHalf.
Definition: DDSolid.cc:547
~DDTECModuleAlgo() override
void execute(DDCompactView &cpv) override
vector< double > siFrSuppBoxWidth
vector< double > siReenforceWidth
vector< double > siReenforceHeight
#define DEFINE_EDM_PLUGIN(factory, type, name)
void doPos(const DDLogicalPart &toPos, const DDLogicalPart &mother, int copyNr, double x, double y, double z, const string &rotName, DDCompactView &cpv)
tmp
align.sh
Definition: createJobs.py:716
vector< double > siFrSuppBoxYPos
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
vector< double > siFrSuppBoxHeight
#define LogDebug(id)
const N & ddname() const
Definition: DDBase.h:61