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