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