BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MucRec3DRoad.cxx
Go to the documentation of this file.
1//$id$
2//
3//$log$
4
5/*
6 * 2003/12/25 Zhengyun You Peking University
7 *
8 * 2005/02/27 Zhengyun You Peking University
9 * transplanted to Gaudi framework
10 */
11
12#include <iostream>
13#include <vector>
14#include <CLHEP/Vector/ThreeVector.h>
15#include <CLHEP/Geometry/Point3D.h>
16
17#include "Identifier/MucID.h"
24
25// Constructor.
27 : m_Road0(road0), m_Road1(road1),
28 m_Index(-1),
29 m_Part(road0->GetPart()),
30 m_Seg(road0->GetSeg()),
31 m_LastGap(0),
32 m_Group(-1)
33{
34 float x, y, z;
35 road0->GetVertexPos(x, y, z);
36 m_VertexPos.setX(x);
37 m_VertexPos.setY(y);
38 m_VertexPos.setZ(z);
39
40 // If the part numbers don't match, something is seriously wrong!
41 if ( (road1->GetPart() != m_Part) || (road1->GetSeg() != m_Seg) ) {
42 cout << "MucRec3DRoad(ctor)-E1 mismatched 2D roads:"
43 << " x part = " << road0->GetPart() << " seg = " << road0->GetSeg() << endl
44 << " y part = " << road1->GetPart() << " seg = " << road1->GetSeg() << endl;
45 m_Part = -1;
46 m_Seg = -1;
47 }
48
49 // Compute the last-gap parameter; take the deeper of the 1D roads.
50 if ( road1->GetLastGap() > road0->GetLastGap() ) {
51 m_LastGap = road1->GetLastGap();
52 } else {
53 m_LastGap = road0->GetLastGap();
54 }
55
56 // Check that the two 1D roads have clusters in the same panels.
57 // FIXME: logic needs more thought!
58
59 // Calculate the chi-square and number of degrees of freedom of the
60 // 2-D trajectory (use the "simple" fits).
61 // FIXME: Can we calc. chi-square without brute force?
62
63 m_DOF = m_Road0->GetDegreesOfFreedom() + m_Road1->GetDegreesOfFreedom();
64 m_Chi2 = 0.0;
65
66 for (int gap = 0; gap < (int)MucID::getGapMax(); gap++)
67 {
68 MucRecHit* hit;
69 float dist, sigma;
70 hit = m_Road0->GetHit(gap);
71 if (hit) {
72 if ( hit->Part() == 1 ) sigma = hit->GetCenterSigma().y(); // ???
73 else sigma = hit->GetCenterSigma().y();
74
75 dist = m_Road0->GetHitDistance(hit) / sigma;
76 m_Chi2 += dist * dist;
77 //cout<<"in MucRec3DRoad dist1="<<dist<<" hitdis "<<dist*sigma<<" sigma="<<sigma<<" chi2="<<m_Chi2<<endl;
78 }
79
80 hit = m_Road1->GetHit(gap);
81 if (hit) {
82 if ( hit->Part() == 1 ) {
83 // sigma = fabs(sqrt( (hit->GetCenterSigma().x())*(hit->GetCenterSigma().x())
84 // + (hit->GetCenterSigma().y())*(hit->GetCenterSigma().y()) ));
85 sigma = hit->GetCenterSigma().x();
86 }
87 else {
88 sigma = hit->GetCenterSigma().x();
89 }
90 dist = m_Road1->GetHitDistance(hit) / sigma;
91 m_Chi2 += dist * dist;
92 // cout<<"in MucRec3DRoad dist2="<<dist<<" hitdis "<<dist*sigma<<" sigma="<<sigma<<" chi2="<<m_Chi2<<endl;
93 }
94 }
95
96}
97
98// Copy constructor.
100 : m_VertexPos(source.m_VertexPos),
101 m_VertexSigma(source.m_VertexSigma),
102 m_Road0(source.m_Road0), m_Road1(source.m_Road1),
103 m_Index(source.m_Index),
104 m_Part(source.m_Part), m_Seg(source.m_Seg),
105 m_LastGap(source.m_LastGap),
106 m_Chi2(source.m_Chi2), m_DOF(source.m_DOF),
107 m_Group(source.m_Group)
108{ }
109
110// Destructor.
112{
113 // The 3D road objects do not "own" 2D objects, so don't delete them
114 // here!
115}
116
117// Set the index for this road.
118void
119MucRec3DRoad::SetIndex(const int& index)
120{
121 if (index >= 0) m_Index = index;
122}
123
124// Set the group index for this road.
125void
126MucRec3DRoad::SetGroup(const int& Group)
127{
128 if (Group >= 0) m_Group = Group;
129}
130
131// Set the fit parameters : slope and intercept for XZ and YZ.
132void
134 const float& interceptZX,
135 const float& slopeZY,
136 const float& interceptZY)
137{
138 m_SlopeZX = slopeZX;
139 m_InterceptZX = interceptZX;
140 m_SlopeZY = slopeZY;
141 m_InterceptZY = interceptZY;
142}
143
144
145// the index for this road in the current event.
146int
148{
149 return m_Index;
150}
151
152// the group index for this road in the current event.
153int
155{
156 return m_Group;
157}
158
159// In which part was this road found?
160int
162{
163 return m_Part;
164}
165
166// In which seg was this road found?
167int
169{
170 return m_Seg;
171}
172
173// Which gap is the last one with hits attached to this road?
174int
176{
177 return m_LastGap;
178}
179
180// How many gaps provide hits attached to this road?
181int
183{
184 int count = 0;
185 for (int gap = 0; gap < (int)MucID::getGapMax(); gap++) {
186 if ( (m_Road0->GetHitsPerGap(gap) > 0) || (m_Road1->GetHitsPerGap(gap) > 0) ) {
187 count++;
188 }
189 }
190 return count;
191}
192
193// How many hits in all does this road contain?
194int
196{
197 return ( m_Road0->GetTotalHits() + m_Road1->GetTotalHits() );
198}
199
200// How many hits per gap does this road contain?
201int
202MucRec3DRoad::GetHitsPerGap(const int& gap) const
203{
204 if ( (gap < 0) || (gap >= (int)MucID::getGapMax()) ) {
205 cout << "MucRec3DRoad::HitsPerGap-E1 invalid gap = " << gap << endl;
206 return 0;
207 }
208
209 return ( m_Road0->GetHitsPerGap(gap) + m_Road1->GetHitsPerGap(gap) );
210}
211
212// How many hits were attached in the gap with the most attached hits?
213int
215{
216 int nHit0 = m_Road0->GetMaxHitsPerGap();
217 int nHit1 = m_Road1->GetMaxHitsPerGap();
218 if( nHit0 > nHit1 ) {
219 return nHit0;
220 }
221 else {
222 return nHit1;
223 }
224}
225
226// Does this road contain any hits in the given gap?
227bool
228MucRec3DRoad::HasHitInGap(const int& gap) const
229{
230 if ( (gap < 0) || (gap >= (int)MucID::getGapMax()) ) {
231 cout << "MucRec3DRoad::HasHitInGap-E2 invalid gap = " << gap << endl;
232 return false;
233 }
234
235 return ( m_Road0->HasHitInGap(gap) || m_Road1->HasHitInGap(gap) );
236}
237
238// How many hits do two roads share?
239int
241{
242 if (!road) {
243 return 0;
244 }
245
246 int count = 0;
247 count += m_Road0->GetNSharedHits( road->Get2DRoad(int(0)) );
248 count += m_Road1->GetNSharedHits( road->Get2DRoad(int(1)) );
249
250 return count;
251}
252
253// Difference between the last gap in the two 2-D roads.
254int
256{
257 return abs( m_Road0->GetLastGap() - m_Road1->GetLastGap() );
258}
259
260// Difference between the number of hits in the two 2-D roads.
261int
263{
264 return abs( m_Road0->GetTotalHits() - m_Road1->GetTotalHits() );
265}
266
267// How many degrees of freedom in the trajectory fit?
268int
270{
271 return m_DOF;
272}
273
274// Chi-square parameter (per degree of freedom) of the trajectory fit.
275float
277{
278 if (m_DOF < 0) {
279 return -1.0;
280 }
281 else {
282 if (m_DOF == 0) {
283 return 0.0;
284 }
285 else {
286 return (m_Chi2/m_DOF);
287 }
288 }
289}
290
291// Get Z-X dimension slope.
292float
294{
295 return m_SlopeZX;
296}
297
298// Get Z-X dimension intercept.
299float
301{
302 return m_InterceptZX;
303}
304
305// Get Z-Y dimension slope.
306float
308{
309 return m_SlopeZY;
310}
311
312// Get Z-Y dimension intercept.
313float
315{
316 return m_InterceptZY;
317}
318
319// Get a pointer to the hit attached in a particular gap.
321MucRec3DRoad::GetHit(const int& gap) const
322{
323 if ( (gap < 0) || (gap >= (int)MucID::getGapMax()) ) {
324 cout << "MucRec3DRoad::GetHit-E1 invalid gap = " << gap << endl;
325 return 0;
326 }
327
328 if ( m_Road0->GetHit(gap) ) {
329 return m_Road0->GetHit(gap);
330 }
331 else {
332 if ( m_Road1->GetHit(gap) ) {
333 return m_Road1->GetHit(gap);
334 }
335 }
336 return 0;
337}
338
339int
341 float &slopeZX,
342 float &interceptZX,
343 float &slopeZY,
344 float &interceptZY)
345{
346 float vx, vy, vk, vr;
347 float x0, y0, k0, r0;
348 float svx, svy, svk, svr;
349 float sx0, sy0, sk0, sr0;
350 int xdof, ydof;
351 float chi2x, chi2y;
352 float spos0, spos1;
353
354 // Determine the projection point of the "simple" fit to the desired gap.
355 int status1, status2;
356
357 // now these 2 2D road have been refit without current gap!
358 if( m_Part == 1 ) {
359 status1 = m_Road0->SimpleFitNoCurrentGap(gap, vr, r0, svr, sr0, chi2x, xdof);
360 status2 = m_Road1->SimpleFitNoCurrentGap(gap, vk, k0, svk, sk0, chi2y, ydof);
361
362 m_Road0->GetPosSigma(spos0);
363 m_Road1->GetPosSigma(spos1);
364
365 TransformPhiRToXY(vk, vr, k0, r0,
366 vx, vy, x0, y0);
367
368// TransformPhiRToXY(svk, svr, sk0, sr0, svx, svy, sx0, sy0);
369 TransformPhiRToXY(vk+svk, vr+svr, k0+sk0, r0+sr0, svx, svy, sx0, sy0);
370 svx -= vx; svy -= vy; sx0 -= x0; sy0 -= y0;
371 }
372 else {
373 status1 = m_Road0->SimpleFitNoCurrentGap(gap, vy, y0, svy, sy0, chi2y, ydof);
374 status2 = m_Road1->SimpleFitNoCurrentGap(gap, vx, x0, svx, sx0, chi2x, xdof);
375 m_Road0->GetPosSigma(spos0);
376 m_Road1->GetPosSigma(spos1);
377 }
378
379 if(status1 == -1 || status2 == -1) return -1;
380 slopeZX = vx; interceptZX = x0;
381 slopeZY = vy; interceptZY = y0;
382
383 return 0;
384}
385
386// Where does the trajectory of this road intersect a specific strip? ---for calib
387vector<Identifier>
388MucRec3DRoad::ProjectToStrip(const int& part, const int& gap, const HepPoint3D& gPoint, const Hep3Vector&gDirection)
389{
390 if ( (part < 0) || (part >= (int)MucID::getPartNum()) ) {
391 cout << "MucRec3DRoad::Project-E1 invalid part = " << part << endl;
392 }
393
394 if ( (gap < 0) || (gap >= (int)MucID::getGapMax()) ) {
395 cout << "MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
396 }
397
398 return MucGeoGeneral::Instance()->FindIntersectStrips(part, gap, gPoint, gDirection);
399}
400
401vector<Identifier>
402MucRec3DRoad::ProjectToStrip(const int& part, const int& gap, const HepPoint3D& gPoint, const Hep3Vector&gDirection, vector<int>&padID, vector<float>&intersect_x, vector<float>&intersect_y, vector<float>&intersect_z)
403{
404 if ( (part < 0) || (part >= (int)MucID::getPartNum()) ) {
405 cout << "MucRec3DRoad::Project-E1 invalid part = " << part << endl;
406 }
407
408 if ( (gap < 0) || (gap >= (int)MucID::getGapMax()) ) {
409 cout << "MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
410 }
411
412 return MucGeoGeneral::Instance()->FindIntersectStrips(part, gap, gPoint, gDirection, padID, intersect_x, intersect_y, intersect_z);
413}
414
415// Where does the trajectory of this road intersect a specific gap?
416void
417MucRec3DRoad::ProjectWithSigma(const int& gap, float& x, float& y, float& z, float& sigmaX, float& sigmaY, float& sigmaZ)
418{
419 x = 0.0; sigmaX = 0.0;
420 y = 0.0; sigmaY = 0.0;
421 z = 0.0; sigmaZ = 0.0;
422
423 if ( (gap < 0) || (gap >= (int)MucID::getGapMax()) ) {
424 cout << "MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
425 return;
426 }
427
428 float vx, vy, vk, vr;
429 float x0, y0, k0, r0;
430 float svx, svy, svk, svr;
431 float sx0, sy0, sk0, sr0;
432 int xdof, ydof;
433 float chi2x, chi2y;
434 float spos0, spos1;
435
436 // Determine the projection point of the "simple" fit to the desired gap.
437 if( m_Part == 1 ) {
438 m_Road0->GetSimpleFitParams(vr, r0, svr, sr0, chi2x, xdof);
439 m_Road1->GetSimpleFitParams(vk, k0, svk, sk0, chi2y, ydof);
440 m_Road0->GetPosSigma(spos0);
441 m_Road1->GetPosSigma(spos1);
442
443 TransformPhiRToXY(vk, vr, k0, r0, vx, vy, x0, y0);
444 //TransformPhiRToXY(svk, svr, sk0, sr0, svx, svy, sx0, sy0);
445 TransformPhiRToXY(vk+svk, vr+svr, k0+sk0, r0+sr0, svx, svy, sx0, sy0);
446 svx -= vx; svy -= vy; sx0 -= x0; sy0 -= y0;
447 }
448 else {
449 m_Road0->GetSimpleFitParams(vy, y0, svy, sy0, chi2y, ydof);
450 m_Road1->GetSimpleFitParams(vx, x0, svx, sx0, chi2x, xdof);
451 m_Road0->GetPosSigma(spos0);
452 m_Road1->GetPosSigma(spos1);
453
454 }
455
456/*
457 cout << " vr " << vr << " vk " << vk << endl;
458 cout << " r0 " << r0 << " k0 " << k0 << endl;
459 cout << " vx " << vx << " vy " << vy << endl;
460 cout << " x0 " << x0 << " y0 " << y0 << endl;
461*/
462
463 MucGeoGeneral::Instance()->FindIntersection(m_Part, m_Seg, gap,
464 vx, vy, 1.0, x0, y0, 0.0,
465 svx, svy, 0.0, sx0, sy0, 0.0,
466 x, y, z,
467 sigmaX, sigmaY, sigmaZ);
468/*
469 if(fabs(vr)>10000) ///////////////////if fabs(vr) too big, r0 will be intersection in x coordinate!!!
470 MucGeoGeneral::Instance()->FindIntersection(m_Part, m_Seg, gap,
471 vx, vy, 1.0, x0, y0, r0,
472 svx, svy, 0.0, sx0, sy0, 0.0,
473 x, y, z,
474 sigmaX, sigmaY, sigmaZ);
475*/
476
477 sigmaX = spos1;
478 sigmaY = spos0;
479 sigmaZ = 0.0;
480
481 float a, b, c;
482 float sa, sb, sc; int whichhalf;
483 //cout<<"in MucRec3DRoad xyz form linefit "<<x<<" "<<y<<" "<<z<<endl;
484
485 if( m_Part == 1 ) {
486 m_Road1->GetSimpleFitParams(a, b, c, whichhalf, sa, sb, sc, chi2x, ydof);
487 //cout<<"in MucRec3DRoad "<<vy<<" "<<y0<<" "<<a<<" "<<b<<" "<<c<<endl;
488 }
489
490 return;
491}
492
493// Where does the trajectory of this road intersect a specific gap?
494void
495MucRec3DRoad::ProjectNoCurrentGap(const int& gap, float& x, float& y, float& z, float& sigmaX, float& sigmaY, float& sigmaZ,
496 float& quad_x1, float& quad_y1, float& quad_z1, float& quad_x2, float& quad_y2, float& quad_z2)
497{
498
499 x = 0.0; sigmaX = 0.0;
500 y = 0.0; sigmaY = 0.0;
501 z = 0.0; sigmaZ = 0.0;
502
503 if ( (gap < 0) || (gap >= (int)MucID::getGapMax()) ) {
504 cout << "MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
505 return;
506 }
507
508 float vx, vy, vk, vr;
509 float x0, y0, k0, r0;
510 float svx, svy, svk, svr;
511 float sx0, sy0, sk0, sr0;
512 int xdof, ydof;
513 float chi2x, chi2y;
514 float spos0, spos1;
515
516 // Determine the projection point of the "simple" fit to the desired gap.
517
518 // now these 2 2D road have been refit without current gap!
519 if( m_Part == 1 ) {
520 m_Road0->SimpleFitNoCurrentGap(gap, vr, r0, svr, sr0, chi2x, xdof);
521 m_Road1->SimpleFitNoCurrentGap(gap, vk, k0, svk, sk0, chi2y, ydof);
522
523 m_Road0->GetPosSigma(spos0);
524 m_Road1->GetPosSigma(spos1);
525
526 TransformPhiRToXY(vk, vr, k0, r0, vx, vy, x0, y0);
527
528 //TransformPhiRToXY(svk, svr, sk0, sr0, svx, svy, sx0, sy0);
529 TransformPhiRToXY(vk+svk, vr+svr, k0+sk0, r0+sr0, svx, svy, sx0, sy0);
530 svx -= vx; svy -= vy; sx0 -= x0; sy0 -= y0;
531 }
532 else {
533 m_Road0->SimpleFitNoCurrentGap(gap, vy, y0, svy, sy0, chi2y, ydof);
534 m_Road1->SimpleFitNoCurrentGap(gap, vx, x0, svx, sx0, chi2x, xdof);
535 m_Road0->GetPosSigma(spos0);
536 m_Road1->GetPosSigma(spos1);
537
538 }
539 /*
540 cout << " vr " << vr << " vk " << vk << endl;
541 cout << " r0 " << r0 << " k0 " << k0 << endl;
542 cout << " vx " << vx << " vy " << vy << endl;
543 cout << " x0 " << x0 << " y0 " << y0 << endl;
544 */
545
546 MucGeoGeneral::Instance()->FindIntersection(m_Part, m_Seg, gap,
547 vx, vy, 1.0, x0, y0, 0.0,
548 svx, svy, 0.0, sx0, sy0, 0.0,
549 x, y, z,
550 sigmaX, sigmaY, sigmaZ);
551 if(fabs(vr)>10000) ///////////////////if fabs(vr) too big, r0 will be intersection in x coordinate!!!
552 MucGeoGeneral::Instance()->FindIntersection(m_Part, m_Seg, gap,
553 vx, vy, 1.0, x0, y0, r0,
554 svx, svy, 0.0, sx0, sy0, 0.0,
555 x, y, z,
556 sigmaX, sigmaY, sigmaZ);
557
558 sigmaX = spos1;
559 sigmaY = spos0;
560 sigmaZ = 0.0;
561
562 float a, b, c;
563 float sa, sb, sc; int whichhalf;
564
565 //calc orient now
566 int orient = 0;
567 if(m_Part == 1 && gap%2 == 0) orient = 1;
568 if(m_Part != 1 && gap%2 == 1) orient = 1;
569
570 if(orient == 0) m_Road0->GetSimpleFitParams(a, b, c, whichhalf, sa, sb, sc, chi2x, ydof);
571 else m_Road1->GetSimpleFitParams(a, b, c, whichhalf, sa, sb, sc, chi2x, ydof);
572
573 //cout<<"orient = "<<orient<<" abc: "<<a<<" "<<b<<" "<<c<<endl;
574 quad_x1 = -9999; quad_y1 = -9999; quad_z1 = -9999; quad_x2 = -9999; quad_y2 = -9999; quad_z2 = -9999;
575
576 if(orient == 0 && m_Road0->GetQuadFitOk() || orient == 1 && m_Road1->GetQuadFitOk() )
578 a, b, c, whichhalf, quad_x1, quad_y1, quad_z1, quad_x2, quad_y2, quad_z2, sigmaX, sigmaY, sigmaZ);
579
580 return;
581}
582
583void
584MucRec3DRoad::Project(const int &gap, const float vx, const float x0,const float vy,const float y0 , float &x, float &y, float &z)
585{
586 float svx=0, svy=0, sx0=0, sy0=0;
587 float sigmaX,sigmaY,sigmaZ;
588 MucGeoGeneral::Instance()->FindIntersection(m_Part, m_Seg, gap,
589 vx, vy, 1.0, x0, y0, 0.0,
590 svx, svy, 0.0, sx0, sy0, 0.0,
591 x, y, z,
592 sigmaX, sigmaY, sigmaZ);
593}
594
595// Where does the trajectory of this road intersect two surface of a specific gap?
596// a line or a parabola!
597void
598MucRec3DRoad::Project(const int& gap, float& x1, float& y1, float& z1, float& x2, float& y2, float& z2) //x1: inner; x2: outer
599{
600 float sigmaX1, sigmaY1, sigmaZ1;
601 float sigmaX2, sigmaY2, sigmaZ2;
602
603 x1 = 0.0; sigmaX1 = 0.0;
604 y1 = 0.0; sigmaY1 = 0.0;
605 z1 = 0.0; sigmaZ1 = 0.0;
606 x2 = 0.0; sigmaX2 = 0.0;
607 y2 = 0.0; sigmaY2 = 0.0;
608 z2 = 0.0; sigmaZ2 = 0.0;
609
610 if ( (gap < 0) || (gap >= (int)MucID::getGapMax()) ) {
611 cout << "MucRec3DRoad::Project-E1 invalid gap = " << gap << endl;
612 return;
613 }
614
615 float vx, vy, vk, vr;
616 float x0, y0, k0, r0;
617 float svx, svy, svk, svr;
618 float sx0, sy0, sk0, sr0;
619 int xdof, ydof;
620 float chi2x, chi2y;
621
622 // Determine the projection point of the "simple" fit to the desired gap.
623
624 if( m_Part == 1 ) {
625 m_Road0->GetSimpleFitParams(vr, r0, svr, sr0, chi2x, xdof);
626 m_Road1->GetSimpleFitParams(vk, k0, svk, sk0, chi2y, ydof);
627 TransformPhiRToXY(vk, vr, k0, r0,
628 vx, vy, x0, y0);
629
630 //cout<<"in MucRec3DRoad after vx,vy"<<endl;
631 TransformPhiRToXY(svk, svr, sk0, sr0,
632 svx, svy, sx0, sy0);
633 }
634 else {
635 m_Road0->GetSimpleFitParams(vy, y0, svy, sy0, chi2y, ydof);
636 m_Road1->GetSimpleFitParams(vx, x0, svx, sx0, chi2x, xdof);
637 }
638 /*
639 cout << " vr " << vr << " vk " << vk << endl;
640 cout << " r0 " << r0 << " k0 " << k0 << endl;
641 cout << " vx " << vx << " vy " << vy << endl;
642 cout << " x0 " << x0 << " y0 " << y0 << endl;
643 */
644
646 vx, vy, 1.0, x0, y0, 0.0,
647 svx, svy, 0.0, sx0, sy0, 0.0,
648 x1, y1, z1, x2, y2, z2,
649 sigmaX1, sigmaY1, sigmaZ1,
650 sigmaX2, sigmaY2, sigmaZ2);
651
652 float a, b, c;
653 float sa, sb, sc; int whichhalf;
654 //cout<<"in MucRec3DRoad xyz form linefit "<<x1<<" "<<y1<<" "<<z1<<" "<<x2<<" "<<y2<<" "<<z2<<endl;
655
656 //if this trajectory is parabola!
657 int projectwithquad = 0;
658 if( m_Part == 1 && projectwithquad) {
659 m_Road1->GetSimpleFitParams(a, b, c, whichhalf, sa, sb, sc, chi2x, ydof);
660
661 //cout<<"in MucRec3DRoad "<<vy<<" "<<y0<<" "<<a<<" "<<b<<" "<<c<<endl;
662 if(m_Road1->GetQuadFitOk()){
664 vy, x0, y0, 0.0,
665 a, b, c, //y = a*x*x + b*x +c
666 whichhalf,
667 svx, svy, 0.0, sx0, sy0, 0.0,
668 x1, y1, z1, x2, y2, z2,
669 sigmaX1, sigmaY1, sigmaZ1);
670 }
671
672 }
673
674 return;
675}
676
677// get a pointer to the 2D road in the 3D road
679MucRec3DRoad::Get2DRoad(const int& orient) const
680{
681 if (orient == 0) {
682 return m_Road0;
683 }
684 else {
685 return m_Road1;
686 }
687}
688
689// Get indices of all hits in the road.
690vector<Identifier>
692
693{
694 vector<Identifier> idCon;
695 vector<Identifier>::iterator hit;
696 vector<Identifier> hitRoad0 = m_Road0->GetHitsID();
697 vector<Identifier> hitRoad1 = m_Road1->GetHitsID();
698
699 // List will be ordered by orientation.
700
701 // Road0 first ...
702 for ( hit = hitRoad0.begin(); hit != hitRoad0.end(); hit++) {
703 int index = *hit;
704 idCon.push_back(*hit);
705 //cout << " MucRec3DRoad::HitIndices Road0 = " << index << endl;
706 }
707
708 // ... then Road1.
709 for ( hit = hitRoad1.begin(); hit != hitRoad1.end();hit++) {
710 int index = *hit;
711 idCon.push_back(*hit);
712 //cout << " MucRec3DRoad::HitIndices Road1 = " << index << endl;
713 }
714
715 return idCon;
716}
717
718// Transform the Phi, ZR cord. to ZX, ZY cord.
719void
720MucRec3DRoad::TransformPhiRToXY(const float& vk, const float& vr,
721 const float& k0, const float& r0,
722 float& vx, float& vy,
723 float& x0, float& y0) const
724{
725 vx = 0.0; vy = 0.0;
726 x0 = 0.0; y0 = 0.0;
727
728 // cout << vk << " " << vr << " " << endl;
729
730 //float pi = 3.1415926536;
731 float phi = 0.25*kPi*m_Seg;
732
733 // From y0 = vk * x0 + k0;
734 // y0 - r0*sin(phi)
735 // ------------------ = tan(phi + 0.5*kPi);
736 // x0 - r0*cos(phi)
737
738 if ( cos(phi) + vk*sin(phi) == 0.0 ) {
739 cout << " track parallel to gap, some error occurs! " << endl;
740 // m_Seg = 1, and vk = -1;
741 // 2, 0;
742 // 3, 1;
743 // 5, -1;
744 // 6, 0;
745 // 7, 1;
746 }
747 else {
748 /*
749 vx = vr / ( cos(phi) + vk*sin(phi) );
750 vy = vk * vx;
751 x0 = (r0 - k0) / ( cos(phi) + vk );
752 y0 = vk * x0 + k0;
753 */
754
755 float atan_vk = atan(vk);
756 if(atan_vk<0) atan_vk += kPi;
757
758 //float deltaPhi = fabs(atan(vk)) - int( fabs(atan(vk))/(0.25*kPi) )*0.25*kPi;
759 //if (deltaPhi > 0.125*kPi) deltaPhi = 0.25*kPi - delta
760
761 float deltaPhi = atan_vk - (m_Seg%4)*(0.25*kPi);
762
763 //vx = vr*cos(deltaPhi)*GetVxSign(vk)/sqrt(1.0+vk*vk); //change to vr/cos()... liangyt 2007.4.10
764 //I think it should be vr/cos...
765
766 vx = (vr/fabs(cos(deltaPhi)))*GetVxSign(vk)/sqrt(1.0+vk*vk);
767 vy = vk*vx;
768 x0 = (r0 - k0*sin(phi)) / (vk*sin(phi) + cos(phi));
769 y0 = vk * x0 + k0;
770
771 float safe_vr = vr;
772
773 if(fabs(vr)>10000){
774 if(vr>0) safe_vr = 10000;
775 else safe_vr = -10000;
776 vx = (safe_vr/fabs(cos(deltaPhi)))*GetVxSign(vk)/sqrt(1.0+vk*vk);
777 vy = vk*vx;
778 y0 = -vy*r0;
779 x0 = (y0 - k0)/vk;
780 }
781
782 }
783}
784
785float
786MucRec3DRoad::GetVxSign(const float vk) const
787{
788 float segmentPhiMin = 0.25*kPi*(m_Seg-2);
789 float segmentPhiMax = 0.25*kPi*(m_Seg+2);
790 if (m_Seg > 4) {
791 segmentPhiMin -= 2.0*kPi;
792 segmentPhiMax -= 2.0*kPi;
793 }
794
795 // vk = tan(theta); theta = atan(vk); -90<theta<90
796 float theta = atan(vk);
797 if (theta >= segmentPhiMin && theta <= segmentPhiMax) return 1.0;
798 else return -1.0;
799}
800
801// Print Hits Infomation.
802void
804{
805 m_Road0->PrintHitsInfo();
806 m_Road1->PrintHitsInfo();
807
808 cout << "Intersection with each gap : " << endl;
809 for (int iGap = 0; iGap <= m_LastGap; iGap++) {
810 float x, y, z, sigmaX, sigmaY, sigmaZ;
811 ProjectWithSigma(iGap, x, y, z, sigmaX, sigmaY, sigmaZ);
812 cout << " gap " << iGap
813 << " (" << x
814 << ", " << y
815 << ", " << z
816 << ")"
817 << endl;
818 }
819}
double sin(const BesAngle a)
Definition: BesAngle.h:210
double cos(const BesAngle a)
Definition: BesAngle.h:213
TTree * sigma
Double_t x[10]
DOUBLE_PRECISION count[3]
const double kPi
Definition: MucConstant.h:6
void FindIntersectionQuadLocal(const int part, const int seg, const int gap, const float a, const float b, const float c, const int whichhalf, float &x1, float &y1, float &z1, float &x2, float &y2, float &z2, float &sigmaX, float &sigmaY, float &sigmaZ)
vector< Identifier > FindIntersectStrips(const int part, const int gap, const HepPoint3D gPoint, const Hep3Vector gDirection)
void FindIntersectionSurface(const int part, const int seg, const int gap, const float vx, const float vy, const float vz, const float x0, const float y0, const float z0, const float sigmaVx, const float sigmaVy, const float sigmaVz, const float sigmaX0, const float sigmaY0, const float sigmaZ0, float &x1, float &y1, float &z1, float &x2, float &y2, float &z2, float &sigmaX1, float &sigmaY1, float &sigmaZ1, float &sigmaX2, float &sigmaY2, float &sigmaZ2)
static MucGeoGeneral * Instance()
Get a pointer to the single instance of MucGeoGeneral.
void FindIntersection(const int part, const int seg, const int gap, const float vx, const float vy, const float vz, const float x0, const float y0, const float z0, const float sigmaVx, const float sigmaVy, const float sigmaVz, const float sigmaX0, const float sigmaY0, const float sigmaZ0, float &x, float &y, float &z, float &sigmaX, float &sigmaY, float &sigmaZ)
static value_type getGapMax()
Definition: MucID.cxx:195
static value_type getPartNum()
Definition: MucID.cxx:159
vector< Identifier > GetHitsID() const
Get indices of all hits in the road.
bool HasHitInGap(const int &gap) const
Does this road contain any hits in the given gap?
void PrintHitsInfo() const
Print Hits Infomation.
int GetTotalHits() const
How many hits in all does this road contain?
int GetHitsPerGap(const int &gap) const
How many hits per gap does this road contain?
void GetVertexPos(float &x, float &y, float &z) const
Position of the vertex point.
void GetPosSigma(float &possigma) const
int GetMaxHitsPerGap() const
How many hits were attached in the gap with the most attached hits?
int GetLastGap() const
Which gap is the last one with hits attached to this road?
int GetNSharedHits(const MucRec2DRoad *road) const
How many hits do two roads share?
int GetPart() const
In which part was this road found?
float GetHitDistance(const MucRecHit *hit)
Distance to a hit.
int GetDegreesOfFreedom() const
How many degrees of freedom in the trajectory fit?
void GetSimpleFitParams(float &slope, float &intercept, float &sigmaSlope, float &sigmaIntercept, float &chisq, int &ndof) const
Get the parameters from the simple fit.
int GetSeg() const
In which segment was this road found?
MucRecHit * GetHit(const int &gap) const
Get a pointer to the first found hit attached in a particular gap.
int SimpleFitNoCurrentGap(int currentgap, float &slope, float &intercept, float &sigmaSlope, float &sigmaIntercept, float &chisq, int &ndof)
Calculate the best-fit straight line with "simple" weights. not use current gap!!!
bool GetQuadFitOk()
Definition: MucRec2DRoad.h:160
int RefitNoCurrentGap(const int &gap, float &slopeZX, float &interceptZX, float &slopeZY, float &interceptZY)
refit the 3D road without the assigned gap
float GetSlopeZX() const
Get Z-X dimension slope.
float GetSlopeZY() const
Get Z-Y dimension slope.
void TransformPhiRToXY(const float &vk, const float &vr, const float &k0, const float &r0, float &vx, float &vy, float &x0, float &y0) const
Where does the trajectory of this road intersect the reference plane?
bool HasHitInGap(const int &gap) const
Does this road contain any hits in the given segment?
int GetLastGapDelta() const
Difference between the last gap in the two 1-D roads.
void SetIndex(const int &index)
set the index for this road
int GetHitsPerGap(const int &gap) const
How many hits per gap does this road contain?
void ProjectNoCurrentGap(const int &gap, float &x, float &y, float &z, float &sigmaX, float &sigmaY, float &sigmaZ, float &quad_x1, float &quad_y1, float &quad_z1, float &quad_x2, float &quad_y2, float &quad_z2)
Where does the trajectory of this road intersect a specific gap when refit without current gap!...
float GetVxSign(const float vk) const
Get sign of vx in TransformPhiRToXY.
MucRecHit * GetHit(const int &gap) const
Get a pointer to the first hit attached in a particular gap.
int GetPart() const
In which part was this road found?
vector< Identifier > ProjectToStrip(const int &part, const int &gap, const HepPoint3D &gPoint, const Hep3Vector &gDirection)
int GetLastGap() const
Which gap is the last one with hits attached to this road?
int GetTotalHitsDelta() const
Difference between the number of hits in the two 1-D roads.
void PrintHitsInfo()
Print Hits Infomation.
void SetGroup(const int &Group)
set the group index for this road
int GetTotalHits() const
How many hits in all does this road contain?
float GetInterceptZY() const
Get Z-Y dimension intercept.
MucRec3DRoad(MucRec2DRoad *road0, MucRec2DRoad *road1)
Constructor.
int GetGroup() const
unique index of group this road belongs to
void SetSimpleFitParams(const float &m_SlopeZX, const float &m_InterceptZX, const float &m_SlopeZY, const float &m_InterceptZY)
set the fit parameters : slope and intercept for XZ and YZ.
int GetNSharedHits(const MucRec3DRoad *road) const
How many hits do two roads share?
int GetSeg() const
In which segment was this road found?
int GetDegreesOfFreedom() const
How many degrees of freedom in the trajectory fit?
~MucRec3DRoad()
Destructor.
MucRec2DRoad * Get2DRoad(const int &orient=0) const
Is the intersection of a pair of H and V clusters inside a panel?
void Project(const int &gap, float &x1, float &y1, float &z1, float &x2, float &y2, float &z2)
Where does the trajectory of this road intersect two surfaces of a specific gap?
vector< Identifier > GetHitsID() const
Get indices of all hits in the road.
void ProjectWithSigma(const int &gap, float &x, float &y, float &z, float &sigmaX, float &sigmaY, float &sigmaZ)
Where does the trajectory of this road intersect a specific gap?
float GetInterceptZX() const
Get Z-X dimension intercept.
int GetNGapsWithHits() const
How many gaps provide hits attached to this road?
int GetIndex() const
A unique identifier for this road in the current event.
float GetReducedChiSquare() const
Chi-square parameter (per degree of freedom) of the trajectory fit.
int GetMaxHitsPerGap() const
How many hits were attached in the gap with the most attached hits?
Hep3Vector GetCenterSigma() const
Get Center position uncertainty of the strip (global coords).
Definition: MucRecHit.cxx:114
int Part() const
Get Part.
Definition: MucRecHit.h:71
double y[1000]
const double b
Definition: slope.cxx:9