CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Geometry/ForwardGeometry/src/IdealCastorTrapezoid.cc

Go to the documentation of this file.
00001 #include "Geometry/ForwardGeometry/interface/IdealCastorTrapezoid.h"
00002 #include "CLHEP/Geometry/Plane3D.h"
00003 #include "CLHEP/Geometry/Transform3D.h"
00004 #include <math.h>
00005 
00006 typedef CaloCellGeometry::CCGFloat CCGFloat ;
00007 typedef CaloCellGeometry::Pt3D     Pt3D     ;
00008 typedef CaloCellGeometry::Pt3DVec  Pt3DVec  ;
00009 typedef CaloCellGeometry::Tr3D     Tr3D     ;
00010 
00011 IdealCastorTrapezoid::IdealCastorTrapezoid()
00012   : CaloCellGeometry()
00013 {
00014 }
00015 
00016 IdealCastorTrapezoid::IdealCastorTrapezoid( const IdealCastorTrapezoid& idct ) 
00017   : CaloCellGeometry( idct )
00018 {
00019    *this = idct ;
00020 }
00021 
00022 IdealCastorTrapezoid& 
00023 IdealCastorTrapezoid::operator=( const IdealCastorTrapezoid& idct ) 
00024 {
00025    if( &idct != this ) CaloCellGeometry::operator=( idct ) ;
00026    return *this ;
00027 }
00028 
00029 IdealCastorTrapezoid::IdealCastorTrapezoid( const GlobalPoint& faceCenter,
00030                                             const CornersMgr*  mgr       ,
00031                                             const CCGFloat*    parm       )
00032   : CaloCellGeometry ( faceCenter, mgr, parm )  
00033 {
00034 }
00035          
00036 IdealCastorTrapezoid::~IdealCastorTrapezoid() 
00037 {
00038 }
00039 
00040 CCGFloat 
00041 IdealCastorTrapezoid::dxl() const 
00042 {
00043    return param()[0] ; 
00044 }
00045 
00046 CCGFloat 
00047 IdealCastorTrapezoid::dxh() const 
00048 {
00049    return param()[1] ; 
00050 }
00051 
00052 CCGFloat 
00053 IdealCastorTrapezoid::dx()  const 
00054 {
00055    return ( dxl()+dxh() )/2. ; 
00056 }
00057 
00058 CCGFloat 
00059 IdealCastorTrapezoid::dh()  const 
00060 {
00061    return param()[2] ; 
00062 }
00063 
00064 CCGFloat 
00065 IdealCastorTrapezoid::dy()  const 
00066 {
00067    return dh()*sin(an()) ; 
00068 }
00069 
00070 CCGFloat 
00071 IdealCastorTrapezoid::dz()  const 
00072 {
00073    return param()[3] ; 
00074 }
00075 
00076 CCGFloat 
00077 IdealCastorTrapezoid::dhz() const 
00078 {
00079    return dh()*cos(an()) ; 
00080 }
00081 
00082 CCGFloat 
00083 IdealCastorTrapezoid::dzb() const 
00084 {
00085    return dz() + dhz() ;
00086 }
00087 
00088 CCGFloat 
00089 IdealCastorTrapezoid::dzs() const 
00090 {
00091    return dz() - dhz() ; 
00092 }
00093 
00094 CCGFloat 
00095 IdealCastorTrapezoid::an()  const 
00096 {
00097    return param()[4] ; 
00098 }
00099 
00100 CCGFloat 
00101 IdealCastorTrapezoid::dR()  const 
00102 {
00103    return param()[5] ; 
00104 }
00105 
00106 void 
00107 IdealCastorTrapezoid::vocalCorners( Pt3DVec&        vec ,
00108                                  const CCGFloat* pv  ,
00109                                  Pt3D&           ref  ) const 
00110 { 
00111    localCorners( vec, pv, ref ) ; 
00112 }
00113 
00114 void
00115 IdealCastorTrapezoid::localCorners( Pt3DVec&        lc  ,
00116                                     const CCGFloat* pv  ,
00117                                     Pt3D&           ref   )
00118 {
00119    assert( 8 == lc.size() ) ;
00120    assert( 0 != pv ) ;
00121    
00122    const CCGFloat dxl ( pv[0] ) ;
00123    const CCGFloat dxh ( pv[1] ) ;
00124    const CCGFloat dh  ( pv[2] ) ;
00125    const CCGFloat dz  ( pv[3] ) ;
00126    const CCGFloat an  ( pv[4] ) ;
00127    const CCGFloat dx  ( ( dxl +dxh )/2. ) ;
00128    const CCGFloat dy  ( dh*sin(an) ) ;
00129    const CCGFloat dhz ( dh*cos(an) ) ;
00130    const CCGFloat dzb ( dz + dhz ) ;
00131    const CCGFloat dzs ( dz - dhz ) ;
00132 
00133    assert( 0 < (dxl*dxh) ) ;
00134 
00135    lc[ 0 ] = Pt3D (        -dx, -dy ,  dzb ) ;
00136    lc[ 1 ] = Pt3D (        -dx, +dy ,  dzs ) ;
00137    lc[ 2 ] = Pt3D ( +2*dxh -dx, +dy ,  dzs ) ;
00138    lc[ 3 ] = Pt3D ( +2*dxl -dx, -dy ,  dzb ) ;
00139    lc[ 4 ] = Pt3D (        -dx, -dy , -dzs ) ;
00140    lc[ 5 ] = Pt3D (        -dx, +dy , -dzb ) ;
00141    lc[ 6 ] = Pt3D ( +2*dxh -dx, +dy , -dzb ) ;
00142    lc[ 7 ] = Pt3D ( +2*dxl -dx, -dy , -dzs ) ;
00143 
00144    ref   = 0.25*( lc[0] + lc[1] + lc[2] + lc[3] ) ;
00145 }
00146 
00147 const CaloCellGeometry::CornersVec& 
00148 IdealCastorTrapezoid::getCorners() const 
00149 {
00150    const CornersVec& co ( CaloCellGeometry::getCorners() ) ;
00151    if( co.uninitialized() ) 
00152    {
00153       CaloCellGeometry::CornersVec& corners ( setCorners() ) ;
00154       const GlobalPoint& p ( getPosition() ) ;
00155       const CCGFloat zsign ( 0 < p.z() ? 1. : -1. ) ;
00156       const Pt3D  gf ( p.x(), p.y(), p.z() ) ;
00157 
00158       Pt3D  lf ;
00159       Pt3DVec lc ( 8, Pt3D(0,0,0) ) ;
00160       localCorners( lc, param(), lf ) ;
00161       const Pt3D lb ( lf.x() , lf.y() , lf.z() - 2.*dz() ) ;
00162       const Pt3D ls ( lf.x() - dx(), lf.y(), lf.z() ) ;
00163 
00164 
00165       const CCGFloat fphi ( atan( dx()/( dR() + dy() ) ) ) ;
00166       const Pt3D     gb ( gf.x() , gf.y() , gf.z() + 2.*zsign*dz() ) ;
00167 
00168       const CCGFloat rho ( dR() + dy() ) ;
00169       const CCGFloat phi ( gf.phi() + fphi ) ;
00170       const Pt3D gs ( rho*cos(phi) ,
00171                       rho*sin(phi) ,
00172                       gf.z()         ) ;
00173 
00174       const Tr3D tr ( lf, lb, ls,
00175                       gf, gb, gs ) ;
00176 
00177       for( unsigned int i ( 0 ) ; i != 8 ; ++i )
00178       {
00179          const Pt3D gl ( tr*lc[i] ) ;
00180          corners[i] = GlobalPoint( gl.x(), gl.y(), gl.z() ) ;
00181       }
00182    }
00183    return co ;
00184 }
00185 
00186 std::ostream& operator<<( std::ostream& s, const IdealCastorTrapezoid& cell ) 
00187 {
00188    s << "Center: " <<  cell.getPosition() << std::endl ;
00189 //      s        << ", dx = " << cell.dx() 
00190 //<< "TiltAngle = " << cell.an() 
00191 //      << ", dy = " << cell.dy() << ", dz = " << cell.dz() << std::endl ;
00192    return s;
00193 }