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