CMS 3D CMS Logo

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