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