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