AliPhysics  master (3d17d9d)
AliAnalysisTaskGammaConvV1.cxx
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: Martin Wilde, Daniel Lohner, Friederike Bock *
5 * Version 1.0 *
6 * *
7 * based on: on older version (see aliroot up to v5-04-42-AN) *
8 * AliAnalysisTaskGammaConversion.cxx *
9 * Authors: Kathrin Koch, Kenneth Aamodt, Ana Marin *
10 * *
11 * Permission to use, copy, modify and distribute this software and its *
12 * documentation strictly for non-commercial purposes is hereby granted *
13 * without fee, provided that the above copyright notice appears in all *
14 * copies and that both the copyright notice and this permission notice *
15 * appear in the supporting documentation. The authors make no claims *
16 * about the suitability of this software for any purpose. It is *
17 * provided "as is" without express or implied warranty. *
18 **************************************************************************/
19 
21 //---------------------------------------------
22 
23 // Class used to do analysis on conversion pairs
24 //---------------------------------------------
26 #include "TChain.h"
27 #include "TTree.h"
28 #include "TBranch.h"
29 #include "TFile.h"
30 #include "TH1F.h"
31 #include "TH2F.h"
32 #include "TH3F.h"
33 #include "THnSparse.h"
34 #include "TCanvas.h"
35 #include "TNtuple.h"
36 #include "AliAnalysisTask.h"
37 #include "AliAnalysisManager.h"
38 #include "AliESDEvent.h"
39 #include "AliESDInputHandler.h"
40 #include "AliMCEventHandler.h"
41 #include "AliMCEvent.h"
42 #include "AliMCParticle.h"
43 #include "AliCentrality.h"
44 #include "AliESDVZERO.h"
45 #include "AliESDpid.h"
47 #include "AliVParticle.h"
48 #include "AliESDtrack.h"
49 #include "AliESDtrackCuts.h"
50 #include "AliKFVertex.h"
51 #include "AliGenCocktailEventHeader.h"
52 #include "AliConversionAODBGHandlerRP.h"
53 #include "AliAODMCParticle.h"
54 #include "AliAODMCHeader.h"
55 #include "AliEventplane.h"
56 #include "AliAODEvent.h"
57 #include <vector>
58 #include <map>
59 
60 
62 
63 //________________________________________________________________________
65  fV0Reader(NULL),
66  fV0ReaderName("V0ReaderV1"),
67  fDoLightOutput(kFALSE),
68  fBGHandler(NULL),
69  fBGHandlerRP(NULL),
70  fInputEvent(NULL),
71  fMCEvent(NULL),
72  fCutFolder(NULL),
73  fESDList(NULL),
74  fBackList(NULL),
75  fMotherList(NULL),
76  fTrueList(NULL),
77  fMCList(NULL),
78  fHeaderNameList(NULL),
79  fOutputContainer(0),
80  fReaderGammas(NULL),
81  fGammaCandidates(NULL),
82  fEventCutArray(NULL),
83  fCutArray(NULL),
84  fMesonCutArray(NULL),
85  fClusterCutArray(NULL),
86  fConvJetReader(NULL),
87  fDoJetAnalysis(kFALSE),
88  fDoIsolatedAnalysis(kFALSE),
89  fDoHighPtHadronAnalysis(kFALSE),
90  fDoJetQA(kFALSE),
91  fJetHistograms(NULL),
92  fTrueJetHistograms(NULL),
93  fMaxPtNearEMCalPlace(0),
94  fJetNearEMCal(kFALSE),
95  fHistoCaloGammaPt(NULL),
96  fHistoCaloGammaE(NULL),
97  fHistoConvGammaPt(NULL),
98  fHistoConvGammaPtwithHighPtHadron(NULL),
99  fHistoConvGammaPtwithoutHighPtHadron(NULL),
100  fHistoConvGammaR(NULL),
101  fHistoConvGammaEta(NULL),
102  fHistoConvGammaPhi(NULL),
103  fHistoConvGammaPsiPairPt(NULL),
104  fHistoConvGammaInvMass(NULL),
105  fHistoConvGammaInvMassReco(NULL),
106  tESDConvGammaPtDcazCat(NULL),
107  fPtGamma(0),
108  fDCAzPhoton(0),
109  fRConvPhoton(0),
110  fEtaPhoton(0),
111  iCatPhoton(0),
112  iPhotonMCInfo(0),
113  fHistoMotherInvMassPt(NULL),
114  fHistoMotherInvMassPtIso(NULL),
115  fHistoMotherInvMassPtNonIso(NULL),
116  fHistoMotherInvMassPtMCRecIsoTrueNonIso(NULL),
117  fHistoMotherInvMassPtMCRecNonIsoTrueIso(NULL),
118  fHistoMotherEisoPt(NULL),
119  fHistoMotherRisoPt(NULL),
120  fHistoMotherNtracksIsoPt(NULL),
121  sESDMotherInvMassPtZM(NULL),
122  fHistoMotherBackInvMassPt(NULL),
123  sESDMotherBackInvMassPtZM(NULL),
124  fHistoMotherInvMassEalpha(NULL),
125  fHistoMotherPi0PtY(NULL),
126  fHistoMotherEtaPtY(NULL),
127  fHistoMotherPi0PtAlpha(NULL),
128  fHistoMotherEtaPtAlpha(NULL),
129  fHistoMotherPi0PtOpenAngle(NULL),
130  fHistoMotherEtaPtOpenAngle(NULL),
131  sPtRDeltaROpenAngle(NULL),
132  fHistoMCHeaders(NULL),
133  fHistoMCAllGammaPt(NULL),
134  fHistoMCAllSecondaryGammaPt(NULL),
135  fHistoMCDecayGammaPi0Pt(NULL),
136  fHistoMCDecayGammaRhoPt(NULL),
137  fHistoMCDecayGammaEtaPt(NULL),
138  fHistoMCDecayGammaOmegaPt(NULL),
139  fHistoMCDecayGammaEtapPt(NULL),
140  fHistoMCDecayGammaPhiPt(NULL),
141  fHistoMCDecayGammaSigmaPt(NULL),
142  fHistoMCConvGammaPt(NULL),
143  fHistoMCSecondaryConvGammaPt(NULL),
144  fHistoMCConvGammaR(NULL),
145  fHistoMCConvGammaEta(NULL),
146  fHistoMCPi0Pt(NULL),
147  fHistoMCPi0WOWeightPt(NULL),
148  fHistoMCPi0WOEvtWeightPt(NULL),
149  fHistoMCEtaWOEvtWeightPt(NULL),
150  fHistoMCEtaPt(NULL),
151  fHistoMCEtaWOWeightPt(NULL),
152  fHistoMCPi0WOWeightInAccPt(NULL),
153  fHistoMCEtaWOWeightInAccPt(NULL),
154  fHistoMCPi0InAccPt(NULL),
155  fHistoMCEtaInAccPt(NULL),
156  fHistoMCPi0WOEvtWeightInAccPt(NULL),
157  fHistoMCEtaWOEvtWeightInAccPt(NULL),
158  fHistoMCPi0PtY(NULL),
159  fHistoMCEtaPtY(NULL),
160  fHistoMCPi0PtAlpha(NULL),
161  fHistoMCEtaPtAlpha(NULL),
162  fHistoMCPrimaryPtvsSource(NULL),
163  fHistoMCSecPi0PtvsSource(NULL),
164  fHistoMCSecPi0RvsSource(NULL),
165  fHistoMCSecPi0Source(NULL),
166  fHistoMCSecPi0InAccPtvsSource(NULL),
167  fHistoMCSecEtaPt(NULL),
168  fHistoMCSecEtaSource(NULL),
169  fHistoMCPi0PtJetPt(NULL),
170  fHistoMCEtaPtJetPt(NULL),
171  fHistoMCPhysicalPrimariesPt(NULL),
172  fHistoTrueMotherInvMassPt(NULL),
173  fHistoTruePrimaryMotherInvMassPt(NULL),
174  fHistoTruePrimaryMotherW0WeightingInvMassPt(NULL),
175  pESDTruePrimaryMotherWeightsInvMassPt(NULL),
176  fHistoTruePrimaryPi0MCPtResolPt(NULL),
177  fHistoTruePrimaryEtaMCPtResolPt(NULL),
178  fHistoTrueSecondaryMotherInvMassPt(NULL),
179  fHistoTrueSecondaryMotherFromK0sInvMassPt(NULL),
180  fHistoTrueK0sWithPi0DaughterMCPt(NULL),
181  fHistoTrueSecondaryMotherFromK0lInvMassPt(NULL),
182  fHistoTrueK0lWithPi0DaughterMCPt(NULL),
183  fHistoTrueSecondaryMotherFromEtaInvMassPt(NULL),
184  fHistoTrueEtaWithPi0DaughterMCPt(NULL),
185  fHistoTrueSecondaryMotherFromLambdaInvMassPt(NULL),
186  fHistoTrueLambdaWithPi0DaughterMCPt(NULL),
187  fHistoTrueBckGGInvMassPt(NULL),
188  fHistoTrueBckContInvMassPt(NULL),
189  fHistoTruePi0PtY(NULL),
190  fHistoTrueEtaPtY(NULL),
191  fHistoTruePi0PtAlpha(NULL),
192  fHistoTrueEtaPtAlpha(NULL),
193  fHistoTruePi0PtOpenAngle(NULL),
194  fHistoTrueEtaPtOpenAngle(NULL),
195  fHistoTrueMotherDalitzInvMassPt(NULL),
196  fHistoTrueConvGammaPt(NULL),
197  fHistoTrueConvGammaR(NULL),
198  fHistoTrueConvGammaPtMC(NULL),
199  fHistoTrueConvGammaRMC(NULL),
200  fHistoTrueConvGammaEta(NULL),
201  fHistoTrueConvGammaPsiPairPt(NULL),
202  fHistoTrueConvGammaInvMass(NULL),
203  fHistoTrueConvGammaInvMassReco(NULL),
204  fHistoCombinatorialPt(NULL),
205  fHistoCombinatorialMothersPt(NULL),
206  fHistoCombinatorialPtDeltaPhi_ek(NULL),
207  fHistoCombinatorialPtDeltaPhi_ep(NULL),
208  fHistoCombinatorialPtDeltaPhi_epi(NULL),
209  fHistoCombinatorialPtDeltaPhi_pik(NULL),
210  fHistoCombinatorialPtDeltaPhi_pip(NULL),
211  fHistoTruePrimaryConvGammaPt(NULL),
212  fHistoTrueSecondaryConvGammaPt(NULL),
213  fHistoTrueSecondaryConvGammaMCPt(NULL),
214  fHistoTruePrimaryConvGammaESDPtMCPt(NULL),
215  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt(NULL),
216  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt(NULL),
217  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt(NULL),
218  fHistoTrueDalitzPsiPairDeltaPhi(NULL),
219  fHistoTrueGammaPsiPairDeltaPhi(NULL),
220  fHistoDoubleCountTruePi0InvMassPt(NULL),
221  fHistoDoubleCountTrueEtaInvMassPt(NULL),
222  fHistoDoubleCountTrueConvGammaRPt(NULL),
223  vecDoubleCountTruePi0s(0),
224  vecDoubleCountTrueEtas(0),
225  vecDoubleCountTrueConvGammas(0),
226  fHistoMultipleCountTruePi0(NULL),
227  fHistoMultipleCountTrueEta(NULL),
228  fHistoMultipleCountTrueConvGamma(NULL),
229  mapMultipleCountTruePi0s(),
230  mapMultipleCountTrueEtas(),
231  mapMultipleCountTrueConvGammas(),
232  fHistoNEvents(NULL),
233  fHistoNEventsWOWeight(NULL),
234  fHistoNGoodESDTracks(NULL),
235  fHistoNEventsWeighted(NULL),
236  fHistoNGoodESDTracksWeighted(NULL),
237  fHistoVertexZ(NULL),
238  fHistoVertexZWeighted(NULL),
239  fDoCentralityFlat(0),
240  fHistoCentrality(NULL),
241  fHistoCentralityFlattened(NULL),
242  fHistoCentralityVsPrimaryTracks(NULL),
243  fHistoNGammaCandidates(NULL),
244  fHistoNGoodESDTracksVsNGammaCandidates(NULL),
245  fHistoPtJet(NULL),
246  fHistoJetEta(NULL),
247  fHistoJetPhi(NULL),
248  fHistoJetArea(NULL),
249  fHistoNJets(NULL),
250  fHistoEventwJets(NULL),
251  fHistoJetPi0PtRatio(NULL),
252  fHistoDoubleCounting(NULL),
253  fHistoJetMotherInvMassPt(NULL),
254  fHistoPi0InJetMotherInvMassPt(NULL),
255  fHistoMotherBackJetInvMassPt(NULL),
256  fHistoRJetPi0Cand(NULL),
257  fHistoEtaPhiJetPi0Cand(NULL),
258  fHistoEtaPhiJetWithPi0Cand(NULL),
259  fHistoJetFragmFunc(NULL),
260  fHistoJetFragmFuncZInvMass(NULL),
261  fHistoTruevsRecJetPt(NULL),
262  fHistoTrueJetMotherInvMassPt(NULL),
263  fHistoTrueInJetMotherInvMassPt(NULL),
264  fHistoTruePrimaryJetInvMassPt(NULL),
265  fHistoTruePrimaryinJetInvMassPt(NULL),
266  fHistoTruePrimaryInJetInvMassTruePt(NULL),
267  fHistoTrueDoubleCountingJet(NULL),
268  fHistoTrueJetFragmFunc(NULL),
269  fHistoTrueJetFragmFuncZInvMass(NULL),
270  fHistoMCPi0JetInAccPt(NULL),
271  fHistoMCPi0inJetInAccPt(NULL),
272  fHistoMCEtaJetInAccPt(NULL),
273  fHistoMCEtainJetInAccPt(NULL),
274  fHistoMCPi0JetEventGenerated(NULL),
275  fHistoMCPi0inJetGenerated(NULL),
276  fHistoMCEtaJetEventGenerated(NULL),
277  fHistoMCEtainJetGenerated(NULL),
278  fHistoTrueSecondaryFromK0sJetInvMassPt(NULL),
279  fHistoTrueSecondaryFromK0sinJetInvMassPt(NULL),
280  fHistoTrueSecondaryFromLambdaJetInvMassPt(NULL),
281  fHistoTrueSecondaryFromLambdainJetInvMassPt(NULL),
282  fHistoTrueSecondaryFromK0lJetInvMassPt(NULL),
283  fHistoTrueSecondaryFromK0linJetInvMassPt(NULL),
284  fHistoTrueSecondaryInvJetMassPt(NULL),
285  fHistoTrueSecondaryInvinJetMassPt(NULL),
286  fHistoUnfoldingAsData(NULL),
287  fHistoUnfoldingMissed(NULL),
288  fHistoUnfoldingReject(NULL),
289  fHistoUnfoldingAsDataInvMassZ(NULL),
290  fHistoUnfoldingMissedInvMassZ(NULL),
291  fHistoUnfoldingRejectInvMassZ(NULL),
292  fVectorJetPt(0),
293  fVectorJetPx(0),
294  fVectorJetPy(0),
295  fVectorJetPz(0),
296  fVectorJetEta(0),
297  fVectorJetPhi(0),
298  fVectorJetArea(0),
299  fTrueVectorJetPt(0),
300  fTrueVectorJetPx(0),
301  fTrueVectorJetPy(0),
302  fTrueVectorJetPz(0),
303  fTrueVectorJetEta(0),
304  fTrueVectorJetPhi(0),
305  fHistoSPDClusterTrackletBackground(NULL),
306  fHistoV0MultVsNumberTPCoutTracks(NULL),
307  fHistoNV0Tracks(NULL),
308  fHistoBDToutput(NULL),
309  fHistoBDToutputPt(NULL),
310  fHistoBDToutputMCTrue(NULL),
311  fProfileEtaShift(NULL),
312  fProfileJetJetXSection(NULL),
313  fhJetJetNTrials(NULL),
314  fHistoEventSphericity(NULL),
315  fHistoEtaShift(NULL),
316  tESDMesonsInvMassPtDcazMinDcazMaxFlag(NULL),
317  fInvMass(0),
318  fBDTvariable(NULL),
319  fBDTreader(NULL),
320  fFileNameBDT(0),
321  fEnableBDT(0),
322  fPt(0),
323  fDCAzGammaMin(0),
324  fDCAzGammaMax(0),
325  iFlag(0),
326  iMesonMCInfo(0),
327  fEventPlaneAngle(-100),
328  fRandom(0),
329  fnGammaCandidates(0),
330  fUnsmearedPx(NULL),
331  fUnsmearedPy(NULL),
332  fUnsmearedPz(NULL),
333  fUnsmearedE(NULL),
334  fMCEventPos(NULL),
335  fMCEventNeg(NULL),
336  fESDArrayPos(NULL),
337  fESDArrayNeg(NULL),
338  fnCuts(0),
339  fiCut(0),
340  fMoveParticleAccordingToVertex(kTRUE),
341  fIsHeavyIon(0),
342  fDoMesonAnalysis(kTRUE),
343  fDoMesonQA(0),
344  fDoPhotonQA(0),
345  fDoChargedPrimary(kFALSE),
346  fDoPlotVsCentrality(kFALSE),
347  fIsFromSelectedHeader(kTRUE),
348  fIsMC(0),
349  fDoTHnSparse(kFALSE),
350  fWeightJetJetMC(1),
351  fWeightCentrality(NULL),
352  fEnableClusterCutsForTrigger(kFALSE),
353  fDoMaterialBudgetWeightingOfGammasForTrueMesons(kFALSE),
354  tBrokenFiles(NULL),
355  fFileNameBroken(NULL)
356 {
357 
358 }
359 
360 //________________________________________________________________________
362  AliAnalysisTaskSE(name),
363  fV0Reader(NULL),
364  fV0ReaderName("V0ReaderV1"),
365  fDoLightOutput(kFALSE),
366  fBGHandler(NULL),
367  fBGHandlerRP(NULL),
368  fInputEvent(NULL),
369  fMCEvent(NULL),
370  fCutFolder(NULL),
371  fESDList(NULL),
372  fBackList(NULL),
373  fMotherList(NULL),
374  fTrueList(NULL),
375  fMCList(NULL),
376  fHeaderNameList(NULL),
377  fOutputContainer(0),
378  fReaderGammas(NULL),
379  fGammaCandidates(NULL),
380  fEventCutArray(NULL),
381  fCutArray(NULL),
382  fMesonCutArray(NULL),
383  fClusterCutArray(NULL),
384  fConvJetReader(NULL),
385  fDoJetAnalysis(kFALSE),
386  fDoIsolatedAnalysis(kFALSE),
387  fDoHighPtHadronAnalysis(kFALSE),
388  fDoJetQA(kFALSE),
389  fJetHistograms(NULL),
390  fTrueJetHistograms(NULL),
391  fMaxPtNearEMCalPlace(0),
392  fJetNearEMCal(kFALSE),
393  fHistoCaloGammaPt(NULL),
394  fHistoCaloGammaE(NULL),
395  fHistoConvGammaPt(NULL),
396  fHistoConvGammaPtwithHighPtHadron(NULL),
397  fHistoConvGammaPtwithoutHighPtHadron(NULL),
398  fHistoConvGammaR(NULL),
399  fHistoConvGammaEta(NULL),
400  fHistoConvGammaPhi(NULL),
401  fHistoConvGammaPsiPairPt(NULL),
402  fHistoConvGammaInvMass(NULL),
403  fHistoConvGammaInvMassReco(NULL),
404  tESDConvGammaPtDcazCat(NULL),
405  fPtGamma(0),
406  fDCAzPhoton(0),
407  fRConvPhoton(0),
408  fEtaPhoton(0),
409  iCatPhoton(0),
410  iPhotonMCInfo(0),
411  fHistoMotherInvMassPt(NULL),
412  fHistoMotherInvMassPtIso(NULL),
413  fHistoMotherInvMassPtNonIso(NULL),
414  fHistoMotherInvMassPtMCRecIsoTrueNonIso(NULL),
415  fHistoMotherInvMassPtMCRecNonIsoTrueIso(NULL),
416  fHistoMotherEisoPt(NULL),
417  fHistoMotherRisoPt(NULL),
418  fHistoMotherNtracksIsoPt(NULL),
419  sESDMotherInvMassPtZM(NULL),
420  fHistoMotherBackInvMassPt(NULL),
421  sESDMotherBackInvMassPtZM(NULL),
422  fHistoMotherInvMassEalpha(NULL),
423  fHistoMotherPi0PtY(NULL),
424  fHistoMotherEtaPtY(NULL),
425  fHistoMotherPi0PtAlpha(NULL),
426  fHistoMotherEtaPtAlpha(NULL),
427  fHistoMotherPi0PtOpenAngle(NULL),
428  fHistoMotherEtaPtOpenAngle(NULL),
429  sPtRDeltaROpenAngle(NULL),
430  fHistoMCHeaders(NULL),
431  fHistoMCAllGammaPt(NULL),
432  fHistoMCAllSecondaryGammaPt(NULL),
433  fHistoMCDecayGammaPi0Pt(NULL),
434  fHistoMCDecayGammaRhoPt(NULL),
435  fHistoMCDecayGammaEtaPt(NULL),
436  fHistoMCDecayGammaOmegaPt(NULL),
437  fHistoMCDecayGammaEtapPt(NULL),
438  fHistoMCDecayGammaPhiPt(NULL),
439  fHistoMCDecayGammaSigmaPt(NULL),
440  fHistoMCConvGammaPt(NULL),
441  fHistoMCSecondaryConvGammaPt(NULL),
442  fHistoMCConvGammaR(NULL),
443  fHistoMCConvGammaEta(NULL),
444  fHistoMCPi0Pt(NULL),
445  fHistoMCPi0WOWeightPt(NULL),
446  fHistoMCPi0WOEvtWeightPt(NULL),
447  fHistoMCEtaWOEvtWeightPt(NULL),
448  fHistoMCEtaPt(NULL),
449  fHistoMCEtaWOWeightPt(NULL),
450  fHistoMCPi0WOWeightInAccPt(NULL),
451  fHistoMCEtaWOWeightInAccPt(NULL),
452  fHistoMCPi0InAccPt(NULL),
453  fHistoMCEtaInAccPt(NULL),
454  fHistoMCPi0WOEvtWeightInAccPt(NULL),
455  fHistoMCEtaWOEvtWeightInAccPt(NULL),
456  fHistoMCPi0PtY(NULL),
457  fHistoMCEtaPtY(NULL),
458  fHistoMCPi0PtAlpha(NULL),
459  fHistoMCEtaPtAlpha(NULL),
460  fHistoMCPrimaryPtvsSource(NULL),
461  fHistoMCSecPi0PtvsSource(NULL),
462  fHistoMCSecPi0RvsSource(NULL),
463  fHistoMCSecPi0Source(NULL),
464  fHistoMCSecPi0InAccPtvsSource(NULL),
465  fHistoMCSecEtaPt(NULL),
466  fHistoMCSecEtaSource(NULL),
467  fHistoMCPi0PtJetPt(NULL),
468  fHistoMCEtaPtJetPt(NULL),
469  fHistoMCPhysicalPrimariesPt(NULL),
470  fHistoTrueMotherInvMassPt(NULL),
471  fHistoTruePrimaryMotherInvMassPt(NULL),
472  fHistoTruePrimaryMotherW0WeightingInvMassPt(NULL),
473  pESDTruePrimaryMotherWeightsInvMassPt(NULL),
474  fHistoTruePrimaryPi0MCPtResolPt(NULL),
475  fHistoTruePrimaryEtaMCPtResolPt(NULL),
476  fHistoTrueSecondaryMotherInvMassPt(NULL),
477  fHistoTrueSecondaryMotherFromK0sInvMassPt(NULL),
478  fHistoTrueK0sWithPi0DaughterMCPt(NULL),
479  fHistoTrueSecondaryMotherFromK0lInvMassPt(NULL),
480  fHistoTrueK0lWithPi0DaughterMCPt(NULL),
481  fHistoTrueSecondaryMotherFromEtaInvMassPt(NULL),
482  fHistoTrueEtaWithPi0DaughterMCPt(NULL),
483  fHistoTrueSecondaryMotherFromLambdaInvMassPt(NULL),
484  fHistoTrueLambdaWithPi0DaughterMCPt(NULL),
485  fHistoTrueBckGGInvMassPt(NULL),
486  fHistoTrueBckContInvMassPt(NULL),
487  fHistoTruePi0PtY(NULL),
488  fHistoTrueEtaPtY(NULL),
489  fHistoTruePi0PtAlpha(NULL),
490  fHistoTrueEtaPtAlpha(NULL),
491  fHistoTruePi0PtOpenAngle(NULL),
492  fHistoTrueEtaPtOpenAngle(NULL),
493  fHistoTrueMotherDalitzInvMassPt(NULL),
494  fHistoTrueConvGammaPt(NULL),
495  fHistoTrueConvGammaR(NULL),
496  fHistoTrueConvGammaPtMC(NULL),
497  fHistoTrueConvGammaRMC(NULL),
498  fHistoTrueConvGammaEta(NULL),
499  fHistoTrueConvGammaPsiPairPt(NULL),
500  fHistoTrueConvGammaInvMass(NULL),
501  fHistoTrueConvGammaInvMassReco(NULL),
502  fHistoCombinatorialPt(NULL),
503  fHistoCombinatorialMothersPt(NULL),
504  fHistoCombinatorialPtDeltaPhi_ek(NULL),
505  fHistoCombinatorialPtDeltaPhi_ep(NULL),
506  fHistoCombinatorialPtDeltaPhi_epi(NULL),
507  fHistoCombinatorialPtDeltaPhi_pik(NULL),
508  fHistoCombinatorialPtDeltaPhi_pip(NULL),
509  fHistoTruePrimaryConvGammaPt(NULL),
510  fHistoTrueSecondaryConvGammaPt(NULL),
511  fHistoTrueSecondaryConvGammaMCPt(NULL),
512  fHistoTruePrimaryConvGammaESDPtMCPt(NULL),
513  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt(NULL),
514  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt(NULL),
515  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt(NULL),
516  fHistoTrueDalitzPsiPairDeltaPhi(NULL),
517  fHistoTrueGammaPsiPairDeltaPhi(NULL),
518  fHistoDoubleCountTruePi0InvMassPt(NULL),
519  fHistoDoubleCountTrueEtaInvMassPt(NULL),
520  fHistoDoubleCountTrueConvGammaRPt(NULL),
521  vecDoubleCountTruePi0s(0),
522  vecDoubleCountTrueEtas(0),
523  vecDoubleCountTrueConvGammas(0),
524  fHistoMultipleCountTruePi0(NULL),
525  fHistoMultipleCountTrueEta(NULL),
526  fHistoMultipleCountTrueConvGamma(NULL),
527  mapMultipleCountTruePi0s(),
528  mapMultipleCountTrueEtas(),
529  mapMultipleCountTrueConvGammas(),
530  fHistoNEvents(NULL),
531  fHistoNEventsWOWeight(NULL),
532  fHistoNGoodESDTracks(NULL),
533  fHistoNEventsWeighted(NULL),
534  fHistoNGoodESDTracksWeighted(NULL),
535  fHistoVertexZ(NULL),
536  fHistoVertexZWeighted(NULL),
537  fDoCentralityFlat(0),
538  fHistoCentrality(NULL),
539  fHistoCentralityFlattened(NULL),
540  fHistoCentralityVsPrimaryTracks(NULL),
541  fHistoNGammaCandidates(NULL),
542  fHistoNGoodESDTracksVsNGammaCandidates(NULL),
543  fHistoPtJet(NULL),
544  fHistoJetEta(NULL),
545  fHistoJetPhi(NULL),
546  fHistoJetArea(NULL),
547  fHistoNJets(NULL),
548  fHistoEventwJets(NULL),
549  fHistoJetPi0PtRatio(NULL),
550  fHistoDoubleCounting(NULL),
551  fHistoJetMotherInvMassPt(NULL),
552  fHistoPi0InJetMotherInvMassPt(NULL),
553  fHistoMotherBackJetInvMassPt(NULL),
554  fHistoRJetPi0Cand(NULL),
555  fHistoEtaPhiJetPi0Cand(NULL),
556  fHistoEtaPhiJetWithPi0Cand(NULL),
557  fHistoJetFragmFunc(NULL),
558  fHistoJetFragmFuncZInvMass(NULL),
559  fHistoTruevsRecJetPt(NULL),
560  fHistoTrueJetMotherInvMassPt(NULL),
561  fHistoTrueInJetMotherInvMassPt(NULL),
562  fHistoTruePrimaryJetInvMassPt(NULL),
563  fHistoTruePrimaryinJetInvMassPt(NULL),
564  fHistoTruePrimaryInJetInvMassTruePt(NULL),
565  fHistoTrueDoubleCountingJet(NULL),
566  fHistoTrueJetFragmFunc(NULL),
567  fHistoTrueJetFragmFuncZInvMass(NULL),
568  fHistoMCPi0JetInAccPt(NULL),
569  fHistoMCPi0inJetInAccPt(NULL),
570  fHistoMCEtaJetInAccPt(NULL),
571  fHistoMCEtainJetInAccPt(NULL),
572  fHistoMCPi0JetEventGenerated(NULL),
573  fHistoMCPi0inJetGenerated(NULL),
574  fHistoMCEtaJetEventGenerated(NULL),
575  fHistoMCEtainJetGenerated(NULL),
576  fHistoTrueSecondaryFromK0sJetInvMassPt(NULL),
577  fHistoTrueSecondaryFromK0sinJetInvMassPt(NULL),
578  fHistoTrueSecondaryFromLambdaJetInvMassPt(NULL),
579  fHistoTrueSecondaryFromLambdainJetInvMassPt(NULL),
580  fHistoTrueSecondaryFromK0lJetInvMassPt(NULL),
581  fHistoTrueSecondaryFromK0linJetInvMassPt(NULL),
582  fHistoTrueSecondaryInvJetMassPt(NULL),
583  fHistoTrueSecondaryInvinJetMassPt(NULL),
584  fHistoUnfoldingAsData(NULL),
585  fHistoUnfoldingMissed(NULL),
586  fHistoUnfoldingReject(NULL),
587  fHistoUnfoldingAsDataInvMassZ(NULL),
588  fHistoUnfoldingMissedInvMassZ(NULL),
589  fHistoUnfoldingRejectInvMassZ(NULL),
590  fVectorJetPt(0),
591  fVectorJetPx(0),
592  fVectorJetPy(0),
593  fVectorJetPz(0),
594  fVectorJetEta(0),
595  fVectorJetPhi(0),
596  fVectorJetArea(0),
597  fTrueVectorJetPt(0),
598  fTrueVectorJetPx(0),
599  fTrueVectorJetPy(0),
600  fTrueVectorJetPz(0),
601  fTrueVectorJetEta(0),
602  fTrueVectorJetPhi(0),
603  fHistoSPDClusterTrackletBackground(NULL),
604  fHistoV0MultVsNumberTPCoutTracks(NULL),
605  fHistoNV0Tracks(NULL),
606  fHistoBDToutput(NULL),
607  fHistoBDToutputPt(NULL),
608  fHistoBDToutputMCTrue(NULL),
609  fProfileEtaShift(NULL),
610  fProfileJetJetXSection(NULL),
611  fhJetJetNTrials(NULL),
612  fHistoEventSphericity(NULL),
613  fHistoEtaShift(NULL),
614  tESDMesonsInvMassPtDcazMinDcazMaxFlag(NULL),
615  fInvMass(0),
616  fBDTvariable(NULL),
617  fBDTreader(NULL),
618  fFileNameBDT(0),
619  fEnableBDT(0),
620  fPt(0),
621  fDCAzGammaMin(0),
622  fDCAzGammaMax(0),
623  iFlag(0),
624  iMesonMCInfo(0),
625  fEventPlaneAngle(-100),
626  fRandom(0),
627  fnGammaCandidates(0),
628  fUnsmearedPx(NULL),
629  fUnsmearedPy(NULL),
630  fUnsmearedPz(NULL),
631  fUnsmearedE(NULL),
632  fMCEventPos(NULL),
633  fMCEventNeg(NULL),
634  fESDArrayPos(NULL),
635  fESDArrayNeg(NULL),
636  fnCuts(0),
637  fiCut(0),
638  fMoveParticleAccordingToVertex(kTRUE),
639  fIsHeavyIon(0),
640  fDoMesonAnalysis(kTRUE),
641  fDoMesonQA(0),
642  fDoPhotonQA(0),
643  fDoChargedPrimary(kFALSE),
644  fDoPlotVsCentrality(kFALSE),
645  fIsFromSelectedHeader(kTRUE),
646  fIsMC(0),
647  fDoTHnSparse(kFALSE),
648  fWeightJetJetMC(1),
649  fWeightCentrality(NULL),
650  fEnableClusterCutsForTrigger(kFALSE),
651  fDoMaterialBudgetWeightingOfGammasForTrueMesons(kFALSE),
652  tBrokenFiles(NULL),
653  fFileNameBroken(NULL)
654 {
655  // Define output slots here
656  DefineOutput(1, TList::Class());
657  DefineOutput(2, TTree::Class());
658  DefineOutput(3, TTree::Class());
659  DefineOutput(4, TTree::Class());
660  DefineOutput(5, TTree::Class());
661  DefineOutput(6, TTree::Class());
662  DefineOutput(7, TTree::Class());
663  DefineOutput(8, TTree::Class());
664  DefineOutput(9, TTree::Class());
665 }
666 
668 {
669  if(fGammaCandidates){
670  delete fGammaCandidates;
671  fGammaCandidates = 0x0;
672  }
673  if(fBGHandler){
674  delete[] fBGHandler;
675  fBGHandler = 0x0;
676  }
677  if(fBGHandlerRP){
678  delete[] fBGHandlerRP;
679  fBGHandlerRP = 0x0;
680  }
681 
682  if(fWeightCentrality){
683  delete[] fWeightCentrality;
684  fWeightCentrality = 0x0;
685  }
686 
687 }
688 //___________________________________________________________
690 
691  const Int_t nDim = 4;
692  Int_t nBins[nDim] = {800,250,7,4};
693  Double_t xMin[nDim] = {0,0, 0,0};
694  Double_t xMax[nDim] = {0.8,25,7,4};
695  Int_t nBinsRP[nDim] = {800,250,7,8};
696  Double_t xMinRP[nDim] = {0,0, 0,0};
697  Double_t xMaxRP[nDim] = {0.8,25,7,8};
698 
699  if(fDoTHnSparse){
700  sESDMotherInvMassPtZM = new THnSparseF*[fnCuts];
701  sESDMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
702  }
704  fBGHandlerRP = new AliConversionAODBGHandlerRP*[fnCuts];
705  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
706  if (((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
707  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
708  TString cutstringPhoton = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
709  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
710 
711  Int_t collisionSystem = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(0,1));
712  Int_t centMin = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(1,1));
713  Int_t centMax = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(2,1));
714 
715  if(collisionSystem == 1 || collisionSystem == 2 ||
716  collisionSystem == 5 || collisionSystem == 8 ||
717  collisionSystem == 9){
718  centMin = centMin*10;
719  centMax = centMax*10;
720  if(centMax ==0 && centMax!=centMin) centMax=100;
721  } else if(collisionSystem == 3 || collisionSystem == 6) {
722  centMin = centMin*5;
723  centMax = centMax*5;
724  } else if(collisionSystem == 4 || collisionSystem == 7) {
725  centMin = ((centMin*5)+45);
726  centMax = ((centMax*5)+45);
727  }
728 
729  if(fDoTHnSparse){
730  fBackList[iCut] = new TList();
731  fBackList[iCut]->SetName(Form("%s_%s_%s Back histograms",cutstringEvent.Data(), cutstringPhoton.Data(),cutstringMeson.Data()));
732  fBackList[iCut]->SetOwner(kTRUE);
733  fCutFolder[iCut]->Add(fBackList[iCut]);
734 
735  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
736  sESDMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_m", "Back_Back_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
737  } else {
738  sESDMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_psi", "Back_Back_InvMass_Pt_z_psi",nDim,nBinsRP,xMinRP,xMaxRP);
739  }
740  if(fDoCentralityFlat > 0) sESDMotherBackInvMassPtZM[iCut]->Sumw2();
741  fBackList[iCut]->Add(sESDMotherBackInvMassPtZM[iCut]);
742 
743  fMotherList[iCut] = new TList();
744  fMotherList[iCut]->SetName(Form("%s_%s_%s Mother histograms",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
745  fMotherList[iCut]->SetOwner(kTRUE);
746  fCutFolder[iCut]->Add(fMotherList[iCut]);
747 
748  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
749  sESDMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_m", "Back_Mother_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
750  } else {
751  sESDMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_psi", "Back_Mother_InvMass_Pt_z_psi",nDim,nBinsRP,xMinRP,xMaxRP);
752  }
753  if(fDoCentralityFlat > 0) sESDMotherInvMassPtZM[iCut]->Sumw2();
754  fMotherList[iCut]->Add(sESDMotherInvMassPtZM[iCut]);
755  }
756  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
758  collisionSystem,centMin,centMax,
759  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents(),
760  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseTrackMultiplicity(),
761  0,8,5);
762  fBGHandlerRP[iCut] = NULL;
763  } else {
764  fBGHandlerRP[iCut] = new AliConversionAODBGHandlerRP(
765  ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsHeavyIon(),
766  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity(),
767  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents());
768  fBGHandler[iCut] = NULL;
769  }
770  }
771  }
772 }
773 //________________________________________________________________________
775 
776  // get V0 Reader
777  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
778  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
779 
780 
781  if( ((AliConversionPhotonCuts*)fCutArray->At(0))->GetUseBDTPhotonCuts()){
782  fEnableBDT = kTRUE;
783  InitializeBDT(); //
784  }
785 
786  if(fDoMesonAnalysis){ //Same Jet Finder MUST be used within same trainconfig
787  if( ((AliConversionMesonCuts*)fMesonCutArray->At(0))->DoJetAnalysis()) fDoJetAnalysis = kTRUE;
788  if( ((AliConversionMesonCuts*)fMesonCutArray->At(0))->DoJetQA()) fDoJetQA = kTRUE;
789  if( ((AliConversionMesonCuts*)fMesonCutArray->At(0))->DoIsolatedAnalysis()) fDoIsolatedAnalysis = kTRUE;
790  }
791  if( ((AliConversionMesonCuts*)fMesonCutArray->At(0))->DoHighPtHadronAnalysis()) fDoHighPtHadronAnalysis = kTRUE;
792 
793  if(fDoJetAnalysis){
794  fConvJetReader=(AliAnalysisTaskConvJet*)AliAnalysisManager::GetAnalysisManager()->GetTask("AliAnalysisTaskConvJet");
795  if(!fConvJetReader){printf("Error: No AliAnalysisTaskConvJet");return;} // GetV0Reader
796  }
797 
798  // Set dimenstions for THnSparse
799  const Int_t nDim2 = 4;
800  Int_t nBins2[nDim2] = {250,180,100,100};
801  Double_t xMin2[nDim2] = {0,0, 0,0};
802  Double_t xMax2[nDim2] = {25,180,10,0.1};
803 
804  // Set maximum number of tracks, gammas and tracklets
805  Int_t nGammaCand = 50;
806  Int_t nTracks = 200;
807  Int_t nSPDTracklets = 200;
808  Int_t nSPDClusters = 400;
809  Int_t nBinsTrklCls = 100;
810  if(fIsHeavyIon == 1){
811  nGammaCand = 200;
812  nTracks = 4000;
813  nSPDTracklets = 6000;
814  nSPDClusters = 20000;
815  nBinsTrklCls = 200;
816  } else if(fIsHeavyIon == 2){
817  nGammaCand = 50;
818  nTracks = 400;
819  nSPDTracklets = 300;
820  nSPDClusters = 600;
821  nBinsTrklCls = 150;
822  }
823 
824 // Float_t binWidthPt = 0.1;
825  Int_t nBinsPt = 250;
826  Float_t minPt = 0;
827  Float_t maxPt = 25;
828  Int_t nBinsQAPt = 175;
829  Float_t maxQAPt = 25;
830  Int_t nBinsClusterPt = 500;
831  Float_t minClusterPt = 0;
832  Float_t maxClusterPt = 50;
833  Double_t *arrPtBinning = new Double_t[1200];
834  Double_t *arrQAPtBinning = new Double_t[1200];
835  Double_t *arrClusPtBinning = new Double_t[1200];
836 
837 
838  // Set special pt binning for pp 13TeV and 5TeV
839  if ( ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k13TeV ||
840  ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k13TeVLowB ){
841  // binWidthPt = 0.05;
842  nBinsPt = 169;
843  minPt = 0;
844  maxPt = 50;
845  for(Int_t i=0; i<nBinsPt+1;i++){
846  if (i < 100) arrPtBinning[i] = 0.10*i;
847  else if(i<140) arrPtBinning[i] = 10.+0.25*(i-100);
848  else if(i<170) arrPtBinning[i] = 20.+1.00*(i-140);
849  else arrPtBinning[i] = maxPt;
850  }
851  nBinsQAPt = 170;
852  maxQAPt = 50;
853  for(Int_t i=0; i<nBinsQAPt+1;i++){
854  if(i<100) arrQAPtBinning[i] = 0.1*i;
855  else if(i<140) arrQAPtBinning[i] = 10.+0.25*(i-100);
856  else if(i<170) arrQAPtBinning[i] = 20.+1.0*(i-140);
857  else arrQAPtBinning[i] = maxQAPt;
858  }
859  nBinsClusterPt = 274;
860  minClusterPt = 0;
861  maxClusterPt = 100;
862  for(Int_t i=0; i<nBinsClusterPt+1;i++){
863  if (i < 1) arrClusPtBinning[i] = 0.3*i;
864  else if(i<98) arrClusPtBinning[i] = 0.3+0.1*(i-1);
865  else if(i<128) arrClusPtBinning[i] = 10.+0.2*(i-98);
866  else if(i<184) arrClusPtBinning[i] = 16.+0.25*(i-128);
867  else if(i<224) arrClusPtBinning[i] = 30.+0.5*(i-184);
868  else if(i<274) arrClusPtBinning[i] = 50.+1.0*(i-224);
869  else arrClusPtBinning[i] = maxClusterPt;
870  }
871  // Set special pt binning for pp 13TeV and 5TeV
872  } else if ( ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::kpPb5TeV ||
873  ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::kpPb5TeVR2 ||
874  ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k5TeV ||
875  ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k8TeV ||
876  ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::kpPb8TeV ){
877  nBinsPt = 159;
878  minPt = 0;
879  maxPt = 40;
880  for(Int_t i=0; i<nBinsPt+1;i++){
881  if (i < 100) arrPtBinning[i] = 0.10*i;
882  else if(i<140) arrPtBinning[i] = 10.+0.25*(i-100);
883  else if(i<160) arrPtBinning[i] = 20.+1.0*(i-140);
884  else arrPtBinning[i] = maxPt;
885  }
886  nBinsQAPt = 159;
887  maxQAPt = 40;
888  for(Int_t i=0; i<nBinsQAPt+1;i++){
889  if(i<100) arrQAPtBinning[i] = 0.1*i;
890  else if(i<140) arrQAPtBinning[i] = 10.+0.25*(i-100);
891  else if(i<160) arrQAPtBinning[i] = 20.+1.0*(i-140);
892  else arrQAPtBinning[i] = maxQAPt;
893  }
894  nBinsClusterPt = 274;
895  minClusterPt = 0;
896  maxClusterPt = 100;
897  for(Int_t i=0; i<nBinsClusterPt+1;i++){
898  if (i < 1) arrClusPtBinning[i] = 0.3*i;
899  else if(i<98) arrClusPtBinning[i] = 0.3+0.1*(i-1);
900  else if(i<128) arrClusPtBinning[i] = 10.+0.2*(i-98);
901  else if(i<184) arrClusPtBinning[i] = 16.+0.25*(i-128);
902  else if(i<224) arrClusPtBinning[i] = 30.+0.5*(i-184);
903  else if(i<274) arrClusPtBinning[i] = 50.+1.0*(i-224);
904  else arrClusPtBinning[i] = maxClusterPt;
905  }
906  // Set special pt binning for XeXe 5.44TeV
907  } else if (((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::kXeXe5440GeV ){
908 // binWidthPt = 0.1;
909  nBinsPt = 90;
910  minPt = 0;
911  maxPt = 20;
912  for(Int_t i=0; i<nBinsPt+1;i++){
913  if (i < 1) arrPtBinning[i] = 0.3*i;
914  else if(i<58) arrPtBinning[i] = 0.3+0.1*(i-1);
915  else if(i<82) arrPtBinning[i] = 6.+0.25*(i-58);
916  else if(i<90) arrPtBinning[i] = 12.+1.0*(i-82);
917  else arrPtBinning[i] = maxPt;
918  }
919  nBinsQAPt = 92;
920  maxQAPt = 20;
921  for(Int_t i=0; i<nBinsQAPt+1;i++){
922  if(i<60) arrQAPtBinning[i] = 0.1*i;
923  else if(i<84) arrQAPtBinning[i] = 6.+0.25*(i-60);
924  else if(i<92) arrQAPtBinning[i] = 12.+1.0*(i-84);
925  else arrQAPtBinning[i] = maxQAPt;
926  }
927  nBinsClusterPt = 148;
928  minClusterPt = 0;
929  maxClusterPt = 40;
930  for(Int_t i=0; i<nBinsClusterPt+1;i++){
931  if (i < 1) arrClusPtBinning[i] = 0.3*i;
932  else if(i<98) arrClusPtBinning[i] = 0.3+0.1*(i-1);
933  else if(i<123) arrClusPtBinning[i] = 10.+0.2*(i-98);
934  else if(i<148) arrClusPtBinning[i] = 15.+1.0*(i-123);
935  else arrClusPtBinning[i] = maxClusterPt;
936  }
937  // Set special pt binning for PbPb 5TeV
938  } else if (((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::kPbPb5TeV ){
939 
940  nBinsPt = 38;
941  minPt = 0.0;
942  maxPt = 25.0;
943  for(Int_t i=0; i<=nBinsPt;i++){
944  if(i<=20) arrPtBinning[i] = 0.0 + 0.2*i; // 0.2 GeV bin width until 4 GeV
945  else if(i<=30) arrPtBinning[i] = 4.0 + 0.5*(i-20); // 0.5 GeV 9 GeV
946  else if(i<=36) arrPtBinning[i] = 9.0 + 1.0*(i-30); // 1.0 GeV 15 GeV
947  else /*i<=nBinsPt*/ arrPtBinning[i] = 15.0 + 5.0*(i-36); // 5.0 GeV 25 GeV
948  }
949 
950  nBinsQAPt = 38;
951  maxQAPt = 25.0;
952  for(Int_t i=0; i<=nBinsQAPt;i++){
953  if(i<=20) arrQAPtBinning[i] = 0.0 + 0.2*i; // 0.2 GeV bin width until 4 GeV
954  else if(i<=30) arrQAPtBinning[i] = 4.0 + 0.5*(i-20); // 0.5 GeV 9 GeV
955  else if(i<=36) arrQAPtBinning[i] = 9.0 + 1.0*(i-30); // 1.0 GeV 15 GeV
956  else /*i<=nBinsPt*/ arrQAPtBinning[i] = 15.0 + 5.0*(i-36); // 5.0 GeV 25 GeV
957  }
958 
959  nBinsClusterPt = 148;
960  minClusterPt = 0;
961  maxClusterPt = 40;
962  for(Int_t i=0; i<nBinsClusterPt+1;i++){
963  if (i < 1) arrClusPtBinning[i] = 0.3*i;
964  else if(i<98) arrClusPtBinning[i] = 0.3+0.1*(i-1);
965  else if(i<123) arrClusPtBinning[i] = 10.+0.2*(i-98);
966  else if(i<148) arrClusPtBinning[i] = 15.+1.0*(i-123);
967  else arrClusPtBinning[i] = maxClusterPt;
968  }
969  //----------------------------------------------------------------------------------------------------------------
970  } else {
971 
972  for(Int_t i=0; i<nBinsPt+1;i++){
973  arrPtBinning[i] = ((maxPt-minPt)/nBinsPt)*i;
974  }
975  for(Int_t i=0; i<nBinsClusterPt+1;i++){
976  arrClusPtBinning[i] = ((maxClusterPt-minClusterPt)/nBinsClusterPt)*i;
977  }
978  for(Int_t i=0; i<nBinsQAPt+1;i++){
979  if(i<60) arrQAPtBinning[i] = 0.05*i;
980  else if(i<130) arrQAPtBinning[i] = 3.+0.1*(i-60);
981  else if(i<170) arrQAPtBinning[i] = 10.+0.25*(i-130);
982  else if(i<175) arrQAPtBinning[i] = 20.+1*(i-170);
983  else arrQAPtBinning[i] = maxQAPt;
984  }
985  }
986  Double_t* arrLogBinning = new Double_t[51]{1.00e-03, 1.20e-03, 1.45e-03, 1.74e-03, 2.01e-03, 2.51e-03, 3.02e-03, 3.63e-03, 4.37e-03, 5.25e-03, 6.31e-03, 7.60e-03,
987  9.12e-03, 1.01e-02, 1.32e-02, 1.58e-02, 1.91e-02, 2.29e-02, 2.75e-02, 3.31e-02, 3.98e-02, 4.79e-02, 5.75e-02, 6.91e-02,
988  8.32e-02, 1.00e-01, 1.20e-01, 1.45e-01, 1.74e-01, 2.09e-01, 2.51e-01, 3.02e-01, 3.63e-01, 4.37e-01, 5.25e-01, 6.31e-01,
989  7.59e-01, 9.12e-01, 1.10e+00, 1.32e+00, 1.58e+00, 1.91e+00, 2.29e+00, 2.75e+00, 3.31e+00, 3.98e+00, 4.79e+00, 5.75e+00,
990  6.92e+00, 8.32e+00, 1.00e+01};
991 
992 
993  if (fIsMC == 2){
994  fDoPhotonQA = 0;
995  fDoTHnSparse = kFALSE;
996  } else if (fIsMC == 3){
997  fDoTHnSparse = kFALSE;
998  }
999  // Create histograms
1000  if(fOutputContainer != NULL){
1001  delete fOutputContainer;
1002  fOutputContainer = NULL;
1003  }
1004  if(fOutputContainer == NULL){
1005  fOutputContainer = new TList();
1006  fOutputContainer->SetOwner(kTRUE);
1007  }
1008 
1009  // Array of current cut's gammas
1010  fGammaCandidates = new TList();
1011 
1012  fCutFolder = new TList*[fnCuts];
1013  fESDList = new TList*[fnCuts];
1014  if(fDoTHnSparse){
1015  fBackList = new TList*[fnCuts];
1016  fMotherList = new TList*[fnCuts];
1017  }
1018 
1019  // event histos:
1020  fHistoNEvents = new TH1F*[fnCuts];
1021  if (fIsMC > 1){
1022  fHistoNEventsWOWeight = new TH1F*[fnCuts];
1023  }
1024  if (fIsMC == 2){
1025  fProfileJetJetXSection = new TProfile*[fnCuts];
1026  fhJetJetNTrials = new TH1F*[fnCuts];
1027  }
1028  fHistoNGoodESDTracks = new TH1F*[fnCuts];
1029  fHistoVertexZ = new TH1F*[fnCuts];
1030  fHistoEventSphericity = new TH1F*[fnCuts];
1031  if(fDoPlotVsCentrality){
1032  fHistoCentrality = new TH1F*[fnCuts];
1034  }
1035  if(fDoCentralityFlat > 0){
1037  fHistoNEventsWeighted = new TH1F*[fnCuts];
1038  fHistoNGoodESDTracksWeighted = new TH1F*[fnCuts];
1039  fHistoVertexZWeighted = new TH1F*[fnCuts];
1040  fHistoCentralityFlattened = new TH1F*[fnCuts];
1041  }
1042 
1043  if(!fDoLightOutput){
1044  fHistoNGammaCandidates = new TH1F*[fnCuts];
1045  if (fIsMC < 2){
1048  }
1050  fHistoNV0Tracks = new TH1F*[fnCuts];
1051  }
1052 
1053  if(fEnableBDT){
1054  fHistoBDToutput = new TH1F*[fnCuts];
1055  fHistoBDToutputPt = new TH1F*[fnCuts];
1056  if (fIsMC > 0){
1057  fHistoBDToutputMCTrue = new TH1F*[fnCuts];
1058  }
1059  }
1060 
1061  fHistoEtaShift = new TProfile*[fnCuts];
1062 
1063  // gamma histos:
1064  fHistoConvGammaPt = new TH1F*[fnCuts];
1068  }
1069  if (fDoPhotonQA > 0 && fIsMC < 2 ){
1071  fHistoConvGammaR = new TH1F*[fnCuts];
1072  fHistoConvGammaEta = new TH1F*[fnCuts];
1073  fHistoConvGammaPhi = new TH1F*[fnCuts];
1074  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
1075  fHistoConvGammaInvMass = new TH1F*[fnCuts];
1076  fHistoConvGammaInvMassReco = new TH1F*[fnCuts];
1077  }
1078  }
1079  if ((fDoPhotonQA == 2)||(fDoPhotonQA == 5)){
1081  }
1082 
1083  // meson histos:
1084  if(fDoMesonAnalysis){
1088  if(fDoMesonQA > 0){
1089  fHistoMotherPi0PtY = new TH2F*[fnCuts];
1090  fHistoMotherEtaPtY = new TH2F*[fnCuts];
1095  }
1096  if(fDoMesonQA == 2){
1098  }
1099  if(fDoMesonQA == 3){
1100  sPtRDeltaROpenAngle = new THnSparseF*[fnCuts];
1101  }
1102  }
1103  if(fDoIsolatedAnalysis){
1106  fHistoMotherEisoPt = new TH2F*[fnCuts];
1107  fHistoMotherRisoPt = new TH2F*[fnCuts];
1109  if (fIsMC > 0){
1112  }
1113  }
1114  if(fDoJetAnalysis){
1115  fJetHistograms = new TList*[fnCuts];
1116 
1117  fHistoPtJet = new TH1F*[fnCuts];
1118  fHistoJetEta = new TH1F*[fnCuts];
1119  fHistoJetPhi = new TH1F*[fnCuts];
1120  fHistoJetArea = new TH1F*[fnCuts];
1121  fHistoNJets = new TH1F*[fnCuts];
1122  fHistoEventwJets = new TH1F*[fnCuts];
1123  if(!fDoLightOutput){
1124  fHistoJetPi0PtRatio = new TH1F*[fnCuts];
1125  fHistoDoubleCounting = new TH1F*[fnCuts];
1129  fHistoRJetPi0Cand = new TH2F*[fnCuts];
1132  fHistoJetFragmFunc = new TH2F*[fnCuts];
1134  }
1135  }
1137  fHistoCaloGammaPt = new TH1F*[fnCuts];
1138  fHistoCaloGammaE = new TH1F*[fnCuts];
1139  }
1140 
1141 
1142  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1143 
1144  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
1145  TString cutstringPhoton = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
1146  TString cutstringMeson = "NoMesonCut";
1147  if(fDoMesonAnalysis)
1148  cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
1149 
1150  fCutFolder[iCut] = new TList();
1151  fCutFolder[iCut]->SetName(Form("Cut Number %s_%s_%s",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
1152  fCutFolder[iCut]->SetOwner(kTRUE);
1153  fOutputContainer->Add(fCutFolder[iCut]);
1154  fESDList[iCut] = new TList();
1155  fESDList[iCut]->SetName(Form("%s_%s_%s ESD histograms",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
1156  fESDList[iCut]->SetOwner(kTRUE);
1157  fCutFolder[iCut]->Add(fESDList[iCut]);
1158 
1159  if(fDoCentralityFlat > 0)
1160  fHistoNEvents[iCut] = new TH1F("NEventsUnweighted", "NEventsUnweighted", 14, -0.5, 13.5);
1161  else
1162  fHistoNEvents[iCut] = new TH1F("NEvents", "NEvents", 14, -0.5, 13.5);
1163  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
1164  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
1165  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
1166  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
1167  TString TriggerNames = "Not Trigger: ";
1168  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
1169  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
1170  } else {
1171  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
1172  }
1173  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
1174  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
1175  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
1176  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
1177  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
1178  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
1179  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
1180  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
1181  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
1182  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
1183  fESDList[iCut]->Add(fHistoNEvents[iCut]);
1184  if (fIsMC > 1){
1185  fHistoNEventsWOWeight[iCut] = new TH1F("NEventsWOWeight", "NEventsWOWeight", 14, -0.5, 13.5);
1186  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
1187  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
1188  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
1189  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
1190  TString TriggerNames = "Not Trigger: ";
1191  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
1192  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
1193  } else {
1194  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
1195  }
1196  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
1197  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
1198  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
1199  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
1200  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
1201  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
1202  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
1203  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
1204  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
1205  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
1206  fESDList[iCut]->Add(fHistoNEventsWOWeight[iCut]);
1207  }
1208  if (fIsMC == 2){
1209  fProfileJetJetXSection[iCut] = new TProfile("XSection", "XSection", 1, -0.5, 0.5);
1210  fESDList[iCut]->Add(fProfileJetJetXSection[iCut]);
1211  fhJetJetNTrials[iCut] = new TH1F("NTrials", "#sum{NTrials}", 1, 0, 1);
1212  fhJetJetNTrials[iCut]->GetXaxis()->SetBinLabel(1,"#sum{NTrials}");
1213  fESDList[iCut]->Add(fhJetJetNTrials[iCut]);
1214  }
1215  if(fDoCentralityFlat > 0){
1216  fHistoNEventsWeighted[iCut] = new TH1F("NEvents", "NEvents", 14, -0.5, 13.5);//weighted histogram!!
1217  fHistoNEventsWeighted[iCut]->Sumw2();
1218  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
1219  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
1220  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
1221  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
1222  TString TriggerNames = "Not Trigger: ";
1223  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
1224  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
1225  } else {
1226  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
1227  }
1228  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
1229  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
1230  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
1231  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
1232  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
1233  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
1234  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
1235  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
1236  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
1237  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
1238  fESDList[iCut]->Add(fHistoNEventsWeighted[iCut]);
1239  }
1240 
1241  if(fDoCentralityFlat > 0 && fIsHeavyIon == 1){
1242  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracksUnweighted", "GoodESDTracksUnweighted", nTracks, -0.5, nTracks-0.5);
1243  fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
1244  fHistoVertexZ[iCut] = new TH1F("VertexZUnweighted", "VertexZUnweighted", 200, -10, 10);
1245  fESDList[iCut]->Add(fHistoVertexZ[iCut]);
1246 
1247  fHistoNGoodESDTracksWeighted[iCut] = new TH1F("GoodESDTracks", "GoodESDTracks", nTracks, -0.5, nTracks-0.5); //weighted histogram!!
1248  fHistoNGoodESDTracksWeighted[iCut]->Sumw2();
1249  fESDList[iCut]->Add(fHistoNGoodESDTracksWeighted[iCut]);
1250  fHistoVertexZWeighted[iCut] = new TH1F("VertexZ", "VertexZ", 200, -10, 10);
1251  fHistoVertexZWeighted[iCut]->Sumw2();
1252  fESDList[iCut]->Add(fHistoVertexZWeighted[iCut]);
1253  } else {
1254  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks", "GoodESDTracks", nTracks, -0.5, nTracks-0.5);
1255  fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
1256  fHistoVertexZ[iCut] = new TH1F("VertexZ", "VertexZ", 200, -10, 10);
1257  fESDList[iCut]->Add(fHistoVertexZ[iCut]);
1258  }
1259 
1260  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetUseSphericity()!=0){
1261  fHistoEventSphericity[iCut] = new TH1F("EventSphericity", "EventSphericity", 100, 0, 1);
1262  fHistoEventSphericity[iCut]->GetXaxis()->SetTitle("S");
1263  fESDList[iCut]->Add(fHistoEventSphericity[iCut]);
1264  fV0Reader->SetCalcSphericity(kTRUE);
1265  }
1266 
1267  if(fDoPlotVsCentrality){
1268  fHistoCentrality[iCut] = new TH1F("Centrality", "Centrality", 100, -0.5, 99.5);
1269  fESDList[iCut]->Add(fHistoCentrality[iCut]);
1270  fHistoCentralityVsPrimaryTracks[iCut] = new TH2F("Centrality vs Primary Tracks", "Centrality vs Primary Tracks ", 100, -0.5, 99.5, nTracks, -0.5, nTracks-0.5);
1271  if(fDoCentralityFlat > 0 || fIsMC > 1) fHistoCentralityVsPrimaryTracks[iCut]->Sumw2();
1272  fESDList[iCut]->Add(fHistoCentralityVsPrimaryTracks[iCut]);
1273  }
1274  if(fDoCentralityFlat > 0){
1275  fHistoCentralityFlattened[iCut] = new TH1F("CentralityFlattened", "CentralityFlattened", 100, -0.5, 99.5);
1276  fHistoCentralityFlattened[iCut]->Sumw2();
1277  fESDList[iCut]->Add(fHistoCentralityFlattened[iCut]);
1278  }
1279 
1280  if(!fDoLightOutput){
1281  fHistoNGammaCandidates[iCut] = new TH1F("GammaCandidates", "GammaCandidates", nGammaCand, -0.5, nGammaCand-0.5);
1282  if(fDoCentralityFlat > 0 || fIsMC > 1) fHistoNGammaCandidates[iCut]->Sumw2();
1283  fESDList[iCut]->Add(fHistoNGammaCandidates[iCut]);
1284  if (fIsMC < 2){
1285  fHistoNGoodESDTracksVsNGammaCandidates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates", "GoodESDTracksVsGammaCandidates", nTracks, -0.5, nTracks-0.5, nGammaCand, -0.5, nGammaCand-0.5);
1288  fHistoSPDClusterTrackletBackground[iCut] = new TH2F("SPD tracklets vs SPD clusters", "SPD tracklets vs SPD clusters", nBinsTrklCls, 0, nSPDTracklets, nBinsTrklCls, 0, nSPDClusters);
1290  fESDList[iCut]->Add(fHistoSPDClusterTrackletBackground[iCut]);
1291  }
1292 
1293  if(fIsHeavyIon == 1)
1294  fHistoV0MultVsNumberTPCoutTracks[iCut] = new TH2F("V0Mult vs TPCout Tracks", "V0Mult vs TPCout Tracks", 500, 0, 15000, 500, 0, 40000);
1295  else if(fIsHeavyIon == 2)
1296  fHistoV0MultVsNumberTPCoutTracks[iCut] = new TH2F("V0Mult vs TPCout Tracks", "V0Mult vs TPCout Tracks", 500, 0, 1000, 500, 0, 2500);
1297  else
1298  fHistoV0MultVsNumberTPCoutTracks[iCut] = new TH2F("V0Mult vs TPCout Tracks", "V0Mult vs TPCout Tracks", 200, 0, 400, 500, 0, 1500);
1299  fESDList[iCut]->Add(fHistoV0MultVsNumberTPCoutTracks[iCut]);
1300 
1301  if(fIsHeavyIon == 1)
1302  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity", "V0 Multiplicity", 20000, 0, 40000);
1303  else if(fIsHeavyIon == 2)
1304  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity", "V0 Multiplicity", 2500, 0, 2500);
1305  else
1306  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity", "V0 Multiplicity", 1500, 0, 1500);
1307  if(fDoCentralityFlat > 0 || fIsMC > 1) fHistoNV0Tracks[iCut]->Sumw2();
1308  fESDList[iCut]->Add(fHistoNV0Tracks[iCut]);
1309  }
1310 
1311  if(fEnableBDT){
1312  fHistoBDToutput[iCut] = new TH1F("BDT_output", "BDT_output", 200, -1, 1);
1313  fESDList[iCut]->Add(fHistoBDToutput[iCut]);
1314 
1315  fHistoBDToutputPt[iCut] = new TH1F("BDT_ConvGamma_Pt", "BDT_ESD_ConvGamma_Pt", nBinsPt, arrPtBinning);
1316  fESDList[iCut]->Add(fHistoBDToutputPt[iCut]);
1317  }
1318 
1319  fHistoEtaShift[iCut] = new TProfile("Eta Shift", "Eta Shift", 1, -0.5, 0.5);
1320  fESDList[iCut]->Add(fHistoEtaShift[iCut]);
1321 
1322  fHistoConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt", "ESD_ConvGamma_Pt", nBinsPt, arrPtBinning);
1323  if(fDoCentralityFlat > 0 ) fHistoConvGammaPt[iCut]->Sumw2();
1324  fESDList[iCut]->Add(fHistoConvGammaPt[iCut]);
1326  fHistoConvGammaPtwithHighPtHadron[iCut] = new TH2F("ESD_ConvGamma_Pt_withHighPtHadron", "ESD_ConvGamma_Pt_withHighPtHadron", nBinsPt, arrPtBinning, nTracks, 0, nTracks);
1327  fESDList[iCut]->Add(fHistoConvGammaPtwithHighPtHadron[iCut]);
1328  fHistoConvGammaPtwithoutHighPtHadron[iCut] = new TH2F("ESD_ConvGamma_Pt_withoutHighPtHadron", "ESD_ConvGamma_Pt_withoutHighPtHadron", nBinsPt, arrPtBinning, nTracks, 0, nTracks);
1330  }
1331 
1333  fHistoConvGammaPt[iCut]->Sumw2();
1335  fHistoConvGammaPtwithHighPtHadron[iCut]->Sumw2();
1336  fHistoConvGammaPtwithoutHighPtHadron[iCut]->Sumw2();
1337  }
1338  }
1339 
1340  if (fIsMC > 1){
1341  fHistoNEvents[iCut]->Sumw2();
1342  fHistoNGoodESDTracks[iCut]->Sumw2();
1343  fHistoVertexZ[iCut]->Sumw2();
1344  fHistoEtaShift[iCut]->Sumw2();
1345  if(fDoPlotVsCentrality){
1346  fHistoCentrality[iCut]->Sumw2();
1347  }
1348  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetUseSphericity()!=0){
1349  fHistoEventSphericity[iCut]->Sumw2();
1350  }
1351  }
1352 
1354  fHistoCaloGammaPt[iCut] = new TH1F("ClusGamma_Pt", "ClusGamma_Pt", nBinsClusterPt, arrClusPtBinning);
1355  fHistoCaloGammaPt[iCut]->SetXTitle("p_{T,clus}(GeV/c)");
1356  fESDList[iCut]->Add(fHistoCaloGammaPt[iCut]);
1357  if (fIsMC > 1) fHistoCaloGammaPt[iCut]->Sumw2();
1358  fHistoCaloGammaE[iCut] = new TH1F("ClusGamma_E", "ClusGamma_E", nBinsClusterPt, arrClusPtBinning);
1359  fHistoCaloGammaE[iCut]->SetXTitle("E_{clus}(GeV)");
1360  fESDList[iCut]->Add(fHistoCaloGammaE[iCut]);
1361  if (fIsMC > 1) fHistoCaloGammaE[iCut]->Sumw2();
1362  }
1363 
1364  if ((fDoPhotonQA == 2)||(fDoPhotonQA == 5)){
1366  tESDConvGammaPtDcazCat[iCut]= new TTree(Form("%s_%s_%s MBW Photon DCA tree", cutstringEvent.Data(), cutstringPhoton.Data(), cutstringMeson.Data()), "ESD_ConvGamma_Pt_Dcaz_R_Eta_Cat");
1367  }else {
1368  tESDConvGammaPtDcazCat[iCut]= new TTree(Form("%s_%s_%s Photon DCA tree", cutstringEvent.Data(), cutstringPhoton.Data(), cutstringMeson.Data()), "ESD_ConvGamma_Pt_Dcaz_R_Eta_Cat");
1369  }
1370  tESDConvGammaPtDcazCat[iCut]->Branch("Pt",&fPtGamma,"fPtGamma/F");
1371  tESDConvGammaPtDcazCat[iCut]->Branch("DcaZPhoton",&fDCAzPhoton,"fDCAzPhoton/F");
1372  tESDConvGammaPtDcazCat[iCut]->Branch("cat",&iCatPhoton,"iCatPhoton/b");
1373  if(fIsMC>0){
1374  tESDConvGammaPtDcazCat[iCut]->Branch("photonMCInfo",&iPhotonMCInfo,"iPhotonMCInfo/b");
1375  }
1376  if (fIsMC > 1){
1377  tESDConvGammaPtDcazCat[iCut]->Branch("weightEvent",&fWeightJetJetMC,"fWeightJetJetMC/F");
1378  }
1379  }
1380 
1381  if(fDoPhotonQA > 0 && fIsMC < 2){
1382 
1383  fHistoConvGammaPsiPairPt[iCut]= new TH2F("ESD_ConvGamma_PsiPair_Pt", "ESD_ConvGamma_PsiPair_Pt", 500, 0, 5, nBinsQAPt, arrQAPtBinning);
1384  if(fDoCentralityFlat > 0) fHistoConvGammaPsiPairPt[iCut]->Sumw2();
1385  fESDList[iCut]->Add(fHistoConvGammaPsiPairPt[iCut]);
1386 
1387  fHistoConvGammaR[iCut] = new TH1F("ESD_ConvGamma_R", "ESD_ConvGamma_R", 800, 0, 200);
1388  if(fDoCentralityFlat > 0) fHistoConvGammaR[iCut]->Sumw2();
1389  fESDList[iCut]->Add(fHistoConvGammaR[iCut]);
1390  fHistoConvGammaEta[iCut] = new TH1F("ESD_ConvGamma_Eta", "ESD_ConvGamma_Eta", 1000, -2, 2);
1391  if(fDoCentralityFlat > 0) fHistoConvGammaEta[iCut]->Sumw2();
1392  fESDList[iCut]->Add(fHistoConvGammaEta[iCut]);
1393  fHistoConvGammaPhi[iCut] = new TH1F("ESD_ConvGamma_Phi", "ESD_ConvGamma_Phi", 360, 0, 2*TMath::Pi());
1394  if(fDoCentralityFlat > 0) fHistoConvGammaPhi[iCut]->Sumw2();
1395  fESDList[iCut]->Add(fHistoConvGammaPhi[iCut]);
1396  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
1397  fHistoConvGammaInvMass[iCut] = new TH1F("ESD_ConvGamma_InvMass", "ESD_ConvGamma_InvMass", 500, 0., 5.);
1398  if(fDoCentralityFlat > 0) fHistoConvGammaInvMass[iCut]->Sumw2();
1399  fESDList[iCut]->Add(fHistoConvGammaInvMass[iCut]);
1400  fHistoConvGammaInvMassReco[iCut] = new TH1F("ESD_ConvGamma_InvMassReco", "ESD_ConvGamma_InvMassReco", 500, 0., 5.);
1401  if(fDoCentralityFlat > 0) fHistoConvGammaInvMassReco[iCut]->Sumw2();
1402  fESDList[iCut]->Add(fHistoConvGammaInvMassReco[iCut]);
1403  }
1404  }
1405 
1406  if(fDoMesonAnalysis){
1407  fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt", "ESD_Mother_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1408  fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
1409  fHistoMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt", "ESD_Background_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1410  fESDList[iCut]->Add(fHistoMotherBackInvMassPt[iCut]);
1411  fHistoMotherInvMassEalpha[iCut] = new TH2F("ESD_Mother_InvMass_vs_E_alpha", "ESD_Mother_InvMass_vs_E_alpha", 800, 0, 0.8, nBinsPt, arrPtBinning);
1412  fESDList[iCut]->Add(fHistoMotherInvMassEalpha[iCut]);
1413 
1414  if (fIsMC > 1 || fDoCentralityFlat > 0){
1415  fHistoMotherInvMassPt[iCut]->Sumw2();
1416  fHistoMotherBackInvMassPt[iCut]->Sumw2();
1417  fHistoMotherInvMassEalpha[iCut]->Sumw2();
1418  }
1419 
1420  if(fDoIsolatedAnalysis){
1421  fHistoMotherInvMassPtIso[iCut] = new TH2F("ESD_Mother_InvMass_Pt_Iso", "ESD_Mother_InvMass_Pt_Iso", 800, 0, 0.8, nBinsPt, arrPtBinning);
1422  fESDList[iCut]->Add(fHistoMotherInvMassPtIso[iCut]);
1423  fHistoMotherInvMassPtNonIso[iCut] = new TH2F("ESD_Mother_InvMass_Pt_NonIso", "ESD_Mother_InvMass_Pt_NonIso", 800, 0, 0.8, nBinsPt, arrPtBinning);
1424  fESDList[iCut]->Add(fHistoMotherInvMassPtNonIso[iCut]);
1425  fHistoMotherEisoPt[iCut] = new TH2F("ESD_Mother_EIso_Pt", "ESD_Mother_EIso_Pt", 400, 0, 40, nBinsPt, arrPtBinning);
1426  fESDList[iCut]->Add(fHistoMotherEisoPt[iCut]);
1427  fHistoMotherRisoPt[iCut] = new TH2F("ESD_Mother_RIso_Pt", "ESD_Mother_RIso_Pt", 800, 0, 8, nBinsPt, arrPtBinning);
1428  fESDList[iCut]->Add(fHistoMotherRisoPt[iCut]);
1429  fHistoMotherNtracksIsoPt[iCut] = new TH2F("ESD_Mother_NTracksIso_Pt", "ESD_Mother_NTracksIso_Pt", 100, 0, 100, nBinsPt, arrPtBinning);
1430  fESDList[iCut]->Add(fHistoMotherNtracksIsoPt[iCut]);
1431  if (fIsMC > 0 ){
1432  fHistoMotherInvMassPtMCRecIsoTrueNonIso[iCut] = new TH2F("ESD_Mother_InvMass_Pt_MCRecIsoTrueNonIso", "ESD_Mother_InvMass_Pt_MCRecIsoTrueNonIso", 800, 0, 0.8, nBinsPt, arrPtBinning);
1434  fHistoMotherInvMassPtMCRecNonIsoTrueIso[iCut] = new TH2F("ESD_Mother_InvMass_Pt_MCRecNonIsoTrueIso", "ESD_Mother_InvMass_Pt_MCRecNonIsoTrueIso", 800, 0, 0.8, nBinsPt, arrPtBinning);
1436  }
1437  if (fIsMC > 1 ){
1438  fHistoMotherInvMassPtIso[iCut]->Sumw2();
1439  fHistoMotherInvMassPtNonIso[iCut]->Sumw2();
1440  fHistoMotherEisoPt[iCut]->Sumw2();
1441  fHistoMotherRisoPt[iCut]->Sumw2();
1442  fHistoMotherNtracksIsoPt[iCut]->Sumw2();
1445  }
1446  }
1447 
1448  if(fDoMesonQA == 2){
1450  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut] = new TTree(Form("%s_%s_%s MBW Meson DCA tree",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()), "ESD_Mesons_InvMass_Pt_DcazMin_DcazMax_Flag");
1451  }else {
1452  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut] = new TTree(Form("%s_%s_%s Meson DCA tree",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()), "ESD_Mesons_InvMass_Pt_DcazMin_DcazMax_Flag");
1453  }
1454 
1455  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("InvMass",&fInvMass,"fInvMass/F");
1456  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("Pt",&fPt,"fPt/F");
1457  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("DcaZMin",&fDCAzGammaMin,"fDCAzGammaMin/F");
1458  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("DcaZMax",&fDCAzGammaMax,"fDCAzGammaMax/F");
1459  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("kind",&iFlag,"iFlag/b");
1460  if(fIsMC>0){
1461  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("mesonMCInfo",&iMesonMCInfo,"iMesonMCInfo/b");
1462  }
1463  }
1464  if(fDoMesonQA > 0 ){
1465  if (fIsMC < 2){
1466  fHistoMotherPi0PtY[iCut] = new TH2F("ESD_MotherPi0_Pt_Y", "ESD_MotherPi0_Pt_Y", nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
1467  fESDList[iCut]->Add(fHistoMotherPi0PtY[iCut]);
1468  fHistoMotherEtaPtY[iCut] = new TH2F("ESD_MotherEta_Pt_Y", "ESD_MotherEta_Pt_Y", nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
1469  fESDList[iCut]->Add(fHistoMotherEtaPtY[iCut]);
1470  fHistoMotherPi0PtOpenAngle[iCut] = new TH2F("ESD_MotherPi0_Pt_OpenAngle", "ESD_MotherPi0_Pt_OpenAngle", nBinsQAPt, arrQAPtBinning, 100, 0, TMath::Pi());
1471  fESDList[iCut]->Add(fHistoMotherPi0PtOpenAngle[iCut]);
1472  fHistoMotherEtaPtOpenAngle[iCut] = new TH2F("ESD_MotherEta_Pt_OpenAngle", "ESD_MotherEta_Pt_OpenAngle", nBinsQAPt, arrQAPtBinning, 100, 0, TMath::Pi());
1473  fESDList[iCut]->Add(fHistoMotherEtaPtOpenAngle[iCut]);
1474  }
1475  fHistoMotherPi0PtAlpha[iCut] = new TH2F("ESD_MotherPi0_Pt_Alpha", "ESD_MotherPi0_Pt_Alpha", nBinsQAPt, arrQAPtBinning, 100, 0, 1);
1476  fESDList[iCut]->Add(fHistoMotherPi0PtAlpha[iCut]);
1477  fHistoMotherEtaPtAlpha[iCut] = new TH2F("ESD_MotherEta_Pt_Alpha", "ESD_MotherEta_Pt_Alpha", nBinsQAPt, arrQAPtBinning, 100, 0, 1);
1478  fESDList[iCut]->Add(fHistoMotherEtaPtAlpha[iCut]);
1479  if(fIsMC > 1){
1480  fHistoMotherPi0PtAlpha[iCut]->Sumw2();
1481  fHistoMotherEtaPtAlpha[iCut]->Sumw2();
1482  }
1483 
1484  }
1485  if(fDoMesonQA == 3){
1486  sPtRDeltaROpenAngle[iCut] = new THnSparseF("PhotonPair_Pt_R_DeltaR_OpenAngle", "PhotonPair_Pt_R_DeltaR_OpenAngle", nDim2, nBins2, xMin2, xMax2);
1487  fESDList[iCut]->Add(sPtRDeltaROpenAngle[iCut]);
1488  }
1489  }
1490  if(fDoJetAnalysis){
1491 
1492  fJetHistograms[iCut] = new TList();
1493  fJetHistograms[iCut]->SetOwner(kTRUE);
1494  fJetHistograms[iCut]->SetName(Form("%s_%s_%s Jet histograms",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
1495 
1496  fHistoPtJet[iCut] = new TH1F("JetPt", "JetPt", 150, 0, 150);
1497  fJetHistograms[iCut]->Add(fHistoPtJet[iCut]);
1498  fHistoJetEta[iCut] = new TH1F("JetEta", "JetEta", 100, -1, 1);
1499  fJetHistograms[iCut]->Add(fHistoJetEta[iCut]);
1500  fHistoJetPhi[iCut] = new TH1F("JetPhi", "JetPhi", 70, 0, 7);
1501  fJetHistograms[iCut]->Add(fHistoJetPhi[iCut]);
1502  fHistoJetArea[iCut] = new TH1F("JetArea", "JetArea", 50, 0, 1);
1503  fJetHistograms[iCut]->Add(fHistoJetArea[iCut]);
1504  fHistoNJets[iCut] = new TH1F("NJets", "NJets", 10, 0, 10);
1505  fJetHistograms[iCut]->Add(fHistoNJets[iCut]);
1506  fHistoEventwJets[iCut] = new TH1F("NEvents_with_Jets", "NEvents_with_Jets", 5, 0, 5);
1507  fJetHistograms[iCut]->Add(fHistoEventwJets[iCut]);
1508  if(!fDoLightOutput){
1509  fHistoJetPi0PtRatio[iCut] = new TH1F("Ratio_Pt_Pi0_Jet", "Ratio_Pt_Pi0_Jet", 20, 0, 1.5);
1510  fJetHistograms[iCut]->Add(fHistoJetPi0PtRatio[iCut]);
1511  fHistoJetMotherInvMassPt[iCut] = new TH2F("ESD_Pi0Jet_Mother_InvMass_Pt", "ESD_Pi0Jet_Mother_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1512  fJetHistograms[iCut]->Add(fHistoJetMotherInvMassPt[iCut]);
1513  fHistoEtaPhiJetPi0Cand[iCut] = new TH2F("Eta_Phi_Distr_Pi0Jet", "Eta_Phi_Distr_Pi0Jet", 20, 0, M_PI, 20, -1, 1);
1514  fJetHistograms[iCut]->Add(fHistoEtaPhiJetPi0Cand[iCut]);
1515  fHistoRJetPi0Cand[iCut] = new TH2F("ESD_RPi0Jet_Pt", "ESD_RPi0Jet_Pt", 35, 0, 3.5, nBinsPt, arrPtBinning);
1516  fJetHistograms[iCut]->Add(fHistoRJetPi0Cand[iCut]);
1517  fHistoPi0InJetMotherInvMassPt[iCut] = new TH2F("ESD_Pi0inJet_Mother_InvMass_Pt", "ESD_Pi0inJet_Mother_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1519  fHistoMotherBackJetInvMassPt[iCut] = new TH2F("ESD_Jet_Background_InvMass_Pt", "ESD_Jet_Background_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1520  fJetHistograms[iCut]->Add(fHistoMotherBackJetInvMassPt[iCut]);
1521  fHistoEtaPhiJetWithPi0Cand[iCut] = new TH2F("Eta_Phi_Distr_Pi0inJet", "Eta_Phi_Distr_Pi0inJet", 15, 0, 0.4, 15, -0.4, 0.4);
1522  fJetHistograms[iCut]->Add(fHistoEtaPhiJetWithPi0Cand[iCut]);
1523  fHistoDoubleCounting[iCut] = new TH1F("Double_Counting_Mesons_Jets", "Double_Counting_Mesons_Jets", 6, 0, 6);
1524  fJetHistograms[iCut]->Add(fHistoDoubleCounting[iCut]);
1525  fHistoJetFragmFunc[iCut] = new TH2F("ESD_Pi0inJetPt_FragmentationFunc", "ESD_Pi0inJetPt_FragmentationFunc", 50, arrLogBinning, 150, 0., 150.);
1526  fJetHistograms[iCut]->Add(fHistoJetFragmFunc[iCut]);
1527  fHistoJetFragmFuncZInvMass[iCut] = new TH2F("ESD_Pi0inJetPt_Fragm_Z_InvMass", "ESD_Pi0inJetPt_Fragm_Z_InvMass", 800, 0, 0.8, 50, arrLogBinning);
1528  fJetHistograms[iCut]->Add(fHistoJetFragmFuncZInvMass[iCut]);
1529  }
1530  }
1531 
1532 
1533  }
1534  if(fDoMesonAnalysis){
1535  InitBack(); // Init Background Handler
1536  }
1537 
1538  if(fIsMC>0){
1539  // MC Histogramms
1540  fMCList = new TList*[fnCuts];
1541  // True Histogramms
1542  fTrueList = new TList*[fnCuts];
1543  // Selected Header List
1544  fHeaderNameList = new TList*[fnCuts];
1545  fHistoMCHeaders = new TH1I*[fnCuts];
1546  fHistoMCAllGammaPt = new TH1F*[fnCuts];
1548  fHistoMCDecayGammaPi0Pt = new TH1F*[fnCuts];
1549  fHistoMCDecayGammaRhoPt = new TH1F*[fnCuts];
1550  fHistoMCDecayGammaEtaPt = new TH1F*[fnCuts];
1551  fHistoMCDecayGammaOmegaPt = new TH1F*[fnCuts];
1552  fHistoMCDecayGammaEtapPt = new TH1F*[fnCuts];
1553  fHistoMCDecayGammaPhiPt = new TH1F*[fnCuts];
1554  fHistoMCDecayGammaSigmaPt = new TH1F*[fnCuts];
1555  fHistoMCConvGammaPt = new TH1F*[fnCuts];
1557  fHistoTrueConvGammaPt = new TH1F*[fnCuts];
1560 
1562  if (fDoPhotonQA == 3){
1569  }
1570  fHistoTruePrimaryConvGammaPt = new TH1F*[fnCuts];
1577 
1580 
1581  if (fDoPhotonQA > 0 ){
1582  if (fIsMC < 2 ){
1583  fHistoMCConvGammaR = new TH1F*[fnCuts];
1584  fHistoMCConvGammaEta = new TH1F*[fnCuts];
1586  fHistoTrueConvGammaEta = new TH1F*[fnCuts];
1587  fHistoTrueConvGammaR = new TH1F*[fnCuts];
1588  fHistoTrueConvGammaRMC = new TH1F*[fnCuts];
1589  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
1590  fHistoTrueConvGammaInvMass = new TH1F*[fnCuts];
1592  }
1593  }
1594  fHistoTrueConvGammaPtMC = new TH1F*[fnCuts];
1595  }
1596 
1597  if(fDoMesonAnalysis){
1598  fHistoMCPi0Pt = new TH1F*[fnCuts];
1599  fHistoMCPi0WOWeightPt = new TH1F*[fnCuts];
1600  fHistoMCEtaPt = new TH1F*[fnCuts];
1601  fHistoMCEtaWOWeightPt = new TH1F*[fnCuts];
1602  fHistoMCPi0WOWeightInAccPt = new TH1F*[fnCuts];
1603  fHistoMCEtaWOWeightInAccPt = new TH1F*[fnCuts];
1604  fHistoMCPi0InAccPt = new TH1F*[fnCuts];
1605  fHistoMCEtaInAccPt = new TH1F*[fnCuts];
1606 
1607  if(fIsMC > 1){
1608  fHistoMCPi0WOEvtWeightPt = new TH1F*[fnCuts];
1609  fHistoMCEtaWOEvtWeightPt = new TH1F*[fnCuts];
1612  }
1613 
1616  fHistoMultipleCountTruePi0 = new TH1F*[fnCuts];
1618  fHistoMultipleCountTrueEta = new TH1F*[fnCuts];
1621  pESDTruePrimaryMotherWeightsInvMassPt = new TProfile2D*[fnCuts];
1628 
1632  fHistoMCSecPi0Source = new TH1F*[fnCuts];
1633  fHistoMCSecEtaPt = new TH1F*[fnCuts];
1634  fHistoMCSecEtaSource = new TH1F*[fnCuts];
1635 
1636  if (fDoMesonQA > 0){
1637  fHistoMCPi0PtAlpha = new TH2F*[fnCuts];
1638  fHistoMCEtaPtAlpha = new TH2F*[fnCuts];
1639  if (fIsMC == 2){
1640  fHistoMCPi0PtJetPt = new TH2F*[fnCuts];
1641  fHistoMCEtaPtJetPt = new TH2F*[fnCuts];
1642  }
1643 
1644  if (fIsMC < 2){
1646  fHistoMCPi0PtY = new TH2F*[fnCuts];
1647  fHistoMCEtaPtY = new TH2F*[fnCuts];
1656  fHistoTruePi0PtY = new TH2F*[fnCuts];
1657  fHistoTrueEtaPtY = new TH2F*[fnCuts];
1660  }
1663 
1664  }
1665  }
1666  if(fDoJetAnalysis && !fDoLightOutput) {
1674  fHistoTrueDoubleCountingJet = new TH1F*[fnCuts];
1677  fHistoMCPi0JetInAccPt = new TH1F*[fnCuts];
1678  fHistoMCPi0inJetInAccPt = new TH1F*[fnCuts];
1679  fHistoMCPi0JetEventGenerated = new TH1F*[fnCuts];
1680  fHistoMCPi0inJetGenerated = new TH1F*[fnCuts];
1689  fHistoMCEtaJetInAccPt = new TH1F*[fnCuts];
1690  fHistoMCEtainJetInAccPt = new TH1F*[fnCuts];
1691  fHistoMCEtaJetEventGenerated = new TH1F*[fnCuts];
1692  fHistoMCEtainJetGenerated = new TH1F*[fnCuts];
1693  }
1694  if(fDoJetQA){
1695  if(fDoLightOutput){
1698  }
1705  }
1706 
1707  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1708  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
1709  TString cutstringPhoton = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
1710  TString cutstringMeson = "NoMesonCut";
1711  if(fDoMesonAnalysis)
1712  cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
1713 
1714  fMCList[iCut] = new TList();
1715  fMCList[iCut]->SetName(Form("%s_%s_%s MC histograms",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
1716  fMCList[iCut]->SetOwner(kTRUE);
1717  fCutFolder[iCut]->Add(fMCList[iCut]);
1718  if (fIsMC < 2){
1719  fHistoMCHeaders[iCut] = new TH1I("MC_Headers", "MC_Headers", 20, 0, 20);
1720  fMCList[iCut]->Add(fHistoMCHeaders[iCut]);
1721  }
1722  fHistoMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt", "MC_AllGamma_Pt", nBinsPt, arrPtBinning);
1723  fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);
1724  fHistoMCAllSecondaryGammaPt[iCut] = new TH2F("MC_AllSecondaryGamma_Pt", "MC_AllSecondaryGamma_Pt", nBinsPt, arrPtBinning, 4, -0.5, 3.5);
1725  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1726  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1727  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1728  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1729  fMCList[iCut]->Add(fHistoMCAllSecondaryGammaPt[iCut]);
1730  fHistoMCDecayGammaPi0Pt[iCut] = new TH1F("MC_DecayGammaPi0_Pt", "MC_DecayGammaPi0_Pt", nBinsPt, arrPtBinning);
1731  fMCList[iCut]->Add(fHistoMCDecayGammaPi0Pt[iCut]);
1732  fHistoMCDecayGammaRhoPt[iCut] = new TH1F("MC_DecayGammaRho_Pt", "MC_DecayGammaRho_Pt", nBinsPt, arrPtBinning);
1733  fMCList[iCut]->Add(fHistoMCDecayGammaRhoPt[iCut]);
1734  fHistoMCDecayGammaEtaPt[iCut] = new TH1F("MC_DecayGammaEta_Pt", "MC_DecayGammaEta_Pt", nBinsPt, arrPtBinning);
1735  fMCList[iCut]->Add(fHistoMCDecayGammaEtaPt[iCut]);
1736  fHistoMCDecayGammaOmegaPt[iCut] = new TH1F("MC_DecayGammaOmega_Pt", "MC_DecayGammaOmmega_Pt", nBinsPt, arrPtBinning);
1737  fMCList[iCut]->Add(fHistoMCDecayGammaOmegaPt[iCut]);
1738  fHistoMCDecayGammaEtapPt[iCut] = new TH1F("MC_DecayGammaEtap_Pt", "MC_DecayGammaEtap_Pt", nBinsPt, arrPtBinning);
1739  fMCList[iCut]->Add(fHistoMCDecayGammaEtapPt[iCut]);
1740  fHistoMCDecayGammaPhiPt[iCut] = new TH1F("MC_DecayGammaPhi_Pt", "MC_DecayGammaPhi_Pt", nBinsPt, arrPtBinning);
1741  fMCList[iCut]->Add(fHistoMCDecayGammaPhiPt[iCut]);
1742  fHistoMCDecayGammaSigmaPt[iCut] = new TH1F("MC_DecayGammaSigma_Pt", "MC_DecayGammaSigma_Pt", nBinsPt, arrPtBinning);
1743  fMCList[iCut]->Add(fHistoMCDecayGammaSigmaPt[iCut]);
1744  fHistoMCConvGammaPt[iCut] = new TH1F("MC_ConvGamma_Pt", "MC_ConvGamma_Pt", nBinsPt, arrPtBinning);
1745  fMCList[iCut]->Add(fHistoMCConvGammaPt[iCut]);
1746  fHistoMCSecondaryConvGammaPt[iCut] = new TH2F("MC_SecondaryConvGamma_Pt", "MC_SecondaryConvGamma_Pt", nBinsPt, arrPtBinning, 4, -0.5, 3.5);
1747  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1748  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1749  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1750  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1751  fMCList[iCut]->Add(fHistoMCSecondaryConvGammaPt[iCut]);
1752 
1753  if (fIsMC > 1){
1754  fHistoMCAllGammaPt[iCut]->Sumw2();
1755  fHistoMCAllSecondaryGammaPt[iCut]->Sumw2();
1756  fHistoMCDecayGammaPi0Pt[iCut]->Sumw2();
1757  fHistoMCDecayGammaRhoPt[iCut]->Sumw2();
1758  fHistoMCDecayGammaEtaPt[iCut]->Sumw2();
1759  fHistoMCDecayGammaOmegaPt[iCut]->Sumw2();
1760  fHistoMCDecayGammaEtapPt[iCut]->Sumw2();
1761  fHistoMCDecayGammaPhiPt[iCut]->Sumw2();
1762  fHistoMCDecayGammaSigmaPt[iCut]->Sumw2();
1763  fHistoMCConvGammaPt[iCut]->Sumw2();
1764  fHistoMCSecondaryConvGammaPt[iCut]->Sumw2();
1765  }
1766 
1767  if (fDoPhotonQA > 0 && fIsMC < 2){
1768  fHistoMCConvGammaR[iCut] = new TH1F("MC_ConvGamma_R", "MC_ConvGamma_R", 800, 0, 200);
1769  fMCList[iCut]->Add(fHistoMCConvGammaR[iCut]);
1770  fHistoMCConvGammaEta[iCut] = new TH1F("MC_ConvGamma_Eta", "MC_ConvGamma_Eta", 1000, -2, 2);
1771  fMCList[iCut]->Add(fHistoMCConvGammaEta[iCut]);
1772  }
1773 
1774  if(fDoMesonAnalysis){
1775  fHistoMCPi0Pt[iCut] = new TH1F("MC_Pi0_Pt", "MC_Pi0_Pt", nBinsPt, arrPtBinning);
1776  fHistoMCPi0Pt[iCut]->Sumw2();
1777  fMCList[iCut]->Add(fHistoMCPi0Pt[iCut]);
1778  fHistoMCPi0WOWeightPt[iCut] = new TH1F("MC_Pi0_WOWeights_Pt", "MC_Pi0_WOWeights_Pt", nBinsPt, arrPtBinning);
1779  fHistoMCPi0WOWeightPt[iCut]->Sumw2();
1780  fMCList[iCut]->Add(fHistoMCPi0WOWeightPt[iCut]);
1781 
1782  fHistoMCEtaPt[iCut] = new TH1F("MC_Eta_Pt", "MC_Eta_Pt", nBinsPt, arrPtBinning);
1783  fHistoMCEtaPt[iCut]->Sumw2();
1784  fMCList[iCut]->Add(fHistoMCEtaPt[iCut]);
1785  fHistoMCEtaWOWeightPt[iCut] = new TH1F("MC_Eta_WOWeights_Pt", "MC_Eta_WOWeights_Pt", nBinsPt, arrPtBinning);
1786  fHistoMCEtaWOWeightPt[iCut]->Sumw2();
1787  fMCList[iCut]->Add(fHistoMCEtaWOWeightPt[iCut]);
1788 
1789  fHistoMCPi0WOWeightInAccPt[iCut] = new TH1F("MC_Pi0WOWeightInAcc_Pt", "MC_Pi0WOWeightInAcc_Pt", nBinsPt, arrPtBinning);
1790  fHistoMCPi0WOWeightInAccPt[iCut]->Sumw2();
1791  fMCList[iCut]->Add(fHistoMCPi0WOWeightInAccPt[iCut]);
1792  fHistoMCEtaWOWeightInAccPt[iCut] = new TH1F("MC_EtaWOWeightInAcc_Pt", "MC_EtaWOWeightInAcc_Pt", nBinsPt, arrPtBinning);
1793  fHistoMCEtaWOWeightInAccPt[iCut]->Sumw2();
1794  fMCList[iCut]->Add(fHistoMCEtaWOWeightInAccPt[iCut]);
1795  fHistoMCPi0InAccPt[iCut] = new TH1F("MC_Pi0InAcc_Pt", "MC_Pi0InAcc_Pt", nBinsPt, arrPtBinning);
1796  fHistoMCPi0InAccPt[iCut]->Sumw2();
1797  fMCList[iCut]->Add(fHistoMCPi0InAccPt[iCut]);
1798  fHistoMCEtaInAccPt[iCut] = new TH1F("MC_EtaInAcc_Pt", "MC_EtaInAcc_Pt", nBinsPt, arrPtBinning);
1799  fHistoMCEtaInAccPt[iCut]->Sumw2();
1800  fMCList[iCut]->Add(fHistoMCEtaInAccPt[iCut]);
1801 
1802  if (fIsMC > 1){
1803  fHistoMCPi0WOEvtWeightPt[iCut] = new TH1F("MC_Pi0_WOEventWeights_Pt", "MC_Pi0_WOEventWeights_Pt", nBinsPt, arrPtBinning);
1804  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightPt[iCut]);
1805  fHistoMCEtaWOEvtWeightPt[iCut] = new TH1F("MC_Eta_WOEventWeights_Pt", "MC_Eta_WOEventWeights_Pt", nBinsPt, arrPtBinning);
1806  fMCList[iCut]->Add(fHistoMCEtaWOEvtWeightPt[iCut]);
1807  fHistoMCPi0WOEvtWeightInAccPt[iCut] = new TH1F("MC_Pi0WOEvtWeightInAcc_Pt", "MC_Pi0WOEvtWeightInAcc_Pt", nBinsPt, arrPtBinning);
1808  fHistoMCPi0WOEvtWeightInAccPt[iCut]->Sumw2();
1809  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightInAccPt[iCut]);
1810  fHistoMCEtaWOEvtWeightInAccPt[iCut] = new TH1F("MC_EtaWOEvtWeightInAcc_Pt", "MC_EtaWOEvtWeightInAcc_Pt", nBinsPt, arrPtBinning);
1811  fHistoMCEtaWOEvtWeightInAccPt[iCut]->Sumw2();
1812  fMCList[iCut]->Add(fHistoMCEtaWOEvtWeightInAccPt[iCut]);
1813 
1814  if (fDoMesonQA > 0 && fIsMC == 2){
1815  fHistoMCPi0PtJetPt[iCut] = new TH2F("MC_Pi0_Pt_JetPt", "MC_Pi0_Pt_JetPt", nBinsPt, arrPtBinning, 200, 0, 200);
1816  fHistoMCPi0PtJetPt[iCut]->Sumw2();
1817  fMCList[iCut]->Add(fHistoMCPi0PtJetPt[iCut]);
1818  fHistoMCEtaPtJetPt[iCut] = new TH2F("MC_Eta_Pt_JetPt", "MC_Eta_Pt_JetPt", nBinsPt, arrPtBinning, 200, 0, 200);
1819  fHistoMCEtaPtJetPt[iCut]->Sumw2();
1820  fMCList[iCut]->Add(fHistoMCEtaPtJetPt[iCut]);
1821  }
1822  }
1823 
1824  fHistoMCPrimaryPtvsSource[iCut] = new TH2F("MC_Primary_Pt_Source", "MC_Primary_Pt_Source", nBinsPt, arrPtBinning, 10, -0.5, 9.5);
1825  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(1,"Pi+");
1826  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(2,"Pi-");
1827  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(3,"K+");
1828  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(4,"K-");
1829  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(5,"K0s");
1830  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(6,"K0l");
1831  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(7,"Lambda");
1832  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(8,"Omega");
1833  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(9,"Phi");
1834  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(10,"Rho0");
1835  fMCList[iCut]->Add(fHistoMCPrimaryPtvsSource[iCut]);
1836  fHistoMCSecPi0Source[iCut] = new TH1F("MC_SecPi0_Source", "MC_SecPi0_Source", 5000, 0., 5000);
1837  fMCList[iCut]->Add(fHistoMCSecPi0Source[iCut]);
1838  fHistoMCSecEtaSource[iCut] = new TH1F("MC_SecEta_Source", "MC_SecEta_Source", 5000, 0, 5000);
1839  fMCList[iCut]->Add(fHistoMCSecEtaSource[iCut]);
1840  fHistoMCSecPi0PtvsSource[iCut] = new TH2F("MC_SecPi0_Pt_Source", "MC_SecPi0_Pt_Source", nBinsPt, arrPtBinning, 16, -0.5, 15.5);
1841  fMCList[iCut]->Add(fHistoMCSecPi0PtvsSource[iCut]);
1842  fHistoMCSecPi0InAccPtvsSource[iCut] = new TH2F("MC_SecPi0InAcc_Pt_Source", "MC_SecPi0InAcc_Pt_Source", nBinsPt, arrPtBinning, 16, -0.5, 15.5);
1843  fMCList[iCut]->Add(fHistoMCSecPi0InAccPtvsSource[iCut]);
1844  fHistoMCSecEtaPt[iCut] = new TH1F("MC_SecEta_Pt", "MC_SecEta_Pt", nBinsPt, arrPtBinning);
1845  fMCList[iCut]->Add(fHistoMCSecEtaPt[iCut]);
1846 
1847  if (fIsMC > 1){
1848  fHistoMCPrimaryPtvsSource[iCut]->Sumw2();
1849  fHistoMCSecPi0PtvsSource[iCut]->Sumw2();
1850  fHistoMCSecPi0InAccPtvsSource[iCut]->Sumw2();
1851  fHistoMCSecEtaPt[iCut]->Sumw2();
1852  }
1853 
1854  if (fDoMesonQA > 0){
1855  fHistoMCPi0PtAlpha[iCut] = new TH2F("MC_Pi0_Pt_Alpha", "MC_Pi0_Pt_Alpha", nBinsQAPt, arrQAPtBinning, 100, 0, 1);
1856  fMCList[iCut]->Add(fHistoMCPi0PtAlpha[iCut]);
1857  fHistoMCEtaPtAlpha[iCut] = new TH2F("MC_Eta_Pt_Alpha", "MC_Eta_Pt_Alpha", nBinsQAPt, arrQAPtBinning, 100, 0, 1);
1858  fMCList[iCut]->Add(fHistoMCEtaPtAlpha[iCut]);
1859 
1860  if (fIsMC < 2){
1861  fHistoMCPi0PtY[iCut] = new TH2F("MC_Pi0_Pt_Y", "MC_Pi0_Pt_Y", nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
1862  fHistoMCPi0PtY[iCut]->Sumw2();
1863  fMCList[iCut]->Add(fHistoMCPi0PtY[iCut]);
1864  fHistoMCEtaPtY[iCut] = new TH2F("MC_Eta_Pt_Y", "MC_Eta_Pt_Y", nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
1865  fHistoMCEtaPtY[iCut]->Sumw2();
1866  fMCList[iCut]->Add(fHistoMCEtaPtY[iCut]);
1867  fHistoMCSecPi0RvsSource[iCut] = new TH2F("MC_SecPi0_R3D_Source", "MC_SecPi0_R3D_Source", 500, 0.0, 20., 16, -0.5, 15.5);
1868  fHistoMCSecPi0RvsSource[iCut]->Sumw2();
1869  fMCList[iCut]->Add(fHistoMCSecPi0RvsSource[iCut]);
1870  }
1871  }
1872 
1873  }
1874 
1875  fTrueList[iCut] = new TList();
1876  fTrueList[iCut]->SetName(Form("%s_%s_%s True histograms",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
1877  fTrueList[iCut]->SetOwner(kTRUE);
1878  fCutFolder[iCut]->Add(fTrueList[iCut]);
1879 
1880  fHistoTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt", "ESD_TrueConvGamma_Pt", nBinsPt, arrPtBinning);
1881  fTrueList[iCut]->Add(fHistoTrueConvGammaPt[iCut]);
1882 
1883  fHistoDoubleCountTrueConvGammaRPt[iCut] = new TH2F("ESD_TrueDoubleCountConvGamma_R_Pt", "ESD_TrueDoubleCountConvGamma_R_Pt", 800, 0, 200, nBinsQAPt, arrQAPtBinning);
1884  fTrueList[iCut]->Add(fHistoDoubleCountTrueConvGammaRPt[iCut]);
1885  fHistoMultipleCountTrueConvGamma[iCut] = new TH1F("ESD_TrueMultipleCountConvGamma", "ESD_TrueMultipleCountConvGamma", 10, 1, 11);
1886  fTrueList[iCut]->Add(fHistoMultipleCountTrueConvGamma[iCut]);
1887 
1888  if(fEnableBDT){
1889  fHistoBDToutputMCTrue[iCut] = new TH1F("BDT_output_MCTrue", "BDT_output_MCTrue", 200, -1, 1);
1890  fTrueList[iCut]->Add(fHistoBDToutputMCTrue[iCut]);
1891  }
1892 
1893  fHistoCombinatorialPt[iCut] = new TH2F("ESD_TrueCombinatorial_Pt", "ESD_TrueCombinatorial_Pt", nBinsPt, arrPtBinning, 16, -0.5, 15.5);
1894  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 1,"Elec+Elec");
1895  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 2,"Elec+Pion");
1896  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 3,"Elec+Kaon");
1897  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 4,"Elec+Proton");
1898  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 5,"Elec+Muon");
1899  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 6,"Pion+Pion");
1900  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 7,"Pion+Kaon");
1901  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 8,"Pion+Proton");
1902  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 9,"Pion+Muon");
1903  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(10,"Kaon+Kaon");
1904  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(11,"Kaon+Proton");
1905  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(12,"Kaon+Muon");
1906  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(13,"Proton+Proton");
1907  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(14,"Proton+Muon");
1908  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(15,"Muon+Muon");
1909  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(16,"Rest");
1910  fTrueList[iCut]->Add(fHistoCombinatorialPt[iCut]);
1911 
1912  fHistoTruePrimaryConvGammaPt[iCut] = new TH1F("ESD_TruePrimaryConvGamma_Pt", "ESD_TruePrimaryConvGamma_Pt", nBinsPt, arrPtBinning);
1913  fTrueList[iCut]->Add(fHistoTruePrimaryConvGammaPt[iCut]);
1914  fHistoTrueSecondaryConvGammaPt[iCut] = new TH2F("ESD_TrueSecondaryConvGamma_Pt", "ESD_TrueSecondaryConvGamma_Pt", nBinsPt, arrPtBinning, 4, -0.5, 3.5);
1915  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1916  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1917  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1918  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1919  fTrueList[iCut]->Add(fHistoTrueSecondaryConvGammaPt[iCut]);
1920  fHistoTrueSecondaryConvGammaMCPt[iCut] = new TH2F("ESD_TrueSecondaryConvGamma_MCPt", "ESD_TrueSecondaryConvGamma_MCPt", nBinsPt, arrPtBinning, 4, -0.5, 3.5);
1921  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1922  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1923  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1924  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1925  fTrueList[iCut]->Add(fHistoTrueSecondaryConvGammaMCPt[iCut]);
1926 
1927  if(fDoPhotonQA == 3 && fIsMC < 2){
1928  if(fIsHeavyIon == 1){
1929  fHistoCombinatorialMothersPt[iCut] = new TH3F("ESD_TrueCombinatorialMothers_Pt", "ESD_TrueCombinatorialMothers_Pt", 6, 0, 6, 13, 0, 13, 250, 0., 25);
1930  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 1,"Elec");
1931  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 2,"Pion");
1932  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 3,"Kaon");
1933  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 4,"Proton");
1934  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 5,"Rest");
1935  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 6,"Ancestor NP");
1936  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 1,"Elec");
1937  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 2,"Pion");
1938  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 3,"Kaon");
1939  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 4,"Proton");
1940  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 5,"Pi0");
1941  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 6,"#eta");
1942  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 7,"#omega");
1943  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 8,"#phi");
1944  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 9,"#eta'");
1945  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel(10,"K0s");
1946  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel(11,"#Lambda");
1947  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel(12,"#rho^{0}, #rho^{#pm}");
1948  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel(13,"Other");
1949  fTrueList[iCut]->Add(fHistoCombinatorialMothersPt[iCut]);
1950  }
1951 
1952  fHistoCombinatorialPtDeltaPhi_ek[iCut] = new TH2F("ESD_TrueCombinatorial_Pt_DeltaPhi_ek", "ESD_TrueCombinatorial_Pt_DeltaPhi_ek", nBinsQAPt, arrQAPtBinning, 90, -0.5*TMath::Pi(), 0.5*TMath::Pi());
1953  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_ek[iCut]);
1954  fHistoCombinatorialPtDeltaPhi_ep[iCut] = new TH2F("ESD_TrueCombinatorial_Pt_DeltaPhi_ep", "ESD_TrueCombinatorial_Pt_DeltaPhi_ep", nBinsQAPt, arrQAPtBinning, 90, -0.5*TMath::Pi(), 0.5*TMath::Pi());
1955  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_ep[iCut]);
1956  fHistoCombinatorialPtDeltaPhi_epi[iCut] = new TH2F("ESD_TrueCombinatorial_Pt_DeltaPhi_epi", "ESD_TrueCombinatorial_Pt_DeltaPhi_epi", nBinsQAPt, arrQAPtBinning, 90, -0.5*TMath::Pi(), 0.5*TMath::Pi());
1957  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_epi[iCut]);
1958  fHistoCombinatorialPtDeltaPhi_pik[iCut] = new TH2F("ESD_TrueCombinatorial_Pt_DeltaPhi_pik", "ESD_TrueCombinatorial_Pt_DeltaPhi_pik", nBinsQAPt, arrQAPtBinning, 90, -0.5*TMath::Pi(), 0.5*TMath::Pi());
1959  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_pik[iCut]);
1960  fHistoCombinatorialPtDeltaPhi_pip[iCut] = new TH2F("ESD_TrueCombinatorial_Pt_DeltaPhi_pip", "ESD_TrueCombinatorial_Pt_DeltaPhi_pip", nBinsQAPt, arrQAPtBinning, 90, -0.5*TMath::Pi(), 0.5*TMath::Pi());
1961  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_pip[iCut]);
1962  }
1963 
1964  fHistoTrueDalitzPsiPairDeltaPhi[iCut] = new TH2F("ESD_TrueDalitzPsiPairDeltaPhi", "ESD_TrueDalitzPsiPairDeltaPhi", 100, -0.5, 2, 100, -0.5, 0.5);
1965  fTrueList[iCut]->Add(fHistoTrueDalitzPsiPairDeltaPhi[iCut]);
1966  fHistoTrueGammaPsiPairDeltaPhi[iCut] = new TH2F("ESD_TrueGammaPsiPairDeltaPhi", "ESD_TrueGammaPsiPairDeltaPhi", 100, -0.5, 2, 100, -0.5, 0.5);
1967  fTrueList[iCut]->Add(fHistoTrueGammaPsiPairDeltaPhi[iCut]);
1968 
1969  fHistoTruePrimaryConvGammaESDPtMCPt[iCut] = new TH2F("ESD_TruePrimaryConvGammaESD_PtMCPt", "ESD_TruePrimaryConvGammaESD_PtMCPt",
1970  nBinsPt, arrPtBinning, nBinsPt, arrPtBinning);
1972 
1973 
1974  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromK0sESD_MCPtPt", "ESD_TrueSecondaryConvGammaFromXFromK0sESD_MCPtPt",
1975  nBinsPt, arrPtBinning, nBinsPt, arrPtBinning);
1977  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromK0lESD_MCPtPt", "ESD_TrueSecondaryConvGammaFromXFromK0lESD_MCPtPt",
1978  nBinsPt, arrPtBinning, nBinsPt, arrPtBinning);
1980  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromLambdaESD_MCPtPt", "ESD_TrueSecondaryConvGammaFromXFromLambdaESD_MCPtPt",
1981  nBinsPt, arrPtBinning, nBinsPt, arrPtBinning);
1983 
1984 
1986  fHistoTrueConvGammaPt[iCut]->Sumw2();
1987  fHistoDoubleCountTrueConvGammaRPt[iCut]->Sumw2();
1988  fHistoMultipleCountTrueConvGamma[iCut]->Sumw2();
1989  fHistoCombinatorialPt[iCut]->Sumw2();
1990  fHistoTruePrimaryConvGammaPt[iCut]->Sumw2();
1991  fHistoTrueSecondaryConvGammaPt[iCut]->Sumw2();
1992  fHistoTrueSecondaryConvGammaMCPt[iCut]->Sumw2();
1993  fHistoTruePrimaryConvGammaESDPtMCPt[iCut]->Sumw2();
1997  fHistoTrueDalitzPsiPairDeltaPhi[iCut]->Sumw2();
1998  fHistoTrueGammaPsiPairDeltaPhi[iCut]->Sumw2();
1999  }
2000 
2002  fTrueJetHistograms[iCut] = new TList();
2003  fTrueJetHistograms[iCut]->SetName(Form("%s_%s_%s True Jet histograms", cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
2004  fTrueJetHistograms[iCut]->SetOwner(kTRUE);
2005  fCutFolder[iCut]->Add(fTrueJetHistograms[iCut]);
2006  fHistoTruevsRecJetPt[iCut] = new TH2F("True_JetPt_vs_Rec_JetPt", "True_JetPt_vs_Rec_JetPt", 150, 0, 150, 150, 0, 150);
2007  fTrueJetHistograms[iCut]->Add(fHistoTruevsRecJetPt[iCut]);
2008  fHistoTrueJetMotherInvMassPt[iCut] = new TH2F("ESD_True_Jet_InvMass_Pt", "ESD_True_Jet_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2010  fHistoTruePrimaryJetInvMassPt[iCut] = new TH2F("ESD_TruePrimaryJet_InvMass_Pt", "ESD_TruePrimaryJet_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2012  fHistoTrueInJetMotherInvMassPt[iCut] = new TH2F("ESD_True_inJet_InvMass_Pt", "ESD_True_inJet_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2014  fHistoTruePrimaryinJetInvMassPt[iCut] = new TH2F("ESD_TruePrimaryinJet_InvMass_Pt", "ESD_TruePrimaryinJet_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2016  fHistoTrueDoubleCountingJet[iCut] = new TH1F("Double_Counting_True_inJet", "Double_Counting_True_inJet", 6, 0, 6);
2018  fHistoTrueJetFragmFunc[iCut] = new TH2F("ESD_TrueinJetPt_FragmentationFunc", "ESD_TrueinJetPt_FragmentationFunc", 50, arrLogBinning, 150, 0., 150.);
2019  fTrueJetHistograms[iCut]->Add(fHistoTrueJetFragmFunc[iCut]);
2020  fHistoTrueJetFragmFuncZInvMass[iCut] = new TH2F("ESD_TrueinJetPt_Fragm_Z_InvMass", "ESD_TrueinJetPt_Fragm_Z_InvMass", 800, 0, 0.8, 50, arrLogBinning);
2022  fHistoMCPi0JetInAccPt[iCut] = new TH1F("MC_Pi0JetInAcc_Pt", "MC_Pi0JetInAcc_Pt", nBinsPt, arrPtBinning);
2023  fTrueJetHistograms[iCut]->Add(fHistoMCPi0JetInAccPt[iCut]);
2024  fHistoMCPi0inJetInAccPt[iCut] = new TH1F("MC_Pi0inJetInAcc_Pt", "MC_Pi0inJetInAcc_Pt", nBinsPt, arrPtBinning);
2025  fTrueJetHistograms[iCut]->Add(fHistoMCPi0inJetInAccPt[iCut]);
2026  fHistoMCPi0JetEventGenerated[iCut] = new TH1F("MC_Pi0_JetEvent_Generated", "MC_Pi0_JetEvent_Generated", nBinsPt, arrPtBinning);
2028  fHistoMCPi0inJetGenerated[iCut] = new TH1F("MC_Pi0_inJet_Generated", "MC_Pi0_inJet_Generated", nBinsPt, arrPtBinning);
2030  fHistoTrueSecondaryFromK0sJetInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryFromK0sJet_InvMass_Pt", "ESD_TrueSecondaryFromK0sJet_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2032  fHistoTrueSecondaryFromK0sinJetInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryFromK0s_inJet_InvMass_Pt", "ESD_TrueSecondaryFromK0s_inJet_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2034  fHistoTrueSecondaryFromLambdaJetInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryFromLambdaJet_InvMass_Pt", "ESD_TrueSecondaryFromLambdaJet_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2036  fHistoTrueSecondaryFromLambdainJetInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryFromLambda_inJet_InvMass_Pt", "ESD_TrueSecondaryFromLambda_inJet_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2038  fHistoTrueSecondaryFromK0lJetInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryFromK0lJet_InvMass_Pt", "ESD_TrueSecondaryFromK0lJet_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2040  fHistoTrueSecondaryFromK0linJetInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryFromK0l_inJet_InvMass_Pt", "ESD_TrueSecondaryFromK0l_inJet_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2042  fHistoTrueSecondaryInvJetMassPt[iCut] = new TH2F("ESD_TrueSecondaryJet_InvMass_Pt", "ESD_TrueSecondaryJet_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2044  fHistoTrueSecondaryInvinJetMassPt[iCut] = new TH2F("ESD_TrueSecondary_inJet_InvMass_Pt", "ESD_TrueSecondary_inJet_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2046  fHistoMCEtaJetInAccPt[iCut] = new TH1F("MC_EtaJetInAcc_Pt", "MC_EtaJetInAcc_Pt", nBinsPt, arrPtBinning);
2047  fTrueJetHistograms[iCut]->Add(fHistoMCEtaJetInAccPt[iCut]);
2048  fHistoMCEtainJetInAccPt[iCut] = new TH1F("MC_EtainJetInAcc_Pt", "MC_EtainJetInAcc_Pt", nBinsPt, arrPtBinning);
2049  fTrueJetHistograms[iCut]->Add(fHistoMCEtainJetInAccPt[iCut]);
2050  fHistoMCEtaJetEventGenerated[iCut] = new TH1F("MC_Eta_JetEvent_Generated", "MC_Eta_JetEvent_Generated", nBinsPt, arrPtBinning);
2052  fHistoMCEtainJetGenerated[iCut] = new TH1F("MC_Eta_inJet_Generated", "MC_Eta_inJet_Generated", nBinsPt, arrPtBinning);
2054  }
2055  if(fDoJetQA){
2056  if(fDoLightOutput){
2057  fTrueJetHistograms[iCut] = new TList();
2058  fTrueJetHistograms[iCut]->SetName(Form("%s_%s_%s True Jet histograms", cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
2059  fTrueJetHistograms[iCut]->SetOwner(kTRUE);
2060  fCutFolder[iCut]->Add(fTrueJetHistograms[iCut]);
2061 
2062  fHistoTruevsRecJetPt[iCut] = new TH2F("True_JetPt_vs_Rec_JetPt", "True_JetPt_vs_Rec_JetPt", 150, 0, 150, 150, 0, 150);
2063  fTrueJetHistograms[iCut]->Add(fHistoTruevsRecJetPt[iCut]);
2064  }
2065  fHistoUnfoldingAsData[iCut] = new TH2F("Unfolding_AsData", "Unfolding_AsData", 800, 0, 0.8, nBinsPt, arrPtBinning);
2066  fTrueJetHistograms[iCut]->Add(fHistoUnfoldingAsData[iCut]);
2067  fHistoUnfoldingMissed[iCut] = new TH2F("Unfolding_Missed", "Unfolding_Missed", 800, 0, 0.8, nBinsPt, arrPtBinning);
2068  fTrueJetHistograms[iCut]->Add(fHistoUnfoldingMissed[iCut]);
2069  fHistoUnfoldingReject[iCut] = new TH2F("Unfolding_Reject", "Unfolding_Reject", 800, 0, 0.8, nBinsPt, arrPtBinning);
2070  fTrueJetHistograms[iCut]->Add(fHistoUnfoldingReject[iCut]);
2071  fHistoUnfoldingAsDataInvMassZ[iCut] = new TH2F("Unfolding_AsData_InvMass_Z", "Unfolding_AsData_InvMass_Z", 800, 0, 0.8, 50, arrLogBinning);
2073  fHistoUnfoldingMissedInvMassZ[iCut] = new TH2F("Unfolding_Missed_InvMass_Z", "Unfolding_Missed_InvMass_Z", 800, 0, 0.8, 50, arrLogBinning);
2075  fHistoUnfoldingRejectInvMassZ[iCut] = new TH2F("Unfolding_Reject_InvMass_Z", "Unfolding_Reject_InvMass_Z", 800, 0, 0.8, 50, arrLogBinning);
2077  }
2078 
2079  if (fDoPhotonQA > 0 ){
2080  if (fIsMC < 2){
2081  fHistoTrueConvGammaPsiPairPt[iCut] = new TH2F("ESD_TrueConvGamma_PsiPair_Pt", "ESD_TrueConvGamma_PsiPair_Pt", 500, 0, 5, nBinsPt, arrPtBinning);
2082  fTrueList[iCut]->Add(fHistoTrueConvGammaPsiPairPt[iCut]);
2083  fHistoTrueConvGammaEta[iCut] = new TH1F("ESD_TrueConvGamma_Eta", "ESD_TrueConvGamma_Eta", 1000, -2, 2);
2084  fTrueList[iCut]->Add(fHistoTrueConvGammaEta[iCut]);
2085  fHistoTrueConvGammaR[iCut] = new TH1F("ESD_TrueConvGamma_R", "ESD_TrueConvGamma_R", 800, 0, 200);
2086  fTrueList[iCut]->Add(fHistoTrueConvGammaR[iCut]);
2087  fHistoTrueConvGammaRMC[iCut] = new TH1F("ESD_TrueConvGamma_RMC", "ESD_TrueConvGamma_RMC", 800, 0, 200);
2088  fTrueList[iCut]->Add(fHistoTrueConvGammaRMC[iCut]);
2089  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
2090  fHistoTrueConvGammaInvMass[iCut] = new TH1F("ESD_TrueConvGamma_InvMass", "ESD_TrueConvGamma_InvMass", 500, 0., 5.);
2091  fTrueList[iCut]->Add(fHistoTrueConvGammaInvMass[iCut]);
2092  fHistoTrueConvGammaInvMassReco[iCut] = new TH1F("ESD_TrueConvGamma_InvMassReco", "ESD_TrueConvGamma_InvMassReco", 500, 0., 5.);
2093  fTrueList[iCut]->Add(fHistoTrueConvGammaInvMassReco[iCut]);
2094  }
2095  }
2096  fHistoTrueConvGammaPtMC[iCut] = new TH1F("ESD_TrueConvGamma_PtMC", "ESD_TrueConvGamma_PtMC", nBinsPt, arrPtBinning);
2097  fTrueList[iCut]->Add(fHistoTrueConvGammaPtMC[iCut]);
2099  fHistoTrueConvGammaPtMC[iCut]->Sumw2();
2100 
2101  }
2102 
2103  if(fDoMesonAnalysis){
2104  fHistoTrueMotherInvMassPt[iCut] = new TH2F("ESD_TrueMother_InvMass_Pt", "ESD_TrueMother_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2105  fTrueList[iCut]->Add(fHistoTrueMotherInvMassPt[iCut]);
2106  fHistoDoubleCountTruePi0InvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountPi0_InvMass_Pt", "ESD_TrueDoubleCountPi0_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2107  fTrueList[iCut]->Add(fHistoDoubleCountTruePi0InvMassPt[iCut]);
2108  fHistoMultipleCountTruePi0[iCut] = new TH1F("ESD_TrueMultipleCountPi0", "ESD_TrueMultipleCountPi0", 10, 1, 11);
2109  fTrueList[iCut]->Add(fHistoMultipleCountTruePi0[iCut]);
2110  fHistoDoubleCountTrueEtaInvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountEta_InvMass_Pt", "ESD_TrueDoubleCountEta_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2111  fTrueList[iCut]->Add(fHistoDoubleCountTrueEtaInvMassPt[iCut]);
2112  fHistoMultipleCountTrueEta[iCut] = new TH1F("ESD_TrueMultipleCountEta", "ESD_TrueMultipleCountEta", 10, 1, 11);
2113  fTrueList[iCut]->Add(fHistoMultipleCountTrueEta[iCut]);
2114  fHistoTruePrimaryMotherInvMassPt[iCut] = new TH2F("ESD_TruePrimaryMother_InvMass_Pt", "ESD_TruePrimaryMother_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2115  fHistoTruePrimaryMotherInvMassPt[iCut]->Sumw2();
2116  fTrueList[iCut]->Add(fHistoTruePrimaryMotherInvMassPt[iCut]);
2117  fHistoTruePrimaryMotherW0WeightingInvMassPt[iCut] = new TH2F("ESD_TruePrimaryMotherW0Weights_InvMass_Pt", "ESD_TruePrimaryMotherW0Weights_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2120  pESDTruePrimaryMotherWeightsInvMassPt[iCut] = new TProfile2D("ESD_TruePrimaryMotherWeights_InvMass_Pt", "ESD_TruePrimaryMotherWeights_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2123  fHistoTrueSecondaryMotherInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMother_InvMass_Pt", "ESD_TrueSecondaryMother_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2124  fHistoTrueSecondaryMotherInvMassPt[iCut]->Sumw2();
2126  fHistoTrueSecondaryMotherFromK0sInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromK0s_InvMass_Pt", "ESD_TrueSecondaryMotherFromK0s_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2129  fHistoTrueSecondaryMotherFromK0lInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromK0l_InvMass_Pt", "ESD_TrueSecondaryMotherFromK0l_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2132  fHistoTrueSecondaryMotherFromEtaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromEta_InvMass_Pt", "ESD_TrueSecondaryMotherFromEta_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2135  fHistoTrueSecondaryMotherFromLambdaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromLambda_InvMass_Pt", "ESD_TrueSecondaryMotherFromLambda_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2138 
2139  if(fIsMC < 2){
2140  fHistoTrueMotherDalitzInvMassPt[iCut] = new TH2F("ESD_TrueDalitz_InvMass_Pt", "ESD_TrueDalitz_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2141  fTrueList[iCut]->Add(fHistoTrueMotherDalitzInvMassPt[iCut]);
2142  }
2143 
2144  if (fIsMC > 1){
2145  fHistoTrueMotherInvMassPt[iCut]->Sumw2();
2146  fHistoDoubleCountTruePi0InvMassPt[iCut]->Sumw2();
2147  fHistoMultipleCountTruePi0[iCut]->Sumw2();
2148 
2149  fHistoDoubleCountTrueEtaInvMassPt[iCut]->Sumw2();
2150  fHistoMultipleCountTrueEta[iCut]->Sumw2();
2151  }
2152 
2153  if (fDoMesonQA > 0){
2154  if (fIsMC < 2){
2155  fHistoTruePrimaryPi0MCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryPi0_MCPt_ResolPt", "ESD_TruePrimaryPi0_ResolPt_MCPt", nBinsPt, arrPtBinning, 1000, -1., 1.);
2156  fHistoTruePrimaryPi0MCPtResolPt[iCut]->Sumw2();
2157  fTrueList[iCut]->Add(fHistoTruePrimaryPi0MCPtResolPt[iCut]);
2158  fHistoTruePrimaryEtaMCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryEta_MCPt_ResolPt", "ESD_TruePrimaryEta_ResolPt_MCPt", nBinsPt, arrPtBinning, 1000, -1., 1.);
2159  fHistoTruePrimaryEtaMCPtResolPt[iCut]->Sumw2();
2160  fTrueList[iCut]->Add(fHistoTruePrimaryEtaMCPtResolPt[iCut]);
2161  fHistoTrueBckGGInvMassPt[iCut] = new TH2F("ESD_TrueBckGG_InvMass_Pt", "ESD_TrueBckGG_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2162  fTrueList[iCut]->Add(fHistoTrueBckGGInvMassPt[iCut]);
2163  fHistoTrueBckContInvMassPt[iCut] = new TH2F("ESD_TrueBckCont_InvMass_Pt", "ESD_TrueBckCont_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
2164  fTrueList[iCut]->Add(fHistoTrueBckContInvMassPt[iCut]);
2165  fHistoTrueK0sWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueK0sWithPi0Daughter_MCPt", "ESD_TrueK0sWithPi0Daughter_MCPt", nBinsPt, arrPtBinning);
2166  fTrueList[iCut]->Add(fHistoTrueK0sWithPi0DaughterMCPt[iCut]);
2167  fHistoTrueK0lWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueK0lWithPi0Daughter_MCPt", "ESD_TrueK0lWithPi0Daughter_MCPt", nBinsPt, arrPtBinning);
2168  fTrueList[iCut]->Add(fHistoTrueK0lWithPi0DaughterMCPt[iCut]);
2169  fHistoTrueEtaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueEtaWithPi0Daughter_MCPt", "ESD_TrueEtaWithPi0Daughter_MCPt", nBinsPt, arrPtBinning);
2170  fTrueList[iCut]->Add(fHistoTrueEtaWithPi0DaughterMCPt[iCut]);
2171  fHistoTrueLambdaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueLambdaWithPi0Daughter_MCPt", "ESD_TrueLambdaWithPi0Daughter_MCPt", nBinsPt, arrPtBinning);
2173 
2174  fHistoTruePi0PtY[iCut] = new TH2F("ESD_TruePi0_Pt_Y", "ESD_TruePi0_Pt_Y", nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
2175  fTrueList[iCut]->Add(fHistoTruePi0PtY[iCut]);
2176  fHistoTrueEtaPtY[iCut] = new TH2F("ESD_TrueEta_Pt_Y", "ESD_TrueEta_Pt_Y", nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
2177  fTrueList[iCut]->Add(fHistoTrueEtaPtY[iCut]);
2178  fHistoTruePi0PtOpenAngle[iCut] = new TH2F("ESD_TruePi0_Pt_OpenAngle", "ESD_TruePi0_Pt_OpenAngle", nBinsQAPt, arrQAPtBinning, 200, 0, 2*TMath::Pi());
2179  fTrueList[iCut]->Add(fHistoTruePi0PtOpenAngle[iCut]);
2180  fHistoTrueEtaPtOpenAngle[iCut] = new TH2F("ESD_TrueEta_Pt_OpenAngle", "ESD_TrueEta_Pt_OpenAngle", nBinsQAPt, arrQAPtBinning, 200, 0, 2*TMath::Pi());
2181  fTrueList[iCut]->Add(fHistoTrueEtaPtOpenAngle[iCut]);
2182  }
2183 
2184  fHistoTruePi0PtAlpha[iCut] = new TH2F("ESD_TruePi0_Pt_Alpha", "ESD_TruePi0_Pt_Alpha", nBinsQAPt, arrQAPtBinning, 100, 0, 1);
2185  fTrueList[iCut]->Add(fHistoTruePi0PtAlpha[iCut]);
2186  fHistoTrueEtaPtAlpha[iCut] = new TH2F("ESD_TrueEta_Pt_Alpha", "ESD_TrueEta_Pt_Alpha", nBinsQAPt, arrQAPtBinning, 100, 0, 1);
2187  fTrueList[iCut]->Add(fHistoTrueEtaPtAlpha[iCut]);
2188 
2189  }
2190  }
2191  }
2192  }
2193 
2194  vecDoubleCountTruePi0s.clear();
2195  vecDoubleCountTrueEtas.clear();
2197 
2198  mapMultipleCountTruePi0s.clear();
2199  mapMultipleCountTrueEtas.clear();
2201 
2202  if(fV0Reader)
2203  if((AliConvEventCuts*)fV0Reader->GetEventCuts())
2204  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms())
2205  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
2206 
2207  if(fV0Reader)
2208  if((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())
2209  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
2210  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
2211 
2212  if(fV0Reader && fV0Reader->GetProduceV0FindingEfficiency())
2213  if (fV0Reader->GetV0FindingEfficiencyHistograms())
2214  fOutputContainer->Add(fV0Reader->GetV0FindingEfficiencyHistograms());
2215 
2216  if(fV0Reader && fV0Reader->GetProduceImpactParamHistograms())fOutputContainer->Add(fV0Reader->GetImpactParamHistograms());
2217 
2218  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
2219  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))) continue;
2220  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms()){
2221  fCutFolder[iCut]->Add(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
2222  }
2223  if(!((AliConversionPhotonCuts*)fCutArray->At(iCut))) continue;
2224  if(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms()){
2225  fCutFolder[iCut]->Add(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms());
2226  }
2227  if(fDoMesonAnalysis){
2228  if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
2229  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
2230  fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
2231  }
2232  }
2233  if(fDoJetAnalysis){
2234  fCutFolder[iCut]->Add(fJetHistograms[iCut]);
2235  }
2237  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
2238  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms()){
2239  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms());
2240  }
2241  }
2242 
2243  }
2244  if (fIsMC > 0){
2245  tBrokenFiles = new TTree("BrokenFiles", "BrokenFiles");
2246  tBrokenFiles->Branch("fileName",&fFileNameBroken);
2248  }
2249  OpenFile(1);
2250  PostData(1, fOutputContainer);
2251  Int_t nContainerOutput = 2;
2252  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
2253  if((fDoPhotonQA == 2)||(fDoPhotonQA == 5)){
2254  OpenFile(nContainerOutput);
2255  PostData(nContainerOutput, tESDConvGammaPtDcazCat[iCut]);
2256  nContainerOutput++;
2257  }
2258  if(fDoMesonQA == 2){
2259  OpenFile(nContainerOutput);
2260  PostData(nContainerOutput, tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]);
2261  nContainerOutput++;
2262  }
2263  }
2264 
2265 }
2266 //_____________________________________________________________________________
2268 {
2269  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
2270  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
2271  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
2272  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
2273  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
2274  }
2275 
2276  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift()){
2277  fHistoEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
2278  continue; // No Eta Shift requested, continue
2279  }
2280  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
2281  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
2282  fHistoEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
2283  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
2284  continue;
2285  }
2286  else{
2287  printf(" Gamma Conversion Task %s :: Eta Shift Manually Set to %f \n\n",
2288  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
2289  fHistoEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
2290  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
2291  }
2292  }
2293  return kTRUE;
2294 }
2295 //_____________________________________________________________________________
2297 {
2298  //
2299  // Called for each event
2300  //
2301  fInputEvent = InputEvent();
2302 
2303  // Set MC events
2304  if(fIsMC>0) fMCEvent = MCEvent();
2305 
2306  //calculating the weight for the centrality flattening
2307  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
2308  if(fDoCentralityFlat > 0){
2309  fWeightCentrality[iCut] = 1.;
2310  fWeightCentrality[iCut] = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetWeightForCentralityFlattening(fInputEvent);
2311  }
2312  }
2313 
2314  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
2315  if(fInputEvent->IsIncompleteDAQ()==kTRUE) eventQuality = 2; // incomplete event
2316  // Event Not Accepted due to MC event missing or because it is incomplere or wrong trigger for V0ReaderV1 => skip broken events/files
2317  if(eventQuality == 2 || eventQuality == 3){
2318  // write out name of broken file for first event
2319  if (fIsMC > 0){
2320  if (fInputEvent->IsA()==AliESDEvent::Class()){
2321  if (((AliESDEvent*)fInputEvent)->GetEventNumberInFile() == 0){
2322  fFileNameBroken = new TObjString(Form("%s",((TString)fV0Reader->GetCurrentFileName()).Data()));
2323  if (tBrokenFiles) tBrokenFiles->Fill();
2324  delete fFileNameBroken;
2325  }
2326  }
2327  }
2328 
2329  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
2330  fHistoNEvents[iCut]->Fill(eventQuality);
2331  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
2332  if( fDoCentralityFlat > 0) fHistoNEventsWeighted[iCut]->Fill(eventQuality, fWeightCentrality[iCut]);
2333  }
2334  return;
2335  }
2336 
2337  fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
2338 
2339  // ------------------- BeginEvent ----------------------------
2340 
2341  AliEventplane *EventPlane = fInputEvent->GetEventplane();
2342  if(fIsHeavyIon ==1)fEventPlaneAngle = EventPlane->GetEventplane("V0",fInputEvent,2);
2343  else fEventPlaneAngle=0.0;
2344 
2345  if(fIsMC > 0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
2346  RelabelAODPhotonCandidates(kTRUE); // In case of AODMC relabeling MC
2347  fV0Reader->RelabelAODs(kTRUE);
2348  }
2349  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
2350  fiCut = iCut;
2351 
2352  Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon,kFALSE);
2353 
2354  if( fIsMC == 2 ){
2355  Float_t xsection = -1.;
2356  Float_t ntrials = -1.;
2357  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetXSectionAndNTrials(fMCEvent,xsection,ntrials,fInputEvent);
2358  if((xsection==-1.) || (ntrials==-1.)) AliFatal(Form("ERROR: GetXSectionAndNTrials returned invalid xsection/ntrials, periodName from V0Reader: '%s'",fV0Reader->GetPeriodName().Data()));
2359  fProfileJetJetXSection[iCut]->Fill(0.,xsection);
2360  fhJetJetNTrials[iCut]->Fill("#sum{NTrials}",ntrials);
2361  }
2362 
2363  if( fIsMC > 0 ){
2364  fWeightJetJetMC = 1;
2365  Float_t pthard = -1;
2366  Bool_t isMCJet = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsJetJetMCEventAccepted( fMCEvent, fWeightJetJetMC , pthard, fInputEvent);
2367  if (fIsMC == 3){
2368  Double_t weightMult = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetWeightForMultiplicity(fV0Reader->GetNumberOfPrimaryTracks());
2369  fWeightJetJetMC = fWeightJetJetMC*weightMult;
2370  }
2371 
2372  if( fIsMC == 1 ) fWeightJetJetMC = 1;
2373  if(!isMCJet){
2374  fHistoNEvents[iCut]->Fill(10,fWeightJetJetMC);
2375  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(10);
2376  continue;
2377  }
2378  }
2379 
2380  if(eventNotAccepted){
2381  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
2382  fHistoNEvents[iCut]->Fill(eventNotAccepted,fWeightJetJetMC); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
2383  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(eventNotAccepted);
2384  if(fDoCentralityFlat > 0) fHistoNEventsWeighted[iCut]->Fill(eventNotAccepted, fWeightCentrality[iCut]*fWeightJetJetMC);
2385  continue;
2386  }
2387 
2388  if(eventQuality != 0){// Event Not Accepted
2389  // cout << "event rejected due to: " <<eventQuality << endl;
2390  fHistoNEvents[iCut]->Fill(eventQuality,fWeightJetJetMC);
2391  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
2392  if(fDoCentralityFlat > 0) fHistoNEventsWeighted[iCut]->Fill(eventQuality, fWeightCentrality[iCut]*fWeightJetJetMC);
2393  continue;
2394  }
2395 
2396  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetUseSphericity()!=0){
2397  if(fV0Reader->GetSphericity() != -1 && fV0Reader->GetSphericity() != 0){
2398  fHistoEventSphericity[iCut]->Fill(fV0Reader->GetSphericity(), fWeightJetJetMC);
2399  fHistoNEvents[iCut]->Fill(eventQuality,fWeightJetJetMC); // Should be 0 here
2400  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
2401  fHistoNGoodESDTracks[iCut]->Fill(fV0Reader->GetNumberOfPrimaryTracks(),fWeightJetJetMC);
2402  fHistoVertexZ[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetZ(),fWeightJetJetMC);
2403  }
2404  } else {
2405  fHistoNEvents[iCut]->Fill(eventQuality,fWeightJetJetMC); // Should be 0 here
2406  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
2407  if(fDoCentralityFlat > 0) fHistoNEventsWeighted[iCut]->Fill(eventQuality, fWeightCentrality[iCut]*fWeightJetJetMC); // Should be 0 here
2408 
2409  fHistoNGoodESDTracks[iCut]->Fill(fV0Reader->GetNumberOfPrimaryTracks(),fWeightJetJetMC);
2410  if(fDoCentralityFlat > 0) fHistoNGoodESDTracksWeighted[iCut]->Fill(fV0Reader->GetNumberOfPrimaryTracks(), fWeightCentrality[iCut]*fWeightJetJetMC);
2411 
2412  fHistoVertexZ[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetZ(),fWeightJetJetMC);
2413  if(fDoCentralityFlat > 0) fHistoVertexZWeighted[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetZ(), fWeightCentrality[iCut]*fWeightJetJetMC);
2414 
2415  if(fDoPlotVsCentrality) fHistoCentrality[iCut]->Fill(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCentrality(fInputEvent),fWeightJetJetMC);
2416  if(fDoCentralityFlat > 0) fHistoCentralityFlattened[iCut]->Fill(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCentrality(fInputEvent), fWeightCentrality[iCut]*fWeightJetJetMC);
2417 
2418  if(fDoCentralityFlat > 0) fHistoCentralityVsPrimaryTracks[iCut]->Fill(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCentrality(fInputEvent),fV0Reader->GetNumberOfPrimaryTracks(), fWeightCentrality[iCut]*fWeightJetJetMC);
2419  else if(fDoPlotVsCentrality) fHistoCentralityVsPrimaryTracks[iCut]->Fill(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCentrality(fInputEvent),fV0Reader->GetNumberOfPrimaryTracks(), fWeightJetJetMC);
2420 
2421  if(!fDoLightOutput){
2422  if( fIsMC < 2 ){
2423  if(fDoCentralityFlat > 0) fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)), fWeightCentrality[iCut]);
2424  else fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)));
2425  }
2426 
2427  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2){
2428  fHistoV0MultVsNumberTPCoutTracks[iCut]->Fill(fV0Reader->GetNumberOfTPCoutTracks(), fInputEvent->GetVZEROData()->GetMTotV0A());
2429  } else {
2430  fHistoV0MultVsNumberTPCoutTracks[iCut]->Fill(fV0Reader->GetNumberOfTPCoutTracks(), fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C());
2431  }
2432  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2) fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A(),fWeightJetJetMC);
2433  else if(fDoCentralityFlat > 0){
2434  fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C(), fWeightCentrality[iCut]*fWeightJetJetMC);
2435  } else {
2436  fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C(),fWeightJetJetMC);
2437  }
2438  }
2439  }
2440 
2442  ProcessClusters();
2443  }
2444 
2445  if(fIsMC > 0){
2446  // Process MC Particle
2447  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
2448  if(fInputEvent->IsA()==AliESDEvent::Class()){
2449  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
2450  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
2451  fMCEvent);
2452  }
2453  else if(fInputEvent->IsA()==AliAODEvent::Class()){
2454  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
2455  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
2456  fInputEvent);
2457  }
2458 
2459  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader()){
2460  for(Int_t i = 0;i<(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader())->GetEntries();i++){
2461  if(fIsMC < 2){
2462  TString nameBin= fHistoMCHeaders[iCut]->GetXaxis()->GetBinLabel(i+1);
2463  if (nameBin.CompareTo("")== 0){
2464  TString nameHeader = ((TObjString*)((TList*)((AliConvEventCuts*)fEventCutArray->At(iCut))
2465  ->GetAcceptedHeader())->At(i))->GetString();
2466  // cout << nameHeader << endl;
2467  fHistoMCHeaders[iCut]->GetXaxis()->SetBinLabel(i+1,nameHeader.Data());
2468  }
2469  }
2470  }
2471  }
2472  }
2473  }
2474 
2475  if( fIsMC > 0 ){
2476  if(fInputEvent->IsA()==AliESDEvent::Class()) ProcessMCParticles();
2477  if(fInputEvent->IsA()==AliAODEvent::Class()) ProcessAODMCParticles();
2478  }
2479 
2480  ProcessPhotonCandidates(); // Process this cuts gammas
2481  if(fEnableBDT) ProcessPhotonBDT(); //
2482  if(fDoJetAnalysis) ProcessJets(); //Process jets
2484 
2485  if(!fDoLightOutput){
2486  if(fDoCentralityFlat > 0){
2488  if( fIsMC < 2 ) fHistoNGoodESDTracksVsNGammaCandidates[iCut]->Fill(fV0Reader->GetNumberOfPrimaryTracks(),fGammaCandidates->GetEntries(), fWeightCentrality[iCut]);
2489  } else {
2490  fHistoNGammaCandidates[iCut]->Fill(fGammaCandidates->GetEntries(),fWeightJetJetMC);
2491  if( fIsMC < 2 ) fHistoNGoodESDTracksVsNGammaCandidates[iCut]->Fill(fV0Reader->GetNumberOfPrimaryTracks(),fGammaCandidates->GetEntries());
2492  }
2493  }
2494 
2495  if(fDoMesonAnalysis){ // Meson Analysis
2496  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseMCPSmearing() && fIsMC > 0 ){
2497  fUnsmearedPx = new Double_t[fGammaCandidates->GetEntries()]; // Store unsmeared Momenta
2498  fUnsmearedPy = new Double_t[fGammaCandidates->GetEntries()];
2499  fUnsmearedPz = new Double_t[fGammaCandidates->GetEntries()];
2500  fUnsmearedE = new Double_t[fGammaCandidates->GetEntries()];
2501 
2502  for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
2503  fUnsmearedPx[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Px();
2504  fUnsmearedPy[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Py();
2505  fUnsmearedPz[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Pz();
2506  fUnsmearedE[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->E();
2507  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->SmearParticle(dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(gamma)));
2508  }
2509  }
2510 
2511  CalculatePi0Candidates(); // Combine Gammas
2512  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
2513  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
2514  CalculateBackground(); // Combinatorial Background
2515  UpdateEventByEventData(); // Store Event for mixed Events
2516  } else {
2517  CalculateBackgroundRP(); // Combinatorial Background
2518  fBGHandlerRP[iCut]->AddEvent(fGammaCandidates,fInputEvent); // Store Event for mixed Events
2519  }
2520  }
2521  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseMCPSmearing() && fIsMC > 0 ){
2522  for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
2523  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPx(fUnsmearedPx[gamma]); // Reset Unsmeared Momenta
2524  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPy(fUnsmearedPy[gamma]);
2525  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPz(fUnsmearedPz[gamma]);
2526  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetE(fUnsmearedE[gamma]);
2527  }
2528  delete[] fUnsmearedPx; fUnsmearedPx = 0x0;
2529  delete[] fUnsmearedPy; fUnsmearedPy = 0x0;
2530  delete[] fUnsmearedPz; fUnsmearedPz = 0x0;
2531  delete[] fUnsmearedE; fUnsmearedE = 0x0;
2532  }
2533 
2534  if( fIsMC > 0 ){
2535  vecDoubleCountTruePi0s.clear();
2536  vecDoubleCountTrueEtas.clear();
2539  }
2540  }
2541 
2542  if( fIsMC > 0 ){
2545  }
2546 
2547  fGammaCandidates->Clear(); // delete this cuts good gammas
2548  }
2549 
2550  if( fIsMC > 0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
2551  RelabelAODPhotonCandidates(kFALSE); // Back to ESDMC Label
2552  fV0Reader->RelabelAODs(kFALSE);
2553  }
2554 
2555  PostData(1, fOutputContainer);
2556 }
2557 //________________________________________________________________________
2559 {
2560  Int_t nV0 = 0;
2561  TList *GammaCandidatesStepOne = new TList();
2562  TList *GammaCandidatesStepTwo = new TList();
2563  // Loop over Photon Candidates allocated by ReaderV1
2564  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
2565  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
2566  if(!PhotonCandidate) continue;
2567  fIsFromSelectedHeader = kTRUE;
2568 
2569  Float_t weightMatBudgetGamma = 1.;
2570  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2571  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(PhotonCandidate);
2572  }
2573  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetDoElecDeDxPostCalibration()){
2574  if(!(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->LoadElecDeDxPostCalibration(fInputEvent->GetRunNumber()))){
2575  AliFatal(Form("ERROR: LoadElecDeDxPostCalibration returned kFALSE for %d despite being requested!",fInputEvent->GetRunNumber()));
2576  }
2577  }
2578 
2579  if( fIsMC > 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2580  Int_t isPosFromMBHeader
2581  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
2582  if(isPosFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2583  Int_t isNegFromMBHeader
2584  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
2585  if(isNegFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2586 
2587  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromSelectedHeader = kFALSE;
2588  }
2589 
2590 
2591  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fInputEvent)) continue;
2592  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(PhotonCandidate->GetPhotonPhi(),fEventPlaneAngle)) continue;
2593  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
2594  !((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
2595  fGammaCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
2596 
2598  if(fDoCentralityFlat > 0) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2599  else fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightJetJetMC*weightMatBudgetGamma);
2600  if (fDoPhotonQA > 0 && fIsMC < 2){
2601  if(fDoCentralityFlat > 0){
2602  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2603  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2604  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2605  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2606  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
2607  fHistoConvGammaInvMass[fiCut]->Fill(PhotonCandidate->GetMass(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2609  }
2610  } else {
2611  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2612  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
2613  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
2614  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(),fWeightJetJetMC*weightMatBudgetGamma);
2615  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
2616  fHistoConvGammaInvMass[fiCut]->Fill(PhotonCandidate->GetMass(),fWeightJetJetMC*weightMatBudgetGamma);
2617  fHistoConvGammaInvMassReco[fiCut]->Fill(GetOriginalInvMass(PhotonCandidate,fInputEvent),fWeightJetJetMC*weightMatBudgetGamma);
2618  }
2619  }
2620  }
2621  if( fIsMC > 0 ){
2622  if(fInputEvent->IsA()==AliESDEvent::Class())
2623  ProcessTruePhotonCandidates(PhotonCandidate);
2624  if(fInputEvent->IsA()==AliAODEvent::Class())
2625  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
2626  }
2627  if ((fDoPhotonQA == 2)||(fDoPhotonQA == 5)){
2628  if (fIsHeavyIon == 1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
2629  fPtGamma = PhotonCandidate->Pt();
2630  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2631  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2632  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2633  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2634  tESDConvGammaPtDcazCat[fiCut]->Fill();
2635  } else if ( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetSingleElectronPtCut() < 0.04 && PhotonCandidate->Pt() > 0.099 && PhotonCandidate->Pt() < 16.){
2636  fPtGamma = PhotonCandidate->Pt();
2637  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2638  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2639  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2640  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2641  tESDConvGammaPtDcazCat[fiCut]->Fill();
2642  } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
2643  fPtGamma = PhotonCandidate->Pt();
2644  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2645  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2646  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2647  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2648  tESDConvGammaPtDcazCat[fiCut]->Fill();
2649  }
2650  }
2651  }
2652  } else if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
2653  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
2654  nV0++;
2655  GammaCandidatesStepOne->Add(PhotonCandidate);
2656  } else if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
2657  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
2658  GammaCandidatesStepTwo->Add(PhotonCandidate);
2659  }
2660  }
2661  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){
2662  for(Int_t i = 0;i<GammaCandidatesStepOne->GetEntries();i++){
2663  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GammaCandidatesStepOne->At(i);
2664  if(!PhotonCandidate) continue;
2665  fIsFromSelectedHeader = kTRUE;
2666 
2667  Float_t weightMatBudgetGamma = 1.;
2668  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2669  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(PhotonCandidate);
2670  }
2671 
2672 
2673  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2674  Int_t isPosFromMBHeader
2675  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
2676  Int_t isNegFromMBHeader
2677  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
2678  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromSelectedHeader = kFALSE;
2679  }
2680  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GammaCandidatesStepOne->GetEntries())) continue;
2681  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
2682  fGammaCandidates->Add(PhotonCandidate);
2683 
2685  if(fDoCentralityFlat > 0) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2686  else fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2687  if (fDoPhotonQA > 0 && fIsMC < 2){
2688  if(fDoCentralityFlat > 0){
2689  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2690  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2691  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2692  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2693  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
2694  fHistoConvGammaInvMass[fiCut]->Fill(PhotonCandidate->GetMass(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2696  }
2697  } else {
2698  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2699  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
2700  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
2701  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(),fWeightJetJetMC*weightMatBudgetGamma);
2702  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
2703  fHistoConvGammaInvMass[fiCut]->Fill(PhotonCandidate->GetMass(),fWeightJetJetMC*weightMatBudgetGamma);
2704  fHistoConvGammaInvMassReco[fiCut]->Fill(GetOriginalInvMass(PhotonCandidate,fInputEvent),fWeightJetJetMC*weightMatBudgetGamma);
2705  }
2706  }
2707  }
2708  if( fIsMC > 0 ){
2709  if(fInputEvent->IsA()==AliESDEvent::Class())
2710  ProcessTruePhotonCandidates(PhotonCandidate);
2711  if(fInputEvent->IsA()==AliAODEvent::Class())
2712  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
2713  }
2714  if ((fDoPhotonQA == 2)||(fDoPhotonQA == 5)){
2715  if (fIsHeavyIon ==1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
2716  fPtGamma = PhotonCandidate->Pt();
2717  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2718  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2719  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2720  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2721  tESDConvGammaPtDcazCat[fiCut]->Fill();
2722  } else if ( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetSingleElectronPtCut() < 0.04 && PhotonCandidate->Pt() > 0.099 && PhotonCandidate->Pt() < 16.){
2723  fPtGamma = PhotonCandidate->Pt();
2724  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2725  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2726  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2727  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2728  tESDConvGammaPtDcazCat[fiCut]->Fill();
2729  } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
2730  fPtGamma = PhotonCandidate->Pt();
2731  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2732  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2733  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2734  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2735  tESDConvGammaPtDcazCat[fiCut]->Fill();
2736  }
2737  }
2738  }
2739  } else GammaCandidatesStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
2740  }
2741  }
2742  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
2743  for(Int_t i = 0;i<GammaCandidatesStepTwo->GetEntries();i++){
2744  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GammaCandidatesStepTwo->At(i);
2745  if(!PhotonCandidate) continue;
2746  fIsFromSelectedHeader = kTRUE;
2747 
2748  Float_t weightMatBudgetGamma = 1.;
2749  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2750  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(PhotonCandidate);
2751  }
2752 
2753  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2754  Int_t isPosFromMBHeader
2755  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
2756  Int_t isNegFromMBHeader
2757  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
2758  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromSelectedHeader = kFALSE;
2759  }
2760  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GammaCandidatesStepTwo,i)) continue;
2761  fGammaCandidates->Add(PhotonCandidate); // Add gamma to current cut TList
2762 
2764  if(fDoCentralityFlat > 0) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2765  else fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2766  if (fDoPhotonQA > 0 && fIsMC < 2 ){
2767  if(fDoCentralityFlat > 0){
2768  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2769  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2770  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2771  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2772  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
2773  fHistoConvGammaInvMass[fiCut]->Fill(PhotonCandidate->GetMass(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2775  }
2776  } else {
2777  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2778  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
2779  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
2780  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(),fWeightJetJetMC*weightMatBudgetGamma);
2781  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
2782  fHistoConvGammaInvMass[fiCut]->Fill(PhotonCandidate->GetMass(),fWeightJetJetMC*weightMatBudgetGamma);
2783  fHistoConvGammaInvMassReco[fiCut]->Fill(GetOriginalInvMass(PhotonCandidate,fInputEvent),fWeightJetJetMC*weightMatBudgetGamma);
2784  }
2785  }
2786  }
2787  if( fIsMC > 0 ){
2788  if(fInputEvent->IsA()==AliESDEvent::Class())
2789  ProcessTruePhotonCandidates(PhotonCandidate);
2790  if(fInputEvent->IsA()==AliAODEvent::Class())
2791  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
2792  }
2793  if ((fDoPhotonQA == 2)||(fDoPhotonQA == 5)){
2794  if (fIsHeavyIon == 1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
2795  fPtGamma = PhotonCandidate->Pt();
2796  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2797  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2798  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2799  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2800  tESDConvGammaPtDcazCat[fiCut]->Fill();
2801  } else if ( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetSingleElectronPtCut() < 0.04 && PhotonCandidate->Pt() > 0.099 && PhotonCandidate->Pt() < 16.){
2802  fPtGamma = PhotonCandidate->Pt();
2803  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2804  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2805  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2806  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2807  tESDConvGammaPtDcazCat[fiCut]->Fill();
2808  } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
2809  fPtGamma = PhotonCandidate->Pt();
2810  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2811  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2812  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2813  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2814  tESDConvGammaPtDcazCat[fiCut]->Fill();
2815  }
2816  }
2817  }
2818  }
2819  }
2820 
2821  delete GammaCandidatesStepOne;
2822  GammaCandidatesStepOne = 0x0;
2823  delete GammaCandidatesStepTwo;
2824  GammaCandidatesStepTwo = 0x0;
2825 
2826 }
2827 
2828 //________________________________________________________________________
2830 {
2832  if(fConvJetReader->GetNJets()>0){
2840  if(fIsMC > 0 && fConvJetReader->GetTrueNJets()>0){
2844  }
2846  for(Int_t i=0; i<fConvJetReader->GetNJets(); i++){
2847  fHistoPtJet[fiCut]->Fill(fVectorJetPt.at(i));
2848  fHistoJetEta[fiCut]->Fill(fVectorJetEta.at(i));
2849  fHistoJetPhi[fiCut]->Fill(fVectorJetPhi.at(i));
2850  fHistoJetArea[fiCut]->Fill(fVectorJetArea.at(i));
2851  if(!fDoJetQA) fHistoEventwJets[fiCut]->Fill(0);
2852  if(fIsMC > 0 && fConvJetReader->GetNJets()>0 && fConvJetReader->GetTrueNJets()>0){
2853  Double_t min = 100;
2854  Int_t match = 0;
2855  for(Int_t j = 0; j<fConvJetReader->GetTrueNJets(); j++){
2856  Double_t R_jetjet;
2857  Double_t DeltaEta = fVectorJetEta.at(i)-fTrueVectorJetEta.at(j);
2858  Double_t DeltaPhi = abs(fVectorJetPhi.at(i)-fTrueVectorJetPhi.at(j));
2859  if(DeltaPhi > M_PI) {
2860  DeltaPhi = 2*M_PI - DeltaPhi;
2861  }
2862  R_jetjet = TMath::Sqrt(pow((DeltaEta),2)+pow((DeltaPhi),2));
2863  if(R_jetjet < min){
2864  min = R_jetjet;
2865  match = j;
2866  }
2867  }
2869  if(fDoJetQA){
2870  if(fVectorJetPt.at(i) >= 10) fHistoEventwJets[fiCut]->Fill(0);
2871  if(fVectorJetPt.at(i) < 10 && fTrueVectorJetPt.at(match) >= 10) fHistoEventwJets[fiCut]->Fill(1);
2872  if(fVectorJetPt.at(i) >= 10 && fTrueVectorJetPt.at(match) < 10) fHistoEventwJets[fiCut]->Fill(2);
2873  }
2874  }
2875  }
2876  }
2877  fVectorJetPt.clear();
2878  fVectorJetPx.clear();
2879  fVectorJetPy.clear();
2880  fVectorJetPz.clear();
2881  fVectorJetEta.clear();
2882  fVectorJetPhi.clear();
2883  fVectorJetArea.clear();
2884  if(fIsMC > 0 && fConvJetReader->GetTrueNJets()>0){
2885  fTrueVectorJetPt.clear();
2886  fTrueVectorJetEta.clear();
2887  fTrueVectorJetPhi.clear();
2888  }
2889  }
2890 }
2891 //________________________________________________________________________
2893 {
2894  Bool_t DoesEventContainHighPtHadron = kFALSE;
2895  Double_t NTotalTracks = fInputEvent->GetNumberOfTracks();
2896  Int_t NTracks = 0;
2897  for(Int_t iTracks = 0; iTracks<NTotalTracks; iTracks++){
2898  AliAODTrack* curTrack = (AliAODTrack*) fInputEvent->GetTrack(iTracks);
2899  if(curTrack->GetID()<0) continue; // Avoid double counting of tracks
2900  if(!curTrack->IsHybridGlobalConstrainedGlobal()) continue;
2901  if(TMath::Abs(curTrack->Eta())>0.8) continue;
2902  if(curTrack->Pt()<0.15) continue;
2903  if(curTrack->Pt()>10) DoesEventContainHighPtHadron = kTRUE;
2904  NTracks++;
2905  }
2906  if(fGammaCandidates->GetEntries()>1){
2907  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries()-1;firstGammaIndex++){
2908  AliAODConversionPhoton *gamma=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
2909  if(gamma==NULL) continue;
2910  if(DoesEventContainHighPtHadron){
2911  fHistoConvGammaPtwithHighPtHadron[fiCut]->Fill(gamma->Pt(),NTracks);
2912  } else {
2913  fHistoConvGammaPtwithoutHighPtHadron[fiCut]->Fill(gamma->Pt(),NTracks);
2914  }
2915  }
2916  }
2917 }
2918 
2919 //________________________________________________________________________
2921 {
2922 
2923  // This loads the library
2924  TMVA::Tools::Instance();
2925  fBDTreader = new TMVA::Reader( "!Color:!Silent" );
2926 
2927  fBDTvariable = new Float_t[18];
2928  for(Int_t i=0; i<18; i++){
2929  fBDTvariable[i] = 0;
2930  }
2931 
2932  // add variables
2933  fBDTreader->AddVariable( "dEdxElectronITS + dEdxPositronITS" , &fBDTvariable[0] );
2934  fBDTreader->AddVariable( "photonQt" , &fBDTvariable[1] );
2935  fBDTreader->AddVariable( "photonInvMass" , &fBDTvariable[2] );
2936  fBDTreader->AddVariable( "photonR" , &fBDTvariable[3] );
2937  fBDTreader->AddVariable( "photonAlpha" , &fBDTvariable[4] );
2938  fBDTreader->AddVariable( "photonPsiPair" , &fBDTvariable[5] );
2939  fBDTreader->AddVariable( "photonCosPoint" , &fBDTvariable[6] );
2940  fBDTreader->AddVariable( "fracClsTPCPositron" , &fBDTvariable[7] );
2941  fBDTreader->AddVariable( "fracClsTPCElectron" , &fBDTvariable[8] );
2942  fBDTreader->AddVariable( "clsITSPositron" , &fBDTvariable[9] );
2943  fBDTreader->AddVariable( "clsITSElectron" , &fBDTvariable[10] );
2944  fBDTreader->AddVariable( "nSigmaTPCElectron" , &fBDTvariable[11] );
2945  fBDTreader->AddVariable( "nSigmaTPCPositron" , &fBDTvariable[12] );
2946  // add spectators like in the training
2947  fBDTreader->AddSpectator( "photonPt", &fBDTvariable[13] );
2948  fBDTreader->AddSpectator( "kind", &fBDTvariable[14] );
2949  fBDTreader->AddSpectator( "photonEta", &fBDTvariable[15] );
2950  fBDTreader->AddSpectator( "photonP", &fBDTvariable[16] );
2951  fBDTreader->AddSpectator( "photonPhi", &fBDTvariable[17] );
2952 
2953  fBDTreader->BookMVA( "BDT method", fFileNameBDT.Data());
2954 
2955 }
2956 //________________________________________________________________________
2958 {
2959  // Loop over Photon Candidates allocated by ReaderV1
2960  for(Int_t i = 0; i < fGammaCandidates->GetEntries(); i++){
2961  AliAODConversionPhoton *PhotonCandidate=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(i));
2962  if(!PhotonCandidate) continue;
2963 
2964  Float_t SingleTrackBDTVariableValues[7];
2965  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetBDTVariableValues(PhotonCandidate,fInputEvent, SingleTrackBDTVariableValues)){
2966  fBDTvariable[0] = SingleTrackBDTVariableValues[0]; //"dEdxElectronITS + dEdxPositronITS"
2967  fBDTvariable[1] = PhotonCandidate->GetArmenterosQt(); //"photonQt"
2968  fBDTvariable[2] = GetOriginalInvMass(PhotonCandidate,fInputEvent); //"photonInvMass"
2969  fBDTvariable[3] = PhotonCandidate->GetConversionRadius(); //"photonR"
2970  fBDTvariable[4] = PhotonCandidate->GetArmenterosAlpha(); //"photonAlpha"
2971  fBDTvariable[5] = PhotonCandidate->GetPsiPair(); //"photonPsiPair"
2972  fBDTvariable[6] = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetCosineOfPointingAngle(PhotonCandidate,fInputEvent); //"photonCosPoint"
2973  fBDTvariable[7] = SingleTrackBDTVariableValues[1]; //"fracClsTPCPositron"
2974  fBDTvariable[8] = SingleTrackBDTVariableValues[2]; //"fracClsTPCElectron"
2975  fBDTvariable[9] = SingleTrackBDTVariableValues[3]; //"clsITSPositron"
2976  fBDTvariable[10] = SingleTrackBDTVariableValues[4]; //"clsITSElectron"
2977  fBDTvariable[11] = SingleTrackBDTVariableValues[5]; //"nSigmaTPCElectron"
2978  fBDTvariable[12] = SingleTrackBDTVariableValues[6]; //"nSigmaTPCPositron"
2979 
2980  //Here we want to see the BDT output value
2981  Float_t BDToutput = fBDTreader->EvaluateMVA("BDT method");
2982  fHistoBDToutput[fiCut]->Fill( BDToutput );
2983  if(BDToutput > 0.) fHistoBDToutputPt[fiCut]->Fill( PhotonCandidate->Pt() );
2984 
2985  //going to check the BDT output if the current photon is a true conversion
2986  if(fIsMC > 0){
2987  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2988  if (AODMCTrackArray != NULL && PhotonCandidate != NULL){
2989  AliAODMCParticle *posDaughter = (AliAODMCParticle*) AODMCTrackArray->At(PhotonCandidate->GetMCLabelPositive());
2990  AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(PhotonCandidate->GetMCLabelNegative());
2991  if(posDaughter != NULL && negDaughter != NULL){
2992  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
2993  if(posDaughter->GetMother() == negDaughter->GetMother()){
2994  if((pdgCode[0]==11 && pdgCode[1]==11)&& posDaughter->GetPdgCode()!=negDaughter->GetPdgCode()){
2995  AliAODMCParticle *Photon = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
2996  if(Photon->GetPdgCode() == 22) fHistoBDToutputMCTrue[fiCut]->Fill( BDToutput );
2997  }
2998  }
2999  }
3000  }
3001  }
3002 
3003  }
3004  }
3005 }
3006 //________________________________________________________________________
3007 void AliAnalysisTaskGammaConvV1::ProcessTruePhotonCandidatesAOD(AliAODConversionPhoton *TruePhotonCandidate)
3008 {
3009  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3010  Double_t mcProdVtxX = primVtxMC->GetX();
3011  Double_t mcProdVtxY = primVtxMC->GetY();
3012  Double_t mcProdVtxZ = primVtxMC->GetZ();
3013 
3014  Double_t magField = fInputEvent->GetMagneticField();
3015  if( magField < 0.0 ){
3016  magField = 1.0;
3017  }
3018  else {
3019  magField = -1.0;
3020  }
3021 
3022  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3023  if (AODMCTrackArray != NULL && TruePhotonCandidate != NULL){
3024 
3025  AliAODMCParticle *posDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelPositive());
3026  AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelNegative());
3027  iPhotonMCInfo = 0;
3028 
3029  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
3030  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
3031 
3032  Double_t PhiParticle[2] = {posDaughter->Phi(),negDaughter->Phi()};
3033 
3034  if(posDaughter->GetMother() != negDaughter->GetMother()){
3035  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
3036  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
3037  if(posDaughter->GetMother() > -1){ //contamination is not a primary
3038  AliAODMCParticle *Mom = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
3039  if(Mom->GetMother() == -1){
3040  FillPhotonCombinatorialMothersHistAOD(posDaughter,Mom);
3041  } else {
3042  AliAODMCParticle *GranMom = (AliAODMCParticle*) AODMCTrackArray->At(Mom->GetMother());
3043  if(GranMom->GetMother() == -1){
3044  FillPhotonCombinatorialMothersHistAOD(posDaughter,GranMom);
3045  } else {
3046  AliAODMCParticle *GranGranMom = (AliAODMCParticle*) AODMCTrackArray->At(GranMom->GetMother());
3047  if(GranGranMom->GetMother() == -1){
3048  FillPhotonCombinatorialMothersHistAOD(posDaughter,GranGranMom);
3049  } else FillPhotonCombinatorialMothersHistAOD(posDaughter,GranGranMom);
3050  }
3051  }
3052  }
3053  if(negDaughter->GetMother() > -1){ //contamination is not a primary
3054  AliAODMCParticle *Mom = (AliAODMCParticle*) AODMCTrackArray->At(negDaughter->GetMother());
3055  if(Mom->GetMother() == -1){
3056  FillPhotonCombinatorialMothersHistAOD(negDaughter,Mom);
3057  } else {
3058  AliAODMCParticle *GranMom = (AliAODMCParticle*) AODMCTrackArray->At(Mom->GetMother());
3059  if(GranMom->GetMother() == -1){
3060  FillPhotonCombinatorialMothersHistAOD(negDaughter,GranMom);
3061  } else {
3062  AliAODMCParticle *GranGranMom = (AliAODMCParticle*) AODMCTrackArray->At(GranMom->GetMother());
3063  if(GranGranMom->GetMother() == -1){
3064  FillPhotonCombinatorialMothersHistAOD(negDaughter,GranGranMom);
3065  } else FillPhotonCombinatorialMothersHistAOD(posDaughter,GranGranMom);
3066  }
3067  }
3068  }
3069  }
3070  iPhotonMCInfo = 1;
3071  return;
3072  }
3073  else if(posDaughter->GetMother() == -1){
3074  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
3075  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
3076  FillPhotonCombinatorialMothersHistAOD(posDaughter,posDaughter);
3077  FillPhotonCombinatorialMothersHistAOD(negDaughter,negDaughter);
3078  }
3079  iPhotonMCInfo = 1;
3080  return;
3081  }
3082 
3083  if(pdgCode[0]!=11 || pdgCode[1]!=11){
3084  iPhotonMCInfo = 1;
3085  return; //One Particle is not a electron
3086  }
3087  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()){
3088  iPhotonMCInfo = 1;
3089  return; // Same Charge
3090  }
3091 
3092  AliAODMCParticle *Photon = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
3093  AliVTrack * electronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelNegative() );
3094  AliVTrack * positronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelPositive() );
3095  Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->Phi()-positronCandidate->Phi());
3096 
3097  if(Photon->GetPdgCode() != 22){
3098  fHistoTrueDalitzPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC);
3099  iPhotonMCInfo = 1;
3100  return; // Mother is no Photon
3101  }
3102 
3103  if(((posDaughter->GetMCProcessCode())) != 5 || ((negDaughter->GetMCProcessCode())) != 5){
3104  iPhotonMCInfo = 1;
3105  return;// check if the daughters come from a conversion
3106  }
3107  // STILL A BUG IN ALIROOT >>8 HAS TPO BE REMOVED AFTER FIX
3108 
3109  Double_t rConv=0.;
3110  rConv = sqrt( (posDaughter->Xv()*posDaughter->Xv()) + (posDaughter->Yv()*posDaughter->Yv()) );
3111 
3112  // True Photon
3113 
3114  Float_t weightMatBudgetGamma = 1.;
3115  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
3116  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TruePhotonCandidate);
3117  }
3118 
3119  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
3120  if (CheckVectorForDoubleCount(vecDoubleCountTrueConvGammas,posDaughter->GetMother())){
3121  fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
3122  FillMultipleCountMap(mapMultipleCountTrueConvGammas,posDaughter->GetMother());
3123  }
3124  if (fDoPhotonQA > 0 ){
3125  if (fIsMC < 2){
3126  fHistoTrueConvGammaPsiPairPt[fiCut]->Fill(TruePhotonCandidate->GetPsiPair(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
3127  fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
3128  fHistoTrueConvGammaR[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
3129  fHistoTrueConvGammaRMC[fiCut]->Fill(rConv,fWeightJetJetMC*weightMatBudgetGamma);
3130  }
3131  fHistoTrueConvGammaPtMC[fiCut]->Fill(Photon->Pt(), fWeightJetJetMC*weightMatBudgetGamma);
3132  }
3133  fHistoTrueGammaPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC*weightMatBudgetGamma);
3134 
3135  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3136  if(isPrimary){
3137  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
3138  iPhotonMCInfo = 6;
3139  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
3140  fHistoTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(),fWeightJetJetMC*weightMatBudgetGamma); // Allways Filled
3141  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
3142  } else {
3143  iPhotonMCInfo = 2;
3144  if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 && ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetMother() > -1 ){
3145  if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 310){
3146  iPhotonMCInfo = 4;
3147  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
3148  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
3149  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
3150  } else if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 130) {
3151  iPhotonMCInfo = 7;
3152  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
3153  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
3154  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
3155  } else if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 3122) {
3156  iPhotonMCInfo = 5;
3157  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
3158  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
3159  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
3160  } else if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 221) {
3161  iPhotonMCInfo = 3;
3162  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
3163  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
3164  } else {
3165  // if ( !(TMath::Abs(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetPdgCode()) == 11 && ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 22) ) {
3166  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
3167  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
3168  // }
3169  }
3170  }
3171  }
3172  }
3173  return;
3174 }
3175 //________________________________________________________________________
3176 void AliAnalysisTaskGammaConvV1::ProcessTruePhotonCandidates(AliAODConversionPhoton *TruePhotonCandidate)
3177 {
3178  Double_t magField = fInputEvent->GetMagneticField();
3179  if( magField < 0.0 ){
3180  magField = 1.0;
3181  }
3182  else {
3183  magField = -1.0;
3184  }
3185 
3186  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3187  Double_t mcProdVtxX = primVtxMC->GetX();
3188  Double_t mcProdVtxY = primVtxMC->GetY();
3189  Double_t mcProdVtxZ = primVtxMC->GetZ();
3190 
3191  // Process True Photons
3192  TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCEvent);
3193  TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCEvent);
3194 
3195  iPhotonMCInfo = 0;
3196 
3197  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
3198  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
3199 
3200  Double_t PhiParticle[2] = {posDaughter->Phi(),negDaughter->Phi()};
3201 
3202  iPhotonMCInfo = 1;
3203  if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){
3204  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
3205  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
3206  if(posDaughter->GetMother(0) > -1){ //contamination is not a primary
3207  TParticle *Mom = fMCEvent->Particle(posDaughter->GetMother(0));
3208  if(Mom->GetMother(0) == -1){
3209  FillPhotonCombinatorialMothersHistESD(posDaughter,Mom);
3210  } else {
3211  TParticle *GranMom = fMCEvent->Particle(Mom->GetMother(0));
3212  if(GranMom->GetMother(0) == -1){
3213  FillPhotonCombinatorialMothersHistESD(posDaughter,GranMom);
3214  } else {
3215  TParticle *GranGranMom = fMCEvent->Particle(GranMom->GetMother(0));
3216  if(GranGranMom->GetMother(0) == -1){
3217  FillPhotonCombinatorialMothersHistESD(posDaughter,GranGranMom);
3218  } else FillPhotonCombinatorialMothersHistESD(posDaughter,GranGranMom);
3219  }
3220  }
3221  }
3222  if(negDaughter->GetMother(0) > -1){ //contamination is not a primary
3223  TParticle *Mom = fMCEvent->Particle(negDaughter->GetMother(0));
3224  if(Mom->GetMother(0) == -1){
3225  FillPhotonCombinatorialMothersHistESD(negDaughter,Mom);
3226  } else {
3227  TParticle *GranMom = fMCEvent->Particle(Mom->GetMother(0));
3228  if(GranMom->GetMother(0) == -1){
3229  FillPhotonCombinatorialMothersHistESD(negDaughter,GranMom);
3230  } else {
3231  TParticle *GranGranMom = fMCEvent->Particle(GranMom->GetMother(0));
3232  if(GranGranMom->GetMother(0) == -1){
3233  FillPhotonCombinatorialMothersHistESD(negDaughter,GranGranMom);
3234  } else FillPhotonCombinatorialMothersHistESD(posDaughter,GranGranMom);
3235  }
3236  }
3237  }
3238  }
3239  return;
3240  } else if(posDaughter->GetMother(0) == -1){ //gamma contamination is a primary
3241  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
3242  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
3243  FillPhotonCombinatorialMothersHistESD(posDaughter,posDaughter);
3244  FillPhotonCombinatorialMothersHistESD(negDaughter,negDaughter);
3245  }
3246  return;
3247  }
3248 
3249  if(pdgCode[0]!=11 || pdgCode[1]!=11) return; //One Particle is not a electron
3250 
3251  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
3252 
3253  TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCEvent);
3254  AliVTrack * electronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelNegative() );
3255  AliVTrack * positronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelPositive() );
3256  Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->Phi()-positronCandidate->Phi());
3257 
3258  if(Photon->GetPdgCode() != 22){
3259  fHistoTrueDalitzPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC);
3260  return; // Mother is no Photon
3261  }
3262 
3263  if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
3264 
3265  // True Photon
3266  Float_t weightMatBudgetGamma = 1.;
3267  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
3268  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TruePhotonCandidate);
3269  }
3270 
3271  // cout<< " AM- Material Budget weight Gamma::"<< weightMatBudgetGamma << " "<< TruePhotonCandidate->GetConversionRadius() << endl;
3272 
3273  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
3274  if (CheckVectorForDoubleCount(vecDoubleCountTrueConvGammas,posDaughter->GetMother(0))){
3275  fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
3276  FillMultipleCountMap(mapMultipleCountTrueConvGammas,posDaughter->GetMother(0));
3277  }
3278  if (fDoPhotonQA > 0){
3279  if (fIsMC < 2){
3280  fHistoTrueConvGammaPsiPairPt[fiCut]->Fill(TruePhotonCandidate->GetPsiPair(),TruePhotonCandidate->Pt(),weightMatBudgetGamma);
3281  fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta(),weightMatBudgetGamma);
3282  fHistoTrueConvGammaR[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),weightMatBudgetGamma);
3283  fHistoTrueConvGammaRMC[fiCut]->Fill(posDaughter->R(),weightMatBudgetGamma);
3284  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
3285  fHistoTrueConvGammaInvMass[fiCut]->Fill(TruePhotonCandidate->GetMass(),weightMatBudgetGamma);
3286  fHistoTrueConvGammaInvMassReco[fiCut]->Fill(GetOriginalInvMass(TruePhotonCandidate,fInputEvent),weightMatBudgetGamma);
3287  }
3288  }
3289  fHistoTrueConvGammaPtMC[fiCut]->Fill(Photon->Pt(), fWeightJetJetMC*weightMatBudgetGamma);
3290  }
3291 
3292  fHistoTrueGammaPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC*weightMatBudgetGamma);
3293  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, posDaughter->GetMother(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
3294  // filling primary histograms
3295  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
3296  iPhotonMCInfo = 6;
3297  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
3298  fHistoTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(),fWeightJetJetMC*weightMatBudgetGamma); // Allways Filled
3299  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
3300  } else {
3301  // filling secondary photon histograms
3302  iPhotonMCInfo = 2;
3303  if( Photon->GetMother(0) > -1 && fMCEvent->Particle(Photon->GetMother(0))->GetMother(0) > -1){
3304  if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
3305  iPhotonMCInfo = 4;
3306  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
3307  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
3308  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
3309  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
3310  iPhotonMCInfo = 7;
3311  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
3312  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
3313  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
3314  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
3315  iPhotonMCInfo = 5;
3316  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
3317  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
3318  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
3319  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 221) {
3320  iPhotonMCInfo = 3;
3321  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
3322  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
3323  } else {
3324 // if ( !(TMath::Abs(fMCEvent->Particle(Photon->GetMother(0))->GetPdgCode()) == 11 && fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 22) ) {
3325  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
3326  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
3327 // }
3328  }
3329  } else {
3330  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
3331  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
3332  }
3333  }
3334 }
3335 //________________________________________________________________________
3337 {
3338  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3339  Double_t mcProdVtxX = primVtxMC->GetX();
3340  Double_t mcProdVtxY = primVtxMC->GetY();
3341  Double_t mcProdVtxZ = primVtxMC->GetZ();
3342 
3343  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3344 
3345  if (AODMCTrackArray){
3346  // Loop over all primary MC particle
3347  for(Int_t i = 0; i < AODMCTrackArray->GetEntriesFast(); i++) {
3348 
3349  AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
3350  if (!particle) continue;
3351 
3352  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, particle, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3353  if (isPrimary){
3354 
3355  Int_t isMCFromMBHeader = -1;
3356  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3357  isMCFromMBHeader
3358  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
3359  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3360  }
3361 
3362  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
3363  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kFALSE)){
3364  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // All MC Gamma
3365  if(particle->GetMother() >-1){ // Meson Decay Gamma
3366  switch((static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother())))->GetPdgCode()){
3367  case 111: // Pi0
3368  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3369  break;
3370  case 113: // Rho0
3371  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3372  break;
3373  case 221: // Eta
3374  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3375  break;
3376  case 223: // Omega
3377  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3378  break;
3379  case 331: // Eta'
3380  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3381  break;
3382  case 333: // Phi
3383  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3384  break;
3385  case 3212: // Sigma
3386  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3387  break;
3388  }
3389  }
3390  }
3391  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kTRUE)){
3392  Double_t rConv = 0;
3393  for(Int_t daughterIndex=particle->GetDaughterLabel(0);daughterIndex<=particle->GetDaughterLabel(1);daughterIndex++){
3394  AliAODMCParticle *tmpDaughter = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(daughterIndex));
3395  if(!tmpDaughter) continue;
3396  if(TMath::Abs(tmpDaughter->GetPdgCode()) == 11){
3397  rConv = sqrt( (tmpDaughter->Xv()*tmpDaughter->Xv()) + (tmpDaughter->Yv()*tmpDaughter->Yv()) );
3398  }
3399  }
3400  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3401  if ( fDoPhotonQA > 0 && fIsMC < 2){
3403  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta(),fWeightJetJetMC);
3404  }
3405  }
3406  // Converted MC Gamma
3407  if(fDoMesonAnalysis){
3408 
3409  Double_t mesonY = 1.e30;
3410  Double_t ratio = 0;
3411  if (particle->E() != TMath::Abs(particle->Pz())){
3412  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
3413  }
3414  if( !(ratio <= 0) ){
3415  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3416  }
3417 
3418  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
3419  if ( particle->GetPdgCode() == 211 ){ // positve pions
3420  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
3421  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
3422  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
3423  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
3424  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3425  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
3426  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3427  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
3428  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),4.,fWeightJetJetMC);
3429  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
3430  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),5.,fWeightJetJetMC);
3431  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
3432  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),6.,fWeightJetJetMC);
3433  } else if ( TMath::Abs(particle->GetPdgCode()) == 223 ){ // Omega
3434  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),7.,fWeightJetJetMC);
3435  } else if ( TMath::Abs(particle->GetPdgCode()) == 333 ){ // Phi
3436  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),8.,fWeightJetJetMC);
3437  } else if ( TMath::Abs(particle->GetPdgCode()) == 113 ){ // Rho0
3438  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),9.,fWeightJetJetMC);
3439  }
3440  }
3441 
3442  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3443  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughterLabel(0)));
3444  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughterLabel(1)));
3445  Float_t weighted= 1;
3446  if (particle->Pt()>0.005){
3447  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, 0x0, fInputEvent);
3448  // if(particle->GetPdgCode() == 221){
3449  // cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3450  // }
3451  }
3452 
3453  Double_t mesonY = 1.e30;
3454  Double_t ratio = 0;
3455  if (particle->E() != TMath::Abs(particle->Pz())){
3456  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
3457  }
3458  if( !(ratio <= 0) ){
3459  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3460  }
3461 
3462  Double_t alpha = -1;
3463  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
3464  alpha = TMath::Abs((daughter0->E() - daughter1->E()))/(daughter0->E() + daughter1->E());
3465  }
3466 
3467  if(particle->GetPdgCode() == 111){
3468  if(!fDoJetAnalysis || (fDoJetAnalysis && !fDoLightOutput)) fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Pi0
3469  if(fDoJetAnalysis){
3470  if(fConvJetReader->GetTrueNJets()>0){
3471  if(!fDoLightOutput) fHistoMCPi0JetEventGenerated[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Pi0 with gamma in acc in jet event
3474  Double_t RJetPi0Cand;
3475  for(Int_t i=0; i<fConvJetReader->GetTrueNJets(); i++){
3476  Double_t DeltaEta = fTrueVectorJetEta.at(i)-particle->Eta();
3477  Double_t DeltaPhi = abs(fTrueVectorJetPhi.at(i)-particle->Phi());
3478  if(DeltaPhi > M_PI) {
3479  DeltaPhi = 2*M_PI - DeltaPhi;
3480  }
3481  RJetPi0Cand = TMath::Sqrt(pow((DeltaEta),2)+pow((DeltaPhi),2));
3482  if(fConvJetReader->Get_Jet_Radius() > 0 ){
3483  if(RJetPi0Cand < fConvJetReader->Get_Jet_Radius()){
3484  if(!fDoLightOutput) fHistoMCPi0inJetGenerated[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Pi0 with gamma in acc in a jet
3485  else fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC);
3486  }
3487  }
3488  }
3489  fTrueVectorJetEta.clear();
3490  fTrueVectorJetPhi.clear();
3491  }
3492  }
3493  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3494  if ( fIsMC > 1 ) fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
3495  if (fDoMesonQA > 0){
3496  if ( fIsMC < 2 )fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
3497  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
3498  if ( fIsMC == 2 ) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
3499  }
3500  } else if(particle->GetPdgCode() == 221){
3501  if(!fDoJetAnalysis || (fDoJetAnalysis && !fDoLightOutput)) fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Eta
3502  if(fDoJetAnalysis){
3503  if(fConvJetReader->GetTrueNJets()>0){
3504  if(!fDoLightOutput) fHistoMCEtaJetEventGenerated[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc in jet event
3507  Double_t RJetPi0Cand;
3508  for(Int_t i=0; i<fConvJetReader->GetTrueNJets(); i++){
3509  Double_t DeltaEta = fTrueVectorJetEta.at(i)-particle->Eta();
3510  Double_t DeltaPhi = abs(fTrueVectorJetPhi.at(i)-particle->Phi());
3511  if(DeltaPhi > M_PI) {
3512  DeltaPhi = 2*M_PI - DeltaPhi;
3513  }
3514  RJetPi0Cand = TMath::Sqrt(pow((DeltaEta),2)+pow((DeltaPhi),2));
3515  if(fConvJetReader->Get_Jet_Radius() > 0 ){
3516  if(RJetPi0Cand < fConvJetReader->Get_Jet_Radius()){
3517  if(!fDoLightOutput) fHistoMCEtainJetGenerated[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc in a jet
3518  else fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC);
3519  }
3520  }
3521  }
3522  fTrueVectorJetEta.clear();
3523  fTrueVectorJetPhi.clear();
3524  }
3525  }
3526  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3527  if ( fIsMC > 1 ) fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
3528  if (fDoMesonQA > 0){
3529  if ( fIsMC < 2 )fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
3530  fHistoMCEtaPtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
3531  if ( fIsMC == 2 ) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
3532  }
3533  }
3534 
3535  // Check the acceptance for both gammas
3536  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
3537  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
3538  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
3539  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
3540 
3541  if(particle->GetPdgCode() == 111){
3542  if(fIsMC > 1) fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 with gamma in acc NOT weighted at all
3543  fHistoMCPi0WOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Pi0 with gamma in acc NOT weighted
3544  if(!fDoJetAnalysis || (fDoJetAnalysis && !fDoLightOutput)) fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc
3545  if(fDoJetAnalysis){
3546  if(fConvJetReader->GetTrueNJets()>0){
3547  if(!fDoLightOutput) fHistoMCPi0JetInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc in jet event
3550  Double_t RJetPi0Cand;
3551  for(Int_t i=0; i<fConvJetReader->GetTrueNJets(); i++){
3552  Double_t DeltaEta = fTrueVectorJetEta.at(i)-particle->Eta();
3553  Double_t DeltaPhi = abs(fTrueVectorJetPhi.at(i)-particle->Phi());
3554  if(DeltaPhi > M_PI) {
3555  DeltaPhi = 2*M_PI - DeltaPhi;
3556  }
3557  RJetPi0Cand = TMath::Sqrt(pow((DeltaEta),2)+pow((DeltaPhi),2));
3558  if(fConvJetReader->Get_Jet_Radius() > 0 ){
3559  if(RJetPi0Cand < fConvJetReader->Get_Jet_Radius()){
3560  if(!fDoLightOutput) fHistoMCPi0inJetInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc in a jet
3561  else fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC);
3562  }
3563  }
3564  }
3565  fTrueVectorJetEta.clear();
3566  fTrueVectorJetPhi.clear();
3567  }
3568  }
3569  } else if(particle->GetPdgCode() == 221){
3570  if(fIsMC > 1) fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta with gamma in acc NOT weighted at all
3571  fHistoMCEtaWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Eta with gamma in acc NOT weighted
3572  if(!fDoJetAnalysis || (fDoJetAnalysis && !fDoLightOutput)) fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Eta with gamma in acc
3573  if(fDoJetAnalysis){
3574  if(fConvJetReader->GetTrueNJets()>0){
3575  if(!fDoLightOutput) fHistoMCEtaJetInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc in jet event
3578  Double_t RJetPi0Cand;
3579  for(Int_t i=0; i<fConvJetReader->GetTrueNJets(); i++){
3580  Double_t DeltaEta = fTrueVectorJetEta.at(i)-particle->Eta();
3581  Double_t DeltaPhi = abs(fTrueVectorJetPhi.at(i)-particle->Phi());
3582  if(DeltaPhi > M_PI) {
3583  DeltaPhi = 2*M_PI - DeltaPhi;
3584  }
3585  RJetPi0Cand = TMath::Sqrt(pow((DeltaEta),2)+pow((DeltaPhi),2));
3586  if(fConvJetReader->Get_Jet_Radius() > 0 ){
3587  if(RJetPi0Cand < fConvJetReader->Get_Jet_Radius()){
3588  if(!fDoLightOutput) fHistoMCEtainJetInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc in a jet
3589  else fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC);
3590  }
3591  }
3592  }
3593  fTrueVectorJetEta.clear();
3594  fTrueVectorJetPhi.clear();
3595  }
3596  }
3597  }
3598  }
3599  }
3600  }
3601  // fill secondary histograms
3602  } else {
3603  Int_t isMCFromMBHeader = -1;
3604  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3605  isMCFromMBHeader
3606  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
3607  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3608  }
3609 
3610  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) {
3611  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kFALSE)){
3612  if (particle->GetMother() > -1) {
3613  AliAODMCParticle *tmpMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
3614  if (tmpMother->GetMother() > -1) {
3615  AliAODMCParticle *tmpGrandMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(tmpMother->GetMother()));
3616  if(tmpGrandMother->GetPdgCode() == 310) {
3617  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
3618  } else if (tmpGrandMother->GetPdgCode() == 130) {
3619  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
3620  } else if (tmpGrandMother->GetPdgCode() == 3122) {
3621  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3622  } else {
3623  if ( !(TMath::Abs(tmpMother->GetPdgCode()) == 11 && tmpGrandMother->GetPdgCode() == 22) )
3624  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3625  }
3626  } else {
3627  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3628  }
3629  } else {
3630  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3631  }
3632  }
3633 
3634  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kTRUE)){
3635  if (particle->GetMother() > -1) {
3636  AliAODMCParticle *tmpMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
3637  if (tmpMother->GetMother() > -1) {
3638  AliAODMCParticle *tmpGrandMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(tmpMother->GetMother()));
3639  if(tmpGrandMother->GetPdgCode() == 310) {
3640  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
3641  } else if (tmpGrandMother->GetPdgCode() == 130) {
3642  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
3643  } else if (tmpGrandMother->GetPdgCode() == 3122) {
3644  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3645  } else {
3646  if ( !(TMath::Abs(tmpMother->GetPdgCode()) == 11 && tmpGrandMother->GetPdgCode() == 22) )
3647  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3648  }
3649  } else {
3650  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3651  }
3652  } else {
3653  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3654  }
3655  }
3656  }
3657 
3658  if(fDoMesonAnalysis){
3659  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3660  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughterLabel(0)));
3661  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughterLabel(1)));
3662  AliAODMCParticle* mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
3663  Int_t pdgCode = mother->GetPdgCode();
3664  if(particle->GetPdgCode() == 111){
3665  Int_t source = GetSourceClassification(111,pdgCode);
3666  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
3667  fHistoMCSecPi0Source[fiCut]->Fill(pdgCode);
3668  } else if(particle->GetPdgCode() == 221){
3669  fHistoMCSecEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3670  fHistoMCSecEtaSource[fiCut]->Fill(pdgCode);
3671  }
3672 
3673  // pi0 really in acceptance/
3674  if( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
3675  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
3676  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
3677  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
3678  if(particle->GetPdgCode() == 111){
3679  Int_t source = GetSourceClassification(111,pdgCode);
3680  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
3681  }
3682  }
3683  }
3684  }
3685  }
3686  }
3687  }
3688  return;
3689 }
3690 //________________________________________________________________________
3692 {
3693  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3694  Double_t mcProdVtxX = primVtxMC->GetX();
3695  Double_t mcProdVtxY = primVtxMC->GetY();
3696  Double_t mcProdVtxZ = primVtxMC->GetZ();
3697 // cout << mcProdVtxX <<"\t" << mcProdVtxY << "\t" << mcProdVtxZ << endl;
3698 
3699  // Loop over all primary MC particle
3700  for(Long_t i = 0; i < fMCEvent->GetNumberOfTracks(); i++) {
3701 
3702  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
3703  // fill primary histogram
3704  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
3705  if (!particle) continue;
3706 
3707  Int_t isMCFromMBHeader = -1;
3708  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3709  isMCFromMBHeader
3710  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
3711  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3712  }
3713 
3714  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
3715  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
3716  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // All MC Gamma
3717  if(particle->GetMother(0) >-1){ // Meson Decay Gamma
3718  switch(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()){
3719  case 111: // Pi0
3720  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3721  break;
3722  case 113: // Rho0
3723  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3724  break;
3725  case 221: // Eta
3726  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3727  break;
3728  case 223: // Omega
3729  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3730  break;
3731  case 331: // Eta'
3732  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3733  break;
3734  case 333: // Phi
3735  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3736  break;
3737  case 3212: // Sigma
3738  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3739  break;
3740  }
3741  }
3742  }
3743  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kTRUE)){
3744  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3745  if (fDoPhotonQA > 0 && fIsMC < 2){
3746  fHistoMCConvGammaR[fiCut]->Fill(((TParticle*)fMCEvent->Particle(particle->GetFirstDaughter()))->R(),fWeightJetJetMC);
3747  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta(),fWeightJetJetMC);
3748  }
3749  } // Converted MC Gamma
3750  if(fDoMesonAnalysis){
3751 
3752  Double_t mesonY = 1.e30;
3753  Double_t ratio = 0;
3754  if (particle->Energy() != TMath::Abs(particle->Pz())){
3755  ratio = (particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz());
3756  }
3757  if( !(ratio <= 0) ){
3758  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3759  }
3760 
3761  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
3762  if ( particle->GetPdgCode() == 211 ){ // positve pions
3763  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
3764  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
3765  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
3766  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
3767  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3768  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
3769  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3770  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
3771  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),4.,fWeightJetJetMC);
3772  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
3773  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),5.,fWeightJetJetMC);
3774  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
3775  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),6.,fWeightJetJetMC);
3776  } else if ( TMath::Abs(particle->GetPdgCode()) == 223 ){ // Omega
3777  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),7.,fWeightJetJetMC);
3778  } else if ( TMath::Abs(particle->GetPdgCode()) == 333 ){ // Phi
3779  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),8.,fWeightJetJetMC);
3780  } else if ( TMath::Abs(particle->GetPdgCode()) == 113 ){ // Rho0
3781  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),9.,fWeightJetJetMC);
3782  }
3783  }
3784 
3785  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))
3786  ->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3787  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
3788  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
3789 
3790  Float_t weighted= 1;
3791  if (particle->Pt()>0.005){
3792  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
3793  // if(particle->GetPdgCode() == 221){
3794  // cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3795  // }
3796  }
3797  Double_t mesonY = 1.e30;
3798  Double_t ratio = 0;
3799  if (particle->Energy() != TMath::Abs(particle->Pz())){
3800  ratio = (particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz());
3801  }
3802  if( !(ratio <= 0) ){
3803  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3804  }
3805 
3806  Double_t alpha = -1;
3807  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
3808  alpha = TMath::Abs((daughter0->Energy() - daughter1->Energy()))/(daughter0->Energy() + daughter1->Energy());
3809  }
3810 
3811  if(particle->GetPdgCode() == 111){
3812  if(!fDoJetAnalysis || (fDoJetAnalysis && !fDoLightOutput)) fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Pi0
3813  if(fDoJetAnalysis){
3814  if(fConvJetReader->GetTrueNJets()>0){
3815  if(!fDoLightOutput) fHistoMCPi0JetEventGenerated[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc in jet event
3818  Double_t RJetPi0Cand;
3819  for(Int_t j=0; j<fConvJetReader->GetTrueNJets(); j++){
3820  Double_t DeltaEta = fTrueVectorJetEta.at(j)-particle->Eta();
3821  Double_t DeltaPhi = abs(fTrueVectorJetPhi.at(j)-particle->Phi());
3822  if(DeltaPhi > M_PI) {
3823  DeltaPhi = 2*M_PI - DeltaPhi;
3824  }
3825  RJetPi0Cand = TMath::Sqrt(pow((DeltaEta),2)+pow((DeltaPhi),2));
3826  if(fConvJetReader->Get_Jet_Radius() > 0 ){
3827  if(RJetPi0Cand < fConvJetReader->Get_Jet_Radius()){
3828  if(!fDoLightOutput) fHistoMCPi0inJetGenerated[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc in a jet
3829  else fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC);
3830  }
3831  }
3832  }
3833  fTrueVectorJetEta.clear();
3834  fTrueVectorJetPhi.clear();
3835  }
3836  }
3837  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3838  if (fIsMC > 1) fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
3839  if (fDoMesonQA > 0){
3840  if (fIsMC < 2)fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
3841  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
3842  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
3843  }
3844  } else if(particle->GetPdgCode() == 221){
3845  if(!fDoJetAnalysis || (fDoJetAnalysis && !fDoLightOutput)) fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Eta
3846  if(fDoJetAnalysis){
3847  if(fConvJetReader->GetTrueNJets()>0){
3848  if(!fDoLightOutput) fHistoMCEtaJetEventGenerated[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc in jet event
3851  Double_t RJetPi0Cand;
3852  for(Int_t j=0; j<fConvJetReader->GetTrueNJets(); j++){
3853  Double_t DeltaEta = fTrueVectorJetEta.at(j)-particle->Eta();
3854  Double_t DeltaPhi = abs(fTrueVectorJetPhi.at(j)-particle->Phi());
3855  if(DeltaPhi > M_PI) {
3856  DeltaPhi = 2*M_PI - DeltaPhi;
3857  }
3858  RJetPi0Cand = TMath::Sqrt(pow((DeltaEta),2)+pow((DeltaPhi),2));
3859  if(fConvJetReader->Get_Jet_Radius() > 0 ){
3860  if(RJetPi0Cand < fConvJetReader->Get_Jet_Radius()){
3861  if(!fDoLightOutput) fHistoMCEtainJetGenerated[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc in a jet
3862  else fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC);
3863  }
3864  }
3865  }
3866  fTrueVectorJetEta.clear();
3867  fTrueVectorJetPhi.clear();
3868  }
3869  }
3870  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3871  if (fIsMC > 1) fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
3872  if (fDoMesonQA > 0){
3873  if (fIsMC < 2)fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
3874  fHistoMCEtaPtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
3875  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
3876  }
3877  }
3878 
3879  // Check the acceptance for both gammas & whether they are counted as primaries as well
3880  Bool_t kDaughter0IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetFirstDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3881  Bool_t kDaughter1IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetLastDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3882 
3883  if( kDaughter0IsPrim && kDaughter1IsPrim &&
3884  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter0,fMCEvent,kFALSE) &&
3885  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter1,fMCEvent,kFALSE) &&
3886  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
3887  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
3888 
3889  if(particle->GetPdgCode() == 111){
3890  if(fIsMC > 1) fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 with gamma in acc NOT weighted at all
3891  fHistoMCPi0WOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Pi0 with gamma in acc NOT weighted
3892  if(!fDoJetAnalysis || (fDoJetAnalysis && !fDoLightOutput)) fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc
3893  if(fDoJetAnalysis){
3894  if(fConvJetReader->GetTrueNJets()>0){
3895  if(!fDoLightOutput) fHistoMCPi0JetInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc in jet event
3898  Double_t RJetPi0Cand;
3899  for(Int_t j=0; j<fConvJetReader->GetTrueNJets(); j++){
3900  Double_t DeltaEta = fTrueVectorJetEta.at(j)-particle->Eta();
3901  Double_t DeltaPhi = abs(fTrueVectorJetPhi.at(j)-particle->Phi());
3902  if(DeltaPhi > M_PI) {
3903  DeltaPhi = 2*M_PI - DeltaPhi;
3904  }
3905  RJetPi0Cand = TMath::Sqrt(pow((DeltaEta),2)+pow((DeltaPhi),2));
3906  if(fConvJetReader->Get_Jet_Radius() > 0 ){
3907  if(RJetPi0Cand < fConvJetReader->Get_Jet_Radius()){
3908  if(!fDoLightOutput) fHistoMCPi0inJetInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc in a jet
3909  else fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC);
3910  }
3911  }
3912  }
3913  fTrueVectorJetEta.clear();
3914  fTrueVectorJetPhi.clear();
3915  }
3916  }
3917  } else if(particle->GetPdgCode() == 221){
3918  if(fIsMC > 1) fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta with gamma in acc NOT weighted at all
3919  fHistoMCEtaWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Eta with gamma in acc NOT weighted
3920  if(!fDoJetAnalysis || (fDoJetAnalysis && !fDoLightOutput)) fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Eta with gamma in acc
3921  if(fDoJetAnalysis){
3922  if(fConvJetReader->GetTrueNJets()>0){
3923  if(!fDoLightOutput) fHistoMCEtaJetInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc in jet event
3926  Double_t RJetPi0Cand;
3927  for(Int_t j=0; j<fConvJetReader->GetTrueNJets(); j++){
3928  Double_t DeltaEta = fTrueVectorJetEta.at(j)-particle->Eta();
3929  Double_t DeltaPhi = abs(fTrueVectorJetPhi.at(j)-particle->Phi());
3930  if(DeltaPhi > M_PI) {
3931  DeltaPhi = 2*M_PI - DeltaPhi;
3932  }
3933  RJetPi0Cand = TMath::Sqrt(pow((DeltaEta),2)+pow((DeltaPhi),2));
3934  if(fConvJetReader->Get_Jet_Radius() > 0 ){
3935  if(RJetPi0Cand < fConvJetReader->Get_Jet_Radius()){
3936  if(!fDoLightOutput) fHistoMCEtainJetInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc in a jet
3937  else fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC);
3938  }
3939  }
3940  }
3941  fTrueVectorJetEta.clear();
3942  fTrueVectorJetPhi.clear();
3943  }
3944  }
3945  }
3946  }
3947  }
3948  }
3949  } else {
3950  // fill secondary histograms
3951  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
3952  if (!particle) continue;
3953 
3954  Int_t isMCFromMBHeader = -1;
3955  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3956  isMCFromMBHeader
3957  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
3958  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3959  }
3960 
3961  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)){
3962  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
3963  if (particle->GetMother(0) > -1 && fMCEvent->Particle(particle->GetMother(0))->GetMother(0) > -1) {
3964  if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
3965  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
3966  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
3967  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
3968  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
3969  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3970  } else {
3971  if ( !(TMath::Abs(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()) == 11 && fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 22) )
3972  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3973  }
3974  } else {
3975  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3976  }
3977  }
3978 
3979  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kTRUE)){
3980  if (particle->GetMother(0) > -1 && fMCEvent->Particle(particle->GetMother(0))->GetMother(0) > -1) {
3981  if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
3982  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
3983  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
3984  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
3985  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
3986  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3987  } else {
3988  if ( !(TMath::Abs(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()) == 11 &&