]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliTrackResiduals.cxx
Use default errors in case the vertexer didn't find any
[u/mrichter/AliRoot.git] / 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"
cc345ce3 25#include "AliAlignObjAngles.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
98937d93 43}
44
45//_____________________________________________________________________________
46ae650f 46AliTrackResiduals::AliTrackResiduals(Int_t ntracks):
98937d93 47 fN(ntracks),
48 fLast(0),
46ae650f 49 fAlignObj(0),
50 fChi2(0),
51 fNdf(0),
cc345ce3 52 fMinNPoints(0),
98937d93 53 fIsOwner(kTRUE)
54{
55 // Constructor
56 if (ntracks > 0) {
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;
61 }
62}
63
64//_____________________________________________________________________________
65AliTrackResiduals::AliTrackResiduals(const AliTrackResiduals &res):
66 TObject(res),
67 fN(res.fN),
68 fLast(res.fLast),
46ae650f 69 fChi2(res.fChi2),
70 fNdf(res.fNdf),
cc345ce3 71 fMinNPoints(res.fMinNPoints),
98937d93 72 fIsOwner(kTRUE)
73{
74 // Copy constructor
75 // By default the created copy owns the track point arrays
46ae650f 76 if (res.fAlignObj)
77 fAlignObj = (AliAlignObj *)res.fAlignObj->Clone();
78
98937d93 79 if (fN > 0) {
80 fVolArray = new AliTrackPointArray*[fN];
81 fTrackArray = new AliTrackPointArray*[fN];
82 for (Int_t itrack = 0; itrack < fN; itrack++)
83 {
84 if (res.fVolArray[itrack])
85 fVolArray[itrack] = new AliTrackPointArray(*res.fVolArray[itrack]);
86 else
87 fVolArray = 0x0;
88 if (res.fTrackArray[itrack])
89 fTrackArray[itrack] = new AliTrackPointArray(*res.fTrackArray[itrack]);
90 else
91 fTrackArray = 0x0;
92 }
93 }
94}
95
96//_____________________________________________________________________________
97AliTrackResiduals &AliTrackResiduals::operator =(const AliTrackResiduals& res)
98{
99 // assignment operator
100 // Does not copy the track point arrays
101 if(this==&res) return *this;
102 ((TObject *)this)->operator=(res);
103
104 fN = res.fN;
105 fLast = res.fLast;
46ae650f 106 fChi2 = res.fChi2;
107 fNdf = res.fNdf;
cc345ce3 108 fMinNPoints = res.fMinNPoints;
98937d93 109 fIsOwner = kFALSE;
110 fAlignObj = res.fAlignObj;
111
112 fVolArray = res.fVolArray;
113 fTrackArray = res.fTrackArray;
114
115 return *this;
116}
117
118//_____________________________________________________________________________
119AliTrackResiduals::~AliTrackResiduals()
120{
121 // Destructor
46ae650f 122 if (fAlignObj) delete fAlignObj;
98937d93 123 DeleteTrackPointArrays();
124}
125
126//_____________________________________________________________________________
127void AliTrackResiduals::SetNTracks(Int_t ntracks)
128{
129 // Set new size for the track point arrays.
130 // Delete the old arrays and allocate the
131 // new ones.
132 DeleteTrackPointArrays();
133
134 fN = ntracks;
135 fLast = 0;
46ae650f 136 fChi2 = 0;
137 fNdf = 0;
98937d93 138 fIsOwner = kTRUE;
139
140 if (ntracks > 0) {
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;
145 }
146}
147
148//_____________________________________________________________________________
149Bool_t AliTrackResiduals::AddTrackPointArrays(AliTrackPointArray *volarray, AliTrackPointArray *trackarray)
150{
151 // Adds pair of track space point and
152 // track extrapolation point arrays
153 if (!fVolArray || !fTrackArray) return kFALSE;
154
cc345ce3 155 if (!volarray || !trackarray) return kFALSE;
156
157 if (volarray->GetNPoints() < fMinNPoints) return kFALSE;
158
98937d93 159 if (fLast >= fN) return kFALSE;
160
161 fVolArray[fLast] = volarray;
162 fTrackArray[fLast] = trackarray;
163 fLast++;
164
165 return kTRUE;
166}
167
46ae650f 168//_____________________________________________________________________________
cc345ce3 169void AliTrackResiduals::InitAlignObj()
46ae650f 170{
cc345ce3 171 // Create the alignment object
172 // to be updated
46ae650f 173 if (fAlignObj) delete fAlignObj;
cc345ce3 174 fAlignObj = new AliAlignObjAngles;
46ae650f 175}
176
177
98937d93 178//_____________________________________________________________________________
179Bool_t AliTrackResiduals::GetTrackPointArrays(Int_t i, AliTrackPointArray* &volarray, AliTrackPointArray* &trackarray) const
180{
181 // Provide an access to a pair of track point arrays
182 // with given index
183 if (i >= fLast) {
184 volarray = trackarray = 0x0;
185 return kFALSE;
186 }
187 else {
188 volarray = fVolArray[i];
189 trackarray = fTrackArray[i];
190 return kTRUE;
191 }
192}
193
194//_____________________________________________________________________________
195void AliTrackResiduals::DeleteTrackPointArrays()
196{
197 // Deletes the track point arrays only in case
198 // the object is their owner.
199 // Called by the destructor and SetNTracks methods.
200 if (fIsOwner) {
201 for (Int_t itrack = 0; itrack < fLast; itrack++)
202 {
203 delete fVolArray[itrack];
204 delete fTrackArray[itrack];
205 }
206 delete [] fVolArray;
207 delete [] fTrackArray;
208 }
209}