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