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