CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/Geometry/ForwardGeometry/src/CastorGeometry.cc

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