]>
Commit | Line | Data |
---|---|---|
46ae650f | 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 | // Implementation of the derived class for track residuals | |
18 | // based on linear chi2 minimization (in approximation of | |
19 | // small alignment angles and translations) | |
20 | // | |
21 | //----------------------------------------------------------------- | |
22 | ||
23 | #include <TMinuit.h> | |
24 | #include <TGeoMatrix.h> | |
25 | ||
cc345ce3 | 26 | #include "AliLog.h" |
46ae650f | 27 | #include "AliAlignObj.h" |
28 | #include "AliTrackPointArray.h" | |
29 | #include "AliTrackResidualsFast.h" | |
30 | ||
31 | ClassImp(AliTrackResidualsFast) | |
32 | ||
33 | //______________________________________________________________________________ | |
75e3794b | 34 | AliTrackResidualsFast::AliTrackResidualsFast(): |
35 | AliTrackResiduals(), | |
36 | fSumR(0) | |
46ae650f | 37 | { |
38 | // Default constructor | |
cc345ce3 | 39 | for (Int_t i = 0; i < 27; i++) fSum[i] = 0; |
46ae650f | 40 | } |
41 | ||
42 | //______________________________________________________________________________ | |
43 | AliTrackResidualsFast::AliTrackResidualsFast(Int_t ntracks): | |
75e3794b | 44 | AliTrackResiduals(ntracks), |
45 | fSumR(0) | |
46ae650f | 46 | { |
47 | // Constructor | |
cc345ce3 | 48 | for (Int_t i = 0; i < 27; i++) fSum[i] = 0; |
46ae650f | 49 | } |
50 | ||
51 | //______________________________________________________________________________ | |
52 | AliTrackResidualsFast::AliTrackResidualsFast(const AliTrackResidualsFast &res): | |
75e3794b | 53 | AliTrackResiduals(res), |
54 | fSumR(res.fSumR) | |
46ae650f | 55 | { |
56 | // Copy constructor | |
cc345ce3 | 57 | for (Int_t i = 0; i < 27; i++) fSum[i] = res.fSum[i]; |
46ae650f | 58 | } |
59 | ||
60 | //______________________________________________________________________________ | |
61 | AliTrackResidualsFast &AliTrackResidualsFast::operator= (const AliTrackResidualsFast& res) | |
62 | { | |
63 | // Assignment operator | |
64 | ((AliTrackResiduals *)this)->operator=(res); | |
cc345ce3 | 65 | for (Int_t i = 0; i < 27; i++) fSum[i] = res.fSum[i]; |
46ae650f | 66 | fSumR = res.fSumR; |
67 | ||
68 | return *this; | |
69 | } | |
70 | ||
71 | //______________________________________________________________________________ | |
72 | Bool_t AliTrackResidualsFast::Minimize() | |
73 | { | |
74 | // Implementation of fast linear Chi2 | |
75 | // based minimization of track residuals sum | |
cc345ce3 | 76 | for (Int_t i = 0; i < 27; i++) fSum[i] = 0; |
46ae650f | 77 | fSumR = 0; |
78 | ||
79 | AliTrackPoint p1,p2; | |
80 | ||
81 | for (Int_t itrack = 0; itrack < fLast; itrack++) { | |
82 | if (!fVolArray[itrack] || !fTrackArray[itrack]) continue; | |
83 | for (Int_t ipoint = 0; ipoint < fVolArray[itrack]->GetNPoints(); ipoint++) { | |
84 | fVolArray[itrack]->GetPoint(p1,ipoint); | |
85 | fTrackArray[itrack]->GetPoint(p2,ipoint); | |
86 | AddPoints(p1,p2); | |
87 | } | |
88 | } | |
89 | ||
90 | return Update(); | |
91 | ||
92 | // debug info | |
93 | // Float_t chi2 = 0; | |
94 | // for (Int_t itrack = 0; itrack < fLast; itrack++) { | |
95 | // if (!fVolArray[itrack] || !fTrackArray[itrack]) continue; | |
96 | // for (Int_t ipoint = 0; ipoint < fVolArray[itrack]->GetNPoints(); ipoint++) { | |
97 | // fVolArray[itrack]->GetPoint(p1,ipoint); | |
98 | // fAlignObj->Transform(p1); | |
99 | // fTrackArray[itrack]->GetPoint(p2,ipoint); | |
100 | // Float_t residual = p2.GetResidual(p1,kFALSE); | |
101 | // chi2 += residual; | |
102 | // } | |
103 | // } | |
104 | // printf("Final chi2 = %f\n",chi2); | |
105 | } | |
106 | ||
107 | //______________________________________________________________________________ | |
108 | void AliTrackResidualsFast::AddPoints(AliTrackPoint &p, AliTrackPoint &pprime) | |
109 | { | |
110 | // Update the sums used for | |
111 | // the linear chi2 minimization | |
112 | Float_t xyz[3],xyzp[3]; | |
cc345ce3 | 113 | Float_t cov[6],covp[6]; |
114 | p.GetXYZ(xyz,cov); pprime.GetXYZ(xyzp,covp); | |
115 | TMatrixDSym mcov(3); | |
116 | mcov(0,0) = cov[0]; mcov(0,1) = cov[1]; mcov(0,2) = cov[2]; | |
117 | mcov(1,0) = cov[1]; mcov(1,1) = cov[3]; mcov(1,2) = cov[4]; | |
118 | mcov(2,0) = cov[2]; mcov(2,1) = cov[4]; mcov(2,2) = cov[5]; | |
119 | TMatrixDSym mcovp(3); | |
120 | mcovp(0,0) = covp[0]; mcovp(0,1) = covp[1]; mcovp(0,2) = covp[2]; | |
121 | mcovp(1,0) = covp[1]; mcovp(1,1) = covp[3]; mcovp(1,2) = covp[4]; | |
122 | mcovp(2,0) = covp[2]; mcovp(2,1) = covp[4]; mcovp(2,2) = covp[5]; | |
123 | TMatrixDSym msum = mcov + mcovp; | |
124 | msum.Invert(); | |
125 | if (!msum.IsValid()) return; | |
126 | ||
127 | TMatrixD sums(3,1); | |
128 | sums(0,0) = (xyzp[0]-xyz[0]); | |
129 | sums(1,0) = (xyzp[1]-xyz[1]); | |
130 | sums(2,0) = (xyzp[2]-xyz[2]); | |
131 | TMatrixD sumst = sums.T(); sums.T(); | |
132 | ||
133 | TMatrixD mf(3,6); | |
134 | mf(0,0) = 1; mf(1,0) = 0; mf(2,0) = 0; | |
135 | mf(0,1) = 0; mf(1,1) = 1; mf(2,1) = 0; | |
136 | mf(0,2) = 0; mf(1,2) = 0; mf(2,2) = 1; | |
137 | mf(0,3) = 0; mf(1,3) =-xyz[2]; mf(2,3) = xyz[1]; | |
138 | mf(0,4) = xyz[2]; mf(1,4) = 0; mf(2,4) =-xyz[0]; | |
139 | mf(0,5) =-xyz[1]; mf(1,5) = xyz[0]; mf(2,5) = 0; | |
140 | TMatrixD mft = mf.T(); mf.T(); | |
141 | TMatrixD sums2 = mft * msum * sums; | |
142 | ||
143 | TMatrixD smatrix = mft * msum * mf; | |
144 | ||
145 | fSum[0] += smatrix(0,0); | |
146 | fSum[1] += smatrix(0,1); | |
147 | fSum[2] += smatrix(0,2); | |
148 | fSum[3] += smatrix(0,3); | |
149 | fSum[4] += smatrix(0,4); | |
150 | fSum[5] += smatrix(0,5); | |
151 | fSum[6] += smatrix(1,1); | |
152 | fSum[7] += smatrix(1,2); | |
153 | fSum[8] += smatrix(1,3); | |
154 | fSum[9] += smatrix(1,4); | |
155 | fSum[10]+= smatrix(1,5); | |
156 | fSum[11]+= smatrix(2,2); | |
157 | fSum[12]+= smatrix(2,3); | |
158 | fSum[13]+= smatrix(2,4); | |
159 | fSum[14]+= smatrix(2,5); | |
160 | fSum[15]+= smatrix(3,3); | |
161 | fSum[16]+= smatrix(3,4); | |
162 | fSum[17]+= smatrix(3,5); | |
163 | fSum[18]+= smatrix(4,4); | |
164 | fSum[19]+= smatrix(4,5); | |
165 | fSum[20]+= smatrix(5,5); | |
166 | fSum[21] += sums2(0,0); | |
167 | fSum[22] += sums2(1,0); | |
168 | fSum[23] += sums2(2,0); | |
169 | fSum[24] += sums2(3,0); | |
170 | fSum[25] += sums2(4,0); | |
171 | fSum[26] += sums2(5,0); | |
172 | ||
173 | TMatrixD tmp = sumst * msum * sums; | |
174 | fSumR += tmp(0,0); | |
46ae650f | 175 | |
176 | fNdf += 3; | |
177 | } | |
178 | ||
179 | //______________________________________________________________________________ | |
180 | Bool_t AliTrackResidualsFast::Update() | |
181 | { | |
182 | // Find the alignment parameters | |
183 | // by using the already accumulated | |
184 | // sums | |
185 | TMatrixDSym smatrix(6); | |
186 | TMatrixD sums(1,6); | |
187 | ||
3bbfb291 | 188 | smatrix(0,0) = fSum[0]; |
189 | smatrix(0,1) = smatrix(1,0) = fSum[1]; | |
190 | smatrix(0,2) = smatrix(2,0) = fSum[2]; | |
191 | smatrix(0,3) = smatrix(3,0) = fSum[3]; | |
192 | smatrix(0,4) = smatrix(4,0) = fSum[4]; | |
193 | smatrix(0,5) = smatrix(5,0) = fSum[5]; | |
194 | smatrix(1,1) = fSum[6]; | |
195 | smatrix(1,2) = smatrix(2,1) = fSum[7]; | |
196 | smatrix(1,3) = smatrix(3,1) = fSum[8]; | |
197 | smatrix(1,4) = smatrix(4,1) = fSum[9]; | |
198 | smatrix(1,5) = smatrix(5,1) = fSum[10]; | |
199 | smatrix(2,2) = fSum[11]; | |
200 | smatrix(2,3) = smatrix(3,2) = fSum[12]; | |
201 | smatrix(2,4) = smatrix(4,2) = fSum[13]; | |
202 | smatrix(2,5) = smatrix(5,2) = fSum[14]; | |
203 | smatrix(3,3) = fSum[15]; | |
204 | smatrix(3,4) = smatrix(4,3) = fSum[16]; | |
205 | smatrix(3,5) = smatrix(5,3) = fSum[17]; | |
206 | smatrix(4,4) = fSum[18]; | |
207 | smatrix(4,5) = smatrix(5,4) = fSum[19]; | |
cc345ce3 | 208 | smatrix(5,5) = fSum[20]; |
209 | ||
210 | sums(0,0) = fSum[21]; sums(0,1) = fSum[22]; sums(0,2) = fSum[23]; | |
211 | sums(0,3) = fSum[24]; sums(0,4) = fSum[25]; sums(0,5) = fSum[26]; | |
46ae650f | 212 | |
213 | smatrix.Invert(); | |
214 | if (!smatrix.IsValid()) return kFALSE; | |
215 | ||
216 | TMatrixD res = sums*smatrix; | |
217 | fAlignObj->SetPars(res(0,0),res(0,1),res(0,2), | |
218 | TMath::RadToDeg()*res(0,3), | |
219 | TMath::RadToDeg()*res(0,4), | |
220 | TMath::RadToDeg()*res(0,5)); | |
221 | TMatrixD tmp = res*sums.T(); | |
222 | fChi2 = fSumR - tmp(0,0); | |
223 | fNdf -= 6; | |
224 | ||
225 | return kTRUE; | |
226 | } |