CMS 3D CMS Logo

DDEcalEndcapAlgo.cc
Go to the documentation of this file.
1 
3 // File: DDEcalEndcapAlgo.cc
4 // Description: Geometry factory class for Ecal Barrel
6 
7 #include <cmath>
8 #include <algorithm>
9 
14 #include <CLHEP/Units/SystemOfUnits.h>
15 
16 #include <CLHEP/Geometry/Transform3D.h>
17 
18 // Header files for endcap supercrystal geometry
20 
21 #include <map>
22 #include <string>
23 #include <vector>
31 #include <CLHEP/Geometry/Transform3D.h>
32 
33 using CLHEP::deg;
34 using CLHEP::mm;
35 //#define EDM_ML_DEBUG
36 
37 class DDEcalEndcapAlgo : public DDAlgorithm {
38 public:
40  typedef HepGeom::Point3D<double> Pt3D;
41  typedef HepGeom::Transform3D Tf3D;
42  typedef HepGeom::ReflectZ3D RfZ3D;
43  typedef HepGeom::Translate3D Tl3D;
44  typedef HepGeom::Rotate3D Ro3D;
45  typedef HepGeom::RotateZ3D RoZ3D;
46  typedef HepGeom::RotateY3D RoY3D;
47  typedef HepGeom::RotateX3D RoX3D;
48 
49  typedef CLHEP::Hep3Vector Vec3;
50  typedef CLHEP::HepRotation Rota;
51 
52  //Constructor and Destructor
54  ~DDEcalEndcapAlgo() override;
55 
56  void initialize(const DDNumericArguments& nArgs,
57  const DDVectorArguments& vArgs,
58  const DDMapArguments& mArgs,
59  const DDStringArguments& sArgs,
60  const DDStringVectorArguments& vsArgs) override;
61  void execute(DDCompactView& cpv) override;
62 
63  // New methods for SC geometry
64  void EEPositionCRs(const DDName& pName, const DDTranslation& offset, const int iSCType, DDCompactView& cpv);
65 
66  void EECreateSC(const unsigned int iSCType, DDCompactView& cpv);
67 
68  void EECreateCR();
69 
70  void EEPosSC(const int iCol, const int iRow, DDName EEDeeName);
71 
72  unsigned int EEGetSCType(const unsigned int iCol, const unsigned int iRow);
73 
74  DDName EEGetSCName(const int iCol, const int iRow);
75 
76  std::vector<double> EEGetSCCtrs(const int iCol, const int iRow);
77 
78  DDMaterial ddmat(const std::string& s) const;
79  DDName ddname(const std::string& s) const;
80  DDRotation myrot(const std::string& s, const DDRotationMatrix& r) const;
81 
82  const std::string& idNameSpace() const { return m_idNameSpace; }
83 
84  // endcap parent volume
85  DDMaterial eeMat() const { return ddmat(m_EEMat); }
86  double eezOff() const { return m_EEzOff; }
87 
88  DDName eeQuaName() const { return ddname(m_EEQuaName); }
89  DDMaterial eeQuaMat() const { return ddmat(m_EEQuaMat); }
90 
91  DDMaterial eeCrysMat() const { return ddmat(m_EECrysMat); }
92  DDMaterial eeWallMat() const { return ddmat(m_EEWallMat); }
93 
94  double eeCrysLength() const { return m_EECrysLength; }
95  double eeCrysRear() const { return m_EECrysRear; }
96  double eeCrysFront() const { return m_EECrysFront; }
97  double eeSCELength() const { return m_EESCELength; }
98  double eeSCERear() const { return m_EESCERear; }
99  double eeSCEFront() const { return m_EESCEFront; }
100  double eeSCALength() const { return m_EESCALength; }
101  double eeSCARear() const { return m_EESCARear; }
102  double eeSCAFront() const { return m_EESCAFront; }
103  double eeSCAWall() const { return m_EESCAWall; }
104  double eeSCHLength() const { return m_EESCHLength; }
105  double eeSCHSide() const { return m_EESCHSide; }
106 
107  double eenSCTypes() const { return m_EEnSCTypes; }
108  double eenColumns() const { return m_EEnColumns; }
109  double eenSCCutaway() const { return m_EEnSCCutaway; }
110  double eenSCquad() const { return m_EEnSCquad; }
111  double eenCRSC() const { return m_EEnCRSC; }
112  const std::vector<double>& eevecEESCProf() const { return m_vecEESCProf; }
113  const std::vector<double>& eevecEEShape() const { return m_vecEEShape; }
114  const std::vector<double>& eevecEESCCutaway() const { return m_vecEESCCutaway; }
115  const std::vector<double>& eevecEESCCtrs() const { return m_vecEESCCtrs; }
116  const std::vector<double>& eevecEECRCtrs() const { return m_vecEECRCtrs; }
117 
118  DDName cutBoxName() const { return ddname(m_cutBoxName); }
119  double eePFHalf() const { return m_PFhalf; }
120  double eePFFifth() const { return m_PFfifth; }
121  double eePF45() const { return m_PF45; }
122 
123  DDName envName(unsigned int i) const { return ddname(m_envName + std::to_string(i)); }
124  DDName alvName(unsigned int i) const { return ddname(m_alvName + std::to_string(i)); }
125  DDName intName(unsigned int i) const { return ddname(m_intName + std::to_string(i)); }
126  DDName cryName() const { return ddname(m_cryName); }
127 
128  DDName addTmp(DDName aName) const { return ddname(aName.name() + "Tmp"); }
129 
130  const DDTranslation& cryFCtr(unsigned int iRow, unsigned int iCol) const { return m_cryFCtr[iRow - 1][iCol - 1]; }
131 
132  const DDTranslation& cryRCtr(unsigned int iRow, unsigned int iCol) const { return m_cryRCtr[iRow - 1][iCol - 1]; }
133 
134  const DDTranslation& scrFCtr(unsigned int iRow, unsigned int iCol) const { return m_scrFCtr[iRow - 1][iCol - 1]; }
135 
136  const DDTranslation& scrRCtr(unsigned int iRow, unsigned int iCol) const { return m_scrRCtr[iRow - 1][iCol - 1]; }
137 
138  const std::vector<double>& vecEESCLims() const { return m_vecEESCLims; }
139 
140  double iLength() const { return m_iLength; }
141  double iXYOff() const { return m_iXYOff; }
142 
143 protected:
144 private:
145  std::string m_idNameSpace; //Namespace of this and ALL sub-parts
146 
147  // Barrel volume
149  double m_EEzOff;
150 
153 
156 
158  double m_EECrysRear;
161  double m_EESCERear;
162  double m_EESCEFront;
164  double m_EESCARear;
165  double m_EESCAFront;
166  double m_EESCAWall;
168  double m_EESCHSide;
169 
170  double m_EEnSCTypes;
171  std::vector<double> m_vecEESCProf;
172  double m_EEnColumns;
173  std::vector<double> m_vecEEShape;
175  std::vector<double> m_vecEESCCutaway;
176  double m_EEnSCquad;
177  std::vector<double> m_vecEESCCtrs;
178  double m_EEnCRSC;
179  std::vector<double> m_vecEECRCtrs;
180 
181  const std::vector<double>* m_cutParms;
183 
188 
191 
194 
195  double m_PFhalf;
196  double m_PFfifth;
197  double m_PF45;
198 
199  std::vector<double> m_vecEESCLims;
200 
201  double m_iLength;
202 
203  double m_iXYOff;
204 
205  double m_cryZOff;
206 
207  double m_zFront;
208 };
209 
210 namespace std {}
211 using namespace std;
212 
214  : m_idNameSpace(""),
215  m_EEMat(""),
216  m_EEzOff(0),
217  m_EEQuaName(""),
218  m_EEQuaMat(""),
219  m_EECrysMat(""),
220  m_EEWallMat(""),
221  m_EECrysLength(0),
222  m_EECrysRear(0),
223  m_EECrysFront(0),
224  m_EESCELength(0),
225  m_EESCERear(0),
226  m_EESCEFront(0),
227  m_EESCALength(0),
228  m_EESCARear(0),
229  m_EESCAFront(0),
230  m_EESCAWall(0),
231  m_EESCHLength(0),
232  m_EESCHSide(0),
233  m_EEnSCTypes(0),
234  m_vecEESCProf(),
235  m_EEnColumns(0),
236  m_vecEEShape(),
237  m_EEnSCCutaway(0),
238  m_vecEESCCutaway(),
239  m_EEnSCquad(0),
240  m_vecEESCCtrs(),
241  m_EEnCRSC(0),
242  m_vecEECRCtrs(),
243  m_cutParms(nullptr),
244  m_cutBoxName(""),
245  m_envName(""),
246  m_alvName(""),
247  m_intName(""),
248  m_cryName(""),
249  m_PFhalf(0),
250  m_PFfifth(0),
251  m_PF45(0),
252  m_vecEESCLims(),
253  m_iLength(0),
254  m_iXYOff(0),
255  m_cryZOff(0),
256  m_zFront(0) {
257  edm::LogVerbatim("EcalGeomX") << "DDEcalEndcapAlgo info: Creating an instance";
258 }
259 
261 
263  const DDVectorArguments& vArgs,
264  const DDMapArguments& /*mArgs*/,
265  const DDStringArguments& sArgs,
266  const DDStringVectorArguments& /*vsArgs*/) {
267 #ifdef EDM_ML_DEBUG
268  edm::LogVerbatim("EcalGeomX") << "DDEcalEndcapAlgo info: Initialize";
269 #endif
271  // TRICK!
272  m_idNameSpace = parent().name().ns();
273  // barrel parent volume
274  m_EEMat = sArgs["EEMat"];
275  m_EEzOff = nArgs["EEzOff"];
276 
277  m_EEQuaName = sArgs["EEQuaName"];
278  m_EEQuaMat = sArgs["EEQuaMat"];
279  m_EECrysMat = sArgs["EECrysMat"];
280  m_EEWallMat = sArgs["EEWallMat"];
281  m_EECrysLength = nArgs["EECrysLength"];
282  m_EECrysRear = nArgs["EECrysRear"];
283  m_EECrysFront = nArgs["EECrysFront"];
284  m_EESCELength = nArgs["EESCELength"];
285  m_EESCERear = nArgs["EESCERear"];
286  m_EESCEFront = nArgs["EESCEFront"];
287  m_EESCALength = nArgs["EESCALength"];
288  m_EESCARear = nArgs["EESCARear"];
289  m_EESCAFront = nArgs["EESCAFront"];
290  m_EESCAWall = nArgs["EESCAWall"];
291  m_EESCHLength = nArgs["EESCHLength"];
292  m_EESCHSide = nArgs["EESCHSide"];
293  m_EEnSCTypes = nArgs["EEnSCTypes"];
294  m_EEnColumns = nArgs["EEnColumns"];
295  m_EEnSCCutaway = nArgs["EEnSCCutaway"];
296  m_EEnSCquad = nArgs["EEnSCquad"];
297  m_EEnCRSC = nArgs["EEnCRSC"];
298  m_vecEESCProf = vArgs["EESCProf"];
299  m_vecEEShape = vArgs["EEShape"];
300  m_vecEESCCutaway = vArgs["EESCCutaway"];
301  m_vecEESCCtrs = vArgs["EESCCtrs"];
302  m_vecEECRCtrs = vArgs["EECRCtrs"];
303 
304  m_cutBoxName = sArgs["EECutBoxName"];
305 
306  m_envName = sArgs["EEEnvName"];
307  m_alvName = sArgs["EEAlvName"];
308  m_intName = sArgs["EEIntName"];
309  m_cryName = sArgs["EECryName"];
310 
311  m_PFhalf = nArgs["EEPFHalf"];
312  m_PFfifth = nArgs["EEPFFifth"];
313  m_PF45 = nArgs["EEPF45"];
314 
315  m_vecEESCLims = vArgs["EESCLims"];
316 
317  m_iLength = nArgs["EEiLength"];
318 
319  m_iXYOff = nArgs["EEiXYOff"];
320 
321  m_cryZOff = nArgs["EECryZOff"];
322 
323  m_zFront = nArgs["EEzFront"];
324 }
325 
327 // DDEcalEndcapAlgo methods...
329 
331  return DDrot(ddname(m_idNameSpace + ":" + s), std::make_unique<DDRotationMatrix>(r));
332 }
333 
335 
337  const pair<std::string, std::string> temp(DDSplit(s));
338  if (temp.second.empty()) {
339  return DDName(temp.first, m_idNameSpace);
340  } else {
341  return DDName(temp.first, temp.second);
342  }
343 }
344 
345 //-------------------- Endcap SC geometry methods ---------------------
346 
348  // Position supercrystals in EE Quadrant
349  // Version: 1.00
350  // Created: 30 July 2007
351  // Last Mod:
352  //---------------------------------------------------------------------
353 
354  //********************************* cutbox for trimming edge SCs
355  const double cutWid(eeSCERear() / sqrt(2.));
356  const DDSolid eeCutBox(DDSolidFactory::box(cutBoxName(), cutWid, cutWid, eeSCELength() / sqrt(2.)));
357  m_cutParms = &eeCutBox.parameters();
358  //**************************************************************
359 
360  const double zFix(m_zFront - 3172.0 * mm); // fix for changing z offset
361 
362  //** fill supercrystal front and rear center positions from xml input
363  for (unsigned int iC(0); iC != (unsigned int)eenSCquad(); ++iC) {
364  const unsigned int iOff(8 * iC);
365  const unsigned int ix((unsigned int)eevecEESCCtrs()[iOff + 0]);
366  const unsigned int iy((unsigned int)eevecEESCCtrs()[iOff + 1]);
367 
368  assert(ix > 0 && ix < 11 && iy > 0 && iy < 11);
369 
370  m_scrFCtr[ix - 1][iy - 1] =
371  DDTranslation(eevecEESCCtrs()[iOff + 2], eevecEESCCtrs()[iOff + 4], eevecEESCCtrs()[iOff + 6] + zFix);
372 
373  m_scrRCtr[ix - 1][iy - 1] =
374  DDTranslation(eevecEESCCtrs()[iOff + 3], eevecEESCCtrs()[iOff + 5], eevecEESCCtrs()[iOff + 7] + zFix);
375  }
376 
377  //** fill crystal front and rear center positions from xml input
378  for (unsigned int iC(0); iC != 25; ++iC) {
379  const unsigned int iOff(8 * iC);
380  const unsigned int ix((unsigned int)eevecEECRCtrs()[iOff + 0]);
381  const unsigned int iy((unsigned int)eevecEECRCtrs()[iOff + 1]);
382 
383  assert(ix > 0 && ix < 6 && iy > 0 && iy < 6);
384 
385  m_cryFCtr[ix - 1][iy - 1] =
386  DDTranslation(eevecEECRCtrs()[iOff + 2], eevecEECRCtrs()[iOff + 4], eevecEECRCtrs()[iOff + 6]);
387 
388  m_cryRCtr[ix - 1][iy - 1] =
389  DDTranslation(eevecEECRCtrs()[iOff + 3], eevecEECRCtrs()[iOff + 5], eevecEECRCtrs()[iOff + 7]);
390  }
391 
392  EECreateCR(); // make a single crystal just once here
393 
394  for (unsigned int isc(0); isc < eenSCTypes(); ++isc) {
395  EECreateSC(isc + 1, cpv);
396  }
397 
398  const std::vector<double>& colLimits(eevecEEShape());
399  //** Loop over endcap columns
400  for (int icol = 1; icol <= int(eenColumns()); icol++) {
401  //** Loop over SCs in column, using limits from xml input
402  for (int irow = int(colLimits[2 * icol - 2]); irow <= int(colLimits[2 * icol - 1]); ++irow) {
403  if (vecEESCLims()[0] <= icol && vecEESCLims()[1] >= icol && vecEESCLims()[2] <= irow &&
404  vecEESCLims()[3] >= irow) {
405  // Find SC type (complete or partial) for this location
406  const unsigned int isctype(EEGetSCType(icol, irow));
407 
408  // Create SC as a DDEcalEndcapTrap object and calculate rotation and
409  // translation required to position it in the endcap.
411 
412  scrys.moveto(scrFCtr(icol, irow), scrRCtr(icol, irow));
413  scrys.translate(DDTranslation(0., 0., -eezOff()));
414 
415  DDName rname(envName(isctype).name() + std::to_string(icol) + "R" + std::to_string(irow));
416 
417 #ifdef EDM_ML_DEBUG
418  edm::LogVerbatim("EcalGeoXm") << "Quadrant, SC col/row " << eeQuaName() << " " << icol << " / " << irow
419  << std::endl
420  << " Limits " << int(colLimits[2 * icol - 2]) << "->"
421  << int(colLimits[2 * icol - 1]) << std::endl
422  << " SC type = " << isctype << std::endl
423  << " Zoff = " << eezOff() << std::endl
424  << " Rotation " << rname << " " << scrys.rotation() << std::endl
425  << " Position " << scrys.centrePos();
426 #endif
427  // Position SC in endcap
428  cpv.position(envName(isctype),
429  eeQuaName(),
430  100 * isctype + 10 * (icol - 1) + (irow - 1),
431  scrys.centrePos(),
432  myrot(rname.fullname(), scrys.rotation()));
433 #ifdef EDM_ML_DEBUG
434  edm::LogVerbatim("EEGeom") << envName(isctype) << " " << (100 * isctype + 10 * (icol - 1) + (irow - 1))
435  << " in " << eeQuaName();
436  edm::LogVerbatim("EcalGeom") << envName(isctype) << " " << (100 * isctype + 10 * (icol - 1) + (irow - 1))
437  << " in " << eeQuaName() << " at " << scrys.centrePos();
438 #endif
439  }
440  }
441  }
442 }
443 
444 void DDEcalEndcapAlgo::EECreateSC(const unsigned int iSCType,
445  DDCompactView& cpv) { // EECreateSCType Create SC logical volume of the given type
446 
447  DDRotation noRot;
448  DDLogicalPart eeSCELog;
449  DDLogicalPart eeSCALog;
450  DDLogicalPart eeSCILog;
451 
452 #ifdef EDM_ML_DEBUG
453  edm::LogVerbatim("EcalGeomX") << "EECreateSC: Creating SC envelope";
454 #endif
455  const string anum(std::to_string(iSCType));
456 
457  const double eFront(0.5 * eeSCEFront());
458  const double eRear(0.5 * eeSCERear());
459  const double eAng(atan((eeSCERear() - eeSCEFront()) / (sqrt(2.) * eeSCELength())));
460  const double ffived(45 * deg);
461  const double zerod(0 * deg);
462  DDSolid eeSCEnv(DDSolidFactory::trap((1 == iSCType ? envName(iSCType) : addTmp(envName(iSCType))),
463  0.5 * eeSCELength(),
464  eAng,
465  ffived,
466  eFront,
467  eFront,
468  eFront,
469  zerod,
470  eRear,
471  eRear,
472  eRear,
473  zerod));
474 #ifdef EDM_ML_DEBUG
475  edm::LogVerbatim("EcalGeom") << eeSCEnv.name() << " Trap with parameters: " << 0.5 * eeSCELength() << ":" << eAng
476  << ffived << ":" << eFront << ":" << eFront << ":" << eFront << ":" << zerod << ":"
477  << eRear << ":" << eRear << ":" << eRear << ":" << zerod;
478 #endif
479 
480  const double aFront(0.5 * eeSCAFront());
481  const double aRear(0.5 * eeSCARear());
482  const double aAng(atan((eeSCARear() - eeSCAFront()) / (sqrt(2.) * eeSCALength())));
483  const DDSolid eeSCAlv(DDSolidFactory::trap((1 == iSCType ? alvName(iSCType) : addTmp(alvName(iSCType))),
484  0.5 * eeSCALength(),
485  aAng,
486  ffived,
487  aFront,
488  aFront,
489  aFront,
490  zerod,
491  aRear,
492  aRear,
493  aRear,
494  zerod));
495 #ifdef EDM_ML_DEBUG
496  edm::LogVerbatim("EcalGeom") << eeSCAlv.name() << " Trap with parameters: " << 0.5 * eeSCALength() << ":" << aAng
497  << ":" << ffived << ":" << aFront << ":" << aFront << ":" << aFront << ":" << zerod
498  << ":" << aRear << ":" << aRear << ":" << aRear << ":" << zerod;
499 #endif
500  const double dwall(eeSCAWall());
501  const double iFront(aFront - dwall);
502  const double iRear(iFront); //aRear - dwall ) ;
503  const double iLen(iLength()); //0.075*eeSCALength() ) ;
504  const DDSolid eeSCInt(DDSolidFactory::trap((1 == iSCType ? intName(iSCType) : addTmp(intName(iSCType))),
505  iLen / 2.,
506  atan((eeSCARear() - eeSCAFront()) / (sqrt(2.) * eeSCALength())),
507  ffived,
508  iFront,
509  iFront,
510  iFront,
511  zerod,
512  iRear,
513  iRear,
514  iRear,
515  zerod));
516 #ifdef EDM_ML_DEBUG
517  edm::LogVerbatim("EcalGeom") << eeSCInt.name() << " Trap with parameters: " << iLen / 2. << ":"
518  << (atan((eeSCARear() - eeSCAFront()) / (sqrt(2.) * eeSCALength()))) << ":" << ffived
519  << ":" << iFront << ":" << iFront << ":" << iFront << ":" << zerod << ":" << iRear << ":"
520  << iRear << ":" << iRear << ":" << zerod;
521 #endif
522  const double dz(-0.5 * (eeSCELength() - eeSCALength()));
523  const double dxy(0.5 * dz * (eeSCERear() - eeSCEFront()) / eeSCELength());
524  const double zIOff(-(eeSCALength() - iLen) / 2.);
525  const double xyIOff(iXYOff());
526 
527  if (1 == iSCType) // standard SC in this block
528  {
529  eeSCELog = DDLogicalPart(envName(iSCType), eeMat(), eeSCEnv);
530  eeSCALog = DDLogicalPart(alvName(iSCType), eeWallMat(), eeSCAlv);
531  eeSCILog = DDLogicalPart(intName(iSCType), eeMat(), eeSCInt);
532  } else // partial SCs this block: create subtraction volumes as appropriate
533  {
534  const double half((*m_cutParms)[0] - eePFHalf() * eeCrysRear());
535  const double fifth((*m_cutParms)[0] + eePFFifth() * eeCrysRear());
536  const double fac(eePF45());
537 
538  const double zmm(0 * mm);
539 
540  DDTranslation cutTra(
541  2 == iSCType ? DDTranslation(zmm, half, zmm)
542  : (3 == iSCType ? DDTranslation(half, zmm, zmm)
543  : (4 == iSCType ? DDTranslation(zmm, -fifth, zmm)
544  : (5 == iSCType ? DDTranslation(-half * fac, -half * fac, zmm)
545  : DDTranslation(-fifth, zmm, zmm)))));
546 
547  const CLHEP::HepRotationZ cutm(ffived);
548 
549  DDRotation cutRot(5 != iSCType ? noRot
550  : myrot("EECry5Rot",
551  DDRotationMatrix(cutm.xx(),
552  cutm.xy(),
553  cutm.xz(),
554  cutm.yx(),
555  cutm.yy(),
556  cutm.yz(),
557  cutm.zx(),
558  cutm.zy(),
559  cutm.zz())));
560 
561  DDSolid eeCutEnv(
562  DDSolidFactory::subtraction(envName(iSCType), addTmp(envName(iSCType)), cutBoxName(), cutTra, cutRot));
563 #ifdef EDM_ML_DEBUG
564  edm::LogVerbatim("EcalGeom") << eeCutEnv.name() << " Subtracted by " << (eeSCERear() / sqrt(2.)) << ":"
565  << (eeSCERear() / sqrt(2.)) << ":" << (eeSCELength() / sqrt(2.));
566 #endif
567  const DDTranslation extra(dxy, dxy, dz);
568 
569  DDSolid eeCutAlv(
570  DDSolidFactory::subtraction(alvName(iSCType), addTmp(alvName(iSCType)), cutBoxName(), cutTra - extra, cutRot));
571 
572 #ifdef EDM_ML_DEBUG
573  edm::LogVerbatim("EcalGeom") << eeCutAlv.name() << " Subtracted by " << (eeSCERear() / sqrt(2.)) << ":"
574  << (eeSCERear() / sqrt(2.)) << ":" << (eeSCELength() / sqrt(2.));
575 #endif
576  const double mySign(iSCType < 4 ? +1. : -1.);
577 
578  const DDTranslation extraI(xyIOff + mySign * 2 * mm, xyIOff + mySign * 2 * mm, zIOff);
579 
580  DDSolid eeCutInt(
581  DDSolidFactory::subtraction(intName(iSCType), addTmp(intName(iSCType)), cutBoxName(), cutTra - extraI, cutRot));
582 #ifdef EDM_ML_DEBUG
583  edm::LogVerbatim("EcalGeom") << eeCutInt.name() << " Subtracted by " << (eeSCERear() / sqrt(2.)) << ":"
584  << (eeSCERear() / sqrt(2.)) << ":" << (eeSCELength() / sqrt(2.));
585 #endif
586 
587  eeSCELog = DDLogicalPart(envName(iSCType), eeMat(), eeCutEnv);
588  eeSCALog = DDLogicalPart(alvName(iSCType), eeWallMat(), eeCutAlv);
589  eeSCILog = DDLogicalPart(intName(iSCType), eeMat(), eeCutInt);
590  }
591 
592  cpv.position(eeSCALog, envName(iSCType), iSCType * 100 + 1, DDTranslation(dxy, dxy, dz), noRot);
593  cpv.position(eeSCILog, alvName(iSCType), iSCType * 100 + 1, DDTranslation(xyIOff, xyIOff, zIOff), noRot);
594 #ifdef EDM_ML_DEBUG
595  edm::LogVerbatim("EEGeom") << eeSCALog.name() << " " << (iSCType * 100 + 1) << " in " << envName(iSCType);
596  edm::LogVerbatim("EEGeom") << eeSCILog.name() << " " << (iSCType * 100 + 1) << " in " << alvName(iSCType);
597  edm::LogVerbatim("EcalGeom") << eeSCALog.name() << " " << (iSCType * 100 + 1) << " in " << envName(iSCType) << " at ("
598  << dxy << ", " << dxy << ", " << dz << ")";
599  edm::LogVerbatim("EcalGeom") << eeSCILog.name() << " " << (iSCType * 100 + 1) << " in " << alvName(iSCType) << " at ("
600  << xyIOff << ", " << xyIOff << ", " << zIOff << ")";
601 #endif
602  DDTranslation croffset(0., 0., 0.);
603  EEPositionCRs(alvName(iSCType), croffset, iSCType, cpv);
604 }
605 
606 unsigned int DDEcalEndcapAlgo::EEGetSCType(const unsigned int iCol, const unsigned int iRow) {
607  unsigned int iType = 1;
608  for (unsigned int ii = 0; ii < (unsigned int)(eenSCCutaway()); ++ii) {
609  if ((eevecEESCCutaway()[3 * ii] == iCol) && (eevecEESCCutaway()[3 * ii + 1] == iRow)) {
610  iType = int(eevecEESCCutaway()[3 * ii + 2]);
611 #ifdef EDM_ML_DEBUG
612  edm::LogVerbatim("EcalGeomX") << "EEGetSCType: col, row, type = " << iCol << " " << iRow << " " << iType;
613 #endif
614  }
615  }
616  return iType;
617 }
618 
620  // EECreateCR Create endcap crystal logical volume
621 
622 #ifdef EDM_ML_DEBUG
623  edm::LogVerbatim("EcalGeomX") << "EECreateCR: = ";
624 #endif
626  0.5 * eeCrysLength(),
627  atan((eeCrysRear() - eeCrysFront()) / (sqrt(2.) * eeCrysLength())),
628  45. * deg,
629  0.5 * eeCrysFront(),
630  0.5 * eeCrysFront(),
631  0.5 * eeCrysFront(),
632  0. * deg,
633  0.5 * eeCrysRear(),
634  0.5 * eeCrysRear(),
635  0.5 * eeCrysRear(),
636  0. * deg));
637 #ifdef EDM_ML_DEBUG
638  edm::LogVerbatim("EcalGeom") << EECRSolid.name() << " Trap with parameters: " << 0.5 * eeCrysLength() << ":"
639  << (atan((eeCrysRear() - eeCrysFront()) / (sqrt(2.) * eeCrysLength()))) << ":"
640  << 45. * deg << ":" << 0.5 * eeCrysFront() << ":" << 0.5 * eeCrysFront() << ":"
641  << 0.5 * eeCrysFront() << ":" << 0. * deg << ":" << 0.5 * eeCrysRear() << ":"
642  << 0.5 * eeCrysRear() << ":" << 0.5 * eeCrysRear() << ":" << 0. * deg;
643 #endif
644 
645  DDLogicalPart part(cryName(), eeCrysMat(), EECRSolid);
646 }
647 
649  const DDTranslation& /*offset*/,
650  const int iSCType,
651  DDCompactView& cpv) {
652  // EEPositionCRs Position crystals within parent supercrystal interior volume
653 
654 #ifdef EDM_ML_DEBUG
655  edm::LogVerbatim("EcalGeomX") << "EEPositionCRs called ";
656 #endif
657  static const unsigned int ncol(5);
658 
659  if (iSCType > 0 && iSCType <= eenSCTypes()) {
660  const unsigned int icoffset((iSCType - 1) * ncol - 1);
661 
662  // Loop over columns of SC
663  for (unsigned int icol(1); icol <= ncol; ++icol) {
664  // Get column limits for this SC type from xml input
665  const int ncrcol((int)eevecEESCProf()[icoffset + icol]);
666 
667  const int imin(0 < ncrcol ? 1 : (0 > ncrcol ? ncol + ncrcol + 1 : 0));
668  const int imax(0 < ncrcol ? ncrcol : (0 > ncrcol ? ncol : 0));
669 
670  if (imax > 0) {
671  // Loop over crystals in this row
672  for (int irow(imin); irow <= imax; ++irow) {
673 #ifdef EDM_ML_DEBUG
674  edm::LogVerbatim("EcalGeomX") << " type, col, row " << iSCType << " " << icol << " " << irow;
675 #endif
676  // Create crystal as a DDEcalEndcapTrap object and calculate rotation and
677  // translation required to position it in the SC.
679 
680  crystal.moveto(cryFCtr(icol, irow), cryRCtr(icol, irow));
681 
682  DDName rname("EECrRoC" + std::to_string(icol) + "R" + std::to_string(irow));
683 
684  cpv.position(cryName(),
685  pName,
686  100 * iSCType + 10 * (icol - 1) + (irow - 1),
687  crystal.centrePos() - DDTranslation(0, 0, m_cryZOff),
688  myrot(rname.fullname(), crystal.rotation()));
689 #ifdef EDM_ML_DEBUG
690  edm::LogVerbatim("EEGeom") << cryName() << " " << (100 * iSCType + 10 * (icol - 1) + (irow - 1)) << " in "
691  << pName;
692  edm::LogVerbatim("EcalGeom") << cryName() << " " << (100 * iSCType + 10 * (icol - 1) + (irow - 1)) << " in "
693  << pName << " at " << (crystal.centrePos() - DDTranslation(0, 0, m_cryZOff));
694 #endif
695  }
696  }
697  }
698  }
699 }
700 
702 
703 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDEcalEndcapAlgo, "ecal:DDEcalEndcapAlgo");
Log< level::Info, true > LogVerbatim
HepGeom::RotateX3D RoX3D
DDTranslation m_cryFCtr[5][5]
HepGeom::Point3D< double > Pt3D
void execute(DDCompactView &cpv) override
void position(const DDLogicalPart &self, const DDLogicalPart &parent, const std::string &copyno, const DDTranslation &trans, const DDRotation &rot, const DDDivision *div=nullptr)
const std::vector< double > & eevecEESCProf() const
std::string m_cutBoxName
DDMaterial eeMat() const
double eeCrysLength() const
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDName ddname(const std::string &s) const
double eenSCTypes() const
void EEPositionCRs(const DDName &pName, const DDTranslation &offset, const int iSCType, DDCompactView &cpv)
DDTranslation m_scrRCtr[10][10]
CLHEP::Hep3Vector Vec3
DDRotation myrot(const std::string &s, const DDRotationMatrix &r) const
unsigned int EEGetSCType(const unsigned int iCol, const unsigned int iRow)
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
HepGeom::Translate3D Tl3D
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:125
static std::string & ns()
const DDTranslation & scrRCtr(unsigned int iRow, unsigned int iCol) const
DDName eeQuaName() const
void moveto(const DDTranslation &frontCentre, const DDTranslation &rearCentre)
assert(be >=bs)
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
double eeSCHSide() const
HepGeom::ReflectZ3D RfZ3D
std::string m_EEQuaMat
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
static std::string to_string(const XMLCh *ch)
double eeSCELength() const
DDMaterial eeWallMat() const
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
const std::vector< double > & vecEESCLims() const
double eeSCAFront() const
double eenColumns() const
std::string m_idNameSpace
EcalTrapezoidParameters Trap
std::vector< double > m_vecEESCLims
DDName cryName() const
void EEPosSC(const int iCol, const int iRow, DDName EEDeeName)
std::string m_EECrysMat
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
CLHEP::HepRotation Rota
~DDEcalEndcapAlgo() override
double eeCrysRear() const
ROOT::Math::Rotation3D DDRotationMatrix
A DDRotationMatrix is currently implemented with a ROOT Rotation3D.
DDMaterial eeQuaMat() const
T sqrt(T t)
Definition: SSEVec.h:23
const DDTranslation & cryRCtr(unsigned int iRow, unsigned int iCol) const
std::string m_EEQuaName
std::vector< double > EEGetSCCtrs(const int iCol, const int iRow)
HepGeom::Transform3D Tf3D
DDTranslation m_scrFCtr[10][10]
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:67
DDName addTmp(DDName aName) const
double eeSCARear() const
double eePFFifth() const
double iLength() const
static DDSolid trap(const DDName &name, double pDz, double pTheta, double pPhi, double pDy1, double pDx1, double pDx2, double pAlp1, double pDy2, double pDx3, double pDx4, double pAlp2)
Definition: DDSolid.cc:609
DDName envName(unsigned int i) const
static DDSolid box(const DDName &name, double xHalf, double yHalf, double zHalf)
Creates a box with side length 2*xHalf, 2*yHalf, 2*zHalf.
Definition: DDSolid.cc:547
double eePFHalf() const
ii
Definition: cuy.py:589
DDName cutBoxName() const
double eenSCquad() const
const N & name() const
Definition: DDBase.h:58
const DDTranslation & cryFCtr(unsigned int iRow, unsigned int iCol) const
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ix(uint32_t id)
double eenCRSC() const
std::vector< double > m_vecEEShape
HepGeom::RotateZ3D RoZ3D
DDTranslation m_cryRCtr[5][5]
part
Definition: HCALResponse.h:20
static DDSolid subtraction(const DDName &name, const DDSolid &a, const DDSolid &b, const DDTranslation &t, const DDRotation &r)
Definition: DDSolid.cc:599
std::vector< double > m_vecEESCCtrs
double eeSCERear() const
std::vector< double > m_vecEECRCtrs
double eeSCEFront() const
DDMaterial eeCrysMat() const
const std::vector< double > & eevecEECRCtrs() const
void translate(const DDTranslation &trans)
const G4String rname[NREG]
DDName intName(unsigned int i) const
const DDTranslation & scrFCtr(unsigned int iRow, unsigned int iCol) const
double eeSCAWall() const
const std::vector< double > & eevecEESCCutaway() const
HepGeom::RotateY3D RoY3D
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t iy(uint32_t id)
double eeSCALength() const
#define DEFINE_EDM_PLUGIN(factory, type, name)
DDMaterial ddmat(const std::string &s) const
double eeCrysFront() const
void EECreateSC(const unsigned int iSCType, DDCompactView &cpv)
std::string m_EEWallMat
const std::string & idNameSpace() const
DDTranslation centrePos()
DDRotationMatrix rotation()
const std::vector< double > * m_cutParms
double iXYOff() const
std::vector< double > m_vecEESCCutaway
std::pair< std::string, std::string > DDSplit(const std::string &n)
split into (name,namespace), separator = &#39;:&#39;
Definition: DDSplit.cc:3
double eeSCHLength() const
const std::vector< double > & eevecEEShape() const
DDName alvName(unsigned int i) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DDTranslation
Definition: DDTranslation.h:7
const std::vector< double > & eevecEESCCtrs() const
double eenSCCutaway() const
double eePF45() const
double eezOff() const
DDName EEGetSCName(const int iCol, const int iRow)
HepGeom::Rotate3D Ro3D
std::vector< double > m_vecEESCProf