]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RALICE/AliJet.cxx
27-may-2001 NvE New class AliEvent introduced and RALICELinkDef.h & co. updated accor...
[u/mrichter/AliRoot.git] / RALICE / AliJet.cxx
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 // $Id$
17
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);
34 // j1.AddTrack(t1);
35 // j1.AddTrack(t2);
36 // j2.AddTrack(t3);
37 // j2.AddTrack(t4);
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
52 //- Modified: NvE $Date$ UU-SAP Utrecht
53 ///////////////////////////////////////////////////////////////////////////
54
55 #include "AliJet.h"
56  
57 ClassImp(AliJet) // Class implementation to enable ROOT I/O
58  
59 AliJet::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 ///////////////////////////////////////////////////////////////////////////
70 AliJet::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 ///////////////////////////////////////////////////////////////////////////
91 AliJet::~AliJet()
92 {
93 // Default destructor
94  if (fTracks) delete fTracks;
95  fTracks=0;
96 }
97 ///////////////////////////////////////////////////////////////////////////
98 void 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 ///////////////////////////////////////////////////////////////////////////
107 void 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 ///////////////////////////////////////////////////////////////////////////
118 void AliJet::AddTrack(AliTrack& t)
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 ///////////////////////////////////////////////////////////////////////////
137 void 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 ///////////////////////////////////////////////////////////////////////////
146 void 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 ///////////////////////////////////////////////////////////////////////////
170 void 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 ///////////////////////////////////////////////////////////////////////////
194 Int_t AliJet::GetNtracks()
195 {
196 // Return the current number of tracks of this jet
197  return fNtrk;
198 }
199 ///////////////////////////////////////////////////////////////////////////
200 Double_t AliJet::GetEnergy()
201 {
202 // Return the total energy of the jet
203  return GetScalar();
204 }
205 ///////////////////////////////////////////////////////////////////////////
206 Double_t AliJet::GetMomentum()
207 {
208 // Return the value of the total jet 3-momentum
209  Ali3Vector p=Get3Vector();
210  Double_t p2=p.Dot(p);
211  return sqrt(p2);
212 }
213 ///////////////////////////////////////////////////////////////////////////
214 Ali3Vector AliJet::Get3Momentum()
215 {
216 // Return the the total jet 3-momentum
217  Ali3Vector p=Get3Vector();
218  return p;
219 }
220 ///////////////////////////////////////////////////////////////////////////
221 Double_t AliJet::GetInvmass()
222 {
223 // Return the invariant mass of the jet
224  Double_t m2=Dot(*this);
225  if (m2>0)
226  {
227   return sqrt(m2);
228  }
229  else
230  {
231   return 0;
232  }
233 }
234 ///////////////////////////////////////////////////////////////////////////
235 Float_t AliJet::GetCharge()
236 {
237 // Return the total charge of the jet
238  return fQ;
239 }
240 ///////////////////////////////////////////////////////////////////////////
241 AliTrack* AliJet::GetTrack(Int_t i)
242 {
243 // Return the i-th track of this jet
244  return (AliTrack*)fTracks->At(i-1);
245 }
246 ///////////////////////////////////////////////////////////////////////////