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