Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:07:40

0001 // -*- C++ -*-
0002 //
0003 // Package:     EcalCommonData
0004 // Module:      EcalTrapezoidParameters
0005 //
0006 // Description: Do trigonometry to figure out all useful dimensions/angles
0007 //
0008 // Implementation: Compute everything in constructor, put in member data
0009 //
0010 // Author:      Brian K. Heltsley
0011 // Created:     Wed Aug 12 09:24:56 EDT 1998
0012 //
0013 
0014 #include <cassert>
0015 #include <cmath>
0016 #include <algorithm>
0017 
0018 #include "Geometry/CaloGeometry/interface/EcalTrapezoidParameters.h"
0019 
0020 typedef EcalTrapezoidParameters::TPFloat TPFloat;
0021 typedef EcalTrapezoidParameters::VertexList VertexList;
0022 typedef CaloCellGeometry::Pt3D Pt3D;
0023 
0024 EcalTrapezoidParameters::EcalTrapezoidParameters(TPFloat aHalfLengthXNegZLoY,  // bl1, A/2
0025                                                  TPFloat aHalfLengthXPosZLoY,  // bl2
0026                                                  TPFloat aHalfLengthXPosZHiY,  // tl2
0027                                                  TPFloat aHalfLengthYNegZ,     // h1
0028                                                  TPFloat aHalfLengthYPosZ,     // h2
0029                                                  TPFloat aHalfLengthZ,         // dz,  L/2
0030                                                  TPFloat aAngleAD,             // alfa1
0031                                                  TPFloat aCoord15X,            // x15
0032                                                  TPFloat aCoord15Y             // y15
0033 ) {
0034   m_dz = aHalfLengthZ;
0035   m_h1 = aHalfLengthYNegZ;
0036   m_bl1 = aHalfLengthXNegZLoY;
0037   m_h2 = aHalfLengthYPosZ;
0038   m_bl2 = aHalfLengthXPosZLoY;
0039   m_tl2 = aHalfLengthXPosZHiY;
0040 
0041   m_a1 = aAngleAD;
0042   m_y15 = aCoord15Y;
0043   m_x15 = aCoord15X;
0044 
0045   m_hAa = fabs(m_y15);
0046 
0047   m_L = 2 * m_dz;
0048   m_h = 2 * m_h2;
0049   m_a = 2 * m_bl2;
0050   m_b = 2 * m_tl2;
0051   m_H = 2 * m_h1;
0052   m_A = 2 * m_bl1;
0053 
0054   // derive everything else
0055   const TPFloat sina1(sin(m_a1));
0056   const TPFloat cosa1(cos(m_a1));
0057   const TPFloat tana1(tan(m_a1 - M_PI_2));
0058 
0059   const TPFloat tana4((m_tl2 - m_bl2 - m_h2 * tana1) / m_h2);
0060 
0061   m_a4 = M_PI_2 + atan(tana4);
0062 
0063   m_tl1 = m_bl1 + m_h1 * (tana1 + tana4);
0064 
0065   m_d = m_h / sina1;
0066   m_D = m_H / sina1;
0067 
0068   const TPFloat tanalp1((m_D * cosa1 + m_tl1 - m_bl1) / m_H);
0069   const TPFloat tanalp2((m_d * cosa1 + m_tl2 - m_bl2) / m_h);
0070   m_alp1 = atan(tanalp1);
0071   m_alp2 = atan(tanalp2);
0072 
0073   const TPFloat sina4(sin(m_a4));
0074   m_c = m_h / sina4;
0075   m_C = m_H / sina4;
0076   m_B = 2 * m_tl1;  // same as m_A - m_D*cosa1 - m_C*cos( m_a4 ) ;
0077 
0078   m_hDd = fabs(m_x15) * sina1 - m_hAa * cosa1;
0079 
0080   const TPFloat xd5((m_hAa + m_hDd * cosa1) / sina1);
0081   const TPFloat xd6(m_D - m_d - xd5);
0082   const TPFloat z6(sqrt(m_hDd * m_hDd + xd6 * xd6));
0083   TPFloat gb6;
0084   if (0. == z6 || 1. < fabs(m_hDd / z6)) {
0085     gb6 = 0;
0086   } else {
0087     gb6 = M_PI - m_a1 - asin(m_hDd / z6);
0088   }
0089   m_hBb = z6 * sin(gb6);
0090 
0091   const TPFloat xb6(z6 * cos(gb6));
0092   const TPFloat xb7(m_B - xb6 - m_b);
0093   const TPFloat z7(sqrt(m_hBb * m_hBb + xb7 * xb7));
0094   TPFloat gc7;
0095   if (0 == z7 || 1. < fabs(m_hBb / z7)) {
0096     gc7 = 0;
0097   } else {
0098     gc7 = M_PI - m_a4 - asin(m_hBb / z7);
0099   }
0100   m_hCc = z7 * sin(gc7);
0101 
0102   const Pt3D fc(m_bl2 + m_h2 * tanalp2, m_h2, 0);
0103   const Pt3D v5(m_x15, m_y15, -m_L);
0104   const Pt3D bc(v5 + Pt3D(m_bl1 + m_h1 * tanalp1, m_h1, 0));
0105   const Pt3D dc(fc - bc);
0106 
0107   m_th = dc.theta();
0108   m_ph = dc.phi();
0109 }
0110 //      m_hBb, m_hCc, m_hDd ;
0111 
0112 // EcalTrapezoidParameters::EcalTrapezoidParameters( const EcalTrapezoidParameters& rhs )
0113 // {
0114 //    // do actual copying here; if you implemented
0115 //    // operator= correctly, you may be able to use just say
0116 //    *this = rhs;
0117 // }
0118 
0119 //EcalTrapezoidParameters::~EcalTrapezoidParameters()
0120 //{
0121 //}
0122 
0123 //
0124 // assignment operators
0125 //
0126 // const EcalTrapezoidParameters& EcalTrapezoidParameters::operator=( const EcalTrapezoidParameters& rhs )
0127 // {
0128 //   if( this != &rhs ) {
0129 //      // do actual copying here, plus:
0130 //      // "SuperClass"::operator=( rhs );
0131 //   }
0132 //
0133 //   return *this;
0134 // }
0135 
0136 //
0137 // member functions
0138 //
0139 
0140 //
0141 // const member functions
0142 //
0143 TPFloat EcalTrapezoidParameters::dz() const { return m_dz; }
0144 TPFloat EcalTrapezoidParameters::theta() const { return m_th; }
0145 TPFloat EcalTrapezoidParameters::phi() const { return m_ph; }
0146 TPFloat EcalTrapezoidParameters::h1() const { return m_h1; }
0147 TPFloat EcalTrapezoidParameters::bl1() const { return m_bl1; }
0148 TPFloat EcalTrapezoidParameters::tl1() const { return m_tl1; }
0149 TPFloat EcalTrapezoidParameters::alp1() const { return m_alp1; }
0150 TPFloat EcalTrapezoidParameters::h2() const { return m_h2; }
0151 TPFloat EcalTrapezoidParameters::bl2() const { return m_bl2; }
0152 TPFloat EcalTrapezoidParameters::tl2() const { return m_tl2; }
0153 TPFloat EcalTrapezoidParameters::alp2() const { return m_alp2; }
0154 
0155 TPFloat EcalTrapezoidParameters::x15() const { return m_x15; }
0156 TPFloat EcalTrapezoidParameters::y15() const { return m_y15; }
0157 TPFloat EcalTrapezoidParameters::hAa() const { return m_hAa; }
0158 TPFloat EcalTrapezoidParameters::hBb() const { return m_hBb; }
0159 TPFloat EcalTrapezoidParameters::hCc() const { return m_hCc; }
0160 TPFloat EcalTrapezoidParameters::hDd() const { return m_hDd; }
0161 TPFloat EcalTrapezoidParameters::a1() const { return m_a1; }
0162 TPFloat EcalTrapezoidParameters::a4() const { return m_a4; }
0163 TPFloat EcalTrapezoidParameters::L() const { return m_L; }
0164 TPFloat EcalTrapezoidParameters::a() const { return m_a; }
0165 TPFloat EcalTrapezoidParameters::b() const { return m_b; }
0166 TPFloat EcalTrapezoidParameters::c() const { return m_c; }
0167 TPFloat EcalTrapezoidParameters::d() const { return m_d; }
0168 TPFloat EcalTrapezoidParameters::h() const { return m_h; }
0169 TPFloat EcalTrapezoidParameters::A() const { return m_A; }
0170 TPFloat EcalTrapezoidParameters::B() const { return m_B; }
0171 TPFloat EcalTrapezoidParameters::C() const { return m_C; }
0172 TPFloat EcalTrapezoidParameters::D() const { return m_D; }
0173 TPFloat EcalTrapezoidParameters::H() const { return m_H; }
0174 
0175 EcalTrapezoidParameters::VertexList EcalTrapezoidParameters::vertexList() const {
0176   VertexList vtx;
0177   vtx.reserve(8);
0178 
0179   const TPFloat dztanth(dz() * tan(theta()));
0180 
0181   const TPFloat ph(phi());
0182   const Pt3D fc(dztanth * cos(ph), dztanth * sin(ph), dz());
0183 
0184   const TPFloat h_(h());
0185   const TPFloat H_(H());
0186   const TPFloat b_(b());
0187   const TPFloat B_(B());
0188   const TPFloat a_(a());
0189   const TPFloat A_(A());
0190 
0191   //   const TPFloat tl1 ( tl1() ) ;
0192 
0193   const TPFloat tanalp1(tan(alp1()));
0194 
0195   const TPFloat tanalp2(tan(alp2()));
0196 
0197   const TPFloat tana1(tan(a1() - M_PI_2));
0198 
0199   const Pt3D f1(-Pt3D(bl2() + h2() * tanalp2, h2(), 0));
0200 
0201   const Pt3D f2(Pt3D(-h_ * tana1, h_, 0) + f1);
0202 
0203   const Pt3D f3(f2 + Pt3D(b_, 0, 0));
0204 
0205   const Pt3D f4(Pt3D(a_, 0, 0) + f1);
0206 
0207   const Pt3D f5(-Pt3D(bl1() + h1() * tanalp1, h1(), 0));
0208 
0209   const Pt3D f6(Pt3D(-H_ * tana1, H_, 0) + f5);
0210 
0211   const Pt3D f7(f6 + Pt3D(B_, 0, 0));
0212 
0213   const Pt3D f8(Pt3D(A_, 0, 0) + f5);
0214 
0215   vtx.emplace_back(fc + f1);
0216   vtx.emplace_back(fc + f2);
0217   vtx.emplace_back(fc + f3);
0218   vtx.emplace_back(fc + f4);
0219   vtx.emplace_back(-fc + f5);
0220   vtx.emplace_back(-fc + f6);
0221   vtx.emplace_back(-fc + f7);
0222   vtx.emplace_back(-fc + f8);
0223 
0224   return vtx;
0225 }
0226 //
0227 // static member functions
0228 //