]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/UserTasks/AliAnalysisTaskEmcalJetMass.cxx
add cut to reject tracks close to TPC sector edge
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / UserTasks / AliAnalysisTaskEmcalJetMass.cxx
1 //
2 // Jet mass analysis task.
3 //
4 // Author: M.Verweij
5
6 #include <TClonesArray.h>
7 #include <TH1F.h>
8 #include <TH2F.h>
9 #include <TH3F.h>
10 #include <THnSparse.h>
11 #include <TList.h>
12 #include <TLorentzVector.h>
13 #include <TProfile.h>
14 #include <TChain.h>
15 #include <TSystem.h>
16 #include <TFile.h>
17 #include <TKey.h>
18
19 #include "AliVCluster.h"
20 #include "AliVTrack.h"
21 #include "AliEmcalJet.h"
22 #include "AliRhoParameter.h"
23 #include "AliLog.h"
24 #include "AliEmcalParticle.h"
25 #include "AliMCEvent.h"
26 #include "AliGenPythiaEventHeader.h"
27 #include "AliAODMCHeader.h"
28 #include "AliMCEvent.h"
29 #include "AliAnalysisManager.h"
30 #include "AliJetContainer.h"
31
32 #include "AliAODEvent.h"
33
34 #include "AliAnalysisTaskEmcalJetMass.h"
35
36 ClassImp(AliAnalysisTaskEmcalJetMass)
37
38 //________________________________________________________________________
39 AliAnalysisTaskEmcalJetMass::AliAnalysisTaskEmcalJetMass() : 
40   AliAnalysisTaskEmcalJet("AliAnalysisTaskEmcalJetMass", kTRUE),
41   fContainerBase(0),
42   fMinFractionShared(0),
43   fJetMassType(kRaw),
44   fh3PtJet1VsMassVsLeadPtAllSel(0),
45   fh3PtJet1VsMassVsLeadPtTagged(0),
46   fh3PtJet1VsMassVsLeadPtTaggedMatch(0),
47   fpPtVsMassJet1All(0),
48   fpPtVsMassJet1Tagged(0),
49   fpPtVsMassJet1TaggedMatch(0),
50   fh2MassVsAreaJet1All(0),
51   fh2MassVsAreaJet1Tagged(0),
52   fh2MassVsAreaJet1TaggedMatch(0),
53   fh2MassVsNConstJet1All(0),
54   fh2MassVsNConstJet1Tagged(0),
55   fh2MassVsNConstJet1TaggedMatch(0),
56   fh3PtJet1VsRatVsLeadPtAllSel(0),
57   fh3PtJet1VsRatVsLeadPtTagged(0),
58   fh3PtJet1VsRatVsLeadPtTaggedMatch(0),
59   fpPtVsRatJet1All(0),
60   fpPtVsRatJet1Tagged(0),
61   fpPtVsRatJet1TaggedMatch(0),
62   fh2RatVsAreaJet1All(0),
63   fh2RatVsAreaJet1Tagged(0),
64   fh2RatVsAreaJet1TaggedMatch(0),
65   fh2RatVsNConstJet1All(0),
66   fh2RatVsNConstJet1Tagged(0),
67   fh2RatVsNConstJet1TaggedMatch(0),
68   fh2EtMassOverEtRSq(0)
69 {
70   // Default constructor.
71
72   fh3PtJet1VsMassVsLeadPtAllSel        = new TH3F*[fNcentBins];
73   fh3PtJet1VsMassVsLeadPtTagged        = new TH3F*[fNcentBins];
74   fh3PtJet1VsMassVsLeadPtTaggedMatch   = new TH3F*[fNcentBins];
75   fpPtVsMassJet1All                    = new TProfile*[fNcentBins];
76   fpPtVsMassJet1Tagged                 = new TProfile*[fNcentBins];
77   fpPtVsMassJet1TaggedMatch            = new TProfile*[fNcentBins];
78   fh2MassVsAreaJet1All                 = new TH2F*[fNcentBins];
79   fh2MassVsAreaJet1Tagged              = new TH2F*[fNcentBins];
80   fh2MassVsAreaJet1TaggedMatch         = new TH2F*[fNcentBins];
81   fh2MassVsNConstJet1All               = new TH2F*[fNcentBins];
82   fh2MassVsNConstJet1Tagged            = new TH2F*[fNcentBins];
83   fh2MassVsNConstJet1TaggedMatch       = new TH2F*[fNcentBins];
84
85   fh3PtJet1VsRatVsLeadPtAllSel        = new TH3F*[fNcentBins];
86   fh3PtJet1VsRatVsLeadPtTagged        = new TH3F*[fNcentBins];
87   fh3PtJet1VsRatVsLeadPtTaggedMatch   = new TH3F*[fNcentBins];
88   fpPtVsRatJet1All                    = new TProfile*[fNcentBins];
89   fpPtVsRatJet1Tagged                 = new TProfile*[fNcentBins];
90   fpPtVsRatJet1TaggedMatch            = new TProfile*[fNcentBins];
91   fh2RatVsAreaJet1All                 = new TH2F*[fNcentBins];
92   fh2RatVsAreaJet1Tagged              = new TH2F*[fNcentBins];
93   fh2RatVsAreaJet1TaggedMatch         = new TH2F*[fNcentBins];
94   fh2RatVsNConstJet1All               = new TH2F*[fNcentBins];
95   fh2RatVsNConstJet1Tagged            = new TH2F*[fNcentBins];
96   fh2RatVsNConstJet1TaggedMatch       = new TH2F*[fNcentBins];
97
98   fh2EtMassOverEtRSq                   = new TH2F*[fNcentBins];
99
100   for (Int_t i = 0; i < fNcentBins; i++) {
101     fh3PtJet1VsMassVsLeadPtAllSel[i]        = 0;
102     fh3PtJet1VsMassVsLeadPtTagged[i]        = 0;
103     fh3PtJet1VsMassVsLeadPtTaggedMatch[i]   = 0;
104     fpPtVsMassJet1All[i]                    = 0;
105     fpPtVsMassJet1Tagged[i]                 = 0;
106     fpPtVsMassJet1TaggedMatch[i]            = 0;
107     fh2MassVsAreaJet1All[i]                 = 0;
108     fh2MassVsAreaJet1Tagged[i]              = 0;
109     fh2MassVsAreaJet1TaggedMatch[i]         = 0;
110     fh2MassVsNConstJet1All[i]               = 0;
111     fh2MassVsNConstJet1Tagged[i]            = 0;
112     fh2MassVsNConstJet1TaggedMatch[i]       = 0;
113
114     fh3PtJet1VsRatVsLeadPtAllSel[i]        = 0;
115     fh3PtJet1VsRatVsLeadPtTagged[i]        = 0;
116     fh3PtJet1VsRatVsLeadPtTaggedMatch[i]   = 0;
117     fpPtVsRatJet1All[i]                    = 0;
118     fpPtVsRatJet1Tagged[i]                 = 0;
119     fpPtVsRatJet1TaggedMatch[i]            = 0;
120     fh2RatVsAreaJet1All[i]                 = 0;
121     fh2RatVsAreaJet1Tagged[i]              = 0;
122     fh2RatVsAreaJet1TaggedMatch[i]         = 0;
123     fh2RatVsNConstJet1All[i]               = 0;
124     fh2RatVsNConstJet1Tagged[i]            = 0;
125     fh2RatVsNConstJet1TaggedMatch[i]       = 0;
126
127     fh2EtMassOverEtRSq[i]                   = 0;
128   }
129
130   SetMakeGeneralHistograms(kTRUE);
131 }
132
133 //________________________________________________________________________
134 AliAnalysisTaskEmcalJetMass::AliAnalysisTaskEmcalJetMass(const char *name) : 
135   AliAnalysisTaskEmcalJet(name, kTRUE),  
136   fContainerBase(0),
137   fMinFractionShared(0),
138   fJetMassType(kRaw),
139   fh3PtJet1VsMassVsLeadPtAllSel(0),
140   fh3PtJet1VsMassVsLeadPtTagged(0),
141   fh3PtJet1VsMassVsLeadPtTaggedMatch(0),
142   fpPtVsMassJet1All(0),
143   fpPtVsMassJet1Tagged(0),
144   fpPtVsMassJet1TaggedMatch(0),
145   fh2MassVsAreaJet1All(0),
146   fh2MassVsAreaJet1Tagged(0),
147   fh2MassVsAreaJet1TaggedMatch(0),
148   fh2MassVsNConstJet1All(0),
149   fh2MassVsNConstJet1Tagged(0),
150   fh2MassVsNConstJet1TaggedMatch(0),
151   fh3PtJet1VsRatVsLeadPtAllSel(0),
152   fh3PtJet1VsRatVsLeadPtTagged(0),
153   fh3PtJet1VsRatVsLeadPtTaggedMatch(0),
154   fpPtVsRatJet1All(0),
155   fpPtVsRatJet1Tagged(0),
156   fpPtVsRatJet1TaggedMatch(0),
157   fh2RatVsAreaJet1All(0),
158   fh2RatVsAreaJet1Tagged(0),
159   fh2RatVsAreaJet1TaggedMatch(0),
160   fh2RatVsNConstJet1All(0),
161   fh2RatVsNConstJet1Tagged(0),
162   fh2RatVsNConstJet1TaggedMatch(0),
163   fh2EtMassOverEtRSq(0)
164 {
165   // Standard constructor.
166
167   fh3PtJet1VsMassVsLeadPtAllSel        = new TH3F*[fNcentBins];
168   fh3PtJet1VsMassVsLeadPtTagged        = new TH3F*[fNcentBins];
169   fh3PtJet1VsMassVsLeadPtTaggedMatch   = new TH3F*[fNcentBins];
170   fpPtVsMassJet1All                    = new TProfile*[fNcentBins];
171   fpPtVsMassJet1Tagged                 = new TProfile*[fNcentBins];
172   fpPtVsMassJet1TaggedMatch            = new TProfile*[fNcentBins];
173   fh2MassVsAreaJet1All                 = new TH2F*[fNcentBins];
174   fh2MassVsAreaJet1Tagged              = new TH2F*[fNcentBins];
175   fh2MassVsAreaJet1TaggedMatch         = new TH2F*[fNcentBins];
176   fh2MassVsNConstJet1All               = new TH2F*[fNcentBins];
177   fh2MassVsNConstJet1Tagged            = new TH2F*[fNcentBins];
178   fh2MassVsNConstJet1TaggedMatch       = new TH2F*[fNcentBins];
179
180   fh3PtJet1VsRatVsLeadPtAllSel        = new TH3F*[fNcentBins];
181   fh3PtJet1VsRatVsLeadPtTagged        = new TH3F*[fNcentBins];
182   fh3PtJet1VsRatVsLeadPtTaggedMatch   = new TH3F*[fNcentBins];
183   fpPtVsRatJet1All                    = new TProfile*[fNcentBins];
184   fpPtVsRatJet1Tagged                 = new TProfile*[fNcentBins];
185   fpPtVsRatJet1TaggedMatch            = new TProfile*[fNcentBins];
186   fh2RatVsAreaJet1All                 = new TH2F*[fNcentBins];
187   fh2RatVsAreaJet1Tagged              = new TH2F*[fNcentBins];
188   fh2RatVsAreaJet1TaggedMatch         = new TH2F*[fNcentBins];
189   fh2RatVsNConstJet1All               = new TH2F*[fNcentBins];
190   fh2RatVsNConstJet1Tagged            = new TH2F*[fNcentBins];
191   fh2RatVsNConstJet1TaggedMatch       = new TH2F*[fNcentBins];
192
193   fh2EtMassOverEtRSq                   = new TH2F*[fNcentBins];
194
195   for (Int_t i = 0; i < fNcentBins; i++) {
196     fh3PtJet1VsMassVsLeadPtAllSel[i]        = 0;
197     fh3PtJet1VsMassVsLeadPtTagged[i]        = 0;
198     fh3PtJet1VsMassVsLeadPtTaggedMatch[i]   = 0;
199     fpPtVsMassJet1All[i]                    = 0;
200     fpPtVsMassJet1Tagged[i]                 = 0;
201     fpPtVsMassJet1TaggedMatch[i]            = 0;
202     fh2MassVsAreaJet1All[i]                 = 0;
203     fh2MassVsAreaJet1Tagged[i]              = 0;
204     fh2MassVsAreaJet1TaggedMatch[i]         = 0;
205     fh2MassVsNConstJet1All[i]               = 0;
206     fh2MassVsNConstJet1Tagged[i]            = 0;
207     fh2MassVsNConstJet1TaggedMatch[i]       = 0;
208
209     fh3PtJet1VsRatVsLeadPtAllSel[i]         = 0;
210     fh3PtJet1VsRatVsLeadPtTagged[i]         = 0;
211     fh3PtJet1VsRatVsLeadPtTaggedMatch[i]    = 0;
212     fpPtVsRatJet1All[i]                     = 0;
213     fpPtVsRatJet1Tagged[i]                  = 0;
214     fpPtVsRatJet1TaggedMatch[i]             = 0;
215     fh2RatVsAreaJet1All[i]                  = 0;
216     fh2RatVsAreaJet1Tagged[i]               = 0;
217     fh2RatVsAreaJet1TaggedMatch[i]          = 0;
218     fh2RatVsNConstJet1All[i]                = 0;
219     fh2RatVsNConstJet1Tagged[i]             = 0;
220     fh2RatVsNConstJet1TaggedMatch[i]        = 0;
221
222     fh2EtMassOverEtRSq[i]                   = 0;
223   }
224
225   SetMakeGeneralHistograms(kTRUE);
226 }
227
228 //________________________________________________________________________
229 AliAnalysisTaskEmcalJetMass::~AliAnalysisTaskEmcalJetMass()
230 {
231   // Destructor.
232 }
233
234 //________________________________________________________________________
235 void AliAnalysisTaskEmcalJetMass::UserCreateOutputObjects()
236 {
237   // Create user output.
238
239   AliAnalysisTaskEmcalJet::UserCreateOutputObjects();
240
241   Bool_t oldStatus = TH1::AddDirectoryStatus();
242   TH1::AddDirectory(kFALSE);
243
244   const Int_t nBinsPt  = 200;
245   const Double_t minPt = -50.;
246   const Double_t maxPt = 150.;
247
248   const Int_t nBinsM  = 100;
249   const Double_t minM = -20.;
250   const Double_t maxM = 80.;
251
252   const Int_t nBinsR  = 100;
253   const Double_t minR = -0.2;
254   const Double_t maxR = 0.8;
255
256   const Int_t nBinsArea = 50;
257   const Double_t minArea = 0.;
258   const Double_t maxArea = 1.;
259
260   const Int_t nBinsNConst = 200;
261   const Double_t minNConst = 0.;
262   const Double_t maxNConst = 200.;
263
264   TString histName = "";
265   TString histTitle = "";
266   for (Int_t i = 0; i < fNcentBins; i++) {
267     histName = TString::Format("fh3PtJet1VsMassVsLeadPtAllSel_%d",i);
268     histTitle = TString::Format("%s;#it{p}_{T,jet1};#it{M}_{jet1};#it{p}_{T,lead trk}",histName.Data());
269     fh3PtJet1VsMassVsLeadPtAllSel[i] = new TH3F(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt,nBinsM,minM,maxM,20,0.,20.);
270     fOutput->Add(fh3PtJet1VsMassVsLeadPtAllSel[i]);
271
272     histName = TString::Format("fh3PtJet1VsMassVsLeadPtTagged_%d",i);
273     histTitle = TString::Format("%s;#it{p}_{T,jet1};#it{M}_{jet1};#it{p}_{T,lead trk}",histName.Data());
274     fh3PtJet1VsMassVsLeadPtTagged[i] =  new TH3F(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt,nBinsM,minM,maxM,20,0.,20.);
275     fOutput->Add(fh3PtJet1VsMassVsLeadPtTagged[i]);
276
277     histName = TString::Format("fh3PtJet1VsMassVsLeadPtTaggedMatch_%d",i);
278     histTitle = TString::Format("%s;#it{p}_{T,jet1};#it{M}_{jet1};#it{p}_{T,lead trk}",histName.Data());
279     fh3PtJet1VsMassVsLeadPtTaggedMatch[i] =  new TH3F(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt,nBinsM,minM,maxM,20,0.,20.);
280     fOutput->Add(fh3PtJet1VsMassVsLeadPtTaggedMatch[i]);
281
282     histName = TString::Format("fpPtVsMassJet1All_%d",i);
283     histTitle = TString::Format("%s;#it{p}_{T,jet1};Avg #it{M}_{jet1}",histName.Data());
284     fpPtVsMassJet1All[i] = new TProfile(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt);
285     fOutput->Add(fpPtVsMassJet1All[i]);
286
287     histName = TString::Format("fpPtVsMassJet1Tagged_%d",i);
288     histTitle = TString::Format("%s;#it{p}_{T,jet1};Avg #it{M}_{jet1}",histName.Data());
289     fpPtVsMassJet1Tagged[i] = new TProfile(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt);
290     fOutput->Add(fpPtVsMassJet1Tagged[i]);
291
292     histName = TString::Format("fpPtVsMassJet1TaggedMatch_%d",i);
293     histTitle = TString::Format("%s;#it{p}_{T,jet1};Avg #it{M}_{jet1}",histName.Data());
294     fpPtVsMassJet1TaggedMatch[i] = new TProfile(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt);
295     fOutput->Add(fpPtVsMassJet1TaggedMatch[i]);
296
297     histName = TString::Format("fh2MassVsAreaJet1All_%d",i);
298     histTitle = TString::Format("%s;#it{M}_{jet1};#it{A}",histName.Data());
299     fh2MassVsAreaJet1All[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsM,minM,maxM,nBinsArea,minArea,maxArea);
300     fOutput->Add(fh2MassVsAreaJet1All[i]);
301
302     histName = TString::Format("fh2MassVsAreaJet1Tagged_%d",i);
303     histTitle = TString::Format("%s;#it{M}_{jet1};#it{A}",histName.Data());
304     fh2MassVsAreaJet1Tagged[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsM,minM,maxM,nBinsArea,minArea,maxArea);
305     fOutput->Add(fh2MassVsAreaJet1Tagged[i]);
306
307     histName = TString::Format("fh2MassVsAreaJet1TaggedMatch_%d",i);
308     histTitle = TString::Format("%s;#it{M}_{jet1};#it{A}",histName.Data());
309     fh2MassVsAreaJet1TaggedMatch[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsM,minM,maxM,nBinsArea,minArea,maxArea);
310     fOutput->Add(fh2MassVsAreaJet1TaggedMatch[i]);
311
312     histName = TString::Format("fh2MassVsNConstJet1All_%d",i);
313     histTitle = TString::Format("%s;#it{M}_{jet1};#it{N}_{constituents}",histName.Data());
314     fh2MassVsNConstJet1All[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsM,minM,maxM,nBinsNConst,minNConst,maxNConst);
315     fOutput->Add(fh2MassVsNConstJet1All[i]);
316
317     histName = TString::Format("fh2MassVsNConstJet1Tagged_%d",i);
318     histTitle = TString::Format("%s;#it{M}_{jet1};#it{N}_{constituents}",histName.Data());
319     fh2MassVsNConstJet1Tagged[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsM,minM,maxM,nBinsNConst,minNConst,maxNConst);
320     fOutput->Add(fh2MassVsNConstJet1Tagged[i]);
321
322     histName = TString::Format("fh2MassVsNConstJet1TaggedMatch_%d",i);
323     histTitle = TString::Format("%s;#it{M}_{jet1};#it{N}_{constituents}",histName.Data());
324     fh2MassVsNConstJet1TaggedMatch[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsM,minM,maxM,nBinsNConst,minNConst,maxNConst);
325     fOutput->Add(fh2MassVsNConstJet1TaggedMatch[i]);
326
327     //
328     histName = TString::Format("fh3PtJet1VsRatVsLeadPtAllSel_%d",i);
329     histTitle = TString::Format("%s;#it{p}_{T,jet1};#it{M}_{jet1}/#it{p}_{T,jet1};#it{p}_{T,lead trk}",histName.Data());
330     fh3PtJet1VsRatVsLeadPtAllSel[i] = new TH3F(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt,nBinsR,minR,maxR,20,0.,20.);
331     fOutput->Add(fh3PtJet1VsRatVsLeadPtAllSel[i]);
332
333     histName = TString::Format("fh3PtJet1VsRatVsLeadPtTagged_%d",i);
334     histTitle = TString::Format("%s;#it{p}_{T,jet1};#it{M}_{jet1}/#it{p}_{T,jet1};#it{p}_{T,lead trk}",histName.Data());
335     fh3PtJet1VsRatVsLeadPtTagged[i] =  new TH3F(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt,nBinsR,minR,maxR,20,0.,20.);
336     fOutput->Add(fh3PtJet1VsRatVsLeadPtTagged[i]);
337
338     histName = TString::Format("fh3PtJet1VsRatVsLeadPtTaggedMatch_%d",i);
339     histTitle = TString::Format("%s;#it{p}_{T,jet1};#it{M}_{jet1}/#it{p}_{T,jet1};#it{p}_{T,lead trk}",histName.Data());
340     fh3PtJet1VsRatVsLeadPtTaggedMatch[i] =  new TH3F(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt,nBinsR,minR,maxR,20,0.,20.);
341     fOutput->Add(fh3PtJet1VsRatVsLeadPtTaggedMatch[i]);
342
343     histName = TString::Format("fpPtVsRatJet1All_%d",i);
344     histTitle = TString::Format("%s;#it{p}_{T,jet1};Avg #it{M}_{jet1}/#it{p}_{T,jet1}",histName.Data());
345     fpPtVsRatJet1All[i] = new TProfile(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt);
346     fOutput->Add(fpPtVsRatJet1All[i]);
347
348     histName = TString::Format("fpPtVsRatJet1Tagged_%d",i);
349     histTitle = TString::Format("%s;#it{p}_{T,jet1};Avg #it{M}_{jet1}/#it{p}_{T,jet1}",histName.Data());
350     fpPtVsRatJet1Tagged[i] = new TProfile(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt);
351     fOutput->Add(fpPtVsRatJet1Tagged[i]);
352
353     histName = TString::Format("fpPtVsRatJet1TaggedMatch_%d",i);
354     histTitle = TString::Format("%s;#it{p}_{T,jet1};Avg #it{M}_{jet1}/#it{p}_{T,jet1}",histName.Data());
355     fpPtVsRatJet1TaggedMatch[i] = new TProfile(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt);
356     fOutput->Add(fpPtVsRatJet1TaggedMatch[i]);
357
358     histName = TString::Format("fh2RatVsAreaJet1All_%d",i);
359     histTitle = TString::Format("%s;#it{M}_{jet1}/#it{p}_{T,jet1};#it{A}",histName.Data());
360     fh2RatVsAreaJet1All[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsR,minR,maxR,nBinsArea,minArea,maxArea);
361     fOutput->Add(fh2RatVsAreaJet1All[i]);
362
363     histName = TString::Format("fh2RatVsAreaJet1Tagged_%d",i);
364     histTitle = TString::Format("%s;#it{M}_{jet1}/#it{p}_{T,jet1};#it{A}",histName.Data());
365     fh2RatVsAreaJet1Tagged[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsR,minR,maxR,nBinsArea,minArea,maxArea);
366     fOutput->Add(fh2RatVsAreaJet1Tagged[i]);
367
368     histName = TString::Format("fh2RatVsAreaJet1TaggedMatch_%d",i);
369     histTitle = TString::Format("%s;#it{M}_{jet1}/#it{p}_{T,jet1};#it{A}",histName.Data());
370     fh2RatVsAreaJet1TaggedMatch[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsR,minR,maxR,nBinsArea,minArea,maxArea);
371     fOutput->Add(fh2RatVsAreaJet1TaggedMatch[i]);
372
373     histName = TString::Format("fh2RatVsNConstJet1All_%d",i);
374     histTitle = TString::Format("%s;#it{M}_{jet1}/#it{p}_{T,jet1};#it{N}_{constituents}",histName.Data());
375     fh2RatVsNConstJet1All[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsR,minR,maxR,nBinsNConst,minNConst,maxNConst);
376     fOutput->Add(fh2RatVsNConstJet1All[i]);
377
378     histName = TString::Format("fh2RatVsNConstJet1Tagged_%d",i);
379     histTitle = TString::Format("%s;#it{M}_{jet1}/#it{p}_{T,jet1};#it{N}_{constituents}",histName.Data());
380     fh2RatVsNConstJet1Tagged[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsR,minR,maxR,nBinsNConst,minNConst,maxNConst);
381     fOutput->Add(fh2RatVsNConstJet1Tagged[i]);
382
383     histName = TString::Format("fh2RatVsNConstJet1TaggedMatch_%d",i);
384     histTitle = TString::Format("%s;#it{M}_{jet1}/#it{p}_{T,jet1};#it{N}_{constituents}",histName.Data());
385     fh2RatVsNConstJet1TaggedMatch[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsR,minR,maxR,nBinsNConst,minNConst,maxNConst);
386     fOutput->Add(fh2RatVsNConstJet1TaggedMatch[i]);
387
388
389     histName = TString::Format("fh2EtMassOverEtRSq_%d",i);
390     histTitle = TString::Format("%s;#it{E}_{T};(#it{M}/(#it{E}_{T}#it{R}))^{2}",histName.Data());
391     fh2EtMassOverEtRSq[i] = new TH2F(histName.Data(),histTitle.Data(),nBinsPt,minPt,maxPt,100,0.,1.);
392     fOutput->Add(fh2EtMassOverEtRSq[i]);
393   }
394
395   // =========== Switch on Sumw2 for all histos ===========
396   for (Int_t i=0; i<fOutput->GetEntries(); ++i) {
397     TH1 *h1 = dynamic_cast<TH1*>(fOutput->At(i));
398     if (h1){
399       h1->Sumw2();
400       continue;
401     }
402     THnSparse *hn = dynamic_cast<THnSparse*>(fOutput->At(i));
403     if(hn)hn->Sumw2();
404   }
405
406   TH1::AddDirectory(oldStatus);
407
408   PostData(1, fOutput); // Post data for ALL output slots > 0 here.
409 }
410
411 //________________________________________________________________________
412 Bool_t AliAnalysisTaskEmcalJetMass::Run()
413 {
414   // Run analysis code here, if needed. It will be executed before FillHistograms().
415
416   return kTRUE;
417 }
418
419 //________________________________________________________________________
420 Bool_t AliAnalysisTaskEmcalJetMass::FillHistograms()
421 {
422   // Fill histograms.
423
424   AliEmcalJet* jet1 = NULL;
425   AliJetContainer *jetCont = GetJetContainer(fContainerBase);
426   if(jetCont) {
427     jetCont->ResetCurrentID();
428     while((jet1 = jetCont->GetNextAcceptJet())) {
429
430       Double_t ptJet1 = jet1->Pt() - GetRhoVal(fContainerBase)*jet1->Area();
431       Double_t mJet1 = GetJetMass(jet1);
432       Double_t rat = -1.;
433       if(ptJet1<0. || ptJet1>0.) rat = mJet1/ptJet1;
434       fh3PtJet1VsMassVsLeadPtAllSel[fCentBin]->Fill(ptJet1,mJet1,jet1->MaxTrackPt());
435       fpPtVsMassJet1All[fCentBin]->Fill(ptJet1,mJet1);
436       fh2MassVsAreaJet1All[fCentBin]->Fill(mJet1,jet1->Area());
437       fh2MassVsNConstJet1All[fCentBin]->Fill(mJet1,jet1->GetNumberOfConstituents());
438
439       fh3PtJet1VsRatVsLeadPtAllSel[fCentBin]->Fill(ptJet1,rat,jet1->MaxTrackPt());
440       fpPtVsRatJet1All[fCentBin]->Fill(ptJet1,rat);
441       fh2RatVsAreaJet1All[fCentBin]->Fill(rat,jet1->Area());
442       fh2RatVsNConstJet1All[fCentBin]->Fill(rat,jet1->GetNumberOfConstituents());
443       
444       if(jet1->GetTagStatus()<1 || !jet1->GetTaggedJet())
445         continue;
446
447       fh3PtJet1VsMassVsLeadPtTagged[fCentBin]->Fill(ptJet1,mJet1,jet1->MaxTrackPt());
448       fpPtVsMassJet1Tagged[fCentBin]->Fill(ptJet1,mJet1);
449       fh2MassVsAreaJet1Tagged[fCentBin]->Fill(mJet1,jet1->Area());
450       fh2MassVsNConstJet1Tagged[fCentBin]->Fill(mJet1,jet1->GetNumberOfConstituents());
451
452       fh3PtJet1VsRatVsLeadPtTagged[fCentBin]->Fill(ptJet1,rat,jet1->MaxTrackPt());
453       fpPtVsRatJet1Tagged[fCentBin]->Fill(ptJet1,rat);
454       fh2RatVsAreaJet1Tagged[fCentBin]->Fill(rat,jet1->Area());
455       fh2RatVsNConstJet1Tagged[fCentBin]->Fill(rat,jet1->GetNumberOfConstituents());
456
457       Double_t fraction = jetCont->GetFractionSharedPt(jet1);
458       if(fMinFractionShared>0. && fraction>fMinFractionShared) {
459         fh3PtJet1VsMassVsLeadPtTaggedMatch[fCentBin]->Fill(ptJet1,mJet1,jet1->MaxTrackPt());
460         fpPtVsMassJet1TaggedMatch[fCentBin]->Fill(ptJet1,mJet1);
461         fh2MassVsAreaJet1TaggedMatch[fCentBin]->Fill(mJet1,jet1->Area());
462         fh2MassVsNConstJet1TaggedMatch[fCentBin]->Fill(mJet1,jet1->GetNumberOfConstituents());
463
464         fh3PtJet1VsRatVsLeadPtTaggedMatch[fCentBin]->Fill(ptJet1,rat,jet1->MaxTrackPt());
465         fpPtVsRatJet1TaggedMatch[fCentBin]->Fill(ptJet1,rat);
466         fh2RatVsAreaJet1TaggedMatch[fCentBin]->Fill(rat,jet1->Area());
467         fh2RatVsNConstJet1TaggedMatch[fCentBin]->Fill(rat,jet1->GetNumberOfConstituents());
468       }
469       
470       Double_t Et2 = mJet1*mJet1 + ptJet1*ptJet1;
471       Double_t Et = 0.;    Double_t massOverEtR = 0.;
472       if(Et2>0.) Et = TMath::Sqrt(Et2);
473       if((Et*jetCont->GetJetRadius())>0.) 
474         massOverEtR = mJet1/(Et*jetCont->GetJetRadius());
475       fh2EtMassOverEtRSq[fCentBin]->Fill(Et,massOverEtR*massOverEtR);
476     }
477   }
478   
479   return kTRUE;
480 }
481
482 //________________________________________________________________________
483 Double_t AliAnalysisTaskEmcalJetMass::GetJetMass(AliEmcalJet *jet) {
484   //calc subtracted jet mass
485   if(fJetMassType==kRaw)
486     return jet->M();
487   else if(fJetMassType==kDeriv)
488     return jet->GetSecondOrderSubtracted();
489   
490   return 0;
491 }
492
493 //________________________________________________________________________
494 Bool_t AliAnalysisTaskEmcalJetMass::RetrieveEventObjects() {
495   //
496   // retrieve event objects
497   //
498   if (!AliAnalysisTaskEmcalJet::RetrieveEventObjects())
499     return kFALSE;
500
501   return kTRUE;
502 }
503
504 //_______________________________________________________________________
505 void AliAnalysisTaskEmcalJetMass::Terminate(Option_t *) 
506 {
507   // Called once at the end of the analysis.
508 }
509