]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RALICE/AliTrack.cxx
example macros for EVE analysis using new ListAnalyser (Ben)
[u/mrichter/AliRoot.git] / RALICE / AliTrack.cxx
CommitLineData
4c039060 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
f531a546 16// $Id$
4c039060 17
959fbac5 18///////////////////////////////////////////////////////////////////////////
19// Class AliTrack
20// Handling of the attributes of a reconstructed particle track.
21//
22// Coding example :
23// ----------------
24//
25// Float_t a[4]={195.,1.2,-0.04,8.5};
26// Ali4Vector pmu;
27// pmu.SetVector(a,"car");
28// AliTrack t1;
29// t1.Set4Momentum(pmu);
30//
31// Float_t b[3]={1.2,-0.04,8.5};
32// Ali3Vector p;
33// p.SetVector(b,"car");
34// AliTrack t2;
35// t2.Set3Momentum(p);
36// t2.SetCharge(0);
37// t2.SetMass(1.115);
38//
84bb7c66 39// t1.Data();
40// t2.Data();
959fbac5 41//
42// Float_t pi=acos(-1.);
43// Float_t thcms=0.2*pi; // decay theta angle in cms
44// Float_t phicms=pi/4.; // decay theta angle in cms
45// Float_t m1=0.938;
46// Float_t m2=0.140;
47// t2.Decay(m1,m2,thcms,phicms); // Track t2 decay : Lambda -> proton + pion
48//
49// t2.List();
50//
51// Int_t ndec=t2.GetNdecay();
52// AliTrack* d1=t2.GetDecayTrack(1); // Access to decay track number 1
53// AliTrack* d2=t2.GetDecayTrack(2); // Access to decay track number 2
54//
55// AliSignal s1,s2,s3,s4;
56//
57// .... // Code (e.g. detector readout) to fill AliSignal data
58//
59// AliTrack trec; // Track which will be reconstructed from signals
60// trec.AddSignal(s1);
61// trec.AddSignal(s3);
62// trec.AddSignal(s4);
63//
64// Ali3Vector P;
65// Float_t Q,M;
66//
67// ... // Code which accesses signals from trec and reconstructs
68// 3-momentum P, charge Q, mass M etc...
69//
70// trec.Set3Momentum(P);
71// trec.SetCharge(Q);
72// trec.SetMass(M);
73//
74// Float_t r1[3]={1.6,-3.8,25.7};
75// Float_t er1[3]={0.2,0.5,1.8};
76// Float_t r2[3]={8.6,23.8,-6.7};
77// Float_t er2[3]={0.93,1.78,0.8};
78// AliPosition begin,end;
79// begin.SetPosition(r1,"car");
80// begin.SetPositionErrors(er1,"car");
81// end.SetPosition(r2,"car");
82// end.SetPositionErrors(er2,"car");
83// trec.SetBeginPoint(begin);
84// trec.SetEndPoint(end);
85//
25eefd00 86// Note : By default all quantities are in GeV, GeV/c or GeV/c**2
87// but the user can indicate the usage of a different scale
88// for the energy-momentum units via the SetEscale() memberfunction.
89// The actual energy-momentum unit scale can be obtained via the
90// GetEscale() memberfunction.
959fbac5 91//
92//--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht
f531a546 93//- Modified: NvE $Date$ UU-SAP Utrecht
959fbac5 94///////////////////////////////////////////////////////////////////////////
95
d88f97cc 96#include "AliTrack.h"
c72198f1 97#include "Riostream.h"
d88f97cc 98
99ClassImp(AliTrack) // Class implementation to enable ROOT I/O
100
5f25234b 101AliTrack::AliTrack() : TNamed(),Ali4Vector()
d88f97cc 102{
103// Default constructor
104// All variables initialised to 0
6516b62d 105 Init();
106 Reset();
107}
108///////////////////////////////////////////////////////////////////////////
109void AliTrack::Init()
110{
111// Initialisation of pointers etc...
d88f97cc 112 fDecays=0;
959fbac5 113 fSignals=0;
5f25234b 114 fHypotheses=0;
c72198f1 115 fBegin=0;
116 fEnd=0;
c5555bc0 117 fRef=0;
c72198f1 118 fImpactXY=0;
119 fImpactXZ=0;
120 fImpactYZ=0;
121 fClosest=0;
1fbffa23 122 fParent=0;
ea0b5b7f 123 fFit=0;
a7dc0627 124 fTstamp=0;
25eefd00 125 fEscale=1;
d88f97cc 126}
127///////////////////////////////////////////////////////////////////////////
128AliTrack::~AliTrack()
129{
5f25234b 130// Destructor to delete memory allocated for decay tracks array.
d0120ca2 131// This destructor automatically cleares all references to this AliTrack
132// from all the related AliSignal objects.
5f25234b 133 Int_t nsig=GetNsignals();
134 for (Int_t i=1; i<=nsig; i++)
135 {
136 AliSignal* s=GetSignal(i);
d0120ca2 137 if (s) s->RemoveTrack(*this,0);
5f25234b 138 }
139
d88f97cc 140 if (fDecays)
141 {
d88f97cc 142 delete fDecays;
143 fDecays=0;
144 }
959fbac5 145 if (fSignals)
146 {
959fbac5 147 delete fSignals;
148 fSignals=0;
149 }
5f25234b 150 if (fHypotheses)
c72198f1 151 {
5f25234b 152 delete fHypotheses;
153 fHypotheses=0;
c72198f1 154 }
155 if (fBegin)
156 {
157 delete fBegin;
158 fBegin=0;
159 }
160 if (fEnd)
161 {
162 delete fEnd;
163 fEnd=0;
164 }
c5555bc0 165 if (fRef)
166 {
167 delete fRef;
168 fRef=0;
169 }
c72198f1 170 if (fImpactXY)
171 {
172 delete fImpactXY;
173 fImpactXY=0;
174 }
175 if (fImpactXZ)
176 {
177 delete fImpactXZ;
178 fImpactXZ=0;
179 }
180 if (fImpactYZ)
181 {
182 delete fImpactYZ;
183 fImpactYZ=0;
184 }
185 if (fClosest)
186 {
187 delete fClosest;
188 fClosest=0;
189 }
ea0b5b7f 190 if (fFit)
191 {
192 delete fFit;
193 fFit=0;
194 }
a7dc0627 195 if (fTstamp)
196 {
197 delete fTstamp;
198 fTstamp=0;
199 }
d88f97cc 200}
201///////////////////////////////////////////////////////////////////////////
261c0caf 202AliTrack::AliTrack(const AliTrack& t) : TNamed(t),Ali4Vector(t)
6516b62d 203{
204// Copy constructor
205 Init();
206
c72198f1 207 fQ=t.fQ;
5f25234b 208 fProb=t.fProb;
c72198f1 209 if (t.fBegin) fBegin=new AliPositionObj(*(t.fBegin));
210 if (t.fEnd) fEnd=new AliPositionObj(*(t.fEnd));
c5555bc0 211 if (t.fRef) fRef=new AliPositionObj(*(t.fRef));
c72198f1 212 if (t.fImpactXY) fImpactXY=new AliPositionObj(*(t.fImpactXY));
213 if (t.fImpactXZ) fImpactXZ=new AliPositionObj(*(t.fImpactXZ));
214 if (t.fImpactYZ) fImpactYZ=new AliPositionObj(*(t.fImpactYZ));
215 if (t.fClosest) fClosest=new AliPositionObj(*(t.fClosest));
ea0b5b7f 216 if (t.fFit) fFit=t.fFit->Clone();
a7dc0627 217 if (t.fTstamp) fTstamp=new AliTimestamp(*(t.fTstamp));
c72198f1 218 fUserId=t.fUserId;
25eefd00 219 fEscale=t.fEscale;
c72198f1 220 fCode=t.fCode;
1fbffa23 221 fParent=t.fParent;
c72198f1 222
5f25234b 223 Int_t ndec=t.GetNdecay();
224 if (ndec)
6516b62d 225 {
5f25234b 226 fDecays=new TObjArray(ndec);
6516b62d 227 fDecays->SetOwner();
5f25234b 228 for (Int_t it=1; it<=ndec; it++)
6516b62d 229 {
c72198f1 230 AliTrack* tx=t.GetDecayTrack(it);
6516b62d 231 fDecays->Add(new AliTrack(*tx));
232 }
233 }
234
5f25234b 235 Int_t nsig=t.GetNsignals();
236 if (nsig)
6516b62d 237 {
5f25234b 238 fSignals=new TObjArray(nsig);
239 for (Int_t is=1; is<=nsig; is++)
6516b62d 240 {
c72198f1 241 AliSignal* sx=t.GetSignal(is);
6516b62d 242 fSignals->Add(sx);
243 }
244 }
5f25234b 245
246 Int_t nhyp=t.GetNhypotheses();
247 if (nhyp)
248 {
249 fHypotheses=new TObjArray(nhyp);
250 fHypotheses->SetOwner();
251 for (Int_t ih=1; ih<=nhyp; ih++)
252 {
253 AliTrack* tx=t.GetTrackHypothesis(ih);
254 fHypotheses->Add(new AliTrack(*tx));
255 }
256 }
6516b62d 257}
258///////////////////////////////////////////////////////////////////////////
d88f97cc 259void AliTrack::Reset()
260{
35044448 261// Reset all variables to 0 and delete all auto-generated decay tracks.
25eefd00 262// Note : The scale for the energy/momentum units will not be changed.
d88f97cc 263 fQ=0;
43bfa5be 264 fUserId=0;
fdbea0ce 265 fCode=0;
5f25234b 266 fProb=0;
d88f97cc 267 Double_t a[4]={0,0,0,0};
268 SetVector(a,"sph");
1fbffa23 269 fParent=0;
d88f97cc 270 if (fDecays)
271 {
d88f97cc 272 delete fDecays;
273 fDecays=0;
274 }
959fbac5 275 if (fSignals)
276 {
959fbac5 277 delete fSignals;
278 fSignals=0;
279 }
5f25234b 280 if (fHypotheses)
f531a546 281 {
5f25234b 282 delete fHypotheses;
283 fHypotheses=0;
f531a546 284 }
c72198f1 285 if (fBegin)
286 {
287 delete fBegin;
288 fBegin=0;
289 }
290 if (fEnd)
291 {
292 delete fEnd;
293 fEnd=0;
294 }
c5555bc0 295 if (fRef)
296 {
297 delete fRef;
298 fRef=0;
299 }
c72198f1 300 if (fImpactXY)
301 {
302 delete fImpactXY;
303 fImpactXY=0;
304 }
305 if (fImpactXZ)
306 {
307 delete fImpactXZ;
308 fImpactXZ=0;
309 }
310 if (fImpactYZ)
311 {
312 delete fImpactYZ;
313 fImpactYZ=0;
314 }
315 if (fClosest)
316 {
317 delete fClosest;
318 fClosest=0;
319 }
ea0b5b7f 320 if (fFit)
321 {
322 delete fFit;
323 fFit=0;
324 }
a7dc0627 325 if (fTstamp)
326 {
327 delete fTstamp;
328 fTstamp=0;
329 }
d88f97cc 330}
331///////////////////////////////////////////////////////////////////////////
332void AliTrack::Set3Momentum(Ali3Vector& p)
333{
261c0caf 334// Set the track parameters according to the 3-momentum p.
335// In case the mass was not yet set, the energy is set to correspond to m=0.
959fbac5 336 Set3Vector(p);
261c0caf 337 Double_t inv=GetInvariant();
338 if (inv<0) SetMass(0.);
d88f97cc 339}
340///////////////////////////////////////////////////////////////////////////
341void AliTrack::Set4Momentum(Ali4Vector& p)
342{
343// Set the track parameters according to the 4-momentum p
344 Double_t E=p.GetScalar();
959fbac5 345 Double_t dE=p.GetResultError();
d88f97cc 346 Ali3Vector pv=p.Get3Vector();
347 SetVector(E,pv);
959fbac5 348 SetScalarError(dE);
d88f97cc 349}
350///////////////////////////////////////////////////////////////////////////
959fbac5 351void AliTrack::SetMass(Double_t m,Double_t dm)
d88f97cc 352{
353// Set the particle mass
959fbac5 354// The default value for the error dm is 0.
355 Double_t inv=pow(m,2);
356 Double_t dinv=fabs(2.*m*dm);
357 SetInvariant(inv,dinv);
d88f97cc 358}
359///////////////////////////////////////////////////////////////////////////
360void AliTrack::SetCharge(Float_t q)
361{
362// Set the particle charge
363 fQ=q;
364}
365///////////////////////////////////////////////////////////////////////////
1f241680 366void AliTrack::Data(TString f,TString u)
d88f97cc 367{
368// Provide track information within the coordinate frame f
1f241680 369//
370// The string argument "u" allows to choose between different angular units
371// in case e.g. a spherical frame is selected.
372// u = "rad" : angles provided in radians
373// "deg" : angles provided in degrees
374//
375// The defaults are f="car" and u="rad".
376
959fbac5 377 Double_t m=GetMass();
378 Double_t dm=GetResultError();
5f25234b 379 const char* name=GetName();
380 const char* title=GetTitle();
381
382 cout << " *" << ClassName() << "::Data*";
ea0b5b7f 383 if (strlen(name)) cout << " Name : " << name;
384 if (strlen(title)) cout << " Title : " << title;
5f25234b 385 cout << endl;
a7dc0627 386 if (fTstamp) fTstamp->Date(1);
5f25234b 387 cout << " Id : " << fUserId << " Code : " << fCode
388 << " m : " << m << " dm : " << dm << " Charge : " << fQ
389 << " p : " << GetMomentum() << endl;
390 cout << " Nhypotheses : " << GetNhypotheses() << " Ndecay-tracks : " << GetNdecay()
25eefd00 391 << " Nsignals : " << GetNsignals() << " Energy scale : " << fEscale << " GeV" << endl;
ea0b5b7f 392 if (fParent)
393 {
394 cout << " Parent track Id : " << fParent->GetId() << " Code : " << fParent->GetParticleCode()
395 << " m : " << fParent->GetMass() << " Q : " << fParent->GetCharge()
396 << " p : " << fParent->GetMomentum();
397 const char* pname=fParent->GetName();
398 const char* ptitle=fParent->GetTitle();
399 if (strlen(pname)) cout << " Name : " << pname;
400 if (strlen(ptitle)) cout << " Title : " << ptitle;
401 cout << endl;
402 }
403 if (fFit)
404 {
405 cout << " Fit details present in object of class " << fFit->ClassName() << endl;
406 if (fFit->InheritsFrom("AliSignal")) ((AliSignal*)fFit)->List(-1);
407 }
1f241680 408 Ali4Vector::Data(f,u);
d88f97cc 409}
410///////////////////////////////////////////////////////////////////////////
1f241680 411void AliTrack::List(TString f,TString u)
d88f97cc 412{
413// Provide current track and decay level 1 information within coordinate frame f
1f241680 414//
415// The string argument "u" allows to choose between different angular units
416// in case e.g. a spherical frame is selected.
417// u = "rad" : angles provided in radians
418// "deg" : angles provided in degrees
419//
420// The defaults are f="car" and u="rad".
d88f97cc 421
1f241680 422 Data(f,u); // Information of the current track
e51b7d1a 423 if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); }
424 if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); }
425 if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); }
d88f97cc 426
427 // Decay products of this track
428 AliTrack* td;
5f25234b 429 for (Int_t id=1; id<=GetNdecay(); id++)
d88f97cc 430 {
431 td=GetDecayTrack(id);
432 if (td)
433 {
434 cout << " ---Level 1 sec. track no. " << id << endl;
1f241680 435 td->Data(f,u);
d88f97cc 436 }
437 else
438 {
5f25234b 439 cout << " *AliTrack::List* Error : Empty decay track slot." << endl;
d88f97cc 440 }
441 }
442}
443///////////////////////////////////////////////////////////////////////////
1f241680 444void AliTrack::ListAll(TString f,TString u)
d88f97cc 445{
446// Provide complete track and decay information within the coordinate frame f
1f241680 447//
448// The string argument "u" allows to choose between different angular units
449// in case e.g. a spherical frame is selected.
450// u = "rad" : angles provided in radians
451// "deg" : angles provided in degrees
452//
453// The defaults are f="car" and u="rad".
d88f97cc 454
1f241680 455 Data(f,u); // Information of the current track
e51b7d1a 456 if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); }
457 if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); }
458 if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); }
5f25234b 459
460 Int_t nhyp=GetNhypotheses();
461 if (nhyp)
462 {
463 cout << " List of the " << nhyp << " track hypotheses : " << endl;
464 for (Int_t ih=1; ih<=nhyp; ih++)
465 {
466 AliTrack* tx=GetTrackHypothesis(ih);
1f241680 467 if (tx) tx->Data(f,u);
5f25234b 468 }
469 }
470
471 Int_t nsig=GetNsignals();
472 if (nsig)
959fbac5 473 {
d0a8ef71 474 cout << " List of the corresponding slots for the " << nsig
475 << " related signals : " << endl;
476 AliPosition r;
477 Int_t nrefs,jslot;
478 TArrayI slotarr;
5f25234b 479 for (Int_t is=1; is<=nsig; is++)
480 {
481 AliSignal* sx=GetSignal(is);
d0a8ef71 482 if (sx)
483 {
484 nrefs=sx->GetIndices(this,slotarr,0);
485 for (Int_t jref=0; jref<nrefs; jref++)
486 {
487 jslot=slotarr.At(jref);
488 sx->List(jslot);
489 }
490 r=sx->GetPosition();
491 cout << " Position";
1f241680 492 r.Data(f,u);
d0a8ef71 493 }
5f25234b 494 }
959fbac5 495 }
d88f97cc 496
497 AliTrack* t=this;
1f241680 498 Dumps(t,1,f,u); // Information of all decay products
d88f97cc 499}
500//////////////////////////////////////////////////////////////////////////
1f241680 501void AliTrack::Dumps(AliTrack* t,Int_t n,TString f,TString u)
d88f97cc 502{
503// Recursively provide the info of all decay levels of this track
504 AliTrack* td;
505 for (Int_t id=1; id<=t->GetNdecay(); id++)
506 {
507 td=t->GetDecayTrack(id);
508 if (td)
509 {
510 cout << " ---Level " << n << " sec. track no. " << id << endl;
1f241680 511 td->Data(f,u);
5f25234b 512
513 Int_t nhyp=td->GetNhypotheses();
514 if (nhyp)
515 {
516 cout << " List of the " << nhyp << " track hypotheses : " << endl;
517 for (Int_t ih=1; ih<=nhyp; ih++)
518 {
519 AliTrack* tx=td->GetTrackHypothesis(ih);
1f241680 520 if (tx) tx->Data(f,u);
5f25234b 521 }
522 }
523
524 Int_t nsig=td->GetNsignals();
525 if (nsig)
959fbac5 526 {
5f25234b 527 cout << " List of the " << nsig << " related signals : " << endl;
528 for (Int_t is=1; is<=nsig; is++)
529 {
530 AliSignal* sx=td->GetSignal(is);
1f241680 531 if (sx) sx->Data(f,u);
5f25234b 532 }
959fbac5 533 }
d88f97cc 534
535 // Go for next decay level of this decay track recursively
1f241680 536 Dumps(td,n+1,f,u);
d88f97cc 537 }
538 else
539 {
5f25234b 540 cout << " *AliTrack::Dumps* Error : Empty decay track slot." << endl;
d88f97cc 541 }
542 }
543}
544//////////////////////////////////////////////////////////////////////////
25eefd00 545Double_t AliTrack::GetMomentum(Float_t scale)
d88f97cc 546{
959fbac5 547// Provide the value of the track 3-momentum.
25eefd00 548// By default the momentum is returned in the units as it was stored in the track
549// structure. However, the user can select a different momentum unit scale by
550// specification of the scale parameter.
551// The convention is that scale=1 corresponds to GeV/c, so specification
552// of scale=0.001 will provide the momentum in MeV/c.
959fbac5 553// The error can be obtained by invoking GetResultError() after
554// invokation of GetMomentum().
25eefd00 555
959fbac5 556 Double_t norm=fV.GetNorm();
d071d629 557 fDresult=fV.GetResultError();
25eefd00 558 if (scale>0)
559 {
560 norm*=fEscale/scale;
561 fDresult*=fEscale/scale;
562 }
959fbac5 563 return norm;
d88f97cc 564}
565///////////////////////////////////////////////////////////////////////////
25eefd00 566Ali3Vector AliTrack::Get3Momentum(Float_t scale) const
d88f97cc 567{
25eefd00 568// Provide the track 3-momentum.
569// By default the components of the 3-momentum are returned in the units
570// as they were stored in the track structure.
571// However, the user can select a different momentum unit scale for the
572// components by specification of the scale parameter.
573// The convention is that scale=1 corresponds to GeV/c, so specification
574// of scale=0.001 will provide the 3-momentum in MeV/c.
575
576 Ali3Vector p=Get3Vector();
577 if (scale>0) p*=fEscale/scale;
578 return p;
d88f97cc 579}
580///////////////////////////////////////////////////////////////////////////
25eefd00 581Double_t AliTrack::GetMass(Float_t scale)
d88f97cc 582{
959fbac5 583// Provide the particle mass.
25eefd00 584// By default the mass is returned in the units as it was stored in the track
585// structure. However, the user can select a different mass unit scale by
586// specification of the scale parameter.
587// The convention is that scale=1 corresponds to GeV/c**2, so specification
588// of scale=0.001 will provide the mass in MeV/c**2.
959fbac5 589// The error can be obtained by invoking GetResultError() after
590// invokation of GetMass().
25eefd00 591
959fbac5 592 Double_t inv=GetInvariant();
593 Double_t dinv=GetResultError();
594 Double_t dm=0;
595 if (inv >= 0)
596 {
597 Double_t m=sqrt(inv);
598 if (m) dm=dinv/(2.*m);
25eefd00 599 if (scale>0)
600 {
601 m*=fEscale/scale;
602 dm*=fEscale/scale;
603 }
959fbac5 604 fDresult=dm;
605 return m;
606 }
607 else
608 {
609 cout << "*AliTrack::GetMass* Unphysical situation m**2 = " << inv << endl;
610 cout << " Value 0 will be returned." << endl;
611 fDresult=dm;
612 return 0;
613 }
d88f97cc 614}
615///////////////////////////////////////////////////////////////////////////
261c0caf 616Float_t AliTrack::GetCharge() const
d88f97cc 617{
618// Provide the particle charge
619 return fQ;
620}
621///////////////////////////////////////////////////////////////////////////
25eefd00 622Double_t AliTrack::GetEnergy(Float_t scale)
d88f97cc 623{
959fbac5 624// Provide the particle's energy.
25eefd00 625// By default the energy is returned in the units as it was stored in the track
626// structure. However, the user can select a different energy unit scale by
627// specification of the scale parameter.
628// The convention is that scale=1 corresponds to GeV, so specification
629// of scale=0.001 will provide the energy in MeV.
959fbac5 630// The error can be obtained by invoking GetResultError() after
631// invokation of GetEnergy().
632 Double_t E=GetScalar();
633 if (E>0)
634 {
25eefd00 635 if (scale>0)
636 {
637 E*=fEscale/scale;
638 fDresult*=fEscale/scale;
639 }
959fbac5 640 return E;
641 }
642 else
643 {
644 cout << "*AliTrack::GetEnergy* Unphysical situation E = " << E << endl;
645 cout << " Value 0 will be returned." << endl;
646 return 0;
647 }
d88f97cc 648}
649///////////////////////////////////////////////////////////////////////////
650void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
651{
652// Perform 2-body decay of current track
653// m1 : mass of decay product 1
654// m2 : mass of decay product 2
655// thcms : cms theta decay angle (in rad.) of m1
656// phicms : cms phi decay angle (in rad.) of m1
657
959fbac5 658 Double_t M=GetMass();
d88f97cc 659
660// Compute the 4-momenta of the decay products in the cms
661// Note : p2=p1=pnorm for a 2-body decay
959fbac5 662 Double_t e1=0;
663 if (M) e1=((M*M)+(m1*m1)-(m2*m2))/(2.*M);
664 Double_t e2=0;
665 if (M) e2=((M*M)+(m2*m2)-(m1*m1))/(2.*M);
d88f97cc 666 Double_t pnorm=(e1*e1)-(m1*m1);
667 if (pnorm>0.)
668 {
669 pnorm=sqrt(pnorm);
670 }
671 else
672 {
673 pnorm=0;
674 }
675
676 Double_t a[3];
677 a[0]=pnorm;
678 a[1]=thcms;
679 a[2]=phicms;
680 Ali3Vector p;
681 p.SetVector(a,"sph");
682
683 Ali4Vector pprim1;
684 pprim1.SetVector(e1,p);
959fbac5 685 pprim1.SetInvariant(m1*m1);
d88f97cc 686
687 Ali4Vector pprim2;
688 p*=-1;
689 pprim2.SetVector(e2,p);
959fbac5 690 pprim2.SetInvariant(m2*m2);
d88f97cc 691
692 // Determine boost parameters from the parent particle
959fbac5 693 Double_t E=GetEnergy();
d88f97cc 694 p=Get3Vector();
695 Ali4Vector pmu;
696 pmu.SetVector(E,p);
697
698 AliBoost q;
699 q.Set4Momentum(pmu);
700
701 Ali4Vector p1=q.Inverse(pprim1); // Boost decay product 1
702 Ali4Vector p2=q.Inverse(pprim2); // Boost decay product 2
703
704 // Enter the boosted data into the decay tracks array
705 if (fDecays)
706 {
d88f97cc 707 delete fDecays;
6516b62d 708 fDecays=0;
d88f97cc 709 }
5f25234b 710 fDecays=new TObjArray(2);
6516b62d 711 fDecays->SetOwner();
d88f97cc 712
713 fDecays->Add(new AliTrack);
714 ((AliTrack*)fDecays->At(0))->Set4Momentum(p1);
959fbac5 715 ((AliTrack*)fDecays->At(0))->SetMass(m1);
d88f97cc 716 fDecays->Add(new AliTrack);
717 ((AliTrack*)fDecays->At(1))->Set4Momentum(p2);
d88f97cc 718 ((AliTrack*)fDecays->At(1))->SetMass(m2);
719}
720///////////////////////////////////////////////////////////////////////////
261c0caf 721Int_t AliTrack::GetNdecay() const
d88f97cc 722{
723// Provide the number of decay produced tracks
5f25234b 724 Int_t ndec=0;
725 if (fDecays) ndec=fDecays->GetEntries();
726 return ndec;
d88f97cc 727}
728///////////////////////////////////////////////////////////////////////////
261c0caf 729AliTrack* AliTrack::GetDecayTrack(Int_t j) const
d88f97cc 730{
731// Provide decay produced track number j
732// Note : j=1 denotes the first decay track
6516b62d 733 if (!fDecays)
d88f97cc 734 {
6516b62d 735 cout << " *AliTrack::GetDecayTrack* No tracks present." << endl;
736 return 0;
d88f97cc 737 }
738 else
739 {
5f25234b 740 if ((j >= 1) && (j <= GetNdecay()))
6516b62d 741 {
742 return (AliTrack*)fDecays->At(j-1);
743 }
744 else
745 {
746 cout << " *AliTrack* decay track number : " << j << " out of range."
5f25234b 747 << " Ndec = " << GetNdecay() << endl;
6516b62d 748 return 0;
749 }
d88f97cc 750 }
751}
752///////////////////////////////////////////////////////////////////////////
5f25234b 753void AliTrack::RemoveDecays()
754{
755// Remove all decay tracks from this track.
756 if (fDecays)
757 {
758 delete fDecays;
759 fDecays=0;
760 }
761}
762///////////////////////////////////////////////////////////////////////////
d0120ca2 763void AliTrack::AddSignal(AliSignal& s,Int_t mode)
959fbac5 764{
765// Relate an AliSignal object to this track.
d0120ca2 766//
767// mode = 0 : Only the reference to the specified signal is stored in
768// the current track, without storing the (backward) reference
769// to this track into the AliSignal structure.
770// 1 : The (backward) reference to the current track is also automatically
771// stored into the AliSignal (or derived) object specified in the
772// input argument.
773//
774// The default is mode=0.
775
5f25234b 776 if (!fSignals) fSignals=new TObjArray(1);
777
778 // Check if this signal is already stored for this track
779 Int_t nsig=GetNsignals();
780 for (Int_t i=0; i<nsig; i++)
781 {
782 if (&s==fSignals->At(i)) return;
783 }
784
959fbac5 785 fSignals->Add(&s);
d0120ca2 786 if (mode==1) s.AddTrack(*this,0);
959fbac5 787}
788///////////////////////////////////////////////////////////////////////////
d0120ca2 789void AliTrack::RemoveSignal(AliSignal& s,Int_t mode)
959fbac5 790{
5f25234b 791// Remove related AliSignal object from this track.
d0120ca2 792//
793// mode = 0 : Only the reference to the specified signal is removed from
794// the current track, without removing the (backward) reference(s)
795// to this track from the AliSignal structure.
796// 1 : The (backward) reference(s) to the current track are also automatically
797// removed from the AliSignal (or derived) object specified in the
798// input argument.
799//
800// The default is mode=1.
801
959fbac5 802 if (fSignals)
803 {
804 AliSignal* test=(AliSignal*)fSignals->Remove(&s);
5f25234b 805 if (test) fSignals->Compress();
806 }
d0120ca2 807 if (mode==1) s.RemoveTrack(*this,0);
5f25234b 808}
809///////////////////////////////////////////////////////////////////////////
d0120ca2 810void AliTrack::RemoveSignals(Int_t mode)
5f25234b 811{
812// Remove all related AliSignal objects from this track.
d0120ca2 813//
814// mode = 0 : All signal references are removed from the current track,
815// without removing the (backward) references to this track from
816// the corresponding AliSignal objects.
817// 1 : The (backward) references to the current track are also automatically
818// removed from the corresponding AliSignal (or derived) objects.
819//
820// The default is mode=1.
821
822 if (!fSignals) return;
823
824 Int_t ns=GetNsignals();
825 for (Int_t i=0; i<ns; i++)
5f25234b 826 {
d0120ca2 827 AliSignal* sx=(AliSignal*)fSignals->At(i);
828 if (sx && mode==1) sx->RemoveTrack(*this,0);
959fbac5 829 }
d0120ca2 830
831 delete fSignals;
832 fSignals=0;
959fbac5 833}
834///////////////////////////////////////////////////////////////////////////
261c0caf 835Int_t AliTrack::GetNsignals() const
959fbac5 836{
837// Provide the number of related AliSignals.
5f25234b 838 Int_t nsig=0;
839 if (fSignals) nsig=fSignals->GetEntries();
840 return nsig;
959fbac5 841}
842///////////////////////////////////////////////////////////////////////////
caa58e1a 843Int_t AliTrack::GetNsignals(const char* classname) const
844{
845// Provide the number of stored signals of the specified class.
846
847 Int_t nsigs=0;
848 for (Int_t isig=1; isig<=GetNsignals(); isig++)
849 {
850 TObject* obj=GetSignal(isig);
851 if (!obj) continue;
852
853 if (obj->InheritsFrom(classname)) nsigs++;
854 }
855 return nsigs;
856}
857///////////////////////////////////////////////////////////////////////////
261c0caf 858AliSignal* AliTrack::GetSignal(Int_t j) const
959fbac5 859{
860// Provide the related AliSignal number j.
861// Note : j=1 denotes the first signal.
6516b62d 862 if (!fSignals)
959fbac5 863 {
6516b62d 864 cout << " *AliTrack::GetSignal* No signals present." << endl;
865 return 0;
959fbac5 866 }
867 else
868 {
5f25234b 869 if ((j >= 1) && (j <= GetNsignals()))
6516b62d 870 {
871 return (AliSignal*)fSignals->At(j-1);
872 }
873 else
874 {
875 cout << " *AliTrack* signal number : " << j << " out of range."
5f25234b 876 << " Nsig = " << GetNsignals() << endl;
6516b62d 877 return 0;
878 }
959fbac5 879 }
880}
881///////////////////////////////////////////////////////////////////////////
5f25234b 882void AliTrack::AddTrackHypothesis(AliTrack& t)
959fbac5 883{
5f25234b 884// Relate a track hypothesis to this track.
885// Note : a private copy of the input track will be made via the Clone()
886// facility.
887 if (!fHypotheses)
c72198f1 888 {
5f25234b 889 fHypotheses=new TObjArray(1);
890 fHypotheses->SetOwner();
c72198f1 891 }
5f25234b 892 fHypotheses->Add(t.Clone());
959fbac5 893}
894///////////////////////////////////////////////////////////////////////////
5f25234b 895void AliTrack::AddTrackHypothesis(Double_t prob,Double_t m,Double_t dm)
959fbac5 896{
5f25234b 897// Add a track hypothesis by explicitly setting the mass and probability.
898// This will affect e.g. the hypothesis track's energy, since the momentum
899// and all other attributes will be copied from the current track.
900//
901// Input arguments :
902// -----------------
903// prob=probalility m=mass value dm=error on the mass value.
904// The default value for the mass error dm is 0.
905
906 AliTrack t(*this);
907 t.RemoveDecays();
908 t.RemoveTrackHypotheses();
909 t.RemoveSignals();
910 t.SetTitle("Mass hypothesis");
911 t.SetMass(m,dm);
912 t.SetProb(prob);
913 AddTrackHypothesis(t);
959fbac5 914}
915///////////////////////////////////////////////////////////////////////////
5f25234b 916void AliTrack::RemoveTrackHypothesis(AliTrack& t)
959fbac5 917{
5f25234b 918// Remove the specified track hypothesis from this track.
919 if (fHypotheses)
c72198f1 920 {
5f25234b 921 AliTrack* test=(AliTrack*)fHypotheses->Remove(&t);
922 if (test) fHypotheses->Compress();
c72198f1 923 }
959fbac5 924}
925///////////////////////////////////////////////////////////////////////////
5f25234b 926void AliTrack::RemoveTrackHypotheses()
959fbac5 927{
5f25234b 928// Remove all track hypotheses from this track.
929 if (fHypotheses)
930 {
931 delete fHypotheses;
932 fHypotheses=0;
933 }
f531a546 934}
935///////////////////////////////////////////////////////////////////////////
261c0caf 936Int_t AliTrack::GetNhypotheses() const
f531a546 937{
5f25234b 938// Provide the number of track hypotheses.
939 Int_t nhyp=0;
940 if (fHypotheses) nhyp=fHypotheses->GetEntries();
941 return nhyp;
f531a546 942}
943///////////////////////////////////////////////////////////////////////////
261c0caf 944AliTrack* AliTrack::GetTrackHypothesis(Int_t j) const
f531a546 945{
5f25234b 946// Provide the j-th track hypothesis.
947// Note : j=1 denotes the first hypothesis.
f531a546 948// Default : j=0 ==> Hypothesis with highest probability.
f531a546 949
5f25234b 950 if (!fHypotheses) return 0;
951
952 Int_t nhyp=GetNhypotheses();
f531a546 953
954 // Check validity of index j
5f25234b 955 if (j<0 || j>nhyp)
f531a546 956 {
5f25234b 957 cout << " *AliTrack* hypothesis number : " << j << " out of range."
958 << " Nhyp = " << nhyp << endl;
959 return 0;
960 }
f531a546 961
5f25234b 962 AliTrack* t=0;
963
964 if (j==0) // Provide track hypothesis with highest probability
f531a546 965 {
5f25234b 966 Float_t prob=0;
967 t=(AliTrack*)fHypotheses->At(0);
968 if (t) prob=t->GetProb();
969 Float_t probx=0;
970 for (Int_t ih=1; ih<nhyp; ih++)
f531a546 971 {
5f25234b 972 AliTrack* tx=(AliTrack*)fHypotheses->At(ih);
973 if (tx)
f531a546 974 {
5f25234b 975 probx=tx->GetProb();
976 if (probx > prob) t=tx;
f531a546 977 }
978 }
5f25234b 979 return t;
980 }
981 else // Provide requested j-th track hypothesis
982 {
983 return (AliTrack*)fHypotheses->At(j-1);
f531a546 984 }
f531a546 985}
986///////////////////////////////////////////////////////////////////////////
5f25234b 987void AliTrack::SetBeginPoint(AliPosition& p)
f531a546 988{
5f25234b 989// Store the position of the track begin-point.
f4d1f676 990 if (fBegin) delete fBegin;
991 fBegin=new AliPositionObj(p);
f531a546 992}
993///////////////////////////////////////////////////////////////////////////
5f25234b 994AliPosition* AliTrack::GetBeginPoint()
f531a546 995{
5f25234b 996// Provide the position of the track begin-point.
997 return fBegin;
998}
999///////////////////////////////////////////////////////////////////////////
1000void AliTrack::SetEndPoint(AliPosition& p)
1001{
1002// Store the position of the track end-point.
f4d1f676 1003 if (fEnd) delete fEnd;
1004 fEnd=new AliPositionObj(p);
f531a546 1005}
1006///////////////////////////////////////////////////////////////////////////
5f25234b 1007AliPosition* AliTrack::GetEndPoint()
1008{
1009// Provide the position of the track end-point.
1010 return fEnd;
1011}
1012///////////////////////////////////////////////////////////////////////////
c5555bc0 1013void AliTrack::SetReferencePoint(AliPosition& p)
1014{
1015// Store the position of the track reference-point.
1016// The reference-point is the point on the track in which the
1017// 3-momentum vector components have been defined.
1018// This reference point is the preferable point to start track extrapolations
1019// etc... which are sensitive to the components of the 3-momentum vector.
f4d1f676 1020 if (fRef) delete fRef;
1021 fRef=new AliPositionObj(p);
c5555bc0 1022}
1023///////////////////////////////////////////////////////////////////////////
1024AliPosition* AliTrack::GetReferencePoint()
1025{
1026// Provide the position of the track reference-point.
1027// The reference-point is the point on the track in which the
1028// 3-momentum vector components have been defined.
1029// This reference point is the preferable point to start track extrapolations
1030// etc... which are sensitive to the components of the 3-momentum vector.
1031 return fRef;
1032}
1033///////////////////////////////////////////////////////////////////////////
5f25234b 1034void AliTrack::SetMass()
f531a546 1035{
5f25234b 1036// Set the mass and error to the value of the hypothesis with highest prob.
f531a546 1037
5f25234b 1038 Double_t m=0,dm=0;
1039
1040 // Select mass hypothesis with highest probability
1041 AliTrack* t=GetTrackHypothesis(0);
1042 if (t)
f531a546 1043 {
5f25234b 1044 m=t->GetMass();
1045 dm=t->GetResultError();
1046 SetMass(m,dm);
f531a546 1047 }
1048 else
1049 {
5f25234b 1050 cout << " *AliTrack::SetMass()* No hypothesis present => No action." << endl;
f531a546 1051 }
1052}
1053///////////////////////////////////////////////////////////////////////////
25eefd00 1054Double_t AliTrack::GetPt(Float_t scale)
d071d629 1055{
25eefd00 1056// Provide the transverse momentum value w.r.t. z-axis.
1057// By default the value is returned in the units as it was stored in the track
1058// structure. However, the user can select a different momentum unit scale by
1059// specification of the scale parameter.
1060// The convention is that scale=1 corresponds to GeV/c, so specification
1061// of scale=0.001 will provide the transverse momentum in MeV/c.
d071d629 1062// The error on the value can be obtained by GetResultError()
1063// after invokation of GetPt().
1064 Ali3Vector v;
1065 v=GetVecTrans();
1066 Double_t norm=v.GetNorm();
1067 fDresult=v.GetResultError();
25eefd00 1068 if (scale>0)
1069 {
1070 norm*=fEscale/scale;
1071 fDresult*=fEscale/scale;
1072 }
d071d629 1073
1074 return norm;
1075}
1076///////////////////////////////////////////////////////////////////////////
25eefd00 1077Double_t AliTrack::GetPl(Float_t scale)
d071d629 1078{
25eefd00 1079// Provide the longitudinal momentum value w.r.t. z-axis.
1080// By default the value is returned in the units as it was stored in the track
1081// structure. However, the user can select a different momentum unit scale by
1082// specification of the scale parameter.
1083// The convention is that scale=1 corresponds to GeV/c, so specification
1084// of scale=0.001 will provide the longitudinal momentum in MeV/c.
8adaf597 1085// Note : the returned value can also be negative.
d071d629 1086// The error on the value can be obtained by GetResultError()
1087// after invokation of GetPl().
25eefd00 1088
d071d629 1089 Ali3Vector v;
1090 v=GetVecLong();
8adaf597 1091
1092 Double_t pl=v.GetNorm();
d071d629 1093 fDresult=v.GetResultError();
1094
8adaf597 1095 Double_t a[3];
1096 v.GetVector(a,"sph");
1097 if (cos(a[1])<0) pl=-pl;
25eefd00 1098 if (scale>0)
1099 {
1100 pl*=fEscale/scale;
1101 fDresult*=fEscale/scale;
1102 }
8adaf597 1103
1104 return pl;
d071d629 1105}
1106///////////////////////////////////////////////////////////////////////////
25eefd00 1107Double_t AliTrack::GetEt(Float_t scale)
d071d629 1108{
25eefd00 1109// Provide transverse energy value w.r.t. z-axis.
1110// By default the value is returned in the units as it was stored in the track
1111// structure. However, the user can select a different energy unit scale by
1112// specification of the scale parameter.
1113// The convention is that scale=1 corresponds to GeV, so specification
1114// of scale=0.001 will provide the transverse energy in MeV.
d071d629 1115// The error on the value can be obtained by GetResultError()
1116// after invokation of GetEt().
25eefd00 1117
d071d629 1118 Double_t et=GetScaTrans();
25eefd00 1119 if (scale>0)
1120 {
1121 et*=fEscale/scale;
1122 fDresult*=fEscale/scale;
1123 }
d071d629 1124
1125 return et;
1126}
1127///////////////////////////////////////////////////////////////////////////
25eefd00 1128Double_t AliTrack::GetEl(Float_t scale)
d071d629 1129{
25eefd00 1130// Provide longitudinal energy value w.r.t. z-axis.
1131// By default the value is returned in the units as it was stored in the track
1132// structure. However, the user can select a different energy unit scale by
1133// specification of the scale parameter.
1134// The convention is that scale=1 corresponds to GeV, so specification
1135// of scale=0.001 will provide the longitudinal energy in MeV.
8adaf597 1136// Note : the returned value can also be negative.
d071d629 1137// The error on the value can be obtained by GetResultError()
1138// after invokation of GetEl().
25eefd00 1139
d071d629 1140 Double_t el=GetScaLong();
25eefd00 1141 if (scale>0)
1142 {
1143 el*=fEscale/scale;
1144 fDresult*=fEscale/scale;
1145 }
d071d629 1146
1147 return el;
1148}
1149///////////////////////////////////////////////////////////////////////////
25eefd00 1150Double_t AliTrack::GetMt(Float_t scale)
d071d629 1151{
1152// Provide transverse mass value w.r.t. z-axis.
25eefd00 1153// By default the value is returned in the units as it was stored in the track
1154// structure. However, the user can select a different energy unit scale by
1155// specification of the scale parameter.
1156// The convention is that scale=1 corresponds to GeV, so specification
1157// of scale=0.001 will provide the transverse mass in MeV.
d071d629 1158// The error on the value can be obtained by GetResultError()
1159// after invokation of GetMt().
1160 Double_t pt=GetPt();
1161 Double_t dpt=GetResultError();
1162 Double_t m=GetMass();
1163 Double_t dm=GetResultError();
1164
1165 Double_t mt=sqrt(pt*pt+m*m);
1166 Double_t dmt2=0;
1167 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
1168
1169 fDresult=sqrt(dmt2);
25eefd00 1170 if (scale>0)
1171 {
1172 mt*=fEscale/scale;
1173 fDresult*=fEscale/scale;
1174 }
d071d629 1175 return mt;
1176}
1177///////////////////////////////////////////////////////////////////////////
8adaf597 1178Double_t AliTrack::GetRapidity()
1179{
1180// Provide rapidity value w.r.t. z-axis.
1181// The error on the value can be obtained by GetResultError()
1182// after invokation of GetRapidity().
1183// Note : Also GetPseudoRapidity() is available since this class is
1184// derived from Ali4Vector.
1185 Double_t e=GetEnergy();
1186 Double_t de=GetResultError();
1187 Double_t pl=GetPl();
1188 Double_t dpl=GetResultError();
1189 Double_t sum=e+pl;
1190 Double_t dif=e-pl;
1191
1192 Double_t y=9999,dy2=0;
1193 if (sum && dif) y=0.5*log(sum/dif);
1194
1195 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
1196
1197 fDresult=sqrt(dy2);
1198 return y;
1199}
1200///////////////////////////////////////////////////////////////////////////
c72198f1 1201void AliTrack::SetImpactPoint(AliPosition& p,TString q)
43bfa5be 1202{
1203// Store the position of the impact-point in the plane "q=0".
1204// Here q denotes one of the axes X, Y or Z.
1205// Note : The character to denote the axis may be entered in lower or
1206// in uppercase.
1207 Int_t axis=0;
1208 if (q=="x" || q=="X") axis=1;
1209 if (q=="y" || q=="Y") axis=2;
1210 if (q=="z" || q=="Z") axis=3;
1211
1212 switch (axis)
1213 {
1214 case 1: // Impact-point in the plane X=0
f4d1f676 1215 if (fImpactYZ) delete fImpactYZ;
1216 fImpactYZ=new AliPositionObj(p);
43bfa5be 1217 break;
1218
1219 case 2: // Impact-point in the plane Y=0
f4d1f676 1220 if (fImpactXZ) delete fImpactXZ;
1221 fImpactXZ=new AliPositionObj(p);
43bfa5be 1222 break;
1223
1224 case 3: // Impact-point in the plane Z=0
f4d1f676 1225 if (fImpactXY) delete fImpactXY;
1226 fImpactXY=new AliPositionObj(p);
43bfa5be 1227 break;
1228
1229 default: // Unsupported axis
1230 cout << "*AliTrack::SetImpactPoint* Unsupported axis : " << q << endl
1231 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
1232 break;
1233 }
1234}
1235///////////////////////////////////////////////////////////////////////////
c72198f1 1236AliPosition* AliTrack::GetImpactPoint(TString q)
43bfa5be 1237{
1238// Provide the position of the impact-point in the plane "q=0".
1239// Here q denotes one of the axes X, Y or Z.
1240// Note : The character to denote the axis may be entered in lower or
1241// in uppercase.
43bfa5be 1242 Int_t axis=0;
1243 if (q=="x" || q=="X") axis=1;
1244 if (q=="y" || q=="Y") axis=2;
1245 if (q=="z" || q=="Z") axis=3;
1246
1247 switch (axis)
1248 {
1249 case 1: // Impact-point in the plane X=0
1250 return fImpactYZ;
1251
1252 case 2: // Impact-point in the plane Y=0
1253 return fImpactXZ;
1254
1255 case 3: // Impact-point in the plane Z=0
1256 return fImpactXY;
1257
1258 default: // Unsupported axis
1259 cout << "*AliTrack::GetImpactPoint* Unsupported axis : " << q << endl
1260 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
c72198f1 1261 return 0;
43bfa5be 1262 }
1263}
1264///////////////////////////////////////////////////////////////////////////
1265void AliTrack::SetId(Int_t id)
1266{
fdbea0ce 1267// Set a user defined unique identifier for this track.
43bfa5be 1268 fUserId=id;
1269}
1270///////////////////////////////////////////////////////////////////////////
261c0caf 1271Int_t AliTrack::GetId() const
43bfa5be 1272{
fdbea0ce 1273// Provide the user defined unique identifier of this track.
43bfa5be 1274 return fUserId;
1275}
1276///////////////////////////////////////////////////////////////////////////
c72198f1 1277void AliTrack::SetClosestPoint(AliPosition& p)
43bfa5be 1278{
1279// Set position p as the point of closest approach w.r.t. some reference
f4d1f676 1280 if (fClosest) delete fClosest;
1281 fClosest=new AliPositionObj(p);
43bfa5be 1282}
1283///////////////////////////////////////////////////////////////////////////
c72198f1 1284AliPosition* AliTrack::GetClosestPoint()
43bfa5be 1285{
1286// Provide the point of closest approach w.r.t. some reference
1287 return fClosest;
1288}
1289///////////////////////////////////////////////////////////////////////////
25eefd00 1290void AliTrack::SetEscale(Float_t scale)
2693cb4e 1291{
25eefd00 1292// Indicate the energy/momentum scale as used by the user.
1293// The convention is that scale=1 indicates values in units
1294// of GeV, GeV/c or GeV/c**2.
1295// So, in case one decides to store values in units of MeV, MeV/c or MeV/c**2
1296// the scale indicator should be set to scale=0.001.
1297//
1298// By default scale=1 is set in the constructor.
1299
1300 if (scale>0)
2693cb4e 1301 {
25eefd00 1302 fEscale=scale;
2693cb4e 1303 }
1304 else
1305 {
25eefd00 1306 cout << " *AliTrack::SetEscale* Invalid scale value : " << scale << endl;
2693cb4e 1307 }
1308}
1309///////////////////////////////////////////////////////////////////////////
25eefd00 1310Float_t AliTrack::GetEscale() const
2693cb4e 1311{
25eefd00 1312// Provide the energy/momentum scale as used by the user.
1313// The convention is that scale=1 indicates values in units
1314// of GeV, GeV/c or GeV/c**2.
1315// So, a value of scale=0.001 indicates that energy/momentum values are
1316// stored in units of MeV, MeV/c or MeV/c**2.
1317 return fEscale;
2693cb4e 1318}
1319///////////////////////////////////////////////////////////////////////////
fdbea0ce 1320void AliTrack::SetParticleCode(Int_t code)
1321{
1322// Set the user defined particle id code (e.g. the PDF convention).
1323 fCode=code;
1324}
1325///////////////////////////////////////////////////////////////////////////
261c0caf 1326Int_t AliTrack::GetParticleCode() const
fdbea0ce 1327{
1328// Provide the user defined particle id code.
1329 return fCode;
1330}
1331///////////////////////////////////////////////////////////////////////////
1fbffa23 1332void AliTrack::SetParentTrack(AliTrack* t)
1333{
1334// Set pointer to the parent track.
1335 fParent=t;
1336}
1337///////////////////////////////////////////////////////////////////////////
1338AliTrack* AliTrack::GetParentTrack()
1339{
1340// Provide pointer to the parent track.
1341 return fParent;
1342}
1343///////////////////////////////////////////////////////////////////////////
5f25234b 1344void AliTrack::SetProb(Double_t prob)
1345{
1346// Set hypothesis probability for this track.
1347 fProb=prob;
1348}
1349///////////////////////////////////////////////////////////////////////////
261c0caf 1350Float_t AliTrack::GetProb() const
5f25234b 1351{
1352// Provide the hypothesis probability for this track.
1353 return fProb;
1354}
1355///////////////////////////////////////////////////////////////////////////
ea0b5b7f 1356void AliTrack::SetFitDetails(TObject* obj)
1357{
1358// Enter the object containing the fit details.
1359// In case an object to hold fit details was already present, this
1360// will be deleted first before the new one is stored.
1361// This means that SetFitDetails(0) can be used to just remove the
1362// existing object with the fit details.
1363// All objects derived from TObject can be entered in this way.
1364// Obvious candidates for objects containing detailed fit information
1365// are functions (e.g. TF1) and histograms (e.g. TH1F).
1366// However, using an AliDevice object provides a very versatile facility
1367// to store the parameters of various fit procedures.
1368// In such a case the AliDevice can be used to provide the various fit
1369// definitions and the corresponding fit parameters can be entered as
1370// separate AliSignal objects which are stored as hits to the AliDevice.
1371// In addition various functions and histograms can be linked to the
1372// various AliSignal instances
1373// The latter procedure is based on the original idea of Adam Bouchta.
1374//
1375// Note : The entered object is owned by this AliTrack instance.
1376// As such, a private copy of obj will be stored using the Clone()
1377// memberfunction.
1378// In case the entered object contains pointers to other objects,
1379// the user has to provide the appropriate Clone() memberfunction
1380// for the class to which the entered object belongs.
1381// An example can be seen from AliTrack::Clone().
1382//
1383 if (fFit)
1384 {
1385 delete fFit;
1386 fFit=0;
1387 }
1388
1389 if (obj) fFit=obj->Clone();
1390}
1391///////////////////////////////////////////////////////////////////////////
1392TObject* AliTrack::GetFitDetails()
1393{
1394// Provide the pointer to the object containing the fit details.
1395 return fFit;
1396}
1397///////////////////////////////////////////////////////////////////////////
a7dc0627 1398void AliTrack::SetTimestamp(AliTimestamp& t)
1399{
1400// Store the timestamp for this track.
1401 if (fTstamp) delete fTstamp;
1402 fTstamp=new AliTimestamp(t);
1403}
1404///////////////////////////////////////////////////////////////////////////
1405AliTimestamp* AliTrack::GetTimestamp()
1406{
1407// Provide the timestamp of this track.
1408 return fTstamp;
1409}
1410///////////////////////////////////////////////////////////////////////////
1411void AliTrack::RemoveTimestamp()
1412{
1413// Remove the timestamp from this track.
1414 if (fTstamp)
1415 {
1416 delete fTstamp;
1417 fTstamp=0;
1418 }
1419}
1420///////////////////////////////////////////////////////////////////////////
25eefd00 1421Double_t AliTrack::GetDistance(AliPosition* p,Float_t scale)
1c96d8dc 1422{
1423// Provide distance of the current track to the position p.
1424// The error on the result can be obtained as usual by invoking
1425// GetResultError() afterwards.
1426//
25eefd00 1427// By default the distance will be provided in the metric unit scale of
1428// the AliPosition p.
1429// However, the user can select a different metric unit scale by
1430// specification of the scale parameter.
1431// The convention is that scale=1 corresponds to meter, so specification
1432// of scale=0.01 will provide the distance in cm.
1c96d8dc 1433// As such it is possible to obtain a correctly computed distance even in case
1434// the track parameters have a different unit scale.
1435// However, it is recommended to work always with one single unit scale.
1436//
1437// Note : In case of incomplete information, a distance value of -1 is
1438// returned.
1439
1440 Double_t dist=-1.;
1441 fDresult=0.;
1442
1443 if (!p) return dist;
1444
1445 // Obtain a defined position on this track
1446 AliPosition* rx=fRef;
1447 if (!rx) rx=fBegin;
1448 if (!rx) rx=fEnd;
1449
1450 if (!rx) return dist;
1451
9427ac75 1452 Ali3Vector p1=Get3Momentum();
1453
1454 if (p1.GetNorm() <= 0.) return dist;
1455
1c96d8dc 1456 Ali3Vector r0=(Ali3Vector)(*rx);
1457
1458 Float_t tscale=rx->GetUnitScale();
1459 Float_t pscale=p->GetUnitScale();
1460 if ((tscale/pscale > 1.1) || (pscale/tscale > 1.1)) r0=r0*(tscale/pscale);
1461
1462 // Obtain the direction unit vector of this track
1463 Double_t vec[3];
1464 Double_t err[3];
1c96d8dc 1465 p1.GetVector(vec,"sph");
1466 p1.GetErrors(err,"sph");
1467 vec[0]=1.;
1468 err[0]=0.;
1469 p1.SetVector(vec,"sph");
1470 p1.SetErrors(err,"sph");
1471
1472 Ali3Vector q=(Ali3Vector)(*p);
1473 Ali3Vector r=q-r0;
1474 Ali3Vector d=r.Cross(p1);
1475 dist=d.GetNorm();
1476 fDresult=d.GetResultError();
25eefd00 1477 if (scale>0)
1478 {
1479 dist*=pscale/scale;
1480 fDresult*=pscale/scale;
1481 }
1c96d8dc 1482 return dist;
1483}
1484///////////////////////////////////////////////////////////////////////////
25eefd00 1485Double_t AliTrack::GetDistance(AliTrack* t,Float_t scale)
9427ac75 1486{
1487// Provide distance of the current track to the track t.
1488// The error on the result can be obtained as usual by invoking
1489// GetResultError() afterwards.
1490//
25eefd00 1491// By default the distance will be provided in the metric unit scale of
1492// the current track.
1493// This implies that the results of t1.GetDistance(t2) and t2.GetDistance(t1)
1494// may be numerically different in case t1 and t2 have different metric units.
1495// However, the user can specify a required metric unit scale by specification
1496// of the scale parameter.
1497// The convention is that scale=1 corresponds to meter, so specification
1498// of scale=0.01 will provide the distance in cm.
9427ac75 1499// As such it is possible to obtain a correctly computed distance even in case
1500// the track parameters have a different unit scale.
9427ac75 1501// However, it is recommended to work always with one single unit scale.
1502//
1503// Note : In case of incomplete information, a distance value of -1 is
1504// returned.
1505
1506 Double_t dist=-1.;
1507 fDresult=0.;
1508
1509 if (!t) return dist;
1510
1511 // Obtain a defined position on this track
1512 AliPosition* rx=fRef;
1513 if (!rx) rx=fBegin;
1514 if (!rx) rx=fEnd;
1515
1516 if (!rx) return dist;
1517
1518 // Obtain a defined position on track t
1519 AliPosition* ry=t->GetReferencePoint();
1520 if (!ry) ry=t->GetBeginPoint();
1521 if (!ry) ry=t->GetEndPoint();
1522
1523 if (!ry) return dist;
1524
1525 Ali3Vector p1=Get3Momentum();
1526 Ali3Vector p2=t->Get3Momentum();
1527
1528 if (p1.GetNorm() <= 0. || p2.GetNorm() <= 0.) return dist;
1529
1530 // The vector normal to both track directions
1531 Ali3Vector n=p1.Cross(p2);
1532
25eefd00 1533 Float_t scalex=rx->GetUnitScale();
1534 Float_t scaley=ry->GetUnitScale();
1535
9427ac75 1536 if (n.GetNorm() > 1.e-10)
1537 {
1538 // Normalise n to a unit vector
1539 Double_t vec[3];
1540 Double_t err[3];
1541 n.GetVector(vec,"sph");
1542 n.GetErrors(err,"sph");
1543 vec[0]=1.;
1544 err[0]=0.;
1545 n.SetVector(vec,"sph");
1546 n.SetErrors(err,"sph");
1547 Ali3Vector r1=(Ali3Vector)(*rx);
1548 Ali3Vector r2=(Ali3Vector)(*ry);
1549 // Correct components of r2 in case of different unit scales
25eefd00 1550 if ((scaley/scalex > 1.1) || (scalex/scaley > 1.1)) r2=r2*(scaley/scalex);
9427ac75 1551 Ali3Vector r=r1-r2;
1552 dist=fabs(r.Dot(n));
1553 fDresult=r.GetResultError();
1554 }
1555 else // Parallel tracks
1556 {
1557 dist=t->GetDistance(rx);
1558 fDresult=t->GetResultError();
1559 }
25eefd00 1560
1561 if (scale>0)
1562 {
1563 dist*=scalex/scale;
1564 fDresult*=scalex/scale;
1565 }
9427ac75 1566 return dist;
1567}
1568///////////////////////////////////////////////////////////////////////////
261c0caf 1569TObject* AliTrack::Clone(const char* name) const
5f25234b 1570{
1571// Make a deep copy of the current object and provide the pointer to the copy.
1572// This memberfunction enables automatic creation of new objects of the
1573// correct type depending on the object type, a feature which may be very useful
1574// for containers when adding objects in case the container owns the objects.
1575// This feature allows e.g. AliJet to store either AliTrack objects or
1576// objects derived from AliTrack via the AddTrack memberfunction, provided
1577// these derived classes also have a proper Clone memberfunction.
1578
1579 AliTrack* trk=new AliTrack(*this);
1580 if (name)
1581 {
1582 if (strlen(name)) trk->SetName(name);
1583 }
1584 return trk;
1585}
1586///////////////////////////////////////////////////////////////////////////