CMS 3D CMS Logo

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