]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliTrackFitter.cxx
New version of the alignment framework (for details see offline week 6-10 Mar 2006)
[u/mrichter/AliRoot.git] / STEER / AliTrackFitter.cxx
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>
23 #include <TArrayI.h>
24
25 #include "AliTrackFitter.h"
26 #include "AliTrackPointArray.h"
27
28 ClassImp(AliTrackFitter)
29
30 //_____________________________________________________________________________
31 AliTrackFitter::AliTrackFitter()
32 {
33   // default constructor
34   //
35   for (Int_t i=0;i<6;i++) fParams[i] = 0;
36   fCov = 0;
37   fPoints = 0;
38   fPVolId = fPTrack = 0;
39   fChi2 = 0;
40   fNdf = 0;
41   fMinNPoints = 0;
42   fIsOwner = kFALSE;
43 }
44
45 //_____________________________________________________________________________
46 AliTrackFitter::AliTrackFitter(AliTrackPointArray *array, Bool_t owner)
47 {
48   // constructor from space points array
49   //
50   for (Int_t i=0;i<6;i++) fParams[i] = 0;
51   fCov = new TMatrixDSym(6);
52   fPVolId = fPTrack = 0;
53   fChi2 = 0;
54   fNdf = 0;
55   fMinNPoints = 0;
56   fIsOwner = kFALSE;
57   SetTrackPointArray(array,owner);
58 }
59
60 //_____________________________________________________________________________
61 AliTrackFitter::AliTrackFitter(const AliTrackFitter &fitter):
62   TObject(fitter)
63 {
64   // Copy constructor
65   //
66   SetTrackPointArray(fitter.fPoints,fitter.fIsOwner);
67   for (Int_t i=0;i<6;i++) fParams[i] = fitter.fParams[i];
68   fCov = new TMatrixDSym(*fitter.fCov);
69   fChi2 = fitter.fChi2;
70   fNdf = fitter.fNdf;
71   fMinNPoints = fitter.fMinNPoints;
72   fIsOwner = kFALSE;
73 }
74
75 //_____________________________________________________________________________
76 AliTrackFitter &AliTrackFitter::operator =(const AliTrackFitter& fitter)
77 {
78   // assignment operator
79   //
80   if(this==&fitter) return *this;
81
82   SetTrackPointArray(fitter.fPoints);
83   for (Int_t i=0;i<6;i++) fParams[i] = fitter.fParams[i];
84   fCov = new TMatrixDSym(*fitter.fCov);
85   fChi2 = fitter.fChi2;
86   fNdf = fitter.fNdf;
87   fMinNPoints = fitter.fMinNPoints;
88   fIsOwner = kFALSE;
89   
90   return *this;
91 }
92
93 //_____________________________________________________________________________
94 AliTrackFitter::~AliTrackFitter()
95 {
96   if (fIsOwner)
97     delete fPoints;
98   delete fCov;
99 }
100
101 //_____________________________________________________________________________
102 void AliTrackFitter::Reset()
103 {
104   for (Int_t i=0;i<6;i++) fParams[i] = 0;
105   delete fCov;
106   fCov = new TMatrixDSym(6);
107   fPVolId = fPTrack = 0;
108   fChi2 = 0;
109   fNdf = 0;
110 }
111
112 void AliTrackFitter::SetTrackPointArray(AliTrackPointArray *array, Bool_t owner)
113 {
114   // Load space points from array
115   // By default we don't copy them but
116   // just put the pointers to them
117   Reset();
118
119   if (fIsOwner) delete fPoints;
120
121   if (owner) {
122     fPoints = new AliTrackPointArray(*array);
123     fIsOwner = kTRUE;
124   }
125   else {
126     fPoints = array;
127     fIsOwner = kFALSE;
128   }
129 }
130
131 Bool_t AliTrackFitter::FindVolId(const TArrayI *array, UShort_t volid) const
132 {
133   // The method is used to check whenever
134   // the volume id (volid) is contained in
135   // a array of integers
136   Int_t nVolIds = array->GetSize();
137   if (nVolIds == 0) return kFALSE;
138
139   Bool_t found = kFALSE;
140   for (Int_t iVolId = 0; iVolId < nVolIds; iVolId++) {
141     if ((*array)[iVolId] == volid) {
142       found = kTRUE;
143       break;
144     }
145   }
146
147   return found;
148 }