]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RALICE/AliJet.cxx
Added the entry for the IRST code checking utility
[u/mrichter/AliRoot.git] / RALICE / AliJet.cxx
1 #include "AliJet.h"
2  
3 ClassImp(AliJet) // Class implementation to enable ROOT I/O
4  
5 AliJet::AliJet()
6 {
7 // Default constructor
8 // All variables initialised to 0
9 // Initial maximum number of tracks is set to the default value
10  fTracks=0;
11  fNtinit=0;
12  Reset();
13  SetNtinit();
14 }
15 ///////////////////////////////////////////////////////////////////////////
16 AliJet::AliJet(Int_t n)
17 {
18 // Create a jet to hold initially a maximum of n tracks
19 // All variables initialised to 0
20  fTracks=0;
21  fNtinit=0;
22  Reset();
23  if (n > 0)
24  {
25   SetNtinit(n);
26  }
27  else
28  {
29   cout << endl;
30   cout << " *AliJet* Initial max. number of tracks entered : " << n << endl;
31   cout << " This is invalid. Default initial maximum will be used." << endl;
32   cout << endl;
33   SetNtinit();
34  }
35 }
36 ///////////////////////////////////////////////////////////////////////////
37 AliJet::~AliJet()
38 {
39 // Default destructor
40  if (fTracks) delete fTracks;
41  fTracks=0;
42 }
43 ///////////////////////////////////////////////////////////////////////////
44 void AliJet::SetNtinit(Int_t n)
45 {
46 // Set the initial maximum number of tracks for this jet
47  fNtinit=n;
48  fNtmax=n;
49  if (fTracks) delete fTracks;
50  fTracks=new TObjArray(fNtmax);
51 }
52 ///////////////////////////////////////////////////////////////////////////
53 void AliJet::Reset()
54 {
55 // Reset all variables to 0
56 // The max. number of tracks is set to the initial value again
57  fNtrk=0;
58  fQ=0;
59  Double_t a[4]={0,0,0,0};
60  SetVector(a,"sph");
61  if (fNtinit > 0) SetNtinit(fNtinit);
62 }
63 ///////////////////////////////////////////////////////////////////////////
64 void AliJet::Add(AliTrack& t)
65 {
66 // Add a track to the jet
67 // In case the maximum number of tracks has been reached
68 // space will be extended to hold an additional amount of tracks as
69 // was initially reserved
70  if (fNtrk == fNtmax) // Check if maximum track number is reached
71  {
72   fNtmax+=fNtinit;
73   fTracks->Expand(fNtmax);
74  }
75  
76  // Add the track to this jet
77  fNtrk++;
78  fTracks->Add(&t);
79  (*this)+=(Ali4Vector&)t;
80  fQ+=t.GetCharge();
81 }
82 ///////////////////////////////////////////////////////////////////////////
83 void AliJet::Info(TString f)
84 {
85 // Provide jet information within the coordinate frame f
86  cout << " *AliJet::Info* Invmass : " << GetInvmass() << " Charge : " << fQ
87       << " Momentum : " << GetMomentum() << " Ntracks : " << fNtrk << endl;
88  cout << " ";
89  Ali4Vector::Info(f); 
90
91 ///////////////////////////////////////////////////////////////////////////
92 void AliJet::List(TString f)
93 {
94 // Provide jet and primary track information within the coordinate frame f
95
96  Info(f); // Information of the current jet
97
98  // The tracks of this jet
99  AliTrack* t; 
100  for (Int_t it=1; it<=fNtrk; it++)
101  {
102   t=GetTrack(it);
103   if (t)
104   {
105    cout << "  ---Track no. " << it << endl;
106    cout << " ";
107    t->Info(f); 
108   }
109   else
110   {
111    cout << " *AliJet::List* Error : No track present." << endl; 
112   }
113  }
114
115 ///////////////////////////////////////////////////////////////////////////
116 void AliJet::ListAll(TString f)
117 {
118 // Provide jet and prim.+sec. track information within the coordinate frame f
119
120  Info(f); // Information of the current jet
121
122  // The tracks of this jet
123  AliTrack* t; 
124  for (Int_t it=1; it<=fNtrk; it++)
125  {
126   t=GetTrack(it);
127   if (t)
128   {
129    cout << "  ---Track no. " << it << endl;
130    cout << " ";
131    t->ListAll(f); 
132   }
133   else
134   {
135    cout << " *AliJet::List* Error : No track present." << endl; 
136   }
137  }
138
139 ///////////////////////////////////////////////////////////////////////////
140 Int_t AliJet::GetNtracks()
141 {
142 // Return the current number of tracks of this jet
143  return fNtrk;
144 }
145 ///////////////////////////////////////////////////////////////////////////
146 Double_t AliJet::GetEnergy()
147 {
148 // Return the total energy of the jet
149  return GetScalar();
150 }
151 ///////////////////////////////////////////////////////////////////////////
152 Double_t AliJet::GetMomentum()
153 {
154 // Return the value of the total jet 3-momentum
155  Ali3Vector p=Get3Vector();
156  Double_t p2=p.Dot(p);
157  return sqrt(p2);
158 }
159 ///////////////////////////////////////////////////////////////////////////
160 Ali3Vector AliJet::Get3Momentum()
161 {
162 // Return the the total jet 3-momentum
163  Ali3Vector p=Get3Vector();
164  return p;
165 }
166 ///////////////////////////////////////////////////////////////////////////
167 Double_t AliJet::GetInvmass()
168 {
169 // Return the invariant mass of the jet
170  Double_t m2=Dot(*this);
171  if (m2>0)
172  {
173   return sqrt(m2);
174  }
175  else
176  {
177   return 0;
178  }
179 }
180 ///////////////////////////////////////////////////////////////////////////
181 Float_t AliJet::GetCharge()
182 {
183 // Return the total charge of the jet
184  return fQ;
185 }
186 ///////////////////////////////////////////////////////////////////////////
187 AliTrack* AliJet::GetTrack(Int_t i)
188 {
189 // Return the i-th track of this jet
190  return (AliTrack*)fTracks->At(i-1);
191 }
192 ///////////////////////////////////////////////////////////////////////////