CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // system include files
15 #include <assert.h>
16 #include <cmath>
17 #include <algorithm>
18 
19 // user include files
21 
25 
26 // STL classes
27 
28 //
29 // constants, enums and typedefs
30 //
31 
32 //static const char* const kReport = "DetectorGeometry.DGTrapezoidParameters" ;
33 
34 //
35 // static data member definitions
36 //
37 
38 //
39 // constructors and destructor
40 //
42  TPFloat aHalfLengthXNegZLoY , // bl1, A/2
43  TPFloat aHalfLengthXPosZLoY , // bl2
44  TPFloat aHalfLengthXPosZHiY , // tl2
45  TPFloat aHalfLengthYNegZ , // h1
46  TPFloat aHalfLengthYPosZ , // h2
47  TPFloat aHalfLengthZ , // dz, L/2
48  TPFloat aAngleAD , // alfa1
49  TPFloat aCoord15X , // x15
50  TPFloat aCoord15Y // y15
51  )
52 {
53  m_dz = aHalfLengthZ ;
54  m_h1 = aHalfLengthYNegZ ;
55  m_bl1 = aHalfLengthXNegZLoY ;
56  m_h2 = aHalfLengthYPosZ ;
57  m_bl2 = aHalfLengthXPosZLoY ;
58  m_tl2 = aHalfLengthXPosZHiY ;
59 
60  m_a1 = aAngleAD ;
61  m_y15 = aCoord15Y ;
62  m_x15 = aCoord15X ;
63 
64  m_hAa = fabs( m_y15 ) ;
65 
66  m_L = 2*m_dz ;
67  m_h = 2*m_h2 ;
68  m_a = 2*m_bl2 ;
69  m_b = 2*m_tl2 ;
70  m_H = 2*m_h1 ;
71  m_A = 2*m_bl1 ;
72 
73  // derive everything else
74  const TPFloat sina1 ( sin( m_a1 ) ) ;
75  const TPFloat cosa1 ( cos( m_a1 ) ) ;
76  const TPFloat tana1 ( tan( m_a1 - M_PI_2 ) ) ;
77 
78  const TPFloat tana4 ( ( m_tl2 - m_bl2 - m_h2*tana1 )/m_h2 ) ;
79 
80  m_a4 = M_PI_2 + atan( tana4 ) ;
81 
82  m_tl1 = m_bl1 + m_h1*( tana1 + tana4 ) ;
83 
84  m_d = m_h/sina1 ;
85  m_D = m_H/sina1 ;
86 
87  const TPFloat tanalp1 ( ( m_D*cosa1 + m_tl1 - m_bl1 )/m_H ) ;
88  const TPFloat tanalp2 ( ( m_d*cosa1 + m_tl2 - m_bl2 )/m_h ) ;
89  m_alp1 = atan( tanalp1 ) ;
90  m_alp2 = atan( tanalp2 ) ;
91 
92  const TPFloat sina4 ( sin( m_a4 ) ) ;
93  m_c = m_h/sina4 ;
94  m_C = m_H/sina4 ;
95  m_B = 2*m_tl1 ; // same as m_A - m_D*cosa1 - m_C*cos( m_a4 ) ;
96 
97  m_hDd = fabs( m_x15 )*sina1 - m_hAa*cosa1 ;
98 
99  const TPFloat xd5 ( ( m_hAa + m_hDd*cosa1 )/sina1 ) ;
100  const TPFloat xd6 ( m_D - m_d - xd5 ) ;
101  const TPFloat z6 ( sqrt( m_hDd*m_hDd + xd6*xd6 ) ) ;
102  TPFloat gb6 ;
103  if( 0. == z6 || 1. < fabs( m_hDd/z6 ) )
104  {
105  gb6 = 0 ;
106  }
107  else
108  {
109  gb6 = M_PI - m_a1 - asin( m_hDd/z6 ) ;
110  }
111  m_hBb = z6*sin( gb6 ) ;
112 
113  const TPFloat xb6 ( z6*cos( gb6 ) ) ;
114  const TPFloat xb7 ( m_B - xb6 - m_b ) ;
115  const TPFloat z7 ( sqrt( m_hBb*m_hBb + xb7*xb7 ) ) ;
116  TPFloat gc7 ;
117  if( 0 == z7 || 1. < fabs( m_hBb/z7 ) )
118  {
119  gc7 = 0 ;
120  }
121  else
122  {
123  gc7 = M_PI - m_a4 - asin( m_hBb/z7 ) ;
124  }
125  m_hCc = z7*sin( gc7 ) ;
126 
127  const Pt3D fc ( m_bl2 + m_h2*tanalp2, m_h2, 0 ) ;
128  const Pt3D v5 ( m_x15 , m_y15 , -m_L ) ;
129  const Pt3D bc ( v5 + Pt3D ( m_bl1 + m_h1*tanalp1, m_h1, 0 ) ) ;
130  const Pt3D dc ( fc - bc ) ;
131 
132  m_th = dc.theta() ;
133  m_ph = dc.phi() ;
134 }
135 // m_hBb, m_hCc, m_hDd ;
136 
137 // EcalTrapezoidParameters::EcalTrapezoidParameters( const EcalTrapezoidParameters& rhs )
138 // {
139 // // do actual copying here; if you implemented
140 // // operator= correctly, you may be able to use just say
141 // *this = rhs;
142 // }
143 
144 //EcalTrapezoidParameters::~EcalTrapezoidParameters()
145 //{
146 //}
147 
148 //
149 // assignment operators
150 //
151 // const EcalTrapezoidParameters& EcalTrapezoidParameters::operator=( const EcalTrapezoidParameters& rhs )
152 // {
153 // if( this != &rhs ) {
154 // // do actual copying here, plus:
155 // // "SuperClass"::operator=( rhs );
156 // }
157 //
158 // return *this;
159 // }
160 
161 //
162 // member functions
163 //
164 
165 //
166 // const member functions
167 //
179 
199 
202 {
203  VertexList vtx ;
204  vtx.reserve( 8 ) ;
205 
206  const TPFloat dztanth ( dz()*tan( theta() ) ) ;
207 
208  const TPFloat ph ( phi() ) ;
209  const Pt3D fc ( dztanth*cos(ph), dztanth*sin(ph), dz() ) ;
210 
211  const TPFloat h_ ( h() ) ;
212  const TPFloat H_ ( H() ) ;
213  const TPFloat b_ ( b() ) ;
214  const TPFloat B_ ( B() ) ;
215  const TPFloat a_ ( a() ) ;
216  const TPFloat A_ ( A() ) ;
217 
218 // const TPFloat tl1 ( tl1() ) ;
219 
220  const TPFloat tanalp1 ( tan(alp1()) ) ;
221 
222  const TPFloat tanalp2 ( tan(alp2()) ) ;
223 
224  const TPFloat tana1 ( tan( a1() - M_PI_2 ) ) ;
225 
226  const Pt3D f1 ( -Pt3D( bl2() + h2()*tanalp2, h2(), 0 ) ) ;
227 
228  const Pt3D f2 ( Pt3D( -h_*tana1, h_, 0 ) + f1 ) ;
229 
230  const Pt3D f3 ( f2 + Pt3D( b_,0,0 ) ) ;
231 
232  const Pt3D f4 ( Pt3D( a_,0,0 ) + f1 ) ;
233 
234 
235  const Pt3D f5 ( -Pt3D( bl1() + h1()*tanalp1, h1(), 0 ) ) ;
236 
237  const Pt3D f6 ( Pt3D( -H_*tana1, H_, 0 ) + f5 ) ;
238 
239  const Pt3D f7 ( f6 + Pt3D( B_,0,0 ) ) ;
240 
241  const Pt3D f8 ( Pt3D( A_,0,0 ) + f5 ) ;
242 
243  vtx.push_back( fc + f1 ) ;
244  vtx.push_back( fc + f2 ) ;
245  vtx.push_back( fc + f3 ) ;
246  vtx.push_back( fc + f4 ) ;
247  vtx.push_back( -fc + f5 ) ;
248  vtx.push_back( -fc + f6 ) ;
249  vtx.push_back( -fc + f7 ) ;
250  vtx.push_back( -fc + f8 ) ;
251 
252  return vtx ;
253 }
254 //
255 // static member functions
256 //
EcalTrapezoidParameters::VertexList VertexList
CaloCellGeometry::Pt3DVec VertexList
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define M_PI_2
T sqrt(T t)
Definition: SSEVec.h:48
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::Pt3D Pt3D
CaloCellGeometry::CCGFloat TPFloat
#define M_PI
Definition: BFit3D.cc:3
HepGeom::Point3D< CCGFloat > Pt3D