]>
Commit | Line | Data |
---|---|---|
8628b70c | 1 | // $Id$ |
a546db49 | 2 | // |
3 | // Emcal jet analysis base task. | |
4 | // | |
5 | // Author: S.Aiola | |
6 | ||
7 | #include "AliAnalysisTaskEmcalJet.h" | |
8 | ||
a546db49 | 9 | #include <TChain.h> |
10 | #include <TClonesArray.h> | |
11 | #include <TList.h> | |
8f3e275e | 12 | #include <TObject.h> |
a546db49 | 13 | |
a546db49 | 14 | #include "AliAnalysisManager.h" |
15 | #include "AliCentrality.h" | |
8f3e275e | 16 | #include "AliEMCALGeometry.h" |
17 | #include "AliESDEvent.h" | |
a546db49 | 18 | #include "AliEmcalJet.h" |
a546db49 | 19 | #include "AliLog.h" |
e2c9f708 | 20 | #include "AliRhoParameter.h" |
8f3e275e | 21 | #include "AliVCluster.h" |
22 | #include "AliVEventHandler.h" | |
23 | #include "AliVParticle.h" | |
a546db49 | 24 | |
25 | ClassImp(AliAnalysisTaskEmcalJet) | |
26 | ||
27 | //________________________________________________________________________ | |
28 | AliAnalysisTaskEmcalJet::AliAnalysisTaskEmcalJet() : | |
29 | AliAnalysisTaskEmcal("AliAnalysisTaskEmcalJet"), | |
30 | fJetRadius(0.4), | |
e2c9f708 | 31 | fJetsName(), |
a487deae | 32 | fRhoName(), |
33 | fPtBiasJetTrack(0), | |
34 | fPtBiasJetClus(0), | |
a546db49 | 35 | fJetPtCut(1), |
1b4db73a | 36 | fJetAreaCut(-1), |
a487deae | 37 | fPercAreaCut(-1), |
38 | fAreaEmcCut(0), | |
39 | fJetMinEta(-0.9), | |
40 | fJetMaxEta(0.9), | |
41 | fJetMinPhi(-10), | |
42 | fJetMaxPhi(10), | |
411b11e0 | 43 | fMaxClusterPt(100), |
44 | fMaxTrackPt(100), | |
83888eef | 45 | fLeadingHadronType(0), |
63fac07f | 46 | fNLeadingJets(1), |
2103dc6a | 47 | fJetBitMap(0), |
a487deae | 48 | fJets(0), |
49 | fRho(0), | |
50 | fRhoVal(0) | |
a546db49 | 51 | { |
52 | // Default constructor. | |
53 | } | |
54 | ||
a546db49 | 55 | //________________________________________________________________________ |
56 | AliAnalysisTaskEmcalJet::AliAnalysisTaskEmcalJet(const char *name, Bool_t histo) : | |
57 | AliAnalysisTaskEmcal(name, histo), | |
58 | fJetRadius(0.4), | |
e2c9f708 | 59 | fJetsName(), |
a487deae | 60 | fRhoName(), |
61 | fPtBiasJetTrack(0), | |
62 | fPtBiasJetClus(0), | |
a546db49 | 63 | fJetPtCut(1), |
1b4db73a | 64 | fJetAreaCut(-1), |
a487deae | 65 | fPercAreaCut(-1), |
66 | fAreaEmcCut(0), | |
67 | fJetMinEta(-0.9), | |
68 | fJetMaxEta(0.9), | |
69 | fJetMinPhi(-10), | |
70 | fJetMaxPhi(10), | |
411b11e0 | 71 | fMaxClusterPt(100), |
72 | fMaxTrackPt(100), | |
83888eef | 73 | fLeadingHadronType(0), |
63fac07f | 74 | fNLeadingJets(1), |
2103dc6a | 75 | fJetBitMap(0), |
a487deae | 76 | fJets(0), |
77 | fRho(0), | |
78 | fRhoVal(0) | |
a546db49 | 79 | { |
80 | // Standard constructor. | |
81 | } | |
82 | ||
83 | //________________________________________________________________________ | |
84 | AliAnalysisTaskEmcalJet::~AliAnalysisTaskEmcalJet() | |
85 | { | |
86 | // Destructor | |
87 | } | |
88 | ||
2bddb6ae | 89 | //________________________________________________________________________ |
90 | Bool_t AliAnalysisTaskEmcalJet::AcceptBiasJet(AliEmcalJet *jet) const | |
91 | { | |
76bc10fe | 92 | // Accept jet with a bias. |
93 | ||
83888eef | 94 | if (fLeadingHadronType == 0) { |
95 | if (jet->MaxTrackPt() < fPtBiasJetTrack) return kFALSE; | |
96 | } | |
97 | else if (fLeadingHadronType == 1) { | |
98 | if (jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE; | |
99 | } | |
100 | else { | |
101 | if (jet->MaxTrackPt() < fPtBiasJetTrack && jet->MaxClusterPt() < fPtBiasJetClus) return kFALSE; | |
102 | } | |
103 | ||
104 | return kTRUE; | |
105 | } | |
106 | ||
107 | //________________________________________________________________________ | |
108 | Float_t* AliAnalysisTaskEmcalJet::GenerateFixedBinArray(Int_t n, Float_t min, Float_t max) const | |
109 | { | |
110 | Float_t *bins = new Float_t[n+1]; | |
111 | ||
112 | Float_t binWidth = (max-min)/n; | |
113 | bins[0] = min; | |
114 | for (Int_t i = 1; i <= n; i++) { | |
115 | bins[i] = bins[i-1]+binWidth; | |
116 | } | |
117 | ||
118 | return bins; | |
119 | } | |
120 | ||
121 | //________________________________________________________________________ | |
122 | Double_t AliAnalysisTaskEmcalJet::GetLeadingHadronPt(AliEmcalJet *jet) const | |
123 | { | |
124 | if (fLeadingHadronType == 0) // charged leading hadron | |
125 | return jet->MaxTrackPt(); | |
126 | else if (fLeadingHadronType == 1) // neutral leading hadron | |
127 | return jet->MaxClusterPt(); | |
128 | else // charged or neutral | |
129 | return jet->MaxPartPt(); | |
2bddb6ae | 130 | } |
131 | ||
a546db49 | 132 | //________________________________________________________________________ |
a487deae | 133 | Bool_t AliAnalysisTaskEmcalJet::AcceptJet(AliEmcalJet *jet) const |
a546db49 | 134 | { |
135 | // Return true if jet is accepted. | |
2103dc6a | 136 | if (!jet) |
137 | return kFALSE; | |
138 | ||
139 | if (jet->TestBits(fJetBitMap) != (Int_t)fJetBitMap) | |
140 | return kFALSE; | |
a546db49 | 141 | |
ca5c29fa | 142 | if (jet->Pt() <= fJetPtCut) |
a546db49 | 143 | return kFALSE; |
ca5c29fa | 144 | |
145 | if (jet->Area() <= fJetAreaCut) | |
a546db49 | 146 | return kFALSE; |
ca5c29fa | 147 | |
a487deae | 148 | if (jet->AreaEmc()<fAreaEmcCut) |
a546db49 | 149 | return kFALSE; |
ca5c29fa | 150 | |
a487deae | 151 | if (!AcceptBiasJet(jet)) |
152 | return kFALSE; | |
ca5c29fa | 153 | |
a487deae | 154 | if (jet->MaxTrackPt() > fMaxTrackPt || jet->MaxClusterPt() > fMaxClusterPt) |
411b11e0 | 155 | return kFALSE; |
a546db49 | 156 | |
6f18d73a | 157 | Double_t jetPhi = jet->Phi(); |
158 | Double_t jetEta = jet->Eta(); | |
159 | ||
160 | if (fJetMinPhi < 0) // if limits are given in (-pi, pi) range | |
161 | jetPhi -= TMath::Pi() * 2; | |
162 | ||
163 | return (Bool_t)(jetEta > fJetMinEta && jetEta < fJetMaxEta && jetPhi > fJetMinPhi && jetPhi < fJetMaxPhi); | |
1f6fff78 | 164 | } |
165 | ||
e2c9f708 | 166 | //________________________________________________________________________ |
167 | AliRhoParameter *AliAnalysisTaskEmcalJet::GetRhoFromEvent(const char *name) | |
168 | { | |
169 | // Get rho from event. | |
170 | ||
171 | AliRhoParameter *rho = 0; | |
172 | TString sname(name); | |
173 | if (!sname.IsNull()) { | |
174 | rho = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(sname)); | |
175 | if (!rho) { | |
176 | AliWarning(Form("%s: Could not retrieve rho with name %s!", GetName(), name)); | |
177 | return 0; | |
178 | } | |
179 | } | |
180 | return rho; | |
181 | } | |
182 | ||
1f6fff78 | 183 | //________________________________________________________________________ |
abc24170 | 184 | void AliAnalysisTaskEmcalJet::ExecOnce() |
1f6fff78 | 185 | { |
186 | // Init the analysis. | |
187 | ||
a487deae | 188 | AliAnalysisTaskEmcal::ExecOnce(); |
189 | ||
a5621834 | 190 | if (fPercAreaCut >= 0) { |
60b1665c | 191 | if (fJetAreaCut >= 0) |
192 | AliInfo(Form("%s: jet area cut will be calculated as a percentage of the average area, given value will be overwritten", GetName())); | |
a5621834 | 193 | fJetAreaCut = fPercAreaCut * fJetRadius * fJetRadius * TMath::Pi(); |
194 | } | |
1b4db73a | 195 | if (fJetAreaCut < 0) |
196 | fJetAreaCut = 0; | |
a5621834 | 197 | |
1f6fff78 | 198 | if (fAnaType == kTPC) { |
a487deae | 199 | SetJetEtaLimits(-0.5, 0.5); |
200 | SetJetPhiLimits(-10, 10); | |
a487deae | 201 | } |
202 | else if (fAnaType == kEMCAL && fGeom) { | |
203 | SetJetEtaLimits(fGeom->GetArm1EtaMin() + fJetRadius, fGeom->GetArm1EtaMax() - fJetRadius); | |
204 | SetJetPhiLimits(fGeom->GetArm1PhiMin() * TMath::DegToRad() + fJetRadius, fGeom->GetArm1PhiMax() * TMath::DegToRad() - fJetRadius); | |
a487deae | 205 | } |
206 | ||
207 | if (!fRhoName.IsNull() && !fRho) { | |
208 | fRho = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(fRhoName)); | |
209 | if (!fRho) { | |
210 | AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data())); | |
211 | fInitialized = kFALSE; | |
212 | return; | |
213 | } | |
214 | } | |
215 | ||
216 | if (!fJetsName.IsNull() && !fJets) { | |
217 | fJets = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fJetsName)); | |
218 | if (!fJets) { | |
219 | AliError(Form("%s: Could not retrieve jets %s!", GetName(), fJetsName.Data())); | |
220 | fInitialized = kFALSE; | |
221 | return; | |
e44e8726 | 222 | } |
a487deae | 223 | else if (!fJets->GetClass()->GetBaseClass("AliEmcalJet")) { |
224 | AliError(Form("%s: Collection %s does not contain AliEmcalJet objects!", GetName(), fJetsName.Data())); | |
225 | fJets = 0; | |
226 | fInitialized = kFALSE; | |
227 | return; | |
1f6fff78 | 228 | } |
1f6fff78 | 229 | } |
a487deae | 230 | } |
1f6fff78 | 231 | |
a487deae | 232 | //________________________________________________________________________ |
ca5c29fa | 233 | Bool_t AliAnalysisTaskEmcalJet::GetSortedArray(Int_t indexes[], TClonesArray *array, Double_t rho) const |
a487deae | 234 | { |
235 | // Get the leading jets. | |
abc24170 | 236 | |
ca5c29fa | 237 | static Float_t pt[9999] = {0}; |
a487deae | 238 | |
239 | if (!array) | |
240 | return 0; | |
241 | ||
242 | const Int_t n = array->GetEntriesFast(); | |
243 | ||
9f52c61f | 244 | if (n < 1) |
ca5c29fa | 245 | return kFALSE; |
9f52c61f | 246 | |
247 | if (array->GetClass()->GetBaseClass("AliEmcalJet")) { | |
a487deae | 248 | |
249 | for (Int_t i = 0; i < n; i++) { | |
250 | ||
251 | pt[i] = -FLT_MAX; | |
252 | ||
253 | AliEmcalJet* jet = static_cast<AliEmcalJet*>(array->At(i)); | |
254 | ||
255 | if (!jet) { | |
256 | AliError(Form("Could not receive jet %d", i)); | |
257 | continue; | |
258 | } | |
259 | ||
260 | if (!AcceptJet(jet)) | |
261 | continue; | |
262 | ||
ca5c29fa | 263 | pt[i] = jet->Pt() - rho * jet->Area(); |
a487deae | 264 | } |
265 | } | |
266 | ||
9f52c61f | 267 | else if (array->GetClass()->GetBaseClass("AliVTrack")) { |
a487deae | 268 | |
269 | for (Int_t i = 0; i < n; i++) { | |
270 | ||
271 | pt[i] = -FLT_MAX; | |
272 | ||
273 | AliVTrack* track = static_cast<AliVTrack*>(array->At(i)); | |
274 | ||
275 | if (!track) { | |
276 | AliError(Form("Could not receive track %d", i)); | |
277 | continue; | |
278 | } | |
279 | ||
280 | if (!AcceptTrack(track)) | |
281 | continue; | |
282 | ||
283 | pt[i] = track->Pt(); | |
284 | } | |
285 | } | |
286 | ||
9f52c61f | 287 | else if (array->GetClass()->GetBaseClass("AliVCluster")) { |
a487deae | 288 | |
289 | for (Int_t i = 0; i < n; i++) { | |
290 | ||
291 | pt[i] = -FLT_MAX; | |
292 | ||
293 | AliVCluster* cluster = static_cast<AliVCluster*>(array->At(i)); | |
294 | ||
295 | if (!cluster) { | |
296 | AliError(Form("Could not receive cluster %d", i)); | |
297 | continue; | |
298 | } | |
299 | ||
300 | if (!AcceptCluster(cluster)) | |
301 | continue; | |
302 | ||
303 | TLorentzVector nPart; | |
304 | cluster->GetMomentum(nPart, const_cast<Double_t*>(fVertex)); | |
305 | ||
306 | pt[i] = nPart.Pt(); | |
307 | } | |
308 | } | |
309 | ||
310 | TMath::Sort(n, pt, indexes); | |
311 | ||
312 | if (pt[indexes[0]] == -FLT_MAX) | |
313 | return 0; | |
314 | ||
ca5c29fa | 315 | return kTRUE; |
1f6fff78 | 316 | } |
317 | ||
318 | //________________________________________________________________________ | |
76bc10fe | 319 | Bool_t AliAnalysisTaskEmcalJet::IsJetCluster(AliEmcalJet* jet, Int_t iclus, Bool_t sorted) const |
320 | { | |
321 | // Return true if cluster is in jet. | |
322 | ||
323 | for (Int_t i = 0; i < jet->GetNumberOfClusters(); ++i) { | |
324 | Int_t ijetclus = jet->ClusterAt(i); | |
325 | if (sorted && ijetclus > iclus) | |
326 | return kFALSE; | |
327 | if (ijetclus == iclus) | |
328 | return kTRUE; | |
329 | } | |
330 | return kFALSE; | |
331 | } | |
332 | ||
333 | //________________________________________________________________________ | |
334 | Bool_t AliAnalysisTaskEmcalJet::IsJetTrack(AliEmcalJet* jet, Int_t itrack, Bool_t sorted) const | |
335 | { | |
336 | // Return true if track is in jet. | |
337 | ||
338 | for (Int_t i = 0; i < jet->GetNumberOfTracks(); ++i) { | |
339 | Int_t ijettrack = jet->TrackAt(i); | |
340 | if (sorted && ijettrack > itrack) | |
341 | return kFALSE; | |
342 | if (ijettrack == itrack) | |
343 | return kTRUE; | |
344 | } | |
345 | return kFALSE; | |
346 | } | |
347 | ||
348 | //________________________________________________________________________ | |
349 | Bool_t AliAnalysisTaskEmcalJet::RetrieveEventObjects() | |
1f6fff78 | 350 | { |
76bc10fe | 351 | // Retrieve objects from event. |
1f6fff78 | 352 | |
76bc10fe | 353 | if (!AliAnalysisTaskEmcal::RetrieveEventObjects()) |
354 | return kFALSE; | |
355 | ||
a487deae | 356 | if (fRho) |
357 | fRhoVal = fRho->GetVal(); | |
76bc10fe | 358 | |
359 | return kTRUE; | |
a546db49 | 360 | } |