CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDTIDModulePosAlgo.cc
Go to the documentation of this file.
1 // File: DDTIDModulePosAlgo.cc
3 // Description: Position various components inside a TID Module
5 
6 #include <cmath>
7 #include <algorithm>
8 
14 #include "CLHEP/Units/GlobalPhysicalConstants.h"
15 #include "CLHEP/Units/GlobalSystemOfUnits.h"
16 
17 
19  LogDebug("TIDGeom") << "DDTIDModulePosAlgo info: Creating an instance";
20 }
21 
23 
25  const DDVectorArguments & vArgs,
26  const DDMapArguments & ,
27  const DDStringArguments & sArgs,
28  const DDStringVectorArguments & vsArgs) {
29 
30  int i;
31  DDName parentName = parent().name();
32  detectorN = (int)(nArgs["DetectorNumber"]);
33 
34  LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: Parent " << parentName
35  << " Detector Planes " << detectorN;
36 
37  detTilt = nArgs["DetTilt"];
38  fullHeight = nArgs["FullHeight"];
39  dlTop = nArgs["DlTop"];
40  dlBottom = nArgs["DlBottom"];
41  dlHybrid = nArgs["DlHybrid"];
42 
43  LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: Detector Tilt "
44  << detTilt/CLHEP::deg << " Height " << fullHeight
45  << " dl(Top) " << dlTop << " dl(Bottom) " << dlBottom
46  << " dl(Hybrid) " << dlHybrid;
47 
48  boxFrameName = sArgs["BoxFrameName"];
49  boxFrameHeight = nArgs["BoxFrameHeight"];
50  boxFrameWidth = nArgs["BoxFrameWidth"];
51  boxFrameZ = vArgs["BoxFrameZ"];
52  bottomFrameHeight = nArgs["BottomFrameHeight"];
53  bottomFrameOver = nArgs["BottomFrameOver"];
54  topFrameHeight = nArgs["TopFrameHeight"];
55  topFrameOver = nArgs["TopFrameOver"];
56  LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: " << boxFrameName
57  << " positioned at Z";
58  for (i = 0; i < detectorN; i++)
59  LogDebug("TIDGeom") << "\tboxFrameZ[" << i << "] = " << boxFrameZ[i];
60  LogDebug("TIDGeom") << "\t Extra Height at Bottom " << bottomFrameHeight
61  << " Overlap " <<bottomFrameOver;
62 
63  sideFrameName = vsArgs["SideFrameName"];
64  sideFrameZ = vArgs["SideFrameZ"];
65  sideFrameRot =vsArgs["SideFrameRotation"];
66  sideFrameWidth = nArgs["SideFrameWidth"];
67  sideFrameOver = nArgs["SideFrameOver"];
68  for (i = 0; i < detectorN; i++)
69  LogDebug("TIDGeom") << "\tsideFrame[" << i << "] = " << sideFrameName[i]
70  << " positioned at Z "<< sideFrameZ[i]
71  << " with rotation " << sideFrameRot[i];
72 
73  kaptonName = vsArgs["KaptonName"];
74  kaptonZ = vArgs["KaptonZ"];
75  kaptonRot =vsArgs["KaptonRotation"];
76  for (i = 0; i < detectorN; i++)
77  LogDebug("TIDGeom") << "\tkapton[" << i << "] = " << kaptonName[i]
78  << " positioned at Z "<< kaptonZ[i]
79  << " with rotation " << kaptonRot[i];
80 
81  waferName =vsArgs["WaferName"];
82  waferZ = vArgs["WaferZ"];
83  waferRot =vsArgs["WaferRotation"];
84  for (i = 0; i < detectorN; i++)
85  LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: " << waferName[i]
86  << " positioned at Z " << waferZ[i]
87  << " with rotation " << waferRot[i];
88 
89  hybridName = sArgs["HybridName"];
90  hybridHeight = nArgs["HybridHeight"];
91  hybridZ = vArgs["HybridZ"];
92  LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: " << hybridName
93  << " Height " << hybridHeight << " Z";
94  for (i = 0; i < detectorN; i++)
95  LogDebug("TIDGeom") << "\thybridZ[" << i <<"] = " << hybridZ[i];
96 
97  pitchName =vsArgs["PitchName"];
98  pitchHeight = nArgs["PitchHeight"];
99  pitchZ = vArgs["PitchZ"];
100  pitchRot =vsArgs["PitchRotation"];
101  LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: Pitch Adapter Height "
102  << pitchHeight;
103  for (i = 0; i < detectorN; i++)
104  LogDebug("TIDGeom") << "DDTIDModulePosAlgo debug: " << pitchName[i]
105  << " position at Z " << pitchZ[i]
106  << " with rotation " << pitchRot[i];
107 
108  coolName = sArgs["CoolInsertName"];
109  coolHeight = nArgs["CoolInsertHeight"];
110  coolZ = nArgs["CoolInsertZ"];
111  coolWidth = nArgs["CoolInsertWidth"];
112  coolRadShift = vArgs["CoolInsertShift"];
113 
114  std::string comp = sArgs["DoSpacers"];
115  if (comp == "No" || comp == "NO" || comp == "no") doSpacers = false;
116  else doSpacers = true;
117 
118  botSpacersName = sArgs["BottomSpacersName"];
119  botSpacersHeight = nArgs["BottomSpacersHeight"];
120  botSpacersZ = nArgs["BottomSpacersZ"];
121  sidSpacersName = sArgs["SideSpacersName"];
122  sidSpacersHeight = nArgs["SideSpacersHeight"];
123  sidSpacersZ = nArgs["SideSpacersZ"];
124  sidSpacersWidth = nArgs["SideSpacersWidth"];
125  sidSpacersRadShift = nArgs["SideSpacersShift"];
126 
127 }
128 
130 
131  LogDebug("TIDGeom") << "==>> Constructing DDTIDModulePosAlgo...";
132 
133  DDName parentName = parent().name();
134  DDName name;
135 
136  double botfr; // width of side frame at the the bottom of the modules
137  double topfr; // width of side frame at the the top of the modules
138  double kaptonHeight;
139  if (dlHybrid > dlTop) {
140  // ring 1, ring 2
143  kaptonHeight = fullHeight + botfr;
144  } else {
145  // ring 3
146  topfr = topFrameHeight - topFrameOver;
148  kaptonHeight = fullHeight + topfr;
149  }
150 
151  double sideFrameHeight = fullHeight + pitchHeight + botfr + topfr;
152  double zCenter = 0.5 * (sideFrameHeight+boxFrameHeight);
153 
154 
155  // (Re) Compute the envelope for positioning Cool Inserts and Side Spacers (Alumina).
156  double sidfr = sideFrameWidth - sideFrameOver; // width of side frame on the sides of module
157  double dxbot = 0.5*dlBottom + sidfr;
158  double dxtop = 0.5*dlTop + sidfr;
159  double dxtopenv, dxbotenv; // top/bot width of the module envelope trap
160 
161  double tanWafer=(dxtop-dxbot)/fullHeight; //
162  double thetaWafer = atan(tanWafer); // 1/2 of the wafer wedge angle
163 
164  if (dlHybrid > dlTop) {
165  // ring 1, ring 2
166  dxtopenv = dxbot + (dxtop-dxbot)*(fullHeight+pitchHeight+topfr+hybridHeight)/fullHeight;
167  dxbotenv = dxtop - (dxtop-dxbot)*(fullHeight+botfr)/fullHeight;
168  } else {
169  // ring 3
170  dxtopenv = dxbot + (dxtop-dxbot)*(fullHeight+topfr)/fullHeight;
171  dxbotenv = dxbot;
172  }
173 
174  double tanEnv=(dxtopenv-dxbotenv)/(sideFrameHeight+boxFrameHeight); // 1/2 of the envelope wedge angle
175 
176  double xpos=0; double ypos=0; double zpos=0;
177 
178  // Cool Inserts
180  ypos = coolZ;
181 
182  double zCool;
183  int copy=0;
184  DDRotation rot = DDRotation(); // should be different for different elements
185 
186  for (int j1=0; j1<2; j1++){ // j1: 0 inserts below the hybrid
187  // 1 inserts below the wafer
188  if (dlHybrid > dlTop) {
189  zCool = sideFrameHeight+boxFrameHeight-coolRadShift[j1];
190  if ( j1==0 ) zCool -= 0.5*coolHeight;
191  } else {
192  zCool = coolRadShift[j1];
193  if ( j1==0 ) zCool += 0.5*coolHeight;
194  }
195 
196  if ( j1==0 ) {
197  xpos = -0.5*(boxFrameWidth-coolWidth);
198  } else {
199  xpos = -(dxbotenv+(zCool-0.5*coolHeight)*tanEnv-0.5*coolWidth);
200  }
201 
202  zpos = zCool-zCenter;
203  for ( int j2=0; j2<2; j2++) {
204  copy++;
205  cpv.position(name, parentName, copy, DDTranslation(xpos,ypos,zpos), rot);
206  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
207  << copy << " positioned in " << parentName << " at "
208  << DDTranslation(xpos,ypos,zpos) << " with " << rot;
209  xpos = -xpos;
210  }
211  }
212 
213 
214  if ( doSpacers ) {
215  // Bottom Spacers (Alumina)
216  name = DDName(DDSplit(botSpacersName).first, DDSplit(botSpacersName).second);
217  ypos = botSpacersZ;
218 
219  double zBotSpacers;
220  if (dlHybrid > dlTop) {
221  zBotSpacers = sideFrameHeight+boxFrameHeight-0.5*botSpacersHeight;
222  } else {
223  zBotSpacers = 0.5*botSpacersHeight;
224  }
225  zpos = zBotSpacers - zCenter;
226  rot = DDRotation();
227  cpv.position(name, parentName, 1, DDTranslation(0.0,ypos,zpos), rot );
228  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
229  << 1 << " positioned in " << parentName << " at "
230  << DDTranslation(0.0,ypos,zpos) << " with no rotation";
231 
232 
233  // Side Spacers (Alumina)
234  name = DDName(DDSplit(sidSpacersName).first,
235  DDSplit(sidSpacersName).second);
236  ypos = sidSpacersZ;
237 
238  double zSideSpacers;
239  if (dlHybrid > dlTop) {
240  zSideSpacers = sideFrameHeight+boxFrameHeight-sidSpacersRadShift;
241  } else {
242  zSideSpacers = sidSpacersRadShift;
243  }
244  zpos = zSideSpacers - zCenter;
245 
246  copy=0;
247  xpos = dxbotenv+(zSideSpacers-0.5*sidSpacersHeight)*tanEnv-0.5*sidSpacersWidth+sideFrameOver;
248 
249  double phix, phiy, phiz;
250  phix=0.*CLHEP::deg; phiy=90.*CLHEP::deg; phiz=0.*CLHEP::deg;
251 
252  double thetay, thetax;
253  thetay=90.*CLHEP::deg;
254  double thetaz = thetaWafer;
255 
256  for (int j1=0; j1<2; j1++){
257  copy++;
258 
259  // tilt Side Spacers (parallel to Side Frame)
260  thetax = 90.*CLHEP::deg+thetaz;
261  double thetadeg = thetax/CLHEP::deg;
262  if (thetadeg != 0) {
263  std::string arotstr = DDSplit(sidSpacersName).first+dbl_to_string(thetadeg*10.);
264  rot = DDrot(DDName(arotstr, DDSplit(sidSpacersName).second), thetax,
265  phix, thetay, phiy, thetaz, phiz);
266  }
267 
268  cpv.position(name, parentName, copy, DDTranslation(xpos,ypos,zpos), rot);
269  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
270  << copy << " positioned in " << parentName << " at "
271  << DDTranslation(xpos,ypos,zpos) << " with " << rot;
272  xpos = -xpos;
273  thetaz = -thetaz;
274  }
275  }
276 
277  // Loop over detectors to be placed
278  for (int k = 0; k < detectorN; k++) {
279  // Wafer
280  name = DDName(DDSplit(waferName[k]).first, DDSplit(waferName[k]).second);
281  xpos=0;
282  zpos=0;
283  ypos = waferZ[k];
284  double zWafer;
285  if (dlHybrid > dlTop) {
286  zWafer = botfr+0.5*fullHeight;
287  } else {
288  zWafer = boxFrameHeight+botfr+pitchHeight+0.5*fullHeight;
289  }
290  zpos = zWafer - zCenter;
291  DDTranslation tran(xpos, ypos, zpos);
292  std::string rotstr = DDSplit(waferRot[k]).first;
293  std::string rotns;
294  if (rotstr != "NULL") {
295  rotns = DDSplit(waferRot[k]).second;
296  rot = DDRotation(DDName(rotstr, rotns));
297  }
298  cpv.position(name, parentName, k+1, tran, rot);
299  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
300  << k+1 << " positioned in " << parentName << " at "
301  << tran << " with " << rot;
302 
303  //Pitch Adapter
304  name = DDName(DDSplit(pitchName[k]).first, DDSplit(pitchName[k]).second);
305  if (k == 0) {
306  xpos = 0;
307  } else {
308  xpos = 0.5 * fullHeight * sin(detTilt);
309  }
310  ypos = pitchZ[k];
311  double zPitch;
312  if (dlHybrid > dlTop) {
313  zPitch = botfr+fullHeight+0.5*pitchHeight;
314  } else {
315  zPitch = boxFrameHeight+botfr+0.5*pitchHeight;
316  }
317  zpos = zPitch - zCenter;
318  rotstr = DDSplit(pitchRot[k]).first;
319  if (rotstr != "NULL") {
320  rotns = DDSplit(pitchRot[k]).second;
321  rot = DDRotation(DDName(rotstr, rotns));
322  } else {
323  rot = DDRotation();
324  }
325  tran = DDTranslation(xpos,ypos,zpos);
326  cpv.position(name, parentName, k+1, tran, rot);
327  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
328  << k+1 << " positioned in " << parentName << " at "
329  << tran << " with " << rot;
330 
331  // Hybrid
332  name = DDName(DDSplit(hybridName).first, DDSplit(hybridName).second);
333  ypos = hybridZ[k];
334  double zHybrid;
335  if (dlHybrid > dlTop) {
336  zHybrid = botfr+fullHeight+pitchHeight+0.5*hybridHeight;
337  } else {
338  zHybrid = 0.5*hybridHeight;
339  }
340  zpos = zHybrid - zCenter;
341  tran = DDTranslation(0,ypos,zpos);
342  rot = DDRotation();
343  cpv.position(name, parentName, k+1, tran, rot);
344  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
345  << k+1 << " positioned in " << parentName << " at "
346  << tran << " with " << rot;
347 
348 
349  // Box frame
350  name = DDName(DDSplit(boxFrameName).first, DDSplit(boxFrameName).second);
351  ypos = boxFrameZ[k];
352  double zBoxFrame;
353  if (dlHybrid > dlTop) {
354  zBoxFrame = sideFrameHeight+0.5*boxFrameHeight;
355  } else {
356  zBoxFrame = 0.5*boxFrameHeight;
357  }
358  zpos = zBoxFrame - zCenter;
359  tran = DDTranslation(0,ypos,zpos);
360  rot = DDRotation();
361  cpv.position(name, parentName, k+1, tran, rot);
362  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
363  << k+1 << " positioned in " << parentName << " at "
364  << tran << " with " << rot;
365 
366  // Side frame
367  name = DDName(DDSplit(sideFrameName[k]).first,
368  DDSplit(sideFrameName[k]).second);
369  ypos = sideFrameZ[k];
370  double zSideFrame;
371  if (dlHybrid > dlTop) {
372  zSideFrame = 0.5*sideFrameHeight;
373  } else {
374  zSideFrame = boxFrameHeight+0.5*sideFrameHeight;
375  }
376  zpos = zSideFrame-zCenter;
377  rotstr = DDSplit(sideFrameRot[k]).first;
378  if (rotstr != "NULL") {
379  rotns = DDSplit(sideFrameRot[k]).second;
380  rot = DDRotation(DDName(rotstr, rotns));
381  } else {
382  rot = DDRotation();
383  }
384  tran = DDTranslation(0,ypos,zpos);
385  cpv.position(name, parentName, k+1, tran, rot);
386  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
387  << k+1 << " positioned in " << parentName << " at "
388  << tran << " with " << rot;
389 
390 
391  // Kapton circuit
392  name = DDName(DDSplit(kaptonName[k]).first, DDSplit(kaptonName[k]).second);
393  ypos = kaptonZ[k];
394  double zKapton;
395  double kaptonExtraHeight=0;
396  if (dlHybrid > dlTop) {
397  if ( k == 1 ) kaptonExtraHeight = dlTop*sin(detTilt)-fullHeight*(1-cos(detTilt));
398  kaptonExtraHeight = 0.5*fabs(kaptonExtraHeight);
399  zKapton = 0.5*(kaptonHeight+kaptonExtraHeight);
400  } else {
401  if ( k == 1 ) kaptonExtraHeight = dlBottom*sin(detTilt)-fullHeight*(1-cos(detTilt));
402  kaptonExtraHeight = 0.5*fabs(kaptonExtraHeight);
403  zKapton = boxFrameHeight+sideFrameHeight-0.5*(kaptonHeight+kaptonExtraHeight);
404  }
405  zpos = zKapton-zCenter;
406  rotstr = DDSplit(kaptonRot[k]).first;
407  if (rotstr != "NULL") {
408  rotns = DDSplit(kaptonRot[k]).second;
409  rot = DDRotation(DDName(rotstr, rotns));
410  } else {
411  rot = DDRotation();
412  }
413  tran = DDTranslation(0,ypos,zpos);
414  cpv.position(name, parentName, k+1, tran, rot);
415  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
416  << k+1 << " positioned in " << parentName << " at "
417  << tran << " with " << rot;
418  }
419 
420  LogDebug("TIDGeom") << "<<== End of DDTIDModulePosAlgo positioning ...";
421 }
422 
423 
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
std::vector< double > pitchZ
list parent
Definition: dbtoconf.py:74
std::vector< std::string > pitchName
std::string botSpacersName
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
void position(const DDLogicalPart &self, const DDLogicalPart &parent, std::string copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=NULL)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:18
void execute(DDCompactView &cpv)
std::string sidSpacersName
std::string dbl_to_string(const double &in)
Converts only the integer part of a double to a string.
Definition: DDutils.cc:12
std::vector< std::string > sideFrameName
type of data representation of DDCompactView
Definition: DDCompactView.h:77
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
U second(std::pair< T, U > const &p)
std::vector< double > coolRadShift
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< std::string > waferRot
std::vector< double > hybridZ
std::vector< std::string > waferName
bool first
Definition: L1TdeRCT.cc:75
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
int k[5][pyjets_maxn]
std::vector< std::string > pitchRot
std::vector< std::string > sideFrameRot
std::vector< double > sideFrameZ
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:4
std::vector< std::string > kaptonRot
std::vector< double > waferZ
std::vector< double > kaptonZ
std::vector< std::string > kaptonName
std::vector< double > boxFrameZ