FairRoot/PandaRoot
PndWayFollower.cxx
Go to the documentation of this file.
1 /*
2  * PndWayFollower.cxx
3  *
4  * Created on: Jul 26, 2016
5  * Author: kibellus
6  */
7 
8 #include <PndWayFollower.h>
9 
13 
14 vector<PndTrackCollection> PndWayFollower::followLines(Int_t begin){
15  vector<PndTrackCollection> result;
16  cout << "Start follow lines" << endl;
17 
18  /*
19  vector<PndLineApproximation> allLines;
20  for(map<Int_t, vector<PndFtsExpandedTrackCand>>::iterator i=cands.begin();i!=cands.end();i++){
21  vector<PndFtsExpandedTrackCand> vec = i->second;
22  for(int j=0;j<vec.size();j++){
23  vector<PndLineApproximation> appr = vec[j].getLineApproximations();
24  for(int k=0;k<appr.size();k++)allLines.push_back(appr[k]);
25  }
26  }*/
27 
28 
29  for(size_t i=0;i<fBefore.size();i++){
30  cout << "Follow Track " << i << endl;
31  PndTrackCollection trackCollection;
33  trackCollection.add(a,kTRUE);
34 
35  //FTS3
36  PndLineApproximation best = getBestApproxTo(trackCollection.getLastLine(),begin);
37  trackCollection.add(best,kFALSE);
38  PndLineApproximation best2=getBestSkewedApproxTo(trackCollection.getLastLine(),begin+1);
39  trackCollection.add(best2,kTRUE);
40  PndLineApproximation best3=getBestSkewedApproxTo(trackCollection.getLastLine(),begin+2);
41  trackCollection.add(best3,kTRUE);
42  PndLineApproximation best4=getBestApproxTo(trackCollection.getLastLine(),begin+3);
43  trackCollection.add(best4,kFALSE);
44 
45  //FTS4
46  PndLineApproximation best5=getBestApproxTo(trackCollection.getLastLine(),begin+4);
47  trackCollection.add(best5,kFALSE);
48  /*if(asd==0 && i==1){
49  TVector3 v(1,1,1);
50  PndTrackCand trackCand;
51  FairTrackParP tp1(trackCollection.getLastLine().getP1(),3 * trackCollection.getLastLine().getDir().Unit(), v, v, 1, v, v, v);
52  FairTrackParP tp2(v,v.Unit(), v, v, 1, v, v, v);
53  PndTrack* myCand = new ((*planes)[0]) PndTrack(tp1, tp2, trackCand);
54  PndPlane p1(allLines[134].getLine(),0);
55  PndPlane p2(allLines[144].getLine(),1);
56  PndPlane p3(allLines[146].getLine(),1);
57  PndLine l1 = p1.getIntersection(p2);
58  PndLine l2 = p1.getIntersection(p3);
59  fLineComp.setZValue(allLines[144].getHits()[0]->GetZ());
60  cout << "Quali wrong line:" <<fLineComp.getQuality3D(trackCollection.getLastLine(),l1) << endl;
61  cout << "Quali right line:" <<fLineComp.getQuality3D(trackCollection.getLastLine(),l2) << endl;
62  asd++;
63  }*/
64  PndLineApproximation best6=getBestSkewedApproxTo(trackCollection.getLastLine(),begin+5);
65  trackCollection.add(best6,kTRUE);
66  PndLineApproximation best7=getBestSkewedApproxTo(trackCollection.getLastLine(),begin+6);
67  trackCollection.add(best7,kTRUE);
68  PndLineApproximation best8=getBestApproxTo(trackCollection.getLastLine(),begin+7);
69  trackCollection.add(best8,kFALSE);
70 
71  result.push_back(trackCollection);
72  }
73  return result;
74 }
75 
77  vector<PndFtsExpandedTrackCand> layerCands = cands[layer];
78 
79  PndLineApproximation bestApprox;
80  bestApprox.getLine().setRating(-1);
81  Double_t bestDist = 99999999;
82 
83  for(size_t i=0;i<layerCands.size();i++){
84  vector<PndLineApproximation> approxs = layerCands[i].getLineApproximations();
85  for(size_t j=0;j<approxs.size();j++){
86  PndLineApproximation approx = approxs[j];
87  fLineComp.setZValue(approx.getHits()[0]->GetZ()-20);
88  PndLine l2 = approx.getLine();
89  Double_t dist = fLineComp.getDist2D(l1.getP1(),l2.getP1(),l1.getDir(),l2.getDir());
90  if(dist<bestDist){
91  bestDist = dist;
92  bestApprox = approx;
93  }
94  }
95  }
96  if(bestDist>5){
97  bestApprox=PndLineApproximation();
98  bestApprox.getLine().setRating(-1);
99  }
100  //to bad?
101  PndLine l2 = bestApprox.getLine();
102  Double_t quali = fLineComp.getQuality(l1,l2);
103  if(quali > qualiT){
104  PndLineApproximation apprWrong;
105  apprWrong.getLine().setRating(-1);
106  return apprWrong;
107  }
108  return bestApprox;
109 }
110 
112  PndPlane p1(l1,layer-1);
113  vector<PndFtsExpandedTrackCand> layerCands = cands[layer];
114 
115  PndLineApproximation bestApprox;
116  bestApprox.getLine().setRating(-1);
117  Double_t bestDist = 99999999;
118 
119  for(size_t i=0;i<layerCands.size();i++){
120  vector<PndLineApproximation> approxs = layerCands[i].getLineApproximations();
121  for(size_t j=0;j<approxs.size();j++){
122  PndLineApproximation approx = approxs[j];
123  fLineComp.setZValue(approx.getHits()[0]->GetZ());
124  PndPlane p2(approx.getLine(),layer);
125  PndLine l3 = p1.getIntersection(p2);
126 
127  Double_t dist = fLineComp.getQuality3D(l1,l3);
128  if(dist<bestDist){
129  bestDist = dist;
130  vector<PndFtsHit*> hits;
131  bestApprox = PndLineApproximation(l3,hits);
132  bestApprox.correctHits3DAndAdd(approx.getHits());
133  }
134  }
135  }
136  //to bad?
137  PndLine l2 = bestApprox.getLine();
138  Double_t quali = fLineComp.getQuality(l1,l2);
139  if(quali > qualiT){
140  PndLineApproximation apprWrong;
141  apprWrong.getLine().setRating(-1);
142  return apprWrong;
143  }
144  return bestApprox;
145 }
146 
148  // TODO Auto-generated destructor stub
149 }
150 
vector< PndFtsHit * > getHits()
PndLine getIntersection(PndPlane &p)
Definition: PndPlane.cxx:28
map< Int_t, vector< PndFtsExpandedTrackCand > > cands
Double_t getDist2D(TVector3 b1, TVector3 b2, TVector3 d1, TVector3 d2)
Int_t i
Definition: run_full.C:25
PndFtsLineComparator fLineComp
static Double_t qualiT
Double_t getQuality3D(PndLine l1, PndLine l2)
virtual ~PndWayFollower()
TVector3 getDir()
Definition: PndLine.h:34
void setZValue(Double_t z)
Double_t getQuality(PndLine l1, PndLine l2)
Int_t a
Definition: anaLmdDigi.C:126
vector< PndTrackCollection > followLines(Int_t begin)
Double_t
void setRating(Int_t r)
Definition: PndLine.h:44
PndLineApproximation getBestSkewedApproxTo(PndLine l2, Int_t layer)
vector< PndLineApproximation > fBefore
TPad * p2
Definition: hist-t7.C:117
void correctHits3DAndAdd(vector< PndFtsHit * > correctedHits)
static Double_t compDist
Int_t layer
Definition: reco_muo.C:36
TPad * p1
Definition: hist-t7.C:116
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
void add(PndLineApproximation l, Bool_t skewed)
TVector3 getP1()
Definition: PndLine.h:32
static Double_t compAngle
PndLineApproximation getBestApproxTo(PndLine l1, Int_t layer)