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