]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RALICE/AliJet.cxx
14-jun-2001 NvE Memberfunction GetRapidity() introduced for AliTrack and AliJet
[u/mrichter/AliRoot.git] / RALICE / AliJet.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
f531a546 16// $Id$
4c039060 17
959fbac5 18///////////////////////////////////////////////////////////////////////////
19// Class AliJet
20// Creation and investigation of a jet of particle tracks.
21// An AliJet can be constructed by adding AliTracks.
22//
23// Coding example to make 2 jets j1 and j2.
24// ----------------------------------------
25// j1 contains the AliTracks 1 and 2
26// j2 contains the AliTracks 3 and 4
27//
28// AliTrack t1,t2,t3,t4;
29// ...
30// ... // code to fill the AliTrack data
31// ...
32// AliJet j1(5);
33// AliJet j2(12);
f531a546 34// j1.AddTrack(t1);
35// j1.AddTrack(t2);
36// j2.AddTrack(t3);
37// j2.AddTrack(t4);
959fbac5 38//
39// j1.Info();
40// j2.Info("sph");
41//
42// Float_t e1=j1.GetEnergy();
43// Float_t pnorm=j1->GetMomentum();
44// Ali3Vector p=j1->Get3Momentum();
45// Float_t m=j1.GetInvmass();
46// Int_t ntk=j1.GetNtracks();
47// AliTrack* tj=j1.GetTrack(1);
48//
49// Note : All quantities are in GeV, GeV/c or GeV/c**2
50//
51//--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht
f531a546 52//- Modified: NvE $Date$ UU-SAP Utrecht
959fbac5 53///////////////////////////////////////////////////////////////////////////
54
d88f97cc 55#include "AliJet.h"
56
57ClassImp(AliJet) // Class implementation to enable ROOT I/O
58
59AliJet::AliJet()
60{
61// Default constructor
62// All variables initialised to 0
63// Initial maximum number of tracks is set to the default value
64 fTracks=0;
65 fNtinit=0;
66 Reset();
67 SetNtinit();
68}
69///////////////////////////////////////////////////////////////////////////
70AliJet::AliJet(Int_t n)
71{
72// Create a jet to hold initially a maximum of n tracks
73// All variables initialised to 0
74 fTracks=0;
75 fNtinit=0;
76 Reset();
77 if (n > 0)
78 {
79 SetNtinit(n);
80 }
81 else
82 {
83 cout << endl;
84 cout << " *AliJet* Initial max. number of tracks entered : " << n << endl;
85 cout << " This is invalid. Default initial maximum will be used." << endl;
86 cout << endl;
87 SetNtinit();
88 }
89}
90///////////////////////////////////////////////////////////////////////////
91AliJet::~AliJet()
92{
93// Default destructor
94 if (fTracks) delete fTracks;
95 fTracks=0;
96}
97///////////////////////////////////////////////////////////////////////////
98void AliJet::SetNtinit(Int_t n)
99{
100// Set the initial maximum number of tracks for this jet
101 fNtinit=n;
102 fNtmax=n;
103 if (fTracks) delete fTracks;
104 fTracks=new TObjArray(fNtmax);
105}
106///////////////////////////////////////////////////////////////////////////
107void AliJet::Reset()
108{
109// Reset all variables to 0
110// The max. number of tracks is set to the initial value again
111 fNtrk=0;
112 fQ=0;
113 Double_t a[4]={0,0,0,0};
114 SetVector(a,"sph");
115 if (fNtinit > 0) SetNtinit(fNtinit);
116}
117///////////////////////////////////////////////////////////////////////////
f531a546 118void AliJet::AddTrack(AliTrack& t)
d88f97cc 119{
120// Add a track to the jet
121// In case the maximum number of tracks has been reached
122// space will be extended to hold an additional amount of tracks as
123// was initially reserved
124 if (fNtrk == fNtmax) // Check if maximum track number is reached
125 {
126 fNtmax+=fNtinit;
127 fTracks->Expand(fNtmax);
128 }
129
130 // Add the track to this jet
131 fNtrk++;
132 fTracks->Add(&t);
133 (*this)+=(Ali4Vector&)t;
134 fQ+=t.GetCharge();
135}
136///////////////////////////////////////////////////////////////////////////
137void AliJet::Info(TString f)
138{
139// Provide jet information within the coordinate frame f
140 cout << " *AliJet::Info* Invmass : " << GetInvmass() << " Charge : " << fQ
141 << " Momentum : " << GetMomentum() << " Ntracks : " << fNtrk << endl;
142 cout << " ";
143 Ali4Vector::Info(f);
144}
145///////////////////////////////////////////////////////////////////////////
146void AliJet::List(TString f)
147{
148// Provide jet and primary track information within the coordinate frame f
149
150 Info(f); // Information of the current jet
151
152 // The tracks of this jet
153 AliTrack* t;
154 for (Int_t it=1; it<=fNtrk; it++)
155 {
156 t=GetTrack(it);
157 if (t)
158 {
159 cout << " ---Track no. " << it << endl;
160 cout << " ";
161 t->Info(f);
162 }
163 else
164 {
165 cout << " *AliJet::List* Error : No track present." << endl;
166 }
167 }
168}
169///////////////////////////////////////////////////////////////////////////
170void AliJet::ListAll(TString f)
171{
172// Provide jet and prim.+sec. track information within the coordinate frame f
173
174 Info(f); // Information of the current jet
175
176 // The tracks of this jet
177 AliTrack* t;
178 for (Int_t it=1; it<=fNtrk; it++)
179 {
180 t=GetTrack(it);
181 if (t)
182 {
183 cout << " ---Track no. " << it << endl;
184 cout << " ";
185 t->ListAll(f);
186 }
187 else
188 {
189 cout << " *AliJet::List* Error : No track present." << endl;
190 }
191 }
192}
193///////////////////////////////////////////////////////////////////////////
194Int_t AliJet::GetNtracks()
195{
196// Return the current number of tracks of this jet
197 return fNtrk;
198}
199///////////////////////////////////////////////////////////////////////////
200Double_t AliJet::GetEnergy()
201{
202// Return the total energy of the jet
203 return GetScalar();
204}
205///////////////////////////////////////////////////////////////////////////
206Double_t AliJet::GetMomentum()
207{
208// Return the value of the total jet 3-momentum
d071d629 209// The error can be obtained by invoking GetResultError() after
210// invokation of GetMomentum().
211 Double_t norm=fV.GetNorm();
212 fDresult=fV.GetResultError();
213 return norm;
d88f97cc 214}
215///////////////////////////////////////////////////////////////////////////
216Ali3Vector AliJet::Get3Momentum()
217{
218// Return the the total jet 3-momentum
219 Ali3Vector p=Get3Vector();
220 return p;
221}
222///////////////////////////////////////////////////////////////////////////
223Double_t AliJet::GetInvmass()
224{
225// Return the invariant mass of the jet
226 Double_t m2=Dot(*this);
227 if (m2>0)
228 {
229 return sqrt(m2);
230 }
231 else
232 {
233 return 0;
234 }
235}
236///////////////////////////////////////////////////////////////////////////
237Float_t AliJet::GetCharge()
238{
239// Return the total charge of the jet
240 return fQ;
241}
242///////////////////////////////////////////////////////////////////////////
243AliTrack* AliJet::GetTrack(Int_t i)
244{
245// Return the i-th track of this jet
246 return (AliTrack*)fTracks->At(i-1);
247}
248///////////////////////////////////////////////////////////////////////////
d071d629 249Double_t AliJet::GetPt()
250{
251// Provide trans. momentum value w.r.t. z-axis.
252// The error on the value can be obtained by GetResultError()
253// after invokation of GetPt().
254 Ali3Vector v;
255 v=GetVecTrans();
256 Double_t norm=v.GetNorm();
257 fDresult=v.GetResultError();
258
259 return norm;
260}
261///////////////////////////////////////////////////////////////////////////
262Double_t AliJet::GetPl()
263{
264// Provide long. momentum value w.r.t. z-axis.
8adaf597 265// Note : the returned value can also be negative.
d071d629 266// The error on the value can be obtained by GetResultError()
267// after invokation of GetPl().
268 Ali3Vector v;
269 v=GetVecLong();
8adaf597 270
271 Double_t pl=v.GetNorm();
d071d629 272 fDresult=v.GetResultError();
273
8adaf597 274 Double_t a[3];
275 v.GetVector(a,"sph");
276 if (cos(a[1])<0) pl=-pl;
277
278 return pl;
d071d629 279}
280///////////////////////////////////////////////////////////////////////////
281Double_t AliJet::GetEt()
282{
283// Provide trans. energy value w.r.t. z-axis.
284// The error on the value can be obtained by GetResultError()
285// after invokation of GetEt().
286 Double_t et=GetScaTrans();
287
288 return et;
289}
290///////////////////////////////////////////////////////////////////////////
291Double_t AliJet::GetEl()
292{
293// Provide long. energy value w.r.t. z-axis.
8adaf597 294// Note : the returned value can also be negative.
d071d629 295// The error on the value can be obtained by GetResultError()
296// after invokation of GetEl().
297 Double_t el=GetScaLong();
298
299 return el;
300}
301///////////////////////////////////////////////////////////////////////////
302Double_t AliJet::GetMt()
303{
304// Provide transverse mass value w.r.t. z-axis.
305// The error on the value can be obtained by GetResultError()
306// after invokation of GetMt().
307 Double_t pt=GetPt();
308 Double_t dpt=GetResultError();
309 Double_t m=GetInvmass();
310 Double_t dm=GetResultError();
311
312 Double_t mt=sqrt(pt*pt+m*m);
313 Double_t dmt2=0;
314 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
315
316 fDresult=sqrt(dmt2);
317 return mt;
318}
319///////////////////////////////////////////////////////////////////////////
8adaf597 320Double_t AliJet::GetRapidity()
321{
322// Provide rapidity value w.r.t. z-axis.
323// The error on the value can be obtained by GetResultError()
324// after invokation of GetRapidity().
325// Note : Also GetPseudoRapidity() is available since this class is
326// derived from Ali4Vector.
327 Double_t e=GetEnergy();
328 Double_t de=GetResultError();
329 Double_t pl=GetPl();
330 Double_t dpl=GetResultError();
331 Double_t sum=e+pl;
332 Double_t dif=e-pl;
333
334 Double_t y=9999,dy2=0;
335 if (sum && dif) y=0.5*log(sum/dif);
336
337 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
338
339 fDresult=sqrt(dy2);
340 return y;
341}
342///////////////////////////////////////////////////////////////////////////