Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-26 22:39:37

0001 /* for High Granularity Calorimeter
0002  * This geometry is essentially driven by topology, 
0003  * which is thus encapsulated in this class. 
0004  * This makes this geometry not suitable to be loaded
0005  * by regular CaloGeometryLoader<T>
0006  */
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "FWCore/Utilities/interface/Exception.h"
0009 #include "DataFormats/GeometrySurface/interface/Plane.h"
0010 #include "Geometry/HGCalGeometry/interface/HGCalGeometry.h"
0011 #include "Geometry/CaloGeometry/interface/CaloGenericDetId.h"
0012 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0013 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0014 #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
0015 
0016 #include <cmath>
0017 
0018 #include <Math/Transform3D.h>
0019 #include <Math/EulerAngles.h>
0020 
0021 typedef CaloCellGeometry::Tr3D Tr3D;
0022 typedef std::vector<float> ParmVec;
0023 
0024 //#define EDM_ML_DEBUG
0025 
0026 const bool debugLocate = false;
0027 
0028 HGCalGeometry::HGCalGeometry(const HGCalTopology& topology_)
0029     : m_topology(topology_),
0030       m_validGeomIds(topology_.totalGeomModules()),
0031       m_det(topology_.detector()),
0032       m_subdet(topology_.subDetector()),
0033       twoBysqrt3_(2.0 / std::sqrt(3.0)) {
0034   if (m_det == DetId::HGCalHSc) {
0035     m_cellVec2 = CellVec2(topology_.totalGeomModules());
0036   } else {
0037     m_cellVec = CellVec(topology_.totalGeomModules());
0038   }
0039   m_validIds.reserve(m_topology.totalModules());
0040 #ifdef EDM_ML_DEBUG
0041   edm::LogVerbatim("HGCalGeom") << "Expected total # of Geometry Modules " << m_topology.totalGeomModules();
0042 #endif
0043 }
0044 
0045 void HGCalGeometry::fillNamedParams(DDFilteredView fv) {}
0046 
0047 void HGCalGeometry::initializeParms() {}
0048 
0049 void HGCalGeometry::localCorners(Pt3DVec& lc, const CCGFloat* pv, unsigned int i, Pt3D& ref) {
0050   if (m_det == DetId::HGCalHSc) {
0051     FlatTrd::localCorners(lc, pv, ref);
0052   } else {
0053     FlatHexagon::localCorners(lc, pv, ref);
0054   }
0055 }
0056 
0057 void HGCalGeometry::newCell(
0058     const GlobalPoint& f1, const GlobalPoint& f2, const GlobalPoint& f3, const CCGFloat* parm, const DetId& detId) {
0059   DetId geomId = getGeometryDetId(detId);
0060   int cells(0);
0061   HGCalTopology::DecodedDetId id = m_topology.decode(detId);
0062   if (m_topology.waferHexagon6()) {
0063     cells = m_topology.dddConstants().numberCellsHexagon(id.iSec1);
0064 #ifdef EDM_ML_DEBUG
0065     edm::LogVerbatim("HGCalGeom") << "NewCell " << HGCalDetId(detId) << " GEOM " << HGCalDetId(geomId);
0066 #endif
0067   } else if (m_topology.tileTrapezoid()) {
0068     cells = 1;
0069 #ifdef EDM_ML_DEBUG
0070     edm::LogVerbatim("HGCalGeom") << "NewCell " << HGCScintillatorDetId(detId) << " GEOM "
0071                                   << HGCScintillatorDetId(geomId);
0072 #endif
0073   } else {
0074     cells = m_topology.dddConstants().numberCellsHexagon(id.iLay, id.iSec1, id.iSec2, false);
0075 #ifdef EDM_ML_DEBUG
0076     edm::LogVerbatim("HGCalGeom") << "NewCell " << HGCSiliconDetId(detId) << " GEOM " << HGCSiliconDetId(geomId);
0077 #endif
0078   }
0079   const uint32_t cellIndex(m_topology.detId2denseGeomId(geomId));
0080 
0081   if (m_det == DetId::HGCalHSc) {
0082     m_cellVec2.at(cellIndex) = FlatTrd(cornersMgr(), f1, f2, f3, parm);
0083   } else {
0084     m_cellVec.at(cellIndex) = FlatHexagon(cornersMgr(), f1, f2, f3, parm);
0085   }
0086   m_validGeomIds.at(cellIndex) = geomId;
0087 
0088 #ifdef EDM_ML_DEBUG
0089   edm::LogVerbatim("HGCalGeom") << "Store for DetId " << std::hex << detId.rawId() << " GeomId " << geomId.rawId()
0090                                 << std::dec << " Index " << cellIndex << " cells " << cells;
0091   unsigned int nOld = m_validIds.size();
0092 #endif
0093   if (m_topology.waferHexagon6()) {
0094     for (int cell = 0; cell < cells; ++cell) {
0095       id.iCell1 = cell;
0096       DetId idc = m_topology.encode(id);
0097       if (m_topology.valid(idc)) {
0098         m_validIds.emplace_back(idc);
0099 #ifdef EDM_ML_DEBUG
0100         edm::LogVerbatim("HGCalGeom") << "Valid Id [" << cell << "] " << HGCalDetId(idc);
0101 #endif
0102       }
0103     }
0104   } else if (m_topology.tileTrapezoid()) {
0105     DetId idc = m_topology.encode(id);
0106     if (m_topology.valid(idc)) {
0107       HGCScintillatorDetId hid(idc);
0108       std::pair<int, int> typm = m_topology.dddConstants().tileType(hid.layer(), hid.ring(), 0);
0109       if (typm.first >= 0) {
0110         hid.setType(typm.first);
0111         hid.setSiPM(typm.second);
0112         idc = static_cast<DetId>(hid);
0113       }
0114       m_validIds.emplace_back(idc);
0115 #ifdef EDM_ML_DEBUG
0116       edm::LogVerbatim("HGCalGeom") << "Valid Id [0] " << HGCScintillatorDetId(idc);
0117 #endif
0118     } else {
0119       edm::LogWarning("HGCalGeom") << "Check " << HGCScintillatorDetId(idc) << " from " << HGCScintillatorDetId(detId)
0120                                    << " ERROR ???";
0121     }
0122   } else {
0123 #ifdef EDM_ML_DEBUG
0124     unsigned int cellAll(0), cellSelect(0);
0125 #endif
0126     for (int u = 0; u < 2 * cells; ++u) {
0127       for (int v = 0; v < 2 * cells; ++v) {
0128         if (((v - u) < cells) && (u - v) <= cells) {
0129           id.iCell1 = u;
0130           id.iCell2 = v;
0131           DetId idc = m_topology.encode(id);
0132 #ifdef EDM_ML_DEBUG
0133           ++cellAll;
0134 #endif
0135           if (m_topology.dddConstants().cellInLayer(id.iSec1, id.iSec2, u, v, id.iLay, true)) {
0136             m_validIds.emplace_back(idc);
0137 #ifdef EDM_ML_DEBUG
0138             ++cellSelect;
0139             edm::LogVerbatim("HGCalGeom") << "Valid Id [" << u << ", " << v << "] " << HGCSiliconDetId(idc);
0140 #endif
0141           }
0142         }
0143       }
0144     }
0145 #ifdef EDM_ML_DEBUG
0146     edm::LogVerbatim("HGCalGeom") << "HGCalGeometry keeps " << cellSelect << " out of " << cellAll << " for wafer "
0147                                   << id.iSec1 << ":" << id.iSec2 << " in "
0148                                   << " layer " << id.iLay;
0149 #endif
0150   }
0151 #ifdef EDM_ML_DEBUG
0152   if (m_det == DetId::HGCalHSc) {
0153     edm::LogVerbatim("HGCalGeom") << "HGCalGeometry::newCell-> [" << cellIndex << "]"
0154                                   << " front:" << f1.x() << '/' << f1.y() << '/' << f1.z() << " back:" << f2.x() << '/'
0155                                   << f2.y() << '/' << f2.z() << " eta|phi " << m_cellVec2[cellIndex].etaPos() << ":"
0156                                   << m_cellVec2[cellIndex].phiPos();
0157   } else {
0158     edm::LogVerbatim("HGCalGeom") << "HGCalGeometry::newCell-> [" << cellIndex << "]"
0159                                   << " front:" << f1.x() << '/' << f1.y() << '/' << f1.z() << " back:" << f2.x() << '/'
0160                                   << f2.y() << '/' << f2.z() << " eta|phi " << m_cellVec[cellIndex].etaPos() << ":"
0161                                   << m_cellVec[cellIndex].phiPos();
0162   }
0163   unsigned int nNew = m_validIds.size();
0164   if (m_topology.waferHexagon6()) {
0165     edm::LogVerbatim("HGCalGeom") << "ID: " << HGCalDetId(detId) << " with valid DetId from " << nOld << " to " << nNew;
0166   } else if (m_topology.tileTrapezoid()) {
0167     edm::LogVerbatim("HGCalGeom") << "ID: " << HGCScintillatorDetId(detId) << " with valid DetId from " << nOld
0168                                   << " to " << nNew;
0169   } else if (m_topology.isHFNose()) {
0170     edm::LogVerbatim("HGCalGeom") << "ID: " << HFNoseDetId(detId) << " with valid DetId from " << nOld << " to "
0171                                   << nNew;
0172   } else {
0173     edm::LogVerbatim("HGCalGeom") << "ID: " << HGCSiliconDetId(detId) << " with valid DetId from " << nOld << " to "
0174                                   << nNew;
0175   }
0176   edm::LogVerbatim("HGCalGeom") << "Cell[" << cellIndex << "] " << std::hex << geomId.rawId() << ":"
0177                                 << m_validGeomIds[cellIndex].rawId() << std::dec;
0178 #endif
0179 }
0180 
0181 std::shared_ptr<const CaloCellGeometry> HGCalGeometry::getGeometry(const DetId& detId) const {
0182   if (detId == DetId())
0183     return nullptr;  // nothing to get
0184   DetId geomId = getGeometryDetId(detId);
0185   const uint32_t cellIndex(m_topology.detId2denseGeomId(geomId));
0186   const GlobalPoint pos = (detId != geomId) ? getPosition(detId, false) : GlobalPoint();
0187   return cellGeomPtr(cellIndex, pos);
0188 }
0189 
0190 bool HGCalGeometry::present(const DetId& detId) const {
0191   if (detId == DetId())
0192     return false;
0193   DetId geomId = getGeometryDetId(detId);
0194   const uint32_t index(m_topology.detId2denseGeomId(geomId));
0195   return (nullptr != getGeometryRawPtr(index));
0196 }
0197 
0198 GlobalPoint HGCalGeometry::getPosition(const DetId& detid, bool debug) const {
0199   unsigned int cellIndex = indexFor(detid);
0200   GlobalPoint glob;
0201   unsigned int maxSize = (m_topology.tileTrapezoid() ? m_cellVec2.size() : m_cellVec.size());
0202   if (cellIndex < maxSize) {
0203     HGCalTopology::DecodedDetId id = m_topology.decode(detid);
0204     std::pair<float, float> xy;
0205     if (m_topology.waferHexagon6()) {
0206       xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
0207       const HepGeom::Point3D<float> lcoord(xy.first, xy.second, 0);
0208       glob = m_cellVec[cellIndex].getPosition(lcoord);
0209       if (debug)
0210         edm::LogVerbatim("HGCalGeom") << "getPosition:: index " << cellIndex << " Local " << lcoord.x() << ":"
0211                                       << lcoord.y() << " ID " << id.iCell1 << ":" << id.iSec1 << " Global " << glob;
0212     } else if (m_topology.tileTrapezoid()) {
0213       const HepGeom::Point3D<float> lcoord(0, 0, 0);
0214       glob = m_cellVec2[cellIndex].getPosition(lcoord);
0215       if (debug)
0216         edm::LogVerbatim("HGCalGeom") << "getPositionTrap:: index " << cellIndex << " Local " << lcoord.x() << ":"
0217                                       << lcoord.y() << " ID " << id.iLay << ":" << id.iSec1 << ":" << id.iCell1
0218                                       << " Global " << glob;
0219     } else {
0220       if (debug)
0221         edm::LogVerbatim("HGCalGeom") << "getPosition for " << HGCSiliconDetId(detid) << " Layer " << id.iLay
0222                                       << " Wafer " << id.iSec1 << ":" << id.iSec2 << " Cell " << id.iCell1 << ":"
0223                                       << id.iCell2;
0224       xy = m_topology.dddConstants().locateCell(
0225           id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, true, false, debug);
0226       double xx = id.zSide * xy.first;
0227       double zz = id.zSide * m_topology.dddConstants().waferZ(id.iLay, true);
0228       glob = GlobalPoint(xx, xy.second, zz);
0229       if (debug)
0230         edm::LogVerbatim("HGCalGeom") << "getPositionWafer:: index " << cellIndex << " Local " << xy.first << ":"
0231                                       << xy.second << " ID " << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":"
0232                                       << id.iCell1 << ":" << id.iCell2 << " Global " << glob;
0233     }
0234   }
0235   return glob;
0236 }
0237 
0238 GlobalPoint HGCalGeometry::getWaferPosition(const DetId& detid) const {
0239   unsigned int cellIndex = indexFor(detid);
0240   GlobalPoint glob;
0241   unsigned int maxSize = (m_topology.tileTrapezoid() ? m_cellVec2.size() : m_cellVec.size());
0242   if (cellIndex < maxSize) {
0243     const HepGeom::Point3D<float> lcoord(0, 0, 0);
0244     if (m_topology.tileTrapezoid()) {
0245       glob = m_cellVec2[cellIndex].getPosition(lcoord);
0246     } else {
0247       glob = m_cellVec[cellIndex].getPosition(lcoord);
0248     }
0249 #ifdef EDM_ML_DEBUG
0250     edm::LogVerbatim("HGCalGeom") << "getPositionTrap:: ID " << std::hex << detid.rawId() << std::dec << " index "
0251                                   << cellIndex << " Global " << glob;
0252 #endif
0253   }
0254   return glob;
0255 }
0256 
0257 double HGCalGeometry::getArea(const DetId& detid) const {
0258   HGCalGeometry::CornersVec corners = getNewCorners(detid);
0259   double area(0);
0260   if (corners.size() > 1) {
0261     int n = corners.size() - 1;
0262     int j = n - 1;
0263     for (int i = 0; i < n; ++i) {
0264       area += ((corners[j].x() + corners[i].x()) * (corners[i].y() - corners[j].y()));
0265       j = i;
0266     }
0267   }
0268   return std::abs(0.5 * area);
0269 }
0270 
0271 HGCalGeometry::CornersVec HGCalGeometry::getCorners(const DetId& detid) const {
0272   unsigned int ncorner = ((m_det == DetId::HGCalHSc) ? FlatTrd::ncorner_ : FlatHexagon::ncorner_);
0273   HGCalGeometry::CornersVec co(ncorner, GlobalPoint(0, 0, 0));
0274   unsigned int cellIndex = indexFor(detid);
0275   HGCalTopology::DecodedDetId id = m_topology.decode(detid);
0276   if (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc) {
0277     GlobalPoint v = getPosition(detid, false);
0278     int type = std::min(id.iType, 1);
0279     std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(type, id.iSec1);
0280     float dr = k_half * (rr.second - rr.first);
0281     float dfi = m_cellVec2[cellIndex].param()[FlatTrd::k_Cell];
0282     float dz = id.zSide * m_cellVec2[cellIndex].param()[FlatTrd::k_dZ];
0283     float r = v.perp();
0284     float fi = v.phi();
0285     static const int signr[] = {1, 1, -1, -1, 1, 1, -1, -1};
0286     static const int signf[] = {-1, 1, 1, -1, -1, 1, 1, -1};
0287     static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
0288     for (unsigned int i = 0; i < ncorner; ++i) {
0289       co[i] = GlobalPoint((r + signr[i] * dr) * cos(fi + signf[i] * dfi),
0290                           (r + signr[i] * dr) * sin(fi + signf[i] * dfi),
0291                           (v.z() + signz[i] * dz));
0292     }
0293   } else if (cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) {
0294     std::pair<float, float> xy;
0295     if (m_topology.waferHexagon6()) {
0296       xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
0297       float dx = m_cellVec[cellIndex].param()[FlatHexagon::k_r];
0298       float dy = k_half * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
0299       float dz = m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
0300       static const int signx[] = {0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1};
0301       static const int signy[] = {-2, -1, 1, 2, 1, -1, -2, -1, 1, 2, 1, -1};
0302       static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
0303       for (unsigned int i = 0; i < ncorner; ++i) {
0304         const HepGeom::Point3D<float> lcoord(xy.first + signx[i] * dx, xy.second + signy[i] * dy, signz[i] * dz);
0305         co[i] = m_cellVec[cellIndex].getPosition(lcoord);
0306       }
0307     } else {
0308       xy = m_topology.dddConstants().locateCell(
0309           id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, false, true, debugLocate);
0310       float zz = m_topology.dddConstants().waferZ(id.iLay, true);
0311       float dx = k_fac2 * m_cellVec[cellIndex].param()[FlatHexagon::k_r];
0312       float dy = k_fac1 * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
0313       float dz = -id.zSide * m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
0314       static const int signx[] = {1, -1, -2, -1, 1, 2, 1, -1, -2, -1, 1, 2};
0315       static const int signy[] = {1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0};
0316       static const int signz[] = {-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1};
0317       for (unsigned int i = 0; i < ncorner; ++i) {
0318         auto xyglob = m_topology.dddConstants().localToGlobal8(
0319             id.iLay, id.iSec1, id.iSec2, (xy.first + signx[i] * dx), (xy.second + signy[i] * dy), true, false);
0320         double xx = id.zSide * xyglob.first;
0321         co[i] = GlobalPoint(xx, xyglob.second, id.zSide * (zz + signz[i] * dz));
0322       }
0323     }
0324   }
0325   return co;
0326 }
0327 
0328 HGCalGeometry::CornersVec HGCalGeometry::get8Corners(const DetId& detid) const {
0329   unsigned int ncorner = FlatTrd::ncorner_;
0330   HGCalGeometry::CornersVec co(ncorner, GlobalPoint(0, 0, 0));
0331   unsigned int cellIndex = indexFor(detid);
0332   HGCalTopology::DecodedDetId id = m_topology.decode(detid);
0333   if (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc) {
0334     GlobalPoint v = getPosition(detid, false);
0335     int type = std::min(id.iType, 1);
0336     std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(type, id.iSec1);
0337     float dr = k_half * (rr.second - rr.first);
0338     float dfi = m_cellVec2[cellIndex].param()[FlatTrd::k_Cell];
0339     float dz = id.zSide * m_cellVec2[cellIndex].param()[FlatTrd::k_dZ];
0340     float r = v.perp();
0341     float fi = v.phi();
0342     static const int signr[] = {1, 1, -1, -1, 1, 1, -1, -1};
0343     static const int signf[] = {-1, 1, 1, -1, -1, 1, 1, -1};
0344     static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
0345     for (unsigned int i = 0; i < ncorner; ++i) {
0346       co[i] = GlobalPoint((r + signr[i] * dr) * cos(fi + signf[i] * dfi),
0347                           (r + signr[i] * dr) * sin(fi + signf[i] * dfi),
0348                           (v.z() + signz[i] * dz));
0349     }
0350   } else if (cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) {
0351     std::pair<float, float> xy;
0352     float dx(0);
0353     static const int signx[] = {-1, -1, 1, 1, -1, -1, 1, 1};
0354     static const int signy[] = {-1, 1, 1, -1, -1, 1, 1, -1};
0355     static const int signz[] = {-1, -1, -1, -1, 1, 1, 1, 1};
0356     if (m_topology.waferHexagon6()) {
0357       xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
0358       dx = m_cellVec[cellIndex].param()[FlatHexagon::k_r];
0359       float dz = m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
0360       for (unsigned int i = 0; i < ncorner; ++i) {
0361         const HepGeom::Point3D<float> lcoord(xy.first + signx[i] * dx, xy.second + signy[i] * dx, signz[i] * dz);
0362         co[i] = m_cellVec[cellIndex].getPosition(lcoord);
0363       }
0364     } else {
0365       xy = m_topology.dddConstants().locateCell(
0366           id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, false, true, debugLocate);
0367       dx = k_fac2 * m_cellVec[cellIndex].param()[FlatHexagon::k_r];
0368       float dy = k_fac1 * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
0369       float dz = -id.zSide * m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
0370       float zz = m_topology.dddConstants().waferZ(id.iLay, true);
0371       for (unsigned int i = 0; i < ncorner; ++i) {
0372         auto xyglob = m_topology.dddConstants().localToGlobal8(
0373             id.iLay, id.iSec1, id.iSec2, (xy.first + signx[i] * dx), (xy.second + signy[i] * dy), true, false);
0374         double xx = id.zSide * xyglob.first;
0375         co[i] = GlobalPoint(xx, xyglob.second, id.zSide * (zz + signz[i] * dz));
0376       }
0377     }
0378   }
0379   return co;
0380 }
0381 
0382 HGCalGeometry::CornersVec HGCalGeometry::getNewCorners(const DetId& detid, bool debug) const {
0383   unsigned int ncorner = (m_det == DetId::HGCalHSc) ? 5 : 7;
0384   HGCalGeometry::CornersVec co(ncorner, GlobalPoint(0, 0, 0));
0385   unsigned int cellIndex = indexFor(detid);
0386   HGCalTopology::DecodedDetId id = m_topology.decode(detid);
0387   if (debug)
0388     edm::LogVerbatim("HGCalGeom") << "NewCorners for Layer " << id.iLay << " Wafer " << id.iSec1 << ":" << id.iSec2
0389                                   << " Cell " << id.iCell1 << ":" << id.iCell2;
0390   if (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc) {
0391     GlobalPoint v = getPosition(detid, false);
0392     int type = std::min(id.iType, 1);
0393     std::pair<double, double> rr = m_topology.dddConstants().cellSizeTrap(type, id.iSec1);
0394     float dr = k_half * (rr.second - rr.first);
0395     float dfi = m_cellVec2[cellIndex].param()[FlatTrd::k_Cell];
0396     float dz = -id.zSide * m_cellVec2[cellIndex].param()[FlatTrd::k_dZ];
0397     float r = v.perp();
0398     float fi = v.phi();
0399     static const int signr[] = {1, 1, -1, -1};
0400     static const int signf[] = {-1, 1, 1, -1};
0401     for (unsigned int i = 0; i < ncorner - 1; ++i) {
0402       co[i] = GlobalPoint(
0403           (r + signr[i] * dr) * cos(fi + signf[i] * dfi), (r + signr[i] * dr) * sin(fi + signf[i] * dfi), (v.z() + dz));
0404     }
0405     // Used to pass downstream the thickness of this cell
0406     co[ncorner - 1] = GlobalPoint(0, 0, -2 * dz);
0407   } else if (cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) {
0408     std::pair<float, float> xy;
0409     float dx = k_fac2 * m_cellVec[cellIndex].param()[FlatHexagon::k_r];
0410     float dy = k_fac1 * m_cellVec[cellIndex].param()[FlatHexagon::k_R];
0411     float dz = -id.zSide * m_cellVec[cellIndex].param()[FlatHexagon::k_dZ];
0412     static const int signx[] = {1, -1, -2, -1, 1, 2};
0413     static const int signy[] = {1, 1, 0, -1, -1, 0};
0414 #ifdef EDM_ML_DEBUG
0415     if (debug)
0416       edm::LogVerbatim("HGCalGeom") << "kfac " << k_fac1 << ":" << k_fac2 << " dx:dy:dz " << dx << ":" << dy << ":"
0417                                     << dz;
0418 #endif
0419     if (m_topology.waferHexagon6()) {
0420       xy = m_topology.dddConstants().locateCellHex(id.iCell1, id.iSec1, true);
0421       for (unsigned int i = 0; i < ncorner - 1; ++i) {
0422         const HepGeom::Point3D<float> lcoord(xy.first + signx[i] * dx, xy.second + signy[i] * dy, dz);
0423         co[i] = m_cellVec[cellIndex].getPosition(lcoord);
0424       }
0425     } else {
0426       xy = m_topology.dddConstants().locateCell(
0427           id.iLay, id.iSec1, id.iSec2, id.iCell1, id.iCell2, true, false, true, debug);
0428       float zz = m_topology.dddConstants().waferZ(id.iLay, true);
0429       for (unsigned int i = 0; i < ncorner; ++i) {
0430         double xloc = xy.first + signx[i] * dx;
0431         double yloc = xy.second + signy[i] * dy;
0432 #ifdef EDM_ML_DEBUG
0433         if (debug)
0434           edm::LogVerbatim("HGCalGeom") << "Corner " << i << " x " << xy.first << ":" << xloc << " y " << xy.second
0435                                         << ":" << yloc << " z " << zz << ":" << id.zSide * (zz + dz);
0436 #endif
0437         auto xyglob = m_topology.dddConstants().localToGlobal8(id.iLay, id.iSec1, id.iSec2, xloc, yloc, true, debug);
0438         double xx = id.zSide * xyglob.first;
0439         co[i] = GlobalPoint(xx, xyglob.second, id.zSide * (zz + dz));
0440       }
0441     }
0442     // Used to pass downstream the thickness of this cell
0443     co[ncorner - 1] = GlobalPoint(0, 0, -2 * dz);
0444   }
0445   return co;
0446 }
0447 
0448 DetId HGCalGeometry::neighborZ(const DetId& idin, const GlobalVector& momentum) const {
0449   DetId idnew;
0450   HGCalTopology::DecodedDetId id = m_topology.decode(idin);
0451   int lay = ((momentum.z() * id.zSide > 0) ? (id.iLay + 1) : (id.iLay - 1));
0452 #ifdef EDM_ML_DEBUG
0453   edm::LogVerbatim("HGCalGeom") << "neighborz1:: ID " << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":"
0454                                 << id.iCell1 << ":" << id.iCell2 << " New Layer " << lay << " Range "
0455                                 << m_topology.dddConstants().firstLayer() << ":"
0456                                 << m_topology.dddConstants().lastLayer(true) << " pz " << momentum.z();
0457 #endif
0458   if ((lay >= m_topology.dddConstants().firstLayer()) && (lay <= m_topology.dddConstants().lastLayer(true)) &&
0459       (momentum.z() != 0.0)) {
0460     GlobalPoint v = getPosition(idin, false);
0461     double z = id.zSide * m_topology.dddConstants().waferZ(lay, true);
0462     double grad = (z - v.z()) / momentum.z();
0463     GlobalPoint p(v.x() + grad * momentum.x(), v.y() + grad * momentum.y(), z);
0464     double r = p.perp();
0465     auto rlimit = topology().dddConstants().rangeR(z, true);
0466     if (r >= rlimit.first && r <= rlimit.second)
0467       idnew = getClosestCell(p);
0468 #ifdef EDM_ML_DEBUG
0469     edm::LogVerbatim("HGCalGeom") << "neighborz1:: Position " << v << " New Z " << z << ":" << grad << " new position "
0470                                   << p << " r-limit " << rlimit.first << ":" << rlimit.second;
0471 #endif
0472   }
0473   return idnew;
0474 }
0475 
0476 DetId HGCalGeometry::neighborZ(const DetId& idin,
0477                                const MagneticField* bField,
0478                                int charge,
0479                                const GlobalVector& momentum) const {
0480   DetId idnew;
0481   HGCalTopology::DecodedDetId id = m_topology.decode(idin);
0482   int lay = ((momentum.z() * id.zSide > 0) ? (id.iLay + 1) : (id.iLay - 1));
0483 #ifdef EDM_ML_DEBUG
0484   edm::LogVerbatim("HGCalGeom") << "neighborz2:: ID " << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":"
0485                                 << id.iCell1 << ":" << id.iCell2 << " New Layer " << lay << " Range "
0486                                 << m_topology.dddConstants().firstLayer() << ":"
0487                                 << m_topology.dddConstants().lastLayer(true) << " pz " << momentum.z();
0488 #endif
0489   if ((lay >= m_topology.dddConstants().firstLayer()) && (lay <= m_topology.dddConstants().lastLayer(true)) &&
0490       (momentum.z() != 0.0)) {
0491     GlobalPoint v = getPosition(idin, false);
0492     double z = id.zSide * m_topology.dddConstants().waferZ(lay, true);
0493     FreeTrajectoryState fts(v, momentum, charge, bField);
0494     Plane::PlanePointer nPlane = Plane::build(Plane::PositionType(0, 0, z), Plane::RotationType());
0495     AnalyticalPropagator myAP(bField, alongMomentum, 2 * M_PI);
0496     TrajectoryStateOnSurface tsos = myAP.propagate(fts, *nPlane);
0497     GlobalPoint p;
0498     auto rlimit = topology().dddConstants().rangeR(z, true);
0499     if (tsos.isValid()) {
0500       p = tsos.globalPosition();
0501       double r = p.perp();
0502       if (r >= rlimit.first && r <= rlimit.second)
0503         idnew = getClosestCell(p);
0504     }
0505 #ifdef EDM_ML_DEBUG
0506     edm::LogVerbatim("HGCalGeom") << "neighborz2:: Position " << v << " New Z " << z << ":" << charge << ":"
0507                                   << tsos.isValid() << " new position " << p << " r limits " << rlimit.first << ":"
0508                                   << rlimit.second;
0509 #endif
0510   }
0511   return idnew;
0512 }
0513 
0514 DetId HGCalGeometry::getClosestCell(const GlobalPoint& r) const {
0515   unsigned int cellIndex = getClosestCellIndex(r);
0516   if ((cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) ||
0517       (cellIndex < m_cellVec2.size() && m_det == DetId::HGCalHSc)) {
0518     HGCalTopology::DecodedDetId id = m_topology.decode(m_validGeomIds[cellIndex]);
0519     if (id.det == 0)
0520       id.det = static_cast<int>(m_topology.detector());
0521     HepGeom::Point3D<float> local;
0522     if (r.z() > 0) {
0523       local = HepGeom::Point3D<float>(r.x(), r.y(), 0);
0524       id.zSide = 1;
0525     } else {
0526       local = HepGeom::Point3D<float>(-r.x(), r.y(), 0);
0527       id.zSide = -1;
0528     }
0529     if (m_topology.waferHexagon6()) {
0530       const auto& kxy = m_topology.dddConstants().assignCell(local.x(), local.y(), id.iLay, id.iType, true);
0531       id.iCell1 = kxy.second;
0532       id.iSec1 = kxy.first;
0533       id.iType = m_topology.dddConstants().waferTypeT(kxy.first);
0534       if (id.iType != 1)
0535         id.iType = -1;
0536     } else if (m_topology.tileTrapezoid()) {
0537       id.iLay = m_topology.dddConstants().getLayer(r.z(), true);
0538       const auto& kxy = m_topology.dddConstants().assignCellTrap(r.x(), r.y(), r.z(), id.iLay, true);
0539       id.iSec1 = kxy[0];
0540       id.iCell1 = kxy[1];
0541       id.iType = kxy[2];
0542     } else {
0543       id.iLay = m_topology.dddConstants().getLayer(r.z(), true);
0544 #ifdef EDM_ML_DEBUG
0545       edm::LogVerbatim("HGCalGeom") << "ZZ " << r.z() << " Layer " << id.iLay << " Global " << r << "  Local " << local;
0546 #endif
0547       const auto& kxy = m_topology.dddConstants().assignCellHex(local.x(), local.y(), id.iLay, false, true);
0548       id.iSec1 = kxy[0];
0549       id.iSec2 = kxy[1];
0550       id.iType = kxy[2];
0551       id.iCell1 = kxy[3];
0552       id.iCell2 = kxy[4];
0553     }
0554 #ifdef EDM_ML_DEBUG
0555     edm::LogVerbatim("HGCalGeom") << "getClosestCell: local " << local << " Id " << id.det << ":" << id.zSide << ":"
0556                                   << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":" << id.iType << ":"
0557                                   << id.iCell1 << ":" << id.iCell2;
0558 #endif
0559 
0560     //check if returned cell is valid
0561     if (id.iCell1 >= 0)
0562       return m_topology.encode(id);
0563   }
0564 
0565   //if not valid or out of bounds return a null DetId
0566   return DetId();
0567 }
0568 
0569 DetId HGCalGeometry::getClosestCellHex(const GlobalPoint& r, bool extend) const {
0570   unsigned int cellIndex = getClosestCellIndex(r);
0571   if (cellIndex < m_cellVec.size() && m_det != DetId::HGCalHSc) {
0572     HGCalTopology::DecodedDetId id = m_topology.decode(m_validGeomIds[cellIndex]);
0573     if (id.det == 0)
0574       id.det = static_cast<int>(m_topology.detector());
0575     HepGeom::Point3D<float> local;
0576     if (r.z() > 0) {
0577       local = HepGeom::Point3D<float>(r.x(), r.y(), 0);
0578       id.zSide = 1;
0579     } else {
0580       local = HepGeom::Point3D<float>(-r.x(), r.y(), 0);
0581       id.zSide = -1;
0582     }
0583     if (m_topology.waferHexagon8()) {
0584       id.iLay = m_topology.dddConstants().getLayer(r.z(), true);
0585 #ifdef EDM_ML_DEBUG
0586       edm::LogVerbatim("HGCalGeom") << "ZZ " << r.z() << " Layer " << id.iLay << " Global " << r << "  Local " << local;
0587 #endif
0588       const auto& kxy = m_topology.dddConstants().assignCellHex(local.x(), local.y(), id.iLay, extend, true);
0589       id.iSec1 = kxy[0];
0590       id.iSec2 = kxy[1];
0591       id.iType = kxy[2];
0592       id.iCell1 = kxy[3];
0593       id.iCell2 = kxy[4];
0594     }
0595 #ifdef EDM_ML_DEBUG
0596     edm::LogVerbatim("HGCalGeom") << "getClosestCell: local " << local << " Id " << id.det << ":" << id.zSide << ":"
0597                                   << id.iLay << ":" << id.iSec1 << ":" << id.iSec2 << ":" << id.iType << ":"
0598                                   << id.iCell1 << ":" << id.iCell2;
0599 #endif
0600 
0601     //check if returned cell is valid
0602     if (id.iCell1 >= 0)
0603       return m_topology.encode(id);
0604   }
0605 
0606   //if not valid or out of bounds return a null DetId
0607   return DetId();
0608 }
0609 
0610 HGCalGeometry::DetIdSet HGCalGeometry::getCells(const GlobalPoint& r, double dR) const {
0611   HGCalGeometry::DetIdSet dss;
0612   return dss;
0613 }
0614 
0615 std::string HGCalGeometry::cellElement() const {
0616   if (m_subdet == HGCEE || m_det == DetId::HGCalEE)
0617     return "HGCalEE";
0618   else if (m_subdet == HGCHEF || m_det == DetId::HGCalHSi)
0619     return "HGCalHEFront";
0620   else if (m_subdet == HGCHEB || m_det == DetId::HGCalHSc)
0621     return "HGCalHEBack";
0622   else
0623     return "Unknown";
0624 }
0625 
0626 unsigned int HGCalGeometry::indexFor(const DetId& detId) const {
0627   unsigned int cellIndex = ((m_det == DetId::HGCalHSc) ? m_cellVec2.size() : m_cellVec.size());
0628   if (detId != DetId()) {
0629     DetId geomId = getGeometryDetId(detId);
0630     cellIndex = m_topology.detId2denseGeomId(geomId);
0631 #ifdef EDM_ML_DEBUG
0632     edm::LogVerbatim("HGCalGeom") << "indexFor " << std::hex << detId.rawId() << ":" << geomId.rawId() << std::dec
0633                                   << " index " << cellIndex;
0634 #endif
0635   }
0636   return cellIndex;
0637 }
0638 
0639 unsigned int HGCalGeometry::sizeForDenseIndex() const { return m_topology.totalGeomModules(); }
0640 
0641 const CaloCellGeometry* HGCalGeometry::getGeometryRawPtr(uint32_t index) const {
0642   // Modify the RawPtr class
0643   if (m_det == DetId::HGCalHSc) {
0644     if (m_cellVec2.size() < index)
0645       return nullptr;
0646     const CaloCellGeometry* cell(&m_cellVec2[index]);
0647     return (nullptr == cell->param() ? nullptr : cell);
0648   } else {
0649     if (m_cellVec2.size() < index)
0650       return nullptr;
0651     const CaloCellGeometry* cell(&m_cellVec[index]);
0652     return (nullptr == cell->param() ? nullptr : cell);
0653   }
0654 }
0655 
0656 std::shared_ptr<const CaloCellGeometry> HGCalGeometry::cellGeomPtr(uint32_t index) const {
0657   if ((index >= m_cellVec.size() && m_det != DetId::HGCalHSc) ||
0658       (index >= m_cellVec2.size() && m_det == DetId::HGCalHSc) || (m_validGeomIds[index].rawId() == 0))
0659     return nullptr;
0660   static const auto do_not_delete = [](const void*) {};
0661   if (m_det == DetId::HGCalHSc) {
0662     auto cell = std::shared_ptr<const CaloCellGeometry>(&m_cellVec2[index], do_not_delete);
0663     if (nullptr == cell->param())
0664       return nullptr;
0665     return cell;
0666   } else {
0667     auto cell = std::shared_ptr<const CaloCellGeometry>(&m_cellVec[index], do_not_delete);
0668     if (nullptr == cell->param())
0669       return nullptr;
0670     return cell;
0671   }
0672 }
0673 
0674 std::shared_ptr<const CaloCellGeometry> HGCalGeometry::cellGeomPtr(uint32_t index, const GlobalPoint& pos) const {
0675   if ((index >= m_cellVec.size() && m_det != DetId::HGCalHSc) ||
0676       (index >= m_cellVec2.size() && m_det == DetId::HGCalHSc) || (m_validGeomIds[index].rawId() == 0))
0677     return nullptr;
0678   if (pos == GlobalPoint())
0679     return cellGeomPtr(index);
0680   if (m_det == DetId::HGCalHSc) {
0681     auto cell = std::make_shared<FlatTrd>(m_cellVec2[index]);
0682     cell->setPosition(pos);
0683 #ifdef EDM_ML_DEBUG
0684     edm::LogVerbatim("HGCalGeom") << "cellGeomPtr " << index << ":" << cell;
0685 #endif
0686     if (nullptr == cell->param())
0687       return nullptr;
0688     return cell;
0689   } else {
0690     auto cell = std::make_shared<FlatHexagon>(m_cellVec[index]);
0691     cell->setPosition(pos);
0692 #ifdef EDM_ML_DEBUG
0693     edm::LogVerbatim("HGCalGeom") << "cellGeomPtr " << index << ":" << cell;
0694 #endif
0695     if (nullptr == cell->param())
0696       return nullptr;
0697     return cell;
0698   }
0699 }
0700 
0701 void HGCalGeometry::addValidID(const DetId& id) {
0702   edm::LogError("HGCalGeom") << "HGCalGeometry::addValidID is not implemented";
0703 }
0704 
0705 unsigned int HGCalGeometry::getClosestCellIndex(const GlobalPoint& r) const {
0706   return ((m_det == DetId::HGCalHSc) ? getClosestCellIndex(r, m_cellVec2) : getClosestCellIndex(r, m_cellVec));
0707 }
0708 
0709 template <class T>
0710 unsigned int HGCalGeometry::getClosestCellIndex(const GlobalPoint& r, const std::vector<T>& vec) const {
0711   float phip = r.phi();
0712   float zp = r.z();
0713   float dzmin(9999), dphimin(9999), dphi10(0.175);
0714   unsigned int cellIndex = vec.size();
0715   for (unsigned int k = 0; k < vec.size(); ++k) {
0716     float dphi = phip - vec[k].phiPos();
0717     while (dphi > M_PI)
0718       dphi -= 2 * M_PI;
0719     while (dphi <= -M_PI)
0720       dphi += 2 * M_PI;
0721     if (std::abs(dphi) < dphi10) {
0722       float dz = std::abs(zp - vec[k].getPosition().z());
0723       if (dz < (dzmin + 0.001)) {
0724         dzmin = dz;
0725         if (std::abs(dphi) < (dphimin + 0.01)) {
0726           cellIndex = k;
0727           dphimin = std::abs(dphi);
0728         } else {
0729           if (cellIndex >= vec.size())
0730             cellIndex = k;
0731         }
0732       }
0733     }
0734   }
0735 #ifdef EDM_ML_DEBUG
0736   edm::LogVerbatim("HGCalGeom") << "getClosestCellIndex::Input " << zp << ":" << phip << " Index " << cellIndex;
0737   if (cellIndex < vec.size())
0738     edm::LogVerbatim("HGCalGeom") << " Cell z " << vec[cellIndex].getPosition().z() << ":" << dzmin << " phi "
0739                                   << vec[cellIndex].phiPos() << ":" << dphimin;
0740 #endif
0741   return cellIndex;
0742 }
0743 
0744 // FIXME: Change sorting algorithm if needed
0745 namespace {
0746   struct rawIdSort {
0747     bool operator()(const DetId& a, const DetId& b) { return (a.rawId() < b.rawId()); }
0748   };
0749 }  // namespace
0750 
0751 void HGCalGeometry::sortDetIds(void) {
0752   m_validIds.shrink_to_fit();
0753   std::sort(m_validIds.begin(), m_validIds.end(), rawIdSort());
0754 }
0755 
0756 void HGCalGeometry::getSummary(CaloSubdetectorGeometry::TrVec& trVector,
0757                                CaloSubdetectorGeometry::IVec& iVector,
0758                                CaloSubdetectorGeometry::DimVec& dimVector,
0759                                CaloSubdetectorGeometry::IVec& dinsVector) const {
0760   unsigned int numberOfCells = m_topology.totalGeomModules();  // total Geom Modules both sides
0761   unsigned int numberOfShapes = k_NumberOfShapes;
0762   unsigned int numberOfParametersPerShape = ((m_det == DetId::HGCalHSc) ? (unsigned int)(k_NumberOfParametersPerTrd)
0763                                                                         : (unsigned int)(k_NumberOfParametersPerHex));
0764 
0765   trVector.reserve(numberOfCells * numberOfTransformParms());
0766   iVector.reserve(numberOfCells);
0767   dimVector.reserve(numberOfShapes * numberOfParametersPerShape);
0768   dinsVector.reserve(numberOfCells);
0769 
0770   for (unsigned itr = 0; itr < m_topology.dddConstants().getTrFormN(); ++itr) {
0771     HGCalParameters::hgtrform mytr = m_topology.dddConstants().getTrForm(itr);
0772     int layer = mytr.lay;
0773 
0774     if (m_topology.waferHexagon6()) {
0775       for (int wafer = 0; wafer < m_topology.dddConstants().sectors(); ++wafer) {
0776         if (m_topology.dddConstants().waferInLayer(wafer, layer, true)) {
0777           HGCalParameters::hgtrap vol = m_topology.dddConstants().getModule(wafer, true, true);
0778           ParmVec params(numberOfParametersPerShape, 0);
0779           params[FlatHexagon::k_dZ] = vol.dz;
0780           params[FlatHexagon::k_r] = vol.cellSize;
0781           params[FlatHexagon::k_R] = twoBysqrt3_ * params[FlatHexagon::k_r];
0782           dimVector.insert(dimVector.end(), params.begin(), params.end());
0783         }
0784       }
0785     } else if (m_topology.tileTrapezoid()) {
0786       int indx = m_topology.dddConstants().layerIndex(layer, true);
0787       for (int md = m_topology.dddConstants().getParameter()->firstModule_[indx];
0788            md <= m_topology.dddConstants().getParameter()->lastModule_[indx];
0789            ++md) {
0790         HGCalParameters::hgtrap vol = m_topology.dddConstants().getModule(md, true, true);
0791         ParmVec params(numberOfParametersPerShape, 0);
0792         params[FlatTrd::k_dZ] = vol.dz;
0793         params[FlatTrd::k_Theta] = params[FlatTrd::k_Phi] = 0;
0794         params[FlatTrd::k_dY1] = params[FlatTrd::k_dY2] = vol.h;
0795         params[FlatTrd::k_dX1] = params[FlatTrd::k_dX3] = vol.bl;
0796         params[FlatTrd::k_dX2] = params[FlatTrd::k_dX4] = vol.tl;
0797         params[FlatTrd::k_Alp1] = params[FlatTrd::k_Alp2] = vol.alpha;
0798         params[FlatTrd::k_Cell] = vol.cellSize;
0799         dimVector.insert(dimVector.end(), params.begin(), params.end());
0800       }
0801     } else {
0802       for (int wafer = 0; wafer < m_topology.dddConstants().sectors(); ++wafer) {
0803         if (m_topology.dddConstants().waferInLayer(wafer, layer, true)) {
0804           HGCalParameters::hgtrap vol = m_topology.dddConstants().getModule(wafer, true, true);
0805           ParmVec params(numberOfParametersPerShape, 0);
0806           params[FlatHexagon::k_dZ] = vol.dz;
0807           params[FlatHexagon::k_r] = vol.cellSize;
0808           params[FlatHexagon::k_R] = twoBysqrt3_ * params[FlatHexagon::k_r];
0809           dimVector.insert(dimVector.end(), params.begin(), params.end());
0810         }
0811       }
0812     }
0813   }
0814 
0815   for (unsigned int i(0); i < numberOfCells; ++i) {
0816     DetId detId = m_validGeomIds[i];
0817     int layer(0);
0818     if (m_topology.waferHexagon6()) {
0819       layer = HGCalDetId(detId).layer();
0820     } else if (m_topology.tileTrapezoid()) {
0821       layer = HGCScintillatorDetId(detId).layer();
0822     } else if (m_topology.isHFNose()) {
0823       layer = HFNoseDetId(detId).layer();
0824     } else {
0825       layer = HGCSiliconDetId(detId).layer();
0826     }
0827     dinsVector.emplace_back(m_topology.detId2denseGeomId(detId));
0828     iVector.emplace_back(layer);
0829 
0830     Tr3D tr;
0831     auto ptr = cellGeomPtr(i);
0832     if (nullptr != ptr) {
0833       ptr->getTransform(tr, (Pt3DVec*)nullptr);
0834 
0835       if (Tr3D() == tr) {  // there is no rotation
0836         const GlobalPoint& gp(ptr->getPosition());
0837         tr = HepGeom::Translate3D(gp.x(), gp.y(), gp.z());
0838       }
0839 
0840       const CLHEP::Hep3Vector tt(tr.getTranslation());
0841       trVector.emplace_back(tt.x());
0842       trVector.emplace_back(tt.y());
0843       trVector.emplace_back(tt.z());
0844       if (6 == numberOfTransformParms()) {
0845         const CLHEP::HepRotation rr(tr.getRotation());
0846         const ROOT::Math::Transform3D rtr(
0847             rr.xx(), rr.xy(), rr.xz(), tt.x(), rr.yx(), rr.yy(), rr.yz(), tt.y(), rr.zx(), rr.zy(), rr.zz(), tt.z());
0848         ROOT::Math::EulerAngles ea;
0849         rtr.GetRotation(ea);
0850         trVector.emplace_back(ea.Phi());
0851         trVector.emplace_back(ea.Theta());
0852         trVector.emplace_back(ea.Psi());
0853       }
0854     }
0855   }
0856 }
0857 
0858 DetId HGCalGeometry::getGeometryDetId(DetId detId) const {
0859   DetId geomId;
0860   if (m_topology.waferHexagon6()) {
0861     geomId = static_cast<DetId>(HGCalDetId(detId).geometryCell());
0862   } else if (m_topology.tileTrapezoid()) {
0863     geomId = static_cast<DetId>(HGCScintillatorDetId(detId).geometryCell());
0864   } else if (m_topology.isHFNose()) {
0865     geomId = static_cast<DetId>(HFNoseDetId(detId).geometryCell());
0866   } else {
0867     geomId = static_cast<DetId>(HGCSiliconDetId(detId).geometryCell());
0868   }
0869   return geomId;
0870 }
0871 
0872 #include "FWCore/Utilities/interface/typelookup.h"
0873 
0874 TYPELOOKUP_DATA_REG(HGCalGeometry);