]>
Commit | Line | Data |
---|---|---|
1 | // $Id$ | |
2 | // | |
3 | // Standalone jet finder | |
4 | // CINT-compatible wrapper for AliFJWrapper, can be used in macros and from the ROOT command line. | |
5 | // Compiled code can use AliFJWrapper directly | |
6 | // | |
7 | // Authors: R.Haake | |
8 | ||
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 | //________________________________________________________________________ | |
17 | AliEmcalJetFinder::AliEmcalJetFinder() : | |
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) | |
19 | { | |
20 | // Constructor | |
21 | fFastjetWrapper = new AliFJWrapper("FJWrapper", "FJWrapper"); | |
22 | } | |
23 | ||
24 | //________________________________________________________________________ | |
25 | AliEmcalJetFinder::AliEmcalJetFinder(const char* name) : | |
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) | |
27 | { | |
28 | // Constructor | |
29 | fFastjetWrapper = new AliFJWrapper("FJWrapper", "FJWrapper"); | |
30 | } | |
31 | ||
32 | //________________________________________________________________________ | |
33 | AliEmcalJetFinder::~AliEmcalJetFinder() | |
34 | { | |
35 | if(fFastjetWrapper) | |
36 | delete fFastjetWrapper; | |
37 | } | |
38 | ||
39 | ||
40 | //________________________________________________________________________ | |
41 | Bool_t AliEmcalJetFinder::FindJets() | |
42 | { | |
43 | // Tidy up and check input | |
44 | for (UInt_t i=0; i<fJetArray.size(); i++) { | |
45 | delete fJetArray[i]; | |
46 | fJetArray[i] = 0; | |
47 | } | |
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); | |
64 | if(fRecombScheme>=0) | |
65 | fFastjetWrapper->SetRecombScheme(static_cast<fastjet::RecombinationScheme>(fRecombScheme)); | |
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()); | |
90 | jet->SetArea(fFastjetWrapper->GetJetArea(i)); | |
91 | jet->SetNumberOfTracks(nConstituents); | |
92 | jet->SetNumberOfClusters(nConstituents); | |
93 | fJetArray[fJetCount] = jet; | |
94 | fJetCount++; | |
95 | } | |
96 | ||
97 | fJetArray.resize(fJetCount); | |
98 | ||
99 | //fastjets.clear(); // will be done by the destructor at the end of the function | |
100 | fFastjetWrapper->Clear(); | |
101 | fInputVectorIndex = 0; | |
102 | return kTRUE; | |
103 | } | |
104 | ||
105 | //________________________________________________________________________ | |
106 | void 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 | ||
112 | //________________________________________________________________________ | |
113 | void 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 | ||
119 | //________________________________________________________________________ | |
120 | void AliEmcalJetFinder::FillPtHistogram(TH1* histogram) | |
121 | { | |
122 | if(!histogram) | |
123 | return; | |
124 | for (std::size_t i=0; i<fJetArray.size(); i++) | |
125 | { | |
126 | histogram->Fill(fJetArray[i]->Pt()); | |
127 | } | |
128 | } | |
129 | ||
130 | //________________________________________________________________________ | |
131 | void AliEmcalJetFinder::FillPhiHistogram(TH1* histogram) | |
132 | { | |
133 | if(!histogram) | |
134 | return; | |
135 | for (std::size_t i=0; i<fJetArray.size(); i++) | |
136 | { | |
137 | histogram->Fill(fJetArray[i]->Phi()); | |
138 | } | |
139 | } | |
140 | ||
141 | //________________________________________________________________________ | |
142 | void AliEmcalJetFinder::FillEtaHistogram(TH1* histogram) | |
143 | { | |
144 | if(!histogram) | |
145 | return; | |
146 | for (std::size_t i=0; i<fJetArray.size(); i++) | |
147 | { | |
148 | histogram->Fill(fJetArray[i]->Eta()); | |
149 | } | |
150 | } |