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 
134  double botfr; // width of side frame at the the bottom of the modules
135  double topfr; // width of side frame at the the top of the modules
136  double kaptonHeight;
137  if (dlHybrid > dlTop) {
138  // ring 1, ring 2
141  kaptonHeight = fullHeight + botfr;
142  } else {
143  // ring 3
144  topfr = topFrameHeight - topFrameOver;
146  kaptonHeight = fullHeight + topfr;
147  }
148 
149  double sideFrameHeight = fullHeight + pitchHeight + botfr + topfr;
150  double zCenter = 0.5 * (sideFrameHeight+boxFrameHeight);
151 
152 
153  // (Re) Compute the envelope for positioning Cool Inserts and Side Spacers (Alumina).
154  double sidfr = sideFrameWidth - sideFrameOver; // width of side frame on the sides of module
155  double dxbot = 0.5*dlBottom + sidfr;
156  double dxtop = 0.5*dlTop + sidfr;
157  double dxtopenv, dxbotenv; // top/bot width of the module envelope trap
158 
159  double tanWafer=(dxtop-dxbot)/fullHeight; //
160  double thetaWafer = atan(tanWafer); // 1/2 of the wafer wedge angle
161 
162  if (dlHybrid > dlTop) {
163  // ring 1, ring 2
164  dxtopenv = dxbot + (dxtop-dxbot)*(fullHeight+pitchHeight+topfr+hybridHeight)/fullHeight;
165  dxbotenv = dxtop - (dxtop-dxbot)*(fullHeight+botfr)/fullHeight;
166  } else {
167  // ring 3
168  dxtopenv = dxbot + (dxtop-dxbot)*(fullHeight+topfr)/fullHeight;
169  dxbotenv = dxbot;
170  }
171 
172  double tanEnv=(dxtopenv-dxbotenv)/(sideFrameHeight+boxFrameHeight); // 1/2 of the envelope wedge angle
173 
174  double xpos=0; double ypos=0; double zpos=0;
175 
176  // Cool Inserts
178  ypos = coolZ;
179 
180  double zCool;
181  int copy=0;
182  DDRotation rot = DDRotation(); // should be different for different elements
183 
184  for (int j1=0; j1<2; j1++){ // j1: 0 inserts below the hybrid
185  // 1 inserts below the wafer
186  if (dlHybrid > dlTop) {
187  zCool = sideFrameHeight+boxFrameHeight-coolRadShift[j1];
188  if ( j1==0 ) zCool -= 0.5*coolHeight;
189  } else {
190  zCool = coolRadShift[j1];
191  if ( j1==0 ) zCool += 0.5*coolHeight;
192  }
193 
194  if ( j1==0 ) {
195  xpos = -0.5*(boxFrameWidth-coolWidth);
196  } else {
197  xpos = -(dxbotenv+(zCool-0.5*coolHeight)*tanEnv-0.5*coolWidth);
198  }
199 
200  zpos = zCool-zCenter;
201  for ( int j2=0; j2<2; j2++) {
202  copy++;
203  cpv.position(name, parentName, copy, DDTranslation(xpos,ypos,zpos), rot);
204  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
205  << copy << " positioned in " << parentName << " at "
206  << DDTranslation(xpos,ypos,zpos) << " with " << rot;
207  xpos = -xpos;
208  }
209  }
210 
211 
212  if ( doSpacers ) {
213  // Bottom Spacers (Alumina)
214  DDName name = DDName(DDSplit(botSpacersName).first, DDSplit(botSpacersName).second);
215  ypos = botSpacersZ;
216 
217  double zBotSpacers;
218  if (dlHybrid > dlTop) {
219  zBotSpacers = sideFrameHeight+boxFrameHeight-0.5*botSpacersHeight;
220  } else {
221  zBotSpacers = 0.5*botSpacersHeight;
222  }
223  zpos = zBotSpacers - zCenter;
224  rot = DDRotation();
225  cpv.position(name, parentName, 1, DDTranslation(0.0,ypos,zpos), rot );
226  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
227  << 1 << " positioned in " << parentName << " at "
228  << DDTranslation(0.0,ypos,zpos) << " with no rotation";
229 
230 
231  // Side Spacers (Alumina)
232  name = DDName(DDSplit(sidSpacersName).first,
233  DDSplit(sidSpacersName).second);
234  ypos = sidSpacersZ;
235 
236  double zSideSpacers;
237  if (dlHybrid > dlTop) {
238  zSideSpacers = sideFrameHeight+boxFrameHeight-sidSpacersRadShift;
239  } else {
240  zSideSpacers = sidSpacersRadShift;
241  }
242  zpos = zSideSpacers - zCenter;
243 
244  copy=0;
245  xpos = dxbotenv+(zSideSpacers-0.5*sidSpacersHeight)*tanEnv-0.5*sidSpacersWidth+sideFrameOver;
246 
247  double phix, phiy, phiz;
248  phix=0.*CLHEP::deg; phiy=90.*CLHEP::deg; phiz=0.*CLHEP::deg;
249 
250  double thetay, thetax;
251  thetay=90.*CLHEP::deg;
252  double thetaz = thetaWafer;
253 
254  for (int j1=0; j1<2; j1++){
255  copy++;
256 
257  // tilt Side Spacers (parallel to Side Frame)
258  thetax = 90.*CLHEP::deg+thetaz;
259  double thetadeg = thetax/CLHEP::deg;
260  if (thetadeg != 0) {
261  std::string arotstr = DDSplit(sidSpacersName).first + std::to_string(thetadeg*10.);
262  rot = DDrot(DDName(arotstr, DDSplit(sidSpacersName).second), thetax,
263  phix, thetay, phiy, thetaz, phiz);
264  }
265 
266  cpv.position(name, parentName, copy, DDTranslation(xpos,ypos,zpos), rot);
267  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
268  << copy << " positioned in " << parentName << " at "
269  << DDTranslation(xpos,ypos,zpos) << " with " << rot;
270  xpos = -xpos;
271  thetaz = -thetaz;
272  }
273  }
274 
275  // Loop over detectors to be placed
276  for (int k = 0; k < detectorN; k++) {
277  // Wafer
278  name = DDName(DDSplit(waferName[k]).first, DDSplit(waferName[k]).second);
279  xpos=0;
280  ypos = waferZ[k];
281  double zWafer;
282  if (dlHybrid > dlTop) {
283  zWafer = botfr+0.5*fullHeight;
284  } else {
285  zWafer = boxFrameHeight+botfr+pitchHeight+0.5*fullHeight;
286  }
287  zpos = zWafer - zCenter;
288  DDTranslation tran(xpos, ypos, zpos);
289  std::string rotstr = DDSplit(waferRot[k]).first;
290  std::string rotns;
291  if (rotstr != "NULL") {
292  rotns = DDSplit(waferRot[k]).second;
293  rot = DDRotation(DDName(rotstr, rotns));
294  }
295  cpv.position(name, parentName, k+1, tran, rot);
296  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
297  << k+1 << " positioned in " << parentName << " at "
298  << tran << " with " << rot;
299 
300  //Pitch Adapter
301  name = DDName(DDSplit(pitchName[k]).first, DDSplit(pitchName[k]).second);
302  if (k == 0) {
303  xpos = 0;
304  } else {
305  xpos = 0.5 * fullHeight * sin(detTilt);
306  }
307  ypos = pitchZ[k];
308  double zPitch;
309  if (dlHybrid > dlTop) {
310  zPitch = botfr+fullHeight+0.5*pitchHeight;
311  } else {
312  zPitch = boxFrameHeight+botfr+0.5*pitchHeight;
313  }
314  zpos = zPitch - zCenter;
315  rotstr = DDSplit(pitchRot[k]).first;
316  if (rotstr != "NULL") {
317  rotns = DDSplit(pitchRot[k]).second;
318  rot = DDRotation(DDName(rotstr, rotns));
319  } else {
320  rot = DDRotation();
321  }
322  tran = DDTranslation(xpos,ypos,zpos);
323  cpv.position(name, parentName, k+1, tran, rot);
324  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
325  << k+1 << " positioned in " << parentName << " at "
326  << tran << " with " << rot;
327 
328  // Hybrid
329  name = DDName(DDSplit(hybridName).first, DDSplit(hybridName).second);
330  ypos = hybridZ[k];
331  double zHybrid;
332  if (dlHybrid > dlTop) {
333  zHybrid = botfr+fullHeight+pitchHeight+0.5*hybridHeight;
334  } else {
335  zHybrid = 0.5*hybridHeight;
336  }
337  zpos = zHybrid - zCenter;
338  tran = DDTranslation(0,ypos,zpos);
339  rot = DDRotation();
340  cpv.position(name, parentName, k+1, tran, rot);
341  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
342  << k+1 << " positioned in " << parentName << " at "
343  << tran << " with " << rot;
344 
345 
346  // Box frame
347  name = DDName(DDSplit(boxFrameName).first, DDSplit(boxFrameName).second);
348  ypos = boxFrameZ[k];
349  double zBoxFrame;
350  if (dlHybrid > dlTop) {
351  zBoxFrame = sideFrameHeight+0.5*boxFrameHeight;
352  } else {
353  zBoxFrame = 0.5*boxFrameHeight;
354  }
355  zpos = zBoxFrame - zCenter;
356  tran = DDTranslation(0,ypos,zpos);
357  rot = DDRotation();
358  cpv.position(name, parentName, k+1, tran, rot);
359  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
360  << k+1 << " positioned in " << parentName << " at "
361  << tran << " with " << rot;
362 
363  // Side frame
364  name = DDName(DDSplit(sideFrameName[k]).first,
365  DDSplit(sideFrameName[k]).second);
366  ypos = sideFrameZ[k];
367  double zSideFrame;
368  if (dlHybrid > dlTop) {
369  zSideFrame = 0.5*sideFrameHeight;
370  } else {
371  zSideFrame = boxFrameHeight+0.5*sideFrameHeight;
372  }
373  zpos = zSideFrame-zCenter;
374  rotstr = DDSplit(sideFrameRot[k]).first;
375  if (rotstr != "NULL") {
376  rotns = DDSplit(sideFrameRot[k]).second;
377  rot = DDRotation(DDName(rotstr, rotns));
378  } else {
379  rot = DDRotation();
380  }
381  tran = DDTranslation(0,ypos,zpos);
382  cpv.position(name, parentName, k+1, tran, rot);
383  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
384  << k+1 << " positioned in " << parentName << " at "
385  << tran << " with " << rot;
386 
387 
388  // Kapton circuit
389  name = DDName(DDSplit(kaptonName[k]).first, DDSplit(kaptonName[k]).second);
390  ypos = kaptonZ[k];
391  double zKapton;
392  double kaptonExtraHeight=0;
393  if (dlHybrid > dlTop) {
394  if ( k == 1 ) kaptonExtraHeight = dlTop*sin(detTilt)-fullHeight*(1-cos(detTilt));
395  kaptonExtraHeight = 0.5*fabs(kaptonExtraHeight);
396  zKapton = 0.5*(kaptonHeight+kaptonExtraHeight);
397  } else {
398  if ( k == 1 ) kaptonExtraHeight = dlBottom*sin(detTilt)-fullHeight*(1-cos(detTilt));
399  kaptonExtraHeight = 0.5*fabs(kaptonExtraHeight);
400  zKapton = boxFrameHeight+sideFrameHeight-0.5*(kaptonHeight+kaptonExtraHeight);
401  }
402  zpos = zKapton-zCenter;
403  rotstr = DDSplit(kaptonRot[k]).first;
404  if (rotstr != "NULL") {
405  rotns = DDSplit(kaptonRot[k]).second;
406  rot = DDRotation(DDName(rotstr, rotns));
407  } else {
408  rot = DDRotation();
409  }
410  tran = DDTranslation(0,ypos,zpos);
411  cpv.position(name, parentName, k+1, tran, rot);
412  LogDebug("TIDGeom") << "DDTIDModulePosAlgo test: " << name <<" number "
413  << k+1 << " positioned in " << parentName << " at "
414  << tran << " with " << rot;
415  }
416 
417  LogDebug("TIDGeom") << "<<== End of DDTIDModulePosAlgo positioning ...";
418 }
419 
420 
#define LogDebug(id)
void execute(DDCompactView &cpv) override
std::vector< double > pitchZ
std::vector< std::string > pitchName
def copy(args, dbName)
std::string botSpacersName
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
std::string sidSpacersName
std::vector< std::string > sideFrameName
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
U second(std::pair< T, U > const &p)
std::vector< double > coolRadShift
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< std::string > waferRot
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:80
std::vector< double > hybridZ
std::vector< std::string > waferName
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
int k[5][pyjets_maxn]
~DDTIDModulePosAlgo() override
std::vector< std::string > pitchRot
std::vector< std::string > sideFrameRot
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=0)
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:3
std::vector< std::string > kaptonRot
std::vector< double > waferZ
std::vector< double > kaptonZ
std::vector< std::string > kaptonName
std::vector< double > boxFrameZ