File indexing completed on 2023-03-17 13:02:54
0001
0002
0003
0004
0005
0006
0007 #include <cmath>
0008 #include <algorithm>
0009
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0012 #include "DetectorDescription/Core/interface/DDSolid.h"
0013 #include "DetectorDescription/Core/interface/DDCurrentNamespace.h"
0014 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0015
0016 #include <CLHEP/Geometry/Transform3D.h>
0017
0018
0019 #include "Geometry/EcalCommonData/interface/DDEcalEndcapTrap.h"
0020
0021 #include <map>
0022 #include <string>
0023 #include <vector>
0024 #include "DetectorDescription/Core/interface/DDTypes.h"
0025 #include "DetectorDescription/Core/interface/DDName.h"
0026 #include "DetectorDescription/Core/interface/DDAlgorithm.h"
0027 #include "DetectorDescription/Core/interface/DDMaterial.h"
0028 #include "DetectorDescription/Core/interface/DDSplit.h"
0029 #include "DetectorDescription/Core/interface/DDTransform.h"
0030 #include "Geometry/CaloGeometry/interface/EcalTrapezoidParameters.h"
0031 #include "CLHEP/Geometry/Transform3D.h"
0032
0033
0034
0035 class DDEcalEndcapAlgo : public DDAlgorithm {
0036 public:
0037 typedef EcalTrapezoidParameters Trap;
0038 typedef HepGeom::Point3D<double> Pt3D;
0039 typedef HepGeom::Transform3D Tf3D;
0040 typedef HepGeom::ReflectZ3D RfZ3D;
0041 typedef HepGeom::Translate3D Tl3D;
0042 typedef HepGeom::Rotate3D Ro3D;
0043 typedef HepGeom::RotateZ3D RoZ3D;
0044 typedef HepGeom::RotateY3D RoY3D;
0045 typedef HepGeom::RotateX3D RoX3D;
0046
0047 typedef CLHEP::Hep3Vector Vec3;
0048 typedef CLHEP::HepRotation Rota;
0049
0050
0051 DDEcalEndcapAlgo();
0052 ~DDEcalEndcapAlgo() override;
0053
0054 void initialize(const DDNumericArguments& nArgs,
0055 const DDVectorArguments& vArgs,
0056 const DDMapArguments& mArgs,
0057 const DDStringArguments& sArgs,
0058 const DDStringVectorArguments& vsArgs) override;
0059 void execute(DDCompactView& cpv) override;
0060
0061
0062 void EEPositionCRs(const DDName& pName, const DDTranslation& offset, const int iSCType, DDCompactView& cpv);
0063
0064 void EECreateSC(const unsigned int iSCType, DDCompactView& cpv);
0065
0066 void EECreateCR();
0067
0068 void EEPosSC(const int iCol, const int iRow, DDName EEDeeName);
0069
0070 unsigned int EEGetSCType(const unsigned int iCol, const unsigned int iRow);
0071
0072 DDName EEGetSCName(const int iCol, const int iRow);
0073
0074 std::vector<double> EEGetSCCtrs(const int iCol, const int iRow);
0075
0076 DDMaterial ddmat(const std::string& s) const;
0077 DDName ddname(const std::string& s) const;
0078 DDRotation myrot(const std::string& s, const DDRotationMatrix& r) const;
0079
0080 const std::string& idNameSpace() const { return m_idNameSpace; }
0081
0082
0083 DDMaterial eeMat() const { return ddmat(m_EEMat); }
0084 double eezOff() const { return m_EEzOff; }
0085
0086 DDName eeQuaName() const { return ddname(m_EEQuaName); }
0087 DDMaterial eeQuaMat() const { return ddmat(m_EEQuaMat); }
0088
0089 DDMaterial eeCrysMat() const { return ddmat(m_EECrysMat); }
0090 DDMaterial eeWallMat() const { return ddmat(m_EEWallMat); }
0091
0092 double eeCrysLength() const { return m_EECrysLength; }
0093 double eeCrysRear() const { return m_EECrysRear; }
0094 double eeCrysFront() const { return m_EECrysFront; }
0095 double eeSCELength() const { return m_EESCELength; }
0096 double eeSCERear() const { return m_EESCERear; }
0097 double eeSCEFront() const { return m_EESCEFront; }
0098 double eeSCALength() const { return m_EESCALength; }
0099 double eeSCARear() const { return m_EESCARear; }
0100 double eeSCAFront() const { return m_EESCAFront; }
0101 double eeSCAWall() const { return m_EESCAWall; }
0102 double eeSCHLength() const { return m_EESCHLength; }
0103 double eeSCHSide() const { return m_EESCHSide; }
0104
0105 double eenSCTypes() const { return m_EEnSCTypes; }
0106 double eenColumns() const { return m_EEnColumns; }
0107 double eenSCCutaway() const { return m_EEnSCCutaway; }
0108 double eenSCquad() const { return m_EEnSCquad; }
0109 double eenCRSC() const { return m_EEnCRSC; }
0110 const std::vector<double>& eevecEESCProf() const { return m_vecEESCProf; }
0111 const std::vector<double>& eevecEEShape() const { return m_vecEEShape; }
0112 const std::vector<double>& eevecEESCCutaway() const { return m_vecEESCCutaway; }
0113 const std::vector<double>& eevecEESCCtrs() const { return m_vecEESCCtrs; }
0114 const std::vector<double>& eevecEECRCtrs() const { return m_vecEECRCtrs; }
0115
0116 DDName cutBoxName() const { return ddname(m_cutBoxName); }
0117 double eePFHalf() const { return m_PFhalf; }
0118 double eePFFifth() const { return m_PFfifth; }
0119 double eePF45() const { return m_PF45; }
0120
0121 DDName envName(unsigned int i) const { return ddname(m_envName + std::to_string(i)); }
0122 DDName alvName(unsigned int i) const { return ddname(m_alvName + std::to_string(i)); }
0123 DDName intName(unsigned int i) const { return ddname(m_intName + std::to_string(i)); }
0124 DDName cryName() const { return ddname(m_cryName); }
0125
0126 DDName addTmp(DDName aName) const { return ddname(aName.name() + "Tmp"); }
0127
0128 const DDTranslation& cryFCtr(unsigned int iRow, unsigned int iCol) const { return m_cryFCtr[iRow - 1][iCol - 1]; }
0129
0130 const DDTranslation& cryRCtr(unsigned int iRow, unsigned int iCol) const { return m_cryRCtr[iRow - 1][iCol - 1]; }
0131
0132 const DDTranslation& scrFCtr(unsigned int iRow, unsigned int iCol) const { return m_scrFCtr[iRow - 1][iCol - 1]; }
0133
0134 const DDTranslation& scrRCtr(unsigned int iRow, unsigned int iCol) const { return m_scrRCtr[iRow - 1][iCol - 1]; }
0135
0136 const std::vector<double>& vecEESCLims() const { return m_vecEESCLims; }
0137
0138 double iLength() const { return m_iLength; }
0139 double iXYOff() const { return m_iXYOff; }
0140
0141 protected:
0142 private:
0143 std::string m_idNameSpace;
0144
0145
0146 std::string m_EEMat;
0147 double m_EEzOff;
0148
0149 std::string m_EEQuaName;
0150 std::string m_EEQuaMat;
0151
0152 std::string m_EECrysMat;
0153 std::string m_EEWallMat;
0154
0155 double m_EECrysLength;
0156 double m_EECrysRear;
0157 double m_EECrysFront;
0158 double m_EESCELength;
0159 double m_EESCERear;
0160 double m_EESCEFront;
0161 double m_EESCALength;
0162 double m_EESCARear;
0163 double m_EESCAFront;
0164 double m_EESCAWall;
0165 double m_EESCHLength;
0166 double m_EESCHSide;
0167
0168 double m_EEnSCTypes;
0169 std::vector<double> m_vecEESCProf;
0170 double m_EEnColumns;
0171 std::vector<double> m_vecEEShape;
0172 double m_EEnSCCutaway;
0173 std::vector<double> m_vecEESCCutaway;
0174 double m_EEnSCquad;
0175 std::vector<double> m_vecEESCCtrs;
0176 double m_EEnCRSC;
0177 std::vector<double> m_vecEECRCtrs;
0178
0179 const std::vector<double>* m_cutParms;
0180 std::string m_cutBoxName;
0181
0182 std::string m_envName;
0183 std::string m_alvName;
0184 std::string m_intName;
0185 std::string m_cryName;
0186
0187 DDTranslation m_cryFCtr[5][5];
0188 DDTranslation m_cryRCtr[5][5];
0189
0190 DDTranslation m_scrFCtr[10][10];
0191 DDTranslation m_scrRCtr[10][10];
0192
0193 double m_PFhalf;
0194 double m_PFfifth;
0195 double m_PF45;
0196
0197 std::vector<double> m_vecEESCLims;
0198
0199 double m_iLength;
0200
0201 double m_iXYOff;
0202
0203 double m_cryZOff;
0204
0205 double m_zFront;
0206 };
0207
0208 namespace std {}
0209 using namespace std;
0210
0211 DDEcalEndcapAlgo::DDEcalEndcapAlgo()
0212 : m_idNameSpace(""),
0213 m_EEMat(""),
0214 m_EEzOff(0),
0215 m_EEQuaName(""),
0216 m_EEQuaMat(""),
0217 m_EECrysMat(""),
0218 m_EEWallMat(""),
0219 m_EECrysLength(0),
0220 m_EECrysRear(0),
0221 m_EECrysFront(0),
0222 m_EESCELength(0),
0223 m_EESCERear(0),
0224 m_EESCEFront(0),
0225 m_EESCALength(0),
0226 m_EESCARear(0),
0227 m_EESCAFront(0),
0228 m_EESCAWall(0),
0229 m_EESCHLength(0),
0230 m_EESCHSide(0),
0231 m_EEnSCTypes(0),
0232 m_vecEESCProf(),
0233 m_EEnColumns(0),
0234 m_vecEEShape(),
0235 m_EEnSCCutaway(0),
0236 m_vecEESCCutaway(),
0237 m_EEnSCquad(0),
0238 m_vecEESCCtrs(),
0239 m_EEnCRSC(0),
0240 m_vecEECRCtrs(),
0241 m_cutParms(nullptr),
0242 m_cutBoxName(""),
0243 m_envName(""),
0244 m_alvName(""),
0245 m_intName(""),
0246 m_cryName(""),
0247 m_PFhalf(0),
0248 m_PFfifth(0),
0249 m_PF45(0),
0250 m_vecEESCLims(),
0251 m_iLength(0),
0252 m_iXYOff(0),
0253 m_cryZOff(0),
0254 m_zFront(0) {
0255 edm::LogVerbatim("EcalGeomX") << "DDEcalEndcapAlgo info: Creating an instance";
0256 }
0257
0258 DDEcalEndcapAlgo::~DDEcalEndcapAlgo() {}
0259
0260 void DDEcalEndcapAlgo::initialize(const DDNumericArguments& nArgs,
0261 const DDVectorArguments& vArgs,
0262 const DDMapArguments& ,
0263 const DDStringArguments& sArgs,
0264 const DDStringVectorArguments& ) {
0265 #ifdef EDM_ML_DEBUG
0266 edm::LogVerbatim("EcalGeomX") << "DDEcalEndcapAlgo info: Initialize";
0267 #endif
0268 m_idNameSpace = DDCurrentNamespace::ns();
0269
0270 m_idNameSpace = parent().name().ns();
0271
0272 m_EEMat = sArgs["EEMat"];
0273 m_EEzOff = nArgs["EEzOff"];
0274
0275 m_EEQuaName = sArgs["EEQuaName"];
0276 m_EEQuaMat = sArgs["EEQuaMat"];
0277 m_EECrysMat = sArgs["EECrysMat"];
0278 m_EEWallMat = sArgs["EEWallMat"];
0279 m_EECrysLength = nArgs["EECrysLength"];
0280 m_EECrysRear = nArgs["EECrysRear"];
0281 m_EECrysFront = nArgs["EECrysFront"];
0282 m_EESCELength = nArgs["EESCELength"];
0283 m_EESCERear = nArgs["EESCERear"];
0284 m_EESCEFront = nArgs["EESCEFront"];
0285 m_EESCALength = nArgs["EESCALength"];
0286 m_EESCARear = nArgs["EESCARear"];
0287 m_EESCAFront = nArgs["EESCAFront"];
0288 m_EESCAWall = nArgs["EESCAWall"];
0289 m_EESCHLength = nArgs["EESCHLength"];
0290 m_EESCHSide = nArgs["EESCHSide"];
0291 m_EEnSCTypes = nArgs["EEnSCTypes"];
0292 m_EEnColumns = nArgs["EEnColumns"];
0293 m_EEnSCCutaway = nArgs["EEnSCCutaway"];
0294 m_EEnSCquad = nArgs["EEnSCquad"];
0295 m_EEnCRSC = nArgs["EEnCRSC"];
0296 m_vecEESCProf = vArgs["EESCProf"];
0297 m_vecEEShape = vArgs["EEShape"];
0298 m_vecEESCCutaway = vArgs["EESCCutaway"];
0299 m_vecEESCCtrs = vArgs["EESCCtrs"];
0300 m_vecEECRCtrs = vArgs["EECRCtrs"];
0301
0302 m_cutBoxName = sArgs["EECutBoxName"];
0303
0304 m_envName = sArgs["EEEnvName"];
0305 m_alvName = sArgs["EEAlvName"];
0306 m_intName = sArgs["EEIntName"];
0307 m_cryName = sArgs["EECryName"];
0308
0309 m_PFhalf = nArgs["EEPFHalf"];
0310 m_PFfifth = nArgs["EEPFFifth"];
0311 m_PF45 = nArgs["EEPF45"];
0312
0313 m_vecEESCLims = vArgs["EESCLims"];
0314
0315 m_iLength = nArgs["EEiLength"];
0316
0317 m_iXYOff = nArgs["EEiXYOff"];
0318
0319 m_cryZOff = nArgs["EECryZOff"];
0320
0321 m_zFront = nArgs["EEzFront"];
0322 }
0323
0324
0325
0326
0327
0328 DDRotation DDEcalEndcapAlgo::myrot(const std::string& s, const DDRotationMatrix& r) const {
0329 return DDrot(ddname(m_idNameSpace + ":" + s), std::make_unique<DDRotationMatrix>(r));
0330 }
0331
0332 DDMaterial DDEcalEndcapAlgo::ddmat(const std::string& s) const { return DDMaterial(ddname(s)); }
0333
0334 DDName DDEcalEndcapAlgo::ddname(const std::string& s) const {
0335 const pair<std::string, std::string> temp(DDSplit(s));
0336 if (temp.second.empty()) {
0337 return DDName(temp.first, m_idNameSpace);
0338 } else {
0339 return DDName(temp.first, temp.second);
0340 }
0341 }
0342
0343
0344
0345 void DDEcalEndcapAlgo::execute(DDCompactView& cpv) {
0346
0347
0348
0349
0350
0351
0352
0353 const double cutWid(eeSCERear() / sqrt(2.));
0354 const DDSolid eeCutBox(DDSolidFactory::box(cutBoxName(), cutWid, cutWid, eeSCELength() / sqrt(2.)));
0355 m_cutParms = &eeCutBox.parameters();
0356
0357
0358 const double zFix(m_zFront - 3172.0 * mm);
0359
0360
0361 for (unsigned int iC(0); iC != (unsigned int)eenSCquad(); ++iC) {
0362 const unsigned int iOff(8 * iC);
0363 const unsigned int ix((unsigned int)eevecEESCCtrs()[iOff + 0]);
0364 const unsigned int iy((unsigned int)eevecEESCCtrs()[iOff + 1]);
0365
0366 assert(ix > 0 && ix < 11 && iy > 0 && iy < 11);
0367
0368 m_scrFCtr[ix - 1][iy - 1] =
0369 DDTranslation(eevecEESCCtrs()[iOff + 2], eevecEESCCtrs()[iOff + 4], eevecEESCCtrs()[iOff + 6] + zFix);
0370
0371 m_scrRCtr[ix - 1][iy - 1] =
0372 DDTranslation(eevecEESCCtrs()[iOff + 3], eevecEESCCtrs()[iOff + 5], eevecEESCCtrs()[iOff + 7] + zFix);
0373 }
0374
0375
0376 for (unsigned int iC(0); iC != 25; ++iC) {
0377 const unsigned int iOff(8 * iC);
0378 const unsigned int ix((unsigned int)eevecEECRCtrs()[iOff + 0]);
0379 const unsigned int iy((unsigned int)eevecEECRCtrs()[iOff + 1]);
0380
0381 assert(ix > 0 && ix < 6 && iy > 0 && iy < 6);
0382
0383 m_cryFCtr[ix - 1][iy - 1] =
0384 DDTranslation(eevecEECRCtrs()[iOff + 2], eevecEECRCtrs()[iOff + 4], eevecEECRCtrs()[iOff + 6]);
0385
0386 m_cryRCtr[ix - 1][iy - 1] =
0387 DDTranslation(eevecEECRCtrs()[iOff + 3], eevecEECRCtrs()[iOff + 5], eevecEECRCtrs()[iOff + 7]);
0388 }
0389
0390 EECreateCR();
0391
0392 for (unsigned int isc(0); isc < eenSCTypes(); ++isc) {
0393 EECreateSC(isc + 1, cpv);
0394 }
0395
0396 const std::vector<double>& colLimits(eevecEEShape());
0397
0398 for (int icol = 1; icol <= int(eenColumns()); icol++) {
0399
0400 for (int irow = int(colLimits[2 * icol - 2]); irow <= int(colLimits[2 * icol - 1]); ++irow) {
0401 if (vecEESCLims()[0] <= icol && vecEESCLims()[1] >= icol && vecEESCLims()[2] <= irow &&
0402 vecEESCLims()[3] >= irow) {
0403
0404 const unsigned int isctype(EEGetSCType(icol, irow));
0405
0406
0407
0408 DDEcalEndcapTrap scrys(1, eeSCEFront(), eeSCERear(), eeSCELength());
0409
0410 scrys.moveto(scrFCtr(icol, irow), scrRCtr(icol, irow));
0411 scrys.translate(DDTranslation(0., 0., -eezOff()));
0412
0413 DDName rname(envName(isctype).name() + std::to_string(icol) + "R" + std::to_string(irow));
0414
0415 #ifdef EDM_ML_DEBUG
0416 edm::LogVerbatim("EcalGeoXm") << "Quadrant, SC col/row " << eeQuaName() << " " << icol << " / " << irow
0417 << std::endl
0418 << " Limits " << int(colLimits[2 * icol - 2]) << "->"
0419 << int(colLimits[2 * icol - 1]) << std::endl
0420 << " SC type = " << isctype << std::endl
0421 << " Zoff = " << eezOff() << std::endl
0422 << " Rotation " << rname << " " << scrys.rotation() << std::endl
0423 << " Position " << scrys.centrePos();
0424 #endif
0425
0426 cpv.position(envName(isctype),
0427 eeQuaName(),
0428 100 * isctype + 10 * (icol - 1) + (irow - 1),
0429 scrys.centrePos(),
0430 myrot(rname.fullname(), scrys.rotation()));
0431 #ifdef EDM_ML_DEBUG
0432 edm::LogVerbatim("EEGeom") << envName(isctype) << " " << (100 * isctype + 10 * (icol - 1) + (irow - 1))
0433 << " in " << eeQuaName();
0434 edm::LogVerbatim("EcalGeom") << envName(isctype) << " " << (100 * isctype + 10 * (icol - 1) + (irow - 1))
0435 << " in " << eeQuaName() << " at " << scrys.centrePos();
0436 #endif
0437 }
0438 }
0439 }
0440 }
0441
0442 void DDEcalEndcapAlgo::EECreateSC(const unsigned int iSCType,
0443 DDCompactView& cpv) {
0444
0445 DDRotation noRot;
0446 DDLogicalPart eeSCELog;
0447 DDLogicalPart eeSCALog;
0448 DDLogicalPart eeSCILog;
0449
0450 #ifdef EDM_ML_DEBUG
0451 edm::LogVerbatim("EcalGeomX") << "EECreateSC: Creating SC envelope";
0452 #endif
0453 const string anum(std::to_string(iSCType));
0454
0455 const double eFront(0.5 * eeSCEFront());
0456 const double eRear(0.5 * eeSCERear());
0457 const double eAng(atan((eeSCERear() - eeSCEFront()) / (sqrt(2.) * eeSCELength())));
0458 const double ffived(45 * deg);
0459 const double zerod(0 * deg);
0460 DDSolid eeSCEnv(DDSolidFactory::trap((1 == iSCType ? envName(iSCType) : addTmp(envName(iSCType))),
0461 0.5 * eeSCELength(),
0462 eAng,
0463 ffived,
0464 eFront,
0465 eFront,
0466 eFront,
0467 zerod,
0468 eRear,
0469 eRear,
0470 eRear,
0471 zerod));
0472 #ifdef EDM_ML_DEBUG
0473 edm::LogVerbatim("EcalGeom") << eeSCEnv.name() << " Trap with parameters: " << 0.5 * eeSCELength() << ":" << eAng
0474 << ffived << ":" << eFront << ":" << eFront << ":" << eFront << ":" << zerod << ":"
0475 << eRear << ":" << eRear << ":" << eRear << ":" << zerod;
0476 #endif
0477
0478 const double aFront(0.5 * eeSCAFront());
0479 const double aRear(0.5 * eeSCARear());
0480 const double aAng(atan((eeSCARear() - eeSCAFront()) / (sqrt(2.) * eeSCALength())));
0481 const DDSolid eeSCAlv(DDSolidFactory::trap((1 == iSCType ? alvName(iSCType) : addTmp(alvName(iSCType))),
0482 0.5 * eeSCALength(),
0483 aAng,
0484 ffived,
0485 aFront,
0486 aFront,
0487 aFront,
0488 zerod,
0489 aRear,
0490 aRear,
0491 aRear,
0492 zerod));
0493 #ifdef EDM_ML_DEBUG
0494 edm::LogVerbatim("EcalGeom") << eeSCAlv.name() << " Trap with parameters: " << 0.5 * eeSCALength() << ":" << aAng
0495 << ":" << ffived << ":" << aFront << ":" << aFront << ":" << aFront << ":" << zerod
0496 << ":" << aRear << ":" << aRear << ":" << aRear << ":" << zerod;
0497 #endif
0498 const double dwall(eeSCAWall());
0499 const double iFront(aFront - dwall);
0500 const double iRear(iFront);
0501 const double iLen(iLength());
0502 const DDSolid eeSCInt(DDSolidFactory::trap((1 == iSCType ? intName(iSCType) : addTmp(intName(iSCType))),
0503 iLen / 2.,
0504 atan((eeSCARear() - eeSCAFront()) / (sqrt(2.) * eeSCALength())),
0505 ffived,
0506 iFront,
0507 iFront,
0508 iFront,
0509 zerod,
0510 iRear,
0511 iRear,
0512 iRear,
0513 zerod));
0514 #ifdef EDM_ML_DEBUG
0515 edm::LogVerbatim("EcalGeom") << eeSCInt.name() << " Trap with parameters: " << iLen / 2. << ":"
0516 << (atan((eeSCARear() - eeSCAFront()) / (sqrt(2.) * eeSCALength()))) << ":" << ffived
0517 << ":" << iFront << ":" << iFront << ":" << iFront << ":" << zerod << ":" << iRear << ":"
0518 << iRear << ":" << iRear << ":" << zerod;
0519 #endif
0520 const double dz(-0.5 * (eeSCELength() - eeSCALength()));
0521 const double dxy(0.5 * dz * (eeSCERear() - eeSCEFront()) / eeSCELength());
0522 const double zIOff(-(eeSCALength() - iLen) / 2.);
0523 const double xyIOff(iXYOff());
0524
0525 if (1 == iSCType)
0526 {
0527 eeSCELog = DDLogicalPart(envName(iSCType), eeMat(), eeSCEnv);
0528 eeSCALog = DDLogicalPart(alvName(iSCType), eeWallMat(), eeSCAlv);
0529 eeSCILog = DDLogicalPart(intName(iSCType), eeMat(), eeSCInt);
0530 } else
0531 {
0532 const double half((*m_cutParms)[0] - eePFHalf() * eeCrysRear());
0533 const double fifth((*m_cutParms)[0] + eePFFifth() * eeCrysRear());
0534 const double fac(eePF45());
0535
0536 const double zmm(0 * mm);
0537
0538 DDTranslation cutTra(
0539 2 == iSCType ? DDTranslation(zmm, half, zmm)
0540 : (3 == iSCType ? DDTranslation(half, zmm, zmm)
0541 : (4 == iSCType ? DDTranslation(zmm, -fifth, zmm)
0542 : (5 == iSCType ? DDTranslation(-half * fac, -half * fac, zmm)
0543 : DDTranslation(-fifth, zmm, zmm)))));
0544
0545 const CLHEP::HepRotationZ cutm(ffived);
0546
0547 DDRotation cutRot(5 != iSCType ? noRot
0548 : myrot("EECry5Rot",
0549 DDRotationMatrix(cutm.xx(),
0550 cutm.xy(),
0551 cutm.xz(),
0552 cutm.yx(),
0553 cutm.yy(),
0554 cutm.yz(),
0555 cutm.zx(),
0556 cutm.zy(),
0557 cutm.zz())));
0558
0559 DDSolid eeCutEnv(
0560 DDSolidFactory::subtraction(envName(iSCType), addTmp(envName(iSCType)), cutBoxName(), cutTra, cutRot));
0561 #ifdef EDM_ML_DEBUG
0562 edm::LogVerbatim("EcalGeom") << eeCutEnv.name() << " Subtracted by " << (eeSCERear() / sqrt(2.)) << ":"
0563 << (eeSCERear() / sqrt(2.)) << ":" << (eeSCELength() / sqrt(2.));
0564 #endif
0565 const DDTranslation extra(dxy, dxy, dz);
0566
0567 DDSolid eeCutAlv(
0568 DDSolidFactory::subtraction(alvName(iSCType), addTmp(alvName(iSCType)), cutBoxName(), cutTra - extra, cutRot));
0569
0570 #ifdef EDM_ML_DEBUG
0571 edm::LogVerbatim("EcalGeom") << eeCutAlv.name() << " Subtracted by " << (eeSCERear() / sqrt(2.)) << ":"
0572 << (eeSCERear() / sqrt(2.)) << ":" << (eeSCELength() / sqrt(2.));
0573 #endif
0574 const double mySign(iSCType < 4 ? +1. : -1.);
0575
0576 const DDTranslation extraI(xyIOff + mySign * 2 * mm, xyIOff + mySign * 2 * mm, zIOff);
0577
0578 DDSolid eeCutInt(
0579 DDSolidFactory::subtraction(intName(iSCType), addTmp(intName(iSCType)), cutBoxName(), cutTra - extraI, cutRot));
0580 #ifdef EDM_ML_DEBUG
0581 edm::LogVerbatim("EcalGeom") << eeCutInt.name() << " Subtracted by " << (eeSCERear() / sqrt(2.)) << ":"
0582 << (eeSCERear() / sqrt(2.)) << ":" << (eeSCELength() / sqrt(2.));
0583 #endif
0584
0585 eeSCELog = DDLogicalPart(envName(iSCType), eeMat(), eeCutEnv);
0586 eeSCALog = DDLogicalPart(alvName(iSCType), eeWallMat(), eeCutAlv);
0587 eeSCILog = DDLogicalPart(intName(iSCType), eeMat(), eeCutInt);
0588 }
0589
0590 cpv.position(eeSCALog, envName(iSCType), iSCType * 100 + 1, DDTranslation(dxy, dxy, dz), noRot);
0591 cpv.position(eeSCILog, alvName(iSCType), iSCType * 100 + 1, DDTranslation(xyIOff, xyIOff, zIOff), noRot);
0592 #ifdef EDM_ML_DEBUG
0593 edm::LogVerbatim("EEGeom") << eeSCALog.name() << " " << (iSCType * 100 + 1) << " in " << envName(iSCType);
0594 edm::LogVerbatim("EEGeom") << eeSCILog.name() << " " << (iSCType * 100 + 1) << " in " << alvName(iSCType);
0595 edm::LogVerbatim("EcalGeom") << eeSCALog.name() << " " << (iSCType * 100 + 1) << " in " << envName(iSCType) << " at ("
0596 << dxy << ", " << dxy << ", " << dz << ")";
0597 edm::LogVerbatim("EcalGeom") << eeSCILog.name() << " " << (iSCType * 100 + 1) << " in " << alvName(iSCType) << " at ("
0598 << xyIOff << ", " << xyIOff << ", " << zIOff << ")";
0599 #endif
0600 DDTranslation croffset(0., 0., 0.);
0601 EEPositionCRs(alvName(iSCType), croffset, iSCType, cpv);
0602 }
0603
0604 unsigned int DDEcalEndcapAlgo::EEGetSCType(const unsigned int iCol, const unsigned int iRow) {
0605 unsigned int iType = 1;
0606 for (unsigned int ii = 0; ii < (unsigned int)(eenSCCutaway()); ++ii) {
0607 if ((eevecEESCCutaway()[3 * ii] == iCol) && (eevecEESCCutaway()[3 * ii + 1] == iRow)) {
0608 iType = int(eevecEESCCutaway()[3 * ii + 2]);
0609 #ifdef EDM_ML_DEBUG
0610 edm::LogVerbatim("EcalGeomX") << "EEGetSCType: col, row, type = " << iCol << " " << iRow << " " << iType;
0611 #endif
0612 }
0613 }
0614 return iType;
0615 }
0616
0617 void DDEcalEndcapAlgo::EECreateCR() {
0618
0619
0620 #ifdef EDM_ML_DEBUG
0621 edm::LogVerbatim("EcalGeomX") << "EECreateCR: = ";
0622 #endif
0623 DDSolid EECRSolid(DDSolidFactory::trap(cryName(),
0624 0.5 * eeCrysLength(),
0625 atan((eeCrysRear() - eeCrysFront()) / (sqrt(2.) * eeCrysLength())),
0626 45. * deg,
0627 0.5 * eeCrysFront(),
0628 0.5 * eeCrysFront(),
0629 0.5 * eeCrysFront(),
0630 0. * deg,
0631 0.5 * eeCrysRear(),
0632 0.5 * eeCrysRear(),
0633 0.5 * eeCrysRear(),
0634 0. * deg));
0635 #ifdef EDM_ML_DEBUG
0636 edm::LogVerbatim("EcalGeom") << EECRSolid.name() << " Trap with parameters: " << 0.5 * eeCrysLength() << ":"
0637 << (atan((eeCrysRear() - eeCrysFront()) / (sqrt(2.) * eeCrysLength()))) << ":"
0638 << 45. * deg << ":" << 0.5 * eeCrysFront() << ":" << 0.5 * eeCrysFront() << ":"
0639 << 0.5 * eeCrysFront() << ":" << 0. * deg << ":" << 0.5 * eeCrysRear() << ":"
0640 << 0.5 * eeCrysRear() << ":" << 0.5 * eeCrysRear() << ":" << 0. * deg;
0641 #endif
0642
0643 DDLogicalPart part(cryName(), eeCrysMat(), EECRSolid);
0644 }
0645
0646 void DDEcalEndcapAlgo::EEPositionCRs(const DDName& pName,
0647 const DDTranslation& ,
0648 const int iSCType,
0649 DDCompactView& cpv) {
0650
0651
0652 #ifdef EDM_ML_DEBUG
0653 edm::LogVerbatim("EcalGeomX") << "EEPositionCRs called ";
0654 #endif
0655 static const unsigned int ncol(5);
0656
0657 if (iSCType > 0 && iSCType <= eenSCTypes()) {
0658 const unsigned int icoffset((iSCType - 1) * ncol - 1);
0659
0660
0661 for (unsigned int icol(1); icol <= ncol; ++icol) {
0662
0663 const int ncrcol((int)eevecEESCProf()[icoffset + icol]);
0664
0665 const int imin(0 < ncrcol ? 1 : (0 > ncrcol ? ncol + ncrcol + 1 : 0));
0666 const int imax(0 < ncrcol ? ncrcol : (0 > ncrcol ? ncol : 0));
0667
0668 if (imax > 0) {
0669
0670 for (int irow(imin); irow <= imax; ++irow) {
0671 #ifdef EDM_ML_DEBUG
0672 edm::LogVerbatim("EcalGeomX") << " type, col, row " << iSCType << " " << icol << " " << irow;
0673 #endif
0674
0675
0676 DDEcalEndcapTrap crystal(1, eeCrysFront(), eeCrysRear(), eeCrysLength());
0677
0678 crystal.moveto(cryFCtr(icol, irow), cryRCtr(icol, irow));
0679
0680 DDName rname("EECrRoC" + std::to_string(icol) + "R" + std::to_string(irow));
0681
0682 cpv.position(cryName(),
0683 pName,
0684 100 * iSCType + 10 * (icol - 1) + (irow - 1),
0685 crystal.centrePos() - DDTranslation(0, 0, m_cryZOff),
0686 myrot(rname.fullname(), crystal.rotation()));
0687 #ifdef EDM_ML_DEBUG
0688 edm::LogVerbatim("EEGeom") << cryName() << " " << (100 * iSCType + 10 * (icol - 1) + (irow - 1)) << " in "
0689 << pName;
0690 edm::LogVerbatim("EcalGeom") << cryName() << " " << (100 * iSCType + 10 * (icol - 1) + (irow - 1)) << " in "
0691 << pName << " at " << (crystal.centrePos() - DDTranslation(0, 0, m_cryZOff));
0692 #endif
0693 }
0694 }
0695 }
0696 }
0697 }
0698
0699 #include "DetectorDescription/Core/interface/DDAlgorithmFactory.h"
0700
0701 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDEcalEndcapAlgo, "ecal:DDEcalEndcapAlgo");