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