]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliTrackResiduals.cxx
Additional protection for locked geometry. Don't MakeAlignablePN in Set/GetLocalMatrix
[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"
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 }
29317b68 68 for (Int_t ipar=0; ipar<6; ipar++){
69 fBFixed[ipar] = kFALSE;
70 fFixed[ipar] = 0.;
71 }
98937d93 72}
73
74//_____________________________________________________________________________
75AliTrackResiduals::AliTrackResiduals(const AliTrackResiduals &res):
76 TObject(res),
77 fN(res.fN),
78 fLast(res.fLast),
75e3794b 79 fAlignObj(0),
80 fVolArray(0),
81 fTrackArray(0),
46ae650f 82 fChi2(res.fChi2),
83 fNdf(res.fNdf),
cc345ce3 84 fMinNPoints(res.fMinNPoints),
98937d93 85 fIsOwner(kTRUE)
86{
87 // Copy constructor
88 // By default the created copy owns the track point arrays
46ae650f 89 if (res.fAlignObj)
90 fAlignObj = (AliAlignObj *)res.fAlignObj->Clone();
91
98937d93 92 if (fN > 0) {
93 fVolArray = new AliTrackPointArray*[fN];
94 fTrackArray = new AliTrackPointArray*[fN];
95 for (Int_t itrack = 0; itrack < fN; itrack++)
96 {
97 if (res.fVolArray[itrack])
98 fVolArray[itrack] = new AliTrackPointArray(*res.fVolArray[itrack]);
99 else
100 fVolArray = 0x0;
101 if (res.fTrackArray[itrack])
102 fTrackArray[itrack] = new AliTrackPointArray(*res.fTrackArray[itrack]);
103 else
104 fTrackArray = 0x0;
105 }
106 }
29317b68 107 for(Int_t i=0;i<6;i++) {
108 fBFixed[i]=res.fBFixed[i];
109 fFixed[i]=res.fFixed[i];
110 }
98937d93 111}
112
113//_____________________________________________________________________________
114AliTrackResiduals &AliTrackResiduals::operator =(const AliTrackResiduals& res)
115{
116 // assignment operator
117 // Does not copy the track point arrays
118 if(this==&res) return *this;
119 ((TObject *)this)->operator=(res);
120
121 fN = res.fN;
122 fLast = res.fLast;
46ae650f 123 fChi2 = res.fChi2;
124 fNdf = res.fNdf;
cc345ce3 125 fMinNPoints = res.fMinNPoints;
98937d93 126 fIsOwner = kFALSE;
127 fAlignObj = res.fAlignObj;
128
129 fVolArray = res.fVolArray;
130 fTrackArray = res.fTrackArray;
131
29317b68 132 for(Int_t i=0;i<6;i++) {
133 fBFixed[i]=res.fBFixed[i];
134 fFixed[i]=res.fFixed[i];
135 }
136
98937d93 137 return *this;
138}
139
140//_____________________________________________________________________________
141AliTrackResiduals::~AliTrackResiduals()
142{
143 // Destructor
46ae650f 144 if (fAlignObj) delete fAlignObj;
98937d93 145 DeleteTrackPointArrays();
146}
147
148//_____________________________________________________________________________
149void AliTrackResiduals::SetNTracks(Int_t ntracks)
150{
151 // Set new size for the track point arrays.
152 // Delete the old arrays and allocate the
153 // new ones.
154 DeleteTrackPointArrays();
155
156 fN = ntracks;
157 fLast = 0;
46ae650f 158 fChi2 = 0;
159 fNdf = 0;
98937d93 160 fIsOwner = kTRUE;
161
162 if (ntracks > 0) {
163 fVolArray = new AliTrackPointArray*[ntracks];
164 fTrackArray = new AliTrackPointArray*[ntracks];
165 for (Int_t itrack = 0; itrack < ntracks; itrack++)
166 fVolArray[itrack] = fTrackArray[itrack] = 0x0;
167 }
168}
169
170//_____________________________________________________________________________
171Bool_t AliTrackResiduals::AddTrackPointArrays(AliTrackPointArray *volarray, AliTrackPointArray *trackarray)
172{
173 // Adds pair of track space point and
174 // track extrapolation point arrays
175 if (!fVolArray || !fTrackArray) return kFALSE;
176
cc345ce3 177 if (!volarray || !trackarray) return kFALSE;
178
179 if (volarray->GetNPoints() < fMinNPoints) return kFALSE;
180
98937d93 181 if (fLast >= fN) return kFALSE;
182
183 fVolArray[fLast] = volarray;
184 fTrackArray[fLast] = trackarray;
185 fLast++;
186
187 return kTRUE;
188}
189
46ae650f 190//_____________________________________________________________________________
cc345ce3 191void AliTrackResiduals::InitAlignObj()
46ae650f 192{
cc345ce3 193 // Create the alignment object
194 // to be updated
46ae650f 195 if (fAlignObj) delete fAlignObj;
90dbf5fb 196 fAlignObj = new AliAlignObjParams;
46ae650f 197}
198
199
98937d93 200//_____________________________________________________________________________
201Bool_t AliTrackResiduals::GetTrackPointArrays(Int_t i, AliTrackPointArray* &volarray, AliTrackPointArray* &trackarray) const
202{
203 // Provide an access to a pair of track point arrays
204 // with given index
205 if (i >= fLast) {
206 volarray = trackarray = 0x0;
207 return kFALSE;
208 }
209 else {
210 volarray = fVolArray[i];
211 trackarray = fTrackArray[i];
212 return kTRUE;
213 }
214}
215
216//_____________________________________________________________________________
217void AliTrackResiduals::DeleteTrackPointArrays()
218{
219 // Deletes the track point arrays only in case
220 // the object is their owner.
221 // Called by the destructor and SetNTracks methods.
222 if (fIsOwner) {
223 for (Int_t itrack = 0; itrack < fLast; itrack++)
224 {
225 delete fVolArray[itrack];
226 delete fTrackArray[itrack];
227 }
228 delete [] fVolArray;
229 delete [] fTrackArray;
230 }
231}