]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/AliJetEventParticles.cxx
Removing extra namespace (alpha)
[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   TObject(), 
21   fHeader(),
22   fNParticles(0),
23   fParticles(new TClonesArray("AliJetParticle",size)),
24   fVertexX(0.),
25   fVertexY(0.),
26   fVertexZ(0.),
27   fTrials(0),
28   fNJets(0),
29   fNUQJets(0),
30   fXJet(-1),
31   fYJet(-1),
32   fImpact(0.),
33   fNHardScatters(0),
34   fNwNwColl(0),
35   fEventNr(0)
36 {
37   // Default Constructor
38   for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
39   for (Int_t i = 0; i < 10; i++) 
40     for (Int_t j = 0; j < 4; j++) {
41       fJets[j][i]=0;    // Trigger jets
42       fUQJets[j][i]=0;  // Unquenched trigger jets
43     }
44   for (Int_t i = 0; i < 5; i++){
45     fHard[i][0]=0;
46     fHard[i][1]=0;
47   }
48 }
49
50 AliJetEventParticles::AliJetEventParticles(const AliJetEventParticles& source) :
51   TObject(source), 
52   fHeader(),
53   fNParticles(source.fNParticles),
54   fParticles(new TClonesArray("AliJetParticle",source.fNParticles)),
55   fVertexX(source.GetVertexX()),
56   fVertexY(source.GetVertexY()),
57   fVertexZ(source.GetVertexZ()),
58   fTrials(source.Trials()),
59   fNJets(source.NTriggerJets()),
60   fNUQJets(source.NUQTriggerJets()),
61   fXJet(source.GetXJet()),
62   fYJet(source.GetXJet()),
63   fImpact(source.GetImpact()),
64   fNHardScatters(source.GetNhard()),
65   fNwNwColl(source.GetNpart()),
66   fEventNr(source.GetEventNr())
67 {
68   //copy constructor
69   for(Int_t i =0; i<fNParticles; i++)
70     {
71       const AliJetParticle *kjp=(const AliJetParticle *)source.fParticles->At(i);
72       new((*fParticles)[i]) AliJetParticle(*(kjp));
73     }
74   for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
75   for (Int_t i = 0; i < 10; i++) 
76     for (Int_t j = 0; j < 4; j++) {
77       fJets[j][i]=0;    // Trigger jets
78       fUQJets[j][i]=0;  // Unquenched trigger jets
79     }
80   source.GetZQuench(fZquench);
81   for (Int_t i = 0; i < NTriggerJets(); i++){
82     source.TriggerJet(i,fJets[0][i],fJets[1][i],fJets[2][i],fJets[3][i]);
83   }
84   for (Int_t i = 0; i < NUQTriggerJets(); i++){
85     source.UQJet(i,fUQJets[0][i],fUQJets[1][i],fUQJets[2][i],fUQJets[3][i]);
86   }
87
88   source.Hard(0,fHard[0][0],fHard[1][0],fHard[2][0],fHard[3][0],fHard[4][0]);
89   source.Hard(1,fHard[0][1],fHard[1][1],fHard[2][1],fHard[3][1],fHard[4][1]);
90 }
91
92 void AliJetEventParticles::Set(const AliJetEventParticles& source)
93 {
94   source.Copy(*this); 
95   fHeader=source.GetHeader();
96   fNParticles=source.fNParticles;
97   if(fParticles) delete fParticles;
98   fParticles=new TClonesArray("AliJetParticle",source.GetParticles()->GetEntries());
99   fVertexX=source.GetVertexX();
100   fVertexY=source.GetVertexY();
101   fVertexZ=source.GetVertexZ();
102   fTrials=source.Trials();
103   fNJets=source.NTriggerJets();
104   fNUQJets=source.NUQTriggerJets();
105   fXJet=source.GetXJet();
106   fYJet=source.GetXJet();
107   fImpact=source.GetImpact();
108   fNHardScatters=source.GetNhard();
109   fNwNwColl=source.GetNpart();
110   fEventNr=source.GetEventNr();
111
112   for(Int_t i =0; i<source.GetParticles()->GetEntries(); i++){
113     const AliJetParticle *kjp=(const AliJetParticle *)source.fParticles->At(i);
114     new((*fParticles)[i]) AliJetParticle(*(kjp));
115   }
116   for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
117   for (Int_t i = 0; i < 10; i++) 
118     for (Int_t j = 0; j < 4; j++) {
119       fJets[j][i]=0;    // Trigger jets
120       fUQJets[j][i]=0;  // Unquenched trigger jets
121     }
122   source.GetZQuench(fZquench);
123   for (Int_t i = 0; i < NTriggerJets(); i++){
124     source.TriggerJet(i,fJets[0][i],fJets[1][i],fJets[2][i],fJets[3][i]);
125   }
126   for (Int_t i = 0; i < NUQTriggerJets(); i++){
127     source.UQJet(i,fUQJets[0][i],fUQJets[1][i],fUQJets[2][i],fUQJets[3][i]);
128   }
129
130   source.Hard(0,fHard[0][0],fHard[1][0],fHard[2][0],fHard[3][0],fHard[4][0]);
131   source.Hard(1,fHard[0][1],fHard[1][1],fHard[2][1],fHard[3][1],fHard[4][1]);
132 }
133
134 AliJetEventParticles::~AliJetEventParticles()
135 {
136   //destructor   
137   Reset();
138   delete fParticles;
139 }
140
141 void  AliJetEventParticles::Reset(Int_t size)
142 {
143   fHeader="";
144   //deletes all particles from the event
145   if(fParticles) fParticles->Clear();
146   if(size>=0) fParticles->Expand(size);
147   fNParticles = 0;
148
149   fVertexX=0.;
150   fVertexY=0.;
151   fVertexZ=0.;
152   fTrials=0;
153   fNJets=0;
154   fNUQJets=0;
155   fXJet=-1;
156   fYJet=-1;
157   fImpact=0.;
158   fNHardScatters=0;
159   fNwNwColl=0;
160   fEventNr=0;
161   for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
162   for (Int_t i = 0; i < 10; i++) 
163     for (Int_t j = 0; j < 4; j++) {
164       fJets[j][i]=0;    // Trigger jets
165       fUQJets[j][i]=0;  // Unquenched trigger jets
166     }
167   for (Int_t i = 0; i < 5; i++){
168     fHard[i][0]=0;
169     fHard[i][1]=0;
170   }
171
172
173 void AliJetEventParticles::AddSignal(const AliJetEventParticles& source)
174 { //mark signal particles and add them to TClonesArray
175   //note that fNParticles still keeps only background particles
176
177   Int_t nSignalParts=source.GetNParticles();
178   for(Int_t i=0; i<nSignalParts; i++)
179     {
180       const AliJetParticle *kjp=source.GetParticle(i);
181
182       AliJetParticle *ap=new((*fParticles)[fNParticles+i]) AliJetParticle(*(kjp));
183       ap->SetType(-123); //mark pythia particle
184     }
185   for(Int_t i=nSignalParts+fNParticles;i<fParticles->GetEntriesFast();i++)
186     fParticles->RemoveAt(i);
187   //cout << fParticles->GetEntries() << " " << fNParticles << " " << nSignalParts << endl;
188
189   /* should we transform the vertex???
190   fVertexX=source.GetVertexX();
191   fVertexY=source.GetVertexY();
192   fVertexZ=source.GetVertexZ();
193   */
194   fTrials=source.Trials();
195   fNJets=source.NTriggerJets();
196   fNUQJets=source.NUQTriggerJets();
197   fXJet=source.GetXJet();
198   fYJet=source.GetXJet();
199   fEventNr=source.GetEventNr();
200
201   for (Int_t i = 0; i < 4; i++) fZquench[i] = 0.;
202   for (Int_t i = 0; i < 10; i++) 
203     for (Int_t j = 0; j < 4; j++) {
204       fJets[j][i]=0;    // Trigger jets
205       fUQJets[j][i]=0;  // Unquenched trigger jets
206     }
207   source.GetZQuench(fZquench);
208   for (Int_t i = 0; i < NTriggerJets(); i++){
209     source.TriggerJet(i,fJets[0][i],fJets[1][i],fJets[2][i],fJets[3][i]);
210   }
211   for (Int_t i = 0; i < NUQTriggerJets(); i++){
212     source.UQJet(i,fUQJets[0][i],fUQJets[1][i],fUQJets[2][i],fUQJets[3][i]);
213   }
214   source.Hard(0,fHard[0][0],fHard[1][0],fHard[2][0],fHard[3][0],fHard[4][0]);
215   source.Hard(1,fHard[0][1],fHard[1][1],fHard[2][1],fHard[3][1],fHard[4][1]);
216 }
217
218 void AliJetEventParticles::AddParticle(AliJetParticle* part)
219 {
220   //Adds new particle to the event
221   fParticles->AddAt(part,fNParticles++);
222 }
223
224 void AliJetEventParticles::AddParticle(const AliJetParticle* part)
225 {
226   //Adds new particle to the event
227   new((*fParticles)[fNParticles++]) AliJetParticle(*part);
228 }
229
230 void AliJetEventParticles::AddParticle(const TParticle* part,Int_t idx, Int_t l, Int_t ncl)
231 {
232   //Adds new particle to the event
233   new((*fParticles)[fNParticles++]) AliJetParticle(part,idx,l,ncl);
234 }
235
236 void AliJetEventParticles::AddParticle(Float_t px, Float_t py, Float_t pz, 
237                               Float_t etot, Int_t idx, Int_t l, Int_t ncl)
238 {
239   //Adds new particle to the event
240   new((*fParticles)[fNParticles++]) AliJetParticle(px,py,pz,etot,idx,l,ncl); 
241 }
242
243 void AliJetEventParticles::AddParticle(Float_t px, Float_t py, Float_t pz, Float_t etot, Int_t idx, Int_t l,
244                               Int_t ncl, Float_t pt, Float_t phi, Float_t eta)
245 {
246   //Adds new particle to the event
247   new((*fParticles)[fNParticles++]) AliJetParticle(px,py,pz,etot,idx,l,ncl,pt,phi,eta); 
248 }
249
250 const AliJetParticle* AliJetEventParticles::GetParticleSafely(Int_t n)
251 {
252   //returns nth particle with range check
253   if( (n<0) || (fNParticles<=n) ) return 0;
254   return (const AliJetParticle*)fParticles->At(n);
255 }
256
257 void AliJetEventParticles::AddJet(Float_t px, Float_t py, Float_t pz, Float_t e)
258 {
259   //
260   //  Add a jet 
261   //
262   if (fNJets < 10) {
263     fJets[0][fNJets] = px;
264     fJets[1][fNJets] = py;
265     fJets[2][fNJets] = pz;
266     fJets[3][fNJets] = e;
267     fNJets++;
268   } else {
269     printf("\nWarning: More than 10 jets triggered !!\n");
270   }
271 }
272
273 void AliJetEventParticles::AddJet(Float_t p[4])
274 {
275   //
276   //  Add a jet 
277   //
278   if (fNJets < 10) {
279     fJets[0][fNJets] = p[0];
280     fJets[1][fNJets] = p[1];
281     fJets[2][fNJets] = p[2];
282     fJets[3][fNJets] = p[3];
283     fNJets++;
284   } else {
285     printf("\nWarning: More than 10 jets triggered !!\n");
286   }
287 }
288
289 void AliJetEventParticles::AddUQJet(Float_t px, Float_t py, Float_t pz, Float_t e)
290 {
291   //
292   //  Add a jet 
293   //
294   if (fNUQJets < 10) {
295     fUQJets[0][fNUQJets] = px;
296     fUQJets[1][fNUQJets] = py;
297     fUQJets[2][fNUQJets] = pz;
298     fUQJets[3][fNUQJets] = e;
299     fNUQJets++;
300   } else {
301     printf("\nWarning: More than 10 jets triggered !!\n");
302   }
303 }
304
305 void AliJetEventParticles::AddUQJet(Float_t p[4])
306 {
307   //
308   //  Add a jet 
309   //
310   if (fNUQJets < 10) {
311     fUQJets[0][fNUQJets] = p[0];
312     fUQJets[1][fNUQJets] = p[1];
313     fUQJets[2][fNUQJets] = p[2];
314     fUQJets[3][fNUQJets] = p[3];
315     fNUQJets++;
316   } else {
317     printf("\nWarning: More than 10 jets triggered !!\n");
318   }
319 }
320
321 void AliJetEventParticles::AddHard(Int_t i,Float_t px, Float_t py, Float_t pz, Float_t e, Float_t type)
322 {
323   //
324   //  Add a had parton
325   //
326   if (i < 2) {
327     fHard[0][i] = px;
328     fHard[1][i] = py;
329     fHard[2][i] = pz;
330     fHard[3][i] = e;
331     fHard[4][i] = type;
332   } else {
333     printf("\nWarning: More than 2 partons !!\n");
334   }
335 }
336
337 void AliJetEventParticles::SetZQuench(Double_t z[4])
338 {
339   //
340   // Set quenching fraction
341   //
342   for (Int_t i = 0; i < 4; i++) fZquench[i] = z[i];
343 }
344
345 void AliJetEventParticles::GetZQuench(Double_t z[4]) const
346 {
347   //
348   // Get quenching fraction
349   //
350   for (Int_t i = 0; i < 4; i++) z[i] = fZquench[i];
351 }
352
353 void AliJetEventParticles::TriggerJet(Int_t i, Float_t p[4]) const
354 {
355   //
356   // Give back jet #i
357   //
358   if (i >= fNJets) {
359     printf("\nWarning: TriggerJet, index out of Range!!\n");
360   } else {
361     p[0] = fJets[0][i];
362     p[1] = fJets[1][i];
363     p[2] = fJets[2][i];
364     p[3] = fJets[3][i];
365   }
366 }
367
368 void AliJetEventParticles::TriggerJet(Int_t i, Float_t &p1, Float_t &p2, Float_t &p3, Float_t &E) const
369 {
370   //
371   // Give back jet #i
372   //
373   if (i >= fNJets) {
374     printf("\nWarning: TriggerJet, index out of Range!!\n");
375   } else {
376     p1   = fJets[0][i];
377     p2   = fJets[1][i];
378     p3   = fJets[2][i];
379     E    = fJets[3][i];
380   }
381 }
382
383 void AliJetEventParticles::UQJet(Int_t i, Float_t p[4]) const
384 {
385   //
386   // Give back jet #i
387   //
388   if (i >= fNUQJets) {
389     printf("\nWarning: Unquenched Jets, index out of Range!!\n");
390   } else {
391     p[0] = fUQJets[0][i];
392     p[1] = fUQJets[1][i];
393     p[2] = fUQJets[2][i];
394     p[3] = fUQJets[3][i];
395   }
396 }
397
398 void AliJetEventParticles::UQJet(Int_t i, Float_t &p1, Float_t &p2, Float_t &p3, Float_t &E) const
399 {
400   //
401   // Give back jet #i
402   //
403   if (i >= fNUQJets) {
404     printf("\nWarning: Unquenched Jets, index out of Range!!\n");
405   } else {
406     p1   = fUQJets[0][i];
407     p2   = fUQJets[1][i];
408     p3   = fUQJets[2][i];
409     E    = fUQJets[3][i];
410   }
411 }
412
413 void AliJetEventParticles::Hard(Int_t i, Float_t &p1, Float_t &p2, Float_t &p3, Float_t &E, Float_t &type) const
414 {
415   //
416   // Give back jet #i
417   //
418   if (i >= 2) {
419     printf("\nWarning: Hard partons, index out of Range!!\n");
420   } else {
421     p1   = fHard[0][i];
422     p2   = fHard[1][i];
423     p3   = fHard[2][i];
424     E    = fHard[3][i];
425     type = fHard[4][i];
426   }
427 }
428
429 void AliJetEventParticles::Hard(Int_t i, Float_t p[4], Float_t &type) const
430 {
431   //
432   // Give back jet #i
433   //
434   if (i >= 2) {
435     printf("\nWarning: Hard partons, index out of Range!!\n");
436   } else {
437     p[0]   = fHard[0][i];
438     p[1]   = fHard[1][i];
439     p[2]   = fHard[2][i];
440     p[3]   = fHard[3][i];
441     type = fHard[4][i];
442   }
443 }
444
445 void AliJetEventParticles::SetXYJet(Double_t x, Double_t y)
446 {
447   //
448   //  Add jet production point
449   //
450   fXJet = x; 
451   fYJet = y; 
452 }
453
454 void AliJetEventParticles::Print(Option_t* /*t*/) const
455 {
456   cout << "--- AliJetEventParticles ---" << endl;
457   if(fHeader.Length()) cout << fHeader.Data() << endl;
458   cout << "Event Number: " << fEventNr << endl;
459   cout << "Particles in Event: " << fNParticles << endl;
460   if(fNUQJets){
461     cout << "Unquenched Jets: " << fNUQJets << endl;
462     for(Int_t i = 0; i<fNUQJets; i++){
463       Float_t x=fUQJets[0][i];
464       Float_t y=fUQJets[1][i];
465       Float_t z=fUQJets[2][i];
466       Float_t e=fUQJets[3][i];
467       Float_t ptj=TMath::Sqrt(x*x+y*y);
468       Float_t thj=TMath::ATan2(ptj,z);
469       Float_t etaj=-TMath::Log(TMath::Tan(thj/2));
470       Float_t phj=TMath::Pi()+TMath::ATan2(-y,-x);
471       Float_t et=e*TMath::Sin(thj);
472       cout << i << " " << et << " " << etaj << " " << phj << endl;
473     }
474   }
475   if(fNJets){
476     cout << "Triggered Jets: " << fNJets << endl;
477     for(Int_t i = 0; i<fNJets; i++){
478       Float_t x=fJets[0][i];
479       Float_t y=fJets[1][i];
480       Float_t z=fJets[2][i];
481       Float_t e=fJets[3][i];
482       Float_t ptj=TMath::Sqrt(x*x+y*y);
483       Float_t thj=TMath::ATan2(ptj,z);
484       Float_t etaj=-TMath::Log(TMath::Tan(thj/2));
485       Float_t phj=TMath::Pi()+TMath::ATan2(-y,-x);
486       Float_t et=e*TMath::Sin(thj);
487       cout << i << " " << et << " " << etaj << " " << phj << endl;
488     }
489   }
490 }