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