]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/ESD/AliESDtrack.cxx
Coverity fixes for dead code (M- Verweij)
[u/mrichter/AliRoot.git] / STEER / ESD / AliESDtrack.cxx
CommitLineData
ae982df3 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 **************************************************************************/
ae982df3 15//-----------------------------------------------------------------
16// Implementation of the ESD track class
4427806c 17// ESD = Event Summary Data
15614b8b 18// This is the class to deal with during the phisics analysis of data
4427806c 19// Origin: Iouri Belikov, CERN
20// e-mail: Jouri.Belikov@cern.ch
4df45162 21//
22//
23//
24// What do you need to know before starting analysis
25// (by Marian Ivanov: marian.ivanov@cern.ch)
26//
27//
28// AliESDtrack:
29// 1. What is the AliESDtrack
30// 2. What informations do we store
31// 3. How to use the information for analysis
32//
33//
34// 1.AliESDtrack is the container of the information about the track/particle
35// reconstructed during Barrel Tracking.
36// The track information is propagated from one tracking detector to
37// other using the functionality of AliESDtrack - Current parameters.
38//
39// No global fit model is used.
40// Barrel tracking use Kalman filtering technique, it gives optimal local
41// track parameters at given point under certian assumptions.
42//
43// Kalman filter take into account additional effect which are
44// difficult to handle using global fit.
45// Effects:
46// a.) Multiple scattering
47// b.) Energy loss
48// c.) Non homogenous magnetic field
49//
50// In general case, following barrel detectors are contributing to
51// the Kalman track information:
52// a. TPC
53// b. ITS
54// c. TRD
55//
56// In general 3 reconstruction itteration are performed:
57// 1. Find tracks - sequence TPC->ITS
58// 2. PropagateBack - sequence ITS->TPC->TRD -> Outer PID detectors
59// 3. Refit invward - sequence TRD->TPC->ITS
60// The current tracks are updated after each detector (see bellow).
61// In specical cases a track sanpshots are stored.
62//
63//
64// For some type of analysis (+visualization) track local parameters at
65// different position are neccesary. A snapshots during the track
66// propagation are created.
67// (See AliExternalTrackParam class for desctiption of variables and
68// functionality)
69// Snapshots:
70// a. Current parameters - class itself (AliExternalTrackParam)
71// Contributors: general case TRD->TPC->ITS
72// Preferable usage: Decission - primary or secondary track
73// NOTICE - By default the track parameters are stored at the DCA point
74// to the primary vertex. optimal for primary tracks,
75// far from optimal for secondary tracks.
76// b. Constrained parameters - Kalman information updated with
77// the Primary vertex information
78// Contributors: general case TRD->TPC->ITS
79// Preferable usage: Use only for tracks selected as primary
80// NOTICE - not real constrain - taken as additional measurement
81// with corresponding error
82// Function:
83// const AliExternalTrackParam *GetConstrainedParam() const {return fCp;}
84// c. Inner parameters - Track parameters at inner wall of the TPC
85// Contributors: general case TRD->TPC
86// function:
87// const AliExternalTrackParam *GetInnerParam() const { return fIp;}
88//
89// d. TPCinnerparam - contributors - TPC only
90// Contributors: TPC
91// Preferable usage: Requested for HBT study
92// (smaller correlations as using also ITS information)
93// NOTICE - the track parameters are propagated to the DCA to
94// to primary vertex
95// Optimal for primary, far from optimal for secondary tracks
96// Function:
97// const AliExternalTrackParam *GetTPCInnerParam() const {return fTPCInner;}
98//
99// e. Outer parameters -
100// Contributors- general case - ITS-> TPC -> TRD
101// The last point - Outer parameters radius is determined
102// e.a) Local inclination angle bigger than threshold -
103// Low momenta tracks
104// e.a) Catastrofic energy losss in material
105// e.b) Not further improvement (no space points)
106// Usage:
107// a.) Tracking: Starting parameter for Refit inward
108// b.) Visualization
109// c.) QA
110// NOTICE: Should be not used for the physic analysis
111// Function:
112// const AliExternalTrackParam *GetOuterParam() const { return fOp;}
113//
ae982df3 114//-----------------------------------------------------------------
115
e1e6896f 116#include <TMath.h>
49edfa08 117#include <TParticle.h>
c180f65d 118#include <TDatabasePDG.h>
ae982df3 119
49d13e89 120#include "AliESDVertex.h"
ae982df3 121#include "AliESDtrack.h"
95621324 122#include "AliESDEvent.h"
ae982df3 123#include "AliKalmanTrack.h"
4f6e22bd 124#include "AliVTrack.h"
5f7789fc 125#include "AliLog.h"
15e85efa 126#include "AliTrackPointArray.h"
0c19adf7 127#include "TPolyMarker3D.h"
ae982df3 128
129ClassImp(AliESDtrack)
130
562dd0b4 131void SetPIDValues(Double_t * dest, const Double_t * src, Int_t n) {
d27bbc79 132 // This function copies "n" PID weights from "scr" to "dest"
133 // and normalizes their sum to 1 thus producing conditional probabilities.
134 // The negative weights are set to 0.
135 // In case all the weights are non-positive they are replaced by
136 // uniform probabilities
137
138 if (n<=0) return;
139
140 Float_t uniform = 1./(Float_t)n;
141
142 Float_t sum = 0;
143 for (Int_t i=0; i<n; i++)
144 if (src[i]>=0) {
145 sum+=src[i];
146 dest[i] = src[i];
147 }
148 else {
149 dest[i] = 0;
150 }
151
152 if(sum>0)
153 for (Int_t i=0; i<n; i++) dest[i] /= sum;
154 else
155 for (Int_t i=0; i<n; i++) dest[i] = uniform;
156}
157
ae982df3 158//_______________________________________________________________________
159AliESDtrack::AliESDtrack() :
c9ec41e8 160 AliExternalTrackParam(),
562dd0b4 161 fCp(0),
162 fIp(0),
163 fTPCInner(0),
164 fOp(0),
c38d443f 165 fHMPIDp(0),
59c31692 166 fFriendTrack(NULL),
562dd0b4 167 fTPCClusterMap(159),//number of padrows
168 fTPCSharedMap(159),//number of padrows
90e48c0c 169 fFlags(0),
90e48c0c 170 fID(0),
562dd0b4 171 fLabel(0),
172 fITSLabel(0),
173 fTPCLabel(0),
174 fTRDLabel(0),
ab37ab1e 175 fTOFCalChannel(-1),
ce3f4882 176 fTOFindex(-1),
562dd0b4 177 fHMPIDqn(0),
81aa7a0d 178 fHMPIDcluIdx(-1),
f1cedef3 179 fCaloIndex(kEMCALNoMatch),
562dd0b4 180 fHMPIDtrkTheta(0),
181 fHMPIDtrkPhi(0),
182 fHMPIDsignal(0),
90e48c0c 183 fTrackLength(0),
d7ddf1e9 184 fdTPC(0),fzTPC(0),
185 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
436dfe39 186 fCchi2TPC(0),
49d13e89 187 fD(0),fZ(0),
188 fCdd(0),fCdz(0),fCzz(0),
562dd0b4 189 fCchi2(0),
90e48c0c 190 fITSchi2(0),
90e48c0c 191 fTPCchi2(0),
949840f6 192 fTPCchi2Iter1(0),
562dd0b4 193 fTRDchi2(0),
194 fTOFchi2(0),
195 fHMPIDchi2(0),
b5b2b4db 196 fGlobalChi2(0),
562dd0b4 197 fITSsignal(0),
90e48c0c 198 fTPCsignal(0),
e1d4c1b5 199 fTPCsignalS(0),
90e48c0c 200 fTRDsignal(0),
90e48c0c 201 fTRDQuality(0),
23d49657 202 fTRDBudget(0),
ab37ab1e 203 fTOFsignal(99999),
204 fTOFsignalToT(99999),
205 fTOFsignalRaw(99999),
206 fTOFsignalDz(999),
207 fTOFsignalDx(999),
208 fTOFdeltaBC(999),
209 fTOFl0l1(999),
f1cedef3 210 fCaloDx(0),
211 fCaloDz(0),
562dd0b4 212 fHMPIDtrkX(0),
213 fHMPIDtrkY(0),
214 fHMPIDmipX(0),
215 fHMPIDmipY(0),
216 fTPCncls(0),
217 fTPCnclsF(0),
218 fTPCsignalN(0),
949840f6 219 fTPCnclsIter1(0),
220 fTPCnclsFIter1(0),
562dd0b4 221 fITSncls(0),
222 fITSClusterMap(0),
25015f7a 223 fITSSharedMap(0),
562dd0b4 224 fTRDncls(0),
225 fTRDncls0(0),
ed15ef4f 226 fTRDntracklets(0),
6984f7c1 227 fTRDnSlices(0),
6dc21f57 228 fTRDslices(0x0),
95621324 229 fVertexID(-2),// -2 means an orphan track
230 fESDEvent(0)
ae982df3 231{
232 //
233 // The default ESD constructor
234 //
59c31692 235 if (!OnlineMode()) fFriendTrack=new AliESDfriendTrack();
236
6984f7c1 237 Int_t i;
6238d7a9 238 for (i=0; i<AliPID::kSPECIES; i++) {
4a78b8c5 239 fTrackTime[i]=0.;
562dd0b4 240 fR[i]=0.;
241 fITSr[i]=0.;
242 fTPCr[i]=0.;
243 fTRDr[i]=0.;
244 fTOFr[i]=0.;
245 fHMPIDr[i]=0.;
2bad268c 246 }
ac2f7574 247
ef7253ac 248 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
562dd0b4 249 for (i=0; i<3; i++) { fV0Indexes[i]=0;}
6984f7c1 250 for (i=0;i<kTRDnPlanes;i++) {
562dd0b4 251 fTRDTimBin[i]=0;
6d45eaef 252 }
1d4882da 253 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
562dd0b4 254 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
ab37ab1e 255 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
562dd0b4 256 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
89f1b176 257 for (i=0;i<12;i++) {fITSModule[i]=-1;}
c4d11b15 258}
259
59c31692 260bool AliESDtrack::fgkOnlineMode=false;
261
c4d11b15 262//_______________________________________________________________________
90e48c0c 263AliESDtrack::AliESDtrack(const AliESDtrack& track):
c9ec41e8 264 AliExternalTrackParam(track),
562dd0b4 265 fCp(0),
266 fIp(0),
267 fTPCInner(0),
268 fOp(0),
c38d443f 269 fHMPIDp(0),
562dd0b4 270 fFriendTrack(0),
271 fTPCClusterMap(track.fTPCClusterMap),
272 fTPCSharedMap(track.fTPCSharedMap),
90e48c0c 273 fFlags(track.fFlags),
90e48c0c 274 fID(track.fID),
562dd0b4 275 fLabel(track.fLabel),
276 fITSLabel(track.fITSLabel),
277 fTPCLabel(track.fTPCLabel),
278 fTRDLabel(track.fTRDLabel),
279 fTOFCalChannel(track.fTOFCalChannel),
280 fTOFindex(track.fTOFindex),
281 fHMPIDqn(track.fHMPIDqn),
282 fHMPIDcluIdx(track.fHMPIDcluIdx),
f1cedef3 283 fCaloIndex(track.fCaloIndex),
562dd0b4 284 fHMPIDtrkTheta(track.fHMPIDtrkTheta),
285 fHMPIDtrkPhi(track.fHMPIDtrkPhi),
286 fHMPIDsignal(track.fHMPIDsignal),
90e48c0c 287 fTrackLength(track.fTrackLength),
d7ddf1e9 288 fdTPC(track.fdTPC),fzTPC(track.fzTPC),
289 fCddTPC(track.fCddTPC),fCdzTPC(track.fCdzTPC),fCzzTPC(track.fCzzTPC),
436dfe39 290 fCchi2TPC(track.fCchi2TPC),
49d13e89 291 fD(track.fD),fZ(track.fZ),
292 fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
90e48c0c 293 fCchi2(track.fCchi2),
90e48c0c 294 fITSchi2(track.fITSchi2),
90e48c0c 295 fTPCchi2(track.fTPCchi2),
949840f6 296 fTPCchi2Iter1(track.fTPCchi2Iter1),
562dd0b4 297 fTRDchi2(track.fTRDchi2),
298 fTOFchi2(track.fTOFchi2),
299 fHMPIDchi2(track.fHMPIDchi2),
b5b2b4db 300 fGlobalChi2(track.fGlobalChi2),
562dd0b4 301 fITSsignal(track.fITSsignal),
90e48c0c 302 fTPCsignal(track.fTPCsignal),
e1d4c1b5 303 fTPCsignalS(track.fTPCsignalS),
90e48c0c 304 fTRDsignal(track.fTRDsignal),
90e48c0c 305 fTRDQuality(track.fTRDQuality),
23d49657 306 fTRDBudget(track.fTRDBudget),
90e48c0c 307 fTOFsignal(track.fTOFsignal),
85324138 308 fTOFsignalToT(track.fTOFsignalToT),
d321691a 309 fTOFsignalRaw(track.fTOFsignalRaw),
310 fTOFsignalDz(track.fTOFsignalDz),
a5d9ff0f 311 fTOFsignalDx(track.fTOFsignalDx),
d86081b1 312 fTOFdeltaBC(track.fTOFdeltaBC),
313 fTOFl0l1(track.fTOFl0l1),
f1cedef3 314 fCaloDx(track.fCaloDx),
315 fCaloDz(track.fCaloDz),
f4b3bbb7 316 fHMPIDtrkX(track.fHMPIDtrkX),
317 fHMPIDtrkY(track.fHMPIDtrkY),
318 fHMPIDmipX(track.fHMPIDmipX),
319 fHMPIDmipY(track.fHMPIDmipY),
562dd0b4 320 fTPCncls(track.fTPCncls),
321 fTPCnclsF(track.fTPCnclsF),
322 fTPCsignalN(track.fTPCsignalN),
949840f6 323 fTPCnclsIter1(track.fTPCnclsIter1),
324 fTPCnclsFIter1(track.fTPCnclsIter1),
562dd0b4 325 fITSncls(track.fITSncls),
326 fITSClusterMap(track.fITSClusterMap),
25015f7a 327 fITSSharedMap(track.fITSSharedMap),
562dd0b4 328 fTRDncls(track.fTRDncls),
329 fTRDncls0(track.fTRDncls0),
ed15ef4f 330 fTRDntracklets(track.fTRDntracklets),
6984f7c1 331 fTRDnSlices(track.fTRDnSlices),
6dc21f57 332 fTRDslices(0x0),
95621324 333 fVertexID(track.fVertexID),
334 fESDEvent(track.fESDEvent)
90e48c0c 335{
c4d11b15 336 //
337 //copy constructor
338 //
ef7253ac 339 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i]=track.fTrackTime[i];
340 for (Int_t i=0;i<AliPID::kSPECIES;i++) fR[i]=track.fR[i];
c4d11b15 341 //
304864ab 342 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=track.fITSr[i];
c4d11b15 343 //
304864ab 344 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=track.fTPCr[i];
1d4882da 345 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=track.fITSdEdxSamples[i];}
51ad6848 346 for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
347 for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
348 for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
c4d11b15 349 //
6984f7c1 350 for (Int_t i=0;i<kTRDnPlanes;i++) {
6d45eaef 351 fTRDTimBin[i]=track.fTRDTimBin[i];
eab5961e 352 }
6984f7c1 353
354 if (fTRDnSlices) {
355 fTRDslices=new Double32_t[fTRDnSlices];
356 for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=track.fTRDslices[i];
357 }
358
304864ab 359 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i]=track.fTRDr[i];
304864ab 360 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i]=track.fTOFr[i];
51ad6848 361 for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
362 for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
89f1b176 363 for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
f4b3bbb7 364 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i]=track.fHMPIDr[i];
c9ec41e8 365
366 if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
367 if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
4aeb9470 368 if (track.fTPCInner) fTPCInner=new AliExternalTrackParam(*track.fTPCInner);
c9ec41e8 369 if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
c38d443f 370 if (track.fHMPIDp) fHMPIDp=new AliExternalTrackParam(*track.fHMPIDp);
371
8497bca0 372 if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
ae982df3 373}
15e85efa 374
4f6e22bd 375//_______________________________________________________________________
376AliESDtrack::AliESDtrack(const AliVTrack *track) :
377 AliExternalTrackParam(track),
378 fCp(0),
379 fIp(0),
380 fTPCInner(0),
381 fOp(0),
c38d443f 382 fHMPIDp(0),
4f6e22bd 383 fFriendTrack(0),
384 fTPCClusterMap(159),//number of padrows
385 fTPCSharedMap(159),//number of padrows
386 fFlags(0),
387 fID(),
388 fLabel(0),
389 fITSLabel(0),
390 fTPCLabel(0),
391 fTRDLabel(0),
ab37ab1e 392 fTOFCalChannel(-1),
4f6e22bd 393 fTOFindex(-1),
394 fHMPIDqn(0),
81aa7a0d 395 fHMPIDcluIdx(-1),
f1cedef3 396 fCaloIndex(kEMCALNoMatch),
4f6e22bd 397 fHMPIDtrkTheta(0),
398 fHMPIDtrkPhi(0),
399 fHMPIDsignal(0),
400 fTrackLength(0),
401 fdTPC(0),fzTPC(0),
402 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
403 fCchi2TPC(0),
404 fD(0),fZ(0),
405 fCdd(0),fCdz(0),fCzz(0),
406 fCchi2(0),
407 fITSchi2(0),
408 fTPCchi2(0),
949840f6 409 fTPCchi2Iter1(0),
4f6e22bd 410 fTRDchi2(0),
411 fTOFchi2(0),
412 fHMPIDchi2(0),
b5b2b4db 413 fGlobalChi2(0),
4f6e22bd 414 fITSsignal(0),
415 fTPCsignal(0),
416 fTPCsignalS(0),
417 fTRDsignal(0),
418 fTRDQuality(0),
419 fTRDBudget(0),
ab37ab1e 420 fTOFsignal(99999),
421 fTOFsignalToT(99999),
422 fTOFsignalRaw(99999),
423 fTOFsignalDz(999),
424 fTOFsignalDx(999),
425 fTOFdeltaBC(999),
426 fTOFl0l1(999),
f1cedef3 427 fCaloDx(0),
428 fCaloDz(0),
4f6e22bd 429 fHMPIDtrkX(0),
430 fHMPIDtrkY(0),
431 fHMPIDmipX(0),
432 fHMPIDmipY(0),
433 fTPCncls(0),
434 fTPCnclsF(0),
435 fTPCsignalN(0),
949840f6 436 fTPCnclsIter1(0),
437 fTPCnclsFIter1(0),
4f6e22bd 438 fITSncls(0),
439 fITSClusterMap(0),
25015f7a 440 fITSSharedMap(0),
4f6e22bd 441 fTRDncls(0),
442 fTRDncls0(0),
ed15ef4f 443 fTRDntracklets(0),
4f6e22bd 444 fTRDnSlices(0),
6dc21f57 445 fTRDslices(0x0),
95621324 446 fVertexID(-2), // -2 means an orphan track
447 fESDEvent(0)
4f6e22bd 448{
449 //
610e3088 450 // ESD track from AliVTrack.
451 // This is not a copy constructor !
4f6e22bd 452 //
453
610e3088 454 if (track->InheritsFrom("AliExternalTrackParam")) {
455 AliError("This is not a copy constructor. Use AliESDtrack(const AliESDtrack &) !");
456 AliWarning("Calling the default constructor...");
457 AliESDtrack();
458 return;
459 }
460
4f6e22bd 461 // Reset all the arrays
462 Int_t i;
463 for (i=0; i<AliPID::kSPECIES; i++) {
464 fTrackTime[i]=0.;
465 fR[i]=0.;
466 fITSr[i]=0.;
467 fTPCr[i]=0.;
468 fTRDr[i]=0.;
469 fTOFr[i]=0.;
470 fHMPIDr[i]=0.;
471 }
472
473 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
474 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
475 for (i=0;i<kTRDnPlanes;i++) {
476 fTRDTimBin[i]=0;
477 }
1d4882da 478 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
4f6e22bd 479 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
ab37ab1e 480 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
4f6e22bd 481 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
482 for (i=0;i<12;i++) {fITSModule[i]=-1;}
483
484 // Set the ID
485 SetID(track->GetID());
486
487 // Set ITS cluster map
488 fITSClusterMap=track->GetITSClusterMap();
25015f7a 489 fITSSharedMap=0;
4f6e22bd 490
d577eec9 491 fITSncls=0;
492 for(i=0; i<6; i++) {
493 if(HasPointOnITSLayer(i)) fITSncls++;
494 }
495
07cc7a48 496 // Set TPC ncls
497 fTPCncls=track->GetTPCNcls();
498
499
4f6e22bd 500 // Set the combined PID
501 const Double_t *pid = track->PID();
67be2d29 502 if(pid){
503 for (i=0; i<AliPID::kSPECIES; i++) fR[i]=pid[i];
504 }
4f6e22bd 505 // AliESD track label
506 SetLabel(track->GetLabel());
39ca41b3 507 // Set the status
508 SetStatus(track->GetStatus());
4f6e22bd 509}
510
49edfa08 511//_______________________________________________________________________
512AliESDtrack::AliESDtrack(TParticle * part) :
513 AliExternalTrackParam(),
562dd0b4 514 fCp(0),
515 fIp(0),
516 fTPCInner(0),
517 fOp(0),
c38d443f 518 fHMPIDp(0),
562dd0b4 519 fFriendTrack(0),
520 fTPCClusterMap(159),//number of padrows
521 fTPCSharedMap(159),//number of padrows
49edfa08 522 fFlags(0),
49edfa08 523 fID(0),
562dd0b4 524 fLabel(0),
525 fITSLabel(0),
526 fTPCLabel(0),
527 fTRDLabel(0),
ab37ab1e 528 fTOFCalChannel(-1),
ce3f4882 529 fTOFindex(-1),
562dd0b4 530 fHMPIDqn(0),
81aa7a0d 531 fHMPIDcluIdx(-1),
f1cedef3 532 fCaloIndex(kEMCALNoMatch),
562dd0b4 533 fHMPIDtrkTheta(0),
534 fHMPIDtrkPhi(0),
535 fHMPIDsignal(0),
49edfa08 536 fTrackLength(0),
d7ddf1e9 537 fdTPC(0),fzTPC(0),
538 fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
436dfe39 539 fCchi2TPC(0),
49edfa08 540 fD(0),fZ(0),
541 fCdd(0),fCdz(0),fCzz(0),
562dd0b4 542 fCchi2(0),
49edfa08 543 fITSchi2(0),
49edfa08 544 fTPCchi2(0),
949840f6 545 fTPCchi2Iter1(0),
562dd0b4 546 fTRDchi2(0),
547 fTOFchi2(0),
548 fHMPIDchi2(0),
b5b2b4db 549 fGlobalChi2(0),
562dd0b4 550 fITSsignal(0),
49edfa08 551 fTPCsignal(0),
49edfa08 552 fTPCsignalS(0),
49edfa08 553 fTRDsignal(0),
49edfa08 554 fTRDQuality(0),
555 fTRDBudget(0),
ab37ab1e 556 fTOFsignal(99999),
557 fTOFsignalToT(99999),
558 fTOFsignalRaw(99999),
559 fTOFsignalDz(999),
560 fTOFsignalDx(999),
561 fTOFdeltaBC(999),
562 fTOFl0l1(999),
f1cedef3 563 fCaloDx(0),
564 fCaloDz(0),
562dd0b4 565 fHMPIDtrkX(0),
566 fHMPIDtrkY(0),
567 fHMPIDmipX(0),
568 fHMPIDmipY(0),
569 fTPCncls(0),
570 fTPCnclsF(0),
571 fTPCsignalN(0),
949840f6 572 fTPCnclsIter1(0),
573 fTPCnclsFIter1(0),
562dd0b4 574 fITSncls(0),
575 fITSClusterMap(0),
25015f7a 576 fITSSharedMap(0),
562dd0b4 577 fTRDncls(0),
578 fTRDncls0(0),
ed15ef4f 579 fTRDntracklets(0),
6984f7c1 580 fTRDnSlices(0),
6dc21f57 581 fTRDslices(0x0),
95621324 582 fVertexID(-2), // -2 means an orphan track
583 fESDEvent(0)
49edfa08 584{
585 //
586 // ESD track from TParticle
587 //
588
589 // Reset all the arrays
6984f7c1 590 Int_t i;
49edfa08 591 for (i=0; i<AliPID::kSPECIES; i++) {
592 fTrackTime[i]=0.;
593 fR[i]=0.;
594 fITSr[i]=0.;
595 fTPCr[i]=0.;
596 fTRDr[i]=0.;
597 fTOFr[i]=0.;
f4b3bbb7 598 fHMPIDr[i]=0.;
49edfa08 599 }
600
601 for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
602 for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
6984f7c1 603 for (i=0;i<kTRDnPlanes;i++) {
562dd0b4 604 fTRDTimBin[i]=0;
49edfa08 605 }
1d4882da 606 for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
562dd0b4 607 for (i=0;i<4;i++) {fTPCPoints[i]=0;}
ab37ab1e 608 for (i=0;i<3;i++) {fTOFLabel[i]=-1;}
562dd0b4 609 for (i=0;i<10;i++) {fTOFInfo[i]=0;}
89f1b176 610 for (i=0;i<12;i++) {fITSModule[i]=-1;}
49edfa08 611
612 // Calculate the AliExternalTrackParam content
613
614 Double_t xref;
615 Double_t alpha;
616 Double_t param[5];
617 Double_t covar[15];
618
619 // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
620 alpha = part->Phi()*180./TMath::Pi();
621 if (alpha<0) alpha+= 360.;
622 if (alpha>360) alpha -= 360.;
623
624 Int_t sector = (Int_t)(alpha/20.);
625 alpha = 10. + 20.*sector;
626 alpha /= 180;
627 alpha *= TMath::Pi();
628
629 // Covariance matrix: no errors, the parameters are exact
6c27b212 630 for (i=0; i<15; i++) covar[i]=0.;
49edfa08 631
632 // Get the vertex of origin and the momentum
633 TVector3 ver(part->Vx(),part->Vy(),part->Vz());
634 TVector3 mom(part->Px(),part->Py(),part->Pz());
635
636 // Rotate to the local coordinate system (TPC sector)
637 ver.RotateZ(-alpha);
638 mom.RotateZ(-alpha);
639
640 // X of the referense plane
641 xref = ver.X();
642
643 Int_t pdgCode = part->GetPdgCode();
644
645 Double_t charge =
646 TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
647
648 param[0] = ver.Y();
649 param[1] = ver.Z();
650 param[2] = TMath::Sin(mom.Phi());
651 param[3] = mom.Pz()/mom.Pt();
652 param[4] = TMath::Sign(1/mom.Pt(),charge);
653
654 // Set AliExternalTrackParam
655 Set(xref, alpha, param, covar);
656
657 // Set the PID
658 Int_t indexPID = 99;
659
660 switch (TMath::Abs(pdgCode)) {
661
662 case 11: // electron
663 indexPID = 0;
664 break;
665
666 case 13: // muon
667 indexPID = 1;
668 break;
669
670 case 211: // pion
671 indexPID = 2;
672 break;
673
674 case 321: // kaon
675 indexPID = 3;
676 break;
677
678 case 2212: // proton
679 indexPID = 4;
680 break;
681
682 default:
683 break;
684 }
685
686 // If the particle is not e,mu,pi,K or p the PID probabilities are set to 0
687 if (indexPID < AliPID::kSPECIES) {
688 fR[indexPID]=1.;
689 fITSr[indexPID]=1.;
690 fTPCr[indexPID]=1.;
691 fTRDr[indexPID]=1.;
692 fTOFr[indexPID]=1.;
f4b3bbb7 693 fHMPIDr[indexPID]=1.;
49edfa08 694
695 }
696 // AliESD track label
697 SetLabel(part->GetUniqueID());
698
699}
700
c4d11b15 701//_______________________________________________________________________
702AliESDtrack::~AliESDtrack(){
703 //
704 // This is destructor according Coding Conventrions
705 //
706 //printf("Delete track\n");
c9ec41e8 707 delete fIp;
4aeb9470 708 delete fTPCInner;
c9ec41e8 709 delete fOp;
c38d443f 710 delete fHMPIDp;
c9ec41e8 711 delete fCp;
59c31692 712 if (fFriendTrack) delete fFriendTrack;
713 fFriendTrack=NULL;
6984f7c1 714 if(fTRDnSlices)
715 delete[] fTRDslices;
c4d11b15 716}
ae982df3 717
732a24fe 718AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source){
719
720
721 if(&source == this) return *this;
722 AliExternalTrackParam::operator=(source);
723
724
725 if(source.fCp){
726 // we have the trackparam: assign or copy construct
727 if(fCp)*fCp = *source.fCp;
728 else fCp = new AliExternalTrackParam(*source.fCp);
729 }
730 else{
731 // no track param delete the old one
732 if(fCp)delete fCp;
733 fCp = 0;
734 }
735
736 if(source.fIp){
737 // we have the trackparam: assign or copy construct
738 if(fIp)*fIp = *source.fIp;
739 else fIp = new AliExternalTrackParam(*source.fIp);
740 }
741 else{
742 // no track param delete the old one
743 if(fIp)delete fIp;
744 fIp = 0;
745 }
746
747
748 if(source.fTPCInner){
749 // we have the trackparam: assign or copy construct
750 if(fTPCInner) *fTPCInner = *source.fTPCInner;
751 else fTPCInner = new AliExternalTrackParam(*source.fTPCInner);
752 }
753 else{
754 // no track param delete the old one
755 if(fTPCInner)delete fTPCInner;
756 fTPCInner = 0;
757 }
758
759
760 if(source.fOp){
761 // we have the trackparam: assign or copy construct
762 if(fOp) *fOp = *source.fOp;
763 else fOp = new AliExternalTrackParam(*source.fOp);
764 }
765 else{
766 // no track param delete the old one
767 if(fOp)delete fOp;
768 fOp = 0;
769 }
770
c38d443f 771
772 if(source.fHMPIDp){
773 // we have the trackparam: assign or copy construct
b01794e9 774 if(fHMPIDp) *fHMPIDp = *source.fHMPIDp;
c38d443f 775 else fHMPIDp = new AliExternalTrackParam(*source.fHMPIDp);
776 }
777 else{
778 // no track param delete the old one
779 if(fHMPIDp)delete fHMPIDp;
780 fHMPIDp = 0;
781 }
782
783
732a24fe 784 // copy also the friend track
785 // use copy constructor
786 if(source.fFriendTrack){
787 // we have the trackparam: assign or copy construct
788 delete fFriendTrack; fFriendTrack=new AliESDfriendTrack(*source.fFriendTrack);
789 }
790 else{
791 // no track param delete the old one
792 delete fFriendTrack; fFriendTrack= 0;
793 }
794
795 fTPCClusterMap = source.fTPCClusterMap;
796 fTPCSharedMap = source.fTPCSharedMap;
797 // the simple stuff
798 fFlags = source.fFlags;
799 fID = source.fID;
800 fLabel = source.fLabel;
801 fITSLabel = source.fITSLabel;
802 for(int i = 0; i< 12;++i){
803 fITSModule[i] = source.fITSModule[i];
804 }
805 fTPCLabel = source.fTPCLabel;
806 fTRDLabel = source.fTRDLabel;
807 for(int i = 0; i< 3;++i){
808 fTOFLabel[i] = source.fTOFLabel[i];
809 }
810 fTOFCalChannel = source.fTOFCalChannel;
811 fTOFindex = source.fTOFindex;
812 fHMPIDqn = source.fHMPIDqn;
813 fHMPIDcluIdx = source.fHMPIDcluIdx;
f1cedef3 814 fCaloIndex = source.fCaloIndex;
732a24fe 815
816 for(int i = 0; i< 3;++i){
817 fKinkIndexes[i] = source.fKinkIndexes[i];
818 fV0Indexes[i] = source.fV0Indexes[i];
819 }
820
821 for(int i = 0; i< AliPID::kSPECIES;++i){
822 fR[i] = source.fR[i];
823 fITSr[i] = source.fITSr[i];
824 fTPCr[i] = source.fTPCr[i];
825 fTRDr[i] = source.fTRDr[i];
826 fTOFr[i] = source.fTOFr[i];
827 fHMPIDr[i] = source.fHMPIDr[i];
828 fTrackTime[i] = source.fTrackTime[i];
829 }
830
831 fHMPIDtrkTheta = source.fHMPIDtrkTheta;
832 fHMPIDtrkPhi = source.fHMPIDtrkPhi;
833 fHMPIDsignal = source.fHMPIDsignal;
834
835
836 fTrackLength = source. fTrackLength;
d7ddf1e9 837 fdTPC = source.fdTPC;
838 fzTPC = source.fzTPC;
839 fCddTPC = source.fCddTPC;
840 fCdzTPC = source.fCdzTPC;
841 fCzzTPC = source.fCzzTPC;
436dfe39 842 fCchi2TPC = source.fCchi2TPC;
843
732a24fe 844 fD = source.fD;
845 fZ = source.fZ;
846 fCdd = source.fCdd;
847 fCdz = source.fCdz;
848 fCzz = source.fCzz;
732a24fe 849 fCchi2 = source.fCchi2;
436dfe39 850
732a24fe 851 fITSchi2 = source.fITSchi2;
852 fTPCchi2 = source.fTPCchi2;
949840f6 853 fTPCchi2Iter1 = source.fTPCchi2Iter1;
732a24fe 854 fTRDchi2 = source.fTRDchi2;
855 fTOFchi2 = source.fTOFchi2;
856 fHMPIDchi2 = source.fHMPIDchi2;
857
b5b2b4db 858 fGlobalChi2 = source.fGlobalChi2;
732a24fe 859
860 fITSsignal = source.fITSsignal;
1d4882da 861 for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=source.fITSdEdxSamples[i];}
732a24fe 862 fTPCsignal = source.fTPCsignal;
863 fTPCsignalS = source.fTPCsignalS;
864 for(int i = 0; i< 4;++i){
865 fTPCPoints[i] = source.fTPCPoints[i];
866 }
867 fTRDsignal = source.fTRDsignal;
868
6984f7c1 869 for(int i = 0;i < kTRDnPlanes;++i){
732a24fe 870 fTRDTimBin[i] = source.fTRDTimBin[i];
732a24fe 871 }
6984f7c1 872
873 if(fTRDnSlices)
874 delete[] fTRDslices;
875 fTRDslices=0;
876 fTRDnSlices=source.fTRDnSlices;
877 if (fTRDnSlices) {
878 fTRDslices=new Double32_t[fTRDnSlices];
879 for(int j = 0;j < fTRDnSlices;++j) fTRDslices[j] = source.fTRDslices[j];
880 }
881
732a24fe 882 fTRDQuality = source.fTRDQuality;
883 fTRDBudget = source.fTRDBudget;
884 fTOFsignal = source.fTOFsignal;
885 fTOFsignalToT = source.fTOFsignalToT;
886 fTOFsignalRaw = source.fTOFsignalRaw;
887 fTOFsignalDz = source.fTOFsignalDz;
a5d9ff0f 888 fTOFsignalDx = source.fTOFsignalDx;
d86081b1 889 fTOFdeltaBC = source.fTOFdeltaBC;
890 fTOFl0l1 = source.fTOFl0l1;
891
732a24fe 892 for(int i = 0;i<10;++i){
893 fTOFInfo[i] = source.fTOFInfo[i];
894 }
895
896 fHMPIDtrkX = source.fHMPIDtrkX;
897 fHMPIDtrkY = source.fHMPIDtrkY;
898 fHMPIDmipX = source.fHMPIDmipX;
899 fHMPIDmipY = source.fHMPIDmipY;
900
901 fTPCncls = source.fTPCncls;
902 fTPCnclsF = source.fTPCnclsF;
903 fTPCsignalN = source.fTPCsignalN;
949840f6 904 fTPCnclsIter1 = source.fTPCnclsIter1;
905 fTPCnclsFIter1 = source.fTPCnclsFIter1;
732a24fe 906
907 fITSncls = source.fITSncls;
908 fITSClusterMap = source.fITSClusterMap;
25015f7a 909 fITSSharedMap = source.fITSSharedMap;
732a24fe 910 fTRDncls = source.fTRDncls;
911 fTRDncls0 = source.fTRDncls0;
ed15ef4f 912 fTRDntracklets = source.fTRDntracklets;
6dc21f57 913 fVertexID = source.fVertexID;
732a24fe 914 return *this;
915}
916
917
918
919void AliESDtrack::Copy(TObject &obj) const {
920
921 // this overwrites the virtual TOBject::Copy()
922 // to allow run time copying without casting
923 // in AliESDEvent
924
925 if(this==&obj)return;
926 AliESDtrack *robj = dynamic_cast<AliESDtrack*>(&obj);
927 if(!robj)return; // not an AliESDtrack
928 *robj = *this;
929
930}
931
932
933
00dce61a 934void AliESDtrack::AddCalibObject(TObject * object){
935 //
936 // add calib object to the list
937 //
938 if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
59c31692 939 if (!fFriendTrack) return;
00dce61a 940 fFriendTrack->AddCalibObject(object);
941}
942
943TObject * AliESDtrack::GetCalibObject(Int_t index){
944 //
945 // return calib objct at given position
946 //
947 if (!fFriendTrack) return 0;
948 return fFriendTrack->GetCalibObject(index);
949}
950
951
f12d42ce 952Bool_t AliESDtrack::FillTPCOnlyTrack(AliESDtrack &track){
b9ca886f 953
954 // Fills the information of the TPC-only first reconstruction pass
955 // into the passed ESDtrack object. For consistency fTPCInner is also filled
956 // again
957
5b305f70 958
959
960 // For data produced before r26675
961 // RelateToVertexTPC was not properly called during reco
962 // so you'll have to call it again, before FillTPCOnlyTrack
963 // Float_t p[2],cov[3];
964 // track->GetImpactParametersTPC(p,cov);
965 // if(p[0]==0&&p[1]==0) // <- Default values
966 // track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
967
968
b9ca886f 969 if(!fTPCInner)return kFALSE;
970
971 // fill the TPC track params to the global track parameters
972 track.Set(fTPCInner->GetX(),fTPCInner->GetAlpha(),fTPCInner->GetParameter(),fTPCInner->GetCovariance());
973 track.fD = fdTPC;
974 track.fZ = fzTPC;
975 track.fCdd = fCddTPC;
976 track.fCdz = fCdzTPC;
977 track.fCzz = fCzzTPC;
978
67ed91d3 979 // copy the inner params
980 if(track.fIp) *track.fIp = *fIp;
981 else track.fIp = new AliExternalTrackParam(*fIp);
982
b9ca886f 983 // copy the TPCinner parameters
984 if(track.fTPCInner) *track.fTPCInner = *fTPCInner;
985 else track.fTPCInner = new AliExternalTrackParam(*fTPCInner);
986 track.fdTPC = fdTPC;
987 track.fzTPC = fzTPC;
988 track.fCddTPC = fCddTPC;
989 track.fCdzTPC = fCdzTPC;
990 track.fCzzTPC = fCzzTPC;
436dfe39 991 track.fCchi2TPC = fCchi2TPC;
b9ca886f 992
b9ca886f 993 // copy all other TPC specific parameters
994
995 // replace label by TPC label
996 track.fLabel = fTPCLabel;
997 track.fTPCLabel = fTPCLabel;
998
999 track.fTPCchi2 = fTPCchi2;
949840f6 1000 track.fTPCchi2Iter1 = fTPCchi2Iter1;
b9ca886f 1001 track.fTPCsignal = fTPCsignal;
1002 track.fTPCsignalS = fTPCsignalS;
1003 for(int i = 0;i<4;++i)track.fTPCPoints[i] = fTPCPoints[i];
1004
1005 track.fTPCncls = fTPCncls;
1006 track.fTPCnclsF = fTPCnclsF;
1007 track.fTPCsignalN = fTPCsignalN;
949840f6 1008 track.fTPCnclsIter1 = fTPCnclsIter1;
1009 track.fTPCnclsFIter1 = fTPCnclsFIter1;
b9ca886f 1010
1011 // PID
1012 for(int i=0;i<AliPID::kSPECIES;++i){
1013 track.fTPCr[i] = fTPCr[i];
1014 // combined PID is TPC only!
1015 track.fR[i] = fTPCr[i];
1016 }
1017 track.fTPCClusterMap = fTPCClusterMap;
1018 track.fTPCSharedMap = fTPCSharedMap;
1019
1020
1021 // reset the flags
1022 track.fFlags = kTPCin;
1023 track.fID = fID;
1024
b1cfce51 1025 track.fFlags |= fFlags & kTPCpid; //copy the TPCpid status flag
b9ca886f 1026
1027 for (Int_t i=0;i<3;i++) track.fKinkIndexes[i] = fKinkIndexes[i];
1028
1029 return kTRUE;
1030
1031}
1032
9559cbc4 1033//_______________________________________________________________________
1034void AliESDtrack::MakeMiniESDtrack(){
1035 // Resets everything except
1036 // fFlags: Reconstruction status flags
1037 // fLabel: Track label
1038 // fID: Unique ID of the track
d7ddf1e9 1039 // Impact parameter information
9559cbc4 1040 // fR[AliPID::kSPECIES]: combined "detector response probability"
8497bca0 1041 // Running track parameters in the base class (AliExternalTrackParam)
9559cbc4 1042
1043 fTrackLength = 0;
562dd0b4 1044
9559cbc4 1045 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTrackTime[i] = 0;
9559cbc4 1046
1047 // Reset track parameters constrained to the primary vertex
562dd0b4 1048 delete fCp;fCp = 0;
9559cbc4 1049
1050 // Reset track parameters at the inner wall of TPC
562dd0b4 1051 delete fIp;fIp = 0;
1052 delete fTPCInner;fTPCInner=0;
9559cbc4 1053 // Reset track parameters at the inner wall of the TRD
562dd0b4 1054 delete fOp;fOp = 0;
c38d443f 1055 // Reset track parameters at the HMPID
1056 delete fHMPIDp;fHMPIDp = 0;
562dd0b4 1057
9559cbc4 1058
1059 // Reset ITS track related information
1060 fITSchi2 = 0;
9559cbc4 1061 fITSncls = 0;
62665e7f 1062 fITSClusterMap=0;
25015f7a 1063 fITSSharedMap=0;
9559cbc4 1064 fITSsignal = 0;
1d4882da 1065 for (Int_t i=0;i<4;i++) fITSdEdxSamples[i] = 0.;
ef7253ac 1066 for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
9559cbc4 1067 fITSLabel = 0;
9559cbc4 1068
1069 // Reset TPC related track information
1070 fTPCchi2 = 0;
949840f6 1071 fTPCchi2Iter1 = 0;
9559cbc4 1072 fTPCncls = 0;
e1d4c1b5 1073 fTPCnclsF = 0;
949840f6 1074 fTPCnclsIter1 = 0;
1075 fTPCnclsFIter1 = 0;
9559cbc4 1076 fTPCClusterMap = 0;
eb7f6854 1077 fTPCSharedMap = 0;
9559cbc4 1078 fTPCsignal= 0;
e1d4c1b5 1079 fTPCsignalS= 0;
1080 fTPCsignalN= 0;
9559cbc4 1081 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0;
1082 fTPCLabel=0;
1083 for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
1084 for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
1085 for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
1086
1087 // Reset TRD related track information
1088 fTRDchi2 = 0;
1089 fTRDncls = 0;
1090 fTRDncls0 = 0;
9559cbc4 1091 fTRDsignal = 0;
6984f7c1 1092 for (Int_t i=0;i<kTRDnPlanes;i++) {
6d45eaef 1093 fTRDTimBin[i] = 0;
9559cbc4 1094 }
1095 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
1096 fTRDLabel = 0;
9559cbc4 1097 fTRDQuality = 0;
ed15ef4f 1098 fTRDntracklets = 0;
6984f7c1 1099 if(fTRDnSlices)
1100 delete[] fTRDslices;
1101 fTRDslices=0x0;
1102 fTRDnSlices=0;
23d49657 1103 fTRDBudget = 0;
9559cbc4 1104
1105 // Reset TOF related track information
1106 fTOFchi2 = 0;
ce3f4882 1107 fTOFindex = -1;
ab37ab1e 1108 fTOFsignal = 99999;
1109 fTOFCalChannel = -1;
1110 fTOFsignalToT = 99999;
1111 fTOFsignalRaw = 99999;
1112 fTOFsignalDz = 999;
1113 fTOFsignalDx = 999;
1114 fTOFdeltaBC = 999;
1115 fTOFl0l1 = 999;
9559cbc4 1116 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
ab37ab1e 1117 for (Int_t i=0;i<3;i++) fTOFLabel[i] = -1;
9559cbc4 1118 for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
1119
f4b3bbb7 1120 // Reset HMPID related track information
1121 fHMPIDchi2 = 0;
562dd0b4 1122 fHMPIDqn = 0;
81aa7a0d 1123 fHMPIDcluIdx = -1;
f4b3bbb7 1124 fHMPIDsignal = 0;
1125 for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
562dd0b4 1126 fHMPIDtrkTheta = 0;
1127 fHMPIDtrkPhi = 0;
1128 fHMPIDtrkX = 0;
1129 fHMPIDtrkY = 0;
1130 fHMPIDmipX = 0;
1131 fHMPIDmipY = 0;
f1cedef3 1132 fCaloIndex = kEMCALNoMatch;
9559cbc4 1133
b5b2b4db 1134 // reset global track chi2
1135 fGlobalChi2 = 0;
1136
6dc21f57 1137 fVertexID = -2; // an orphan track
1138
15e85efa 1139 delete fFriendTrack; fFriendTrack = 0;
9559cbc4 1140}
ec729fb0 1141
bf7942ff 1142//_______________________________________________________________________
1143Int_t AliESDtrack::GetPID() const
1144{
1145 // Returns the particle most probable id
ec729fb0 1146 Int_t i;
bf7942ff 1147 for (i=0; i<AliPID::kSPECIES-1; i++) if (fR[i] != fR[i+1]) break;
1148 //
1149 if (i == AliPID::kSPECIES-1) return AliPID::kPion; // If all the probabilities are equal, return the pion mass
1150 //
ae982df3 1151 Float_t max=0.;
1152 Int_t k=-1;
bf7942ff 1153 for (i=0; i<AliPID::kSPECIES; i++) if (fR[i]>max) {k=i; max=fR[i];}
1154 //
db3989b3 1155 if (k==0) { // dE/dx "crossing points" in the TPC
bf7942ff 1156 Double_t p=GetP();
1157 if ((p>0.38)&&(p<0.48))
1158 if (fR[0]<fR[3]*10.) return AliPID::kKaon;
1159 if ((p>0.75)&&(p<0.85))
1160 if (fR[0]<fR[4]*10.) return AliPID::kProton;
1161 return AliPID::kElectron;
db3989b3 1162 }
bf7942ff 1163 if (k==1) return AliPID::kMuon;
1164 if (k==2||k==-1) return AliPID::kPion;
1165 if (k==3) return AliPID::kKaon;
1166 if (k==4) return AliPID::kProton;
1167 AliWarning("Undefined PID !");
1168 return AliPID::kPion;
1169}
1170
1171//_______________________________________________________________________
a512bf97 1172Int_t AliESDtrack::GetTOFBunchCrossing(Double_t b) const
bf7942ff 1173{
1174 // Returns the number of bunch crossings after trigger (assuming 25ns spacing)
bf7942ff 1175 const double kSpacing = 25e3; // min interbanch spacing
1176 const double kShift = 0;
1177 Int_t bcid = -1; // defualt one
a512bf97 1178 if (!IsOn(kTOFout) || !IsOn(kESDpid)) return bcid; // no info
1179 //
1180 double tdif = fTOFsignal;
1181 if (IsOn(kTIME)) { // integrated time info is there
1182 int pid = GetPID();
1183 tdif -= fTrackTime[pid];
1184 }
1185 else { // assume integrated time info from TOF radius and momentum
1186 const double kRTOF = 385.;
1187 const double kCSpeed = 3.e-2; // cm/ps
1188 double p = GetP();
1189 if (p<0.01) return bcid;
1190 double m = GetMass();
1191 double curv = GetC(b);
1192 double path = TMath::Abs(curv)>kAlmost0 ? // account for curvature
1193 2./curv*TMath::ASin(kRTOF*curv/2.)*TMath::Sqrt(1.+GetTgl()*GetTgl()) : kRTOF;
1194 tdif -= path/kCSpeed*TMath::Sqrt(1.+m*m/(p*p));
1195 }
bf7942ff 1196 bcid = TMath::Nint((tdif - kShift)/kSpacing);
1197 return bcid;
ae982df3 1198}
1199
6b5b49c9 1200//______________________________________________________________________________
1201Double_t AliESDtrack::M() const
1202{
2850a7f3 1203 // Returns the assumed mass
1204 // (the pion mass, if the particle can't be identified properly).
9be82450 1205 static Bool_t printerr=kTRUE;
1206 if (printerr) {
1207 AliWarning("WARNING !!! ... THIS WILL BE PRINTED JUST ONCE !!!");
1208 printerr = kFALSE;
1209 AliWarning("This is the ESD mass. Use it with care !");
1210 }
6b5b49c9 1211 return GetMass();
1212}
1213
aad8d435 1214//______________________________________________________________________________
1215Double_t AliESDtrack::E() const
1216{
1217 // Returns the energy of the particle given its assumed mass.
1218 // Assumes the pion mass if the particle can't be identified properly.
1219
1220 Double_t m = M();
1221 Double_t p = P();
1222 return TMath::Sqrt(p*p + m*m);
1223}
1224
1225//______________________________________________________________________________
1226Double_t AliESDtrack::Y() const
1227{
1228 // Returns the rapidity of a particle given its assumed mass.
1229 // Assumes the pion mass if the particle can't be identified properly.
1230
1231 Double_t e = E();
1232 Double_t pz = Pz();
e03e4544 1233 if (e != TMath::Abs(pz)) { // energy was not equal to pz
aad8d435 1234 return 0.5*TMath::Log((e+pz)/(e-pz));
1235 } else { // energy was equal to pz
1236 return -999.;
1237 }
1238}
1239
ae982df3 1240//_______________________________________________________________________
c9ec41e8 1241Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
ae982df3 1242 //
1243 // This function updates track's running parameters
1244 //
15614b8b 1245 Bool_t rc=kTRUE;
1246
9b859005 1247 SetStatus(flags);
1248 fLabel=t->GetLabel();
1249
1250 if (t->IsStartedTimeIntegral()) {
1251 SetStatus(kTIME);
1252 Double_t times[10];t->GetIntegratedTimes(times); SetIntegratedTimes(times);
1253 SetIntegratedLength(t->GetIntegratedLength());
1254 }
1255
6c94f330 1256 Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
59c31692 1257 if (fFriendTrack) {
ded25cc6 1258 if (flags==kITSout) fFriendTrack->SetITSOut(*t);
1259 if (flags==kTPCout) fFriendTrack->SetTPCOut(*t);
fae4c212 1260 if (flags==kTRDrefit) fFriendTrack->SetTRDIn(*t);
59c31692 1261 }
e1d4c1b5 1262
ae982df3 1263 switch (flags) {
ad2f1f2b 1264
9b859005 1265 case kITSin: case kITSout: case kITSrefit:
6d3a7bbf 1266 {
48704648 1267 fITSClusterMap=0;
ae982df3 1268 fITSncls=t->GetNumberOfClusters();
59c31692 1269 if (fFriendTrack) {
6d3a7bbf 1270 Int_t* indexITS = new Int_t[AliESDfriendTrack::kMaxITScluster];
62665e7f 1271 for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
6d3a7bbf 1272 indexITS[i]=t->GetClusterIndex(i);
1273
62665e7f 1274 if (i<fITSncls) {
6d3a7bbf 1275 Int_t l=(indexITS[i] & 0xf0000000) >> 28;
62665e7f 1276 SETBIT(fITSClusterMap,l);
1277 }
1278 }
6d3a7bbf 1279 fFriendTrack->SetITSIndices(indexITS,AliESDfriendTrack::kMaxITScluster);
1280 delete [] indexITS;
59c31692 1281 }
6d3a7bbf 1282
ae982df3 1283 fITSchi2=t->GetChi2();
ae982df3 1284 fITSsignal=t->GetPIDsignal();
6e5b1b04 1285 fITSLabel = t->GetLabel();
57483eb1 1286 // keep in fOp the parameters outside ITS for ITS stand-alone tracks
1287 if (flags==kITSout) {
1288 if (!fOp) fOp=new AliExternalTrackParam(*t);
1289 else
1290 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
ded25cc6 1291 }
6d3a7bbf 1292 }
ae982df3 1293 break;
ad2f1f2b 1294
9b859005 1295 case kTPCin: case kTPCrefit:
6d3a7bbf 1296 {
6e5b1b04 1297 fTPCLabel = t->GetLabel();
949840f6 1298 if (flags==kTPCin) {
1299 fTPCInner=new AliExternalTrackParam(*t);
1300 fTPCnclsIter1=t->GetNumberOfClusters();
1301 fTPCchi2Iter1=t->GetChi2();
1302 }
c9ec41e8 1303 if (!fIp) fIp=new AliExternalTrackParam(*t);
6c94f330 1304 else
1305 fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
6d3a7bbf 1306 }
5d6fb68d 1307 // Intentionally no break statement; need to set general TPC variables as well
9b859005 1308 case kTPCout:
6d3a7bbf 1309 {
1d303a24 1310 if (flags & kTPCout){
1311 if (!fOp) fOp=new AliExternalTrackParam(*t);
6c94f330 1312 else
1313 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1d303a24 1314 }
e1d4c1b5 1315 fTPCncls=t->GetNumberOfClusters();
ae982df3 1316 fTPCchi2=t->GetChi2();
a866ac60 1317
5d6fb68d 1318 if (fFriendTrack) { // Copy cluster indices
1319 Int_t* indexTPC = new Int_t[AliESDfriendTrack::kMaxTPCcluster];
1320 for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
1321 indexTPC[i]=t->GetClusterIndex(i);
1322 fFriendTrack->SetTPCIndices(indexTPC,AliESDfriendTrack::kMaxTPCcluster);
1323 delete [] indexTPC;
1324 }
ae982df3 1325 fTPCsignal=t->GetPIDsignal();
6d3a7bbf 1326 }
ae982df3 1327 break;
9b859005 1328
64130601 1329 case kTRDin: case kTRDrefit:
1330 break;
1331 case kTRDout:
6d3a7bbf 1332 {
51ad6848 1333 fTRDLabel = t->GetLabel();
2f83b7a6 1334 fTRDchi2 = t->GetChi2();
1335 fTRDncls = t->GetNumberOfClusters();
59c31692 1336 if (fFriendTrack) {
6d3a7bbf 1337 Int_t* indexTRD = new Int_t[AliESDfriendTrack::kMaxTRDcluster];
1338 for (Int_t i=0;i<AliESDfriendTrack::kMaxTRDcluster;i++) indexTRD[i]=-2;
1339 for (Int_t i=0;i<6;i++) indexTRD[i]=t->GetTrackletIndex(i);
1340 fFriendTrack->SetTRDIndices(indexTRD,AliESDfriendTrack::kMaxTRDcluster);
1341 delete [] indexTRD;
59c31692 1342 }
5bc3e158 1343
79e94bf8 1344 fTRDsignal=t->GetPIDsignal();
6d3a7bbf 1345 }
79e94bf8 1346 break;
c4d11b15 1347 case kTRDbackup:
c9ec41e8 1348 if (!fOp) fOp=new AliExternalTrackParam(*t);
6c94f330 1349 else
1350 fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
c4d11b15 1351 fTRDncls0 = t->GetNumberOfClusters();
1352 break;
1353 case kTOFin:
1354 break;
1355 case kTOFout:
1356 break;
d0862fea 1357 case kTRDStop:
1358 break;
c38d443f 1359 case kHMPIDout:
1360 if (!fHMPIDp) fHMPIDp=new AliExternalTrackParam(*t);
1361 else
1362 fHMPIDp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1363 break;
ae982df3 1364 default:
5f7789fc 1365 AliError("Wrong flag !");
ae982df3 1366 return kFALSE;
1367 }
1368
15614b8b 1369 return rc;
ae982df3 1370}
1371
1372//_______________________________________________________________________
1373void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
1374 //---------------------------------------------------------------------
1375 // This function returns external representation of the track parameters
1376 //---------------------------------------------------------------------
c9ec41e8 1377 x=GetX();
1378 for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
15614b8b 1379}
1380
67c3dcbe 1381//_______________________________________________________________________
a866ac60 1382void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
67c3dcbe 1383 //---------------------------------------------------------------------
1384 // This function returns external representation of the cov. matrix
1385 //---------------------------------------------------------------------
c9ec41e8 1386 for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
67c3dcbe 1387}
1388
67c3dcbe 1389//_______________________________________________________________________
c0b978f0 1390Bool_t AliESDtrack::GetConstrainedExternalParameters
1391 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
67c3dcbe 1392 //---------------------------------------------------------------------
1393 // This function returns the constrained external track parameters
1394 //---------------------------------------------------------------------
c0b978f0 1395 if (!fCp) return kFALSE;
1396 alpha=fCp->GetAlpha();
c9ec41e8 1397 x=fCp->GetX();
1398 for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
c0b978f0 1399 return kTRUE;
67c3dcbe 1400}
c9ec41e8 1401
67c3dcbe 1402//_______________________________________________________________________
c0b978f0 1403Bool_t
67c3dcbe 1404AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
1405 //---------------------------------------------------------------------
1406 // This function returns the constrained external cov. matrix
1407 //---------------------------------------------------------------------
c0b978f0 1408 if (!fCp) return kFALSE;
c9ec41e8 1409 for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
c0b978f0 1410 return kTRUE;
67c3dcbe 1411}
1412
c0b978f0 1413Bool_t
1414AliESDtrack::GetInnerExternalParameters
1415 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1416 //---------------------------------------------------------------------
c9ec41e8 1417 // This function returns external representation of the track parameters
1418 // at the inner layer of TPC
9b859005 1419 //---------------------------------------------------------------------
c0b978f0 1420 if (!fIp) return kFALSE;
1421 alpha=fIp->GetAlpha();
c9ec41e8 1422 x=fIp->GetX();
1423 for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
c0b978f0 1424 return kTRUE;
9b859005 1425}
1426
c0b978f0 1427Bool_t
1428AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
c9ec41e8 1429 //---------------------------------------------------------------------
1430 // This function returns external representation of the cov. matrix
1431 // at the inner layer of TPC
1432 //---------------------------------------------------------------------
c0b978f0 1433 if (!fIp) return kFALSE;
c9ec41e8 1434 for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
c0b978f0 1435 return kTRUE;
9b859005 1436}
1437
d61ca12d 1438void
1439AliESDtrack::SetOuterParam(const AliExternalTrackParam *p, ULong_t flags) {
1440 //
1441 // This is a direct setter for the outer track parameters
1442 //
1443 SetStatus(flags);
1444 if (fOp) delete fOp;
1445 fOp=new AliExternalTrackParam(*p);
1446}
1447
c38d443f 1448void
1449AliESDtrack::SetOuterHmpParam(const AliExternalTrackParam *p, ULong_t flags) {
1450 //
1451 // This is a direct setter for the outer track parameters
1452 //
1453 SetStatus(flags);
1454 if (fHMPIDp) delete fHMPIDp;
1455 fHMPIDp=new AliExternalTrackParam(*p);
1456}
1457
c0b978f0 1458Bool_t
1459AliESDtrack::GetOuterExternalParameters
1460 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1461 //---------------------------------------------------------------------
c9ec41e8 1462 // This function returns external representation of the track parameters
1463 // at the inner layer of TRD
a866ac60 1464 //---------------------------------------------------------------------
c0b978f0 1465 if (!fOp) return kFALSE;
1466 alpha=fOp->GetAlpha();
c9ec41e8 1467 x=fOp->GetX();
1468 for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
c0b978f0 1469 return kTRUE;
a866ac60 1470}
c9ec41e8 1471
c38d443f 1472Bool_t
1473AliESDtrack::GetOuterHmpExternalParameters
1474 (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1475 //---------------------------------------------------------------------
1476 // This function returns external representation of the track parameters
1477 // at the inner layer of TRD
1478 //---------------------------------------------------------------------
1479 if (!fHMPIDp) return kFALSE;
1480 alpha=fHMPIDp->GetAlpha();
1481 x=fHMPIDp->GetX();
1482 for (Int_t i=0; i<5; i++) p[i]=fHMPIDp->GetParameter()[i];
1483 return kTRUE;
1484}
1485
c0b978f0 1486Bool_t
1487AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
a866ac60 1488 //---------------------------------------------------------------------
c9ec41e8 1489 // This function returns external representation of the cov. matrix
1490 // at the inner layer of TRD
a866ac60 1491 //---------------------------------------------------------------------
c0b978f0 1492 if (!fOp) return kFALSE;
c9ec41e8 1493 for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
c0b978f0 1494 return kTRUE;
a866ac60 1495}
1496
c38d443f 1497Bool_t
1498AliESDtrack::GetOuterHmpExternalCovariance(Double_t cov[15]) const {
1499 //---------------------------------------------------------------------
1500 // This function returns external representation of the cov. matrix
1501 // at the inner layer of TRD
1502 //---------------------------------------------------------------------
1503 if (!fHMPIDp) return kFALSE;
1504 for (Int_t i=0; i<15; i++) cov[i]=fHMPIDp->GetCovariance()[i];
1505 return kTRUE;
1506}
1507
98937d93 1508Int_t AliESDtrack::GetNcls(Int_t idet) const
1509{
1510 // Get number of clusters by subdetector index
1511 //
1512 Int_t ncls = 0;
1513 switch(idet){
1514 case 0:
1515 ncls = fITSncls;
1516 break;
1517 case 1:
1518 ncls = fTPCncls;
1519 break;
1520 case 2:
1521 ncls = fTRDncls;
1522 break;
1523 case 3:
ce3f4882 1524 if (fTOFindex != -1)
98937d93 1525 ncls = 1;
1526 break;
81aa7a0d 1527 case 4: //PHOS
1528 break;
1529 case 5: //HMPID
1530 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1531 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1532 ncls = 1;
1533 }
1534 }
1535 break;
98937d93 1536 default:
1537 break;
1538 }
1539 return ncls;
1540}
1541
ef7253ac 1542Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
98937d93 1543{
1544 // Get cluster index array by subdetector index
1545 //
1546 Int_t ncls = 0;
1547 switch(idet){
1548 case 0:
1549 ncls = GetITSclusters(idx);
1550 break;
1551 case 1:
ef7253ac 1552 ncls = GetTPCclusters(idx);
98937d93 1553 break;
1554 case 2:
1555 ncls = GetTRDclusters(idx);
1556 break;
1557 case 3:
ce3f4882 1558 if (fTOFindex != -1) {
1559 idx[0] = fTOFindex;
98937d93 1560 ncls = 1;
1561 }
1562 break;
313af949 1563 case 4: //PHOS
1564 break;
1565 case 5:
81aa7a0d 1566 if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1567 if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1568 idx[0] = GetHMPIDcluIdx();
1569 ncls = 1;
1570 }
313af949 1571 }
1572 break;
1573 case 6: //EMCAL
1574 break;
98937d93 1575 default:
1576 break;
1577 }
1578 return ncls;
1579}
1580
ae982df3 1581//_______________________________________________________________________
1582void AliESDtrack::GetIntegratedTimes(Double_t *times) const {
4427806c 1583 // Returns the array with integrated times for each particle hypothesis
304864ab 1584 for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fTrackTime[i];
ae982df3 1585}
1586
1587//_______________________________________________________________________
1588void AliESDtrack::SetIntegratedTimes(const Double_t *times) {
4427806c 1589 // Sets the array with integrated times for each particle hypotesis
304864ab 1590 for (Int_t i=0; i<AliPID::kSPECIES; i++) fTrackTime[i]=times[i];
ae982df3 1591}
1592
c630aafd 1593//_______________________________________________________________________
4427806c 1594void AliESDtrack::SetITSpid(const Double_t *p) {
1595 // Sets values for the probability of each particle type (in ITS)
d27bbc79 1596 SetPIDValues(fITSr,p,AliPID::kSPECIES);
c630aafd 1597 SetStatus(AliESDtrack::kITSpid);
1598}
1599
1600//_______________________________________________________________________
1601void AliESDtrack::GetITSpid(Double_t *p) const {
4427806c 1602 // Gets the probability of each particle type (in ITS)
304864ab 1603 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fITSr[i];
c630aafd 1604}
1605
ae982df3 1606//_______________________________________________________________________
562dd0b4 1607Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
ae982df3 1608 //---------------------------------------------------------------------
1609 // This function returns indices of the assgined ITS clusters
1610 //---------------------------------------------------------------------
59c31692 1611 if (idx && fFriendTrack) {
6d3a7bbf 1612 Int_t *index=fFriendTrack->GetITSindices();
1613 for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) {
1614 if ( (i>=fITSncls) && (i<6) ) idx[i]=-1;
1615 else {
1616 if (index) {
1617 idx[i]=index[i];
1618 }
1619 else idx[i]= -2;
1620 }
1621 }
15e85efa 1622 }
ae982df3 1623 return fITSncls;
1624}
1625
89f1b176 1626//_______________________________________________________________________
1627Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
1628 Float_t &xloc,Float_t &zloc) const {
1629 //----------------------------------------------------------------------
1630 // This function encodes in the module number also the status of cluster association
1631 // "status" can have the following values:
1632 // 1 "found" (cluster is associated),
1633 // 2 "dead" (module is dead from OCDB),
1634 // 3 "skipped" (module or layer forced to be skipped),
1635 // 4 "outinz" (track out of z acceptance),
1636 // 5 "nocls" (no clusters in the road),
1637 // 6 "norefit" (cluster rejected during refit),
1638 // 7 "deadzspd" (holes in z in SPD)
1639 // Also given are the coordinates of the crossing point of track and module
1640 // (in the local module ref. system)
1641 // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
1642 //----------------------------------------------------------------------
1643
1644 if(fITSModule[ilayer]==-1) {
89f1b176 1645 idet = -1;
1646 status=0;
1647 xloc=-99.; zloc=-99.;
1648 return kFALSE;
1649 }
1650
1651 Int_t module = fITSModule[ilayer];
1652
1653 idet = Int_t(module/1000000);
1654
1655 module -= idet*1000000;
1656
1657 status = Int_t(module/100000);
1658
1659 module -= status*100000;
1660
1661 Int_t signs = Int_t(module/10000);
1662
1663 module-=signs*10000;
1664
1665 Int_t xInt = Int_t(module/100);
1666 module -= xInt*100;
1667
1668 Int_t zInt = module;
1669
1670 if(signs==1) { xInt*=1; zInt*=1; }
1671 if(signs==2) { xInt*=1; zInt*=-1; }
1672 if(signs==3) { xInt*=-1; zInt*=1; }
1673 if(signs==4) { xInt*=-1; zInt*=-1; }
1674
1675 xloc = 0.1*(Float_t)xInt;
1676 zloc = 0.1*(Float_t)zInt;
1677
1678 if(status==4) idet = -1;
1679
1680 return kTRUE;
1681}
1682
ae982df3 1683//_______________________________________________________________________
562dd0b4 1684UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
ae982df3 1685 //---------------------------------------------------------------------
1686 // This function returns indices of the assgined ITS clusters
1687 //---------------------------------------------------------------------
59c31692 1688 if (idx && fFriendTrack) {
15e85efa 1689 Int_t *index=fFriendTrack->GetTPCindices();
6d3a7bbf 1690
1691 if (index){
1692 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
1693 }
1694 else {
1695 for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=-2;
1696 }
15e85efa 1697 }
ae982df3 1698 return fTPCncls;
1699}
8c6a71ab 1700
6a6f0c1f 1701//_______________________________________________________________________
204022f3 1702Float_t AliESDtrack::GetTPCClusterInfo(Int_t nNeighbours/*=3*/, Int_t type/*=0*/, Int_t row0, Int_t row1) const
6a6f0c1f 1703{
1704 //
1705 // TPC cluster information
1706 // type 0: get fraction of found/findable clusters with neighbourhood definition
1707 // 1: findable clusters with neighbourhood definition
1708 // 2: found clusters
1709 //
1710 // definition of findable clusters:
1711 // a cluster is defined as findable if there is another cluster
1712 // within +- nNeighbours pad rows. The idea is to overcome threshold
1713 // effects with a very simple algorithm.
1714 //
1715
1716 if (type==2) return fTPCClusterMap.CountBits();
1717
1718 Int_t found=0;
1719 Int_t findable=0;
1720 Int_t last=-nNeighbours;
1721
59c31692 1722 Int_t upperBound=fTPCClusterMap.GetNbits();
1723 if (upperBound>row1) upperBound=row1;
1724 for (Int_t i=row0; i<upperBound; ++i){
6a6f0c1f 1725 //look to current row
1726 if (fTPCClusterMap[i]) {
1727 last=i;
1728 ++found;
1729 ++findable;
1730 continue;
1731 }
1732 //look to nNeighbours before
1733 if ((i-last)<=nNeighbours) {
1734 ++findable;
1735 continue;
1736 }
1737 //look to nNeighbours after
1738 for (Int_t j=i+1; j<i+1+nNeighbours; ++j){
1739 if (fTPCClusterMap[j]){
1740 ++findable;
1741 break;
1742 }
1743 }
1744 }
82cc468e 1745 if (type==1) return findable;
1746
6a6f0c1f 1747 if (type==0){
82cc468e 1748 Float_t fraction=0;
1749 if (findable>0)
1750 fraction=(Float_t)found/(Float_t)findable;
1751 else
1752 fraction=0;
1753 return fraction;
1754 }
1755 return 0; // undefined type - default value
6a6f0c1f 1756}
1757
1758//_______________________________________________________________________
562dd0b4 1759Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
81e97e0d 1760 //
1761 // GetDensity of the clusters on given region between row0 and row1
1762 // Dead zone effect takin into acoount
1763 //
59c31692 1764 if (!fFriendTrack) return 0.0;
81e97e0d 1765 Int_t good = 0;
1766 Int_t found = 0;
1767 //
15e85efa 1768 Int_t *index=fFriendTrack->GetTPCindices();
81e97e0d 1769 for (Int_t i=row0;i<=row1;i++){
15e85efa 1770 Int_t idx = index[i];
1771 if (idx!=-1) good++; // track outside of dead zone
1772 if (idx>0) found++;
81e97e0d 1773 }
1774 Float_t density=0.5;
1775 if (good>(row1-row0)*0.5) density = Float_t(found)/Float_t(good);
1776 return density;
1777}
c84a5e9e 1778
8c6a71ab 1779//_______________________________________________________________________
1780void AliESDtrack::SetTPCpid(const Double_t *p) {
4427806c 1781 // Sets values for the probability of each particle type (in TPC)
d27bbc79 1782 SetPIDValues(fTPCr,p,AliPID::kSPECIES);
8c6a71ab 1783 SetStatus(AliESDtrack::kTPCpid);
1784}
1785
1786//_______________________________________________________________________
1787void AliESDtrack::GetTPCpid(Double_t *p) const {
4427806c 1788 // Gets the probability of each particle type (in TPC)
304864ab 1789 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTPCr[i];
8c6a71ab 1790}
1791
bb2ceb1f 1792//_______________________________________________________________________
562dd0b4 1793UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
bb2ceb1f 1794 //---------------------------------------------------------------------
1795 // This function returns indices of the assgined TRD clusters
1796 //---------------------------------------------------------------------
59c31692 1797 if (idx && fFriendTrack) {
6d3a7bbf 1798 Int_t *index=fFriendTrack->GetTRDindices();
1799
1800 if (index) {
1801 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
1802 }
1803 else {
1804 for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=-2;
1805 }
15e85efa 1806 }
bb2ceb1f 1807 return fTRDncls;
1808}
1809
5bc3e158 1810//_______________________________________________________________________
1811UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
0ad488b0 1812//
1813// This function returns the number of TRD tracklets used in tracking
1814// and it fills the indices of these tracklets in the array "idx" as they
1815// are registered in the TRD track list.
1816//
1817// Caution :
1818// 1. The idx array has to be allocated with a size >= AliESDtrack::kTRDnPlanes
1819// 2. The idx array store not only the index but also the layer of the tracklet.
1820// Therefore tracks with TRD gaps contain default values for indices [-1]
1821
59c31692 1822 if (!fFriendTrack) return 0;
0ad488b0 1823 if (!idx) return GetTRDntracklets();
6d3a7bbf 1824 Int_t *index=fFriendTrack->GetTRDindices();
1825 Int_t n = 0;
0ad488b0 1826 for (Int_t i=0; i<kTRDnPlanes; i++){
6d3a7bbf 1827 if (index){
1828 if(index[i]>=0) n++;
1829 idx[i]=index[i];
1830 }
1831 else idx[i] = -2;
5bc3e158 1832 }
0ad488b0 1833 return n;
5bc3e158 1834}
1835
c630aafd 1836//_______________________________________________________________________
1837void AliESDtrack::SetTRDpid(const Double_t *p) {
4427806c 1838 // Sets values for the probability of each particle type (in TRD)
d27bbc79 1839 SetPIDValues(fTRDr,p,AliPID::kSPECIES);
c630aafd 1840 SetStatus(AliESDtrack::kTRDpid);
1841}
1842
1843//_______________________________________________________________________
1844void AliESDtrack::GetTRDpid(Double_t *p) const {
4427806c 1845 // Gets the probability of each particle type (in TRD)
304864ab 1846 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTRDr[i];
c630aafd 1847}
1848
79e94bf8 1849//_______________________________________________________________________
1850void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
1851{
4427806c 1852 // Sets the probability of particle type iSpecies to p (in TRD)
79e94bf8 1853 fTRDr[iSpecies] = p;
1854}
1855
562dd0b4 1856Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
79e94bf8 1857{
4427806c 1858 // Returns the probability of particle type iSpecies (in TRD)
79e94bf8 1859 return fTRDr[iSpecies];
1860}
1861
fae4c212 1862//____________________________________________________
1863Int_t AliESDtrack::GetNumberOfTRDslices() const
1864{
1865 // built in backward compatibility
1866 Int_t idx = fTRDnSlices - (kTRDnPlanes<<1);
1867 return idx<18 ? fTRDnSlices/kTRDnPlanes : idx/kTRDnPlanes;
1868}
1869
1870//____________________________________________________
1871Double_t AliESDtrack::GetTRDmomentum(Int_t plane, Double_t *sp) const
1872{
1873//Returns momentum estimation and optional its error (sp)
1874// in TRD layer "plane".
1875
1876 if (!fTRDnSlices) {
ba8cee18 1877 AliDebug(2, "No TRD info allocated for this track.");
fae4c212 1878 return -1.;
1879 }
1880 if ((plane<0) || (plane>=kTRDnPlanes)) {
ba8cee18 1881 AliWarning(Form("Request for TRD plane[%d] outside range.", plane));
fae4c212 1882 return -1.;
1883 }
1884
1885 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1886 // Protection for backward compatibility
1887 if(idx<(GetNumberOfTRDslices()*kTRDnPlanes)) return -1.;
1888
1889 if(sp) (*sp) = fTRDslices[idx+kTRDnPlanes];
1890 return fTRDslices[idx];
1891}
1892
1893//____________________________________________________
1894Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
1895 //Gets the charge from the slice of the plane
1896
1897 if(!fTRDslices) {
1898 //AliError("No TRD slices allocated for this track !");
1899 return -1.;
1900 }
1901 if ((plane<0) || (plane>=kTRDnPlanes)) {
1902 AliError("Info for TRD plane not available !");
1903 return -1.;
1904 }
1905 Int_t ns=GetNumberOfTRDslices();
1906 if ((slice<-1) || (slice>=ns)) {
1907 //AliError("Wrong TRD slice !");
1908 return -1.;
1909 }
1910
1911 if(slice>=0) return fTRDslices[plane*ns + slice];
1912
1913 // return average of the dEdx measurements
1914 Double_t q=0.; Double32_t *s = &fTRDslices[plane*ns];
1915 for (Int_t i=0; i<ns; i++, s++) if((*s)>0.) q+=(*s);
1916 return q/ns;
1917}
1918
1919//____________________________________________________
6984f7c1 1920void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
1921 //Sets the number of slices used for PID
fae4c212 1922 if (fTRDnSlices) return;
1923
1924 fTRDnSlices=n;
6984f7c1 1925 fTRDslices=new Double32_t[fTRDnSlices];
fae4c212 1926
1927 // set-up correctly the allocated memory
1928 memset(fTRDslices, 0, n*sizeof(Double32_t));
1929 for (Int_t i=GetNumberOfTRDslices(); i--;) fTRDslices[i]=-1.;
6984f7c1 1930}
1931
fae4c212 1932//____________________________________________________
6984f7c1 1933void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
1934 //Sets the charge q in the slice of the plane
fae4c212 1935 if(!fTRDslices) {
6984f7c1 1936 AliError("No TRD slices allocated for this track !");
1937 return;
1938 }
6984f7c1 1939 if ((plane<0) || (plane>=kTRDnPlanes)) {
fae4c212 1940 AliError("Info for TRD plane not allocated !");
6984f7c1 1941 return;
1942 }
fae4c212 1943 Int_t ns=GetNumberOfTRDslices();
6984f7c1 1944 if ((slice<0) || (slice>=ns)) {
1945 AliError("Wrong TRD slice !");
1946 return;
1947 }
1948 Int_t n=plane*ns + slice;
1949 fTRDslices[n]=q;
1950}
1951
6984f7c1 1952
fae4c212 1953//____________________________________________________
1954void AliESDtrack::SetTRDmomentum(Double_t p, Int_t plane, Double_t *sp)
1955{
1956 if(!fTRDslices) {
1957 AliError("No TRD slices allocated for this track !");
1958 return;
6984f7c1 1959 }
fae4c212 1960 if ((plane<0) || (plane>=kTRDnPlanes)) {
1961 AliError("Info for TRD plane not allocated !");
1962 return;
6984f7c1 1963 }
1964
fae4c212 1965 Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
1966 // Protection for backward compatibility
1967 if(idx<GetNumberOfTRDslices()*kTRDnPlanes) return;
6984f7c1 1968
fae4c212 1969 if(sp) fTRDslices[idx+kTRDnPlanes] = (*sp);
1970 fTRDslices[idx] = p;
6984f7c1 1971}
1972
1973
c630aafd 1974//_______________________________________________________________________
1975void AliESDtrack::SetTOFpid(const Double_t *p) {
4427806c 1976 // Sets the probability of each particle type (in TOF)
d27bbc79 1977 SetPIDValues(fTOFr,p,AliPID::kSPECIES);
c630aafd 1978 SetStatus(AliESDtrack::kTOFpid);
1979}
1980
51ad6848 1981//_______________________________________________________________________
1982void AliESDtrack::SetTOFLabel(const Int_t *p) {
1983 // Sets (in TOF)
1984 for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
1985}
1986
c630aafd 1987//_______________________________________________________________________
1988void AliESDtrack::GetTOFpid(Double_t *p) const {
4427806c 1989 // Gets probabilities of each particle type (in TOF)
304864ab 1990 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fTOFr[i];
c630aafd 1991}
1992
51ad6848 1993//_______________________________________________________________________
1994void AliESDtrack::GetTOFLabel(Int_t *p) const {
1995 // Gets (in TOF)
1996 for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
1997}
1998
1999//_______________________________________________________________________
2000void AliESDtrack::GetTOFInfo(Float_t *info) const {
2001 // Gets (in TOF)
2002 for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
2003}
2004
2005//_______________________________________________________________________
2006void AliESDtrack::SetTOFInfo(Float_t*info) {
2007 // Gets (in TOF)
2008 for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
2009}
2010
4a78b8c5 2011
2012
4a78b8c5 2013//_______________________________________________________________________
f4b3bbb7 2014void AliESDtrack::SetHMPIDpid(const Double_t *p) {
2015 // Sets the probability of each particle type (in HMPID)
2016 SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
2017 SetStatus(AliESDtrack::kHMPIDpid);
4a78b8c5 2018}
2019
2020//_______________________________________________________________________
f4b3bbb7 2021void AliESDtrack::GetHMPIDpid(Double_t *p) const {
2022 // Gets probabilities of each particle type (in HMPID)
2023 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fHMPIDr[i];
4a78b8c5 2024}
2025
2026
2027
8c6a71ab 2028//_______________________________________________________________________
2029void AliESDtrack::SetESDpid(const Double_t *p) {
4427806c 2030 // Sets the probability of each particle type for the ESD track
d27bbc79 2031 SetPIDValues(fR,p,AliPID::kSPECIES);
8c6a71ab 2032 SetStatus(AliESDtrack::kESDpid);
2033}
2034
2035//_______________________________________________________________________
2036void AliESDtrack::GetESDpid(Double_t *p) const {
4427806c 2037 // Gets probability of each particle type for the ESD track
304864ab 2038 for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i]=fR[i];
8c6a71ab 2039}
2040
d7ddf1e9 2041//_______________________________________________________________________
436dfe39 2042Bool_t AliESDtrack::RelateToVertexTPC(const AliESDVertex *vtx,
2043Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
d7ddf1e9 2044 //
436dfe39 2045 // Try to relate the TPC-only track parameters to the vertex "vtx",
d7ddf1e9 2046 // if the (rough) transverse impact parameter is not bigger then "maxd".
2047 // Magnetic field is "b" (kG).
2048 //
2049 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2050 // b) The impact parameters and their covariance matrix are calculated.
436dfe39 2051 // c) An attempt to constrain the TPC-only params to the vertex is done.
2052 // The constrained params are returned via "cParam".
d7ddf1e9 2053 //
436dfe39 2054 // In the case of success, the returned value is kTRUE
2055 // otherwise, it's kFALSE)
2056 //
d7ddf1e9 2057
2058 if (!fTPCInner) return kFALSE;
2059 if (!vtx) return kFALSE;
2060
2061 Double_t dz[2],cov[3];
2062 if (!fTPCInner->PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2063
2064 fdTPC = dz[0];
2065 fzTPC = dz[1];
2066 fCddTPC = cov[0];
2067 fCdzTPC = cov[1];
2068 fCzzTPC = cov[2];
2069
436dfe39 2070 Double_t covar[6]; vtx->GetCovMatrix(covar);
2071 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2072 Double_t c[3]={covar[2],0.,covar[5]};
2073
2074 Double_t chi2=GetPredictedChi2(p,c);
2075 if (chi2>kVeryBig) return kFALSE;
2076
2077 fCchi2TPC=chi2;
2078
2079 if (!cParam) return kTRUE;
2080
2081 *cParam = *fTPCInner;
2082 if (!cParam->Update(p,c)) return kFALSE;
2083
d7ddf1e9 2084 return kTRUE;
2085}
2086
266a0f9b 2087//_______________________________________________________________________
2088Bool_t AliESDtrack::RelateToVertexTPCBxByBz(const AliESDVertex *vtx,
2089Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2090 //
2091 // Try to relate the TPC-only track parameters to the vertex "vtx",
2092 // if the (rough) transverse impact parameter is not bigger then "maxd".
2093 //
2094 // All three components of the magnetic field ,"b[3]" (kG),
2095 // are taken into account.
2096 //
2097 // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2098 // b) The impact parameters and their covariance matrix are calculated.
2099 // c) An attempt to constrain the TPC-only params to the vertex is done.
2100 // The constrained params are returned via "cParam".
2101 //
2102 // In the case of success, the returned value is kTRUE
2103 // otherwise, it's kFALSE)
2104 //
2105
2106 if (!fTPCInner) return kFALSE;
2107 if (!vtx) return kFALSE;
2108
2109 Double_t dz[2],cov[3];
2110 if (!fTPCInner->PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2111
2112 fdTPC = dz[0];
2113 fzTPC = dz[1];
2114 fCddTPC = cov[0];
2115 fCdzTPC = cov[1];
2116 fCzzTPC = cov[2];
2117
2118 Double_t covar[6]; vtx->GetCovMatrix(covar);
2119 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2120 Double_t c[3]={covar[2],0.,covar[5]};
2121
2122 Double_t chi2=GetPredictedChi2(p,c);
2123 if (chi2>kVeryBig) return kFALSE;
2124
2125 fCchi2TPC=chi2;
2126
2127 if (!cParam) return kTRUE;
2128
2129 *cParam = *fTPCInner;
2130 if (!cParam->Update(p,c)) return kFALSE;
2131
2132 return kTRUE;
2133}
2134
49d13e89 2135//_______________________________________________________________________
436dfe39 2136Bool_t AliESDtrack::RelateToVertex(const AliESDVertex *vtx,
2137Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
49d13e89 2138 //
2139 // Try to relate this track to the vertex "vtx",
2140 // if the (rough) transverse impact parameter is not bigger then "maxd".
2141 // Magnetic field is "b" (kG).
2142 //
2143 // a) The track gets extapolated to the DCA to the vertex.
2144 // b) The impact parameters and their covariance matrix are calculated.
2145 // c) An attempt to constrain this track to the vertex is done.
436dfe39 2146 // The constrained params are returned via "cParam".
49d13e89 2147 //
436dfe39 2148 // In the case of success, the returned value is kTRUE
2149 // (otherwise, it's kFALSE)
49d13e89 2150 //
b5d34a4c 2151
2152 if (!vtx) return kFALSE;
2153
e99a34df 2154 Double_t dz[2],cov[3];
2155 if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2156
2157 fD = dz[0];
2158 fZ = dz[1];
2159 fCdd = cov[0];
2160 fCdz = cov[1];
2161 fCzz = cov[2];
49d13e89 2162
e99a34df 2163 Double_t covar[6]; vtx->GetCovMatrix(covar);
2164 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2165 Double_t c[3]={covar[2],0.,covar[5]};
3231f9e5 2166
e99a34df 2167 Double_t chi2=GetPredictedChi2(p,c);
436dfe39 2168 if (chi2>kVeryBig) return kFALSE;
2169
2170 fCchi2=chi2;
49d13e89 2171
436dfe39 2172
266a0f9b 2173 //--- Could now these lines be removed ? ---
2174 delete fCp;
2175 fCp=new AliExternalTrackParam(*this);
2176
2177 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2178 //----------------------------------------
2179
2180 fVertexID = vtx->GetID();
2181
2182 if (!cParam) return kTRUE;
2183
2184 *cParam = *this;
2185 if (!cParam->Update(p,c)) return kFALSE;
2186
2187 return kTRUE;
2188}
2189
2190//_______________________________________________________________________
2191Bool_t AliESDtrack::RelateToVertexBxByBz(const AliESDVertex *vtx,
2192Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2193 //
2194 // Try to relate this track to the vertex "vtx",
2195 // if the (rough) transverse impact parameter is not bigger then "maxd".
2196 // Magnetic field is "b" (kG).
2197 //
2198 // a) The track gets extapolated to the DCA to the vertex.
2199 // b) The impact parameters and their covariance matrix are calculated.
2200 // c) An attempt to constrain this track to the vertex is done.
2201 // The constrained params are returned via "cParam".
2202 //
2203 // In the case of success, the returned value is kTRUE
2204 // (otherwise, it's kFALSE)
2205 //
2206
2207 if (!vtx) return kFALSE;
2208
2209 Double_t dz[2],cov[3];
2210 if (!PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2211
2212 fD = dz[0];
2213 fZ = dz[1];
2214 fCdd = cov[0];
2215 fCdz = cov[1];
2216 fCzz = cov[2];
2217
2218 Double_t covar[6]; vtx->GetCovMatrix(covar);
2219 Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2220 Double_t c[3]={covar[2],0.,covar[5]};
2221
2222 Double_t chi2=GetPredictedChi2(p,c);
2223 if (chi2>kVeryBig) return kFALSE;
2224
2225 fCchi2=chi2;
2226
2227
436dfe39 2228 //--- Could now these lines be removed ? ---
e99a34df 2229 delete fCp;
2230 fCp=new AliExternalTrackParam(*this);
49d13e89 2231
e99a34df 2232 if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
436dfe39 2233 //----------------------------------------
2234
6dc21f57 2235 fVertexID = vtx->GetID();
436dfe39 2236
2237 if (!cParam) return kTRUE;
2238
2239 *cParam = *this;
2240 if (!cParam->Update(p,c)) return kFALSE;
2241
49d13e89 2242 return kTRUE;
2243}
2244
ac2f7574 2245//_______________________________________________________________________
2246void AliESDtrack::Print(Option_t *) const {
2247 // Prints info on the track
b9ca886f 2248 AliExternalTrackParam::Print();
5f7789fc 2249 printf("ESD track info\n") ;
304864ab 2250 Double_t p[AliPID::kSPECIESN] ;
ac2f7574 2251 Int_t index = 0 ;
2252 if( IsOn(kITSpid) ){
2253 printf("From ITS: ") ;
2254 GetITSpid(p) ;
304864ab 2255 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 2256 printf("%f, ", p[index]) ;
2257 printf("\n signal = %f\n", GetITSsignal()) ;
2258 }
2259 if( IsOn(kTPCpid) ){
2260 printf("From TPC: ") ;
2261 GetTPCpid(p) ;
304864ab 2262 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 2263 printf("%f, ", p[index]) ;
2264 printf("\n signal = %f\n", GetTPCsignal()) ;
2265 }
2266 if( IsOn(kTRDpid) ){
2267 printf("From TRD: ") ;
2268 GetTRDpid(p) ;
304864ab 2269 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 2270 printf("%f, ", p[index]) ;
6984f7c1 2271 printf("\n signal = %f\n", GetTRDsignal()) ;
ac2f7574 2272 }
2273 if( IsOn(kTOFpid) ){
2274 printf("From TOF: ") ;
2275 GetTOFpid(p) ;
304864ab 2276 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 2277 printf("%f, ", p[index]) ;
2278 printf("\n signal = %f\n", GetTOFsignal()) ;
2279 }
f4b3bbb7 2280 if( IsOn(kHMPIDpid) ){
2281 printf("From HMPID: ") ;
2282 GetHMPIDpid(p) ;
304864ab 2283 for(index = 0 ; index < AliPID::kSPECIES; index++)
ac2f7574 2284 printf("%f, ", p[index]) ;
f4b3bbb7 2285 printf("\n signal = %f\n", GetHMPIDsignal()) ;
ac2f7574 2286 }
ac2f7574 2287}
6c94f330 2288
0c19adf7 2289
2290//
2291// Draw functionality
2292// Origin: Marian Ivanov, Marian.Ivanov@cern.ch
2293//
2294void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
2295 //
2296 // Fill points in the polymarker
2297 //
2298 TObjArray arrayRef;
2299 arrayRef.AddLast(new AliExternalTrackParam(*this));
2300 if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
2301 if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
c38d443f 2302 if (fHMPIDp) arrayRef.AddLast(new AliExternalTrackParam(*fHMPIDp));
0c19adf7 2303 //
2304 Double_t mpos[3]={0,0,0};
2305 Int_t entries=arrayRef.GetEntries();
2306 for (Int_t i=0;i<entries;i++){
2307 Double_t pos[3];
2308 ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
2309 mpos[0]+=pos[0]/entries;
2310 mpos[1]+=pos[1]/entries;
2311 mpos[2]+=pos[2]/entries;
2312 }
2313 // Rotate to the mean position
2314 //
2315 Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
2316 for (Int_t i=0;i<entries;i++){
2317 Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
2318 if (!res) delete arrayRef.RemoveAt(i);
2319 }
2320 Int_t counter=0;
2321 for (Double_t r=minR; r<maxR; r+=stepR){
2322 Double_t sweight=0;
2323 Double_t mlpos[3]={0,0,0};
2324 for (Int_t i=0;i<entries;i++){
2325 Double_t point[3]={0,0,0};
2326 AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
2327 if (!param) continue;
2328 if (param->GetXYZAt(r,magF,point)){
2329 Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
2330 sweight+=weight;
2331 mlpos[0]+=point[0]*weight;
2332 mlpos[1]+=point[1]*weight;
2333 mlpos[2]+=point[2]*weight;
2334 }
2335 }
2336 if (sweight>0){
2337 mlpos[0]/=sweight;
2338 mlpos[1]/=sweight;
2339 mlpos[2]/=sweight;
2340 pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
2341 printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);
2342 counter++;
2343 }
2344 }
2345}
1d4882da 2346
2347//_______________________________________________________________________
2348void AliESDtrack::SetITSdEdxSamples(const Double_t s[4]) {
2349 //
2350 // Store the dE/dx samples measured by the two SSD and two SDD layers.
2351 // These samples are corrected for the track segment length.
2352 //
2353 for (Int_t i=0; i<4; i++) fITSdEdxSamples[i]=s[i];
2354}
2355
2356//_______________________________________________________________________
2357void AliESDtrack::GetITSdEdxSamples(Double_t *s) const {
2358 //
2359 // Get the dE/dx samples measured by the two SSD and two SDD layers.
2360 // These samples are corrected for the track segment length.
2361 //
2362 for (Int_t i=0; i<4; i++) s[i]=fITSdEdxSamples[i];
2363}
949840f6 2364
2365
2366UShort_t AliESDtrack::GetTPCnclsS(Int_t i0,Int_t i1) const{
2367 //
beb01154 2368 // get number of shared TPC clusters
949840f6 2369 //
2370 return fTPCSharedMap.CountBits(i0)-fTPCSharedMap.CountBits(i1);
2371}
beb01154 2372
2373UShort_t AliESDtrack::GetTPCncls(Int_t i0,Int_t i1) const{
2374 //
2375 // get number of TPC clusters
2376 //
2377 return fTPCClusterMap.CountBits(i0)-fTPCClusterMap.CountBits(i1);
2378}