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):
81 fVolArray(new AliTrackPointArray*[fN]),
82 fTrackArray(new AliTrackPointArray*[fN]),
85 fMinNPoints(res.fMinNPoints),
89 // By default the created copy owns the track point arrays
91 if(res.fAlignObj) fAlignObj = (AliAlignObj *)res.fAlignObj->Clone();
93 memset(fVolArray,0,sizeof(AliTrackPointArray*)*fN);
94 memset(fTrackArray,0,sizeof(AliTrackPointArray*)*fN);
96 for (Int_t itrack = 0; itrack < fN; itrack++)
98 if (res.fVolArray[itrack])
99 fVolArray[itrack] = new AliTrackPointArray(*res.fVolArray[itrack]);
100 if (res.fTrackArray[itrack])
101 fTrackArray[itrack] = new AliTrackPointArray(*res.fTrackArray[itrack]);
106 //_____________________________________________________________________________
107 AliTrackResiduals &AliTrackResiduals::operator =(const AliTrackResiduals& res)
109 // assignment operator
110 // Does not copy the track point arrays
112 TObject::operator=(res);
116 fAlignObj = res.fAlignObj;
117 fVolArray = res.fVolArray;
118 fTrackArray = res.fTrackArray;
121 fMinNPoints = res.fMinNPoints;
124 memcpy(fBFixed,res.fBFixed,sizeof(Float_t)*6);
125 memcpy(fFixed,res.fFixed,sizeof(Float_t)*6);
130 //_____________________________________________________________________________
131 AliTrackResiduals::~AliTrackResiduals()
134 if (fAlignObj) delete fAlignObj;
135 DeleteTrackPointArrays();
138 //_____________________________________________________________________________
139 void AliTrackResiduals::SetNTracks(Int_t ntracks)
141 // Set new size for the track point arrays.
142 // Delete the old arrays and allocate the
144 DeleteTrackPointArrays();
153 fVolArray = new AliTrackPointArray*[ntracks];
154 fTrackArray = new AliTrackPointArray*[ntracks];
155 for (Int_t itrack = 0; itrack < ntracks; itrack++)
156 fVolArray[itrack] = fTrackArray[itrack] = 0x0;
159 fVolArray = fTrackArray = 0x0;
163 //_____________________________________________________________________________
164 Bool_t AliTrackResiduals::AddTrackPointArrays(AliTrackPointArray *volarray, AliTrackPointArray *trackarray)
166 // Adds pair of track space point and
167 // track extrapolation point arrays
168 if (!fVolArray || !fTrackArray) return kFALSE;
170 if (!volarray || !trackarray) return kFALSE;
172 if (volarray->GetNPoints() < fMinNPoints) return kFALSE;
174 if (fLast >= fN) return kFALSE;
176 fVolArray[fLast] = volarray;
177 fTrackArray[fLast] = trackarray;
183 //_____________________________________________________________________________
184 void AliTrackResiduals::InitAlignObj()
186 // Create the alignment object
188 if (fAlignObj) delete fAlignObj;
189 fAlignObj = new AliAlignObjParams;
193 //_____________________________________________________________________________
194 Bool_t AliTrackResiduals::GetTrackPointArrays(Int_t i, AliTrackPointArray* &volarray, AliTrackPointArray* &trackarray) const
196 // Provide an access to a pair of track point arrays
199 volarray = trackarray = 0x0;
203 volarray = fVolArray[i];
204 trackarray = fTrackArray[i];
209 //_____________________________________________________________________________
210 void AliTrackResiduals::DeleteTrackPointArrays()
212 // Deletes the track point arrays only in case
213 // the object is their owner.
214 // Called by the destructor and SetNTracks methods.
217 for (Int_t itrack = 0; itrack < fN; itrack++) {
218 if (fVolArray[itrack]) delete fVolArray[itrack];
223 for (Int_t itrack = 0; itrack < fN; itrack++) {
224 if (fTrackArray[itrack]) delete fTrackArray[itrack];
226 delete [] fTrackArray;
231 //_____________________________________________________
232 Int_t AliTrackResiduals::GetNFreeParam(){
233 Int_t unfixedparam=6;
234 for(Int_t j=0;j<6;j++){
235 if(fBFixed[j]==kTRUE)unfixedparam--;