CMS 3D CMS Logo

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

Generated on Tue Jun 9 17:37:17 2009 for CMSSW by  doxygen 1.5.4