]>
Commit | Line | Data |
---|---|---|
814ecea4 | 1 | /************************************************************************** |
52a79f8d | 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 | **************************************************************************/ | |
814ecea4 | 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" | |
de520d8f | 30 | #include "AliLog.h" |
31 | ||
814ecea4 | 32 | #include "AliTRDseedV1.h" |
33 | #include "AliTRDtrackV1.h" | |
34 | ||
35 | #include <cstdio> | |
36 | #include <cstdlib> | |
37 | ||
38 | #include "AliTRDtrackInfo.h" | |
39 | ||
40 | ClassImp(AliTRDtrackInfo) | |
93e41bce | 41 | ClassImp(AliTRDtrackInfo::AliMCinfo) |
42 | ClassImp(AliTRDtrackInfo::AliESDinfo) | |
814ecea4 | 43 | |
44 | //___________________________________________________ | |
45 | AliTRDtrackInfo::AliTRDtrackInfo(): | |
46 | TObject() | |
93e41bce | 47 | ,fNClusters(0) |
814ecea4 | 48 | ,fTRDtrack(0x0) |
49 | ,fOP(0x0) | |
93e41bce | 50 | ,fMC(0x0) |
51 | ,fESD() | |
814ecea4 | 52 | { |
53 | // | |
54 | // Default constructor | |
55 | // | |
814ecea4 | 56 | } |
57 | ||
814ecea4 | 58 | |
59 | //___________________________________________________ | |
60 | AliTRDtrackInfo::AliTRDtrackInfo(const AliTRDtrackInfo &trdInfo): | |
61 | TObject((const TObject&)trdInfo) | |
93e41bce | 62 | ,fNClusters(trdInfo.fNClusters) |
814ecea4 | 63 | ,fTRDtrack(0x0) |
64 | ,fOP(0x0) | |
93e41bce | 65 | ,fMC(new AliMCinfo(*trdInfo.fMC)) |
66 | ,fESD(trdInfo.fESD) | |
814ecea4 | 67 | { |
68 | // | |
69 | // copy Entries | |
70 | // | |
71 | ||
814ecea4 | 72 | if(trdInfo.fOP) fOP = new AliExternalTrackParam(*trdInfo.fOP); |
93e41bce | 73 | |
74 | if(trdInfo.fMC) fMC = new AliMCinfo(*trdInfo.fMC); | |
75 | ||
7102d1b1 | 76 | if(trdInfo.fTRDtrack){ |
77 | fTRDtrack = new AliTRDtrackV1(*trdInfo.fTRDtrack); | |
78 | if(trdInfo.fTRDtrack->IsOwner()) fTRDtrack->SetOwner(); | |
79 | } | |
814ecea4 | 80 | } |
81 | ||
93e41bce | 82 | //___________________________________________________ |
83 | AliTRDtrackInfo::AliMCinfo::AliMCinfo() | |
84 | :fLabel(0) | |
85 | ,fPDG(0) | |
86 | ,fNTrackRefs(0) | |
87 | { | |
88 | // Set 0-Pointers | |
89 | memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12); | |
90 | } | |
91 | ||
92 | //___________________________________________________ | |
93 | AliTRDtrackInfo::AliMCinfo::AliMCinfo(const AliMCinfo &mc) | |
94 | :fLabel(mc.fLabel) | |
95 | ,fPDG(mc.fPDG) | |
96 | ,fNTrackRefs(mc.fNTrackRefs) | |
97 | { | |
98 | memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12); | |
99 | for(Int_t ien = 0; ien < 12; ien++){ | |
52a79f8d | 100 | if(mc.fTrackRefs[ien]) |
93e41bce | 101 | fTrackRefs[ien] = new AliTrackReference(*(mc.fTrackRefs[ien])); |
102 | } | |
103 | } | |
104 | ||
105 | //___________________________________________________ | |
106 | AliTRDtrackInfo::AliESDinfo::AliESDinfo() | |
107 | :fId(-1) | |
108 | ,fStatus(0) | |
52a79f8d | 109 | ,fKinkIndex(0) |
110 | ,fTPCncls(0) | |
93e41bce | 111 | ,fTRDpidQuality(0) |
112 | ,fTRDnSlices(0) | |
113 | ,fTRDslices(0x0) | |
114 | { | |
115 | memset(fTRDr, 0, AliPID::kSPECIES*sizeof(Double32_t)); | |
116 | } | |
117 | ||
118 | //___________________________________________________ | |
119 | AliTRDtrackInfo::AliESDinfo::AliESDinfo(const AliESDinfo &esd) | |
120 | :fId(esd.fId) | |
121 | ,fStatus(esd.fStatus) | |
52a79f8d | 122 | ,fKinkIndex(esd.fKinkIndex) |
123 | ,fTPCncls(esd.fTPCncls) | |
93e41bce | 124 | ,fTRDpidQuality(esd.fTRDpidQuality) |
125 | ,fTRDnSlices(esd.fTRDnSlices) | |
126 | ,fTRDslices(0x0) | |
127 | { | |
128 | memcpy(fTRDr, esd.fTRDr, AliPID::kSPECIES*sizeof(Double32_t)); | |
129 | ||
130 | if(fTRDnSlices){ | |
131 | fTRDslices = new Double32_t[fTRDnSlices]; | |
132 | memcpy(fTRDslices, esd.fTRDslices, fTRDnSlices*sizeof(Double32_t)); | |
133 | } | |
134 | } | |
135 | ||
136 | ||
814ecea4 | 137 | //___________________________________________________ |
138 | AliTRDtrackInfo::~AliTRDtrackInfo() | |
139 | { | |
140 | // | |
141 | // Destructor | |
142 | // | |
143 | ||
144 | if(fOP) delete fOP; | |
93e41bce | 145 | if(fTRDtrack) delete fTRDtrack; |
146 | } | |
147 | ||
148 | //___________________________________________________ | |
149 | AliTRDtrackInfo::AliMCinfo::~AliMCinfo() | |
150 | { | |
151 | fNTrackRefs = 0; | |
814ecea4 | 152 | for(Int_t ien = 0; ien < 12; ien++){ |
153 | if(fTrackRefs[ien]) delete fTrackRefs[ien]; | |
93e41bce | 154 | fTrackRefs[ien] = 0x0; |
155 | } | |
156 | } | |
157 | ||
158 | //___________________________________________________ | |
159 | AliTRDtrackInfo::AliESDinfo::~AliESDinfo() | |
160 | { | |
161 | if(fTRDnSlices){ | |
162 | delete [] fTRDslices; | |
163 | fTRDslices = 0x0; | |
164 | fTRDnSlices = 0; | |
814ecea4 | 165 | } |
814ecea4 | 166 | } |
167 | ||
168 | ||
169 | //___________________________________________________ | |
170 | AliTRDtrackInfo& AliTRDtrackInfo::operator=(const AliTRDtrackInfo &trdInfo) | |
171 | { | |
172 | // | |
173 | // = Operator | |
174 | // | |
175 | ||
814ecea4 | 176 | fNClusters = trdInfo.fNClusters; |
93e41bce | 177 | fESD = trdInfo.fESD; |
814ecea4 | 178 | |
179 | // copy Entries | |
814ecea4 | 180 | if(trdInfo.fOP){ |
52a79f8d | 181 | if(!fOP) |
182 | fOP = new AliExternalTrackParam(*trdInfo.fOP); | |
183 | else | |
184 | new(fOP) AliExternalTrackParam(*trdInfo.fOP); | |
814ecea4 | 185 | } |
93e41bce | 186 | |
187 | if(trdInfo.fMC){ | |
52a79f8d | 188 | if(!fMC) |
189 | fMC = new AliMCinfo(*trdInfo.fMC); | |
190 | else | |
191 | new(fMC) AliMCinfo(*trdInfo.fMC); | |
93e41bce | 192 | } |
193 | ||
814ecea4 | 194 | if(trdInfo.fTRDtrack){ |
52a79f8d | 195 | if(!fTRDtrack) |
196 | fTRDtrack = new AliTRDtrackV1(*trdInfo.fTRDtrack); | |
197 | else | |
198 | new(fTRDtrack) AliTRDtrackV1(*trdInfo.fTRDtrack); | |
39779ce6 | 199 | if(trdInfo.fTRDtrack->IsOwner()) fTRDtrack->SetOwner(); |
814ecea4 | 200 | } |
201 | ||
202 | return *this; | |
203 | } | |
204 | ||
93e41bce | 205 | //___________________________________________________ |
206 | AliTRDtrackInfo::AliMCinfo& AliTRDtrackInfo::AliMCinfo::operator=(const AliMCinfo &mc) | |
207 | { | |
208 | fLabel = mc.fLabel; | |
209 | fPDG = mc.fPDG; | |
210 | fNTrackRefs = mc.fNTrackRefs; | |
211 | ||
212 | AliTrackReference **itr = &fTrackRefs[0]; | |
213 | AliTrackReference* const *jtr = &mc.fTrackRefs[0]; | |
214 | for(Int_t ien = 0; ien < 12; ien++, itr++, jtr++){ | |
215 | if((*jtr)){ | |
216 | if(!(*itr)) (*itr) = new AliTrackReference(*(*jtr)); | |
217 | else new(&(*itr)) AliTrackReference(*(*jtr)); | |
218 | } else (*itr) = 0x0; | |
219 | } | |
220 | return *this; | |
221 | } | |
222 | ||
223 | //___________________________________________________ | |
224 | AliTRDtrackInfo::AliESDinfo& AliTRDtrackInfo::AliESDinfo::operator=(const AliESDinfo &esd) | |
225 | { | |
226 | fId = esd.fId; | |
227 | fStatus = esd.fStatus; | |
228 | fTRDpidQuality = esd.fTRDpidQuality; | |
229 | fTRDnSlices = esd.fTRDnSlices; | |
230 | fTRDslices = 0x0; | |
231 | ||
232 | memcpy(fTRDr, esd.fTRDr, AliPID::kSPECIES*sizeof(Double32_t)); | |
233 | ||
234 | if(fTRDnSlices){ | |
235 | fTRDslices = new Double32_t[fTRDnSlices]; | |
236 | memcpy(fTRDslices, esd.fTRDslices, fTRDnSlices*sizeof(Double32_t)); | |
237 | } | |
238 | ||
239 | return *this; | |
240 | } | |
241 | ||
814ecea4 | 242 | //___________________________________________________ |
243 | void AliTRDtrackInfo::Delete(const Option_t *) | |
244 | { | |
245 | // | |
246 | // Delete | |
247 | // | |
248 | ||
814ecea4 | 249 | fNClusters = 0; |
814ecea4 | 250 | if(fOP) delete fOP; fOP = 0x0; |
93e41bce | 251 | if(fMC) delete fMC; fMC = 0x0; |
814ecea4 | 252 | if(fTRDtrack) delete fTRDtrack; fTRDtrack = 0x0; |
814ecea4 | 253 | } |
254 | ||
814ecea4 | 255 | //___________________________________________________ |
c46a7947 | 256 | void AliTRDtrackInfo::SetTrack(const AliTRDtrackV1 *track) |
814ecea4 | 257 | { |
258 | // | |
259 | // Set the TRD track | |
260 | // | |
261 | ||
262 | if(!fTRDtrack) | |
52a79f8d | 263 | fTRDtrack = new AliTRDtrackV1(*track); |
814ecea4 | 264 | else |
52a79f8d | 265 | new(fTRDtrack)AliTRDtrackV1(*track); |
266 | fTRDtrack->SetOwner(); | |
814ecea4 | 267 | // Make a copy for the object in order to avoid ownership problems |
268 | } | |
269 | ||
270 | //___________________________________________________ | |
271 | void AliTRDtrackInfo::AddTrackRef(const AliTrackReference *tref) | |
272 | { | |
273 | // | |
274 | // Add track reference | |
275 | // | |
276 | ||
93e41bce | 277 | SetMC(); |
278 | if(fMC->fNTrackRefs >= 12){ | |
814ecea4 | 279 | SetCurved(); |
280 | return; | |
281 | } | |
282 | // Make a copy for the object in order to avoid ownership problems | |
93e41bce | 283 | fMC->fTrackRefs[fMC->fNTrackRefs++] = new AliTrackReference(*tref); |
814ecea4 | 284 | } |
285 | ||
814ecea4 | 286 | //___________________________________________________ |
287 | AliTrackReference * AliTRDtrackInfo::GetTrackRef(Int_t idx) const | |
288 | { | |
289 | // | |
290 | // Returns a track reference | |
291 | // | |
93e41bce | 292 | if(!fMC) return 0x0; |
b718144c | 293 | return (idx>=0 && idx < 12) ? fMC->fTrackRefs[idx] : 0x0; |
814ecea4 | 294 | } |
295 | ||
296 | //___________________________________________________ | |
297 | Int_t AliTRDtrackInfo::GetNumberOfClusters() const | |
298 | { | |
299 | // | |
300 | // Returns the number of clusters | |
301 | // | |
302 | ||
303 | Int_t n = 0; | |
52a79f8d | 304 | if(!fTRDtrack) return 0; |
814ecea4 | 305 | if(fTRDtrack->GetNumberOfTracklets() == 0) return n; |
306 | AliTRDseedV1 *tracklet = 0x0; | |
307 | for(Int_t ip=0; ip<6; ip++){ | |
52a79f8d | 308 | if(!(tracklet = const_cast<AliTRDseedV1 *>(fTRDtrack->GetTracklet(ip)))) continue; |
814ecea4 | 309 | n+=tracklet->GetN(); |
310 | } | |
311 | return n; | |
312 | } | |
313 | ||
314 | ||
315 | //___________________________________________________ | |
316 | void AliTRDtrackInfo::SetOuterParam(const AliExternalTrackParam *op) | |
317 | { | |
318 | // | |
319 | // Set outer track parameters | |
320 | // | |
321 | ||
322 | if(!op) return; | |
323 | if(fOP) new(fOP) AliExternalTrackParam(*op); | |
324 | else | |
52a79f8d | 325 | fOP = new AliExternalTrackParam(*op); |
814ecea4 | 326 | } |
327 | ||
328 | //___________________________________________________ | |
329 | Int_t AliTRDtrackInfo::GetNTracklets() const | |
330 | { | |
331 | // | |
332 | // Return the number of tracklets | |
333 | // | |
334 | ||
52a79f8d | 335 | if(!fTRDtrack) return 0x0; |
336 | return fTRDtrack->GetNumberOfTracklets(); | |
814ecea4 | 337 | } |
93e41bce | 338 | |
339 | //___________________________________________________ | |
340 | void AliTRDtrackInfo::SetSlices(Int_t n, Double32_t *s) | |
341 | { | |
342 | if(fESD.fTRDnSlices != n){ | |
343 | fESD.fTRDnSlices = 0; | |
344 | delete [] fESD.fTRDslices; | |
345 | fESD.fTRDslices = 0x0; | |
346 | } | |
347 | ||
348 | if(!fESD.fTRDnSlices){ | |
349 | fESD.fTRDnSlices = n; | |
350 | fESD.fTRDslices = new Double32_t[n]; | |
351 | } | |
352 | ||
353 | memcpy(fESD.fTRDslices, s, n*sizeof(Double32_t)); | |
354 | } | |
de520d8f | 355 | |
356 | //___________________________________________________ | |
357 | Bool_t AliTRDtrackInfo::AliMCinfo::GetDirections(Float_t x0, Float_t &y0, Float_t &z0, Float_t &dydx, Float_t &dzdx) const | |
358 | { | |
52a79f8d | 359 | // check for 2 track ref where the radial position has a distance less than 3.7mm and are close to the x0 |
de520d8f | 360 | |
361 | Int_t nFound = 0; | |
362 | AliTrackReference *tr[2] = {0x0, 0x0}; | |
363 | AliTrackReference * const* jtr = &fTrackRefs[0]; | |
364 | for(Int_t itr = 0; itr < fNTrackRefs; itr++, ++jtr){ | |
365 | if(!(*jtr)) break; | |
366 | /* | |
367 | if(fDebugLevel>=5) printf("\t\tref[%2d] x[%6.3f]\n", itr, (*jtr)->LocalX());*/ | |
368 | if(TMath::Abs(x0 - (*jtr)->LocalX()) > 3.7) continue; | |
369 | tr[nFound++] = (*jtr); | |
370 | if(nFound == 2) break; | |
371 | } | |
372 | if(nFound < 2){ | |
373 | AliWarningGeneral("AliTRDtrackInfo::AliMCinfo::GetDirections()", Form("Missing track ref x0[%6.3f] nref[%d]\n", x0, nFound)); | |
374 | return kFALSE; | |
375 | } | |
376 | Double_t dx = tr[1]->LocalX() - tr[0]->LocalX(); | |
377 | if(dx <= 0. || TMath::Abs(dx-3.7)>1.E-3){ | |
378 | AliWarningGeneral("AliTRDtrackInfo::AliMCinfo::GetDirections()", Form("Track ref with wrong radial distances refX0[%6.3f] refX1[%6.3f]", tr[0]->LocalX(), tr[1]->LocalX())); | |
379 | return kFALSE; | |
380 | } | |
381 | ||
382 | dydx = (tr[1]->LocalY() - tr[0]->LocalY()) / dx; | |
383 | dzdx = (tr[1]->Z() - tr[0]->Z()) / dx; | |
384 | Float_t dx0 = tr[1]->LocalX() - x0; | |
385 | y0 = tr[1]->LocalY() - dydx*dx0; | |
386 | z0 = tr[1]->Z() - dzdx*dx0; | |
387 | return kTRUE; | |
388 | } | |
389 |