]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/AliJetParticle.cxx
Allocation of big array in the heap
[u/mrichter/AliRoot.git] / JETAN / AliJetParticle.cxx
1 // $Id$
2
3 //___________________________________________________________
4 /////////////////////////////////////////////////////////////
5 //
6 // class AliJetParticle
7 //
8 // loizides@ikf.uni-frankfurt.de
9 //
10 /////////////////////////////////////////////////////////////
11
12 #include <Riostream.h>
13 #include <TMath.h>
14 #include <TParticle.h>
15 #include "AliJetParticle.h"
16
17 ClassImp(AliJetParticle)
18
19 AliJetParticle::AliJetParticle() : 
20   TObject()    
21 {
22   Clear();
23 }
24
25 AliJetParticle::AliJetParticle(const AliJetParticle& in) :
26   TObject(in)
27 {
28   Clear();
29   SetMomentum(in.fPx,in.fPy,in.fPz,in.fE);
30   fIdxInEvent=in.fIdxInEvent;
31   fLabel=in.fLabel;
32   fType=in.fType;
33   fNhits=in.fNhits;
34 }
35  
36 AliJetParticle::AliJetParticle(const TParticle* p, Int_t idx, Int_t l, Int_t ncl) :
37   TObject()
38 {
39   Clear();
40   SetMomentum(p->Px(),p->Py(),p->Pz(),p->Energy());
41   fIdxInEvent=idx;
42   fLabel=l;
43   fType=(Int_t)p->GetWeight();
44   fNhits=ncl;
45 }
46
47 AliJetParticle::AliJetParticle(Float_t px, Float_t py, Float_t pz, 
48                                Float_t etot, Int_t idx, Int_t l, Int_t ncl) :
49   TObject()
50 {
51   Clear();
52   SetMomentum(px,py,pz,etot);
53   fIdxInEvent=idx;
54   fLabel=l;
55   fNhits=ncl;
56 }
57
58 AliJetParticle::AliJetParticle(Float_t px, Float_t py, Float_t pz, 
59                                Float_t etot, Int_t idx, Int_t l, Int_t ncl,
60                                Float_t pt, Float_t phi, Float_t eta) :
61   TObject(),
62   fPx(px),fPy(py),fPz(pz),
63   fE(etot),fIdxInEvent(idx),
64   fType(0),fLabel(l),fNhits(ncl),
65   fPt(pt),fEta(eta),fPhi(phi)
66 {
67 }
68
69 TParticle* AliJetParticle::Particle() const
70 {
71   TParticle *ret=new TParticle(0,0,0,0,0,0,fPx,fPy,fPz,fE,0,0,0,0);
72   ret->SetWeight(fType);
73   return ret;
74 }
75
76 void AliJetParticle::Calculate()
77 {
78   //calculate values from px, py, pz
79   //which are frequently needed
80
81   fPt=TMath::Sqrt(fPx*fPx+fPy*fPy);
82   const Float_t kp=P();
83   fEta=0.5*TMath::Log((kp+fPz+1e-30)/(kp-fPz+1e-30)); 
84   fPhi=TMath::Pi()+TMath::ATan2(-fPy,-fPx);
85 }
86
87 void AliJetParticle::Clear(Option_t* /*t*/)
88 {
89   fPx=0.;
90   fPy=0.;
91   fPz=0.;
92   fE=0.;
93   fIdxInEvent=0;
94   fType=0;
95   fLabel=0;
96   fNhits=0;
97   fPt=0.;
98   fEta=0.;
99   fPhi=0.;
100 }
101
102 void AliJetParticle::Print(Option_t* /*t*/) const
103 {
104   cout << fPt << " " << fEta << " " << fPhi << endl;
105 }
106
107 Int_t AliJetParticle::Compare(const TObject *obj) const
108 {
109   Double_t val=((AliJetParticle*)obj)->Pt();
110
111   if(fPt>val) return 1;
112   else if (fPt<val) return -1;
113   else return 0;
114 }