Go to the documentation of this file.00001 #include "Geometry/CaloGeometry/interface/CaloGenericDetId.h"
00002 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00003 #include "Geometry/ForwardGeometry/interface/ZdcGeometry.h"
00004 #include "Geometry/ForwardGeometry/interface/IdealZDCTrapezoid.h"
00005 #include "ZdcHardcodeGeometryData.h"
00006 #include <algorithm>
00007
00008 ZdcGeometry::ZdcGeometry() :
00009 theTopology( new ZdcTopology ),
00010 lastReqDet_(DetId::Detector(0)),
00011 lastReqSubdet_(0),
00012 m_ownsTopology ( true )
00013 {
00014 }
00015
00016 ZdcGeometry::ZdcGeometry( const ZdcTopology* topology) :
00017 theTopology(topology),
00018 lastReqDet_(DetId::Detector(0)),
00019 lastReqSubdet_(0),
00020 m_ownsTopology ( false )
00021 {
00022 }
00023
00024 ZdcGeometry::~ZdcGeometry()
00025 {
00026 if( m_ownsTopology ) delete theTopology ;
00027 }
00028
00029 const std::vector<DetId>&
00030 ZdcGeometry::getValidDetIds( DetId::Detector det,
00031 int subdet ) const
00032 {
00033 const std::vector<DetId>& baseIds ( CaloSubdetectorGeometry::getValidDetIds() ) ;
00034 if( det == DetId::Detector( 0 ) &&
00035 subdet == 0 )
00036 {
00037 return baseIds ;
00038 }
00039
00040 if( lastReqDet_ != det ||
00041 lastReqSubdet_ != subdet )
00042 {
00043 lastReqDet_ = det ;
00044 lastReqSubdet_ = subdet ;
00045 m_validIds.clear();
00046 m_validIds.reserve( baseIds.size() ) ;
00047 }
00048
00049 if( m_validIds.empty() )
00050 {
00051 for( unsigned int i ( 0 ) ; i != baseIds.size() ; ++i )
00052 {
00053 const DetId id ( baseIds[i] );
00054 if( id.det() == det &&
00055 id.subdetId() == subdet )
00056 {
00057 m_validIds.push_back( id ) ;
00058 }
00059 }
00060 std::sort(m_validIds.begin(),m_validIds.end());
00061 }
00062 return m_validIds;
00063 }
00064
00065 DetId ZdcGeometry::getClosestCell(const GlobalPoint& r) const
00066 {
00067 DetId returnId ( 0 ) ;
00068 const std::vector<DetId>& detIds ( getValidDetIds() ) ;
00069 for( std::vector<DetId>::const_iterator it ( detIds.begin() ) ;
00070 it != detIds.end(); ++it )
00071 {
00072 const CaloCellGeometry& cell ( *getGeometry( *it ) ) ;
00073 if( cell.inside( r ) )
00074 {
00075 returnId = *it ;
00076 break ;
00077 }
00078 }
00079 return returnId ;
00080 }
00081
00082 unsigned int
00083 ZdcGeometry::alignmentTransformIndexLocal( const DetId& id )
00084 {
00085 const CaloGenericDetId gid ( id ) ;
00086
00087 assert( gid.isZDC() ) ;
00088
00089 return ( 0 > HcalZDCDetId( id ).zside() ? 0 : 1 ) ;
00090 }
00091
00092 unsigned int
00093 ZdcGeometry::alignmentTransformIndexGlobal( const DetId& id )
00094 {
00095 return (unsigned int)DetId::Calo - 1 ;
00096 }
00097
00098 std::vector<HepGeom::Point3D<double> >
00099 ZdcGeometry::localCorners( const double* pv,
00100 unsigned int i,
00101 HepGeom::Point3D<double> & ref )
00102 {
00103 return ( calogeom::IdealZDCTrapezoid::localCorners( pv, ref ) ) ;
00104 }
00105
00106 CaloCellGeometry*
00107 ZdcGeometry::newCell( const GlobalPoint& f1 ,
00108 const GlobalPoint& f2 ,
00109 const GlobalPoint& f3 ,
00110 CaloCellGeometry::CornersMgr* mgr,
00111 const double* parm ,
00112 const DetId& detId )
00113 {
00114 const CaloGenericDetId cgid ( detId ) ;
00115
00116 assert( cgid.isZDC() ) ;
00117
00118 return ( new calogeom::IdealZDCTrapezoid( f1, mgr, parm ) ) ;
00119 }
00120