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