Added hard partons.
[u/mrichter/AliRoot.git] / JETAN / AliJetEventParticles.cxx
1 // $Id$
2
3 //__________________________________________________________
4 ///////////////////////////////////////////////////////////////////
5 //
6 // class AliJetEventParticles
7 //
8 // loizides@ikf.uni-frankfurt.de
9 //
10 ///////////////////////////////////////////////////////////////////
11
12 #include <Riostream.h>
13 #include <TClonesArray.h>
14 #include "AliJetParticle.h"
15 #include "AliJetEventParticles.h"
16
17 ClassImp(AliJetEventParticles)
18
19 AliJetEventParticles::AliJetEventParticles(Int_t size) :
20   fNParticles(0),
21   fParticles(new TClonesArray("AliJetParticle",size)),
22   fVertexX(0.),
23   fVertexY(0.),
24   fVertexZ(0.),
25   fTrials(0),
26   fNJets(0),
27   fNUQJets(0),
28   fXJet(-1),
29   fYJet(-1)
30 {
31   // Default Constructor
32   for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
33   for (Int_t i = 0; i < 10; i++) 
34     for (Int_t j = 0; j < 4; j++) {
35       fJets[j][i]=0;    // Trigger jets
36       fUQJets[j][i]=0;  // Unquenched trigger jets
37     }
38   for (Int_t i = 0; i < 5; i++){
39     fHard[i][0]=0;
40     fHard[i][1]=0;
41   }
42 }
43
44 AliJetEventParticles::AliJetEventParticles(const AliJetEventParticles& source) :
45   TObject(source), 
46   fNParticles(source.fNParticles),
47   fParticles(new TClonesArray("AliJetParticle",source.fNParticles)),
48   fVertexX(source.GetVertexX()),
49   fVertexY(source.GetVertexY()),
50   fVertexZ(source.GetVertexZ()),
51   fTrials(source.Trials()),
52   fNJets(source.NTriggerJets()),
53   fNUQJets(source.NUQTriggerJets()),
54   fXJet(source.GetXJet()),
55   fYJet(source.GetXJet())
56 {
57   //copy constructor
58   for(Int_t i =0; i<fNParticles; i++)
59     {
60       const AliJetParticle *kjp=(const AliJetParticle *)source.fParticles->At(i);
61       new((*fParticles)[i]) AliJetParticle(*(kjp));
62     }
63   for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
64   for (Int_t i = 0; i < 10; i++) 
65     for (Int_t j = 0; j < 4; j++) {
66       fJets[j][i]=0;    // Trigger jets
67       fUQJets[j][i]=0;  // Unquenched trigger jets
68     }
69   source.GetZQuench(fZquench);
70   for (Int_t i = 0; i < NTriggerJets(); i++){
71     source.TriggerJet(i,fJets[0][i],fJets[1][i],fJets[2][i],fJets[3][i]);
72   }
73   for (Int_t i = 0; i < NUQTriggerJets(); i++){
74     source.UQJet(i,fUQJets[0][i],fUQJets[1][i],fUQJets[2][i],fUQJets[3][i]);
75   }
76
77   source.Hard(0,fHard[0][0],fHard[1][0],fHard[2][0],fHard[3][0],fHard[4][0]);
78   source.Hard(1,fHard[0][1],fHard[1][1],fHard[2][1],fHard[3][1],fHard[4][1]);
79 }
80
81 AliJetEventParticles::~AliJetEventParticles()
82 {
83   //destructor   
84   Reset();
85   delete fParticles;
86 }
87
88 void  AliJetEventParticles::Reset(Int_t size)
89 {
90   //deletes all particles from the event
91   if(fParticles) fParticles->Clear();
92   if(size>=0) fParticles->Expand(size);
93   fNParticles = 0;
94
95   fVertexX=0.;
96   fVertexY=0.;
97   fVertexZ=0.;
98   fTrials=0;
99   fNJets=0;
100   fNUQJets=0;
101   fXJet=-1;
102   fYJet=-1;
103   for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
104   for (Int_t i = 0; i < 10; i++) 
105     for (Int_t j = 0; j < 4; j++) {
106       fJets[j][i]=0;    // Trigger jets
107       fUQJets[j][i]=0;  // Unquenched trigger jets
108     }
109   for (Int_t i = 0; i < 5; i++){
110     fHard[i][0]=0;
111     fHard[i][1]=0;
112   }
113
114
115 void AliJetEventParticles::AddParticle(AliJetParticle* part)
116 {
117   //Adds new particle to the event
118   fParticles->AddAt(part,fNParticles++);
119 }
120
121 void AliJetEventParticles::AddParticle(const AliJetParticle* part)
122 {
123   //Adds new particle to the event
124   new((*fParticles)[fNParticles++]) AliJetParticle(*part);
125 }
126
127 void AliJetEventParticles::AddParticle(const TParticle* part,Int_t idx, Int_t l)
128 {
129   //Adds new particle to the event
130   new((*fParticles)[fNParticles++]) AliJetParticle(part,idx,l);
131 }
132
133 void AliJetEventParticles::AddParticle(Float_t px, Float_t py, Float_t pz, 
134                               Float_t etot, Int_t idx, Int_t l)
135 {
136   //Adds new particle to the event
137   new((*fParticles)[fNParticles++]) AliJetParticle(px,py,pz,etot,idx,l); 
138 }
139
140 void AliJetEventParticles::AddParticle(Float_t px, Float_t py, Float_t pz, Float_t etot, Int_t idx, Int_t l,
141                               Float_t pt, Float_t phi, Float_t eta)
142 {
143   //Adds new particle to the event
144   new((*fParticles)[fNParticles++]) AliJetParticle(px,py,pz,etot,idx,l,pt,phi,eta); 
145 }
146
147 const AliJetParticle* AliJetEventParticles::GetParticleSafely(Int_t n)
148 {
149   //returns nth particle with range check
150   if( (n<0) || (fNParticles<=n) ) return 0;
151   return (const AliJetParticle*)fParticles->At(n);
152 }
153
154 void AliJetEventParticles::AddJet(Float_t px, Float_t py, Float_t pz, Float_t e)
155 {
156   //
157   //  Add a jet 
158   //
159   if (fNJets < 10) {
160     fJets[0][fNJets] = px;
161     fJets[1][fNJets] = py;
162     fJets[2][fNJets] = pz;
163     fJets[3][fNJets] = e;
164     fNJets++;
165   } else {
166     printf("\nWarning: More than 10 jets triggered !!\n");
167   }
168 }
169
170 void AliJetEventParticles::AddJet(Float_t p[4])
171 {
172   //
173   //  Add a jet 
174   //
175   if (fNJets < 10) {
176     fJets[0][fNJets] = p[0];
177     fJets[1][fNJets] = p[1];
178     fJets[2][fNJets] = p[2];
179     fJets[3][fNJets] = p[3];
180     fNJets++;
181   } else {
182     printf("\nWarning: More than 10 jets triggered !!\n");
183   }
184 }
185
186 void AliJetEventParticles::AddUQJet(Float_t px, Float_t py, Float_t pz, Float_t e)
187 {
188   //
189   //  Add a jet 
190   //
191   if (fNUQJets < 10) {
192     fUQJets[0][fNUQJets] = px;
193     fUQJets[1][fNUQJets] = py;
194     fUQJets[2][fNUQJets] = pz;
195     fUQJets[3][fNUQJets] = e;
196     fNUQJets++;
197   } else {
198     printf("\nWarning: More than 10 jets triggered !!\n");
199   }
200 }
201
202 void AliJetEventParticles::AddUQJet(Float_t p[4])
203 {
204   //
205   //  Add a jet 
206   //
207   if (fNUQJets < 10) {
208     fUQJets[0][fNUQJets] = p[0];
209     fUQJets[1][fNUQJets] = p[1];
210     fUQJets[2][fNUQJets] = p[2];
211     fUQJets[3][fNUQJets] = p[3];
212     fNUQJets++;
213   } else {
214     printf("\nWarning: More than 10 jets triggered !!\n");
215   }
216 }
217
218 void AliJetEventParticles::AddHard(Int_t i,Float_t px, Float_t py, Float_t pz, Float_t e, Float_t type)
219 {
220   //
221   //  Add a had parton
222   //
223   if (i < 2) {
224     fHard[0][i] = px;
225     fHard[1][i] = py;
226     fHard[2][i] = pz;
227     fHard[3][i] = e;
228     fHard[4][i] = type;
229   } else {
230     printf("\nWarning: More than 2 partons !!\n");
231   }
232 }
233
234 void AliJetEventParticles::SetZQuench(Double_t z[4])
235 {
236   //
237   // Set quenching fraction
238   //
239   for (Int_t i = 0; i < 4; i++) fZquench[i] = z[i];
240 }
241
242 void AliJetEventParticles::GetZQuench(Double_t z[4]) const
243 {
244   //
245   // Get quenching fraction
246   //
247   for (Int_t i = 0; i < 4; i++) z[i] = fZquench[i];
248 }
249
250 void AliJetEventParticles::TriggerJet(Int_t i, Float_t p[4]) const
251 {
252   //
253   // Give back jet #i
254   //
255   if (i >= fNJets) {
256     printf("\nWarning: TriggerJet, index out of Range!!\n");
257   } else {
258     p[0] = fJets[0][i];
259     p[1] = fJets[1][i];
260     p[2] = fJets[2][i];
261     p[3] = fJets[3][i];
262   }
263 }
264
265 void AliJetEventParticles::TriggerJet(Int_t i, Float_t &p1, Float_t &p2, Float_t &p3, Float_t &E) const
266 {
267   //
268   // Give back jet #i
269   //
270   if (i >= fNJets) {
271     printf("\nWarning: TriggerJet, index out of Range!!\n");
272   } else {
273     p1   = fJets[0][i];
274     p2   = fJets[1][i];
275     p3   = fJets[2][i];
276     E    = fJets[3][i];
277   }
278 }
279
280 void AliJetEventParticles::UQJet(Int_t i, Float_t p[4]) const
281 {
282   //
283   // Give back jet #i
284   //
285   if (i >= fNUQJets) {
286     printf("\nWarning: Unquenched Jets, index out of Range!!\n");
287   } else {
288     p[0] = fUQJets[0][i];
289     p[1] = fUQJets[1][i];
290     p[2] = fUQJets[2][i];
291     p[3] = fUQJets[3][i];
292   }
293 }
294
295 void AliJetEventParticles::UQJet(Int_t i, Float_t &p1, Float_t &p2, Float_t &p3, Float_t &E) const
296 {
297   //
298   // Give back jet #i
299   //
300   if (i >= fNUQJets) {
301     printf("\nWarning: Unquenched Jets, index out of Range!!\n");
302   } else {
303     p1   = fUQJets[0][i];
304     p2   = fUQJets[1][i];
305     p3   = fUQJets[2][i];
306     E    = fUQJets[3][i];
307   }
308 }
309
310 void AliJetEventParticles::Hard(Int_t i, Float_t &p1, Float_t &p2, Float_t &p3, Float_t &E, Float_t &type) const
311 {
312   //
313   // Give back jet #i
314   //
315   if (i >= 2) {
316     printf("\nWarning: Hard partons, index out of Range!!\n");
317   } else {
318     p1   = fHard[0][i];
319     p2   = fHard[1][i];
320     p3   = fHard[2][i];
321     E    = fHard[3][i];
322     type = fHard[4][i];
323   }
324 }
325
326 void AliJetEventParticles::SetXYJet(Double_t x, Double_t y)
327 {
328   //
329   //  Add jet production point
330   //
331   fXJet = x; 
332   fYJet = y; 
333 }
334
335 void AliJetEventParticles::Print(Option_t* /*t*/) const
336 {
337   cout << "--- AliJetEventParticles ---" << endl;
338   if(fHeader.Length()) cout << fHeader.Data() << endl;
339   cout << "Particles in Event: " << fNParticles << endl;
340   if(fNUQJets){
341     cout << "Unquenched Jets: " << fNUQJets << endl;
342     for(Int_t i = 0; i<fNUQJets; i++){
343       Float_t x=fUQJets[0][i];
344       Float_t y=fUQJets[1][i];
345       Float_t z=fUQJets[2][i];
346       Float_t e=fUQJets[3][i];
347       Float_t ptj=TMath::Sqrt(x*x+y*y);
348       Float_t thj=TMath::ATan2(ptj,z);
349       Float_t etaj=-TMath::Log(TMath::Tan(thj/2));
350       Float_t phj=TMath::Pi()+TMath::ATan2(-y,-x);
351       Float_t et=e*TMath::Sin(thj);
352       cout << i << " " << et << " " << etaj << " " << phj << endl;
353     }
354   }
355   if(fNJets){
356     cout << "Triggered Jets: " << fNJets << endl;
357     for(Int_t i = 0; i<fNJets; i++){
358       Float_t x=fJets[0][i];
359       Float_t y=fJets[1][i];
360       Float_t z=fJets[2][i];
361       Float_t e=fJets[3][i];
362       Float_t ptj=TMath::Sqrt(x*x+y*y);
363       Float_t thj=TMath::ATan2(ptj,z);
364       Float_t etaj=-TMath::Log(TMath::Tan(thj/2));
365       Float_t phj=TMath::Pi()+TMath::ATan2(-y,-x);
366       Float_t et=e*TMath::Sin(thj);
367       cout << i << " " << et << " " << etaj << " " << phj << endl;
368     }
369   }
370
371 }