]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RALICE/AliTrack.cxx
Introducing Copyright include file
[u/mrichter/AliRoot.git] / RALICE / AliTrack.cxx
1 #include "AliTrack.h"
2  
3 ClassImp(AliTrack) // Class implementation to enable ROOT I/O
4  
5 AliTrack::AliTrack()
6 {
7 // Default constructor
8 // All variables initialised to 0
9  fDecays=0;
10  Reset();
11 }
12 ///////////////////////////////////////////////////////////////////////////
13 AliTrack::~AliTrack()
14 {
15 // Destructor to delete memory allocated for decay tracks array
16  if (fDecays)
17  {
18   fDecays->Delete();
19   delete fDecays;
20   fDecays=0;
21  }
22 }
23 ///////////////////////////////////////////////////////////////////////////
24 void AliTrack::Reset()
25 {
26 // Reset all variables to 0
27  fM=0;
28  fQ=0;
29  fNdec=0;
30  Double_t a[4]={0,0,0,0};
31  SetVector(a,"sph");
32  if (fDecays)
33  {
34   fDecays->Delete();
35   delete fDecays;
36   fDecays=0;
37  }
38 }
39 ///////////////////////////////////////////////////////////////////////////
40 void AliTrack::Set3Momentum(Ali3Vector& p)
41 {
42 // Set the track parameters according to the 3-momentum p
43  Double_t E=sqrt(p.Dot(p)+fM*fM);
44  SetVector(E,p);
45 }
46 ///////////////////////////////////////////////////////////////////////////
47 void AliTrack::Set4Momentum(Ali4Vector& p)
48 {
49 // Set the track parameters according to the 4-momentum p
50  Double_t E=p.GetScalar();
51  Ali3Vector pv=p.Get3Vector();
52  SetVector(E,pv);
53
54  Double_t m2=p.Dot(p);
55  fM=0;
56  if (m2 > 0.) fM=sqrt(m2);
57 }
58 ///////////////////////////////////////////////////////////////////////////
59 void AliTrack::SetMass(Double_t m)
60 {
61 // Set the particle mass
62  fM=m;
63  Ali3Vector p=Get3Vector();
64  Double_t E=sqrt(p.Dot(p)+fM*fM);
65  SetVector(E,p);
66 }
67 ///////////////////////////////////////////////////////////////////////////
68 void AliTrack::SetCharge(Float_t q)
69 {
70 // Set the particle charge
71  fQ=q;
72 }
73 ///////////////////////////////////////////////////////////////////////////
74 void AliTrack::Info(TString f)
75 {
76 // Provide track information within the coordinate frame f
77  cout << " *AliTrack::Info* Mass : " << fM << " Charge : " << fQ
78       << " Momentum : " << GetMomentum() << " Ntracks : " << fNdec << endl;
79  cout << " ";
80  Ali4Vector::Info(f); 
81
82 ///////////////////////////////////////////////////////////////////////////
83 void AliTrack::List(TString f)
84 {
85 // Provide current track and decay level 1 information within coordinate frame f
86
87  Info(f); // Information of the current track
88
89  // Decay products of this track
90  AliTrack* td; 
91  for (Int_t id=1; id<=fNdec; id++)
92  {
93   td=GetDecayTrack(id);
94   if (td)
95   {
96    cout << "  ---Level 1 sec. track no. " << id << endl;
97    cout << " ";
98    td->Info(f); 
99   }
100   else
101   {
102    cout << " *AliTrack::List* Error : No decay track present." << endl; 
103   }
104  }
105
106 ///////////////////////////////////////////////////////////////////////////
107 void AliTrack::ListAll(TString f)
108 {
109 // Provide complete track and decay information within the coordinate frame f
110
111  Info(f); // Information of the current track
112
113  AliTrack* t=this;
114  Dump(t,1,f); // Information of all decay products
115 }
116 //////////////////////////////////////////////////////////////////////////
117 void AliTrack::Dump(AliTrack* t,Int_t n,TString f)
118 {
119 // Recursively provide the info of all decay levels of this track
120  AliTrack* td; 
121  for (Int_t id=1; id<=t->GetNdecay(); id++)
122  {
123   td=t->GetDecayTrack(id);
124   if (td)
125   {
126    cout << "  ---Level " << n << " sec. track no. " << id << endl;
127    cout << " ";
128    td->Info(f); 
129
130    // Go for next decay level of this decay track recursively
131    Dump(td,n+1,f);
132   }
133   else
134   {
135    cout << " *AliTrack::Dump* Error : No decay track present." << endl; 
136   }
137  }
138
139 //////////////////////////////////////////////////////////////////////////
140 Double_t AliTrack::GetMomentum()
141 {
142 // Provide the value of the track 3-momentum
143  Ali3Vector p=Get3Vector();
144  return sqrt(p.Dot(p));
145 }
146 ///////////////////////////////////////////////////////////////////////////
147 Ali3Vector AliTrack::Get3Momentum()
148 {
149 // Provide the track 3-momentum
150  return (Ali3Vector)Get3Vector();
151 }
152 ///////////////////////////////////////////////////////////////////////////
153 Double_t AliTrack::GetMass()
154 {
155 // Provide the particle mass
156  return fM;
157 }
158 ///////////////////////////////////////////////////////////////////////////
159 Float_t AliTrack::GetCharge()
160 {
161 // Provide the particle charge
162  return fQ;
163 }
164 ///////////////////////////////////////////////////////////////////////////
165 Double_t AliTrack::GetEnergy()
166 {
167 // Provide the particle's energy
168  return GetScalar();
169 }
170 ///////////////////////////////////////////////////////////////////////////
171 void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
172 {
173 // Perform 2-body decay of current track
174 // m1     : mass of decay product 1
175 // m2     : mass of decay product 2
176 // thcms  : cms theta decay angle (in rad.) of m1
177 // phicms : cms phi decay angle (in rad.) of m1
178  
179  fNdec=2; // it's a 2-body decay
180  
181 // Compute the 4-momenta of the decay products in the cms
182 // Note : p2=p1=pnorm for a 2-body decay
183  Double_t e1=((fM*fM)+(m1*m1)-(m2*m2))/(2.*fM);
184  Double_t e2=((fM*fM)+(m2*m2)-(m1*m1))/(2.*fM);
185  Double_t pnorm=(e1*e1)-(m1*m1);
186  if (pnorm>0.)
187  {
188   pnorm=sqrt(pnorm);
189  }
190  else
191  {
192   pnorm=0;
193  }
194  
195  Double_t a[3];
196  a[0]=pnorm;
197  a[1]=thcms;
198  a[2]=phicms;
199  Ali3Vector p;
200  p.SetVector(a,"sph");
201
202  Ali4Vector pprim1;
203  pprim1.SetVector(e1,p);
204
205  Ali4Vector pprim2;
206  p*=-1;
207  pprim2.SetVector(e2,p);
208
209  // Determine boost parameters from the parent particle
210  Double_t E=GetScalar();
211  p=Get3Vector();
212  Ali4Vector pmu;
213  pmu.SetVector(E,p);
214
215  AliBoost q;
216  q.Set4Momentum(pmu);
217  
218  Ali4Vector p1=q.Inverse(pprim1); // Boost decay product 1
219  Ali4Vector p2=q.Inverse(pprim2); // Boost decay product 2
220  
221  // Enter the boosted data into the decay tracks array
222  if (fDecays)
223  {
224   fDecays->Delete();
225   delete fDecays;
226  }
227  fDecays=new TObjArray();
228
229  fDecays->Add(new AliTrack);
230  ((AliTrack*)fDecays->At(0))->Set4Momentum(p1);
231  fDecays->Add(new AliTrack);
232  ((AliTrack*)fDecays->At(1))->Set4Momentum(p2);
233  
234 // Set the mass values to m1 and m2 to omit roundoff errors
235  ((AliTrack*)fDecays->At(0))->SetMass(m1);
236  ((AliTrack*)fDecays->At(1))->SetMass(m2);
237 }
238 ///////////////////////////////////////////////////////////////////////////
239 Int_t AliTrack::GetNdecay()
240 {
241 // Provide the number of decay produced tracks
242  return fNdec;
243 }
244 ///////////////////////////////////////////////////////////////////////////
245 AliTrack* AliTrack::GetDecayTrack(Int_t j)
246 {
247 // Provide decay produced track number j
248 // Note : j=1 denotes the first decay track
249  if ((j >= 1) && (j <= fNdec))
250  {
251   return (AliTrack*)fDecays->At(j-1);
252  }
253  else
254  {
255   cout << " *AliTrack* decay track number : " << j << " out of range." << endl;
256   cout << " -- Decay track number 1 (if any) returned." << endl;
257   return (AliTrack*)fDecays->At(0);
258  }
259 }
260 ///////////////////////////////////////////////////////////////////////////