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 // Implementation of the base class for fast track fitters
20 //-----------------------------------------------------------------
22 #include <TMatrixDSym.h>
25 #include "AliTrackFitter.h"
26 #include "AliTrackPointArray.h"
29 ClassImp(AliTrackFitter)
31 //_____________________________________________________________________________
32 AliTrackFitter::AliTrackFitter() :
43 // default constructor
45 for (Int_t i=0;i<6;i++) fParams[i] = 0;
48 //_____________________________________________________________________________
49 AliTrackFitter::AliTrackFitter(AliTrackPointArray *array, Bool_t owner) :
51 fCov(new TMatrixDSym(6)),
61 // constructor from space points array
63 for (Int_t i=0;i<6;i++) fParams[i] = 0;
64 SetTrackPointArray(array,owner);
67 //_____________________________________________________________________________
68 AliTrackFitter::AliTrackFitter(const AliTrackFitter &fitter):
70 fCov(new TMatrixDSym(*fitter.fCov)),
76 fMinNPoints(fitter.fMinNPoints),
81 SetTrackPointArray(fitter.fPoints,fitter.fIsOwner);
82 for (Int_t i=0;i<6;i++) fParams[i] = fitter.fParams[i];
85 //_____________________________________________________________________________
86 AliTrackFitter &AliTrackFitter::operator =(const AliTrackFitter& fitter)
88 // assignment operator
90 if(this==&fitter) return *this;
92 SetTrackPointArray(fitter.fPoints);
93 for (Int_t i=0;i<6;i++) fParams[i] = fitter.fParams[i];
94 fCov = new TMatrixDSym(*fitter.fCov);
97 fMinNPoints = fitter.fMinNPoints;
103 //_____________________________________________________________________________
104 AliTrackFitter::~AliTrackFitter()
111 //_____________________________________________________________________________
112 void AliTrackFitter::Reset()
114 for (Int_t i=0;i<6;i++) fParams[i] = 0;
116 fCov = new TMatrixDSym(6);
117 fPVolId = fPTrack = 0;
122 void AliTrackFitter::SetTrackPointArray(AliTrackPointArray *array, Bool_t owner)
124 // Load space points from array
125 // By default we don't copy them but
126 // just put the pointers to them
128 AliWarning("Invalid pointer to the space-points array !");
129 if (fIsOwner) delete fPoints;
136 if (fIsOwner) delete fPoints;
139 fPoints = new AliTrackPointArray(*array);
148 Bool_t AliTrackFitter::FindVolId(const TArrayI *array, UShort_t volid) const
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;
156 Bool_t found = kFALSE;
157 for (Int_t iVolId = 0; iVolId < nVolIds; iVolId++) {
158 if ((*array)[iVolId] == volid) {
167 Bool_t AliTrackFitter::Fit(const TArrayI *volIds,const TArrayI *volIdsFit,
168 AliAlignObj::ELayerID layerRangeMin,
169 AliAlignObj::ELayerID layerRangeMax)
171 //-------------------------------------------------------------------
173 // Fit the track points.
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
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
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.
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.
194 //--------------------------------------------------------------------
196 Int_t npoints=fPoints->GetNPoints();
197 if (npoints<fMinNPoints) return kFALSE;
199 // Fast counting the points
202 if (volIdsFit != 0x0) {
203 for (Int_t i=0; i<npoints; i++) {
204 if (FindVolId(volIds, fPoints->GetVolumeID()[i])) countPnt++;
205 if (FindVolId(volIdsFit,fPoints->GetVolumeID()[i])) countFit++;
208 for (Int_t i=0; i<npoints; i++) {
209 UShort_t id=fPoints->GetVolumeID()[i];
210 if (FindVolId(volIds,id)) countPnt++;
211 if (id < AliAlignObj::LayerToVolUID(layerRangeMin,0)) continue;
212 if (id > AliAlignObj::LayerToVolUID(layerRangeMax,
213 AliAlignObj::LayerSize(layerRangeMax))) continue;
217 if (countPnt==0) return kFALSE;
218 if (countFit<fMinNPoints) return kFALSE;
222 //************* Fit the selected track points
227 if (volIdsFit != 0x0) {
228 for (Int_t i=0; i<npoints; i++) {
229 if (!FindVolId(volIdsFit,fPoints->GetVolumeID()[i])) continue;
230 fPoints->GetPoint(p,i);
231 if (!AddPoint(&p)) return kFALSE;
234 for (Int_t i=0; i<npoints; i++) {
235 UShort_t id=fPoints->GetVolumeID()[i];
236 if (id < AliAlignObj::LayerToVolUID(layerRangeMin,0)) continue;
237 if (id > AliAlignObj::LayerToVolUID(layerRangeMax,
238 AliAlignObj::LayerSize(layerRangeMax))) continue;
239 fPoints->GetPoint(p,i);
240 if (!AddPoint(&p)) continue;
244 if (!Update()) return kFALSE;
249 //************* Calculate the intersection points
251 fPVolId = new AliTrackPointArray(countPnt);
252 fPTrack = new AliTrackPointArray(countPnt);
256 for (Int_t i=0; i<npoints; i++) {
257 if (!FindVolId(volIds,fPoints->GetVolumeID()[i])) continue;
258 fPoints->GetPoint(p,i);
260 fPVolId->AddPoint(n,&p);
261 fPTrack->AddPoint(n,&p2);