Line data Source code
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 : // Content:
37 : // a.) Track parameters and covariance - AliExternalTrackParam - snapshots along trajectory at differnt tracking steps
38 : // current, fIp, fTPCinner, fCp, fOp, fHMPIDp, + friendTrack (fITSout, fTPCout, fTRDin)
39 : // b.) Flags - per detector status bits
40 : // c.) Track fit quality -chi2, number of clusters
41 : // d.) Detector PID information
42 : // d.) Different detector specific information (e.g number of tracklets in TRD, TOF cluster descriptor ...)
43 : //
44 : //
45 : // The track information is propagated from one tracking detector to
46 : // other using the functionality of AliESDtrack (AliExternalTrackParam - current parameters)
47 : //
48 : // Barrel tracking uses Kalman filtering technique (no global fit model is used). Kalman provides optimal local
49 : // track parameters estimate at given position under certian assumptions.
50 : // Following approximations were used:
51 : // a.) gaussian Multiple scattering
52 : // b.) gaussian energy loss
53 : // c.) gaussian error of the space point residuals
54 : //
55 : // Kalman filter take into account following effects which are
56 : // difficult to handle using global fit:
57 : // a.) Multiple scattering
58 : // b.) Energy loss
59 : // c.) Non homogenous magnetic field
60 : //
61 : // In general case, following barrel detectors are contributing to
62 : // the Kalman track information:
63 : // a. TPC
64 : // b. ITS
65 : // c. TRD
66 : //
67 : // Track findind/fitting procedure is done in 3 steps:
68 : // 1. Cluster2Track(in) - inward sequence TPC->ITS
69 : // 2. PropagateBack(out) - outward sequence ITS->TPC->TRD -> Outer PID detectors
70 : // 3. RefitInward(refit) - inward sequence TRD->TPC->ITS
71 : // After each recosntruction step detector status is updated in the data member fFlags
72 : // fFlags|=k<DetectorName><step> where step={1:in,2:out,3:refit,}
73 : // For some of detectors a special flags were implemented. Declaration of list of all flags can be find in $ALICE_ROOT/STEER/STEERBase/AliVTrack.h
74 : //
75 : //
76 : // The current track parameter is updated after each detector (see bellow).
77 : // In specical cases a track snapshots (AliExternalTrackParam) are stored
78 : //
79 : //
80 : //
81 : // For some type of analysis (+visualization) track local parameters at
82 : // different position are neccesary. A snapshots during the track
83 : // propagation are created and stored either in track itself (for analysis purposes) or assiciated friend track (for calibration and debugging purposes)
84 : // (See AliExternalTrackParam class for desctiption of variables and functionality)
85 : // Snapshots:
86 : // a.) Current parameters (AliESDtrack itself)
87 : // Description: as obtained in the last succesfull tracking step
88 : // Contributors: best case TRD->TPC->ITS after RefitInward
89 : // Recomended way to get track parameters. It includes all of the information.
90 : // NOTICE - By default the track parameters are stored at the DCA point to the primary vertex.
91 : // Optimal for primary tracks, far from optimal for deeply secondary tracks.
92 : // To get optimal track parameters at the secondary vertex, OnTheFly V0s with associated track parameters should be used
93 : //
94 : // b.) Constrained parameters (fCp)
95 : // Description:
96 : // Kalman track updated with the Primary vertex information with corresponding error (soft constraint - see http://en.wikipedia.org/wiki/Constraint_(mathematics)#Hard_and_soft_constraints)
97 : // Function:
98 : // const AliExternalTrackParam *GetConstrainedParam() const {return fCp;}
99 : // Contributors: best case TRD->TPC->ITS after RefitInward
100 : // Recommended usage: Use only for tracks selected as primary (check GetConstrainedChi2())
101 : // NOTICE - not real constraint only soft constraint
102 : //
103 : // c.) Inner parameters (fIp) -
104 : // Description: Track parameters at inner wall of the TPC
105 : // Function:
106 : // const AliExternalTrackParam *GetInnerParam() const { return fIp;}
107 : // Contributors: general case TRD->TPC (during RefitInward)
108 : // Recomended usage: To provide momenta for the TPC PID and to estimate quality of the track determination for further
109 : //
110 : // d.) TPCinnerParam (fTPCinner):
111 : // Description: TPC only parameters at DCA to the primary vertex (corrected for the material between TPC and vertex)
112 : // Function:
113 : // const AliExternalTrackParam *GetTPCInnerParam() const {return fTPCInner;}
114 : // Contributors: TPC only from in step 1 (Cluster2Tracks)
115 : // Recomended usage: Requested for HBT study
116 : // (smaller correlations as using also ITS information)
117 : // NOTICE: Optimal for primary, far from optimal for secondary tracks (similar to track parameters a.)
118 : // ! We should always use the c.) fIp in case of the TPC PID analysis, or undo material budget correction!
119 : //
120 : // e.) Outer parameters - (fOp)
121 : // Description: track parameters during PropagateBack in the last sucessfull propagation
122 : // Reason to generate backup OuterParameters
123 : // a.) Local inclination angle bigger than threshold -
124 : // Low momenta tracks
125 : // b.) Catastrofic (large relative>~20 %)energy loss in material outside of the TPC
126 : // c.) No additional space points contributing to track
127 : // Function:
128 : // const AliExternalTrackParam *GetOuterParam() const { return fOp;}
129 : // Contributors: general case - ITS-> TPC -> TRD ( during PropagateBack )
130 : // Recomended usage:
131 : // a.) Tracking: Starting parameter for Refit inward
132 : // b.) Visualization
133 : // c.) QA
134 : // NOTICE: Should be not used for the physic analysis
135 : // Function:
136 : // const AliExternalTrackParam *GetOuterParam() const { return fOp;}
137 : //
138 : //-----------------------------------------------------------------
139 :
140 : #include <TMath.h>
141 : #include <TParticle.h>
142 : #include <TDatabasePDG.h>
143 : #include <TMatrixD.h>
144 :
145 : #include "AliESDVertex.h"
146 : #include "AliESDtrack.h"
147 : #include "AliESDEvent.h"
148 : #include "AliKalmanTrack.h"
149 : #include "AliVTrack.h"
150 : #include "AliLog.h"
151 : #include "AliTrackPointArray.h"
152 : #include "TPolyMarker3D.h"
153 : #include "AliTrackerBase.h"
154 : #include "AliTPCdEdxInfo.h"
155 : #include "AliDetectorPID.h"
156 : #include "TTreeStream.h"
157 : #include "TObjArray.h"
158 :
159 172 : ClassImp(AliESDtrack)
160 :
161 : void SetPIDValues(Double_t * dest, const Double_t * src, Int_t n) {
162 : // This function copies "n" PID weights from "scr" to "dest"
163 : // and normalizes their sum to 1 thus producing conditional probabilities.
164 : // The negative weights are set to 0.
165 : // In case all the weights are non-positive they are replaced by
166 : // uniform probabilities
167 :
168 224 : if (n<=0) return;
169 :
170 112 : Float_t uniform = 1./(Float_t)n;
171 :
172 : Float_t sum = 0;
173 1344 : for (Int_t i=0; i<n; i++)
174 560 : if (src[i]>=0) {
175 560 : sum+=src[i];
176 560 : dest[i] = src[i];
177 560 : }
178 : else {
179 0 : dest[i] = 0;
180 : }
181 :
182 112 : if(sum>0)
183 1456 : for (Int_t i=0; i<n; i++) dest[i] /= sum;
184 : else
185 0 : for (Int_t i=0; i<n; i++) dest[i] = uniform;
186 224 : }
187 :
188 : //_______________________________________________________________________
189 : AliESDtrack::AliESDtrack() :
190 360 : AliExternalTrackParam(),
191 360 : fCp(0),
192 360 : fIp(0),
193 360 : fTPCInner(0),
194 360 : fOp(0),
195 360 : fHMPIDp(0),
196 360 : fFriendTrack(NULL),
197 360 : fTPCFitMap(159),//number of padrows
198 360 : fTPCClusterMap(159),//number of padrows
199 360 : fTPCSharedMap(159),//number of padrows
200 360 : fFrTrackID(0),
201 360 : fFlags(0),
202 360 : fID(0),
203 360 : fLabel(0),
204 360 : fITSLabel(0),
205 360 : fTPCLabel(0),
206 360 : fTRDLabel(0),
207 360 : fTOFLabel(NULL),
208 360 : fTOFCalChannel(-1),
209 360 : fTOFindex(-1),
210 360 : fHMPIDqn(0),
211 360 : fHMPIDcluIdx(-1),
212 360 : fCaloIndex(kEMCALNoMatch),
213 360 : fR(0),
214 360 : fITSr(0),
215 360 : fTPCr(0),
216 360 : fTRDr(0),
217 360 : fTOFr(0),
218 360 : fHMPIDr(0),
219 360 : fHMPIDtrkTheta(0),
220 360 : fHMPIDtrkPhi(0),
221 360 : fHMPIDsignal(0),
222 360 : fTrackTime(0),
223 360 : fTrackLength(0),
224 360 : fdTPC(0),fzTPC(0),
225 360 : fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
226 360 : fCchi2TPC(0),
227 360 : fD(0),fZ(0),
228 360 : fCdd(0),fCdz(0),fCzz(0),
229 360 : fCchi2(0),
230 360 : fITSchi2(0),
231 360 : fTPCchi2(0),
232 360 : fTPCchi2Iter1(0),
233 360 : fTRDchi2(0),
234 360 : fTOFchi2(0),
235 360 : fHMPIDchi2(0),
236 360 : fGlobalChi2(0),
237 360 : fITSsignal(0),
238 360 : fITSsignalTuned(0),
239 360 : fTPCsignal(0),
240 360 : fTPCsignalTuned(0),
241 360 : fTPCsignalS(0),
242 360 : fTPCdEdxInfo(0),
243 360 : fTRDsignal(0),
244 360 : fTRDQuality(0),
245 360 : fTRDBudget(0),
246 360 : fTOFsignal(99999),
247 360 : fTOFsignalTuned(99999),
248 360 : fTOFsignalToT(99999),
249 360 : fTOFsignalRaw(99999),
250 360 : fTOFsignalDz(999),
251 360 : fTOFsignalDx(999),
252 360 : fTOFdeltaBC(999),
253 360 : fTOFl0l1(999),
254 360 : fCaloDx(0),
255 360 : fCaloDz(0),
256 360 : fHMPIDtrkX(0),
257 360 : fHMPIDtrkY(0),
258 360 : fHMPIDmipX(0),
259 360 : fHMPIDmipY(0),
260 360 : fTPCncls(0),
261 360 : fTPCnclsF(0),
262 360 : fTPCsignalN(0),
263 360 : fTPCnclsIter1(0),
264 360 : fTPCnclsFIter1(0),
265 360 : fITSncls(0),
266 360 : fITSClusterMap(0),
267 360 : fITSSharedMap(0),
268 360 : fTRDncls(0),
269 360 : fTRDncls0(0),
270 360 : fTRDntracklets(0),
271 360 : fTRDNchamberdEdx(0),
272 360 : fTRDNclusterdEdx(0),
273 360 : fTRDnSlices(0),
274 360 : fTRDslices(0x0),
275 360 : fVertexID(-2),// -2 means an orphan track
276 360 : fPIDForTracking(AliPID::kPion),
277 360 : fESDEvent(0),
278 360 : fCacheNCrossedRows(-10),
279 360 : fCacheChi2TPCConstrainedVsGlobal(-10),
280 360 : fCacheChi2TPCConstrainedVsGlobalVertex(0),
281 360 : fDetectorPID(0x0),
282 360 : fTrackPhiOnEMCal(-999),
283 360 : fTrackEtaOnEMCal(-999),
284 360 : fTrackPtOnEMCal(-999),
285 360 : fNtofClusters(0),
286 360 : fTOFcluster(NULL)
287 1800 : {
288 : //
289 : // The default ESD constructor
290 : //
291 1440 : if (!OnlineMode()) fFriendTrack=new AliESDfriendTrack();
292 :
293 : Int_t i;
294 2880 : for (i=kNITSchi2Std;i--;) fITSchi2Std[i] = 0;
295 :
296 2880 : for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
297 2880 : for (i=0; i<3; i++) { fV0Indexes[i]=0;}
298 5040 : for (i=0;i<kTRDnPlanes;i++) {
299 2160 : fTRDTimBin[i]=0;
300 : }
301 3600 : for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
302 3600 : for (i=0;i<4;i++) {fTPCPoints[i]=0;}
303 7920 : for (i=0;i<10;i++) {fTOFInfo[i]=0;}
304 9360 : for (i=0;i<12;i++) {fITSModule[i]=-1;}
305 720 : }
306 :
307 : bool AliESDtrack::fgkOnlineMode=false;
308 :
309 : //_______________________________________________________________________
310 : AliESDtrack::AliESDtrack(const AliESDtrack& track):
311 162 : AliExternalTrackParam(track),
312 162 : fCp(0),
313 162 : fIp(0),
314 162 : fTPCInner(0),
315 162 : fOp(0),
316 162 : fHMPIDp(0),
317 162 : fFriendTrack(0),
318 162 : fTPCFitMap(track.fTPCFitMap),
319 162 : fTPCClusterMap(track.fTPCClusterMap),
320 162 : fTPCSharedMap(track.fTPCSharedMap),
321 162 : fFrTrackID(track.fFrTrackID),
322 162 : fFlags(track.fFlags),
323 162 : fID(track.fID),
324 162 : fLabel(track.fLabel),
325 162 : fITSLabel(track.fITSLabel),
326 162 : fTPCLabel(track.fTPCLabel),
327 162 : fTRDLabel(track.fTRDLabel),
328 162 : fTOFLabel(NULL),
329 162 : fTOFCalChannel(track.fTOFCalChannel),
330 162 : fTOFindex(track.fTOFindex),
331 162 : fHMPIDqn(track.fHMPIDqn),
332 162 : fHMPIDcluIdx(track.fHMPIDcluIdx),
333 162 : fCaloIndex(track.fCaloIndex),
334 162 : fR(0),
335 162 : fITSr(0),
336 162 : fTPCr(0),
337 162 : fTRDr(0),
338 162 : fTOFr(0),
339 162 : fHMPIDr(0),
340 162 : fHMPIDtrkTheta(track.fHMPIDtrkTheta),
341 162 : fHMPIDtrkPhi(track.fHMPIDtrkPhi),
342 162 : fHMPIDsignal(track.fHMPIDsignal),
343 162 : fTrackTime(NULL),
344 162 : fTrackLength(track.fTrackLength),
345 162 : fdTPC(track.fdTPC),fzTPC(track.fzTPC),
346 162 : fCddTPC(track.fCddTPC),fCdzTPC(track.fCdzTPC),fCzzTPC(track.fCzzTPC),
347 162 : fCchi2TPC(track.fCchi2TPC),
348 162 : fD(track.fD),fZ(track.fZ),
349 162 : fCdd(track.fCdd),fCdz(track.fCdz),fCzz(track.fCzz),
350 162 : fCchi2(track.fCchi2),
351 162 : fITSchi2(track.fITSchi2),
352 162 : fTPCchi2(track.fTPCchi2),
353 162 : fTPCchi2Iter1(track.fTPCchi2Iter1),
354 162 : fTRDchi2(track.fTRDchi2),
355 162 : fTOFchi2(track.fTOFchi2),
356 162 : fHMPIDchi2(track.fHMPIDchi2),
357 162 : fGlobalChi2(track.fGlobalChi2),
358 162 : fITSsignal(track.fITSsignal),
359 162 : fITSsignalTuned(track.fITSsignalTuned),
360 162 : fTPCsignal(track.fTPCsignal),
361 162 : fTPCsignalTuned(track.fTPCsignalTuned),
362 162 : fTPCsignalS(track.fTPCsignalS),
363 162 : fTPCdEdxInfo(0),
364 162 : fTRDsignal(track.fTRDsignal),
365 162 : fTRDQuality(track.fTRDQuality),
366 162 : fTRDBudget(track.fTRDBudget),
367 162 : fTOFsignal(track.fTOFsignal),
368 162 : fTOFsignalTuned(track.fTOFsignalTuned),
369 162 : fTOFsignalToT(track.fTOFsignalToT),
370 162 : fTOFsignalRaw(track.fTOFsignalRaw),
371 162 : fTOFsignalDz(track.fTOFsignalDz),
372 162 : fTOFsignalDx(track.fTOFsignalDx),
373 162 : fTOFdeltaBC(track.fTOFdeltaBC),
374 162 : fTOFl0l1(track.fTOFl0l1),
375 162 : fCaloDx(track.fCaloDx),
376 162 : fCaloDz(track.fCaloDz),
377 162 : fHMPIDtrkX(track.fHMPIDtrkX),
378 162 : fHMPIDtrkY(track.fHMPIDtrkY),
379 162 : fHMPIDmipX(track.fHMPIDmipX),
380 162 : fHMPIDmipY(track.fHMPIDmipY),
381 162 : fTPCncls(track.fTPCncls),
382 162 : fTPCnclsF(track.fTPCnclsF),
383 162 : fTPCsignalN(track.fTPCsignalN),
384 162 : fTPCnclsIter1(track.fTPCnclsIter1),
385 162 : fTPCnclsFIter1(track.fTPCnclsIter1),
386 162 : fITSncls(track.fITSncls),
387 162 : fITSClusterMap(track.fITSClusterMap),
388 162 : fITSSharedMap(track.fITSSharedMap),
389 162 : fTRDncls(track.fTRDncls),
390 162 : fTRDncls0(track.fTRDncls0),
391 162 : fTRDntracklets(track.fTRDntracklets),
392 162 : fTRDNchamberdEdx(track.fTRDNchamberdEdx),
393 162 : fTRDNclusterdEdx(track.fTRDNclusterdEdx),
394 162 : fTRDnSlices(track.fTRDnSlices),
395 162 : fTRDslices(0x0),
396 162 : fVertexID(track.fVertexID),
397 162 : fPIDForTracking(AliPID::kPion),
398 162 : fESDEvent(track.fESDEvent),
399 162 : fCacheNCrossedRows(track.fCacheNCrossedRows),
400 162 : fCacheChi2TPCConstrainedVsGlobal(track.fCacheChi2TPCConstrainedVsGlobal),
401 162 : fCacheChi2TPCConstrainedVsGlobalVertex(track.fCacheChi2TPCConstrainedVsGlobalVertex),
402 162 : fDetectorPID(0x0),
403 162 : fTrackPhiOnEMCal(track.fTrackPhiOnEMCal),
404 162 : fTrackEtaOnEMCal(track.fTrackEtaOnEMCal),
405 162 : fTrackPtOnEMCal(track.fTrackPtOnEMCal),
406 162 : fNtofClusters(track.fNtofClusters),
407 162 : fTOFcluster(NULL)
408 810 : {
409 : //
410 : //copy constructor
411 : //
412 1296 : for (Int_t i=kNITSchi2Std;i--;) fITSchi2Std[i] = track.fITSchi2Std[i];
413 :
414 162 : if(track.fTrackTime){
415 20 : fTrackTime = new Double32_t[AliPID::kSPECIESC];
416 200 : for (Int_t i=0;i<AliPID::kSPECIESC;i++) fTrackTime[i]=track.fTrackTime[i];
417 10 : }
418 :
419 162 : if (track.fR) {
420 0 : fR = new Double32_t[AliPID::kSPECIES];
421 0 : for (Int_t i=AliPID::kSPECIES;i--;) fR[i]=track.fR[i];
422 0 : }
423 162 : if (track.fITSr) {
424 0 : fITSr = new Double32_t[AliPID::kSPECIES];
425 0 : for (Int_t i=AliPID::kSPECIES;i--;) fITSr[i]=track.fITSr[i];
426 0 : }
427 : //
428 162 : if (track.fTPCr) {
429 0 : fTPCr = new Double32_t[AliPID::kSPECIES];
430 0 : for (Int_t i=AliPID::kSPECIES;i--;) fTPCr[i]=track.fTPCr[i];
431 0 : }
432 :
433 1620 : for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=track.fITSdEdxSamples[i];}
434 1620 : for (Int_t i=0;i<4;i++) {fTPCPoints[i]=track.fTPCPoints[i];}
435 1296 : for (Int_t i=0; i<3;i++) { fKinkIndexes[i]=track.fKinkIndexes[i];}
436 1296 : for (Int_t i=0; i<3;i++) { fV0Indexes[i]=track.fV0Indexes[i];}
437 : //
438 2268 : for (Int_t i=0;i<kTRDnPlanes;i++) {
439 972 : fTRDTimBin[i]=track.fTRDTimBin[i];
440 : }
441 :
442 162 : if (fTRDnSlices) {
443 0 : fTRDslices=new Double32_t[fTRDnSlices];
444 0 : for (Int_t i=0; i<fTRDnSlices; i++) fTRDslices[i]=track.fTRDslices[i];
445 0 : }
446 :
447 162 : if (track.fDetectorPID) fDetectorPID = new AliDetectorPID(*track.fDetectorPID);
448 :
449 162 : if (track.fTRDr) {
450 0 : fTRDr = new Double32_t[AliPID::kSPECIES];
451 0 : for (Int_t i=AliPID::kSPECIES;i--;) fTRDr[i]=track.fTRDr[i];
452 0 : }
453 :
454 162 : if (track.fTOFr) {
455 0 : fTOFr = new Double32_t[AliPID::kSPECIES];
456 0 : for (Int_t i=AliPID::kSPECIES;i--;) fTOFr[i]=track.fTOFr[i];
457 0 : }
458 :
459 162 : if(track.fTOFLabel){
460 0 : if(!fTOFLabel) fTOFLabel = new Int_t[3];
461 0 : for (Int_t i=0;i<3;i++) fTOFLabel[i]=track.fTOFLabel[i];
462 0 : }
463 :
464 3564 : for (Int_t i=0;i<10;i++) fTOFInfo[i]=track.fTOFInfo[i];
465 4212 : for (Int_t i=0;i<12;i++) fITSModule[i]=track.fITSModule[i];
466 :
467 162 : if (track.fHMPIDr) {
468 0 : fHMPIDr = new Double32_t[AliPID::kSPECIES];
469 0 : for (Int_t i=AliPID::kSPECIES;i--;) fHMPIDr[i]=track.fHMPIDr[i];
470 0 : }
471 :
472 192 : if (track.fCp) fCp=new AliExternalTrackParam(*track.fCp);
473 570 : if (track.fIp) fIp=new AliExternalTrackParam(*track.fIp);
474 570 : if (track.fTPCInner) fTPCInner=new AliExternalTrackParam(*track.fTPCInner);
475 192 : if (track.fOp) fOp=new AliExternalTrackParam(*track.fOp);
476 162 : if (track.fHMPIDp) fHMPIDp=new AliExternalTrackParam(*track.fHMPIDp);
477 162 : if (track.fTPCdEdxInfo) fTPCdEdxInfo = new AliTPCdEdxInfo(*track.fTPCdEdxInfo);
478 :
479 :
480 618 : if (track.fFriendTrack) fFriendTrack=new AliESDfriendTrack(*(track.fFriendTrack));
481 :
482 162 : if(fNtofClusters > 0){
483 0 : fTOFcluster = new Int_t[fNtofClusters];
484 0 : for(Int_t i=0;i < fNtofClusters;i++) fTOFcluster[i] = track.fTOFcluster[i];
485 0 : }
486 324 : }
487 :
488 : //_______________________________________________________________________
489 : AliESDtrack::AliESDtrack(const AliVTrack *track) :
490 0 : AliExternalTrackParam(track),
491 0 : fCp(0),
492 0 : fIp(0),
493 0 : fTPCInner(0),
494 0 : fOp(0),
495 0 : fHMPIDp(0),
496 0 : fFriendTrack(0),
497 0 : fTPCFitMap(159),//number of padrows
498 0 : fTPCClusterMap(159),//number of padrows
499 0 : fTPCSharedMap(159),//number of padrows
500 0 : fFrTrackID(0),
501 0 : fFlags(0),
502 0 : fID(),
503 0 : fLabel(0),
504 0 : fITSLabel(0),
505 0 : fTPCLabel(0),
506 0 : fTRDLabel(0),
507 0 : fTOFLabel(NULL),
508 0 : fTOFCalChannel(-1),
509 0 : fTOFindex(-1),
510 0 : fHMPIDqn(0),
511 0 : fHMPIDcluIdx(-1),
512 0 : fCaloIndex(kEMCALNoMatch),
513 0 : fR(0),
514 0 : fITSr(0),
515 0 : fTPCr(0),
516 0 : fTRDr(0),
517 0 : fTOFr(0),
518 0 : fHMPIDr(0),
519 0 : fHMPIDtrkTheta(0),
520 0 : fHMPIDtrkPhi(0),
521 0 : fHMPIDsignal(0),
522 0 : fTrackTime(NULL),
523 0 : fTrackLength(0),
524 0 : fdTPC(0),fzTPC(0),
525 0 : fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
526 0 : fCchi2TPC(0),
527 0 : fD(0),fZ(0),
528 0 : fCdd(0),fCdz(0),fCzz(0),
529 0 : fCchi2(0),
530 0 : fITSchi2(0),
531 0 : fTPCchi2(0),
532 0 : fTPCchi2Iter1(0),
533 0 : fTRDchi2(0),
534 0 : fTOFchi2(0),
535 0 : fHMPIDchi2(0),
536 0 : fGlobalChi2(0),
537 0 : fITSsignal(0),
538 0 : fITSsignalTuned(0),
539 0 : fTPCsignal(0),
540 0 : fTPCsignalTuned(0),
541 0 : fTPCsignalS(0),
542 0 : fTPCdEdxInfo(0),
543 0 : fTRDsignal(0),
544 0 : fTRDQuality(0),
545 0 : fTRDBudget(0),
546 0 : fTOFsignal(99999),
547 0 : fTOFsignalTuned(99999),
548 0 : fTOFsignalToT(99999),
549 0 : fTOFsignalRaw(99999),
550 0 : fTOFsignalDz(999),
551 0 : fTOFsignalDx(999),
552 0 : fTOFdeltaBC(999),
553 0 : fTOFl0l1(999),
554 0 : fCaloDx(0),
555 0 : fCaloDz(0),
556 0 : fHMPIDtrkX(0),
557 0 : fHMPIDtrkY(0),
558 0 : fHMPIDmipX(0),
559 0 : fHMPIDmipY(0),
560 0 : fTPCncls(0),
561 0 : fTPCnclsF(0),
562 0 : fTPCsignalN(0),
563 0 : fTPCnclsIter1(0),
564 0 : fTPCnclsFIter1(0),
565 0 : fITSncls(0),
566 0 : fITSClusterMap(0),
567 0 : fITSSharedMap(0),
568 0 : fTRDncls(0),
569 0 : fTRDncls0(0),
570 0 : fTRDntracklets(0),
571 0 : fTRDNchamberdEdx(0),
572 0 : fTRDNclusterdEdx(0),
573 0 : fTRDnSlices(0),
574 0 : fTRDslices(0x0),
575 0 : fVertexID(-2), // -2 means an orphan track
576 0 : fPIDForTracking(track->GetPIDForTracking()),
577 0 : fESDEvent(0),
578 0 : fCacheNCrossedRows(-10),
579 0 : fCacheChi2TPCConstrainedVsGlobal(-10),
580 0 : fCacheChi2TPCConstrainedVsGlobalVertex(0),
581 0 : fDetectorPID(0x0),
582 0 : fTrackPhiOnEMCal(-999),
583 0 : fTrackEtaOnEMCal(-999),
584 0 : fTrackPtOnEMCal(-999),
585 0 : fNtofClusters(0),
586 0 : fTOFcluster(NULL)
587 0 : {
588 : //
589 : // ESD track from AliVTrack.
590 : // This is not a copy constructor !
591 : //
592 :
593 0 : if (track->InheritsFrom("AliExternalTrackParam")) {
594 0 : AliError("This is not a copy constructor. Use AliESDtrack(const AliESDtrack &) !");
595 0 : AliWarning("Calling the default constructor...");
596 0 : AliESDtrack();
597 0 : return;
598 : }
599 :
600 : // Reset all the arrays
601 : Int_t i;
602 0 : for (i=kNITSchi2Std;i--;) fITSchi2Std[i] = 0;
603 :
604 0 : for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
605 0 : for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
606 0 : for (i=0;i<kTRDnPlanes;i++) {
607 0 : fTRDTimBin[i]=0;
608 : }
609 0 : for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
610 0 : for (i=0;i<4;i++) {fTPCPoints[i]=0;}
611 0 : for (i=0;i<10;i++) {fTOFInfo[i]=0;}
612 0 : for (i=0;i<12;i++) {fITSModule[i]=-1;}
613 :
614 :
615 : // Set ITS cluster map
616 0 : fITSClusterMap=track->GetITSClusterMap();
617 0 : fITSSharedMap=0;
618 :
619 0 : fITSncls=0;
620 0 : for(i=0; i<6; i++) {
621 0 : if(HasPointOnITSLayer(i)) fITSncls++;
622 : }
623 :
624 : // Set TPC ncls
625 0 : fTPCncls=track->GetTPCNcls();
626 0 : fTPCnclsF=track->GetTPCNclsF();
627 : // TPC cluster maps
628 0 : const TBits* bmap = track->GetTPCClusterMapPtr();
629 0 : if (bmap) SetTPCClusterMap(*bmap);
630 0 : bmap = GetTPCFitMapPtr();
631 0 : if (bmap) SetTPCFitMap(*bmap);
632 0 : bmap = GetTPCSharedMapPtr();
633 0 : if (bmap) SetTPCSharedMap(*bmap);
634 : //
635 : // Set the combined PID
636 0 : const Double_t *pid = track->PID();
637 0 : if(pid) {
638 0 : fR = new Double32_t[AliPID::kSPECIES];
639 0 : for (i=AliPID::kSPECIES; i--;) fR[i]=pid[i];
640 : }
641 : //
642 : // calo matched cluster id
643 0 : SetEMCALcluster(track->GetEMCALcluster());
644 : // AliESD track label
645 : //
646 : // PID info
647 0 : fITSsignal = track->GetITSsignal();
648 0 : fITSsignalTuned = track->GetITSsignalTunedOnData();
649 0 : double itsdEdx[4];
650 0 : track->GetITSdEdxSamples(itsdEdx);
651 0 : SetITSdEdxSamples(itsdEdx);
652 : //
653 0 : SetTPCsignal(track->GetTPCsignal(),fTPCsignalS,track->GetTPCsignalN()); // No signalS in AODPi
654 0 : AliTPCdEdxInfo * dEdxInfo = track->GetTPCdEdxInfo();
655 0 : if (dEdxInfo) SetTPCdEdxInfo(new AliTPCdEdxInfo(*dEdxInfo));
656 : //
657 0 : SetTRDsignal(track->GetTRDsignal());
658 0 : int ntrdsl = track->GetNumberOfTRDslices();
659 0 : if (ntrdsl>0) {
660 0 : SetNumberOfTRDslices((ntrdsl+2)*kTRDnPlanes);
661 0 : for (int ipl=kTRDnPlanes;ipl--;){
662 0 : for (int isl=ntrdsl;isl--;) SetTRDslice(track->GetTRDslice(ipl,isl),ipl,isl);
663 0 : Double_t sp, p = track->GetTRDmomentum(ipl, &sp);
664 0 : SetTRDmomentum(p, ipl, &sp);
665 0 : }
666 0 : }
667 : //
668 0 : fTRDncls = track->GetTRDncls();
669 0 : fTRDntracklets &= 0xff & track->GetTRDntrackletsPID();
670 0 : fTRDchi2 = track->GetTRDchi2();
671 : //
672 0 : SetTOFsignal(track->GetTOFsignal());
673 0 : Double_t expt[AliPID::kSPECIESC];
674 0 : track->GetIntegratedTimes(expt,AliPID::kSPECIESC);
675 0 : SetIntegratedTimes(expt);
676 : //
677 0 : SetTrackPhiEtaPtOnEMCal(track->GetTrackPhiOnEMCal(),track->GetTrackEtaOnEMCal(),track->GetTrackPtOnEMCal());
678 : //
679 0 : SetLabel(track->GetLabel());
680 : // Set the status
681 0 : SetStatus(track->GetStatus());
682 : //
683 : // Set the ID
684 0 : SetID(track->GetID());
685 : //
686 0 : }
687 :
688 : //_______________________________________________________________________
689 : AliESDtrack::AliESDtrack(TParticle * part) :
690 0 : AliExternalTrackParam(),
691 0 : fCp(0),
692 0 : fIp(0),
693 0 : fTPCInner(0),
694 0 : fOp(0),
695 0 : fHMPIDp(0),
696 0 : fFriendTrack(0),
697 0 : fTPCFitMap(159),//number of padrows
698 0 : fTPCClusterMap(159),//number of padrows
699 0 : fTPCSharedMap(159),//number of padrows
700 0 : fFrTrackID(0),
701 0 : fFlags(0),
702 0 : fID(0),
703 0 : fLabel(0),
704 0 : fITSLabel(0),
705 0 : fTPCLabel(0),
706 0 : fTRDLabel(0),
707 0 : fTOFLabel(NULL),
708 0 : fTOFCalChannel(-1),
709 0 : fTOFindex(-1),
710 0 : fHMPIDqn(0),
711 0 : fHMPIDcluIdx(-1),
712 0 : fCaloIndex(kEMCALNoMatch),
713 0 : fR(0),
714 0 : fITSr(0),
715 0 : fTPCr(0),
716 0 : fTRDr(0),
717 0 : fTOFr(0),
718 0 : fHMPIDr(0),
719 0 : fHMPIDtrkTheta(0),
720 0 : fHMPIDtrkPhi(0),
721 0 : fHMPIDsignal(0),
722 0 : fTrackTime(NULL),
723 0 : fTrackLength(0),
724 0 : fdTPC(0),fzTPC(0),
725 0 : fCddTPC(0),fCdzTPC(0),fCzzTPC(0),
726 0 : fCchi2TPC(0),
727 0 : fD(0),fZ(0),
728 0 : fCdd(0),fCdz(0),fCzz(0),
729 0 : fCchi2(0),
730 0 : fITSchi2(0),
731 0 : fTPCchi2(0),
732 0 : fTPCchi2Iter1(0),
733 0 : fTRDchi2(0),
734 0 : fTOFchi2(0),
735 0 : fHMPIDchi2(0),
736 0 : fGlobalChi2(0),
737 0 : fITSsignal(0),
738 0 : fITSsignalTuned(0),
739 0 : fTPCsignal(0),
740 0 : fTPCsignalTuned(0),
741 0 : fTPCsignalS(0),
742 0 : fTPCdEdxInfo(0),
743 0 : fTRDsignal(0),
744 0 : fTRDQuality(0),
745 0 : fTRDBudget(0),
746 0 : fTOFsignal(99999),
747 0 : fTOFsignalTuned(99999),
748 0 : fTOFsignalToT(99999),
749 0 : fTOFsignalRaw(99999),
750 0 : fTOFsignalDz(999),
751 0 : fTOFsignalDx(999),
752 0 : fTOFdeltaBC(999),
753 0 : fTOFl0l1(999),
754 0 : fCaloDx(0),
755 0 : fCaloDz(0),
756 0 : fHMPIDtrkX(0),
757 0 : fHMPIDtrkY(0),
758 0 : fHMPIDmipX(0),
759 0 : fHMPIDmipY(0),
760 0 : fTPCncls(0),
761 0 : fTPCnclsF(0),
762 0 : fTPCsignalN(0),
763 0 : fTPCnclsIter1(0),
764 0 : fTPCnclsFIter1(0),
765 0 : fITSncls(0),
766 0 : fITSClusterMap(0),
767 0 : fITSSharedMap(0),
768 0 : fTRDncls(0),
769 0 : fTRDncls0(0),
770 0 : fTRDntracklets(0),
771 0 : fTRDNchamberdEdx(0),
772 0 : fTRDNclusterdEdx(0),
773 0 : fTRDnSlices(0),
774 0 : fTRDslices(0x0),
775 0 : fVertexID(-2), // -2 means an orphan track
776 0 : fPIDForTracking(AliPID::kPion),
777 0 : fESDEvent(0),
778 0 : fCacheNCrossedRows(-10),
779 0 : fCacheChi2TPCConstrainedVsGlobal(-10),
780 0 : fCacheChi2TPCConstrainedVsGlobalVertex(0),
781 0 : fDetectorPID(0x0),
782 0 : fTrackPhiOnEMCal(-999),
783 0 : fTrackEtaOnEMCal(-999),
784 0 : fTrackPtOnEMCal(-999),
785 0 : fNtofClusters(0),
786 0 : fTOFcluster(NULL)
787 0 : {
788 : //
789 : // ESD track from TParticle
790 : //
791 :
792 : // Reset all the arrays
793 : Int_t i;
794 0 : for (i=kNITSchi2Std;i--;) fITSchi2Std[i] = 0;
795 :
796 0 : for (i=0; i<3; i++) { fKinkIndexes[i]=0;}
797 0 : for (i=0; i<3; i++) { fV0Indexes[i]=-1;}
798 0 : for (i=0;i<kTRDnPlanes;i++) {
799 0 : fTRDTimBin[i]=0;
800 : }
801 0 : for (i=0;i<4;i++) {fITSdEdxSamples[i]=0.;}
802 0 : for (i=0;i<4;i++) {fTPCPoints[i]=0;}
803 0 : for (i=0;i<10;i++) {fTOFInfo[i]=0;}
804 0 : for (i=0;i<12;i++) {fITSModule[i]=-1;}
805 :
806 : // Calculate the AliExternalTrackParam content
807 :
808 : Double_t xref;
809 : Double_t alpha;
810 0 : Double_t param[5];
811 0 : Double_t covar[15];
812 :
813 : // Calculate alpha: the rotation angle of the corresponding local system (TPC sector)
814 0 : alpha = part->Phi()*180./TMath::Pi();
815 0 : if (alpha<0) alpha+= 360.;
816 0 : if (alpha>360) alpha -= 360.;
817 :
818 0 : Int_t sector = (Int_t)(alpha/20.);
819 0 : alpha = 10. + 20.*sector;
820 0 : alpha /= 180;
821 0 : alpha *= TMath::Pi();
822 :
823 : // Covariance matrix: no errors, the parameters are exact
824 0 : for (i=0; i<15; i++) covar[i]=0.;
825 :
826 : // Get the vertex of origin and the momentum
827 0 : TVector3 ver(part->Vx(),part->Vy(),part->Vz());
828 0 : TVector3 mom(part->Px(),part->Py(),part->Pz());
829 :
830 : // Rotate to the local coordinate system (TPC sector)
831 0 : ver.RotateZ(-alpha);
832 0 : mom.RotateZ(-alpha);
833 :
834 : // X of the referense plane
835 0 : xref = ver.X();
836 :
837 0 : Int_t pdgCode = part->GetPdgCode();
838 :
839 : Double_t charge =
840 0 : TDatabasePDG::Instance()->GetParticle(pdgCode)->Charge();
841 :
842 0 : param[0] = ver.Y();
843 0 : param[1] = ver.Z();
844 0 : param[2] = TMath::Sin(mom.Phi());
845 0 : param[3] = mom.Pz()/mom.Pt();
846 0 : param[4] = TMath::Sign(1/mom.Pt(),charge);
847 :
848 : // Set AliExternalTrackParam
849 0 : Set(xref, alpha, param, covar);
850 :
851 : // Set the PID
852 : Int_t indexPID = 99;
853 0 : if (pdgCode<0) pdgCode = -pdgCode;
854 0 : for (i=0;i<AliPID::kSPECIESC;i++) if (pdgCode==AliPID::ParticleCode(i)) {indexPID = i; break;}
855 :
856 0 : if (indexPID < AliPID::kSPECIESC) fPIDForTracking = indexPID;
857 :
858 : // AliESD track label
859 0 : SetLabel(part->GetUniqueID());
860 :
861 0 : }
862 :
863 : //_______________________________________________________________________
864 2812 : AliESDtrack::~AliESDtrack(){
865 : //
866 : // This is destructor according Coding Conventrions
867 : //
868 : //printf("Delete track\n");
869 968 : delete fIp;
870 968 : delete fTPCInner;
871 880 : delete fOp;
872 542 : delete fHMPIDp;
873 874 : delete fCp;
874 1024 : delete fFriendTrack;
875 832 : delete fTPCdEdxInfo;
876 522 : if(fTRDnSlices)
877 464 : delete[] fTRDslices;
878 :
879 : //Reset cached values - needed for TClonesArray in AliESDInputHandler
880 522 : fCacheNCrossedRows = -10.;
881 522 : fCacheChi2TPCConstrainedVsGlobal = -10.;
882 522 : if(fCacheChi2TPCConstrainedVsGlobalVertex) fCacheChi2TPCConstrainedVsGlobalVertex = 0;
883 :
884 522 : if(fTOFcluster)
885 372 : delete[] fTOFcluster;
886 522 : fTOFcluster = NULL;
887 522 : fNtofClusters=0;
888 :
889 522 : delete fDetectorPID;
890 :
891 522 : delete[] fR;
892 522 : delete[] fITSr;
893 522 : delete[] fTPCr;
894 626 : delete[] fTRDr;
895 522 : delete[] fTOFr;
896 530 : delete[] fHMPIDr;
897 : //
898 846 : if(fTrackTime) delete[] fTrackTime;
899 522 : if(fTOFLabel) delete[] fTOFLabel;
900 1406 : }
901 :
902 : //_______________________________________________________________________
903 : AliESDtrack &AliESDtrack::operator=(const AliESDtrack &source)
904 : {
905 : // == operator
906 :
907 0 : if(&source == this) return *this;
908 0 : AliExternalTrackParam::operator=(source);
909 :
910 :
911 0 : if(source.fCp){
912 : // we have the trackparam: assign or copy construct
913 0 : if(fCp)*fCp = *source.fCp;
914 0 : else fCp = new AliExternalTrackParam(*source.fCp);
915 : }
916 : else{
917 : // no track param delete the old one
918 0 : delete fCp;
919 0 : fCp = 0;
920 : }
921 :
922 0 : if(source.fIp){
923 : // we have the trackparam: assign or copy construct
924 0 : if(fIp)*fIp = *source.fIp;
925 0 : else fIp = new AliExternalTrackParam(*source.fIp);
926 : }
927 : else{
928 : // no track param delete the old one
929 0 : delete fIp;
930 0 : fIp = 0;
931 : }
932 :
933 :
934 0 : if(source.fTPCInner){
935 : // we have the trackparam: assign or copy construct
936 0 : if(fTPCInner) *fTPCInner = *source.fTPCInner;
937 0 : else fTPCInner = new AliExternalTrackParam(*source.fTPCInner);
938 : }
939 : else{
940 : // no track param delete the old one
941 0 : delete fTPCInner;
942 0 : fTPCInner = 0;
943 : }
944 :
945 0 : if(source.fTPCdEdxInfo) {
946 0 : if(fTPCdEdxInfo) *fTPCdEdxInfo = *source.fTPCdEdxInfo;
947 0 : fTPCdEdxInfo = new AliTPCdEdxInfo(*source.fTPCdEdxInfo);
948 0 : }
949 :
950 0 : if(source.fOp){
951 : // we have the trackparam: assign or copy construct
952 0 : if(fOp) *fOp = *source.fOp;
953 0 : else fOp = new AliExternalTrackParam(*source.fOp);
954 : }
955 : else{
956 : // no track param delete the old one
957 0 : delete fOp;
958 0 : fOp = 0;
959 : }
960 :
961 :
962 0 : if(source.fHMPIDp){
963 : // we have the trackparam: assign or copy construct
964 0 : if(fHMPIDp) *fHMPIDp = *source.fHMPIDp;
965 0 : else fHMPIDp = new AliExternalTrackParam(*source.fHMPIDp);
966 : }
967 : else{
968 : // no track param delete the old one
969 0 : delete fHMPIDp;
970 0 : fHMPIDp = 0;
971 : }
972 :
973 : // copy also the friend track
974 : // use copy constructor
975 0 : if(source.fFriendTrack){
976 : // we have the trackparam: assign or copy construct
977 0 : delete fFriendTrack; fFriendTrack=new AliESDfriendTrack(*source.fFriendTrack);
978 0 : }
979 : else{
980 : // no track param delete the old one
981 0 : delete fFriendTrack; fFriendTrack= 0;
982 : }
983 :
984 0 : fTPCFitMap = source.fTPCFitMap;
985 0 : fTPCClusterMap = source.fTPCClusterMap;
986 0 : fTPCSharedMap = source.fTPCSharedMap;
987 : // the simple stuff
988 0 : fFrTrackID = source.fFrTrackID;
989 0 : fFlags = source.fFlags;
990 0 : fID = source.fID;
991 0 : fLabel = source.fLabel;
992 0 : fITSLabel = source.fITSLabel;
993 0 : for(int i = 0; i< 12;++i){
994 0 : fITSModule[i] = source.fITSModule[i];
995 : }
996 0 : fTPCLabel = source.fTPCLabel;
997 0 : fTRDLabel = source.fTRDLabel;
998 0 : if(source.fTOFLabel){
999 0 : if(!fTOFLabel) fTOFLabel = new Int_t[3];
1000 0 : for(int i = 0; i< 3;++i){
1001 0 : fTOFLabel[i] = source.fTOFLabel[i];
1002 : }
1003 0 : }
1004 0 : fTOFCalChannel = source.fTOFCalChannel;
1005 0 : fTOFindex = source.fTOFindex;
1006 0 : fHMPIDqn = source.fHMPIDqn;
1007 0 : fHMPIDcluIdx = source.fHMPIDcluIdx;
1008 0 : fCaloIndex = source.fCaloIndex;
1009 0 : for (int i=kNITSchi2Std;i--;) fITSchi2Std[i] = source.fITSchi2Std[i];
1010 0 : for(int i = 0; i< 3;++i){
1011 0 : fKinkIndexes[i] = source.fKinkIndexes[i];
1012 0 : fV0Indexes[i] = source.fV0Indexes[i];
1013 : }
1014 :
1015 0 : if (source.fR) {
1016 0 : if (!fR) fR = new Double32_t[AliPID::kSPECIES];
1017 0 : for (Int_t i=AliPID::kSPECIES;i--;) fR[i]=source.fR[i];
1018 0 : }
1019 0 : else {delete[] fR; fR = 0;}
1020 :
1021 0 : if (source.fITSr) {
1022 0 : if (!fITSr) fITSr = new Double32_t[AliPID::kSPECIES];
1023 0 : for (Int_t i=AliPID::kSPECIES;i--;) fITSr[i]=source.fITSr[i];
1024 0 : }
1025 0 : else {delete[] fITSr; fITSr = 0;}
1026 : //
1027 0 : if (source.fTPCr) {
1028 0 : if (!fTPCr) fTPCr = new Double32_t[AliPID::kSPECIES];
1029 0 : for (Int_t i=AliPID::kSPECIES;i--;) fTPCr[i]=source.fTPCr[i];
1030 0 : }
1031 0 : else {delete[] fTPCr; fTPCr = 0;}
1032 :
1033 0 : if (source.fTRDr) {
1034 0 : if (!fTRDr) fTRDr = new Double32_t[AliPID::kSPECIES];
1035 0 : for (Int_t i=AliPID::kSPECIES;i--;) fTRDr[i]=source.fTRDr[i];
1036 0 : }
1037 0 : else {delete[] fTRDr; fTRDr = 0;}
1038 :
1039 0 : if (source.fTOFr) {
1040 0 : if (!fTOFr) fTOFr = new Double32_t[AliPID::kSPECIES];
1041 0 : for (Int_t i=AliPID::kSPECIES;i--;) fTOFr[i]=source.fTOFr[i];
1042 0 : }
1043 0 : else {delete[] fTOFr; fTOFr = 0;}
1044 :
1045 0 : if (source.fHMPIDr) {
1046 0 : if (!fHMPIDr) fHMPIDr = new Double32_t[AliPID::kSPECIES];
1047 0 : for (Int_t i=AliPID::kSPECIES;i--;) fHMPIDr[i]=source.fHMPIDr[i];
1048 0 : }
1049 0 : else {delete[] fHMPIDr; fHMPIDr = 0;}
1050 :
1051 0 : fPIDForTracking = source.fPIDForTracking;
1052 :
1053 0 : fHMPIDtrkTheta = source.fHMPIDtrkTheta;
1054 0 : fHMPIDtrkPhi = source.fHMPIDtrkPhi;
1055 0 : fHMPIDsignal = source.fHMPIDsignal;
1056 :
1057 :
1058 0 : if(fTrackTime){
1059 0 : delete[] fTrackTime;
1060 : }
1061 0 : if(source.fTrackTime){
1062 0 : fTrackTime = new Double32_t[AliPID::kSPECIESC];
1063 0 : for(Int_t i=0;i < AliPID::kSPECIESC;i++)
1064 0 : fTrackTime[i] = source.fTrackTime[i];
1065 0 : }
1066 :
1067 0 : fTrackLength = source. fTrackLength;
1068 0 : fdTPC = source.fdTPC;
1069 0 : fzTPC = source.fzTPC;
1070 0 : fCddTPC = source.fCddTPC;
1071 0 : fCdzTPC = source.fCdzTPC;
1072 0 : fCzzTPC = source.fCzzTPC;
1073 0 : fCchi2TPC = source.fCchi2TPC;
1074 :
1075 0 : fD = source.fD;
1076 0 : fZ = source.fZ;
1077 0 : fCdd = source.fCdd;
1078 0 : fCdz = source.fCdz;
1079 0 : fCzz = source.fCzz;
1080 0 : fCchi2 = source.fCchi2;
1081 :
1082 0 : fITSchi2 = source.fITSchi2;
1083 0 : fTPCchi2 = source.fTPCchi2;
1084 0 : fTPCchi2Iter1 = source.fTPCchi2Iter1;
1085 0 : fTRDchi2 = source.fTRDchi2;
1086 0 : fTOFchi2 = source.fTOFchi2;
1087 0 : fHMPIDchi2 = source.fHMPIDchi2;
1088 :
1089 0 : fGlobalChi2 = source.fGlobalChi2;
1090 :
1091 0 : fITSsignal = source.fITSsignal;
1092 0 : fITSsignalTuned = source.fITSsignalTuned;
1093 0 : for (Int_t i=0;i<4;i++) {fITSdEdxSamples[i]=source.fITSdEdxSamples[i];}
1094 0 : fTPCsignal = source.fTPCsignal;
1095 0 : fTPCsignalTuned = source.fTPCsignalTuned;
1096 0 : fTPCsignalS = source.fTPCsignalS;
1097 0 : for(int i = 0; i< 4;++i){
1098 0 : fTPCPoints[i] = source.fTPCPoints[i];
1099 : }
1100 0 : fTRDsignal = source.fTRDsignal;
1101 0 : fTRDNchamberdEdx = source.fTRDNchamberdEdx;
1102 0 : fTRDNclusterdEdx = source.fTRDNclusterdEdx;
1103 :
1104 0 : for(int i = 0;i < kTRDnPlanes;++i){
1105 0 : fTRDTimBin[i] = source.fTRDTimBin[i];
1106 : }
1107 :
1108 0 : if(fTRDnSlices)
1109 0 : delete[] fTRDslices;
1110 0 : fTRDslices=0;
1111 0 : fTRDnSlices=source.fTRDnSlices;
1112 0 : if (fTRDnSlices) {
1113 0 : fTRDslices=new Double32_t[fTRDnSlices];
1114 0 : for(int j = 0;j < fTRDnSlices;++j) fTRDslices[j] = source.fTRDslices[j];
1115 0 : }
1116 :
1117 0 : fTRDQuality = source.fTRDQuality;
1118 0 : fTRDBudget = source.fTRDBudget;
1119 0 : fTOFsignal = source.fTOFsignal;
1120 0 : fTOFsignalTuned = source.fTOFsignalTuned;
1121 0 : fTOFsignalToT = source.fTOFsignalToT;
1122 0 : fTOFsignalRaw = source.fTOFsignalRaw;
1123 0 : fTOFsignalDz = source.fTOFsignalDz;
1124 0 : fTOFsignalDx = source.fTOFsignalDx;
1125 0 : fTOFdeltaBC = source.fTOFdeltaBC;
1126 0 : fTOFl0l1 = source.fTOFl0l1;
1127 :
1128 0 : for(int i = 0;i<10;++i){
1129 0 : fTOFInfo[i] = source.fTOFInfo[i];
1130 : }
1131 :
1132 0 : fHMPIDtrkX = source.fHMPIDtrkX;
1133 0 : fHMPIDtrkY = source.fHMPIDtrkY;
1134 0 : fHMPIDmipX = source.fHMPIDmipX;
1135 0 : fHMPIDmipY = source.fHMPIDmipY;
1136 :
1137 0 : fTPCncls = source.fTPCncls;
1138 0 : fTPCnclsF = source.fTPCnclsF;
1139 0 : fTPCsignalN = source.fTPCsignalN;
1140 0 : fTPCnclsIter1 = source.fTPCnclsIter1;
1141 0 : fTPCnclsFIter1 = source.fTPCnclsFIter1;
1142 :
1143 0 : fITSncls = source.fITSncls;
1144 0 : fITSClusterMap = source.fITSClusterMap;
1145 0 : fITSSharedMap = source.fITSSharedMap;
1146 0 : fTRDncls = source.fTRDncls;
1147 0 : fTRDncls0 = source.fTRDncls0;
1148 0 : fTRDntracklets = source.fTRDntracklets;
1149 0 : fVertexID = source.fVertexID;
1150 0 : fPIDForTracking = source.fPIDForTracking;
1151 :
1152 0 : fCacheNCrossedRows = source.fCacheNCrossedRows;
1153 0 : fCacheChi2TPCConstrainedVsGlobal = source.fCacheChi2TPCConstrainedVsGlobal;
1154 0 : fCacheChi2TPCConstrainedVsGlobalVertex = source.fCacheChi2TPCConstrainedVsGlobalVertex;
1155 :
1156 0 : delete fDetectorPID;
1157 0 : fDetectorPID=0x0;
1158 0 : if (source.fDetectorPID) fDetectorPID = new AliDetectorPID(*source.fDetectorPID);
1159 :
1160 0 : fTrackPhiOnEMCal= source.fTrackPhiOnEMCal;
1161 0 : fTrackEtaOnEMCal= source.fTrackEtaOnEMCal;
1162 0 : fTrackPtOnEMCal= source.fTrackPtOnEMCal;
1163 :
1164 0 : if(fTOFcluster){
1165 0 : delete[] fTOFcluster;
1166 : }
1167 0 : fNtofClusters = source.fNtofClusters;
1168 0 : if(fNtofClusters > 0){
1169 0 : fTOFcluster = new Int_t[fNtofClusters];
1170 0 : for(Int_t i=0;i < fNtofClusters;i++) fTOFcluster[i] = source.fTOFcluster[i];
1171 0 : }
1172 :
1173 0 : return *this;
1174 0 : }
1175 :
1176 :
1177 :
1178 : void AliESDtrack::Copy(TObject &obj) const {
1179 :
1180 : // this overwrites the virtual TOBject::Copy()
1181 : // to allow run time copying without casting
1182 : // in AliESDEvent
1183 :
1184 0 : if(this==&obj)return;
1185 0 : AliESDtrack *robj = dynamic_cast<AliESDtrack*>(&obj);
1186 0 : if(!robj)return; // not an AliESDtrack
1187 0 : *robj = *this;
1188 :
1189 0 : }
1190 :
1191 :
1192 :
1193 : void AliESDtrack::AddCalibObject(TObject * object){
1194 : //
1195 : // add calib object to the list
1196 : //
1197 496 : if (!fFriendTrack) fFriendTrack = new AliESDfriendTrack;
1198 248 : if (!fFriendTrack) return;
1199 248 : fFriendTrack->AddCalibObject(object);
1200 496 : }
1201 :
1202 : TObject * AliESDtrack::GetCalibObject(Int_t index){
1203 : //
1204 : // return calib objct at given position
1205 : //
1206 230 : if (!fFriendTrack) return 0;
1207 115 : return fFriendTrack->GetCalibObject(index);
1208 115 : }
1209 :
1210 :
1211 : Bool_t AliESDtrack::FillTPCOnlyTrack(AliESDtrack &track){
1212 :
1213 : // Fills the information of the TPC-only first reconstruction pass
1214 : // into the passed ESDtrack object. For consistency fTPCInner is also filled
1215 : // again
1216 :
1217 :
1218 :
1219 : // For data produced before r26675
1220 : // RelateToVertexTPC was not properly called during reco
1221 : // so you'll have to call it again, before FillTPCOnlyTrack
1222 : // Float_t p[2],cov[3];
1223 : // track->GetImpactParametersTPC(p,cov);
1224 : // if(p[0]==0&&p[1]==0) // <- Default values
1225 : // track->RelateToVertexTPC(esd->GetPrimaryVertexTPC(),esd->GetMagneticField(),kVeryBig);
1226 :
1227 :
1228 0 : if(!fTPCInner)return kFALSE;
1229 :
1230 : // fill the TPC track params to the global track parameters
1231 0 : track.Set(fTPCInner->GetX(),fTPCInner->GetAlpha(),fTPCInner->GetParameter(),fTPCInner->GetCovariance());
1232 0 : track.fD = fdTPC;
1233 0 : track.fZ = fzTPC;
1234 0 : track.fCdd = fCddTPC;
1235 0 : track.fCdz = fCdzTPC;
1236 0 : track.fCzz = fCzzTPC;
1237 :
1238 : // copy the inner params
1239 0 : if(track.fIp) *track.fIp = *fIp;
1240 0 : else track.fIp = new AliExternalTrackParam(*fIp);
1241 :
1242 : // copy the TPCinner parameters
1243 0 : if(track.fTPCInner) *track.fTPCInner = *fTPCInner;
1244 0 : else track.fTPCInner = new AliExternalTrackParam(*fTPCInner);
1245 0 : track.fdTPC = fdTPC;
1246 0 : track.fzTPC = fzTPC;
1247 0 : track.fCddTPC = fCddTPC;
1248 0 : track.fCdzTPC = fCdzTPC;
1249 0 : track.fCzzTPC = fCzzTPC;
1250 0 : track.fCchi2TPC = fCchi2TPC;
1251 :
1252 : // copy all other TPC specific parameters
1253 :
1254 : // replace label by TPC label
1255 0 : track.fLabel = fTPCLabel;
1256 0 : track.fTPCLabel = fTPCLabel;
1257 :
1258 0 : track.fTPCchi2 = fTPCchi2;
1259 0 : track.fTPCchi2Iter1 = fTPCchi2Iter1;
1260 0 : track.fTPCsignal = fTPCsignal;
1261 0 : track.fTPCsignalTuned = fTPCsignalTuned;
1262 0 : track.fTPCsignalS = fTPCsignalS;
1263 0 : for(int i = 0;i<4;++i)track.fTPCPoints[i] = fTPCPoints[i];
1264 :
1265 0 : track.fTPCncls = fTPCncls;
1266 0 : track.fTPCnclsF = fTPCnclsF;
1267 0 : track.fTPCsignalN = fTPCsignalN;
1268 0 : track.fTPCnclsIter1 = fTPCnclsIter1;
1269 0 : track.fTPCnclsFIter1 = fTPCnclsFIter1;
1270 :
1271 : // PID
1272 0 : if (fTPCr) {
1273 0 : if (!track.fTPCr) track.fTPCr = new Double32_t[AliPID::kSPECIES];
1274 0 : for(int i=AliPID::kSPECIES;i--;) track.fTPCr[i] = fTPCr[i];
1275 0 : }
1276 : //
1277 0 : if (fR) {
1278 0 : if (!track.fR) track.fR = new Double32_t[AliPID::kSPECIES];
1279 0 : for(int i=AliPID::kSPECIES;i--;) track.fR[i] = fR[i];
1280 0 : }
1281 :
1282 0 : track.fTPCFitMap = fTPCFitMap;
1283 0 : track.fTPCClusterMap = fTPCClusterMap;
1284 0 : track.fTPCSharedMap = fTPCSharedMap;
1285 :
1286 :
1287 : // reset the flags
1288 0 : track.fFlags = kTPCin;
1289 0 : track.fID = fID;
1290 :
1291 0 : track.fFlags |= fFlags & kTPCpid; //copy the TPCpid status flag
1292 :
1293 0 : for (Int_t i=0;i<3;i++) track.fKinkIndexes[i] = fKinkIndexes[i];
1294 :
1295 0 : return kTRUE;
1296 :
1297 0 : }
1298 :
1299 : //_______________________________________________________________________
1300 : void AliESDtrack::MakeMiniESDtrack(){
1301 : // Resets everything except
1302 : // fFlags: Reconstruction status flags
1303 : // fLabel: Track label
1304 : // fID: Unique ID of the track
1305 : // Impact parameter information
1306 : // fR[AliPID::kSPECIES]: combined "detector response probability"
1307 : // Running track parameters in the base class (AliExternalTrackParam)
1308 :
1309 0 : fTrackLength = 0;
1310 :
1311 0 : if(fTrackTime)
1312 0 : for (Int_t i=0;i<AliPID::kSPECIESC;i++) fTrackTime[i] = 0;
1313 :
1314 : // Reset track parameters constrained to the primary vertex
1315 0 : delete fCp;fCp = 0;
1316 :
1317 : // Reset track parameters at the inner wall of TPC
1318 0 : delete fIp;fIp = 0;
1319 0 : delete fTPCInner;fTPCInner=0;
1320 : // Reset track parameters at the inner wall of the TRD
1321 0 : delete fOp;fOp = 0;
1322 : // Reset track parameters at the HMPID
1323 0 : delete fHMPIDp;fHMPIDp = 0;
1324 :
1325 :
1326 : // Reset ITS track related information
1327 0 : fITSchi2 = 0;
1328 0 : fITSncls = 0;
1329 0 : fITSClusterMap=0;
1330 0 : fITSSharedMap=0;
1331 0 : fITSsignal = 0;
1332 0 : fITSsignalTuned = 0;
1333 0 : for (Int_t i=0;i<4;i++) fITSdEdxSamples[i] = 0.;
1334 0 : if (fITSr) for (Int_t i=0;i<AliPID::kSPECIES;i++) fITSr[i]=0;
1335 0 : fITSLabel = 0;
1336 :
1337 : // Reset TPC related track information
1338 0 : fTPCchi2 = 0;
1339 0 : fTPCchi2Iter1 = 0;
1340 0 : fTPCncls = 0;
1341 0 : fTPCnclsF = 0;
1342 0 : fTPCnclsIter1 = 0;
1343 0 : fTPCnclsFIter1 = 0;
1344 0 : fTPCFitMap = 0;
1345 0 : fTPCClusterMap = 0;
1346 0 : fTPCSharedMap = 0;
1347 0 : fTPCsignal= 0;
1348 0 : fTPCsignalTuned= 0;
1349 0 : fTPCsignalS= 0;
1350 0 : fTPCsignalN= 0;
1351 0 : if (fTPCr) for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i] = 0;
1352 0 : fTPCLabel=0;
1353 0 : for (Int_t i=0;i<4;i++) fTPCPoints[i] = 0;
1354 0 : for (Int_t i=0; i<3;i++) fKinkIndexes[i] = 0;
1355 0 : for (Int_t i=0; i<3;i++) fV0Indexes[i] = 0;
1356 :
1357 : // Reset TRD related track information
1358 0 : fTRDchi2 = 0;
1359 0 : fTRDncls = 0;
1360 0 : fTRDncls0 = 0;
1361 0 : fTRDsignal = 0;
1362 0 : fTRDNchamberdEdx = 0;
1363 0 : fTRDNclusterdEdx = 0;
1364 :
1365 0 : for (Int_t i=0;i<kTRDnPlanes;i++) {
1366 0 : fTRDTimBin[i] = 0;
1367 : }
1368 0 : if (fTRDr) for (Int_t i=0;i<AliPID::kSPECIES;i++) fTRDr[i] = 0;
1369 0 : fTRDLabel = 0;
1370 0 : fTRDQuality = 0;
1371 0 : fTRDntracklets = 0;
1372 0 : if(fTRDnSlices)
1373 0 : delete[] fTRDslices;
1374 0 : fTRDslices=0x0;
1375 0 : fTRDnSlices=0;
1376 0 : fTRDBudget = 0;
1377 :
1378 : // Reset TOF related track information
1379 0 : fTOFchi2 = 0;
1380 0 : fTOFindex = -1;
1381 0 : fTOFsignal = 99999;
1382 0 : fTOFCalChannel = -1;
1383 0 : fTOFsignalToT = 99999;
1384 0 : fTOFsignalRaw = 99999;
1385 0 : fTOFsignalDz = 999;
1386 0 : fTOFsignalDx = 999;
1387 0 : fTOFdeltaBC = 999;
1388 0 : fTOFl0l1 = 999;
1389 0 : if (fTOFr) for (Int_t i=0;i<AliPID::kSPECIES;i++) fTOFr[i] = 0;
1390 0 : for (Int_t i=0;i<10;i++) fTOFInfo[i] = 0;
1391 :
1392 : // Reset HMPID related track information
1393 0 : fHMPIDchi2 = 0;
1394 0 : fHMPIDqn = 0;
1395 0 : fHMPIDcluIdx = -1;
1396 0 : fHMPIDsignal = 0;
1397 0 : if (fHMPIDr) for (Int_t i=0;i<AliPID::kSPECIES;i++) fHMPIDr[i] = 0;
1398 0 : fHMPIDtrkTheta = 0;
1399 0 : fHMPIDtrkPhi = 0;
1400 0 : fHMPIDtrkX = 0;
1401 0 : fHMPIDtrkY = 0;
1402 0 : fHMPIDmipX = 0;
1403 0 : fHMPIDmipY = 0;
1404 0 : fCaloIndex = kEMCALNoMatch;
1405 :
1406 : // reset global track chi2
1407 0 : fGlobalChi2 = 0;
1408 :
1409 0 : fVertexID = -2; // an orphan track
1410 0 : fPIDForTracking = AliPID::kPion;
1411 : //
1412 0 : delete fFriendTrack; fFriendTrack = 0;
1413 0 : }
1414 :
1415 : //_______________________________________________________________________
1416 : Int_t AliESDtrack::GetPID(Bool_t tpcOnly) const
1417 : {
1418 : // Returns the particle most probable id. For backward compatibility first the prob. arrays
1419 : // will be checked, but normally the GetPIDForTracking will be returned
1420 : Int_t i;
1421 : const Double32_t *prob = 0;
1422 1295 : if (tpcOnly) { // check if TPCpid is valid
1423 442 : if (!fTPCr) return GetPIDForTracking();
1424 : prob = fTPCr;
1425 0 : for (i=0; i<AliPID::kSPECIES-1; i++) if (prob[i] != prob[i+1]) break;
1426 0 : if (i == AliPID::kSPECIES-1) prob = 0; // not valid, try with combined pid
1427 : }
1428 1074 : if (!prob) { // either requested TPCpid is not valid or comb.pid is requested
1429 2148 : if (!fR) return GetPIDForTracking();
1430 : prob = fR;
1431 0 : for (i=0; i<AliPID::kSPECIES-1; i++) if (prob[i] != prob[i+1]) break;
1432 0 : if (i == AliPID::kSPECIES-1) return GetPIDForTracking(); // If all the probabilities are equal, return the pion mass
1433 : }
1434 : //
1435 : Float_t max=0.;
1436 : Int_t k=-1;
1437 0 : for (i=0; i<AliPID::kSPECIES; i++) if (prob[i]>max) {k=i; max=prob[i];}
1438 : //
1439 0 : if (k==0) { // dE/dx "crossing points" in the TPC
1440 : /*
1441 : Double_t p=GetP();
1442 : if ((p>0.38)&&(p<0.48))
1443 : if (prob[0]<prob[3]*10.) return AliPID::kKaon;
1444 : if ((p>0.75)&&(p<0.85))
1445 : if (prob[0]<prob[4]*10.) return AliPID::kProton;
1446 : */
1447 0 : return AliPID::kElectron;
1448 : }
1449 0 : if (k==1) return AliPID::kMuon;
1450 0 : if (k==2||k==-1) return AliPID::kPion;
1451 0 : if (k==3) return AliPID::kKaon;
1452 0 : if (k==4) return AliPID::kProton;
1453 : // AliWarning("Undefined PID !");
1454 0 : return GetPIDForTracking();
1455 1295 : }
1456 :
1457 : //_______________________________________________________________________
1458 : Int_t AliESDtrack::GetTOFBunchCrossing(Double_t b, Bool_t pidTPConly) const
1459 : {
1460 : // Returns the number of bunch crossings after trigger (assuming 25ns spacing)
1461 : const double kSpacing = 25; // min interbanch spacing in ns
1462 0 : if (!IsOn(kTOFout)) return kTOFBCNA;
1463 0 : double tdif = GetTOFExpTDiff(b,pidTPConly);
1464 0 : return TMath::Nint(tdif/kSpacing);
1465 : //
1466 0 : }
1467 :
1468 : //_______________________________________________________________________
1469 : Double_t AliESDtrack::GetTOFExpTDiff(Double_t b, Bool_t pidTPConly) const
1470 : {
1471 : // Returns the time difference in ns between TOF signal and expected time
1472 : const double kps2ns = 1e-3; // we need ns
1473 : const double kNoInfo = kTOFBCNA*25; // no info
1474 125 : if (!IsOn(kTOFout)) return kNoInfo; // no info
1475 : //
1476 59 : double tdif = GetTOFsignal();
1477 59 : if (IsOn(kTIME)) { // integrated time info is there
1478 59 : int pid = GetPID(pidTPConly);
1479 59 : Double_t times[AliPID::kSPECIESC];
1480 : // old esd has only AliPID::kSPECIES times
1481 59 : GetIntegratedTimes(times,pid>=AliPID::kSPECIES ? AliPID::kSPECIESC : AliPID::kSPECIES);
1482 59 : tdif -= times[pid];
1483 59 : }
1484 : else { // assume integrated time info from TOF radius and momentum
1485 : const double kRTOF = 385.;
1486 : const double kCSpeed = 3.e-2; // cm/ps
1487 0 : double p = GetP();
1488 0 : if (p<0.01) return kNoInfo;
1489 0 : double m = GetMass(pidTPConly);
1490 0 : double curv = GetC(b);
1491 0 : double path = TMath::Abs(curv)>kAlmost0 ? // account for curvature
1492 0 : 2./curv*TMath::ASin(kRTOF*curv/2.)*TMath::Sqrt(1.+GetTgl()*GetTgl()) : kRTOF;
1493 0 : tdif -= path/kCSpeed*TMath::Sqrt(1.+m*m/(p*p));
1494 0 : }
1495 59 : return tdif*kps2ns;
1496 92 : }
1497 :
1498 : //_______________________________________________________________________
1499 : Double_t AliESDtrack::GetTOFExpTDiffSpec(AliPID::EParticleType specie,Double_t b) const
1500 : {
1501 : // Returns the time difference in ns between TOF signal and expected time for given specii
1502 : const double kps2ns = 1e-3; // we need ns
1503 : const double kNoInfo = kTOFBCNA*25; // no info
1504 0 : if (!IsOn(kTOFout)) return kNoInfo; // no info
1505 : //
1506 0 : double tdif = GetTOFsignal();
1507 0 : if (IsOn(kTIME)) { // integrated time info is there
1508 0 : Double_t times[AliPID::kSPECIESC];
1509 : // old esd has only AliPID::kSPECIES times
1510 0 : GetIntegratedTimes(times,int(specie)>=int(AliPID::kSPECIES) ? AliPID::kSPECIESC : AliPID::kSPECIES);
1511 0 : tdif -= times[specie];
1512 0 : }
1513 : else { // assume integrated time info from TOF radius and momentum
1514 : const double kRTOF = 385.;
1515 : const double kCSpeed = 3.e-2; // cm/ps
1516 0 : double p = GetP();
1517 0 : if (p<0.01) return kNoInfo;
1518 0 : double m = GetMass(specie);
1519 0 : double curv = GetC(b);
1520 0 : double path = TMath::Abs(curv)>kAlmost0 ? // account for curvature
1521 0 : 2./curv*TMath::ASin(kRTOF*curv/2.)*TMath::Sqrt(1.+GetTgl()*GetTgl()) : kRTOF;
1522 0 : tdif -= path/kCSpeed*TMath::Sqrt(1.+m*m/(p*p));
1523 0 : }
1524 0 : return tdif*kps2ns;
1525 0 : }
1526 :
1527 : //______________________________________________________________________________
1528 : Double_t AliESDtrack::M() const
1529 : {
1530 : // Returns the assumed mass
1531 : // (the pion mass, if the particle can't be identified properly).
1532 : static Bool_t printerr=kTRUE;
1533 0 : if (printerr) {
1534 0 : AliWarning("WARNING !!! ... THIS WILL BE PRINTED JUST ONCE !!!");
1535 0 : printerr = kFALSE;
1536 0 : AliWarning("This is the ESD mass. Use it with care !");
1537 0 : }
1538 0 : return GetMass();
1539 : }
1540 :
1541 : //______________________________________________________________________________
1542 : Double_t AliESDtrack::E() const
1543 : {
1544 : // Returns the energy of the particle given its assumed mass.
1545 : // Assumes the pion mass if the particle can't be identified properly.
1546 :
1547 0 : Double_t m = M();
1548 0 : Double_t p = P();
1549 0 : return TMath::Sqrt(p*p + m*m);
1550 : }
1551 :
1552 : //______________________________________________________________________________
1553 : Double_t AliESDtrack::Y() const
1554 : {
1555 : // Returns the rapidity of a particle given its assumed mass.
1556 : // Assumes the pion mass if the particle can't be identified properly.
1557 :
1558 0 : Double_t e = E();
1559 0 : Double_t pz = Pz();
1560 0 : if (e != TMath::Abs(pz)) { // energy was not equal to pz
1561 0 : return 0.5*TMath::Log((e+pz)/(e-pz));
1562 : } else { // energy was equal to pz
1563 0 : return -999.;
1564 : }
1565 0 : }
1566 :
1567 : //_______________________________________________________________________
1568 : Bool_t AliESDtrack::UpdateTrackParams(const AliKalmanTrack *t, ULong_t flags){
1569 : //
1570 : // This function updates track's running parameters
1571 : //
1572 : Bool_t rc=kTRUE;
1573 :
1574 3064 : SetStatus(flags);
1575 1532 : fLabel=t->GetLabel();
1576 :
1577 1532 : if (t->IsStartedTimeIntegral()) {
1578 1014 : SetStatus(kTIME);
1579 1014 : Double_t times[AliPID::kSPECIESC];
1580 1014 : t->GetIntegratedTimes(times);
1581 1014 : SetIntegratedTimes(times);
1582 1014 : SetIntegratedLength(t->GetIntegratedLength());
1583 1014 : }
1584 :
1585 1532 : Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1586 1532 : if (fFriendTrack) {
1587 1630 : if (flags==kITSout) fFriendTrack->SetITSOut(*t);
1588 1666 : if (flags==kTPCout) fFriendTrack->SetTPCOut(*t);
1589 1574 : if (flags==kTRDrefit) fFriendTrack->SetTRDIn(*t);
1590 : }
1591 :
1592 3474 : switch (flags) {
1593 :
1594 : case kITSin:
1595 382 : fITSchi2Std[0] = t->GetChi2();
1596 : //
1597 : case kITSout:
1598 480 : fITSchi2Std[1] = t->GetChi2();
1599 : case kITSrefit:
1600 : {
1601 572 : fITSchi2Std[2] = t->GetChi2();
1602 572 : fITSClusterMap=0;
1603 572 : fITSncls=t->GetNumberOfClusters();
1604 572 : if (fFriendTrack) {
1605 572 : Int_t indexITS[AliESDfriendTrack::kMaxITScluster];
1606 14872 : for (Int_t i=0;i<AliESDfriendTrack::kMaxITScluster;i++) {
1607 6864 : indexITS[i]=t->GetClusterIndex(i);
1608 :
1609 6864 : if (i<fITSncls) {
1610 3008 : Int_t l=(indexITS[i] & 0xf0000000) >> 28;
1611 3008 : SETBIT(fITSClusterMap,l);
1612 3008 : }
1613 : }
1614 572 : fFriendTrack->SetITSIndices(indexITS,AliESDfriendTrack::kMaxITScluster);
1615 572 : }
1616 :
1617 572 : fITSchi2=t->GetChi2();
1618 572 : fITSsignal=t->GetPIDsignal();
1619 572 : fITSLabel = t->GetLabel();
1620 : // keep in fOp the parameters outside ITS for ITS stand-alone tracks
1621 572 : if (flags==kITSout) {
1622 294 : if (!fOp) fOp=new AliExternalTrackParam(*t);
1623 : else
1624 0 : fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1625 : }
1626 : }
1627 : break;
1628 :
1629 : case kTPCin: case kTPCrefit:
1630 : {
1631 272 : fTPCLabel = t->GetLabel();
1632 272 : if (flags==kTPCin) {
1633 272 : fTPCInner=new AliExternalTrackParam(*t);
1634 136 : fTPCnclsIter1=t->GetNumberOfClusters();
1635 136 : fTPCchi2Iter1=t->GetChi2();
1636 136 : }
1637 544 : if (!fIp) fIp=new AliExternalTrackParam(*t);
1638 : else
1639 136 : fIp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1640 : }
1641 : // Intentionally no break statement; need to set general TPC variables as well
1642 : case kTPCout:
1643 : {
1644 406 : if (flags & kTPCout){
1645 238 : if (!fOp) fOp=new AliExternalTrackParam(*t);
1646 : else
1647 82 : fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1648 : }
1649 406 : fTPCncls=t->GetNumberOfClusters();
1650 406 : fTPCchi2=t->GetChi2();
1651 :
1652 406 : if (fFriendTrack) { // Copy cluster indices
1653 406 : Int_t indexTPC[AliESDfriendTrack::kMaxTPCcluster];
1654 130732 : for (Int_t i=0;i<AliESDfriendTrack::kMaxTPCcluster;i++)
1655 64960 : indexTPC[i]=t->GetClusterIndex(i);
1656 406 : fFriendTrack->SetTPCIndices(indexTPC,AliESDfriendTrack::kMaxTPCcluster);
1657 406 : }
1658 406 : fTPCsignal=t->GetPIDsignal();
1659 : }
1660 406 : break;
1661 :
1662 : case kTRDin: case kTRDrefit:
1663 : break;
1664 : case kTRDout:
1665 : {
1666 104 : fTRDLabel = t->GetLabel();
1667 104 : fTRDchi2 = t->GetChi2();
1668 104 : fTRDncls = t->GetNumberOfClusters();
1669 104 : if (fFriendTrack) {
1670 104 : Int_t indexTRD[AliESDfriendTrack::kMaxTRDcluster];
1671 37648 : for (Int_t i=0;i<AliESDfriendTrack::kMaxTRDcluster;i++) indexTRD[i]=-2;
1672 1456 : for (Int_t i=0;i<6;i++) indexTRD[i]=t->GetTrackletIndex(i);
1673 104 : fFriendTrack->SetTRDIndices(indexTRD,AliESDfriendTrack::kMaxTRDcluster);
1674 104 : }
1675 :
1676 : //commented out by Xianguo
1677 : //fTRDsignal=t->GetPIDsignal();
1678 : }
1679 : break;
1680 : case kTRDbackup:
1681 154 : if (!fOp) fOp=new AliExternalTrackParam(*t);
1682 : else
1683 148 : fOp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1684 150 : fTRDncls0 = t->GetNumberOfClusters();
1685 150 : break;
1686 : case kTOFin:
1687 : break;
1688 : case kTOFout:
1689 : break;
1690 : case kTRDStop:
1691 : break;
1692 : case kHMPIDout:
1693 0 : if (!fHMPIDp) fHMPIDp=new AliExternalTrackParam(*t);
1694 : else
1695 0 : fHMPIDp->Set(t->GetX(),t->GetAlpha(),t->GetParameter(),t->GetCovariance());
1696 : break;
1697 : default:
1698 0 : AliError("Wrong flag !");
1699 0 : return kFALSE;
1700 : }
1701 :
1702 1532 : return rc;
1703 1532 : }
1704 :
1705 : //_______________________________________________________________________
1706 : void AliESDtrack::GetExternalParameters(Double_t &x, Double_t p[5]) const {
1707 : //---------------------------------------------------------------------
1708 : // This function returns external representation of the track parameters
1709 : //---------------------------------------------------------------------
1710 184 : x=GetX();
1711 1104 : for (Int_t i=0; i<5; i++) p[i]=GetParameter()[i];
1712 92 : }
1713 :
1714 : //_______________________________________________________________________
1715 : void AliESDtrack::GetExternalCovariance(Double_t cov[15]) const {
1716 : //---------------------------------------------------------------------
1717 : // This function returns external representation of the cov. matrix
1718 : //---------------------------------------------------------------------
1719 42504 : for (Int_t i=0; i<15; i++) cov[i]=AliExternalTrackParam::GetCovariance()[i];
1720 1288 : }
1721 :
1722 : //_______________________________________________________________________
1723 : Bool_t AliESDtrack::GetConstrainedExternalParameters
1724 : (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1725 : //---------------------------------------------------------------------
1726 : // This function returns the constrained external track parameters
1727 : //---------------------------------------------------------------------
1728 0 : if (!fCp) return kFALSE;
1729 0 : alpha=fCp->GetAlpha();
1730 0 : x=fCp->GetX();
1731 0 : for (Int_t i=0; i<5; i++) p[i]=fCp->GetParameter()[i];
1732 0 : return kTRUE;
1733 0 : }
1734 :
1735 : //_______________________________________________________________________
1736 : Bool_t
1737 : AliESDtrack::GetConstrainedExternalCovariance(Double_t c[15]) const {
1738 : //---------------------------------------------------------------------
1739 : // This function returns the constrained external cov. matrix
1740 : //---------------------------------------------------------------------
1741 0 : if (!fCp) return kFALSE;
1742 0 : for (Int_t i=0; i<15; i++) c[i]=fCp->GetCovariance()[i];
1743 0 : return kTRUE;
1744 0 : }
1745 :
1746 : Bool_t
1747 : AliESDtrack::GetInnerExternalParameters
1748 : (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1749 : //---------------------------------------------------------------------
1750 : // This function returns external representation of the track parameters
1751 : // at the inner layer of TPC
1752 : //---------------------------------------------------------------------
1753 0 : if (!fIp) return kFALSE;
1754 0 : alpha=fIp->GetAlpha();
1755 0 : x=fIp->GetX();
1756 0 : for (Int_t i=0; i<5; i++) p[i]=fIp->GetParameter()[i];
1757 0 : return kTRUE;
1758 0 : }
1759 :
1760 : Bool_t
1761 : AliESDtrack::GetInnerExternalCovariance(Double_t cov[15]) const {
1762 : //---------------------------------------------------------------------
1763 : // This function returns external representation of the cov. matrix
1764 : // at the inner layer of TPC
1765 : //---------------------------------------------------------------------
1766 24 : if (!fIp) return kFALSE;
1767 384 : for (Int_t i=0; i<15; i++) cov[i]=fIp->GetCovariance()[i];
1768 12 : return kTRUE;
1769 12 : }
1770 :
1771 : void
1772 : AliESDtrack::SetOuterParam(const AliExternalTrackParam *p, ULong_t flags) {
1773 : //
1774 : // This is a direct setter for the outer track parameters
1775 : //
1776 0 : SetStatus(flags);
1777 0 : if (fOp) delete fOp;
1778 0 : fOp=new AliExternalTrackParam(*p);
1779 0 : }
1780 :
1781 : void
1782 : AliESDtrack::SetOuterHmpParam(const AliExternalTrackParam *p, ULong_t flags) {
1783 : //
1784 : // This is a direct setter for the outer track parameters
1785 : //
1786 16 : SetStatus(flags);
1787 8 : if (fHMPIDp) delete fHMPIDp;
1788 16 : fHMPIDp=new AliExternalTrackParam(*p);
1789 8 : }
1790 :
1791 : Bool_t
1792 : AliESDtrack::GetOuterExternalParameters
1793 : (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1794 : //---------------------------------------------------------------------
1795 : // This function returns external representation of the track parameters
1796 : // at the inner layer of TRD
1797 : //---------------------------------------------------------------------
1798 0 : if (!fOp) return kFALSE;
1799 0 : alpha=fOp->GetAlpha();
1800 0 : x=fOp->GetX();
1801 0 : for (Int_t i=0; i<5; i++) p[i]=fOp->GetParameter()[i];
1802 0 : return kTRUE;
1803 0 : }
1804 :
1805 : Bool_t
1806 : AliESDtrack::GetOuterHmpExternalParameters
1807 : (Double_t &alpha, Double_t &x, Double_t p[5]) const {
1808 : //---------------------------------------------------------------------
1809 : // This function returns external representation of the track parameters
1810 : // at the inner layer of TRD
1811 : //---------------------------------------------------------------------
1812 0 : if (!fHMPIDp) return kFALSE;
1813 0 : alpha=fHMPIDp->GetAlpha();
1814 0 : x=fHMPIDp->GetX();
1815 0 : for (Int_t i=0; i<5; i++) p[i]=fHMPIDp->GetParameter()[i];
1816 0 : return kTRUE;
1817 0 : }
1818 :
1819 : Bool_t
1820 : AliESDtrack::GetOuterExternalCovariance(Double_t cov[15]) const {
1821 : //---------------------------------------------------------------------
1822 : // This function returns external representation of the cov. matrix
1823 : // at the inner layer of TRD
1824 : //---------------------------------------------------------------------
1825 0 : if (!fOp) return kFALSE;
1826 0 : for (Int_t i=0; i<15; i++) cov[i]=fOp->GetCovariance()[i];
1827 0 : return kTRUE;
1828 0 : }
1829 :
1830 : Bool_t
1831 : AliESDtrack::GetOuterHmpExternalCovariance(Double_t cov[15]) const {
1832 : //---------------------------------------------------------------------
1833 : // This function returns external representation of the cov. matrix
1834 : // at the inner layer of TRD
1835 : //---------------------------------------------------------------------
1836 0 : if (!fHMPIDp) return kFALSE;
1837 0 : for (Int_t i=0; i<15; i++) cov[i]=fHMPIDp->GetCovariance()[i];
1838 0 : return kTRUE;
1839 0 : }
1840 :
1841 : Int_t AliESDtrack::GetNcls(Int_t idet) const
1842 : {
1843 : // Get number of clusters by subdetector index
1844 : //
1845 : Int_t ncls = 0;
1846 1340 : switch(idet){
1847 : case 0:
1848 168 : ncls = fITSncls;
1849 168 : break;
1850 : case 1:
1851 76 : ncls = fTPCncls;
1852 76 : break;
1853 : case 2:
1854 0 : ncls = fTRDncls;
1855 0 : break;
1856 : case 3:
1857 76 : if (fTOFindex != -1)
1858 41 : ncls = 1;
1859 : break;
1860 : case 4: //PHOS
1861 : break;
1862 : case 5: //HMPID
1863 143 : if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1864 16 : if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1865 : ncls = 1;
1866 8 : }
1867 : }
1868 : break;
1869 : default:
1870 : break;
1871 : }
1872 472 : return ncls;
1873 : }
1874 :
1875 : Int_t AliESDtrack::GetClusters(Int_t idet, Int_t *idx) const
1876 : {
1877 : // Get cluster index array by subdetector index
1878 : //
1879 : Int_t ncls = 0;
1880 1292 : switch(idet){
1881 : case 0:
1882 152 : ncls = GetITSclusters(idx);
1883 152 : break;
1884 : case 1:
1885 76 : ncls = GetTPCclusters(idx);
1886 76 : break;
1887 : case 2:
1888 0 : ncls = GetTRDclusters(idx);
1889 0 : break;
1890 : case 3:
1891 76 : if (fTOFindex != -1) {
1892 41 : idx[0] = fTOFindex;
1893 : ncls = 1;
1894 41 : }
1895 : break;
1896 : case 4: //PHOS
1897 : break;
1898 : case 5:
1899 143 : if ((fHMPIDcluIdx >= 0) && (fHMPIDcluIdx < 7000000)) {
1900 16 : if ((fHMPIDcluIdx%1000000 != 9999) && (fHMPIDcluIdx%1000000 != 99999)) {
1901 8 : idx[0] = GetHMPIDcluIdx();
1902 : ncls = 1;
1903 8 : }
1904 : }
1905 : break;
1906 : case 6: //EMCAL
1907 : break;
1908 : default:
1909 : break;
1910 : }
1911 456 : return ncls;
1912 : }
1913 :
1914 : //_______________________________________________________________________
1915 : void AliESDtrack::GetIntegratedTimes(Double_t *times, Int_t nspec) const
1916 : {
1917 : // get integrated time for requested N species
1918 3676 : if (nspec<1) return;
1919 3082 : if(fNtofClusters>0 && GetESDEvent()){
1920 1244 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
1921 1244 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
1922 : //
1923 2628 : for(int i=tofcl->GetNMatchableTracks();i--;){
1924 1384 : if(tofcl->GetTrackIndex(i) == GetID()) {
1925 24408 : for (int j=nspec; j--;) times[j]=tofcl->GetIntegratedTime(j,i);
1926 1244 : return;
1927 : }
1928 : }
1929 0 : }
1930 594 : else if(fNtofClusters>0)
1931 0 : AliInfo("No AliESDEvent available here!\n");
1932 :
1933 : // Returns the array with integrated times for each particle hypothesis
1934 594 : if(fTrackTime)
1935 11634 : for (int i=nspec; i--;) times[i]=fTrackTime[i];
1936 : else
1937 : // The line below is wrong since it does not honor the nspec value
1938 : // The "times" array may have only AliPID::kSPECIES size, as called by:
1939 : // AliESDpidCuts::AcceptTrack()
1940 : // for (int i=AliPID::kSPECIESC; i--;) times[i]=0.0;
1941 800 : for (int i=nspec; i--;) times[i]=0.0;
1942 1838 : }
1943 : //_______________________________________________________________________
1944 : Double_t AliESDtrack::GetIntegratedLength() const{
1945 : Int_t index = -1;
1946 6582 : if(fNtofClusters>0 && GetESDEvent()){
1947 1798 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
1948 1798 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
1949 :
1950 7700 : for(Int_t i=0;i < tofcl->GetNMatchableTracks();i++){
1951 3850 : if(tofcl->GetTrackIndex(i) == GetID()) index = i;
1952 : }
1953 :
1954 1798 : if(fNtofClusters>0 && index > -1)
1955 1798 : return tofcl->GetLength(index);
1956 0 : }
1957 594 : else if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
1958 :
1959 594 : return fTrackLength;
1960 2392 : }
1961 :
1962 : //_______________________________________________________________________
1963 : void AliESDtrack::SetIntegratedTimes(const Double_t *times)
1964 : {
1965 : // Sets the array with integrated times for each particle hypotesis
1966 2484 : if(!fTrackTime) fTrackTime = new Double32_t[AliPID::kSPECIESC];
1967 23320 : for (int i=AliPID::kSPECIESC; i--;) fTrackTime[i]=times[i];
1968 1166 : }
1969 :
1970 : //_______________________________________________________________________
1971 : void AliESDtrack::SetITSpid(const Double_t *p)
1972 : {
1973 : // Sets values for the probability of each particle type (in ITS)
1974 0 : if (!fITSr) fITSr = new Double32_t[AliPID::kSPECIESC];
1975 0 : SetPIDValues(fITSr,p,AliPID::kSPECIES);
1976 0 : SetStatus(AliESDtrack::kITSpid);
1977 0 : }
1978 :
1979 : //_______________________________________________________________________
1980 : void AliESDtrack::GetITSpid(Double_t *p) const {
1981 : // Gets the probability of each particle type (in ITS)
1982 0 : for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i] = fITSr ? fITSr[i] : 0;
1983 0 : }
1984 :
1985 : //_______________________________________________________________________
1986 : Char_t AliESDtrack::GetITSclusters(Int_t *idx) const {
1987 : //---------------------------------------------------------------------
1988 : // This function returns indices of the assgined ITS clusters
1989 : //---------------------------------------------------------------------
1990 5936 : if (idx && fFriendTrack) {
1991 1040 : Int_t *index=fFriendTrack->GetITSindices();
1992 27040 : for (Int_t i=0; i<AliESDfriendTrack::kMaxITScluster; i++) {
1993 15338 : if ( (i>=fITSncls) && (i<6) ) idx[i]=-1;
1994 : else {
1995 19244 : if (index) {
1996 16904 : idx[i]=index[i];
1997 7282 : }
1998 2340 : else idx[i]= -2;
1999 : }
2000 : }
2001 1040 : }
2002 2448 : return fITSncls;
2003 : }
2004 :
2005 : //_______________________________________________________________________
2006 : Bool_t AliESDtrack::GetITSModuleIndexInfo(Int_t ilayer,Int_t &idet,Int_t &status,
2007 : Float_t &xloc,Float_t &zloc) const {
2008 : //----------------------------------------------------------------------
2009 : // This function encodes in the module number also the status of cluster association
2010 : // "status" can have the following values:
2011 : // 1 "found" (cluster is associated),
2012 : // 2 "dead" (module is dead from OCDB),
2013 : // 3 "skipped" (module or layer forced to be skipped),
2014 : // 4 "outinz" (track out of z acceptance),
2015 : // 5 "nocls" (no clusters in the road),
2016 : // 6 "norefit" (cluster rejected during refit),
2017 : // 7 "deadzspd" (holes in z in SPD)
2018 : // Also given are the coordinates of the crossing point of track and module
2019 : // (in the local module ref. system)
2020 : // WARNING: THIS METHOD HAS TO BE SYNCHRONIZED WITH AliITStrackV2::GetModuleIndexInfo()!
2021 : //----------------------------------------------------------------------
2022 :
2023 12528 : if(fITSModule[ilayer]==-1) {
2024 852 : idet = -1;
2025 852 : status=0;
2026 852 : xloc=-99.; zloc=-99.;
2027 852 : return kFALSE;
2028 : }
2029 :
2030 : Int_t module = fITSModule[ilayer];
2031 :
2032 5412 : idet = Int_t(module/1000000);
2033 :
2034 5412 : module -= idet*1000000;
2035 :
2036 5412 : status = Int_t(module/100000);
2037 :
2038 5412 : module -= status*100000;
2039 :
2040 5412 : Int_t signs = Int_t(module/10000);
2041 :
2042 5412 : module-=signs*10000;
2043 :
2044 5412 : Int_t xInt = Int_t(module/100);
2045 5412 : module -= xInt*100;
2046 :
2047 : Int_t zInt = module;
2048 :
2049 7482 : if(signs==1) { xInt*=1; zInt*=1; }
2050 6252 : if(signs==2) { xInt*=1; zInt*=-1; }
2051 7336 : if(signs==3) { xInt*=-1; zInt*=1; }
2052 5972 : if(signs==4) { xInt*=-1; zInt*=-1; }
2053 :
2054 5412 : xloc = 0.1*(Float_t)xInt;
2055 5412 : zloc = 0.1*(Float_t)zInt;
2056 :
2057 5430 : if(status==4) idet = -1;
2058 :
2059 : return kTRUE;
2060 6264 : }
2061 :
2062 : //_______________________________________________________________________
2063 : UShort_t AliESDtrack::GetTPCclusters(Int_t *idx) const {
2064 : //---------------------------------------------------------------------
2065 : // This function returns indices of the assgined ITS clusters
2066 : //---------------------------------------------------------------------
2067 6876 : if (idx && fFriendTrack) {
2068 348 : Int_t *index=fFriendTrack->GetTPCindices();
2069 :
2070 348 : if (index){
2071 340 : memcpy(idx,index,sizeof(int)*AliESDfriendTrack::kMaxTPCcluster);
2072 : //RS for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=index[i];
2073 340 : }
2074 : else {
2075 2576 : for (Int_t i=0; i<AliESDfriendTrack::kMaxTPCcluster; i++) idx[i]=-2;
2076 : }
2077 348 : }
2078 3264 : return fTPCncls;
2079 : }
2080 :
2081 : //_______________________________________________________________________
2082 : Float_t AliESDtrack::GetTPCCrossedRows() const
2083 : {
2084 : // This function calls GetTPCClusterInfo with some default parameters which are used in the track selection and caches the outcome
2085 : // because GetTPCClusterInfo is quite time-consuming
2086 :
2087 2602 : if (fCacheNCrossedRows > -1)
2088 1023 : return fCacheNCrossedRows;
2089 :
2090 278 : fCacheNCrossedRows = GetTPCClusterInfo(2, 1);
2091 278 : return fCacheNCrossedRows;
2092 1301 : }
2093 :
2094 : //_______________________________________________________________________
2095 : Float_t AliESDtrack::GetTPCClusterInfo(Int_t nNeighbours/*=3*/, Int_t type/*=0*/, Int_t row0, Int_t row1, Int_t bitType ) const
2096 : {
2097 : //
2098 : // TPC cluster information
2099 : // type 0: get fraction of found/findable clusters with neighbourhood definition
2100 : // 1: findable clusters with neighbourhood definition
2101 : // 2: found clusters
2102 : // 3: get fraction of found/findable clusters with neighbourhood definition - requiring before and after row
2103 : // 4: findable clusters with neighbourhood definition - before and after row
2104 : // bitType:
2105 : // 0 - all cluster used
2106 : // 1 - clusters used for the kalman update
2107 : // definition of findable clusters:
2108 : // a cluster is defined as findable if there is another cluster
2109 : // within +- nNeighbours pad rows. The idea is to overcome threshold
2110 : // effects with a very simple algorithm.
2111 : //
2112 :
2113 :
2114 : Int_t found=0;
2115 : Int_t findable=0;
2116 556 : Int_t last=-nNeighbours;
2117 278 : const TBits & clusterMap = (bitType%2==0) ? fTPCClusterMap : fTPCFitMap;
2118 :
2119 :
2120 278 : Int_t upperBound=clusterMap.GetNbits();
2121 278 : if (upperBound>row1) upperBound=row1;
2122 278 : if (type>=3){ // requires cluster before and after
2123 0 : for (Int_t i=row0; i<upperBound; ++i){
2124 : Int_t beforeAfter=0;
2125 0 : if (clusterMap[i]) {
2126 : last=i;
2127 0 : ++found;
2128 0 : ++findable;
2129 0 : continue;
2130 : }
2131 0 : if ((i-last)<=nNeighbours) {
2132 : ++beforeAfter;
2133 0 : }
2134 : //look to nNeighbours after
2135 0 : for (Int_t j=i+1; j<i+1+nNeighbours; ++j){
2136 0 : if (clusterMap[j]){
2137 0 : ++beforeAfter;
2138 0 : break;
2139 : }
2140 : }
2141 0 : if (beforeAfter>1) ++findable;
2142 0 : }
2143 0 : if (type==3) return Float_t(found)/Float_t(TMath::Max(findable,1));
2144 0 : if (type==4) return findable;
2145 0 : return 0;
2146 : }
2147 :
2148 88960 : for (Int_t i=row0; i<upperBound; ++i){
2149 : //look to current row
2150 44202 : if (clusterMap[i]) {
2151 : last=i;
2152 32940 : ++found;
2153 32940 : ++findable;
2154 32940 : continue;
2155 : }
2156 : //look to nNeighbours before
2157 11262 : if ((i-last)<=nNeighbours) {
2158 3252 : ++findable;
2159 3252 : continue;
2160 : }
2161 : //look to nNeighbours after
2162 53766 : for (Int_t j=i+1; j<i+1+nNeighbours; ++j){
2163 15684 : if (clusterMap[j]){
2164 544 : ++findable;
2165 544 : break;
2166 : }
2167 : }
2168 8010 : }
2169 278 : if (type==2) return found;
2170 556 : if (type==1) return findable;
2171 :
2172 0 : if (type==0){
2173 : Float_t fraction=0;
2174 0 : if (findable>0)
2175 0 : fraction=(Float_t)found/(Float_t)findable;
2176 : else
2177 : fraction=0;
2178 : return fraction;
2179 : }
2180 0 : return 0; // undefined type - default value
2181 278 : }
2182 :
2183 : //_______________________________________________________________________
2184 : Float_t AliESDtrack::GetTPCClusterDensity(Int_t nNeighbours/*=3*/, Int_t type/*=0*/, Int_t row0, Int_t row1, Int_t bitType ) const
2185 : {
2186 : //
2187 : // TPC cluster density - only rows where signal before and after given row are used
2188 : // - slower function
2189 : // type 0: get fraction of found/findable clusters with neighbourhood definition
2190 : // 1: findable clusters with neighbourhood definition
2191 : // 2: found clusters
2192 : // bitType:
2193 : // 0 - all cluster used
2194 : // 1 - clusters used for the kalman update
2195 : // definition of findable clusters:
2196 : // a cluster is defined as findable if there is another cluster
2197 : // within +- nNeighbours pad rows. The idea is to overcome threshold
2198 : // effects with a very simple algorithm.
2199 : //
2200 : Int_t found=0;
2201 : Int_t findable=0;
2202 : // Int_t last=-nNeighbours;
2203 0 : const TBits & clusterMap = (bitType%2==0) ? fTPCClusterMap : fTPCFitMap;
2204 0 : Int_t upperBound=clusterMap.GetNbits();
2205 0 : if (upperBound>row1) upperBound=row1;
2206 0 : for (Int_t i=row0; i<upperBound; ++i){
2207 : Bool_t isUp=kFALSE;
2208 : Bool_t isDown=kFALSE;
2209 0 : for (Int_t idelta=1; idelta<=nNeighbours; idelta++){
2210 0 : if (i-idelta>=0 && clusterMap[i-idelta]) isDown=kTRUE;
2211 0 : if (i+idelta<upperBound && clusterMap[i+idelta]) isUp=kTRUE;
2212 : }
2213 0 : if (isUp&&isDown){
2214 0 : ++findable;
2215 0 : if (clusterMap[i]) ++found;
2216 : }
2217 : }
2218 0 : if (type==2) return found;
2219 0 : if (type==1) return findable;
2220 :
2221 0 : if (type==0){
2222 : Float_t fraction=0;
2223 0 : if (findable>0)
2224 0 : fraction=(Float_t)found/(Float_t)findable;
2225 : else
2226 : fraction=0;
2227 : return fraction;
2228 : }
2229 0 : return 0; // undefined type - default value
2230 0 : }
2231 :
2232 :
2233 :
2234 :
2235 : //_______________________________________________________________________
2236 : Double_t AliESDtrack::GetTPCdensity(Int_t row0, Int_t row1) const{
2237 : //
2238 : // GetDensity of the clusters on given region between row0 and row1
2239 : // Dead zone effect takin into acoount
2240 : //
2241 1400 : if (!fFriendTrack) return 0.0;
2242 : Int_t good = 0;
2243 : Int_t found = 0;
2244 : //
2245 700 : Int_t *index=fFriendTrack->GetTPCindices();
2246 40560 : for (Int_t i=row0;i<=row1;i++){
2247 19580 : Int_t idx = index[i];
2248 38042 : if (idx!=-1) good++; // track outside of dead zone
2249 34924 : if (idx>0) found++;
2250 : }
2251 : Float_t density=0.5;
2252 1392 : if (good>TMath::Max((row1-row0)*0.5,0.0)) density = Float_t(found)/Float_t(good);
2253 700 : return density;
2254 700 : }
2255 :
2256 : //_______________________________________________________________________
2257 : void AliESDtrack::SetTPCpid(const Double_t *p) {
2258 : // Sets values for the probability of each particle type (in TPC)
2259 0 : if (!fTPCr) fTPCr = new Double32_t[AliPID::kSPECIES];
2260 0 : SetPIDValues(fTPCr,p,AliPID::kSPECIES);
2261 0 : SetStatus(AliESDtrack::kTPCpid);
2262 0 : }
2263 :
2264 : //_______________________________________________________________________
2265 : void AliESDtrack::GetTPCpid(Double_t *p) const {
2266 : // Gets the probability of each particle type (in TPC)
2267 0 : for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i] = fTPCr ? fTPCr[i] : 0;
2268 0 : }
2269 :
2270 : //_______________________________________________________________________
2271 : UChar_t AliESDtrack::GetTRDclusters(Int_t *idx) const {
2272 : //---------------------------------------------------------------------
2273 : // This function returns indices of the assgined TRD clusters
2274 : //---------------------------------------------------------------------
2275 0 : if (idx && fFriendTrack) {
2276 0 : Int_t *index=fFriendTrack->GetTRDindices();
2277 :
2278 0 : if (index) {
2279 0 : for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=index[i];
2280 0 : }
2281 : else {
2282 0 : for (Int_t i=0; i<AliESDfriendTrack::kMaxTRDcluster; i++) idx[i]=-2;
2283 : }
2284 0 : }
2285 0 : return fTRDncls;
2286 : }
2287 :
2288 : //_______________________________________________________________________
2289 : UChar_t AliESDtrack::GetTRDtracklets(Int_t *idx) const {
2290 : //
2291 : // This function returns the number of TRD tracklets used in tracking
2292 : // and it fills the indices of these tracklets in the array "idx" as they
2293 : // are registered in the TRD track list.
2294 : //
2295 : // Caution :
2296 : // 1. The idx array has to be allocated with a size >= AliESDtrack::kTRDnPlanes
2297 : // 2. The idx array store not only the index but also the layer of the tracklet.
2298 : // Therefore tracks with TRD gaps contain default values for indices [-1]
2299 :
2300 724 : if (!fFriendTrack) return 0;
2301 362 : if (!idx) return GetTRDntracklets();
2302 362 : Int_t *index=fFriendTrack->GetTRDindices();
2303 : Int_t n = 0;
2304 5068 : for (Int_t i=0; i<kTRDnPlanes; i++){
2305 4344 : if (index){
2306 3429 : if(index[i]>=0) n++;
2307 936 : idx[i]=index[i];
2308 936 : }
2309 1236 : else idx[i] = -2;
2310 : }
2311 362 : return n;
2312 362 : }
2313 :
2314 : //_______________________________________________________________________
2315 : void AliESDtrack::SetTRDpid(const Double_t *p) {
2316 : // Sets values for the probability of each particle type (in TRD)
2317 312 : if (!fTRDr) fTRDr = new Double32_t[AliPID::kSPECIES];
2318 104 : SetPIDValues(fTRDr,p,AliPID::kSPECIES);
2319 104 : SetStatus(AliESDtrack::kTRDpid);
2320 104 : }
2321 :
2322 : //_______________________________________________________________________
2323 : void AliESDtrack::GetTRDpid(Double_t *p) const {
2324 : // Gets the probability of each particle type (in TRD)
2325 0 : for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i] = fTRDr ? fTRDr[i]:0;
2326 0 : }
2327 :
2328 : //_______________________________________________________________________
2329 : void AliESDtrack::SetTRDpid(Int_t iSpecies, Float_t p)
2330 : {
2331 : // Sets the probability of particle type iSpecies to p (in TRD)
2332 0 : if (!fTRDr) {
2333 0 : fTRDr = new Double32_t[AliPID::kSPECIES];
2334 0 : for (Int_t i=AliPID::kSPECIES; i--;) fTRDr[i] = 0;
2335 0 : }
2336 0 : fTRDr[iSpecies] = p;
2337 0 : }
2338 :
2339 : Double_t AliESDtrack::GetTRDpid(Int_t iSpecies) const
2340 : {
2341 : // Returns the probability of particle type iSpecies (in TRD)
2342 0 : return fTRDr ? fTRDr[iSpecies] : 0;
2343 : }
2344 :
2345 : //____________________________________________________
2346 : Int_t AliESDtrack::GetNumberOfTRDslices() const
2347 : {
2348 : // built in backward compatibility
2349 26196 : Int_t idx = fTRDnSlices - (kTRDnPlanes<<1);
2350 39294 : return idx<18 ? fTRDnSlices/kTRDnPlanes : idx/kTRDnPlanes;
2351 : }
2352 :
2353 : //____________________________________________________
2354 : Double_t AliESDtrack::GetTRDmomentum(Int_t plane, Double_t *sp) const
2355 : {
2356 : //Returns momentum estimation and optional its error (sp)
2357 : // in TRD layer "plane".
2358 :
2359 1440 : if (!fTRDnSlices) {
2360 396 : AliDebug(2, "No TRD info allocated for this track.");
2361 132 : return -1.;
2362 : }
2363 588 : if ((plane<0) || (plane>=kTRDnPlanes)) {
2364 0 : AliWarning(Form("Request for TRD plane[%d] outside range.", plane));
2365 0 : return -1.;
2366 : }
2367 :
2368 588 : Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
2369 : // Protection for backward compatibility
2370 588 : if(idx<(GetNumberOfTRDslices()*kTRDnPlanes)) return -1.;
2371 :
2372 588 : if(sp) (*sp) = fTRDslices[idx+kTRDnPlanes];
2373 588 : return fTRDslices[idx];
2374 720 : }
2375 :
2376 : //____________________________________________________
2377 : Double_t AliESDtrack::GetTRDslice(Int_t plane, Int_t slice) const {
2378 : //Gets the charge from the slice of the plane
2379 :
2380 9408 : if(!fTRDslices) {
2381 : //AliError("No TRD slices allocated for this track !");
2382 0 : return -1.;
2383 : }
2384 4704 : if ((plane<0) || (plane>=kTRDnPlanes)) {
2385 0 : AliError("Info for TRD plane not available !");
2386 0 : return -1.;
2387 : }
2388 4704 : Int_t ns=GetNumberOfTRDslices();
2389 9408 : if ((slice<-1) || (slice>=ns)) {
2390 : //AliError("Wrong TRD slice !");
2391 0 : return -1.;
2392 : }
2393 :
2394 9408 : if(slice>=0) return fTRDslices[plane*ns + slice];
2395 :
2396 : // return average of the dEdx measurements
2397 0 : Double_t q=0.; Double32_t *s = &fTRDslices[plane*ns];
2398 0 : for (Int_t i=0; i<ns; i++, s++) if((*s)>0.) q+=(*s);
2399 0 : return q/ns;
2400 4704 : }
2401 :
2402 : //____________________________________________________
2403 : void AliESDtrack::SetNumberOfTRDslices(Int_t n) {
2404 : //Sets the number of slices used for PID
2405 208 : if (fTRDnSlices) return;
2406 :
2407 104 : fTRDnSlices=n;
2408 104 : fTRDslices=new Double32_t[fTRDnSlices];
2409 :
2410 : // set-up correctly the allocated memory
2411 104 : memset(fTRDslices, 0, n*sizeof(Double32_t));
2412 1872 : for (Int_t i=GetNumberOfTRDslices(); i--;) fTRDslices[i]=-1.;
2413 104 : }
2414 :
2415 : //____________________________________________________
2416 : void AliESDtrack::SetTRDslice(Double_t q, Int_t plane, Int_t slice) {
2417 : //Sets the charge q in the slice of the plane
2418 3296 : if(!fTRDslices) {
2419 0 : AliError("No TRD slices allocated for this track !");
2420 0 : return;
2421 : }
2422 1648 : if ((plane<0) || (plane>=kTRDnPlanes)) {
2423 0 : AliError("Info for TRD plane not allocated !");
2424 0 : return;
2425 : }
2426 1648 : Int_t ns=GetNumberOfTRDslices();
2427 3296 : if ((slice<0) || (slice>=ns)) {
2428 0 : AliError(Form("Wrong TRD slice %d/%d, NSlices=%d",plane,slice,ns));
2429 0 : return;
2430 : }
2431 1648 : Int_t n=plane*ns + slice;
2432 1648 : fTRDslices[n]=q;
2433 3296 : }
2434 :
2435 :
2436 : //____________________________________________________
2437 : void AliESDtrack::SetTRDmomentum(Double_t p, Int_t plane, Double_t *sp)
2438 : {
2439 412 : if(!fTRDslices) {
2440 0 : AliError("No TRD slices allocated for this track !");
2441 0 : return;
2442 : }
2443 206 : if ((plane<0) || (plane>=kTRDnPlanes)) {
2444 0 : AliError("Info for TRD plane not allocated !");
2445 0 : return;
2446 : }
2447 :
2448 206 : Int_t idx = fTRDnSlices-(kTRDnPlanes<<1)+plane;
2449 : // Protection for backward compatibility
2450 206 : if(idx<GetNumberOfTRDslices()*kTRDnPlanes) return;
2451 :
2452 412 : if(sp) fTRDslices[idx+kTRDnPlanes] = (*sp);
2453 206 : fTRDslices[idx] = p;
2454 412 : }
2455 :
2456 :
2457 : //_______________________________________________________________________
2458 : void AliESDtrack::SetTOFpid(const Double_t *p) {
2459 : // Sets the probability of each particle type (in TOF)
2460 0 : if (!fTOFr) fTOFr = new Double32_t[AliPID::kSPECIES];
2461 0 : SetPIDValues(fTOFr,p,AliPID::kSPECIES);
2462 0 : SetStatus(AliESDtrack::kTOFpid);
2463 0 : }
2464 :
2465 : //_______________________________________________________________________
2466 : void AliESDtrack::SetTOFLabel(const Int_t *p) {
2467 :
2468 0 : if(fNtofClusters>0){
2469 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
2470 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
2471 0 : AliESDTOFHit* hit = tofcl->GetTOFHit(0);
2472 :
2473 0 : if(hit) hit->SetTOFLabel(p);
2474 0 : }
2475 : else{
2476 : // Sets (in TOF)
2477 0 : if(!fTOFLabel) fTOFLabel = new Int_t[3];
2478 0 : for (Int_t i=0; i<3; i++) fTOFLabel[i]=p[i];
2479 : }
2480 0 : }
2481 :
2482 : //_______________________________________________________________________
2483 : void AliESDtrack::GetTOFpid(Double_t *p) const {
2484 : // Gets probabilities of each particle type (in TOF)
2485 0 : for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i] = fTOFr ? fTOFr[i]:0;
2486 0 : }
2487 :
2488 : //_______________________________________________________________________
2489 : void AliESDtrack::GetTOFLabel(Int_t *p) const {
2490 : // Gets (in TOF)
2491 430 : if(fNtofClusters>0){
2492 169 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
2493 169 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
2494 :
2495 1352 : for (Int_t i=0; i<3; i++) p[i]=tofcl->GetLabel(i);
2496 169 : }
2497 : else{
2498 46 : if(fTOFLabel) for (Int_t i=0; i<3; i++) p[i]=fTOFLabel[i];
2499 368 : else for (int i=3;i--;) p[i] = -1;
2500 : }
2501 215 : }
2502 :
2503 : //_______________________________________________________________________
2504 : void AliESDtrack::GetTOFInfo(Float_t *info) const {
2505 : // Gets (in TOF)
2506 1863 : for (Int_t i=0; i<10; i++) info[i]=fTOFInfo[i];
2507 81 : }
2508 :
2509 : //_______________________________________________________________________
2510 : void AliESDtrack::SetTOFInfo(Float_t*info) {
2511 : // Gets (in TOF)
2512 3749 : for (Int_t i=0; i<10; i++) fTOFInfo[i]=info[i];
2513 163 : }
2514 :
2515 :
2516 :
2517 : //_______________________________________________________________________
2518 : void AliESDtrack::SetHMPIDpid(const Double_t *p) {
2519 : // Sets the probability of each particle type (in HMPID)
2520 24 : if (!fHMPIDr) fHMPIDr = new Double32_t[AliPID::kSPECIES];
2521 8 : SetPIDValues(fHMPIDr,p,AliPID::kSPECIES);
2522 8 : SetStatus(AliESDtrack::kHMPIDpid);
2523 8 : }
2524 :
2525 : //_______________________________________________________________________
2526 : void AliESDtrack::SetTPCdEdxInfo(AliTPCdEdxInfo * dEdxInfo){
2527 272 : if(fTPCdEdxInfo) delete fTPCdEdxInfo;
2528 136 : fTPCdEdxInfo = dEdxInfo;
2529 136 : }
2530 :
2531 : //_______________________________________________________________________
2532 : void AliESDtrack::GetHMPIDpid(Double_t *p) const {
2533 : // Gets probabilities of each particle type (in HMPID)
2534 594 : for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i] = fHMPIDr ? fHMPIDr[i]:0;
2535 33 : }
2536 :
2537 :
2538 :
2539 : //_______________________________________________________________________
2540 : void AliESDtrack::SetESDpid(const Double_t *p) {
2541 : // Sets the probability of each particle type for the ESD track
2542 0 : if (!fR) fR = new Double32_t[AliPID::kSPECIES];
2543 0 : SetPIDValues(fR,p,AliPID::kSPECIES);
2544 0 : SetStatus(AliESDtrack::kESDpid);
2545 0 : }
2546 :
2547 : //_______________________________________________________________________
2548 : void AliESDtrack::GetESDpid(Double_t *p) const {
2549 : // Gets probability of each particle type for the ESD track
2550 2448 : for (Int_t i=0; i<AliPID::kSPECIES; i++) p[i] = fR ? fR[i]:0;
2551 136 : }
2552 :
2553 : //_______________________________________________________________________
2554 : Bool_t AliESDtrack::RelateToVVertexTPC(const AliVVertex *vtx,
2555 : Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
2556 : //
2557 : // Try to relate the TPC-only track parameters to the vertex "vtx",
2558 : // if the (rough) transverse impact parameter is not bigger then "maxd".
2559 : // Magnetic field is "b" (kG).
2560 : //
2561 : // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2562 : // b) The impact parameters and their covariance matrix are calculated.
2563 : // c) An attempt to constrain the TPC-only params to the vertex is done.
2564 : // The constrained params are returned via "cParam".
2565 : //
2566 : // In the case of success, the returned value is kTRUE
2567 : // otherwise, it's kFALSE)
2568 : //
2569 :
2570 0 : if (!fTPCInner) return kFALSE;
2571 0 : if (!vtx) return kFALSE;
2572 :
2573 0 : Double_t dz[2],cov[3];
2574 0 : if (!fTPCInner->PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2575 :
2576 0 : fdTPC = dz[0];
2577 0 : fzTPC = dz[1];
2578 0 : fCddTPC = cov[0];
2579 0 : fCdzTPC = cov[1];
2580 0 : fCzzTPC = cov[2];
2581 :
2582 0 : Double_t covar[6]; vtx->GetCovarianceMatrix(covar);
2583 0 : Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2584 0 : Double_t c[3]={covar[2],0.,covar[5]};
2585 :
2586 0 : Double_t chi2=GetPredictedChi2(p,c);
2587 0 : if (chi2>kVeryBig) return kFALSE;
2588 :
2589 0 : fCchi2TPC=chi2;
2590 :
2591 0 : if (!cParam) return kTRUE;
2592 :
2593 0 : *cParam = *fTPCInner;
2594 0 : if (!cParam->Update(p,c)) return kFALSE;
2595 :
2596 0 : return kTRUE;
2597 0 : }
2598 :
2599 : //_______________________________________________________________________
2600 : Bool_t AliESDtrack::RelateToVVertexTPCBxByBz(const AliVVertex *vtx,
2601 : Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2602 : //
2603 : // Try to relate the TPC-only track parameters to the vertex "vtx",
2604 : // if the (rough) transverse impact parameter is not bigger then "maxd".
2605 : //
2606 : // All three components of the magnetic field ,"b[3]" (kG),
2607 : // are taken into account.
2608 : //
2609 : // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2610 : // b) The impact parameters and their covariance matrix are calculated.
2611 : // c) An attempt to constrain the TPC-only params to the vertex is done.
2612 : // The constrained params are returned via "cParam".
2613 : //
2614 : // In the case of success, the returned value is kTRUE
2615 : // otherwise, it's kFALSE)
2616 : //
2617 :
2618 0 : if (!fTPCInner) return kFALSE;
2619 0 : if (!vtx) return kFALSE;
2620 :
2621 0 : Double_t dz[2],cov[3];
2622 0 : if (!fTPCInner->PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2623 :
2624 0 : fdTPC = dz[0];
2625 0 : fzTPC = dz[1];
2626 0 : fCddTPC = cov[0];
2627 0 : fCdzTPC = cov[1];
2628 0 : fCzzTPC = cov[2];
2629 :
2630 0 : Double_t covar[6]; vtx->GetCovarianceMatrix(covar);
2631 0 : Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2632 0 : Double_t c[3]={covar[2],0.,covar[5]};
2633 :
2634 0 : Double_t chi2=GetPredictedChi2(p,c);
2635 0 : if (chi2>kVeryBig) return kFALSE;
2636 :
2637 0 : fCchi2TPC=chi2;
2638 :
2639 0 : if (!cParam) return kTRUE;
2640 :
2641 0 : *cParam = *fTPCInner;
2642 0 : if (!cParam->Update(p,c)) return kFALSE;
2643 :
2644 0 : return kTRUE;
2645 0 : }
2646 :
2647 : //_______________________________________________________________________
2648 : Bool_t AliESDtrack::RelateToVVertex(const AliVVertex *vtx,
2649 : Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
2650 : //
2651 : // Try to relate this track to the vertex "vtx",
2652 : // if the (rough) transverse impact parameter is not bigger then "maxd".
2653 : // Magnetic field is "b" (kG).
2654 : //
2655 : // a) The track gets extapolated to the DCA to the vertex.
2656 : // b) The impact parameters and their covariance matrix are calculated.
2657 : // c) An attempt to constrain this track to the vertex is done.
2658 : // The constrained params are returned via "cParam".
2659 : //
2660 : // In the case of success, the returned value is kTRUE
2661 : // (otherwise, it's kFALSE)
2662 : //
2663 :
2664 0 : if (!vtx) return kFALSE;
2665 :
2666 0 : Double_t dz[2],cov[3];
2667 0 : if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2668 :
2669 0 : fD = dz[0];
2670 0 : fZ = dz[1];
2671 0 : fCdd = cov[0];
2672 0 : fCdz = cov[1];
2673 0 : fCzz = cov[2];
2674 :
2675 0 : Double_t covar[6]; vtx->GetCovarianceMatrix(covar);
2676 0 : Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2677 0 : Double_t c[3]={covar[2],0.,covar[5]};
2678 :
2679 0 : Double_t chi2=GetPredictedChi2(p,c);
2680 0 : if (chi2>kVeryBig) return kFALSE;
2681 :
2682 0 : fCchi2=chi2;
2683 :
2684 :
2685 : //--- Could now these lines be removed ? ---
2686 0 : delete fCp;
2687 0 : fCp=new AliExternalTrackParam(*this);
2688 :
2689 0 : if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2690 : //----------------------------------------
2691 :
2692 : // fVertexID = vtx->GetID(); //No GetID() in AliVVertex
2693 :
2694 0 : if (!cParam) return kTRUE;
2695 :
2696 0 : *cParam = *this;
2697 0 : if (!cParam->Update(p,c)) return kFALSE;
2698 :
2699 0 : return kTRUE;
2700 0 : }
2701 :
2702 : //_______________________________________________________________________
2703 : Bool_t AliESDtrack::RelateToVVertexBxByBz(const AliVVertex *vtx,
2704 : Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2705 : //
2706 : // Try to relate this track to the vertex "vtx",
2707 : // if the (rough) transverse impact parameter is not bigger then "maxd".
2708 : // Magnetic field is "b" (kG).
2709 : //
2710 : // a) The track gets extapolated to the DCA to the vertex.
2711 : // b) The impact parameters and their covariance matrix are calculated.
2712 : // c) An attempt to constrain this track to the vertex is done.
2713 : // The constrained params are returned via "cParam".
2714 : //
2715 : // In the case of success, the returned value is kTRUE
2716 : // (otherwise, it's kFALSE)
2717 : //
2718 :
2719 0 : if (!vtx) return kFALSE;
2720 :
2721 0 : Double_t dz[2],cov[3];
2722 0 : if (!PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2723 :
2724 0 : fD = dz[0];
2725 0 : fZ = dz[1];
2726 0 : fCdd = cov[0];
2727 0 : fCdz = cov[1];
2728 0 : fCzz = cov[2];
2729 :
2730 0 : Double_t covar[6]; vtx->GetCovarianceMatrix(covar);
2731 0 : Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2732 0 : Double_t c[3]={covar[2],0.,covar[5]};
2733 :
2734 0 : Double_t chi2=GetPredictedChi2(p,c);
2735 0 : if (chi2>kVeryBig) return kFALSE;
2736 :
2737 0 : fCchi2=chi2;
2738 :
2739 :
2740 : //--- Could now these lines be removed ? ---
2741 0 : delete fCp;
2742 0 : fCp=new AliExternalTrackParam(*this);
2743 :
2744 0 : if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2745 : //----------------------------------------
2746 :
2747 : // fVertexID = vtx->GetID(); // No GetID in AliVVertex
2748 :
2749 0 : if (!cParam) return kTRUE;
2750 :
2751 0 : *cParam = *this;
2752 0 : if (!cParam->Update(p,c)) return kFALSE;
2753 :
2754 0 : return kTRUE;
2755 0 : }
2756 :
2757 :
2758 :
2759 :
2760 :
2761 :
2762 :
2763 :
2764 :
2765 :
2766 : //_______________________________________________________________________
2767 : Bool_t AliESDtrack::RelateToVertexTPC(const AliESDVertex *vtx,
2768 : Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
2769 : //
2770 : // Try to relate the TPC-only track parameters to the vertex "vtx",
2771 : // if the (rough) transverse impact parameter is not bigger then "maxd".
2772 : // Magnetic field is "b" (kG).
2773 : //
2774 : // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2775 : // b) The impact parameters and their covariance matrix are calculated.
2776 : // c) An attempt to constrain the TPC-only params to the vertex is done.
2777 : // The constrained params are returned via "cParam".
2778 : //
2779 : // In the case of success, the returned value is kTRUE
2780 : // otherwise, it's kFALSE)
2781 : //
2782 :
2783 0 : if (!fTPCInner) return kFALSE;
2784 0 : if (!vtx) return kFALSE;
2785 :
2786 0 : Double_t dz[2],cov[3];
2787 0 : if (!fTPCInner->PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2788 :
2789 0 : fdTPC = dz[0];
2790 0 : fzTPC = dz[1];
2791 0 : fCddTPC = cov[0];
2792 0 : fCdzTPC = cov[1];
2793 0 : fCzzTPC = cov[2];
2794 :
2795 0 : Double_t covar[6]; vtx->GetCovMatrix(covar);
2796 0 : Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2797 0 : Double_t c[3]={covar[2],0.,covar[5]};
2798 :
2799 0 : Double_t chi2=GetPredictedChi2(p,c);
2800 0 : if (chi2>kVeryBig) return kFALSE;
2801 :
2802 0 : fCchi2TPC=chi2;
2803 :
2804 0 : if (!cParam) return kTRUE;
2805 :
2806 0 : *cParam = *fTPCInner;
2807 0 : if (!cParam->Update(p,c)) return kFALSE;
2808 :
2809 0 : return kTRUE;
2810 0 : }
2811 :
2812 : //_______________________________________________________________________
2813 : Bool_t AliESDtrack::RelateToVertexTPCBxByBz(const AliESDVertex *vtx,
2814 : Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2815 : //
2816 : // Try to relate the TPC-only track parameters to the vertex "vtx",
2817 : // if the (rough) transverse impact parameter is not bigger then "maxd".
2818 : //
2819 : // All three components of the magnetic field ,"b[3]" (kG),
2820 : // are taken into account.
2821 : //
2822 : // a) The TPC-only paramters are extapolated to the DCA to the vertex.
2823 : // b) The impact parameters and their covariance matrix are calculated.
2824 : // c) An attempt to constrain the TPC-only params to the vertex is done.
2825 : // The constrained params are returned via "cParam".
2826 : //
2827 : // In the case of success, the returned value is kTRUE
2828 : // otherwise, it's kFALSE)
2829 : //
2830 :
2831 320 : if (!fTPCInner) return kFALSE;
2832 136 : if (!vtx) return kFALSE;
2833 :
2834 136 : Double_t dz[2],cov[3];
2835 136 : if (!fTPCInner->PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2836 :
2837 136 : fdTPC = dz[0];
2838 136 : fzTPC = dz[1];
2839 136 : fCddTPC = cov[0];
2840 136 : fCdzTPC = cov[1];
2841 136 : fCzzTPC = cov[2];
2842 :
2843 136 : Double_t covar[6]; vtx->GetCovMatrix(covar);
2844 136 : Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2845 136 : Double_t c[3]={covar[2],0.,covar[5]};
2846 :
2847 136 : Double_t chi2=GetPredictedChi2(p,c);
2848 136 : if (chi2>kVeryBig) return kFALSE;
2849 :
2850 136 : fCchi2TPC=chi2;
2851 :
2852 272 : if (!cParam) return kTRUE;
2853 :
2854 0 : *cParam = *fTPCInner;
2855 0 : if (!cParam->Update(p,c)) return kFALSE;
2856 :
2857 0 : return kTRUE;
2858 424 : }
2859 :
2860 : //_______________________________________________________________________
2861 : Bool_t AliESDtrack::RelateToVertex(const AliESDVertex *vtx,
2862 : Double_t b, Double_t maxd, AliExternalTrackParam *cParam) {
2863 : //
2864 : // Try to relate this track to the vertex "vtx",
2865 : // if the (rough) transverse impact parameter is not bigger then "maxd".
2866 : // Magnetic field is "b" (kG).
2867 : //
2868 : // a) The track gets extapolated to the DCA to the vertex.
2869 : // b) The impact parameters and their covariance matrix are calculated.
2870 : // c) An attempt to constrain this track to the vertex is done.
2871 : // The constrained params are returned via "cParam".
2872 : //
2873 : // In the case of success, the returned value is kTRUE
2874 : // (otherwise, it's kFALSE)
2875 : //
2876 :
2877 184 : if (!vtx) return kFALSE;
2878 :
2879 92 : Double_t dz[2],cov[3];
2880 92 : if (!PropagateToDCA(vtx, b, maxd, dz, cov)) return kFALSE;
2881 :
2882 92 : fD = dz[0];
2883 92 : fZ = dz[1];
2884 92 : fCdd = cov[0];
2885 92 : fCdz = cov[1];
2886 92 : fCzz = cov[2];
2887 :
2888 92 : Double_t covar[6]; vtx->GetCovMatrix(covar);
2889 92 : Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2890 92 : Double_t c[3]={covar[2],0.,covar[5]};
2891 :
2892 92 : Double_t chi2=GetPredictedChi2(p,c);
2893 92 : if (chi2>kVeryBig) return kFALSE;
2894 :
2895 92 : fCchi2=chi2;
2896 :
2897 :
2898 : //--- Could now these lines be removed ? ---
2899 92 : delete fCp;
2900 184 : fCp=new AliExternalTrackParam(*this);
2901 :
2902 92 : if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2903 : //----------------------------------------
2904 :
2905 92 : fVertexID = vtx->GetID();
2906 :
2907 184 : if (!cParam) return kTRUE;
2908 :
2909 0 : *cParam = *this;
2910 0 : if (!cParam->Update(p,c)) return kFALSE;
2911 :
2912 0 : return kTRUE;
2913 276 : }
2914 :
2915 : //_______________________________________________________________________
2916 : Bool_t AliESDtrack::RelateToVertexBxByBz(const AliESDVertex *vtx,
2917 : Double_t b[3], Double_t maxd, AliExternalTrackParam *cParam) {
2918 : //
2919 : // Try to relate this track to the vertex "vtx",
2920 : // if the (rough) transverse impact parameter is not bigger then "maxd".
2921 : // Magnetic field is "b" (kG).
2922 : //
2923 : // a) The track gets extapolated to the DCA to the vertex.
2924 : // b) The impact parameters and their covariance matrix are calculated.
2925 : // c) An attempt to constrain this track to the vertex is done.
2926 : // The constrained params are returned via "cParam".
2927 : //
2928 : // In the case of success, the returned value is kTRUE
2929 : // (otherwise, it's kFALSE)
2930 : //
2931 :
2932 424 : if (!vtx) return kFALSE;
2933 :
2934 212 : Double_t dz[2],cov[3];
2935 212 : if (!PropagateToDCABxByBz(vtx, b, maxd, dz, cov)) return kFALSE;
2936 :
2937 212 : fD = dz[0];
2938 212 : fZ = dz[1];
2939 212 : fCdd = cov[0];
2940 212 : fCdz = cov[1];
2941 212 : fCzz = cov[2];
2942 :
2943 212 : Double_t covar[6]; vtx->GetCovMatrix(covar);
2944 212 : Double_t p[2]={GetParameter()[0]-dz[0],GetParameter()[1]-dz[1]};
2945 212 : Double_t c[3]={covar[2],0.,covar[5]};
2946 :
2947 212 : Double_t chi2=GetPredictedChi2(p,c);
2948 212 : if (chi2>kVeryBig) return kFALSE;
2949 :
2950 212 : fCchi2=chi2;
2951 :
2952 :
2953 : //--- Could now these lines be removed ? ---
2954 360 : delete fCp;
2955 424 : fCp=new AliExternalTrackParam(*this);
2956 :
2957 242 : if (!fCp->Update(p,c)) {delete fCp; fCp=0; return kFALSE;}
2958 : //----------------------------------------
2959 :
2960 202 : fVertexID = vtx->GetID();
2961 :
2962 404 : if (!cParam) return kTRUE;
2963 :
2964 0 : *cParam = *this;
2965 0 : if (!cParam->Update(p,c)) return kFALSE;
2966 :
2967 0 : return kTRUE;
2968 636 : }
2969 :
2970 : //_______________________________________________________________________
2971 : void AliESDtrack::Print(Option_t *) const {
2972 : // Prints info on the track
2973 0 : AliExternalTrackParam::Print();
2974 0 : printf("ESD track info\n") ;
2975 0 : Double_t p[AliPID::kSPECIES] ;
2976 : Int_t index = 0 ;
2977 0 : if( IsOn(kITSpid) ){
2978 0 : printf("From ITS: ") ;
2979 0 : GetITSpid(p) ;
2980 0 : for(index = 0 ; index < AliPID::kSPECIES; index++)
2981 0 : printf("%f, ", p[index]) ;
2982 0 : printf("\n signal = %f\n", GetITSsignal()) ;
2983 0 : }
2984 0 : if( IsOn(kTPCpid) ){
2985 0 : printf("From TPC: ") ;
2986 0 : GetTPCpid(p) ;
2987 0 : for(index = 0 ; index < AliPID::kSPECIES; index++)
2988 0 : printf("%f, ", p[index]) ;
2989 0 : printf("\n signal = %f\n", GetTPCsignal()) ;
2990 0 : }
2991 0 : if( IsOn(kTRDpid) ){
2992 0 : printf("From TRD: ") ;
2993 0 : GetTRDpid(p) ;
2994 0 : for(index = 0 ; index < AliPID::kSPECIES; index++)
2995 0 : printf("%f, ", p[index]) ;
2996 0 : printf("\n signal = %f\n", GetTRDsignal()) ;
2997 0 : printf("\n NchamberdEdx = %d\n", GetTRDNchamberdEdx()) ;
2998 0 : printf("\n NclusterdEdx = %d\n", GetTRDNclusterdEdx()) ;
2999 0 : }
3000 0 : if( IsOn(kTOFpid) ){
3001 0 : printf("From TOF: ") ;
3002 0 : GetTOFpid(p) ;
3003 0 : for(index = 0 ; index < AliPID::kSPECIES; index++)
3004 0 : printf("%f, ", p[index]) ;
3005 0 : printf("\n signal = %f\n", GetTOFsignal()) ;
3006 0 : }
3007 0 : if( IsOn(kHMPIDpid) ){
3008 0 : printf("From HMPID: ") ;
3009 0 : GetHMPIDpid(p) ;
3010 0 : for(index = 0 ; index < AliPID::kSPECIES; index++)
3011 0 : printf("%f, ", p[index]) ;
3012 0 : printf("\n signal = %f\n", GetHMPIDsignal()) ;
3013 0 : }
3014 0 : }
3015 :
3016 :
3017 : //
3018 : // Draw functionality
3019 : // Origin: Marian Ivanov, Marian.Ivanov@cern.ch
3020 : //
3021 : void AliESDtrack::FillPolymarker(TPolyMarker3D *pol, Float_t magF, Float_t minR, Float_t maxR, Float_t stepR){
3022 : //
3023 : // Fill points in the polymarker
3024 : //
3025 0 : TObjArray arrayRef;
3026 0 : arrayRef.AddLast(new AliExternalTrackParam(*this));
3027 0 : if (fIp) arrayRef.AddLast(new AliExternalTrackParam(*fIp));
3028 0 : if (fOp) arrayRef.AddLast(new AliExternalTrackParam(*fOp));
3029 0 : if (fHMPIDp) arrayRef.AddLast(new AliExternalTrackParam(*fHMPIDp));
3030 : //
3031 : Double_t mpos[3]={0,0,0};
3032 0 : Int_t entries=arrayRef.GetEntries();
3033 0 : for (Int_t i=0;i<entries;i++){
3034 0 : Double_t pos[3];
3035 0 : ((AliExternalTrackParam*)arrayRef.At(i))->GetXYZ(pos);
3036 0 : mpos[0]+=pos[0]/entries;
3037 0 : mpos[1]+=pos[1]/entries;
3038 0 : mpos[2]+=pos[2]/entries;
3039 0 : }
3040 : // Rotate to the mean position
3041 : //
3042 0 : Float_t fi= TMath::ATan2(mpos[1],mpos[0]);
3043 0 : for (Int_t i=0;i<entries;i++){
3044 0 : Bool_t res = ((AliExternalTrackParam*)arrayRef.At(i))->Rotate(fi);
3045 0 : if (!res) delete arrayRef.RemoveAt(i);
3046 : }
3047 : Int_t counter=0;
3048 0 : for (Double_t r=minR; r<maxR; r+=stepR){
3049 : Double_t sweight=0;
3050 : Double_t mlpos[3]={0,0,0};
3051 0 : for (Int_t i=0;i<entries;i++){
3052 0 : Double_t point[3]={0,0,0};
3053 0 : AliExternalTrackParam *param = ((AliExternalTrackParam*)arrayRef.At(i));
3054 0 : if (!param) continue;
3055 0 : if (param->GetXYZAt(r,magF,point)){
3056 0 : Double_t weight = 1./(10.+(r-param->GetX())*(r-param->GetX()));
3057 0 : sweight+=weight;
3058 0 : mlpos[0]+=point[0]*weight;
3059 0 : mlpos[1]+=point[1]*weight;
3060 0 : mlpos[2]+=point[2]*weight;
3061 0 : }
3062 0 : }
3063 0 : if (sweight>0){
3064 0 : mlpos[0]/=sweight;
3065 0 : mlpos[1]/=sweight;
3066 0 : mlpos[2]/=sweight;
3067 0 : pol->SetPoint(counter,mlpos[0],mlpos[1], mlpos[2]);
3068 : // printf("xyz\t%f\t%f\t%f\n",mlpos[0], mlpos[1],mlpos[2]);
3069 0 : counter++;
3070 0 : }
3071 : }
3072 0 : }
3073 :
3074 : //_______________________________________________________________________
3075 : void AliESDtrack::SetITSdEdxSamples(const Double_t s[4]) {
3076 : //
3077 : // Store the dE/dx samples measured by the two SSD and two SDD layers.
3078 : // These samples are corrected for the track segment length.
3079 : //
3080 6292 : for (Int_t i=0; i<4; i++) fITSdEdxSamples[i]=s[i];
3081 572 : }
3082 :
3083 : //_______________________________________________________________________
3084 : void AliESDtrack::GetITSdEdxSamples(Double_t s[4]) const {
3085 : //
3086 : // Get the dE/dx samples measured by the two SSD and two SDD layers.
3087 : // These samples are corrected for the track segment length.
3088 : //
3089 1320 : for (Int_t i=0; i<4; i++) s[i]=fITSdEdxSamples[i];
3090 120 : }
3091 :
3092 :
3093 : UShort_t AliESDtrack::GetTPCnclsS(Int_t i0,Int_t i1) const{
3094 : //
3095 : // get number of shared TPC clusters
3096 : //
3097 2088 : return fTPCSharedMap.CountBits(i0)-fTPCSharedMap.CountBits(i1);
3098 : }
3099 :
3100 : UShort_t AliESDtrack::GetTPCncls(Int_t i0,Int_t i1) const{
3101 : //
3102 : // get number of TPC clusters
3103 : //
3104 1392 : return fTPCClusterMap.CountBits(i0)-fTPCClusterMap.CountBits(i1);
3105 : }
3106 :
3107 : //____________________________________________________________________
3108 : Double_t AliESDtrack::GetChi2TPCConstrainedVsGlobal(const AliESDVertex* vtx) const
3109 : {
3110 : // Calculates the chi2 between the TPC track (TPCinner) constrained to the primary vertex and the global track
3111 : //
3112 : // Returns -1 in case the calculation failed
3113 : //
3114 : // Value is cached as a non-persistent member.
3115 : //
3116 : // Code adapted from original code by GSI group (Jacek, Marian, Michael)
3117 :
3118 : // cache, ignoring that a different vertex might be passed
3119 0 : if (fCacheChi2TPCConstrainedVsGlobalVertex == vtx)
3120 0 : return fCacheChi2TPCConstrainedVsGlobal;
3121 :
3122 0 : fCacheChi2TPCConstrainedVsGlobal = -1;
3123 0 : fCacheChi2TPCConstrainedVsGlobalVertex = vtx;
3124 :
3125 0 : Double_t x[3];
3126 0 : GetXYZ(x);
3127 0 : Double_t b[3];
3128 0 : AliTrackerBase::GetBxByBz(x,b);
3129 :
3130 0 : if (!fTPCInner) {
3131 0 : AliWarning("Could not get TPC Inner Param.");
3132 0 : return fCacheChi2TPCConstrainedVsGlobal;
3133 : }
3134 :
3135 : // clone for constraining
3136 0 : AliExternalTrackParam* tpcInnerC = new AliExternalTrackParam(*fTPCInner);
3137 0 : if (!tpcInnerC) {
3138 0 : AliWarning("Clone of TPCInnerParam failed.");
3139 0 : return fCacheChi2TPCConstrainedVsGlobal;
3140 : }
3141 :
3142 : // transform to the track reference frame
3143 0 : Bool_t isOK = tpcInnerC->Rotate(GetAlpha());
3144 0 : isOK &= tpcInnerC->PropagateTo(GetX(), b[2]);
3145 0 : if (!isOK) {
3146 0 : delete tpcInnerC;
3147 : tpcInnerC = 0;
3148 0 : AliWarning("Rotation/Propagation of track failed.") ;
3149 0 : return fCacheChi2TPCConstrainedVsGlobal;
3150 : }
3151 :
3152 : // constrain TPCinner
3153 0 : isOK = tpcInnerC->ConstrainToVertex(vtx, b);
3154 :
3155 : // transform to the track reference frame
3156 0 : isOK &= tpcInnerC->Rotate(GetAlpha());
3157 0 : isOK &= tpcInnerC->PropagateTo(GetX(), b[2]);
3158 :
3159 0 : if (!isOK) {
3160 0 : AliWarning("ConstrainTPCInner failed.") ;
3161 0 : delete tpcInnerC;
3162 : tpcInnerC = 0;
3163 0 : return fCacheChi2TPCConstrainedVsGlobal;
3164 : }
3165 :
3166 : // calculate chi2 between vi and vj vectors
3167 : // with covi and covj covariance matrices
3168 : // chi2ij = (vi-vj)^(T)*(covi+covj)^(-1)*(vi-vj)
3169 0 : TMatrixD deltaT(5,1);
3170 0 : TMatrixD delta(1,5);
3171 0 : TMatrixD covarM(5,5);
3172 :
3173 0 : for (Int_t ipar=0; ipar<5; ipar++) {
3174 0 : deltaT(ipar,0) = tpcInnerC->GetParameter()[ipar] - GetParameter()[ipar];
3175 0 : delta(0,ipar) = tpcInnerC->GetParameter()[ipar] - GetParameter()[ipar];
3176 :
3177 0 : for (Int_t jpar=0; jpar<5; jpar++) {
3178 0 : Int_t index = GetIndex(ipar,jpar);
3179 0 : covarM(ipar,jpar) = GetCovariance()[index]+tpcInnerC->GetCovariance()[index];
3180 : }
3181 : }
3182 : // chi2 distance TPC constrained and TPC+ITS
3183 0 : TMatrixD covarMInv = covarM.Invert();
3184 0 : TMatrixD mat2 = covarMInv*deltaT;
3185 0 : TMatrixD chi2 = delta*mat2;
3186 :
3187 0 : delete tpcInnerC;
3188 : tpcInnerC = 0;
3189 :
3190 0 : fCacheChi2TPCConstrainedVsGlobal = chi2(0,0);
3191 0 : return fCacheChi2TPCConstrainedVsGlobal;
3192 0 : }
3193 :
3194 : void AliESDtrack::SetDetectorPID(const AliDetectorPID *pid)
3195 : {
3196 : //
3197 : // Set the detector PID
3198 : //
3199 0 : if (fDetectorPID) delete fDetectorPID;
3200 0 : fDetectorPID=pid;
3201 :
3202 0 : }
3203 :
3204 : Double_t AliESDtrack::GetLengthInActiveZone( Int_t mode, Double_t deltaY, Double_t deltaZ, Double_t bz, Double_t exbPhi , TTreeSRedirector * pcstream) const {
3205 : //
3206 : // Input parameters:
3207 : // mode - type of external track parameters
3208 : // deltaY - user defined "dead region" in cm
3209 : // deltaZ - user defined "active region" in cm (250 cm drift lenght - 14 cm L1 delay
3210 : // bz - magnetic field
3211 : // exbPhi - optional rotation due to the ExB effect
3212 : // return value:
3213 : // the length of the track in cm in "active volume" of the TPC
3214 : //
3215 0 : if (mode==0) return GetLengthInActiveZone(this, deltaY,deltaZ,bz, exbPhi,pcstream);
3216 0 : if (mode==1) return GetLengthInActiveZone(fIp, deltaY,deltaZ,bz, exbPhi,pcstream);
3217 0 : if (mode==2) return GetLengthInActiveZone(fOp, deltaY,deltaZ,bz, exbPhi,pcstream);
3218 0 : return 0;
3219 0 : }
3220 :
3221 : Double_t AliESDtrack::GetLengthInActiveZone(const AliExternalTrackParam *paramT, Double_t deltaY, Double_t deltaZ, Double_t bz, Double_t exbPhi , TTreeSRedirector * pcstream) {
3222 : //
3223 : // Numerical code to calculate the length of the track in active region of the TPC
3224 : // ( can be speed up if somebody wants to invest time - analysical version shoult be possible)
3225 : //
3226 : // Input parameters:
3227 : // paramT - external track parameters
3228 : // deltaY - user defined "dead region" in cm
3229 : // deltaZ - user defined "active region" in cm (250 cm drift lenght - 14 cm L1 delay
3230 : // bz - magnetic field
3231 : // exbPhi - optional rotation due to the ExB effect
3232 : // return value:
3233 : // the length of the track in cm in "active volume" of the TPC
3234 : //
3235 : const Double_t rIn=85;
3236 : const Double_t rOut=245;
3237 0 : Double_t xyz[3], pxyz[3];
3238 0 : if (paramT->GetXYZAt(rIn,bz,xyz)){
3239 0 : paramT->GetPxPyPzAt(rIn,bz,pxyz);
3240 0 : }else{
3241 0 : paramT->GetXYZ(xyz);
3242 0 : paramT->GetPxPyPz(pxyz);
3243 : }
3244 : //
3245 0 : Double_t dca = -paramT->GetD(0,0,bz); // get impact parameter distance to point (0,0)
3246 0 : Double_t radius= TMath::Abs(1/paramT->GetC(bz)); //
3247 0 : Double_t sign = paramT->GetSign()*TMath::Sign(1.,bz)*(-1.);
3248 0 : Double_t R0 = TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]); // radius at current point
3249 0 : Double_t phiR0 = TMath::ATan2(xyz[1],xyz[0]); // angle of given point
3250 0 : Double_t dPhiR0= -TMath::ASin((dca*dca-2*dca*radius*sign+R0*R0)/(2*R0*(dca-radius*sign)));
3251 0 : Double_t phi0 = phiR0-(dPhiR0); // global phi offset to be added
3252 : //
3253 : //
3254 0 : AliExternalTrackParam paramR=(*paramT);
3255 0 : Double_t length=0;
3256 0 : for (Double_t R=rIn; R<=rOut; R++){
3257 0 : Double_t sinPhi=(dca*dca-2*dca*radius*sign+R*R)/(2*R*(dca-radius*sign));
3258 0 : if (TMath::Abs(sinPhi)>=1) continue;
3259 0 : Double_t dphi = -TMath::ASin(sinPhi);
3260 0 : Double_t phi = phi0+dphi; // global phi
3261 0 : Int_t sector = TMath::Nint(9*phi/(TMath::Pi()));
3262 0 : Double_t dPhiEdge = phi-(sector*TMath::Pi()/9)+exbPhi; // distance to sector boundary in rphi
3263 0 : Double_t dX = R*TMath::Cos(phi)-xyz[0];
3264 0 : Double_t dY = R*TMath::Sin(phi)-xyz[1];
3265 0 : Double_t deltaPhi = 2*TMath::ASin(0.5*TMath::Sqrt(dX*dX+dY*dY)/radius);
3266 0 : Double_t z = xyz[2]+deltaPhi*radius*paramT->GetTgl();
3267 0 : if (TMath::Abs(dPhiEdge*R)>deltaY && TMath::Abs(z)<deltaZ){
3268 0 : length++;
3269 0 : }
3270 : // Double_t deltaZ= dphi*radius;
3271 0 : if (pcstream){
3272 : //should we keep debug possibility ?
3273 0 : AliExternalTrackParam paramTcopy=(*paramT);
3274 0 : paramR.Rotate(phi);
3275 0 : paramR.PropagateTo(R,bz);
3276 0 : (*pcstream)<<"debugEdge"<<
3277 0 : "length="<<length<< // track length
3278 0 : "radius="<<radius<< // radius
3279 0 : "R="<<R<< // radius
3280 0 : "dphiEdge="<<dPhiEdge<< // distance to edge
3281 0 : "phi0="<<phi0<< // phi0 -phi at the track initial position
3282 0 : "phi="<<phi<< //
3283 0 : "z="<<z<<
3284 0 : "pT.="<<¶mTcopy<<
3285 0 : "pR.="<<¶mR<<
3286 : "\n";
3287 0 : }
3288 0 : }
3289 0 : return length;
3290 0 : }
3291 :
3292 : Double_t AliESDtrack::GetMassForTracking() const
3293 : {
3294 3540 : int pid = fPIDForTracking;
3295 1770 : if (pid<AliPID::kPion) pid = AliPID::kPion;
3296 1770 : double m = AliPID::ParticleMass(pid);
3297 7080 : return (fPIDForTracking==AliPID::kHe3 || fPIDForTracking==AliPID::kAlpha) ? -m : m;
3298 : }
3299 :
3300 :
3301 : void AliESDtrack::SetTOFclusterArray(Int_t /*ncluster*/,Int_t */*TOFcluster*/){
3302 0 : AliInfo("Method has to be implemented!");
3303 : // fNtofClusters=ncluster;
3304 : // if(TOFcluster == fTOFcluster) return;
3305 : // if(fTOFcluster){ // reset previous content
3306 : // delete[] fTOFcluster;
3307 : // fTOFcluster = NULL;
3308 : // fNtofClusters=0;
3309 : // }
3310 :
3311 : // if(ncluster){ // set new content
3312 : // fTOFcluster = new Int_t[fNtofClusters];
3313 : // for(Int_t i=0;i < fNtofClusters;i++) fTOFcluster[i] = TOFcluster[i];
3314 : // }
3315 : // else
3316 : // fTOFcluster = 0;
3317 0 : }
3318 :
3319 : //____________________________________________
3320 : void AliESDtrack::SuppressTOFMatches()
3321 : {
3322 : // remove reference to this track from TOF clusters
3323 20 : if (!fNtofClusters || !GetESDEvent()) return;
3324 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3325 0 : for (;fNtofClusters--;) {
3326 0 : AliESDTOFCluster* clTOF = (AliESDTOFCluster*)tofclArray->At(fTOFcluster[fNtofClusters]);
3327 0 : clTOF->SuppressMatchedTrack(GetID());
3328 0 : if (!clTOF->GetNMatchableTracks()) { // remove this cluster
3329 0 : int last = tofclArray->GetEntriesFast()-1;
3330 0 : AliESDTOFCluster* clTOFL = (AliESDTOFCluster*)tofclArray->At(last);
3331 0 : if (last != fTOFcluster[fNtofClusters]) {
3332 0 : *clTOF = *clTOFL; // move last cluster to the place of eliminated one
3333 : // fix the references on this cluster
3334 0 : clTOF->FixSelfReferences(last,fTOFcluster[fNtofClusters]);
3335 0 : }
3336 0 : tofclArray->RemoveAt(last);
3337 0 : }
3338 : }
3339 10 : }
3340 :
3341 : //____________________________________________
3342 : void AliESDtrack::ReplaceTOFTrackID(int oldID, int newID)
3343 : {
3344 : // replace the ID in TOF clusters references to this track
3345 0 : if (!fNtofClusters || !GetESDEvent()) return;
3346 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3347 0 : for (int it=fNtofClusters;it--;) {
3348 0 : AliESDTOFCluster* clTOF = (AliESDTOFCluster*)tofclArray->At(fTOFcluster[it]);
3349 0 : clTOF->ReplaceMatchedTrackID(oldID,newID);
3350 : }
3351 0 : }
3352 :
3353 : //____________________________________________
3354 : void AliESDtrack::ReplaceTOFClusterID(int oldID, int newID)
3355 : {
3356 : // replace the referenc on TOF cluster oldID by newID
3357 0 : if (!fNtofClusters || !GetESDEvent()) return;
3358 0 : for (int it=fNtofClusters;it--;) {
3359 0 : if (fTOFcluster[it] == oldID) {
3360 0 : fTOFcluster[it] = newID;
3361 0 : return;
3362 : }
3363 : }
3364 0 : }
3365 :
3366 : //____________________________________________
3367 : void AliESDtrack::ReplaceTOFMatchID(int oldID, int newID)
3368 : {
3369 : // replace in the ESDTOFCluster associated with this track the id of the corresponding
3370 : // ESDTOFMatch from oldID to newID
3371 0 : if (!fNtofClusters || !GetESDEvent()) return;
3372 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3373 0 : for (int it=fNtofClusters;it--;) {
3374 0 : AliESDTOFCluster* clTOF = (AliESDTOFCluster*)tofclArray->At(fTOFcluster[it]);
3375 0 : clTOF->ReplaceMatchID(oldID,newID);
3376 : }
3377 0 : }
3378 :
3379 : //____________________________________________
3380 : void AliESDtrack::AddTOFcluster(Int_t icl)
3381 : {
3382 264 : fNtofClusters++;
3383 :
3384 132 : Int_t *old = fTOFcluster;
3385 132 : fTOFcluster = new Int_t[fNtofClusters];
3386 :
3387 494 : for(Int_t i=0;i < fNtofClusters-1;i++) fTOFcluster[i] = old[i];
3388 132 : fTOFcluster[fNtofClusters-1] = icl;
3389 :
3390 232 : if(fNtofClusters-1) delete[] old; // delete previous content
3391 :
3392 132 : }
3393 :
3394 : //____________________________________________
3395 : void AliESDtrack::SetTOFsignal(Double_t tof)
3396 : {
3397 0 : if(fNtofClusters>0 && GetESDEvent()){
3398 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3399 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3400 0 : AliESDTOFHit* hit = tofcl->GetTOFHit(0);
3401 0 : if(hit) hit->SetTime(tof);
3402 0 : }
3403 : else{
3404 0 : if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3405 0 : fTOFsignal=tof;
3406 : }
3407 0 : }
3408 : //____________________________________________
3409 : void AliESDtrack::SetTOFCalChannel(Int_t index){
3410 0 : if(fNtofClusters>0 && GetESDEvent()){
3411 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3412 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3413 0 : AliESDTOFHit* hit = tofcl->GetTOFHit(0);
3414 0 : if(hit) hit->SetTOFchannel(index);
3415 0 : }
3416 : else{
3417 0 : if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3418 0 : fTOFCalChannel=index;
3419 : }
3420 0 : }
3421 : //____________________________________________
3422 : void AliESDtrack::SetTOFsignalToT(Double_t ToT){
3423 0 : if(fNtofClusters>0 && GetESDEvent()){
3424 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3425 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3426 0 : AliESDTOFHit* hit = tofcl->GetTOFHit(0);
3427 0 : if(hit) hit->SetTOT(ToT);
3428 0 : }
3429 : else{
3430 0 : if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3431 0 : fTOFsignalToT=ToT;
3432 : }
3433 0 : }
3434 : //____________________________________________
3435 : void AliESDtrack::SetTOFsignalRaw(Double_t tof){
3436 0 : if(fNtofClusters>0 && GetESDEvent()){
3437 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3438 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3439 0 : AliESDTOFHit* hit = tofcl->GetTOFHit(0);
3440 0 : if(hit) hit->SetTimeRaw(tof);
3441 0 : }
3442 : else{
3443 0 : if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3444 0 : fTOFsignalRaw=tof;
3445 : }
3446 0 : }
3447 : //____________________________________________
3448 : void AliESDtrack::SetTOFsignalDz(Double_t dz){
3449 : Int_t index = -1;
3450 : AliESDTOFCluster *tofcl;
3451 :
3452 0 : if(fNtofClusters>0 && GetESDEvent()){
3453 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3454 0 : tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3455 :
3456 0 : for(Int_t i=0;i < tofcl->GetNMatchableTracks();i++){
3457 0 : if(tofcl->GetTrackIndex(i) == GetID()) index = i;
3458 : }
3459 :
3460 0 : }
3461 0 : if(index > -1){
3462 0 : AliESDTOFMatch* match = tofcl->GetTOFMatch(index);
3463 0 : if(match){
3464 0 : match->SetDz(dz);
3465 0 : }
3466 0 : }
3467 : else{
3468 0 : if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3469 0 : fTOFsignalDz=dz;
3470 : }
3471 :
3472 :
3473 0 : }
3474 : //____________________________________________
3475 : void AliESDtrack::SetTOFsignalDx(Double_t dx){
3476 : Int_t index = -1;
3477 : AliESDTOFCluster *tofcl;
3478 :
3479 0 : if(fNtofClusters>0 && GetESDEvent()){
3480 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3481 0 : tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3482 :
3483 0 : for(Int_t i=0;i < tofcl->GetNMatchableTracks();i++){
3484 0 : if(tofcl->GetTrackIndex(i) == GetID()) index = i;
3485 : }
3486 :
3487 0 : }
3488 0 : if(index > -1){
3489 0 : AliESDTOFMatch* match = tofcl->GetTOFMatch(index);
3490 0 : if(match){
3491 0 : match->SetDx(dx);
3492 0 : }
3493 0 : }
3494 : else{
3495 0 : if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3496 0 : fTOFsignalDx=dx;
3497 : }
3498 0 : }
3499 : //____________________________________________
3500 : void AliESDtrack::SetTOFDeltaBC(Short_t deltaBC){
3501 0 : if(fNtofClusters>0 && GetESDEvent()){
3502 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3503 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3504 0 : AliESDTOFHit* hit = tofcl->GetTOFHit(0);
3505 0 : if(hit) hit->SetDeltaBC(deltaBC);
3506 0 : }
3507 : else{
3508 0 : if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3509 0 : fTOFdeltaBC=deltaBC;
3510 : }
3511 0 : }
3512 : //____________________________________________
3513 : void AliESDtrack::SetTOFL0L1(Short_t l0l1){
3514 0 : if(fNtofClusters>0 && GetESDEvent()){
3515 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3516 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3517 0 : AliESDTOFHit* hit = tofcl->GetTOFHit(0);
3518 0 : if(hit) hit->SetL0L1Latency(l0l1);
3519 0 : }
3520 : else{
3521 0 : if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3522 0 : fTOFl0l1=l0l1;
3523 : }
3524 0 : }
3525 : //____________________________________________
3526 : Double_t AliESDtrack::GetTOFsignal() const
3527 : {
3528 5003 : if(fNtofClusters>0 && GetESDEvent()){
3529 1641 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3530 1641 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3531 :
3532 1641 : return tofcl->GetTime();
3533 : }
3534 40 : else if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3535 :
3536 40 : return fTOFsignal;
3537 1681 : }
3538 :
3539 : //____________________________________________
3540 : Double_t AliESDtrack::GetTOFsignalToT() const
3541 : {
3542 0 : if(fNtofClusters>0 && GetESDEvent()){
3543 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3544 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3545 :
3546 0 : return tofcl->GetTOT();
3547 : }
3548 0 : else if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3549 :
3550 0 : return fTOFsignalToT;
3551 0 : }
3552 :
3553 : //____________________________________________
3554 : Double_t AliESDtrack::GetTOFsignalRaw() const
3555 : {
3556 0 : if(fNtofClusters>0 && GetESDEvent()){
3557 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3558 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3559 :
3560 0 : return tofcl->GetTimeRaw();
3561 : }
3562 0 : else if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3563 :
3564 0 : return fTOFsignalRaw;
3565 0 : }
3566 :
3567 : //____________________________________________
3568 : Double_t AliESDtrack::GetTOFsignalDz() const
3569 : {
3570 :
3571 : AliESDTOFCluster *tofcl;
3572 :
3573 : Int_t index = -1;
3574 0 : if(fNtofClusters>0 && GetESDEvent()){
3575 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3576 0 : tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3577 :
3578 0 : for(Int_t i=0;i < tofcl->GetNMatchableTracks();i++){
3579 0 : if(tofcl->GetTrackIndex(i) == GetID()) index = i;
3580 : }
3581 0 : }
3582 0 : else if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3583 :
3584 0 : if(fNtofClusters>0 && index > -1){
3585 0 : return tofcl->GetDz(index);
3586 : }
3587 0 : return fTOFsignalDz;
3588 0 : }
3589 :
3590 : //____________________________________________
3591 : Double_t AliESDtrack::GetTOFsignalDx() const
3592 : {
3593 : AliESDTOFCluster *tofcl;
3594 :
3595 : Int_t index = -1;
3596 0 : if(fNtofClusters>0 && GetESDEvent()){
3597 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3598 0 : tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3599 0 : for(Int_t i=0;i < tofcl->GetNMatchableTracks();i++){
3600 0 : if(tofcl->GetTrackIndex(i) == GetID()) index = i;
3601 : }
3602 0 : }
3603 0 : else if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3604 0 : if(fNtofClusters>0 && index > -1){
3605 0 : return tofcl->GetDx(index);
3606 : }
3607 0 : return fTOFsignalDx;
3608 0 : }
3609 :
3610 : //____________________________________________
3611 : Short_t AliESDtrack::GetTOFDeltaBC() const
3612 : {
3613 0 : if(fNtofClusters>0 && GetESDEvent()){
3614 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3615 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3616 0 : return tofcl->GetDeltaBC();
3617 : }
3618 0 : else if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3619 :
3620 0 : return fTOFdeltaBC;
3621 0 : }
3622 :
3623 : //____________________________________________
3624 : Short_t AliESDtrack::GetTOFL0L1() const
3625 : {
3626 0 : if(fNtofClusters>0 && GetESDEvent()){
3627 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3628 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3629 :
3630 0 : return tofcl->GetL0L1Latency();
3631 : }
3632 0 : else if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3633 :
3634 0 : return fTOFl0l1;
3635 0 : }
3636 :
3637 : //____________________________________________
3638 : Int_t AliESDtrack::GetTOFCalChannel() const
3639 : {
3640 0 : if(fNtofClusters>0 && GetESDEvent()){
3641 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3642 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3643 :
3644 0 : return tofcl->GetTOFchannel();
3645 : }
3646 0 : else if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3647 :
3648 0 : return fTOFCalChannel;
3649 0 : }
3650 :
3651 : //____________________________________________
3652 : Int_t AliESDtrack::GetTOFcluster() const
3653 : {
3654 0 : if(fNtofClusters>0 && GetESDEvent()){
3655 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3656 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3657 :
3658 0 : return tofcl->GetClusterIndex();
3659 : }
3660 0 : else if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3661 :
3662 0 : return fTOFindex;
3663 0 : }
3664 :
3665 : //____________________________________________
3666 : Int_t AliESDtrack::GetTOFclusterN() const
3667 : {
3668 0 : return fNtofClusters;
3669 : }
3670 :
3671 : //____________________________________________
3672 : Bool_t AliESDtrack::IsTOFHitAlreadyMatched() const{
3673 0 : if(fNtofClusters>0 && GetESDEvent()){
3674 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3675 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[0]);
3676 :
3677 0 : if (tofcl->GetNMatchableTracks() > 1)
3678 0 : return kTRUE;
3679 0 : }
3680 0 : else if(fNtofClusters>0) AliInfo("No AliESDEvent available here!\n");
3681 :
3682 0 : return kFALSE;
3683 0 : }
3684 :
3685 : //____________________________________________
3686 : void AliESDtrack::ReMapTOFcluster(Int_t ncl,Int_t *mapping){
3687 0 : for(Int_t i=0;i<fNtofClusters;i++){
3688 0 : if(fTOFcluster[i]<ncl && fTOFcluster[i]>-1)
3689 0 : fTOFcluster[i] = mapping[fTOFcluster[i]];
3690 : else
3691 0 : AliInfo(Form("TOF cluster re-mapping in AliESDtrack: out of range (%i > %i)\n",fTOFcluster[i],ncl));
3692 : }
3693 0 : }
3694 :
3695 : //____________________________________________
3696 : void AliESDtrack::SortTOFcluster(){
3697 0 : TClonesArray *tofclArray = GetESDEvent()->GetESDTOFClusters();
3698 :
3699 0 : for(Int_t i=0;i<fNtofClusters-1;i++){
3700 0 : for(Int_t j=i+1;j<fNtofClusters;j++){
3701 0 : AliESDTOFCluster *tofcl = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[i]);
3702 : Int_t index1 = -1;
3703 0 : for(Int_t it=0;it < tofcl->GetNMatchableTracks();it++){
3704 0 : if(tofcl->GetTrackIndex(it) == GetID()) index1 = it;
3705 : }
3706 : Double_t timedist1 = 10000;
3707 0 : for(Int_t isp=0; isp< AliPID::kSPECIESC;isp++){
3708 0 : Double_t timec = TMath::Abs(tofcl->GetTime() - tofcl->GetIntegratedTime(isp));
3709 0 : if(timec < timedist1) timedist1 = timec;
3710 : }
3711 0 : timedist1 *= 0.03; // in cm
3712 0 : Double_t radius1 = tofcl->GetDx(index1)*tofcl->GetDx(index1) + tofcl->GetDz(index1)*tofcl->GetDz(index1) + timedist1*timedist1;
3713 :
3714 0 : AliESDTOFCluster *tofcl2 = (AliESDTOFCluster *) tofclArray->At(fTOFcluster[j]);
3715 : Int_t index2 = -1;
3716 0 : for(Int_t it=0;it < tofcl2->GetNMatchableTracks();it++){
3717 0 : if(tofcl2->GetTrackIndex(it) == GetID()) index2 = it;
3718 : }
3719 0 : if(index1 == -1 || index2 == -1){
3720 : }
3721 : Double_t timedist2 = 10000;
3722 0 : for(Int_t isp=0; isp< AliPID::kSPECIESC;isp++){
3723 0 : Double_t timec = TMath::Abs(tofcl2->GetTime() - tofcl2->GetIntegratedTime(isp));
3724 0 : if(timec < timedist2) timedist2 = timec;
3725 : }
3726 0 : timedist2 *= 0.03; // in cm
3727 0 : Double_t radius2 = tofcl2->GetDx(index2)*tofcl2->GetDx(index2) + tofcl2->GetDz(index2)*tofcl2->GetDz(index2) + timedist2*timedist2;
3728 :
3729 0 : if(radius2 < radius1){
3730 0 : Int_t change = fTOFcluster[i];
3731 0 : fTOFcluster[i] = fTOFcluster[j];
3732 0 : fTOFcluster[j] = change;
3733 0 : }
3734 : }
3735 : }
3736 0 : }
3737 :
3738 : //____________________________________________
3739 : const AliTOFHeader* AliESDtrack::GetTOFHeader() const {
3740 0 : return fESDEvent ? fESDEvent->GetTOFHeader() : 0x0;
3741 : }
3742 :
3743 : //___________________________________________
3744 : void AliESDtrack::SetID(Short_t id)
3745 : {
3746 : // set track ID taking care about dependencies
3747 324 : if (fNtofClusters) ReplaceTOFTrackID(fID,id);
3748 162 : fID=id;
3749 162 : }
3750 :
3751 :
3752 : Double_t AliESDtrack::GetdEdxInfo(Int_t regionID, Int_t calibID, Int_t qID, Int_t valueID){
3753 : //
3754 : // Interface to get the calibrated dEdx information
3755 : // For details of arguments and return values see
3756 : // AliTPCdEdxInfo::GetdEdxInfo(Int_t regionID, Int_t calibID, Int_t valueID)
3757 : //
3758 0 : if (!fTPCdEdxInfo) return 0;
3759 0 : if (!fIp) return 0;
3760 0 : return fTPCdEdxInfo->GetdEdxInfo(fIp, regionID, calibID, qID, valueID);
3761 0 : }
3762 :
3763 :
3764 : Double_t AliESDtrack::GetdEdxInfoTRD(Int_t method, Double_t p0, Double_t p1, Double_t p2){
3765 : //
3766 : // Methods
3767 : // mean values:
3768 : // 0.) linear
3769 : // 1.) logarithmic
3770 : // 2.) 1/sqrt
3771 : // 3.) power()
3772 : // time COG:
3773 : // 4.) linear
3774 : // 5.) logarithmic
3775 : // 6.) square
3776 0 : Int_t nSlicesPerLayer=GetNumberOfTRDslices();
3777 0 : Int_t nSlicesAll=GetNumberOfTRDslices()*kTRDnPlanes;
3778 :
3779 0 : if (method<=3){
3780 : Double_t sumAmp=0;
3781 : Int_t sumW=0;
3782 0 : for (Int_t ibin=0; ibin<nSlicesAll; ibin++){
3783 0 : if (fTRDslices[ibin]<=0) continue;
3784 0 : sumW++;
3785 0 : if (method==0) sumAmp+=fTRDslices[ibin];
3786 0 : if (method==1) sumAmp+=TMath::Log(TMath::Abs(fTRDslices[ibin])+p0);
3787 0 : if (method==2) sumAmp+=1/TMath::Sqrt(TMath::Abs(fTRDslices[ibin])+p0);
3788 0 : if (method==3) sumAmp+=TMath::Power(TMath::Abs(fTRDslices[ibin])+p0,p1);
3789 : }
3790 0 : if (sumW==0) return 0;
3791 0 : Double_t dEdx=sumAmp/sumW;
3792 0 : if (method==1) dEdx= TMath::Exp(dEdx);
3793 0 : if (method==2) dEdx= 1/(dEdx*dEdx);
3794 0 : if (method==3) dEdx= TMath::Power(dEdx,1/p1);
3795 : return dEdx;
3796 : }
3797 0 : if (method>3){
3798 : Double_t sumWT=0;
3799 : Double_t sumW=0;
3800 0 : for (Int_t ibin=0; ibin<nSlicesAll; ibin++){
3801 0 : if (fTRDslices[ibin]<=0) continue;
3802 0 : Double_t time=(ibin%nSlicesPerLayer);
3803 : Double_t weight=fTRDslices[ibin];
3804 0 : if (method==5) weight=TMath::Log((weight+p0)/p0);
3805 0 : if (method==6) weight=TMath::Power(weight+p0,p1);
3806 0 : sumWT+=time*weight;
3807 0 : sumW+=weight;
3808 0 : }
3809 0 : if (sumW<=0) return 0;
3810 0 : Double_t meanTime=sumWT/sumW;
3811 : return meanTime;
3812 : }
3813 0 : return 0;
3814 0 : }
3815 :
3816 : void AliESDtrack::SetImpactParameters( const Float_t p[2], const Float_t cov[3], const Float_t chi2, const AliExternalTrackParam *cParam)
3817 : {
3818 : // set impact parameters
3819 :
3820 0 : fD = p[0];
3821 0 : fZ = p[1];
3822 0 : fCdd = cov[0];
3823 0 : fCdz = cov[1];
3824 0 : fCzz = cov[2];
3825 0 : fCchi2=chi2;
3826 0 : delete fCp;
3827 0 : if( cParam ) fCp=new AliExternalTrackParam(*cParam);
3828 0 : }
3829 :
3830 : void AliESDtrack::SetImpactParametersTPC( const Float_t p[2], const Float_t cov[3], const Float_t chi2 )
3831 : {
3832 : // set impact parameters TPC
3833 :
3834 0 : fdTPC = p[0];
3835 0 : fzTPC = p[1];
3836 0 : fCddTPC = cov[0];
3837 0 : fCdzTPC = cov[1];
3838 0 : fCzzTPC = cov[2];
3839 0 : fCchi2TPC = chi2;
3840 0 : }
|