CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/Geometry/CaloGeometry/src/EcalTrapezoidParameters.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     EcalCommonData
00004 // Module:      EcalTrapezoidParameters
00005 // 
00006 // Description: Do trigonometry to figure out all useful dimensions/angles
00007 //
00008 // Implementation: Compute everything in constructor, put in member data
00009 //
00010 // Author:      Brian K. Heltsley
00011 // Created:     Wed Aug 12 09:24:56 EDT 1998
00012 //
00013 
00014 // system include files
00015 #include <assert.h>
00016 #include <cmath>
00017 #include <algorithm>
00018 
00019 // user include files
00020 #include "Geometry/CaloGeometry/interface/EcalTrapezoidParameters.h"
00021 
00022 typedef EcalTrapezoidParameters::TPFloat    TPFloat    ;
00023 typedef EcalTrapezoidParameters::VertexList VertexList ;
00024 typedef CaloCellGeometry::Pt3D              Pt3D       ;
00025 
00026 // STL classes
00027 
00028 //
00029 // constants, enums and typedefs
00030 //
00031 
00032 //static const char* const kReport = "DetectorGeometry.DGTrapezoidParameters" ;
00033 
00034 //
00035 // static data member definitions
00036 //
00037 
00038 //
00039 // constructors and destructor
00040 //
00041 EcalTrapezoidParameters::EcalTrapezoidParameters(
00042    TPFloat aHalfLengthXNegZLoY , // bl1, A/2
00043    TPFloat aHalfLengthXPosZLoY , // bl2
00044    TPFloat aHalfLengthXPosZHiY , // tl2
00045    TPFloat aHalfLengthYNegZ    , // h1
00046    TPFloat aHalfLengthYPosZ    , // h2
00047    TPFloat aHalfLengthZ        , // dz,  L/2
00048    TPFloat aAngleAD            , // alfa1
00049    TPFloat aCoord15X           , // x15
00050    TPFloat aCoord15Y             // y15
00051    ) 
00052 {
00053    m_dz  = aHalfLengthZ        ;
00054    m_h1  = aHalfLengthYNegZ    ;
00055    m_bl1 = aHalfLengthXNegZLoY ;
00056    m_h2  = aHalfLengthYPosZ    ;
00057    m_bl2 = aHalfLengthXPosZLoY ;
00058    m_tl2 = aHalfLengthXPosZHiY ;
00059 
00060    m_a1  = aAngleAD            ;
00061    m_y15 = aCoord15Y           ;
00062    m_x15 = aCoord15X           ;
00063 
00064    m_hAa = fabs( m_y15 ) ;
00065 
00066    m_L   = 2*m_dz  ;
00067    m_h   = 2*m_h2  ;
00068    m_a   = 2*m_bl2 ;
00069    m_b   = 2*m_tl2 ;
00070    m_H   = 2*m_h1  ;
00071    m_A   = 2*m_bl1 ;
00072 
00073    // derive everything else
00074    const TPFloat sina1 ( sin( m_a1 ) ) ;
00075    const TPFloat cosa1 ( cos( m_a1 ) ) ;
00076    const TPFloat tana1 ( tan( m_a1 - M_PI_2 ) ) ;
00077 
00078    const TPFloat tana4 ( ( m_tl2 - m_bl2 - m_h2*tana1 )/m_h2 ) ;
00079 
00080    m_a4  = M_PI_2 + atan( tana4 ) ;
00081 
00082    m_tl1 = m_bl1 + m_h1*( tana1 + tana4 ) ;
00083 
00084    m_d   = m_h/sina1 ;
00085    m_D   = m_H/sina1 ;
00086 
00087    const TPFloat tanalp1 ( ( m_D*cosa1 + m_tl1 - m_bl1 )/m_H ) ;
00088    const TPFloat tanalp2 ( ( m_d*cosa1 + m_tl2 - m_bl2 )/m_h ) ;
00089    m_alp1 = atan( tanalp1 ) ;
00090    m_alp2 = atan( tanalp2 ) ;
00091 
00092    const TPFloat sina4 ( sin( m_a4 ) ) ;
00093    m_c   = m_h/sina4 ;
00094    m_C   = m_H/sina4 ;
00095    m_B   = 2*m_tl1 ; // same as m_A - m_D*cosa1 - m_C*cos( m_a4 ) ;
00096 
00097    m_hDd = fabs( m_x15 )*sina1 - m_hAa*cosa1 ;
00098 
00099    const TPFloat xd5 ( ( m_hAa + m_hDd*cosa1 )/sina1 ) ;
00100    const TPFloat xd6 ( m_D - m_d - xd5 ) ;
00101    const TPFloat z6  ( sqrt( m_hDd*m_hDd + xd6*xd6 ) ) ;
00102    TPFloat gb6 ;
00103    if( 0. == z6 || 1. < fabs( m_hDd/z6 ) )
00104    {
00105       gb6 = 0 ;
00106    }
00107    else
00108    {
00109       gb6 = M_PI - m_a1 - asin( m_hDd/z6 ) ;
00110    }
00111    m_hBb = z6*sin( gb6 ) ;
00112 
00113    const TPFloat xb6 ( z6*cos( gb6 ) ) ;
00114    const TPFloat xb7 ( m_B - xb6 - m_b ) ;
00115    const TPFloat z7  ( sqrt( m_hBb*m_hBb + xb7*xb7 ) ) ;
00116    TPFloat gc7 ;
00117    if( 0 == z7 || 1. < fabs( m_hBb/z7 ) )
00118    {
00119       gc7 = 0 ;
00120    }
00121    else
00122    {
00123       gc7 = M_PI - m_a4 - asin( m_hBb/z7 ) ;   
00124    }
00125    m_hCc = z7*sin( gc7 ) ;
00126 
00127    const Pt3D fc ( m_bl2 + m_h2*tanalp2, m_h2, 0 ) ;
00128    const Pt3D v5 ( m_x15 , m_y15 , -m_L ) ;
00129    const Pt3D bc ( v5 + Pt3D ( m_bl1 + m_h1*tanalp1, m_h1, 0 ) ) ;
00130    const Pt3D dc ( fc - bc ) ;
00131 
00132    m_th  = dc.theta() ;
00133    m_ph  = dc.phi()   ;
00134 }
00135 //      m_hBb, m_hCc, m_hDd ;
00136 
00137 // EcalTrapezoidParameters::EcalTrapezoidParameters( const EcalTrapezoidParameters& rhs )
00138 // {
00139 //    // do actual copying here; if you implemented
00140 //    // operator= correctly, you may be able to use just say      
00141 //    *this = rhs;
00142 // }
00143 
00144 //EcalTrapezoidParameters::~EcalTrapezoidParameters()
00145 //{
00146 //}
00147 
00148 //
00149 // assignment operators
00150 //
00151 // const EcalTrapezoidParameters& EcalTrapezoidParameters::operator=( const EcalTrapezoidParameters& rhs )
00152 // {
00153 //   if( this != &rhs ) {
00154 //      // do actual copying here, plus:
00155 //      // "SuperClass"::operator=( rhs );
00156 //   }
00157 //
00158 //   return *this;
00159 // }
00160 
00161 //
00162 // member functions
00163 //
00164 
00165 //
00166 // const member functions
00167 //
00168 TPFloat EcalTrapezoidParameters::dz()    const { return m_dz   ; }
00169 TPFloat EcalTrapezoidParameters::theta() const { return m_th   ; }
00170 TPFloat EcalTrapezoidParameters::phi()   const { return m_ph   ; }
00171 TPFloat EcalTrapezoidParameters::h1()    const { return m_h1   ; }
00172 TPFloat EcalTrapezoidParameters::bl1()   const { return m_bl1  ; }
00173 TPFloat EcalTrapezoidParameters::tl1()   const { return m_tl1  ; }
00174 TPFloat EcalTrapezoidParameters::alp1()  const { return m_alp1 ; }
00175 TPFloat EcalTrapezoidParameters::h2()    const { return m_h2   ; }
00176 TPFloat EcalTrapezoidParameters::bl2()   const { return m_bl2  ; }
00177 TPFloat EcalTrapezoidParameters::tl2()   const { return m_tl2  ; }
00178 TPFloat EcalTrapezoidParameters::alp2()  const { return m_alp2 ; }
00179 
00180 TPFloat EcalTrapezoidParameters::x15()   const { return m_x15  ; }
00181 TPFloat EcalTrapezoidParameters::y15()   const { return m_y15  ; }
00182 TPFloat EcalTrapezoidParameters::hAa()   const { return m_hAa  ; }
00183 TPFloat EcalTrapezoidParameters::hBb()   const { return m_hBb  ; }
00184 TPFloat EcalTrapezoidParameters::hCc()   const { return m_hCc  ; }
00185 TPFloat EcalTrapezoidParameters::hDd()   const { return m_hDd  ; }
00186 TPFloat EcalTrapezoidParameters::a1()    const { return m_a1   ; }
00187 TPFloat EcalTrapezoidParameters::a4()    const { return m_a4   ; }
00188 TPFloat EcalTrapezoidParameters::L()     const { return m_L    ; }
00189 TPFloat EcalTrapezoidParameters::a()     const { return m_a    ; }
00190 TPFloat EcalTrapezoidParameters::b()     const { return m_b    ; }
00191 TPFloat EcalTrapezoidParameters::c()     const { return m_c    ; }
00192 TPFloat EcalTrapezoidParameters::d()     const { return m_d    ; }
00193 TPFloat EcalTrapezoidParameters::h()     const { return m_h    ; }
00194 TPFloat EcalTrapezoidParameters::A()     const { return m_A    ; }
00195 TPFloat EcalTrapezoidParameters::B()     const { return m_B    ; }
00196 TPFloat EcalTrapezoidParameters::C()     const { return m_C    ; }
00197 TPFloat EcalTrapezoidParameters::D()     const { return m_D    ; }
00198 TPFloat EcalTrapezoidParameters::H()     const { return m_H    ; }
00199 
00200 EcalTrapezoidParameters::VertexList
00201 EcalTrapezoidParameters::vertexList() const
00202 {
00203    VertexList vtx ;
00204    vtx.reserve( 8 ) ;
00205 
00206    const TPFloat dztanth ( dz()*tan( theta() ) ) ;
00207 
00208    const TPFloat ph ( phi() ) ;
00209    const Pt3D  fc ( dztanth*cos(ph), dztanth*sin(ph), dz() ) ;
00210 
00211    const TPFloat h_ ( h() ) ;
00212    const TPFloat H_ ( H() ) ;
00213    const TPFloat b_ ( b() ) ;
00214    const TPFloat B_ ( B() ) ;
00215    const TPFloat a_ ( a() ) ;
00216    const TPFloat A_ ( A() ) ;
00217 
00218 //   const TPFloat tl1 ( tl1() ) ;
00219 
00220    const TPFloat tanalp1 ( tan(alp1()) ) ;
00221 
00222    const TPFloat tanalp2 ( tan(alp2()) ) ;
00223 
00224    const TPFloat tana1   ( tan( a1() - M_PI_2 )  ) ;
00225 
00226    const Pt3D f1 ( -Pt3D( bl2() + h2()*tanalp2,  h2(), 0 ) ) ;
00227 
00228    const Pt3D f2 ( Pt3D( -h_*tana1, h_, 0 ) + f1 ) ;
00229 
00230    const Pt3D f3 ( f2 + Pt3D( b_,0,0 ) ) ;
00231 
00232    const Pt3D f4 ( Pt3D( a_,0,0 ) + f1 ) ;
00233 
00234 
00235    const Pt3D f5 ( -Pt3D( bl1() + h1()*tanalp1,  h1(),      0 ) ) ;
00236 
00237    const Pt3D f6 ( Pt3D( -H_*tana1, H_, 0 ) + f5 ) ;
00238 
00239    const Pt3D f7 ( f6 + Pt3D( B_,0,0 ) ) ;
00240 
00241    const Pt3D f8 ( Pt3D( A_,0,0 ) + f5 ) ;
00242 
00243    vtx.push_back(  fc + f1 ) ;
00244    vtx.push_back(  fc + f2 ) ;
00245    vtx.push_back(  fc + f3 ) ;
00246    vtx.push_back(  fc + f4 ) ;
00247    vtx.push_back( -fc + f5 ) ;
00248    vtx.push_back( -fc + f6 ) ;
00249    vtx.push_back( -fc + f7 ) ;
00250    vtx.push_back( -fc + f8 ) ;
00251 
00252    return vtx ;
00253 }
00254 //
00255 // static member functions
00256 //