]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskSAJF.cxx
update from megan
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / UserTasks / AliAnalysisTaskSAJF.cxx
CommitLineData
00514d01 1// $Id$
91f4b7c5 2//
297edd60 3// Jet analysis task.
91f4b7c5 4//
297edd60 5// Author: S.Aiola
25283b37 6
25283b37 7#include <TClonesArray.h>
8#include <TH1F.h>
9#include <TH2F.h>
a487deae 10#include <TH3F.h>
25283b37 11#include <TList.h>
12#include <TLorentzVector.h>
25283b37 13
f0a0fd33 14#include "AliVCluster.h"
df43b607 15#include "AliVParticle.h"
6fd5039f 16#include "AliVTrack.h"
25283b37 17#include "AliEmcalJet.h"
e44e8726 18#include "AliRhoParameter.h"
55264f20 19#include "AliLog.h"
25283b37 20
00514d01 21#include "AliAnalysisTaskSAJF.h"
25283b37 22
00514d01 23ClassImp(AliAnalysisTaskSAJF)
25283b37 24
25//________________________________________________________________________
00514d01 26AliAnalysisTaskSAJF::AliAnalysisTaskSAJF() :
1f03e093 27 AliAnalysisTaskEmcalJet("AliAnalysisTaskSAJF", kTRUE),
624bef5b 28 fNjetsVsCent(0)
226f511d 29
25283b37 30{
31 // Default constructor.
f0a0fd33 32
33 for (Int_t i = 0; i < 4; i++) {
e44e8726 34 fHistEvents[i] = 0;
55264f20 35 fHistLeadingJetPt[i] = 0;
36 fHist2LeadingJetPt[i] = 0;
a487deae 37 fHistLeadingJetCorrPt[i] = 0;
59f16b27 38 fHistRhoVSleadJetPt[i] = 0;
a487deae 39 fHistJetPhiEta[i] = 0;
40 fHistJetsPtArea[i] = 0;
41 fHistJetsCorrPtArea[i] = 0;
b12a85c3 42 fHistJetsNEFvsPt[i] = 0;
43 fHistJetsZvsPt[i] = 0;
58285fc6 44 fHistConstituents[i] = 0;
a487deae 45 fHistTracksJetPt[i] = 0;
46 fHistClustersJetPt[i] = 0;
624bef5b 47 fHistJetNconstVsPt[i] = 0;
f0a0fd33 48 }
a487deae 49
50 SetMakeGeneralHistograms(kTRUE);
25283b37 51}
52
53//________________________________________________________________________
00514d01 54AliAnalysisTaskSAJF::AliAnalysisTaskSAJF(const char *name) :
1f03e093 55 AliAnalysisTaskEmcalJet(name, kTRUE),
624bef5b 56 fNjetsVsCent(0)
25283b37 57{
58 // Standard constructor.
59
f0a0fd33 60 for (Int_t i = 0; i < 4; i++) {
e44e8726 61 fHistEvents[i] = 0;
55264f20 62 fHistLeadingJetPt[i] = 0;
63 fHist2LeadingJetPt[i] = 0;
a487deae 64 fHistLeadingJetCorrPt[i] = 0;
59f16b27 65 fHistRhoVSleadJetPt[i] = 0;
a487deae 66 fHistJetPhiEta[i] = 0;
67 fHistJetsPtArea[i] = 0;
68 fHistJetsCorrPtArea[i] = 0;
b12a85c3 69 fHistJetsNEFvsPt[i] = 0;
70 fHistJetsZvsPt[i] = 0;
58285fc6 71 fHistConstituents[i] = 0;
a487deae 72 fHistTracksJetPt[i] = 0;
73 fHistClustersJetPt[i] = 0;
624bef5b 74 fHistJetNconstVsPt[i] = 0;
f0a0fd33 75 }
a487deae 76
77 SetMakeGeneralHistograms(kTRUE);
25283b37 78}
79
80//________________________________________________________________________
00514d01 81AliAnalysisTaskSAJF::~AliAnalysisTaskSAJF()
25283b37 82{
16d143bd 83 // Destructor.
25283b37 84}
85
86//________________________________________________________________________
00514d01 87void AliAnalysisTaskSAJF::UserCreateOutputObjects()
25283b37 88{
16d143bd 89 // Create user output.
df43b607 90
16d143bd 91 AliAnalysisTaskEmcalJet::UserCreateOutputObjects();
a825589f 92
624bef5b 93 fNjetsVsCent = new TH2F("fNjetsVsCent","fNjetsVsCent", 100, 0, 100, 150, -0.5, 149.5);
94 fNjetsVsCent->GetXaxis()->SetTitle("Centrality (%)");
95 fNjetsVsCent->GetYaxis()->SetTitle("# of jets");
96 fOutput->Add(fNjetsVsCent);
97
a487deae 98 const Int_t nbinsZ = 12;
99 Float_t binsZ[nbinsZ+1] = {0,1,2,3,4,5,6,7,8,9,10,20,1000};
100
101 Float_t *binsPt = GenerateFixedBinArray(fNbins, fMinBinPt, fMaxBinPt);
102 Float_t *binsCorrPt = GenerateFixedBinArray(fNbins*2, -fMaxBinPt, fMaxBinPt);
103 Float_t *binsArea = GenerateFixedBinArray(30, 0, fJetRadius * fJetRadius * TMath::Pi() * 3);
104 Float_t *binsEta = GenerateFixedBinArray(50,-1, 1);
105 Float_t *binsPhi = GenerateFixedBinArray(101, 0, TMath::Pi() * 2.02);
106 Float_t *bins120 = GenerateFixedBinArray(120, 0, 1.2);
624bef5b 107 Float_t *bins150 = GenerateFixedBinArray(150, -0.5, 149.5);
b5ee47fb 108
f0a0fd33 109 TString histname;
110
111 for (Int_t i = 0; i < 4; i++) {
e44e8726 112 histname = "fHistEvents_";
113 histname += i;
114 fHistEvents[i] = new TH1F(histname,histname, 6, 0, 6);
115 fHistEvents[i]->GetXaxis()->SetTitle("Event state");
116 fHistEvents[i]->GetYaxis()->SetTitle("counts");
a5621834 117 fHistEvents[i]->GetXaxis()->SetBinLabel(1, "No jets");
e22bc1b8 118 fHistEvents[i]->GetXaxis()->SetBinLabel(2, "Max jet not found");
a5621834 119 fHistEvents[i]->GetXaxis()->SetBinLabel(3, "Rho == 0");
e22bc1b8 120 fHistEvents[i]->GetXaxis()->SetBinLabel(4, "Max jet <= 0");
a5621834 121 fHistEvents[i]->GetXaxis()->SetBinLabel(5, "OK");
e44e8726 122 fOutput->Add(fHistEvents[i]);
123
55264f20 124 histname = "fHistLeadingJetPt_";
f0a0fd33 125 histname += i;
6fd5039f 126 fHistLeadingJetPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt);
a487deae 127 fHistLeadingJetPt[i]->GetXaxis()->SetTitle("p_{T}^{raw} (GeV/c)");
55264f20 128 fHistLeadingJetPt[i]->GetYaxis()->SetTitle("counts");
129 fOutput->Add(fHistLeadingJetPt[i]);
b5ee47fb 130
131 histname = "fHist2LeadingJetPt_";
132 histname += i;
6fd5039f 133 fHist2LeadingJetPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt);
a487deae 134 fHist2LeadingJetPt[i]->GetXaxis()->SetTitle("p_{T}^{raw} (GeV/c)");
b5ee47fb 135 fHist2LeadingJetPt[i]->GetYaxis()->SetTitle("counts");
136 fOutput->Add(fHist2LeadingJetPt[i]);
137
a487deae 138 histname = "fHistLeadingJetCorrPt_";
139 histname += i;
140 fHistLeadingJetCorrPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins * 2, -fMaxBinPt, fMaxBinPt);
141 fHistLeadingJetCorrPt[i]->GetXaxis()->SetTitle("p_{T}^{corr} (GeV/c)");
142 fHistLeadingJetCorrPt[i]->GetYaxis()->SetTitle("counts");
143 fOutput->Add(fHistLeadingJetCorrPt[i]);
59f16b27 144
145 histname = "fHistRhoVSleadJetPt_";
146 histname += i;
147 fHistRhoVSleadJetPt[i] = new TH2F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt*2, fNbins, fMinBinPt, fMaxBinPt);
148 fHistRhoVSleadJetPt[i]->GetXaxis()->SetTitle("#rho * area (GeV/c)");
149 fHistRhoVSleadJetPt[i]->GetYaxis()->SetTitle("Leading jet p_{T} (GeV/c)");
150 fOutput->Add(fHistRhoVSleadJetPt[i]);
a487deae 151
152 histname = "fHistJetPhiEta_";
153 histname += i;
154 fHistJetPhiEta[i] = new TH3F(histname.Data(), histname.Data(),
155 50, binsEta,
156 101, binsPhi,
157 nbinsZ, binsZ);
158 fHistJetPhiEta[i]->GetXaxis()->SetTitle("#eta");
159 fHistJetPhiEta[i]->GetYaxis()->SetTitle("#phi");
160 fHistJetPhiEta[i]->GetZaxis()->SetTitle("p_{T,lead} (GeV/c)");
161 fOutput->Add(fHistJetPhiEta[i]);
162
163 histname = "fHistJetsPtArea_";
164 histname += i;
165 fHistJetsPtArea[i] = new TH3F(histname.Data(), histname.Data(),
166 fNbins, binsPt,
167 30, binsArea,
168 nbinsZ, binsZ);
169 fHistJetsPtArea[i]->GetXaxis()->SetTitle("p_{T}^{raw} (GeV/c)");
170 fHistJetsPtArea[i]->GetYaxis()->SetTitle("area");
171 fHistJetsPtArea[i]->GetZaxis()->SetTitle("p_{T,lead} (GeV/c)");
172 fOutput->Add(fHistJetsPtArea[i]);
173
b12a85c3 174 histname = "fHistJetsZvsPt_";
b5ee47fb 175 histname += i;
a487deae 176 fHistJetsZvsPt[i] = new TH3F(histname.Data(), histname.Data(),
177 120, bins120,
178 fNbins, binsPt,
179 nbinsZ, binsZ);
b12a85c3 180 fHistJetsZvsPt[i]->GetXaxis()->SetTitle("Z");
a487deae 181 fHistJetsZvsPt[i]->GetYaxis()->SetTitle("p_{T}^{raw} (GeV/c)");
182 fHistJetsZvsPt[i]->GetZaxis()->SetTitle("p_{T,lead} (GeV/c)");
b12a85c3 183 fOutput->Add(fHistJetsZvsPt[i]);
184
a487deae 185 if (!fCaloName.IsNull()) {
b12a85c3 186 histname = "fHistJetsNEFvsPt_";
187 histname += i;
a487deae 188 fHistJetsNEFvsPt[i] = new TH3F(histname.Data(), histname.Data(),
189 120, bins120,
190 fNbins, binsPt,
191 nbinsZ, binsZ);
b12a85c3 192 fHistJetsNEFvsPt[i]->GetXaxis()->SetTitle("NEF");
a487deae 193 fHistJetsNEFvsPt[i]->GetYaxis()->SetTitle("p_{T}^{raw} (GeV/c)");
194 fHistJetsNEFvsPt[i]->GetZaxis()->SetTitle("p_{T,lead} (GeV/c)");
b12a85c3 195 fOutput->Add(fHistJetsNEFvsPt[i]);
b12a85c3 196 }
197
c92284d5 198 histname = "fHistJetsCorrPtArea_";
2bddb6ae 199 histname += i;
a487deae 200 fHistJetsCorrPtArea[i] = new TH3F(histname.Data(), histname.Data(),
201 fNbins * 2, binsCorrPt,
202 30, binsArea,
203 nbinsZ, binsZ);
c92284d5 204 fHistJetsCorrPtArea[i]->GetXaxis()->SetTitle("p_{T}^{corr} [GeV/c]");
205 fHistJetsCorrPtArea[i]->GetYaxis()->SetTitle("area");
206 fOutput->Add(fHistJetsCorrPtArea[i]);
2bddb6ae 207
a487deae 208 histname = "fHistConstituents_";
a55e4f1d 209 histname += i;
624bef5b 210 fHistConstituents[i] = new TH2F(histname.Data(), histname.Data(), 100, 1, 101, 100, -0.5, 99.5);
a487deae 211 fHistConstituents[i]->GetXaxis()->SetTitle("p_{T,part} (GeV/c)");
212 fHistConstituents[i]->GetYaxis()->SetTitle("no. of particles");
624bef5b 213 fHistConstituents[i]->GetZaxis()->SetTitle("counts");
a487deae 214 fOutput->Add(fHistConstituents[i]);
a55e4f1d 215
a487deae 216 histname = "fHistTracksJetPt_";
a55e4f1d 217 histname += i;
a487deae 218 fHistTracksJetPt[i] = new TH2F(histname.Data(), histname.Data(), fNbins / 2, fMinBinPt, fMaxBinPt / 2, fNbins, fMinBinPt, fMaxBinPt);
219 fHistTracksJetPt[i]->GetXaxis()->SetTitle("p_{T,track} (GeV/c)");
220 fHistTracksJetPt[i]->GetYaxis()->SetTitle("p_{T,jet} (GeV/c)");
221 fHistTracksJetPt[i]->GetZaxis()->SetTitle("counts");
222 fOutput->Add(fHistTracksJetPt[i]);
223
224 if (!fCaloName.IsNull()) {
225 histname = "fHistClustersJetPt_";
e44e8726 226 histname += i;
a487deae 227 fHistClustersJetPt[i] = new TH2F(histname.Data(), histname.Data(), fNbins / 2, fMinBinPt, fMaxBinPt / 2, fNbins, fMinBinPt, fMaxBinPt);
228 fHistClustersJetPt[i]->GetXaxis()->SetTitle("p_{T,clus} (GeV/c)");
229 fHistClustersJetPt[i]->GetYaxis()->SetTitle("p_{T,jet} (GeV/c)");
230 fHistClustersJetPt[i]->GetZaxis()->SetTitle("counts");
231 fOutput->Add(fHistClustersJetPt[i]);
e44e8726 232 }
624bef5b 233
234 histname = "fHistJetNconstVsPt_";
235 histname += i;
236 fHistJetNconstVsPt[i] = new TH3F(histname.Data(), histname.Data(), 150, bins150, fNbins, binsPt, nbinsZ, binsZ);
237 fHistJetNconstVsPt[i]->GetXaxis()->SetTitle("# of constituents");
238 fHistJetNconstVsPt[i]->GetYaxis()->SetTitle("p_{T,jet} (GeV/c)");
239 fHistJetNconstVsPt[i]->GetZaxis()->SetTitle("p_{T,lead} (GeV/c)");
240 fOutput->Add(fHistJetNconstVsPt[i]);
e82e282c 241 }
242
25283b37 243 PostData(1, fOutput); // Post data for ALL output slots >0 here, to get at least an empty histogram
25283b37 244
a487deae 245 delete binsPt;
246 delete binsCorrPt;
247 delete binsArea;
248 delete binsEta;
249 delete binsPhi;
250 delete bins120;
2bee31e9 251}
252
55264f20 253//________________________________________________________________________
6fd5039f 254Bool_t AliAnalysisTaskSAJF::FillHistograms()
25283b37 255{
16d143bd 256 // Fill histograms.
257
a487deae 258 if (!fJets) {
259 AliError(Form("%s - Jet array not provided, returning...", GetName()));
260 return kFALSE;
261 }
262
263 if (fJets->GetEntriesFast() < 1) { // no jets in array, skipping
264 fHistEvents[fCentBin]->Fill("No jets", 1);
265 return kTRUE;
266 }
25283b37 267
a487deae 268 Int_t *sortedJets = GetSortedArray(fJets);
55264f20 269
a487deae 270 if (!sortedJets || sortedJets[0] < 0) { // no accepted jets, skipping
e44e8726 271 fHistEvents[fCentBin]->Fill("No jets", 1);
272 return kTRUE;
fb9ac42f 273 }
c554a987 274
a487deae 275 AliEmcalJet* jet = static_cast<AliEmcalJet*>(fJets->At(sortedJets[0]));
276 if (!jet) { // error, I cannot get the leading jet from collection (should never happen), skipping
e22bc1b8 277 fHistEvents[fCentBin]->Fill("Max jet not found", 1);
e44e8726 278 return kTRUE;
fb9ac42f 279 }
c554a987 280
e44e8726 281 // OK, event accepted
11d4d636 282
a487deae 283 Float_t maxJetCorrPt = jet->Pt() - fRhoVal * jet->Area();
284
a5621834 285 if (fRhoVal == 0)
286 fHistEvents[fCentBin]->Fill("Rho == 0", 1);
287
a487deae 288 else if (maxJetCorrPt <= 0)
e22bc1b8 289 fHistEvents[fCentBin]->Fill("Max jet <= 0", 1);
e44e8726 290
a487deae 291 else
292 fHistEvents[fCentBin]->Fill("OK", 1);
6fd5039f 293
294 if (jet) {
295 fHistLeadingJetPt[fCentBin]->Fill(jet->Pt());
59f16b27 296 fHistRhoVSleadJetPt[fCentBin]->Fill(fRhoVal, jet->Pt());
c92284d5 297 fHistLeadingJetCorrPt[fCentBin]->Fill(maxJetCorrPt);
6fd5039f 298 }
a487deae 299
55264f20 300 AliEmcalJet* jet2 = 0;
a487deae 301 if (sortedJets[1] >= 0)
302 jet2 = static_cast<AliEmcalJet*>(fJets->At(sortedJets[1]));
55264f20 303
6fd5039f 304 if (jet2)
b5ee47fb 305 fHist2LeadingJetPt[fCentBin]->Fill(jet2->Pt());
b5ee47fb 306
624bef5b 307 Int_t njets = DoJetLoop();
308
309 fNjetsVsCent->Fill(fCent, njets);
6fd5039f 310
311 return kTRUE;
55264f20 312}
313
6fd5039f 314//________________________________________________________________________
624bef5b 315Int_t AliAnalysisTaskSAJF::DoJetLoop()
6fd5039f 316{
16d143bd 317 // Do the jet loop.
318
6fd5039f 319 if (!fJets)
624bef5b 320 return 0;
6fd5039f 321
16d143bd 322 const Int_t njets = fJets->GetEntriesFast();
624bef5b 323 Int_t nAccJets = 0;
6fd5039f 324
58285fc6 325 TH1F constituents("constituents", "constituents",
326 fHistConstituents[0]->GetNbinsX(), fHistConstituents[0]->GetXaxis()->GetXmin(), fHistConstituents[0]->GetXaxis()->GetXmax());
327
6fd5039f 328 for (Int_t ij = 0; ij < njets; ij++) {
329
e44e8726 330 AliEmcalJet* jet = static_cast<AliEmcalJet*>(fJets->At(ij));
6fd5039f 331
332 if (!jet) {
333 AliError(Form("Could not receive jet %d", ij));
334 continue;
335 }
336
e44e8726 337 if (!AcceptJet(jet))
6fd5039f 338 continue;
339
4643d2e8 340 Float_t corrPt = jet->Pt() - fRhoVal * jet->Area();
226f511d 341
83888eef 342 Float_t ptLeading = GetLeadingHadronPt(jet);
e44e8726 343
a487deae 344 fHistJetPhiEta[fCentBin]->Fill(jet->Eta(), jet->Phi(), ptLeading);
345 fHistJetsPtArea[fCentBin]->Fill(jet->Pt(), jet->Area(), ptLeading);
346 fHistJetsCorrPtArea[fCentBin]->Fill(corrPt, jet->Area(), ptLeading);
624bef5b 347 fHistJetNconstVsPt[fCentBin]->Fill(jet->GetNumberOfConstituents(), jet->Pt(), ptLeading);
226f511d 348
a487deae 349 if (fCaloClusters)
350 fHistJetsNEFvsPt[fCentBin]->Fill(jet->NEF(), jet->Pt(), ptLeading);
a825589f 351
6e8d91c9 352 if (fTracks) {
353 for (Int_t it = 0; it < jet->GetNumberOfTracks(); it++) {
354 AliVParticle *track = jet->TrackAt(it, fTracks);
a825589f 355 if (track) {
a487deae 356 fHistJetsZvsPt[fCentBin]->Fill(track->Pt() / jet->Pt(), jet->Pt(), ptLeading);
58285fc6 357 constituents.Fill(track->Pt());
a487deae 358 fHistTracksJetPt[fCentBin]->Fill(track->Pt(), jet->Pt());
a825589f 359 }
6e8d91c9 360 }
35789a2d 361 }
a55e4f1d 362
6e8d91c9 363 if (fCaloClusters) {
364 for (Int_t ic = 0; ic < jet->GetNumberOfClusters(); ic++) {
365 AliVCluster *cluster = jet->ClusterAt(ic, fCaloClusters);
366
367 if (cluster) {
368 TLorentzVector nPart;
369 cluster->GetMomentum(nPart, fVertex);
a487deae 370 fHistJetsZvsPt[fCentBin]->Fill(nPart.Et() / jet->Pt(), jet->Pt(), ptLeading);
58285fc6 371 constituents.Fill(nPart.Pt());
a487deae 372 fHistClustersJetPt[fCentBin]->Fill(nPart.Pt(), jet->Pt());
6e8d91c9 373 }
55264f20 374 }
f0a0fd33 375 }
a825589f 376
58285fc6 377 for (Int_t i = 1; i <= constituents.GetNbinsX(); i++) {
624bef5b 378 fHistConstituents[fCentBin]->Fill(constituents.GetBinCenter(i), constituents.GetBinContent(i));
58285fc6 379 }
380
381 constituents.Reset();
624bef5b 382 nAccJets++;
25283b37 383 } //jet loop
624bef5b 384
385 return nAccJets;
55264f20 386}
e82e282c 387
25283b37 388//________________________________________________________________________
00514d01 389void AliAnalysisTaskSAJF::Terminate(Option_t *)
25283b37 390{
391 // Called once at the end of the analysis.
392}