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