]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/AliJet.cxx
- Correct setting of FUDGEM parameter.
[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 ////////////////////////////////////////////////////////////////////////
31
32 AliJet::AliJet() 
33 {
34   //
35   // Constructor
36   //
37   fJets = new TClonesArray("TLorentzVector",1000);
38   fNInput=0;
39   fNJets=0;
40   fInJet=TArrayI();
41   fPtFromSignal=TArrayF();
42   fMultiplicities=TArrayI();
43
44
45 ////////////////////////////////////////////////////////////////////////
46
47 AliJet::~AliJet()
48 {
49   // destructor
50   if (fJets) {
51     fJets->Delete();
52     delete fJets;
53   }
54 }
55
56 ////////////////////////////////////////////////////////////////////////
57
58 Bool_t AliJet::OutOfRange(Int_t i, const char *s) const
59 {
60   // checks if i is a valid index. s= name of calling method
61   if (i >= fNJets || i < 0) {
62     cout << s << " Index " << i << " out of range" << endl;
63     return kTRUE;
64   }
65   return kFALSE;
66 }
67
68 ////////////////////////////////////////////////////////////////////////
69
70 TLorentzVector* AliJet::GetJet(Int_t i)
71 {
72   // returns i-jet
73   if (OutOfRange(i, "AliJet::GetJet:")) return 0;
74
75   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
76   return lv; 
77 }
78
79 ////////////////////////////////////////////////////////////////////////
80
81 Int_t AliJet::GetMultiplicity(Int_t i)
82 {
83   // gets multiplicity of i-jet
84   if (OutOfRange(i, "AliJet::GetMultiplicity:")) return 0;
85   return fMultiplicities[i];
86 }
87
88 ////////////////////////////////////////////////////////////////////////
89
90 Double_t AliJet::GetPx(Int_t i)
91 {
92 // Get Px component of jet i
93   if (OutOfRange(i, "AliJet::GetPx:")) return -1e30;
94
95   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
96   return lv->Px();
97 }
98
99 ////////////////////////////////////////////////////////////////////////
100
101 Double_t AliJet::GetPy(Int_t i)
102 {
103 // Get Py component of jet i
104   if (OutOfRange(i, "AliJet::GetPy:")) return -1e30;
105
106   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
107   return lv->Py();
108 }
109
110 ////////////////////////////////////////////////////////////////////////
111
112 Double_t AliJet::GetPz(Int_t i)
113 {
114 // Get Pz component of jet i
115   if (OutOfRange(i, "AliJet::GetPz:")) return -1e30;
116
117   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
118   return lv->Pz();
119 }
120
121 ////////////////////////////////////////////////////////////////////////
122
123 Double_t AliJet::GetP(Int_t i)
124 {
125 // Get momentum of jet i
126   if (OutOfRange(i, "AliJet::GetP:")) return -1e30;
127
128   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
129   return lv->P();
130 }
131
132 ////////////////////////////////////////////////////////////////////////
133
134 Double_t AliJet::GetE(Int_t i)
135 {
136 // Get energy of jet i
137   if (OutOfRange(i, "AliJet::GetE:")) return -1e30;
138
139   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
140   return lv->E();
141 }
142
143 ////////////////////////////////////////////////////////////////////////
144
145 Double_t AliJet::GetPt(Int_t i)
146 {
147 // Get transverse momentum of jet i
148   if (OutOfRange(i, "AliJet::GetPt:")) return -1e30;
149
150   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
151   return lv->Pt();
152 }
153
154 ////////////////////////////////////////////////////////////////////////
155
156 Double_t AliJet::GetEta(Int_t i)
157 {
158 // Get eta of jet i
159   if (OutOfRange(i, "AliJet::GetEta:")) return -1e30;
160
161   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
162   return lv->Eta();
163 }
164
165 ////////////////////////////////////////////////////////////////////////
166
167 Double_t AliJet::GetPhi(Int_t i)
168 {
169 // Get phi of jet i
170   if (OutOfRange(i, "AliJet::GetPhi:")) return -1e30;
171
172   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
173   return ( (lv->Phi() < 0) ? (lv->Phi()) + 2. * TMath::Pi() : lv->Phi());
174 }
175
176 ////////////////////////////////////////////////////////////////////////
177
178 Double_t AliJet::GetTheta(Int_t i)
179 {
180 // Get theta of jet i
181   if (OutOfRange(i, "AliJet::GetTheta:")) return -1e30;
182
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
194   TLorentzVector *lv = (TLorentzVector*) fJets->At(i);
195   return lv->M();
196 }
197
198 ////////////////////////////////////////////////////////////////////////
199  
200
201 void AliJet::AddJet(Double_t px, Double_t py, Double_t pz, Double_t e)
202 {
203 // Add new jet to the list
204   new ((*fJets)[fNJets++]) TLorentzVector(px,py,pz,e);
205 }
206
207 ////////////////////////////////////////////////////////////////////////
208
209 void AliJet::SetInJet(Int_t* j)
210 {
211   // set information of which input object belongs
212   // to each jet. filled in by AliJetFinder
213   if (fNInput>0) fInJet.Set(fNInput, j);
214 }
215
216 ////////////////////////////////////////////////////////////////////////
217
218 void AliJet::SetPtFromSignal(Float_t* p)
219 {
220   // set information of percentage of pt of jets
221   // coming from signal (ie Pythia)
222   if (fNJets>0) fPtFromSignal.Set(fNJets, p);
223 }
224
225 ////////////////////////////////////////////////////////////////////////
226
227 void AliJet::SetMultiplicities(Int_t* m)
228 {
229   // set information of jet multiplicities
230   // filled in by AliJetFinder
231   if (fNJets>0) fMultiplicities.Set(fNJets, m);
232 }
233
234 ////////////////////////////////////////////////////////////////////////
235
236 void AliJet::ClearJets(Option_t *option)
237 {
238   // reset all values
239   fJets->Clear(option);
240   fNInput=0;
241   fNJets=0;
242   fMultiplicities.Set(0);
243   fInJet.Set(0); 
244 }
245
246 ////////////////////////////////////////////////////////////////////////
247
248 void AliJet::PrintJets()
249 {
250 // Print jet information
251   if (fNJets == 0) {
252     cout << " AliJet::PrintJets: There are no jets in this event " << endl;
253     return;
254   }
255   cout << " AliJet::PrintJets: There are " << fNJets
256        << " jets in this event" << endl;
257   for(Int_t i=0;i<fNJets;i++) {
258     cout << "   Jet " << i << " (px,py,pz,en)=(" << GetPx(i)
259          << "," << GetPy(i)
260          << "," << GetPz(i)
261          << "," << GetE(i) 
262          << ")" << endl;
263     cout << "         (pt,eta,phi)=(" << GetPt(i)
264          << "," << GetEta(i)
265          << "," << GetPhi(i) << ")" << endl;
266     cout << "         # of tracks =" << GetMultiplicity(i) << endl;
267   }
268 }