]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGGA/EMCALJetTasks/AliAnalysisTaskSAJF.cxx
ana update salvatore
[u/mrichter/AliRoot.git] / PWGGA / EMCALJetTasks / AliAnalysisTaskSAJF.cxx
CommitLineData
00514d01 1// $Id$
91f4b7c5 2//
b12a85c3 3// Jet analysis task (S.Aiola).
91f4b7c5 4//
5//
25283b37 6
b5ee47fb 7#include <TObject.h>
25283b37 8#include <TChain.h>
9#include <TClonesArray.h>
10#include <TH1F.h>
11#include <TH2F.h>
12#include <TList.h>
13#include <TLorentzVector.h>
a55e4f1d 14#include <TRandom3.h>
226f511d 15#include <TParameter.h>
25283b37 16
17#include "AliAnalysisManager.h"
18#include "AliCentrality.h"
f0a0fd33 19#include "AliVCluster.h"
55264f20 20#include "AliVTrack.h"
25283b37 21#include "AliEmcalJet.h"
22#include "AliVEventHandler.h"
55264f20 23#include "AliLog.h"
25283b37 24
00514d01 25#include "AliAnalysisTaskSAJF.h"
25283b37 26
00514d01 27ClassImp(AliAnalysisTaskSAJF)
25283b37 28
29//________________________________________________________________________
00514d01 30AliAnalysisTaskSAJF::AliAnalysisTaskSAJF() :
31 AliAnalysisTaskSE("AliAnalysisTaskSAJF"),
b5ee47fb 32 fAnaType(kTPC),
33 fMinEta(-0.9),
34 fMaxEta(0.9),
35 fMinPhi(-10),
36 fMaxPhi(10),
a55e4f1d 37 fJetRadius(0.4),
b12a85c3 38 fMinRC2LJ(1.0),
25283b37 39 fTracksName("Tracks"),
40 fCaloName("CaloClusters"),
41 fJetsName("Jets"),
2bee31e9 42 fEmbJetsName("EmbJets"),
b12a85c3 43 fRandTracksName("TracksRandomized"),
44 fRandCaloName("CaloClustersRandomized"),
226f511d 45 fRhoName("Rho"),
46 fNbins(500),
47 fMinPt(0),
48 fMaxPt(250),
49 fPtCut(0.15),
b12a85c3 50 fPtBiasJetTrack(10),
51 fPtBiasJetClus(10),
25283b37 52 fTracks(0),
53 fCaloClusters(0),
54 fJets(0),
2bee31e9 55 fEmbJets(0),
b12a85c3 56 fRandTracks(0),
57 fRandCaloClusters(0),
f0a0fd33 58 fCent(0),
55264f20 59 fCentBin(-1),
b12a85c3 60 fRho(0),
226f511d 61 fOutput(0),
f0a0fd33 62 fHistCentrality(0),
91f4b7c5 63 fHistJetPhiEta(0),
b12a85c3 64 fHistRhoVSleadJetPt(0),
65 fHistRCPhiEta(0),
66 fHistRCPtExLJVSDPhiLJ(0),
67 fHistRhoVSRCPt(0),
b5ee47fb 68 fHistEmbJetPhiEta(0),
69 fHistEmbPartPhiEta(0),
b12a85c3 70 fHistRhoVSEmbBkg(0)
226f511d 71
25283b37 72{
73 // Default constructor.
f0a0fd33 74
75 for (Int_t i = 0; i < 4; i++) {
55264f20 76 fHistJetsPt[i] = 0;
b12a85c3 77 fHistJetsPtTrack[i] = 0;
78 fHistJetsPtClus[i] = 0;
11d4d636 79 fHistJetsPtNonBias[i] = 0;
55264f20 80 fHistLeadingJetPt[i] = 0;
81 fHist2LeadingJetPt[i] = 0;
b12a85c3 82 fHistJetsNEFvsPt[i] = 0;
83 fHistJetsZvsPt[i] = 0;
f0a0fd33 84 fHistTracksPtLJ[i] = 0;
55264f20 85 fHistClusEtLJ[i] = 0;
f0a0fd33 86 fHistTracksPtBkg[i] = 0;
55264f20 87 fHistClusEtBkg[i] = 0;
b12a85c3 88 fHistRho[i] = 0;
89 fHistCorrJetsPt[i] = 0;
90 fHistCorrJetsPtClus[i] = 0;
91 fHistCorrJetsPtTrack[i] = 0;
92 fHistCorrJetsPtNonBias[i] = 0;
93 fHistCorrLeadingJetPt[i] = 0;
a55e4f1d 94 fHistRCPt[i] = 0;
95 fHistRCPtExLJ[i] = 0;
b12a85c3 96 fHistRCPtRand[i] = 0;
97 fHistDeltaPtRC[i] = 0;
98 fHistDeltaPtRCExLJ[i] = 0;
99 fHistDeltaPtRCRand[i] = 0;
2bee31e9 100 fHistEmbJets[i] = 0;
101 fHistEmbPart[i] = 0;
b12a85c3 102 fHistDeltaPtEmb[i] = 0;
f0a0fd33 103 }
91f4b7c5 104
105 // Output slot #1 writes into a TH1 container
106 DefineOutput(1, TList::Class());
25283b37 107}
108
109//________________________________________________________________________
00514d01 110AliAnalysisTaskSAJF::AliAnalysisTaskSAJF(const char *name) :
111 AliAnalysisTaskSE(name),
b5ee47fb 112 fAnaType(kTPC),
113 fMinEta(-0.9),
114 fMaxEta(0.9),
115 fMinPhi(-10),
116 fMaxPhi(10),
a55e4f1d 117 fJetRadius(0.4),
b12a85c3 118 fMinRC2LJ(1.0),
25283b37 119 fTracksName("Tracks"),
120 fCaloName("CaloClusters"),
121 fJetsName("Jets"),
2bee31e9 122 fEmbJetsName("EmbJets"),
b12a85c3 123 fRandTracksName("TracksRandomized"),
124 fRandCaloName("CaloClustersRandomized"),
226f511d 125 fRhoName("Rho"),
126 fNbins(500),
127 fMinPt(0),
128 fMaxPt(250),
129 fPtCut(0.15),
b12a85c3 130 fPtBiasJetTrack(10),
131 fPtBiasJetClus(10),
25283b37 132 fTracks(0),
133 fCaloClusters(0),
134 fJets(0),
2bee31e9 135 fEmbJets(0),
b12a85c3 136 fRandTracks(0),
137 fRandCaloClusters(0),
f0a0fd33 138 fCent(0),
55264f20 139 fCentBin(-1),
b12a85c3 140 fRho(0),
226f511d 141 fOutput(0),
f0a0fd33 142 fHistCentrality(0),
91f4b7c5 143 fHistJetPhiEta(0),
b12a85c3 144 fHistRhoVSleadJetPt(0),
145 fHistRCPhiEta(0),
146 fHistRCPtExLJVSDPhiLJ(0),
147 fHistRhoVSRCPt(0),
b5ee47fb 148 fHistEmbJetPhiEta(0),
149 fHistEmbPartPhiEta(0),
b12a85c3 150 fHistRhoVSEmbBkg(0)
25283b37 151{
152 // Standard constructor.
153
f0a0fd33 154 for (Int_t i = 0; i < 4; i++) {
55264f20 155 fHistJetsPt[i] = 0;
b12a85c3 156 fHistJetsPtTrack[i] = 0;
157 fHistJetsPtClus[i] = 0;
11d4d636 158 fHistJetsPtNonBias[i] = 0;
55264f20 159 fHistLeadingJetPt[i] = 0;
160 fHist2LeadingJetPt[i] = 0;
b12a85c3 161 fHistJetsNEFvsPt[i] = 0;
162 fHistJetsZvsPt[i] = 0;
f0a0fd33 163 fHistTracksPtLJ[i] = 0;
55264f20 164 fHistClusEtLJ[i] = 0;
f0a0fd33 165 fHistTracksPtBkg[i] = 0;
55264f20 166 fHistClusEtBkg[i] = 0;
b12a85c3 167 fHistRho[i] = 0;
168 fHistCorrJetsPt[i] = 0;
169 fHistCorrJetsPtClus[i] = 0;
170 fHistCorrJetsPtTrack[i] = 0;
171 fHistCorrJetsPtNonBias[i] = 0;
172 fHistCorrLeadingJetPt[i] = 0;
a55e4f1d 173 fHistRCPt[i] = 0;
174 fHistRCPtExLJ[i] = 0;
b12a85c3 175 fHistRCPtRand[i] = 0;
176 fHistDeltaPtRC[i] = 0;
177 fHistDeltaPtRCExLJ[i] = 0;
178 fHistDeltaPtRCRand[i] = 0;
2bee31e9 179 fHistEmbJets[i] = 0;
180 fHistEmbPart[i] = 0;
b12a85c3 181 fHistDeltaPtEmb[i] = 0;
f0a0fd33 182 }
91f4b7c5 183
184 // Output slot #1 writes into a TH1 container
185 DefineOutput(1, TList::Class());
25283b37 186}
187
188//________________________________________________________________________
00514d01 189AliAnalysisTaskSAJF::~AliAnalysisTaskSAJF()
25283b37 190{
191 // Destructor
192}
193
194//________________________________________________________________________
00514d01 195void AliAnalysisTaskSAJF::UserCreateOutputObjects()
25283b37 196{
f0a0fd33 197 // Create histograms
11d4d636 198
b12a85c3 199 const Float_t binWidth = (fMaxPt - fMinPt) / fNbins;
25283b37 200
226f511d 201 OpenFile(1);
25283b37 202 fOutput = new TList();
226f511d 203 fOutput->SetOwner();
25283b37 204
55264f20 205 fHistCentrality = new TH1F("fHistCentrality","Event centrality distribution", fNbins, 0, 100);
f0a0fd33 206 fHistCentrality->GetXaxis()->SetTitle("Centrality (%)");
207 fHistCentrality->GetYaxis()->SetTitle("counts");
208 fOutput->Add(fHistCentrality);
25283b37 209
91f4b7c5 210 fHistJetPhiEta = new TH2F("fHistJetPhiEta","Phi-Eta distribution of jets", 20, -2, 2, 32, 0, 6.4);
b12a85c3 211 fHistJetPhiEta->GetXaxis()->SetTitle("#eta");
212 fHistJetPhiEta->GetYaxis()->SetTitle("#phi");
91f4b7c5 213 fOutput->Add(fHistJetPhiEta);
214
b12a85c3 215 fHistRhoVSleadJetPt = new TH2F("fHistRhoVSleadJetPt","fHistRhoVSleadJetPt", fNbins, fMinPt, fMaxPt, fNbins, fMinPt, fMaxPt);
216 fHistRhoVSleadJetPt->GetXaxis()->SetTitle("#rho * area [GeV/c]");
217 fHistRhoVSleadJetPt->GetYaxis()->SetTitle("Leading jet p_{T} [GeV/c]");
218 fOutput->Add(fHistRhoVSleadJetPt);
b5ee47fb 219
b12a85c3 220 fHistRCPhiEta = new TH2F("fHistRCPhiEta","Phi-Eta distribution of rigid cones", 20, -2, 2, 32, 0, 6.4);
221 fHistRCPhiEta->GetXaxis()->SetTitle("#eta");
222 fHistRCPhiEta->GetYaxis()->SetTitle("#phi");
223 fOutput->Add(fHistRCPhiEta);
b5ee47fb 224
225 fHistRCPtExLJVSDPhiLJ = new TH2F("fHistRCPtExLJVSDPhiLJ","fHistRCPtExLJVSDPhiLJ", fNbins, fMinPt, fMaxPt, 128, -1.6, 4.8);
b12a85c3 226 fHistRCPtExLJVSDPhiLJ->GetXaxis()->SetTitle("rigid cone p_{T} [GeV/c]");
b5ee47fb 227 fHistRCPtExLJVSDPhiLJ->GetYaxis()->SetTitle("#Delta#phi");
228 fOutput->Add(fHistRCPtExLJVSDPhiLJ);
229
b12a85c3 230 fHistRhoVSRCPt = new TH2F("fHistRhoVSRCPt","fHistRhoVSRCPt", fNbins, fMinPt, fMaxPt, fNbins, fMinPt, fMaxPt);
231 fHistRhoVSRCPt->GetXaxis()->SetTitle("#rho * area [GeV/c]");
232 fHistRhoVSRCPt->GetYaxis()->SetTitle("rigid cone p_{T} [GeV/c]");
233 fOutput->Add(fHistRhoVSRCPt);
234
235 fHistEmbJetPhiEta = new TH2F("fHistEmbJetPhiEta","Phi-Eta distribution of embedded jets", 20, -2, 2, 32, 0, 6.4);
236 fHistEmbJetPhiEta->GetXaxis()->SetTitle("#eta");
237 fHistEmbJetPhiEta->GetYaxis()->SetTitle("#phi");
238 fOutput->Add(fHistEmbJetPhiEta);
239
240 fHistEmbPartPhiEta = new TH2F("fHistEmbPartPhiEta","Phi-Eta distribution of embedded particles", 20, -2, 2, 32, 0, 6.4);
241 fHistEmbPartPhiEta->GetXaxis()->SetTitle("#eta");
242 fHistEmbPartPhiEta->GetYaxis()->SetTitle("#phi");
243 fOutput->Add(fHistEmbPartPhiEta);
244
245 fHistRhoVSEmbBkg = new TH2F("fHistRhoVSEmbBkg","fHistRhoVSEmbBkg", fNbins, fMinPt, fMaxPt, fNbins, fMinPt, fMaxPt);
246 fHistRhoVSEmbBkg->GetXaxis()->SetTitle("rho * area [GeV/c]");
247 fHistRhoVSEmbBkg->GetYaxis()->SetTitle("background of embedded track [GeV/c]");
248 fOutput->Add(fHistRhoVSEmbBkg);
b5ee47fb 249
f0a0fd33 250 TString histname;
251
252 for (Int_t i = 0; i < 4; i++) {
55264f20 253 histname = "fHistJetsPt_";
f0a0fd33 254 histname += i;
55264f20 255 fHistJetsPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt);
b12a85c3 256 fHistJetsPt[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
55264f20 257 fHistJetsPt[i]->GetYaxis()->SetTitle("counts");
258 fOutput->Add(fHistJetsPt[i]);
226f511d 259
b12a85c3 260 if (fAnaType == kEMCAL) {
261 histname = "fHistJetsPtClus_";
262 histname += i;
263 fHistJetsPtClus[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt);
264 fHistJetsPtClus[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
265 fHistJetsPtClus[i]->GetYaxis()->SetTitle("counts");
266 fOutput->Add(fHistJetsPtClus[i]);
267 }
226f511d 268
b12a85c3 269 histname = "fHistJetsPtTrack_";
11d4d636 270 histname += i;
b12a85c3 271 fHistJetsPtTrack[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt);
272 fHistJetsPtTrack[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
273 fHistJetsPtTrack[i]->GetYaxis()->SetTitle("counts");
274 fOutput->Add(fHistJetsPtTrack[i]);
11d4d636 275
276 histname = "fHistJetsPtNonBias_";
226f511d 277 histname += i;
11d4d636 278 fHistJetsPtNonBias[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt);
b12a85c3 279 fHistJetsPtNonBias[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
11d4d636 280 fHistJetsPtNonBias[i]->GetYaxis()->SetTitle("counts");
281 fOutput->Add(fHistJetsPtNonBias[i]);
226f511d 282
55264f20 283 histname = "fHistLeadingJetPt_";
f0a0fd33 284 histname += i;
55264f20 285 fHistLeadingJetPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt);
b12a85c3 286 fHistLeadingJetPt[i]->GetXaxis()->SetTitle("p_{T} [GeV]");
55264f20 287 fHistLeadingJetPt[i]->GetYaxis()->SetTitle("counts");
288 fOutput->Add(fHistLeadingJetPt[i]);
b5ee47fb 289
290 histname = "fHist2LeadingJetPt_";
291 histname += i;
292 fHist2LeadingJetPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt);
b12a85c3 293 fHist2LeadingJetPt[i]->GetXaxis()->SetTitle("p_{T} [GeV]");
b5ee47fb 294 fHist2LeadingJetPt[i]->GetYaxis()->SetTitle("counts");
295 fOutput->Add(fHist2LeadingJetPt[i]);
296
b12a85c3 297 histname = "fHistJetsZvsPt_";
b5ee47fb 298 histname += i;
b12a85c3 299 fHistJetsZvsPt[i] = new TH2F(histname.Data(), histname.Data(), fNbins, 0, 1.2, fNbins, fMinPt, fMaxPt);
300 fHistJetsZvsPt[i]->GetXaxis()->SetTitle("Z");
301 fHistJetsZvsPt[i]->GetYaxis()->SetTitle("p_{T} [GeV/c]");
302 fOutput->Add(fHistJetsZvsPt[i]);
303
304 if (fAnaType == kEMCAL) {
305 histname = "fHistJetsNEFvsPt_";
306 histname += i;
307 fHistJetsNEFvsPt[i] = new TH2F(histname.Data(), histname.Data(), fNbins, 0, 1.2, fNbins, fMinPt, fMaxPt);
308 fHistJetsNEFvsPt[i]->GetXaxis()->SetTitle("NEF");
309 fHistJetsNEFvsPt[i]->GetYaxis()->SetTitle("p_{T} [GeV/c]");
310 fOutput->Add(fHistJetsNEFvsPt[i]);
311
312 histname = "fHistClusEtLJ_";
313 histname += i;
314 fHistClusEtLJ[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt / 5);
315 fHistClusEtLJ[i]->GetXaxis()->SetTitle("E_{T} [GeV]");
316 fHistClusEtLJ[i]->GetYaxis()->SetTitle("counts");
317 fOutput->Add(fHistClusEtLJ[i]);
318
319 histname = "fHistClusEtBkg_";
320 histname += i;
321 fHistClusEtBkg[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt / 5);
322 fHistClusEtBkg[i]->GetXaxis()->SetTitle("E_{T} [GeV]");
323 fHistClusEtBkg[i]->GetYaxis()->SetTitle("counts");
324 fOutput->Add(fHistClusEtBkg[i]);
325 }
326
f0a0fd33 327 histname = "fHistTracksPtLJ_";
328 histname += i;
b5ee47fb 329 fHistTracksPtLJ[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt / 5);
b12a85c3 330 fHistTracksPtLJ[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
f0a0fd33 331 fHistTracksPtLJ[i]->GetYaxis()->SetTitle("counts");
332 fOutput->Add(fHistTracksPtLJ[i]);
f0a0fd33 333
334 histname = "fHistTracksPtBkg_";
335 histname += i;
b5ee47fb 336 fHistTracksPtBkg[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt / 5);
b12a85c3 337 fHistTracksPtBkg[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
f0a0fd33 338 fHistTracksPtBkg[i]->GetYaxis()->SetTitle("counts");
339 fOutput->Add(fHistTracksPtBkg[i]);
b12a85c3 340
341 histname = "fHistRho_";
342 histname += i;
343 fHistRho[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt * 2);
344 fHistRho[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
345 fHistRho[i]->GetYaxis()->SetTitle("counts");
346 fOutput->Add(fHistRho[i]);
347
348 histname = "fHistCorrJetsPt_";
349 histname += i;
350 fHistCorrJetsPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins * 2, -fMaxPt, fMaxPt);
351 fHistCorrJetsPt[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
352 fHistCorrJetsPt[i]->GetYaxis()->SetTitle("counts");
353 fOutput->Add(fHistCorrJetsPt[i]);
354
355 if (fAnaType == kEMCAL) {
356 histname = "fHistCorrJetsPtClus_";
357 histname += i;
358 fHistCorrJetsPtClus[i] = new TH1F(histname.Data(), histname.Data(), fNbins * 2, -fMaxPt, fMaxPt);
359 fHistCorrJetsPtClus[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
360 fHistCorrJetsPtClus[i]->GetYaxis()->SetTitle("counts");
361 fOutput->Add(fHistCorrJetsPtClus[i]);
362 }
363
364 histname = "fHistCorrJetsPtTrack_";
f0a0fd33 365 histname += i;
b12a85c3 366 fHistCorrJetsPtTrack[i] = new TH1F(histname.Data(), histname.Data(), fNbins * 2, -fMaxPt, fMaxPt);
367 fHistCorrJetsPtTrack[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
368 fHistCorrJetsPtTrack[i]->GetYaxis()->SetTitle("counts");
369 fOutput->Add(fHistCorrJetsPtTrack[i]);
c554a987 370
b12a85c3 371 histname = "fHistCorrJetsPtNonBias_";
372 histname += i;
373 fHistCorrJetsPtNonBias[i] = new TH1F(histname.Data(), histname.Data(), fNbins * 2, -fMaxPt, fMaxPt);
374 fHistCorrJetsPtNonBias[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
375 fHistCorrJetsPtNonBias[i]->GetYaxis()->SetTitle("counts");
376 fOutput->Add(fHistCorrJetsPtNonBias[i]);
377
378 histname = "fHistCorrLeadingJetPt_";
379 histname += i;
380 fHistCorrLeadingJetPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins * 2, -fMaxPt, fMaxPt);
381 fHistCorrLeadingJetPt[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
382 fHistCorrLeadingJetPt[i]->GetYaxis()->SetTitle("counts");
383 fOutput->Add(fHistCorrLeadingJetPt[i]);
384
385 histname = "fHistRCPt_";
c554a987 386 histname += i;
b12a85c3 387 fHistRCPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt * 2);
388 fHistRCPt[i]->GetXaxis()->SetTitle("rigid cone p_{T} [GeV/c]");
389 fHistRCPt[i]->GetYaxis()->SetTitle("counts");
390 fOutput->Add(fHistRCPt[i]);
c554a987 391
b12a85c3 392 histname = "fHistRCPtExLJ_";
c554a987 393 histname += i;
b12a85c3 394 fHistRCPtExLJ[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt * 2);
395 fHistRCPtExLJ[i]->GetXaxis()->SetTitle("rigid cone p_{T} [GeV/c]");
396 fHistRCPtExLJ[i]->GetYaxis()->SetTitle("counts");
397 fOutput->Add(fHistRCPtExLJ[i]);
c554a987 398
b12a85c3 399 histname = "fHistRCPtRand_";
c554a987 400 histname += i;
b12a85c3 401 fHistRCPtRand[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt * 2);
402 fHistRCPtRand[i]->GetXaxis()->SetTitle("rigid cone p_{T} [GeV/c]");
403 fHistRCPtRand[i]->GetYaxis()->SetTitle("counts");
404 fOutput->Add(fHistRCPtRand[i]);
a55e4f1d 405
406 histname = "fHistDeltaPtRC_";
407 histname += i;
11d4d636 408 fHistDeltaPtRC[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt - fMaxPt / 2 + binWidth / 2, fMinPt + fMaxPt / 2 + binWidth / 2);
b12a85c3 409 fHistDeltaPtRC[i]->GetXaxis()->SetTitle("#deltap_{T} [GeV/c]");
a55e4f1d 410 fHistDeltaPtRC[i]->GetYaxis()->SetTitle("counts");
411 fOutput->Add(fHistDeltaPtRC[i]);
412
413 histname = "fHistDeltaPtRCExLJ_";
414 histname += i;
11d4d636 415 fHistDeltaPtRCExLJ[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt - fMaxPt / 2 + binWidth / 2, fMinPt + fMaxPt / 2 + binWidth / 2);
b12a85c3 416 fHistDeltaPtRCExLJ[i]->GetXaxis()->SetTitle("#deltap_{T} [GeV/c]");
a55e4f1d 417 fHistDeltaPtRCExLJ[i]->GetYaxis()->SetTitle("counts");
418 fOutput->Add(fHistDeltaPtRCExLJ[i]);
419
b12a85c3 420 histname = "fHistDeltaPtRCRand_";
a55e4f1d 421 histname += i;
b12a85c3 422 fHistDeltaPtRCRand[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt - fMaxPt / 2 + binWidth / 2, fMinPt + fMaxPt / 2 + binWidth / 2);
423 fHistDeltaPtRCRand[i]->GetXaxis()->SetTitle("#deltap_{T} [GeV/c]");
424 fHistDeltaPtRCRand[i]->GetYaxis()->SetTitle("counts");
425 fOutput->Add(fHistDeltaPtRCRand[i]);
2bee31e9 426
427 histname = "fHistEmbJets_";
428 histname += i;
429 fHistEmbJets[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt);
b12a85c3 430 fHistEmbJets[i]->GetXaxis()->SetTitle("embedded jet p_{T} [GeV/c]");
2bee31e9 431 fHistEmbJets[i]->GetYaxis()->SetTitle("counts");
432 fOutput->Add(fHistEmbJets[i]);
433
434 histname = "fHistEmbPart_";
435 histname += i;
436 fHistEmbPart[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt, fMaxPt);
b12a85c3 437 fHistEmbPart[i]->GetXaxis()->SetTitle("embedded particle p_{T} [GeV/c]");
2bee31e9 438 fHistEmbPart[i]->GetYaxis()->SetTitle("counts");
439 fOutput->Add(fHistEmbPart[i]);
440
b12a85c3 441 histname = "fHistDeltaPtEmb_";
2bee31e9 442 histname += i;
b12a85c3 443 fHistDeltaPtEmb[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinPt - fMaxPt / 2 + binWidth / 2, fMinPt + fMaxPt / 2 + binWidth / 2);
444 fHistDeltaPtEmb[i]->GetXaxis()->SetTitle("#deltap_{T} [GeV/c]");
445 fHistDeltaPtEmb[i]->GetYaxis()->SetTitle("counts");
446 fOutput->Add(fHistDeltaPtEmb[i]);
e82e282c 447 }
448
25283b37 449 PostData(1, fOutput); // Post data for ALL output slots >0 here, to get at least an empty histogram
450}
451
55264f20 452//________________________________________________________________________
00514d01 453void AliAnalysisTaskSAJF::RetrieveEventObjects()
25283b37 454{
11d4d636 455 if (strcmp(fCaloName,"") && fAnaType == kEMCAL) {
b5ee47fb 456 fCaloClusters = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fCaloName));
457 if (!fCaloClusters) {
b12a85c3 458 AliWarning(Form("Could not retrieve clusters %s!", fCaloName.Data()));
b5ee47fb 459 }
f0a0fd33 460 }
25283b37 461
b12a85c3 462 if (strcmp(fTracksName,"")) {
463 fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksName));
464 if (!fTracks) {
465 AliWarning(Form("Could not retrieve tracks %s!", fTracksName.Data()));
466 }
25283b37 467 }
f0a0fd33 468
b12a85c3 469 if (strcmp(fJetsName,"")) {
470 fJets = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fJetsName));
471 if (!fJets) {
472 AliWarning(Form("Could not retrieve jets %s!", fJetsName.Data()));
473 }
e82e282c 474 }
f0a0fd33 475
2bee31e9 476 if (strcmp(fEmbJetsName,"")) {
477 fEmbJets = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fEmbJetsName));
478 if (!fEmbJets) {
b12a85c3 479 AliWarning(Form("Could not retrieve emb jets %s!", fEmbJetsName.Data()));
480 }
481 }
482
483 if (strcmp(fRandCaloName,"") && fAnaType == kEMCAL) {
484 fRandCaloClusters = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fRandCaloName));
485 if (!fRandCaloClusters) {
486 AliWarning(Form("Could not retrieve randomized clusters %s!", fRandCaloName.Data()));
487 }
488 }
489
490 if (strcmp(fRandTracksName,"")) {
491 fRandTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fRandTracksName));
492 if (!fRandTracks) {
493 AliWarning(Form("Could not retrieve randomized tracks %s!", fRandTracksName.Data()));
2bee31e9 494 }
495 }
f0a0fd33 496
11d4d636 497 AliCentrality *aliCent = InputEvent()->GetCentrality();
498 if (aliCent) {
499 fCent = aliCent->GetCentralityPercentile("V0M");
500 if (fCent >= 0 && fCent < 10) fCentBin = 0;
501 else if (fCent >= 10 && fCent < 30) fCentBin = 1;
502 else if (fCent >= 30 && fCent < 50) fCentBin = 2;
503 else if (fCent >= 50 && fCent <= 100) fCentBin = 3;
55264f20 504 else {
11d4d636 505 AliWarning(Form("Negative centrality: %f. Assuming 99", fCent));
55264f20 506 fCentBin = 3;
507 }
508 }
509 else {
510 AliWarning(Form("Could not retrieve centrality information! Assuming 99"));
511 fCentBin = 3;
c554a987 512 }
226f511d 513
11d4d636 514 fRho = -1;
226f511d 515
11d4d636 516 if (strcmp(fRhoName,"")) {
517 TParameter<Double_t> *rho = dynamic_cast<TParameter<Double_t>*>(InputEvent()->FindListObject(fRhoName));
518
519 if (rho) {
520 fRho = rho->GetVal();
521 }
522 else {
b12a85c3 523 AliWarning(Form("Could not retrieve rho %s!", fRhoName.Data()));
11d4d636 524 }
226f511d 525 }
b12a85c3 526
527 fVertex[0] = 0;
528 fVertex[1] = 0;
529 fVertex[2] = 0;
530 InputEvent()->GetPrimaryVertex()->GetXYZ(fVertex);
25283b37 531}
532
55264f20 533//________________________________________________________________________
00514d01 534AliVTrack* AliAnalysisTaskSAJF::GetTrack(const Int_t i) const
25283b37 535{
e82e282c 536 if (fTracks)
537 return dynamic_cast<AliVTrack*>(fTracks->At(i));
538 else
539 return 0;
25283b37 540}
541
55264f20 542//________________________________________________________________________
00514d01 543Int_t AliAnalysisTaskSAJF::GetNumberOfTracks() const
25283b37 544{
e82e282c 545 if (fTracks)
546 return fTracks->GetEntriesFast();
547 else
548 return 0;
25283b37 549}
550
55264f20 551//________________________________________________________________________
00514d01 552AliVCluster* AliAnalysisTaskSAJF::GetCaloCluster(const Int_t i) const
e82e282c 553{
554 if (fCaloClusters)
555 return dynamic_cast<AliVCluster*>(fCaloClusters->At(i));
556 else
557 return 0;
25283b37 558}
559
55264f20 560//________________________________________________________________________
00514d01 561Int_t AliAnalysisTaskSAJF::GetNumberOfCaloClusters() const
e82e282c 562{
563 if (fCaloClusters)
564 return fCaloClusters->GetEntriesFast();
565 else
566 return 0;
25283b37 567}
568
55264f20 569//________________________________________________________________________
00514d01 570AliEmcalJet* AliAnalysisTaskSAJF::GetJet(const Int_t i) const
25283b37 571{
e82e282c 572 if (fJets)
573 return dynamic_cast<AliEmcalJet*>(fJets->At(i));
574 else
575 return 0;
25283b37 576}
577
55264f20 578//________________________________________________________________________
00514d01 579Int_t AliAnalysisTaskSAJF::GetNumberOfJets() const
25283b37 580{
e82e282c 581 if (fJets)
582 return fJets->GetEntriesFast();
583 else
584 return 0;
585}
586
2bee31e9 587//________________________________________________________________________
588AliEmcalJet* AliAnalysisTaskSAJF::GetEmbJet(const Int_t i) const
589{
590 if (fEmbJets)
591 return dynamic_cast<AliEmcalJet*>(fEmbJets->At(i));
592 else
593 return 0;
594}
595
596//________________________________________________________________________
597Int_t AliAnalysisTaskSAJF::GetNumberOfEmbJets() const
598{
599 if (fEmbJets)
600 return fEmbJets->GetEntriesFast();
601 else
602 return 0;
603}
604
55264f20 605//________________________________________________________________________
00514d01 606void AliAnalysisTaskSAJF::FillHistograms()
25283b37 607{
b12a85c3 608 const Float_t A = fJetRadius * fJetRadius * TMath::Pi();
a55e4f1d 609
55264f20 610 Int_t maxJetIndex = -1;
611 Int_t max2JetIndex = -1;
25283b37 612
b12a85c3 613 // ************
614 // General histograms
615 // _________________________________
616
55264f20 617 DoJetLoop(maxJetIndex, max2JetIndex);
618
619 if (maxJetIndex < 0)
620 return;
c554a987 621
55264f20 622 AliEmcalJet* jet = GetJet(maxJetIndex);
623 if (!jet)
624 return;
c554a987 625
11d4d636 626 fHistCentrality->Fill(fCent);
627
55264f20 628 fHistLeadingJetPt[fCentBin]->Fill(jet->Pt());
b12a85c3 629 fHistRhoVSleadJetPt->Fill(fRho * jet->Area(), jet->Pt());
630
55264f20 631 jet->SortConstituents();
632
633 AliEmcalJet* jet2 = 0;
634 if (max2JetIndex >= 0)
635 jet2 = GetJet(max2JetIndex);
636
b5ee47fb 637 if (jet2) {
638 fHist2LeadingJetPt[fCentBin]->Fill(jet2->Pt());
55264f20 639 jet2->SortConstituents();
b5ee47fb 640 }
c554a987 641
b12a85c3 642 fHistRho[fCentBin]->Fill(fRho);
b5ee47fb 643
226f511d 644 Float_t maxJetCorrPt = jet->Pt() - fRho * jet->Area();
645 if (maxJetCorrPt > 0)
646 fHistCorrLeadingJetPt[fCentBin]->Fill(maxJetCorrPt);
55264f20 647
b12a85c3 648 DoTrackLoop(maxJetIndex);
55264f20 649
b5ee47fb 650 if (fAnaType == kEMCAL)
b12a85c3 651 DoClusterLoop(maxJetIndex);
55264f20 652
b12a85c3 653 // ************
654 // Random cones
655 // _________________________________
a55e4f1d 656
b12a85c3 657 // Simple random cones
658 Float_t RCpt = 0;
659 Float_t RCeta = 0;
660 Float_t RCphi = 0;
661 GetRigidCone(RCpt, RCeta, RCphi, kFALSE, 0);
662 if (RCpt > 0) {
a55e4f1d 663 fHistRCPt[fCentBin]->Fill(RCpt / A);
b12a85c3 664 fHistDeltaPtRC[fCentBin]->Fill(RCpt - A * fRho);
665 }
666
667 // Random cones far from leading jet
668 Float_t RCptExLJ = 0;
669 Float_t RCetaExLJ = 0;
670 Float_t RCphiExLJ = 0;
671 GetRigidCone(RCptExLJ, RCetaExLJ, RCphiExLJ, kFALSE, jet);
672 if (RCptExLJ > 0) {
673 fHistRCPhiEta->Fill(RCetaExLJ, RCphiExLJ);
674 fHistRhoVSRCPt->Fill(fRho, RCptExLJ / A);
b5ee47fb 675
676 Float_t dphi = RCphiExLJ - jet->Phi();
677 if (dphi > 4.8) dphi -= TMath::Pi() * 2;
678 if (dphi < -1.6) dphi += TMath::Pi() * 2;
679 fHistRCPtExLJVSDPhiLJ->Fill(RCptExLJ, dphi);
b12a85c3 680
681 fHistRCPtExLJ[fCentBin]->Fill(RCptExLJ / A);
682 fHistDeltaPtRCExLJ[fCentBin]->Fill(RCptExLJ - A * fRho);
683 }
684
685 // Random cones with randomized particles
686 Float_t RCptRand = 0;
687 Float_t RCetaRand = 0;
688 Float_t RCphiRand = 0;
689 GetRigidCone(RCptRand, RCetaRand, RCphiRand, kTRUE, 0, fRandTracks, fRandCaloClusters);
690 if (RCptRand > 0) {
691 fHistRCPtRand[fCentBin]->Fill(RCptRand / A);
692 fHistDeltaPtRCRand[fCentBin]->Fill(RCptRand - A * fRho);
a55e4f1d 693 }
2bee31e9 694
b12a85c3 695 // ************
696 // Embedding
697 // _________________________________
698
699 AliEmcalJet *embJet = 0;
b5ee47fb 700 TObject *maxPart = 0;
2bee31e9 701
b12a85c3 702 DoEmbJetLoop(embJet, maxPart);
2bee31e9 703
b12a85c3 704 if (embJet && maxPart) {
b5ee47fb 705 Float_t maxEmbPartPt = 0;
706 Float_t maxEmbPartEta = 0;
707 Float_t maxEmbPartPhi = 0;
b12a85c3 708
709 AliVCluster *cluster = dynamic_cast<AliVCluster*>(maxPart);
b5ee47fb 710 if (cluster) {
b5ee47fb 711 TLorentzVector nPart;
b12a85c3 712 cluster->GetMomentum(nPart, fVertex);
b5ee47fb 713 Float_t pos[3];
714 cluster->GetPosition(pos);
715 TVector3 clusVec(pos);
716
717 maxEmbPartPt = nPart.Et();
718 maxEmbPartEta = clusVec.Eta();
719 maxEmbPartPhi = clusVec.Phi();
720 }
b5ee47fb 721 else {
b12a85c3 722 AliVTrack *track = dynamic_cast<AliVTrack*>(maxPart);
723 if (track) {
724 maxEmbPartPt = track->Pt();
725 maxEmbPartEta = track->Eta();
726 maxEmbPartPhi = track->Phi();
727 }
728 else {
729 AliWarning(Form("%s - Embedded particle type not recognized (neither AliVCluster nor AliVTrack)!", GetName()));
730 return;
731 }
b5ee47fb 732 }
b12a85c3 733 fHistEmbJets[fCentBin]->Fill(embJet->Pt());
2bee31e9 734 fHistEmbPart[fCentBin]->Fill(maxEmbPartPt);
b12a85c3 735 fHistEmbJetPhiEta->Fill(embJet->Eta(), embJet->Phi());
b5ee47fb 736 fHistEmbPartPhiEta->Fill(maxEmbPartEta, maxEmbPartPhi);
b12a85c3 737
738 fHistDeltaPtEmb[fCentBin]->Fill(embJet->Pt() - embJet->Area() * fRho - maxEmbPartPt);
739 fHistRhoVSEmbBkg->Fill(embJet->Area() * fRho, embJet->Pt() - maxEmbPartPt);
2bee31e9 740 }
741 else {
b12a85c3 742 AliWarning(Form("%s - Embedded particle not found in the event!", GetName()));
2bee31e9 743 }
55264f20 744}
745
746//________________________________________________________________________
747void AliAnalysisTaskSAJF::DoJetLoop(Int_t &maxJetIndex, Int_t &max2JetIndex)
748{
55264f20 749 Int_t njets = GetNumberOfJets();
55264f20 750
751 Float_t maxJetPt = 0;
752 Float_t max2JetPt = 0;
25283b37 753 for (Int_t ij = 0; ij < njets; ij++) {
f0a0fd33 754
25283b37 755 AliEmcalJet* jet = GetJet(ij);
f0a0fd33 756
25283b37 757 if (!jet) {
a55e4f1d 758 AliError(Form("Could not receive jet %d", ij));
25283b37 759 continue;
760 }
761
55264f20 762 if (jet->Pt() <= 0)
f0a0fd33 763 continue;
764
91f4b7c5 765 if (!AcceptJet(jet))
766 continue;
767
226f511d 768 Float_t corrPt = jet->Pt() - fRho * jet->Area();
769
11d4d636 770 fHistJetsPtNonBias[fCentBin]->Fill(jet->Pt());
771 fHistCorrJetsPtNonBias[fCentBin]->Fill(corrPt);
226f511d 772
b12a85c3 773 if (jet->MaxTrackPt() > fPtBiasJetTrack) {
774 fHistJetsPtTrack[fCentBin]->Fill(jet->Pt());
775 fHistCorrJetsPtTrack[fCentBin]->Fill(corrPt);
776 }
777
778 if (fAnaType == kEMCAL && jet->MaxClusterPt() > fPtBiasJetClus) {
779 fHistJetsPtClus[fCentBin]->Fill(jet->Pt());
780 fHistCorrJetsPtClus[fCentBin]->Fill(corrPt);
781 }
782
783 if (jet->MaxTrackPt() < fPtBiasJetTrack && (fAnaType == kTPC || jet->MaxClusterPt() < fPtBiasJetClus))
784 continue;
226f511d 785
11d4d636 786 fHistJetsPt[fCentBin]->Fill(jet->Pt());
787 fHistCorrJetsPt[fCentBin]->Fill(corrPt);
f0a0fd33 788
11d4d636 789 fHistJetPhiEta->Fill(jet->Eta(), jet->Phi());
b12a85c3 790
791 if (fAnaType == kEMCAL)
792 fHistJetsNEFvsPt[fCentBin]->Fill(jet->NEF(), jet->Pt());
226f511d 793
35789a2d 794 for (Int_t it = 0; it < jet->GetNumberOfTracks(); it++) {
a55e4f1d 795 AliVTrack *track = jet->TrackAt(it, fTracks);
35789a2d 796 if (track)
b12a85c3 797 fHistJetsZvsPt[fCentBin]->Fill(track->Pt() / jet->Pt(), jet->Pt());
35789a2d 798 }
a55e4f1d 799
35789a2d 800 for (Int_t ic = 0; ic < jet->GetNumberOfClusters(); ic++) {
a55e4f1d 801 AliVCluster *cluster = jet->ClusterAt(ic, fCaloClusters);
55264f20 802
803 if (cluster) {
804 TLorentzVector nPart;
b12a85c3 805 cluster->GetMomentum(nPart, fVertex);
11d4d636 806 fHistJetsZvsPt[fCentBin]->Fill(nPart.Et() / jet->Pt(), corrPt);
55264f20 807 }
f0a0fd33 808 }
809
11d4d636 810 if (maxJetPt < corrPt) {
55264f20 811 max2JetPt = maxJetPt;
c554a987 812 max2JetIndex = maxJetIndex;
11d4d636 813 maxJetPt = corrPt;
f0a0fd33 814 maxJetIndex = ij;
35789a2d 815 }
11d4d636 816 else if (max2JetPt < corrPt) {
817 max2JetPt = corrPt;
c554a987 818 max2JetIndex = ij;
819 }
25283b37 820 } //jet loop
55264f20 821}
e82e282c 822
55264f20 823//________________________________________________________________________
b12a85c3 824void AliAnalysisTaskSAJF::DoEmbJetLoop(AliEmcalJet* &embJet, TObject* &maxPart)
55264f20 825{
b12a85c3 826 TLorentzVector *maxClusVect = new TLorentzVector();
2bee31e9 827
828 Int_t nembjets = GetNumberOfEmbJets();
829
2bee31e9 830 for (Int_t ij = 0; ij < nembjets; ij++) {
831
832 AliEmcalJet* jet = GetEmbJet(ij);
833
834 if (!jet) {
835 AliError(Form("Could not receive jet %d", ij));
836 continue;
837 }
838
839 if (jet->Pt() <= 0)
840 continue;
841
b12a85c3 842 //if (!AcceptJet(jet))
843 //continue;
2bee31e9 844
b12a85c3 845 AliVTrack *maxTrack = 0;
2bee31e9 846
b12a85c3 847 for (Int_t it = 0; it < jet->GetNumberOfTracks(); it++) {
848 AliVTrack *track = jet->TrackAt(it, fTracks);
849
850 if (!track) continue;
851
852 if (!maxTrack || track->Pt() > maxTrack->Pt())
853 maxTrack = track;
2bee31e9 854 }
2bee31e9 855
b12a85c3 856 AliVCluster *maxClus = 0;
2bee31e9 857
b12a85c3 858 for (Int_t ic = 0; ic < jet->GetNumberOfClusters(); ic++) {
859 AliVCluster *cluster = jet->ClusterAt(ic, fCaloClusters);
860
861 if (!cluster) continue;
862
863 TLorentzVector nPart;
864 cluster->GetMomentum(nPart, fVertex);
865
866 if (!maxClus || nPart.Et() > maxClusVect->Et()) {
867 new (maxClusVect) TLorentzVector(nPart);
868 maxClus = cluster;
869 }
870 }
2bee31e9 871
b12a85c3 872 if ((maxClus && maxTrack && maxClusVect->Et() > maxTrack->Pt()) || (maxClus && !maxTrack)) {
873 if (maxClus->Chi2() == 100) {
874 maxPart = maxClus;
875 embJet = jet;
876 delete maxClusVect;
877 return;
878 }
879 }
880 else if (maxTrack) {
881 if (maxTrack->GetLabel() == 100) {
882 maxPart = maxTrack;
883 embJet = jet;
884 delete maxClusVect;
885 return;
886 }
887 }
2bee31e9 888 }
b12a85c3 889
890 delete maxClusVect;
2bee31e9 891}
892
893//________________________________________________________________________
b12a85c3 894void AliAnalysisTaskSAJF::DoTrackLoop(Int_t maxJetIndex)
2bee31e9 895{
27b20058 896 AliEmcalJet* jet = 0;
b12a85c3 897 if (maxJetIndex >= 0)
27b20058 898 jet = GetJet(maxJetIndex);
899
c554a987 900 Int_t ntracks = GetNumberOfTracks();
2bee31e9 901
c554a987 902 for(Int_t iTracks = 0; iTracks < ntracks; iTracks++) {
903 AliVTrack* track = GetTrack(iTracks);
904 if(!track) {
27b20058 905 AliError(Form("Could not retrieve track %d",iTracks));
c554a987 906 continue;
907 }
908
909 if (!AcceptTrack(track)) continue;
32bf39af 910
27b20058 911 if (jet && IsJetTrack(jet, iTracks)) {
55264f20 912 fHistTracksPtLJ[fCentBin]->Fill(track->Pt());
c554a987 913 }
b12a85c3 914 else {
55264f20 915 fHistTracksPtBkg[fCentBin]->Fill(track->Pt());
c554a987 916 }
55264f20 917 }
55264f20 918}
c554a987 919
55264f20 920//________________________________________________________________________
b12a85c3 921void AliAnalysisTaskSAJF::DoClusterLoop(Int_t maxJetIndex)
55264f20 922{
27b20058 923 AliEmcalJet* jet = 0;
b12a85c3 924 if (maxJetIndex >= 0)
27b20058 925 jet = GetJet(maxJetIndex);
926
f0a0fd33 927 Int_t nclusters = GetNumberOfCaloClusters();
928 for (Int_t iClusters = 0; iClusters < nclusters; iClusters++) {
929 AliVCluster* cluster = GetCaloCluster(iClusters);
e82e282c 930 if (!cluster) {
a55e4f1d 931 AliError(Form("Could not receive cluster %d", iClusters));
e82e282c 932 continue;
933 }
934
935 if (!(cluster->IsEMCAL())) continue;
f0a0fd33 936
2bee31e9 937 if (!AcceptCluster(cluster)) continue;
938
55264f20 939 TLorentzVector nPart;
b12a85c3 940 cluster->GetMomentum(nPart, fVertex);
32bf39af 941
27b20058 942 if (jet && IsJetCluster(jet, iClusters)) {
55264f20 943 fHistClusEtLJ[fCentBin]->Fill(nPart.Et());
f0a0fd33 944 }
b12a85c3 945 else {
55264f20 946 fHistClusEtBkg[fCentBin]->Fill(nPart.Et());
f0a0fd33 947 }
e82e282c 948 } //cluster loop
c554a987 949}
950
951//________________________________________________________________________
a55e4f1d 952void AliAnalysisTaskSAJF::Init()
c554a987 953{
b5ee47fb 954 if (fAnaType == kTPC) {
955 fMinEta = -0.9;
956 fMaxEta = 0.9;
957 fMinPhi = -10;
958 fMaxPhi = 10;
c554a987 959 }
b5ee47fb 960 else if (fAnaType == kEMCAL) {
a55e4f1d 961 fMinEta = -0.7;
962 fMaxEta = 0.7;
963 fMinPhi = 80 * TMath::DegToRad();
964 fMaxPhi = 180 * TMath::DegToRad();
c554a987 965 }
966 else {
b5ee47fb 967 AliWarning("Analysis type not recognized! Assuming kTPC...");
968 fAnaType = kTPC;
969 Init();
c554a987 970 }
b12a85c3 971
972 const Float_t semiDiag = TMath::Sqrt((fMaxPhi - fMinPhi) * (fMaxPhi - fMinPhi) + (fMaxEta - fMinEta) * (fMaxEta - fMinEta)) / 2;
973 if (fMinRC2LJ > semiDiag * 0.5) {
974 AliWarning(Form("The parameter fMinRC2LJ = %f is too large for the considered acceptance. Will use fMinRC2LJ = %f", fMinRC2LJ, semiDiag * 0.5));
975 fMinRC2LJ = semiDiag * 0.5;
976 }
c554a987 977}
978
a55e4f1d 979//________________________________________________________________________
b12a85c3 980void AliAnalysisTaskSAJF::GetRigidCone(Float_t &pt, Float_t &eta, Float_t &phi, Bool_t acceptMC,
981 AliEmcalJet *jet, TClonesArray* tracks, TClonesArray* clusters) const
a55e4f1d 982{
b12a85c3 983 if (!tracks)
984 tracks = fTracks;
a55e4f1d 985
b12a85c3 986 if (!clusters)
987 clusters = fCaloClusters;
a55e4f1d 988
b5ee47fb 989 eta = 0;
990 phi = 0;
b12a85c3 991 pt = 0;
a55e4f1d 992
993 Float_t LJeta = 999;
994 Float_t LJphi = 999;
995
996 if (jet) {
997 LJeta = jet->Eta();
998 LJphi = jet->Phi();
999 }
1000
b5ee47fb 1001 Float_t maxEta = fMaxEta - fJetRadius;
1002 Float_t minEta = fMinEta + fJetRadius;
1003 Float_t maxPhi = fMaxPhi - fJetRadius;
1004 Float_t minPhi = fMinPhi + fJetRadius;
1005
1006 if (maxPhi > TMath::Pi() * 2) maxPhi = TMath::Pi() * 2;
1007 if (minPhi < 0) minPhi = 0;
1008
a55e4f1d 1009 Float_t dLJ = 0;
b12a85c3 1010 Int_t repeats = 0;
a55e4f1d 1011 do {
b12a85c3 1012 eta = gRandom->Rndm() * (maxEta - minEta) + minEta;
1013 phi = gRandom->Rndm() * (maxPhi - minPhi) + minPhi;
a55e4f1d 1014 dLJ = TMath::Sqrt((LJeta - eta) * (LJeta - eta) + (LJphi - phi) * (LJphi - phi));
b12a85c3 1015 repeats++;
1016 } while (dLJ < fMinRC2LJ && repeats < 999);
1017
1018 if (repeats == 999)
1019 return;
b5ee47fb 1020
1021 if (fAnaType == kEMCAL) {
b12a85c3 1022 Int_t nclusters = clusters->GetEntriesFast();
b5ee47fb 1023 for (Int_t iClusters = 0; iClusters < nclusters; iClusters++) {
b12a85c3 1024 AliVCluster* cluster = dynamic_cast<AliVCluster*>(clusters->At(iClusters));
b5ee47fb 1025 if (!cluster) {
1026 AliError(Form("Could not receive cluster %d", iClusters));
1027 continue;
1028 }
1029
1030 if (!(cluster->IsEMCAL())) continue;
1031
b12a85c3 1032 if (!AcceptCluster(cluster, acceptMC)) continue;
b5ee47fb 1033
1034 TLorentzVector nPart;
b12a85c3 1035 cluster->GetMomentum(nPart, const_cast<Double_t*>(fVertex));
b5ee47fb 1036
1037 Float_t pos[3];
1038 cluster->GetPosition(pos);
1039 TVector3 clusVec(pos);
1040
1041 Float_t d = TMath::Sqrt((clusVec.Eta() - eta) * (clusVec.Eta() - eta) + (clusVec.Phi() - phi) * (clusVec.Phi() - phi));
1042
1043 if (d <= fJetRadius)
1044 pt += nPart.Pt();
1045 }
a55e4f1d 1046 }
1047
b12a85c3 1048 Int_t ntracks = tracks->GetEntriesFast();
a55e4f1d 1049 for(Int_t iTracks = 0; iTracks < ntracks; iTracks++) {
b12a85c3 1050 AliVTrack* track = dynamic_cast<AliVTrack*>(tracks->At(iTracks));
a55e4f1d 1051 if(!track) {
27b20058 1052 AliError(Form("Could not retrieve track %d",iTracks));
a55e4f1d 1053 continue;
1054 }
1055
b12a85c3 1056 if (!AcceptTrack(track, acceptMC)) continue;
a55e4f1d 1057
1058 Float_t tracketa = track->Eta();
1059 Float_t trackphi = track->Phi();
1060
1061 if (TMath::Abs(trackphi - phi) > TMath::Abs(trackphi - phi + 2 * TMath::Pi()))
1062 trackphi += 2 * TMath::Pi();
1063 if (TMath::Abs(trackphi - phi) > TMath::Abs(trackphi - phi - 2 * TMath::Pi()))
1064 trackphi -= 2 * TMath::Pi();
1065
1066 Float_t d = TMath::Sqrt((tracketa - eta) * (tracketa - eta) + (trackphi - phi) * (trackphi - phi));
1067
1068 if (d <= fJetRadius)
1069 pt += track->Pt();
1070 }
a55e4f1d 1071}
1072
c554a987 1073//________________________________________________________________________
1074Bool_t AliAnalysisTaskSAJF::IsJetTrack(AliEmcalJet* jet, Int_t itrack, Bool_t sorted) const
1075{
1076 for (Int_t i = 0; i < jet->GetNumberOfTracks(); i++) {
1077 Int_t ijettrack = jet->TrackAt(i);
1078 if (sorted && ijettrack > itrack)
1079 return kFALSE;
1080 if (ijettrack == itrack)
1081 return kTRUE;
1082 }
1083 return kFALSE;
1084}
1085
1086//________________________________________________________________________
1087Bool_t AliAnalysisTaskSAJF::IsJetCluster(AliEmcalJet* jet, Int_t iclus, Bool_t sorted) const
1088{
1089 for (Int_t i = 0; i < jet->GetNumberOfClusters(); i++) {
1090 Int_t ijetclus = jet->ClusterAt(i);
1091 if (sorted && ijetclus > iclus)
1092 return kFALSE;
1093 if (ijetclus == iclus)
1094 return kTRUE;
25283b37 1095 }
c554a987 1096 return kFALSE;
f0a0fd33 1097}
1098
91f4b7c5 1099//________________________________________________________________________
a55e4f1d 1100Bool_t AliAnalysisTaskSAJF::AcceptJet(Float_t eta, Float_t phi) const
91f4b7c5 1101{
b5ee47fb 1102 return (Bool_t)(eta > fMinEta + fJetRadius && eta < fMaxEta - fJetRadius && phi > fMinPhi + fJetRadius && phi < fMaxPhi - fJetRadius);
91f4b7c5 1103}
f0a0fd33 1104
a55e4f1d 1105//________________________________________________________________________
b12a85c3 1106Bool_t AliAnalysisTaskSAJF::AcceptJet(AliEmcalJet *jet) const
a55e4f1d 1107{
1108 return AcceptJet(jet->Eta(), jet->Phi());
1109}
1110
f0a0fd33 1111//________________________________________________________________________
b12a85c3 1112Bool_t AliAnalysisTaskSAJF::AcceptCluster(AliVCluster* clus, Bool_t acceptMC) const
2bee31e9 1113{
1114 if (!acceptMC && clus->Chi2() == 100)
1115 return kFALSE;
1116
226f511d 1117 TLorentzVector nPart;
b12a85c3 1118 clus->GetMomentum(nPart, const_cast<Double_t*>(fVertex));
226f511d 1119
1120 if (nPart.Et() < fPtCut)
1121 return kFALSE;
1122
2bee31e9 1123 return kTRUE;
1124}
1125
2bee31e9 1126//________________________________________________________________________
1127Bool_t AliAnalysisTaskSAJF::AcceptTrack(AliVTrack* track, Bool_t acceptMC) const
f0a0fd33 1128{
2bee31e9 1129 if (!acceptMC && track->GetLabel() == 100)
1130 return kFALSE;
226f511d 1131
1132 if (track->Pt() < fPtCut)
1133 return kFALSE;
2bee31e9 1134
b5ee47fb 1135 return (Bool_t)(track->Eta() > fMinEta && track->Eta() < fMaxEta && track->Phi() > fMinPhi && track->Phi() < fMaxPhi);
25283b37 1136}
1137
1138//________________________________________________________________________
00514d01 1139void AliAnalysisTaskSAJF::UserExec(Option_t *)
25283b37 1140{
a55e4f1d 1141 Init();
25283b37 1142
1143 RetrieveEventObjects();
1144
b12a85c3 1145 if (fRho < 0) {
1146 AliWarning(Form("Could not retrieve rho information! Event skipped!"));
1147 return;
1148 }
1149
25283b37 1150 FillHistograms();
1151
1152 // information for this iteration of the UserExec in the container
1153 PostData(1, fOutput);
1154}
1155
1156//________________________________________________________________________
00514d01 1157void AliAnalysisTaskSAJF::Terminate(Option_t *)
25283b37 1158{
1159 // Called once at the end of the analysis.
1160}