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):
59 fVolArray = new AliTrackPointArray*[ntracks];
60 fTrackArray = new AliTrackPointArray*[ntracks];
61 for (Int_t itrack = 0; itrack < ntracks; itrack++)
62 fVolArray[itrack] = fTrackArray[itrack] = 0x0;
66 //_____________________________________________________________________________
67 AliTrackResiduals::AliTrackResiduals(const AliTrackResiduals &res):
76 fMinNPoints(res.fMinNPoints),
80 // By default the created copy owns the track point arrays
82 fAlignObj = (AliAlignObj *)res.fAlignObj->Clone();
85 fVolArray = new AliTrackPointArray*[fN];
86 fTrackArray = new AliTrackPointArray*[fN];
87 for (Int_t itrack = 0; itrack < fN; itrack++)
89 if (res.fVolArray[itrack])
90 fVolArray[itrack] = new AliTrackPointArray(*res.fVolArray[itrack]);
93 if (res.fTrackArray[itrack])
94 fTrackArray[itrack] = new AliTrackPointArray(*res.fTrackArray[itrack]);
101 //_____________________________________________________________________________
102 AliTrackResiduals &AliTrackResiduals::operator =(const AliTrackResiduals& res)
104 // assignment operator
105 // Does not copy the track point arrays
106 if(this==&res) return *this;
107 ((TObject *)this)->operator=(res);
113 fMinNPoints = res.fMinNPoints;
115 fAlignObj = res.fAlignObj;
117 fVolArray = res.fVolArray;
118 fTrackArray = res.fTrackArray;
123 //_____________________________________________________________________________
124 AliTrackResiduals::~AliTrackResiduals()
127 if (fAlignObj) delete fAlignObj;
128 DeleteTrackPointArrays();
131 //_____________________________________________________________________________
132 void AliTrackResiduals::SetNTracks(Int_t ntracks)
134 // Set new size for the track point arrays.
135 // Delete the old arrays and allocate the
137 DeleteTrackPointArrays();
146 fVolArray = new AliTrackPointArray*[ntracks];
147 fTrackArray = new AliTrackPointArray*[ntracks];
148 for (Int_t itrack = 0; itrack < ntracks; itrack++)
149 fVolArray[itrack] = fTrackArray[itrack] = 0x0;
153 //_____________________________________________________________________________
154 Bool_t AliTrackResiduals::AddTrackPointArrays(AliTrackPointArray *volarray, AliTrackPointArray *trackarray)
156 // Adds pair of track space point and
157 // track extrapolation point arrays
158 if (!fVolArray || !fTrackArray) return kFALSE;
160 if (!volarray || !trackarray) return kFALSE;
162 if (volarray->GetNPoints() < fMinNPoints) return kFALSE;
164 if (fLast >= fN) return kFALSE;
166 fVolArray[fLast] = volarray;
167 fTrackArray[fLast] = trackarray;
173 //_____________________________________________________________________________
174 void AliTrackResiduals::InitAlignObj()
176 // Create the alignment object
178 if (fAlignObj) delete fAlignObj;
179 fAlignObj = new AliAlignObjAngles;
183 //_____________________________________________________________________________
184 Bool_t AliTrackResiduals::GetTrackPointArrays(Int_t i, AliTrackPointArray* &volarray, AliTrackPointArray* &trackarray) const
186 // Provide an access to a pair of track point arrays
189 volarray = trackarray = 0x0;
193 volarray = fVolArray[i];
194 trackarray = fTrackArray[i];
199 //_____________________________________________________________________________
200 void AliTrackResiduals::DeleteTrackPointArrays()
202 // Deletes the track point arrays only in case
203 // the object is their owner.
204 // Called by the destructor and SetNTracks methods.
206 for (Int_t itrack = 0; itrack < fLast; itrack++)
208 delete fVolArray[itrack];
209 delete fTrackArray[itrack];
212 delete [] fTrackArray;