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

#include <PndPlane.h>

Public Member Functions

 PndPlane (TVector3 b, TVector3 d1, TVector3 d2)
 
 PndPlane (PndLine line, Int_t layer)
 
virtual ~PndPlane ()
 
PndLine getIntersection (PndPlane &p)
 
void Print ()
 
TVector3 getBase ()
 
TVector3 getDir1 ()
 
TVector3 getDir2 ()
 
TVector3 getIntersection (PndLine l)
 

Private Attributes

TVector3 base
 
TVector3 dir1
 
TVector3 dir2
 

Detailed Description

Definition at line 21 of file PndPlane.h.

Constructor & Destructor Documentation

PndPlane::PndPlane ( TVector3  b,
TVector3  d1,
TVector3  d2 
)
inline

Definition at line 23 of file PndPlane.h.

23 : base(b),dir1(d1),dir2(d2) {}
TTree * b
TVector3 dir2
Definition: PndPlane.h:35
TVector3 dir1
Definition: PndPlane.h:34
TVector3 base
Definition: PndPlane.h:33
PndPlane::PndPlane ( PndLine  line,
Int_t  layer 
)

Definition at line 11 of file PndPlane.cxx.

References base, CAMath::Cos(), dir1, dir2, PndLine::getP1(), PndLine::getP2(), and CAMath::Sin().

11  {
12  base = line.getP1();
13  dir1 = line.getP2()-line.getP1();
14  if(layer%4==1){
15  dir2 = TVector3(TMath::Sin(-5*TMath::DegToRad()),TMath::Cos(-5*TMath::DegToRad()),0);
16  }else if(layer%4==2){
17  dir2 = TVector3(TMath::Sin(5*TMath::DegToRad()),TMath::Cos(5*TMath::DegToRad()),0);
18  } else {
19  dir2 = TVector3(0,1,0);
20  }
21 }
TVector3 dir2
Definition: PndPlane.h:35
static T Sin(const T &x)
Definition: PndCAMath.h:42
TVector3 getP2()
Definition: PndLine.h:33
static T Cos(const T &x)
Definition: PndCAMath.h:43
TVector3 dir1
Definition: PndPlane.h:34
TVector3 getP1()
Definition: PndLine.h:32
TVector3 base
Definition: PndPlane.h:33
PndPlane::~PndPlane ( )
virtual

Definition at line 23 of file PndPlane.cxx.

23  {
24  // TODO Auto-generated destructor stub
25 }

Member Function Documentation

TVector3 PndPlane::getBase ( )
inline

Definition at line 28 of file PndPlane.h.

28 {return base;}
TVector3 base
Definition: PndPlane.h:33
TVector3 PndPlane::getDir1 ( )
inline

Definition at line 29 of file PndPlane.h.

29 {return dir1;}
TVector3 dir1
Definition: PndPlane.h:34
TVector3 PndPlane::getDir2 ( )
inline

Definition at line 30 of file PndPlane.h.

30 {return dir2;}
TVector3 dir2
Definition: PndPlane.h:35
PndLine PndPlane::getIntersection ( PndPlane p)

Definition at line 28 of file PndPlane.cxx.

References base, dir1, dir2, Double_t, and i.

Referenced by PndTrackCombiner::combine(), PndWayFollower::getBestSkewedApproxTo(), and PndLine::getPerpendicular().

28  {
29  //create the direction vector
30  TVector3 norm1 = dir1.Cross(dir2);
31  Double_t d1 = norm1.Dot(base);
32  TVector3 norm2 = p.dir1.Cross(p.dir2);
33  Double_t d2 = norm2.Dot(p.base);
34  TVector3 dirLine = norm1.Cross(norm2);
35  //create the base vector
36 
37  //init array
38  Double_t arr[2][3];
39  arr[0][0]=norm1[0];
40  arr[0][1]=norm1[1];
41  arr[0][2]=d1-norm1[2]*base[2];
42  arr[1][0]=norm2[0];
43  arr[1][1]=norm2[1];
44  arr[1][2]=d2-norm2[2]*base[2];
45 
46  //swap rows
47  if(arr[0][0]==0){
48  for(int i=0;i<3;i++){
49  //Double_t temp = arr[0][i]; //[R.K.03/2017] unused variable
50  arr[0][i]=arr[1][i];
51  arr[1][i]=arr[0][i];
52  }
53  }
54 
55  Double_t fac = -arr[1][0]/arr[0][0];
56  for(int i=0;i<3;i++){
57  arr[1][i]+=fac*arr[0][i];
58  }
59 
60  Double_t x2 = arr[1][2]/arr[1][1];
61  Double_t x1 = (arr[0][2]-x2*arr[0][1])/arr[0][0];
62 
63  //create the line
64  TVector3 lineBase;
65  lineBase.SetXYZ(x1,x2,base[2]);
66  PndLine l(lineBase,dirLine);
67  return l;
68 }
Int_t i
Definition: run_full.C:25
TVector3 dir2
Definition: PndPlane.h:35
Double_t
TVector3 dir1
Definition: PndPlane.h:34
TVector3 base
Definition: PndPlane.h:33
TVector3 PndPlane::getIntersection ( PndLine  l)

Definition at line 78 of file PndPlane.cxx.

References CAMath::Abs(), base, dir1, dir2, Double_t, PndLine::getDir(), PndLine::getP1(), i, and max().

78  {
79  //create the Matrix
80  TVector3 lineDir = l.getDir();
81  TVector3 lineBase = l.getP1();
82  Double_t matrix[3][4];
83  for(int i=0;i<3;i++){
84  matrix[i][0]=dir1[i];
85  matrix[i][1]=dir2[i];
86  matrix[i][2]=-lineDir[i];
87  matrix[i][3]=lineBase[i]-base[i];
88  }
89  //solve the Matrix
90  for(int i=0;i<3;i++){
91  if(TMath::Abs(matrix[i][i])<0.000000001){//equal 0
92  //search max element
93  Int_t max = i;
94  for(int j=i+1;j<3;j++){
95  if(TMath::Abs(matrix[j][i])>TMath::Abs(matrix[max][i]))max=j;
96  }
97  //no greater element found
98  if(max==i){
99  cout << "\033[1;31mNo Intersection from plane and line\033[0m" << endl;
100  return TVector3(0,0,0);
101  }
102  //swap lines
103  for(int j=i;j<4;j++){
104  Double_t temp = matrix[i][j];
105  matrix[i][j] = matrix[max][j];
106  matrix[max][j] = temp;
107  }
108  }
109  for(int j=i+1;j<3;j++){
110  Double_t fac = -matrix[j][i]/matrix[i][i];
111  for(int k=i;k<4;k++){
112  matrix[j][k]+=(fac*matrix[i][k]);
113  }
114  }
115  }
116  //create the result
117  Double_t lamp = matrix[2][3]/matrix[2][2];
118  return lineBase+lamp*lineDir;
119 }
Int_t i
Definition: run_full.C:25
TVector3 dir2
Definition: PndPlane.h:35
TVector3 getDir()
Definition: PndLine.h:34
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:26
static T Abs(const T &x)
Definition: PndCAMath.h:39
Double_t
TVector3 dir1
Definition: PndPlane.h:34
TVector3 getP1()
Definition: PndLine.h:32
TVector3 base
Definition: PndPlane.h:33
void PndPlane::Print ( )

Definition at line 70 of file PndPlane.cxx.

References base, dir1, and dir2.

70  {
71  cout << "Plane:";
72  cout << "(" << base[0] << "," << base[1] << "," << base[2] << ")";
73  cout << "+a*(" << dir1[0] << "," << dir1[1] << "," << dir1[2] << ")";
74  cout << "+b*(" << dir2[0] << "," << dir2[1] << "," << dir2[2] << ")";
75 }
TVector3 dir2
Definition: PndPlane.h:35
TVector3 dir1
Definition: PndPlane.h:34
TVector3 base
Definition: PndPlane.h:33

Member Data Documentation

TVector3 PndPlane::base
private

Definition at line 33 of file PndPlane.h.

Referenced by getIntersection(), PndPlane(), and Print().

TVector3 PndPlane::dir1
private

Definition at line 34 of file PndPlane.h.

Referenced by getIntersection(), PndPlane(), and Print().

TVector3 PndPlane::dir2
private

Definition at line 35 of file PndPlane.h.

Referenced by getIntersection(), PndPlane(), and Print().


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