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 "AliAlignObjAngles.h"
26 #include "AliTrackPointArray.h"
28 ClassImp(AliTrackResiduals)
30 //_____________________________________________________________________________
31 AliTrackResiduals::AliTrackResiduals():
42 // Default constructor
45 //_____________________________________________________________________________
46 AliTrackResiduals::AliTrackResiduals(Int_t ntracks):
57 fVolArray = new AliTrackPointArray*[ntracks];
58 fTrackArray = new AliTrackPointArray*[ntracks];
59 for (Int_t itrack = 0; itrack < ntracks; itrack++)
60 fVolArray[itrack] = fTrackArray[itrack] = 0x0;
64 //_____________________________________________________________________________
65 AliTrackResiduals::AliTrackResiduals(const AliTrackResiduals &res):
71 fMinNPoints(res.fMinNPoints),
75 // By default the created copy owns the track point arrays
77 fAlignObj = (AliAlignObj *)res.fAlignObj->Clone();
80 fVolArray = new AliTrackPointArray*[fN];
81 fTrackArray = new AliTrackPointArray*[fN];
82 for (Int_t itrack = 0; itrack < fN; itrack++)
84 if (res.fVolArray[itrack])
85 fVolArray[itrack] = new AliTrackPointArray(*res.fVolArray[itrack]);
88 if (res.fTrackArray[itrack])
89 fTrackArray[itrack] = new AliTrackPointArray(*res.fTrackArray[itrack]);
96 //_____________________________________________________________________________
97 AliTrackResiduals &AliTrackResiduals::operator =(const AliTrackResiduals& res)
99 // assignment operator
100 // Does not copy the track point arrays
101 if(this==&res) return *this;
102 ((TObject *)this)->operator=(res);
108 fMinNPoints = res.fMinNPoints;
110 fAlignObj = res.fAlignObj;
112 fVolArray = res.fVolArray;
113 fTrackArray = res.fTrackArray;
118 //_____________________________________________________________________________
119 AliTrackResiduals::~AliTrackResiduals()
122 if (fAlignObj) delete fAlignObj;
123 DeleteTrackPointArrays();
126 //_____________________________________________________________________________
127 void AliTrackResiduals::SetNTracks(Int_t ntracks)
129 // Set new size for the track point arrays.
130 // Delete the old arrays and allocate the
132 DeleteTrackPointArrays();
141 fVolArray = new AliTrackPointArray*[ntracks];
142 fTrackArray = new AliTrackPointArray*[ntracks];
143 for (Int_t itrack = 0; itrack < ntracks; itrack++)
144 fVolArray[itrack] = fTrackArray[itrack] = 0x0;
148 //_____________________________________________________________________________
149 Bool_t AliTrackResiduals::AddTrackPointArrays(AliTrackPointArray *volarray, AliTrackPointArray *trackarray)
151 // Adds pair of track space point and
152 // track extrapolation point arrays
153 if (!fVolArray || !fTrackArray) return kFALSE;
155 if (!volarray || !trackarray) return kFALSE;
157 if (volarray->GetNPoints() < fMinNPoints) return kFALSE;
159 if (fLast >= fN) return kFALSE;
161 fVolArray[fLast] = volarray;
162 fTrackArray[fLast] = trackarray;
168 //_____________________________________________________________________________
169 void AliTrackResiduals::InitAlignObj()
171 // Create the alignment object
173 if (fAlignObj) delete fAlignObj;
174 fAlignObj = new AliAlignObjAngles;
178 //_____________________________________________________________________________
179 Bool_t AliTrackResiduals::GetTrackPointArrays(Int_t i, AliTrackPointArray* &volarray, AliTrackPointArray* &trackarray) const
181 // Provide an access to a pair of track point arrays
184 volarray = trackarray = 0x0;
188 volarray = fVolArray[i];
189 trackarray = fTrackArray[i];
194 //_____________________________________________________________________________
195 void AliTrackResiduals::DeleteTrackPointArrays()
197 // Deletes the track point arrays only in case
198 // the object is their owner.
199 // Called by the destructor and SetNTracks methods.
201 for (Int_t itrack = 0; itrack < fLast; itrack++)
203 delete fVolArray[itrack];
204 delete fTrackArray[itrack];
207 delete [] fTrackArray;