File indexing completed on 2023-03-17 13:02:58
0001 #include "Geometry/CaloGeometry/interface/CaloGenericDetId.h"
0002 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
0003 #include "Geometry/ForwardGeometry/interface/CastorGeometry.h"
0004 #include "Geometry/ForwardGeometry/interface/IdealCastorTrapezoid.h"
0005 #include "CastorGeometryData.h"
0006 #include <algorithm>
0007
0008 typedef CaloCellGeometry::CCGFloat CCGFloat;
0009 typedef CaloCellGeometry::Pt3D Pt3D;
0010 typedef CaloCellGeometry::Pt3DVec Pt3DVec;
0011
0012 CastorGeometry::CastorGeometry()
0013 : theTopology(new CastorTopology),
0014 lastReqDet_(DetId::Detector(0)),
0015 lastReqSubdet_(0),
0016 m_ownsTopology(true),
0017 m_cellVec(k_NumberOfCellsForCorners) {}
0018
0019 CastorGeometry::CastorGeometry(const CastorTopology* topology)
0020 : theTopology(topology),
0021 lastReqDet_(DetId::Detector(0)),
0022 lastReqSubdet_(0),
0023 m_ownsTopology(false),
0024 m_cellVec(k_NumberOfCellsForCorners) {}
0025
0026 CastorGeometry::~CastorGeometry() {
0027 if (m_ownsTopology)
0028 delete theTopology;
0029 }
0030
0031 DetId CastorGeometry::getClosestCell(const GlobalPoint& r) const {
0032 DetId returnId(0);
0033 const std::vector<DetId>& detIds(getValidDetIds());
0034 for (auto detId : detIds) {
0035 auto cell = getGeometry(detId);
0036 if (nullptr != cell && cell->inside(r)) {
0037 returnId = detId;
0038 break;
0039 }
0040 }
0041 return returnId;
0042 }
0043
0044 unsigned int CastorGeometry::alignmentTransformIndexLocal(const DetId& id) {
0045 const CaloGenericDetId gid(id);
0046
0047 assert(gid.isCastor());
0048
0049 return 0;
0050 }
0051
0052 unsigned int CastorGeometry::alignmentTransformIndexGlobal(const DetId& ) {
0053 return (unsigned int)DetId::Calo - 1;
0054 }
0055
0056 void CastorGeometry::localCorners(Pt3DVec& lc, const CCGFloat* pv, unsigned int , Pt3D& ref) {
0057 IdealCastorTrapezoid::localCorners(lc, pv, ref);
0058 }
0059
0060 void CastorGeometry::newCell(const GlobalPoint& f1,
0061 const GlobalPoint& ,
0062 const GlobalPoint& ,
0063 const CCGFloat* parm,
0064 const DetId& detId) {
0065 const CaloGenericDetId cgid(detId);
0066
0067 assert(cgid.isCastor());
0068
0069 const unsigned int di(cgid.denseIndex());
0070
0071 m_cellVec[di] = IdealCastorTrapezoid(f1, cornersMgr(), parm);
0072 addValidID(detId);
0073 }
0074
0075 const CaloCellGeometry* CastorGeometry::getGeometryRawPtr(uint32_t index) const {
0076
0077 const CaloCellGeometry* cell(&m_cellVec[index]);
0078 return (m_cellVec.size() < index || nullptr == cell->param() ? nullptr : cell);
0079 }