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