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