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