AliPhysics  5364b50 (5364b50)
AliAnalysisTaskGammaCalo.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: Baldo Sahlmueller, Friederike Bock *
5  * Version 1.0 *
6  * *
7  * *
8  * Permission to use, copy, modify and distribute this software and its *
9  * documentation strictly for non-commercial purposes is hereby granted *
10  * without fee, provided that the above copyright notice appears in all *
11  * copies and that both the copyright notice and this permission notice *
12  * appear in the supporting documentation. The authors make no claims *
13  * about the suitability of this software for any purpose. It is *
14  * provided "as is" without express or implied warranty. *
15  **************************************************************************/
16 
18 //----------------------------------------------------------------
19 // Class used to do analysis on conversion photons + calo photons
20 //----------------------------------------------------------------
22 #include "TChain.h"
23 #include "TTree.h"
24 #include "TBranch.h"
25 #include "TFile.h"
26 #include "TH1F.h"
27 #include "TH2F.h"
28 #include "TH3F.h"
29 #include "THnSparse.h"
30 #include "TCanvas.h"
31 #include "TNtuple.h"
32 #include "AliAnalysisTask.h"
33 #include "AliAnalysisManager.h"
34 #include "AliESDEvent.h"
35 #include "AliESDInputHandler.h"
36 #include "AliMCEventHandler.h"
37 #include "AliMCEvent.h"
38 #include "AliMCParticle.h"
39 #include "AliCentrality.h"
40 #include "AliESDVZERO.h"
41 #include "AliESDpid.h"
43 #include "AliVParticle.h"
44 #include "AliESDtrack.h"
45 #include "AliESDtrackCuts.h"
46 #include "AliKFVertex.h"
47 #include "AliV0ReaderV1.h"
48 #include "AliGenCocktailEventHeader.h"
49 #include "AliAODMCParticle.h"
50 #include "AliAODMCHeader.h"
51 #include "AliEventplane.h"
53 #include "AliAODEvent.h"
54 #include "AliAODInputHandler.h"
55 #include "AliESDEvent.h"
56 #include "AliESDInputHandler.h"
57 #include "AliInputEventHandler.h"
58 #include "AliCaloTrackMatcher.h"
59 #include <vector>
60 #include <map>
61 #include <fstream>
62 
64 
65 //________________________________________________________________________
67  fV0Reader(NULL),
68  fV0ReaderName("V0ReaderV1"),
69  fCorrTaskSetting(""),
70  fBGHandler(NULL),
71  fInputEvent(NULL),
72  fMCEvent(NULL),
73  fCutFolder(NULL),
74  fESDList(NULL),
75  fBackList(NULL),
76  fMotherList(NULL),
77  fTrueList(NULL),
78  fMCList(NULL),
79  fTreeList(NULL),
80  fClusterTreeList(NULL),
81  fOutputContainer(NULL),
82  fClusterCandidates(NULL),
83  fEventCutArray(NULL),
84  fEventCuts(NULL),
85  fClusterCutArray(NULL),
86  fCaloPhotonCuts(NULL),
87  fMesonCutArray(NULL),
88  fMesonCuts(NULL),
89  fHistoMotherInvMassPt(NULL),
90  fSparseMotherInvMassPtZM(NULL),
91  fHistoMotherBackInvMassPt(NULL),
92  fSparseMotherBackInvMassPtZM(NULL),
93  fHistoMotherInvMassPtAlpha(NULL),
94  fHistoMotherBackInvMassPtAlpha(NULL),
95  fHistoMotherPi0PtY(NULL),
96  fHistoMotherEtaPtY(NULL),
97  fHistoMotherPi0PtAlpha(NULL),
98  fHistoMotherEtaPtAlpha(NULL),
99  fHistoMotherPi0PtOpenAngle(NULL),
100  fHistoMotherEtaPtOpenAngle(NULL),
101  fHistoMotherPi0NGoodESDTracksPt(NULL),
102  fHistoMotherEtaNGoodESDTracksPt(NULL),
103  fHistoClusGammaPt(NULL),
104  fHistoClusGammaE(NULL),
105  fHistoClusOverlapHeadersGammaPt(NULL),
106  fHistoClusAllHeadersGammaPt(NULL),
107  fHistoClusRejectedHeadersGammaPt(NULL),
108  fHistoClusGammaPtM02(NULL),
109  fHistoMCHeaders(NULL),
110  fHistoMCAllGammaPt(NULL),
111  fHistoMCAllSecondaryGammaPt(NULL),
112  fHistoMCDecayGammaPi0Pt(NULL),
113  fHistoMCDecayGammaRhoPt(NULL),
114  fHistoMCDecayGammaEtaPt(NULL),
115  fHistoMCDecayGammaOmegaPt(NULL),
116  fHistoMCDecayGammaEtapPt(NULL),
117  fHistoMCDecayGammaPhiPt(NULL),
118  fHistoMCDecayGammaSigmaPt(NULL),
119  fHistoMCPi0Pt(NULL),
120  fHistoMCPi0WOWeightPt(NULL),
121  fHistoMCPi0WOEvtWeightPt(NULL),
122  fHistoMCEtaPt(NULL),
123  fHistoMCEtaWOWeightPt(NULL),
124  fHistoMCEtaWOEvtWeightPt(NULL),
125  fHistoMCPi0InAccPt(NULL),
126  fHistoMCEtaInAccPt(NULL),
127  fHistoMCPi0WOEvtWeightInAccPt(NULL),
128  fHistoMCEtaWOEvtWeightInAccPt(NULL),
129  fHistoMCPi0PtY(NULL),
130  fHistoMCEtaPtY(NULL),
131  fHistoMCPi0PtAlpha(NULL),
132  fHistoMCEtaPtAlpha(NULL),
133  fHistoMCPrimaryPtvsSource(NULL),
134  fHistoMCSecPi0PtvsSource(NULL),
135  fHistoMCSecPi0Source(NULL),
136  fHistoMCSecPi0InAccPtvsSource(NULL),
137  fHistoMCSecEtaPt(NULL),
138  fHistoMCSecEtaSource(NULL),
139  fHistoMCPi0PtJetPt(NULL),
140  fHistoMCEtaPtJetPt(NULL),
141  fHistoTruePi0InvMassPt(NULL),
142  fHistoTrueEtaInvMassPt(NULL),
143  fHistoTruePi0CaloPhotonInvMassPt(NULL),
144  fHistoTrueEtaCaloPhotonInvMassPt(NULL),
145  fHistoTruePi0CaloConvertedPhotonInvMassPt(NULL),
146  fHistoTrueEtaCaloConvertedPhotonInvMassPt(NULL),
147  fHistoTruePi0CaloMixedPhotonConvPhotonInvMassPt(NULL),
148  fHistoTrueEtaCaloMixedPhotonConvPhotonInvMassPt(NULL),
149  fHistoTruePi0CaloElectronInvMassPt(NULL),
150  fHistoTrueEtaCaloElectronInvMassPt(NULL),
151  fHistoTruePi0CaloMergedClusterInvMassPt(NULL),
152  fHistoTrueEtaCaloMergedClusterInvMassPt(NULL),
153  fHistoTruePi0CaloMergedClusterPartConvInvMassPt(NULL),
154  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt(NULL),
155  fHistoTruePi0NonMergedElectronPhotonInvMassPt(NULL),
156  fHistoTruePi0NonMergedElectronMergedPhotonInvMassPt(NULL),
157  fHistoTruePi0Category1(NULL),
158  fHistoTrueEtaCategory1(NULL),
159  fHistoTruePi0Category2(NULL),
160  fHistoTrueEtaCategory2(NULL),
161  fHistoTruePi0Category3(NULL),
162  fHistoTrueEtaCategory3(NULL),
163  fHistoTruePi0Category4_6(NULL),
164  fHistoTrueEtaCategory4_6(NULL),
165  fHistoTruePi0Category5(NULL),
166  fHistoTrueEtaCategory5(NULL),
167  fHistoTruePi0Category7(NULL),
168  fHistoTrueEtaCategory7(NULL),
169  fHistoTruePi0Category8(NULL),
170  fHistoTrueEtaCategory8(NULL),
171  fHistoTruePrimaryPi0InvMassPt(NULL),
172  fHistoTruePrimaryEtaInvMassPt(NULL),
173  fHistoTruePrimaryPi0W0WeightingInvMassPt(NULL),
174  fHistoTruePrimaryEtaW0WeightingInvMassPt(NULL),
175  fProfileTruePrimaryPi0WeightsInvMassPt(NULL),
176  fProfileTruePrimaryEtaWeightsInvMassPt(NULL),
177  fHistoTruePrimaryPi0MCPtResolPt(NULL),
178  fHistoTruePrimaryEtaMCPtResolPt(NULL),
179  fHistoTrueSecondaryPi0InvMassPt(NULL),
180  fHistoTrueSecondaryPi0FromK0sInvMassPt(NULL),
181  fHistoTrueK0sWithPi0DaughterMCPt(NULL),
182  fHistoTrueSecondaryPi0FromK0lInvMassPt(NULL),
183  fHistoTrueK0lWithPi0DaughterMCPt(NULL),
184  fHistoTrueSecondaryPi0FromEtaInvMassPt(NULL),
185  fHistoTrueEtaWithPi0DaughterMCPt(NULL),
186  fHistoTrueSecondaryPi0FromLambdaInvMassPt(NULL),
187  fHistoTrueLambdaWithPi0DaughterMCPt(NULL),
188  fHistoTrueBckGGInvMassPt(NULL),
189  fHistoTrueBckFullMesonContainedInOneClusterInvMassPt(NULL),
190  fHistoTrueBckAsymEClustersInvMassPt(NULL),
191  fHistoTrueBckContInvMassPt(NULL),
192  fHistoTruePi0PtY(NULL),
193  fHistoTrueEtaPtY(NULL),
194  fHistoTruePi0PtAlpha(NULL),
195  fHistoTrueEtaPtAlpha(NULL),
196  fHistoTruePi0PtOpenAngle(NULL),
197  fHistoTrueEtaPtOpenAngle(NULL),
198  fHistoClusPhotonBGPt(NULL),
199  fHistoClusPhotonPlusConvBGPt(NULL),
200  fHistoClustPhotonElectronBGPtM02(NULL),
201  fHistoClustPhotonPionBGPtM02(NULL),
202  fHistoClustPhotonKaonBGPtM02(NULL),
203  fHistoClustPhotonK0lBGPtM02(NULL),
204  fHistoClustPhotonNeutronBGPtM02(NULL),
205  fHistoClustPhotonRestBGPtM02(NULL),
206  fHistoClustPhotonPlusConvElectronBGPtM02(NULL),
207  fHistoClustPhotonPlusConvPionBGPtM02(NULL),
208  fHistoClustPhotonPlusConvKaonBGPtM02(NULL),
209  fHistoClustPhotonPlusConvK0lBGPtM02(NULL),
210  fHistoClustPhotonPlusConvNeutronBGPtM02(NULL),
211  fHistoClustPhotonPlusConvRestBGPtM02(NULL),
212  fHistoTrueClusGammaPt(NULL),
213  fHistoTrueClusUnConvGammaPt(NULL),
214  fHistoTrueClusUnConvGammaMCPt(NULL),
215  fHistoTrueClusGammaPtM02(NULL),
216  fHistoTrueClusUnConvGammaPtM02(NULL),
217  fHistoTrueClusElectronPt(NULL),
218  fHistoTrueClusConvGammaPt(NULL),
219  fHistoTrueClusConvGammaMCPt(NULL),
220  fHistoTrueClusConvGammaFullyPt(NULL),
221  fHistoTrueClusMergedGammaPt(NULL),
222  fHistoTrueClusMergedPartConvGammaPt(NULL),
223  fHistoTrueClusDalitzPt(NULL),
224  fHistoTrueClusDalitzMergedPt(NULL),
225  fHistoTrueClusPhotonFromElecMotherPt(NULL),
226  fHistoTrueClusShowerPt(NULL),
227  fHistoTrueClusSubLeadingPt(NULL),
228  fHistoTrueClusNParticles(NULL),
229  fHistoTrueClusEMNonLeadingPt(NULL),
230  fHistoTrueNLabelsInClus(NULL),
231  fHistoTruePrimaryClusGammaPt(NULL),
232  fHistoTruePrimaryClusGammaESDPtMCPt(NULL),
233  fHistoTruePrimaryClusConvGammaPt(NULL),
234  fHistoTruePrimaryClusConvGammaESDPtMCPt(NULL),
235  fHistoTrueSecondaryClusGammaPt(NULL),
236  fHistoTrueSecondaryClusConvGammaPt(NULL),
237  fHistoTrueSecondaryClusGammaMCPt(NULL),
238  fHistoTrueSecondaryClusConvGammaMCPt(NULL),
239  fHistoTrueSecondaryClusGammaFromXFromK0sMCPtESDPt(NULL),
240  fHistoTrueSecondaryClusConvGammaFromXFromK0sMCPtESDPt(NULL),
241  fHistoTrueSecondaryClusGammaFromXFromK0lMCPtESDPt(NULL),
242  fHistoTrueSecondaryClusConvGammaFromXFromK0lMCPtESDPt(NULL),
243  fHistoTrueSecondaryClusGammaFromXFromLambdaMCPtESDPt(NULL),
244  fHistoTrueSecondaryClusConvGammaFromXFromLambdaMCPtESDPt(NULL),
245  fHistoDoubleCountTruePi0InvMassPt(NULL),
246  fHistoDoubleCountTrueEtaInvMassPt(NULL),
247  fHistoDoubleCountTrueClusterGammaPt(NULL),
248  fVectorDoubleCountTruePi0s(0),
249  fVectorDoubleCountTrueEtas(0),
250  fVectorDoubleCountTrueClusterGammas(0),
251  fHistoMultipleCountTrueClusterGamma(NULL),
252  fMapMultipleCountTrueClusterGammas(),
253  fHistoTruePi0InvMassPtAlpha(NULL),
254  fHistoTruePi0PureGammaInvMassPtAlpha(NULL),
255  fHistCellIDvsClusterEnergy(NULL),
256  fHistCellIDvsClusterEnergyMax(NULL),
257  fHistoNEvents(NULL),
258  fHistoNEventsWOWeight(NULL),
259  fHistoNGoodESDTracks(NULL),
260  fHistoVertexZ(NULL),
261  fHistoNGammaCandidates(NULL),
262  fHistoNGammaCandidatesBasic(NULL),
263  fHistoNGoodESDTracksVsNGammaCandidates(NULL),
264  fHistoSPDClusterTrackletBackground(NULL),
265  fHistoNV0Tracks(NULL),
266  fProfileEtaShift(NULL),
267  fProfileJetJetXSection(NULL),
268  fHistoJetJetNTrials(NULL),
269  tTrueInvMassROpenABPtFlag(NULL),
270  fInvMass(-1),
271  fRconv(-1),
272  fOpenRPrim(-1),
273  fInvMassRTOF(-1),
274  fPt(-1),
275  iFlag(3),
276  tSigInvMassPtAlphaTheta(NULL),
277  tBckInvMassPtAlphaTheta(NULL),
278  fInvMassTreeInvMass(0),
279  fInvMassTreePt(0),
280  fInvMassTreeAlpha(0),
281  fInvMassTreeTheta(0),
282  fInvMassTreeMixPool(0),
283  fInvMassTreeZVertex(0),
284  fInvMassTreeEta(0),
285  tClusterEOverP(NULL),
286  fClusterE(0),
287  fClusterM02(0),
288  fClusterM20(0),
289  fClusterEP(0),
290  fClusterLeadCellID(0),
291  fClusterClassification(0),
292  fDeltaEta(0),
293  fDeltaPhi(0),
294  fTrackPt(0),
295  fTrackPID_e(0),
296  fTrackPID_Pi(0),
297  fTrackPID_K(0),
298  fTrackPID_P(0),
299  fClusterIsoSumClusterEt(0),
300  fClusterIsoSumTrackEt(0),
301 // fHistoTruePi0NonLinearity(NULL),
302 // fHistoTrueEtaNonLinearity(NULL),
303  fEventPlaneAngle(-100),
304  fRandom(0),
305  fnCuts(0),
306  fiCut(0),
307  fIsHeavyIon(0),
308  fDoLightOutput(kFALSE),
309  fDoMesonAnalysis(kTRUE),
310  fDoMesonQA(0),
311  fDoClusterQA(0),
312  fIsFromDesiredHeader(kTRUE),
313  fIsOverlappingWithOtherHeader(kFALSE),
314  fIsMC(0),
315  fDoTHnSparse(kTRUE),
316  fSetPlotHistsExtQA(kFALSE),
317  fWeightJetJetMC(1),
318  fDoInOutTimingCluster(kFALSE),
319  fMinTimingCluster(0),
320  fMaxTimingCluster(0),
321  fEnableSortForClusMC(kFALSE),
322  fProduceCellIDPlots(kFALSE),
323  fProduceTreeEOverP(kFALSE),
324  tBrokenFiles(NULL),
325  fFileNameBroken(NULL),
326  tClusterQATree(NULL),
327  fCloseHighPtClusters(NULL),
328  fLocalDebugFlag(0),
329  fAllowOverlapHeaders(kTRUE),
330  fNCurrentClusterBasic(0)
331 {
332 
333 }
334 
335 //________________________________________________________________________
337  AliAnalysisTaskSE(name),
338  fV0Reader(NULL),
339  fV0ReaderName("V0ReaderV1"),
340  fCorrTaskSetting(""),
341  fBGHandler(NULL),
342  fInputEvent(NULL),
343  fMCEvent(NULL),
344  fCutFolder(NULL),
345  fESDList(NULL),
346  fBackList(NULL),
347  fMotherList(NULL),
348  fTrueList(NULL),
349  fMCList(NULL),
350  fTreeList(NULL),
351  fClusterTreeList(NULL),
352  fOutputContainer(0),
353  fClusterCandidates(NULL),
354  fEventCutArray(NULL),
355  fEventCuts(NULL),
356  fClusterCutArray(NULL),
357  fCaloPhotonCuts(NULL),
358  fMesonCutArray(NULL),
359  fMesonCuts(NULL),
360  fHistoMotherInvMassPt(NULL),
361  fSparseMotherInvMassPtZM(NULL),
362  fHistoMotherBackInvMassPt(NULL),
363  fSparseMotherBackInvMassPtZM(NULL),
364  fHistoMotherInvMassPtAlpha(NULL),
365  fHistoMotherBackInvMassPtAlpha(NULL),
366  fHistoMotherPi0PtY(NULL),
367  fHistoMotherEtaPtY(NULL),
368  fHistoMotherPi0PtAlpha(NULL),
369  fHistoMotherEtaPtAlpha(NULL),
370  fHistoMotherPi0PtOpenAngle(NULL),
371  fHistoMotherEtaPtOpenAngle(NULL),
372  fHistoMotherPi0NGoodESDTracksPt(NULL),
373  fHistoMotherEtaNGoodESDTracksPt(NULL),
374  fHistoClusGammaPt(NULL),
375  fHistoClusGammaE(NULL),
376  fHistoClusOverlapHeadersGammaPt(NULL),
377  fHistoClusAllHeadersGammaPt(NULL),
378  fHistoClusRejectedHeadersGammaPt(NULL),
379  fHistoClusGammaPtM02(NULL),
380  fHistoMCHeaders(NULL),
381  fHistoMCAllGammaPt(NULL),
382  fHistoMCAllSecondaryGammaPt(NULL),
383  fHistoMCDecayGammaPi0Pt(NULL),
384  fHistoMCDecayGammaRhoPt(NULL),
385  fHistoMCDecayGammaEtaPt(NULL),
386  fHistoMCDecayGammaOmegaPt(NULL),
387  fHistoMCDecayGammaEtapPt(NULL),
388  fHistoMCDecayGammaPhiPt(NULL),
389  fHistoMCDecayGammaSigmaPt(NULL),
390  fHistoMCPi0Pt(NULL),
391  fHistoMCPi0WOWeightPt(NULL),
392  fHistoMCPi0WOEvtWeightPt(NULL),
393  fHistoMCEtaPt(NULL),
394  fHistoMCEtaWOWeightPt(NULL),
395  fHistoMCEtaWOEvtWeightPt(NULL),
396  fHistoMCPi0InAccPt(NULL),
397  fHistoMCEtaInAccPt(NULL),
398  fHistoMCPi0WOEvtWeightInAccPt(NULL),
399  fHistoMCEtaWOEvtWeightInAccPt(NULL),
400  fHistoMCPi0PtY(NULL),
401  fHistoMCEtaPtY(NULL),
402  fHistoMCPi0PtAlpha(NULL),
403  fHistoMCEtaPtAlpha(NULL),
404  fHistoMCPrimaryPtvsSource(NULL),
405  fHistoMCSecPi0PtvsSource(NULL),
406  fHistoMCSecPi0Source(NULL),
407  fHistoMCSecPi0InAccPtvsSource(NULL),
408  fHistoMCSecEtaPt(NULL),
409  fHistoMCSecEtaSource(NULL),
410  fHistoMCPi0PtJetPt(NULL),
411  fHistoMCEtaPtJetPt(NULL),
412  fHistoTruePi0InvMassPt(NULL),
413  fHistoTrueEtaInvMassPt(NULL),
414  fHistoTruePi0CaloPhotonInvMassPt(NULL),
415  fHistoTrueEtaCaloPhotonInvMassPt(NULL),
416  fHistoTruePi0CaloConvertedPhotonInvMassPt(NULL),
417  fHistoTrueEtaCaloConvertedPhotonInvMassPt(NULL),
418  fHistoTruePi0CaloMixedPhotonConvPhotonInvMassPt(NULL),
419  fHistoTrueEtaCaloMixedPhotonConvPhotonInvMassPt(NULL),
420  fHistoTruePi0CaloElectronInvMassPt(NULL),
421  fHistoTrueEtaCaloElectronInvMassPt(NULL),
422  fHistoTruePi0CaloMergedClusterInvMassPt(NULL),
423  fHistoTrueEtaCaloMergedClusterInvMassPt(NULL),
424  fHistoTruePi0CaloMergedClusterPartConvInvMassPt(NULL),
425  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt(NULL),
426  fHistoTruePi0NonMergedElectronPhotonInvMassPt(NULL),
427  fHistoTruePi0NonMergedElectronMergedPhotonInvMassPt(NULL),
428  fHistoTruePi0Category1(NULL),
429  fHistoTrueEtaCategory1(NULL),
430  fHistoTruePi0Category2(NULL),
431  fHistoTrueEtaCategory2(NULL),
432  fHistoTruePi0Category3(NULL),
433  fHistoTrueEtaCategory3(NULL),
434  fHistoTruePi0Category4_6(NULL),
435  fHistoTrueEtaCategory4_6(NULL),
436  fHistoTruePi0Category5(NULL),
437  fHistoTrueEtaCategory5(NULL),
438  fHistoTruePi0Category7(NULL),
439  fHistoTrueEtaCategory7(NULL),
440  fHistoTruePi0Category8(NULL),
441  fHistoTrueEtaCategory8(NULL),
442  fHistoTruePrimaryPi0InvMassPt(NULL),
443  fHistoTruePrimaryEtaInvMassPt(NULL),
444  fHistoTruePrimaryPi0W0WeightingInvMassPt(NULL),
445  fHistoTruePrimaryEtaW0WeightingInvMassPt(NULL),
446  fProfileTruePrimaryPi0WeightsInvMassPt(NULL),
447  fProfileTruePrimaryEtaWeightsInvMassPt(NULL),
448  fHistoTruePrimaryPi0MCPtResolPt(NULL),
449  fHistoTruePrimaryEtaMCPtResolPt(NULL),
450  fHistoTrueSecondaryPi0InvMassPt(NULL),
451  fHistoTrueSecondaryPi0FromK0sInvMassPt(NULL),
452  fHistoTrueK0sWithPi0DaughterMCPt(NULL),
453  fHistoTrueSecondaryPi0FromK0lInvMassPt(NULL),
454  fHistoTrueK0lWithPi0DaughterMCPt(NULL),
455  fHistoTrueSecondaryPi0FromEtaInvMassPt(NULL),
456  fHistoTrueEtaWithPi0DaughterMCPt(NULL),
457  fHistoTrueSecondaryPi0FromLambdaInvMassPt(NULL),
458  fHistoTrueLambdaWithPi0DaughterMCPt(NULL),
459  fHistoTrueBckGGInvMassPt(NULL),
460  fHistoTrueBckFullMesonContainedInOneClusterInvMassPt(NULL),
461  fHistoTrueBckAsymEClustersInvMassPt(NULL),
462  fHistoTrueBckContInvMassPt(NULL),
463  fHistoTruePi0PtY(NULL),
464  fHistoTrueEtaPtY(NULL),
465  fHistoTruePi0PtAlpha(NULL),
466  fHistoTrueEtaPtAlpha(NULL),
467  fHistoTruePi0PtOpenAngle(NULL),
468  fHistoTrueEtaPtOpenAngle(NULL),
469  fHistoClusPhotonBGPt(NULL),
470  fHistoClusPhotonPlusConvBGPt(NULL),
471  fHistoClustPhotonElectronBGPtM02(NULL),
472  fHistoClustPhotonPionBGPtM02(NULL),
473  fHistoClustPhotonKaonBGPtM02(NULL),
474  fHistoClustPhotonK0lBGPtM02(NULL),
475  fHistoClustPhotonNeutronBGPtM02(NULL),
476  fHistoClustPhotonRestBGPtM02(NULL),
477  fHistoClustPhotonPlusConvElectronBGPtM02(NULL),
478  fHistoClustPhotonPlusConvPionBGPtM02(NULL),
479  fHistoClustPhotonPlusConvKaonBGPtM02(NULL),
480  fHistoClustPhotonPlusConvK0lBGPtM02(NULL),
481  fHistoClustPhotonPlusConvNeutronBGPtM02(NULL),
482  fHistoClustPhotonPlusConvRestBGPtM02(NULL),
483  fHistoTrueClusGammaPt(NULL),
484  fHistoTrueClusUnConvGammaPt(NULL),
485  fHistoTrueClusUnConvGammaMCPt(NULL),
486  fHistoTrueClusGammaPtM02(NULL),
487  fHistoTrueClusUnConvGammaPtM02(NULL),
488  fHistoTrueClusElectronPt(NULL),
489  fHistoTrueClusConvGammaPt(NULL),
490  fHistoTrueClusConvGammaMCPt(NULL),
491  fHistoTrueClusConvGammaFullyPt(NULL),
492  fHistoTrueClusMergedGammaPt(NULL),
493  fHistoTrueClusMergedPartConvGammaPt(NULL),
494  fHistoTrueClusDalitzPt(NULL),
495  fHistoTrueClusDalitzMergedPt(NULL),
496  fHistoTrueClusPhotonFromElecMotherPt(NULL),
497  fHistoTrueClusShowerPt(NULL),
498  fHistoTrueClusSubLeadingPt(NULL),
499  fHistoTrueClusNParticles(NULL),
500  fHistoTrueClusEMNonLeadingPt(NULL),
501  fHistoTrueNLabelsInClus(NULL),
502  fHistoTruePrimaryClusGammaPt(NULL),
503  fHistoTruePrimaryClusGammaESDPtMCPt(NULL),
504  fHistoTruePrimaryClusConvGammaPt(NULL),
505  fHistoTruePrimaryClusConvGammaESDPtMCPt(NULL),
506  fHistoTrueSecondaryClusGammaPt(NULL),
507  fHistoTrueSecondaryClusConvGammaPt(NULL),
508  fHistoTrueSecondaryClusGammaMCPt(NULL),
509  fHistoTrueSecondaryClusConvGammaMCPt(NULL),
510  fHistoTrueSecondaryClusGammaFromXFromK0sMCPtESDPt(NULL),
511  fHistoTrueSecondaryClusConvGammaFromXFromK0sMCPtESDPt(NULL),
512  fHistoTrueSecondaryClusGammaFromXFromK0lMCPtESDPt(NULL),
513  fHistoTrueSecondaryClusConvGammaFromXFromK0lMCPtESDPt(NULL),
514  fHistoTrueSecondaryClusGammaFromXFromLambdaMCPtESDPt(NULL),
515  fHistoTrueSecondaryClusConvGammaFromXFromLambdaMCPtESDPt(NULL),
516  fHistoDoubleCountTruePi0InvMassPt(NULL),
517  fHistoDoubleCountTrueEtaInvMassPt(NULL),
518  fHistoDoubleCountTrueClusterGammaPt(NULL),
519  fVectorDoubleCountTruePi0s(0),
520  fVectorDoubleCountTrueEtas(0),
521  fVectorDoubleCountTrueClusterGammas(0),
522  fHistoMultipleCountTrueClusterGamma(NULL),
523  fMapMultipleCountTrueClusterGammas(),
524  fHistoTruePi0InvMassPtAlpha(NULL),
525  fHistoTruePi0PureGammaInvMassPtAlpha(NULL),
526  fHistCellIDvsClusterEnergy(NULL),
527  fHistCellIDvsClusterEnergyMax(NULL),
528  fHistoNEvents(NULL),
529  fHistoNEventsWOWeight(NULL),
530  fHistoNGoodESDTracks(NULL),
531  fHistoVertexZ(NULL),
532  fHistoNGammaCandidates(NULL),
533  fHistoNGammaCandidatesBasic(NULL),
534  fHistoNGoodESDTracksVsNGammaCandidates(NULL),
535  fHistoSPDClusterTrackletBackground(NULL),
536  fHistoNV0Tracks(NULL),
537  fProfileEtaShift(NULL),
538  fProfileJetJetXSection(NULL),
539  fHistoJetJetNTrials(NULL),
540  tTrueInvMassROpenABPtFlag(NULL),
541  fInvMass(-1),
542  fRconv(-1),
543  fOpenRPrim(-1),
544  fInvMassRTOF(-1),
545  fPt(-1),
546  iFlag(3),
547  tSigInvMassPtAlphaTheta(NULL),
548  tBckInvMassPtAlphaTheta(NULL),
549  fInvMassTreeInvMass(0),
550  fInvMassTreePt(0),
551  fInvMassTreeAlpha(0),
552  fInvMassTreeTheta(0),
553  fInvMassTreeMixPool(0),
554  fInvMassTreeZVertex(0),
555  fInvMassTreeEta(0),
556  tClusterEOverP(NULL),
557  fClusterE(0),
558  fClusterM02(0),
559  fClusterM20(0),
560  fClusterEP(0),
561  fClusterLeadCellID(0),
562  fClusterClassification(0),
563  fDeltaEta(0),
564  fDeltaPhi(0),
565  fTrackPt(0),
566  fTrackPID_e(0),
567  fTrackPID_Pi(0),
568  fTrackPID_K(0),
569  fTrackPID_P(0),
570  fClusterIsoSumClusterEt(0),
571  fClusterIsoSumTrackEt(0),
572 // fHistoTruePi0NonLinearity(NULL),
573 // fHistoTrueEtaNonLinearity(NULL),
574  fEventPlaneAngle(-100),
575  fRandom(0),
576  fnCuts(0),
577  fiCut(0),
578  fIsHeavyIon(0),
579  fDoLightOutput(kFALSE),
580  fDoMesonAnalysis(kTRUE),
581  fDoMesonQA(0),
582  fDoClusterQA(0),
583  fIsFromDesiredHeader(kTRUE),
584  fIsOverlappingWithOtherHeader(kFALSE),
585  fIsMC(0),
586  fDoTHnSparse(kTRUE),
587  fSetPlotHistsExtQA(kFALSE),
588  fWeightJetJetMC(1),
589  fDoInOutTimingCluster(kFALSE),
590  fMinTimingCluster(0),
591  fMaxTimingCluster(0),
592  fEnableSortForClusMC(kFALSE),
593  fProduceCellIDPlots(kFALSE),
594  fProduceTreeEOverP(kFALSE),
595  tBrokenFiles(NULL),
596  fFileNameBroken(NULL),
597  tClusterQATree(NULL),
598  fCloseHighPtClusters(NULL),
599  fLocalDebugFlag(0),
600  fAllowOverlapHeaders(kTRUE),
601  fNCurrentClusterBasic(0)
602 {
603  // Define output slots here
604  DefineOutput(1, TList::Class());
605 }
606 
608 {
609  if(fClusterCandidates){
610  delete fClusterCandidates;
611  fClusterCandidates = 0x0;
612  }
613  if(fBGHandler){
614  delete[] fBGHandler;
615  fBGHandler = 0x0;
616  }
617 }
618 //___________________________________________________________
620 
621  const Int_t nDim = 4;
622  Int_t nBins[nDim] = {800,350,7,6};
623  Double_t xMin[nDim] = {0,0, 0,0};
624  Double_t xMax[nDim] = {0.8,35,7,6};
625 
626  if(fDoTHnSparse){
627  fSparseMotherInvMassPtZM = new THnSparseF*[fnCuts];
628  fSparseMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
629  }
630 
632 
633 
634  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
635  if (((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
636  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
637  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
638  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
639 
640  Int_t collisionSystem = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(0,1));
641  Int_t centMin = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(1,1));
642  Int_t centMax = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(2,1));
643 
644  if(collisionSystem == 1 || collisionSystem == 2 ||
645  collisionSystem == 5 || collisionSystem == 8 ||
646  collisionSystem == 9){
647  centMin = centMin*10;
648  centMax = centMax*10;
649  if(centMax ==0 && centMax!=centMin) centMax=100;
650  } else if(collisionSystem == 3 || collisionSystem == 6){
651  centMin = centMin*5;
652  centMax = centMax*5;
653  } else if(collisionSystem == 4 || collisionSystem == 7){
654  centMin = ((centMin*5)+45);
655  centMax = ((centMax*5)+45);
656  }
657 
658  if(fDoTHnSparse){
659  fBackList[iCut] = new TList();
660  fBackList[iCut]->SetName(Form("%s_%s_%s Back histograms",cutstringEvent.Data(),cutstringCalo.Data(), cutstringMeson.Data()));
661  fBackList[iCut]->SetOwner(kTRUE);
662  fCutFolder[iCut]->Add(fBackList[iCut]);
663 
664  fSparseMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_m","Back_Back_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
665  fBackList[iCut]->Add(fSparseMotherBackInvMassPtZM[iCut]);
666 
667  fMotherList[iCut] = new TList();
668  fMotherList[iCut]->SetName(Form("%s_%s_%s Mother histograms",cutstringEvent.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
669  fMotherList[iCut]->SetOwner(kTRUE);
670  fCutFolder[iCut]->Add(fMotherList[iCut]);
671 
672  fSparseMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_m","Back_Mother_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
673  fMotherList[iCut]->Add(fSparseMotherInvMassPtZM[iCut]);
674  }
675 
676  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
678  collisionSystem,centMin,centMax,
679  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents(),
680  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseTrackMultiplicity(),
681  4,8,7);
682  }
683  }
684  }
685 }
686 //________________________________________________________________________
688 
689  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
690  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
691 
692  if (fDoClusterQA == 2) fProduceCellIDPlots = kTRUE;
693  if (fIsMC == 2){
694  fDoTHnSparse = kFALSE;
695  } else if (fIsMC == 3){
696  fDoTHnSparse = kFALSE;
697  }
698 
699  // set common binning in pT for mesons and photons
700  Int_t nBinsPt = 250;
701  Float_t minPt = 0;
702  Float_t maxPt = 25;
703  Int_t nBinsQAPt = 200;
704  Float_t minQAPt = 0.4;
705  Float_t maxQAPt = 25;
706  Int_t nBinsClusterPt = 500;
707  Float_t minClusterPt = 0;
708  Float_t maxClusterPt = 50;
709  if (((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k8TeV ){
710  nBinsPt = 400;
711  minPt = 0;
712  maxPt = 40;
713  nBinsQAPt = 300;
714  minQAPt = 0.4;
715  maxQAPt = 40;
716  nBinsClusterPt = 800;
717  minClusterPt = 0;
718  maxClusterPt = 80;
719  } else if ( ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k13TeV ||
723  nBinsPt = 600;
724  minPt = 0;
725  maxPt = 60;
726  nBinsQAPt = 400;
727  minQAPt = 0.4;
728  maxQAPt = 60;
729  nBinsClusterPt = 1000;
730  minClusterPt = 0;
731  maxClusterPt = 100;
732  }
733 
734  // Create histograms
735  if(fOutputContainer != NULL){
736  delete fOutputContainer;
737  fOutputContainer = NULL;
738  }
739  if(fOutputContainer == NULL){
740  fOutputContainer = new TList();
741  fOutputContainer->SetOwner(kTRUE);
742  }
743 
744  // Array of current cut's gammas
745  fClusterCandidates = new TList();
746  fClusterCandidates->SetOwner(kTRUE);
747 
748  fCutFolder = new TList*[fnCuts];
749  fESDList = new TList*[fnCuts];
750  if(fDoTHnSparse){
751  fBackList = new TList*[fnCuts];
752  fMotherList = new TList*[fnCuts];
753  }
754  fHistoNEvents = new TH1F*[fnCuts];
755  if(fIsMC > 1){
756  fHistoNEventsWOWeight = new TH1F*[fnCuts];
757  }
758  if(fIsMC == 2){
759  fProfileJetJetXSection = new TProfile*[fnCuts];
760  fHistoJetJetNTrials = new TH1F*[fnCuts];
761  }
762 
763  fHistoNGoodESDTracks = new TH1F*[fnCuts];
764  fHistoVertexZ = new TH1F*[fnCuts];
765  fHistoNGammaCandidates = new TH1F*[fnCuts];
766  fHistoNGammaCandidatesBasic = new TH1F*[fnCuts];
767  if(!fDoLightOutput){
770  fHistoNV0Tracks = new TH1F*[fnCuts];
771  }
772  if(fIsHeavyIon==2) fProfileEtaShift = new TProfile*[fnCuts];
773 
774  if(fDoMesonAnalysis){
777  if(!fDoLightOutput){
780  }
781  if (fDoMesonQA > 0 && fDoMesonQA < 3){
790  }
791  }
792 
796  }
797 
798  fHistoClusGammaPt = new TH1F*[fnCuts];
799  fHistoClusGammaE = new TH1F*[fnCuts];
801  fHistoClusAllHeadersGammaPt = new TH1F*[fnCuts];
803  if(!fDoLightOutput && fDoClusterQA > 0)
805 
806  if (fDoMesonQA == 4 && fIsMC == 0){
807  fTreeList = new TList*[fnCuts];
810  }
811 
812  if (fProduceTreeEOverP){
813  fClusterTreeList = new TList*[fnCuts];
814  tClusterEOverP = new TTree*[fnCuts];
815  }
816 
817  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
818  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
819  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
820  TString cutstringMeson = "NoMesonCut";
821  if(fDoMesonAnalysis)
822  cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
823 
824  fCutFolder[iCut] = new TList();
825  fCutFolder[iCut]->SetName(Form("Cut Number %s_%s_%s",cutstringEvent.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
826  fCutFolder[iCut]->SetOwner(kTRUE);
827  fOutputContainer->Add(fCutFolder[iCut]);
828  fESDList[iCut] = new TList();
829  fESDList[iCut]->SetName(Form("%s_%s_%s ESD histograms",cutstringEvent.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
830  fESDList[iCut]->SetOwner(kTRUE);
831  fCutFolder[iCut]->Add(fESDList[iCut]);
832 
833  fHistoNEvents[iCut] = new TH1F("NEvents","NEvents",14,-0.5,13.5);
834  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
835  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
836  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
837  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
838  TString TriggerNames = "Not Trigger: ";
839  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
840  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
841  } else {
842  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
843  }
844  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
845  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
846  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(7,"SPD Pile-Up");
847  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
848  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
849  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problems");
850  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
851  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
852  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
853  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
854  fESDList[iCut]->Add(fHistoNEvents[iCut]);
855 
856  if (fIsMC > 1){
857  fHistoNEventsWOWeight[iCut] = new TH1F("NEventsWOWeight","NEventsWOWeight",14,-0.5,13.5);
858  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
859  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
860  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
861  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
862  TString TriggerNames = "Not Trigger: ";
863  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
864  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
865  } else {
866  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
867  }
868  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
869  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
870  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
871  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
872  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
873  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
874  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
875  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
876  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
877  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
878  fESDList[iCut]->Add(fHistoNEventsWOWeight[iCut]);
879  }
880  if (fIsMC == 2){
881  fProfileJetJetXSection[iCut] = new TProfile("XSection","XSection",1,-0.5,0.5);
882  fESDList[iCut]->Add(fProfileJetJetXSection[iCut]);
883  fHistoJetJetNTrials[iCut] = new TH1F("NTrials","#sum{NTrials}",1,0,1);
884  fHistoJetJetNTrials[iCut]->GetXaxis()->SetBinLabel(1,"#sum{NTrials}");
885  fESDList[iCut]->Add(fHistoJetJetNTrials[iCut]);
886  }
887 
888  if(fIsHeavyIon == 1)
889  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks","GoodESDTracks",4000,0,4000);
890  else if(fIsHeavyIon == 2)
891  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks","GoodESDTracks",400,0,400);
892  else
893  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks","GoodESDTracks",200,0,200);
894  fHistoNGoodESDTracks[iCut]->GetXaxis()->SetTitle("#primary tracks");
895  fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
896 
897  fHistoVertexZ[iCut] = new TH1F("VertexZ","VertexZ",1000,-50,50);
898  fHistoVertexZ[iCut]->GetXaxis()->SetTitle("Z_{vtx} (cm)");
899  fESDList[iCut]->Add(fHistoVertexZ[iCut]);
900 
901  if(fIsHeavyIon == 1)
902  fHistoNGammaCandidatesBasic[iCut] = new TH1F("GammaCandidatesBasic","GammaCandidatesBasic",600,0,600);
903  else if(fIsHeavyIon == 2)
904  fHistoNGammaCandidatesBasic[iCut] = new TH1F("GammaCandidatesBasic","GammaCandidatesBasic",400,0,400);
905  else
906  fHistoNGammaCandidatesBasic[iCut] = new TH1F("GammaCandidatesBasic","GammaCandidatesBasic",100,0,100);
907  fHistoNGammaCandidatesBasic[iCut]->GetXaxis()->SetTitle("#cluster candidates basic");
908  fESDList[iCut]->Add(fHistoNGammaCandidatesBasic[iCut]);
909 
910 
911  if(fIsHeavyIon == 1)
912  fHistoNGammaCandidates[iCut] = new TH1F("GammaCandidates","GammaCandidates",600,0,600);
913  else if(fIsHeavyIon == 2)
914  fHistoNGammaCandidates[iCut] = new TH1F("GammaCandidates","GammaCandidates",400,0,400);
915  else
916  fHistoNGammaCandidates[iCut] = new TH1F("GammaCandidates","GammaCandidates",100,0,100);
917  fHistoNGammaCandidates[iCut]->GetXaxis()->SetTitle("#cluster candidates with current cut");
918  fESDList[iCut]->Add(fHistoNGammaCandidates[iCut]);
919 
920  if(!fDoLightOutput){
921  if(fIsHeavyIon == 1)
922  fHistoNGoodESDTracksVsNGammaCandidates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",4000,0,4000,600,0,600);
923  else if(fIsHeavyIon == 2)
924  fHistoNGoodESDTracksVsNGammaCandidates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",400,0,400,400,0,400);
925  else
926  fHistoNGoodESDTracksVsNGammaCandidates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",200,0,200,100,0,100);
928 
929  fHistoSPDClusterTrackletBackground[iCut] = new TH2F("SPD tracklets vs SPD clusters","SPD tracklets vs SPD clusters",100,0,200,250,0,1000);
931 
932  if(fIsHeavyIon == 1)
933  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity","V0 Multiplicity",30000,0,30000);
934  else if(fIsHeavyIon == 2)
935  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity","V0 Multiplicity",2500,0,2500);
936  else
937  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity","V0 Multiplicity",1500,0,1500);
938  fESDList[iCut]->Add(fHistoNV0Tracks[iCut]);
939  }
940 
941  if(fIsHeavyIon==2) {
942  fProfileEtaShift[iCut] = new TProfile("Eta Shift","Eta Shift",1, -0.5,0.5);
943  fESDList[iCut]->Add(fProfileEtaShift[iCut]);
944  }
945 
946  if (fIsMC > 1){
947  fHistoNEvents[iCut]->Sumw2();
948  fHistoNGoodESDTracks[iCut]->Sumw2();
949  fHistoVertexZ[iCut]->Sumw2();
950  fHistoNGammaCandidates[iCut]->Sumw2();
951  fHistoNGammaCandidatesBasic[iCut]->Sumw2();
952  if(!fDoLightOutput){
954  fHistoSPDClusterTrackletBackground[iCut]->Sumw2();
955  fHistoNV0Tracks[iCut]->Sumw2();
956  }
957  if(fIsHeavyIon==2) fProfileEtaShift[iCut]->Sumw2();
958  }
959 
960  fHistoClusGammaPt[iCut] = new TH1F("ClusGamma_Pt","ClusGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
961  fESDList[iCut]->Add(fHistoClusGammaPt[iCut]);
962  fHistoClusGammaE[iCut] = new TH1F("ClusGamma_E","ClusGamma_E",nBinsClusterPt, minClusterPt, maxClusterPt);
963  fESDList[iCut]->Add(fHistoClusGammaE[iCut]);
964  fHistoClusOverlapHeadersGammaPt[iCut] = new TH1F("ClusGammaOverlapHeaders_Pt","ClusGammaOverlapHeaders_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
965  fHistoClusOverlapHeadersGammaPt[iCut]->SetXTitle("p_{T,clus}(GeV/c), selected header w/ overlap");
966  fESDList[iCut]->Add(fHistoClusOverlapHeadersGammaPt[iCut]);
967  fHistoClusAllHeadersGammaPt[iCut] = new TH1F("ClusGammaAllHeaders_Pt","ClusGammaAllHeaders_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
968  fHistoClusAllHeadersGammaPt[iCut]->SetXTitle("p_{T,clus}(GeV/c), all headers");
969  fESDList[iCut]->Add(fHistoClusAllHeadersGammaPt[iCut]);
970  fHistoClusRejectedHeadersGammaPt[iCut] = new TH1F("ClusGammaRejectedHeaders_Pt","ClusGammaRejectedHeaders_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
971  fHistoClusRejectedHeadersGammaPt[iCut]->SetXTitle("p_{T,clus}(GeV/c), rejected headers");
972  fESDList[iCut]->Add(fHistoClusRejectedHeadersGammaPt[iCut]);
973  if(!fDoLightOutput && fDoClusterQA > 0){
974  fHistoClusGammaPtM02[iCut] = new TH2F("ClusGamma_Pt_M02","ClusGamma_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
975  fESDList[iCut]->Add(fHistoClusGammaPtM02[iCut]);
976  }
977 
978  if (fIsMC > 1){
979  fHistoClusGammaPt[iCut]->Sumw2();
980  fHistoClusGammaE[iCut]->Sumw2();
981  fHistoClusOverlapHeadersGammaPt[iCut]->Sumw2();
982  fHistoClusAllHeadersGammaPt[iCut]->Sumw2();
983  fHistoClusRejectedHeadersGammaPt[iCut]->Sumw2();
984  if(!fDoLightOutput && fDoClusterQA > 0)fHistoClusGammaPtM02[iCut]->Sumw2();
985  }
986 
987  if(fDoMesonAnalysis){
988  fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
989  fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
990  fHistoMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt","ESD_Background_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
991  fESDList[iCut]->Add(fHistoMotherBackInvMassPt[iCut]);
992  if(!fDoLightOutput){
993  fHistoMotherInvMassPtAlpha[iCut] = new TH2F("ESD_Mother_InvMass_vs_Pt_Alpha","ESD_Mother_InvMass_vs_Pt_Alpha",800,0,0.8,nBinsPt, minPt, maxPt);
994  fESDList[iCut]->Add(fHistoMotherInvMassPtAlpha[iCut]);
995  fHistoMotherBackInvMassPtAlpha[iCut] = new TH2F("ESD_Background_InvMass_vs_Pt_Alpha","ESD_Background_InvMass_vs_Pt_Alpha",800,0,0.8,nBinsPt, minPt, maxPt);
996  fESDList[iCut]->Add(fHistoMotherBackInvMassPtAlpha[iCut]);
997  }
998 
999  if (fIsMC > 1){
1000  fHistoMotherInvMassPt[iCut]->Sumw2();
1001  fHistoMotherBackInvMassPt[iCut]->Sumw2();
1002  if(!fDoLightOutput){
1003  fHistoMotherInvMassPtAlpha[iCut]->Sumw2();
1004  fHistoMotherBackInvMassPtAlpha[iCut]->Sumw2();
1005  }
1006  }
1007 
1008  if (fDoMesonQA > 0 && fDoMesonQA < 3 ){
1009  fHistoMotherPi0PtY[iCut] = new TH2F("ESD_MotherPi0_Pt_Y","ESD_MotherPi0_Pt_Y",nBinsQAPt, minQAPt, maxQAPt,150,-1.5,1.5);
1011  fESDList[iCut]->Add(fHistoMotherPi0PtY[iCut]);
1012  fHistoMotherEtaPtY[iCut] = new TH2F("ESD_MotherEta_Pt_Y","ESD_MotherEta_Pt_Y",nBinsQAPt, minQAPt, maxQAPt,150,-1.5,1.5);
1014  fESDList[iCut]->Add(fHistoMotherEtaPtY[iCut]);
1015  fHistoMotherPi0PtAlpha[iCut] = new TH2F("ESD_MotherPi0_Pt_Alpha","ESD_MotherPi0_Pt_Alpha",nBinsQAPt, minQAPt, maxQAPt,100,0,1);
1017  fESDList[iCut]->Add(fHistoMotherPi0PtAlpha[iCut]);
1018  fHistoMotherEtaPtAlpha[iCut] = new TH2F("ESD_MotherEta_Pt_Alpha","ESD_MotherEta_Pt_Alpha",nBinsQAPt, minQAPt, maxQAPt,100,0,1);
1020  fESDList[iCut]->Add(fHistoMotherEtaPtAlpha[iCut]);
1021  fHistoMotherPi0PtOpenAngle[iCut] = new TH2F("ESD_MotherPi0_Pt_OpenAngle","ESD_MotherPi0_Pt_OpenAngle",nBinsQAPt, minQAPt, maxQAPt,100,0, 0.5);
1023  fESDList[iCut]->Add(fHistoMotherPi0PtOpenAngle[iCut]);
1024  fHistoMotherEtaPtOpenAngle[iCut] = new TH2F("ESD_MotherEta_Pt_OpenAngle","ESD_MotherEta_Pt_OpenAngle",nBinsQAPt, minQAPt, maxQAPt,180,0, 1.8);
1026  fESDList[iCut]->Add(fHistoMotherEtaPtOpenAngle[iCut]);
1027  if(fIsHeavyIon == 1){
1028  fHistoMotherPi0NGoodESDTracksPt[iCut] = new TH2F("ESD_MotherPi0_GoodESDTracks_Pt","ESD_MotherPi0_GoodESDTracks_Pt",4000,0,4000,nBinsQAPt, minQAPt, maxQAPt);
1029  fHistoMotherEtaNGoodESDTracksPt[iCut] = new TH2F("ESD_MotherEta_GoodESDTracks_Pt","ESD_MotherEta_GoodESDTracks_Pt",4000,0,4000,nBinsQAPt, minQAPt, maxQAPt);
1030  }else if(fIsHeavyIon == 2){
1031  fHistoMotherPi0NGoodESDTracksPt[iCut] = new TH2F("ESD_MotherPi0_GoodESDTracks_Pt","ESD_MotherPi0_GoodESDTracks_Pt",400,0,400,nBinsQAPt, minQAPt, maxQAPt);
1032  fHistoMotherEtaNGoodESDTracksPt[iCut] = new TH2F("ESD_MotherEta_GoodESDTracks_Pt","ESD_MotherEta_GoodESDTracks_Pt",400,0,400,nBinsQAPt, minQAPt, maxQAPt);
1033  }else{
1034  fHistoMotherPi0NGoodESDTracksPt[iCut] = new TH2F("ESD_MotherPi0_GoodESDTracks_Pt","ESD_MotherPi0_GoodESDTracks_Pt",200,0,200,nBinsQAPt, minQAPt, maxQAPt);
1035  fHistoMotherEtaNGoodESDTracksPt[iCut] = new TH2F("ESD_MotherEta_GoodESDTracks_Pt","ESD_MotherEta_GoodESDTracks_Pt",200,0,200,nBinsQAPt, minQAPt, maxQAPt);
1036  }
1037  fESDList[iCut]->Add(fHistoMotherPi0NGoodESDTracksPt[iCut]);
1038  fESDList[iCut]->Add(fHistoMotherEtaNGoodESDTracksPt[iCut]);
1039  }
1040 
1041  if (fIsMC > 1 && fDoMesonQA > 0 && fDoMesonQA < 3){
1042  fHistoMotherPi0PtY[iCut]->Sumw2();
1043  fHistoMotherEtaPtY[iCut]->Sumw2();
1044  fHistoMotherPi0PtAlpha[iCut]->Sumw2();
1045  fHistoMotherEtaPtAlpha[iCut]->Sumw2();
1046  fHistoMotherPi0PtOpenAngle[iCut]->Sumw2();
1047  fHistoMotherEtaPtOpenAngle[iCut]->Sumw2();
1048  fHistoMotherPi0NGoodESDTracksPt[iCut]->Sumw2();
1049  fHistoMotherEtaNGoodESDTracksPt[iCut]->Sumw2();
1050  }
1051 
1052  if (fProduceCellIDPlots){
1053  Int_t nMaxCells = 12*48*24;
1054  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetClusterType() == 2) nMaxCells = 5*56*64;
1055  fHistCellIDvsClusterEnergy[iCut] = new TH2F("CellIDvsClusterEnergy","CellIDvsClusterEnergy",100,0.5,100.,nMaxCells,0,nMaxCells);
1057  fESDList[iCut]->Add(fHistCellIDvsClusterEnergy[iCut]);
1058  fHistCellIDvsClusterEnergyMax[iCut] = new TH2F("CellIDvsClusterEnergyMax","CellIDvsClusterEnergyMax",100,0.5,100.,nMaxCells,0,nMaxCells);
1060  fESDList[iCut]->Add(fHistCellIDvsClusterEnergyMax[iCut]);
1061  }
1062 
1063  if (fDoMesonQA == 4 && fIsMC == 0){
1064  fTreeList[iCut] = new TList();
1065  fTreeList[iCut]->SetName(Form("%s_%s_%s InvMass Tree",cutstringEvent.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
1066  fTreeList[iCut]->SetOwner(kTRUE);
1067  fCutFolder[iCut]->Add(fTreeList[iCut]);
1068 
1069  tSigInvMassPtAlphaTheta[iCut] = new TTree("Sig_InvMass_Pt_Alpha_Theta_MixPool","Sig_InvMass_Pt_Alpha_Theta_MixPool");
1070  tSigInvMassPtAlphaTheta[iCut]->Branch("InvMass",&fInvMassTreeInvMass,"fInvMassTreeInvMass/F");
1071  tSigInvMassPtAlphaTheta[iCut]->Branch("Pt",&fInvMassTreePt,"fInvMassTreePt/F");
1072  tSigInvMassPtAlphaTheta[iCut]->Branch("Alpha",&fInvMassTreeAlpha,"fInvMassTreeAlpha/F");
1073  tSigInvMassPtAlphaTheta[iCut]->Branch("Theta",&fInvMassTreeTheta,"fInvMassTreeTheta/F");
1074  tSigInvMassPtAlphaTheta[iCut]->Branch("MixPool",&fInvMassTreeMixPool,"fInvMassTreeMixPool/I");
1075  tSigInvMassPtAlphaTheta[iCut]->Branch("zVtx",&fInvMassTreeZVertex,"fInvMassTreeZVertex/F");
1076  tSigInvMassPtAlphaTheta[iCut]->Branch("Eta",&fInvMassTreeEta,"fInvMassTreeEta/F");
1077  fTreeList[iCut]->Add(tSigInvMassPtAlphaTheta[iCut]);
1078 
1079  tBckInvMassPtAlphaTheta[iCut] = new TTree("Bck_InvMass_Pt_Alpha_Theta_MixPool","Bck_InvMass_Pt_Alpha_Theta_MixPool");
1080  tBckInvMassPtAlphaTheta[iCut]->Branch("InvMass",&fInvMassTreeInvMass,"fInvMassTreeInvMass/F");
1081  tBckInvMassPtAlphaTheta[iCut]->Branch("Pt",&fInvMassTreePt,"fInvMassTreePt/F");
1082  tBckInvMassPtAlphaTheta[iCut]->Branch("Alpha",&fInvMassTreeAlpha,"fInvMassTreeAlpha/F");
1083  tBckInvMassPtAlphaTheta[iCut]->Branch("Theta",&fInvMassTreeTheta,"fInvMassTreeTheta/F");
1084  tBckInvMassPtAlphaTheta[iCut]->Branch("MixPool",&fInvMassTreeMixPool,"fInvMassTreeMixPool/I");
1085  tBckInvMassPtAlphaTheta[iCut]->Branch("zVtx",&fInvMassTreeZVertex,"fInvMassTreeZVertex/F");
1086  tBckInvMassPtAlphaTheta[iCut]->Branch("Eta",&fInvMassTreeEta,"fInvMassTreeEta/F");
1087  fTreeList[iCut]->Add(tBckInvMassPtAlphaTheta[iCut]);
1088  }
1089 
1090  if (fProduceTreeEOverP ){
1091  fClusterTreeList[iCut] = new TList();
1092  fClusterTreeList[iCut]->SetName(Form("%s_%s EoverP Tree",cutstringEvent.Data(),cutstringCalo.Data()));
1093  fClusterTreeList[iCut]->SetOwner(kTRUE);
1094  fCutFolder[iCut]->Add(fClusterTreeList[iCut]);
1095 
1096  tClusterEOverP[iCut] = new TTree("EOverP_ClusE_ClusM02_ClusM20_TrackP_TrackPt","EOverP_ClusE_ClusM02_ClusM20_TrackP_TrackPt");
1097  tClusterEOverP[iCut]->Branch("ClusE",&fClusterE,"fClusterE/F");
1098  tClusterEOverP[iCut]->Branch("ClusM02",&fClusterM02,"fClusterM02/F");
1099  tClusterEOverP[iCut]->Branch("ClusM20",&fClusterM20,"fClusterM20/F");
1100  tClusterEOverP[iCut]->Branch("ClusEP",&fClusterEP,"fClusterEP/F");
1101  tClusterEOverP[iCut]->Branch("ClusLeadCellID",&fClusterLeadCellID,"fClusterLeadCellID/I");
1102  if(fIsMC > 0) tClusterEOverP[iCut]->Branch("ClusClassification",&fClusterClassification,"fClusterClassification/I");
1103  tClusterEOverP[iCut]->Branch("ClusTrackDeltaEta",&fDeltaEta,"fDeltaEta/F");
1104  tClusterEOverP[iCut]->Branch("ClusTrackDeltaPhi",&fDeltaPhi,"fDeltaPhi/F");
1105  tClusterEOverP[iCut]->Branch("TrackPt",&fTrackPt,"fTrackPt/F");
1106  tClusterEOverP[iCut]->Branch("TrackPID_e",&fTrackPID_e,"fTrackPID_e/I");
1107  tClusterEOverP[iCut]->Branch("TrackPID_Pi",&fTrackPID_Pi,"fTrackPID_Pi/I");
1108  tClusterEOverP[iCut]->Branch("TrackPID_K",&fTrackPID_K,"fTrackPID_K/I");
1109  tClusterEOverP[iCut]->Branch("TrackPID_P",&fTrackPID_P,"fTrackPID_P/I");
1110  tClusterEOverP[iCut]->Branch("ClusIsoSumClusEt",&fClusterIsoSumClusterEt,"fClusterIsoSumClusterEt/F");
1111  tClusterEOverP[iCut]->Branch("ClusIsoSumTrackEt",&fClusterIsoSumTrackEt,"fClusterIsoSumTrackEt/F");
1112  fClusterTreeList[iCut]->Add(tClusterEOverP[iCut]);
1113  }
1114  }
1115  }
1116  if(fDoMesonAnalysis){
1117  InitBack(); // Init Background Handler
1118  }
1119 
1120  if(fIsMC> 0){
1121  // MC Histogramms
1122  fMCList = new TList*[fnCuts];
1123  // True Histogramms
1124  fTrueList = new TList*[fnCuts];
1125  // Selected Header List
1126  if (fDoMesonQA ==3){
1127  fTreeList = new TList*[fnCuts];
1129  }
1130 
1131  if(!fDoLightOutput){
1132  fHistoMCHeaders = new TH1I*[fnCuts];
1133  fHistoMCAllGammaPt = new TH1F*[fnCuts];
1135  fHistoMCDecayGammaPi0Pt = new TH1F*[fnCuts];
1136  fHistoMCDecayGammaRhoPt = new TH1F*[fnCuts];
1137  fHistoMCDecayGammaEtaPt = new TH1F*[fnCuts];
1138  fHistoMCDecayGammaOmegaPt = new TH1F*[fnCuts];
1139  fHistoMCDecayGammaEtapPt = new TH1F*[fnCuts];
1140  fHistoMCDecayGammaPhiPt = new TH1F*[fnCuts];
1141  fHistoMCDecayGammaSigmaPt = new TH1F*[fnCuts];
1144  if (fDoClusterQA > 0) {
1157  }
1158  }
1159 
1160  fHistoTrueClusGammaPt = new TH1F*[fnCuts];
1161  if(!fDoLightOutput){
1163  fHistoTruePrimaryClusGammaPt = new TH1F*[fnCuts];
1177  fHistoTrueNLabelsInClus = new TH1F*[fnCuts];
1178  }
1181 
1182 // fHistoTruePi0NonLinearity = new TH2F*[fnCuts];
1183 // fHistoTrueEtaNonLinearity = new TH2F*[fnCuts];
1184 
1185  if (fDoClusterQA > 0){
1186  fHistoTrueClusUnConvGammaPt = new TH1F*[fnCuts];
1188  if (!fDoLightOutput)
1190  fHistoTrueClusElectronPt = new TH1F*[fnCuts];
1191  fHistoTrueClusConvGammaPt = new TH1F*[fnCuts];
1192  fHistoTrueClusConvGammaMCPt = new TH1F*[fnCuts];
1194  fHistoTrueClusMergedGammaPt = new TH1F*[fnCuts];
1196  fHistoTrueClusDalitzPt = new TH1F*[fnCuts];
1197  fHistoTrueClusDalitzMergedPt = new TH1F*[fnCuts];
1199  fHistoTrueClusShowerPt = new TH1F*[fnCuts];
1200  fHistoTrueClusSubLeadingPt = new TH1F*[fnCuts];
1201  fHistoTrueClusNParticles = new TH1F*[fnCuts];
1202  fHistoTrueClusEMNonLeadingPt = new TH1F*[fnCuts];
1203  }
1204 
1205  if(fDoMesonAnalysis){
1206  fHistoMCPi0Pt = new TH1F*[fnCuts];
1207  fHistoMCPi0WOWeightPt = new TH1F*[fnCuts];
1208  fHistoMCEtaPt = new TH1F*[fnCuts];
1209  fHistoMCEtaWOWeightPt = new TH1F*[fnCuts];
1210  fHistoMCPi0InAccPt = new TH1F*[fnCuts];
1211  fHistoMCEtaInAccPt = new TH1F*[fnCuts];
1212 
1213  if (fIsMC > 1){
1214  fHistoMCPi0WOEvtWeightPt = new TH1F*[fnCuts];
1215  fHistoMCEtaWOEvtWeightPt = new TH1F*[fnCuts];
1218  }
1219 
1235  if(!fDoLightOutput){
1238  }
1242  fHistoMCSecPi0Source = new TH1F*[fnCuts];
1243  fHistoMCSecEtaPt = new TH1F*[fnCuts];
1244  fHistoMCSecEtaSource = new TH1F*[fnCuts];
1245 
1246  if (fDoMesonQA > 0 && fDoMesonQA < 3 ){
1247  fHistoMCPi0PtY = new TH2F*[fnCuts];
1248  fHistoMCEtaPtY = new TH2F*[fnCuts];
1249  fHistoMCPi0PtAlpha = new TH2F*[fnCuts];
1250  fHistoMCEtaPtAlpha = new TH2F*[fnCuts];
1251  if (fIsMC == 2){
1252  fHistoMCPi0PtJetPt = new TH2F*[fnCuts];
1253  fHistoMCEtaPtJetPt = new TH2F*[fnCuts];
1254  }
1255 
1256  if (fIsMC < 2){
1277  }
1278  fHistoTruePi0PtY = new TH2F*[fnCuts];
1279  fHistoTrueEtaPtY = new TH2F*[fnCuts];
1288  }
1289  if (fDoMesonQA==2){
1304  }
1305  }
1306 
1307 
1308 
1309  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1310  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
1311  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
1312  TString cutstringMeson = "NoMesonCut";
1313  if(fDoMesonAnalysis)
1314  cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
1315 
1316  fMCList[iCut] = new TList();
1317  fMCList[iCut]->SetName(Form("%s_%s_%s MC histograms",cutstringEvent.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
1318  fMCList[iCut]->SetOwner(kTRUE);
1319  fCutFolder[iCut]->Add(fMCList[iCut]);
1320 
1321  if(!fDoLightOutput){
1322  fHistoMCHeaders[iCut] = new TH1I("MC_Headers","MC_Headers",20,0,20);
1323  fMCList[iCut]->Add(fHistoMCHeaders[iCut]);
1324  fHistoMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt","MC_AllGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1325  fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);
1326  fHistoMCAllSecondaryGammaPt[iCut] = new TH2F("MC_AllSecondaryGamma_Pt","MC_AllSecondaryGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt, 5, -0.5, 4.5);
1327  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1328  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1329  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1330  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(4,"Eta");
1331  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(5,"rest");
1332  fMCList[iCut]->Add(fHistoMCAllSecondaryGammaPt[iCut]);
1333  fHistoMCDecayGammaPi0Pt[iCut] = new TH1F("MC_DecayGammaPi0_Pt","MC_DecayGammaPi0_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1334  fMCList[iCut]->Add(fHistoMCDecayGammaPi0Pt[iCut]);
1335  fHistoMCDecayGammaRhoPt[iCut] = new TH1F("MC_DecayGammaRho_Pt","MC_DecayGammaRho_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1336  fMCList[iCut]->Add(fHistoMCDecayGammaRhoPt[iCut]);
1337  fHistoMCDecayGammaEtaPt[iCut] = new TH1F("MC_DecayGammaEta_Pt","MC_DecayGammaEta_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1338  fMCList[iCut]->Add(fHistoMCDecayGammaEtaPt[iCut]);
1339  fHistoMCDecayGammaOmegaPt[iCut] = new TH1F("MC_DecayGammaOmega_Pt","MC_DecayGammaOmmega_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1340  fMCList[iCut]->Add(fHistoMCDecayGammaOmegaPt[iCut]);
1341  fHistoMCDecayGammaEtapPt[iCut] = new TH1F("MC_DecayGammaEtap_Pt","MC_DecayGammaEtap_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1342  fMCList[iCut]->Add(fHistoMCDecayGammaEtapPt[iCut]);
1343  fHistoMCDecayGammaPhiPt[iCut] = new TH1F("MC_DecayGammaPhi_Pt","MC_DecayGammaPhi_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1344  fMCList[iCut]->Add(fHistoMCDecayGammaPhiPt[iCut]);
1345  fHistoMCDecayGammaSigmaPt[iCut] = new TH1F("MC_DecayGammaSigma_Pt","MC_DecayGammaSigma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1346  fMCList[iCut]->Add(fHistoMCDecayGammaSigmaPt[iCut]);
1347 
1348  if (fIsMC > 1){
1349  fHistoMCAllGammaPt[iCut]->Sumw2();
1350  fHistoMCAllSecondaryGammaPt[iCut]->Sumw2();
1351  fHistoMCDecayGammaPi0Pt[iCut]->Sumw2();
1352  fHistoMCDecayGammaRhoPt[iCut]->Sumw2();
1353  fHistoMCDecayGammaEtaPt[iCut]->Sumw2();
1354  fHistoMCDecayGammaOmegaPt[iCut]->Sumw2();
1355  fHistoMCDecayGammaEtapPt[iCut]->Sumw2();
1356  fHistoMCDecayGammaPhiPt[iCut]->Sumw2();
1357  fHistoMCDecayGammaSigmaPt[iCut]->Sumw2();
1358  }
1359  }
1360 
1361  if(fDoMesonAnalysis){
1362  fHistoMCPi0Pt[iCut] = new TH1F("MC_Pi0_Pt","MC_Pi0_Pt",nBinsPt, minPt, maxPt);
1363  fHistoMCPi0Pt[iCut]->Sumw2();
1364  fMCList[iCut]->Add(fHistoMCPi0Pt[iCut]);
1365  fHistoMCPi0WOWeightPt[iCut] = new TH1F("MC_Pi0_WOWeights_Pt","MC_Pi0_WOWeights_Pt",nBinsPt, minPt, maxPt);
1366  fHistoMCPi0WOWeightPt[iCut]->Sumw2();
1367  fMCList[iCut]->Add(fHistoMCPi0WOWeightPt[iCut]);
1368 
1369  fHistoMCEtaPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",nBinsPt, minPt, maxPt);
1370  fHistoMCEtaPt[iCut]->Sumw2();
1371  fMCList[iCut]->Add(fHistoMCEtaPt[iCut]);
1372  fHistoMCEtaWOWeightPt[iCut] = new TH1F("MC_Eta_WOWeights_Pt","MC_Eta_WOWeights_Pt",nBinsPt, minPt, maxPt);
1373  fHistoMCEtaWOWeightPt[iCut]->Sumw2();
1374  fMCList[iCut]->Add(fHistoMCEtaWOWeightPt[iCut]);
1375  fHistoMCPi0InAccPt[iCut] = new TH1F("MC_Pi0InAcc_Pt","MC_Pi0InAcc_Pt",nBinsPt, minPt, maxPt);
1376  fHistoMCPi0InAccPt[iCut]->Sumw2();
1377  fMCList[iCut]->Add(fHistoMCPi0InAccPt[iCut]);
1378  fHistoMCEtaInAccPt[iCut] = new TH1F("MC_EtaInAcc_Pt","MC_EtaInAcc_Pt",nBinsPt, minPt, maxPt);
1379  fHistoMCEtaInAccPt[iCut]->Sumw2();
1380  fMCList[iCut]->Add(fHistoMCEtaInAccPt[iCut]);
1381  if (fIsMC > 1){
1382  fHistoMCPi0WOWeightPt[iCut]->Sumw2();
1383  fHistoMCEtaWOWeightPt[iCut]->Sumw2();
1384  fHistoMCPi0WOEvtWeightPt[iCut] = new TH1F("MC_Pi0_WOEventWeights_Pt","MC_Pi0_WOEventWeights_Pt",nBinsPt, minPt, maxPt);
1385  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightPt[iCut]);
1386  fHistoMCEtaWOEvtWeightPt[iCut] = new TH1F("MC_Eta_WOEventWeights_Pt","MC_Eta_WOEventWeights_Pt",nBinsPt, minPt, maxPt);
1387  fMCList[iCut]->Add(fHistoMCEtaWOEvtWeightPt[iCut]);
1388  fHistoMCPi0WOEvtWeightInAccPt[iCut] = new TH1F("MC_Pi0WOEvtWeightInAcc_Pt","MC_Pi0WOEvtWeightInAcc_Pt",nBinsPt, minPt, maxPt);
1389  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightInAccPt[iCut]);
1390  fHistoMCEtaWOEvtWeightInAccPt[iCut] = new TH1F("MC_EtaWOEvtWeightInAcc_Pt","MC_EtaWOEvtWeightInAcc_Pt",nBinsPt, minPt, maxPt);
1391  fMCList[iCut]->Add(fHistoMCEtaWOEvtWeightInAccPt[iCut]);
1392  if (fDoMesonQA > 0 && fDoMesonQA < 3 && fIsMC == 2){
1393  fHistoMCPi0PtJetPt[iCut] = new TH2F("MC_Pi0_Pt_JetPt","MC_Pi0_Pt_JetPt",nBinsQAPt, minQAPt, maxQAPt,200,0,200);
1394  fHistoMCPi0PtJetPt[iCut]->Sumw2();
1396  fMCList[iCut]->Add(fHistoMCPi0PtJetPt[iCut]);
1397  fHistoMCEtaPtJetPt[iCut] = new TH2F("MC_Eta_Pt_JetPt","MC_Eta_Pt_JetPt",nBinsQAPt, minQAPt, maxQAPt,200,0,200);
1398  fHistoMCEtaPtJetPt[iCut]->Sumw2();
1400  fMCList[iCut]->Add(fHistoMCEtaPtJetPt[iCut]);
1401  }
1402  }
1403 
1404  fHistoMCPrimaryPtvsSource[iCut] = new TH2F("MC_Primary_Pt_Source","MC_Primary_Pt_Source",nBinsPt, minPt, maxPt, 7, -0.5, 6.5);
1405  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(1,"Pi+");
1406  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(2,"Pi-");
1407  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(3,"K+");
1408  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(4,"K-");
1409  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(5,"K0s");
1410  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(6,"K0l");
1411  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(7,"Lambda");
1412  fMCList[iCut]->Add(fHistoMCPrimaryPtvsSource[iCut]);
1413 
1414  fHistoMCSecPi0Source[iCut] = new TH1F("MC_SecPi0_Source","MC_SecPi0_Source",5000,0.,5000);
1415  fMCList[iCut]->Add(fHistoMCSecPi0Source[iCut]);
1416  fHistoMCSecEtaSource[iCut] = new TH1F("MC_SecEta_Source","MC_SecEta_Source",5000,0,5000);
1417  fMCList[iCut]->Add(fHistoMCSecEtaSource[iCut]);
1418  fHistoMCSecPi0PtvsSource[iCut] = new TH2F("MC_SecPi0_Pt_Source","MC_SecPi0_Pt_Source",nBinsPt, minPt, maxPt,16,-0.5,15.5);
1419  fMCList[iCut]->Add(fHistoMCSecPi0PtvsSource[iCut]);
1420  fHistoMCSecPi0InAccPtvsSource[iCut] = new TH2F("MC_SecPi0InAcc_Pt_Source","MC_SecPi0InAcc_Pt_Source",nBinsPt, minPt, maxPt, 16,-0.5,15.5);
1421  fMCList[iCut]->Add(fHistoMCSecPi0InAccPtvsSource[iCut]);
1422  fHistoMCSecEtaPt[iCut] = new TH1F("MC_SecEta_Pt","MC_SecEta_Pt",nBinsPt, minPt, maxPt);
1423  fMCList[iCut]->Add(fHistoMCSecEtaPt[iCut]);
1424  if (fIsMC == 2) {
1425  fHistoMCPrimaryPtvsSource[iCut]->Sumw2();
1426  fHistoMCSecPi0PtvsSource[iCut]->Sumw2();
1427  fHistoMCSecPi0InAccPtvsSource[iCut]->Sumw2();
1428  fHistoMCSecEtaPt[iCut]->Sumw2();
1429  }
1430 
1431 
1432  if (fDoMesonQA > 0 && fDoMesonQA < 3){
1433  fHistoMCPi0PtY[iCut] = new TH2F("MC_Pi0_Pt_Y","MC_Pi0_Pt_Y",nBinsQAPt, minQAPt, maxQAPt,150,-1.5,1.5);
1434  fHistoMCPi0PtY[iCut]->Sumw2();
1436  fMCList[iCut]->Add(fHistoMCPi0PtY[iCut]);
1437  fHistoMCEtaPtY[iCut] = new TH2F("MC_Eta_Pt_Y","MC_Eta_Pt_Y",nBinsQAPt, minQAPt, maxQAPt,150,-1.5,1.5);
1438  fHistoMCEtaPtY[iCut]->Sumw2();
1440  fMCList[iCut]->Add(fHistoMCEtaPtY[iCut]);
1441  fHistoMCPi0PtAlpha[iCut] = new TH2F("MC_Pi0_Pt_Alpha","MC_Pi0_Pt_Alpha",nBinsQAPt, minQAPt, maxQAPt,100,0,1);
1443  fMCList[iCut]->Add(fHistoMCPi0PtAlpha[iCut]);
1444  fHistoMCEtaPtAlpha[iCut] = new TH2F("MC_Eta_Pt_Alpha","MC_Eta_Pt_Alpha",nBinsQAPt, minQAPt, maxQAPt,100,0,1);
1446  fMCList[iCut]->Add(fHistoMCEtaPtAlpha[iCut]);
1447 
1448  if (fIsMC == 2) {
1449  fHistoMCPi0PtAlpha[iCut]->Sumw2();
1450  fHistoMCEtaPtAlpha[iCut]->Sumw2();
1451  }
1452  }
1453  }
1454  fTrueList[iCut] = new TList();
1455  fTrueList[iCut]->SetName(Form("%s_%s_%s True histograms",cutstringEvent.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
1456  fTrueList[iCut]->SetOwner(kTRUE);
1457  fCutFolder[iCut]->Add(fTrueList[iCut]);
1458 
1459  if(!fDoLightOutput){
1460  fHistoClusPhotonBGPt[iCut] = new TH2F("ESD_TrueClusPhotonBG_Pt","ESD_TrueClusPhotonBG_Pt",nBinsClusterPt, minClusterPt, maxClusterPt,10,-0.5,9.5);
1461  fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 1,"Elec");
1462  fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 2,"Pion");
1463  fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 3,"Proton");
1464  fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 4,"Kaon");
1465  fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 5,"Neutron");
1466  fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 6,"K0s");
1467  fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 7,"Lambda");
1468  fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 8,"Muon");
1469  fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 9,"K0l");
1470  fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 10,"Rest");
1471  fTrueList[iCut]->Add(fHistoClusPhotonBGPt[iCut]);
1472  fHistoClusPhotonPlusConvBGPt[iCut] = new TH2F("ESD_TrueClusPhotonPlusConvBG_Pt","ESD_TrueClusPhotonPlusConvBG_Pt",nBinsClusterPt, minClusterPt, maxClusterPt,10,-0.5,9.5);
1473  fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 1,"Elec");
1474  fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 2,"Pion");
1475  fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 3,"Proton");
1476  fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 4,"Kaon");
1477  fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 5,"Neutron");
1478  fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 6,"K0s");
1479  fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 7,"Lambda");
1480  fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 8,"Muon");
1481  fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 9,"K0l");
1482  fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel(10,"Rest");
1483  fTrueList[iCut]->Add(fHistoClusPhotonPlusConvBGPt[iCut]);
1484 
1485  if (fDoClusterQA > 0) {
1486  fHistoClustPhotonElectronBGPtM02[iCut] = new TH2F("ESD_TrueClusPhotonElectronBG_Pt_M02","ESD_TrueClusPhotonElectronBG_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
1487  fTrueList[iCut]->Add(fHistoClustPhotonElectronBGPtM02[iCut]);
1488  fHistoClustPhotonPionBGPtM02[iCut] = new TH2F("ESD_TrueClusPhotonPionBG_Pt_M02","ESD_TrueClusPhotonPionBG_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
1489  fTrueList[iCut]->Add(fHistoClustPhotonPionBGPtM02[iCut]);
1490  fHistoClustPhotonKaonBGPtM02[iCut] = new TH2F("ESD_TrueClusPhotonKaonBG_Pt_M02","ESD_TrueClusPhotonKaonBG_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
1491  fTrueList[iCut]->Add(fHistoClustPhotonKaonBGPtM02[iCut]);
1492  fHistoClustPhotonK0lBGPtM02[iCut] = new TH2F("ESD_TrueClusPhotonK0lBG_Pt_M02","ESD_TrueClusPhotonK0lBG_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
1493  fTrueList[iCut]->Add(fHistoClustPhotonK0lBGPtM02[iCut]);
1494  fHistoClustPhotonNeutronBGPtM02[iCut] = new TH2F("ESD_TrueClusPhotonNeutronBG_Pt_M02","ESD_TrueClusPhotonNeutronBG_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
1495  fTrueList[iCut]->Add(fHistoClustPhotonNeutronBGPtM02[iCut]);
1496  fHistoClustPhotonRestBGPtM02[iCut] = new TH2F("ESD_TrueClusPhotonRestBG_Pt_M02","ESD_TrueClusPhotonRestBG_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
1497  fTrueList[iCut]->Add(fHistoClustPhotonRestBGPtM02[iCut]);
1498  fHistoClustPhotonPlusConvElectronBGPtM02[iCut]= new TH2F("ESD_TrueClusPhotonPlusConvElectronBG_Pt_M02","ESD_TrueClusPhotonPlusConvElectronBG_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
1500  fHistoClustPhotonPlusConvPionBGPtM02[iCut] = new TH2F("ESD_TrueClusPhotonPlusConvPionBG_Pt_M02","ESD_TrueClusPhotonPlusConvPionBG_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
1502  fHistoClustPhotonPlusConvKaonBGPtM02[iCut] = new TH2F("ESD_TrueClusPhotonPlusConvKaonBG_Pt_M02","ESD_TrueClusPhotonPlusConvKaonBG_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
1504  fHistoClustPhotonPlusConvK0lBGPtM02[iCut] = new TH2F("ESD_TrueClusPhotonPlusConvK0lBG_Pt_M02","ESD_TrueClusPhotonPlusConvK0lBG_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
1506  fHistoClustPhotonPlusConvNeutronBGPtM02[iCut] = new TH2F("ESD_TrueClusPhotonPlusConvNeutronBG_Pt_M02","ESD_TrueClusPhotonPlusConvNeutronBG_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
1508  fHistoClustPhotonPlusConvRestBGPtM02[iCut] = new TH2F("ESD_TrueClusPhotonPlusConvRestBG_Pt_M02","ESD_TrueClusPhotonPlusConvRestBG_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
1510  }
1511  }
1512 
1513  fHistoTrueClusGammaPt[iCut] = new TH1F("TrueClusGamma_Pt","ESD_TrueClusGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1514  fTrueList[iCut]->Add(fHistoTrueClusGammaPt[iCut]);
1515  if(!fDoLightOutput){
1516  if (fDoClusterQA > 0) {
1517  fHistoTrueClusGammaPtM02[iCut] = new TH2F("TrueClusGamma_Pt_M02","TrueClusGamma_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
1518  fTrueList[iCut]->Add(fHistoTrueClusGammaPtM02[iCut]);
1519  }
1520  fHistoTruePrimaryClusGammaPt[iCut] = new TH1F("TruePrimaryClusGamma_Pt","ESD_TruePrimaryClusGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1521  fTrueList[iCut]->Add(fHistoTruePrimaryClusGammaPt[iCut]);
1522  fHistoTruePrimaryClusGammaESDPtMCPt[iCut] = new TH2F("TruePrimaryClusGamma_Pt_MCPt","ESD_TruePrimaryClusGamma_MCPt",nBinsClusterPt, minClusterPt, maxClusterPt,nBinsClusterPt, minClusterPt, maxClusterPt);
1524  fHistoTruePrimaryClusConvGammaPt[iCut] = new TH1F("TruePrimaryClusConvGamma_Pt","ESD_TruePrimaryClusConvGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1525  fTrueList[iCut]->Add(fHistoTruePrimaryClusConvGammaPt[iCut]);
1526  fHistoTruePrimaryClusConvGammaESDPtMCPt[iCut] = new TH2F("TruePrimaryClusConvGamma_Pt_MCPt","ESD_TruePrimaryClusConvGamma_MCPt",nBinsClusterPt, minClusterPt, maxClusterPt,nBinsClusterPt, minClusterPt, maxClusterPt);
1528  fHistoTrueSecondaryClusGammaPt[iCut] = new TH2F("ESD_TrueSecondaryClusGamma_Pt","ESD_TrueSecondaryClusGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt, 5, -0.5, 4.5);
1529  fHistoTrueSecondaryClusGammaPt[iCut]->GetYaxis()->SetBinLabel( 1,"K0s");
1530  fHistoTrueSecondaryClusGammaPt[iCut]->GetYaxis()->SetBinLabel( 2,"K0l");
1531  fHistoTrueSecondaryClusGammaPt[iCut]->GetYaxis()->SetBinLabel( 3,"Lambda");
1532  fHistoTrueSecondaryClusGammaPt[iCut]->GetYaxis()->SetBinLabel( 4,"Eta");
1533  fHistoTrueSecondaryClusGammaPt[iCut]->GetYaxis()->SetBinLabel( 5,"rest");
1534  fTrueList[iCut]->Add(fHistoTrueSecondaryClusGammaPt[iCut]);
1535  fHistoTrueSecondaryClusConvGammaPt[iCut] = new TH2F("ESD_TrueSecondaryClusConvGamma_Pt","ESD_TrueSecondaryClusConvGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt, 5, -0.5, 4.5);
1536  fHistoTrueSecondaryClusConvGammaPt[iCut]->GetYaxis()->SetBinLabel( 1,"K0s");
1537  fHistoTrueSecondaryClusConvGammaPt[iCut]->GetYaxis()->SetBinLabel( 2,"K0l");
1538  fHistoTrueSecondaryClusConvGammaPt[iCut]->GetYaxis()->SetBinLabel( 3,"Lambda");
1539  fHistoTrueSecondaryClusConvGammaPt[iCut]->GetYaxis()->SetBinLabel( 4,"Eta");
1540  fHistoTrueSecondaryClusConvGammaPt[iCut]->GetYaxis()->SetBinLabel( 5,"rest");
1542  fHistoTrueSecondaryClusGammaMCPt[iCut] = new TH2F("ESD_TrueSecondaryClusGamma_MCPt","ESD_TrueSecondaryClusGamma_MCPt",nBinsClusterPt, minClusterPt, maxClusterPt, 5, -0.5, 4.5);
1543  fHistoTrueSecondaryClusGammaMCPt[iCut]->GetYaxis()->SetBinLabel( 1,"K0s");
1544  fHistoTrueSecondaryClusGammaMCPt[iCut]->GetYaxis()->SetBinLabel( 2,"K0l");
1545  fHistoTrueSecondaryClusGammaMCPt[iCut]->GetYaxis()->SetBinLabel( 3,"Lambda");
1546  fHistoTrueSecondaryClusGammaMCPt[iCut]->GetYaxis()->SetBinLabel( 4,"Eta");
1547  fHistoTrueSecondaryClusGammaMCPt[iCut]->GetYaxis()->SetBinLabel( 5,"rest");
1548  fTrueList[iCut]->Add(fHistoTrueSecondaryClusGammaMCPt[iCut]);
1549  fHistoTrueSecondaryClusConvGammaMCPt[iCut] = new TH2F("ESD_TrueSecondaryClusConvGamma_MCPt","ESD_TrueSecondaryClusConvGamma_MCPt",nBinsClusterPt, minClusterPt, maxClusterPt, 5, -0.5, 4.5);
1550  fHistoTrueSecondaryClusConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel( 1,"K0s");
1551  fHistoTrueSecondaryClusConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel( 2,"K0l");
1552  fHistoTrueSecondaryClusConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel( 3,"Lambda");
1553  fHistoTrueSecondaryClusConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel( 4,"Eta");
1554  fHistoTrueSecondaryClusConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel( 5,"rest");
1556 
1557  fHistoTrueSecondaryClusGammaFromXFromK0sMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryClusGammaFromXFromK0s_MCPt_Pt", "ESD_TrueSecondaryClusGammaFromXFromK0s_MCPt_Pt",nBinsClusterPt, minClusterPt, maxClusterPt,nBinsClusterPt, minClusterPt, maxClusterPt);
1559  fHistoTrueSecondaryClusConvGammaFromXFromK0sMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryClusConvGammaFromXFromK0s_MCPt_Pt", "ESD_TrueSecondaryClusConvGammaFromXFromK0s_MCPt_Pt",nBinsClusterPt, minClusterPt, maxClusterPt,nBinsClusterPt, minClusterPt, maxClusterPt);
1561  fHistoTrueSecondaryClusGammaFromXFromK0lMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryClusGammaFromXFromK0l_MCPt_Pt", "ESD_TrueSecondaryClusGammaFromXFromK0l_MCPt_Pt",nBinsClusterPt, minClusterPt, maxClusterPt,nBinsClusterPt, minClusterPt, maxClusterPt);
1563  fHistoTrueSecondaryClusConvGammaFromXFromK0lMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryClusConvGammaFromXFromK0l_MCPt_Pt", "ESD_TrueSecondaryClusConvGammaFromXFromK0l_MCPt_Pt",nBinsClusterPt, minClusterPt, maxClusterPt,nBinsClusterPt, minClusterPt, maxClusterPt);
1565  fHistoTrueSecondaryClusGammaFromXFromLambdaMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryClusGammaFromXFromLambda_MCPt_Pt", "ESD_TrueSecondaryClusGammaFromXFromLambda_MCPt_Pt",nBinsClusterPt, minClusterPt, maxClusterPt,nBinsClusterPt, minClusterPt, maxClusterPt);
1567  fHistoTrueSecondaryClusConvGammaFromXFromLambdaMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryClusConvGammaFromXFromLambda_MCPt_Pt", "ESD_TrueSecondaryClusConvGammaFromXFromLambda_MCPt_Pt",nBinsClusterPt, minClusterPt, maxClusterPt,nBinsClusterPt, minClusterPt, maxClusterPt);
1569 
1570  fHistoTrueNLabelsInClus[iCut] = new TH1F("TrueNLabelsInClus","TrueNLabelsInClus",100,-0.5,99.5);
1571  fTrueList[iCut]->Add(fHistoTrueNLabelsInClus[iCut]);
1572  }
1573 
1574  fHistoDoubleCountTrueClusterGammaPt[iCut] = new TH2F("TrueDoubleCountClusterGamma_Pt","TrueDoubleCountClusterGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt,2,0,2);
1576  fHistoMultipleCountTrueClusterGamma[iCut] = new TH1F("TrueMultipleCountClusterGamma","TrueMultipleCountClusterGamma",10,1,11);
1578 
1579  if (fIsMC > 1){
1580  fHistoTrueClusGammaPt[iCut]->Sumw2();
1581  fHistoDoubleCountTrueClusterGammaPt[iCut]->Sumw2();
1582  fHistoMultipleCountTrueClusterGamma[iCut]->Sumw2();
1583  if(!fDoLightOutput){
1584  fHistoTrueNLabelsInClus[iCut]->Sumw2();
1585  if (fDoClusterQA > 0) fHistoTrueClusGammaPtM02[iCut]->Sumw2();
1586  fHistoTruePrimaryClusGammaPt[iCut]->Sumw2();
1587  fHistoTruePrimaryClusGammaESDPtMCPt[iCut]->Sumw2();
1588  fHistoTruePrimaryClusConvGammaPt[iCut]->Sumw2();
1590  fHistoTrueSecondaryClusGammaPt[iCut]->Sumw2();
1591  fHistoTrueSecondaryClusConvGammaPt[iCut]->Sumw2();
1592  fHistoTrueSecondaryClusGammaMCPt[iCut]->Sumw2();
1593  fHistoTrueSecondaryClusConvGammaMCPt[iCut]->Sumw2();
1600  }
1601  }
1602 
1603 // fHistoTruePi0NonLinearity[iCut] = new TH2F("TruePi0: E_truth / E_rec Vs E_rec","TruePi0: E_truth / E_rec Vs E_rec",700,0,35,200,0,2);
1604 // fTrueList[iCut]->Add(fHistoTruePi0NonLinearity[iCut]);
1605 // fHistoTrueEtaNonLinearity[iCut] = new TH2F("TrueEta: E_truth / E_rec Vs E_rec","TrueEta: E_truth / E_rec Vs E_rec",700,0,35,200,0,2);
1606 // fTrueList[iCut]->Add(fHistoTrueEtaNonLinearity[iCut]);
1607 
1608  if (fDoClusterQA > 0){
1609  fHistoTrueClusUnConvGammaPt[iCut] = new TH1F("TrueClusUnConvGamma_Pt","TrueClusUnConvGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1610  fTrueList[iCut]->Add(fHistoTrueClusUnConvGammaPt[iCut]);
1611  fHistoTrueClusUnConvGammaMCPt[iCut] = new TH1F("TrueClusUnConvGamma_MCPt","TrueClusUnConvGamma_MCPt",nBinsClusterPt, minClusterPt, maxClusterPt);
1612  fTrueList[iCut]->Add(fHistoTrueClusUnConvGammaMCPt[iCut]);
1613  if (!fDoLightOutput) {
1614  fHistoTrueClusUnConvGammaPtM02[iCut] = new TH2F("TrueClusUnConvGamma_Pt_M02","TrueClusUnConvGamma_Pt_M02",nBinsClusterPt, minClusterPt, maxClusterPt,100,0,1);
1615  fTrueList[iCut]->Add(fHistoTrueClusUnConvGammaPtM02[iCut]);
1616  }
1617  fHistoTrueClusElectronPt[iCut] = new TH1F("TrueClusElectron_Pt","TrueElectronGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1618  fTrueList[iCut]->Add(fHistoTrueClusElectronPt[iCut]);
1619  fHistoTrueClusConvGammaPt[iCut] = new TH1F("TrueClusConvGamma_Pt","TrueClusConvGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1620  fTrueList[iCut]->Add(fHistoTrueClusConvGammaPt[iCut]);
1621  fHistoTrueClusConvGammaMCPt[iCut] = new TH1F("TrueClusConvGamma_MCPt","TrueClusConvGamma_MCPt",nBinsClusterPt, minClusterPt, maxClusterPt);
1622  fTrueList[iCut]->Add(fHistoTrueClusConvGammaMCPt[iCut]);
1623  fHistoTrueClusConvGammaFullyPt[iCut] = new TH1F("TrueClusConvGammaFullyContained_Pt","TrueClusConvGammaFullyContained_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1624  fTrueList[iCut]->Add(fHistoTrueClusConvGammaFullyPt[iCut]);
1625  fHistoTrueClusMergedGammaPt[iCut] = new TH1F("TrueClusMergedGamma_Pt","TrueClusMergedGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1626  fTrueList[iCut]->Add(fHistoTrueClusMergedGammaPt[iCut]);
1627  fHistoTrueClusMergedPartConvGammaPt[iCut] = new TH1F("TrueClusMergedPartConvGamma_Pt","TrueClusMergedPartConvGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1629  fHistoTrueClusDalitzPt[iCut] = new TH1F("TrueClusDalitz_Pt","TrueClusDalitz_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1630  fTrueList[iCut]->Add(fHistoTrueClusDalitzPt[iCut]);
1631  fHistoTrueClusDalitzMergedPt[iCut] = new TH1F("TrueClusDalitzMerged_Pt","TrueClusDalitzMerged_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1632  fTrueList[iCut]->Add(fHistoTrueClusDalitzMergedPt[iCut]);
1633  fHistoTrueClusPhotonFromElecMotherPt[iCut] = new TH1F("TrueClusPhotonFromElecMother_Pt","TrueClusPhotonFromElecMother_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1635  fHistoTrueClusShowerPt[iCut] = new TH1F("TrueClusShower_Pt","TrueClusShower_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1636  fTrueList[iCut]->Add(fHistoTrueClusShowerPt[iCut]);
1637  fHistoTrueClusSubLeadingPt[iCut] = new TH1F("TrueClusSubleading_Pt","TrueClusSubleading_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1638  fTrueList[iCut]->Add(fHistoTrueClusSubLeadingPt[iCut]);
1639  fHistoTrueClusNParticles[iCut] = new TH1F("TrueClusNParticles","TrueClusNParticles",20,0,20);
1640  fTrueList[iCut]->Add(fHistoTrueClusNParticles[iCut]);
1641  fHistoTrueClusEMNonLeadingPt[iCut] = new TH1F("TrueClusEMNonLeading_Pt","TrueClusEMNonLeading_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1642  fTrueList[iCut]->Add(fHistoTrueClusEMNonLeadingPt[iCut]);
1643 
1644  if (fIsMC > 1){
1645  fHistoTrueClusUnConvGammaPt[iCut]->Sumw2();
1646  fHistoTrueClusUnConvGammaMCPt[iCut]->Sumw2();
1647  if (!fDoLightOutput)
1648  fHistoTrueClusUnConvGammaPtM02[iCut]->Sumw2();
1649  fHistoTrueClusElectronPt[iCut]->Sumw2();
1650  fHistoTrueClusConvGammaPt[iCut]->Sumw2();
1651  fHistoTrueClusConvGammaMCPt[iCut]->Sumw2();
1652  fHistoTrueClusConvGammaFullyPt[iCut]->Sumw2();
1653  fHistoTrueClusMergedGammaPt[iCut]->Sumw2();
1654  fHistoTrueClusMergedPartConvGammaPt[iCut]->Sumw2();
1655  fHistoTrueClusDalitzPt[iCut]->Sumw2();
1656  fHistoTrueClusDalitzMergedPt[iCut]->Sumw2();
1657  fHistoTrueClusPhotonFromElecMotherPt[iCut]->Sumw2();
1658  fHistoTrueClusShowerPt[iCut]->Sumw2();
1659  fHistoTrueClusSubLeadingPt[iCut]->Sumw2();
1660  fHistoTrueClusNParticles[iCut]->Sumw2();
1661  fHistoTrueClusEMNonLeadingPt[iCut]->Sumw2();
1662  }
1663  }
1664 
1665  if(fDoMesonAnalysis){
1666  fHistoTruePi0InvMassPt[iCut] = new TH2F("ESD_TruePi0_InvMass_Pt","ESD_TruePi0_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1667  fTrueList[iCut]->Add(fHistoTruePi0InvMassPt[iCut]);
1668  fHistoTrueEtaInvMassPt[iCut] = new TH2F("ESD_TrueEta_InvMass_Pt","ESD_TrueEta_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1669  fTrueList[iCut]->Add(fHistoTrueEtaInvMassPt[iCut]);
1670 
1671  fHistoDoubleCountTruePi0InvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountPi0_InvMass_Pt","ESD_TrueDoubleCountPi0_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1672  fTrueList[iCut]->Add(fHistoDoubleCountTruePi0InvMassPt[iCut]);
1673  fHistoDoubleCountTrueEtaInvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountEta_InvMass_Pt","ESD_TrueDoubleCountEta_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1674  fTrueList[iCut]->Add(fHistoDoubleCountTrueEtaInvMassPt[iCut]);
1675 
1676  fHistoTruePrimaryPi0InvMassPt[iCut] = new TH2F("ESD_TruePrimaryPi0_InvMass_Pt", "ESD_TruePrimaryPi0_InvMass_Pt", 800,0,0.8,nBinsPt, minPt, maxPt);
1677  fHistoTruePrimaryPi0InvMassPt[iCut]->Sumw2();
1678  fTrueList[iCut]->Add(fHistoTruePrimaryPi0InvMassPt[iCut]);
1679  fHistoTruePrimaryEtaInvMassPt[iCut] = new TH2F("ESD_TruePrimaryEta_InvMass_Pt", "ESD_TruePrimaryEta_InvMass_Pt", 800,0,0.8,nBinsPt, minPt, maxPt);
1680  fHistoTruePrimaryEtaInvMassPt[iCut]->Sumw2();
1681  fTrueList[iCut]->Add(fHistoTruePrimaryEtaInvMassPt[iCut]);
1682 
1683  fHistoTruePrimaryPi0W0WeightingInvMassPt[iCut] = new TH2F("ESD_TruePrimaryPi0W0Weights_InvMass_Pt", "ESD_TruePrimaryPi0W0Weights_InvMass_Pt", 800,0,0.8,nBinsPt, minPt, maxPt);
1686  fHistoTruePrimaryEtaW0WeightingInvMassPt[iCut] = new TH2F("ESD_TruePrimaryEtaW0Weights_InvMass_Pt", "ESD_TruePrimaryEtaW0Weights_InvMass_Pt", 800,0,0.8,nBinsPt, minPt, maxPt);
1689 
1690  fProfileTruePrimaryPi0WeightsInvMassPt[iCut] = new TProfile2D("ESD_TruePrimaryPi0Weights_InvMass_Pt", "ESD_TruePrimaryPi0Weights_InvMass_Pt", 800,0,0.8,nBinsPt, minPt, maxPt);
1693  fProfileTruePrimaryEtaWeightsInvMassPt[iCut] = new TProfile2D("ESD_TruePrimaryEtaWeights_InvMass_Pt", "ESD_TruePrimaryEtaWeights_InvMass_Pt", 800,0,0.8,nBinsPt, minPt, maxPt);
1696 
1697  fHistoTrueSecondaryPi0InvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0_InvMass_Pt", "ESD_TrueSecondaryPi0_InvMass_Pt", 800,0,0.8,nBinsPt, minPt, maxPt);
1698  fHistoTrueSecondaryPi0InvMassPt[iCut]->Sumw2();
1699  fTrueList[iCut]->Add(fHistoTrueSecondaryPi0InvMassPt[iCut]);
1700 
1701  if(!fDoLightOutput){
1702  fHistoTruePi0InvMassPtAlpha[iCut] = new TH2F("ESD_TruePi0_InvMass_vs_Pt_Alpha","ESD_TruePi0_InvMass_vs_Pt_Alpha",800,0,0.8,nBinsPt, minPt, maxPt);
1703  fHistoTruePi0InvMassPtAlpha[iCut]->Sumw2();
1704  fESDList[iCut]->Add(fHistoTruePi0InvMassPtAlpha[iCut]);
1705  fHistoTruePi0PureGammaInvMassPtAlpha[iCut] = new TH2F("ESD_TruePi0PureGamma_InvMass_vs_Pt_Alpha","ESD_TruePi0PureGamma_InvMass_vs_Pt_Alpha",800,0,0.8,nBinsPt, minPt, maxPt);
1706  fHistoTruePi0PureGammaInvMassPtAlpha[iCut]->Sumw2();
1708  }
1709 
1710  fHistoTrueSecondaryPi0FromK0sInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0FromK0s_InvMass_Pt","ESD_TrueSecondaryPi0FromK0s_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1713  fHistoTrueSecondaryPi0FromK0lInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0FromK0l_InvMass_Pt","ESD_TrueSecondaryPi0FromK0l_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1716  fHistoTrueSecondaryPi0FromEtaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0FromEta_InvMass_Pt","ESD_TrueSecondaryPi0FromEta_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1718  fHistoTrueSecondaryPi0FromLambdaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0FromLambda_InvMass_Pt","ESD_TrueSecondaryPi0FromLambda_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1720 
1721  if (fIsMC > 1){
1722  fHistoTruePi0InvMassPt[iCut]->Sumw2();
1723  fHistoTrueEtaInvMassPt[iCut]->Sumw2();
1724  fHistoDoubleCountTruePi0InvMassPt[iCut]->Sumw2();
1725  fHistoDoubleCountTrueEtaInvMassPt[iCut]->Sumw2();
1730  }
1731 
1732 
1733  if (fDoMesonQA > 0 && fDoMesonQA < 3){
1734  if (fIsMC < 2){
1735 
1736  fHistoTruePi0CaloPhotonInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloPhoton_InvMass_Pt","ESD_TruePi0CaloPhoton_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1737  fTrueList[iCut]->Add(fHistoTruePi0CaloPhotonInvMassPt[iCut]);
1738  fHistoTrueEtaCaloPhotonInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloPhoton_InvMass_Pt","ESD_TrueEtaCaloPhoton_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1739  fTrueList[iCut]->Add(fHistoTrueEtaCaloPhotonInvMassPt[iCut]);
1740 
1741  fHistoTruePi0CaloMixedPhotonConvPhotonInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloMixedPhotonConvertedPhoton_InvMass_Pt","ESD_TruePi0CaloMixedPhotonConvertedPhoton_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1743  fHistoTrueEtaCaloMixedPhotonConvPhotonInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloMixedPhotonConvertedPhoton_InvMass_Pt","ESD_TrueEtaCaloMixedPhotonConvertedPhoton_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1745 
1746  fHistoTruePi0CaloConvertedPhotonInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloConvertedPhoton_InvMass_Pt","ESD_TruePi0CaloConvertedPhoton_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1748  fHistoTrueEtaCaloConvertedPhotonInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloConvertedPhoton_InvMass_Pt","ESD_TrueEtaCaloConvertedPhoton_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1750 
1751  fHistoTruePi0CaloElectronInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloElectron_InvMass_Pt","ESD_TruePi0CaloElectron_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1753  fHistoTrueEtaCaloElectronInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloElectron_InvMass_Pt","ESD_TrueEtaCaloElectron_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1755 
1756  fHistoTruePi0CaloMergedClusterInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloMergedCluster_InvMass_Pt","ESD_TruePi0CaloMergedCluster_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1758  fHistoTrueEtaCaloMergedClusterInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloMergedCluster_InvMass_Pt","ESD_TrueEtaCaloMergedCluster_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1760 
1761  fHistoTruePi0CaloMergedClusterPartConvInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloMergedClusterPartConv_InvMass_Pt","ESD_TruePi0CaloMergedClusterPartConv_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1763  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloMergedClusterPartConv_InvMass_Pt","ESD_TrueEtaCaloMergedClusterPartConv_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1765 
1766  fHistoTruePi0NonMergedElectronPhotonInvMassPt[iCut] = new TH2F("ESD_TruePi0NonMergedElectronPhoton_InvMass_Pt","ESD_TruePi0NonMergedElectronPhoton_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1768  fHistoTruePi0NonMergedElectronMergedPhotonInvMassPt[iCut] = new TH2F("ESD_TruePi0NonMergedElectronMergedPhoton_InvMass_Pt","ESD_TruePi0NonMergedElectronMergedPhoton_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1770 
1771  fHistoTruePrimaryPi0MCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryPi0_MCPt_ResolPt","ESD_TruePrimaryPi0_ResolPt_MCPt",500,0.03,35,1000,-1.,1.);
1772  fHistoTruePrimaryPi0MCPtResolPt[iCut]->Sumw2();
1774  fTrueList[iCut]->Add(fHistoTruePrimaryPi0MCPtResolPt[iCut]);
1775  fHistoTruePrimaryEtaMCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryEta_MCPt_ResolPt","ESD_TruePrimaryEta_ResolPt_MCPt",500,0.03,35,1000,-1.,1.);
1776  fHistoTruePrimaryEtaMCPtResolPt[iCut]->Sumw2();
1778  fTrueList[iCut]->Add(fHistoTruePrimaryEtaMCPtResolPt[iCut]);
1779  fHistoTrueK0sWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueK0sWithPi0Daughter_MCPt","ESD_TrueK0sWithPi0Daughter_MCPt",nBinsPt, minPt, maxPt);
1780  fTrueList[iCut]->Add(fHistoTrueK0sWithPi0DaughterMCPt[iCut]);
1781  fHistoTrueK0lWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueK0lWithPi0Daughter_MCPt","ESD_TrueK0lWithPi0Daughter_MCPt",nBinsPt, minPt, maxPt);
1782  fTrueList[iCut]->Add(fHistoTrueK0lWithPi0DaughterMCPt[iCut]);
1783  fHistoTrueEtaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueEtaWithPi0Daughter_MCPt","ESD_TrueEtaWithPi0Daughter_MCPt",nBinsPt, minPt, maxPt);
1784  fTrueList[iCut]->Add(fHistoTrueEtaWithPi0DaughterMCPt[iCut]);
1785  fHistoTrueLambdaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueLambdaWithPi0Daughter_MCPt","ESD_TrueLambdaWithPi0Daughter_MCPt",nBinsPt, minPt, maxPt);
1787  }
1788 
1789  fHistoTruePi0PtY[iCut] = new TH2F("ESD_TruePi0_Pt_Y","ESD_TruePi0_Pt_Y",nBinsQAPt, minQAPt, maxQAPt,150,-1.5,1.5);
1791  fTrueList[iCut]->Add(fHistoTruePi0PtY[iCut]);
1792  fHistoTrueEtaPtY[iCut] = new TH2F("ESD_TrueEta_Pt_Y","ESD_TrueEta_Pt_Y",nBinsQAPt, minQAPt, maxQAPt,150,-1.5,1.5);
1794  fTrueList[iCut]->Add(fHistoTrueEtaPtY[iCut]);
1795  fHistoTruePi0PtAlpha[iCut] = new TH2F("ESD_TruePi0_Pt_Alpha","ESD_TruePi0_Pt_Alpha",nBinsQAPt, minQAPt, maxQAPt,100,0,1);
1797  fTrueList[iCut]->Add(fHistoTruePi0PtAlpha[iCut]);
1798  fHistoTrueEtaPtAlpha[iCut] = new TH2F("ESD_TrueEta_Pt_Alpha","ESD_TrueEta_Pt_Alpha",nBinsQAPt, minQAPt, maxQAPt,100,0,1);
1800  fTrueList[iCut]->Add(fHistoTrueEtaPtAlpha[iCut]);
1801 
1802  fHistoTruePi0PtOpenAngle[iCut] = new TH2F("ESD_TruePi0_Pt_OpenAngle","ESD_TruePi0_Pt_OpenAngle",nBinsQAPt, minQAPt, maxQAPt,100,0,0.5);
1804  fTrueList[iCut]->Add(fHistoTruePi0PtOpenAngle[iCut]);
1805  fHistoTrueEtaPtOpenAngle[iCut] = new TH2F("ESD_TrueEta_Pt_OpenAngle","ESD_TrueEta_Pt_OpenAngle",nBinsQAPt, minQAPt, maxQAPt,180,0,1.8);
1807  fTrueList[iCut]->Add(fHistoTrueEtaPtOpenAngle[iCut]);
1808 
1809  fHistoTrueBckGGInvMassPt[iCut] = new TH2F("ESD_TrueBckGG_InvMass_Pt","ESD_TrueBckGG_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1810  fTrueList[iCut]->Add(fHistoTrueBckGGInvMassPt[iCut]);
1811  fHistoTrueBckFullMesonContainedInOneClusterInvMassPt[iCut] = new TH2F("ESD_TrueBckFullMesonContained_InvMass_Pt","ESD_TrueBckFullMesonContained_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1813  fHistoTrueBckAsymEClustersInvMassPt[iCut] = new TH2F("ESD_TrueBckAsymEClus_InvMass_Pt","ESD_TrueBckAsymEClus_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1815  fHistoTrueBckContInvMassPt[iCut] = new TH2F("ESD_TrueBckCont_InvMass_Pt","ESD_TrueBckCont_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1816  fTrueList[iCut]->Add(fHistoTrueBckContInvMassPt[iCut]);
1817 
1818  if (fIsMC > 1){
1819  fHistoTruePi0PtY[iCut]->Sumw2();
1820  fHistoTrueEtaPtY[iCut]->Sumw2();
1821  fHistoTruePi0PtAlpha[iCut]->Sumw2();
1822  fHistoTrueEtaPtAlpha[iCut]->Sumw2();
1823  fHistoTruePi0PtOpenAngle[iCut]->Sumw2();
1824  fHistoTrueEtaPtOpenAngle[iCut]->Sumw2();
1825  fHistoTrueBckGGInvMassPt[iCut]->Sumw2();
1827  fHistoTrueBckAsymEClustersInvMassPt[iCut]->Sumw2();
1828  fHistoTrueBckContInvMassPt[iCut]->Sumw2();
1829  }
1830 
1831  }
1832 
1833  if (fDoMesonQA == 2 && fIsMC < 2){
1834  fHistoTruePi0Category1[iCut] = new TH2F("ESD_TruePi0Category1_InvMass_Pt","ESD_TruePi0Category1_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1835  fTrueList[iCut]->Add(fHistoTruePi0Category1[iCut]);
1836  fHistoTrueEtaCategory1[iCut] = new TH2F("ESD_TrueEtaCategory1_InvMass_Pt","ESD_TrueEtaCategory1_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1837  fTrueList[iCut]->Add(fHistoTrueEtaCategory1[iCut]);
1838  fHistoTruePi0Category2[iCut] = new TH2F("ESD_TruePi0Category2_InvMass_Pt","ESD_TruePi0Category2_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1839  fTrueList[iCut]->Add(fHistoTruePi0Category2[iCut]);
1840  fHistoTrueEtaCategory2[iCut] = new TH2F("ESD_TrueEtaCategory2_InvMass_Pt","ESD_TrueEtaCategory2_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1841  fTrueList[iCut]->Add(fHistoTrueEtaCategory2[iCut]);
1842  fHistoTruePi0Category3[iCut] = new TH2F("ESD_TruePi0Category3_InvMass_Pt","ESD_TruePi0Category3_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1843  fTrueList[iCut]->Add(fHistoTruePi0Category3[iCut]);
1844  fHistoTrueEtaCategory3[iCut] = new TH2F("ESD_TrueEtaCategory3_InvMass_Pt","ESD_TrueEtaCategory3_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1845  fTrueList[iCut]->Add(fHistoTrueEtaCategory3[iCut]);
1846  fHistoTruePi0Category4_6[iCut] = new TH2F("ESD_TruePi0Category4_6_InvMass_Pt","ESD_TruePi0Category4_6_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1847  fTrueList[iCut]->Add(fHistoTruePi0Category4_6[iCut]);
1848  fHistoTrueEtaCategory4_6[iCut] = new TH2F("ESD_TrueEtaCategory4_6_InvMass_Pt","ESD_TrueEtaCategory4_6_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1849  fTrueList[iCut]->Add(fHistoTrueEtaCategory4_6[iCut]);
1850  fHistoTruePi0Category5[iCut] = new TH2F("ESD_TruePi0Category5_InvMass_Pt","ESD_TruePi0Category5_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1851  fTrueList[iCut]->Add(fHistoTruePi0Category5[iCut]);
1852  fHistoTrueEtaCategory5[iCut] = new TH2F("ESD_TrueEtaCategory5_InvMass_Pt","ESD_TrueEtaCategory5_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1853  fTrueList[iCut]->Add(fHistoTrueEtaCategory5[iCut]);
1854  fHistoTruePi0Category7[iCut] = new TH2F("ESD_TruePi0Category7_InvMass_Pt","ESD_TruePi0Category7_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1855  fTrueList[iCut]->Add(fHistoTruePi0Category7[iCut]);
1856  fHistoTrueEtaCategory7[iCut] = new TH2F("ESD_TrueEtaCategory7_InvMass_Pt","ESD_TrueEtaCategory7_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1857  fTrueList[iCut]->Add(fHistoTrueEtaCategory7[iCut]);
1858  fHistoTruePi0Category8[iCut] = new TH2F("ESD_TruePi0Category8_InvMass_Pt","ESD_TruePi0Category8_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1859  fTrueList[iCut]->Add(fHistoTruePi0Category8[iCut]);
1860  fHistoTrueEtaCategory8[iCut] = new TH2F("ESD_TrueEtaCategory8_InvMass_Pt","ESD_TrueEtaCategory8_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1861  fTrueList[iCut]->Add(fHistoTrueEtaCategory8[iCut]);
1862  }
1863 
1864  if (fDoMesonQA == 3){
1865  fTreeList[iCut] = new TList();
1866  fTreeList[iCut]->SetName(Form("%s_%s_%s True ClusterComb tree",cutstringEvent.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
1867  fTreeList[iCut]->SetOwner(kTRUE);
1868  fCutFolder[iCut]->Add(fTreeList[iCut]);
1869 
1870  tTrueInvMassROpenABPtFlag[iCut] = new TTree("True_InvMass_R_OpenA_OpenB_Pt_Flag","True_InvMass_R_OpenA_OpenB_Pt_Flag");
1871  tTrueInvMassROpenABPtFlag[iCut]->Branch("InvMass",&fInvMass,"fInvMass/F");
1872  tTrueInvMassROpenABPtFlag[iCut]->Branch("RConv",&fRconv,"fRconv/F");
1873  tTrueInvMassROpenABPtFlag[iCut]->Branch("OpenAngleRPrimVtx",&fOpenRPrim,"fOpenRPrim/F");
1874  tTrueInvMassROpenABPtFlag[iCut]->Branch("InvMassRTOF",&fInvMassRTOF,"fInvMassRTOF/F");
1875  tTrueInvMassROpenABPtFlag[iCut]->Branch("Pt",&fPt,"fPt/F");
1876 // tTrueInvMassROpenABPtFlag[iCut]->Branch("Weight",&fWeightJetJetMC,"fWeightJetJetMC/F");
1877  tTrueInvMassROpenABPtFlag[iCut]->Branch("cat",&iFlag,"iFlag/b");
1878  fTreeList[iCut]->Add(tTrueInvMassROpenABPtFlag[iCut]);
1879  }
1880  }
1881  }
1882  }
1883 
1887 
1889 
1890  if(fV0Reader)
1892  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
1893  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
1894  if(fV0Reader)
1896  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms())
1897  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
1898 
1899  for(Int_t iMatcherTask = 0; iMatcherTask < 3; iMatcherTask++){
1900  AliCaloTrackMatcher* temp = (AliCaloTrackMatcher*) (AliAnalysisManager::GetAnalysisManager()->GetTask(Form("CaloTrackMatcher_%i",iMatcherTask)));
1901  if(temp) fOutputContainer->Add(temp->GetCaloTrackMatcherHistograms());
1902  }
1903 
1904  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1905  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))) continue;
1906  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms()){
1907  fCutFolder[iCut]->Add(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
1908  }
1909  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
1910  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms()){
1911  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms());
1912  }
1913  if(fSetPlotHistsExtQA){
1914  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
1915  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetExtQAHistograms()){
1916  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetExtQAHistograms());
1917  }
1918  }
1919  if(fDoMesonAnalysis){
1920  if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
1921  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
1922  fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
1923  }
1924  }
1925  }
1926 
1927  if (fIsMC > 0 ){
1928  tBrokenFiles = new TTree("BrokenFiles","BrokenFiles");
1929  tBrokenFiles->Branch("fileName",&fFileNameBroken);
1931  }
1932  if (fDoClusterQA > 1){
1933  tClusterQATree = new TTree("ClusterQATree","ClusterQATree");
1934  tClusterQATree->Branch("closeHighPtClusters",&fCloseHighPtClusters);
1936  }
1937 
1938  if(fLocalDebugFlag > 0){
1939  fstream fOutputLocalDebug;
1940  fOutputLocalDebug.open("debugOutput.txt",ios::out);
1941  fOutputLocalDebug.close();
1942  }
1943 
1944  PostData(1, fOutputContainer);
1945 }
1946 //_____________________________________________________________________________
1948 {
1949  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1950  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
1951  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
1952  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
1953  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
1954  }
1955  if(fIsHeavyIon==2) {
1956  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift()){
1957  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1958  continue; // No Eta Shift requested, continue
1959  }
1960  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
1961  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
1962  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1963  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1964  continue;
1965  }
1966  else{
1967  printf(" Gamma Conversion Task %s :: Eta Shift Manually Set to %f \n\n",
1968  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
1969  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1970  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1971  }
1972  }
1973  }
1974 
1975  return kTRUE;
1976 }
1977 //_____________________________________________________________________________
1979 {
1980  //
1981  // Called for each event
1982  //
1983  fInputEvent = InputEvent();
1984  fCloseHighPtClusters = 0x0;
1985  if(fIsMC> 0) fMCEvent = MCEvent();
1986 
1987  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
1988  if(fInputEvent->IsIncompleteDAQ()==kTRUE) eventQuality = 2; // incomplete event
1989  if(eventQuality == 2 || eventQuality == 3){// Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1 or because it is incomplete
1990  // write out name of broken file for first event
1991  if (fIsMC > 0){
1992  if (fInputEvent->IsA()==AliESDEvent::Class()){
1993  if (((AliESDEvent*)fInputEvent)->GetEventNumberInFile() == 0){
1994  fFileNameBroken = new TObjString(Form("%s",((TString)fV0Reader->GetCurrentFileName()).Data()));
1995  if (tBrokenFiles) tBrokenFiles->Fill();
1996  delete fFileNameBroken;
1997  }
1998  }
1999  }
2000 
2001  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
2002  fHistoNEvents[iCut]->Fill(eventQuality);
2003  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
2004  }
2005  return;
2006  }
2007 
2008  // ------------------- BeginEvent ----------------------------
2009 
2010  AliEventplane *EventPlane = fInputEvent->GetEventplane();
2011  if(fIsHeavyIon ==1)fEventPlaneAngle = EventPlane->GetEventplane("V0",fInputEvent,2);
2012  else fEventPlaneAngle=0.0;
2013 
2014  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
2015 
2016  fiCut = iCut;
2017 
2019  Bool_t isRunningEMCALrelAna = kFALSE;
2020  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetClusterType() == 1) isRunningEMCALrelAna = kTRUE;
2021 
2022  Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon, isRunningEMCALrelAna);
2023 
2024  if(fIsMC==2){
2025  Float_t xsection = -1.;
2026  Float_t ntrials = -1.;
2027  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetXSectionAndNTrials(fMCEvent,xsection,ntrials);
2028  if((xsection==-1.) || (ntrials==-1.)) AliFatal(Form("ERROR: GetXSectionAndNTrials returned invalid xsection/ntrials, periodName from V0Reader: '%s'",fV0Reader->GetPeriodName().Data()));
2029  fProfileJetJetXSection[iCut]->Fill(0.,xsection);
2030  fHistoJetJetNTrials[iCut]->Fill("#sum{NTrials}",ntrials);
2031  }
2032 
2033  if (fIsMC > 0){
2034  fWeightJetJetMC = 1;
2035  Bool_t isMCJet = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsJetJetMCEventAccepted( fMCEvent, fWeightJetJetMC );
2036  if (fIsMC == 3){
2037  Double_t weightMult = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetWeightForMultiplicity(fV0Reader->GetNumberOfPrimaryTracks());
2038  fWeightJetJetMC = fWeightJetJetMC*weightMult;
2039  }
2040 
2041  if (!isMCJet){
2042  fHistoNEvents[iCut]->Fill(10,fWeightJetJetMC);
2043  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(10);
2044  continue;
2045  }
2046  }
2047 
2048  Bool_t triggered = kTRUE;
2049  if(eventNotAccepted){
2050  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
2051  fHistoNEvents[iCut]->Fill(eventNotAccepted, fWeightJetJetMC); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
2052  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventNotAccepted);
2053  if (eventNotAccepted==3 && fIsMC>0){
2054  triggered = kFALSE;
2055  } else {
2056  continue;
2057  }
2058  }
2059 
2060  if(eventQuality != 0){// Event Not Accepted
2061  //cout << "event rejected due to: " <<eventQuality << endl;
2062  fHistoNEvents[iCut]->Fill(eventQuality, fWeightJetJetMC);
2063  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventQuality); // Should be 0 here
2064  continue;
2065  }
2066  if (triggered == kTRUE) {
2067  fHistoNEvents[iCut]->Fill(eventQuality, fWeightJetJetMC); // Should be 0 here
2068  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventQuality); // Should be 0 here
2069 
2071  fHistoVertexZ[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetZ(), fWeightJetJetMC);
2072  if(!fDoLightOutput){
2073  fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)), fWeightJetJetMC);
2074  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2) fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A(), fWeightJetJetMC);
2075  else fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C(), fWeightJetJetMC);
2076  }
2077  }
2078  if(fIsMC> 0){
2079  // Process MC Particle
2080  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
2081  if(fInputEvent->IsA()==AliESDEvent::Class()){
2082  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
2083  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
2084  fMCEvent);
2085  }
2086  else if(fInputEvent->IsA()==AliAODEvent::Class()){
2087  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
2088  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
2089  fInputEvent);
2090  }
2091 
2092  if(!fDoLightOutput){
2093  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader()){
2094  for(Int_t i = 0;i<(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader())->GetEntries();i++){
2095  TString nameBin= fHistoMCHeaders[iCut]->GetXaxis()->GetBinLabel(i+1);
2096  if (nameBin.CompareTo("")== 0){
2097  TString nameHeader = ((TObjString*)((TList*)((AliConvEventCuts*)fEventCutArray->At(iCut))
2098  ->GetAcceptedHeader())->At(i))->GetString();
2099  fHistoMCHeaders[iCut]->GetXaxis()->SetBinLabel(i+1,nameHeader.Data());
2100  }
2101  }
2102  }
2103  }
2104  }
2105  }
2106  if(fIsMC> 0){
2107  if(fInputEvent->IsA()==AliESDEvent::Class())
2109  if(fInputEvent->IsA()==AliAODEvent::Class())
2111  }
2112 
2113  if (triggered==kFALSE) continue;
2114 
2115  // it is in the loop to have the same conversion cut string (used also for MC stuff that should be same for V0 and Cluster)
2116  ProcessClusters(); // process calo clusters
2117 
2119 
2120  fHistoNGammaCandidates[iCut]->Fill(fClusterCandidates->GetEntries(), fWeightJetJetMC);
2122  if(fDoMesonAnalysis){ // Meson Analysis
2123 
2124  CalculatePi0Candidates(); // Combine Gammas from conversion and from calo
2125  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
2126  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
2127 
2128  CalculateBackground(); // Combinatorial Background
2129  UpdateEventByEventData(); // Store Event for mixed Events
2130  }
2131 
2132  }
2135  }
2136 
2137  if(fIsMC> 0){
2140  }
2141 
2142  fClusterCandidates->Clear(); // delete cluster candidates
2143  }
2145 
2146  PostData(1, fOutputContainer);
2147 }
2148 
2149 //________________________________________________________________________
2151 {
2152 
2153  Int_t nclus = 0;
2154  TClonesArray * arrClustersProcess = NULL;
2156  if(!fCorrTaskSetting.CompareTo("")){
2157  nclus = fInputEvent->GetNumberOfCaloClusters();
2158  } else {
2159  arrClustersProcess = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
2160  if(!arrClustersProcess)
2161  AliFatal(Form("%sClustersBranch was not found in AliAnalysisTaskGammaCalo! Check the correction framework settings!",fCorrTaskSetting.Data()));
2162  nclus = arrClustersProcess->GetEntries();
2163  }
2164 
2165  if(nclus == 0) return;
2166  // plotting histograms on cell/tower level, only if extendedMatchAndQA > 1
2167  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->FillHistogramsExtendedQA(fInputEvent,fIsMC);
2168 
2169  // match tracks to clusters
2170  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchTracksToClusters(fInputEvent,fWeightJetJetMC);
2171 
2172  // vertex
2173  Double_t vertex[3] = {0};
2174  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
2175 
2176  Double_t maxClusterEnergy = -1;
2177  Int_t maxClusterID = -1;
2178  map<Long_t,Int_t> mapIsClusterAccepted;
2179  map<Long_t,Int_t> mapIsClusterAcceptedWithoutTrackMatch;
2180  // Loop over EMCal clusters
2181  for(Long_t i = 0; i < nclus; i++){
2182 
2183  AliVCluster* clus = NULL;
2184  if(fInputEvent->IsA()==AliESDEvent::Class()){
2185  if(arrClustersProcess)
2186  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersProcess->At(i));
2187  else
2188  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(i));
2189  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
2190  if(arrClustersProcess)
2191  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersProcess->At(i));
2192  else
2193  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i));
2194  }
2195 
2196  if(!clus) continue;
2197  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC,fWeightJetJetMC,i)){
2198  if(fProduceTreeEOverP && ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedBeforeTrackMatch() ) mapIsClusterAcceptedWithoutTrackMatch[i] = 1;
2199  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetIsAcceptedForBasicCounting())fNCurrentClusterBasic++;
2200  delete clus;
2201  continue;
2202  }
2204 
2205  // TLorentzvector with cluster
2206  TLorentzVector clusterVector;
2207  clus->GetMomentum(clusterVector,vertex);
2208 
2209  TLorentzVector* tmpvec = new TLorentzVector();
2210  tmpvec->SetPxPyPzE(clusterVector.Px(),clusterVector.Py(),clusterVector.Pz(),clusterVector.E());
2211 
2212  // convert to AODConversionPhoton
2213  AliAODConversionPhoton *PhotonCandidate=new AliAODConversionPhoton(tmpvec);
2214  if(!PhotonCandidate){ delete clus; delete tmpvec; continue;}
2215 
2216  //determine maximum cluster energy in event
2217  if(fProduceCellIDPlots && (clus->E() > maxClusterEnergy)){
2218  maxClusterEnergy = clus->E();
2219  maxClusterID = (Int_t) i;
2220  }
2222  mapIsClusterAccepted[i] = 1;
2223  mapIsClusterAcceptedWithoutTrackMatch[i] = 1;
2224  }
2225 
2226  // Flag Photon as CaloPhoton
2227  PhotonCandidate->SetIsCaloPhoton();
2228  PhotonCandidate->SetCaloClusterRef(i);
2229  PhotonCandidate->SetLeadingCellID(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->FindLargestCellInCluster(clus,fInputEvent));
2230  // get MC label
2231  if(fIsMC> 0){
2232  Int_t* mclabelsCluster = clus->GetLabels();
2233  PhotonCandidate->SetNCaloPhotonMCLabels(clus->GetNLabels());
2234 // cout << clus->GetNLabels() << endl;
2235  if (clus->GetNLabels()>0){
2236  for (Int_t k =0; k< (Int_t)clus->GetNLabels(); k++){
2237  if (k< 50)PhotonCandidate->SetCaloPhotonMCLabel(k,mclabelsCluster[k]);
2238 // Int_t pdgCode = fMCEvent->Particle(mclabelsCluster[k])->GetPdgCode();
2239 // cout << "label " << k << "\t" << mclabelsCluster[k] << " pdg code: " << pdgCode << endl;
2240  }
2241  }
2242  }
2243 
2244  fIsFromDesiredHeader = kTRUE;
2246  // test whether largest contribution to cluster orginates in added signals
2247  if (fIsMC>0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() > 0){
2248  if ( ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetCaloPhotonMCLabel(0), fMCEvent, fInputEvent) == 0) fIsFromDesiredHeader = kFALSE;
2249  if (clus->GetNLabels()>1){
2250  Int_t* mclabelsCluster = clus->GetLabels();
2251  if (fLocalDebugFlag > 1) cout << "testing if other labels in cluster belong to different header, need to test " << (Int_t)clus->GetNLabels()-1 << " additional labels" << endl;
2252  for (Int_t l = 1; l < (Int_t)clus->GetNLabels(); l++ ){
2253  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(mclabelsCluster[l], fMCEvent, fInputEvent, fLocalDebugFlag) == 0) fIsOverlappingWithOtherHeader = kTRUE;
2254  }
2255  if (fLocalDebugFlag > 1 && fIsOverlappingWithOtherHeader) cout << "found overlapping header: " << endl;
2256  }
2257  }
2258 
2259  fHistoClusAllHeadersGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightJetJetMC);
2260  if (!fIsFromDesiredHeader) fHistoClusRejectedHeadersGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightJetJetMC);
2262 
2263 
2265  fHistoClusGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightJetJetMC);
2266  fHistoClusGammaE[fiCut]->Fill(PhotonCandidate->E(), fWeightJetJetMC);
2267  if (!fDoLightOutput && fDoClusterQA > 0) fHistoClusGammaPtM02[fiCut]->Fill(PhotonCandidate->Pt(), clus->GetM02(), fWeightJetJetMC);
2268  if(fIsMC> 0){
2269  if(fInputEvent->IsA()==AliESDEvent::Class()){
2270  ProcessTrueClusterCandidates(PhotonCandidate,clus);
2271  } else {
2272  ProcessTrueClusterCandidatesAOD(PhotonCandidate,clus);
2273  }
2274  }
2275 
2276  fClusterCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
2277  } else{
2278  delete PhotonCandidate;
2279  }
2280 
2281  delete clus;
2282  delete tmpvec;
2283  }
2284 
2285  if(fProduceCellIDPlots){
2286  for(Long_t i = 0; i < nclus; i++){
2287  if( mapIsClusterAccepted[i] != 1 ) continue;
2288 
2289  AliVCluster* clus = NULL;
2290  if(fInputEvent->IsA()==AliESDEvent::Class()){
2291  if(arrClustersProcess)
2292  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersProcess->At(i));
2293  else
2294  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(i));
2295  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
2296  if(arrClustersProcess)
2297  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersProcess->At(i));
2298  else
2299  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i));
2300  }
2301 
2302  if(!clus) continue;
2303 
2304  Int_t cellID = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->FindLargestCellInCluster(clus,fInputEvent);
2305  fHistCellIDvsClusterEnergy[fiCut]->Fill(clus->E(),cellID);
2306  if (maxClusterID == i && maxClusterID > -1 ) fHistCellIDvsClusterEnergyMax[fiCut]->Fill(maxClusterEnergy,cellID);
2307  delete clus;
2308  }
2309  }
2310 
2311  if(fProduceTreeEOverP){
2312  AliESDEvent *esdev = dynamic_cast<AliESDEvent*>(fInputEvent);
2313  AliAODEvent *aodev = 0;
2314  Bool_t isESD = kTRUE;
2315  if (!esdev) {
2316  isESD = kFALSE;
2317  aodev = dynamic_cast<AliAODEvent*>(fInputEvent);
2318  if (!aodev) {
2319  AliError("Task needs AOD or ESD event...");
2320  }
2321  }
2322 
2323  AliESDtrackCuts *EsdTrackCuts = 0x0;
2324  if(esdev){
2325  // Using standard function for setting Cuts
2326  Int_t runNumber = fInputEvent->GetRunNumber();
2327  // if LHC11a or earlier or if LHC13g or if LHC12a-i -> use 2010 cuts
2328  if( (runNumber<=146860) || (runNumber>=197470 && runNumber<=197692) || (runNumber>=172440 && runNumber<=193766) ){
2329  EsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010();
2330  // else if run2 data use 2015 PbPb cuts
2331  }else if (runNumber>=209122){
2332  EsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2015PbPb();
2333  // else use 2011 version of track cuts
2334  }else{
2335  EsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011();
2336  }
2337  EsdTrackCuts->SetMaxDCAToVertexZ(2);
2338  EsdTrackCuts->SetEtaRange(-0.8, 0.8);
2339  EsdTrackCuts->SetPtRange(0.15);
2340  }
2341 
2342  for(Long_t i = 0; i < nclus; i++){
2343  if( mapIsClusterAcceptedWithoutTrackMatch[i] != 1 ) continue;
2344 
2345  AliVCluster* clus = NULL;
2346  if(fInputEvent->IsA()==AliESDEvent::Class()){
2347  if(arrClustersProcess)
2348  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersProcess->At(i));
2349  else
2350  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(i));
2351  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
2352  if(arrClustersProcess)
2353  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersProcess->At(i));
2354  else
2355  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i));
2356  }
2357 
2358  if(!clus) continue;
2359 
2360  fClusterE = clus->E();
2361  fClusterM02 = clus->GetM02();
2362  fClusterM20 = clus->GetM20();
2363  fClusterLeadCellID = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->FindLargestCellInCluster(clus,fInputEvent);
2364 
2365  Int_t labelTrackMatch = -1;
2366  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetHighestPtMatchedTrackToCluster(fInputEvent,clus,labelTrackMatch)){
2367  delete clus;
2368  continue;
2369  }
2370 
2371  AliVTrack* currTrack = dynamic_cast<AliVTrack*>(fInputEvent->GetTrack(labelTrackMatch));
2372  if(!currTrack){
2373  delete clus;
2374  continue;
2375  }
2376  if(esdev){
2377  AliESDtrack *esdt = dynamic_cast<AliESDtrack*>(currTrack);
2378  if(!EsdTrackCuts->AcceptTrack(esdt)){
2379  delete clus;
2380  continue;
2381  }
2382  if(esdt->Pt()<1.){
2383  delete clus;
2384  continue;
2385  }
2386  fClusterEP = fClusterE/esdt->P();
2387  fTrackPt = esdt->Pt();
2388  }else if(aodev){
2389  AliAODTrack *aodt = dynamic_cast<AliAODTrack*>(currTrack);
2390  if(!aodt->IsHybridGlobalConstrainedGlobal()){
2391  delete clus;
2392  continue;
2393  }
2394  if(TMath::Abs(aodt->Eta())>0.8){
2395  delete clus;
2396  continue;
2397  }
2398  if(aodt->Pt()<1.){
2399  delete clus;
2400  continue;
2401  }
2402  fClusterEP = fClusterE/aodt->P();
2403  fTrackPt = aodt->Pt();
2404  }
2405 
2406  AliPIDResponse* pidResponse = ((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetPIDResponse();
2407  if(!pidResponse){
2408  delete clus;
2409  continue;
2410  }
2411 
2412  Float_t temp = TMath::Abs(pidResponse->NumberOfSigmasTPC(currTrack,AliPID::kElectron));
2413  if(temp<10.){
2414  fTrackPID_e = temp*10;
2415  }else fTrackPID_e = 99;
2416 
2417  temp = TMath::Abs(pidResponse->NumberOfSigmasTPC(currTrack,AliPID::kPion));
2418  if(temp<10.){
2419  fTrackPID_Pi = temp*10;
2420  }else fTrackPID_Pi = 99;
2421 
2422  temp = TMath::Abs(pidResponse->NumberOfSigmasTPC(currTrack,AliPID::kKaon));
2423  if(temp<10.){
2424  fTrackPID_K = temp*10;
2425  }else fTrackPID_K = 99;
2426 
2427  temp = TMath::Abs(pidResponse->NumberOfSigmasTPC(currTrack,AliPID::kProton));
2428  if(temp<10.){
2429  fTrackPID_P = temp*10;
2430  }else fTrackPID_P = 99;
2431 
2432  Float_t tempEta = -99999;
2433  Float_t tempPhi = -99999;
2434  ((AliCaloTrackMatcher*)((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetCaloTrackMatcherInstance())->GetTrackClusterMatchingResidual(currTrack->GetID(),clus->GetID(),tempEta,tempPhi);
2435  fDeltaEta = tempEta;
2436  fDeltaPhi = tempPhi;
2437 
2438  //determine isolation in cluster Et
2439  Float_t clsPos[3] = {0.,0.,0.};
2440  Float_t secondClsPos[3] = {0.,0.,0.};
2441  TLorentzVector clusterVector;
2442 
2443  clus->GetPosition(clsPos);
2444  TVector3 clsPosVec(clsPos);
2445 
2446  Float_t sum_Et = 0;
2447  for(Int_t j=0; j<nclus; j++){
2448  if( i == j ) continue;
2449  if( mapIsClusterAcceptedWithoutTrackMatch[j] != 1 ) continue;
2450 
2451  AliVCluster* secondClus = NULL;
2452  if(fInputEvent->IsA()==AliESDEvent::Class()){
2453  if(arrClustersProcess)
2454  secondClus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersProcess->At(j));
2455  else
2456  secondClus = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(j));
2457  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
2458  if(arrClustersProcess)
2459  secondClus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersProcess->At(j));
2460  else
2461  secondClus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(j));
2462  }
2463 
2464  if(!secondClus) continue;
2465  secondClus->GetPosition(secondClsPos);
2466  TVector3 secondClsPosVec(secondClsPos);
2467 
2468  Float_t dPhi = clsPosVec.DeltaPhi(secondClsPosVec);
2469  Float_t dEta = clsPosVec.Eta()-secondClsPosVec.Eta();
2470  if(TMath::Sqrt(dEta*dEta + dPhi*dPhi) < 0.2){
2471  secondClus->GetMomentum(clusterVector,vertex);
2472  sum_Et += clusterVector.Et();
2473  }
2474  delete secondClus;
2475  }
2476  fClusterIsoSumClusterEt = sum_Et;
2477 
2478  //determine isolation in track Et
2479  fClusterIsoSumTrackEt = ((AliCaloTrackMatcher*)((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetCaloTrackMatcherInstance())->SumTrackEtAroundCluster(fInputEvent,clus->GetID(),0.2);
2480  //remove Et from matched track
2481  TLorentzVector vecTrack;
2482  vecTrack.SetPxPyPzE(currTrack->Px(),currTrack->Py(),currTrack->Pz(),currTrack->E());
2483  fClusterIsoSumTrackEt -= vecTrack.Et();
2484 
2485  //get cluster classification
2486  if(fIsMC > 0) fClusterClassification = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClassifyClusterForTMEffi(clus,fInputEvent,fMCEvent,isESD);
2487 
2488  tClusterEOverP[fiCut]->Fill();
2489  delete clus;
2490  }
2491  mapIsClusterAcceptedWithoutTrackMatch.clear();
2492  }
2493 
2494  if(fProduceCellIDPlots || fProduceTreeEOverP) mapIsClusterAccepted.clear();
2495 
2496  if(fLocalDebugFlag == 2) EventDebugMethod();
2497 
2498  return;
2499 }
2500 
2501 //________________________________________________________________________
2503 {
2504 
2505  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2506  Double_t mcProdVtxX = primVtxMC->GetX();
2507  Double_t mcProdVtxY = primVtxMC->GetY();
2508  Double_t mcProdVtxZ = primVtxMC->GetZ();
2509 
2510  TParticle *Photon = NULL;
2511  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
2513 
2514  if (TruePhotonCandidate->GetCaloPhotonMCLabel(0) < 0) return;
2515  if (TruePhotonCandidate->GetNCaloPhotonMCLabels() > 0) Photon = fMCEvent->Particle(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
2516  else return;
2517 
2518  if(Photon == NULL){
2519  // cout << "no photon" << endl;
2520  return;
2521  }
2522 
2523  Int_t pdgCodeParticle = Photon->GetPdgCode();
2524  TruePhotonCandidate->SetCaloPhotonMCFlags(fMCEvent, fEnableSortForClusMC);
2525 
2526  // True Photon
2527 
2528  if (TruePhotonCandidate->IsLargestComponentPhoton() || (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())) {
2529  fHistoTrueClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2530  if (!fDoLightOutput && fDoClusterQA > 0) fHistoTrueClusGammaPtM02[fiCut]->Fill(TruePhotonCandidate->Pt(), clus->GetM02(), fWeightJetJetMC);
2531  } else if (fDoClusterQA > 0) fHistoTrueClusEMNonLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2532  if (fDoClusterQA > 0){
2533  if (TruePhotonCandidate->IsLargestComponentPhoton()){
2534  fHistoTrueClusUnConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2535  fHistoTrueClusUnConvGammaMCPt[fiCut]->Fill(Photon->Pt(), fWeightJetJetMC);
2536  if (!fDoLightOutput) fHistoTrueClusUnConvGammaPtM02[fiCut]->Fill(TruePhotonCandidate->Pt(), clus->GetM02(), fWeightJetJetMC);
2537  }
2538  if (TruePhotonCandidate->IsLargestComponentElectron())
2539  fHistoTrueClusElectronPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2540  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2541  fHistoTrueClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2542  if(Photon->GetMother(0) > -1){
2543  TParticle* motherPart = (TParticle*)fMCEvent->Particle(Photon->GetMother(0));
2544  fHistoTrueClusConvGammaMCPt[fiCut]->Fill(motherPart->Pt(), fWeightJetJetMC);
2545  }
2546  }
2547  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion() && TruePhotonCandidate->IsConversionFullyContained())
2548  fHistoTrueClusConvGammaFullyPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2549  if (TruePhotonCandidate->IsMerged() || TruePhotonCandidate->IsMergedPartConv() || TruePhotonCandidate->IsDalitzMerged())
2550  fHistoTrueClusMergedGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2551  if (TruePhotonCandidate->IsMergedPartConv())
2552  fHistoTrueClusMergedPartConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2553  if (TruePhotonCandidate->IsDalitz())
2554  fHistoTrueClusDalitzPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2555  if (TruePhotonCandidate->IsDalitzMerged())
2556  fHistoTrueClusDalitzMergedPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2557  if (TruePhotonCandidate->IsPhotonWithElecMother())
2558  fHistoTrueClusPhotonFromElecMotherPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2559  if (TruePhotonCandidate->IsShower())
2560  fHistoTrueClusShowerPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2561  if (TruePhotonCandidate->IsSubLeadingEM())
2562  fHistoTrueClusSubLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2563  fHistoTrueClusNParticles[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels(), fWeightJetJetMC);
2564  if (!TruePhotonCandidate->IsLargestComponentPhoton()) {
2565  FillPhotonBackgroundHist(TruePhotonCandidate,pdgCodeParticle);
2566  if (!fDoLightOutput) FillPhotonBackgroundM02Hist(TruePhotonCandidate,clus,pdgCodeParticle);
2567  }
2568  if (!(TruePhotonCandidate->IsLargestComponentPhoton() || (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())) ) {
2569  FillPhotonPlusConversionBackgroundHist(TruePhotonCandidate,pdgCodeParticle);
2570  if (!fDoLightOutput) FillPhotonPlusConversionBackgroundM02Hist(TruePhotonCandidate,clus,pdgCodeParticle);
2571  }
2572  Int_t motherLab = Photon->GetMother(0);
2573  if (motherLab > -1){
2574  if (TruePhotonCandidate->IsLargestComponentPhoton()){
2576  fHistoDoubleCountTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),(Double_t)0,fWeightJetJetMC);
2578  }
2579  }
2580  Int_t grandMotherLab = fMCEvent->Particle(motherLab)->GetMother(0);
2581  if (grandMotherLab > -1){
2582  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2584  fHistoDoubleCountTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),(Double_t)1,fWeightJetJetMC);
2586  }
2587  }
2588  }
2589  }
2590  }
2591 
2592  if(!fDoLightOutput){
2593  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, TruePhotonCandidate->GetCaloPhotonMCLabel(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2594  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
2595  isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, Photon->GetMother(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2596 
2597  if(isPrimary){
2598  // filling primary histograms
2599  if (TruePhotonCandidate->IsLargestComponentPhoton()){
2600  fHistoTruePrimaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2601  fHistoTruePrimaryClusGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(), fWeightJetJetMC); // Allways Filled
2602  }
2603  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2604  fHistoTruePrimaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2605  fHistoTruePrimaryClusConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(), fWeightJetJetMC); // Allways Filled
2606  }
2607 
2608  } else {
2609  // filling secondary histograms
2610  Int_t secondaryClass = -1;
2611  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
2612  secondaryClass = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->SecondaryClassificationPhoton( Photon, fMCEvent, kTRUE);
2613  else
2614  secondaryClass = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->SecondaryClassificationPhoton( Photon, fMCEvent, kFALSE);
2615 
2616  // all secondaries
2617  if (TruePhotonCandidate->IsLargestComponentPhoton()){
2618  if (secondaryClass == 2) {
2619  fHistoTrueSecondaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC);
2620  fHistoTrueSecondaryClusGammaMCPt[fiCut]->Fill(Photon->Pt(),0.,fWeightJetJetMC);
2621  fHistoTrueSecondaryClusGammaFromXFromK0sMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2622  } else if (secondaryClass == 5) {
2623  fHistoTrueSecondaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC);
2624  fHistoTrueSecondaryClusGammaMCPt[fiCut]->Fill(Photon->Pt(),1.,fWeightJetJetMC);
2625  fHistoTrueSecondaryClusGammaFromXFromK0lMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2626  } else if (secondaryClass == 3) {
2627  fHistoTrueSecondaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC);
2628  fHistoTrueSecondaryClusGammaMCPt[fiCut]->Fill(Photon->Pt(),2.,fWeightJetJetMC);
2629  fHistoTrueSecondaryClusGammaFromXFromLambdaMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2630  } else if (secondaryClass == 4) {
2631  fHistoTrueSecondaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC);
2632  fHistoTrueSecondaryClusGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC);
2633  } else {
2634  fHistoTrueSecondaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),4.,fWeightJetJetMC);
2635  fHistoTrueSecondaryClusGammaMCPt[fiCut]->Fill(Photon->Pt(),4.,fWeightJetJetMC);
2636  }
2637  }
2638  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2639  if (secondaryClass == 2) {
2640  fHistoTrueSecondaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC);
2642  fHistoTrueSecondaryClusConvGammaFromXFromK0sMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2643  } else if (secondaryClass == 5) {
2644  fHistoTrueSecondaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC);
2646  fHistoTrueSecondaryClusConvGammaFromXFromK0lMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2647  } else if (secondaryClass == 3) {
2648  fHistoTrueSecondaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC);
2650  fHistoTrueSecondaryClusConvGammaFromXFromLambdaMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2651  } else if (secondaryClass == 4) {
2652  fHistoTrueSecondaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC);
2654  } else {
2655  fHistoTrueSecondaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),4.,fWeightJetJetMC);
2657  }
2658  }
2659  }
2660  }
2661  return;
2662 }
2663 
2664 
2665 //________________________________________________________________________
2667 {
2668  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2669  Double_t mcProdVtxX = primVtxMC->GetX();
2670  Double_t mcProdVtxY = primVtxMC->GetY();
2671  Double_t mcProdVtxZ = primVtxMC->GetZ();
2672 
2673  AliAODMCParticle *Photon = NULL;
2674  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2676  if (AODMCTrackArray){
2677  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
2678  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0) Photon = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
2679  else return;
2680  } else {
2681  AliInfo("AODMCTrackArray could not be loaded");
2682  return;
2683  }
2684 
2685  if(Photon == NULL){
2686  // cout << "no photon" << endl;
2687  return;
2688  }
2689  Int_t pdgCodeParticle = Photon->GetPdgCode();
2691 
2692  // True Photon
2693  if (TruePhotonCandidate->IsLargestComponentPhoton() || (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())) {
2694  fHistoTrueClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2695  if (!fDoLightOutput && fDoClusterQA > 0) fHistoTrueClusGammaPtM02[fiCut]->Fill(TruePhotonCandidate->Pt(), clus->GetM02(), fWeightJetJetMC);
2696  } else if (fDoClusterQA > 0) fHistoTrueClusEMNonLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2697  if (fDoClusterQA > 0){
2698  if (TruePhotonCandidate->IsLargestComponentPhoton()) {
2699  fHistoTrueClusUnConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2700  fHistoTrueClusUnConvGammaMCPt[fiCut]->Fill(Photon->Pt(), fWeightJetJetMC);
2701  if (!fDoLightOutput) fHistoTrueClusUnConvGammaPtM02[fiCut]->Fill(TruePhotonCandidate->Pt(), clus->GetM02(), fWeightJetJetMC);
2702  }
2703  if (TruePhotonCandidate->IsLargestComponentElectron())
2704  fHistoTrueClusElectronPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2705  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()) {
2706  fHistoTrueClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2707  AliAODMCParticle *motherPart = (AliAODMCParticle*) AODMCTrackArray->At(Photon->GetMother());
2708  fHistoTrueClusConvGammaMCPt[fiCut]->Fill(motherPart->Pt(), fWeightJetJetMC);
2709  }
2710  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion() && TruePhotonCandidate->IsConversionFullyContained())
2711  fHistoTrueClusConvGammaFullyPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2712  if (TruePhotonCandidate->IsMerged() || TruePhotonCandidate->IsMergedPartConv() || TruePhotonCandidate->IsDalitzMerged())
2713  fHistoTrueClusMergedGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2714  if (TruePhotonCandidate->IsMergedPartConv())
2715  fHistoTrueClusMergedPartConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2716  if (TruePhotonCandidate->IsDalitz())
2717  fHistoTrueClusDalitzPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2718  if (TruePhotonCandidate->IsDalitzMerged())
2719  fHistoTrueClusDalitzMergedPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2720  if (TruePhotonCandidate->IsPhotonWithElecMother())
2721  fHistoTrueClusPhotonFromElecMotherPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2722  if (TruePhotonCandidate->IsShower())
2723  fHistoTrueClusShowerPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2724  if (TruePhotonCandidate->IsSubLeadingEM())
2725  fHistoTrueClusSubLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2726  fHistoTrueClusNParticles[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels(), fWeightJetJetMC);
2727 
2728  if (!TruePhotonCandidate->IsLargestComponentPhoton()) {
2729  FillPhotonBackgroundHist(TruePhotonCandidate,pdgCodeParticle);
2730  if (!fDoLightOutput) FillPhotonBackgroundM02Hist(TruePhotonCandidate,clus,pdgCodeParticle);
2731  }
2732  if (!(TruePhotonCandidate->IsLargestComponentPhoton() || (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())) ) {
2733  FillPhotonPlusConversionBackgroundHist(TruePhotonCandidate,pdgCodeParticle);
2734  if (!fDoLightOutput) FillPhotonPlusConversionBackgroundM02Hist(TruePhotonCandidate,clus,pdgCodeParticle);
2735  }
2736  Int_t motherLab = Photon->GetMother();
2737  if (motherLab > -1){
2738  if (TruePhotonCandidate->IsLargestComponentPhoton()){
2740  fHistoDoubleCountTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),(Double_t)0,fWeightJetJetMC);
2742  }
2743  }
2744  Int_t grandMotherLab = ((AliAODMCParticle*) AODMCTrackArray->At(motherLab))->GetMother();
2745  if (grandMotherLab > -1){
2746  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2748  fHistoDoubleCountTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),(Double_t)1,fWeightJetJetMC);
2750  }
2751  }
2752  }
2753  }
2754  }
2755 
2756  if(!fDoLightOutput){
2757  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2758  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2759  if (Photon->GetMother()> -1){
2760  AliAODMCParticle *Mother = (AliAODMCParticle*) AODMCTrackArray->At(Photon->GetMother());
2761  isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, Mother, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2762  }
2763  }
2764  if(isPrimary){
2765  if (TruePhotonCandidate->IsLargestComponentPhoton()){
2766  fHistoTruePrimaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2767  fHistoTruePrimaryClusGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(), fWeightJetJetMC); // Allways Filled
2768  }
2769  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2770  fHistoTruePrimaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2771  fHistoTruePrimaryClusConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(), fWeightJetJetMC); // Allways Filled
2772  }
2773 
2774  } else {
2775  // filling secondary histograms
2776  Int_t secondaryClass = -1;
2777  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
2778  secondaryClass = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->SecondaryClassificationPhotonAOD( Photon, AODMCTrackArray, kTRUE);
2779  else
2780  secondaryClass = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->SecondaryClassificationPhotonAOD( Photon, AODMCTrackArray, kFALSE);
2781 
2782  // all secondaries
2783  if (TruePhotonCandidate->IsLargestComponentPhoton()){
2784  if (secondaryClass == 2) {
2785  fHistoTrueSecondaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC);
2786  fHistoTrueSecondaryClusGammaMCPt[fiCut]->Fill(Photon->Pt(),0.,fWeightJetJetMC);
2787  fHistoTrueSecondaryClusGammaFromXFromK0sMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2788  } else if (secondaryClass == 5) {
2789  fHistoTrueSecondaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC);
2790  fHistoTrueSecondaryClusGammaMCPt[fiCut]->Fill(Photon->Pt(),1.,fWeightJetJetMC);
2791  fHistoTrueSecondaryClusGammaFromXFromK0lMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2792  } else if (secondaryClass == 3) {
2793  fHistoTrueSecondaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC);
2794  fHistoTrueSecondaryClusGammaMCPt[fiCut]->Fill(Photon->Pt(),2.,fWeightJetJetMC);
2795  fHistoTrueSecondaryClusGammaFromXFromLambdaMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2796  } else if (secondaryClass == 4) {
2797  fHistoTrueSecondaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC);
2798  fHistoTrueSecondaryClusGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC);
2799  } else {
2800  fHistoTrueSecondaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),4.,fWeightJetJetMC);
2801  fHistoTrueSecondaryClusGammaMCPt[fiCut]->Fill(Photon->Pt(),4.,fWeightJetJetMC);
2802  }
2803  }
2804  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2805  if (secondaryClass == 2) {
2806  fHistoTrueSecondaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC);
2808  fHistoTrueSecondaryClusConvGammaFromXFromK0sMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2809  } else if (secondaryClass == 5) {
2810  fHistoTrueSecondaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC);
2812  fHistoTrueSecondaryClusConvGammaFromXFromK0lMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2813  } else if (secondaryClass == 3) {
2814  fHistoTrueSecondaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC);
2816  fHistoTrueSecondaryClusConvGammaFromXFromLambdaMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2817  } else if (secondaryClass == 4) {
2818  fHistoTrueSecondaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC);
2820  } else {
2821  fHistoTrueSecondaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),4.,fWeightJetJetMC);
2823  }
2824  }
2825  }
2826  }
2827 
2828 }
2829 
2830 //________________________________________________________________________
2832 {
2833  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2834  Double_t mcProdVtxX = primVtxMC->GetX();
2835  Double_t mcProdVtxY = primVtxMC->GetY();
2836  Double_t mcProdVtxZ = primVtxMC->GetZ();
2837 
2838  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2839  if (AODMCTrackArray == NULL) return;
2840 
2841  // Loop over all primary MC particle
2842  for(Long_t i = 0; i < AODMCTrackArray->GetEntriesFast(); i++) {
2843 
2844  AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
2845  if (!particle) continue;
2846 
2847  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, particle, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2848  if (isPrimary){
2849 
2850  Int_t isMCFromMBHeader = -1;
2851  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2852  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2853  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2854  }
2855 
2856  if(!fDoLightOutput){
2857  if(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(particle,AODMCTrackArray)){
2858  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC); // All MC Gamma
2859  if(particle->GetMother() >-1){ // Meson Decay Gamma
2860  switch((static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother())))->GetPdgCode()){
2861  case 111: // Pi0
2862  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2863  break;
2864  case 113: // Rho0
2865  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2866  break;
2867  case 221: // Eta
2868  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2869  break;
2870  case 223: // Omega
2871  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2872  break;
2873  case 331: // Eta'
2874  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2875  break;
2876  case 333: // Phi
2877  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2878  break;
2879  case 3212: // Sigma
2880  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2881  break;
2882  }
2883  }
2884  }
2885  }
2886  // Converted MC Gamma
2887  if(fDoMesonAnalysis){
2888  Double_t mesonY = 1.e30;
2889  Double_t ratio = 0;
2890  if (particle->E() != TMath::Abs(particle->Pz())){
2891  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2892  }
2893  if( !(ratio <= 0) ){
2894  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2895  }
2896 
2897  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
2898  if ( particle->GetPdgCode() == 211 ){ // positve pions
2899  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 0., fWeightJetJetMC);
2900  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2901  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 1., fWeightJetJetMC);
2902  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2903  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 2., fWeightJetJetMC);
2904  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
2905  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 3., fWeightJetJetMC);
2906  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
2907  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 4., fWeightJetJetMC);
2908  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
2909  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 5., fWeightJetJetMC);
2910  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
2911  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 6., fWeightJetJetMC);
2912  }
2913  }
2914 
2916  ->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2917  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
2918  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
2919  Float_t weighted= 1;
2920  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2921  if (particle->Pt()>0.005){
2922  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, 0x0, fInputEvent);
2923  }
2924  }
2925 
2926  Double_t mesonY = 1.e30;
2927  Double_t ratio = 0;
2928  if (particle->E() != TMath::Abs(particle->Pz())){
2929  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2930  }
2931  if( !(ratio <= 0) ){
2932  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2933  }
2934  Double_t alpha = -1;
2935  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
2936  alpha = TMath::Abs((daughter0->E() - daughter1->E()))/(daughter0->E() + daughter1->E());
2937  }
2938 
2939  if(particle->GetPdgCode() == 111){
2940  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // All MC Pi0
2941  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2942  if (fIsMC > 1) fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
2943  if (fDoMesonQA > 0 && fDoMesonQA < 3){
2944  fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted* fWeightJetJetMC);
2945  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha, fWeightJetJetMC);
2946  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2947  }
2948  } else if(particle->GetPdgCode() == 221){
2949  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // All MC Eta
2950  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2951  if (fIsMC > 1) fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2952  if (fDoMesonQA > 0 && fDoMesonQA < 3){
2953  fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted* fWeightJetJetMC);
2954  fHistoMCEtaPtAlpha[fiCut]->Fill(particle->Pt(),alpha, fWeightJetJetMC);
2955  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2956  }
2957  }
2958 
2959  // Check the acceptance for both gammas
2960  if( ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter0,AODMCTrackArray) &&
2961  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter1,AODMCTrackArray) ){
2962 
2963  if(particle->GetPdgCode() == 111){
2964  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Pi0 with gamma in acc
2965  if(fIsMC > 1) fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 with gamma in acc
2966  } else if(particle->GetPdgCode() == 221){
2967  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Eta with gamma in acc
2968  if(fIsMC > 1) fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta with gamma in acc
2969  }
2970  }
2971  }
2972  }
2973  // fill secondaries
2974  } else {
2975  Int_t isMCFromMBHeader = -1;
2976  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2977  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2978  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2979  }
2980 
2981  if(!fDoLightOutput) {
2982  if(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(particle,AODMCTrackArray)){
2983  if(particle->GetMother() >-1){
2984  AliAODMCParticle *tmpMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2985  if(tmpMother->GetMother() >-1){
2986  AliAODMCParticle *tmpGrandMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(tmpMother->GetMother()));
2987  if(tmpGrandMother->GetPdgCode() == 310) {
2988  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2989  } else if (tmpGrandMother->GetPdgCode() == 130) {
2990  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2991  } else if (tmpGrandMother->GetPdgCode() == 3122) {
2992  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
2993  } else if (tmpGrandMother->GetPdgCode() == 221) {
2994  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2995  } else {
2996  if( !(TMath::Abs(tmpMother->GetPdgCode()) == 11 && tmpGrandMother->GetPdgCode() == 22) )
2997  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),4.,fWeightJetJetMC);
2998  }
2999  } else {
3000  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),4.,fWeightJetJetMC);
3001  }
3002  } else {
3003  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),4.,fWeightJetJetMC);
3004  }
3005  }
3006  }
3007 
3008  if(fDoMesonAnalysis){
3009  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3010  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
3011  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
3012  AliAODMCParticle* mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
3013  Int_t pdgCode = mother->GetPdgCode();
3014  if(particle->GetPdgCode() == 111){
3015  Int_t source = GetSourceClassification(111,pdgCode);
3016  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC); // All MC Pi0
3017  fHistoMCSecPi0Source[fiCut]->Fill(pdgCode);
3018  }else if(particle->GetPdgCode() == 221){
3019 
3020  fHistoMCSecEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // All MC Pi0
3021  fHistoMCSecEtaSource[fiCut]->Fill(pdgCode);
3022  }
3023 
3024  // check if conversion where within acceptance
3025  if( ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter0,AODMCTrackArray) &&
3026  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter1,AODMCTrackArray)){
3027  if(particle->GetPdgCode() == 111){
3028  Int_t source = GetSourceClassification(111,pdgCode);
3029  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC); // All MC Pi0
3030  }
3031  }
3032  }
3033  }
3034  }
3035  }
3036 }
3037 //________________________________________________________________________
3039 {
3040  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3041  Double_t mcProdVtxX = primVtxMC->GetX();
3042  Double_t mcProdVtxY = primVtxMC->GetY();
3043  Double_t mcProdVtxZ = primVtxMC->GetZ();
3044 
3045  // Loop over all primary MC particle
3046  for(Long_t i = 0; i < fMCEvent->GetNumberOfTracks(); i++) {
3047  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
3048 
3049  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
3050  if (!particle) continue;
3051 
3052  Int_t isMCFromMBHeader = -1;
3053  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3054  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
3055  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3056  }
3057 
3058  if(!fDoLightOutput){
3059  if(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(particle,fMCEvent)){
3060  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC); // All MC Gamma
3061  if(particle->GetMother(0) >-1){ // Meson Decay Gamma
3062  switch(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()){
3063  case 111: // Pi0
3064  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
3065  break;
3066  case 113: // Rho0
3067  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
3068  break;
3069  case 221: // Eta
3070  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
3071  break;
3072  case 223: // Omega
3073  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
3074  break;
3075  case 331: // Eta'
3076  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
3077  break;
3078  case 333: // Phi
3079  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
3080  break;
3081  case 3212: // Sigma
3082  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
3083  break;
3084  }
3085  }
3086  }
3087  }
3088  if(fDoMesonAnalysis){
3089 
3090  Double_t mesonY = 1.e30;
3091  Double_t ratio = 0;
3092  if (particle->Energy() != TMath::Abs(particle->Pz())){
3093  ratio = (particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz());
3094  }
3095  if( !(ratio <= 0) ){
3096  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3097  }
3098 
3099  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
3100  if ( particle->GetPdgCode() == 211 ){ // positve pions
3101  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 0., fWeightJetJetMC);
3102  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
3103  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 1., fWeightJetJetMC);
3104  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
3105  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 2., fWeightJetJetMC);
3106  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
3107  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 3., fWeightJetJetMC);
3108  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
3109  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 4., fWeightJetJetMC);
3110  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
3111  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 5., fWeightJetJetMC);
3112  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
3113  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 6., fWeightJetJetMC);
3114  }
3115  }
3116 
3118  ->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3119  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
3120  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
3121 
3122  Float_t weighted= 1;
3123  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
3124  if (particle->Pt()>0.005){
3125  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
3126  }
3127  }
3128  Double_t mesonY = 1.e30;
3129  Double_t ratio = 0;
3130  if (particle->Energy() != TMath::Abs(particle->Pz())){
3131  ratio = (particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz());
3132  }
3133  if( !(ratio <= 0) ){
3134  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3135  }
3136  Double_t alpha = -1;
3137  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
3138  alpha = TMath::Abs((daughter0->Energy() - daughter1->Energy()))/(daughter0->Energy() + daughter1->Energy());
3139  }
3140 
3141  if(particle->GetPdgCode() == 111){
3142  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // All MC Pi0
3143  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
3144  if (fIsMC > 1)fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
3145  if (fDoMesonQA > 0 && fDoMesonQA < 3){
3146  fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted* fWeightJetJetMC);
3147  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha, fWeightJetJetMC);
3148  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
3149  }
3150  } else if(particle->GetPdgCode() == 221){
3151  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // All MC Eta
3152  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
3153  if (fIsMC > 1)fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
3154  if (fDoMesonQA > 0 && fDoMesonQA < 3){
3155  fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted* fWeightJetJetMC);
3156  fHistoMCEtaPtAlpha[fiCut]->Fill(particle->Pt(),alpha, fWeightJetJetMC);
3157  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
3158  }
3159  }
3160 
3161  // Check the acceptance for both gammas & whether they are counted as primaries as well
3162  Bool_t kDaughter0IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetFirstDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3163  Bool_t kDaughter1IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetLastDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3164 
3165  if( kDaughter0IsPrim && kDaughter1IsPrim &&
3166  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter0,fMCEvent) &&
3167  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter1,fMCEvent) ){
3168  if(particle->GetPdgCode() == 111){
3169  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Pi0 with gamma in acc
3170  if(fIsMC > 1) fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 with gamma in acc
3171  } else if(particle->GetPdgCode() == 221){
3172  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Eta with gamma in acc
3173  if(fIsMC > 1) fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta with gamma in acc
3174  }
3175  }
3176  }
3177  }
3178  // fill secondary histograms
3179  } else {
3180  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
3181  if (!particle) continue;
3182 
3183  Int_t isMCFromMBHeader = -1;
3184  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3185  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
3186  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3187  }
3188 
3189  if(!fDoLightOutput) {
3190  if(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(particle,fMCEvent)){
3191  if (particle->GetMother(0) > -1 && fMCEvent->Particle(particle->GetMother(0))->GetMother(0) > -1) {
3192  if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
3193  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
3194  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
3195  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
3196  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
3197  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3198  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 221) {
3199  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3200  } else {
3201  if ( !(TMath::Abs(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()) == 11 && fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 22) )
3202  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),4.,fWeightJetJetMC);
3203  }
3204  } else {
3205  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),4.,fWeightJetJetMC);
3206  }
3207  }
3208  }
3209 
3210  if(fDoMesonAnalysis){
3211  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3212  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
3213  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
3214  Int_t pdgCode = -1;
3215  if(particle->GetFirstMother() > -1) pdgCode = ((TParticle*)fMCEvent->Particle( particle->GetFirstMother() ))->GetPdgCode();
3216 
3217  if(particle->GetPdgCode() == 111){
3218  Int_t source = GetSourceClassification(111,pdgCode);
3219  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
3220  fHistoMCSecPi0Source[fiCut]->Fill(pdgCode);
3221  } else if(particle->GetPdgCode() == 221){
3222  fHistoMCSecEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3223  fHistoMCSecEtaSource[fiCut]->Fill(pdgCode);
3224  }
3225 
3226  // check if photons where within acceptance
3227  if( ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter0,fMCEvent) &&
3228  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter1,fMCEvent)){
3229  if(particle->GetPdgCode() == 111){
3230  Int_t source = GetSourceClassification(111,pdgCode);
3231  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
3232  }
3233  }
3234  }
3235  }
3236 
3237  }
3238  }
3239 }
3240 
3241 //________________________________________________________________________
3243 
3244  // Conversion Gammas
3245  if(fClusterCandidates->GetEntries()>0){
3246 
3247  for(Int_t firstGammaIndex=0;firstGammaIndex<fClusterCandidates->GetEntries();firstGammaIndex++){
3248  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(firstGammaIndex));
3249  if (gamma0==NULL) continue;
3250  if ( fDoInOutTimingCluster ){
3251  Double_t tof = fInputEvent->GetCaloCluster(gamma0->GetCaloClusterRef())->GetTOF();
3252  if ( tof < fMinTimingCluster || tof > fMaxTimingCluster ) continue;
3253  }
3254 
3255  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
3256  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
3257  if (gamma1==NULL) continue;
3258  if ( fDoInOutTimingCluster ){
3259  Double_t tof = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef())->GetTOF();
3260  if ( tof > fMinTimingCluster && tof < fMaxTimingCluster ) continue;
3261  }
3262 
3263  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0,gamma1);
3264  pi0cand->SetLabels(firstGammaIndex,secondGammaIndex);
3265 
3266  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),gamma0->GetLeadingCellID(),gamma1->GetLeadingCellID()))){
3267  if(fLocalDebugFlag == 1) DebugMethodPrint1(pi0cand,gamma0,gamma1);
3268  fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(), fWeightJetJetMC);
3269  // fill new histograms
3270  if(!fDoLightOutput && TMath::Abs(pi0cand->GetAlpha())<0.1)
3271  fHistoMotherInvMassPtAlpha[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(), fWeightJetJetMC);
3272 
3273  if (fDoMesonQA > 0 && fDoMesonQA < 3){
3274  if ( pi0cand->M() > 0.05 && pi0cand->M() < 0.17){
3275  fHistoMotherPi0PtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), fWeightJetJetMC);
3276  fHistoMotherPi0PtAlpha[fiCut]->Fill(pi0cand->Pt(),TMath::Abs(pi0cand->GetAlpha()), fWeightJetJetMC);
3277  fHistoMotherPi0PtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle(), fWeightJetJetMC);
3279  }
3280  if ( pi0cand->M() > 0.45 && pi0cand->M() < 0.65){
3281  fHistoMotherEtaPtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), fWeightJetJetMC);
3282  fHistoMotherEtaPtAlpha[fiCut]->Fill(pi0cand->Pt(),TMath::Abs(pi0cand->GetAlpha()), fWeightJetJetMC);
3283  fHistoMotherEtaPtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle(), fWeightJetJetMC);
3285  }
3286  }
3287  if(fDoTHnSparse && ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
3288  Int_t zbin = 0;
3289  Int_t mbin = 0;
3290 
3291  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
3292  zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3293  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3295  } else {
3297  }
3298  }
3299  Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
3300  fSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
3301  }
3302 
3303  if(fDoMesonQA == 4 && fIsMC == 0 && (pi0cand->Pt() > 13.) ){
3304  Int_t zbin = 0;
3305  Int_t mbin = 0;
3306  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
3307  zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3308  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3310  } else {
3312  }
3313  }
3314  fInvMassTreeInvMass = pi0cand->M();
3315  fInvMassTreePt = pi0cand->Pt();
3316  fInvMassTreeAlpha = TMath::Abs(pi0cand->GetAlpha());
3317  fInvMassTreeTheta = pi0cand->GetOpeningAngle();
3318  fInvMassTreeMixPool = zbin*100 + mbin;
3319  fInvMassTreeZVertex = fInputEvent->GetPrimaryVertex()->GetZ();
3320  fInvMassTreeEta = pi0cand->Eta();
3321  tSigInvMassPtAlphaTheta[fiCut]->Fill();
3322  }
3323 
3324  if(fIsMC> 0){
3325  if(fInputEvent->IsA()==AliESDEvent::Class())
3326  ProcessTrueMesonCandidates(pi0cand,gamma0,gamma1);
3327  if(fInputEvent->IsA()==AliAODEvent::Class())
3328  ProcessTrueMesonCandidatesAOD(pi0cand,gamma0,gamma1);
3329  }
3330 
3331  if((pi0cand->GetOpeningAngle() < 0.017) && (pi0cand->Pt() > 15.) && fDoClusterQA > 1){
3332  if (fCloseHighPtClusters == NULL){
3333  fCloseHighPtClusters = new TObjString(Form("%s",((TString)fV0Reader->GetCurrentFileName()).Data()));
3334  if (tClusterQATree) tClusterQATree->Fill();
3335  }
3336  }
3337  }
3338  delete pi0cand;
3339  pi0cand=0x0;
3340  }
3341  }
3342  }
3343 }
3344 //______________________________________________________________________
3346 {
3347  // Process True Mesons
3348  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3349  Double_t mcProdVtxX = primVtxMC->GetX();
3350  Double_t mcProdVtxY = primVtxMC->GetY();
3351  Double_t mcProdVtxZ = primVtxMC->GetZ();
3352  fRconv = -1;
3353 
3354  Bool_t isTruePi0 = kFALSE;
3355  Bool_t isTrueEta = kFALSE;
3356  //Bool_t isTrueGamma = kFALSE;
3357  Bool_t isSameConvertedGamma = kFALSE;
3358  Int_t convertedPhotonLabel0 = -1;
3359  Int_t convertedPhotonLabel1 = -1;
3360 
3361  Int_t gamma0MCLabel = TrueGammaCandidate0->GetCaloPhotonMCLabel(0); // get most probable MC label
3362  Int_t gamma0MotherLabel = -1;
3363 
3364  TParticle * gammaMC0 = 0x0;
3365  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3366  gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
3367  if (TrueGammaCandidate0->IsLargestComponentPhoton() || TrueGammaCandidate0->IsLargestComponentElectron()){ // largest component is electro magnetic
3368  // get mother of interest (pi0 or eta)
3369  if (TrueGammaCandidate0->IsLargestComponentPhoton()){ // for photons its the direct mother
3370  gamma0MotherLabel=gammaMC0->GetMother(0);
3371  } else if (TrueGammaCandidate0->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
3372  if (TrueGammaCandidate0->IsConversion() && (gammaMC0->GetMother(0) > -1)){
3373  convertedPhotonLabel0 = gammaMC0->GetMother(0);
3374  gamma0MotherLabel=fMCEvent->Particle(gammaMC0->GetMother(0))->GetMother(0);
3375  } else {
3376  gamma0MotherLabel=gammaMC0->GetMother(0);
3377  }
3378  }
3379  }
3380  }
3381  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3382 
3383  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
3384  Int_t gamma1MotherLabel = -1;
3385  // check if
3386 
3387  TParticle * gammaMC1 = 0x0;
3388  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3389  // Daughters Gamma 1
3390  gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
3391  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
3392  // get mother of interest (pi0 or eta)
3393  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
3394  gamma1MotherLabel = gammaMC1->GetMother(0);
3395  fRconv = gammaMC1->R();
3396  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
3397  if (TrueGammaCandidate1->IsConversion()){
3398  convertedPhotonLabel1 = gammaMC1->GetMother(0);
3399  fRconv = gammaMC1->R();
3400  if(convertedPhotonLabel1 > -1) gamma1MotherLabel = fMCEvent->Particle(convertedPhotonLabel1)->GetMother(0);
3401  } else {
3402  gamma1MotherLabel=gammaMC1->GetMother(0);
3403  fRconv = gammaMC1->R();
3404  }
3405  }
3406  }
3407  }
3408 
3409  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3410  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
3411  isTruePi0=kTRUE;
3412  }
3413  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 221){
3414  isTrueEta=kTRUE;
3415  }
3416  }
3417 
3418  if (fDoMesonQA == 3){
3419  // calculate meson properties
3420  fPt = Pi0Candidate->Pt();
3421  fOpenRPrim = Pi0Candidate->GetOpeningAngle();
3422  fInvMass = Pi0Candidate->M();
3423 
3424  Double_t vertex[3] = {0};
3425  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
3426 
3427 // cout << vertex[0] << "\t" << vertex[1] << "\t" << vertex[2] << "\t" << Pi0Candidate->Px() << "\t" << Pi0Candidate->Py() << "\t" << Pi0Candidate->Pz() << "\t"
3428 // << Pi0Candidate->Phi() << endl;
3429 
3430  Double_t scaling = (375 - TMath::Sqrt(vertex[0]*vertex[0]+vertex[1]*vertex[1]))/(TMath::Sqrt(Pi0Candidate->Px()*Pi0Candidate->Px()+Pi0Candidate->Py()*Pi0Candidate->Py()));
3431  vertex[0] = vertex[0] + scaling*Pi0Candidate->Px();
3432  vertex[1] = vertex[1] + scaling*Pi0Candidate->Py();
3433  vertex[2] = vertex[2] + scaling*Pi0Candidate->Pz();
3434 
3435 // cout << vertex[0] << "\t" << vertex[1] << "\t" << vertex[2] << endl;
3436 
3437  TClonesArray * arrClustersMesonCand = NULL;
3438  if(fCorrTaskSetting.CompareTo(""))
3439  arrClustersMesonCand = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3440 
3441  AliVCluster* clus1 = NULL;
3442  if(fInputEvent->IsA()==AliESDEvent::Class()){
3443  if(arrClustersMesonCand)
3444  clus1 = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMesonCand->At(TrueGammaCandidate0->GetCaloClusterRef()));
3445  else
3446  clus1 = fInputEvent->GetCaloCluster(TrueGammaCandidate0->GetCaloClusterRef());
3447  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
3448  if(arrClustersMesonCand)
3449  clus1 = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMesonCand->At(TrueGammaCandidate0->GetCaloClusterRef()));
3450  else
3451  clus1 = fInputEvent->GetCaloCluster(TrueGammaCandidate0->GetCaloClusterRef());
3452  }
3453 
3454  if (!clus1) return;
3455  TLorentzVector clusterVector1;
3456  clus1->GetMomentum(clusterVector1,vertex);
3457 
3458  TLorentzVector* tmpvec1 = new TLorentzVector();
3459  tmpvec1->SetPxPyPzE(clusterVector1.Px(),clusterVector1.Py(),clusterVector1.Pz(),clusterVector1.E());
3460  // convert to AODConversionPhoton
3461  AliAODConversionPhoton *PhotonCandidate1=new AliAODConversionPhoton(tmpvec1);
3462  if(!PhotonCandidate1) return;
3463 
3464 
3465  AliVCluster* clus2 = NULL;
3466  if(fInputEvent->IsA()==AliESDEvent::Class()){
3467  if(arrClustersMesonCand)
3468  clus2 = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMesonCand->At(TrueGammaCandidate1->GetCaloClusterRef()));
3469  else
3470  clus2 = fInputEvent->GetCaloCluster(TrueGammaCandidate1->GetCaloClusterRef());
3471  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
3472  if(arrClustersMesonCand)
3473  clus2 = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMesonCand->At(TrueGammaCandidate1->GetCaloClusterRef()));
3474  else
3475  clus2 = fInputEvent->GetCaloCluster(TrueGammaCandidate1->GetCaloClusterRef());
3476  }
3477 
3478  if (!clus2) return;
3479  TLorentzVector clusterVector2;
3480  clus2->GetMomentum(clusterVector2,vertex);
3481  TLorentzVector* tmpvec2 = new TLorentzVector();
3482  tmpvec2->SetPxPyPzE(clusterVector2.Px(),clusterVector2.Py(),clusterVector2.Pz(),clusterVector2.E());
3483  // convert to AODConversionPhoton
3484  AliAODConversionPhoton *PhotonCandidate2=new AliAODConversionPhoton(tmpvec2);
3485  if(!PhotonCandidate2) return;
3486 
3487  AliAODConversionMother *pi0cand2 = new AliAODConversionMother(PhotonCandidate1,PhotonCandidate2);
3488  fInvMassRTOF = pi0cand2->M();
3489 
3490  delete tmpvec1;
3491  delete tmpvec2;
3492  delete PhotonCandidate1;
3493  delete PhotonCandidate2;
3494  delete pi0cand2;
3495 
3496 // cout << fOpenRPrim << "\t" << fInvMassRTOF << endl;
3497 
3498  }
3499 
3500  if (convertedPhotonLabel0 > -1 && convertedPhotonLabel1 > -1){
3501  if (convertedPhotonLabel0==convertedPhotonLabel1){
3502  isSameConvertedGamma = kTRUE;
3503  if (fDoMesonQA == 3 ){
3504  iFlag = 0;
3506  }
3507  }
3508  }
3509 
3510  if(isTruePi0 || isTrueEta){// True Pion or Eta
3511  if (isTruePi0){
3512  fHistoTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3513 // fHistoTruePi0NonLinearity[fiCut]->Fill(TrueGammaCandidate0->E(),gammaMC0->Energy()/TrueGammaCandidate0->E());
3514 // fHistoTruePi0NonLinearity[fiCut]->Fill(TrueGammaCandidate1->E(),gammaMC1->Energy()/TrueGammaCandidate1->E());
3515  if (!fDoLightOutput && TMath::Abs(Pi0Candidate->GetAlpha())< 0.1){
3516  fHistoTruePi0InvMassPtAlpha[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3517  if (TrueGammaCandidate1->IsLargestComponentPhoton() && TrueGammaCandidate0->IsLargestComponentPhoton())
3518  fHistoTruePi0PureGammaInvMassPtAlpha[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3519  }
3520  }
3521  if (isTrueEta){
3522  fHistoTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3523 // fHistoTrueEtaNonLinearity[fiCut]->Fill(TrueGammaCandidate0->E(),gammaMC0->Energy()/TrueGammaCandidate0->E());
3524 // fHistoTrueEtaNonLinearity[fiCut]->Fill(TrueGammaCandidate1->E(),gammaMC1->Energy()/TrueGammaCandidate1->E());
3525  }
3526  if (fDoMesonQA > 0 && fDoMesonQA < 3 && fIsMC < 2){
3527 // if(isTruePi0) {
3528 // fHistoPi0OpenAngleInvMassPt[fiCut]->Fill(Pi0Candidate->GetOpeningAngle(),Pi0Candidate->M(),Pi0Candidate->Pt(),1);
3529 // }
3530 // if(isTrueEta) {
3531 // fHistoEtaOpenAngleInvMassPt[fiCut]->Fill(Pi0Candidate->GetOpeningAngle(),Pi0Candidate->M(),Pi0Candidate->Pt(),1);
3532 // }
3533  // both gammas are real gammas
3534  if (TrueGammaCandidate0->IsLargestComponentPhoton() && TrueGammaCandidate1->IsLargestComponentPhoton()) {
3535  if (isTruePi0) fHistoTruePi0CaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3536  if (isTrueEta) fHistoTrueEtaCaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3537  }
3538  // both particles are electrons
3539  if (TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate1->IsLargestComponentElectron() ) {
3540  if (isTruePi0) fHistoTruePi0CaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3541  if (isTrueEta) fHistoTrueEtaCaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3542  }
3543  // both particles are converted electrons
3544  if ((TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion()) && (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()) ){
3545  if (isTruePi0 )fHistoTruePi0CaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3546  if (isTrueEta )fHistoTrueEtaCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3547  }
3548  // 1 gamma is converted the other one is normals
3549  if ( (TrueGammaCandidate0->IsLargestComponentPhoton() && TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()) ||
3550  (TrueGammaCandidate1->IsLargestComponentPhoton() && TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion())
3551  ) {
3552  if (isTruePi0) fHistoTruePi0CaloMixedPhotonConvPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3553  if (isTrueEta) fHistoTrueEtaCaloMixedPhotonConvPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3554  }
3555 
3556  if ( (TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion() && TrueGammaCandidate1->IsLargestComponentPhoton() && !TrueGammaCandidate1->IsMerged()) ||
3557  (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion() && TrueGammaCandidate0->IsLargestComponentPhoton() && !TrueGammaCandidate0->IsMerged())
3558  ) {
3559  if (isTruePi0) fHistoTruePi0NonMergedElectronPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3560  }
3561 
3562  if ( (TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion() && TrueGammaCandidate1->IsLargestComponentPhoton() && TrueGammaCandidate1->IsMerged()) ||
3563  (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion() && TrueGammaCandidate0->IsLargestComponentPhoton() && TrueGammaCandidate0->IsMerged())
3564  ) {
3565  if (isTruePi0) fHistoTruePi0NonMergedElectronMergedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3566  }
3567 
3568  // at least one of the photon is merged
3569  if (TrueGammaCandidate0->IsMerged() || TrueGammaCandidate0->IsMergedPartConv() || TrueGammaCandidate0->IsDalitzMerged() || TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged() ){
3570  if (isTruePi0) fHistoTruePi0CaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3571  if (isTrueEta) fHistoTruePi0CaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3572  }
3573  // at least one of the photon is merged and part conv
3574  if (TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate0->IsMergedPartConv()) {
3575  if (isTruePi0) fHistoTruePi0CaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3576  if (isTrueEta) fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3577  }
3578  }
3579 
3580  if (fDoMesonQA == 2 && fIsMC < 2){
3581  // category 1: 2 real photons unmerged
3582  if (TrueGammaCandidate0->IsLargestComponentPhoton() && !TrueGammaCandidate0->IsMerged() && TrueGammaCandidate1->IsLargestComponentPhoton() && !TrueGammaCandidate1->IsMerged()) {
3583  if (isTruePi0) fHistoTruePi0Category1[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3584  if (isTrueEta) fHistoTrueEtaCategory1[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3585  }
3586  // category 2, 3: 1 real photons unmerged, 1 electron (category 2 merged, category 3 unmerged )
3587  // -> photon 0 is unconverted
3588  if ( (TrueGammaCandidate0->IsLargestComponentPhoton() && !TrueGammaCandidate0->IsMerged()) && (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion())) {
3589  if (isTruePi0){
3590  if (TrueGammaCandidate1->IsMergedPartConv()) fHistoTruePi0Category2[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3591  if (!TrueGammaCandidate1->IsMergedPartConv()){
3592  fHistoTruePi0Category3[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3593  }
3594  }
3595  if (isTrueEta){
3596  if (TrueGammaCandidate1->IsMergedPartConv()) fHistoTrueEtaCategory2[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3597  if (!TrueGammaCandidate1->IsMergedPartConv()) fHistoTrueEtaCategory3[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3598  }
3599  }
3600  // -> photon 1 is unconverted
3601  if ( ( TrueGammaCandidate1->IsLargestComponentPhoton() && !TrueGammaCandidate1->IsMerged()) && (TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion())) {
3602  if (isTruePi0){
3603  if (TrueGammaCandidate0->IsMergedPartConv()) fHistoTruePi0Category2[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3604  if (!TrueGammaCandidate0->IsMergedPartConv()){
3605  fHistoTruePi0Category3[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3606  }
3607  }
3608  if (isTrueEta){
3609  if (TrueGammaCandidate0->IsMergedPartConv()) fHistoTrueEtaCategory2[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3610  if (!TrueGammaCandidate0->IsMergedPartConv()) fHistoTrueEtaCategory3[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3611  }
3612  }
3613 
3614  // category 4 & 6, 5, 7, 8
3615  if ( (TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion()) && (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()) ){
3616  if (isTruePi0){
3617  // category 4: both electrons are from same conversion
3618  if (isSameConvertedGamma && !TrueGammaCandidate0->IsMergedPartConv() && !TrueGammaCandidate1->IsMergedPartConv() ) fHistoTruePi0Category4_6[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3619  if (!isSameConvertedGamma ){
3620  if (!TrueGammaCandidate0->IsMergedPartConv() && !TrueGammaCandidate1->IsMergedPartConv()){ // category 5: both electrons from different converted photons, electrons not merged
3621  fHistoTruePi0Category5[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3622  } else if (TrueGammaCandidate0->IsMergedPartConv() && TrueGammaCandidate1->IsMergedPartConv()){ // category 8: both electrons from different converted photons, both electrons merged
3623  fHistoTruePi0Category8[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3624  } else { // category 7: both electrons from different converted photons, 1 electrons not merged, 1 electron merged
3625  fHistoTruePi0Category7[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3626  }
3627  }
3628  }
3629  if (isTrueEta){
3630  // category 4: both electrons are from same conversion
3631  if (isSameConvertedGamma && !TrueGammaCandidate0->IsMergedPartConv() && !TrueGammaCandidate1->IsMergedPartConv()) fHistoTrueEtaCategory4_6[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3632  if (!isSameConvertedGamma ){
3633  if (!TrueGammaCandidate0->IsMergedPartConv() && !TrueGammaCandidate1->IsMergedPartConv()){ // category 5: both electrons from different converted photons, electrons not merged
3634  fHistoTrueEtaCategory5[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3635  } else if (TrueGammaCandidate0->IsMergedPartConv() && TrueGammaCandidate1->IsMergedPartConv()){ // category 8: both electrons from different converted photons, both electrons merged
3636  fHistoTrueEtaCategory8[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3637  } else { // category 7: both electrons from different converted photons, 1 electrons not merged, 1 electron merged
3638  fHistoTrueEtaCategory7[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3639  }
3640  }
3641  }
3642  }
3643  }
3644 
3645  if (fDoMesonQA > 0 && fDoMesonQA < 3){
3646  if (isTruePi0){
3647  if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
3648  fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), fWeightJetJetMC);
3649  fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()), fWeightJetJetMC);
3650  fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle(), fWeightJetJetMC);
3651  }
3652  } else if (isTrueEta){
3653  if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
3654  fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), fWeightJetJetMC);
3655  fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()), fWeightJetJetMC);
3656  fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle(), fWeightJetJetMC);
3657  }
3658  }
3659  }
3660  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, gamma0MotherLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3661  if(!isPrimary){ // Secondary Meson
3662  // filling secondary histograms
3663  Long_t secMotherLabel = -1;
3664  if(gamma0MotherLabel > -1) secMotherLabel = ((TParticle*)fMCEvent->Particle(gamma0MotherLabel))->GetMother(0);
3665 
3666  Float_t weightedSec= 1;
3667  if((secMotherLabel > -1) && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, fMCEvent, fInputEvent) && fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310){
3668  weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(secMotherLabel, fMCEvent, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
3669  //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3670  }
3671  if (isTruePi0) fHistoTrueSecondaryPi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec* fWeightJetJetMC);
3672  if (secMotherLabel >-1){
3673  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310 && isTruePi0){
3674  fHistoTrueSecondaryPi0FromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec* fWeightJetJetMC);
3675  if (fDoMesonQA > 0 && fDoMesonQA < 3 && fIsMC < 2)fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt(), fWeightJetJetMC);
3676  if (fDoMesonQA == 3 ){
3677  iFlag = 3;
3678  if (!isSameConvertedGamma)tTrueInvMassROpenABPtFlag[fiCut]->Fill();
3679  }
3680  } else if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==130 && isTruePi0){
3681  fHistoTrueSecondaryPi0FromK0lInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec* fWeightJetJetMC);
3682  if (fDoMesonQA > 0 && fDoMesonQA < 3 && fIsMC < 2)fHistoTrueK0lWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt(), fWeightJetJetMC);
3683 
3684  } else if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==221 && isTruePi0){
3685  fHistoTrueSecondaryPi0FromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec* fWeightJetJetMC);
3686  if (fDoMesonQA > 0 && fDoMesonQA < 3 && fIsMC < 2)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt(), fWeightJetJetMC);
3687  if (fDoMesonQA == 3 ){
3688  iFlag = 4;
3689  if (!isSameConvertedGamma)tTrueInvMassROpenABPtFlag[fiCut]->Fill();
3690  }
3691  } else if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==3122 && isTruePi0){
3692  fHistoTrueSecondaryPi0FromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec* fWeightJetJetMC);
3693  if (fDoMesonQA > 0 && fDoMesonQA < 3 && fIsMC < 2)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt(), fWeightJetJetMC);
3694  if (fDoMesonQA == 3 ){
3695  iFlag = 5;
3696  if (!isSameConvertedGamma)tTrueInvMassROpenABPtFlag[fiCut]->Fill();
3697  }
3698  } else if (isTruePi0){
3699  if (fDoMesonQA == 3 ){
3700  iFlag = 6;
3701  if (!isSameConvertedGamma)tTrueInvMassROpenABPtFlag[fiCut]->Fill();
3702  }
3703  } else if (isTrueEta){
3704  if (fDoMesonQA == 3 ){
3705  iFlag = 7;
3706  if (!isSameConvertedGamma)tTrueInvMassROpenABPtFlag[fiCut]->Fill();
3707  }
3708  }
3709  }
3710  } else { // Only primary pi0 for efficiency calculation
3711  // filling primary histograms
3712  Float_t weighted= 1;
3713  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCEvent, fInputEvent)){
3714  if (((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt()>0.005){
3715  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, fMCEvent, fInputEvent);
3716  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3717  }
3718  }
3719  if (isTruePi0){
3720  if (fDoMesonQA == 3 ){
3721  iFlag = 1;
3722  if (!isSameConvertedGamma)tTrueInvMassROpenABPtFlag[fiCut]->Fill();
3723  }
3724 
3725  fHistoTruePrimaryPi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted* fWeightJetJetMC);
3726  fHistoTruePrimaryPi0W0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3727  fProfileTruePrimaryPi0WeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted* fWeightJetJetMC);
3728  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), weighted*fWeightJetJetMC);
3729  } else if (isTrueEta){
3730  if (fDoMesonQA == 3 ){
3731  iFlag = 2;
3732  if (!isSameConvertedGamma)tTrueInvMassROpenABPtFlag[fiCut]->Fill();
3733  }
3734 
3735  fHistoTruePrimaryEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted* fWeightJetJetMC);
3736  fHistoTruePrimaryEtaW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3737  fProfileTruePrimaryEtaWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted* fWeightJetJetMC);
3738  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueEtas,gamma0MotherLabel)) fHistoDoubleCountTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), weighted*fWeightJetJetMC);
3739  }
3740 
3741  if (fDoMesonQA > 0 && fDoMesonQA < 3 && fIsMC<2){
3742  if(isTruePi0){ // Only primary pi0 for resolution
3743  fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted* fWeightJetJetMC);
3744  }
3745  if (isTrueEta){ // Only primary eta for resolution
3746  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted* fWeightJetJetMC);
3747  }
3748  }
3749  }
3750  } else if(!isTruePi0 && !isTrueEta){ // Background
3751  if (fDoMesonQA > 0 && fDoMesonQA < 3){
3752  if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
3753  fHistoTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3754 
3755  if( ((((TParticle*)fMCEvent->Particle(gamma0MotherLabel))->GetPdgCode() == 111
3756  || ((TParticle*)fMCEvent->Particle(gamma0MotherLabel))->GetPdgCode() == 221)
3757  && (TrueGammaCandidate0->IsMerged() || TrueGammaCandidate0->IsMergedPartConv()))
3758  ||
3759  ((((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 111
3760  || ((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 221)
3761  && (TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv()))
3762  ){
3763  fHistoTrueBckFullMesonContainedInOneClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3764  }else if( (TrueGammaCandidate0->E()/Pi0Candidate->E() > 0.7) || (TrueGammaCandidate1->E()/Pi0Candidate->E() > 0.7) ){
3765  fHistoTrueBckAsymEClustersInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3766  }
3767  } else { // No photon or without mother
3768  fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3769  }
3770  }
3771  }
3772 
3773 }
3774 //______________________________________________________________________
3776 {
3777  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3778  Double_t mcProdVtxX = primVtxMC->GetX();
3779  Double_t mcProdVtxY = primVtxMC->GetY();
3780  Double_t mcProdVtxZ = primVtxMC->GetZ();
3781 
3782  // Process True Mesons
3783  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3784  if (AODMCTrackArray == NULL) return;
3785 
3786  Bool_t isTruePi0 = kFALSE;
3787  Bool_t isTrueEta = kFALSE;
3788  Bool_t isSameConvertedGamma = kFALSE;
3789  Int_t convertedPhotonLabel0 = -1;
3790  Int_t convertedPhotonLabel1 = -1;
3791 
3792  Int_t gamma0MCLabel = TrueGammaCandidate0->GetCaloPhotonMCLabel(0); // get most probable MC label
3793  Int_t gamma0MotherLabel = -1;
3794 
3795  // check if
3796  AliAODMCParticle * gammaMC0 = 0x0;
3797  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3798  // Daughters Gamma 0
3799  gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3800  if (TrueGammaCandidate0->IsLargestComponentPhoton() || TrueGammaCandidate0->IsLargestComponentElectron()){ // largest component is electro magnetic
3801  // get mother of interest (pi0 or eta)
3802  if (TrueGammaCandidate0->IsLargestComponentPhoton()){ // for photons its the direct mother
3803  gamma0MotherLabel=gammaMC0->GetMother();
3804  } else if (TrueGammaCandidate0->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
3805  if (TrueGammaCandidate0->IsConversion()){
3806  convertedPhotonLabel0 = gammaMC0->GetMother();
3807  AliAODMCParticle * gammaGrandMotherMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC0->GetMother()));
3808  gamma0MotherLabel=gammaGrandMotherMC0->GetMother();
3809  } else gamma0MotherLabel=gammaMC0->GetMother();
3810  }
3811  }
3812  }
3813 
3814  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
3815  Int_t gamma1MotherLabel = -1;
3816 
3817  // check if
3818  AliAODMCParticle *gammaMC1 = 0x0;
3819  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3820  // Daughters Gamma 1
3821  gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3822  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
3823  // get mother of interest (pi0 or eta)
3824  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
3825  gamma1MotherLabel=gammaMC1->GetMother();
3826  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
3827  if (TrueGammaCandidate1->IsConversion()){
3828  convertedPhotonLabel1 = gammaMC1->GetMother();
3829  AliAODMCParticle * gammaGrandMotherMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC1->GetMother()));
3830  gamma1MotherLabel=gammaGrandMotherMC1->GetMother();
3831  } else gamma1MotherLabel=gammaMC1->GetMother();
3832  }
3833  }
3834  }
3835 
3836  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3837  if(((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
3838  isTruePi0=kTRUE;
3839  }
3840  if(((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 221){
3841  isTrueEta=kTRUE;
3842  }
3843  }
3844 
3845  if (convertedPhotonLabel0 > -1 && convertedPhotonLabel1 > 1){
3846  if (convertedPhotonLabel0==convertedPhotonLabel1){
3847  isSameConvertedGamma = kTRUE;
3848  if (fDoMesonQA == 3 ){
3849 // fHistoGammaOpenAngleInvMassPt[fiCut]->Fill(Pi0Candidate->GetOpeningAngle(),Pi0Candidate->M(),Pi0Candidate->Pt(),1);
3850  }
3851  }
3852  }
3853 
3854 
3855  if(isTruePi0 || isTrueEta){// True Pion or Eta
3856  if(isTruePi0){
3857  fHistoTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3858 // fHistoTruePi0NonLinearity[fiCut]->Fill(TrueGammaCandidate0->E(),gammaMC0->E()/TrueGammaCandidate0->E());
3859 // fHistoTruePi0NonLinearity[fiCut]->Fill(TrueGammaCandidate1->E(),gammaMC1->E()/TrueGammaCandidate1->E());
3860  if (!fDoLightOutput && TMath::Abs(Pi0Candidate->GetAlpha())< 0.1){
3861  fHistoTruePi0InvMassPtAlpha[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3862  if (TrueGammaCandidate1->IsLargestComponentPhoton() && TrueGammaCandidate0->IsLargestComponentPhoton())
3863  fHistoTruePi0PureGammaInvMassPtAlpha[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3864  }
3865  }
3866  if(isTrueEta){
3867  fHistoTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3868 // fHistoTrueEtaNonLinearity[fiCut]->Fill(TrueGammaCandidate0->E(),gammaMC0->E()/TrueGammaCandidate0->E());
3869 // fHistoTrueEtaNonLinearity[fiCut]->Fill(TrueGammaCandidate1->E(),gammaMC1->E()/TrueGammaCandidate1->E());
3870  }
3871  if (fDoMesonQA > 0 && fDoMesonQA < 3 && fIsMC < 2){
3872 // if(isTruePi0) {
3873 // fHistoPi0OpenAngleInvMassPt[fiCut]->Fill(Pi0Candidate->GetOpeningAngle(),Pi0Candidate->M(),Pi0Candidate->Pt(),1);
3874 // }
3875 // if(isTrueEta) {
3876 // fHistoEtaOpenAngleInvMassPt[fiCut]->Fill(Pi0Candidate->GetOpeningAngle(),Pi0Candidate->M(),Pi0Candidate->Pt(),1);
3877 // }
3878  // both gammas are real gammas
3879  if (TrueGammaCandidate0->IsLargestComponentPhoton() && TrueGammaCandidate1->IsLargestComponentPhoton()) {
3880  if (isTruePi0)fHistoTruePi0CaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3881  if (isTrueEta)fHistoTrueEtaCaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3882  }
3883  // both particles are electrons
3884  if (TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate1->IsLargestComponentElectron() ) {
3885  if (isTruePi0) fHistoTruePi0CaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3886  if (isTrueEta) fHistoTrueEtaCaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3887  }
3888  // both particles are converted electrons
3889  if ((TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion()) && (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()) ){
3890  if (isTruePi0 )fHistoTruePi0CaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3891  if (isTrueEta )fHistoTrueEtaCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3892  }
3893  // 1 gamma is converted the other one is normals
3894  if ( (TrueGammaCandidate0->IsLargestComponentPhoton() && TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()) ||
3895  (TrueGammaCandidate1->IsLargestComponentPhoton() && TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion())
3896  ) {
3897  if (isTruePi0) fHistoTruePi0CaloMixedPhotonConvPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3898  if (isTrueEta) fHistoTrueEtaCaloMixedPhotonConvPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3899  }
3900 
3901  if ( (TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion() && TrueGammaCandidate1->IsLargestComponentPhoton() && !TrueGammaCandidate1->IsMerged()) ||
3902  (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion() && TrueGammaCandidate0->IsLargestComponentPhoton() && !TrueGammaCandidate0->IsMerged())
3903  ) {
3904  if (isTruePi0) fHistoTruePi0NonMergedElectronPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3905  }
3906 
3907  if ( (TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion() && TrueGammaCandidate1->IsLargestComponentPhoton() && TrueGammaCandidate1->IsMerged()) ||
3908  (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion() && TrueGammaCandidate0->IsLargestComponentPhoton() && TrueGammaCandidate0->IsMerged())
3909  ) {
3910  if (isTruePi0) fHistoTruePi0NonMergedElectronMergedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3911  }
3912 
3913  // at least one of the photon is merged
3914  if (TrueGammaCandidate0->IsMerged() || TrueGammaCandidate0->IsMergedPartConv() || TrueGammaCandidate0->IsDalitzMerged() || TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged() ){
3915  if (isTruePi0) fHistoTruePi0CaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3916  if (isTrueEta) fHistoTrueEtaCaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3917  }
3918  // at least one of the photon is merged and part conv
3919  if (TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate0->IsMergedPartConv()) {
3920  if (isTruePi0)fHistoTruePi0CaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3921  if (isTrueEta)fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3922  }
3923  }
3924 
3925  if (fDoMesonQA == 2 && fIsMC < 2){
3926  // category 1: 2 real photons unmerged
3927  if (TrueGammaCandidate0->IsLargestComponentPhoton() && !TrueGammaCandidate0->IsMerged() && TrueGammaCandidate1->IsLargestComponentPhoton() && !TrueGammaCandidate1->IsMerged()) {
3928  if (isTruePi0) fHistoTruePi0Category1[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3929  if (isTrueEta) fHistoTrueEtaCategory1[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3930  }
3931  // category 2, 3: 1 real photons unmerged, 1 electron (category 2 merged, category 3 unmerged )
3932  // -> photon 0 is unconverted
3933  if ( (TrueGammaCandidate0->IsLargestComponentPhoton() && !TrueGammaCandidate0->IsMerged()) && (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion())) {
3934  if (isTruePi0){
3935  if (TrueGammaCandidate1->IsMergedPartConv()) fHistoTruePi0Category2[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3936  if (!TrueGammaCandidate1->IsMergedPartConv()) fHistoTruePi0Category3[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3937  }
3938  if (isTrueEta){
3939  if (TrueGammaCandidate1->IsMergedPartConv()) fHistoTrueEtaCategory2[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3940  if (!TrueGammaCandidate1->IsMergedPartConv()) fHistoTrueEtaCategory3[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3941  }
3942  }
3943  // -> photon 1 is unconverted
3944  if ( ( TrueGammaCandidate1->IsLargestComponentPhoton() && !TrueGammaCandidate1->IsMerged()) && (TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion())) {
3945  if (isTruePi0){
3946  if (TrueGammaCandidate0->IsMergedPartConv()) fHistoTruePi0Category2[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3947  if (!TrueGammaCandidate0->IsMergedPartConv()) fHistoTruePi0Category3[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3948  }
3949  if (isTrueEta){
3950  if (TrueGammaCandidate0->IsMergedPartConv()) fHistoTrueEtaCategory2[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3951  if (!TrueGammaCandidate0->IsMergedPartConv()) fHistoTrueEtaCategory3[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3952  }
3953  }
3954 
3955  // category 4 & 6, 5, 7, 8
3956  if ( (TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion()) && (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()) ){
3957  if (isTruePi0){
3958  // category 4: both electrons are from same conversion
3959  if (isSameConvertedGamma && !TrueGammaCandidate0->IsMergedPartConv() && !TrueGammaCandidate1->IsMergedPartConv() ) fHistoTruePi0Category4_6[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3960  if (!isSameConvertedGamma ){
3961  if (!TrueGammaCandidate0->IsMergedPartConv() && !TrueGammaCandidate1->IsMerged()){ // category 5: both electrons from different converted photons, electrons not merged
3962  fHistoTruePi0Category5[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3963  } else if (TrueGammaCandidate0->IsMergedPartConv() && TrueGammaCandidate1->IsMerged()){ // category 8: both electrons from different converted photons, both electrons merged
3964  fHistoTruePi0Category8[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3965  } else { // category 7: both electrons from different converted photons, 1 electrons not merged, 1 electron merged
3966  fHistoTruePi0Category7[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3967  }
3968  }
3969  }
3970  if (isTrueEta){
3971  // category 4: both electrons are from same conversion
3972  if (isSameConvertedGamma && !TrueGammaCandidate0->IsMergedPartConv() && !TrueGammaCandidate1->IsMergedPartConv()) fHistoTrueEtaCategory4_6[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3973  if (!isSameConvertedGamma ){
3974  if (!TrueGammaCandidate0->IsMergedPartConv() && !TrueGammaCandidate1->IsMergedPartConv()){ // category 5: both electrons from different converted photons, electrons not merged
3975  fHistoTrueEtaCategory5[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3976  } else if (TrueGammaCandidate0->IsMergedPartConv() && TrueGammaCandidate1->IsMergedPartConv()){ // category 8: both electrons from different converted photons, both electrons merged
3977  fHistoTrueEtaCategory8[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3978  } else { // category 7: both electrons from different converted photons, 1 electrons not merged, 1 electron merged
3979  fHistoTrueEtaCategory7[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3980  }
3981  }
3982  }
3983  }
3984  }
3985 
3986  if (fDoMesonQA > 0 && fDoMesonQA < 3){
3987  if (isTruePi0){
3988  if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
3989  fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(