![]() |
![]() |
00001 #include "Geometry/ForwardGeometry/interface/IdealZDCTrapezoid.h" 00002 #include <math.h> 00003 00004 namespace calogeom { 00005 00006 const CaloCellGeometry::CornersVec& 00007 IdealZDCTrapezoid::getCorners() const 00008 { 00009 const CornersVec& co ( CaloCellGeometry::getCorners() ) ; 00010 if( co.uninitialized() ) 00011 { 00012 CaloCellGeometry::CornersVec& corners ( setCorners() ) ; 00013 const GlobalPoint& p ( getPosition() ) ; 00014 const float zz ( p.z() ) ; 00015 const float yy ( p.y() ) ; 00016 const float cdy ( cos( an() )*dy()/2. ) ; 00017 const float sdy ( sin( an() )*dy()/2. ) ; 00018 const float sign ( zz<0 ? 1 : -1 ) ; 00019 const float z1 ( zz + sign*cdy ) ; 00020 const float z2 ( zz - sign*cdy ) ; 00021 const float z3 ( z1 + dz() ) ; 00022 const float z4 ( z2 + dz() ) ; 00023 const float x1 ( dx()/2 ); 00024 const float x2 ( -dx()/2 ); 00025 const float y1 ( yy + sdy ) ; 00026 const float y2 ( yy - sdy ) ; 00027 corners[ 0 ] = GlobalPoint( x1, y1, z1 ) ; 00028 corners[ 1 ] = GlobalPoint( x2, y1, z1 ) ; 00029 corners[ 2 ] = GlobalPoint( x2, y2, z2 ) ; 00030 corners[ 3 ] = GlobalPoint( x1, y2, z2 ) ; 00031 corners[ 4 ] = GlobalPoint( x1, y1, z3 ) ; 00032 corners[ 5 ] = GlobalPoint( x2, y1, z3 ) ; 00033 corners[ 6 ] = GlobalPoint( x2, y2, z4 ) ; 00034 corners[ 7 ] = GlobalPoint( x1, y2, z4 ) ; 00035 } 00036 return co ; 00037 } 00038 00039 bool 00040 IdealZDCTrapezoid::inside( const GlobalPoint& point ) const 00041 { 00042 bool is_inside ( false ) ; 00043 00044 const GlobalPoint& face ( getPosition() ) ; 00045 00046 if( fabs( point.x() - face.x() ) <= dx()/2 && 00047 fabs( point.y() - face.y() ) <= sin( an() )*dy()/2 ) 00048 { 00049 const float sl ( tan( an() ) ) ; 00050 const float blow ( face.y() - sl*face.z() ) ; 00051 00052 const float sign ( 0 < point.z() ? 1 : -1 ) ; 00053 const float bhigh ( face.y() - sl*sign*( face.z() + sign*dz() ) ) ; 00054 00055 is_inside = ( ( point.z() > sign*( point.y() - blow )/sl ) && 00056 ( point.z() <= sign*( point.y() - bhigh )/sl ) ) ; 00057 } 00058 return is_inside; 00059 } 00060 00061 std::ostream& operator<<( std::ostream& s, const IdealZDCTrapezoid& cell ) 00062 { 00063 s << "Center: " << cell.getPosition() << std::endl ; 00064 s << "TiltAngle = " << cell.an() << ", dx = " << cell.dx() 00065 << ", dy = " << cell.dy() << ", dz = " << cell.dz() << std::endl ; 00066 return s; 00067 } 00068 }