Added sort method.
[u/mrichter/AliRoot.git] / JETAN / AliJetParticle.cxx
CommitLineData
d7c6ab14 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
17ClassImp(AliJetParticle)
18
19AliJetParticle::AliJetParticle() :
20 TObject()
21{
22 Clear();
23}
24
25AliJetParticle::AliJetParticle(const AliJetParticle& in) :
26 TObject(in)
27{
28 SetMomentum(in.fPx,in.fPy,in.fPz,in.fE);
29 fIdxInEvent=in.fIdxInEvent;
30 fLabel=in.fLabel;
31}
32
33AliJetParticle::AliJetParticle(const TParticle* p, Int_t idx, Int_t l) :
34 TObject()
35{
36 SetMomentum(p->Px(),p->Py(),p->Pz(),p->Energy());
37 fIdxInEvent=idx;
38 fLabel=l;
39}
40
41AliJetParticle::AliJetParticle(Float_t px, Float_t py, Float_t pz,
42 Float_t etot, Int_t idx, Int_t l) :
43 TObject()
44{
45 SetMomentum(px,py,pz,etot);
46 fIdxInEvent=idx;
47 fLabel=l;
48}
49
50AliJetParticle::AliJetParticle(Float_t px, Float_t py, Float_t pz,
51 Float_t etot, Int_t idx, Int_t l,
52 Float_t pt, Float_t phi, Float_t eta) :
53 TObject(),
54 fPx(px),fPy(py),fPz(pz),
55 fE(etot),fIdxInEvent(idx),fLabel(l),
56 fPt(pt),fEta(eta),fPhi(phi)
57{
58
59}
60
61void AliJetParticle::Calculate()
62{
63 //calculate values from px, py, pz
64 //which are frequently needed
65
66 fPt=TMath::Sqrt(fPx*fPx+fPy*fPy);
67 const Float_t kp=P();
68 fEta=0.5*TMath::Log((kp+fPz+1e-30)/(kp-fPz+1e-30));
69 fPhi=TMath::Pi()+TMath::ATan2(-fPy,-fPx);
70}
71
72void AliJetParticle::Clear(Option_t* /*t*/)
73{
74 fPx=0.;
75 fPy=0.;
76 fPz=0.;
77 fE=0.;
78 fIdxInEvent=0;
79 fLabel=0;
80 fPt=0.;
81 fEta=0.;
82 fPhi=0.;
83}
84
85void AliJetParticle::Print(Option_t* /*t*/) const
86{
87 cout << fPt << " " << fEta << " " << fPhi << endl;
88}
89
f83e88f6 90Int_t AliJetParticle::Compare(const TObject *obj) const
d7c6ab14 91{
f83e88f6 92 Double_t val=((AliJetParticle*)obj)->Pt();
d7c6ab14 93
f83e88f6 94 if(fPt>val) return 1;
95 else if (fPt<val) return -1;
96 else return 0;
d7c6ab14 97}