]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/AliJet.cxx
Modifications needed to do the following:
[u/mrichter/AliRoot.git] / JETAN / 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 //---------------------------------------------------------------------
17 // Jet class 
18 // Stores the output of a jet algorithm
19 // Author: jgcn@mda.cinvestav.mx
20 //---------------------------------------------------------------------
21  
22 #include <Riostream.h>
23 #include <TClonesArray.h>
24 #include <TLorentzVector.h>
25
26 #include "AliJet.h"
27 ClassImp(AliJet)
28
29
30 AliJet::AliJet() 
31 {
32   // Constructor
33   fJets = new TClonesArray("TLorentzVector",1000);
34   fNInput=0;
35   fNJets=0;
36   fEtAvg = 0;
37   fInJet=TArrayI();
38   fPtIn=TArrayF();
39   fEtaIn=TArrayF();
40   fPhiIn=TArrayF();
41   fPtFromSignal=TArrayF();
42   fMultiplicities=TArrayI();
43   fNCells=TArrayI();
44
45
46 ////////////////////////////////////////////////////////////////////////
47
48 AliJet::~AliJet()
49 {
50   // destructor
51   if (fJets) {
52     fJets->Delete();
53     delete fJets;
54   }
55 }
56
57 ////////////////////////////////////////////////////////////////////////
58
59 Bool_t AliJet::OutOfRange(Int_t i, const char *s) const
60 {
61   // checks if i is a valid index. s = name of calling method
62   if (i >= fNJets || i < 0) {
63     cout << s << " Index " << i << " out of range" << endl;
64     return kTRUE;
65   }
66   return kFALSE;
67 }
68
69 ////////////////////////////////////////////////////////////////////////
70
71 TLorentzVector* AliJet::GetJet(Int_t i)
72 {
73   // returns i-jet
74   if (OutOfRange(i, "AliJet::GetJet:")) return 0;
75   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
76   return lv; 
77 }
78
79 ////////////////////////////////////////////////////////////////////////
80
81 Int_t AliJet::GetMultiplicity(Int_t i) const
82 {
83   // gets multiplicity of i-jet
84   if (OutOfRange(i, "AliJet::GetMultiplicity:")) return 0;
85   return fMultiplicities[i];
86 }
87
88 ////////////////////////////////////////////////////////////////////////
89
90 Int_t AliJet::GetNCell(Int_t i) const
91 {
92   // gets number of cell of i-jet
93   if (OutOfRange(i, "AliJet::GetNCell:")) return 0;
94   return fNCells[i];
95 }
96
97 ////////////////////////////////////////////////////////////////////////
98
99 Double_t AliJet::GetPx(Int_t i)
100 {
101 // Get Px component of jet i
102   if (OutOfRange(i, "AliJet::GetPx:")) return -1e30;
103   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
104   return lv->Px();
105 }
106
107 ////////////////////////////////////////////////////////////////////////
108
109 Double_t AliJet::GetPy(Int_t i)
110 {
111 // Get Py component of jet i
112   if (OutOfRange(i, "AliJet::GetPy:")) return -1e30;
113   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
114   return lv->Py();
115 }
116
117 ////////////////////////////////////////////////////////////////////////
118
119 Double_t AliJet::GetPz(Int_t i)
120 {
121 // Get Pz component of jet i
122   if (OutOfRange(i, "AliJet::GetPz:")) return -1e30;
123   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
124   return lv->Pz();
125 }
126
127 ////////////////////////////////////////////////////////////////////////
128
129 Double_t AliJet::GetP(Int_t i)
130 {
131 // Get momentum of jet i
132   if (OutOfRange(i, "AliJet::GetP:")) return -1e30;
133   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
134   return lv->P();
135 }
136
137 ////////////////////////////////////////////////////////////////////////
138
139 Double_t AliJet::GetE(Int_t i)
140 {
141 // Get energy of jet i
142   if (OutOfRange(i, "AliJet::GetE:")) return -1e30;
143   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
144   return lv->E();
145 }
146
147 ////////////////////////////////////////////////////////////////////////
148
149 Double_t AliJet::GetPt(Int_t i)
150 {
151 // Get transverse momentum of jet i
152   if (OutOfRange(i, "AliJet::GetPt:")) return -1e30;
153   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
154   return lv->Pt();
155 }
156
157 ////////////////////////////////////////////////////////////////////////
158
159 Double_t AliJet::GetEta(Int_t i)
160 {
161 // Get eta of jet i
162   if (OutOfRange(i, "AliJet::GetEta:")) return -1e30;
163   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
164   return lv->Eta();
165 }
166
167 ////////////////////////////////////////////////////////////////////////
168
169 Double_t AliJet::GetPhi(Int_t i)
170 {
171 // Get phi of jet i
172   if (OutOfRange(i, "AliJet::GetPhi:")) return -1e30;
173   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
174   return ( (lv->Phi() < 0) ? (lv->Phi()) + 2. * TMath::Pi() : lv->Phi());
175 }
176
177 ////////////////////////////////////////////////////////////////////////
178
179 Double_t AliJet::GetTheta(Int_t i)
180 {
181 // Get theta of jet i
182   if (OutOfRange(i, "AliJet::GetTheta:")) return -1e30;
183   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
184   return lv->Theta();
185 }
186
187 ////////////////////////////////////////////////////////////////////////
188
189 Double_t AliJet::GetMass(Int_t i)
190 {
191 // Get invariant mass of jet i
192   if (OutOfRange(i, "AliJet::GetMass:")) return -1e30;
193   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
194   return lv->M();
195 }
196
197 ////////////////////////////////////////////////////////////////////////
198  
199
200 void AliJet::AddJet(Double_t px, Double_t py, Double_t pz, Double_t e)
201 {
202 // Add new jet to the list
203   new ((*fJets)[fNJets++]) TLorentzVector(px,py,pz,e);
204 }
205
206 ////////////////////////////////////////////////////////////////////////
207
208 void AliJet::SetInJet(Int_t* j)
209 {
210   // set information of which input object belongs
211   // to each jet. If zero, object was not assigned to
212   // a jet, if n,positive, it was assiged to jet n
213   // if n, negative, it is within cone of jet n, but
214   // it did not passed the user cuts. filled in by AliJetFinder
215
216   if (fNInput>0) fInJet.Set(fNInput, j);
217 }
218
219 ////////////////////////////////////////////////////////////////////////
220
221 void AliJet::SetEtaIn(Float_t* r)
222 {
223   if (fNInput>0) fEtaIn.Set(fNInput, r);
224 }
225
226 ////////////////////////////////////////////////////////////////////////
227
228 void AliJet::SetPtIn(Float_t* pt)
229 {
230   if (fNInput>0) fPtIn.Set(fNInput, pt);
231 }
232
233 ////////////////////////////////////////////////////////////////////////
234
235 void AliJet::SetPhiIn(Float_t* x)
236 {
237   if (fNInput>0) fPhiIn.Set(fNInput, x);
238 }
239
240 ////////////////////////////////////////////////////////////////////////
241
242 void AliJet::SetPtFromSignal(Float_t* p)
243 {
244   // set information of percentage of pt of jets
245   // coming from signal (ie Pythia)
246   if (fNJets>0) fPtFromSignal.Set(fNJets, p);
247 }
248
249 ////////////////////////////////////////////////////////////////////////
250
251 void AliJet::SetMultiplicities(Int_t* m)
252 {
253   // set information of jet multiplicities
254   // filled in by AliJetFinder
255   if (fNJets>0) fMultiplicities.Set(fNJets, m);
256 }
257
258 ////////////////////////////////////////////////////////////////////////
259
260 void AliJet::SetNCells(Int_t* n)
261 {
262   if (fNJets>0) fNCells.Set(fNJets, n);
263 }
264
265 ////////////////////////////////////////////////////////////////////////
266
267 void AliJet::ClearJets(Option_t *option)
268 {
269   // reset all values
270   fJets->Clear(option);
271   fNInput=0;
272   fNJets=0;
273   fMultiplicities.Set(0);
274   fInJet.Set(0); 
275   fPtFromSignal.Set(0);
276   fPhiIn.Set(0);
277   fEtaIn.Set(0);
278   fPtIn.Set(0);
279   fNCells.Set(0);
280 }
281
282 ////////////////////////////////////////////////////////////////////////
283
284 void AliJet::PrintJets()
285 {
286 // Print jet information
287   if (fNJets == 0) {
288     cout << " AliJet::PrintJets: There are no jets in this event " << endl;
289     return;
290   }
291   cout << " AliJet::PrintJets: There are " << fNJets
292        << " jets in this event" << endl;
293   for(Int_t i=0;i<fNJets;i++) {
294     cout << "   Jet " << i << " (px,py,pz,en)=(" << GetPx(i)
295          << "," << GetPy(i)
296          << "," << GetPz(i)
297          << "," << GetE(i) 
298          << ")" << endl;
299     cout << "         (pt,eta,phi)=(" << GetPt(i)
300          << "," << GetEta(i)
301          << "," << GetPhi(i) << ")" << endl;
302     cout << "         # of tracks =" << GetMultiplicity(i) << endl;
303   }
304 }