CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/Geometry/CaloGeometry/src/PreshowerStrip.cc

Go to the documentation of this file.
00001 #include "Geometry/CaloGeometry/interface/PreshowerStrip.h"
00002 #include <iostream>
00003 
00004 typedef PreshowerStrip::CCGFloat CCGFloat ;
00005 typedef PreshowerStrip::Pt3D     Pt3D     ;
00006 typedef PreshowerStrip::Pt3DVec  Pt3DVec  ;
00007 typedef PreshowerStrip::Tr3D     Tr3D     ;
00008 
00009 
00010 PreshowerStrip::PreshowerStrip()
00011   : CaloCellGeometry()
00012 {}
00013 
00014 PreshowerStrip::PreshowerStrip( const PreshowerStrip& tr ) 
00015   : CaloCellGeometry( tr )
00016 {
00017   *this = tr ; 
00018 }
00019 
00020 PreshowerStrip::~PreshowerStrip() 
00021 {}
00022 
00023 PreshowerStrip& 
00024 PreshowerStrip::operator=( const PreshowerStrip& tr ) 
00025 {
00026   if( &tr != this )
00027   {
00028     CaloCellGeometry::operator=( tr ) ;
00029   }
00030   return *this ; 
00031 }
00032 
00033 const CaloCellGeometry::CornersVec& 
00034 PreshowerStrip::getCorners() const 
00035 {
00036   const CornersVec& co ( CaloCellGeometry::getCorners() ) ;
00037   if( co.uninitialized() ) 
00038   {
00039     CornersVec& corners ( setCorners() ) ;
00040 
00041     const GlobalPoint& ctr ( getPosition() ) ;
00042     const CCGFloat x ( ctr.x() ) ;
00043     const CCGFloat y ( ctr.y() ) ;
00044     const CCGFloat z ( ctr.z() ) ;
00045 
00046     const double st ( sin(tilt()) ) ;
00047     const double ct ( cos(tilt()) ) ;
00048 
00049     for( unsigned int ix ( 0 ) ; ix !=2 ; ++ix )
00050     {
00051       const double sx ( 0 == ix ? -1.0 : +1.0 ) ;
00052       for( unsigned int iy ( 0 ) ; iy !=2 ; ++iy )
00053       {
00054         const double sy ( 0 == iy ? -1.0 : +1.0 ) ;
00055         for( unsigned int iz ( 0 ) ; iz !=2 ; ++iz )
00056         {
00057           const double sz ( 0 == iz ? -1.0 : +1.0 ) ;
00058           const unsigned int  i ( 4*iz + 2*ix + 
00059                                   ( 1 == ix ? 1-iy : iy ) ) ;//keeps ordering same as before
00060 
00061           corners[ i ] = GlobalPoint( 
00062             dy()>dx() ? 
00063             x + sx*dx() : 
00064             x + sx*dx()*ct - sz*dz()*st ,
00065             dy()<dx() ? 
00066             y + sy*dy() : 
00067             y + sy*dy()*ct - sz*dz()*st ,
00068             dy()>dx() ? 
00069             z + sz*dz()*ct + sy*dy()*st :
00070             z + sz*dz()*ct + sx*dx()*st ) ;
00071         }
00072       }
00073     }
00074   }
00075   return co ;
00076 }
00077 
00078 std::ostream& operator<<( std::ostream& s, const PreshowerStrip& cell ) 
00079 {
00080   s << "Center: " <<  cell.getPosition() << std::endl ;
00081   if( cell.param() != 0 )
00082   {
00083     s << "dx = " << cell.dx() << ", dy = " << cell.dy() << ", dz = " << cell.dz() << std::endl ;
00084 
00085     const CaloCellGeometry::CornersVec& corners ( cell.getCorners() ) ; 
00086     for( unsigned int ci ( 0 ) ; ci != corners.size(); ci++ ) 
00087     {
00088       s  << "Corner: " << corners[ci] << std::endl;
00089     }
00090   }
00091   else
00092   {
00093     s << " with empty parameters." << std::endl;
00094   }
00095   
00096   return s;
00097 }
00098 
00099 void
00100 PreshowerStrip::localCorners( Pt3DVec&        lc  ,
00101                               const CCGFloat* pv  ,
00102                               Pt3D&           ref  )
00103 {
00104   assert( 8 == lc.size() ) ;
00105   assert( 0 != pv ) ;
00106 
00107   const CCGFloat dx ( pv[0] ) ;
00108   const CCGFloat dy ( pv[1] ) ;
00109   const CCGFloat dz ( pv[2] ) ;
00110 
00111   lc[0] = Pt3D( -dx, -dy, -dz ) ;
00112   lc[1] = Pt3D( -dx,  dy, -dz ) ;
00113   lc[2] = Pt3D(  dx,  dy, -dz ) ;
00114   lc[3] = Pt3D(  dx, -dy, -dz ) ;
00115   lc[4] = Pt3D( -dx, -dy,  dz ) ;
00116   lc[5] = Pt3D( -dx,  dy,  dz ) ;
00117   lc[6] = Pt3D(  dx,  dy,  dz ) ;
00118   lc[7] = Pt3D(  dx, -dy,  dz ) ;
00119 
00120   ref   = Pt3D(0,0,0) ;
00121 }