]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/jetan2004/AliJFMCJet.cxx
SetInput call corrected for generated jets.
[u/mrichter/AliRoot.git] / JETAN / jetan2004 / AliJFMCJet.cxx
1 // $Id$
2
3 #include <Riostream.h>
4
5 #include <TParticle.h>
6 #include <TClonesArray.h>
7 #include <TIterator.h>
8 #include <TMath.h>
9
10 #include "AliJFMCJet.h"
11
12 ClassImp(AliJFMCJet)
13
14 AliJFMCJet::AliJFMCJet(Int_t n) : AliJFJet(n)
15 {
16 }
17
18 AliJFMCJet::~AliJFMCJet()
19 {
20   Clean();
21 }
22
23 void AliJFMCJet::AddParticle(TParticle *p)
24 {
25   if(!p) return;
26
27   new(fParticles[fN]) TParticle(*p);
28   fN++;
29   fIsUpdated=kFALSE;
30 }
31
32 void AliJFMCJet::Clean()
33 {
34   fParticles.Delete();
35 }
36
37 void AliJFMCJet::Update()
38 {
39   if(fIsUpdated) return;
40
41   fIsUpdated=kTRUE;
42
43   fPhi=0;
44   fEta=0;
45   fY=0;
46   fPt=0;
47   fPx=0;
48   fPy=0;
49   fPz=0;
50   fE=0;
51   fE_=0;
52
53   //  Float_t fMaxParticlePt=0;
54
55   TIterator *iter=fParticles.MakeIterator();
56   TParticle *p;
57
58   while((p=(TParticle*)iter->Next()) != NULL){
59
60     Float_t px=p->Px();
61     Float_t py=p->Py();
62     Float_t pz=p->Pz();
63     Float_t E=p->Energy();
64     Float_t E_=TMath::Sqrt(px*px+py*py+pz*pz); //massless particles
65     //    Float_t pt=p->Pt();
66
67     fPx+=px;
68     fPy+=py;
69     fPz+=pz;
70     fE+=E;
71     fE_+=E_;
72     /* to do: max particle, charge particle, etc.
73     if(pt>fMaxParticlePt){
74       fMaxParticlePt=pt;
75       fMaxParticle=*p;
76     }
77     */
78   } 
79
80   fPt=TMath::Sqrt(fPx*fPx+fPy*fPy);
81   fPhi=TMath::ATan(fPy/fPx);
82   fEta=0.5*TMath::Log((fE+fPz)/(fE-fPz));
83   fY=0.5*TMath::Log((fE_+fPz)/(fE_-fPz));
84 }
85
86 void AliJFMCJet::Debug()
87 {
88   TIterator *iter=fParticles.MakeIterator();
89   TParticle *p;
90
91   Int_t i=0;
92   while((p=(TParticle*)iter->Next()) != NULL){
93     cout << i++ << ": " << p->Energy() << endl;
94   }
95 }