]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskSAJF.cxx
updates 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
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"
df43b607 20#include "AliVParticle.h"
6fd5039f 21#include "AliVTrack.h"
25283b37 22#include "AliEmcalJet.h"
23#include "AliVEventHandler.h"
e44e8726 24#include "AliRhoParameter.h"
55264f20 25#include "AliLog.h"
25283b37 26
00514d01 27#include "AliAnalysisTaskSAJF.h"
25283b37 28
00514d01 29ClassImp(AliAnalysisTaskSAJF)
25283b37 30
31//________________________________________________________________________
00514d01 32AliAnalysisTaskSAJF::AliAnalysisTaskSAJF() :
1f03e093 33 AliAnalysisTaskEmcalJet("AliAnalysisTaskSAJF", kTRUE),
121eb688 34 fMCAna(kFALSE),
b0e00dc4 35 fMinRC2LJ(-1),
2bee31e9 36 fEmbJetsName("EmbJets"),
e44e8726 37 fEmbTracksName(""),
38 fEmbCaloName(""),
b12a85c3 39 fRandTracksName("TracksRandomized"),
40 fRandCaloName("CaloClustersRandomized"),
226f511d 41 fRhoName("Rho"),
2bee31e9 42 fEmbJets(0),
e44e8726 43 fEmbTracks(0),
44 fEmbCaloClusters(0),
b12a85c3 45 fRandTracks(0),
46 fRandCaloClusters(0),
b12a85c3 47 fRho(0),
a5621834 48 fRhoVal(0),
a825589f 49 fEmbeddedClusterId(-1),
50 fEmbeddedTrackId(-1),
f0a0fd33 51 fHistCentrality(0),
a825589f 52 fHistDeltaVectorPt(0),
b12a85c3 53 fHistRhoVSleadJetPt(0),
54 fHistRCPhiEta(0),
55 fHistRCPtExLJVSDPhiLJ(0),
56 fHistRhoVSRCPt(0),
b5ee47fb 57 fHistEmbJetPhiEta(0),
58 fHistEmbPartPhiEta(0),
b12a85c3 59 fHistRhoVSEmbBkg(0)
226f511d 60
25283b37 61{
62 // Default constructor.
f0a0fd33 63
64 for (Int_t i = 0; i < 4; i++) {
e44e8726 65 fHistEvents[i] = 0;
66 fHistTracksPt[i] = 0;
67 fHistClustersPt[i] = 0;
df43b607 68 fHistJetPhiEta[i] = 0;
55264f20 69 fHistJetsPt[i] = 0;
df43b607 70 fHistJetsPtArea[i] = 0;
55264f20 71 fHistLeadingJetPt[i] = 0;
72 fHist2LeadingJetPt[i] = 0;
b12a85c3 73 fHistJetsNEFvsPt[i] = 0;
74 fHistJetsZvsPt[i] = 0;
e44e8726 75 fHistMaxTrackPtvsJetPt[i] = 0;
76 fHistMaxClusPtvsJetPt[i] = 0;
77 fHistMaxPartPtvsJetPt[i] = 0;
78 fHistMaxTrackPtvsJetCorrPt[i] = 0;
79 fHistMaxClusPtvsJetCorrPt[i] = 0;
80 fHistMaxPartPtvsJetCorrPt[i] = 0;
58285fc6 81 fHistConstituents[i] = 0;
b12a85c3 82 fHistRho[i] = 0;
c92284d5 83 fHistJetsCorrPt[i] = 0;
84 fHistJetsCorrPtArea[i] = 0;
85 fHistLeadingJetCorrPt[i] = 0;
9b265496 86 fHistRCPtRigid[i] = 0;
a55e4f1d 87 fHistRCPt[i] = 0;
88 fHistRCPtExLJ[i] = 0;
b12a85c3 89 fHistRCPtRand[i] = 0;
9b265496 90 fHistDeltaPtRCRigid[i] = 0;
b12a85c3 91 fHistDeltaPtRC[i] = 0;
92 fHistDeltaPtRCExLJ[i] = 0;
93 fHistDeltaPtRCRand[i] = 0;
b0e00dc4 94 fHistEmbNotFoundPhiEta[i] = 0;
e44e8726 95 fHistEmbJetsPt[i] = 0;
96 fHistEmbJetsCorrPt[i] = 0;
c92284d5 97 fHistEmbPartPt[i] = 0;
98 fHistDistEmbPartJetAxis[i] = 0;
b12a85c3 99 fHistDeltaPtEmb[i] = 0;
f0a0fd33 100 }
25283b37 101}
102
103//________________________________________________________________________
00514d01 104AliAnalysisTaskSAJF::AliAnalysisTaskSAJF(const char *name) :
1f03e093 105 AliAnalysisTaskEmcalJet(name, kTRUE),
121eb688 106 fMCAna(kFALSE),
b0e00dc4 107 fMinRC2LJ(-1),
2bee31e9 108 fEmbJetsName("EmbJets"),
e44e8726 109 fEmbTracksName(""),
110 fEmbCaloName(""),
b12a85c3 111 fRandTracksName("TracksRandomized"),
112 fRandCaloName("CaloClustersRandomized"),
226f511d 113 fRhoName("Rho"),
2bee31e9 114 fEmbJets(0),
e44e8726 115 fEmbTracks(0),
116 fEmbCaloClusters(0),
b12a85c3 117 fRandTracks(0),
118 fRandCaloClusters(0),
b12a85c3 119 fRho(0),
a5621834 120 fRhoVal(0),
a825589f 121 fEmbeddedClusterId(-1),
122 fEmbeddedTrackId(-1),
f0a0fd33 123 fHistCentrality(0),
a825589f 124 fHistDeltaVectorPt(0),
b12a85c3 125 fHistRhoVSleadJetPt(0),
126 fHistRCPhiEta(0),
127 fHistRCPtExLJVSDPhiLJ(0),
128 fHistRhoVSRCPt(0),
b5ee47fb 129 fHistEmbJetPhiEta(0),
130 fHistEmbPartPhiEta(0),
b12a85c3 131 fHistRhoVSEmbBkg(0)
25283b37 132{
133 // Standard constructor.
134
f0a0fd33 135 for (Int_t i = 0; i < 4; i++) {
e44e8726 136 fHistEvents[i] = 0;
137 fHistTracksPt[i] = 0;
138 fHistClustersPt[i] = 0;
df43b607 139 fHistJetPhiEta[i] = 0;
55264f20 140 fHistJetsPt[i] = 0;
df43b607 141 fHistJetsPtArea[i] = 0;
55264f20 142 fHistLeadingJetPt[i] = 0;
143 fHist2LeadingJetPt[i] = 0;
b12a85c3 144 fHistJetsNEFvsPt[i] = 0;
145 fHistJetsZvsPt[i] = 0;
e44e8726 146 fHistMaxTrackPtvsJetPt[i] = 0;
147 fHistMaxClusPtvsJetPt[i] = 0;
148 fHistMaxPartPtvsJetPt[i] = 0;
149 fHistMaxTrackPtvsJetCorrPt[i] = 0;
150 fHistMaxClusPtvsJetCorrPt[i] = 0;
151 fHistMaxPartPtvsJetCorrPt[i] = 0;
58285fc6 152 fHistConstituents[i] = 0;
b12a85c3 153 fHistRho[i] = 0;
c92284d5 154 fHistJetsCorrPt[i] = 0;
155 fHistJetsCorrPtArea[i] = 0;
156 fHistLeadingJetCorrPt[i] = 0;
9b265496 157 fHistRCPtRigid[i] = 0;
a55e4f1d 158 fHistRCPt[i] = 0;
159 fHistRCPtExLJ[i] = 0;
9b265496 160 fHistRCPtRand[i] = 0;
161 fHistDeltaPtRCRigid[i] = 0;
b12a85c3 162 fHistDeltaPtRC[i] = 0;
163 fHistDeltaPtRCExLJ[i] = 0;
164 fHistDeltaPtRCRand[i] = 0;
b0e00dc4 165 fHistEmbNotFoundPhiEta[i] = 0;
e44e8726 166 fHistEmbJetsPt[i] = 0;
167 fHistEmbJetsCorrPt[i] = 0;
c92284d5 168 fHistEmbPartPt[i] = 0;
169 fHistDistEmbPartJetAxis[i] = 0;
b12a85c3 170 fHistDeltaPtEmb[i] = 0;
f0a0fd33 171 }
25283b37 172}
173
174//________________________________________________________________________
00514d01 175AliAnalysisTaskSAJF::~AliAnalysisTaskSAJF()
25283b37 176{
16d143bd 177 // Destructor.
25283b37 178}
179
180//________________________________________________________________________
00514d01 181void AliAnalysisTaskSAJF::UserCreateOutputObjects()
25283b37 182{
16d143bd 183 // Create user output.
df43b607 184
16d143bd 185 AliAnalysisTaskEmcalJet::UserCreateOutputObjects();
25283b37 186
226f511d 187 OpenFile(1);
25283b37 188 fOutput = new TList();
226f511d 189 fOutput->SetOwner();
25283b37 190
fb9ac42f 191 fHistCentrality = new TH1F("fHistCentrality","fHistCentrality", fNbins, 0, 100);
f0a0fd33 192 fHistCentrality->GetXaxis()->SetTitle("Centrality (%)");
193 fHistCentrality->GetYaxis()->SetTitle("counts");
194 fOutput->Add(fHistCentrality);
25283b37 195
a825589f 196 fHistDeltaVectorPt = new TH1F("fHistDeltaVectorPt", "fHistDeltaVectorPt", fNbins, -50, 50);
197 fHistDeltaVectorPt->GetXaxis()->SetTitle("#deltap_{T} [GeV/c]");
198 fHistDeltaVectorPt->GetYaxis()->SetTitle("counts");
199 fOutput->Add(fHistDeltaVectorPt);
200
6fd5039f 201 fHistRhoVSleadJetPt = new TH2F("fHistRhoVSleadJetPt","fHistRhoVSleadJetPt", fNbins, fMinBinPt, fMaxBinPt, fNbins, fMinBinPt, fMaxBinPt);
b12a85c3 202 fHistRhoVSleadJetPt->GetXaxis()->SetTitle("#rho * area [GeV/c]");
203 fHistRhoVSleadJetPt->GetYaxis()->SetTitle("Leading jet p_{T} [GeV/c]");
204 fOutput->Add(fHistRhoVSleadJetPt);
b5ee47fb 205
6fd5039f 206 fHistRCPhiEta = new TH2F("fHistRCPhiEta","Phi-Eta distribution of rigid cones", 40, -2, 2, 64, 0, 6.4);
b12a85c3 207 fHistRCPhiEta->GetXaxis()->SetTitle("#eta");
208 fHistRCPhiEta->GetYaxis()->SetTitle("#phi");
209 fOutput->Add(fHistRCPhiEta);
b5ee47fb 210
6fd5039f 211 fHistRCPtExLJVSDPhiLJ = new TH2F("fHistRCPtExLJVSDPhiLJ","fHistRCPtExLJVSDPhiLJ", fNbins, fMinBinPt, fMaxBinPt, 128, -1.6, 4.8);
b12a85c3 212 fHistRCPtExLJVSDPhiLJ->GetXaxis()->SetTitle("rigid cone p_{T} [GeV/c]");
b5ee47fb 213 fHistRCPtExLJVSDPhiLJ->GetYaxis()->SetTitle("#Delta#phi");
214 fOutput->Add(fHistRCPtExLJVSDPhiLJ);
215
6fd5039f 216 fHistRhoVSRCPt = new TH2F("fHistRhoVSRCPt","fHistRhoVSRCPt", fNbins, fMinBinPt, fMaxBinPt, fNbins, fMinBinPt, fMaxBinPt);
c92284d5 217 fHistRhoVSRCPt->GetXaxis()->SetTitle("A#rho [GeV/c]");
b12a85c3 218 fHistRhoVSRCPt->GetYaxis()->SetTitle("rigid cone p_{T} [GeV/c]");
219 fOutput->Add(fHistRhoVSRCPt);
220
e44e8726 221 if (!fEmbJetsName.IsNull()) {
222 fHistEmbJetPhiEta = new TH2F("fHistEmbJetPhiEta","Phi-Eta distribution of embedded jets", 40, -2, 2, 64, 0, 6.4);
223 fHistEmbJetPhiEta->GetXaxis()->SetTitle("#eta");
224 fHistEmbJetPhiEta->GetYaxis()->SetTitle("#phi");
225 fOutput->Add(fHistEmbJetPhiEta);
226
227 fHistEmbPartPhiEta = new TH2F("fHistEmbPartPhiEta","Phi-Eta distribution of embedded particles", 40, -2, 2, 64, 0, 6.4);
228 fHistEmbPartPhiEta->GetXaxis()->SetTitle("#eta");
229 fHistEmbPartPhiEta->GetYaxis()->SetTitle("#phi");
230 fOutput->Add(fHistEmbPartPhiEta);
231
232 fHistRhoVSEmbBkg = new TH2F("fHistRhoVSEmbBkg","fHistRhoVSEmbBkg", fNbins, fMinBinPt, fMaxBinPt, fNbins, fMinBinPt, fMaxBinPt);
c92284d5 233 fHistRhoVSEmbBkg->GetXaxis()->SetTitle("A#rho [GeV/c]");
e44e8726 234 fHistRhoVSEmbBkg->GetYaxis()->SetTitle("background of embedded track [GeV/c]");
235 fOutput->Add(fHistRhoVSEmbBkg);
236 }
b5ee47fb 237
f0a0fd33 238 TString histname;
239
240 for (Int_t i = 0; i < 4; i++) {
e44e8726 241 histname = "fHistEvents_";
242 histname += i;
243 fHistEvents[i] = new TH1F(histname,histname, 6, 0, 6);
244 fHistEvents[i]->GetXaxis()->SetTitle("Event state");
245 fHistEvents[i]->GetYaxis()->SetTitle("counts");
a5621834 246 fHistEvents[i]->GetXaxis()->SetBinLabel(1, "No jets");
e22bc1b8 247 fHistEvents[i]->GetXaxis()->SetBinLabel(2, "Max jet not found");
a5621834 248 fHistEvents[i]->GetXaxis()->SetBinLabel(3, "Rho == 0");
e22bc1b8 249 fHistEvents[i]->GetXaxis()->SetBinLabel(4, "Max jet <= 0");
a5621834 250 fHistEvents[i]->GetXaxis()->SetBinLabel(5, "OK");
e44e8726 251 fOutput->Add(fHistEvents[i]);
252
a5621834 253 if (fAnaType != kEMCALOnly) {
254 histname = "fHistTracksPt_";
255 histname += i;
be7b6e63 256 fHistTracksPt[i] = new TH1F(histname.Data(), histname.Data(), (Int_t)(fNbins / 2.5), fMinBinPt, fMaxBinPt / 2.5);
a5621834 257 fHistTracksPt[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
258 fHistTracksPt[i]->GetYaxis()->SetTitle("counts");
259 fOutput->Add(fHistTracksPt[i]);
260 }
e44e8726 261
a5621834 262 if (fAnaType == kEMCAL || fAnaType == kEMCALOnly) {
e44e8726 263 histname = "fHistClustersPt_";
264 histname += i;
be7b6e63 265 fHistClustersPt[i] = new TH1F(histname.Data(), histname.Data(), (Int_t)(fNbins / 2.5), fMinBinPt, fMaxBinPt / 2.5);
e44e8726 266 fHistClustersPt[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
267 fHistClustersPt[i]->GetYaxis()->SetTitle("counts");
268 fOutput->Add(fHistClustersPt[i]);
269 }
270
df43b607 271 histname = "fHistJetPhiEta_";
272 histname += i;
6fd5039f 273 fHistJetPhiEta[i] = new TH2F(histname.Data(), histname.Data(), 40, -2, 2, 64, 0, 6.4);
df43b607 274 fHistJetPhiEta[i]->GetXaxis()->SetTitle("#eta");
275 fHistJetPhiEta[i]->GetYaxis()->SetTitle("#phi");
276 fOutput->Add(fHistJetPhiEta[i]);
277
55264f20 278 histname = "fHistJetsPt_";
f0a0fd33 279 histname += i;
6fd5039f 280 fHistJetsPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt);
e44e8726 281 fHistJetsPt[i]->GetXaxis()->SetTitle("p_{T}^{raw} [GeV/c]");
55264f20 282 fHistJetsPt[i]->GetYaxis()->SetTitle("counts");
283 fOutput->Add(fHistJetsPt[i]);
226f511d 284
df43b607 285 histname = "fHistJetsPtArea_";
286 histname += i;
5d950148 287 fHistJetsPtArea[i] = new TH2F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt, 40, 0, fJetRadius * fJetRadius * TMath::Pi() * 3);
e44e8726 288 fHistJetsPtArea[i]->GetXaxis()->SetTitle("p_{T}^{raw} [GeV/c]");
df43b607 289 fHistJetsPtArea[i]->GetYaxis()->SetTitle("area");
290 fOutput->Add(fHistJetsPtArea[i]);
291
55264f20 292 histname = "fHistLeadingJetPt_";
f0a0fd33 293 histname += i;
6fd5039f 294 fHistLeadingJetPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt);
e44e8726 295 fHistLeadingJetPt[i]->GetXaxis()->SetTitle("p_{T}^{raw} [GeV]");
55264f20 296 fHistLeadingJetPt[i]->GetYaxis()->SetTitle("counts");
297 fOutput->Add(fHistLeadingJetPt[i]);
b5ee47fb 298
299 histname = "fHist2LeadingJetPt_";
300 histname += i;
6fd5039f 301 fHist2LeadingJetPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt);
e44e8726 302 fHist2LeadingJetPt[i]->GetXaxis()->SetTitle("p_{T}^{raw} [GeV]");
b5ee47fb 303 fHist2LeadingJetPt[i]->GetYaxis()->SetTitle("counts");
304 fOutput->Add(fHist2LeadingJetPt[i]);
305
b12a85c3 306 histname = "fHistJetsZvsPt_";
b5ee47fb 307 histname += i;
6fd5039f 308 fHistJetsZvsPt[i] = new TH2F(histname.Data(), histname.Data(), fNbins, 0, 1.2, fNbins, fMinBinPt, fMaxBinPt);
b12a85c3 309 fHistJetsZvsPt[i]->GetXaxis()->SetTitle("Z");
e44e8726 310 fHistJetsZvsPt[i]->GetYaxis()->SetTitle("p_{T}^{raw} [GeV/c]");
b12a85c3 311 fOutput->Add(fHistJetsZvsPt[i]);
312
a5621834 313 if (fAnaType == kEMCAL || fAnaType == kEMCALOnly) {
b12a85c3 314 histname = "fHistJetsNEFvsPt_";
315 histname += i;
6fd5039f 316 fHistJetsNEFvsPt[i] = new TH2F(histname.Data(), histname.Data(), fNbins, 0, 1.2, fNbins, fMinBinPt, fMaxBinPt);
b12a85c3 317 fHistJetsNEFvsPt[i]->GetXaxis()->SetTitle("NEF");
e44e8726 318 fHistJetsNEFvsPt[i]->GetYaxis()->SetTitle("p_{T}^{raw} [GeV/c]");
b12a85c3 319 fOutput->Add(fHistJetsNEFvsPt[i]);
b12a85c3 320 }
321
a5621834 322 if (fAnaType != kEMCALOnly) {
323 histname = "fHistMaxTrackPtvsJetPt_";
324 histname += i;
be7b6e63 325 fHistMaxTrackPtvsJetPt[i] = new TH2F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt, (Int_t)(fNbins / 2.5), fMinBinPt, fMaxBinPt / 2.5);
a5621834 326 fHistMaxTrackPtvsJetPt[i]->GetXaxis()->SetTitle("p_{T}^{jet} [GeV/c]");
327 fHistMaxTrackPtvsJetPt[i]->GetYaxis()->SetTitle("p_{T}^{track} [GeV/c]");
328 fOutput->Add(fHistMaxTrackPtvsJetPt[i]);
329 }
e44e8726 330
a5621834 331 if (fAnaType == kEMCAL || fAnaType == kEMCALOnly) {
e44e8726 332 histname = "fHistMaxClusPtvsJetPt_";
333 histname += i;
be7b6e63 334 fHistMaxClusPtvsJetPt[i] = new TH2F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt, (Int_t)(fNbins / 2.5), fMinBinPt, fMaxBinPt / 2.5);
e44e8726 335 fHistMaxClusPtvsJetPt[i]->GetXaxis()->SetTitle("p_{T}^{jet} [GeV/c]");
336 fHistMaxClusPtvsJetPt[i]->GetYaxis()->SetTitle("p_{T}^{clus} [GeV/c]");
337 fOutput->Add(fHistMaxClusPtvsJetPt[i]);
338 }
339
340 histname = "fHistMaxPartPtvsJetPt_";
341 histname += i;
be7b6e63 342 fHistMaxPartPtvsJetPt[i] = new TH2F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt, (Int_t)(fNbins / 2.5), fMinBinPt, fMaxBinPt / 2.5);
e44e8726 343 fHistMaxPartPtvsJetPt[i]->GetXaxis()->SetTitle("p_{T}^{jet} [GeV/c]");
344 fHistMaxPartPtvsJetPt[i]->GetYaxis()->SetTitle("p_{T}^{part} [GeV/c]");
345 fOutput->Add(fHistMaxPartPtvsJetPt[i]);
346
a5621834 347 if (fAnaType != kEMCALOnly) {
348 histname = "fHistMaxTrackPtvsJetCorrPt_";
349 histname += i;
be7b6e63 350 fHistMaxTrackPtvsJetCorrPt[i] = new TH2F(histname.Data(), histname.Data(), fNbins * 2, -fMaxBinPt, fMaxBinPt, (Int_t)(fNbins / 2.5), fMinBinPt, fMaxBinPt / 2.5);
a5621834 351 fHistMaxTrackPtvsJetCorrPt[i]->GetXaxis()->SetTitle("p_{T}^{jet} [GeV/c]");
352 fHistMaxTrackPtvsJetCorrPt[i]->GetYaxis()->SetTitle("p_{T}^{track} [GeV/c]");
353 fOutput->Add(fHistMaxTrackPtvsJetCorrPt[i]);
354 }
e44e8726 355
a5621834 356 if (fAnaType == kEMCAL || fAnaType == kEMCALOnly) {
e44e8726 357 histname = "fHistMaxClusPtvsJetCorrPt_";
358 histname += i;
be7b6e63 359 fHistMaxClusPtvsJetCorrPt[i] = new TH2F(histname.Data(), histname.Data(), fNbins * 2, -fMaxBinPt, fMaxBinPt, (Int_t)(fNbins / 2.5), fMinBinPt, fMaxBinPt / 2.5);
e44e8726 360 fHistMaxClusPtvsJetCorrPt[i]->GetXaxis()->SetTitle("p_{T}^{jet} [GeV/c]");
361 fHistMaxClusPtvsJetCorrPt[i]->GetYaxis()->SetTitle("p_{T}^{clus} [GeV/c]");
362 fOutput->Add(fHistMaxClusPtvsJetCorrPt[i]);
363 }
364
365 histname = "fHistMaxPartPtvsJetCorrPt_";
366 histname += i;
58285fc6 367 fHistMaxPartPtvsJetCorrPt[i] = new TH2F(histname.Data(), histname.Data(), fNbins * 2, -fMaxBinPt, fMaxBinPt, (Int_t)(fNbins / 2.5), fMinBinPt, fMaxBinPt / 2.5);
e44e8726 368 fHistMaxPartPtvsJetCorrPt[i]->GetXaxis()->SetTitle("p_{T}^{jet} [GeV/c]");
369 fHistMaxPartPtvsJetCorrPt[i]->GetYaxis()->SetTitle("p_{T}^{part} [GeV/c]");
370 fOutput->Add(fHistMaxPartPtvsJetCorrPt[i]);
371
58285fc6 372 histname = "fHistConstituents_";
373 histname += i;
374 fHistConstituents[i] = new TH2F(histname.Data(), histname.Data(), 100, 1, 101, 100, -0.5, 99.5);
375 fHistConstituents[i]->GetXaxis()->SetTitle("p_{T,part} [GeV/c]");
376 fHistConstituents[i]->GetYaxis()->SetTitle("no. of particles");
377 fOutput->Add(fHistConstituents[i]);
378
b12a85c3 379 histname = "fHistRho_";
380 histname += i;
6fd5039f 381 fHistRho[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt * 2);
b12a85c3 382 fHistRho[i]->GetXaxis()->SetTitle("p_{T} [GeV/c]");
383 fHistRho[i]->GetYaxis()->SetTitle("counts");
384 fOutput->Add(fHistRho[i]);
385
c92284d5 386 histname = "fHistJetsCorrPt_";
b12a85c3 387 histname += i;
c92284d5 388 fHistJetsCorrPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins * 2, -fMaxBinPt, fMaxBinPt);
389 fHistJetsCorrPt[i]->GetXaxis()->SetTitle("p_{T}^{corr} [GeV/c]");
390 fHistJetsCorrPt[i]->GetYaxis()->SetTitle("counts");
391 fOutput->Add(fHistJetsCorrPt[i]);
b12a85c3 392
c92284d5 393 histname = "fHistJetsCorrPtArea_";
2bddb6ae 394 histname += i;
5d950148 395 fHistJetsCorrPtArea[i] = new TH2F(histname.Data(), histname.Data(), fNbins * 2, -fMaxBinPt, fMaxBinPt, 40, 0, fJetRadius * fJetRadius * TMath::Pi() * 3);
c92284d5 396 fHistJetsCorrPtArea[i]->GetXaxis()->SetTitle("p_{T}^{corr} [GeV/c]");
397 fHistJetsCorrPtArea[i]->GetYaxis()->SetTitle("area");
398 fOutput->Add(fHistJetsCorrPtArea[i]);
2bddb6ae 399
c92284d5 400 histname = "fHistLeadingJetCorrPt_";
b12a85c3 401 histname += i;
c92284d5 402 fHistLeadingJetCorrPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins * 2, -fMaxBinPt, fMaxBinPt);
403 fHistLeadingJetCorrPt[i]->GetXaxis()->SetTitle("p_{T}^{RC} [GeV/c]");
404 fHistLeadingJetCorrPt[i]->GetYaxis()->SetTitle("counts");
405 fOutput->Add(fHistLeadingJetCorrPt[i]);
9b265496 406
407 histname = "fHistRCPtRigid_";
408 histname += i;
409 fHistRCPtRigid[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt * 2);
410 fHistRCPtRigid[i]->GetXaxis()->SetTitle("rigid cone p_{T} [GeV/c]");
411 fHistRCPtRigid[i]->GetYaxis()->SetTitle("counts");
412 fOutput->Add(fHistRCPtRigid[i]);
413
b12a85c3 414 histname = "fHistRCPt_";
c554a987 415 histname += i;
6fd5039f 416 fHistRCPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt * 2);
b12a85c3 417 fHistRCPt[i]->GetXaxis()->SetTitle("rigid cone p_{T} [GeV/c]");
418 fHistRCPt[i]->GetYaxis()->SetTitle("counts");
419 fOutput->Add(fHistRCPt[i]);
c554a987 420
b12a85c3 421 histname = "fHistRCPtExLJ_";
c554a987 422 histname += i;
6fd5039f 423 fHistRCPtExLJ[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt * 2);
e44e8726 424 fHistRCPtExLJ[i]->GetXaxis()->SetTitle("rigid cone p_{T}^{RC} [GeV/c]");
b12a85c3 425 fHistRCPtExLJ[i]->GetYaxis()->SetTitle("counts");
426 fOutput->Add(fHistRCPtExLJ[i]);
c554a987 427
b12a85c3 428 histname = "fHistRCPtRand_";
c554a987 429 histname += i;
6fd5039f 430 fHistRCPtRand[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt * 2);
e44e8726 431 fHistRCPtRand[i]->GetXaxis()->SetTitle("rigid cone p_{T}^{RC} [GeV/c]");
b12a85c3 432 fHistRCPtRand[i]->GetYaxis()->SetTitle("counts");
433 fOutput->Add(fHistRCPtRand[i]);
a55e4f1d 434
9b265496 435 histname = "fHistDeltaPtRCRigid_";
436 histname += i;
437 fHistDeltaPtRCRigid[i] = new TH1F(histname.Data(), histname.Data(), fNbins * 2, -fMaxBinPt, fMaxBinPt);
438 fHistDeltaPtRCRigid[i]->GetXaxis()->SetTitle("#deltap_{T}^{RC} [GeV/c]");
439 fHistDeltaPtRCRigid[i]->GetYaxis()->SetTitle("counts");
440 fOutput->Add(fHistDeltaPtRCRigid[i]);
441
a55e4f1d 442 histname = "fHistDeltaPtRC_";
443 histname += i;
3a322119 444 fHistDeltaPtRC[i] = new TH1F(histname.Data(), histname.Data(), fNbins * 2, -fMaxBinPt, fMaxBinPt);
e44e8726 445 fHistDeltaPtRC[i]->GetXaxis()->SetTitle("#deltap_{T}^{RC} [GeV/c]");
a55e4f1d 446 fHistDeltaPtRC[i]->GetYaxis()->SetTitle("counts");
447 fOutput->Add(fHistDeltaPtRC[i]);
448
449 histname = "fHistDeltaPtRCExLJ_";
450 histname += i;
3a322119 451 fHistDeltaPtRCExLJ[i] = new TH1F(histname.Data(), histname.Data(), fNbins * 2, -fMaxBinPt, fMaxBinPt);
e44e8726 452 fHistDeltaPtRCExLJ[i]->GetXaxis()->SetTitle("#deltap_{T}^{RC} [GeV/c]");
a55e4f1d 453 fHistDeltaPtRCExLJ[i]->GetYaxis()->SetTitle("counts");
454 fOutput->Add(fHistDeltaPtRCExLJ[i]);
455
b12a85c3 456 histname = "fHistDeltaPtRCRand_";
a55e4f1d 457 histname += i;
3a322119 458 fHistDeltaPtRCRand[i] = new TH1F(histname.Data(), histname.Data(), fNbins * 2, -fMaxBinPt, fMaxBinPt);
e44e8726 459 fHistDeltaPtRCRand[i]->GetXaxis()->SetTitle("#deltap_{T}^{RC} [GeV/c]");
b12a85c3 460 fHistDeltaPtRCRand[i]->GetYaxis()->SetTitle("counts");
461 fOutput->Add(fHistDeltaPtRCRand[i]);
2bee31e9 462
e44e8726 463 if (!fEmbJetsName.IsNull()) {
464 histname = "fHistEmbJetsPt_";
465 histname += i;
466 fHistEmbJetsPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt);
467 fHistEmbJetsPt[i]->GetXaxis()->SetTitle("embedded jet p_{T}^{raw} [GeV/c]");
468 fHistEmbJetsPt[i]->GetYaxis()->SetTitle("counts");
469 fOutput->Add(fHistEmbJetsPt[i]);
2bee31e9 470
e44e8726 471 histname = "fHistEmbJetsCorrPt_";
472 histname += i;
2510bb9c 473 fHistEmbJetsCorrPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins * 2, -fMaxBinPt, fMaxBinPt);
e44e8726 474 fHistEmbJetsCorrPt[i]->GetXaxis()->SetTitle("embedded jet p_{T}^{corr} [GeV/c]");
475 fHistEmbJetsCorrPt[i]->GetYaxis()->SetTitle("counts");
476 fOutput->Add(fHistEmbJetsCorrPt[i]);
11d18b51 477
478 histname = "fHistEmbJetsArea_";
479 histname += i;
5d950148 480 fHistEmbJetsArea[i] = new TH1F(histname.Data(), histname.Data(), 40, 0, fJetRadius * fJetRadius * TMath::Pi() * 3);
11d18b51 481 fHistEmbJetsArea[i]->GetXaxis()->SetTitle("area");
482 fHistEmbJetsArea[i]->GetYaxis()->SetTitle("counts");
483 fOutput->Add(fHistEmbJetsArea[i]);
484
c92284d5 485 histname = "fHistEmbPartPt_";
e44e8726 486 histname += i;
c92284d5 487 fHistEmbPartPt[i] = new TH1F(histname.Data(), histname.Data(), fNbins, fMinBinPt, fMaxBinPt);
488 fHistEmbPartPt[i]->GetXaxis()->SetTitle("embedded particle p_{T}^{emb} [GeV/c]");
489 fHistEmbPartPt[i]->GetYaxis()->SetTitle("counts");
490 fOutput->Add(fHistEmbPartPt[i]);
491
492 histname = "fHistDistEmbPartJetAxis_";
493 histname += i;
494 fHistDistEmbPartJetAxis[i] = new TH1F(histname.Data(), histname.Data(), 50, 0, 0.5);
495 fHistDistEmbPartJetAxis[i]->GetXaxis()->SetTitle("distance");
496 fHistDistEmbPartJetAxis[i]->GetYaxis()->SetTitle("counts");
497 fOutput->Add(fHistDistEmbPartJetAxis[i]);
b0e00dc4 498
499 histname = "fHistEmbNotFoundPhiEta_";
500 histname += i;
501 fHistEmbNotFoundPhiEta[i] = new TH2F(histname.Data(), histname.Data(), 40, -2, 2, 64, 0, 6.4);
502 fHistEmbNotFoundPhiEta[i]->GetXaxis()->SetTitle("#eta");
503 fHistEmbNotFoundPhiEta[i]->GetYaxis()->SetTitle("#phi");
504 fOutput->Add(fHistEmbNotFoundPhiEta[i]);
e44e8726 505
506 histname = "fHistDeltaPtEmb_";
507 histname += i;
3a322119 508 fHistDeltaPtEmb[i] = new TH1F(histname.Data(), histname.Data(), fNbins * 2, -fMaxBinPt, fMaxBinPt);
e44e8726 509 fHistDeltaPtEmb[i]->GetXaxis()->SetTitle("#deltap_{T}^{emb} [GeV/c]");
510 fHistDeltaPtEmb[i]->GetYaxis()->SetTitle("counts");
511 fOutput->Add(fHistDeltaPtEmb[i]);
512 }
e82e282c 513 }
514
25283b37 515 PostData(1, fOutput); // Post data for ALL output slots >0 here, to get at least an empty histogram
516}
517
55264f20 518//________________________________________________________________________
6fd5039f 519Bool_t AliAnalysisTaskSAJF::RetrieveEventObjects()
25283b37 520{
16d143bd 521 // Retrieve event objects.
522
523 if (!AliAnalysisTaskEmcalJet::RetrieveEventObjects())
6fd5039f 524 return kFALSE;
6fd5039f 525
a5621834 526 if (fRho)
527 fRhoVal = fRho->GetVal();
f0a0fd33 528
6fd5039f 529 return kTRUE;
2bee31e9 530}
531
55264f20 532//________________________________________________________________________
6fd5039f 533Bool_t AliAnalysisTaskSAJF::FillHistograms()
25283b37 534{
16d143bd 535 // Fill histograms.
536
55264f20 537 Int_t maxJetIndex = -1;
538 Int_t max2JetIndex = -1;
25283b37 539
6fd5039f 540 GetLeadingJets(maxJetIndex, max2JetIndex);
55264f20 541
a5621834 542 if (maxJetIndex < 0) { // no accepted jet, skipping
e44e8726 543 fHistEvents[fCentBin]->Fill("No jets", 1);
544 return kTRUE;
fb9ac42f 545 }
c554a987 546
e44e8726 547 AliEmcalJet* jet = static_cast<AliEmcalJet*>(fJets->At(maxJetIndex));
548 if (!jet) { // error, I cannot get the lead jet from collection (should never happen), skipping
e22bc1b8 549 fHistEvents[fCentBin]->Fill("Max jet not found", 1);
e44e8726 550 return kTRUE;
fb9ac42f 551 }
c554a987 552
e44e8726 553 // OK, event accepted
11d4d636 554
a5621834 555 if (fRhoVal == 0)
556 fHistEvents[fCentBin]->Fill("Rho == 0", 1);
557
558 Float_t maxJetCorrPt = jet->Pt() - fRhoVal * jet->Area();
e44e8726 559
560 if (maxJetCorrPt <= 0)
e22bc1b8 561 fHistEvents[fCentBin]->Fill("Max jet <= 0", 1);
e44e8726 562
a5621834 563 fHistEvents[fCentBin]->Fill("OK", 1);
e44e8726 564
565 // ************
566 // General histograms
567 // _________________________________
568
569 DoJetLoop();
570 DoTrackLoop();
571 DoClusterLoop();
b12a85c3 572
6fd5039f 573 fHistCentrality->Fill(fCent);
a5621834 574 fHistRho[fCentBin]->Fill(fRhoVal);
6fd5039f 575
576 if (jet) {
577 fHistLeadingJetPt[fCentBin]->Fill(jet->Pt());
a5621834 578 fHistRhoVSleadJetPt->Fill(fRhoVal * jet->Area(), jet->Pt());
c92284d5 579 fHistLeadingJetCorrPt[fCentBin]->Fill(maxJetCorrPt);
6fd5039f 580 }
55264f20 581
582 AliEmcalJet* jet2 = 0;
583 if (max2JetIndex >= 0)
e44e8726 584 jet2 = static_cast<AliEmcalJet*>(fJets->At(max2JetIndex));
55264f20 585
6fd5039f 586 if (jet2)
b5ee47fb 587 fHist2LeadingJetPt[fCentBin]->Fill(jet2->Pt());
b5ee47fb 588
b12a85c3 589 // ************
590 // Random cones
591 // _________________________________
a55e4f1d 592
d41a0b1c 593 const Float_t rcArea = fJetRadius * fJetRadius * TMath::Pi();
a5621834 594
b12a85c3 595 // Simple random cones
596 Float_t RCpt = 0;
9b265496 597 Float_t RCptRigid = 0;
b12a85c3 598 Float_t RCeta = 0;
599 Float_t RCphi = 0;
a5621834 600 GetRigidCone(RCpt, RCptRigid, RCeta, RCphi, 0);
b12a85c3 601 if (RCpt > 0) {
d41a0b1c 602 fHistRCPt[fCentBin]->Fill(RCpt / rcArea);
a5621834 603 fHistDeltaPtRC[fCentBin]->Fill(RCpt - rcArea * fRhoVal);
b12a85c3 604 }
9b265496 605 if (RCptRigid > 0) {
606 fHistRCPtRigid[fCentBin]->Fill(RCptRigid / rcArea);
a5621834 607 fHistDeltaPtRCRigid[fCentBin]->Fill(RCptRigid - rcArea * fRhoVal);
9b265496 608 }
b12a85c3 609
610 // Random cones far from leading jet
9b265496 611 RCpt = 0;
612 RCptRigid = 0;
613 RCeta = 0;
614 RCphi = 0;
a5621834 615 GetRigidCone(RCpt, RCptRigid, RCeta, RCphi, jet);
9b265496 616 if (RCpt > 0) {
617 fHistRCPhiEta->Fill(RCeta, RCphi);
a5621834 618 fHistRhoVSRCPt->Fill(fRhoVal, RCpt / rcArea);
9b265496 619
620 Float_t dphi = RCphi - jet->Phi();
b5ee47fb 621 if (dphi > 4.8) dphi -= TMath::Pi() * 2;
622 if (dphi < -1.6) dphi += TMath::Pi() * 2;
9b265496 623 fHistRCPtExLJVSDPhiLJ->Fill(RCpt, dphi);
b12a85c3 624
9b265496 625 fHistRCPtExLJ[fCentBin]->Fill(RCpt / rcArea);
a5621834 626 fHistDeltaPtRCExLJ[fCentBin]->Fill(RCpt - rcArea * fRhoVal);
b12a85c3 627 }
628
629 // Random cones with randomized particles
9b265496 630 RCpt = 0;
631 RCptRigid = 0;
632 RCeta = 0;
633 RCphi = 0;
a5621834 634 GetRigidCone(RCpt, RCptRigid, RCeta, RCphi, 0, fRandTracks, fRandCaloClusters);
9b265496 635 if (RCpt > 0) {
636 fHistRCPtRand[fCentBin]->Fill(RCpt / rcArea);
a5621834 637 fHistDeltaPtRCRand[fCentBin]->Fill(RCpt - rcArea * fRhoVal);
a55e4f1d 638 }
2bee31e9 639
b12a85c3 640 // ************
641 // Embedding
642 // _________________________________
643
df43b607 644 if (!fEmbJets)
6fd5039f 645 return kTRUE;
df43b607 646
b12a85c3 647 AliEmcalJet *embJet = 0;
e44e8726 648 TObject *embPart = 0;
2bee31e9 649
e44e8726 650 DoEmbJetLoop(embJet, embPart);
2bee31e9 651
fb9ac42f 652 if (embJet) {
a825589f 653 Double_t probePt = 0;
c92284d5 654 Double_t probeEta = 0;
655 Double_t probePhi = 0;
b12a85c3 656
e44e8726 657 AliVCluster *cluster = dynamic_cast<AliVCluster*>(embPart);
b5ee47fb 658 if (cluster) {
a825589f 659 TLorentzVector nPart;
660 cluster->GetMomentum(nPart, fVertex);
c92284d5 661
662 probeEta = nPart.Eta();
663 probePhi = nPart.Phi();
a825589f 664 probePt = nPart.Pt();
b5ee47fb 665 }
b5ee47fb 666 else {
e44e8726 667 AliVTrack *track = dynamic_cast<AliVTrack*>(embPart);
b12a85c3 668 if (track) {
c92284d5 669 probeEta = track->Eta();
670 probePhi = track->Phi();
a825589f 671 probePt = track->Pt();
b12a85c3 672 }
673 else {
c92284d5 674 AliWarning(Form("%s - Embedded jet found but embedded particle not found (wrong type?)!", GetName()));
6fd5039f 675 return kTRUE;
b12a85c3 676 }
b5ee47fb 677 }
c92284d5 678 Double_t distProbeJet = TMath::Sqrt((embJet->Eta() - probeEta) * (embJet->Eta() - probeEta) + (embJet->Phi() - probePhi) * (embJet->Phi() - probePhi));
679
680 fHistEmbPartPt[fCentBin]->Fill(probePt);
681 fHistEmbPartPhiEta->Fill(probeEta, probePhi);
682
683 fHistDistEmbPartJetAxis[fCentBin]->Fill(distProbeJet);
b12a85c3 684
a825589f 685 fHistEmbJetsPt[fCentBin]->Fill(embJet->Pt());
a5621834 686 fHistEmbJetsCorrPt[fCentBin]->Fill(embJet->Pt() - fRhoVal * embJet->Area());
11d18b51 687 fHistEmbJetsArea[fCentBin]->Fill(embJet->Area());
a825589f 688 fHistEmbJetPhiEta->Fill(embJet->Eta(), embJet->Phi());
c92284d5 689
a5621834 690 fHistDeltaPtEmb[fCentBin]->Fill(embJet->Pt() - embJet->Area() * fRhoVal - probePt);
691 fHistRhoVSEmbBkg->Fill(embJet->Area() * fRhoVal, embJet->Pt() - probePt);
2bee31e9 692 }
693 else {
b0e00dc4 694 if (fAnaType != kEMCALOnly)
695 DoEmbTrackLoop();
696 if (fAnaType == kEMCAL || fAnaType == kEMCALOnly)
697 DoEmbClusterLoop();
a825589f 698 if (fEmbeddedTrackId >= 0) {
b0e00dc4 699 AliVTrack *track2 = static_cast<AliVTrack*>(fEmbTracks->At(fEmbeddedTrackId));
700 fHistEmbNotFoundPhiEta[fCentBin]->Fill(track2->Eta(), track2->Phi());
a825589f 701 }
702 else if (fEmbeddedClusterId >= 0) {
b0e00dc4 703 AliVCluster *cluster2 = static_cast<AliVCluster*>(fEmbCaloClusters->At(fEmbeddedClusterId));
a825589f 704 TLorentzVector nPart;
705 cluster2->GetMomentum(nPart, fVertex);
b0e00dc4 706 fHistEmbNotFoundPhiEta[fCentBin]->Fill(nPart.Eta(), nPart.Phi());
a825589f 707 }
708 else {
709 AliWarning(Form("%s - Embedded particle not found!", GetName()));
710 }
2bee31e9 711 }
6fd5039f 712
713 return kTRUE;
55264f20 714}
715
716//________________________________________________________________________
6fd5039f 717void AliAnalysisTaskSAJF::GetLeadingJets(Int_t &maxJetIndex, Int_t &max2JetIndex)
55264f20 718{
16d143bd 719 // Get the leading jets.
720
df43b607 721 if (!fJets)
722 return;
723
16d143bd 724 const Int_t njets = fJets->GetEntriesFast();
55264f20 725
1f03e093 726 Float_t maxJetPt = -999;
727 Float_t max2JetPt = -999;
25283b37 728 for (Int_t ij = 0; ij < njets; ij++) {
f0a0fd33 729
e44e8726 730 AliEmcalJet* jet = static_cast<AliEmcalJet*>(fJets->At(ij));
f0a0fd33 731
25283b37 732 if (!jet) {
a55e4f1d 733 AliError(Form("Could not receive jet %d", ij));
25283b37 734 continue;
735 }
f0a0fd33 736
e44e8726 737 if (!AcceptJet(jet))
91f4b7c5 738 continue;
739
a5621834 740 Float_t corrPt = jet->Pt() - fRhoVal * jet->Area();
226f511d 741
6fd5039f 742 if (maxJetIndex == -1 || maxJetPt < corrPt) {
743 max2JetPt = maxJetPt;
744 max2JetIndex = maxJetIndex;
745 maxJetPt = corrPt;
746 maxJetIndex = ij;
b12a85c3 747 }
6fd5039f 748 else if (max2JetIndex == -1 || max2JetPt < corrPt) {
749 max2JetPt = corrPt;
750 max2JetIndex = ij;
b12a85c3 751 }
16d143bd 752 }
6fd5039f 753}
754
e44e8726 755//________________________________________________________________________
756void AliAnalysisTaskSAJF::DoClusterLoop()
757{
758 // Do cluster loop.
759
760 if (!fCaloClusters)
761 return;
762
763 Int_t nclusters = fCaloClusters->GetEntriesFast();
764
765 for (Int_t iClusters = 0; iClusters < nclusters; iClusters++) {
766 AliVCluster* cluster = static_cast<AliVCluster*>(fCaloClusters->At(iClusters));
767 if (!cluster) {
768 AliError(Form("Could not receive cluster %d", iClusters));
769 continue;
770 }
771
b0e00dc4 772 if (!AcceptCluster(cluster))
e44e8726 773 continue;
774
775 fHistClustersPt[fCentBin]->Fill(cluster->E());
776 }
777}
778
779//________________________________________________________________________
780void AliAnalysisTaskSAJF::DoTrackLoop()
781{
782 // Do track loop.
783
784 if (!fTracks)
785 return;
786
787 Int_t ntracks = fTracks->GetEntriesFast();
788
789 for (Int_t i = 0; i < ntracks; i++) {
790
791 AliVParticle* track = static_cast<AliVParticle*>(fTracks->At(i)); // pointer to reconstructed to track
792
793 if (!track) {
794 AliError(Form("Could not retrieve track %d",i));
795 continue;
796 }
797
798 AliVTrack* vtrack = dynamic_cast<AliVTrack*>(track);
799
b0e00dc4 800 if (vtrack && !AcceptTrack(vtrack))
e44e8726 801 continue;
802
803 fHistTracksPt[fCentBin]->Fill(track->Pt());
804 }
805}
806
6fd5039f 807//________________________________________________________________________
808void AliAnalysisTaskSAJF::DoJetLoop()
809{
16d143bd 810 // Do the jet loop.
811
6fd5039f 812 if (!fJets)
813 return;
814
16d143bd 815 const Int_t njets = fJets->GetEntriesFast();
6fd5039f 816
58285fc6 817 TH1F constituents("constituents", "constituents",
818 fHistConstituents[0]->GetNbinsX(), fHistConstituents[0]->GetXaxis()->GetXmin(), fHistConstituents[0]->GetXaxis()->GetXmax());
819
6fd5039f 820 for (Int_t ij = 0; ij < njets; ij++) {
821
e44e8726 822 AliEmcalJet* jet = static_cast<AliEmcalJet*>(fJets->At(ij));
6fd5039f 823
824 if (!jet) {
825 AliError(Form("Could not receive jet %d", ij));
826 continue;
827 }
828
e44e8726 829 if (!AcceptJet(jet))
6fd5039f 830 continue;
831
4643d2e8 832 Float_t corrPt = jet->Pt() - fRhoVal * jet->Area();
226f511d 833
11d4d636 834 fHistJetsPt[fCentBin]->Fill(jet->Pt());
2bddb6ae 835 fHistJetsPtArea[fCentBin]->Fill(jet->Pt(), jet->Area());
c92284d5 836 fHistJetsCorrPt[fCentBin]->Fill(corrPt);
837 fHistJetsCorrPtArea[fCentBin]->Fill(corrPt, jet->Area());
f0a0fd33 838
8b9f02fd 839 fHistJetPhiEta[fCentBin]->Fill(jet->Eta(), jet->Phi());
a5621834 840
e44e8726 841 fHistMaxPartPtvsJetPt[fCentBin]->Fill(jet->Pt(), jet->MaxPartPt());
e44e8726 842 fHistMaxPartPtvsJetCorrPt[fCentBin]->Fill(corrPt, jet->MaxPartPt());
843
8b9f02fd 844 if (fAnaType != kEMCALOnly) {
845 fHistMaxTrackPtvsJetPt[fCentBin]->Fill(jet->Pt(), jet->MaxTrackPt());
846 fHistMaxTrackPtvsJetCorrPt[fCentBin]->Fill(corrPt, jet->MaxTrackPt());
847 }
b12a85c3 848
8b9f02fd 849 if (fAnaType == kEMCAL || fAnaType == kEMCALOnly) {
e44e8726 850 fHistMaxClusPtvsJetPt[fCentBin]->Fill(jet->Pt(), jet->MaxClusterPt());
851 fHistMaxClusPtvsJetCorrPt[fCentBin]->Fill(corrPt, jet->MaxClusterPt());
b12a85c3 852 fHistJetsNEFvsPt[fCentBin]->Fill(jet->NEF(), jet->Pt());
e44e8726 853 }
226f511d 854
a825589f 855 Float_t scalarpt = 0;
856
6e8d91c9 857 if (fTracks) {
858 for (Int_t it = 0; it < jet->GetNumberOfTracks(); it++) {
859 AliVParticle *track = jet->TrackAt(it, fTracks);
a825589f 860 if (track) {
6e8d91c9 861 fHistJetsZvsPt[fCentBin]->Fill(track->Pt() / jet->Pt(), jet->Pt());
58285fc6 862 constituents.Fill(track->Pt());
a825589f 863 scalarpt += track->Pt();
864 }
6e8d91c9 865 }
35789a2d 866 }
a55e4f1d 867
6e8d91c9 868 if (fCaloClusters) {
869 for (Int_t ic = 0; ic < jet->GetNumberOfClusters(); ic++) {
870 AliVCluster *cluster = jet->ClusterAt(ic, fCaloClusters);
871
872 if (cluster) {
873 TLorentzVector nPart;
874 cluster->GetMomentum(nPart, fVertex);
2bddb6ae 875 fHistJetsZvsPt[fCentBin]->Fill(nPart.Et() / jet->Pt(), jet->Pt());
a825589f 876 scalarpt += nPart.Pt();
58285fc6 877 constituents.Fill(nPart.Pt());
6e8d91c9 878 }
55264f20 879 }
f0a0fd33 880 }
a825589f 881
882 fHistDeltaVectorPt->Fill(scalarpt - jet->Pt());
58285fc6 883
884 for (Int_t i = 1; i <= constituents.GetNbinsX(); i++) {
885 fHistConstituents[fCentBin]->Fill(constituents.GetBinCenter(i), constituents.GetBinContent(i));
886 }
887
888 constituents.Reset();
25283b37 889 } //jet loop
55264f20 890}
e82e282c 891
b0e00dc4 892//________________________________________________________________________
893void AliAnalysisTaskSAJF::DoEmbTrackLoop()
894{
895 // Do track loop.
896
897 if (!fEmbTracks)
898 return;
899
900 fEmbeddedTrackId = -1;
901
902 Int_t ntracks = fEmbTracks->GetEntriesFast();
903
904 for (Int_t i = 0; i < ntracks; i++) {
905
906 AliVParticle* track = static_cast<AliVParticle*>(fEmbTracks->At(i)); // pointer to reconstructed to track
907
908 if (!track) {
909 AliError(Form("Could not retrieve track %d",i));
910 continue;
911 }
912
913 AliVTrack* vtrack = dynamic_cast<AliVTrack*>(track);
914
915 if (vtrack && !AcceptTrack(vtrack, kTRUE))
916 continue;
917
918 if (track->GetLabel() == 100) {
919 fEmbeddedTrackId = i;
920 continue;
921 }
922 }
923}
924
925//________________________________________________________________________
926void AliAnalysisTaskSAJF::DoEmbClusterLoop()
927{
928 // Do cluster loop.
929
930 if (!fEmbCaloClusters)
931 return;
932
933 fEmbeddedClusterId = -1;
934
935 Int_t nclusters = fEmbCaloClusters->GetEntriesFast();
936
937 for (Int_t iClusters = 0; iClusters < nclusters; iClusters++) {
938 AliVCluster* cluster = static_cast<AliVCluster*>(fEmbCaloClusters->At(iClusters));
939 if (!cluster) {
940 AliError(Form("Could not receive cluster %d", iClusters));
941 continue;
942 }
943
944 if (!AcceptCluster(cluster, kTRUE))
945 continue;
946
947 if (cluster->Chi2() == 100) {
948 fEmbeddedClusterId = iClusters;
949 continue;
950 }
951 }
952}
953
55264f20 954//________________________________________________________________________
e44e8726 955void AliAnalysisTaskSAJF::DoEmbJetLoop(AliEmcalJet* &embJet, TObject* &embPart)
55264f20 956{
16d143bd 957 // Do the embedded jet loop.
958
df43b607 959 if (!fEmbJets)
960 return;
961
fb9ac42f 962 TLorentzVector maxClusVect;
2bee31e9 963
df43b607 964 Int_t nembjets = fEmbJets->GetEntriesFast();
2bee31e9 965
2bee31e9 966 for (Int_t ij = 0; ij < nembjets; ij++) {
967
e44e8726 968 AliEmcalJet* jet = static_cast<AliEmcalJet*>(fEmbJets->At(ij));
2bee31e9 969
970 if (!jet) {
971 AliError(Form("Could not receive jet %d", ij));
972 continue;
973 }
974
df43b607 975 if (!AcceptJet(jet))
976 continue;
2bee31e9 977
fb9ac42f 978 if (!jet->IsMC())
979 continue;
980
df43b607 981 AliVParticle *maxTrack = 0;
2bee31e9 982
b12a85c3 983 for (Int_t it = 0; it < jet->GetNumberOfTracks(); it++) {
e44e8726 984 AliVParticle *track = jet->TrackAt(it, fEmbTracks);
b12a85c3 985
fb9ac42f 986 if (!track)
987 continue;
988
1f6fff78 989 if (track->GetLabel() != 100)
fb9ac42f 990 continue;
b12a85c3 991
992 if (!maxTrack || track->Pt() > maxTrack->Pt())
993 maxTrack = track;
2bee31e9 994 }
2bee31e9 995
b12a85c3 996 AliVCluster *maxClus = 0;
2bee31e9 997
b12a85c3 998 for (Int_t ic = 0; ic < jet->GetNumberOfClusters(); ic++) {
e44e8726 999 AliVCluster *cluster = jet->ClusterAt(ic, fEmbCaloClusters);
b12a85c3 1000
fb9ac42f 1001 if (!cluster)
1002 continue;
1003
1004 if (cluster->Chi2() != 100)
1005 continue;
b12a85c3 1006
1007 TLorentzVector nPart;
1008 cluster->GetMomentum(nPart, fVertex);
1009
fb9ac42f 1010 if (!maxClus || nPart.Et() > maxClusVect.Et()) {
1011 new (&maxClusVect) TLorentzVector(nPart);
b12a85c3 1012 maxClus = cluster;
1013 }
1014 }
2bee31e9 1015
fb9ac42f 1016 if ((maxClus && maxTrack && maxClusVect.Et() > maxTrack->Pt()) || (maxClus && !maxTrack)) {
e44e8726 1017 embPart = maxClus;
fb9ac42f 1018 embJet = jet;
b12a85c3 1019 }
1020 else if (maxTrack) {
e44e8726 1021 embPart = maxTrack;
fb9ac42f 1022 embJet = jet;
b12a85c3 1023 }
b12a85c3 1024
e22bc1b8 1025 return; // MC jet found, exit
fb9ac42f 1026 }
2bee31e9 1027}
1028
a55e4f1d 1029//________________________________________________________________________
a5621834 1030void AliAnalysisTaskSAJF::GetRigidCone(Float_t &pt, Float_t &ptrigid, Float_t &eta, Float_t &phi,
b12a85c3 1031 AliEmcalJet *jet, TClonesArray* tracks, TClonesArray* clusters) const
a55e4f1d 1032{
16d143bd 1033 // Get rigid cone.
1034
b12a85c3 1035 if (!tracks)
1036 tracks = fTracks;
a55e4f1d 1037
b12a85c3 1038 if (!clusters)
1039 clusters = fCaloClusters;
a55e4f1d 1040
b5ee47fb 1041 eta = 0;
1042 phi = 0;
b12a85c3 1043 pt = 0;
9b265496 1044 ptrigid = 0;
1045
1046 if (!tracks && !clusters)
1047 return;
a55e4f1d 1048
1049 Float_t LJeta = 999;
1050 Float_t LJphi = 999;
1051
1052 if (jet) {
1053 LJeta = jet->Eta();
1054 LJphi = jet->Phi();
1055 }
1056
1f6fff78 1057 Float_t maxEta = fMaxEta;
1058 Float_t minEta = fMinEta;
1059 Float_t maxPhi = fMaxPhi;
1060 Float_t minPhi = fMinPhi;
b5ee47fb 1061
1062 if (maxPhi > TMath::Pi() * 2) maxPhi = TMath::Pi() * 2;
1063 if (minPhi < 0) minPhi = 0;
1064
a55e4f1d 1065 Float_t dLJ = 0;
b12a85c3 1066 Int_t repeats = 0;
a55e4f1d 1067 do {
b12a85c3 1068 eta = gRandom->Rndm() * (maxEta - minEta) + minEta;
1069 phi = gRandom->Rndm() * (maxPhi - minPhi) + minPhi;
a55e4f1d 1070 dLJ = TMath::Sqrt((LJeta - eta) * (LJeta - eta) + (LJphi - phi) * (LJphi - phi));
b12a85c3 1071 repeats++;
1072 } while (dLJ < fMinRC2LJ && repeats < 999);
1073
e44e8726 1074 if (repeats == 999) {
b0e00dc4 1075 AliWarning(Form("%s: Could not get random cone!", GetName()));
b12a85c3 1076 return;
e44e8726 1077 }
b5ee47fb 1078
9b265496 1079 TVector3 rigidAxis;
1080 rigidAxis.SetPtEtaPhi(1, eta, phi);
1081 rigidAxis = rigidAxis.Unit();
1082
94d22b76 1083 if ((fAnaType == kEMCAL || fAnaType == kEMCALOnly) && clusters) {
b12a85c3 1084 Int_t nclusters = clusters->GetEntriesFast();
b5ee47fb 1085 for (Int_t iClusters = 0; iClusters < nclusters; iClusters++) {
e44e8726 1086 AliVCluster* cluster = static_cast<AliVCluster*>(clusters->At(iClusters));
b5ee47fb 1087 if (!cluster) {
b0e00dc4 1088 AliError(Form("Could not receive cluster %d", iClusters));
b5ee47fb 1089 continue;
1090 }
1091
121eb688 1092 if (!AcceptCluster(cluster, fMCAna))
e44e8726 1093 continue;
b5ee47fb 1094
1095 TLorentzVector nPart;
b12a85c3 1096 cluster->GetMomentum(nPart, const_cast<Double_t*>(fVertex));
9b265496 1097
1098 Float_t d = TMath::Sqrt((nPart.Eta() - eta) * (nPart.Eta() - eta) + (nPart.Phi() - phi) * (nPart.Phi() - phi));
1099
1100 if (d <= fJetRadius) {
1101 TVector3 vect = nPart.Vect();
1102 vect *= vect * rigidAxis / vect.Mag();
1103 ptrigid += vect.Pt();
1104
b5ee47fb 1105 pt += nPart.Pt();
9b265496 1106 }
b5ee47fb 1107 }
a55e4f1d 1108 }
1109
df43b607 1110 if (tracks) {
1111 Int_t ntracks = tracks->GetEntriesFast();
1112 for(Int_t iTracks = 0; iTracks < ntracks; iTracks++) {
e44e8726 1113 AliVTrack* track = static_cast<AliVTrack*>(tracks->At(iTracks));
df43b607 1114 if(!track) {
1115 AliError(Form("Could not retrieve track %d",iTracks));
1116 continue;
1117 }
1118
121eb688 1119 if (!AcceptTrack(track, fMCAna))
e44e8726 1120 continue;
df43b607 1121
1122 Float_t tracketa = track->Eta();
1123 Float_t trackphi = track->Phi();
1124
1125 if (TMath::Abs(trackphi - phi) > TMath::Abs(trackphi - phi + 2 * TMath::Pi()))
1126 trackphi += 2 * TMath::Pi();
1127 if (TMath::Abs(trackphi - phi) > TMath::Abs(trackphi - phi - 2 * TMath::Pi()))
1128 trackphi -= 2 * TMath::Pi();
1129
1130 Float_t d = TMath::Sqrt((tracketa - eta) * (tracketa - eta) + (trackphi - phi) * (trackphi - phi));
9b265496 1131 if (d <= fJetRadius){
1132 TVector3 vect(track->Px(), track->Py(), track->Pz());
1133 vect *= vect * rigidAxis / vect.Mag();
1134 ptrigid += vect.Pt();
1135
df43b607 1136 pt += track->Pt();
9b265496 1137 }
df43b607 1138 }
25283b37 1139 }
f0a0fd33 1140}
94d22b76 1141
a55e4f1d 1142//________________________________________________________________________
9b265496 1143void AliAnalysisTaskSAJF::ExecOnce()
25283b37 1144{
16d143bd 1145 // Initialize the analysis.
1146
a5621834 1147 if (!fRhoName.IsNull() && !fRho) {
1148 fRho = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(fRhoName));
1149 if (!fRho) {
1150 AliError(Form("%s: Could not retrieve rho %s!", GetName(), fRhoName.Data()));
1151 return;
1152 }
1153 }
1154
1155 if (!fEmbJetsName.IsNull() && !fEmbJets) {
1156 fEmbJets = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fEmbJetsName));
1157 if (!fEmbJets) {
1158 AliError(Form("%s: Could not retrieve emb jets %s!", GetName(), fEmbJetsName.Data()));
1159 return;
1160 }
1161 else if (!fEmbJets->GetClass()->GetBaseClass("AliEmcalJet")) {
1162 AliError(Form("%s: Collection %s does not contain AliEmcalJet objects!", GetName(), fEmbJetsName.Data()));
1163 fEmbJets = 0;
1164 return;
1165 }
1166 }
1167
8b9f02fd 1168 if (!fEmbCaloName.IsNull() && (fAnaType == kEMCAL || fAnaType == kEMCALOnly) && !fEmbCaloClusters) {
a5621834 1169 fEmbCaloClusters = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fEmbCaloName));
1170 if (!fEmbCaloClusters) {
1171 AliError(Form("%s: Could not retrieve embedded clusters %s!", GetName(), fEmbCaloName.Data()));
1172 return;
1173 }
1174 else if (!fEmbCaloClusters->GetClass()->GetBaseClass("AliVCluster") && !fEmbCaloClusters->GetClass()->GetBaseClass("AliEmcalParticle")) {
1175 AliError(Form("%s: Collection %s does not contain AliVCluster nor AliEmcalParticle objects!", GetName(), fEmbCaloName.Data()));
1176 fEmbCaloClusters = 0;
1177 return;
1178 }
1179 }
1180
8b9f02fd 1181 if (!fEmbTracksName.IsNull() && fAnaType != kEMCALOnly && !fEmbTracks) {
a5621834 1182 fEmbTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fEmbTracksName));
1183 if (!fEmbTracks) {
1184 AliError(Form("%s: Could not retrieve embedded tracks %s!", GetName(), fEmbTracksName.Data()));
1185 return;
1186 }
1187 else if (!fEmbTracks->GetClass()->GetBaseClass("AliVParticle") && !fEmbTracks->GetClass()->GetBaseClass("AliEmcalParticle")) {
1188 AliError(Form("%s: Collection %s does not contain AliVParticle nor AliEmcalParticle objects!", GetName(), fEmbTracksName.Data()));
1189 fEmbTracks = 0;
1190 return;
1191 }
1192 }
1193
8b9f02fd 1194 if (!fRandCaloName.IsNull() && (fAnaType == kEMCAL || fAnaType == kEMCALOnly) && !fRandCaloClusters) {
a5621834 1195 fRandCaloClusters = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fRandCaloName));
1196 if (!fRandCaloClusters) {
1197 AliError(Form("%s: Could not retrieve randomized clusters %s!", GetName(), fRandCaloName.Data()));
1198 return;
1199 }
1200 else if (!fRandCaloClusters->GetClass()->GetBaseClass("AliVCluster") && !fRandCaloClusters->GetClass()->GetBaseClass("AliEmcalParticle")) {
1201 AliError(Form("%s: Collection %s does not contain AliVCluster nor AliEmcalParticle objects!", GetName(), fRandCaloName.Data()));
1202 fRandCaloClusters = 0;
1203 return;
1204 }
1205 }
1206
8b9f02fd 1207 if (!fRandTracksName.IsNull() && fAnaType != kEMCALOnly && !fRandTracks) {
a5621834 1208 fRandTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fRandTracksName));
1209 if (!fRandTracks) {
1210 AliError(Form("%s: Could not retrieve randomized tracks %s!", GetName(), fRandTracksName.Data()));
1211 return;
1212 }
1213 else if (!fRandTracks->GetClass()->GetBaseClass("AliVParticle") && !fRandTracks->GetClass()->GetBaseClass("AliEmcalParticle")) {
1214 AliError(Form("%s: Collection %s does not contain AliVParticle nor AliEmcalParticle objects!", GetName(), fRandTracksName.Data()));
1215 fRandTracks = 0;
1216 return;
1217 }
1218 }
1219
9b265496 1220 AliAnalysisTaskEmcalJet::ExecOnce();
1221
b0e00dc4 1222 if (fMinRC2LJ < 0)
679e9805 1223 fMinRC2LJ = fJetRadius * 1.5;
b0e00dc4 1224
679e9805 1225 const Float_t maxDist = TMath::Max(fMaxPhi - fMinPhi, fMaxEta - fMinEta) / 2;
1226 if (fMinRC2LJ > maxDist) {
1227 AliWarning(Form("The parameter fMinRC2LJ = %f is too large for the considered acceptance. "
1228 "Will use fMinRC2LJ = %f", fMinRC2LJ, maxDist));
1229 fMinRC2LJ = maxDist;
1230 }
25283b37 1231}
1232
1233//________________________________________________________________________
00514d01 1234void AliAnalysisTaskSAJF::Terminate(Option_t *)
25283b37 1235{
1236 // Called once at the end of the analysis.
1237}