FairRoot/PandaRoot
PndLine.cxx
Go to the documentation of this file.
1 /*
2  * PndLine.cpp
3  *
4  * Created on: Jun 14, 2016
5  * Author: kibellus
6  */
7 
8 #include <PndLine.h>
9 
10 PndLine::PndLine(FairHit *h1, FairHit *h2){
11  h1->Position(fP1);
12  h2->Position(fP2);
13  fRating = 1;
14 }
15 
16 PndLine::PndLine(TVector3 &base, TVector3 &dir){
17  fP1=base;
18  fP2=base+dir;
19  fRating = 1;
20 }
21 
22 PndLine::PndLine(TVector3 h1, Int_t layer){
23  fP1 = h1;
24  if(layer%4==1){
25  fP2 = fP1+TVector3(TMath::Sin(-5*TMath::DegToRad()),TMath::Cos(-5*TMath::DegToRad()),0);
26  }else if(layer%4==2){
27  fP2 = fP1+TVector3(TMath::Sin(5*TMath::DegToRad()),TMath::Cos(5*TMath::DegToRad()),0);
28  } else {
29  fP2 = fP1+TVector3(0,1,0);
30  }
31  fRating = 1;
32 }
33 
35  // TODO Auto-generated destructor stub
36 }
37 
38 void PndLine::Print(Bool_t withDirVec){
39  cout << "Line:";
40  cout << "(" << fP1[0] << "," << fP1[1] << "," << fP1[2] << ")";
41  if(!withDirVec)
42  cout << ",(" << fP2[0] << "," << fP2[1] << "," << fP2[2] << ")";
43  else{
44  TVector3 d = fP2-fP1;
45  cout << "+l*(" << d[0] << "," << d[1] << "," << d[2] << ")";
46  }
47 }
48 
49 FairTrackParP PndLine::plot(Double_t zVal1, Double_t zVal2){
50  TVector3 dir = getDir();
51  Double_t lam1 = (zVal1 - fP1[2])/dir[2];
52  Double_t lam2 = (zVal2 - fP1[2])/dir[2];
53  TVector3 pointA = fP1+lam1*dir;
54  TVector3 pointB = fP1+lam2*dir;
55  TVector3 dir2 = pointB-pointA;
56  TVector3 v(1, 1, 1);
57  FairTrackParP tp(pointA, 2 * dir2.Unit(), v, v, 1, v, v, v);
58  return tp;
59 }
60 /*
61 PndLine PndLine::approx(PndLine &l2){
62  TVector3 v1 = getDir().Unit();
63  TVector3 v2 = l2.getDir().Unit();
64  v1*=rating;
65  v2*=l2.rating;
66  TVector3 newDir = v1+v2;
67  TVector3 newBase = (p1*rating + l2.p1*l2.rating);
68  newBase*=1/(rating + l2.rating);
69  TVector3 newBase2 = p1+newDir;
70  PndLine newLine(p1,newBase2);
71  newLine.rating = rating + l2.rating;
72  return newLine;
73 }*/
74 
75 
76 TVector3 PndLine::getPerpendicular(PndLine l2){//returns point on this line
77  PndPlane plane(l2.fP1,l2.getDir(),getDir().Cross(l2.getDir()));
78  return plane.getIntersection(*this);
79 }
80 
82  TVector3 p3 = (p-fP1).Cross(getDir());
83  Double_t dist = p3.Mag()/getDir().Mag();
84  return dist;
85 }
PndLine getIntersection(PndPlane &p)
Definition: PndPlane.cxx:28
Double_t p
Definition: anasim.C:58
TVector3 getPerpendicular(PndLine l2)
Definition: PndLine.cxx:76
TObjArray * d
static T Sin(const T &x)
Definition: PndCAMath.h:42
PndLine()
Definition: PndLine.h:25
TVector3 getDir()
Definition: PndLine.h:34
static T Cos(const T &x)
Definition: PndCAMath.h:43
__m128 v
Definition: P4_F32vec4.h:4
TVector3 fP1
Definition: PndLine.h:49
TVector3 fP2
Definition: PndLine.h:50
Double_t
void Print(Bool_t withDirVec=kFALSE)
Definition: PndLine.cxx:38
Double_t getDistTo(TVector3 p)
Definition: PndLine.cxx:81
Int_t fRating
Definition: PndLine.h:51
virtual ~PndLine()
Definition: PndLine.cxx:34
Int_t layer
Definition: reco_muo.C:36
FairTrackParP plot(Double_t zVal1, Double_t zVal2)
Definition: PndLine.cxx:49