]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSStrLine.cxx
Removing obsolete macros
[u/mrichter/AliRoot.git] / ITS / AliITSStrLine.cxx
CommitLineData
87eecb52 1/**************************************************************************
2 * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15///////////////////////////////////////////////////////////////////
16// //
17// A straight line is coded as a point (3 Double_t) and //
18// 3 direction cosines //
19// //
20///////////////////////////////////////////////////////////////////
21#include <Riostream.h>
22#include <TMath.h>
23#include <TObject.h>
24#include <TObjArray.h>
25#include <TTree.h>
26#include <TClonesArray.h>
27#include "AliITSStrLine.h"
28
29ClassImp(AliITSStrLine)
30
31//________________________________________________________
32AliITSStrLine::AliITSStrLine() {
33 // Default constructor
34 for(Int_t i=0;i<3;i++) {
35 fP0[i] = 0.;
36 fCd[i] = 0.;
37 }
38 fTpar = 0.;
39 SetDebug();
40}
41
42//________________________________________________________
43AliITSStrLine::AliITSStrLine(Double_t *point, Double_t *cd) {
44 // Standard constructor
45 Double_t norm = 0.;
46 for(Int_t i=0;i<3;i++)norm+=cd[i]*cd[i];
47 if(norm) {
48 norm = TMath::Sqrt(norm);
49 for(Int_t i=0;i<3;i++) cd[i]/=norm;
50 }
51 else {
52 Error("AliITSStrLine","Null direction cosines!!!");
53 }
54 SetP0(point);
55 SetCd(cd);
56 fTpar = 0.;
57 SetDebug();
58}
59
60//________________________________________________________
61AliITSStrLine::~AliITSStrLine() {
62 // destructor
63}
64
65//________________________________________________________
66void AliITSStrLine::PrintStatus() const {
67 // Print current status
68 cout <<"=======================================================\n";
69 cout <<"Direction cosines: ";
70 for(Int_t i=0;i<3;i++)cout <<fCd[i]<<"; ";
71 cout <<endl;
72 cout <<"Known point: ";
73 for(Int_t i=0;i<3;i++)cout <<fP0[i]<<"; ";
74 cout <<endl;
75 cout <<"Current value for the parameter: "<<fTpar<<endl;
76 cout <<" Debug flag: "<<fDebug<<endl;
77}
78
79//________________________________________________________
80Int_t AliITSStrLine::Crossrphi(AliITSStrLine *line){
81 // Cross 2 lines in the X-Y plane
82 Double_t p2[3];
83 Double_t cd2[3];
84 line->GetP0(p2);
85 line->GetCd(cd2);
86 Double_t a=fCd[0];
87 Double_t b=-cd2[0];
88 Double_t c=p2[0]-fP0[0];
89 Double_t d=fCd[1];
90 Double_t e=-cd2[1];
91 Double_t f=p2[1]-fP0[1];
92 Double_t deno = a*e-b*d;
93 Int_t retcode = 0;
94 if(deno != 0.) {
95 fTpar = (c*e-b*f)/deno;
96 }
97 else {
98 retcode = -1;
99 }
100 return retcode;
101}
102
103//________________________________________________________
104Int_t AliITSStrLine::Cross(AliITSStrLine *line, Double_t *point){
105 // Looks for the crossing point estimated starting from the
106 // DCA segment
107 Double_t p2[3];
108 Double_t cd2[3];
109 line->GetP0(p2);
110 line->GetCd(cd2);
111 Int_t i;
112 Double_t k1 = 0;
113 for(i=0;i<3;i++)k1+=(fP0[i]-p2[i])*fCd[i];
114 Double_t k2 = 0;
115 for(i=0;i<3;i++)k2+=(fP0[i]-p2[i])*cd2[i];
116 Double_t a11 = 0;
117 for(i=0;i<3;i++)a11+=fCd[i]*cd2[i];
118 Double_t a22 = -a11;
119 Double_t a21 = 0;
120 for(i=0;i<3;i++)a21+=cd2[i]*cd2[i];
121 Double_t a12 = 0;
122 for(i=0;i<3;i++)a12-=fCd[i]*fCd[i];
123 Double_t deno = a11*a22-a21*a12;
124 if(deno == 0.) return -1;
125 fTpar = (a11*k2-a21*k1) / deno;
126 Double_t par2 = (k1*a22-k2*a12) / deno;
127 line->SetPar(par2);
128 Double_t point1[3];
129 Double_t point2[3];
130 GetCurrentPoint(point1);
131 line->GetCurrentPoint(point2);
132 for(i=0;i<3;i++)point[i]=(point1[i]+point2[i])/2.;
133 return 0;
134}
135//________________________________________________________
136void AliITSStrLine::GetCurrentPoint(Double_t *point){
137 // Fills the array point with the current value on the line
138 for(Int_t i=0;i<3;i++)point[i]=fP0[i]+fCd[i]*fTpar;
139}