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