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