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