1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 // this class is used for a simple
17 // track fitting using the polynom
18 // bending in both directions are allowed
19 //-----------------------------------------------------------------
22 #include "AliTPCpolyTrack.h"
25 ClassImp(AliTPCpolyTrack)
28 AliTPCpolyTrack::AliTPCpolyTrack()
33 void AliTPCpolyTrack::Reset()
37 fSumX = fSumX2= fSumX3=fSumX4 = fSumY=fSumYX=fSumYX2=fSumZ=fSumZX=fSumZX2=fSumW =0;
41 void AliTPCpolyTrack::AddPoint(Double_t x, Double_t y, Double_t z,Double_t sy, Double_t sz)
54 Double_t w = 2./(sy+sz);
80 void AliTPCpolyTrack::UpdateParameters()
84 //Update fit parameters
86 Fit2(fSumY,fSumYX,fSumYX2,fSumX,fSumX2,fSumX3,fSumX4,fSumW,fA,fB,fC);
87 // Fit2(fSumZ,fSumZX,fSumZX2,fSumX,fSumX2,fSumX3,fSumX4,fNPoints,fD,fE,fF);
88 Fit1(fSumZ,fSumZX,fSumX,fSumX2,fSumW,fD,fE,fF);
92 Fit1(fSumY,fSumYX,fSumX,fSumX2,fSumW,fA,fB,fC);
93 Fit1(fSumZ,fSumZX,fSumX,fSumX2,fSumW,fD,fE,fF);
97 void AliTPCpolyTrack::UpdateParameters(Int_t ny, Int_t nz)
101 //Update fit parameters
103 Fit2(fSumY,fSumYX,fSumYX2,fSumX,fSumX2,fSumX3,fSumX4,fSumW,fA,fB,fC);
106 Fit1(fSumY,fSumYX,fSumX,fSumX2,fSumW,fA,fB,fC);
109 Fit2(fSumZ,fSumZX,fSumZX2,fSumX,fSumX2,fSumX3,fSumX4,fNPoints,fD,fE,fF);
112 Fit1(fSumZ,fSumZX,fSumX,fSumX2,fSumW,fD,fE,fF);
118 void AliTPCpolyTrack::Fit2(Double_t fSumY, Double_t fSumYX, Double_t fSumYX2,
119 Double_t fSumX, Double_t fSumX2, Double_t fSumX3,
120 Double_t fSumX4, Double_t fSumW,
121 Double_t &a, Double_t &b, Double_t &c)
123 //fit of second order
125 fSumW* (fSumX2*fSumX4-fSumX3*fSumX3) -
126 fSumX* (fSumX*fSumX4-fSumX3*fSumX2)+
127 fSumX2* (fSumX*fSumX3-fSumX2*fSumX2);
129 if (TMath::Abs(det)> 0.000000000000001) {
131 (fSumY * (fSumX2*fSumX4-fSumX3*fSumX3)-
132 fSumX *(fSumYX*fSumX4-fSumYX2*fSumX3)+
133 fSumX2*(fSumYX*fSumX3-fSumYX2*fSumX2))/det;
135 (fSumW*(fSumYX*fSumX4-fSumX3*fSumYX2)-
136 fSumY*(fSumX*fSumX4-fSumX3*fSumX2)+
137 fSumX2*(fSumX*fSumYX2-fSumYX*fSumX2))/det;
139 (fSumW*(fSumX2*fSumYX2-fSumYX*fSumX3)-
140 fSumX*(fSumX*fSumYX2-fSumYX*fSumX2)+
141 fSumY*(fSumX*fSumX3-fSumX2*fSumX2))/det;
145 void AliTPCpolyTrack::Fit1(Double_t fSumY, Double_t fSumYX,
146 Double_t fSumX, Double_t fSumX2,
147 Double_t fSumW, Double_t &a, Double_t &b, Double_t &c)
152 Double_t det = fSumW*fSumX2-fSumX*fSumX;
153 if (TMath::Abs(det)> 0.000000000000001) {
154 b = (fSumW*fSumYX-fSumX*fSumY)/det;
155 a = (fSumX2*fSumY-fSumX*fSumYX)/det;
165 void AliTPCpolyTrack::Refit(AliTPCpolyTrack &track, Double_t deltay, Double_t deltaz)
168 // refit with cut on distortion
171 //first refit to temporary
172 AliTPCpolyTrack track0;
174 for (Int_t i=0;i<fNPoints;i++){
176 GetFitPoint(fX[i],y,z);
177 if ( (TMath::Abs(y-fY[i])<deltay)&&(TMath::Abs(z-fZ[i])<deltaz)){
178 track0.AddPoint(fX[i],y,z);
182 track0.UpdateParameters();
186 for (Int_t i=0;i<fNPoints;i++){
188 track0.GetFitPoint(fX[i],y,z);
189 if ( (TMath::Abs(y-fY[i])<deltay)&&(TMath::Abs(z-fZ[i])<deltaz)){
190 track.AddPoint(fX[i],y,z);
194 track.UpdateParameters();
198 void AliTPCpolyTrack::Refit(AliTPCpolyTrack &track, Double_t deltay, Double_t deltaz, Int_t nfirst, Int_t ny, Int_t nz)
201 // refit with cut on distortion
204 //first refit to temporary
205 AliTPCpolyTrack track0;
207 for (Int_t i=0;i<fNPoints;i++){
209 GetFitPoint(fX[i],y,z);
210 if ( (TMath::Abs(y-fY[i])<deltay)&&(TMath::Abs(z-fZ[i])<deltaz)){
211 track0.AddPoint(fX[i],y,z);
214 if (track0.GetN()>2){
215 if (track0.GetN()>nfirst)
216 track0.UpdateParameters(ny,nz);
218 track0.UpdateParameters(1,1);
223 for (Int_t i=0;i<fNPoints;i++){
225 track0.GetFitPoint(fX[i],y,z);
226 if ( (TMath::Abs(y-fY[i])<deltay)&&(TMath::Abs(z-fZ[i])<deltaz)){
227 track.AddPoint(fX[i],y,z);
231 track.UpdateParameters(ny,nz);