1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////
20 // Handling of the attributes of a reconstructed particle track.
25 // Float_t a[4]={195.,1.2,-0.04,8.5};
27 // pmu.SetVector(a,"car");
29 // t1.Set4Momentum(pmu);
31 // Float_t b[3]={1.2,-0.04,8.5};
33 // p.SetVector(b,"car");
35 // t2.Set3Momentum(p);
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
47 // t2.Decay(m1,m2,thcms,phicms); // Track t2 decay : Lambda -> proton + pion
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
55 // AliSignal s1,s2,s3,s4;
57 // .... // Code (e.g. detector readout) to fill AliSignal data
59 // AliTrack trec; // Track which will be reconstructed from signals
60 // trec.AddSignal(s1);
61 // trec.AddSignal(s3);
62 // trec.AddSignal(s4);
67 // ... // Code which accesses signals from trec and reconstructs
68 // 3-momentum P, charge Q, mass M etc...
70 // trec.Set3Momentum(P);
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);
86 // Note : All quantities are in GeV, GeV/c or GeV/c**2
88 //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht
89 //- Modified: NvE $Date$ UU-SAP Utrecht
90 ///////////////////////////////////////////////////////////////////////////
94 ClassImp(AliTrack) // Class implementation to enable ROOT I/O
98 // Default constructor
99 // All variables initialised to 0
107 ///////////////////////////////////////////////////////////////////////////
108 AliTrack::~AliTrack()
110 // Destructor to delete memory allocated for decay tracks array
124 ///////////////////////////////////////////////////////////////////////////
125 void AliTrack::Reset()
127 // Reset all variables to 0 and delete all auto-generated decay tracks.
132 Double_t a[4]={0,0,0,0};
146 Double_t b[3]={0,0,0};
147 fBegin.SetPosition(b,"sph");
148 fEnd.SetPosition(b,"sph");
165 ///////////////////////////////////////////////////////////////////////////
166 void AliTrack::Set3Momentum(Ali3Vector& p)
168 // Set the track parameters according to the 3-momentum p
171 ///////////////////////////////////////////////////////////////////////////
172 void AliTrack::Set4Momentum(Ali4Vector& p)
174 // Set the track parameters according to the 4-momentum p
175 Double_t E=p.GetScalar();
176 Double_t dE=p.GetResultError();
177 Ali3Vector pv=p.Get3Vector();
181 ///////////////////////////////////////////////////////////////////////////
182 void AliTrack::SetMass(Double_t m,Double_t dm)
184 // Set the particle mass
185 // The default value for the error dm is 0.
186 Double_t inv=pow(m,2);
187 Double_t dinv=fabs(2.*m*dm);
188 SetInvariant(inv,dinv);
190 ///////////////////////////////////////////////////////////////////////////
191 void AliTrack::SetCharge(Float_t q)
193 // Set the particle charge
196 ///////////////////////////////////////////////////////////////////////////
197 void AliTrack::Info(TString f)
199 // Provide track information within the coordinate frame f
200 Double_t m=GetMass();
201 Double_t dm=GetResultError();
202 cout << " *AliTrack::Info* Mass : " << m
203 << " error : " << dm << " Charge : " << fQ
204 << " Momentum : " << GetMomentum() << " Nmass hyp. : " << fNmasses
205 << " Ntracks : " << fNdec << " Nsignals : " << fNsig << endl;
206 for (Int_t i=0; i<fNmasses; i++)
208 cout << " Mass hypothesis " << (i+1) << " Mass : " << fMasses->At(i)
209 << " error : " << fDmasses->At(i) << " prob. : " << fPmasses->At(i)
214 ///////////////////////////////////////////////////////////////////////////
215 void AliTrack::List(TString f)
217 // Provide current track and decay level 1 information within coordinate frame f
219 Info(f); // Information of the current track
221 // Decay products of this track
223 for (Int_t id=1; id<=fNdec; id++)
225 td=GetDecayTrack(id);
228 cout << " ---Level 1 sec. track no. " << id << endl;
233 cout << " *AliTrack::List* Error : No decay track present." << endl;
237 ///////////////////////////////////////////////////////////////////////////
238 void AliTrack::ListAll(TString f)
240 // Provide complete track and decay information within the coordinate frame f
242 Info(f); // Information of the current track
243 cout << " Begin-point :"; fBegin.Info(f);
244 cout << " End-point :"; fEnd.Info(f);
245 for (Int_t is=1; is<=GetNsignals(); is++)
247 ((AliSignal*)GetSignal(is))->Info(f);
251 Dump(t,1,f); // Information of all decay products
253 //////////////////////////////////////////////////////////////////////////
254 void AliTrack::Dump(AliTrack* t,Int_t n,TString f)
256 // Recursively provide the info of all decay levels of this track
258 for (Int_t id=1; id<=t->GetNdecay(); id++)
260 td=t->GetDecayTrack(id);
263 cout << " ---Level " << n << " sec. track no. " << id << endl;
265 for (Int_t is=1; is<=td->GetNsignals(); is++)
267 ((AliSignal*)td->GetSignal(is))->Info(f);
270 // Go for next decay level of this decay track recursively
275 cout << " *AliTrack::Dump* Error : No decay track present." << endl;
279 //////////////////////////////////////////////////////////////////////////
280 Double_t AliTrack::GetMomentum()
282 // Provide the value of the track 3-momentum.
283 // The error can be obtained by invoking GetResultError() after
284 // invokation of GetMomentum().
285 Double_t norm=fV.GetNorm();
286 fDresult=fV.GetResultError();
289 ///////////////////////////////////////////////////////////////////////////
290 Ali3Vector AliTrack::Get3Momentum()
292 // Provide the track 3-momentum
293 return (Ali3Vector)Get3Vector();
295 ///////////////////////////////////////////////////////////////////////////
296 Double_t AliTrack::GetMass()
298 // Provide the particle mass.
299 // The error can be obtained by invoking GetResultError() after
300 // invokation of GetMass().
301 Double_t inv=GetInvariant();
302 Double_t dinv=GetResultError();
306 Double_t m=sqrt(inv);
307 if (m) dm=dinv/(2.*m);
313 cout << "*AliTrack::GetMass* Unphysical situation m**2 = " << inv << endl;
314 cout << " Value 0 will be returned." << endl;
319 ///////////////////////////////////////////////////////////////////////////
320 Float_t AliTrack::GetCharge()
322 // Provide the particle charge
325 ///////////////////////////////////////////////////////////////////////////
326 Double_t AliTrack::GetEnergy()
328 // Provide the particle's energy.
329 // The error can be obtained by invoking GetResultError() after
330 // invokation of GetEnergy().
331 Double_t E=GetScalar();
338 cout << "*AliTrack::GetEnergy* Unphysical situation E = " << E << endl;
339 cout << " Value 0 will be returned." << endl;
343 ///////////////////////////////////////////////////////////////////////////
344 void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
346 // Perform 2-body decay of current track
347 // m1 : mass of decay product 1
348 // m2 : mass of decay product 2
349 // thcms : cms theta decay angle (in rad.) of m1
350 // phicms : cms phi decay angle (in rad.) of m1
352 fNdec=2; // it's a 2-body decay
354 Double_t M=GetMass();
356 // Compute the 4-momenta of the decay products in the cms
357 // Note : p2=p1=pnorm for a 2-body decay
359 if (M) e1=((M*M)+(m1*m1)-(m2*m2))/(2.*M);
361 if (M) e2=((M*M)+(m2*m2)-(m1*m1))/(2.*M);
362 Double_t pnorm=(e1*e1)-(m1*m1);
377 p.SetVector(a,"sph");
380 pprim1.SetVector(e1,p);
381 pprim1.SetInvariant(m1*m1);
385 pprim2.SetVector(e2,p);
386 pprim2.SetInvariant(m2*m2);
388 // Determine boost parameters from the parent particle
389 Double_t E=GetEnergy();
397 Ali4Vector p1=q.Inverse(pprim1); // Boost decay product 1
398 Ali4Vector p2=q.Inverse(pprim2); // Boost decay product 2
400 // Enter the boosted data into the decay tracks array
406 fDecays=new TObjArray();
408 fDecays->Add(new AliTrack);
409 ((AliTrack*)fDecays->At(0))->Set4Momentum(p1);
410 ((AliTrack*)fDecays->At(0))->SetMass(m1);
411 fDecays->Add(new AliTrack);
412 ((AliTrack*)fDecays->At(1))->Set4Momentum(p2);
413 ((AliTrack*)fDecays->At(1))->SetMass(m2);
415 ///////////////////////////////////////////////////////////////////////////
416 Int_t AliTrack::GetNdecay()
418 // Provide the number of decay produced tracks
421 ///////////////////////////////////////////////////////////////////////////
422 AliTrack* AliTrack::GetDecayTrack(Int_t j)
424 // Provide decay produced track number j
425 // Note : j=1 denotes the first decay track
426 if ((j >= 1) && (j <= fNdec))
428 return (AliTrack*)fDecays->At(j-1);
432 cout << " *AliTrack* decay track number : " << j << " out of range." << endl;
433 cout << " -- Decay track number 1 (if any) returned." << endl;
434 return (AliTrack*)fDecays->At(0);
437 ///////////////////////////////////////////////////////////////////////////
438 void AliTrack::AddSignal(AliSignal& s)
440 // Relate an AliSignal object to this track.
441 if (!fSignals) fSignals=new TObjArray();
445 ///////////////////////////////////////////////////////////////////////////
446 void AliTrack::RemoveSignal(AliSignal& s)
448 // Remove related AliSignal object to this track.
451 AliSignal* test=(AliSignal*)fSignals->Remove(&s);
455 fSignals->Compress();
459 ///////////////////////////////////////////////////////////////////////////
460 Int_t AliTrack::GetNsignals()
462 // Provide the number of related AliSignals.
465 ///////////////////////////////////////////////////////////////////////////
466 AliSignal* AliTrack::GetSignal(Int_t j)
468 // Provide the related AliSignal number j.
469 // Note : j=1 denotes the first signal.
470 if ((j >= 1) && (j <= fNsig))
472 return (AliSignal*)fSignals->At(j-1);
476 cout << " *AliTrack* signal number : " << j << " out of range." << endl;
477 cout << " -- Signal number 1 (if any) returned." << endl;
478 return (AliSignal*)fDecays->At(0);
481 ///////////////////////////////////////////////////////////////////////////
482 void AliTrack::SetBeginPoint(AliPosition p)
484 // Store the position of the track begin-point.
487 ///////////////////////////////////////////////////////////////////////////
488 AliPosition AliTrack::GetBeginPoint()
490 // Provide the position of the track begin-point.
493 ///////////////////////////////////////////////////////////////////////////
494 void AliTrack::SetEndPoint(AliPosition p)
496 // Store the position of the track end-point.
499 ///////////////////////////////////////////////////////////////////////////
500 AliPosition AliTrack::GetEndPoint()
502 // Provide the position of the track end-point.
505 ///////////////////////////////////////////////////////////////////////////
506 void AliTrack::AddMassHypothesis(Double_t prob,Double_t m,Double_t dm)
508 // Add a mass hypothesis for this current track.
509 // prob=probalility m=mass value dm=error on the mass value.
510 // The default value for the mass error dm is 0.
511 if (!fMasses) fMasses=new TArrayD();
512 if (!fDmasses) fDmasses=new TArrayD();
513 if (!fPmasses) fPmasses=new TArrayD();
516 fMasses->Set(fNmasses);
517 fDmasses->Set(fNmasses);
518 fPmasses->Set(fNmasses);
520 fMasses->AddAt(m,fNmasses-1);
521 fDmasses->AddAt(dm,fNmasses-1);
522 fPmasses->AddAt(prob,fNmasses-1);
524 ///////////////////////////////////////////////////////////////////////////
525 Int_t AliTrack::GetNMassHypotheses()
527 // Provide the number of mass hypotheses for this track.
530 ///////////////////////////////////////////////////////////////////////////
531 Double_t AliTrack::GetMassHypothesis(Int_t j)
533 // Provide the mass of the jth hypothesis for this track.
534 // Note : the first hypothesis is indicated by j=1.
535 // Default : j=0 ==> Hypothesis with highest probability.
536 // The error on the mass can be obtained by invoking GetResultError()
537 // after invokation of GetMassHypothesis(j).
539 Double_t m=0,dm=0,prob=0;
541 // Check validity of index j
542 if (j<0 || j>fNmasses)
544 cout << " *AliTrack::GetMassHypothesis* Invalid index j : " << j
545 << " Number of mass hypotheses : " << fNmasses << endl;
550 // Select mass hypothesis with highest probability
557 prob=fPmasses->At(0);
558 for (Int_t i=1; i<fNmasses; i++)
560 if (fPmasses->At(i)>prob)
571 // Provide data of requested mass hypothesis
573 fDresult=fDmasses->At(j-1);
576 ///////////////////////////////////////////////////////////////////////////
577 Double_t AliTrack::GetMassHypothesisProb(Int_t j)
579 // Provide the probability of the jth hypothesis for this track.
580 // Note : the first hypothesis is indicated by j=1.
581 // Default : j=0 ==> Hypothesis with highest probability.
585 // Check validity of index j
586 if (j<0 || j>fNmasses)
588 cout << " *AliTrack::GetMassHypothesisProb* Invalid index j : " << j
589 << " Number of mass hypotheses : " << fNmasses << endl;
593 // Select mass hypothesis with highest probability
598 prob=fPmasses->At(0);
599 for (Int_t i=1; i<fNmasses; i++)
601 if (fPmasses->At(i)>prob) prob=fPmasses->At(i);
607 // Provide probability of requested mass hypothesis
608 prob=fPmasses->At(j-1);
611 ///////////////////////////////////////////////////////////////////////////
612 void AliTrack::SetMass()
614 // Set the mass and error to the value of the hypothesis with highest prob.
616 Double_t m=0,dm=0,prob=0;
618 // Select mass hypothesis with highest probability
623 prob=fPmasses->At(0);
624 for (Int_t i=1; i<fNmasses; i++)
626 if (fPmasses->At(i)>prob)
636 cout << " *AliTrack::SetMass()* No hypothesis present => No action." << endl;
639 ///////////////////////////////////////////////////////////////////////////
640 void AliTrack::RemoveMassHypothesis(Int_t j)
642 // Remove the jth mass hypothesis for this track.
643 // Note : the first hypothesis is indicated by j=1.
645 if (j<=0 || j>fNmasses) // Check validity of index j
647 cout << " *AliTrack::RemoveMassHypothesis* Invalid index j : " << j
648 << " Number of mass hypotheses : " << fNmasses << endl;
654 fMasses->AddAt(fMasses->At(fNmasses-1),j-1);
655 fDmasses->AddAt(fDmasses->At(fNmasses-1),j-1);
656 fPmasses->AddAt(fPmasses->At(fNmasses-1),j-1);
658 fMasses->AddAt(0,fNmasses-1);
659 fDmasses->AddAt(0,fNmasses-1);
660 fPmasses->AddAt(0,fNmasses-1);
662 fMasses->Set(fNmasses);
663 fDmasses->Set(fNmasses);
664 fPmasses->Set(fNmasses);
667 ///////////////////////////////////////////////////////////////////////////
668 Double_t AliTrack::GetPt()
670 // Provide trans. momentum value w.r.t. z-axis.
671 // The error on the value can be obtained by GetResultError()
672 // after invokation of GetPt().
675 Double_t norm=v.GetNorm();
676 fDresult=v.GetResultError();
680 ///////////////////////////////////////////////////////////////////////////
681 Double_t AliTrack::GetPl()
683 // Provide long. momentum value w.r.t. z-axis.
684 // Note : the returned value can also be negative.
685 // The error on the value can be obtained by GetResultError()
686 // after invokation of GetPl().
690 Double_t pl=v.GetNorm();
691 fDresult=v.GetResultError();
694 v.GetVector(a,"sph");
695 if (cos(a[1])<0) pl=-pl;
699 ///////////////////////////////////////////////////////////////////////////
700 Double_t AliTrack::GetEt()
702 // Provide trans. energy value w.r.t. z-axis.
703 // The error on the value can be obtained by GetResultError()
704 // after invokation of GetEt().
705 Double_t et=GetScaTrans();
709 ///////////////////////////////////////////////////////////////////////////
710 Double_t AliTrack::GetEl()
712 // Provide long. energy value w.r.t. z-axis.
713 // Note : the returned value can also be negative.
714 // The error on the value can be obtained by GetResultError()
715 // after invokation of GetEl().
716 Double_t el=GetScaLong();
720 ///////////////////////////////////////////////////////////////////////////
721 Double_t AliTrack::GetMt()
723 // Provide transverse mass value w.r.t. z-axis.
724 // The error on the value can be obtained by GetResultError()
725 // after invokation of GetMt().
727 Double_t dpt=GetResultError();
728 Double_t m=GetMass();
729 Double_t dm=GetResultError();
731 Double_t mt=sqrt(pt*pt+m*m);
733 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
738 ///////////////////////////////////////////////////////////////////////////
739 Double_t AliTrack::GetMt(Int_t j)
741 // Provide transverse mass value w.r.t. z-axis and jth mass hypothesis.
742 // Note : the first hypothesis is indicated by j=1.
743 // j=0 ==> Hypothesis with highest probability.
744 // The error on the value can be obtained by GetResultError()
745 // after invokation of GetMt(j).
747 Double_t dpt=GetResultError();
748 Double_t m=GetMassHypothesis(j);
749 Double_t dm=GetResultError();
751 Double_t mt=sqrt(pt*pt+m*m);
753 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
758 ///////////////////////////////////////////////////////////////////////////
759 Double_t AliTrack::GetRapidity()
761 // Provide rapidity value w.r.t. z-axis.
762 // The error on the value can be obtained by GetResultError()
763 // after invokation of GetRapidity().
764 // Note : Also GetPseudoRapidity() is available since this class is
765 // derived from Ali4Vector.
766 Double_t e=GetEnergy();
767 Double_t de=GetResultError();
769 Double_t dpl=GetResultError();
773 Double_t y=9999,dy2=0;
774 if (sum && dif) y=0.5*log(sum/dif);
776 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
781 ///////////////////////////////////////////////////////////////////////////