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