]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/STEER/AliTrackResiduals.cxx
Coverity 18791
[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
96 for (Int_t itrack = 0; itrack < fN; itrack++)
98937d93 97 {
98 if (res.fVolArray[itrack])
99 fVolArray[itrack] = new AliTrackPointArray(*res.fVolArray[itrack]);
98937d93 100 if (res.fTrackArray[itrack])
101 fTrackArray[itrack] = new AliTrackPointArray(*res.fTrackArray[itrack]);
98937d93 102 }
4c234df8 103
8f112cf8 104 memcpy(fBFixed,res.fBFixed,sizeof(Bool_t)*6);
105 memcpy(fFixed,res.fFixed,sizeof(Float_t)*6);
106
98937d93 107}
108
109//_____________________________________________________________________________
110AliTrackResiduals &AliTrackResiduals::operator =(const AliTrackResiduals& res)
111{
112 // assignment operator
113 // Does not copy the track point arrays
17ef8526 114 if(this!=&res) {
115 TObject::operator=(res);
116
117 fN = res.fN;
118 fLast = res.fLast;
119 fAlignObj = res.fAlignObj;
120 fVolArray = res.fVolArray;
121 fTrackArray = res.fTrackArray;
122 fChi2 = res.fChi2;
123 fNdf = res.fNdf;
124 fMinNPoints = res.fMinNPoints;
125 fIsOwner = kFALSE;
126
b1613a6d 127 memcpy(fBFixed,res.fBFixed,sizeof(Bool_t)*6);
17ef8526 128 memcpy(fFixed,res.fFixed,sizeof(Float_t)*6);
29317b68 129 }
98937d93 130 return *this;
131}
132
133//_____________________________________________________________________________
134AliTrackResiduals::~AliTrackResiduals()
135{
136 // Destructor
46ae650f 137 if (fAlignObj) delete fAlignObj;
98937d93 138 DeleteTrackPointArrays();
139}
140
141//_____________________________________________________________________________
142void AliTrackResiduals::SetNTracks(Int_t ntracks)
143{
144 // Set new size for the track point arrays.
145 // Delete the old arrays and allocate the
146 // new ones.
147 DeleteTrackPointArrays();
148
149 fN = ntracks;
150 fLast = 0;
46ae650f 151 fChi2 = 0;
152 fNdf = 0;
98937d93 153 fIsOwner = kTRUE;
154
155 if (ntracks > 0) {
156 fVolArray = new AliTrackPointArray*[ntracks];
157 fTrackArray = new AliTrackPointArray*[ntracks];
158 for (Int_t itrack = 0; itrack < ntracks; itrack++)
159 fVolArray[itrack] = fTrackArray[itrack] = 0x0;
160 }
faf254af 161 else {
162 fVolArray = fTrackArray = 0x0;
163 }
98937d93 164}
165
166//_____________________________________________________________________________
167Bool_t AliTrackResiduals::AddTrackPointArrays(AliTrackPointArray *volarray, AliTrackPointArray *trackarray)
168{
169 // Adds pair of track space point and
170 // track extrapolation point arrays
171 if (!fVolArray || !fTrackArray) return kFALSE;
172
cc345ce3 173 if (!volarray || !trackarray) return kFALSE;
174
175 if (volarray->GetNPoints() < fMinNPoints) return kFALSE;
176
98937d93 177 if (fLast >= fN) return kFALSE;
178
179 fVolArray[fLast] = volarray;
180 fTrackArray[fLast] = trackarray;
181 fLast++;
182
183 return kTRUE;
184}
185
46ae650f 186//_____________________________________________________________________________
cc345ce3 187void AliTrackResiduals::InitAlignObj()
46ae650f 188{
cc345ce3 189 // Create the alignment object
190 // to be updated
46ae650f 191 if (fAlignObj) delete fAlignObj;
90dbf5fb 192 fAlignObj = new AliAlignObjParams;
46ae650f 193}
194
195
98937d93 196//_____________________________________________________________________________
197Bool_t AliTrackResiduals::GetTrackPointArrays(Int_t i, AliTrackPointArray* &volarray, AliTrackPointArray* &trackarray) const
198{
199 // Provide an access to a pair of track point arrays
200 // with given index
201 if (i >= fLast) {
202 volarray = trackarray = 0x0;
203 return kFALSE;
204 }
205 else {
206 volarray = fVolArray[i];
207 trackarray = fTrackArray[i];
208 return kTRUE;
209 }
210}
211
212//_____________________________________________________________________________
213void AliTrackResiduals::DeleteTrackPointArrays()
214{
215 // Deletes the track point arrays only in case
216 // the object is their owner.
217 // Called by the destructor and SetNTracks methods.
218 if (fIsOwner) {
faf254af 219 if (fVolArray) {
220 for (Int_t itrack = 0; itrack < fN; itrack++) {
221 if (fVolArray[itrack]) delete fVolArray[itrack];
222 }
223 delete [] fVolArray;
224 }
225 if (fTrackArray) {
226 for (Int_t itrack = 0; itrack < fN; itrack++) {
227 if (fTrackArray[itrack]) delete fTrackArray[itrack];
98937d93 228 }
faf254af 229 delete [] fTrackArray;
230 }
98937d93 231 }
232}
cc101660 233
234//_____________________________________________________
f12d42ce 235Int_t AliTrackResiduals::GetNFreeParam(){
cc101660 236 Int_t unfixedparam=6;
237 for(Int_t j=0;j<6;j++){
238 if(fBFixed[j]==kTRUE)unfixedparam--;
239 }
240 return unfixedparam;
241}