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