FairRoot/PandaRoot
PndTrackCollection.cxx
Go to the documentation of this file.
1 /*
2  * PndTrackCollection.cxx
3  *
4  * Created on: Jul 28, 2016
5  * Author: kibellus
6  */
7 
8 #include <PndTrackCollection.h>
9 
11  fLines = new vector<PndLineApproximation>();
12 }
13 
15 }
16 
18  if(l.getLine().getRating()==-1)return;
19  //copy hits
20  vector<PndFtsHit*> newHits;
21  vector<PndFtsHit*> oldHits = l.getHits();
22  for(size_t i=0;i<oldHits.size();i++){
23  newHits.push_back(copyHit(oldHits[i]));
24  }
25  l.setHits(newHits);
26  //add new Aprrox
27  fLines->push_back(l);
28  //refit
29  if(fLines->size()==1)fCurrLine=(*fLines)[0].getLine();
30  if(fLines->size()>1 && skewed){
31  refitAllHits();
32  } else if(fLines->size()>1){
33  vector<PndFtsHit*> hits = l.getHits();
34  for(size_t i=0;i<hits.size();i++){
35  refitHit(fCurrLine,hits[i]);
36  }
37  }
39 }
40 
42  PndFtsHit* h2 = new PndFtsHit();
43  h2->SetDetectorID(h->GetDetectorID());
44  h2->SetTubeID(h->GetTubeID());
45  h2->SetChamberID(h->GetChamberID());
46  h2->SetLayerID(h->GetLayerID());
47  h2->SetXYZ(h->GetX(),h->GetY(),h->GetZ());
48  h2->SetIsochrone(h->GetIsochrone());
50  h2->SetRefIndex(h->GetRefIndex());
51  h2->SetEntryNr(h->GetEntryNr());
52  return h2;
53 }
54 
56  //get all hits
57  vector<PndFtsHit*> allHits;
58  for(size_t i=0;i<fLines->size();i++){
59  vector<PndFtsHit*> hits = (*fLines)[i].getHits();
60  for(size_t j=0;j<hits.size();j++) allHits.push_back(hits[j]);
61  }
62  //refit with line
63  PndLine zyLine = (*fLines)[0].linearRegressionZY(allHits);
64  //set the z pos
65  for(size_t i=0;i<allHits.size();i++){
66  refitHit(zyLine,allHits[i]);
67  }
68  fCurrLine = zyLine;
69 }
70 
72  for(size_t i=0;i<fLines->size();i++){
73  PndLineApproximation a = (*fLines)[i];
74  PndPlane p(a.getLine(),0);
75  PndPlane p2(fCurrLine.getP1(),fCurrLine.getDir(),TVector3(1,0,0));
76  PndLine newLine = p.getIntersection(p2);
77  (*fLines)[i].setLine(newLine);
78  }
79 }
80 
82  TVector3 base = l.getP1();
83  TVector3 dir = l.getDir();
84  Double_t lamp = (hit->GetZ()-base[2])/dir[2];
85  TVector3 p = base+lamp*dir;
86  hit->SetY(p[1]);
87 }
88 
89 PndTrack PndTrackCollection::getPndTrack(map<Int_t,PndFtsHit*> orgHits){
90  PndLine first = (*fLines)[0].getLine();
91  PndLine last = (*fLines)[fLines->size()-1].getLine();
92  TVector3 v(1,1,1);
93  FairTrackParP tp1(first.getP1(),3 * first.getDir().Unit(), v, v, 1, v, v, v);
94  FairTrackParP tp2(last.getP1(),3 * last.getDir().Unit(), v, v, 1, v, v, v);
95  PndTrackCand trackCand;
96  Int_t hitCount;
97  for(size_t i=0;i<fLines->size();i++){
98  PndLineApproximation a = (*fLines)[i];
99  vector<PndFtsHit*> hits = a.getHits();
100  hitCount = hits.size();
101  for(size_t j=0;j<hits.size();j++){
102  trackCand.AddHit(orgHits[hits[j]->GetTubeID()]->GetEntryNr(),j);
103  }
104  }
105  for(size_t i=0;i<fHits.size();i++)
106  trackCand.AddHit(fHits[i]->GetEntryNr(),i+hitCount);
107  return PndTrack(tp1,tp2,trackCand);
108 }
109 
111  Double_t dist = 9999999999;
112  for(size_t i=0;i<fLines->size();i++){
113  PndLineApproximation appr = (*fLines)[i];
114  Int_t apprLayer = appr.getHits()[0]->GetLayerID();
115  if(layer<8 && apprLayer>=8)continue;
116  if(layer>=16 && apprLayer<16)continue;
117  if(layer>8 && layer < 16 && layer!=apprLayer)continue;
118  PndLine l2 = appr.getLine();
119  TVector3 p1 = l.getPerpendicular(l2);
120  TVector3 p2 = l2.getPerpendicular(l);
121  Double_t dist2 = (p1-p2).Mag();
122  if(dist2<dist) dist = dist2;
123  }
124  return dist;
125 }
vector< PndFtsHit * > getHits()
std::vector< PndLineApproximation > * fLines
Double_t p
Definition: anasim.C:58
void SetIsochrone(Double_t isochrone)
Definition: PndFtsHit.h:64
TVector3 getPerpendicular(PndLine l2)
Definition: PndLine.cxx:76
Int_t i
Definition: run_full.C:25
void SetChamberID(Int_t chamberid)
Definition: PndFtsHit.h:71
void SetTubeID(Int_t tubeid)
Definition: PndFtsHit.h:69
TVector3 getDir()
Definition: PndLine.h:34
Double_t getDistTo(PndLine l, Int_t layer)
__m128 v
Definition: P4_F32vec4.h:4
Int_t GetTubeID() const
Definition: PndFtsHit.h:70
Int_t GetLayerID() const
Definition: PndFtsHit.h:74
Int_t a
Definition: anaLmdDigi.C:126
void refitHit(PndLine &l, PndFtsHit *hit)
Double_t
vector< PndFtsHit * > fHits
Int_t getRating()
Definition: PndLine.h:42
TPad * p2
Definition: hist-t7.C:117
Double_t GetIsochrone() const
Definition: PndFtsHit.h:57
PndTrack getPndTrack(map< Int_t, PndFtsHit * > orgHits)
Double_t GetIsochroneError() const
Definition: PndFtsHit.h:58
Int_t layer
Definition: reco_muo.C:36
TPad * p1
Definition: hist-t7.C:116
void SetLayerID(Int_t layerid)
Definition: PndFtsHit.h:73
PndFtsHit * copyHit(PndFtsHit *h)
PndSdsMCPoint * hit
Definition: anasim.C:70
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
void add(PndLineApproximation l, Bool_t skewed)
TVector3 getP1()
Definition: PndLine.h:32
void SetIsochroneError(Double_t isochroneError)
Definition: PndFtsHit.h:65
Int_t GetChamberID() const
Definition: PndFtsHit.h:72
void setHits(vector< PndFtsHit * > h)