FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PndLineApproximation Class Reference

#include <PndLineApproximation.h>

Public Member Functions

 PndLineApproximation (vector< PndFtsHit * > hits)
 
 PndLineApproximation ()
 
 PndLineApproximation (PndLine lineApprox, vector< PndFtsHit * > correctedHits)
 
 PndLineApproximation (PndLine lineApprox, vector< PndFtsHit * > ch1, vector< PndFtsHit * > ch2)
 
virtual ~PndLineApproximation ()
 
PndLinegetLine ()
 
void setLine (PndLine l)
 
vector< PndFtsHit * > getHits ()
 
void setHits (vector< PndFtsHit * > h)
 
PndLineApproximation newApproximation (PndLineApproximation &approx2)
 
PndLine linearRegression (vector< PndFtsHit * > hits)
 
PndLine linearRegressionXZ (vector< PndFtsHit * > hits)
 
PndLine linearRegressionZX (vector< PndFtsHit * > hits)
 
PndLine linearRegressionYZ (vector< PndFtsHit * > hits)
 
PndLine linearRegressionZY (vector< PndFtsHit * > hits)
 
PndTrack plot (Double_t zVal1, Double_t zVal2, TClonesArray *hitArr)
 
void correctHits3DAndAdd (vector< PndFtsHit * > correctedHits)
 
void setYInfo (Bool_t i)
 
Bool_t HasYInfo ()
 

Private Member Functions

TVector2 linearRegression (Double_t matrix[2][3])
 
PndFtsHitcopyHitWithNewPosition (PndFtsHit *h, TVector3 pos)
 

Private Attributes

PndLine fLineApprox
 
vector< PndFtsHit * > fCorrectedHits
 
Bool_t hasYInfo
 

Detailed Description

Definition at line 23 of file PndLineApproximation.h.

Constructor & Destructor Documentation

PndLineApproximation::PndLineApproximation ( vector< PndFtsHit * >  hits)
inline

Definition at line 25 of file PndLineApproximation.h.

PndLine linearRegression(vector< PndFtsHit * > hits)
vector< PndFtsHit * > fCorrectedHits
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
PndLineApproximation::PndLineApproximation ( )
inline

Definition at line 26 of file PndLineApproximation.h.

26 {}
PndLineApproximation::PndLineApproximation ( PndLine  lineApprox,
vector< PndFtsHit * >  correctedHits 
)
inline

Definition at line 27 of file PndLineApproximation.h.

28  :fLineApprox(lineApprox),fCorrectedHits(correctedHits) {}
vector< PndFtsHit * > fCorrectedHits
PndLineApproximation::PndLineApproximation ( PndLine  lineApprox,
vector< PndFtsHit * >  ch1,
vector< PndFtsHit * >  ch2 
)

Definition at line 15 of file PndLineApproximation.cxx.

References correctHits3DAndAdd(), and fLineApprox.

15  {
16  fLineApprox = lineApprox;
19 }
void correctHits3DAndAdd(vector< PndFtsHit * > correctedHits)
PndLineApproximation::~PndLineApproximation ( )
virtual

Definition at line 11 of file PndLineApproximation.cxx.

11  {
12  // TODO Auto-generated destructor stub
13 }

Member Function Documentation

PndFtsHit * PndLineApproximation::copyHitWithNewPosition ( PndFtsHit h,
TVector3  pos 
)
private

Definition at line 192 of file PndLineApproximation.cxx.

References PndFtsHit::GetChamberID(), PndFtsHit::GetLayerID(), PndFtsHit::GetTubeID(), h2, PndFtsHit::SetChamberID(), PndFtsHit::SetLayerID(), and PndFtsHit::SetTubeID().

Referenced by correctHits3DAndAdd().

192  {
193  PndFtsHit* h2 = new PndFtsHit();
194  h2->SetDetectorID(h->GetDetectorID());
195  h2->SetTubeID(h->GetTubeID());
196  h2->SetChamberID(h->GetChamberID());
197  h2->SetLayerID(h->GetLayerID());
198  h2->SetXYZ(pos[0],pos[1],pos[2]);
199  h2->SetRefIndex(h->GetRefIndex());
200  h2->SetEntryNr(h->GetEntryNr());
201  return h2;
202 }
TVector3 pos
void SetChamberID(Int_t chamberid)
Definition: PndFtsHit.h:71
void SetTubeID(Int_t tubeid)
Definition: PndFtsHit.h:69
Int_t GetTubeID() const
Definition: PndFtsHit.h:70
Int_t GetLayerID() const
Definition: PndFtsHit.h:74
void SetLayerID(Int_t layerid)
Definition: PndFtsHit.h:73
Int_t GetChamberID() const
Definition: PndFtsHit.h:72
void PndLineApproximation::correctHits3DAndAdd ( vector< PndFtsHit * >  correctedHits)

Definition at line 21 of file PndLineApproximation.cxx.

References Bool_t, copyHitWithNewPosition(), CAMath::Cos(), fCorrectedHits, fLineApprox, PndLine::getPerpendicular(), i, and CAMath::Sin().

Referenced by PndWayFollower::getBestSkewedApproxTo(), newApproximation(), and PndLineApproximation().

21  {
22  for (size_t i = 0; i < ch.size(); i++) {
23  //check to duplicate hits
24  Bool_t duplicated = kFALSE;
25  for(size_t j=0;j<fCorrectedHits.size();j++){
26  Int_t id1 = fCorrectedHits[j]->GetTubeID();
27  Int_t id2 = ch[i]->GetTubeID();
28  if(id1==id2){
29  duplicated = kTRUE;
30  break;
31  }
32  }
33  if(duplicated) continue;
34  Int_t layer = (ch[i]->GetLayerID() - 1) / 2;
35  TVector3 base2;
36  ch[i]->Position(base2);
37  TVector3 dir2;
38  if (layer % 4 == 1) {
39  dir2 = TVector3(TMath::Sin(-5 * TMath::DegToRad()),
40  TMath::Cos(-5 * TMath::DegToRad()), 0);
41  } else if (layer % 4 == 2) {
42  dir2 = TVector3(TMath::Sin(5 * TMath::DegToRad()),
43  TMath::Cos(5 * TMath::DegToRad()), 0);
44  } else {
45  dir2 = TVector3(0, 1, 0);
46  }
47  PndLine line2(base2, dir2);
48  TVector3 newPos = line2.getPerpendicular(fLineApprox);
49  PndFtsHit* newHit = copyHitWithNewPosition(ch[i], newPos);
50  fCorrectedHits.push_back(newHit);
51  }
52 }
Int_t i
Definition: run_full.C:25
vector< PndFtsHit * > fCorrectedHits
static T Sin(const T &x)
Definition: PndCAMath.h:42
static T Cos(const T &x)
Definition: PndCAMath.h:43
PndFtsHit * copyHitWithNewPosition(PndFtsHit *h, TVector3 pos)
vector<PndFtsHit*> PndLineApproximation::getHits ( )
inline
PndLine& PndLineApproximation::getLine ( )
inline
Bool_t PndLineApproximation::HasYInfo ( )
inline

Definition at line 44 of file PndLineApproximation.h.

Referenced by PndModuleCombiner::combineModules().

44 {return hasYInfo;}
PndLine PndLineApproximation::linearRegression ( vector< PndFtsHit * >  hits)

Definition at line 69 of file PndLineApproximation.cxx.

References PndLine::getDir(), PndLine::getP1(), linearRegressionZX(), linearRegressionZY(), p1, and p2.

Referenced by linearRegressionXZ(), linearRegressionYZ(), linearRegressionZX(), linearRegressionZY(), and newApproximation().

69  {
72  PndPlane p1(zxLine.getP1(),zxLine.getDir(),TVector3(0,1,0));
73  PndPlane p2(zyLine.getP1(),zyLine.getDir(),TVector3(1,0,0));
74  PndLine newLine = p1.getIntersection(p2);
75  return newLine;
76 }
PndLine linearRegressionZY(vector< PndFtsHit * > hits)
TVector3 getDir()
Definition: PndLine.h:34
TPad * p2
Definition: hist-t7.C:117
TPad * p1
Definition: hist-t7.C:116
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
PndLine linearRegressionZX(vector< PndFtsHit * > hits)
TVector3 getP1()
Definition: PndLine.h:32
TVector2 PndLineApproximation::linearRegression ( Double_t  matrix[2][3])
private

Definition at line 182 of file PndLineApproximation.cxx.

References a, b, Double_t, and i.

182  {
183  Double_t fac = -matrix[1][0]/matrix[0][0];
184  for(int i=0;i<3;i++){
185  matrix[1][i]+= (fac*matrix[0][i]);
186  }
187  Double_t b = matrix[1][2]/matrix[1][1];
188  Double_t a = (matrix[0][2] - b*matrix[0][1])/matrix[0][0];
189  return TVector2(a,b);
190 }
Int_t i
Definition: run_full.C:25
TTree * b
Int_t a
Definition: anaLmdDigi.C:126
Double_t
PndLine PndLineApproximation::linearRegressionXZ ( vector< PndFtsHit * >  hits)

Definition at line 78 of file PndLineApproximation.cxx.

References Double_t, i, linearRegression(), p1, and p2.

78  {
79  Double_t sumX = 0;
80  Double_t sumX2 = 0;
81  Double_t sumZ = 0;
82  Double_t sumXZ = 0;
83  for(size_t i=0;i<hits.size();i++){
84  cout.precision(10);
85  sumX+=hits[i]->GetX();
86  sumX2+=hits[i]->GetX()*hits[i]->GetX();
87  sumZ+=hits[i]->GetZ();
88  sumXZ+=hits[i]->GetX()*hits[i]->GetZ();
89  }
90  Double_t matrix[2][3];
91  matrix[0][0]=hits.size();
92  matrix[1][0]=sumX;
93  matrix[0][1]=sumX;
94  matrix[1][1]=sumX2;
95  matrix[0][2]=sumZ;
96  matrix[1][2]=sumXZ;
97  TVector2 result = linearRegression(matrix);
98  TVector3 p1(20,0,result.X()+20*result.Y());
99  TVector3 p2(40,0,result.X()+40*result.Y());
100  //TVector3 p1(hits[0]->GetX(),0,result.X()+hits[0]->GetX()*result.Y());
101  //TVector3 p2(hits[0]->GetX()+20,0,result.X()+(hits[0]->GetX())+20*result.Y());
102  TVector3 dir = p1-p2;
103  return PndLine(p1,dir);
104 }
PndLine linearRegression(vector< PndFtsHit * > hits)
Int_t i
Definition: run_full.C:25
Double_t
TPad * p2
Definition: hist-t7.C:117
TPad * p1
Definition: hist-t7.C:116
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
PndLine PndLineApproximation::linearRegressionYZ ( vector< PndFtsHit * >  hits)

Definition at line 131 of file PndLineApproximation.cxx.

References Double_t, i, linearRegression(), p1, and p2.

131  {
132  Double_t sumY = 0;
133  Double_t sumY2 = 0;
134  Double_t sumZ = 0;
135  Double_t sumYZ = 0;
136  for(size_t i=0;i<hits.size();i++){
137  sumY+=hits[i]->GetY();
138  sumY2+=hits[i]->GetY()*hits[i]->GetY();
139  sumZ+=hits[i]->GetZ();
140  sumYZ+=hits[i]->GetY()*hits[i]->GetZ();
141  }
142  Double_t matrix[2][3];
143  matrix[0][0]=hits.size();
144  matrix[1][0]=sumY;
145  matrix[0][1]=sumY;
146  matrix[1][1]=sumY2;
147  matrix[0][2]=sumZ;
148  matrix[1][2]=sumYZ;
149  TVector2 result = linearRegression(matrix);
150  TVector3 p1(0,-20,result.X()-20*result.Y());
151  TVector3 p2(0,20,result.X()+20*result.Y());
152  TVector3 dir = p1-p2;
153  return PndLine(p1,dir);
154 }
PndLine linearRegression(vector< PndFtsHit * > hits)
Int_t i
Definition: run_full.C:25
Double_t
TPad * p2
Definition: hist-t7.C:117
TPad * p1
Definition: hist-t7.C:116
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
PndLine PndLineApproximation::linearRegressionZX ( vector< PndFtsHit * >  hits)

Definition at line 106 of file PndLineApproximation.cxx.

References Double_t, i, linearRegression(), p1, and p2.

Referenced by linearRegression().

106  {
107  Double_t sumZ = 0;
108  Double_t sumZ2 = 0;
109  Double_t sumX = 0;
110  Double_t sumZX = 0;
111  for(size_t i=0;i<hits.size();i++){
112  sumZ+=hits[i]->GetZ();
113  sumZ2+=hits[i]->GetZ()*hits[i]->GetZ();
114  sumX+=hits[i]->GetX();
115  sumZX+=hits[i]->GetZ()*hits[i]->GetX();
116  }
117  Double_t matrix[2][3];
118  matrix[0][0]=hits.size();
119  matrix[1][0]=sumZ;
120  matrix[0][1]=sumZ;
121  matrix[1][1]=sumZ2;
122  matrix[0][2]=sumX;
123  matrix[1][2]=sumZX;
124  TVector2 result = linearRegression(matrix);
125  TVector3 p1(result.X()+hits[0]->GetZ()*result.Y(),0,hits[0]->GetZ());
126  TVector3 p2(result.X()+(hits[0]->GetZ()+50)*result.Y(),0,hits[0]->GetZ()+50);
127  TVector3 dir = p1-p2;
128  return PndLine(p1,dir);
129 }
PndLine linearRegression(vector< PndFtsHit * > hits)
Int_t i
Definition: run_full.C:25
Double_t
TPad * p2
Definition: hist-t7.C:117
TPad * p1
Definition: hist-t7.C:116
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
PndLine PndLineApproximation::linearRegressionZY ( vector< PndFtsHit * >  hits)

Definition at line 156 of file PndLineApproximation.cxx.

References Double_t, i, linearRegression(), p1, and p2.

Referenced by linearRegression().

156  {
157  Double_t sumZ = 0;
158  Double_t sumZ2 = 0;
159  Double_t sumY = 0;
160  Double_t sumZY = 0;
161  for(size_t i=0;i<hits.size();i++){
162  sumZ+=hits[i]->GetZ();
163  sumZ2+=hits[i]->GetZ()*hits[i]->GetZ();
164  sumY+=hits[i]->GetY();
165  sumZY+=hits[i]->GetZ()*hits[i]->GetY();
166  }
167  Double_t matrix[2][3];
168  matrix[0][0]=hits.size();
169  matrix[1][0]=sumZ;
170  matrix[0][1]=sumZ;
171  matrix[1][1]=sumZ2;
172  matrix[0][2]=sumY;
173  matrix[1][2]=sumZY;
174  TVector2 result = linearRegression(matrix);
175  TVector3 p1(0,result.X()+hits[0]->GetZ()*result.Y(),hits[0]->GetZ());
176  TVector3 p2(0,result.X()+(hits[0]->GetZ()+300)*result.Y(),hits[0]->GetZ()+300);
177  TVector3 dir = p1-p2;
178  return PndLine(p1,dir);
179 }
PndLine linearRegression(vector< PndFtsHit * > hits)
Int_t i
Definition: run_full.C:25
Double_t
TPad * p2
Definition: hist-t7.C:117
TPad * p1
Definition: hist-t7.C:116
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
PndLineApproximation PndLineApproximation::newApproximation ( PndLineApproximation approx2)

Definition at line 54 of file PndLineApproximation.cxx.

References correctHits3DAndAdd(), fCorrectedHits, fLineApprox, PndLine::getRating(), hits, i, linearRegression(), and PndLine::setRating().

Referenced by PndTrackCombiner::combine(), PndModuleCombiner::combineModules(), PndTrackCombiner::compareAndRefit(), PndFtsLineApproximator::createExpandedTrackCand(), and PndTrackCombiner::refitLines().

54  {
55  vector<PndFtsHit*> hits;
56  for(size_t i=0;i<fCorrectedHits.size();i++)
57  hits.push_back(fCorrectedHits[i]);
58  for(size_t i=0;i<approx2.fCorrectedHits.size();i++){
59  hits.push_back(approx2.fCorrectedHits[i]);
60  }
61  PndLine newLine = linearRegression(hits);
63  vector<PndFtsHit*> hits2;
64  PndLineApproximation newApprox(newLine,hits2);
65  newApprox.correctHits3DAndAdd(hits);
66  return newApprox;
67 }
PndLine linearRegression(vector< PndFtsHit * > hits)
Int_t i
Definition: run_full.C:25
vector< PndFtsHit * > fCorrectedHits
void setRating(Int_t r)
Definition: PndLine.h:44
Int_t getRating()
Definition: PndLine.h:42
CbmHit * hits[nHits]
Definition: RiemannTest.C:19
PndTrack PndLineApproximation::plot ( Double_t  zVal1,
Double_t  zVal2,
TClonesArray *  hitArr 
)

Definition at line 204 of file PndLineApproximation.cxx.

References PndTrackCand::AddHit(), fCorrectedHits, fLineApprox, i, PndLine::plot(), t, and v.

204  {
205  FairTrackParP tp1 = fLineApprox.plot(zVal1,zVal2);
206  TVector3 v(1, 1, 1);
207  FairTrackParP tp2(v, 0 * v, v, v, 1, v, v, v);
208  PndTrackCand cand;
209  Int_t j = hitArr->GetEntries();
210  for(size_t i=0;i<fCorrectedHits.size();i++){
211  fCorrectedHits[i]->SetEntryNr(FairLink(-1, FairRootManager::Instance()->GetEntryNr(),FairRootManager::Instance()->GetBranchId("CorrectedHits"), j));
212  new ((*hitArr)[j++]) PndFtsHit(*fCorrectedHits[i]);//PndFtsHit* myHit = //[R.K.03/2017] unused variable
213  cand.AddHit(fCorrectedHits[i]->GetEntryNr(),i);
214  }
215  PndTrack t(tp1,tp2,cand);
216  return t;
217 }
Int_t i
Definition: run_full.C:25
vector< PndFtsHit * > fCorrectedHits
__m128 v
Definition: P4_F32vec4.h:4
void AddHit(UInt_t detId, UInt_t hitId, Double_t rho)
TTree * t
Definition: bump_analys.C:13
FairTrackParP plot(Double_t zVal1, Double_t zVal2)
Definition: PndLine.cxx:49
void PndLineApproximation::setHits ( vector< PndFtsHit * >  h)
inline

Definition at line 34 of file PndLineApproximation.h.

References h.

Referenced by PndTrackCollection::add().

34 {fCorrectedHits = h;}
vector< PndFtsHit * > fCorrectedHits
void PndLineApproximation::setLine ( PndLine  l)
inline

Definition at line 32 of file PndLineApproximation.h.

void PndLineApproximation::setYInfo ( Bool_t  i)
inline

Definition at line 43 of file PndLineApproximation.h.

References i.

Referenced by PndTrackCombiner::combine().

43 {hasYInfo=i;}
Int_t i
Definition: run_full.C:25

Member Data Documentation

vector<PndFtsHit*> PndLineApproximation::fCorrectedHits
private

Definition at line 48 of file PndLineApproximation.h.

Referenced by correctHits3DAndAdd(), newApproximation(), and plot().

PndLine PndLineApproximation::fLineApprox
private
Bool_t PndLineApproximation::hasYInfo
private

Definition at line 50 of file PndLineApproximation.h.


The documentation for this class was generated from the following files: