CMS 3D CMS Logo

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