]>
Commit | Line | Data |
---|---|---|
98937d93 | 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 | ||
339fbe23 | 16 | /************************************************************************* |
17 | * AliTrackFitter: base class for the fast track fitters * | |
18 | * * | |
19 | * Supposed to be used for alignment framework * | |
20 | * More information is available in | |
21 | * http://agenda.cern.ch/askArchive.php?base=agenda&categ=a057717&id=a057717s1t6/transparencies | |
22 | * Author: C.Cheskov * | |
23 | * * | |
24 | * * | |
25 | *************************************************************************/ | |
98937d93 | 26 | |
27 | #include <TMatrixDSym.h> | |
cc345ce3 | 28 | #include <TArrayI.h> |
98937d93 | 29 | |
30 | #include "AliTrackFitter.h" | |
31 | #include "AliTrackPointArray.h" | |
33bebad6 | 32 | #include "AliLog.h" |
98937d93 | 33 | |
34 | ClassImp(AliTrackFitter) | |
35 | ||
36 | //_____________________________________________________________________________ | |
75e3794b | 37 | AliTrackFitter::AliTrackFitter() : |
38 | TObject(), | |
39 | fCov(0), | |
40 | fPoints(0), | |
41 | fPVolId(0), | |
42 | fPTrack(0), | |
43 | fChi2(0), | |
44 | fNdf(0), | |
45 | fMinNPoints(0), | |
46 | fIsOwner(kFALSE) | |
98937d93 | 47 | { |
48 | // default constructor | |
49 | // | |
50 | for (Int_t i=0;i<6;i++) fParams[i] = 0; | |
98937d93 | 51 | } |
52 | ||
53 | //_____________________________________________________________________________ | |
75e3794b | 54 | AliTrackFitter::AliTrackFitter(AliTrackPointArray *array, Bool_t owner) : |
55 | TObject(), | |
56 | fCov(new TMatrixDSym(6)), | |
57 | fPoints(0), | |
58 | fPVolId(0), | |
59 | fPTrack(0), | |
60 | fChi2(0), | |
61 | fNdf(0), | |
62 | fMinNPoints(0), | |
63 | fIsOwner(kFALSE) | |
64 | ||
98937d93 | 65 | { |
66 | // constructor from space points array | |
67 | // | |
68 | for (Int_t i=0;i<6;i++) fParams[i] = 0; | |
98937d93 | 69 | SetTrackPointArray(array,owner); |
70 | } | |
71 | ||
72 | //_____________________________________________________________________________ | |
73 | AliTrackFitter::AliTrackFitter(const AliTrackFitter &fitter): | |
75e3794b | 74 | TObject(fitter), |
75 | fCov(new TMatrixDSym(*fitter.fCov)), | |
76 | fPoints(0), | |
77 | fPVolId(0), | |
78 | fPTrack(0), | |
79 | fChi2(fitter.fChi2), | |
80 | fNdf(fitter.fNdf), | |
81 | fMinNPoints(fitter.fMinNPoints), | |
82 | fIsOwner(kFALSE) | |
98937d93 | 83 | { |
84 | // Copy constructor | |
85 | // | |
46ae650f | 86 | SetTrackPointArray(fitter.fPoints,fitter.fIsOwner); |
98937d93 | 87 | for (Int_t i=0;i<6;i++) fParams[i] = fitter.fParams[i]; |
98937d93 | 88 | } |
89 | ||
90 | //_____________________________________________________________________________ | |
91 | AliTrackFitter &AliTrackFitter::operator =(const AliTrackFitter& fitter) | |
92 | { | |
93 | // assignment operator | |
94 | // | |
95 | if(this==&fitter) return *this; | |
96 | ||
46ae650f | 97 | SetTrackPointArray(fitter.fPoints); |
98937d93 | 98 | for (Int_t i=0;i<6;i++) fParams[i] = fitter.fParams[i]; |
99 | fCov = new TMatrixDSym(*fitter.fCov); | |
46ae650f | 100 | fChi2 = fitter.fChi2; |
101 | fNdf = fitter.fNdf; | |
cc345ce3 | 102 | fMinNPoints = fitter.fMinNPoints; |
98937d93 | 103 | fIsOwner = kFALSE; |
98937d93 | 104 | |
105 | return *this; | |
106 | } | |
107 | ||
108 | //_____________________________________________________________________________ | |
109 | AliTrackFitter::~AliTrackFitter() | |
110 | { | |
111 | if (fIsOwner) | |
112 | delete fPoints; | |
113 | delete fCov; | |
114 | } | |
115 | ||
116 | //_____________________________________________________________________________ | |
117 | void AliTrackFitter::Reset() | |
118 | { | |
119 | for (Int_t i=0;i<6;i++) fParams[i] = 0; | |
120 | delete fCov; | |
121 | fCov = new TMatrixDSym(6); | |
46ae650f | 122 | fPVolId = fPTrack = 0; |
123 | fChi2 = 0; | |
124 | fNdf = 0; | |
98937d93 | 125 | } |
126 | ||
127 | void AliTrackFitter::SetTrackPointArray(AliTrackPointArray *array, Bool_t owner) | |
128 | { | |
129 | // Load space points from array | |
130 | // By default we don't copy them but | |
131 | // just put the pointers to them | |
33bebad6 | 132 | if (!array) { |
133 | AliWarning("Invalid pointer to the space-points array !"); | |
134 | if (fIsOwner) delete fPoints; | |
135 | fPoints = NULL; | |
136 | return; | |
137 | } | |
7b1ba5da | 138 | |
98937d93 | 139 | Reset(); |
140 | ||
141 | if (fIsOwner) delete fPoints; | |
142 | ||
143 | if (owner) { | |
144 | fPoints = new AliTrackPointArray(*array); | |
145 | fIsOwner = kTRUE; | |
146 | } | |
147 | else { | |
148 | fPoints = array; | |
149 | fIsOwner = kFALSE; | |
150 | } | |
151 | } | |
cc345ce3 | 152 | |
153 | Bool_t AliTrackFitter::FindVolId(const TArrayI *array, UShort_t volid) const | |
154 | { | |
155 | // The method is used to check whenever | |
156 | // the volume id (volid) is contained in | |
157 | // a array of integers | |
158 | Int_t nVolIds = array->GetSize(); | |
159 | if (nVolIds == 0) return kFALSE; | |
160 | ||
161 | Bool_t found = kFALSE; | |
162 | for (Int_t iVolId = 0; iVolId < nVolIds; iVolId++) { | |
163 | if ((*array)[iVolId] == volid) { | |
164 | found = kTRUE; | |
165 | break; | |
166 | } | |
167 | } | |
168 | ||
169 | return found; | |
170 | } | |
9c4c8863 | 171 | |
172 | Bool_t AliTrackFitter::Fit(const TArrayI *volIds,const TArrayI *volIdsFit, | |
25be1e5c | 173 | AliGeomManager::ELayerID layerRangeMin, |
174 | AliGeomManager::ELayerID layerRangeMax) | |
9c4c8863 | 175 | { |
176 | //------------------------------------------------------------------- | |
177 | // | |
178 | // Fit the track points. | |
179 | // | |
180 | // volIds - the array of IDs of volumes where the residuals | |
181 | // will be calculated. | |
182 | // volIdsFit - the array of IDs of volumes having the points | |
183 | // that will be fitted | |
184 | // | |
185 | // If volIdsFit==0, the IDs of volumes having the points to fit | |
186 | // are taken in the range defined by the two last parameters | |
187 | // | |
188 | // | |
189 | // The function fills two track-point arrays: fPVolId and fPTrack. | |
190 | // The first one contains the track points from the volumes with IDs | |
191 | // taken from the "volIds". The second array is filled with | |
192 | // the intersection points between the fitted track and the volumes | |
193 | // the points from the first arry belong to. | |
194 | // | |
195 | // The two arrays are used for calculation of the residuals | |
196 | // and for the construction of a chi2 function to be minimized | |
197 | // in the alignment procedures. | |
198 | // | |
199 | //-------------------------------------------------------------------- | |
200 | ||
201 | Int_t npoints=fPoints->GetNPoints(); | |
202 | if (npoints<fMinNPoints) return kFALSE; | |
203 | ||
204 | // Fast counting the points | |
205 | Int_t countFit=0; | |
206 | Int_t countPnt=0; | |
57c8a1c2 | 207 | |
208 | Int_t fst=-1; | |
209 | Int_t lst=-1; | |
9c4c8863 | 210 | if (volIdsFit != 0x0) { |
211 | for (Int_t i=0; i<npoints; i++) { | |
212 | if (FindVolId(volIds, fPoints->GetVolumeID()[i])) countPnt++; | |
57c8a1c2 | 213 | if (FindVolId(volIdsFit,fPoints->GetVolumeID()[i])) { |
214 | countFit++; | |
215 | if (fst<0) fst=i; | |
216 | lst=i; | |
217 | } | |
9c4c8863 | 218 | } |
219 | } else { | |
220 | for (Int_t i=0; i<npoints; i++) { | |
221 | UShort_t id=fPoints->GetVolumeID()[i]; | |
222 | if (FindVolId(volIds,id)) countPnt++; | |
25be1e5c | 223 | if (id < AliGeomManager::LayerToVolUID(layerRangeMin,0)) continue; |
224 | if (id > AliGeomManager::LayerToVolUID(layerRangeMax, | |
225 | AliGeomManager::LayerSize(layerRangeMax))) continue; | |
9c4c8863 | 226 | countFit++; |
57c8a1c2 | 227 | if (fst<0) fst=i; |
228 | lst=i; | |
9c4c8863 | 229 | } |
230 | } | |
231 | if (countPnt==0) return kFALSE; | |
232 | if (countFit<fMinNPoints) return kFALSE; | |
233 | ||
234 | ||
235 | ||
236 | //************* Fit the selected track points | |
237 | ||
57c8a1c2 | 238 | if (!Begin(fst,lst)) return kFALSE; |
9c4c8863 | 239 | |
240 | AliTrackPoint p; | |
241 | if (volIdsFit != 0x0) { | |
242 | for (Int_t i=0; i<npoints; i++) { | |
243 | if (!FindVolId(volIdsFit,fPoints->GetVolumeID()[i])) continue; | |
244 | fPoints->GetPoint(p,i); | |
245 | if (!AddPoint(&p)) return kFALSE; | |
246 | } | |
247 | } else { | |
248 | for (Int_t i=0; i<npoints; i++) { | |
249 | UShort_t id=fPoints->GetVolumeID()[i]; | |
25be1e5c | 250 | if (id < AliGeomManager::LayerToVolUID(layerRangeMin,0)) continue; |
251 | if (id > AliGeomManager::LayerToVolUID(layerRangeMax, | |
252 | AliGeomManager::LayerSize(layerRangeMax))) continue; | |
9c4c8863 | 253 | fPoints->GetPoint(p,i); |
254 | if (!AddPoint(&p)) continue; | |
255 | } | |
256 | } | |
257 | ||
258 | if (!Update()) return kFALSE; | |
259 | ||
260 | ||
261 | ||
262 | ||
263 | //************* Calculate the intersection points | |
264 | ||
265 | fPVolId = new AliTrackPointArray(countPnt); | |
266 | fPTrack = new AliTrackPointArray(countPnt); | |
267 | ||
268 | Int_t n=0; | |
269 | AliTrackPoint p2; | |
270 | for (Int_t i=0; i<npoints; i++) { | |
271 | if (!FindVolId(volIds,fPoints->GetVolumeID()[i])) continue; | |
272 | fPoints->GetPoint(p,i); | |
273 | if (GetPCA(p,p2)) { | |
274 | fPVolId->AddPoint(n,&p); | |
275 | fPTrack->AddPoint(n,&p2); | |
276 | n++; | |
277 | } else { | |
278 | delete fPVolId; | |
279 | fPVolId=0; | |
280 | delete fPTrack; | |
281 | fPTrack=0; | |
282 | return kFALSE; | |
283 | } | |
284 | } | |
285 | ||
286 | return kTRUE; | |
287 | } |