Tracking of secondaries (M.Ivanov)
[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
93void AliTPCpolyTrack::GetFitPoint(Double_t x, Double_t &y, Double_t &z)
94{
95 y = fA+fB*x+fC*x*x;
96 z = fD+fE*x+fF*x*x;
97}
98
99
100void AliTPCpolyTrack::Fit2(Double_t fSumY, Double_t fSumYX, Double_t fSumYX2,
101 Double_t fSumX, Double_t fSumX2, Double_t fSumX3,
102 Double_t fSumX4, Double_t fSumW,
103 Double_t &a, Double_t &b, Double_t &c)
104{
105 //fit of second order
106 Double_t det =
107 fSumW* (fSumX2*fSumX4-fSumX3*fSumX3) -
108 fSumX* (fSumX*fSumX4-fSumX3*fSumX2)+
109 fSumX2* (fSumX*fSumX3-fSumX2*fSumX2);
110
111 if (TMath::Abs(det)> 0.000000000000001) {
112 a =
113 (fSumY * (fSumX2*fSumX4-fSumX3*fSumX3)-
114 fSumX *(fSumYX*fSumX4-fSumYX2*fSumX3)+
115 fSumX2*(fSumYX*fSumX3-fSumYX2*fSumX2))/det;
116 b=
117 (fSumW*(fSumYX*fSumX4-fSumX3*fSumYX2)-
118 fSumY*(fSumX*fSumX4-fSumX3*fSumX2)+
119 fSumX2*(fSumX*fSumYX2-fSumYX*fSumX2))/det;
120 c=
121 (fSumW*(fSumX2*fSumYX2-fSumYX*fSumX3)-
122 fSumX*(fSumX*fSumYX2-fSumYX*fSumX2)+
123 fSumY*(fSumX*fSumX3-fSumX2*fSumX2))/det;
124 }
125}
126
127void AliTPCpolyTrack::Fit1(Double_t fSumY, Double_t fSumYX,
128 Double_t fSumX, Double_t fSumX2,
129 Double_t fSumW, Double_t &a, Double_t &b, Double_t &c)
130{
131 //
132 //
133 //
134 Double_t det = fSumW*fSumX2-fSumX*fSumX;
135 if (TMath::Abs(det)> 0.000000000000001) {
136 b = (fSumW*fSumYX-fSumX*fSumY)/det;
137 a = (fSumX2*fSumY-fSumX*fSumYX)/det;
138 c = 0;
139 }else{
140 a =fSumYX/fSumX;
141 b =0;
142 c =0;
143 }
144
145}