CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/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 namespace calogeom {
00005 
00006    std::vector<HepGeom::Point3D<double> >
00007    IdealZDCTrapezoid::localCorners( const double* pv  ,
00008                                     HepGeom::Point3D<double> &   ref   )
00009    {
00010       assert( 0 != pv ) ;
00011 
00012       const double an ( pv[0] ) ;
00013       const double dx ( pv[1] ) ;
00014       const double dy ( pv[2] ) ;
00015       const double dz ( pv[3] ) ;
00016       const double ta ( tan( an ) ) ;
00017       const double dt ( dy*ta ) ;
00018 
00019       std::vector<HepGeom::Point3D<double> >  lc ( 8, HepGeom::Point3D<double> ( 0,0,0) ) ;
00020 
00021       lc[0] = HepGeom::Point3D<double> ( -dx, -dy, +dz+dt ) ;
00022       lc[1] = HepGeom::Point3D<double> ( -dx, +dy, +dz-dt ) ;
00023       lc[2] = HepGeom::Point3D<double> ( +dx, +dy, +dz-dt ) ;
00024       lc[3] = HepGeom::Point3D<double> ( +dx, -dy, +dz+dt ) ;
00025       lc[4] = HepGeom::Point3D<double> ( -dx, -dy, -dz+dt ) ;
00026       lc[5] = HepGeom::Point3D<double> ( -dx, +dy, -dz-dt ) ;
00027       lc[6] = HepGeom::Point3D<double> ( +dx, +dy, -dz-dt ) ;
00028       lc[7] = HepGeom::Point3D<double> ( +dx, -dy, -dz+dt ) ;
00029 
00030       ref   = 0.25*( lc[0] + lc[1] + lc[2] + lc[3] ) ;
00031       return lc ;
00032    }
00033 
00034    const CaloCellGeometry::CornersVec& 
00035    IdealZDCTrapezoid::getCorners() const 
00036    {
00037       const CornersVec& co ( CaloCellGeometry::getCorners() ) ;
00038       if( co.uninitialized() ) 
00039       {
00040          CaloCellGeometry::CornersVec& corners ( setCorners() ) ;
00041          const GlobalPoint& p ( getPosition() ) ;
00042          const double zsign ( 0 < p.z() ? 1. : -1. ) ;
00043          const HepGeom::Point3D<double>  gf ( p.x(), p.y(), p.z() ) ;
00044 
00045          HepGeom::Point3D<double>  lf ;
00046          const std::vector<HepGeom::Point3D<double> > lc ( localCorners( param(), lf ) ) ;
00047          const HepGeom::Point3D<double>  lb ( lf.x() , lf.y() , lf.z() - 2.*dz() ) ;
00048          const HepGeom::Point3D<double>  ls ( lf.x() - dx(), lf.y(), lf.z() ) ;
00049 
00050          const HepGeom::Point3D<double>   gb ( gf.x() , gf.y() , gf.z() + 2.*zsign*dz() ) ;
00051 
00052          const HepGeom::Point3D<double>  gs ( gf.x() - zsign*dx(),
00053                                gf.y() ,
00054                                gf.z()         ) ;
00055 
00056          const HepGeom::Transform3D tr ( lf, lb, ls,
00057                                    gf, gb, gs ) ;
00058 
00059          for( unsigned int i ( 0 ) ; i != 8 ; ++i )
00060          {
00061             const HepGeom::Point3D<double>  gl ( tr*lc[i] ) ;
00062             corners[i] = GlobalPoint( gl.x(), gl.y(), gl.z() ) ;
00063          }
00064       }
00065       return co ;
00066    }
00067 
00068    std::ostream& operator<<( std::ostream& s, const IdealZDCTrapezoid& cell ) 
00069    {
00070       s << "Center: " <<  cell.getPosition() << std::endl ;
00071       s << "TiltAngle = " << cell.an()*180./M_PI << " deg, dx = " 
00072         << cell.dx() 
00073         << ", dy = " << cell.dy() << ", dz = " << cell.dz() << std::endl ;
00074       return s;
00075    }
00076 }