CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/Geometry/ForwardGeometry/src/IdealZDCTrapezoid.cc

Go to the documentation of this file.
00001 #include "Geometry/ForwardGeometry/interface/IdealZDCTrapezoid.h"
00002 #include <math.h>
00003 
00004 typedef CaloCellGeometry::CCGFloat CCGFloat ;
00005 typedef CaloCellGeometry::Pt3D     Pt3D     ;
00006 typedef CaloCellGeometry::Pt3DVec  Pt3DVec  ;
00007 
00008 IdealZDCTrapezoid::IdealZDCTrapezoid() :
00009    CaloCellGeometry()
00010 {
00011 }
00012 
00013 IdealZDCTrapezoid::IdealZDCTrapezoid( const IdealZDCTrapezoid& idzt ) 
00014 {
00015    *this = idzt ;
00016 }
00017 
00018 IdealZDCTrapezoid& 
00019 IdealZDCTrapezoid::operator=( const IdealZDCTrapezoid& idzt ) 
00020 {
00021    if( &idzt != this ) CaloCellGeometry::operator=( idzt ) ;
00022    return *this ;
00023 }
00024 
00025 IdealZDCTrapezoid::IdealZDCTrapezoid( const GlobalPoint& faceCenter,
00026                                       const CornersMgr*  mgr       ,
00027                                       const CCGFloat*    parm        ) :  
00028    CaloCellGeometry ( faceCenter, mgr, parm )  
00029 {
00030 }
00031          
00032 IdealZDCTrapezoid::~IdealZDCTrapezoid() {}
00033 
00034 const CCGFloat 
00035 IdealZDCTrapezoid::an() const { return param()[0] ; }
00036 
00037 const CCGFloat 
00038 IdealZDCTrapezoid::dx() const 
00039 {
00040    return param()[1] ; 
00041 }
00042 
00043 const CCGFloat 
00044 IdealZDCTrapezoid::dy() const 
00045 {
00046    return param()[2] ; 
00047 }
00048 
00049 const CCGFloat 
00050 IdealZDCTrapezoid::dz() const 
00051 {
00052    return param()[3] ; 
00053 }
00054 
00055 const CCGFloat 
00056 IdealZDCTrapezoid::ta() const 
00057 {
00058    return tan( an() ) ; 
00059 }
00060 
00061 const CCGFloat 
00062 IdealZDCTrapezoid::dt() const 
00063 {
00064    return dy()*ta() ; 
00065 }
00066 
00067 void 
00068 IdealZDCTrapezoid::vocalCorners( Pt3DVec&        vec ,
00069                                  const CCGFloat* pv  ,
00070                                  Pt3D&           ref  ) const 
00071 {
00072    localCorners( vec, pv, ref ) ; 
00073 }
00074 
00075 void
00076 IdealZDCTrapezoid::localCorners( Pt3DVec&        lc  ,
00077                                  const CCGFloat* pv  ,
00078                                  Pt3D&           ref   )
00079 {
00080    assert( 8 == lc.size() ) ;
00081    assert( 0 != pv ) ;
00082 
00083    const CCGFloat an ( pv[0] ) ;
00084    const CCGFloat dx ( pv[1] ) ;
00085    const CCGFloat dy ( pv[2] ) ;
00086    const CCGFloat dz ( pv[3] ) ;
00087    const CCGFloat ta ( tan( an ) ) ;
00088    const CCGFloat dt ( dy*ta ) ;
00089 
00090    lc[0] = Pt3D ( -dx, -dy, +dz+dt ) ;
00091    lc[1] = Pt3D ( -dx, +dy, +dz-dt ) ;
00092    lc[2] = Pt3D ( +dx, +dy, +dz-dt ) ;
00093    lc[3] = Pt3D ( +dx, -dy, +dz+dt ) ;
00094    lc[4] = Pt3D ( -dx, -dy, -dz+dt ) ;
00095    lc[5] = Pt3D ( -dx, +dy, -dz-dt ) ;
00096    lc[6] = Pt3D ( +dx, +dy, -dz-dt ) ;
00097    lc[7] = Pt3D ( +dx, -dy, -dz+dt ) ;
00098 
00099    ref   = 0.25*( lc[0] + lc[1] + lc[2] + lc[3] ) ;
00100 }
00101 
00102 const CaloCellGeometry::CornersVec& 
00103 IdealZDCTrapezoid::getCorners() const 
00104 {
00105    const CornersVec& co ( CaloCellGeometry::getCorners() ) ;
00106    if( co.uninitialized() ) 
00107    {
00108       CaloCellGeometry::CornersVec& corners ( setCorners() ) ;
00109       const GlobalPoint& p ( getPosition() ) ;
00110       const CCGFloat zsign ( 0 < p.z() ? 1. : -1. ) ;
00111       const Pt3D  gf ( p.x(), p.y(), p.z() ) ;
00112 
00113       Pt3D  lf ;
00114       Pt3DVec lc ( 8, Pt3D(0,0,0) ) ;
00115       localCorners( lc, param(), lf ) ;
00116       const Pt3D  lb ( lf.x() , lf.y() , lf.z() - 2.*dz() ) ;
00117       const Pt3D  ls ( lf.x() - dx(), lf.y(), lf.z() ) ;
00118       
00119       const Pt3D  gb ( gf.x() , gf.y() , gf.z() + 2.*zsign*dz() ) ;
00120 
00121       const Pt3D  gs ( gf.x() - zsign*dx(),
00122                        gf.y() ,
00123                        gf.z()         ) ;
00124 
00125       const HepGeom::Transform3D tr ( lf, lb, ls,
00126                                       gf, gb, gs ) ;
00127 
00128       for( unsigned int i ( 0 ) ; i != 8 ; ++i )
00129       {
00130          const Pt3D  gl ( tr*lc[i] ) ;
00131          corners[i] = GlobalPoint( gl.x(), gl.y(), gl.z() ) ;
00132       }
00133    }
00134    return co ;
00135 }
00136 
00137 std::ostream& operator<<( std::ostream& s, const IdealZDCTrapezoid& cell ) 
00138 {
00139    s << "Center: " <<  cell.getPosition() << std::endl ;
00140    s << "TiltAngle = " << cell.an()*180./M_PI << " deg, dx = " 
00141      << cell.dx() 
00142      << ", dy = " << cell.dy() << ", dz = " << cell.dz() << std::endl ;
00143    return s;
00144 }