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 track residuals
20 //-----------------------------------------------------------------
22 #include "AliTrackResiduals.h"
24 #include "AliAlignObj.h"
25 #include "AliAlignObjParams.h"
26 #include "AliTrackPointArray.h"
28 ClassImp(AliTrackResiduals)
30 //_____________________________________________________________________________
31 AliTrackResiduals::AliTrackResiduals():
42 // Default constructor
43 for (Int_t ipar=0; ipar<6; ipar++){
44 fBFixed[ipar] = kFALSE;
49 //_____________________________________________________________________________
50 AliTrackResiduals::AliTrackResiduals(Int_t ntracks):
63 fVolArray = new AliTrackPointArray*[ntracks];
64 fTrackArray = new AliTrackPointArray*[ntracks];
65 for (Int_t itrack = 0; itrack < ntracks; itrack++)
66 fVolArray[itrack] = fTrackArray[itrack] = 0x0;
69 for (Int_t ipar=0; ipar<6; ipar++){
70 fBFixed[ipar] = kFALSE;
75 //_____________________________________________________________________________
76 AliTrackResiduals::AliTrackResiduals(const AliTrackResiduals &res):
85 fMinNPoints(res.fMinNPoints),
89 // By default the created copy owns the track point arrays
91 fAlignObj = (AliAlignObj *)res.fAlignObj->Clone();
94 fVolArray = new AliTrackPointArray*[fN];
95 fTrackArray = new AliTrackPointArray*[fN];
96 for (Int_t itrack = 0; itrack < fN; itrack++)
98 if (res.fVolArray[itrack])
99 fVolArray[itrack] = new AliTrackPointArray(*res.fVolArray[itrack]);
102 if (res.fTrackArray[itrack])
103 fTrackArray[itrack] = new AliTrackPointArray(*res.fTrackArray[itrack]);
108 for(Int_t i=0;i<6;i++) {
109 fBFixed[i]=res.fBFixed[i];
110 fFixed[i]=res.fFixed[i];
114 //_____________________________________________________________________________
115 AliTrackResiduals &AliTrackResiduals::operator =(const AliTrackResiduals& res)
117 // assignment operator
118 // Does not copy the track point arrays
119 if(this==&res) return *this;
120 ((TObject *)this)->operator=(res);
126 fMinNPoints = res.fMinNPoints;
128 fAlignObj = res.fAlignObj;
130 fVolArray = res.fVolArray;
131 fTrackArray = res.fTrackArray;
133 for(Int_t i=0;i<6;i++) {
134 fBFixed[i]=res.fBFixed[i];
135 fFixed[i]=res.fFixed[i];
141 //_____________________________________________________________________________
142 AliTrackResiduals::~AliTrackResiduals()
145 if (fAlignObj) delete fAlignObj;
146 DeleteTrackPointArrays();
149 //_____________________________________________________________________________
150 void AliTrackResiduals::SetNTracks(Int_t ntracks)
152 // Set new size for the track point arrays.
153 // Delete the old arrays and allocate the
155 DeleteTrackPointArrays();
164 fVolArray = new AliTrackPointArray*[ntracks];
165 fTrackArray = new AliTrackPointArray*[ntracks];
166 for (Int_t itrack = 0; itrack < ntracks; itrack++)
167 fVolArray[itrack] = fTrackArray[itrack] = 0x0;
170 fVolArray = fTrackArray = 0x0;
174 //_____________________________________________________________________________
175 Bool_t AliTrackResiduals::AddTrackPointArrays(AliTrackPointArray *volarray, AliTrackPointArray *trackarray)
177 // Adds pair of track space point and
178 // track extrapolation point arrays
179 if (!fVolArray || !fTrackArray) return kFALSE;
181 if (!volarray || !trackarray) return kFALSE;
183 if (volarray->GetNPoints() < fMinNPoints) return kFALSE;
185 if (fLast >= fN) return kFALSE;
187 fVolArray[fLast] = volarray;
188 fTrackArray[fLast] = trackarray;
194 //_____________________________________________________________________________
195 void AliTrackResiduals::InitAlignObj()
197 // Create the alignment object
199 if (fAlignObj) delete fAlignObj;
200 fAlignObj = new AliAlignObjParams;
204 //_____________________________________________________________________________
205 Bool_t AliTrackResiduals::GetTrackPointArrays(Int_t i, AliTrackPointArray* &volarray, AliTrackPointArray* &trackarray) const
207 // Provide an access to a pair of track point arrays
210 volarray = trackarray = 0x0;
214 volarray = fVolArray[i];
215 trackarray = fTrackArray[i];
220 //_____________________________________________________________________________
221 void AliTrackResiduals::DeleteTrackPointArrays()
223 // Deletes the track point arrays only in case
224 // the object is their owner.
225 // Called by the destructor and SetNTracks methods.
228 for (Int_t itrack = 0; itrack < fN; itrack++) {
229 if (fVolArray[itrack]) delete fVolArray[itrack];
234 for (Int_t itrack = 0; itrack < fN; itrack++) {
235 if (fTrackArray[itrack]) delete fTrackArray[itrack];
237 delete [] fTrackArray;
242 //_____________________________________________________
243 const Int_t AliTrackResiduals::GetNFreeParam(){
244 Int_t unfixedparam=6;
245 for(Int_t j=0;j<6;j++){
246 if(fBFixed[j]==kTRUE)unfixedparam--;