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