CMS 3D CMS Logo

DDEcalEndcapAlgo.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
6 // Header files for endcap supercrystal geometry
8 #include <CLHEP/Geometry/Transform3D.h>
9 
10 #include <string>
11 #include <vector>
12 
13 using namespace angle_units::operators;
14 
15 //#define EDM_ML_DEBUG
16 
17 namespace {
18  struct Endcap {
19  std::string mat;
20  double zOff;
21 
22  std::string quaName;
23  std::string quaMat;
24 
25  std::string crysMat;
26  std::string wallMat;
27 
28  double crysLength;
29  double crysRear;
30  double crysFront;
31  double sCELength;
32  double sCERear;
33  double sCEFront;
34  double sCALength;
35  double sCARear;
36  double sCAFront;
37  double sCAWall;
38  double sCHLength;
39  double sCHSide;
40 
41  double nSCTypes;
42  std::vector<double> vecEESCProf;
43  double nColumns;
44  std::vector<double> vecEEShape;
45  double nSCCutaway;
46  std::vector<double> vecEESCCutaway;
47  double nSCquad;
48  std::vector<double> vecEESCCtrs;
49  double nCRSC;
50  std::vector<double> vecEECRCtrs;
51 
52  std::array<double, 3> cutParms;
53  std::string cutBoxName;
54 
55  std::string envName;
56  std::string alvName;
57  std::string intName;
58  std::string cryName;
59 
60  DDTranslation cryFCtr[5][5];
61  DDTranslation cryRCtr[5][5];
62  DDTranslation scrFCtr[10][10];
63  DDTranslation scrRCtr[10][10];
64 
65  double pFHalf;
66  double pFFifth;
67  double pF45;
68 
69  std::vector<double> vecEESCLims;
70 
71  double iLength;
72  double iXYOff;
73  double cryZOff;
74  double zFront;
75  };
76 
77  const DDRotationMatrix& myrot(cms::DDNamespace& ns, const std::string& nam, const DDRotationMatrix& r) {
78  ns.addRotation(nam, r);
79  return ns.rotation(ns.prepend(nam));
80  }
81 
82  std::string_view mynamespace(std::string_view input) {
83  std::string_view v = input;
84  auto trim_pos = v.find(':');
85  if (trim_pos != v.npos)
86  v.remove_suffix(v.size() - (trim_pos + 1));
87  return v;
88  }
89 
90  void placeEFRYn00(dd4hep::Volume& eeSCALog,
91  const dd4hep::Volume& eeCRLog,
92  int copyNum,
93  cms::DDNamespace& ns,
94  const std::string& rname,
95  DDEcalEndcapTrapX& crystal,
96  double cryZOff) {
97  // The "EECrRoC1R1" rotation is too small. It is ignored by ROOT when the volume is placed. In order for the
98  // volume to be placed with some rotation, the original rotation is increased by 1%, which is just enough for
99  // the revised rotation to pass ROOT's check for a valid, non-identity rotation. It is hoped that such a small
100  // change in a tiny rotaion will have no negative effects in the geometry.
101  //
102  // ROOT version where issue is observed: ROOT 6.22/09
103  // TGeoRotation::CheckMatrix() is the method that checks rotations. When it determines a rotation is too
104  // small, it sets the rotation to be ignored.
105  // Original rotation angles: x = -7.045281e-07, y = 7.045385e-07, z = 0
106  // Adjusted rotation angles: x = -7.115734e-07, y = 7.115839e-07, z = 0
107 
108  double xx, xy, xz, yx, yy, yz, zx, zy, zz;
109  auto rotAdjusted = crystal.rotation();
110  rotAdjusted.GetComponents(xx, xy, xz, yx, yy, yz, zx, zy, zz);
111  double xtheta = atan2(zy, zz);
112  double distyz = sqrt(zy * zy + zz * zz);
113  double ytheta = atan2(-zx, distyz);
114  double ztheta = atan2(yx, xx);
115  LogDebug("EcalGeom") << "Original " << rname << " rotation angles: xtheta = " << std::setprecision(18) << xtheta
116  << ", distyz = " << distyz << ", ytheta = " << ytheta << ", ztheta = " << ztheta;
117  double increase = 1.01; // Increase rotation angle by 1%
118  xtheta *= increase;
119  ytheta *= increase;
120  LogDebug("EcalGeom") << "Adjusted (+1%) " << rname << " rotation angles: xtheta = " << std::setprecision(18)
121  << xtheta << ", distyz = " << distyz << ", ytheta = " << ytheta << ", ztheta = " << ztheta;
122  double xdiag = cos(xtheta), xoff = sin(xtheta);
123  double ydiag = cos(ytheta), yoff = sin(ytheta);
124  DDRotationMatrix xrot(1., 0., 0., 0., xdiag, -xoff, 0., xoff, xdiag);
125  DDRotationMatrix yrot(ydiag, 0., yoff, 0., 1., 0., -yoff, 0., ydiag);
126  rotAdjusted = yrot * xrot;
127  eeSCALog.placeVolume(
128  eeCRLog,
129  copyNum,
130  dd4hep::Transform3D(
131  myrot(ns, rname, rotAdjusted),
132  dd4hep::Position(crystal.centrePos().x(), crystal.centrePos().y(), crystal.centrePos().z() - cryZOff)));
133  }
134 
135 } // namespace
136 
137 static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
138  BenchmarkGrd counter("DDEcalEndcapAlgo");
139  cms::DDNamespace ns(ctxt, e, true);
140  cms::DDAlgoArguments args(ctxt, e);
141 
142  // TRICK!
143  std::string myns{mynamespace(args.parentName()).data(), mynamespace(args.parentName()).size()};
144 
145  Endcap ee;
146  ee.mat = args.str("EEMat");
147  ee.zOff = args.dble("EEzOff");
148 
149  ee.quaName = args.str("EEQuaName");
150  ee.quaMat = args.str("EEQuaMat");
151  ee.crysMat = args.str("EECrysMat");
152  ee.wallMat = args.str("EEWallMat");
153  ee.crysLength = args.dble("EECrysLength");
154  ee.crysRear = args.dble("EECrysRear");
155  ee.crysFront = args.dble("EECrysFront");
156  ee.sCELength = args.dble("EESCELength");
157  ee.sCERear = args.dble("EESCERear");
158  ee.sCEFront = args.dble("EESCEFront");
159  ee.sCALength = args.dble("EESCALength");
160  ee.sCARear = args.dble("EESCARear");
161  ee.sCAFront = args.dble("EESCAFront");
162  ee.sCAWall = args.dble("EESCAWall");
163  ee.sCHLength = args.dble("EESCHLength");
164  ee.sCHSide = args.dble("EESCHSide");
165  ee.nSCTypes = args.dble("EEnSCTypes");
166  ee.nColumns = args.dble("EEnColumns");
167  ee.nSCCutaway = args.dble("EEnSCCutaway");
168  ee.nSCquad = args.dble("EEnSCquad");
169  ee.nCRSC = args.dble("EEnCRSC");
170  ee.vecEESCProf = args.vecDble("EESCProf");
171  ee.vecEEShape = args.vecDble("EEShape");
172  ee.vecEESCCutaway = args.vecDble("EESCCutaway");
173  ee.vecEESCCtrs = args.vecDble("EESCCtrs");
174  ee.vecEECRCtrs = args.vecDble("EECRCtrs");
175 
176  ee.cutBoxName = args.str("EECutBoxName");
177 
178  ee.envName = args.str("EEEnvName");
179  ee.alvName = args.str("EEAlvName");
180  ee.intName = args.str("EEIntName");
181  ee.cryName = args.str("EECryName");
182 
183  ee.pFHalf = args.dble("EEPFHalf");
184  ee.pFFifth = args.dble("EEPFFifth");
185  ee.pF45 = args.dble("EEPF45");
186 
187  ee.vecEESCLims = args.vecDble("EESCLims");
188  ee.iLength = args.dble("EEiLength");
189  ee.iXYOff = args.dble("EEiXYOff");
190  ee.cryZOff = args.dble("EECryZOff");
191  ee.zFront = args.dble("EEzFront");
192 
193  // Position supercrystals in EE Quadrant
194 
195  //********************************* cutbox for trimming edge SCs
196  const double cutWid(ee.sCERear / sqrt(2.));
197  ee.cutParms[0] = cutWid;
198  ee.cutParms[1] = cutWid;
199  ee.cutParms[2] = ee.sCELength / sqrt(2.);
200  dd4hep::Solid eeCutBox = dd4hep::Box(ee.cutBoxName, ee.cutParms[0], ee.cutParms[1], ee.cutParms[2]);
201  //**************************************************************
202 
203  const double zFix(ee.zFront - 3172 * dd4hep::mm); // fix for changing z offset
204 
205  //** fill supercrystal front and rear center positions from xml input
206  for (unsigned int iC(0); iC != (unsigned int)ee.nSCquad; ++iC) {
207  const unsigned int iOff(8 * iC);
208  const unsigned int ix((unsigned int)ee.vecEESCCtrs[iOff + 0]);
209  const unsigned int iy((unsigned int)ee.vecEESCCtrs[iOff + 1]);
210 
211  assert(ix > 0 && ix < 11 && iy > 0 && iy < 11);
212 
213  ee.scrFCtr[ix - 1][iy - 1] =
214  DDTranslation(ee.vecEESCCtrs[iOff + 2], ee.vecEESCCtrs[iOff + 4], ee.vecEESCCtrs[iOff + 6] + zFix);
215 
216  ee.scrRCtr[ix - 1][iy - 1] =
217  DDTranslation(ee.vecEESCCtrs[iOff + 3], ee.vecEESCCtrs[iOff + 5], ee.vecEESCCtrs[iOff + 7] + zFix);
218  }
219 
220  //** fill crystal front and rear center positions from xml input
221  for (unsigned int iC(0); iC != 25; ++iC) {
222  const unsigned int iOff(8 * iC);
223  const unsigned int ix((unsigned int)ee.vecEECRCtrs[iOff + 0]);
224  const unsigned int iy((unsigned int)ee.vecEECRCtrs[iOff + 1]);
225 
226  assert(ix > 0 && ix < 6 && iy > 0 && iy < 6);
227 
228  ee.cryFCtr[ix - 1][iy - 1] =
229  DDTranslation(ee.vecEECRCtrs[iOff + 2], ee.vecEECRCtrs[iOff + 4], ee.vecEECRCtrs[iOff + 6]);
230 
231  ee.cryRCtr[ix - 1][iy - 1] =
232  DDTranslation(ee.vecEECRCtrs[iOff + 3], ee.vecEECRCtrs[iOff + 5], ee.vecEECRCtrs[iOff + 7]);
233  }
234 
235  dd4hep::Solid eeCRSolid = dd4hep::Trap(ee.cryName,
236  0.5 * ee.crysLength,
237  atan((ee.crysRear - ee.crysFront) / (sqrt(2.) * ee.crysLength)),
238  45._deg,
239  0.5 * ee.crysFront,
240  0.5 * ee.crysFront,
241  0.5 * ee.crysFront,
242  0._deg,
243  0.5 * ee.crysRear,
244  0.5 * ee.crysRear,
245  0.5 * ee.crysRear,
246  0._deg);
247 #ifdef EDM_ML_DEBUG
248  edm::LogVerbatim("EcalGeom") << eeCRSolid.name() << " Trap with parameters: " << cms::convert2mm(0.5 * ee.crysLength)
249  << ":" << (atan((ee.crysRear - ee.crysFront) / (sqrt(2.) * ee.crysLength))) << ":"
250  << 45._deg << ":" << cms::convert2mm(0.5 * ee.crysFront) << ":"
251  << cms::convert2mm(0.5 * ee.crysFront) << ":" << cms::convert2mm(0.5 * ee.crysFront)
252  << ":" << 0._deg << ":" << cms::convert2mm(0.5 * ee.crysRear) << ":"
253  << cms::convert2mm(0.5 * ee.crysRear) << ":" << cms::convert2mm(0.5 * ee.crysRear) << ":"
254  << 0._deg;
255 #endif
256  dd4hep::Volume eeCRLog = dd4hep::Volume(myns + ee.cryName, eeCRSolid, ns.material(ee.crysMat));
257 
258  for (unsigned int isc(0); isc < ee.nSCTypes; ++isc) {
259  unsigned int iSCType = isc + 1;
260  const std::string anum(std::to_string(iSCType));
261  const double eFront(0.5 * ee.sCEFront);
262  const double eRear(0.5 * ee.sCERear);
263  const double eAng(atan((ee.sCERear - ee.sCEFront) / (sqrt(2.) * ee.sCELength)));
264  const double ffived(45_deg);
265  const double zerod(0_deg);
266  std::string eeSCEnvName(1 == iSCType ? ee.envName + std::to_string(iSCType)
267  : (ee.envName + std::to_string(iSCType) + "Tmp"));
268  dd4hep::Solid eeSCEnv = ns.addSolidNS(
269  eeSCEnvName,
270  dd4hep::Trap(
271  eeSCEnvName, 0.5 * ee.sCELength, eAng, ffived, eFront, eFront, eFront, zerod, eRear, eRear, eRear, zerod));
272 #ifdef EDM_ML_DEBUG
273  edm::LogVerbatim("EcalGeom") << eeSCEnv.name() << " Trap with parameters: " << cms::convert2mm(0.5 * ee.sCELength)
274  << ":" << eAng << ":" << ffived << ":" << cms::convert2mm(eFront) << ":"
275  << cms::convert2mm(eFront) << ":" << cms::convert2mm(eFront) << ":" << zerod << ":"
276  << cms::convert2mm(eRear) << ":" << cms::convert2mm(eRear) << ":"
277  << cms::convert2mm(eRear) << ":" << zerod;
278 #endif
279 
280  const double aFront(0.5 * ee.sCAFront);
281  const double aRear(0.5 * ee.sCARear);
282  const double aAng(atan((ee.sCARear - ee.sCAFront) / (sqrt(2.) * ee.sCALength)));
283  std::string eeSCAlvName(
284  (1 == iSCType ? ee.alvName + std::to_string(iSCType) : (ee.alvName + std::to_string(iSCType) + "Tmp")));
285  dd4hep::Solid eeSCAlv = ns.addSolidNS(
286  eeSCAlvName,
287  dd4hep::Trap(
288  eeSCAlvName, 0.5 * ee.sCALength, aAng, ffived, aFront, aFront, aFront, zerod, aRear, aRear, aRear, zerod));
289 #ifdef EDM_ML_DEBUG
290  edm::LogVerbatim("EcalGeom") << eeSCAlv.name() << " Trap with parameters: " << cms::convert2mm(0.5 * ee.sCALength)
291  << ":" << aAng << ":" << ffived << ":" << cms::convert2mm(aFront) << ":"
292  << cms::convert2mm(aFront) << ":" << cms::convert2mm(aFront) << ":" << zerod << ":"
293  << cms::convert2mm(aRear) << ":" << cms::convert2mm(aRear) << ":"
294  << cms::convert2mm(aRear) << ":" << zerod;
295 #endif
296 
297  const double dwall(ee.sCAWall);
298  const double iFront(aFront - dwall);
299  const double iRear(iFront);
300  const double iLen(ee.iLength);
301  std::string eeSCIntName(1 == iSCType ? ee.intName + std::to_string(iSCType)
302  : (ee.intName + std::to_string(iSCType) + "Tmp"));
303  dd4hep::Solid eeSCInt = ns.addSolidNS(eeSCIntName,
304  dd4hep::Trap(eeSCIntName,
305  iLen / 2.,
306  atan((ee.sCARear - ee.sCAFront) / (sqrt(2.) * ee.sCALength)),
307  ffived,
308  iFront,
309  iFront,
310  iFront,
311  zerod,
312  iRear,
313  iRear,
314  iRear,
315  zerod));
316 #ifdef EDM_ML_DEBUG
317  edm::LogVerbatim("EcalGeom") << eeSCAlv.name() << " Trap with parameters: " << cms::convert2mm(iLen / 2.) << ":"
318  << (atan((ee.sCARear - ee.sCAFront) / (sqrt(2.) * ee.sCALength))) << ":" << ffived
319  << ":" << cms::convert2mm(iFront) << ":" << cms::convert2mm(iFront) << ":"
320  << cms::convert2mm(iFront) << ":" << zerod << ":" << cms::convert2mm(iRear) << ":"
321  << cms::convert2mm(iRear) << ":" << cms::convert2mm(iRear) << ":" << zerod;
322 #endif
323 
324  const double dz(-0.5 * (ee.sCELength - ee.sCALength));
325  const double dxy(0.5 * dz * (ee.sCERear - ee.sCEFront) / ee.sCELength);
326  const double zIOff(-(ee.sCALength - iLen) / 2.);
327  const double xyIOff(ee.iXYOff);
328 
329  dd4hep::Volume eeSCELog;
330  dd4hep::Volume eeSCALog;
331  dd4hep::Volume eeSCILog;
332 
333  if (1 == iSCType) { // standard SC in this block
334  eeSCELog =
335  ns.addVolumeNS(dd4hep::Volume(myns + ee.envName + std::to_string(iSCType), eeSCEnv, ns.material(ee.mat)));
336  eeSCALog = dd4hep::Volume(myns + ee.alvName + std::to_string(iSCType), eeSCAlv, ns.material(ee.wallMat));
337  eeSCILog = dd4hep::Volume(myns + ee.intName + std::to_string(iSCType), eeSCInt, ns.material(ee.mat));
338  } else { // partial SCs this block: create subtraction volumes as appropriate
339  const double half(ee.cutParms[0] - ee.pFHalf * ee.crysRear);
340  const double fifth(ee.cutParms[0] + ee.pFFifth * ee.crysRear);
341  const double fac(ee.pF45);
342 
343  const double zmm(0 * dd4hep::mm);
344 
345  DDTranslation cutTra(
346  2 == iSCType ? DDTranslation(zmm, half, zmm)
347  : (3 == iSCType ? DDTranslation(half, zmm, zmm)
348  : (4 == iSCType ? DDTranslation(zmm, -fifth, zmm)
349  : (5 == iSCType ? DDTranslation(-half * fac, -half * fac, zmm)
350  : DDTranslation(-fifth, zmm, zmm)))));
351 
352  const CLHEP::HepRotationZ cutm(ffived);
353 
354  DDRotationMatrix cutRot(5 != iSCType ? DDRotationMatrix()
355  : myrot(ns,
356  "EECry5Rot",
357  DDRotationMatrix(cutm.xx(),
358  cutm.xy(),
359  cutm.xz(),
360  cutm.yx(),
361  cutm.yy(),
362  cutm.yz(),
363  cutm.zx(),
364  cutm.zy(),
365  cutm.zz())));
366 
367  dd4hep::Solid eeCutEnv = dd4hep::SubtractionSolid(ee.envName + std::to_string(iSCType),
368  ns.solid(ee.envName + std::to_string(iSCType) + "Tmp"),
369  eeCutBox,
370  dd4hep::Transform3D(cutRot, cutTra));
371 #ifdef EDM_ML_DEBUG
372  edm::LogVerbatim("EcalGeom") << eeCutEnv.name() << " Subtracted by " << cms::convert2mm(ee.cutParms[0]) << ":"
373  << cms::convert2mm(ee.cutParms[1]) << ":" << cms::convert2mm(ee.cutParms[2]);
374 #endif
375 
376  const DDTranslation extra(dxy, dxy, dz);
377 
378  dd4hep::Solid eeCutAlv = dd4hep::SubtractionSolid(ee.alvName + std::to_string(iSCType),
379  ns.solid(ee.alvName + std::to_string(iSCType) + "Tmp"),
380  eeCutBox,
381  dd4hep::Transform3D(cutRot, cutTra - extra));
382 #ifdef EDM_ML_DEBUG
383  edm::LogVerbatim("EcalGeom") << eeCutAlv.name() << " Subtracted by " << cms::convert2mm(ee.cutParms[0]) << ":"
384  << cms::convert2mm(ee.cutParms[1]) << ":" << cms::convert2mm(ee.cutParms[2]);
385 #endif
386 
387  const double mySign(iSCType < 4 ? +1. : -1.);
388 
389  const DDTranslation extraI(xyIOff + mySign * 2 * dd4hep::mm, xyIOff + mySign * 2 * dd4hep::mm, zIOff);
390 
391  dd4hep::Solid eeCutInt = dd4hep::SubtractionSolid(ee.intName + std::to_string(iSCType),
392  ns.solid(ee.intName + std::to_string(iSCType) + "Tmp"),
393  eeCutBox,
394  dd4hep::Transform3D(cutRot, cutTra - extraI));
395 #ifdef EDM_ML_DEBUG
396  edm::LogVerbatim("EcalGeom") << eeCutInt.name() << " Subtracted by " << cms::convert2mm(ee.cutParms[0]) << ":"
397  << cms::convert2mm(ee.cutParms[1]) << ":" << cms::convert2mm(ee.cutParms[2]);
398 #endif
399 
400  eeSCELog =
401  ns.addVolumeNS(dd4hep::Volume(myns + ee.envName + std::to_string(iSCType), eeCutEnv, ns.material(ee.mat)));
402  eeSCALog = dd4hep::Volume(myns + ee.alvName + std::to_string(iSCType), eeCutAlv, ns.material(ee.wallMat));
403  eeSCILog = dd4hep::Volume(myns + ee.intName + std::to_string(iSCType), eeCutInt, ns.material(ee.mat));
404  }
405  eeSCELog.placeVolume(eeSCALog, iSCType * 100 + 1, dd4hep::Position(dxy, dxy, dz));
406  eeSCALog.placeVolume(eeSCILog, iSCType * 100 + 1, dd4hep::Position(xyIOff, xyIOff, zIOff));
407 #ifdef EDM_ML_DEBUG
408  edm::LogVerbatim("EEGeom") << eeSCALog.name() << " " << (iSCType * 100 + 1) << " in " << eeSCELog.name();
409  edm::LogVerbatim("EEGeom") << eeSCILog.name() << " " << (iSCType * 100 + 1) << " in " << eeSCALog.name();
410  edm::LogVerbatim("EcalGeom") << eeSCALog.name() << " " << (iSCType * 100 + 1) << " in " << eeSCELog.name()
411  << " at (" << cms::convert2mm(dxy) << ", " << cms::convert2mm(dxy) << ", "
412  << cms::convert2mm(dz) << ")";
413  edm::LogVerbatim("EcalGeom") << eeSCILog.name() << " " << (iSCType * 100 + 1) << " in " << eeSCALog.name()
414  << " at (" << cms::convert2mm(xyIOff) << ", " << cms::convert2mm(xyIOff) << ", "
415  << cms::convert2mm(zIOff) << ")";
416 #endif
417  DDTranslation croffset(0., 0., 0.);
418 
419  // Position crystals within parent supercrystal interior volume
420  static const unsigned int ncol(5);
421 
422  if (iSCType > 0 && iSCType <= ee.nSCTypes) {
423  const unsigned int icoffset((iSCType - 1) * ncol - 1);
424 
425  // Loop over columns of SC
426  for (unsigned int icol(1); icol <= ncol; ++icol) {
427  // Get column limits for this SC type from xml input
428  const int ncrcol((int)ee.vecEESCProf[icoffset + icol]);
429 
430  const int imin(0 < ncrcol ? 1 : (0 > ncrcol ? ncol + ncrcol + 1 : 0));
431  const int imax(0 < ncrcol ? ncrcol : (0 > ncrcol ? ncol : 0));
432 
433  if (imax > 0) {
434  // Loop over crystals in this row
435  for (int irow(imin); irow <= imax; ++irow) {
436  // Create crystal as a DDEcalEndcapTrapX object and calculate rotation and
437  // translation required to position it in the SC.
438  DDEcalEndcapTrapX crystal(1, ee.crysFront, ee.crysRear, ee.crysLength);
439 
440  crystal.moveto(ee.cryFCtr[icol - 1][irow - 1], ee.cryRCtr[icol - 1][irow - 1]);
441 
442  std::string rname("EECrRoC" + std::to_string(icol) + "R" + std::to_string(irow));
443 
444  if (rname == "EECrRoC1R1") {
445  // The "EECrRoC1R1" rotation is too small and would be ignored by ROOT. It needs to be
446  // increased by 1% to take effect. See placeEFRYn00 for more details.
447 
448  placeEFRYn00(
449  eeSCALog, eeCRLog, 100 * iSCType + 10 * (icol - 1) + (irow - 1), ns, rname, crystal, ee.cryZOff);
450  } else
451  eeSCALog.placeVolume(eeCRLog,
452  100 * iSCType + 10 * (icol - 1) + (irow - 1),
453  dd4hep::Transform3D(myrot(ns, rname, crystal.rotation()),
454  dd4hep::Position(crystal.centrePos().x(),
455  crystal.centrePos().y(),
456  crystal.centrePos().z() - ee.cryZOff)));
457 #ifdef EDM_ML_DEBUG
458  edm::LogVerbatim("EEGeom") << eeCRLog.name() << " " << (100 * iSCType + 10 * (icol - 1) + (irow - 1))
459  << " in " << eeSCALog.name();
460  edm::LogVerbatim("EcalGeom") << eeCRLog.name() << " " << (100 * iSCType + 10 * (icol - 1) + (irow - 1))
461  << " in " << eeSCALog.name() << " at ("
462  << cms::convert2mm(crystal.centrePos().x()) << ", "
463  << cms::convert2mm(crystal.centrePos().y()) << ", "
464  << cms::convert2mm((crystal.centrePos().z() - ee.cryZOff)) << ")";
465 #endif
466  }
467  }
468  }
469  }
470  }
471 
472  //** Loop over endcap columns
473  for (int icol = 1; icol <= int(ee.nColumns); icol++) {
474  //** Loop over SCs in column, using limits from xml input
475  for (int irow = int(ee.vecEEShape[2 * icol - 2]); irow <= int(ee.vecEEShape[2 * icol - 1]); ++irow) {
476  if (ee.vecEESCLims[0] <= icol && ee.vecEESCLims[1] >= icol && ee.vecEESCLims[2] <= irow &&
477  ee.vecEESCLims[3] >= irow) {
478  // Find SC type (complete or partial) for this location
479  unsigned int isctype = 1;
480 
481  for (unsigned int ii = 0; ii < (unsigned int)(ee.nSCCutaway); ++ii) {
482  if ((ee.vecEESCCutaway[3 * ii] == icol) && (ee.vecEESCCutaway[3 * ii + 1] == irow)) {
483  isctype = int(ee.vecEESCCutaway[3 * ii + 2]);
484  }
485  }
486 
487  // Create SC as a DDEcalEndcapTrapX object and calculate rotation and
488  // translation required to position it in the endcap.
489  DDEcalEndcapTrapX scrys(1, ee.sCEFront, ee.sCERear, ee.sCELength);
490  scrys.moveto(ee.scrFCtr[icol - 1][irow - 1], ee.scrRCtr[icol - 1][irow - 1]);
491  scrys.translate(DDTranslation(0., 0., -ee.zOff));
492 
493  std::string rname(ee.envName + std::to_string(isctype) + std::to_string(icol) + "R" + std::to_string(irow));
494  // Position SC in endcap
495  dd4hep::Volume quaLog = ns.volume(ee.quaName);
496  dd4hep::Volume childEnvLog = ns.volume(myns + ee.envName + std::to_string(isctype));
497  quaLog.placeVolume(childEnvLog,
498  100 * isctype + 10 * (icol - 1) + (irow - 1),
499  dd4hep::Transform3D(scrys.rotation(), scrys.centrePos()));
500 #ifdef EDM_ML_DEBUG
501  edm::LogVerbatim("EEGeom") << childEnvLog.name() << " " << (100 * isctype + 10 * (icol - 1) + (irow - 1))
502  << " in " << quaLog.name();
503  edm::LogVerbatim("EcalGeom") << childEnvLog.name() << " " << (100 * isctype + 10 * (icol - 1) + (irow - 1))
504  << " in " << quaLog.name() << " at (" << cms::convert2mm(scrys.centrePos().x())
505  << ", " << cms::convert2mm(scrys.centrePos().y()) << ", "
506  << cms::convert2mm(scrys.centrePos().z()) << ")";
507 #endif
508  }
509  }
510  }
511 
512  return 1;
513 }
514 
515 DECLARE_DDCMS_DETELEMENT(DDCMS_ecal_DDEcalEndcapAlgo, algorithm)
size
Write out results.
Log< level::Info, true > LogVerbatim
const dd4hep::Rotation3D & rotation(const std::string &name) const
Definition: DDNamespace.cc:182
DDTranslation centrePos()
void translate(const DDTranslation &trans)
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
assert(be >=bs)
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:166
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
static std::string to_string(const XMLCh *ch)
static std::string const input
Definition: EdmProvDump.cc:50
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
void addRotation(const std::string &name, const dd4hep::Rotation3D &rot) const
Definition: DDNamespace.cc:170
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
dd4hep::Solid solid(const std::string &name) const
Definition: DDNamespace.cc:311
dd4hep::Volume Volume
ii
Definition: cuy.py:589
const G4String rname[NREG]
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
static std::atomic< unsigned int > counter
DDRotationMatrix rotation()
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
Definition: DDNamespace.cc:202
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
void moveto(const DDTranslation &frontCentre, const DDTranslation &rearCentre)
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:276
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:292
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:99
#define LogDebug(id)