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 Revision 1.2 1999/09/29 09:24:28 fca
19 Introduction of the Copyright and cvs Log
23 ///////////////////////////////////////////////////////////////////////////
25 // Handling of the attributes of a reconstructed particle track.
30 // Float_t a[4]={195.,1.2,-0.04,8.5};
32 // pmu.SetVector(a,"car");
34 // t1.Set4Momentum(pmu);
36 // Float_t b[3]={1.2,-0.04,8.5};
38 // p.SetVector(b,"car");
40 // t2.Set3Momentum(p);
47 // Float_t pi=acos(-1.);
48 // Float_t thcms=0.2*pi; // decay theta angle in cms
49 // Float_t phicms=pi/4.; // decay theta angle in cms
52 // t2.Decay(m1,m2,thcms,phicms); // Track t2 decay : Lambda -> proton + pion
56 // Int_t ndec=t2.GetNdecay();
57 // AliTrack* d1=t2.GetDecayTrack(1); // Access to decay track number 1
58 // AliTrack* d2=t2.GetDecayTrack(2); // Access to decay track number 2
60 // AliSignal s1,s2,s3,s4;
62 // .... // Code (e.g. detector readout) to fill AliSignal data
64 // AliTrack trec; // Track which will be reconstructed from signals
65 // trec.AddSignal(s1);
66 // trec.AddSignal(s3);
67 // trec.AddSignal(s4);
72 // ... // Code which accesses signals from trec and reconstructs
73 // 3-momentum P, charge Q, mass M etc...
75 // trec.Set3Momentum(P);
79 // Float_t r1[3]={1.6,-3.8,25.7};
80 // Float_t er1[3]={0.2,0.5,1.8};
81 // Float_t r2[3]={8.6,23.8,-6.7};
82 // Float_t er2[3]={0.93,1.78,0.8};
83 // AliPosition begin,end;
84 // begin.SetPosition(r1,"car");
85 // begin.SetPositionErrors(er1,"car");
86 // end.SetPosition(r2,"car");
87 // end.SetPositionErrors(er2,"car");
88 // trec.SetBeginPoint(begin);
89 // trec.SetEndPoint(end);
91 // Note : All quantities are in GeV, GeV/c or GeV/c**2
93 //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht
94 //- Modified: NvE 29-oct-1999 UU-SAP Utrecht
95 ///////////////////////////////////////////////////////////////////////////
99 ClassImp(AliTrack) // Class implementation to enable ROOT I/O
103 // Default constructor
104 // All variables initialised to 0
109 ///////////////////////////////////////////////////////////////////////////
110 AliTrack::~AliTrack()
112 // Destructor to delete memory allocated for decay tracks array
126 ///////////////////////////////////////////////////////////////////////////
127 void AliTrack::Reset()
129 // Reset all variables to 0
133 Double_t a[4]={0,0,0,0};
147 Double_t b[3]={0,0,0};
148 fBegin.SetPosition(b,"sph");
149 fEnd.SetPosition(b,"sph");
151 ///////////////////////////////////////////////////////////////////////////
152 void AliTrack::Set3Momentum(Ali3Vector& p)
154 // Set the track parameters according to the 3-momentum p
157 ///////////////////////////////////////////////////////////////////////////
158 void AliTrack::Set4Momentum(Ali4Vector& p)
160 // Set the track parameters according to the 4-momentum p
161 Double_t E=p.GetScalar();
162 Double_t dE=p.GetResultError();
163 Ali3Vector pv=p.Get3Vector();
167 ///////////////////////////////////////////////////////////////////////////
168 void AliTrack::SetMass(Double_t m,Double_t dm)
170 // Set the particle mass
171 // The default value for the error dm is 0.
172 Double_t inv=pow(m,2);
173 Double_t dinv=fabs(2.*m*dm);
174 SetInvariant(inv,dinv);
176 ///////////////////////////////////////////////////////////////////////////
177 void AliTrack::SetCharge(Float_t q)
179 // Set the particle charge
182 ///////////////////////////////////////////////////////////////////////////
183 void AliTrack::Info(TString f)
185 // Provide track information within the coordinate frame f
186 Double_t m=GetMass();
187 Double_t dm=GetResultError();
188 cout << " *AliTrack::Info* Mass : " << m
189 << " error : " << dm << " Charge : " << fQ
190 << " Momentum : " << GetMomentum() << " Ntracks : " << fNdec
191 << " Nsignals : " << fNsig << endl;
194 ///////////////////////////////////////////////////////////////////////////
195 void AliTrack::List(TString f)
197 // Provide current track and decay level 1 information within coordinate frame f
199 Info(f); // Information of the current track
201 // Decay products of this track
203 for (Int_t id=1; id<=fNdec; id++)
205 td=GetDecayTrack(id);
208 cout << " ---Level 1 sec. track no. " << id << endl;
213 cout << " *AliTrack::List* Error : No decay track present." << endl;
217 ///////////////////////////////////////////////////////////////////////////
218 void AliTrack::ListAll(TString f)
220 // Provide complete track and decay information within the coordinate frame f
222 Info(f); // Information of the current track
223 cout << " Begin-point :"; fBegin.Info(f);
224 cout << " End-point :"; fEnd.Info(f);
225 for (Int_t is=1; is<=GetNsignals(); is++)
227 ((AliSignal*)GetSignal(is))->Info(f);
231 Dump(t,1,f); // Information of all decay products
233 //////////////////////////////////////////////////////////////////////////
234 void AliTrack::Dump(AliTrack* t,Int_t n,TString f)
236 // Recursively provide the info of all decay levels of this track
238 for (Int_t id=1; id<=t->GetNdecay(); id++)
240 td=t->GetDecayTrack(id);
243 cout << " ---Level " << n << " sec. track no. " << id << endl;
245 for (Int_t is=1; is<=td->GetNsignals(); is++)
247 ((AliSignal*)td->GetSignal(is))->Info(f);
250 // Go for next decay level of this decay track recursively
255 cout << " *AliTrack::Dump* Error : No decay track present." << endl;
259 //////////////////////////////////////////////////////////////////////////
260 Double_t AliTrack::GetMomentum()
262 // Provide the value of the track 3-momentum.
263 // The error can be obtained by invoking GetResultError() after
264 // invokation of GetMomentum().
266 // Ali3Vector p=Get3Vector();
267 // return sqrt(p.Dot(p));
268 Double_t norm=fV.GetNorm();
271 ///////////////////////////////////////////////////////////////////////////
272 Ali3Vector AliTrack::Get3Momentum()
274 // Provide the track 3-momentum
275 return (Ali3Vector)Get3Vector();
277 ///////////////////////////////////////////////////////////////////////////
278 Double_t AliTrack::GetMass()
280 // Provide the particle mass.
281 // The error can be obtained by invoking GetResultError() after
282 // invokation of GetMass().
283 Double_t inv=GetInvariant();
284 Double_t dinv=GetResultError();
288 Double_t m=sqrt(inv);
289 if (m) dm=dinv/(2.*m);
295 cout << "*AliTrack::GetMass* Unphysical situation m**2 = " << inv << endl;
296 cout << " Value 0 will be returned." << endl;
301 ///////////////////////////////////////////////////////////////////////////
302 Float_t AliTrack::GetCharge()
304 // Provide the particle charge
307 ///////////////////////////////////////////////////////////////////////////
308 Double_t AliTrack::GetEnergy()
310 // Provide the particle's energy.
311 // The error can be obtained by invoking GetResultError() after
312 // invokation of GetEnergy().
313 Double_t E=GetScalar();
320 cout << "*AliTrack::GetEnergy* Unphysical situation E = " << E << endl;
321 cout << " Value 0 will be returned." << endl;
325 ///////////////////////////////////////////////////////////////////////////
326 void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
328 // Perform 2-body decay of current track
329 // m1 : mass of decay product 1
330 // m2 : mass of decay product 2
331 // thcms : cms theta decay angle (in rad.) of m1
332 // phicms : cms phi decay angle (in rad.) of m1
334 fNdec=2; // it's a 2-body decay
336 Double_t M=GetMass();
338 // Compute the 4-momenta of the decay products in the cms
339 // Note : p2=p1=pnorm for a 2-body decay
341 if (M) e1=((M*M)+(m1*m1)-(m2*m2))/(2.*M);
343 if (M) e2=((M*M)+(m2*m2)-(m1*m1))/(2.*M);
344 Double_t pnorm=(e1*e1)-(m1*m1);
359 p.SetVector(a,"sph");
362 pprim1.SetVector(e1,p);
363 pprim1.SetInvariant(m1*m1);
367 pprim2.SetVector(e2,p);
368 pprim2.SetInvariant(m2*m2);
370 // Determine boost parameters from the parent particle
371 Double_t E=GetEnergy();
379 Ali4Vector p1=q.Inverse(pprim1); // Boost decay product 1
380 Ali4Vector p2=q.Inverse(pprim2); // Boost decay product 2
382 // Enter the boosted data into the decay tracks array
388 fDecays=new TObjArray();
390 fDecays->Add(new AliTrack);
391 ((AliTrack*)fDecays->At(0))->Set4Momentum(p1);
392 ((AliTrack*)fDecays->At(0))->SetMass(m1);
393 fDecays->Add(new AliTrack);
394 ((AliTrack*)fDecays->At(1))->Set4Momentum(p2);
395 ((AliTrack*)fDecays->At(1))->SetMass(m2);
397 ///////////////////////////////////////////////////////////////////////////
398 Int_t AliTrack::GetNdecay()
400 // Provide the number of decay produced tracks
403 ///////////////////////////////////////////////////////////////////////////
404 AliTrack* AliTrack::GetDecayTrack(Int_t j)
406 // Provide decay produced track number j
407 // Note : j=1 denotes the first decay track
408 if ((j >= 1) && (j <= fNdec))
410 return (AliTrack*)fDecays->At(j-1);
414 cout << " *AliTrack* decay track number : " << j << " out of range." << endl;
415 cout << " -- Decay track number 1 (if any) returned." << endl;
416 return (AliTrack*)fDecays->At(0);
419 ///////////////////////////////////////////////////////////////////////////
420 void AliTrack::AddSignal(AliSignal& s)
422 // Relate an AliSignal object to this track.
423 if (!fSignals) fSignals=new TObjArray();
427 ///////////////////////////////////////////////////////////////////////////
428 void AliTrack::RemoveSignal(AliSignal& s)
430 // Remove related AliSignal object to this track.
433 AliSignal* test=(AliSignal*)fSignals->Remove(&s);
437 fSignals->Compress();
441 ///////////////////////////////////////////////////////////////////////////
442 Int_t AliTrack::GetNsignals()
444 // Provide the number of related AliSignals.
447 ///////////////////////////////////////////////////////////////////////////
448 AliSignal* AliTrack::GetSignal(Int_t j)
450 // Provide the related AliSignal number j.
451 // Note : j=1 denotes the first signal.
452 if ((j >= 1) && (j <= fNsig))
454 return (AliSignal*)fSignals->At(j-1);
458 cout << " *AliTrack* signal number : " << j << " out of range." << endl;
459 cout << " -- Signal number 1 (if any) returned." << endl;
460 return (AliSignal*)fDecays->At(0);
463 ///////////////////////////////////////////////////////////////////////////
464 void AliTrack::SetBeginPoint(AliPosition p)
466 // Store the position of the track begin-point.
469 ///////////////////////////////////////////////////////////////////////////
470 AliPosition AliTrack::GetBeginPoint()
472 // Provide the position of the track begin-point.
475 ///////////////////////////////////////////////////////////////////////////
476 void AliTrack::SetEndPoint(AliPosition p)
478 // Store the position of the track end-point.
481 ///////////////////////////////////////////////////////////////////////////
482 AliPosition AliTrack::GetEndPoint()
484 // Provide the position of the track end-point.
487 ///////////////////////////////////////////////////////////////////////////