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