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
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().
286 // Ali3Vector p=Get3Vector();
287 // return sqrt(p.Dot(p));
288 Double_t norm=fV.GetNorm();
291 ///////////////////////////////////////////////////////////////////////////
292 Ali3Vector AliTrack::Get3Momentum()
294 // Provide the track 3-momentum
295 return (Ali3Vector)Get3Vector();
297 ///////////////////////////////////////////////////////////////////////////
298 Double_t AliTrack::GetMass()
300 // Provide the particle mass.
301 // The error can be obtained by invoking GetResultError() after
302 // invokation of GetMass().
303 Double_t inv=GetInvariant();
304 Double_t dinv=GetResultError();
308 Double_t m=sqrt(inv);
309 if (m) dm=dinv/(2.*m);
315 cout << "*AliTrack::GetMass* Unphysical situation m**2 = " << inv << endl;
316 cout << " Value 0 will be returned." << endl;
321 ///////////////////////////////////////////////////////////////////////////
322 Float_t AliTrack::GetCharge()
324 // Provide the particle charge
327 ///////////////////////////////////////////////////////////////////////////
328 Double_t AliTrack::GetEnergy()
330 // Provide the particle's energy.
331 // The error can be obtained by invoking GetResultError() after
332 // invokation of GetEnergy().
333 Double_t E=GetScalar();
340 cout << "*AliTrack::GetEnergy* Unphysical situation E = " << E << endl;
341 cout << " Value 0 will be returned." << endl;
345 ///////////////////////////////////////////////////////////////////////////
346 void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
348 // Perform 2-body decay of current track
349 // m1 : mass of decay product 1
350 // m2 : mass of decay product 2
351 // thcms : cms theta decay angle (in rad.) of m1
352 // phicms : cms phi decay angle (in rad.) of m1
354 fNdec=2; // it's a 2-body decay
356 Double_t M=GetMass();
358 // Compute the 4-momenta of the decay products in the cms
359 // Note : p2=p1=pnorm for a 2-body decay
361 if (M) e1=((M*M)+(m1*m1)-(m2*m2))/(2.*M);
363 if (M) e2=((M*M)+(m2*m2)-(m1*m1))/(2.*M);
364 Double_t pnorm=(e1*e1)-(m1*m1);
379 p.SetVector(a,"sph");
382 pprim1.SetVector(e1,p);
383 pprim1.SetInvariant(m1*m1);
387 pprim2.SetVector(e2,p);
388 pprim2.SetInvariant(m2*m2);
390 // Determine boost parameters from the parent particle
391 Double_t E=GetEnergy();
399 Ali4Vector p1=q.Inverse(pprim1); // Boost decay product 1
400 Ali4Vector p2=q.Inverse(pprim2); // Boost decay product 2
402 // Enter the boosted data into the decay tracks array
408 fDecays=new TObjArray();
410 fDecays->Add(new AliTrack);
411 ((AliTrack*)fDecays->At(0))->Set4Momentum(p1);
412 ((AliTrack*)fDecays->At(0))->SetMass(m1);
413 fDecays->Add(new AliTrack);
414 ((AliTrack*)fDecays->At(1))->Set4Momentum(p2);
415 ((AliTrack*)fDecays->At(1))->SetMass(m2);
417 ///////////////////////////////////////////////////////////////////////////
418 Int_t AliTrack::GetNdecay()
420 // Provide the number of decay produced tracks
423 ///////////////////////////////////////////////////////////////////////////
424 AliTrack* AliTrack::GetDecayTrack(Int_t j)
426 // Provide decay produced track number j
427 // Note : j=1 denotes the first decay track
428 if ((j >= 1) && (j <= fNdec))
430 return (AliTrack*)fDecays->At(j-1);
434 cout << " *AliTrack* decay track number : " << j << " out of range." << endl;
435 cout << " -- Decay track number 1 (if any) returned." << endl;
436 return (AliTrack*)fDecays->At(0);
439 ///////////////////////////////////////////////////////////////////////////
440 void AliTrack::AddSignal(AliSignal& s)
442 // Relate an AliSignal object to this track.
443 if (!fSignals) fSignals=new TObjArray();
447 ///////////////////////////////////////////////////////////////////////////
448 void AliTrack::RemoveSignal(AliSignal& s)
450 // Remove related AliSignal object to this track.
453 AliSignal* test=(AliSignal*)fSignals->Remove(&s);
457 fSignals->Compress();
461 ///////////////////////////////////////////////////////////////////////////
462 Int_t AliTrack::GetNsignals()
464 // Provide the number of related AliSignals.
467 ///////////////////////////////////////////////////////////////////////////
468 AliSignal* AliTrack::GetSignal(Int_t j)
470 // Provide the related AliSignal number j.
471 // Note : j=1 denotes the first signal.
472 if ((j >= 1) && (j <= fNsig))
474 return (AliSignal*)fSignals->At(j-1);
478 cout << " *AliTrack* signal number : " << j << " out of range." << endl;
479 cout << " -- Signal number 1 (if any) returned." << endl;
480 return (AliSignal*)fDecays->At(0);
483 ///////////////////////////////////////////////////////////////////////////
484 void AliTrack::SetBeginPoint(AliPosition p)
486 // Store the position of the track begin-point.
489 ///////////////////////////////////////////////////////////////////////////
490 AliPosition AliTrack::GetBeginPoint()
492 // Provide the position of the track begin-point.
495 ///////////////////////////////////////////////////////////////////////////
496 void AliTrack::SetEndPoint(AliPosition p)
498 // Store the position of the track end-point.
501 ///////////////////////////////////////////////////////////////////////////
502 AliPosition AliTrack::GetEndPoint()
504 // Provide the position of the track end-point.
507 ///////////////////////////////////////////////////////////////////////////
508 void AliTrack::AddMassHypothesis(Double_t prob,Double_t m,Double_t dm)
510 // Add a mass hypothesis for this current track.
511 // prob=probalility m=mass value dm=error on the mass value.
512 // The default value for the mass error dm is 0.
513 if (!fMasses) fMasses=new TArrayD();
514 if (!fDmasses) fDmasses=new TArrayD();
515 if (!fPmasses) fPmasses=new TArrayD();
518 fMasses->Set(fNmasses);
519 fDmasses->Set(fNmasses);
520 fPmasses->Set(fNmasses);
522 fMasses->AddAt(m,fNmasses-1);
523 fDmasses->AddAt(dm,fNmasses-1);
524 fPmasses->AddAt(prob,fNmasses-1);
526 ///////////////////////////////////////////////////////////////////////////
527 Int_t AliTrack::GetNMassHypotheses()
529 // Provide the number of mass hypotheses for this track.
532 ///////////////////////////////////////////////////////////////////////////
533 Double_t AliTrack::GetMassHypothesis(Int_t j)
535 // Provide the mass of the jth hypothesis for this track.
536 // Note : the first hypothesis is indicated by j=1.
537 // Default : j=0 ==> Hypothesis with highest probability.
538 // The error on the mass can be obtained by invoking GetResultError()
539 // after invokation of GetMassHypothesis(j).
541 Double_t m=0,dm=0,prob=0;
543 // Check validity of index j
544 if (j<0 || j>fNmasses)
546 cout << " *AliTrack::GetMassHypothesis* Invalid index j : " << j
547 << " Number of mass hypotheses : " << fNmasses << endl;
552 // Select mass hypothesis with highest probability
559 prob=fPmasses->At(0);
560 for (Int_t i=1; i<fNmasses; i++)
562 if (fPmasses->At(i)>prob)
573 // Provide data of requested mass hypothesis
575 fDresult=fDmasses->At(j-1);
578 ///////////////////////////////////////////////////////////////////////////
579 Double_t AliTrack::GetMassHypothesisProb(Int_t j)
581 // Provide the probability of the jth hypothesis for this track.
582 // Note : the first hypothesis is indicated by j=1.
583 // Default : j=0 ==> Hypothesis with highest probability.
587 // Check validity of index j
588 if (j<0 || j>fNmasses)
590 cout << " *AliTrack::GetMassHypothesisProb* Invalid index j : " << j
591 << " Number of mass hypotheses : " << fNmasses << endl;
595 // Select mass hypothesis with highest probability
600 prob=fPmasses->At(0);
601 for (Int_t i=1; i<fNmasses; i++)
603 if (fPmasses->At(i)>prob) prob=fPmasses->At(i);
609 // Provide probability of requested mass hypothesis
610 prob=fPmasses->At(j-1);
613 ///////////////////////////////////////////////////////////////////////////
614 void AliTrack::SetMass()
616 // Set the mass and error to the value of the hypothesis with highest prob.
618 Double_t m=0,dm=0,prob=0;
620 // Select mass hypothesis with highest probability
625 prob=fPmasses->At(0);
626 for (Int_t i=1; i<fNmasses; i++)
628 if (fPmasses->At(i)>prob)
638 cout << " *AliTrack::SetMass()* No hypothesis present => No action." << endl;
641 ///////////////////////////////////////////////////////////////////////////
642 void AliTrack::RemoveMassHypothesis(Int_t j)
644 // Remove the jth mass hypothesis for this track.
645 // Note : the first hypothesis is indicated by j=1.
647 if (j<=0 || j>fNmasses) // Check validity of index j
649 cout << " *AliTrack::RemoveMassHypothesis* Invalid index j : " << j
650 << " Number of mass hypotheses : " << fNmasses << endl;
656 fMasses->AddAt(fMasses->At(fNmasses-1),j-1);
657 fDmasses->AddAt(fDmasses->At(fNmasses-1),j-1);
658 fPmasses->AddAt(fPmasses->At(fNmasses-1),j-1);
660 fMasses->AddAt(0,fNmasses-1);
661 fDmasses->AddAt(0,fNmasses-1);
662 fPmasses->AddAt(0,fNmasses-1);
664 fMasses->Set(fNmasses);
665 fDmasses->Set(fNmasses);
666 fPmasses->Set(fNmasses);
669 ///////////////////////////////////////////////////////////////////////////