]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGJE/EMCALJetTasks/AliEmcalJetFinder.cxx
standalone jet finder class (Ruediger)
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / AliEmcalJetFinder.cxx
CommitLineData
14ca6380 1// $Id$
2//
3// Standalone jet finder
4//
5// Authors: R.Haake
6
7#ifndef ALIEMCALJETFINDER_CXX
8#define ALIEMCALJETFINDER_CXX
9
10#include "AliFJWrapper.h"
11#include "AliEmcalJet.h"
12#include "AliEmcalJetFinder.h"
13#include "AliLog.h"
14#include <vector>
15#include "TH1.h"
16
17//________________________________________________________________________
18AliEmcalJetFinder::AliEmcalJetFinder() :
19 TNamed("EmcalJetFinder","EmcalJetFinder"), fFastjetWrapper(0), fInputVectorIndex(0), fJetCount(0), fJetArray(), fGhostArea(0.005), fRadius(0.4), fJetAlgorithm(0), fTrackMaxEta(0.9), fJetMaxEta(0.5), fJetMinPt(0), fJetMinArea(0)
20{
21 // Constructor
22 fFastjetWrapper = new AliFJWrapper("FJWrapper", "FJWrapper");
23}
24
25//________________________________________________________________________
26AliEmcalJetFinder::AliEmcalJetFinder(const char* name) :
27 TNamed(name, name), fFastjetWrapper(0), fInputVectorIndex(0), fJetCount(0), fJetArray(), fGhostArea(0.005), fRadius(0.4), fJetAlgorithm(0), fTrackMaxEta(0.9), fJetMaxEta(0.5), fJetMinPt(0), fJetMinArea(0)
28{
29 // Constructor
30 fFastjetWrapper = new AliFJWrapper("FJWrapper", "FJWrapper");
31}
32
33//________________________________________________________________________
34AliEmcalJetFinder::~AliEmcalJetFinder()
35{
36 if(fFastjetWrapper)
37 delete fFastjetWrapper;
38}
39
40
41//________________________________________________________________________
42Bool_t AliEmcalJetFinder::FindJets()
43{
44 // Tidy up and check input
45 fJetArray.clear();
46 fJetCount = 0;
47 if(!fInputVectorIndex)
48 {
49 AliError("No input vectors added to jet finder!");
50 return kFALSE;
51 }
52
53 // Pass settings to fastjet
54 fFastjetWrapper->SetAreaType(fastjet::active_area_explicit_ghosts);
55 fFastjetWrapper->SetGhostArea(fGhostArea);
56 fFastjetWrapper->SetR(fRadius);
57 if(fJetAlgorithm == 0)
58 fFastjetWrapper->SetAlgorithm(fastjet::antikt_algorithm);
59 if(fJetAlgorithm == 1)
60 fFastjetWrapper->SetAlgorithm(fastjet::kt_algorithm);
61
62 fFastjetWrapper->SetMaxRap(fTrackMaxEta);
63
64 // Run jet finding
65 fFastjetWrapper->Run();
66
67 // Save the found jets as light-weight objects
68 std::vector<fastjet::PseudoJet> fastjets = fFastjetWrapper->GetInclusiveJets();
69 fJetArray.resize(fastjets.size());
70
71 for (UInt_t i=0; i<fastjets.size(); i++)
72 {
73 // Apply jet cuts
74 if (fastjets[i].perp()<fJetMinPt)
75 continue;
76 if (fFastjetWrapper->GetJetArea(i)<fJetMinArea)
77 continue;
78 if (TMath::Abs(fastjets[i].eta())>fJetMaxEta)
79 continue;
80
81 AliEmcalJet* jet = new AliEmcalJet(fastjets[i].perp(), fastjets[i].eta(), fastjets[i].phi(), fastjets[i].m());
82
83 // Set the most important properties of the jet
84 Int_t nConstituents(fFastjetWrapper->GetJetConstituents(i).size());
85 jet->SetNumberOfTracks(nConstituents);
86 jet->SetNumberOfClusters(nConstituents);
87 fJetArray[fJetCount] = jet;
88 fJetCount++;
89 }
90
91 fJetArray.resize(fJetCount);
92
93 fFastjetWrapper->Clear();
94 fInputVectorIndex = 0;
95 return kTRUE;
96}
97
98//________________________________________________________________________
99void AliEmcalJetFinder::AddInputVector(Double_t px, Double_t py, Double_t pz)
100{
101 fFastjetWrapper->AddInputVector(px, py, pz, TMath::Sqrt(px*px + py*py + pz*pz), fInputVectorIndex + 100);
102 fInputVectorIndex++;
103}
104
105//________________________________________________________________________
106void AliEmcalJetFinder::FillPtHistogram(TH1* histogram)
107{
108 if(!histogram)
109 return;
110 for (Int_t i=0; i<fJetArray.size(); i++)
111 {
112 histogram->Fill(fJetArray[i]->Pt());
113 }
114}
115
116//________________________________________________________________________
117void AliEmcalJetFinder::FillPhiHistogram(TH1* histogram)
118{
119 if(!histogram)
120 return;
121 for (Int_t i=0; i<fJetArray.size(); i++)
122 {
123 histogram->Fill(fJetArray[i]->Phi());
124 }
125}
126
127//________________________________________________________________________
128void AliEmcalJetFinder::FillEtaHistogram(TH1* histogram)
129{
130 if(!histogram)
131 return;
132 for (Int_t i=0; i<fJetArray.size(); i++)
133 {
134 histogram->Fill(fJetArray[i]->Eta());
135 }
136}
137#endif