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