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 **************************************************************************/
16 /*************************************************************************
17 * AliTrackFitter: base class for the fast track fitters *
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
25 *************************************************************************/
27 #include <TMatrixDSym.h>
30 #include "AliTrackFitter.h"
31 #include "AliTrackPointArray.h"
34 ClassImp(AliTrackFitter)
36 //_____________________________________________________________________________
37 AliTrackFitter::AliTrackFitter() :
48 // default constructor
50 for (Int_t i=0;i<6;i++) fParams[i] = 0;
53 //_____________________________________________________________________________
54 AliTrackFitter::AliTrackFitter(AliTrackPointArray *array, Bool_t owner) :
56 fCov(new TMatrixDSym(6)),
66 // constructor from space points array
68 for (Int_t i=0;i<6;i++) fParams[i] = 0;
69 SetTrackPointArray(array,owner);
72 //_____________________________________________________________________________
73 AliTrackFitter::AliTrackFitter(const AliTrackFitter &fitter):
75 fCov(new TMatrixDSym(*fitter.fCov)),
81 fMinNPoints(fitter.fMinNPoints),
86 SetTrackPointArray(fitter.fPoints,fitter.fIsOwner);
87 for (Int_t i=0;i<6;i++) fParams[i] = fitter.fParams[i];
90 //_____________________________________________________________________________
91 AliTrackFitter &AliTrackFitter::operator =(const AliTrackFitter& fitter)
93 // assignment operator
95 if(this==&fitter) return *this;
97 SetTrackPointArray(fitter.fPoints);
98 for (Int_t i=0;i<6;i++) fParams[i] = fitter.fParams[i];
99 fCov = new TMatrixDSym(*fitter.fCov);
100 fChi2 = fitter.fChi2;
102 fMinNPoints = fitter.fMinNPoints;
108 //_____________________________________________________________________________
109 AliTrackFitter::~AliTrackFitter()
116 //_____________________________________________________________________________
117 void AliTrackFitter::Reset()
119 for (Int_t i=0;i<6;i++) fParams[i] = 0;
121 fCov = new TMatrixDSym(6);
122 fPVolId = fPTrack = 0;
127 void AliTrackFitter::SetTrackPointArray(AliTrackPointArray *array, Bool_t owner)
129 // Load space points from array
130 // By default we don't copy them but
131 // just put the pointers to them
133 AliWarning("Invalid pointer to the space-points array !");
134 if (fIsOwner) delete fPoints;
141 if (fIsOwner) delete fPoints;
144 fPoints = new AliTrackPointArray(*array);
153 Bool_t AliTrackFitter::FindVolId(const TArrayI *array, UShort_t volid) const
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;
161 Bool_t found = kFALSE;
162 for (Int_t iVolId = 0; iVolId < nVolIds; iVolId++) {
163 if ((*array)[iVolId] == volid) {
172 Bool_t AliTrackFitter::Fit(const TArrayI *volIds,const TArrayI *volIdsFit,
173 AliGeomManager::ELayerID layerRangeMin,
174 AliGeomManager::ELayerID layerRangeMax)
176 //-------------------------------------------------------------------
178 // Fit the track points.
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
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
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.
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.
199 //--------------------------------------------------------------------
201 Int_t npoints=fPoints->GetNPoints();
202 if (npoints<fMinNPoints) return kFALSE;
204 // Fast counting the points
210 if (volIdsFit != 0x0) {
211 for (Int_t i=0; i<npoints; i++) {
212 if (FindVolId(volIds, fPoints->GetVolumeID()[i])) countPnt++;
213 if (FindVolId(volIdsFit,fPoints->GetVolumeID()[i])) {
220 for (Int_t i=0; i<npoints; i++) {
221 UShort_t id=fPoints->GetVolumeID()[i];
222 if (FindVolId(volIds,id)) countPnt++;
223 if (id < AliGeomManager::LayerToVolUID(layerRangeMin,0)) continue;
224 if (id > AliGeomManager::LayerToVolUID(layerRangeMax,
225 AliGeomManager::LayerSize(layerRangeMax))) continue;
231 if (countPnt==0) return kFALSE;
232 if (countFit<fMinNPoints) return kFALSE;
236 //************* Fit the selected track points
238 if (!Begin(fst,lst)) return kFALSE;
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;
248 for (Int_t i=0; i<npoints; i++) {
249 UShort_t id=fPoints->GetVolumeID()[i];
250 if (id < AliGeomManager::LayerToVolUID(layerRangeMin,0)) continue;
251 if (id > AliGeomManager::LayerToVolUID(layerRangeMax,
252 AliGeomManager::LayerSize(layerRangeMax))) continue;
253 fPoints->GetPoint(p,i);
254 if (!AddPoint(&p)) continue;
258 if (!Update()) return kFALSE;
263 //************* Calculate the intersection points
265 fPVolId = new AliTrackPointArray(countPnt);
266 fPTrack = new AliTrackPointArray(countPnt);
270 for (Int_t i=0; i<npoints; i++) {
271 if (!FindVolId(volIds,fPoints->GetVolumeID()[i])) continue;
272 fPoints->GetPoint(p,i);
274 fPVolId->AddPoint(n,&p);
275 fPTrack->AddPoint(n,&p2);