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