CMS 3D CMS Logo

EcalTrapezoidParameters.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EcalCommonData
4 // Module: EcalTrapezoidParameters
5 //
6 // Description: Do trigonometry to figure out all useful dimensions/angles
7 //
8 // Implementation: Compute everything in constructor, put in member data
9 //
10 // Author: Brian K. Heltsley
11 // Created: Wed Aug 12 09:24:56 EDT 1998
12 //
13 
14 #include <cassert>
15 #include <cmath>
16 #include <algorithm>
17 
19 
23 
25  TPFloat aHalfLengthXNegZLoY , // bl1, A/2
26  TPFloat aHalfLengthXPosZLoY , // bl2
27  TPFloat aHalfLengthXPosZHiY , // tl2
28  TPFloat aHalfLengthYNegZ , // h1
29  TPFloat aHalfLengthYPosZ , // h2
30  TPFloat aHalfLengthZ , // dz, L/2
31  TPFloat aAngleAD , // alfa1
32  TPFloat aCoord15X , // x15
33  TPFloat aCoord15Y // y15
34  )
35 {
36  m_dz = aHalfLengthZ ;
37  m_h1 = aHalfLengthYNegZ ;
38  m_bl1 = aHalfLengthXNegZLoY ;
39  m_h2 = aHalfLengthYPosZ ;
40  m_bl2 = aHalfLengthXPosZLoY ;
41  m_tl2 = aHalfLengthXPosZHiY ;
42 
43  m_a1 = aAngleAD ;
44  m_y15 = aCoord15Y ;
45  m_x15 = aCoord15X ;
46 
47  m_hAa = fabs( m_y15 ) ;
48 
49  m_L = 2*m_dz ;
50  m_h = 2*m_h2 ;
51  m_a = 2*m_bl2 ;
52  m_b = 2*m_tl2 ;
53  m_H = 2*m_h1 ;
54  m_A = 2*m_bl1 ;
55 
56  // derive everything else
57  const TPFloat sina1 ( sin( m_a1 ) ) ;
58  const TPFloat cosa1 ( cos( m_a1 ) ) ;
59  const TPFloat tana1 ( tan( m_a1 - M_PI_2 ) ) ;
60 
61  const TPFloat tana4 ( ( m_tl2 - m_bl2 - m_h2*tana1 )/m_h2 ) ;
62 
63  m_a4 = M_PI_2 + atan( tana4 ) ;
64 
65  m_tl1 = m_bl1 + m_h1*( tana1 + tana4 ) ;
66 
67  m_d = m_h/sina1 ;
68  m_D = m_H/sina1 ;
69 
70  const TPFloat tanalp1 ( ( m_D*cosa1 + m_tl1 - m_bl1 )/m_H ) ;
71  const TPFloat tanalp2 ( ( m_d*cosa1 + m_tl2 - m_bl2 )/m_h ) ;
72  m_alp1 = atan( tanalp1 ) ;
73  m_alp2 = atan( tanalp2 ) ;
74 
75  const TPFloat sina4 ( sin( m_a4 ) ) ;
76  m_c = m_h/sina4 ;
77  m_C = m_H/sina4 ;
78  m_B = 2*m_tl1 ; // same as m_A - m_D*cosa1 - m_C*cos( m_a4 ) ;
79 
80  m_hDd = fabs( m_x15 )*sina1 - m_hAa*cosa1 ;
81 
82  const TPFloat xd5 ( ( m_hAa + m_hDd*cosa1 )/sina1 ) ;
83  const TPFloat xd6 ( m_D - m_d - xd5 ) ;
84  const TPFloat z6 ( sqrt( m_hDd*m_hDd + xd6*xd6 ) ) ;
85  TPFloat gb6 ;
86  if( 0. == z6 || 1. < fabs( m_hDd/z6 ) )
87  {
88  gb6 = 0 ;
89  }
90  else
91  {
92  gb6 = M_PI - m_a1 - asin( m_hDd/z6 ) ;
93  }
94  m_hBb = z6*sin( gb6 ) ;
95 
96  const TPFloat xb6 ( z6*cos( gb6 ) ) ;
97  const TPFloat xb7 ( m_B - xb6 - m_b ) ;
98  const TPFloat z7 ( sqrt( m_hBb*m_hBb + xb7*xb7 ) ) ;
99  TPFloat gc7 ;
100  if( 0 == z7 || 1. < fabs( m_hBb/z7 ) )
101  {
102  gc7 = 0 ;
103  }
104  else
105  {
106  gc7 = M_PI - m_a4 - asin( m_hBb/z7 ) ;
107  }
108  m_hCc = z7*sin( gc7 ) ;
109 
110  const Pt3D fc ( m_bl2 + m_h2*tanalp2, m_h2, 0 ) ;
111  const Pt3D v5 ( m_x15 , m_y15 , -m_L ) ;
112  const Pt3D bc ( v5 + Pt3D ( m_bl1 + m_h1*tanalp1, m_h1, 0 ) ) ;
113  const Pt3D dc ( fc - bc ) ;
114 
115  m_th = dc.theta() ;
116  m_ph = dc.phi() ;
117 }
118 // m_hBb, m_hCc, m_hDd ;
119 
120 // EcalTrapezoidParameters::EcalTrapezoidParameters( const EcalTrapezoidParameters& rhs )
121 // {
122 // // do actual copying here; if you implemented
123 // // operator= correctly, you may be able to use just say
124 // *this = rhs;
125 // }
126 
127 //EcalTrapezoidParameters::~EcalTrapezoidParameters()
128 //{
129 //}
130 
131 //
132 // assignment operators
133 //
134 // const EcalTrapezoidParameters& EcalTrapezoidParameters::operator=( const EcalTrapezoidParameters& rhs )
135 // {
136 // if( this != &rhs ) {
137 // // do actual copying here, plus:
138 // // "SuperClass"::operator=( rhs );
139 // }
140 //
141 // return *this;
142 // }
143 
144 //
145 // member functions
146 //
147 
148 //
149 // const member functions
150 //
162 
182 
185 {
186  VertexList vtx ;
187  vtx.reserve( 8 ) ;
188 
189  const TPFloat dztanth ( dz()*tan( theta() ) ) ;
190 
191  const TPFloat ph ( phi() ) ;
192  const Pt3D fc ( dztanth*cos(ph), dztanth*sin(ph), dz() ) ;
193 
194  const TPFloat h_ ( h() ) ;
195  const TPFloat H_ ( H() ) ;
196  const TPFloat b_ ( b() ) ;
197  const TPFloat B_ ( B() ) ;
198  const TPFloat a_ ( a() ) ;
199  const TPFloat A_ ( A() ) ;
200 
201 // const TPFloat tl1 ( tl1() ) ;
202 
203  const TPFloat tanalp1 ( tan(alp1()) ) ;
204 
205  const TPFloat tanalp2 ( tan(alp2()) ) ;
206 
207  const TPFloat tana1 ( tan( a1() - M_PI_2 ) ) ;
208 
209  const Pt3D f1 ( -Pt3D( bl2() + h2()*tanalp2, h2(), 0 ) ) ;
210 
211  const Pt3D f2 ( Pt3D( -h_*tana1, h_, 0 ) + f1 ) ;
212 
213  const Pt3D f3 ( f2 + Pt3D( b_,0,0 ) ) ;
214 
215  const Pt3D f4 ( Pt3D( a_,0,0 ) + f1 ) ;
216 
217 
218  const Pt3D f5 ( -Pt3D( bl1() + h1()*tanalp1, h1(), 0 ) ) ;
219 
220  const Pt3D f6 ( Pt3D( -H_*tana1, H_, 0 ) + f5 ) ;
221 
222  const Pt3D f7 ( f6 + Pt3D( B_,0,0 ) ) ;
223 
224  const Pt3D f8 ( Pt3D( A_,0,0 ) + f5 ) ;
225 
226  vtx.emplace_back( fc + f1 ) ;
227  vtx.emplace_back( fc + f2 ) ;
228  vtx.emplace_back( fc + f3 ) ;
229  vtx.emplace_back( fc + f4 ) ;
230  vtx.emplace_back( -fc + f5 ) ;
231  vtx.emplace_back( -fc + f6 ) ;
232  vtx.emplace_back( -fc + f7 ) ;
233  vtx.emplace_back( -fc + f8 ) ;
234 
235  return vtx ;
236 }
237 //
238 // static member functions
239 //
EcalTrapezoidParameters()=delete
EcalTrapezoidParameters::VertexList VertexList
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define M_PI_2
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
EcalTrapezoidParameters::TPFloat TPFloat
CaloCellGeometry::CCGFloat TPFloat
#define M_PI
CaloCellGeometry::Pt3D Pt3D
HepGeom::Point3D< CCGFloat > Pt3D
CaloCellGeometry::Pt3D Pt3D
CaloCellGeometry::Pt3DVec VertexList