]>
Commit | Line | Data |
---|---|---|
814ecea4 | 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 | /* $Id: AliTRDtrackInfo.cxx 27496 2008-07-22 08:35:45Z cblume $ */ | |
17 | ||
18 | //////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // Reconstruction QA // | |
21 | // // | |
22 | // Authors: // | |
93e41bce | 23 | // Alex Bercuci <A.Bercuci@gsi.de> // |
814ecea4 | 24 | // Markus Fasel <M.Fasel@gsi.de> // |
25 | // // | |
26 | //////////////////////////////////////////////////////////////////////////// | |
27 | ||
28 | #include "AliTrackReference.h" | |
29 | #include "AliExternalTrackParam.h" | |
30 | #include "AliTRDseedV1.h" | |
31 | #include "AliTRDtrackV1.h" | |
32 | ||
33 | #include <cstdio> | |
34 | #include <cstdlib> | |
35 | ||
36 | #include "AliTRDtrackInfo.h" | |
37 | ||
38 | ClassImp(AliTRDtrackInfo) | |
93e41bce | 39 | ClassImp(AliTRDtrackInfo::AliMCinfo) |
40 | ClassImp(AliTRDtrackInfo::AliESDinfo) | |
814ecea4 | 41 | |
42 | //___________________________________________________ | |
43 | AliTRDtrackInfo::AliTRDtrackInfo(): | |
44 | TObject() | |
93e41bce | 45 | ,fNClusters(0) |
814ecea4 | 46 | ,fTRDtrack(0x0) |
47 | ,fOP(0x0) | |
93e41bce | 48 | ,fMC(0x0) |
49 | ,fESD() | |
814ecea4 | 50 | { |
51 | // | |
52 | // Default constructor | |
53 | // | |
814ecea4 | 54 | } |
55 | ||
814ecea4 | 56 | |
57 | //___________________________________________________ | |
58 | AliTRDtrackInfo::AliTRDtrackInfo(const AliTRDtrackInfo &trdInfo): | |
59 | TObject((const TObject&)trdInfo) | |
93e41bce | 60 | ,fNClusters(trdInfo.fNClusters) |
814ecea4 | 61 | ,fTRDtrack(0x0) |
62 | ,fOP(0x0) | |
93e41bce | 63 | ,fMC(new AliMCinfo(*trdInfo.fMC)) |
64 | ,fESD(trdInfo.fESD) | |
814ecea4 | 65 | { |
66 | // | |
67 | // copy Entries | |
68 | // | |
69 | ||
814ecea4 | 70 | if(trdInfo.fOP) fOP = new AliExternalTrackParam(*trdInfo.fOP); |
93e41bce | 71 | |
72 | if(trdInfo.fMC) fMC = new AliMCinfo(*trdInfo.fMC); | |
73 | ||
7102d1b1 | 74 | if(trdInfo.fTRDtrack){ |
75 | fTRDtrack = new AliTRDtrackV1(*trdInfo.fTRDtrack); | |
76 | if(trdInfo.fTRDtrack->IsOwner()) fTRDtrack->SetOwner(); | |
77 | } | |
814ecea4 | 78 | } |
79 | ||
93e41bce | 80 | //___________________________________________________ |
81 | AliTRDtrackInfo::AliMCinfo::AliMCinfo() | |
82 | :fLabel(0) | |
83 | ,fPDG(0) | |
84 | ,fNTrackRefs(0) | |
85 | { | |
86 | // Set 0-Pointers | |
87 | memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12); | |
88 | } | |
89 | ||
90 | //___________________________________________________ | |
91 | AliTRDtrackInfo::AliMCinfo::AliMCinfo(const AliMCinfo &mc) | |
92 | :fLabel(mc.fLabel) | |
93 | ,fPDG(mc.fPDG) | |
94 | ,fNTrackRefs(mc.fNTrackRefs) | |
95 | { | |
96 | memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12); | |
97 | for(Int_t ien = 0; ien < 12; ien++){ | |
98 | if(mc.fTrackRefs[ien]) | |
99 | fTrackRefs[ien] = new AliTrackReference(*(mc.fTrackRefs[ien])); | |
100 | } | |
101 | } | |
102 | ||
103 | //___________________________________________________ | |
104 | AliTRDtrackInfo::AliESDinfo::AliESDinfo() | |
105 | :fId(-1) | |
106 | ,fStatus(0) | |
107 | ,fTRDpidQuality(0) | |
108 | ,fTRDnSlices(0) | |
109 | ,fTRDslices(0x0) | |
110 | { | |
111 | memset(fTRDr, 0, AliPID::kSPECIES*sizeof(Double32_t)); | |
112 | } | |
113 | ||
114 | //___________________________________________________ | |
115 | AliTRDtrackInfo::AliESDinfo::AliESDinfo(const AliESDinfo &esd) | |
116 | :fId(esd.fId) | |
117 | ,fStatus(esd.fStatus) | |
118 | ,fTRDpidQuality(esd.fTRDpidQuality) | |
119 | ,fTRDnSlices(esd.fTRDnSlices) | |
120 | ,fTRDslices(0x0) | |
121 | { | |
122 | memcpy(fTRDr, esd.fTRDr, AliPID::kSPECIES*sizeof(Double32_t)); | |
123 | ||
124 | if(fTRDnSlices){ | |
125 | fTRDslices = new Double32_t[fTRDnSlices]; | |
126 | memcpy(fTRDslices, esd.fTRDslices, fTRDnSlices*sizeof(Double32_t)); | |
127 | } | |
128 | } | |
129 | ||
130 | ||
814ecea4 | 131 | //___________________________________________________ |
132 | AliTRDtrackInfo::~AliTRDtrackInfo() | |
133 | { | |
134 | // | |
135 | // Destructor | |
136 | // | |
137 | ||
138 | if(fOP) delete fOP; | |
93e41bce | 139 | if(fTRDtrack) delete fTRDtrack; |
140 | } | |
141 | ||
142 | //___________________________________________________ | |
143 | AliTRDtrackInfo::AliMCinfo::~AliMCinfo() | |
144 | { | |
145 | fNTrackRefs = 0; | |
814ecea4 | 146 | for(Int_t ien = 0; ien < 12; ien++){ |
147 | if(fTrackRefs[ien]) delete fTrackRefs[ien]; | |
93e41bce | 148 | fTrackRefs[ien] = 0x0; |
149 | } | |
150 | } | |
151 | ||
152 | //___________________________________________________ | |
153 | AliTRDtrackInfo::AliESDinfo::~AliESDinfo() | |
154 | { | |
155 | if(fTRDnSlices){ | |
156 | delete [] fTRDslices; | |
157 | fTRDslices = 0x0; | |
158 | fTRDnSlices = 0; | |
814ecea4 | 159 | } |
814ecea4 | 160 | } |
161 | ||
162 | ||
163 | //___________________________________________________ | |
164 | AliTRDtrackInfo& AliTRDtrackInfo::operator=(const AliTRDtrackInfo &trdInfo) | |
165 | { | |
166 | // | |
167 | // = Operator | |
168 | // | |
169 | ||
814ecea4 | 170 | fNClusters = trdInfo.fNClusters; |
93e41bce | 171 | fESD = trdInfo.fESD; |
814ecea4 | 172 | |
173 | // copy Entries | |
814ecea4 | 174 | if(trdInfo.fOP){ |
175 | if(!fOP) | |
176 | fOP = new AliExternalTrackParam(*trdInfo.fOP); | |
177 | else | |
178 | new(fOP) AliExternalTrackParam(*trdInfo.fOP); | |
179 | } | |
93e41bce | 180 | |
181 | if(trdInfo.fMC){ | |
182 | if(!fMC) | |
183 | fMC = new AliMCinfo(*trdInfo.fMC); | |
184 | else | |
185 | new(fMC) AliMCinfo(*trdInfo.fMC); | |
186 | } | |
187 | ||
814ecea4 | 188 | if(trdInfo.fTRDtrack){ |
189 | if(!fTRDtrack) | |
190 | fTRDtrack = new AliTRDtrackV1(*trdInfo.fTRDtrack); | |
191 | else | |
192 | new(fTRDtrack) AliTRDtrackV1(*trdInfo.fTRDtrack); | |
39779ce6 | 193 | if(trdInfo.fTRDtrack->IsOwner()) fTRDtrack->SetOwner(); |
814ecea4 | 194 | } |
195 | ||
196 | return *this; | |
197 | } | |
198 | ||
93e41bce | 199 | //___________________________________________________ |
200 | AliTRDtrackInfo::AliMCinfo& AliTRDtrackInfo::AliMCinfo::operator=(const AliMCinfo &mc) | |
201 | { | |
202 | fLabel = mc.fLabel; | |
203 | fPDG = mc.fPDG; | |
204 | fNTrackRefs = mc.fNTrackRefs; | |
205 | ||
206 | AliTrackReference **itr = &fTrackRefs[0]; | |
207 | AliTrackReference* const *jtr = &mc.fTrackRefs[0]; | |
208 | for(Int_t ien = 0; ien < 12; ien++, itr++, jtr++){ | |
209 | if((*jtr)){ | |
210 | if(!(*itr)) (*itr) = new AliTrackReference(*(*jtr)); | |
211 | else new(&(*itr)) AliTrackReference(*(*jtr)); | |
212 | } else (*itr) = 0x0; | |
213 | } | |
214 | return *this; | |
215 | } | |
216 | ||
217 | //___________________________________________________ | |
218 | AliTRDtrackInfo::AliESDinfo& AliTRDtrackInfo::AliESDinfo::operator=(const AliESDinfo &esd) | |
219 | { | |
220 | fId = esd.fId; | |
221 | fStatus = esd.fStatus; | |
222 | fTRDpidQuality = esd.fTRDpidQuality; | |
223 | fTRDnSlices = esd.fTRDnSlices; | |
224 | fTRDslices = 0x0; | |
225 | ||
226 | memcpy(fTRDr, esd.fTRDr, AliPID::kSPECIES*sizeof(Double32_t)); | |
227 | ||
228 | if(fTRDnSlices){ | |
229 | fTRDslices = new Double32_t[fTRDnSlices]; | |
230 | memcpy(fTRDslices, esd.fTRDslices, fTRDnSlices*sizeof(Double32_t)); | |
231 | } | |
232 | ||
233 | return *this; | |
234 | } | |
235 | ||
814ecea4 | 236 | //___________________________________________________ |
237 | void AliTRDtrackInfo::Delete(const Option_t *) | |
238 | { | |
239 | // | |
240 | // Delete | |
241 | // | |
242 | ||
814ecea4 | 243 | fNClusters = 0; |
814ecea4 | 244 | if(fOP) delete fOP; fOP = 0x0; |
93e41bce | 245 | if(fMC) delete fMC; fMC = 0x0; |
814ecea4 | 246 | if(fTRDtrack) delete fTRDtrack; fTRDtrack = 0x0; |
814ecea4 | 247 | } |
248 | ||
249 | ||
250 | //___________________________________________________ | |
251 | void AliTRDtrackInfo::SetTRDtrack(const AliTRDtrackV1 *track) | |
252 | { | |
253 | // | |
254 | // Set the TRD track | |
255 | // | |
256 | ||
257 | if(!fTRDtrack) | |
258 | fTRDtrack = new AliTRDtrackV1(*track); | |
259 | else | |
260 | new(fTRDtrack)AliTRDtrackV1(*track); | |
261 | fTRDtrack->SetOwner(); | |
262 | // Make a copy for the object in order to avoid ownership problems | |
263 | } | |
264 | ||
265 | //___________________________________________________ | |
266 | void AliTRDtrackInfo::AddTrackRef(const AliTrackReference *tref) | |
267 | { | |
268 | // | |
269 | // Add track reference | |
270 | // | |
271 | ||
93e41bce | 272 | SetMC(); |
273 | if(fMC->fNTrackRefs >= 12){ | |
814ecea4 | 274 | SetCurved(); |
275 | return; | |
276 | } | |
277 | // Make a copy for the object in order to avoid ownership problems | |
93e41bce | 278 | fMC->fTrackRefs[fMC->fNTrackRefs++] = new AliTrackReference(*tref); |
814ecea4 | 279 | } |
280 | ||
814ecea4 | 281 | //___________________________________________________ |
282 | AliTrackReference * AliTRDtrackInfo::GetTrackRef(Int_t idx) const | |
283 | { | |
284 | // | |
285 | // Returns a track reference | |
286 | // | |
93e41bce | 287 | if(!fMC) return 0x0; |
b718144c | 288 | return (idx>=0 && idx < 12) ? fMC->fTrackRefs[idx] : 0x0; |
814ecea4 | 289 | } |
290 | ||
291 | //___________________________________________________ | |
292 | Int_t AliTRDtrackInfo::GetNumberOfClusters() const | |
293 | { | |
294 | // | |
295 | // Returns the number of clusters | |
296 | // | |
297 | ||
298 | Int_t n = 0; | |
299 | if(!fTRDtrack) return 0; | |
300 | if(fTRDtrack->GetNumberOfTracklets() == 0) return n; | |
301 | AliTRDseedV1 *tracklet = 0x0; | |
302 | for(Int_t ip=0; ip<6; ip++){ | |
303 | if(!(tracklet = const_cast<AliTRDseedV1 *>(fTRDtrack->GetTracklet(ip)))) continue; | |
304 | n+=tracklet->GetN(); | |
305 | } | |
306 | return n; | |
307 | } | |
308 | ||
309 | ||
310 | //___________________________________________________ | |
311 | void AliTRDtrackInfo::SetOuterParam(const AliExternalTrackParam *op) | |
312 | { | |
313 | // | |
314 | // Set outer track parameters | |
315 | // | |
316 | ||
317 | if(!op) return; | |
318 | if(fOP) new(fOP) AliExternalTrackParam(*op); | |
319 | else | |
320 | fOP = new AliExternalTrackParam(*op); | |
321 | } | |
322 | ||
323 | //___________________________________________________ | |
324 | Int_t AliTRDtrackInfo::GetNTracklets() const | |
325 | { | |
326 | // | |
327 | // Return the number of tracklets | |
328 | // | |
329 | ||
330 | if(!fTRDtrack) return 0x0; | |
331 | return fTRDtrack->GetNumberOfTracklets(); | |
332 | } | |
93e41bce | 333 | |
334 | //___________________________________________________ | |
335 | void AliTRDtrackInfo::SetSlices(Int_t n, Double32_t *s) | |
336 | { | |
337 | if(fESD.fTRDnSlices != n){ | |
338 | fESD.fTRDnSlices = 0; | |
339 | delete [] fESD.fTRDslices; | |
340 | fESD.fTRDslices = 0x0; | |
341 | } | |
342 | ||
343 | if(!fESD.fTRDnSlices){ | |
344 | fESD.fTRDnSlices = n; | |
345 | fESD.fTRDslices = new Double32_t[n]; | |
346 | } | |
347 | ||
348 | memcpy(fESD.fTRDslices, s, n*sizeof(Double32_t)); | |
349 | } |