CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
RecMucTrack.cxx
Go to the documentation of this file.
1//$id$
2//
3//$log$
4
5/*
6 * 2004/03/08 Zhengyun You Peking University
7 *
8 * 2004/09/12 Zhengyun You Peking University
9 * transplanted to Gaudi framework
10 */
11
12using namespace std;
13
14#include <iostream>
15#include <vector>
16#include <CLHEP/Vector/ThreeVector.h>
17#include <CLHEP/Geometry/Point3D.h>
18
24
25// Constructor.
27 : //m_trackId(-1), //--------------->
28 m_ExtTrackID(-1),
29 m_MdcPos(0.0, 0.0, 0.0),
30 m_MdcMomentum(0.0, 0.0, 0.0),
31 m_MucPos(0.0, 0.0, 0.0),
32 m_MucPosSigma(0.0, 0.0, 0.0),
33 m_MucMomentum(0.0, 0.0, 0.0),
34 m_CurrentPos(0.0, 0.0, 0.0),
35 m_CurrentDir(0.0, 0.0, 0.0),
36 m_CurrentInsct(0.0, 0.0, 0.0),
37 m_Good3DLine(0),
38 m_pHits(0),
39 m_pExpectedHits(0),
40 m_Intersections(0),
41 m_Directions(0)
42{
43 // initialize m_IntersectionInner/Outer.
44 for(int igap = 0; igap < 9; igap++){
45 m_IntersectionInner[igap].set(-9999,-9999,-9999);
46 m_IntersectionOuter[igap].set(-9999,-9999,-9999);
47 }
48 m_id = 0;
49 m_status = -1;
50 m_type = -1;
51
52 m_numHits = 0;
53 m_startPart = -1;
54 m_endPart = -1;
55 m_brLastLayer = -1;
56 m_ecLastLayer = -1;
57 m_brFirstLayer = -1;
58 m_ecFirstLayer = -1;
59 m_ecPart = -1;
60 m_numLayers = 0;
62 m_depth = -99;
63 m_dof = 0;
64 m_chi2 = 0.0;
65 m_rms = 0.0;
66 m_deltaPhi = 0.0;
67
68 m_xPosSigma = 0.0;
69 m_yPosSigma = 0.0;
70 m_zPosSigma = 0.0;
71
72 m_changeUnit = false;
73 m_recmode = 0;
74 //added by LI Chunhua
75 m_kalrechi2 =0. ;
76 m_kaldof =0;
77 m_kaldepth = -99;
80}
81
82// Assignment constructor.
85{
86 // Assignment operator.
87 if ( this != &orig ) { // Watch out for self-assignment!
88 //m_trackId = orig.m_trackId; //--------------->
89 m_ExtTrackID = orig.m_ExtTrackID;
90 m_MdcPos = orig.m_MdcPos;
91 m_MdcMomentum = orig.m_MdcMomentum;
92 m_MucPos = orig.m_MucPos;
93 m_MucPosSigma = orig.m_MucPosSigma;
94 m_MucMomentum = orig.m_MucMomentum;
95 m_CurrentPos = orig.m_CurrentPos;
96 m_CurrentDir = orig.m_CurrentDir;
97 m_CurrentInsct = orig.m_CurrentInsct;
98 m_id = orig.m_id;
99 m_status = orig.m_status;
100 m_type = orig.m_type;
101 m_numHits = orig.m_numHits; //--------------->
103 m_endPart = orig.m_endPart;
108 m_depth = orig.m_depth;
109 m_dof = orig.m_dof;
110 m_chi2 = orig.m_chi2;
111 m_rms = orig.m_rms;
112 m_deltaPhi = orig.m_deltaPhi;
113 m_pHits = orig.m_pHits;
114 m_pExpectedHits = orig.m_pExpectedHits;
115 m_Intersections = orig.m_Intersections;
116 m_Directions = orig.m_Directions;
120 m_changeUnit = orig.m_changeUnit;
121 m_recmode = orig.m_recmode;
122 //*******
124 m_kaldof = orig.m_kaldof;
128 }
129
130 return *this;
131}
132
133// Copy constructor.
135 : //m_trackId (source.m_trackId), //--------------->
136 m_ExtTrackID (source.m_ExtTrackID),
137 m_MdcPos (source.m_MdcPos),
138 m_MdcMomentum (source.m_MdcMomentum),
139 m_MucPos (source.m_MucPos),
140 m_MucPosSigma (source.m_MucPosSigma),
141 m_MucMomentum (source.m_MucMomentum),
142 m_CurrentPos (source.m_CurrentPos),
143 m_CurrentDir (source.m_CurrentDir),
144 m_CurrentInsct (source.m_CurrentInsct),
145 m_pHits (source.m_pHits),
146 m_pExpectedHits(source.m_pExpectedHits),
147 m_Intersections(source.m_Intersections),
148 m_Directions (source.m_Directions)
149{
150 m_id = source.m_id;
151 m_status = source.m_status;
152 m_type = source.m_type;
153 m_numHits = source.m_numHits; //--------------->
154 m_startPart = source.m_startPart;
155 m_endPart = source.m_endPart;
158 m_numLayers = source.m_numLayers;
160 m_depth = source.m_depth;
161 m_dof = source.m_dof;
162 m_chi2 = source.m_chi2;
163 m_rms = source.m_rms;
164 m_deltaPhi = source.m_deltaPhi;
165 m_xPosSigma = source.m_xPosSigma;
166 m_yPosSigma = source.m_yPosSigma;
167 m_zPosSigma = source.m_zPosSigma;
168 m_changeUnit = source.m_changeUnit;
169 m_recmode = source.m_recmode;
170 //******
171 m_kalrechi2 = source.m_kalrechi2;
172 m_kaldof = source.m_kaldof;
173 m_kaldepth = source.m_kaldepth;
176}
177
179 :DstMucTrack(dstTrack)
180{
181
182 SetDefault();
183
184}
185
187{
188 SetDefault();
189 DstMucTrack::operator=(dstTrack);
190 return *this;
191}
192
194{
195 m_brFirstLayer = -99;
196 m_ecFirstLayer = -99;
197 m_Good3DPart = -99;
198}
199
200// Destructor.
202{
203for(int i = 0 ; i < m_pExpectedHits.size(); i++)
204 delete m_pExpectedHits[i];
205}
206
207// Set the index for this track.
208void
209RecMucTrack::setTrackId(const int trackId)
210{
211 if(trackId >= 0) {
213 }
214}
215
216//now, what we get is cm, so it' multiplied by 10 to convert to mm
217//and GeV -> MeV
218void
220 const float y,
221 const float z)
222{
223 m_MdcPos.set(x*10, y*10, z*10);
224}
225
226void
228 const float py,
229 const float pz)
230{
231 m_MdcMomentum.set(px*1000, py*1000, pz*1000);
232}
233
234void
236 const float y,
237 const float z)
238{
239 m_MucPos.set(x*10, y*10, z*10);
240 m_xPos = x*10;
241 m_yPos = y*10;
242 m_zPos = z*10;
243}
244
245void
247 const float y,
248 const float z)
249{
250 m_MucPosSigma.set(x*10, y*10, z*10);
251 m_xPosSigma = x*10;
252 m_yPosSigma = y*10;
253 m_zPosSigma = z*10;
254}
255
256void
258 const float py,
259 const float pz)
260{
261 m_MucMomentum.set(px*1000, py*1000, pz*1000);
262 m_px = px*1000;
263 m_py = py*1000;
264 m_pz = pz*1000;
265}
266
267void
269 const float y,
270 const float z)
271{
272 m_ExtMucPos.set(x*10, y*10, z*10);
273}
274
275void
277 const float py,
278 const float pz)
279{
280 m_ExtMucMomentum.set(px*1000, py*1000, pz*1000);
281}
282
283void
285 const float y,
286 const float z)
287{
288 m_CurrentPos.set(x*10, y*10, z*10);
289}
290
291void
293 const float y,
294 const float z)
295{
296 m_CurrentDir.set(x*1000, y*1000, z*1000); //unnecessary, because it's dir, not mom
297}
298
299void
301 const float y,
302 const float z)
303{
304 m_CurrentInsct.set(x, y, z); /////this is intenal function, it receive "mm", so need not convert.
305}
306
307// set corresponding monte carlo track pointer.
308//RecMucTrack::SetMCTrack(const BesPersTrack* mcTrack);
309//{
310// m_MCTrack = mcTrack;
311//}
312
313void
315{
316 m_ExtTrack = extTrack;
317 if (m_ExtTrack) m_ExtTrackID = extTrack->GetTrackId();
318}
319
320//reload setVecHits
321
322void
323RecMucTrack::setVecHits(vector<MucRecHit*>& pHits)
324{
325 for(int i = 0 ; i < pHits.size(); i++)
326 m_vecHits.push_back((pHits[i]->GetID()).get_value());
327}
328
329void
330RecMucTrack::setExpHits(vector<MucRecHit*>& pHits)
331{
332 for(int i = 0 ; i < pHits.size(); i++)
333 m_expHits.push_back((pHits[i]->GetID()).get_value());
334}
335
336void
337RecMucTrack::GetMdcExtTrack(Hep3Vector mdcStartPos, Hep3Vector mdcStartMomentum, int charge,
338 Hep3Vector &mucStartPos, Hep3Vector &mucStartMomentum)
339{
340
341 //cm->mm; GeV->MeV//
342 mdcStartPos*=10;
343 mdcStartMomentum*=1000;
344 ////////////////////
345
346
347 Hep3Vector pt = mdcStartMomentum;
348 pt.setZ(0);
349 //cout << "pt " << pt.mag() << endl;
350 double radius = (pt.mag() * 1e6 / kvC * 1e3) / (fabs(charge * kMagnetField)) ;
351 //double startPhi = startP.phi();
352 double deltaPhi = -1.0 * (charge / abs(charge)) * kDeltaPhi;
353 double deltaZ = (mdcStartMomentum.z() * 1e6 / kvC * 1e3) * kDeltaPhi / (abs(charge) * kMagnetField);
354
355 //cout << "r = " << radius << endl;
356 mucStartPos = mdcStartPos;
357 mucStartMomentum = mdcStartMomentum;
358 double phi;
359 int iter = 0;
360 do {
361 phi = mucStartMomentum.getPhi() + deltaPhi;
362 mucStartPos.setX(mucStartPos.x() + radius * kDeltaPhi * cos(phi));
363 mucStartPos.setY(mucStartPos.y() + radius * kDeltaPhi * sin(phi));
364 mucStartPos.setZ(mucStartPos.z() + deltaZ);
365
366 mucStartMomentum.setPhi(mucStartMomentum.phi() + deltaPhi);
367 iter++;
368 //cout << endP << " " << mucStartPos << endl;
369 }
370 while(IsInsideSuperConductor(mucStartPos) && iter < kMdcExtIterMax);
371
372 //mm->cm; MeV->GeV//
373 mucStartPos/=10;
374 mucStartMomentum/=1000;
375 ////////////////////
376}
377
378bool
380{
381 if(pos.mag() < kSuperConductorR && fabs(pos.z()) < kSuperConductorZ) {
382 return true;
383 }
384 else {
385 return false;
386 }
387}
388
389// Attach the given hit to this track.
390// Assume that this hit has been verified to be consistent with the road.
391void
393{
394 // cout << "Muc2DRoad::AttachHit-I0 hit = " << hit << endl;
395
396 if (!hit) {
397 cout << "RecMucTrack::AttachHit-E1 null hit pointer!" << endl;
398 return ;
399 }
400
401 int part = hit->Part();
402 int gap = hit->Gap();
403 if ( (gap < 0) || (gap >= (int)MucID::getGapNum(part)) ) {
404 // The gap number of the hit is out of range.
405 cout << "Muc2DRoad::AttachHit(MucRecHit*), bad gap number = " << gap
406 << endl;
407 return;
408 }
409
410 // Attach the hit to the road.
411 m_pHits.push_back(hit);
412
413 // m_HitDistance[gap] = dX;
414
415 // Now recalculate the total number of hits and the max. number of
416 // hits per gap.
417 //CountHits();
418}
419
420// Where does the trajectory of this track intersect a specific gap?
421void
422RecMucTrack::Project(const int& part, const int& gap,
423 float& x, float& y, float& z,
424 int& seg)
425{
426 seg = -1;
427 x = 0.0; y = 0.0; z = 0.0;
428
429 if ( (gap < 0) || (gap >= (int)MucID::getGapNum(part)) ) {
430 cout << "Muc2DRoad::Project(), invalid gap = " << gap << endl;
431 return;
432 }
433
434 HepPoint3D pos = m_CurrentPos;
435 Hep3Vector dir = m_CurrentDir;
436
437 vector<HepPoint3D> insctCon = MucGeoGeneral::Instance()->FindIntersections(part, gap, pos, dir);
438 if( insctCon.size() == 0 ) {
439 return;
440 }
441
442 HepPoint3D intersection = insctCon[0];
443
444 x = intersection.x();
445 y = intersection.y();
446 z = intersection.z();
447
448 //cout << " x " << x << " y " << y << " z " << z << endl;
449
450 float phi;
451 if( (x*x+y*y+z*z) < kMinor) {
452 return;
453 }
454 else {
455 if(part == 1) {
456 phi = acos(x/sqrt(x*x+y*y));
457 if(y < 0) phi = 2.0*kPi - phi;
458 phi = fmod((phi + kPi/8.0), 2.0*kPi);
459 seg = int(phi/(kPi/4.0));
460 }
461 else {
462 if(x >= 0.0) {
463 if(y >= 0.0) {
464 seg = 0;
465 }
466 else {
467 seg = 3;
468 }
469 }
470 else {
471 if(y >= 0.0) {
472 seg = 1;
473 }
474 else {
475 seg = 2;
476 }
477 }
478 }
479 }
480}
481
482float
484{
485 if (!hit) {
486 cout << "RecMucTrack:GetHitDistance-E1 null hit pointer!" << endl;
487 return kInfinity;
488 }
489
490 int part = hit->Part();
491 int gap = hit->Gap();
492 if ( (gap < 0) || (gap >= (int)MucID::getGapNum(part)) ) {
493 cout << "RecMucTrack::GetHitDistance() bad gap number = " << gap << endl;
494 return kInfinity;
495 }
496
497 HepPoint3D posHit = hit->GetCenterPos();
498 HepPoint3D posHitLocal = hit->GetGap()->TransformToGap(posHit);
499 HepPoint3D posInsctLocal = hit->GetGap()->TransformToGap(m_CurrentInsct);
500 int orient = hit->GetGap()->Orient();
501
502 float distance = -9990;
503 if(orient == 1) distance = fabs(posInsctLocal.x() - posHitLocal.x());
504 if(orient == 0) distance = fabs(posInsctLocal.y() - posHitLocal.y());
505
506 return distance;
507}
508
509//not abs value
510float
512{
513 if (!hit) {
514 cout << "RecMucTrack:GetHitDistance-E1 null hit pointer!" << endl;
515 return kInfinity;
516 }
517
518 int part = hit->Part();
519 int gap = hit->Gap();
520 if ( (gap < 0) || (gap >= (int)MucID::getGapNum(part)) ) {
521 cout << "RecMucTrack::GetHitDistance() bad gap number = " << gap << endl;
522 return kInfinity;
523 }
524
525 HepPoint3D posHit = hit->GetCenterPos();
526 HepPoint3D posHitLocal = hit->GetGap()->TransformToGap(posHit);
527 HepPoint3D posInsctLocal = hit->GetGap()->TransformToGap(m_CurrentInsct);
528 int orient = hit->GetGap()->Orient();
529
530 float distance = -9990;
531 if(orient == 1) distance = (posInsctLocal.x() - posHitLocal.x());
532 if(orient == 0) distance = (posInsctLocal.y() - posHitLocal.y());
533
534 //cout<<"========in RecMucTrack: line insct: "<<posInsctLocal.x()<<" "<<posInsctLocal.y()<<" -> "<<posHitLocal.x()<<" "<<posHitLocal.y()<<endl;
535
536 return distance;
537}
538
539/// Calculate intersection from all hits attached on this gap.
540Hep3Vector
542 const int seg,
543 const int gap)
544{
545 MucGeoGap *gapPtr = MucGeoGeneral::Instance()->GetGap(part, seg, gap);
546 vector<int> hitSeq;
547 for(int i = 0; i < (int)m_pHits.size(); i++) {
548 MucRecHit *aHit = m_pHits[i];
549 if(aHit->Part() == part &&
550 aHit->Seg() == seg &&
551 aHit->Gap() == gap) {
552 hitSeq.push_back(i);
553 }
554 }
555 int nHitInGap = hitSeq.size();
556 //cout << "nHitInGap " << nHitInGap << endl;
557
558 HepPoint3D insctLocal = gapPtr->TransformToGap(m_CurrentInsct);
559 //HepPoint3D newInsct(0.0, 0.0, 0.0);
560 HepPoint3D newInsctLocal = insctLocal;
561
562 vector<float> x;
563 for(int i = 0; i < nHitInGap; i++) x.push_back(0);
564 float xInsct = 0, xNewInsct = 0;
565
566
567 int orient = gapPtr->Orient();
568 if(orient == 1) xInsct = insctLocal.x();
569 if(orient == 0) xInsct = insctLocal.y();
570
571 for(int i = 0; i < nHitInGap; i++) {
572 float xStrip, yStrip, zStrip;
573 (m_pHits[hitSeq[i]])->GetStrip()->GetCenterPos(xStrip, yStrip, zStrip);
574 if(orient == 1) x[i] = xStrip;
575 if(orient == 0) x[i] = yStrip;
576 }
577 //cout << "local Old" << insctLocal << endl;
578
579 //if == 0, no direction change;
580 if(nHitInGap > 0) {
581 xNewInsct = xInsct * kInsctWeight;
582
583 //float minDist = kInfinity;
584 for(int i = 0; i < nHitInGap; i++) {
585 //if(fabs(x[i] - xInsct) < minDist) {
586 //xNewInsct = x[i]; //}
587 xNewInsct += x[i] * ((1.0 - kInsctWeight) / nHitInGap);
588 }
589
590 if(orient == 1) {
591 newInsctLocal.setX(xNewInsct);
592 newInsctLocal.setY(insctLocal.y());
593 }
594 if(orient == 0) {
595 newInsctLocal.setX(insctLocal.x());
596 newInsctLocal.setY(xNewInsct);
597 }
598 }
599
600 m_CurrentInsct = gapPtr->TransformToGlobal(newInsctLocal);
601 //cout << "local New" << newInsctLocal << endl;
602 //cout << "global New" << m_CurrentInsct << endl;
603
604 return m_CurrentInsct;
605}
606
607void
609{
610 m_Intersections.push_back(insct);
611}
612
613void
615{
616 m_Directions.push_back(dir);
617}
618
619void
621{
622 //cout << "Before CorrectDir(), fCurrentDir " << m_CurrentDir << endl;
623 m_CurrentDir = m_CurrentInsct - m_CurrentPos;
624 m_CurrentDir.setMag(1.0);
625 //cout << "After CorrectDir(), fCurrentDir " << m_CurrentDir << endl;
626}
627
628void
630{
631 m_CurrentPos = m_CurrentInsct;
632}
633
634void
636{
637 int lastGap1, lastGap2;
638 int firstGap1, firstGap2;
639 lastGap1 = lastGap2 = -1;
640 firstGap1 = firstGap2 = 99;
641 vector<MucRecHit*>::const_iterator iHit;
642 iHit = m_pHits.begin();
643 for( ;iHit != m_pHits.end(); iHit++)
644 {
645 if(*iHit)
646 { // Check for a null pointer.
647 int part = (*iHit)->Part();
648 int gap = (*iHit)->Gap();
649
650 if(part == 1) {
651 if(gap > lastGap1) lastGap1 = gap;
652 if(gap < firstGap1) firstGap1 = gap;
653 }
654 else {
655 if(gap > lastGap2) { m_ecPart = part; m_endPart = part; lastGap2 = gap; }
656 if(gap < firstGap2) firstGap2 = gap;
657 }
658 }
659 }
660
661 m_brLastLayer = lastGap1;
662 if(firstGap1 == 99) m_brFirstLayer = -1;
663 else if(firstGap1>=0&&firstGap1<9) m_brFirstLayer = firstGap1;
664
665 m_ecLastLayer = lastGap2;
666 if(firstGap2 == 99) m_ecFirstLayer = -1;
667 else if(firstGap2>=0&&firstGap2<8) m_ecFirstLayer = firstGap2;
668
669 //cout<<"MucTrack, br: "<<m_brFirstLayer<<", "<<m_brLastLayer<<"\tec: "<<m_ecFirstLayer<<", "<<m_ecLastLayer<<endl;
670}
671
672int
674{
675 if( m_numLayers == 0 ) {
676 m_depth = m_depth_3 = -99; return 0;
677 }
678 else if( m_numLayers == 1 && (m_brLastLayer == 0 || m_ecLastLayer == 0) ) {
679 m_depth = m_depth_3 = 0; return 0;
680 }
681
682 m_depth_3 = 0.0;
683
684 float brThickness = 0.0; float ecThickness = 0.0; float deltaPhi = 0.0;
685 int betweenSeg = 0;
686
687 float phi = m_MucMomentum.phi();
688 float theta = m_MucMomentum.theta();
689
690 vector<MucRecHit*>::const_iterator iHit;
691 int ngap = MucID::getGapMax();
692 //cout<<"ngap:\t"<<ngap<<endl;
693
694 int Seg[9]; int part, seg, gap, strip;
695 for(int gap = 0; gap < ngap; gap++){Seg[gap] = -1;}
696 for(iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
697 if(*iHit) { // Check for a null pointer.
698 part = (*iHit)->Part();
699 seg = (*iHit)->Seg();
700 gap = (*iHit)->Gap();
701 strip = (*iHit)->Strip();
702 if(part==1) Seg[gap] = seg;
703 }
704 }
705
706 int segTrackBr = -1;
707 for(int gap = 0; gap <= brLastLayer(); gap++){
708 if(Seg[gap] != -1) segTrackBr = Seg[gap];
709 }
710 // BR, the innermost layer is RPC module
711 for(int gap = 0; gap <= brLastLayer(); gap++){
712 float thickness = 0.0;
713 if(Seg[gap] != -1 && Seg[brLastLayer()-1] != -1 && Seg[gap] != Seg[brLastLayer()-1]) betweenSeg = 1;
714 thickness = MucGeoGeneral::Instance()->GetGap(1, 0, gap)->GetIronThickness();
715 //cout<<"RecMucTrack gap="<<gap<<" brlastgap="<<brLastLayer()<<" "<<thickness<<endl;
716 if(sin(m_MucMomentum.theta()) != 0 ) thickness /= sin(m_MucMomentum.theta());
717 else ;//cout<<"RecMucTrack::ComputeDepth, In Barrel,theta=0?"<<endl;
718 deltaPhi = m_MucMomentum.phi() - segTrackBr*kPi/4;
719 if(Seg[gap] == -1 && betweenSeg == 1) {
720 thickness += 40; // gap width
721 }
722 if(cos(deltaPhi) != 0 ) thickness /= cos(deltaPhi);
723 else ;//cout<<"RecMucTrack::ComputeDepth, In Barrel,Cos(phi)=0?"<<endl;
724 if(deltaPhi == 0 && Seg[brLastLayer()-1]==2 ) thickness = 0;
725 //cout<<"in muctrack "<<thickness<<" "<<brThickness<<" theta "<<m_MucMomentum.theta()<<" phi="<<deltaPhi<<" "<<m_MucMomentum.phi()<<endl;
726
727 if(brFirstLayer()<brLastLayer()) brThickness += thickness;
728 else if(brFirstLayer()==brLastLayer()) { //only one gap
729 if(m_MucMomentum.mag()>1000 || brFirstLayer()<2) brThickness += thickness; //high momentum or only one or two gap
730 //cout<<"mom="<<m_MucMomentum.mag()<<" "<<brFirstLayer()<<" "<<brThickness<<" "<<thickness<<endl;
731 }
732 else cout<<"in RecMucTrack: Wrong Gap Info"<<endl;
733
734 //cout<<brThickness<<endl;
735 }
736
737 //cout<<"eclastgap= "<<ecLastLayer()<<" ecfirstgap= "<<ecFirstLayer()<<endl;
738
739 // EC, the innermost layer is Iron
740 //for (int gap = ecFirstLayer(); gap!=-1&&gap <= ecLastLayer(); gap++) {
741 for (int gap = 0; gap!=-1&&gap <= ecLastLayer(); gap++) {
742 ecThickness += MucGeoGeneral::Instance()->GetGap(0, 0, gap)->GetIronThickness();
743 }
744
745 if (cos(theta) != 0.0) ecThickness /= cos(theta);
746 else ;//cout << "RecMucTrack::ComputeDepth, In EndCap, Track theta = 90.0 ? " << endl;
747 ecThickness = fabs(ecThickness);
748
749 //cout<<"eclastgap= "<<ecLastLayer()<<" ecthickness="<<ecThickness<<endl;
750
751 if(method == 2){
752 //barrel first
753 if((m_Good3DLine == 1) &&(m_Good3DPart == 1)){
754 if(m_IntersectionInner[0].x()!=-9999){
755 for(int gap = 1;gap <= brLastLayer(); gap++)//Inner[gap1]-Outer[gap0] ...
756 {
757 if(m_IntersectionInner[gap].x() != -9999 && m_IntersectionInner[gap-1].x() != -9999)
758 m_depth_3 += (m_IntersectionInner[gap] - m_IntersectionOuter[gap-1]).mag();
759 }
760 //may be pass some gap in endcap!
761 m_depth_3 += ecThickness;
762 }
763 else m_depth_3 = brThickness + ecThickness;
764 }
765 if((m_Good3DLine == 1) &&(m_Good3DPart != 1)){
766 for(int gap = 1;gap <= ecLastLayer(); gap++)//Inner[gap1]-Outer[gap0] ...
767 {
768 if(m_IntersectionInner[gap].x() != -9999 && m_IntersectionInner[gap-1].x() != -9999)
769 m_depth_3 += (m_IntersectionInner[gap] - m_IntersectionOuter[gap-1]).mag();
770 }
771 //may be pass some gap in barrel!
772 m_depth_3 += brThickness;
773 if (cos(theta) != 0.0) m_depth_3 += 40/cos(theta); //there is 1 absorber before first gap in endcap!
774 }
775 if(m_Good3DLine == 0) m_depth_3 = brThickness + ecThickness;
776 if(m_depth_3>2000) m_depth_3 = brThickness + ecThickness; //unreasonable depth! so use previous method!
777 }
778 else //method == 1 linefit
779 {
780 m_depth_3 = brThickness + ecThickness;
781
782 }
783
784 double offset = 50.0;
785 //if(GetTotalHits() > 0) m_depth_3 += offset;
786
787 m_depth = m_depth_3;
788
789 //if(m_depth<0||m_depth>2000) m_depth = 0;
790 if(m_depth>2000) m_depth = -99;
791 //cout<<"depth= "<<m_depth<<endl;
792
793}
794
795void
797{
798 m_depth = -99.0;
799 // Part 1 first.
800 float brThickness = 0.0;
801 for (int gap = 0; gap <= brLastLayer(); gap++) {
802 brThickness += MucGeoGeneral::Instance()->GetGap(1, 0, gap)->GetIronThickness();
803 }
804
805 // second alg
806 float brThickness_2 = 0.0;
807 for (int gap = 0; gap <= brLastLayer(); gap++) {
808 if(HasHitInGap(1,gap)){
809 brThickness_2 += MucGeoGeneral::Instance()->GetGap(1, 0, gap)->GetIronThickness();
810 }
811 }
812 // third alg
813 float brThickness_3 = 0.0;
814 vector<MucRecHit*>::const_iterator iHit;
815 int ngap = MucID::getGapMax();
816 int Seg[9]; int part, seg, gap, strip;
817 for(int gap = 0; gap < ngap; gap++){Seg[gap] = -1;}
818 for(iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
819 if(*iHit) { // Check for a null pointer.
820 part = (*iHit)->Part();
821 seg = (*iHit)->Seg();
822 gap = (*iHit)->Gap();
823 strip = (*iHit)->Strip();
824 if(part==1) Seg[gap] = seg;
825 }
826 }
827
828 float deltaPhi_3 = 0.0;
829 int betweenSeg = 0;
830
831 int segTrackBr = -1;
832 for(int gap = 0; gap <= brLastLayer(); gap++){
833 if(Seg[gap] != -1) segTrackBr = Seg[gap];
834 }
835
836 for(int gap = 0; gap <= brLastLayer(); gap++){
837 float thickness = 0.0;
838 if(Seg[gap] != -1 && Seg[brLastLayer()-1] != -1 && Seg[gap] != Seg[brLastLayer()-1]) betweenSeg = 1;
839 thickness = MucGeoGeneral::Instance()->GetGap(1, 0, gap)->GetIronThickness();
840 if(sin(m_MucMomentum.theta()) != 0 ) thickness /= sin(m_MucMomentum.theta());
841 else cout<<"RecMucTrack::ComputeDepth, In Barrel,theta=0?"<<endl;
842 //if(Seg[gap] != -1) deltaPhi_3 = m_MucMomentum.phi() - Seg[gap]*kPi/4;
843 deltaPhi_3 = m_MucMomentum.phi() - segTrackBr*kPi/4; //some times, no hits in a gap, but a good track exist!
844 if(Seg[gap] == -1 && betweenSeg == 1) {
845 cout<<"between segment"<<endl;
846 thickness += 40; // gap width
847 }
848
849 if(cos(deltaPhi_3) != 0 ) thickness /= cos(deltaPhi_3);
850 else cout<<"RecMucTrack::ComputeDepth, In Barrel,Cos(phi)=0?"<<endl;
851
852 if(deltaPhi_3 == 0 && Seg[brLastLayer()-1]==2 ) thickness = 0;
853 //cout<<"in muctrack "<<thickness<<" "<<brThickness_3<<" theta "<<m_MucMomentum.theta()<<" phi="<<deltaPhi_3<<" "<<m_MucMomentum.phi()<<endl;
854 brThickness_3 += thickness;
855
856 }
857
858 //cout<<"in RecMucTrack: compare thickness "<<brThickness<<" "<<brThickness_2<<" "<<brThickness_3<<endl;
859
860 float phi = m_MucMomentum.phi();
861 float deltaPhi = phi - kPi/4*(int)(phi/(kPi/4));
862 if (deltaPhi > kPi/8) deltaPhi = kPi/4 - deltaPhi;
863 float theta = m_MucMomentum.theta();
864// cout << "br LastGap " << brLastLayer() << " Thick " << brThickness
865// << " 1/sin(theta) " << 1/sin(theta) << " 1/cos(deltaPhi) " << 1/cos(deltaPhi) << endl;
866
867 if (sin(theta) != 0.0) brThickness /= sin(theta);
868 else cout << "RecMucTrack::ComputeDepth, In Barrel, Track theta = 0.0 ? " << endl;
869
870 brThickness /= cos(deltaPhi);
871 brThickness = fabs(brThickness);
872 //cout << "br Depth " << brThickness << endl;
873
874 // EC, then
875 float ecThickness = 0.0;
876 for (int gap = 0; gap <= ecLastLayer(); gap++) {
877 ecThickness += MucGeoGeneral::Instance()->GetGap(0, 0, gap)->GetIronThickness();
878 }
879 //cout << "ec LastGap " << ecLastLayer() << " Thick " << ecThickness
880 // << " 1/cos(theta) " << 1/cos(theta) << endl;
881
882 if (cos(theta) != 0.0) ecThickness /= cos(theta);
883 else ; //cout << "RecMucTrack::ComputeDepth, In EndCap, Track theta = 90.0 ? " << endl;
884 ecThickness = fabs(ecThickness);
885 //cout << "ec Depth " << ecThickness << endl;
886
887 m_depth = brThickness + ecThickness;
888 m_depth_3 = brThickness_3 + ecThickness;
889 cout << "Depth " << m_depth << " Depth3 = "<<m_depth_3<<endl;
890 m_depth = m_depth_3;
891 double offset = 50.0;
892 if(GetTotalHits() > 0) m_depth += offset; // since brThickness on gap 0 is zero, give an offset for track arriving muc.
893
894}
895
896void
898{
899 bool firstHitFound = false;
900 MucGeoGap *firstGap = 0;
901 vector<MucRecHit*>::const_iterator iHit;
902 vector<MucRecHit*> hitsGap0;
903 float stripLocal[3]={0.0, 0.0, 0.0};
904 float stripGlobal[3]={0.0, 0.0, 0.0};
905 int nStrip = 0;
906
907 int part, seg, gap, strip;
908 int barrel_gap0_exist = 0;
909
910 for(iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
911 if(*iHit) { // Check for a null pointer.
912 part = (*iHit)->Part();
913 seg = (*iHit)->Seg();
914 gap = (*iHit)->Gap();
915 strip = (*iHit)->Strip();
916 if(!firstHitFound && gap == 0) {
917 firstGap = MucGeoGeneral::Instance()->GetGap(part, seg, gap);
918 firstHitFound = true;
919 }
920 if(firstGap && part == firstGap->Part() && seg == firstGap->Seg() && gap == firstGap->Gap()) {
921 //cout<<"in RecMucTrack "<<part<<" "<<seg<<" "<<gap<<" "<<strip<<endl;
922 HepPoint3D posHit = (*iHit)->GetCenterPos();
923 HepPoint3D posHitLocal = (*iHit)->GetGap()->TransformToGap(posHit);
924 if(part==1&&gap==0) barrel_gap0_exist = 1; //exist
925
926 stripLocal[0] += posHitLocal.x();
927 stripLocal[1] += posHitLocal.y();
928 stripLocal[2] += posHitLocal.z();
929
930 stripGlobal[0] += posHit.x(); //to calc phi of this strip
931 stripGlobal[1] += posHit.y();
932 stripGlobal[2] += posHit.z();
933
934 nStrip++;
935 }
936 }
937 }
938
939 //cout<<"in RecMucTrack: extpos "<<m_ExtMucPos<<" mucpos "<< m_MucPos<<endl;
940
941 int apart = -1, aseg = -1;
942 int nHits = FindSegWithMaxHits(apart, aseg);
943 MucGeoGap *fakefirstGap = 0; // maybe not exist!
944 if(apart == -1 && aseg== -1)
945 {m_Dist_muc_ext.set(0,0,0);}
946 else {
947 fakefirstGap = MucGeoGeneral::Instance()->GetGap(apart, aseg, 0);
948 HepPoint3D fextLocal = fakefirstGap->TransformToGap(m_ExtMucPos);
949 HepPoint3D fmucLocal = fakefirstGap->TransformToGap(m_MucPos);
950 float dist_x = fextLocal.x() - fmucLocal.x();
951 float dist_y = fextLocal.y() - fmucLocal.y();
952 float dist_z = fextLocal.z() - fmucLocal.z();
953 m_Dist_muc_ext.set(dist_x,dist_y,dist_z);
954 //cout<<"in RecMucTrack dist = "<<dist_x<<" "<<dist_y<<" "<<dist_z<<endl;
955 if (fakefirstGap->Orient() == 0) { // part 0,2
956 //cout<<"in RecMucTrack "<< extLocal.y()<<" "<<stripLocal[1]<<endl;
957 }
958 else {
959 //cout<<"in RecMucTrack1 "<< extLocal.x()<<" "<<stripLocal[0]<<endl;
960 }
961 }
962
963 float distance = -9990;
964
965 if (nStrip == 0 || !firstGap) {
966 distance = -9990;
967 //cout << "no hits on first gap" << endl;
968 }
969 else{
970 for (int k = 0; k < 3; k++) stripLocal[k] /= nStrip;
971 for (int k = 0; k < 3; k++) stripGlobal[k] /= nStrip;
972
973 m_StripPhi.set(stripGlobal[0],stripGlobal[1],stripGlobal[2]);
974
975 HepPoint3D extLocal = firstGap->TransformToGap(m_ExtMucPos);
976 // extmucpos may be can be used to identify mu/pion
977
978// cout<<"in RecMucTrack mom "<<m_MucMomentum.x()<<" "<<m_MucMomentum.y()<<" "<<m_MucMomentum.z()<<endl;
979// cout<<"in RecMucTrack extpos "<<m_ExtMucPos.x()<<" "<<m_ExtMucPos.y()<<" "<<m_ExtMucPos.z()<<endl;
980// cout<<"in RecMucTrack extpos2 "<<ExtMucPos_2.x()<<" "<<ExtMucPos_2.y()<<" "<<ExtMucPos_2.z()<<endl;
981// cout<<"in RecMucTrack extloc "<<extLocal.x()<<" "<<extLocal.y()<<" "<<extLocal.z()<<endl;
982 if (firstGap->Orient() == 0) { // part 0,2
983 distance = extLocal.y() - stripLocal[1];
984 //cout<<"in RecMucTrack "<< extLocal.y()<<" "<<stripLocal[1]<<endl;
985 }
986 else {
987 distance = extLocal.x() - stripLocal[0];
988 //cout<<"in RecMucTrack1 "<< extLocal.x()<<" "<<stripLocal[0]<<endl;
989 }
990 }
991
993
994 //use m_chi2 temporary
995 //m_chi2 = distance;
996 // cout<<"in RecMucTrack distance= "<<m_distance<<" n= "<<nStrip<<endl;
997}
998
999void
1001{
1002 float x = m_ExtMucPos.x(), y = m_ExtMucPos.y(), z = m_ExtMucPos.z();
1003 //cout<<"in MucTrac, MucPos= "<<x<<" "<<y<<" "<<z<<endl;
1004 float step = 0.005;
1005 float myMucR = 1720.0;
1006 float myMucZ = 2110.0;
1007
1008 while ( ( (fabs(x)<=myMucR) && (fabs(y)<=myMucR) && ((fabs(x-y)/sqrt(2.))<=myMucR) && ((fabs(x+y)/sqrt(2.))<=myMucR) && (fabs(z)<=myMucZ) ) ) {
1009 x += step * m_MucMomentum.x();
1010 y += step * m_MucMomentum.y();
1011 z += step * m_MucMomentum.z();
1012 //cout << "in RecMucTrack+ x " << x << " y " << y << " z " << z <<" mom "<< m_MucMomentum.x()<< " "<<m_MucMomentum.y()<<" "<<m_MucMomentum.z()<<endl;
1013 }
1014
1015 int count = 0;
1016 while( !( (fabs(x)<=myMucR) && (fabs(y)<=myMucR) && ((fabs(x-y)/sqrt(2.))<=myMucR) && ((fabs(x+y)/sqrt(2.))<=myMucR) && (fabs(z)<=myMucZ) )&&count<1000 ) {
1017 x -= step * m_MucMomentum.x();
1018 y -= step * m_MucMomentum.y();
1019 z -= step * m_MucMomentum.z();
1020 count++;
1021 //cout << "in RecMucTrack- x " << x << " y " << y << " z " << z <<" mom "<< m_MucMomentum.x()<< " "<<m_MucMomentum.y()<<" "<<m_MucMomentum.z()<<endl;
1022 }
1023
1024 if(count<1000){
1025 if(fabs(x)<2600&&fabs(y)<2600&&fabs(z)<2800){
1026 m_ExtMucPos.set(x, y, z);
1027 m_MucPos.set(x,y,z);
1028 m_xPos = x;
1029 m_yPos = y;
1030 m_zPos = z;
1031 }
1032 }
1033
1034}
1035
1036void
1037RecMucTrack::LineFit(int fittingMethod)
1038{
1039 Extend();
1040
1041 int part = -1, seg = -1;
1042 int nHits = FindSegWithMaxHits(part, seg);
1043// cout << "RecMucTrack::ComputeDepth(), part " << part << " seg " << seg
1044// << " contains most hits " << nHits << endl;
1045 if (part < 0 || seg < 0) {
1046 m_depth = 0;
1047 //cout << "No hit in this track" << endl;
1048 return;
1049 }
1050
1051 float startPos[3] = {0.0, 0.0, 0.0};
1052 MucRec2DRoad road2D[2];
1053 vector<MucRecHit*>::const_iterator iHit;
1054 for (int orient = 0; orient <= 1; orient++) {
1055 road2D[orient] = MucRec2DRoad(part, seg, orient, startPos[0], startPos[1], startPos[2],fittingMethod );
1056 for(iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1057 if(*iHit) { // Check for a null pointer.
1058 int hitPart = (*iHit)->Part();
1059 int hitSeg = (*iHit)->Seg();
1060 int hitOrient = (*iHit)->GetGap()->Orient();
1061 if (hitPart == part && hitSeg == seg && hitOrient == orient) {
1062 road2D[orient].AttachHit(*iHit);
1063 }
1064 }
1065 }
1066 //cout << "Orient " << orient
1067 // << " Slope " << road2D[orient].GetSlope()
1068 // << " Intercept " << road2D[orient].GetIntercept()
1069 // << " LastGap " << road2D[orient].GetLastGap()
1070 // << endl;
1071
1072 }
1073 MucRec3DRoad road3D(&road2D[0], &road2D[1]);
1074 float vx, vy, x0, y0;
1075 if ( road3D.GetPart() == 1 ){
1076 road3D.TransformPhiRToXY( road2D[1].GetSlope(), road2D[0].GetSlope(),
1077 road2D[1].GetIntercept(), road2D[0].GetIntercept(),
1078 vx, vy, x0, y0);
1079 }
1080 else {
1081 vx = road2D[1].GetSlope();
1082 x0 = road2D[1].GetIntercept();
1083 vy = road2D[0].GetSlope();
1084 y0 = road2D[0].GetIntercept();
1085 }
1086
1087 //cout << "road3D Last Gap " << road3D.GetLastGap() << endl;
1088 //cout << "vx " << vx << " x0 " << x0 << " vy " << vy << " y0 " << y0 << endl;
1089
1090 // if number of gaps with hits >= 2 on both orient, change muc pos and momentum
1091 if (road2D[0].GetNGapsWithHits() >= 2 && road2D[1].GetNGapsWithHits() >= 2) {
1092
1093 //good 3d road!!!
1094 m_Good3DLine = 1;
1095 m_status = 1;
1096
1097 m_Good3DPart = road3D.GetPart();
1098 road3D.SetSimpleFitParams(vx, x0, vy, y0);
1099 //road3D.PrintHitsInfo();
1100
1101 float startx = 0.0, starty = 0.0, startz = 0.0;
1102 float startxSigma = 0.0, startySigma = 0.0, startzSigma = 0.0;
1103 float x1 = 0.0, y1 = 0.0, z1 = 0.0, x2 = 0.0, y2 = 0.0, z2 = 0.0;
1104 int gap = 0;
1105
1106 if(fittingMethod==2){ //if choose quadratic fitting method!
1107 for(int igap=0; igap<9;igap++){
1108 road3D.Project(igap, x1, y1, z1, x2, y2, z2);
1109 m_IntersectionInner[igap].set(x1,y1,z1);
1110 m_IntersectionOuter[igap].set(x2,y2,z2);
1111 //cout<<"3dproject sur "<<x1<<" "<<y1<<" "<<z1<<" "<<x2<<" "<<y2<<" "<<z2<<endl;
1112 }
1113 }
1114
1115 do {
1116 //road3D.Project(gap, startx, starty, startz);
1117 road3D.ProjectWithSigma(gap, startx, starty, startz, startxSigma, startySigma, startzSigma);
1118 gap++;
1119 }
1120 while ( (startx*startx + starty*starty + startz*startz) < kMinor &&
1121 gap < (int)MucID::getGapNum(part) );
1122
1123 if(fabs(startx)<2600&&fabs(starty)<2600&&fabs(startz)<2800){
1124 Hep3Vector MucPos_self;
1125 MucPos_self.set(startx, starty, startz);
1126 float dist = (MucPos_self - m_MucPos).mag();
1127
1128 if(dist < 1000 ){ // (mm) maybe the fit is bad, if the dist is too big.
1129 m_MucPos.set(startx, starty, startz);
1130 m_xPos = startx;
1131 m_yPos = starty;
1132 m_zPos = startz;
1133 }
1134 }
1135 m_MucPosSigma.set(startxSigma, startySigma, startzSigma);
1136 m_xPosSigma = startxSigma;
1137 m_yPosSigma = startySigma;
1138 m_zPosSigma = startzSigma;
1139
1140 //cout<<"in RecMucTrack gap= "<<gap<<" start= "<<startx<<" "<<starty<<" "<<startz<<" "<<endl;
1141 float momentum = m_MucMomentum.mag();
1142 float zDir = 1.0;
1143 if (m_MucMomentum.z() != 0.0) zDir = m_MucMomentum.z() / fabs(m_MucMomentum.z());
1144
1145 float px = road3D.GetSlopeZX()*zDir;
1146 float py = road3D.GetSlopeZY()*zDir;
1147 float pz = zDir;
1148 float segPhi = 0.25*kPi*seg;
1149 // if vr is opposite to original, but both are very small, e.x. -0.01 -> + 0.01, or you can say, pt~p, change it to guarantee vx, vy is correct.
1150 if (part == 1 && px*cos(segPhi)+py*sin(segPhi) < 0.0) { // when in barrel, pt dot segPhi < 0, angle between them > 90deg
1151 px *= -1.0;
1152 py *= -1.0;
1153 pz *= -1.0;
1154 }
1155
1156 //if(sqrt(px*px+py*py)>0.01)m_MucMomentum.set(px, py, pz);
1157 m_MucMomentum.set(px, py, pz);
1158 m_MucMomentum.setMag(momentum);
1159
1160 m_px = px; m_py = py; m_pz = pz;
1161 Hep3Vector phi_mdc, phi_muc;
1162 phi_mdc.set(m_MdcMomentum.x(),m_MdcMomentum.y(),0);
1163 phi_muc.set(px,py,0);
1164 double deltaPhi = phi_mdc.angle(phi_muc);
1165
1167 m_dof = road3D.GetDegreesOfFreedom();
1168 m_chi2 = road3D.GetReducedChiSquare();
1169 if(m_chi2<0||m_chi2>1000) m_chi2 = 0;
1170 m_rms = 0.0; // road3D.GetReducedChiSquare(); // ??? in MucRecRoad3D
1171
1172
1173 if(road2D[0].GetNGapsWithHits() >= 3 && road2D[1].GetNGapsWithHits() >= 3){ //need 3+ gap to do refit
1174 //calc distance between each hit with this track.
1175 //use GetHitDistance(), so we should provide m_CurrentInsct.
1176 float xInsct = 0.0, yInsct = 0.0, zInsct = 0.0, sigmax = 0.0, sigmay = 0.0, sigmaz = 0.0;
1177 float quad_x1 = 0.0, quad_y1 = 0.0, quad_z1 = 0.0, quad_x2 = 0.0, quad_y2 = 0.0, quad_z2 = 0.0;
1178 for(int ihit = 0; ihit < m_pHits.size(); ihit++){
1179 int igap = (m_pHits[ihit])->Gap();
1180 road3D.ProjectNoCurrentGap(igap, xInsct, yInsct, zInsct, sigmax, sigmay, sigmaz,
1181 quad_x1, quad_y1, quad_z1, quad_x2, quad_y2, quad_z2);
1182
1183 SetCurrentInsct(xInsct, yInsct, zInsct);
1184
1185 float dist_hit_track = GetHitDistance2(m_pHits[ihit]);
1186 m_distHits.push_back(dist_hit_track);
1187
1188 //cout<<"===========in RecMucTrack: line dist: "<<dist_hit_track<<endl;
1189
1190 if(fittingMethod==2) // ------calc local insct in a gap with quad line.
1191 {
1192
1193 Hep3Vector center = m_pHits[ihit]->GetCenterPos();
1194 int iPart = m_pHits[ihit]->Part();
1195 int iSeg = m_pHits[ihit]->Seg();
1196 int iGap = m_pHits[ihit]->Gap();
1197 float xHit, yHit, zHit = 0.;
1198 if (iPart == 1) {
1199 if ( iGap %2 == 1) {
1200 xHit = center.z();
1201 yHit = sqrt(center.x()*center.x()
1202 + center.y()*center.y());
1203 if(iSeg==2) yHit = center.y(); //deal with seg2 seperately! because there is a hole here. 2006.11.9
1204 }
1205 else {
1206 xHit = center.x();
1207 yHit = center.y();
1208 }
1209 }
1210 else {
1211 if ( iGap %2 == 0) {
1212 xHit = center.z();
1213 yHit = center.y();
1214 }
1215 else {
1216 xHit = center.z();
1217 yHit = center.x();
1218 }
1219 }
1220
1221 float distance1 = fabs(xHit - quad_x1)/(xHit - quad_x1) * sqrt((xHit - quad_x1)*(xHit - quad_x1) + (yHit - quad_y1)*(yHit - quad_y1));
1222 float distance2 = fabs(xHit - quad_x2)/(xHit - quad_x2) * sqrt((xHit - quad_x2)*(xHit - quad_x2) + (yHit - quad_y2)*(yHit - quad_y2));
1223
1224 float dist_quad = distance1;
1225 if(fabs(distance1) > fabs(distance2)) dist_quad = distance2;
1226
1227 //cout<<"============in RecMucTrack: quad xyz: "<<quad_x1<<" "<<quad_y1<<" "<<quad_z1<<" "<<quad_x2<<" "<<quad_y2<<endl;
1228 //cout<<"============in RecMucTrack: hit pos: "<<xHit<<" "<<yHit<<" "<<zHit<<endl;
1229 //cout<<"============in RecMucTrack: dist1 = "<<distance1<<" dist2 = "<<distance2<<" dist ="<<dist_quad<<endl;
1230
1231 if(quad_x1 == -9999) m_distHits_quad.push_back(-99);
1232 else m_distHits_quad.push_back(dist_quad);
1233
1234 }
1235 }
1236 }
1237 else{
1238 for(int ihit = 0; ihit < m_pHits.size(); ihit++){
1239 m_distHits.push_back(-99);
1240 m_distHits_quad.push_back(-99);
1241 }
1242 }
1243 //////////////////////////////////////
1244
1245 ///////////////find expected strips for this 3D road
1247 //HepPoint3D initPos(startx, starty,startz);
1248 HepPoint3D initPos(startx-m_MucMomentum.x()/momentum, starty-m_MucMomentum.y()/momentum,startz-m_MucMomentum.z()/momentum);
1249
1250 //for(int igap = 0; igap <= m_brLastLayer; igap++){
1251 for(int igap = 0; igap < 9 ; igap++){
1252 vector<int> padID;
1253 vector<float> intersect_x;
1254 vector<float> intersect_y;
1255 vector<float> intersect_z;
1256
1257 //refit---------------------------------
1258 float zx, zy, x0, y0;
1259 int status = road3D.RefitNoCurrentGap(igap,zx,x0,zy,y0);
1260 Hep3Vector mom_refit;
1261 if(status == 0){ //refit succeed
1262 float zDir = 1.0;
1263 if (m_MucMomentum.z() != 0.0) zDir = m_MucMomentum.z() / fabs(m_MucMomentum.z());
1264 float px_refit = zx * zDir;
1265 float py_refit = zy * zDir;
1266 float pz_refit = zDir;
1267 float segPhi = 0.25*kPi*seg;
1268 // if vr is opposite to original, but both are very small, e.x. -0.01 -> + 0.01, or you can say, pt~p, change it to guarantee vx, vy is correct.
1269 if (part == 1 && px_refit*cos(segPhi)+py_refit*sin(segPhi) < 0.0) { // when in barrel, pt dot segPhi < 0, angle between them > 90deg
1270 px_refit *= -1.0;
1271 py_refit *= -1.0;
1272 pz_refit *= -1.0;
1273 }
1274
1275 mom_refit.setX(px_refit);
1276 mom_refit.setY(py_refit);
1277 mom_refit.setZ(pz_refit);
1278 mom_refit.setMag(momentum);
1279 }
1280 else mom_refit = m_MucMomentum; //use the former momentum
1281
1282 HepPoint3D initPos_refit;
1283 if(status == 0){
1284 float initPosx_refit, initPosy_refit, initPosz_refit;
1285 float sigmax_refit, sigmay_refit, sigmaz_refit;
1286 road3D.Project(0, zx, x0, zy, y0, initPosx_refit, initPosy_refit, initPosz_refit);
1287 initPos_refit.setX(initPosx_refit-mom_refit.x()/momentum);
1288 initPos_refit.setY(initPosy_refit-mom_refit.y()/momentum);
1289 initPos_refit.setZ(initPosz_refit-mom_refit.z()/momentum);
1290 }
1291 else initPos_refit = initPos;
1292
1293 //cout<<"initPos: "<<initPos<<" "<<initPos_refit<<endl;
1294 //if((initPos - initPos_refit).mag()>100) cout<<"--------=====------to far"<<endl;
1295 //refit---------------------------------
1296 //cout<<"no gap: "<<igap<<" mom: "<<m_MucMomentum<<" refit: "<<mom_refit<<endl;
1297
1298 //vector<Identifier> MuId = road3D.ProjectToStrip(1,igap,initPos,m_MucMomentum,padID,intersect_x,intersect_y,intersect_z);
1299 vector<Identifier> MuId = road3D.ProjectToStrip(1,igap,initPos_refit,mom_refit,padID,intersect_x,intersect_y,intersect_z);
1300
1301 //vector<Identifier> MuId = road3D.ProjectToStrip(1,igap,initPos,mom_refit,padID,intersect_x,intersect_y,intersect_z);
1302
1303 vector<Identifier>::const_iterator mucid;
1304 int i = 0;
1305 for(mucid = MuId.begin(); mucid != MuId.end(); mucid++,i++)
1306 {
1307 MucRecHit *pHit = new MucRecHit(MucID::part(*mucid),MucID::seg(*mucid),MucID::gap(*mucid),MucID::strip(*mucid));
1308 pHit->SetPadID(padID[i]);
1309 pHit->SetIntersectX(intersect_x[i]);
1310 pHit->SetIntersectY(intersect_y[i]);
1311 pHit->SetIntersectZ(intersect_z[i]);
1312
1313 m_pExpectedHits.push_back(pHit);
1314 }
1315 }
1316
1317 if(m_endPart!=-1&&m_ecLastLayer!=-1)
1318 {
1319 //for(int igap = 0; igap <= m_ecLastLayer; igap++){
1320 for(int igap = 0; igap < 8; igap++){
1321 vector<int> padID;
1322 vector<float> intersect_x;
1323 vector<float> intersect_y;
1324 vector<float> intersect_z;
1325
1326 //refit---------------------------------
1327 float zx, zy, x0, y0;
1328 //int status = road3D.RefitNoCurrentGap(igap,zy,y0,zx,x0); //!!!!!different sequence
1329 int status = road3D.RefitNoCurrentGap(igap,zx,x0,zy,y0);
1330 Hep3Vector mom_refit;
1331 if(status == 0){ //refit succeed
1332 float zDir = 1.0;
1333 if (m_MucMomentum.z() != 0.0) zDir = m_MucMomentum.z() / fabs(m_MucMomentum.z());
1334 float px_refit = zx * zDir;
1335 float py_refit = zy * zDir;
1336 float pz_refit = zDir;
1337 float segPhi = 0.25*kPi*seg;
1338 // if vr is opposite to original, but both are very small, e.x. -0.01 -> + 0.01, or you can say, pt~p, change it to guarantee vx, vy is correct.
1339 if (part == 1 && px_refit*cos(segPhi)+py_refit*sin(segPhi) < 0.0) { // when in barrel, pt dot segPhi < 0, angle between them > 90deg
1340 px_refit *= -1.0;
1341 py_refit *= -1.0;
1342 pz_refit *= -1.0;
1343 }
1344
1345 mom_refit.setX(px_refit);
1346 mom_refit.setY(py_refit);
1347 mom_refit.setZ(pz_refit);
1348 mom_refit.setMag(momentum);
1349 }
1350 else mom_refit = m_MucMomentum; //use the former momentum
1351
1352 HepPoint3D initPos_refit;
1353 if(status == 0){
1354 float initPosx_refit, initPosy_refit, initPosz_refit;
1355 float sigmax_refit, sigmay_refit, sigmaz_refit;
1356 road3D.Project(0, zx, x0, zy, y0, initPosx_refit, initPosy_refit, initPosz_refit);
1357 initPos_refit.setX(initPosx_refit-mom_refit.x()/momentum);
1358 initPos_refit.setY(initPosy_refit-mom_refit.y()/momentum);
1359 initPos_refit.setZ(initPosz_refit-mom_refit.z()/momentum);
1360 }
1361 else initPos_refit = initPos;
1362 //refit---------------------------------
1363 //cout<<"mom: "<<m_MucMomentum<<" "<<mom_refit<<" pos: "<<initPos<<" "<<initPos_refit<<endl;
1364 //vector<Identifier> MuId = road3D.ProjectToStrip(m_endPart,igap,initPos,m_MucMomentum,padID,intersect_x,intersect_y,intersect_z);
1365
1366 vector<Identifier> MuId = road3D.ProjectToStrip(m_endPart,igap,initPos_refit,mom_refit,padID,intersect_x,intersect_y,intersect_z);
1367
1368 vector<Identifier>::const_iterator mucid;
1369 int i = 0;
1370 for(mucid = MuId.begin(); mucid != MuId.end(); mucid++,i++)
1371 {
1372 MucRecHit *pHit = new MucRecHit(MucID::part(*mucid),MucID::seg(*mucid),MucID::gap(*mucid),MucID::strip(*mucid));
1373 pHit->SetPadID(padID[i]);
1374 pHit->SetIntersectX(intersect_x[i]);
1375 pHit->SetIntersectY(intersect_y[i]);
1376 pHit->SetIntersectZ(intersect_z[i]);
1377
1378 m_pExpectedHits.push_back(pHit);
1379 }
1380 }
1381 }
1382
1383 //cout<<"in RecMucTrack push back expected hits size= "<<m_pExpectedHits.size()<<" ? "<<m_pHits.size()<<endl;
1384 for(int i=0; i< m_pExpectedHits.size(); i++)
1385 {
1386 MucRecHit *ihit = m_pExpectedHits[i];
1387 //cout<<"expected Hits: "<<ihit->Part()<<" "<<ihit->Seg()<<" "<<ihit->Gap()<<" "<<ihit->Strip()<<endl;
1388 //cout<<"pad: "<<ihit->GetPadID()<<" pos: "<<ihit->GetIntersectX()<<" "<<ihit->GetIntersectY()<<" "<<ihit->GetIntersectZ()<<" "<<endl;
1389 }
1390
1391 for(int i=0; i< m_pHits.size(); i++)
1392 {
1393 MucRecHit *ihit = m_pHits[i];
1394 //cout<<"attachedd Hits: "<<ihit->Part()<<" "<<ihit->Seg()<<" "<<ihit->Gap()<<" "<<ihit->Strip()<<" isseed: "<<ihit->HitIsSeed()<<endl;
1395 }
1396 //cout<<"1st: "<<brFirstLayer()<<" "<<ecFirstLayer()<<" last: "<<brLastLayer()<<" "<<ecLastLayer()<<endl;
1397
1398 }
1399 else {
1400 //calc distance between each hit with this track.
1401 //initialize distHits
1402 for(int ihit = 0; ihit < m_pHits.size(); ihit++){
1403 m_distHits.push_back(-99);
1404 m_distHits_quad.push_back(-99);
1405 }
1406 }
1407 //cout << "Muc Pos: x " << m_MucPos.x() << " y " << m_MucPos.y() << " z " << m_MucPos.z() << endl;
1408}
1409
1410void
1412{
1413 int ngap = MucID::getGapMax();
1414 int gap, count = 0;
1415 vector<int> firedGap;
1416 for(gap = 0; gap < ngap; gap++) firedGap.push_back(0);
1417
1418 vector<MucRecHit*>::const_iterator iHit;
1419 for (iHit=m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1420 if (*iHit) { // Check for a null pointer.
1421 gap = (*iHit)->Gap();
1422 firedGap[gap] = 1;
1423 }
1424 }
1425
1426 for ( gap = 0; gap < ngap; gap++) {
1427 count += firedGap[gap];
1428 }
1429
1430 m_numHits = m_pHits.size();
1431 m_numLayers = count;
1432 //cout<<"nLayer:\t"<<m_numLayers<<endl;
1433}
1434
1435int
1437{
1438 return m_pHits.size();
1439}
1440
1441int
1442RecMucTrack::GetHitInGap(const int part, const int gap) const
1443{
1444 if ( part < 0 || part > 2 ) {
1445 cout << "RecMucTrack::GetHitInGap(), invalid part " << part << endl;
1446 return 0;
1447 }
1448 if ( (gap < 0) || (gap >= (int)MucID::getGapNum(part)) ) {
1449 cout << "RecMucTrack::GetHitInGap(), invalid gap " << gap << endl;
1450 return 0;
1451 }
1452
1453 vector<MucRecHit*>::const_iterator iHit;
1454 int hitsInGap = 0;
1455
1456 for (iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1457
1458 if ( !(*iHit) ) {
1459 cout << "RecMucTrack::GetHitInGap() null hit pointer !" << endl;
1460 return 0;
1461 }
1462 else {
1463 if( part == (*iHit)->Part() && gap == (*iHit)->Gap() ) hitsInGap++;
1464 }
1465 }
1466
1467 return hitsInGap;
1468}
1469
1470int
1471RecMucTrack::GetHitInSeg(const int part, const int seg) const
1472{
1473 int num = GetHitInSegOrient(part, seg, 0) + GetHitInSegOrient(part, seg, 1);
1474 return num;
1475}
1476
1477int
1478RecMucTrack::GetHitInSegOrient(const int part, const int seg, const int orient) const
1479{
1480 if ( part < 0 || part > 2 ) {
1481 cout << "RecMucTrack::GetHitInSeg(), invalid part " << part << endl;
1482 return 0;
1483 }
1484 if ( (seg < 0) || (seg >= (int)MucID::getSegNum(part)) ) {
1485 cout << "RecMucTrack::GetHitInSeg(), invalid seg = " << seg << endl;
1486 return 0;
1487 }
1488
1489 vector<MucRecHit*>::const_iterator iHit;
1490 int hitsInSeg = 0;
1491
1492 for (iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1493
1494 if ( !(*iHit) ) {
1495 cout << "RecMucTrack::GetHitInSeg(), null hit pointer !" << endl;
1496 return 0;
1497 }
1498 else {
1499 if( part == (*iHit)->Part() && seg == (*iHit)->Seg() &&
1500 orient == (*iHit)->GetGap()->Orient() ) hitsInSeg++;
1501 }
1502 }
1503
1504 return hitsInSeg;
1505}
1506
1507int
1508RecMucTrack::FindSegWithMaxHits(int &findPart, int &findSeg)
1509{
1510 int maxHits = 0;
1511 int hits = 0;
1512 for(int part = 0; part < (int)MucID::getPartNum(); part++) {
1513 for(int seg = 0; seg < (int)MucID::getSegNum(part); seg++) {
1514 hits = GetHitInSeg(part, seg);
1515 if (hits > maxHits) {
1516 maxHits = hits;
1517 findPart = part;
1518 findSeg = seg;
1519 }
1520 }
1521 }
1522
1523 return maxHits;
1524}
1525
1526void
1528{
1529 int maxHits = 0;
1530 int hits = 0;
1531 for(int part = 0; part < (int)MucID::getPartNum(); part++) {
1532 for(int gap = 0; gap < (int)MucID::getGapNum(part); gap++) {
1533 hits = GetHitInGap(part, gap);
1534 if(hits > maxHits) maxHits = hits;
1535 }
1536 }
1537
1538 m_maxHitsInLayer = maxHits;
1539}
1540
1541bool
1542RecMucTrack::HasHit(const int part, const int seg, const int gap, const int strip) const
1543{
1544 bool found = false;
1545 vector<MucRecHit*>::const_iterator iHit;
1546
1547 for (iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1548 if (*iHit) { // Check for a null pointer.
1549 if ( (*iHit)->Part() == part &&
1550 (*iHit)->Seg() == seg &&
1551 (*iHit)->Gap() == gap &&
1552 (*iHit)->Strip() == strip ) {
1553 found = true;
1554 }
1555 }
1556 }
1557
1558 return found;
1559}
1560
1561bool
1562RecMucTrack::HasHitInGap(const int part, const int gap) const
1563{
1564 if ( (gap < 0) || (gap >= (int)MucID::getGapNum(part)) ) {
1565 cout << "RecMucTrack::HasHitInGap-E2 invalid gap = " << gap << endl;
1566 return false;
1567 }
1568
1569 bool found = false;
1570 vector<MucRecHit*>::const_iterator iHit;
1571
1572 for (iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1573 if (*iHit) { // Check for a null pointer.
1574 if ( (*iHit)->Part() == part &&
1575 (*iHit)->Gap() == gap ) {
1576 found = true;
1577 }
1578 }
1579 }
1580
1581 return found;
1582}
1583
1584int
1586{
1587 if (!track2) {
1588 return 0;
1589 }
1590
1591 int count = 0;
1592 vector<MucRecHit*>::const_iterator iHit1;
1593 vector<MucRecHit*>::const_iterator iHit2;
1594 MucRecHit *hit1, *hit2;
1595
1596 for( iHit1 = m_pHits.begin(); iHit1 != m_pHits.end(); iHit1++){
1597 for( iHit2 = track2->m_pHits.begin();
1598 iHit2 != track2->m_pHits.end(); iHit2++){
1599 hit1 = (*iHit1);
1600 hit2 = (*iHit2);
1601
1602 if ( (hit1 != 0) && (hit2 != 0) ) {
1603 if (hit1->GetID() == hit2->GetID()) {
1604 count++;
1605 }
1606 }
1607 }
1608 }
1609
1610 return count;
1611}
1612
1613MucRecHit*
1614RecMucTrack::GetHit(const int part, const int gap) const
1615{
1616 if ( (gap < 0) || (gap >= (int)MucID::getGapNum(part)) ) {
1617 cout << "RecMucTrack::Hit-E1 invalid gap = " << gap << endl;
1618 return 0;
1619 }
1620
1621 vector<MucRecHit*>::const_iterator iHit;
1622
1623 for (iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1624 if (*iHit) { // Check for a null pointer.
1625 if ( (*iHit)->Part() == part &&
1626 (*iHit)->Gap() == gap) {
1627 return (*iHit);
1628 }
1629 }
1630 }
1631
1632 return 0L;
1633}
1634
1635vector<MucRecHit*>
1637{
1638 return m_pHits;
1639}
1640
1641vector<MucRecHit*>
1643{
1644 return m_pExpectedHits;
1645}
1646
1647vector<long>
1649{
1650 vector<long> v;
1651
1652 vector<MucRecHit*>::const_iterator iHit;
1653 for ( iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1654 if (*iHit) { // Check for a null pointer.
1655 long index = (*iHit)->GetID();
1656 v.push_back(index);
1657 /*
1658 cout << " Muc2DRoad::HitIndices gap orientation twopack= "
1659 << (*iHit)->ChannelID().Plane() << " "
1660 << (*iHit)->ChannelID().Orient() << " "
1661 << (*iHit)->ChannelID().TwoPack() << endl;
1662 */
1663 }
1664 }
1665 return v;
1666}
1667
1668void
1670{
1671 setVecHits(m_pHits);
1672 setExpHits(m_pExpectedHits);
1676 //ComputeDepth();
1677 ComputeDepth(fittingmethod);
1680}
1681
1682void
1684{
1685 vector<MucRecHit*>::const_iterator iHit;
1686 for ( iHit = m_pHits.begin(); iHit != m_pHits.end(); iHit++) {
1687 if (*iHit) { // Check for a null pointer.
1688 float xl, yl, zl;
1689 (*iHit)->GetStrip()->GetCenterPos(xl, yl, zl);
1690 HepPoint3D vl(xl, yl, zl);
1691 HepPoint3D vg = (*iHit)->GetGap()->TransformToGlobal(vl);
1692
1693 cout << " part " << (*iHit)->Part()
1694 << " seg " << (*iHit)->Seg()
1695 << " gap " << (*iHit)->Gap()
1696 << " strip " << (*iHit)->Strip()
1697 << " pos (" << vg.x() << ", " << vg.y() << ", " << vg.z() << ")"
1698 << endl;
1699 }
1700 }
1701
1702}
1703
1704void
1706{
1707 if(m_changeUnit == false){
1708 m_depth/=10;
1709
1710 m_xPos /=10;
1711 m_yPos /=10;
1712 m_zPos /=10;
1713
1714 m_xPosSigma/=10;
1715 m_yPosSigma/=10;
1716 m_zPosSigma/=10;
1717
1718 m_px /= 1000;
1719 m_py /= 1000;
1720 m_pz /= 1000;
1721
1722 m_distance /= 10;
1723 }
1724
1725 m_changeUnit = true;
1726
1727}
double sin(const BesAngle a)
Definition: BesAngle.h:210
double cos(const BesAngle a)
Definition: BesAngle.h:213
**********INTEGER nmxhep !maximum number of particles DOUBLE PRECISION vhep INTEGER jdahep COMMON hepevt $ !serial number $ !number of particles $ !status code $ !particle ident KF $ !parent particles $ !childreen particles $ !four momentum
Double_t x[10]
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:212
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition: KarLud.h:35
const double kSuperConductorR
Definition: MucConstant.h:11
const double kMinor
Definition: MucConstant.h:8
const double kPi
Definition: MucConstant.h:6
const double kSuperConductorZ
Definition: MucConstant.h:12
const double kMagnetField
Definition: MucConstant.h:13
const double kvC
const int kMdcExtIterMax
const double kInsctWeight
const double kDeltaPhi
int intersection(const HepPoint3D &c1, double r1, const HepPoint3D &c2, double r2, double eps, HepPoint3D &x1, HepPoint3D &x2)
Circle utilities.
Definition: TMDCUtil.cxx:99
const int GetTrackId() const
Definition: DstExtTrack.h:42
double m_rms
Definition: DstMucTrack.h:134
double m_zPos
Definition: DstMucTrack.h:138
int m_kalbrLastLayer
Definition: DstMucTrack.h:157
double pz() const
Definition: DstMucTrack.h:60
int brLastLayer() const
Definition: DstMucTrack.h:39
double py() const
Definition: DstMucTrack.h:59
double m_xPos
Definition: DstMucTrack.h:136
double m_xPosSigma
Definition: DstMucTrack.h:140
double deltaPhi() const
Definition: DstMucTrack.h:63
int status() const
Definition: DstMucTrack.h:34
int m_kalecLastLayer
Definition: DstMucTrack.h:158
int trackId() const
Definition: DstMucTrack.h:32
double m_py
Definition: DstMucTrack.h:145
double m_kalrechi2
Definition: DstMucTrack.h:154
double m_depth
Definition: DstMucTrack.h:131
int m_ecLastLayer
Definition: DstMucTrack.h:126
int m_brLastLayer
Definition: DstMucTrack.h:125
double m_zPosSigma
Definition: DstMucTrack.h:142
double m_distance
Definition: DstMucTrack.h:148
double px() const
Definition: DstMucTrack.h:58
int ecLastLayer() const
Definition: DstMucTrack.h:40
double m_deltaPhi
Definition: DstMucTrack.h:149
double m_kaldepth
Definition: DstMucTrack.h:156
double m_px
Definition: DstMucTrack.h:144
double distance() const
Definition: DstMucTrack.h:62
double m_chi2
Definition: DstMucTrack.h:132
double m_yPos
Definition: DstMucTrack.h:137
double m_yPosSigma
Definition: DstMucTrack.h:141
double m_pz
Definition: DstMucTrack.h:146
int m_maxHitsInLayer
Definition: DstMucTrack.h:129
HepPoint3D TransformToGlobal(const HepPoint3D pPoint) const
Transform a point from gap coordinate to global coordinate.
Definition: MucGeoGap.cxx:620
int Seg() const
Get seg identifier (0-7).
Definition: MucGeoGap.h:101
int Gap() const
Get gap identifier (0-8).
Definition: MucGeoGap.h:104
int Part() const
Get part identifier (0,2 for cap, 1 for barrel).
Definition: MucGeoGap.h:98
float GetIronThickness() const
Definition: MucGeoGap.h:116
HepPoint3D TransformToGap(const HepPoint3D gPoint) const
Transform a point from global coordinate to gap coordinate.
Definition: MucGeoGap.cxx:627
int Orient() const
Definition: MucGeoGap.h:108
vector< HepPoint3D > FindIntersections(const int part, const int gap, const HepPoint3D gPoint, const Hep3Vector gDirection)
MucGeoGap * GetGap(const int part, const int seg, const int gap) const
Get a pointer to the gap identified by (part,seg,gap).
static MucGeoGeneral * Instance()
Get a pointer to the single instance of MucGeoGeneral.
static int part(const Identifier &id)
Definition: MucID.cxx:46
static value_type getGapMax()
Definition: MucID.cxx:195
static value_type getPartNum()
Definition: MucID.cxx:159
static int gap(const Identifier &id)
Definition: MucID.cxx:66
static int seg(const Identifier &id)
Definition: MucID.cxx:56
static value_type getSegNum(int part)
Definition: MucID.cxx:164
static int strip(const Identifier &id)
Definition: MucID.cxx:76
static value_type getGapNum(int part)
Definition: MucID.cxx:171
float GetIntercept() const
Intercept of trajectory.
void AttachHit(MucRecHit *hit)
Attach the given hit to this road.
float GetSlope() const
Slope of trajectory.
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?
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!...
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)
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 GetDegreesOfFreedom() const
How many degrees of freedom in the trajectory fit?
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?
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 GetReducedChiSquare() const
Chi-square parameter (per degree of freedom) of the trajectory fit.
void SetIntersectZ(float z)
Definition: MucRecHit.h:105
int Seg() const
Get Seg.
Definition: MucRecHit.h:74
MucGeoGap * GetGap() const
Get geometry data for the gap containing this hit.
Definition: MucRecHit.h:83
Hep3Vector GetCenterPos() const
Get Center position of the strip (global coords).
Definition: MucRecHit.cxx:104
int Part() const
Get Part.
Definition: MucRecHit.h:71
int Gap() const
Get Gap.
Definition: MucRecHit.h:77
void SetIntersectY(float y)
Definition: MucRecHit.h:104
void SetIntersectX(float x)
Definition: MucRecHit.h:103
Identifier GetID() const
Get soft identifier of this hit.
Definition: MucRecHit.h:68
void SetPadID(int padID)
Definition: MucRecHit.h:102
int GetTotalHits() const
How many hits in all does this track contain?
void LineFit(int fittingMethod)
Line fit with hits on a seg with max hits.
void CorrectPos()
Correct current position of this trajectory.
void PrintHitsInfo() const
Print Hits Infomation.
void CorrectDir()
Correct direction of this trajectory.
void ComputeTrackInfo(int fittingmethod)
Get corresponding monte carlo track pointer.
int GetNGapsWithHits() const
How many gaps provide hits attached to this track?
Definition: RecMucTrack.h:267
void SetDefault()
void SetMdcMomentum(const float px, const float py, const float pz)
set start moment of the track in Mdc.
void setExpHits(vector< MucRecHit * > &pHits)
void SetMucPosSigma(const float sigmax, const float sigmay, const float sigmaz)
MucRecHit * GetHit(const int part, const int gap) const
Get a pointer to the first hit attached in a particular gap.
bool IsInsideSuperConductor(Hep3Vector pos)
int GetHitInSeg(const int part, const int seg) const
How many hits does a segment contains.
~RecMucTrack()
Destructor.
void AttachInsct(Hep3Vector insct)
Attach the intersection to this trajectory.
int brFirstLayer() const
Which gap on Barrel is the first one with hits attached to this track?
Definition: RecMucTrack.h:221
void SetExtMucPos(const float x, const float y, const float z)
set start position of ext track in Muc. (compute from MdcPos MdcMomentum or get from ExtTrack)
int GetNSharedHits(const RecMucTrack *track) const
How many hits do two tracks share?
void ComputeNGapsWithHits()
ComputeNGapsWithHits;.
void SetMdcPos(const float x, const float y, const float z)
set start position of the track in Mdc.
void SetCurrentDir(const float x, const float y, const float z)
set current direction of the trajectory.
void ComputeDepth()
chi2 of line fit
float GetHitDistance(const MucRecHit *hit)
Calculate the distance of the hit to the intersection in read direction.
void SetExtTrack(RecExtTrack *extTrack)
set Ext track point.
void setTrackId(const int trackId)
set the index for this track.
bool HasHit(const int part, const int seg, const int gap, const int strip) const
How many hits were attached in the gap with the most attached hits?
void GetMdcExtTrack(Hep3Vector mdcStartPos, Hep3Vector mdcStartMomentum, int charge, Hep3Vector &mucStartPos, Hep3Vector &mucStartMomentum)
compute ext track myself from mdc.
void ComputeMaxHitsInGap()
ComputeMaxHitsInGap;.
int GetHitInGap(const int part, const int gap) const
How many hits per gap does this track contain?
int FindSegWithMaxHits(int &part, int &seg)
Find the segment which contains most hits, return max hits number.
Hep3Vector CalculateInsct(const int part, const int seg, const int gap)
Calculate intersection from all hits attached on this gap.
void Project(const int &part, const int &gap, float &x, float &y, float &z, int &seg)
Where does the trajectory of this track intersect a specific gap?
void SetMucMomentum(const float px, const float py, const float pz)
set start moment of the track in Muc.
void setVecHits(vector< MucRecHit * > &pHits)
reload setVecHits
vector< long > GetHitIndices() const
Get indices of all hits in the track.
int GetHitInSegOrient(const int part, const int seg, const int orient) const
How many hits does a segment contains in one orient.
void SetExtMucMomentum(const float px, const float py, const float pz)
set start moment of ext track in Muc.
RecMucTrack & operator=(const RecMucTrack &orig)
Assignment constructor.
Definition: RecMucTrack.cxx:84
vector< MucRecHit * > GetHits() const
Get all hits on this track.
void AttachHit(MucRecHit *hit)
set corresponding monte carlo track pointer.
void SetCurrentInsct(const float x, const float y, const float z)
set current intersection of the trajectory with strip plane.
void ComputeDistanceMatch()
Compute distance match //2006.11.08.
void OutputUnitChange()
change unit
void SetCurrentPos(const float x, const float y, const float z)
set current position of the trajectory.
vector< MucRecHit * > GetExpectedHits() const
void SetMucPos(const float x, const float y, const float z)
set start position of the track in Muc. (after line fit and correction)
float GetHitDistance2(const MucRecHit *hit)
no abs value
void Extend()
Extend mucpos and extmucpos to first layer of muc.
bool HasHitInGap(const int part, const int gap) const
Does this track contain any hits in the given gap?
void ComputeLastGap()
Comute last gap in barrel and endcap.
RecMucTrack()
Constructor.
Definition: RecMucTrack.cxx:26
void AttachDirection(Hep3Vector dir)
Attach the direction to this trajectory.
int num[96]
Definition: ranlxd.c:373