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