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