prevent running if CDB snapshot setting failed
[u/mrichter/AliRoot.git] / STEER / STEER / AliTrackResiduals.cxx
CommitLineData
98937d93 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 track residuals
18//
19//
20//-----------------------------------------------------------------
21
22#include "AliTrackResiduals.h"
23
24#include "AliAlignObj.h"
90dbf5fb 25#include "AliAlignObjParams.h"
98937d93 26#include "AliTrackPointArray.h"
27
28ClassImp(AliTrackResiduals)
29
30//_____________________________________________________________________________
31AliTrackResiduals::AliTrackResiduals():
32 fN(0),
33 fLast(0),
46ae650f 34 fAlignObj(0),
35 fVolArray(0),
36 fTrackArray(0),
37 fChi2(0),
38 fNdf(0),
cc345ce3 39 fMinNPoints(0),
98937d93 40 fIsOwner(kTRUE)
41{
42 // Default constructor
29317b68 43 for (Int_t ipar=0; ipar<6; ipar++){
44 fBFixed[ipar] = kFALSE;
45 fFixed[ipar] = 0.;
46 }
98937d93 47}
48
49//_____________________________________________________________________________
46ae650f 50AliTrackResiduals::AliTrackResiduals(Int_t ntracks):
98937d93 51 fN(ntracks),
52 fLast(0),
46ae650f 53 fAlignObj(0),
75e3794b 54 fVolArray(0),
55 fTrackArray(0),
46ae650f 56 fChi2(0),
57 fNdf(0),
cc345ce3 58 fMinNPoints(0),
98937d93 59 fIsOwner(kTRUE)
60{
61 // Constructor
62 if (ntracks > 0) {
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;
67 }
faf254af 68
29317b68 69 for (Int_t ipar=0; ipar<6; ipar++){
70 fBFixed[ipar] = kFALSE;
71 fFixed[ipar] = 0.;
72 }
98937d93 73}
74
75//_____________________________________________________________________________
76AliTrackResiduals::AliTrackResiduals(const AliTrackResiduals &res):
77 TObject(res),
78 fN(res.fN),
79 fLast(res.fLast),
75e3794b 80 fAlignObj(0),
4c234df8 81 fVolArray(new AliTrackPointArray*[fN]),
82 fTrackArray(new AliTrackPointArray*[fN]),
46ae650f 83 fChi2(res.fChi2),
84 fNdf(res.fNdf),
cc345ce3 85 fMinNPoints(res.fMinNPoints),
98937d93 86 fIsOwner(kTRUE)
87{
88 // Copy constructor
89 // By default the created copy owns the track point arrays
46ae650f 90
4c234df8 91 if(res.fAlignObj) fAlignObj = (AliAlignObj *)res.fAlignObj->Clone();
92
93 memset(fVolArray,0,sizeof(AliTrackPointArray*)*fN);
94 memset(fTrackArray,0,sizeof(AliTrackPointArray*)*fN);
95
047a2966 96 for (Int_t itrack = 0; itrack < fN; itrack++) {
97 if (res.fVolArray[itrack])
98 fVolArray[itrack] = new AliTrackPointArray(*res.fVolArray[itrack]);
99 if (res.fTrackArray[itrack])
100 fTrackArray[itrack] = new AliTrackPointArray(*res.fTrackArray[itrack]);
101 }
4c234df8 102
047a2966 103 memcpy(fBFixed,res.fBFixed,sizeof(Bool_t)*6);
104 memcpy(fFixed,res.fFixed,sizeof(Float_t)*6);
8f112cf8 105
98937d93 106}
107
108//_____________________________________________________________________________
109AliTrackResiduals &AliTrackResiduals::operator =(const AliTrackResiduals& res)
110{
111 // assignment operator
112 // Does not copy the track point arrays
17ef8526 113 if(this!=&res) {
114 TObject::operator=(res);
115
17ef8526 116 fLast = res.fLast;
047a2966 117 delete fAlignObj;
118 if(res.fAlignObj)
119 fAlignObj = (AliAlignObj *)res.fAlignObj->Clone();
120 else
121 fAlignObj = 0;
122
123 if (fIsOwner) {
124 if (fVolArray) {
125 for (Int_t itrack = 0; itrack < fN; itrack++)
126 delete fVolArray[itrack];
127 delete [] fVolArray;
128 fVolArray=0;
129 }
130 if(res.fN) {
131 fVolArray = new AliTrackPointArray*[res.fN];
132 memset(fVolArray,0,sizeof(AliTrackPointArray*)*res.fN);
133 for (Int_t itrack = 0; itrack < res.fN; itrack++)
134 if (res.fVolArray[itrack])
135 fVolArray[itrack] = new AliTrackPointArray(*res.fVolArray[itrack]);
136 }
137 if (fTrackArray) {
138 for (Int_t itrack = 0; itrack < fN; itrack++)
139 delete fTrackArray[itrack];
140 delete [] fTrackArray;
141 }
142 if(res.fN) {
143 fTrackArray = new AliTrackPointArray*[res.fN];
144 memset(fTrackArray,0,sizeof(AliTrackPointArray*)*res.fN);
145 for (Int_t itrack = 0; itrack < res.fN; itrack++)
146 if (res.fTrackArray[itrack])
147 fTrackArray[itrack] = new AliTrackPointArray(*res.fTrackArray[itrack]);
148 }
149 } else {
150 fVolArray = res.fVolArray;
151 fTrackArray = res.fTrackArray;
152 }
153 fN = res.fN;
17ef8526 154 fChi2 = res.fChi2;
155 fNdf = res.fNdf;
156 fMinNPoints = res.fMinNPoints;
157 fIsOwner = kFALSE;
25f774e7 158
b1613a6d 159 memcpy(fBFixed,res.fBFixed,sizeof(Bool_t)*6);
17ef8526 160 memcpy(fFixed,res.fFixed,sizeof(Float_t)*6);
29317b68 161 }
98937d93 162 return *this;
163}
164
165//_____________________________________________________________________________
166AliTrackResiduals::~AliTrackResiduals()
167{
168 // Destructor
047a2966 169 delete fAlignObj;
98937d93 170 DeleteTrackPointArrays();
171}
172
173//_____________________________________________________________________________
174void AliTrackResiduals::SetNTracks(Int_t ntracks)
175{
176 // Set new size for the track point arrays.
177 // Delete the old arrays and allocate the
178 // new ones.
179 DeleteTrackPointArrays();
180
181 fN = ntracks;
182 fLast = 0;
46ae650f 183 fChi2 = 0;
184 fNdf = 0;
98937d93 185 fIsOwner = kTRUE;
186
187 if (ntracks > 0) {
188 fVolArray = new AliTrackPointArray*[ntracks];
189 fTrackArray = new AliTrackPointArray*[ntracks];
190 for (Int_t itrack = 0; itrack < ntracks; itrack++)
191 fVolArray[itrack] = fTrackArray[itrack] = 0x0;
192 }
faf254af 193 else {
194 fVolArray = fTrackArray = 0x0;
195 }
98937d93 196}
197
198//_____________________________________________________________________________
199Bool_t AliTrackResiduals::AddTrackPointArrays(AliTrackPointArray *volarray, AliTrackPointArray *trackarray)
200{
201 // Adds pair of track space point and
202 // track extrapolation point arrays
203 if (!fVolArray || !fTrackArray) return kFALSE;
204
cc345ce3 205 if (!volarray || !trackarray) return kFALSE;
206
207 if (volarray->GetNPoints() < fMinNPoints) return kFALSE;
208
98937d93 209 if (fLast >= fN) return kFALSE;
210
211 fVolArray[fLast] = volarray;
212 fTrackArray[fLast] = trackarray;
213 fLast++;
214
215 return kTRUE;
216}
217
218//_____________________________________________________________________________
cc345ce3 219void AliTrackResiduals::InitAlignObj()
46ae650f 220{
cc345ce3 221 // Create the alignment object
222 // to be updated
047a2966 223 delete fAlignObj;
90dbf5fb 224 fAlignObj = new AliAlignObjParams;
46ae650f 225}
226
227
228//_____________________________________________________________________________
98937d93 229Bool_t AliTrackResiduals::GetTrackPointArrays(Int_t i, AliTrackPointArray* &volarray, AliTrackPointArray* &trackarray) const
230{
231 // Provide an access to a pair of track point arrays
232 // with given index
233 if (i >= fLast) {
234 volarray = trackarray = 0x0;
235 return kFALSE;
236 }
237 else {
238 volarray = fVolArray[i];
239 trackarray = fTrackArray[i];
240 return kTRUE;
241 }
242}
243
244//_____________________________________________________________________________
245void AliTrackResiduals::DeleteTrackPointArrays()
246{
247 // Deletes the track point arrays only in case
248 // the object is their owner.
249 // Called by the destructor and SetNTracks methods.
250 if (fIsOwner) {
faf254af 251 if (fVolArray) {
047a2966 252 for (Int_t itrack = 0; itrack < fN; itrack++)
253 delete fVolArray[itrack];
faf254af 254 delete [] fVolArray;
255 }
256 if (fTrackArray) {
047a2966 257 for (Int_t itrack = 0; itrack < fN; itrack++)
258 delete fTrackArray[itrack];
faf254af 259 delete [] fTrackArray;
260 }
98937d93 261 }
262}
cc101660 263
264//_____________________________________________________
f12d42ce 265Int_t AliTrackResiduals::GetNFreeParam(){
cc101660 266 Int_t unfixedparam=6;
267 for(Int_t j=0;j<6;j++){
268 if(fBFixed[j]==kTRUE)unfixedparam--;
269 }
270 return unfixedparam;
271}