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 aHalfLengthXPosZLoY, // bl2
26  TPFloat aHalfLengthXPosZHiY, // tl2
27  TPFloat aHalfLengthYNegZ, // h1
28  TPFloat aHalfLengthYPosZ, // h2
29  TPFloat aHalfLengthZ, // dz, L/2
30  TPFloat aAngleAD, // alfa1
31  TPFloat aCoord15X, // x15
32  TPFloat aCoord15Y // y15
33 ) {
34  m_dz = aHalfLengthZ;
35  m_h1 = aHalfLengthYNegZ;
36  m_bl1 = aHalfLengthXNegZLoY;
37  m_h2 = aHalfLengthYPosZ;
38  m_bl2 = aHalfLengthXPosZLoY;
39  m_tl2 = aHalfLengthXPosZHiY;
40 
41  m_a1 = aAngleAD;
42  m_y15 = aCoord15Y;
43  m_x15 = aCoord15X;
44 
45  m_hAa = fabs(m_y15);
46 
47  m_L = 2 * m_dz;
48  m_h = 2 * m_h2;
49  m_a = 2 * m_bl2;
50  m_b = 2 * m_tl2;
51  m_H = 2 * m_h1;
52  m_A = 2 * m_bl1;
53 
54  // derive everything else
55  const TPFloat sina1(sin(m_a1));
56  const TPFloat cosa1(cos(m_a1));
57  const TPFloat tana1(tan(m_a1 - M_PI_2));
58 
59  const TPFloat tana4((m_tl2 - m_bl2 - m_h2 * tana1) / m_h2);
60 
61  m_a4 = M_PI_2 + atan(tana4);
62 
63  m_tl1 = m_bl1 + m_h1 * (tana1 + tana4);
64 
65  m_d = m_h / sina1;
66  m_D = m_H / sina1;
67 
68  const TPFloat tanalp1((m_D * cosa1 + m_tl1 - m_bl1) / m_H);
69  const TPFloat tanalp2((m_d * cosa1 + m_tl2 - m_bl2) / m_h);
70  m_alp1 = atan(tanalp1);
71  m_alp2 = atan(tanalp2);
72 
73  const TPFloat sina4(sin(m_a4));
74  m_c = m_h / sina4;
75  m_C = m_H / sina4;
76  m_B = 2 * m_tl1; // same as m_A - m_D*cosa1 - m_C*cos( m_a4 ) ;
77 
78  m_hDd = fabs(m_x15) * sina1 - m_hAa * cosa1;
79 
80  const TPFloat xd5((m_hAa + m_hDd * cosa1) / sina1);
81  const TPFloat xd6(m_D - m_d - xd5);
82  const TPFloat z6(sqrt(m_hDd * m_hDd + xd6 * xd6));
83  TPFloat gb6;
84  if (0. == z6 || 1. < fabs(m_hDd / z6)) {
85  gb6 = 0;
86  } else {
87  gb6 = M_PI - m_a1 - asin(m_hDd / z6);
88  }
89  m_hBb = z6 * sin(gb6);
90 
91  const TPFloat xb6(z6 * cos(gb6));
92  const TPFloat xb7(m_B - xb6 - m_b);
93  const TPFloat z7(sqrt(m_hBb * m_hBb + xb7 * xb7));
94  TPFloat gc7;
95  if (0 == z7 || 1. < fabs(m_hBb / z7)) {
96  gc7 = 0;
97  } else {
98  gc7 = M_PI - m_a4 - asin(m_hBb / z7);
99  }
100  m_hCc = z7 * sin(gc7);
101 
102  const Pt3D fc(m_bl2 + m_h2 * tanalp2, m_h2, 0);
103  const Pt3D v5(m_x15, m_y15, -m_L);
104  const Pt3D bc(v5 + Pt3D(m_bl1 + m_h1 * tanalp1, m_h1, 0));
105  const Pt3D dc(fc - bc);
106 
107  m_th = dc.theta();
108  m_ph = dc.phi();
109 }
110 // m_hBb, m_hCc, m_hDd ;
111 
112 // EcalTrapezoidParameters::EcalTrapezoidParameters( const EcalTrapezoidParameters& rhs )
113 // {
114 // // do actual copying here; if you implemented
115 // // operator= correctly, you may be able to use just say
116 // *this = rhs;
117 // }
118 
119 //EcalTrapezoidParameters::~EcalTrapezoidParameters()
120 //{
121 //}
122 
123 //
124 // assignment operators
125 //
126 // const EcalTrapezoidParameters& EcalTrapezoidParameters::operator=( const EcalTrapezoidParameters& rhs )
127 // {
128 // if( this != &rhs ) {
129 // // do actual copying here, plus:
130 // // "SuperClass"::operator=( rhs );
131 // }
132 //
133 // return *this;
134 // }
135 
136 //
137 // member functions
138 //
139 
140 //
141 // const member functions
142 //
154 
174 
176  VertexList vtx;
177  vtx.reserve(8);
178 
179  const TPFloat dztanth(dz() * tan(theta()));
180 
181  const TPFloat ph(phi());
182  const Pt3D fc(dztanth * cos(ph), dztanth * sin(ph), dz());
183 
184  const TPFloat h_(h());
185  const TPFloat H_(H());
186  const TPFloat b_(b());
187  const TPFloat B_(B());
188  const TPFloat a_(a());
189  const TPFloat A_(A());
190 
191  // const TPFloat tl1 ( tl1() ) ;
192 
193  const TPFloat tanalp1(tan(alp1()));
194 
195  const TPFloat tanalp2(tan(alp2()));
196 
197  const TPFloat tana1(tan(a1() - M_PI_2));
198 
199  const Pt3D f1(-Pt3D(bl2() + h2() * tanalp2, h2(), 0));
200 
201  const Pt3D f2(Pt3D(-h_ * tana1, h_, 0) + f1);
202 
203  const Pt3D f3(f2 + Pt3D(b_, 0, 0));
204 
205  const Pt3D f4(Pt3D(a_, 0, 0) + f1);
206 
207  const Pt3D f5(-Pt3D(bl1() + h1() * tanalp1, h1(), 0));
208 
209  const Pt3D f6(Pt3D(-H_ * tana1, H_, 0) + f5);
210 
211  const Pt3D f7(f6 + Pt3D(B_, 0, 0));
212 
213  const Pt3D f8(Pt3D(A_, 0, 0) + f5);
214 
215  vtx.emplace_back(fc + f1);
216  vtx.emplace_back(fc + f2);
217  vtx.emplace_back(fc + f3);
218  vtx.emplace_back(fc + f4);
219  vtx.emplace_back(-fc + f5);
220  vtx.emplace_back(-fc + f6);
221  vtx.emplace_back(-fc + f7);
222  vtx.emplace_back(-fc + f8);
223 
224  return vtx;
225 }
226 //
227 // static member functions
228 //
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:19
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