]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCpolyTrack.cxx
new classes added
[u/mrichter/AliRoot.git] / TPC / AliTPCpolyTrack.cxx
CommitLineData
1627d1c4 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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#include "AliTPCpolyTrack.h"
18#include "TMath.h"
19
20ClassImp(AliTPCpolyTrack)
21
22
23AliTPCpolyTrack::AliTPCpolyTrack()
24{
25 Reset();
26}
27
28void AliTPCpolyTrack::Reset()
29{
30 //
31 // reset track
32 fSumX = fSumX2= fSumX3=fSumX4 = fSumY=fSumYX=fSumYX2=fSumZ=fSumZX=fSumZX2=fSumW =0;
33 fNPoints = 0;
34}
35
36void AliTPCpolyTrack::AddPoint(Double_t x, Double_t y, Double_t z,Double_t sy, Double_t sz)
37{
38 //
39 //
40 if (fNPoints==0){
41 fMaxX = x;
42 fMinX = x;
43 }else{
44 if (x>fMaxX) fMaxX=x;
45 if (x<fMinX) fMinX=x;
46 }
47
48 Double_t x2 = x*x;
49 Double_t w = 2./(sy+sz);
50 fSumW += w;
51 //
52 fSumX += x*w;
53 fSumX2 += x2*w;
54 fSumX3 += x2*x*w;
55 fSumX4 += x2*x2*w;
56 //
57 fSumY +=y*w;
58 fSumYX +=y*x*w;
59 fSumYX2 +=y*x2*w;
60 //
61 fSumZ +=z*w;
62 fSumZX +=z*x*w;
63 fSumZX2 +=z*x2*w;
64 //
65 fX[fNPoints] = x;
66 fY[fNPoints] = y;
67 fZ[fNPoints] = z;
68 fSY[fNPoints] = sy;
69 fSZ[fNPoints] = sz;
70
71 fNPoints++;
72
73}
74
75void AliTPCpolyTrack::UpdateParameters()
76{
77 //
78 //
79 //Update fit parameters
80 if (fNPoints>4){
81 Fit2(fSumY,fSumYX,fSumYX2,fSumX,fSumX2,fSumX3,fSumX4,fSumW,fA,fB,fC);
82 // Fit2(fSumZ,fSumZX,fSumZX2,fSumX,fSumX2,fSumX3,fSumX4,fNPoints,fD,fE,fF);
83 Fit1(fSumZ,fSumZX,fSumX,fSumX2,fSumW,fD,fE,fF);
84 }
85 else
86 {
87 Fit1(fSumY,fSumYX,fSumX,fSumX2,fSumW,fA,fB,fC);
88 Fit1(fSumZ,fSumZX,fSumX,fSumX2,fSumW,fD,fE,fF);
89 }
90}
91
92
1627d1c4 93
94void AliTPCpolyTrack::Fit2(Double_t fSumY, Double_t fSumYX, Double_t fSumYX2,
95 Double_t fSumX, Double_t fSumX2, Double_t fSumX3,
96 Double_t fSumX4, Double_t fSumW,
97 Double_t &a, Double_t &b, Double_t &c)
98{
99 //fit of second order
100 Double_t det =
101 fSumW* (fSumX2*fSumX4-fSumX3*fSumX3) -
102 fSumX* (fSumX*fSumX4-fSumX3*fSumX2)+
103 fSumX2* (fSumX*fSumX3-fSumX2*fSumX2);
104
105 if (TMath::Abs(det)> 0.000000000000001) {
106 a =
107 (fSumY * (fSumX2*fSumX4-fSumX3*fSumX3)-
108 fSumX *(fSumYX*fSumX4-fSumYX2*fSumX3)+
109 fSumX2*(fSumYX*fSumX3-fSumYX2*fSumX2))/det;
110 b=
111 (fSumW*(fSumYX*fSumX4-fSumX3*fSumYX2)-
112 fSumY*(fSumX*fSumX4-fSumX3*fSumX2)+
113 fSumX2*(fSumX*fSumYX2-fSumYX*fSumX2))/det;
114 c=
115 (fSumW*(fSumX2*fSumYX2-fSumYX*fSumX3)-
116 fSumX*(fSumX*fSumYX2-fSumYX*fSumX2)+
117 fSumY*(fSumX*fSumX3-fSumX2*fSumX2))/det;
118 }
119}
120
121void AliTPCpolyTrack::Fit1(Double_t fSumY, Double_t fSumYX,
122 Double_t fSumX, Double_t fSumX2,
123 Double_t fSumW, Double_t &a, Double_t &b, Double_t &c)
124{
125 //
126 //
127 //
128 Double_t det = fSumW*fSumX2-fSumX*fSumX;
129 if (TMath::Abs(det)> 0.000000000000001) {
130 b = (fSumW*fSumYX-fSumX*fSumY)/det;
131 a = (fSumX2*fSumY-fSumX*fSumYX)/det;
132 c = 0;
133 }else{
134 a =fSumYX/fSumX;
135 b =0;
136 c =0;
137 }
138
139}
37264142 140
141void AliTPCpolyTrack::Refit(AliTPCpolyTrack &track, Double_t deltay, Double_t deltaz)
142{
143 //
144 // refit with cut on distortion
145 //
146 track.Reset();
147 //first refit to temporary
148 AliTPCpolyTrack track0;
149 track0.Reset;
150 for (Int_t i=0;i<fNPoints;i++){
151 Double_t y,z;
152 GetFitPoint(fX[i],y,z);
153 if ( (TMath::Abs(y-fY[i])<deltay)&&(TMath::Abs(z-fZ[i])<deltaz)){
154 track0.AddPoint(fX[i],y,z);
155 }
156 }
157 if (track0.GetN()>2)
158 track0.UpdateParameters();
159 else
160 return;
161 //
162 for (Int_t i=0;i<fNPoints;i++){
163 Double_t y,z;
164 track0.GetFitPoint(fX[i],y,z);
165 if ( (TMath::Abs(y-fY[i])<deltay)&&(TMath::Abs(z-fZ[i])<deltaz)){
166 track.AddPoint(fX[i],y,z);
167 }
168 }
169 if (track.GetN()>2)
170 track.UpdateParameters();
171
172}
173