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