BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MucGeometron.cxx
Go to the documentation of this file.
1//$id$
2//
3//$log$
4
5/*
6 * 2003/08/30 Zhengyun You Peking University
7 *
8 * 2004/09/09 Zhengyun You Peking University
9 * transplanted to Gaudi framework
10 */
11
12using namespace std;
13
14#include "MucGeomSvc/MucGeometron.h"
15
17 // Constructor.
18}
19
21 // Destructor.
22}
23
24bool MucGeometron::GetIntersectionLinePlane( const HepPoint3D pLine, const Hep3Vector vectLine,
25 const HepPlane3D plane, HepPoint3D& cross ) {
26 // Given a line by basepoint linePoint and direction lineDir,
27 // find the intersection with the plane.
28 HepPoint3D linePoint = pLine;
29 Hep3Vector lineDir = vectLine;
30
31 HepPoint3D planePoint = plane.point();
32 Hep3Vector planeDir( plane.a(), plane.b(), plane.c() );
33
34 lineDir.setMag( 1.0 );
35 planeDir.setMag( 1.0 );
36
37 // Vector connecting the basepoint.
38 HepPoint3D basePoint = planePoint - linePoint;
39
40 double distance, denominator; // d , cos(theta).
41
42 denominator = planeDir.dot( lineDir );
43
44 if ( denominator != 0 )
45 {
46 // Line and gap are not parallel.
47 distance = ( planeDir.dot( basePoint ) ) / denominator;
48 cross = linePoint + lineDir * distance;
49 return 1;
50 }
51 else
52 {
53 // Line and gap are parrellel.
54 // cout << " Line is parrellel to plane! No intersect point found!" << endl;
55 return 0;
56 }
57}
58
60 const HepPoint3D pLine, const Hep3Vector vectLine, const HepPoint3D pLineSigma,
61 const Hep3Vector vectLineSigma, const HepPlane3D plane, HepPoint3D& cross,
62 HepPoint3D& crossSigma ) {
63 HepPoint3D linePoint = pLine;
64 Hep3Vector lineDir = vectLine;
65
66 HepPoint3D planePoint = plane.point();
67 Hep3Vector planeDir( plane.a(), plane.b(), plane.c() );
68
69 lineDir.setMag( 1.0 );
70 planeDir.setMag( 1.0 );
71 HepPoint3D basePoint = planePoint - linePoint;
72
73 double distance, denominator; // d , cos(theta).
74
75 denominator = planeDir.dot( lineDir );
76 if ( denominator != 0 )
77 {
78 distance = ( planeDir.dot( basePoint ) ) / denominator;
79 cross = linePoint + lineDir * distance;
80
81 // calculation of the uncertainty in intercept
82
83 double x0 = pLine.x();
84 double y0 = pLine.y();
85 double z0 = pLine.z();
86
87 double vx = vectLine.x();
88 double vy = vectLine.y();
89 double vz = vectLine.z();
90
91 double dx0 = pLineSigma.x();
92 double dy0 = pLineSigma.y();
93 double dz0 = pLineSigma.z();
94
95 double dvx = vectLineSigma.x();
96 double dvy = vectLineSigma.y();
97 double dvz = vectLineSigma.z();
98
99 double pa = plane.a();
100 double pb = plane.b();
101 double pc = plane.c();
102
103 double Const1 = planeDir.dot( planePoint );
104 double Const2 = pa * vx + pb * vy + pc * vz;
105 double Const3 = pa * x0 + pb * y0 + pc * z0;
106
107 double sigmaX_1 = dx0 * dx0 * ( pb * vy + pc * vz ) / Const2;
108 double sigmaX_2 = ( -1 ) * dy0 * dy0 * pb * vx / Const2;
109 double sigmaX_3 = ( -1 ) * dz0 * dz0 * pc * vx / Const2;
110 double sigmaX_4 =
111 dvx * dvx * ( Const1 - Const3 ) * ( pb * vy + pc * vz ) / Const2 / Const2;
112 double sigmaX_5 = ( -1 ) * dvy * dvy * vx * ( Const1 - Const3 ) * pb / Const2 / Const2;
113 double sigmaX_6 = ( -1 ) * dvz * dvz * vx * ( Const1 - Const3 ) * pc / Const2 / Const2;
114
115 double sigmaX = sigmaX_1 + sigmaX_2 + sigmaX_3 + sigmaX_4 + sigmaX_5 + sigmaX_6;
116
117 double sigmaY_1 = ( -1 ) * dx0 * dx0 * pa * vy / Const2;
118 double sigmaY_2 = dy0 * dy0 * ( 1 - pb * vy / Const2 );
119 double sigmaY_3 = ( -1 ) * dz0 * dz0 * pc * vy / Const2;
120 double sigmaY_4 = ( -1 ) * dvx * dvx * ( Const1 - Const3 ) * pa * vy / Const2 / Const2;
121 double sigmaY_5 =
122 dvy * dvy * ( Const1 - Const3 ) * ( pa * vx + pc * vz ) / Const2 / Const2;
123 double sigmaY_6 = ( -1 ) * dvz * dvz * ( Const1 - Const3 ) * pc * vy / Const2 / Const2;
124
125 double sigmaY = sigmaY_1 + sigmaY_2 + sigmaY_3 + sigmaY_4 + sigmaY_5 + sigmaY_6;
126
127 double sigmaZ_1 = ( -1 ) * dx0 * dx0 * pa * vz / Const2;
128 double sigmaZ_2 = ( -1 ) * dy0 * dy0 * pb * vz / Const2;
129 double sigmaZ_3 = dz0 * dz0 * ( 1 - pc * vz / Const2 );
130 double sigmaZ_4 = ( -1 ) * dvx * dvx * ( Const1 - Const3 ) * pa * vz / Const2 / Const2;
131 double sigmaZ_5 = ( -1 ) * dvy * dvy * ( Const1 - Const3 ) * pb * vz / Const2 / Const2;
132 double sigmaZ_6 =
133 dvz * dvz * ( Const1 - Const3 ) * ( pa * vx + pb * vy ) / Const2 / Const2;
134
135 double sigmaZ = sigmaZ_1 + sigmaZ_2 + sigmaZ_3 + sigmaZ_4 + sigmaZ_5 + sigmaZ_6;
136
137 HepPoint3D c1( sqrt( abs( sigmaX ) ), sqrt( abs( sigmaY ) ), sqrt( abs( sigmaZ ) ) );
138 crossSigma = c1;
139 return 1;
140 }
141 else { return 0; }
142}
143
144bool MucGeometron::GetIntersectionQuadPlaneLocal( const int part, // liangyt 2009.3.12
145 const int orient,
146 const float a, // y = a * x * x + b * x + c;
147 const float b, const float c,
148 const HepPlane3D plane, HepPoint3D& cross1,
149 HepPoint3D& cross2 ) {
150
151 if ( a == 0 )
152 {
153 // not quad
154 return 0;
155 }
156
157 HepPoint3D planePoint = plane.point();
158 Hep3Vector planeDir( plane.a(), plane.b(), plane.c() );
159
160 float A, B, C, D;
161 A = plane.a();
162 B = plane.b();
163 C = plane.c();
164 D = planeDir.dot( planePoint );
165
166 // B*a*x^2 + (Bb + A)*x + Bc - D = 0
167
168 // cout<<"in geomtron ABCD = "<<A<<" "<<B<<" "<<C<<" "<<D<<endl;
169
170 float a1 = B * a;
171 float b1 = B * b + A;
172 float c1 = B * c - D;
173
174 float b2sub4ac = b1 * b1 - 4 * a1 * c1;
175
176 // cout<<"in geomtron abc delta = "<<a1<<" "<<b1<<" "<<c1<<" "<<b2sub4ac<<endl;
177
178 float x1 = 0.0, x2 = 0.0, y1 = 0.0, y2 = 0.0, z1 = 0.0, z2 = 0.0;
179 if ( abs( a1 ) > 10E-10 )
180 {
181 if ( b2sub4ac >= 0 )
182 {
183 x1 = ( -b1 + sqrt( b2sub4ac ) ) / ( 2 * a1 );
184 x2 = ( -b1 - sqrt( b2sub4ac ) ) / ( 2 * a1 );
185 y1 = a * x1 * x1 + b * x1 + c;
186 y2 = a * x2 * x2 + b * x2 + c;
187 // cout<<"in MucGeometron------ x1 y1 z1 = "<<x1<<" "<<y1<<" "<<z1<<endl;
188 // cout<<"in MucGeometron------ x2 y2 z2 = "<<x2<<" "<<y2<<" "<<z2<<endl;
189 cross1.set( x1, y1, z1 );
190 cross2.set( x2, y2, z2 );
191 return 1;
192 }
193 else
194 {
195 // cout<<"MucGeometron: no intersection!"<<endl;
196 cross1.set( -9999, -9999, -9999 );
197 cross2.set( -9999, -9999, -9999 );
198 return 0;
199 }
200 }
201 else
202 {
203 x1 = -c1 / b1;
204 y1 = a * x1 * x1 + b * x1 + c;
205 // cout<<"in MucGeometron------ x1 y1 z1 = "<<x1<<" "<<y1<<" "<<z1<<endl;
206 cross1.set( x1, y1, z1 );
207 cross2.set( x1, y1, z1 );
208 // cout<<"in MucGeometron: abs(a1)<10E-10"<<endl;
209 return 1;
210 }
211}
212
213bool MucGeometron::GetIntersectionQuadPlane( const HepPoint3D pLine, // liangyt 2007.4.9
214 const float vy, const float y0,
215 const float a, // y = a * x * x + b * x + c;
216 const float b, const float c,
217 const HepPlane3D plane, HepPoint3D& cross1,
218 HepPoint3D& cross2 ) {
219 // Given a parabola by a b c,
220 // find the intersection with the plane.
221
222 // y = vy * z + y0;
223 // y = a * x * x + b * x + c;
224 // plane.a() * x + plane.b() * y + plane.c() * z = planeDir.dot(planePoint)
225
226 HepPoint3D planePoint = plane.point();
227 Hep3Vector planeDir( plane.a(), plane.b(), plane.c() );
228
229 float A, B, C, D;
230 A = plane.a();
231 B = plane.b();
232 C = plane.c();
233 D = planeDir.dot( planePoint );
234
235 //(B+Cv)*a*x^2 + ((B+Cv)b + A)*x + (B+Cv)c + Cy0 - D = 0
236
237 float a1 = ( B + C / vy ) * a;
238 float b1 = ( B + C / vy ) * b + A;
239 float c1 = ( B + C / vy ) * c - C / y0 - D;
240
241 float b2sub4ac = b1 * b1 - 4 * a1 * c1;
242
243 float x1, x2, y1, y2, z1, z2;
244 if ( abs( a1 ) > 10E-10 )
245 {
246 if ( b2sub4ac >= 0 )
247 {
248 x1 = ( -b1 + sqrt( b2sub4ac ) ) / ( 2 * a1 );
249 x2 = ( -b1 - sqrt( b2sub4ac ) ) / ( 2 * a1 );
250 y1 = a * x1 * x1 + b * x1 + c;
251 y2 = a * x2 * x2 + b * x2 + c;
252 z1 = ( y1 - y0 ) / vy;
253 z2 = ( y2 - y0 ) / vy;
254 // cout<<"in MucGeometron------ x1 y1 z1 = "<<x1<<" "<<y1<<" "<<z1<<endl;
255 // cout<<"in MucGeometron------ x2 y2 z2 = "<<x2<<" "<<y2<<" "<<z2<<endl;
256 cross1.set( x1, y1, z1 );
257 cross2.set( x2, y2, z2 );
258 return 1;
259 }
260 else
261 {
262 // cout<<"MucGeometron: no intersection!"<<endl;
263 cross1.set( -9999, -9999, -9999 );
264 cross2.set( -9999, -9999, -9999 );
265 return 0;
266 }
267 }
268 else
269 {
270 x1 = -c1 / b1;
271 y1 = a * x1 * x1 + b * x1 + c;
272 z1 = ( y1 - y0 ) / vy;
273 // cout<<"in MucGeometron------ x1 y1 z1 = "<<x1<<" "<<y1<<" "<<z1<<endl;
274 cross1.set( x1, y1, z1 );
275 cross2.set( x1, y1, z1 );
276 // cout<<"in MucGeometron: abs(a1)<10E-10"<<endl;
277 return 1;
278 }
279}
EvtVector3R cross(const EvtVector3R &p1, const EvtVector3R &p2)
HepGeom::Point3D< double > HepPoint3D
HepGeom::Plane3D< double > HepPlane3D
***************************************************************************************Pseudo Class RRes *****************************************************************************************Parameters and physical constants **Maarten sept ************************************************************************DOUBLE PRECISION xsmu **************************************************************************PARTICLE DATA all others are from PDG *Only resonances with known widths into electron pairs are sept ************************************************************************C Declarations C
Definition RRes.h:29
MucGeometron()
Constructor.
bool GetIntersectionQuadPlane(const HepPoint3D pLine, const float vy, const float y0, const float a, const float b, const float c, const HepPlane3D plane, HepPoint3D &cross1, HepPoint3D &cross2)
bool GetIntersectionLinePlane(const HepPoint3D pLine, const Hep3Vector vectLine, const HepPlane3D plane, HepPoint3D &cross)
Get intersection of a line and a plane.
bool GetIntersectionQuadPlaneLocal(const int part, const int orient, const float a, const float b, const float c, const HepPlane3D plane, HepPoint3D &cross1, HepPoint3D &cross2)
bool GetIntersectionLinePlaneWithSigma(const HepPoint3D pLine, const Hep3Vector vectLine, const HepPoint3D pLineSigma, const Hep3Vector vectLineSigma, const HepPlane3D plane, HepPoint3D &cross, HepPoint3D &crossSigma)
~MucGeometron()
Destructor.