]> git.uio.no Git - u/mrichter/AliRoot.git/blame - JETAN/jetan2004/AliJFParticlesCut.cxx
Replaced by JETANLinkDef.h
[u/mrichter/AliRoot.git] / JETAN / jetan2004 / AliJFParticlesCut.cxx
CommitLineData
b9a6a391 1// $Id$
2
3#include <Riostream.h>
4
5#include <TParticle.h>
6#include <TClonesArray.h>
7#include <TH2F.h>
8
9#include "AliJFParticlesCut.h"
10
11
12AliJFParticlesCut::AliJFParticlesCut(TClonesArray *p)
13 : fPtMin(0),fPtMax(1000),
14 fEtaMin(-1),fEtaMax(1),
15 fPhiMin(0),fPhiMax(2*TMath::Pi()),
16 fNeutral(kTRUE),fCharged(kTRUE),fEM(kTRUE),
17 fParts(0)
18{
19 SetParticles(p);
20}
21
22Int_t AliJFParticlesCut::Cut()
23{
24 if(fParts==0) return -1;
25
26 Int_t n=0;
27 TParticle *particle;
28 TIterator *iter = fParts->MakeIterator();
29 while ((particle = (TParticle *) iter->Next()) != NULL) {
30 if(IsAcceptedParticle(particle)) n++;
31 else fParts->Remove(particle);
32 } //end loop particles
33
34 delete iter;
35 return n;
36}
37
38Int_t AliJFParticlesCut::Cut(TClonesArray *p)
39{
40 SetParticles(p);
41 return Cut();
42}
43
44TH2F* AliJFParticlesCut::CreateHistogram(Char_t *title,Char_t *text,Int_t phibins,Int_t etabins)
45{
46 if(fParts==0) return 0;
47
48 TH2F *h=new TH2F(title,text,etabins,fEtaMin,fEtaMax,phibins,fPhiMin,fPhiMax);
49 TParticle *particle;
50 TIterator *iter = fParts->MakeIterator();
51 while ((particle = (TParticle *) iter->Next()) != NULL) {
52 if(IsAcceptedParticle(particle)){
53 h->Fill(particle->Eta(),particle->Phi(),particle->Pt());
54 }
55 } //end loop particles
56
57 //h->GetZaxis()->SetTitle("Pt");
58 return h;
59}
60
61Bool_t AliJFParticlesCut::IsAcceptedParticle(TParticle *p)
62{
63#ifndef ALICEINTERFACE
64 if(p->GetStatusCode()%100!=1) return kFALSE;
65#endif
66
67 Int_t pcode=p->GetPdgCode();
68
69 if ((pcode==11)||(pcode==-11)||(pcode==22)) {
70 if(!fEM) return kFALSE;
71 } else {
72 TParticlePDG *pdg=p->GetPDG();
73 Float_t ch=pdg->Charge();
74 if((!fCharged)&&(ch)) return kFALSE;
75 if((!fNeutral)&&(!ch)) return kFALSE;
76 }
77
78 Float_t eta=p->Eta();
79 if((eta<fEtaMin)||(eta>fEtaMax)) return kFALSE;
80
81 Float_t phi=p->Phi();
82 if((phi<fPhiMin)||(phi>fPhiMax)) return kFALSE;
83
84 Float_t pt=p->Pt();
85 if((pt<fPtMin)||(pt>fPtMax)) return kFALSE;
86
87 return kTRUE;
88}
89
90void AliJFParticlesCut::SetPtCut(Float_t ptmin, Float_t ptmax)
91{
92 fPtMin=ptmin;
93 fPtMax=ptmax;
94}
95
96void AliJFParticlesCut::SetPhiCut(Float_t phimin, Float_t phimax)
97{
98 fPhiMin=phimin;
99 fPhiMax=phimax;
100}
101
102void AliJFParticlesCut::SetEtaCut(Float_t emin, Float_t emax)
103{
104 fEtaMin=emin;
105 fEtaMax=emax;
106}