Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-10-25 23:57:06

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), m_ownsTopology(true), m_cellVec(k_NumberOfCellsForCorners) {}
0014 
0015 CastorGeometry::CastorGeometry(const CastorTopology* topology)
0016     : theTopology(topology), m_ownsTopology(false), m_cellVec(k_NumberOfCellsForCorners) {}
0017 
0018 CastorGeometry::~CastorGeometry() {
0019   if (m_ownsTopology)
0020     delete theTopology;
0021 }
0022 
0023 DetId CastorGeometry::getClosestCell(const GlobalPoint& r) const {
0024   DetId returnId(0);
0025   const std::vector<DetId>& detIds(getValidDetIds());
0026   for (auto detId : detIds) {
0027     auto cell = getGeometry(detId);
0028     if (nullptr != cell && cell->inside(r)) {
0029       returnId = detId;
0030       break;
0031     }
0032   }
0033   return returnId;
0034 }
0035 
0036 unsigned int CastorGeometry::alignmentTransformIndexLocal(const DetId& id) {
0037   const CaloGenericDetId gid(id);
0038 
0039   assert(gid.isCastor());
0040 
0041   return 0;
0042 }
0043 
0044 unsigned int CastorGeometry::alignmentTransformIndexGlobal(const DetId& /*id*/) {
0045   return (unsigned int)DetId::Calo - 1;
0046 }
0047 
0048 void CastorGeometry::localCorners(Pt3DVec& lc, const CCGFloat* pv, unsigned int /*i*/, Pt3D& ref) {
0049   IdealCastorTrapezoid::localCorners(lc, pv, ref);
0050 }
0051 
0052 void CastorGeometry::newCell(const GlobalPoint& f1,
0053                              const GlobalPoint& /*f2*/,
0054                              const GlobalPoint& /*f3*/,
0055                              const CCGFloat* parm,
0056                              const DetId& detId) {
0057   const CaloGenericDetId cgid(detId);
0058 
0059   assert(cgid.isCastor());
0060 
0061   const unsigned int di(cgid.denseIndex());
0062 
0063   m_cellVec[di] = IdealCastorTrapezoid(f1, cornersMgr(), parm);
0064   addValidID(detId);
0065 }
0066 
0067 CaloCellGeometryPtr CastorGeometry::getGeometryRawPtr(uint32_t index) const {
0068   // Modify the RawPtr class
0069   return CaloCellGeometryPtr(m_cellVec.size() <= index || nullptr == m_cellVec[index].param() ? nullptr
0070                                                                                               : &m_cellVec[index]);
0071 }