CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/Geometry/CaloGeometry/src/IdealObliquePrism.cc

Go to the documentation of this file.
00001 #include "Geometry/CaloGeometry/interface/IdealObliquePrism.h"
00002 #include <math.h>
00003 
00004 typedef IdealObliquePrism::CCGFloat CCGFloat ;
00005 typedef IdealObliquePrism::Pt3D     Pt3D     ;
00006 typedef IdealObliquePrism::Pt3DVec  Pt3DVec  ;
00007 
00008 IdealObliquePrism::IdealObliquePrism() :
00009    CaloCellGeometry()
00010 {
00011 }
00012 
00013 IdealObliquePrism::IdealObliquePrism( const IdealObliquePrism& idop ) 
00014 {
00015    *this = idop ;
00016 }
00017 
00018 IdealObliquePrism& 
00019 IdealObliquePrism::operator=( const IdealObliquePrism& idop ) 
00020 {
00021    if( &idop != this ) CaloCellGeometry::operator=( idop ) ;
00022    return *this ;
00023 }
00024 
00025 IdealObliquePrism::IdealObliquePrism( const GlobalPoint& faceCenter, 
00026                                       const CornersMgr*  mgr       ,
00027                                       const CCGFloat*    parm       ) : 
00028    CaloCellGeometry ( faceCenter, mgr, parm )
00029 {
00030 }
00031 
00032 IdealObliquePrism::~IdealObliquePrism() 
00033 {
00034 }
00035 
00036 CCGFloat 
00037 IdealObliquePrism::dEta()  const 
00038 {
00039    return param()[0] ;
00040 }
00041 
00042 CCGFloat 
00043 IdealObliquePrism::dPhi()  const 
00044 { 
00045    return param()[1] ;
00046 }
00047 
00048 CCGFloat 
00049 IdealObliquePrism::dz()    const 
00050 {
00051    return param()[2] ;
00052 }
00053 
00054 CCGFloat 
00055 IdealObliquePrism::eta()   const
00056 {
00057    return param()[3] ; 
00058 }
00059 
00060 CCGFloat 
00061 IdealObliquePrism::z()     const 
00062 {
00063    return param()[4] ;
00064 }
00065 
00066 void 
00067 IdealObliquePrism::vocalCorners( Pt3DVec&        vec ,
00068                                  const CCGFloat* pv  ,
00069                                  Pt3D&           ref  ) const 
00070 { 
00071    localCorners( vec, pv, ref ) ; 
00072 }
00073 
00074   /*
00075    static GlobalPoint etaPhiR( float eta, float phi, float rad )
00076    {
00077       return GlobalPoint( rad*cosf(phi)/coshf(eta) , 
00078                           rad*sinf(phi)/coshf(eta) ,
00079                           rad*tanhf(eta)            ) ;
00080    }
00081   */
00082 
00083 GlobalPoint
00084 IdealObliquePrism::etaPhiPerp( float eta, float phi, float perp )  
00085 {
00086    return GlobalPoint( perp*cosf(phi) ,
00087                        perp*sinf(phi) ,
00088                        perp*sinhf(eta) ) ;
00089 }
00090 
00091 GlobalPoint 
00092 IdealObliquePrism::etaPhiZ(float eta, float phi, float z) 
00093 {
00094    return GlobalPoint( z*cosf(phi)/sinhf(eta) , 
00095                        z*sinf(phi)/sinhf(eta) ,
00096                        z                       ) ;
00097 }
00098 
00099 void IdealObliquePrism::localCorners( Pt3DVec&        lc  ,
00100                                       const CCGFloat* pv  ,
00101                                       Pt3D&           ref   )
00102 {
00103    assert( 8 == lc.size() ) ;
00104    assert( 0 != pv ) ;
00105    
00106    const CCGFloat dEta ( pv[0] ) ;
00107    const CCGFloat dPhi ( pv[1] ) ;
00108    const CCGFloat dz   ( pv[2] ) ;
00109    const CCGFloat eta  ( pv[3] ) ;
00110    const CCGFloat z    ( pv[4] ) ;
00111    
00112    std::vector<GlobalPoint> gc ( 8, GlobalPoint(0,0,0) ) ;
00113 
00114    const GlobalPoint p ( etaPhiZ( eta, 0, z ) ) ;
00115 
00116    if( 0 < dz )
00117    {
00118       const CCGFloat r_near ( p.perp()/cos( dPhi ) ) ;
00119       const CCGFloat r_far  ( r_near*( ( p.mag() + 2*dz )/p.mag() ) ) ;
00120       gc[ 0 ] = etaPhiPerp( eta + dEta , +dPhi , r_near ) ; // (+,+,near)
00121       gc[ 1 ] = etaPhiPerp( eta + dEta , -dPhi , r_near ) ; // (+,-,near)
00122       gc[ 2 ] = etaPhiPerp( eta - dEta , -dPhi , r_near ) ; // (-,-,near)
00123       gc[ 3 ] = etaPhiPerp( eta - dEta , +dPhi , r_near ) ; // (-,+,far)
00124       gc[ 4 ] = etaPhiPerp( eta + dEta , +dPhi , r_far  ) ; // (+,+,far)
00125       gc[ 5 ] = etaPhiPerp( eta + dEta , -dPhi , r_far  ) ; // (+,-,far)
00126       gc[ 6 ] = etaPhiPerp( eta - dEta , -dPhi , r_far  ) ; // (-,-,far)
00127       gc[ 7 ] = etaPhiPerp( eta - dEta , +dPhi , r_far  ) ; // (-,+,far)
00128    }
00129    else
00130    {
00131       const CCGFloat z_near ( z ) ;
00132       const CCGFloat z_far  ( z*( 1 - 2*dz/p.mag() ) ) ;
00133       gc[ 0 ] = etaPhiZ( eta + dEta , +dPhi , z_near ) ; // (+,+,near)
00134       gc[ 1 ] = etaPhiZ( eta + dEta , -dPhi , z_near ) ; // (+,-,near)
00135       gc[ 2 ] = etaPhiZ( eta - dEta , -dPhi , z_near ) ; // (-,-,near)
00136       gc[ 3 ] = etaPhiZ( eta - dEta , +dPhi , z_near ) ; // (-,+,far)
00137       gc[ 4 ] = etaPhiZ( eta + dEta , +dPhi , z_far  ) ; // (+,+,far)
00138       gc[ 5 ] = etaPhiZ( eta + dEta , -dPhi , z_far  ) ; // (+,-,far)
00139       gc[ 6 ] = etaPhiZ( eta - dEta , -dPhi , z_far  ) ; // (-,-,far)
00140       gc[ 7 ] = etaPhiZ( eta - dEta , +dPhi , z_far  ) ; // (-,+,far)
00141    }
00142    for( unsigned int i ( 0 ) ; i != 8 ; ++i )
00143    {
00144       lc[i] = Pt3D( gc[i].x(), gc[i].y(), gc[i].z() ) ;
00145    }
00146    
00147    ref   = 0.25*( lc[0] + lc[1] + lc[2] + lc[3] ) ;
00148 }
00149 
00150 const CaloCellGeometry::CornersVec& 
00151 IdealObliquePrism::getCorners() const
00152 {
00153    const CornersVec& co ( CaloCellGeometry::getCorners() ) ;
00154    if( co.uninitialized() )
00155    {
00156       CornersVec& corners ( setCorners() ) ;
00157       if( dz()>0 ) 
00158       { 
00159          /* In this case, the faces are parallel to the zaxis.  
00160             This implies that all corners will have the same 
00161             cylindrical radius. 
00162          */
00163          const GlobalPoint p      ( getPosition() ) ;
00164          const CCGFloat    r_near ( p.perp()/cos(dPhi()) ) ;
00165          const CCGFloat    r_far  ( r_near*( ( p.mag() + 2*dz() )/p.mag() ) ) ;
00166          const CCGFloat    eta    ( p.eta() ) ;
00167          const CCGFloat    phi    ( p.phi() ) ;
00168          corners[ 0 ] = etaPhiPerp( eta + dEta() , phi + dPhi() , r_near ) ; // (+,+,near)
00169          corners[ 1 ] = etaPhiPerp( eta + dEta() , phi - dPhi() , r_near ) ; // (+,-,near)
00170          corners[ 2 ] = etaPhiPerp( eta - dEta() , phi - dPhi() , r_near ) ; // (-,-,near)
00171          corners[ 3 ] = etaPhiPerp( eta - dEta() , phi + dPhi() , r_near ) ; // (-,+,near)
00172          corners[ 4 ] = etaPhiPerp( eta + dEta() , phi + dPhi() , r_far ) ; // (+,+,far)
00173          corners[ 5 ] = etaPhiPerp( eta + dEta() , phi - dPhi() , r_far ) ; // (+,-,far)
00174          corners[ 6 ] = etaPhiPerp( eta - dEta() , phi - dPhi() , r_far ) ; // (-,-,far)
00175          corners[ 7 ] = etaPhiPerp( eta - dEta() , phi + dPhi() , r_far ) ; // (-,+,far)
00176       } 
00177       else 
00178       {
00179          /* In this case, the faces are perpendicular to the zaxis.  
00180             This implies that all corners will have the same 
00181             z-dimension. 
00182          */
00183          const GlobalPoint p      ( getPosition() ) ;
00184          const CCGFloat    z_near ( p.z() ) ;
00185          const CCGFloat    mag    ( p.mag() ) ;
00186          const CCGFloat    z_far  ( z_near*( 1 - 2*dz()/mag ) ) ; // negative to correct sign
00187          const CCGFloat    eta    ( p.eta() ) ;
00188          const CCGFloat    phi    ( p.phi() ) ;
00189          
00190          corners[ 0 ] = etaPhiZ( eta + dEta(), phi + dPhi(), z_near ) ; // (+,+,near)
00191          corners[ 1 ] = etaPhiZ( eta + dEta(), phi - dPhi(), z_near ) ; // (+,-,near)
00192          corners[ 2 ] = etaPhiZ( eta - dEta(), phi - dPhi(), z_near ) ; // (-,-,near)
00193          corners[ 3 ] = etaPhiZ( eta - dEta(), phi + dPhi(), z_near ) ; // (-,+,near)
00194          corners[ 4 ] = etaPhiZ( eta + dEta(), phi + dPhi(), z_far  ) ; // (+,+,far)
00195          corners[ 5 ] = etaPhiZ( eta + dEta(), phi - dPhi(), z_far  ) ; // (+,-,far)
00196          corners[ 6 ] = etaPhiZ( eta - dEta(), phi - dPhi(), z_far  ) ; // (-,-,far)
00197          corners[ 7 ] = etaPhiZ( eta - dEta(), phi + dPhi(), z_far  ) ; // (-,+,far)
00198          
00199       }
00200    }
00201    return co ;
00202 }
00203 
00204 std::ostream& operator<<( std::ostream& s, const IdealObliquePrism& cell ) 
00205 {
00206    s << "Center: " <<  cell.getPosition() << std::endl ;
00207    s << "dEta = " << cell.dEta() << ", dPhi = " << cell.dPhi() << ", dz = " << cell.dz() << std::endl ;
00208    return s;
00209 }