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/CastorGeometry.h"
00004 #include "Geometry/ForwardGeometry/interface/IdealCastorTrapezoid.h"
00005 #include "CastorGeometryData.h"
00006 #include <algorithm>
00007
00008 typedef CaloCellGeometry::CCGFloat CCGFloat ;
00009 typedef CaloCellGeometry::Pt3D Pt3D ;
00010 typedef CaloCellGeometry::Pt3DVec Pt3DVec ;
00011
00012 CastorGeometry::CastorGeometry() :
00013 theTopology( new CastorTopology ),
00014 lastReqDet_(DetId::Detector(0)),
00015 lastReqSubdet_(0),
00016 m_ownsTopology ( true ),
00017 m_cellVec ( k_NumberOfCellsForCorners )
00018 {
00019 }
00020
00021 CastorGeometry::CastorGeometry( const CastorTopology* topology ) :
00022 theTopology(topology),
00023 lastReqDet_(DetId::Detector(0)),
00024 lastReqSubdet_(0),
00025 m_ownsTopology ( false ),
00026 m_cellVec ( k_NumberOfCellsForCorners )
00027 {
00028 }
00029
00030
00031 CastorGeometry::~CastorGeometry()
00032 {
00033 if( m_ownsTopology ) delete theTopology ;
00034 }
00035
00036 DetId
00037 CastorGeometry::getClosestCell(const GlobalPoint& r) const
00038 {
00039 DetId returnId ( 0 ) ;
00040 const std::vector<DetId>& detIds ( getValidDetIds() ) ;
00041 for( std::vector<DetId>::const_iterator it ( detIds.begin() ) ;
00042 it != detIds.end(); ++it )
00043 {
00044 const CaloCellGeometry* cell ( getGeometry( *it ) ) ;
00045 if( 0 != cell &&
00046 cell->inside( r ) )
00047 {
00048 returnId = *it ;
00049 break ;
00050 }
00051 }
00052 return returnId ;
00053 }
00054
00055
00056
00057 unsigned int
00058 CastorGeometry::alignmentTransformIndexLocal( const DetId& id )
00059 {
00060 const CaloGenericDetId gid ( id ) ;
00061
00062 assert( gid.isCastor() ) ;
00063
00064 return 0 ;
00065 }
00066
00067 unsigned int
00068 CastorGeometry::alignmentTransformIndexGlobal( const DetId& id )
00069 {
00070 return (unsigned int)DetId::Calo - 1 ;
00071 }
00072
00073 void
00074 CastorGeometry::localCorners( Pt3DVec& lc ,
00075 const CCGFloat* pv ,
00076 unsigned int i ,
00077 Pt3D& ref )
00078 {
00079 IdealCastorTrapezoid::localCorners( lc, pv, ref ) ;
00080 }
00081
00082 void
00083 CastorGeometry::newCell( const GlobalPoint& f1 ,
00084 const GlobalPoint& f2 ,
00085 const GlobalPoint& f3 ,
00086 const CCGFloat* parm ,
00087 const DetId& detId )
00088 {
00089 const CaloGenericDetId cgid ( detId ) ;
00090
00091 assert( cgid.isCastor() ) ;
00092
00093 const unsigned int di ( cgid.denseIndex() ) ;
00094
00095 m_cellVec[ di ] = IdealCastorTrapezoid( f1, cornersMgr(), parm ) ;
00096 m_validIds.push_back( detId ) ;
00097 }
00098
00099 const CaloCellGeometry*
00100 CastorGeometry::cellGeomPtr( uint32_t index ) const
00101 {
00102 const CaloCellGeometry* cell ( &m_cellVec[ index ] ) ;
00103 return ( m_cellVec.size() < index ||
00104 0 == cell->param() ? 0 : cell ) ;
00105 }