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  ypos = waferZ[k];
283  double zWafer;
284  if (dlHybrid > dlTop) {
285  zWafer = botfr+0.5*fullHeight;
286  } else {
287  zWafer = boxFrameHeight+botfr+pitchHeight+0.5*fullHeight;
288  }
289  zpos = zWafer - zCenter;
290  DDTranslation tran(xpos, ypos, zpos);
291  std::string rotstr = DDSplit(waferRot[k]).first;
292  std::string rotns;
293  if (rotstr != "NULL") {
294  rotns = DDSplit(waferRot[k]).second;
295  rot = DDRotation(DDName(rotstr, rotns));
296  }
297  cpv.position(name, parentName, k+1, tran, rot);
298  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
299  << k+1 << " positioned in " << parentName << " at "
300  << tran << " with " << rot;
301 
302  //Pitch Adapter
303  name = DDName(DDSplit(pitchName[k]).first, DDSplit(pitchName[k]).second);
304  if (k == 0) {
305  xpos = 0;
306  } else {
307  xpos = 0.5 * fullHeight * sin(detTilt);
308  }
309  ypos = pitchZ[k];
310  double zPitch;
311  if (dlHybrid > dlTop) {
312  zPitch = botfr+fullHeight+0.5*pitchHeight;
313  } else {
314  zPitch = boxFrameHeight+botfr+0.5*pitchHeight;
315  }
316  zpos = zPitch - zCenter;
317  rotstr = DDSplit(pitchRot[k]).first;
318  if (rotstr != "NULL") {
319  rotns = DDSplit(pitchRot[k]).second;
320  rot = DDRotation(DDName(rotstr, rotns));
321  } else {
322  rot = DDRotation();
323  }
324  tran = DDTranslation(xpos,ypos,zpos);
325  cpv.position(name, parentName, k+1, tran, rot);
326  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
327  << k+1 << " positioned in " << parentName << " at "
328  << tran << " with " << rot;
329 
330  // Hybrid
331  name = DDName(DDSplit(hybridName).first, DDSplit(hybridName).second);
332  ypos = hybridZ[k];
333  double zHybrid;
334  if (dlHybrid > dlTop) {
335  zHybrid = botfr+fullHeight+pitchHeight+0.5*hybridHeight;
336  } else {
337  zHybrid = 0.5*hybridHeight;
338  }
339  zpos = zHybrid - zCenter;
340  tran = DDTranslation(0,ypos,zpos);
341  rot = DDRotation();
342  cpv.position(name, parentName, k+1, tran, rot);
343  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
344  << k+1 << " positioned in " << parentName << " at "
345  << tran << " with " << rot;
346 
347 
348  // Box frame
349  name = DDName(DDSplit(boxFrameName).first, DDSplit(boxFrameName).second);
350  ypos = boxFrameZ[k];
351  double zBoxFrame;
352  if (dlHybrid > dlTop) {
353  zBoxFrame = sideFrameHeight+0.5*boxFrameHeight;
354  } else {
355  zBoxFrame = 0.5*boxFrameHeight;
356  }
357  zpos = zBoxFrame - zCenter;
358  tran = DDTranslation(0,ypos,zpos);
359  rot = DDRotation();
360  cpv.position(name, parentName, k+1, tran, rot);
361  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
362  << k+1 << " positioned in " << parentName << " at "
363  << tran << " with " << rot;
364 
365  // Side frame
366  name = DDName(DDSplit(sideFrameName[k]).first,
367  DDSplit(sideFrameName[k]).second);
368  ypos = sideFrameZ[k];
369  double zSideFrame;
370  if (dlHybrid > dlTop) {
371  zSideFrame = 0.5*sideFrameHeight;
372  } else {
373  zSideFrame = boxFrameHeight+0.5*sideFrameHeight;
374  }
375  zpos = zSideFrame-zCenter;
376  rotstr = DDSplit(sideFrameRot[k]).first;
377  if (rotstr != "NULL") {
378  rotns = DDSplit(sideFrameRot[k]).second;
379  rot = DDRotation(DDName(rotstr, rotns));
380  } else {
381  rot = DDRotation();
382  }
383  tran = DDTranslation(0,ypos,zpos);
384  cpv.position(name, parentName, k+1, tran, rot);
385  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
386  << k+1 << " positioned in " << parentName << " at "
387  << tran << " with " << rot;
388 
389 
390  // Kapton circuit
391  name = DDName(DDSplit(kaptonName[k]).first, DDSplit(kaptonName[k]).second);
392  ypos = kaptonZ[k];
393  double zKapton;
394  double kaptonExtraHeight=0;
395  if (dlHybrid > dlTop) {
396  if ( k == 1 ) kaptonExtraHeight = dlTop*sin(detTilt)-fullHeight*(1-cos(detTilt));
397  kaptonExtraHeight = 0.5*fabs(kaptonExtraHeight);
398  zKapton = 0.5*(kaptonHeight+kaptonExtraHeight);
399  } else {
400  if ( k == 1 ) kaptonExtraHeight = dlBottom*sin(detTilt)-fullHeight*(1-cos(detTilt));
401  kaptonExtraHeight = 0.5*fabs(kaptonExtraHeight);
402  zKapton = boxFrameHeight+sideFrameHeight-0.5*(kaptonHeight+kaptonExtraHeight);
403  }
404  zpos = zKapton-zCenter;
405  rotstr = DDSplit(kaptonRot[k]).first;
406  if (rotstr != "NULL") {
407  rotns = DDSplit(kaptonRot[k]).second;
408  rot = DDRotation(DDName(rotstr, rotns));
409  } else {
410  rot = DDRotation();
411  }
412  tran = DDTranslation(0,ypos,zpos);
413  cpv.position(name, parentName, k+1, tran, rot);
414  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
415  << k+1 << " positioned in " << parentName << " at "
416  << tran << " with " << rot;
417  }
418 
419  LogDebug("TIDGeom") << "<<== End of DDTIDModulePosAlgo positioning ...";
420 }
421 
422 
#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:14
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
DDRotation DDrot(const DDName &name, DDRotationMatrix *rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:90
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