CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/Geometry/ForwardGeometry/src/ZdcGeometry.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/ZdcGeometry.h"
00004 #include "Geometry/ForwardGeometry/interface/IdealZDCTrapezoid.h"
00005 #include "ZdcHardcodeGeometryData.h"
00006 #include <algorithm>
00007 
00008 typedef CaloCellGeometry::CCGFloat CCGFloat ;
00009 typedef CaloCellGeometry::Pt3D     Pt3D     ;
00010 typedef CaloCellGeometry::Pt3DVec  Pt3DVec  ;
00011 
00012 ZdcGeometry::ZdcGeometry() :
00013    theTopology( new ZdcTopology ),
00014    lastReqDet_(DetId::Detector(0)), 
00015    lastReqSubdet_(0),
00016    m_ownsTopology ( true ),
00017    m_cellVec ( k_NumberOfCellsForCorners )
00018 {
00019 }
00020 
00021 ZdcGeometry::ZdcGeometry( const ZdcTopology* 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 ZdcGeometry::~ZdcGeometry() 
00031 {
00032    if( m_ownsTopology ) delete theTopology ;
00033 }
00034 /*
00035 DetId ZdcGeometry::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 unsigned int
00054 ZdcGeometry::alignmentTransformIndexLocal( const DetId& id )
00055 {
00056    const CaloGenericDetId gid ( id ) ;
00057 
00058    assert( gid.isZDC() ) ;
00059 
00060    return ( 0 > HcalZDCDetId( id ).zside() ? 0 : 1 ) ;
00061 }
00062 
00063 unsigned int
00064 ZdcGeometry::alignmentTransformIndexGlobal( const DetId& id )
00065 {
00066    return (unsigned int)DetId::Calo - 1 ;
00067 }
00068 
00069 void
00070 ZdcGeometry::localCorners( Pt3DVec&        lc  ,
00071                            const CCGFloat* pv ,
00072                            unsigned int    i  ,
00073                            Pt3D&           ref  )
00074 {
00075    IdealZDCTrapezoid::localCorners( lc, pv, ref ) ;
00076 }
00077 
00078 void
00079 ZdcGeometry::newCell( const GlobalPoint& f1 ,
00080                       const GlobalPoint& f2 ,
00081                       const GlobalPoint& f3 ,
00082                       const CCGFloat*    parm ,
00083                       const DetId&       detId   ) 
00084 {
00085    const CaloGenericDetId cgid ( detId ) ;
00086 
00087    assert( cgid.isZDC() ) ;
00088 
00089    const unsigned int di ( cgid.denseIndex() ) ;
00090 
00091    m_cellVec[ di ] = IdealZDCTrapezoid( f1, cornersMgr(), parm ) ;
00092    m_validIds.push_back( detId ) ;
00093 }
00094 
00095 const CaloCellGeometry* 
00096 ZdcGeometry::cellGeomPtr( uint32_t index ) const
00097 {
00098    const CaloCellGeometry* cell ( &m_cellVec[ index ] ) ;
00099    return ( m_cellVec.size() < index ||
00100             0 == cell->param() ? 0 : cell ) ;
00101 }
00102