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