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