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