AliPhysics  d497547 (d497547)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskGammaConvCalo.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2020, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: Daniel Muehlheim, 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 "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 
63 
64 //________________________________________________________________________
66  fV0Reader(NULL),
67  fV0ReaderName("V0ReaderV1"),
68  fBGHandler(NULL),
69  fBGHandlerRP(NULL),
70  fBGClusHandler(NULL),
71  fBGClusHandlerRP(NULL),
72  fInputEvent(NULL),
73  fMCEvent(NULL),
74  fCutFolder(NULL),
75  fESDList(NULL),
76  fBackList(NULL),
77  fMotherList(NULL),
78  fPhotonDCAList(NULL),
79  fGammaERM02(NULL),
80  fInvMassShowerShape(NULL),
81  fTrueList(NULL),
82  fMCList(NULL),
83  fClusterOutputList(NULL),
84  fOutputContainer(NULL),
85  fReaderGammas(NULL),
86  fGammaCandidates(NULL),
87  fClusterCandidates(NULL),
88  fEventCutArray(NULL),
89  fEventCuts(NULL),
90  fCutArray(NULL),
91  fConversionCuts(NULL),
92  fClusterCutArray(NULL),
93  fCaloPhotonCuts(NULL),
94  fMesonCutArray(NULL),
95  fMesonCuts(NULL),
96  fHistoConvGammaPt(NULL),
97  fHistoConvGammaR(NULL),
98  fHistoConvGammaEta(NULL),
99  fTreeConvGammaPtDcazCat(NULL),
100  fPtGamma(0),
101  fDCAzPhoton(0),
102  fRConvPhoton(0),
103  fEtaPhoton(0),
104  fCharCatPhoton(0),
105  fCharPhotonMCInfo(0),
106  tESDGammaERM02(NULL),
107  tESDClusE(0),
108  tESDGammaConvR(0),
109  tESDClusterM02(0),
110  tESDClusterM20(0),
111  tESDClusterEta(0),
112  tESDClusterPhi(0),
113  tESDClusterNCells(0),
114  tESDClusterMaxECell(0),
115  tESDClusterNLM(0),
116  tESDInvMassShowerShape(0),
117  tESDIMMesonInvMass(0),
118  tESDIMMesonPt(0),
119  tESDIMClusE(0),
120  tESDIMClusterM02(0),
121  tESDIMClusterM20(0),
122  tESDIMClusterLeadCellID(0),
123  tESDIMClusterClassification(0),
124  tESDIMClusMatchedTrackPt(0),
125  tESDIMClusTrackDeltaEta(0),
126  tESDIMClusTrackDeltaPhi(0),
127  tESDIMClusterIsoSumClusterEt(0),
128  tESDIMClusterIsoSumTrackEt(0),
129  tESDmapIsClusterAcceptedWithoutTrackMatch(),
130  fHistoMotherInvMassPt(NULL),
131  fHistoMotherMatchedInvMassPt(NULL),
132  fSparseMotherInvMassPtZM(NULL),
133  fHistoMotherBackInvMassPt(NULL),
134  fSparseMotherBackInvMassPtZM(NULL),
135  fHistoMotherInvMassPtAlpha(NULL),
136  fHistoMotherPi0PtY(NULL),
137  fHistoMotherEtaPtY(NULL),
138  fHistoMotherPi0PtAlpha(NULL),
139  fHistoMotherEtaPtAlpha(NULL),
140  fHistoMotherPi0PtOpenAngle(NULL),
141  fHistoMotherEtaPtOpenAngle(NULL),
142  fHistoMotherPi0ConvPhotonEtaPhi(NULL),
143  fHistoMotherEtaConvPhotonEtaPhi(NULL),
144  fHistoMotherInvMassECalib(NULL),
145  fHistoMotherBackInvMassECalib(NULL),
146  fHistoPhotonPairPtconv(NULL),
147  fHistoPhotonPairMixedEventPtconv(NULL),
148  fHistoClusGammaPt(NULL),
149  fHistoClusGammaE(NULL),
150  fHistoClusOverlapHeadersGammaPt(NULL),
151  fHistoMCHeaders(NULL),
152  fHistoMCAllGammaPt(NULL),
153  fHistoMCAllGammaEMCALAccPt(NULL),
154  fHistoMCAllSecondaryGammaPt(NULL),
155  fHistoMCDecayGammaPi0Pt(NULL),
156  fHistoMCDecayGammaRhoPt(NULL),
157  fHistoMCDecayGammaEtaPt(NULL),
158  fHistoMCDecayGammaOmegaPt(NULL),
159  fHistoMCDecayGammaEtapPt(NULL),
160  fHistoMCDecayGammaPhiPt(NULL),
161  fHistoMCDecayGammaSigmaPt(NULL),
162  fHistoMCConvGammaPt(NULL),
163  fHistoMCSecondaryConvGammaPt(NULL),
164  fHistoMCConvGammaR(NULL),
165  fHistoMCConvGammaEta(NULL),
166  fHistoMCPi0Pt(NULL),
167  fHistoMCPi0WOWeightPt(NULL),
168  fHistoMCPi0WOEvtWeightPt(NULL),
169  fHistoMCEtaPt(NULL),
170  fHistoMCEtaWOWeightPt(NULL),
171  fHistoMCEtaWOEvtWeightPt(NULL),
172  fHistoMCPi0InAccPt(NULL),
173  fHistoMCPi0WOWeightInAccPt(NULL),
174  fHistoMCPi0WOEvtWeightInAccPt(NULL),
175  fHistoMCEtaInAccPt(NULL),
176  fHistoMCEtaWOWeightInAccPt(NULL),
177  fHistoMCEtaWOEvtWeightInAccPt(NULL),
178  fHistoMCPi0PtY(NULL),
179  fHistoMCEtaPtY(NULL),
180  fHistoMCPi0PtAlpha(NULL),
181  fHistoMCEtaPtAlpha(NULL),
182  fHistoMCPrimaryPtvsSource(NULL),
183  fHistoMCSecPi0PtvsSource(NULL),
184  fHistoMCSecPi0Source(NULL),
185  fHistoMCSecPi0InAccPtvsSource(NULL),
186  fHistoMCSecEtaPt(NULL),
187  fHistoMCSecEtaSource(NULL),
188  fHistoMCPi0PtJetPt(NULL),
189  fHistoMCEtaPtJetPt(NULL),
190  fHistoMCPi0PtGammaLeg(NULL),
191  fHistoMCPi0WOWeightPtGammaLeg(NULL),
192  fHistoMCPi0InAccPtGammaLeg(NULL),
193  fHistoMCPi0WOWeightInAccPtGammaLeg(NULL),
194  fHistoMCSecPi0PtGamma1vsSource(NULL),
195  fHistoMCSecPi0InAccPtGamma1vsSource(NULL),
196  fHistoMCSecPi0PtGamma2vsSource(NULL),
197  fHistoMCSecPi0InAccPtGamma2vsSource(NULL),
198  fHistoTruePi0InvMassPt(NULL),
199  fHistoTrueEtaInvMassPt(NULL),
200  fHistoTruePi0MatchedInvMassPt(NULL),
201  fHistoTrueEtaMatchedInvMassPt(NULL),
202  fHistoTruePi0CaloPhotonInvMassPt(NULL),
203  fHistoTrueEtaCaloPhotonInvMassPt(NULL),
204  fHistoTruePi0CaloConvertedPhotonInvMassPt(NULL),
205  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt(NULL),
206  fHistoTruePi0CaloConvPhotonConvRPt(NULL),
207  fHistoTruePi0CaloConvPhotonConvRAlpha(NULL),
208  fHistoTruePi0CaloConvPhotonPtAlpha(NULL),
209  fHistoTrueEtaCaloConvertedPhotonInvMassPt(NULL),
210  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt(NULL),
211  fHistoTrueEtaCaloConvPhotonConvRPt(NULL),
212  fHistoTrueEtaCaloConvPhotonConvRAlpha(NULL),
213  fHistoTrueEtaCaloConvPhotonPtAlpha(NULL),
214  fHistoTruePi0CaloElectronInvMassPt(NULL),
215  fHistoTrueEtaCaloElectronInvMassPt(NULL),
216  fHistoTruePi0CaloMergedClusterInvMassPt(NULL),
217  fHistoTrueEtaCaloMergedClusterInvMassPt(NULL),
218  fHistoTrueMotherCaloEMNonLeadingInvMassPt(NULL),
219  fHistoTruePi0CaloMergedClusterPartConvInvMassPt(NULL),
220  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt(NULL),
221  fHistoTruePrimaryPi0InvMassPt(NULL),
222  fHistoTruePrimaryEtaInvMassPt(NULL),
223  fHistoTruePrimaryPi0W0WeightingInvMassPt(NULL),
224  fHistoTruePrimaryEtaW0WeightingInvMassPt(NULL),
225  fProfileTruePrimaryPi0WeightsInvMassPt(NULL),
226  fProfileTruePrimaryEtaWeightsInvMassPt(NULL),
227  fHistoTruePrimaryPi0MCPtResolPt(NULL),
228  fHistoTruePrimaryEtaMCPtResolPt(NULL),
229  fHistoTrueMotherPi0ConvPhotonEtaPhi(NULL),
230  fHistoTrueMotherEtaConvPhotonEtaPhi(NULL),
231  fHistoTrueSecondaryPi0InvMassPt(NULL),
232  fHistoTrueSecondaryPi0FromK0sInvMassPt(NULL),
233  fHistoTrueK0sWithPi0DaughterMCPt(NULL),
234  fHistoTrueSecondaryPi0FromK0lInvMassPt(NULL),
235  fHistoTrueK0lWithPi0DaughterMCPt(NULL),
236  fHistoTrueSecondaryPi0FromEtaInvMassPt(NULL),
237  fHistoTrueEtaWithPi0DaughterMCPt(NULL),
238  fHistoTrueSecondaryPi0FromLambdaInvMassPt(NULL),
239  fHistoTrueLambdaWithPi0DaughterMCPt(NULL),
240  fHistoTrueBckGGInvMassPt(NULL),
241  fHistoTrueBckFullMesonContainedInOneClusterInvMassPt(NULL),
242  fHistoTrueBckAsymEClustersInvMassPt(NULL),
243  fHistoTrueBckContInvMassPt(NULL),
244  fHistoTruePi0PtY(NULL),
245  fHistoTrueEtaPtY(NULL),
246  fHistoTruePi0PtAlpha(NULL),
247  fHistoTrueEtaPtAlpha(NULL),
248  fHistoTruePi0PtOpenAngle(NULL),
249  fHistoTrueEtaPtOpenAngle(NULL),
250  fHistoTrueConvGammaPt(NULL),
251  fHistoTrueConvGammaEta(NULL),
252  fHistoCombinatorialPt(NULL),
253  fHistoTruePrimaryConvGammaPt(NULL),
254  fHistoTruePrimaryConvGammaESDPtMCPt(NULL),
255  fHistoTrueSecondaryConvGammaPt(NULL),
256  fHistoTrueSecondaryConvGammaMCPt(NULL),
257  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt(NULL),
258  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt(NULL),
259  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt(NULL),
260  fHistoTrueClusGammaPt(NULL),
261  fHistoTrueClusElectronPt(NULL),
262  fHistoTrueClusConvGammaPt(NULL),
263  fHistoTrueClusConvGammaFullyPt(NULL),
264  fHistoTrueClusMergedGammaPt(NULL),
265  fHistoTrueClusMergedPartConvGammaPt(NULL),
266  fHistoTrueClusDalitzPt(NULL),
267  fHistoTrueClusDalitzMergedPt(NULL),
268  fHistoTrueClusPhotonFromElecMotherPt(NULL),
269  fHistoTrueClusShowerPt(NULL),
270  fHistoTrueClusSubLeadingPt(NULL),
271  fHistoTrueClusNMothers(NULL),
272  fHistoTrueClusEMNonLeadingPt(NULL),
273  fHistoTrueNLabelsInClusPt(NULL),
274  fHistoTruePrimaryClusGammaPt(NULL),
275  fHistoTruePrimaryClusGammaESDPtMCPt(NULL),
276  fHistoTruePrimaryClusConvGammaPt(NULL),
277  fHistoTruePrimaryClusConvGammaESDPtMCPt(NULL),
278  fHistoTrueSecondaryClusGammaPt(NULL),
279  fHistoTrueSecondaryClusGammaFromK0sPt(NULL),
280  fHistoTrueSecondaryClusGammaFromK0lPt(NULL),
281  fHistoTrueSecondaryClusGammaFromLambdaPt(NULL),
282  fHistoTruePrimaryPi0PhotonPairPtconv(NULL),
283  fHistoTruePrimaryPi0W0WeightsPhotonPairPtconv(NULL),
284  fHistoTruePrimaryPi0DCPtconv(NULL),
285  fHistoTruePrimaryPi0MissingPtconv(NULL),
286  fHistoTrueSecondaryPi0PhotonPairPtconv(NULL),
287  fHistoTrueSecondaryPi0FromK0sPhotonPairPtconv(NULL),
288  fHistoTrueSecondaryPi0FromK0lPhotonPairPtconv(NULL),
289  fHistoTrueSecondaryPi0FromLambdaPhotonPairPtconv(NULL),
290  fHistoTrueSecondaryPi0DCPtconvSource(NULL),
291  fHistoTrueSecondaryPi0MissingPtconvSource(NULL),
292  fVectorRecTruePi0s(0),
293  fVectorRecTrueEtas(0),
294  fHistoDoubleCountTruePi0InvMassPt(NULL),
295  fHistoDoubleCountTrueEtaInvMassPt(NULL),
296  fHistoDoubleCountTrueConvGammaRPt(NULL),
297  fHistoDoubleCountTrueClusterGammaPt(NULL),
298  fVectorDoubleCountTruePi0s(0),
299  fVectorDoubleCountTrueEtas(0),
300  fVectorDoubleCountTrueConvGammas(0),
301  fVectorDoubleCountTrueClusterGammas(0),
302  fHistoMultipleCountTruePi0(NULL),
303  fHistoMultipleCountTrueEta(NULL),
304  fHistoMultipleCountTrueConvGamma(NULL),
305  fHistoMultipleCountTrueClusterGamma(NULL),
306  fMapMultipleCountTruePi0s(),
307  fMapMultipleCountTrueEtas(),
308  fMapMultipleCountTrueConvGammas(),
309  fMapMultipleCountTrueClusterGammas(),
310  fHistoTrueClusGammaEM02(NULL),
311  fHistoTrueClusPi0EM02(NULL),
312  fHistoTruePi0InvMassECalib(NULL),
313  fHistoTruePi0PureGammaInvMassECalib(NULL),
314  fHistoNEvents(NULL),
315  fHistoNEventsWOWeight(NULL),
316  fHistoNGoodESDTracks(NULL),
317  fHistoVertexZ(NULL),
318  fHistoVertexX(NULL),
319  fHistoVertexY(NULL),
320  fHistoNGammaCandidates(NULL),
321  fHistoNGoodESDTracksVsNGammaCandidates(NULL),
322  fHistoSPDClusterTrackletBackground(NULL),
323  fHistoNV0Tracks(NULL),
324  fProfileEtaShift(NULL),
325  fProfileJetJetXSection(NULL),
326  fHistoJetJetNTrials(NULL),
327 // fHistoTruePi0NonLinearity(NULL),
328 // fHistoTrueEtaNonLinearity(NULL),
329  fEventPlaneAngle(-100),
330  fRandom(0),
331  fNGammaCandidates(0),
332  fUnsmearedPx(NULL),
333  fUnsmearedPy(NULL),
334  fUnsmearedPz(NULL),
335  fUnsmearedE(NULL),
336  fMCEventPos(NULL),
337  fMCEventNeg(NULL),
338  fESDArrayPos(NULL),
339  fESDArrayNeg(NULL),
340  fnCuts(0),
341  fiCut(0),
342  fMoveParticleAccordingToVertex(kTRUE),
343  fIsHeavyIon(0),
344  fDoLightOutput(kFALSE),
345  fDoMesonAnalysis(kTRUE),
346  fDoMesonQA(0),
347  fDoPhotonQA(0),
348  fDoClusterQA(0),
349  fIsFromMBHeader(kTRUE),
350  fIsOverlappingWithOtherHeader(kFALSE),
351  fIsMC(0),
352  fDoTHnSparse(kTRUE),
353  fSetPlotHistsExtQA(kFALSE),
354  fWeightJetJetMC(1),
355  fDoConvGammaShowerShapeTree(kFALSE),
356  fEnableSortForClusMC(kFALSE),
357  fDoPrimaryTrackMatching(kFALSE),
358  fDoInvMassShowerShapeTree(kFALSE),
359  tBrokenFiles(NULL),
360  fFileNameBroken(NULL)
361 {
362 
363 }
364 
365 //________________________________________________________________________
367  AliAnalysisTaskSE(name),
368  fV0Reader(NULL),
369  fV0ReaderName("V0ReaderV1"),
370  fBGHandler(NULL),
371  fBGHandlerRP(NULL),
372  fBGClusHandler(NULL),
373  fBGClusHandlerRP(NULL),
374  fInputEvent(NULL),
375  fMCEvent(NULL),
376  fCutFolder(NULL),
377  fESDList(NULL),
378  fBackList(NULL),
379  fMotherList(NULL),
380  fPhotonDCAList(NULL),
381  fGammaERM02(NULL),
382  fInvMassShowerShape(NULL),
383  fTrueList(NULL),
384  fMCList(NULL),
385  fClusterOutputList(NULL),
386  fOutputContainer(0),
387  fReaderGammas(NULL),
388  fGammaCandidates(NULL),
389  fClusterCandidates(NULL),
390  fEventCutArray(NULL),
391  fEventCuts(NULL),
392  fCutArray(NULL),
393  fConversionCuts(NULL),
394  fClusterCutArray(NULL),
395  fCaloPhotonCuts(NULL),
396  fMesonCutArray(NULL),
397  fMesonCuts(NULL),
398  fHistoConvGammaPt(NULL),
399  fHistoConvGammaR(NULL),
400  fHistoConvGammaEta(NULL),
401  fTreeConvGammaPtDcazCat(NULL),
402  fPtGamma(0),
403  fDCAzPhoton(0),
404  fRConvPhoton(0),
405  fEtaPhoton(0),
406  fCharCatPhoton(0),
407  fCharPhotonMCInfo(0),
408  tESDGammaERM02(NULL),
409  tESDClusE(0),
410  tESDGammaConvR(0),
411  tESDClusterM02(0),
412  tESDClusterM20(0),
413  tESDClusterEta(0),
414  tESDClusterPhi(0),
415  tESDClusterNCells(0),
416  tESDClusterMaxECell(0),
417  tESDClusterNLM(0),
418  tESDInvMassShowerShape(0),
419  tESDIMMesonInvMass(0),
420  tESDIMMesonPt(0),
421  tESDIMClusE(0),
422  tESDIMClusterM02(0),
423  tESDIMClusterM20(0),
424  tESDIMClusterLeadCellID(0),
425  tESDIMClusterClassification(0),
426  tESDIMClusMatchedTrackPt(0),
427  tESDIMClusTrackDeltaEta(0),
428  tESDIMClusTrackDeltaPhi(0),
429  tESDIMClusterIsoSumClusterEt(0),
430  tESDIMClusterIsoSumTrackEt(0),
431  tESDmapIsClusterAcceptedWithoutTrackMatch(),
432  fHistoMotherInvMassPt(NULL),
433  fHistoMotherMatchedInvMassPt(NULL),
434  fSparseMotherInvMassPtZM(NULL),
435  fHistoMotherBackInvMassPt(NULL),
436  fSparseMotherBackInvMassPtZM(NULL),
437  fHistoMotherInvMassPtAlpha(NULL),
438  fHistoMotherPi0PtY(NULL),
439  fHistoMotherEtaPtY(NULL),
440  fHistoMotherPi0PtAlpha(NULL),
441  fHistoMotherEtaPtAlpha(NULL),
442  fHistoMotherPi0PtOpenAngle(NULL),
443  fHistoMotherEtaPtOpenAngle(NULL),
444  fHistoMotherPi0ConvPhotonEtaPhi(NULL),
445  fHistoMotherEtaConvPhotonEtaPhi(NULL),
446  fHistoMotherInvMassECalib(NULL),
447  fHistoMotherBackInvMassECalib(NULL),
448  fHistoPhotonPairPtconv(NULL),
449  fHistoPhotonPairMixedEventPtconv(NULL),
450  fHistoClusGammaPt(NULL),
451  fHistoClusGammaE(NULL),
452  fHistoClusOverlapHeadersGammaPt(NULL),
453  fHistoMCHeaders(NULL),
454  fHistoMCAllGammaPt(NULL),
455  fHistoMCAllGammaEMCALAccPt(NULL),
456  fHistoMCAllSecondaryGammaPt(NULL),
457  fHistoMCDecayGammaPi0Pt(NULL),
458  fHistoMCDecayGammaRhoPt(NULL),
459  fHistoMCDecayGammaEtaPt(NULL),
460  fHistoMCDecayGammaOmegaPt(NULL),
461  fHistoMCDecayGammaEtapPt(NULL),
462  fHistoMCDecayGammaPhiPt(NULL),
463  fHistoMCDecayGammaSigmaPt(NULL),
464  fHistoMCConvGammaPt(NULL),
465  fHistoMCSecondaryConvGammaPt(NULL),
466  fHistoMCConvGammaR(NULL),
467  fHistoMCConvGammaEta(NULL),
468  fHistoMCPi0Pt(NULL),
469  fHistoMCPi0WOWeightPt(NULL),
470  fHistoMCPi0WOEvtWeightPt(NULL),
471  fHistoMCEtaPt(NULL),
472  fHistoMCEtaWOWeightPt(NULL),
473  fHistoMCEtaWOEvtWeightPt(NULL),
474  fHistoMCPi0InAccPt(NULL),
475  fHistoMCPi0WOWeightInAccPt(NULL),
476  fHistoMCPi0WOEvtWeightInAccPt(NULL),
477  fHistoMCEtaInAccPt(NULL),
478  fHistoMCEtaWOWeightInAccPt(NULL),
479  fHistoMCEtaWOEvtWeightInAccPt(NULL),
480  fHistoMCPi0PtY(NULL),
481  fHistoMCEtaPtY(NULL),
482  fHistoMCPi0PtAlpha(NULL),
483  fHistoMCEtaPtAlpha(NULL),
484  fHistoMCPrimaryPtvsSource(NULL),
485  fHistoMCSecPi0PtvsSource(NULL),
486  fHistoMCSecPi0Source(NULL),
487  fHistoMCSecPi0InAccPtvsSource(NULL),
488  fHistoMCSecEtaPt(NULL),
489  fHistoMCSecEtaSource(NULL),
490  fHistoMCPi0PtJetPt(NULL),
491  fHistoMCEtaPtJetPt(NULL),
492  fHistoMCPi0PtGammaLeg(NULL),
493  fHistoMCPi0WOWeightPtGammaLeg(NULL),
494  fHistoMCPi0InAccPtGammaLeg(NULL),
495  fHistoMCPi0WOWeightInAccPtGammaLeg(NULL),
496  fHistoMCSecPi0PtGamma1vsSource(NULL),
497  fHistoMCSecPi0InAccPtGamma1vsSource(NULL),
498  fHistoMCSecPi0PtGamma2vsSource(NULL),
499  fHistoMCSecPi0InAccPtGamma2vsSource(NULL),
500  fHistoTruePi0InvMassPt(NULL),
501  fHistoTrueEtaInvMassPt(NULL),
502  fHistoTruePi0MatchedInvMassPt(NULL),
503  fHistoTrueEtaMatchedInvMassPt(NULL),
504  fHistoTruePi0CaloPhotonInvMassPt(NULL),
505  fHistoTrueEtaCaloPhotonInvMassPt(NULL),
506  fHistoTruePi0CaloConvertedPhotonInvMassPt(NULL),
507  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt(NULL),
508  fHistoTruePi0CaloConvPhotonConvRPt(NULL),
509  fHistoTruePi0CaloConvPhotonConvRAlpha(NULL),
510  fHistoTruePi0CaloConvPhotonPtAlpha(NULL),
511  fHistoTrueEtaCaloConvertedPhotonInvMassPt(NULL),
512  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt(NULL),
513  fHistoTrueEtaCaloConvPhotonConvRPt(NULL),
514  fHistoTrueEtaCaloConvPhotonConvRAlpha(NULL),
515  fHistoTrueEtaCaloConvPhotonPtAlpha(NULL),
516  fHistoTruePi0CaloElectronInvMassPt(NULL),
517  fHistoTrueEtaCaloElectronInvMassPt(NULL),
518  fHistoTruePi0CaloMergedClusterInvMassPt(NULL),
519  fHistoTrueEtaCaloMergedClusterInvMassPt(NULL),
520  fHistoTrueMotherCaloEMNonLeadingInvMassPt(NULL),
521  fHistoTruePi0CaloMergedClusterPartConvInvMassPt(NULL),
522  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt(NULL),
523  fHistoTruePrimaryPi0InvMassPt(NULL),
524  fHistoTruePrimaryEtaInvMassPt(NULL),
525  fHistoTruePrimaryPi0W0WeightingInvMassPt(NULL),
526  fHistoTruePrimaryEtaW0WeightingInvMassPt(NULL),
527  fProfileTruePrimaryPi0WeightsInvMassPt(NULL),
528  fProfileTruePrimaryEtaWeightsInvMassPt(NULL),
529  fHistoTruePrimaryPi0MCPtResolPt(NULL),
530  fHistoTruePrimaryEtaMCPtResolPt(NULL),
531  fHistoTrueMotherPi0ConvPhotonEtaPhi(NULL),
532  fHistoTrueMotherEtaConvPhotonEtaPhi(NULL),
533  fHistoTrueSecondaryPi0InvMassPt(NULL),
534  fHistoTrueSecondaryPi0FromK0sInvMassPt(NULL),
535  fHistoTrueK0sWithPi0DaughterMCPt(NULL),
536  fHistoTrueSecondaryPi0FromK0lInvMassPt(NULL),
537  fHistoTrueK0lWithPi0DaughterMCPt(NULL),
538  fHistoTrueSecondaryPi0FromEtaInvMassPt(NULL),
539  fHistoTrueEtaWithPi0DaughterMCPt(NULL),
540  fHistoTrueSecondaryPi0FromLambdaInvMassPt(NULL),
541  fHistoTrueLambdaWithPi0DaughterMCPt(NULL),
542  fHistoTrueBckGGInvMassPt(NULL),
543  fHistoTrueBckFullMesonContainedInOneClusterInvMassPt(NULL),
544  fHistoTrueBckAsymEClustersInvMassPt(NULL),
545  fHistoTrueBckContInvMassPt(NULL),
546  fHistoTruePi0PtY(NULL),
547  fHistoTrueEtaPtY(NULL),
548  fHistoTruePi0PtAlpha(NULL),
549  fHistoTrueEtaPtAlpha(NULL),
550  fHistoTruePi0PtOpenAngle(NULL),
551  fHistoTrueEtaPtOpenAngle(NULL),
552  fHistoTrueConvGammaPt(NULL),
553  fHistoTrueConvGammaEta(NULL),
554  fHistoCombinatorialPt(NULL),
555  fHistoTruePrimaryConvGammaPt(NULL),
556  fHistoTruePrimaryConvGammaESDPtMCPt(NULL),
557  fHistoTrueSecondaryConvGammaPt(NULL),
558  fHistoTrueSecondaryConvGammaMCPt(NULL),
559  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt(NULL),
560  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt(NULL),
561  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt(NULL),
562  fHistoTrueClusGammaPt(NULL),
563  fHistoTrueClusElectronPt(NULL),
564  fHistoTrueClusConvGammaPt(NULL),
565  fHistoTrueClusConvGammaFullyPt(NULL),
566  fHistoTrueClusMergedGammaPt(NULL),
567  fHistoTrueClusMergedPartConvGammaPt(NULL),
568  fHistoTrueClusDalitzPt(NULL),
569  fHistoTrueClusDalitzMergedPt(NULL),
570  fHistoTrueClusPhotonFromElecMotherPt(NULL),
571  fHistoTrueClusShowerPt(NULL),
572  fHistoTrueClusSubLeadingPt(NULL),
573  fHistoTrueClusNMothers(NULL),
574  fHistoTrueClusEMNonLeadingPt(NULL),
575  fHistoTrueNLabelsInClusPt(NULL),
576  fHistoTruePrimaryClusGammaPt(NULL),
577  fHistoTruePrimaryClusGammaESDPtMCPt(NULL),
578  fHistoTruePrimaryClusConvGammaPt(NULL),
579  fHistoTruePrimaryClusConvGammaESDPtMCPt(NULL),
580  fHistoTrueSecondaryClusGammaPt(NULL),
581  fHistoTrueSecondaryClusGammaFromK0sPt(NULL),
582  fHistoTrueSecondaryClusGammaFromK0lPt(NULL),
583  fHistoTrueSecondaryClusGammaFromLambdaPt(NULL),
584  fHistoTruePrimaryPi0PhotonPairPtconv(NULL),
585  fHistoTruePrimaryPi0W0WeightsPhotonPairPtconv(NULL),
586  fHistoTruePrimaryPi0DCPtconv(NULL),
587  fHistoTruePrimaryPi0MissingPtconv(NULL),
588  fHistoTrueSecondaryPi0PhotonPairPtconv(NULL),
589  fHistoTrueSecondaryPi0FromK0sPhotonPairPtconv(NULL),
590  fHistoTrueSecondaryPi0FromK0lPhotonPairPtconv(NULL),
591  fHistoTrueSecondaryPi0FromLambdaPhotonPairPtconv(NULL),
592  fHistoTrueSecondaryPi0DCPtconvSource(NULL),
593  fHistoTrueSecondaryPi0MissingPtconvSource(NULL),
594  fVectorRecTruePi0s(0),
595  fVectorRecTrueEtas(0),
596  fHistoDoubleCountTruePi0InvMassPt(NULL),
597  fHistoDoubleCountTrueEtaInvMassPt(NULL),
598  fHistoDoubleCountTrueConvGammaRPt(NULL),
599  fHistoDoubleCountTrueClusterGammaPt(NULL),
600  fVectorDoubleCountTruePi0s(0),
601  fVectorDoubleCountTrueEtas(0),
602  fVectorDoubleCountTrueConvGammas(0),
603  fVectorDoubleCountTrueClusterGammas(0),
604  fHistoMultipleCountTruePi0(NULL),
605  fHistoMultipleCountTrueEta(NULL),
606  fHistoMultipleCountTrueConvGamma(NULL),
607  fHistoMultipleCountTrueClusterGamma(NULL),
608  fMapMultipleCountTruePi0s(),
609  fMapMultipleCountTrueEtas(),
610  fMapMultipleCountTrueConvGammas(),
611  fMapMultipleCountTrueClusterGammas(),
612  fHistoTrueClusGammaEM02(NULL),
613  fHistoTrueClusPi0EM02(NULL),
614  fHistoTruePi0InvMassECalib(NULL),
615  fHistoTruePi0PureGammaInvMassECalib(NULL),
616  fHistoNEvents(NULL),
617  fHistoNEventsWOWeight(NULL),
618  fHistoNGoodESDTracks(NULL),
619  fHistoVertexZ(NULL),
620  fHistoVertexX(NULL),
621  fHistoVertexY(NULL),
622  fHistoNGammaCandidates(NULL),
623  fHistoNGoodESDTracksVsNGammaCandidates(NULL),
624  fHistoSPDClusterTrackletBackground(NULL),
625  fHistoNV0Tracks(NULL),
626  fProfileEtaShift(NULL),
627  fProfileJetJetXSection(NULL),
628  fHistoJetJetNTrials(NULL),
629 // fHistoTruePi0NonLinearity(NULL),
630 // fHistoTrueEtaNonLinearity(NULL),
631  fEventPlaneAngle(-100),
632  fRandom(0),
633  fNGammaCandidates(0),
634  fUnsmearedPx(NULL),
635  fUnsmearedPy(NULL),
636  fUnsmearedPz(NULL),
637  fUnsmearedE(NULL),
638  fMCEventPos(NULL),
639  fMCEventNeg(NULL),
640  fESDArrayPos(NULL),
641  fESDArrayNeg(NULL),
642  fnCuts(0),
643  fiCut(0),
644  fMoveParticleAccordingToVertex(kTRUE),
645  fIsHeavyIon(0),
646  fDoLightOutput(kFALSE),
647  fDoMesonAnalysis(kTRUE),
648  fDoMesonQA(0),
649  fDoPhotonQA(0),
650  fDoClusterQA(0),
651  fIsFromMBHeader(kTRUE),
652  fIsOverlappingWithOtherHeader(kFALSE),
653  fIsMC(0),
654  fDoTHnSparse(kTRUE),
655  fSetPlotHistsExtQA(kFALSE),
656  fWeightJetJetMC(1),
657  fDoConvGammaShowerShapeTree(kFALSE),
658  fEnableSortForClusMC(kFALSE),
659  fDoPrimaryTrackMatching(kFALSE),
660  fDoInvMassShowerShapeTree(kFALSE),
661  tBrokenFiles(NULL),
662  fFileNameBroken(NULL)
663 {
664  // Define output slots here
665  DefineOutput(1, TList::Class());
666 }
667 
669 {
670  if(fGammaCandidates){
671  delete fGammaCandidates;
672  fGammaCandidates = 0x0;
673  }
674  if(fClusterCandidates){
675  delete fClusterCandidates;
676  fClusterCandidates = 0x0;
677  }
678  if(fBGHandler){
679  delete[] fBGHandler;
680  fBGHandler = 0x0;
681  }
682  if(fBGHandlerRP){
683  delete[] fBGHandlerRP;
684  fBGHandlerRP = 0x0;
685  }
686  if(fBGClusHandler){
687  delete[] fBGClusHandler;
688  fBGClusHandler = 0x0;
689  }
690  if(fBGClusHandlerRP){
691  delete[] fBGClusHandlerRP;
692  fBGClusHandlerRP = 0x0;
693  }
694 }
695 //___________________________________________________________
697 
698  const Int_t nDim = 4;
699  Int_t nBins[nDim] = {800,300,7,4};
700  Double_t xMin[nDim] = {0,0, 0,0};
701  Double_t xMax[nDim] = {0.8,30,7,4};
702 
703  if(fDoTHnSparse){
704  fSparseMotherInvMassPtZM = new THnSparseF*[fnCuts];
705  fSparseMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
706  }
707 
710 
713 
714  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
715  if (((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
716  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
717  TString cutstringPhoton = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
718  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
719  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
720 
721  Int_t collisionSystem = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(0,1));
722  Int_t centMin = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(1,1));
723  Int_t centMax = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(2,1));
724 
725  if(collisionSystem == 1 || collisionSystem == 2 ||
726  collisionSystem == 5 || collisionSystem == 8 ||
727  collisionSystem == 9){
728  centMin = centMin*10;
729  centMax = centMax*10;
730  if(centMax ==0 && centMax!=centMin) centMax=100;
731  }else if(collisionSystem == 3 || collisionSystem == 6){
732  centMin = centMin*5;
733  centMax = centMax*5;
734  }else if(collisionSystem == 4 || collisionSystem == 7){
735  centMin = ((centMin*5)+45);
736  centMax = ((centMax*5)+45);
737  }
738 
739  if(fDoTHnSparse){
740  fBackList[iCut] = new TList();
741  fBackList[iCut]->SetName(Form("%s_%s_%s_%s Back histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(), cutstringMeson.Data()));
742  fBackList[iCut]->SetOwner(kTRUE);
743  fCutFolder[iCut]->Add(fBackList[iCut]);
744 
745  fSparseMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_m","Back_Back_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
746  fBackList[iCut]->Add(fSparseMotherBackInvMassPtZM[iCut]);
747 
748  fMotherList[iCut] = new TList();
749  fMotherList[iCut]->SetName(Form("%s_%s_%s_%s Mother histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
750  fMotherList[iCut]->SetOwner(kTRUE);
751  fCutFolder[iCut]->Add(fMotherList[iCut]);
752 
753  fSparseMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_m","Back_Mother_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
754  fMotherList[iCut]->Add(fSparseMotherInvMassPtZM[iCut]);
755  }
756 
757  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
759  collisionSystem,centMin,centMax,
760  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents(),
761  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseTrackMultiplicity(),
762  2,8,5);
764  collisionSystem,centMin,centMax,
765  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents(),
766  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseTrackMultiplicity(),
767  2,8,5);
768  fBGHandlerRP[iCut] = NULL;
769  }else{
771  ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsHeavyIon(),
772  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity(),
773  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents());
775  ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsHeavyIon(),
776  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity(),
777  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents());
778  fBGHandler[iCut] = NULL;
779  }
780  }
781  }
782 }
783 //________________________________________________________________________
785 
786  fV0Reader = (AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
787  if(!fV0Reader){printf("Error: No V0 Reader");return;}// GetV0Reader
788 
789 
790  if (fIsMC == 2){
791  fDoClusterQA = 0;
792  fDoTHnSparse = kFALSE;
793  } else if (fIsMC == 3){
794  fDoTHnSparse = kFALSE;
795  }
796  // Create histograms
797  if(fOutputContainer != NULL){
798  delete fOutputContainer;
799  fOutputContainer = NULL;
800  }
801  if(fOutputContainer == NULL){
802  fOutputContainer = new TList();
803  fOutputContainer->SetOwner(kTRUE);
804  }
805 
806  // Array of current cut's gammas
807  fGammaCandidates = new TList();
808  fClusterCandidates = new TList();
809  fClusterCandidates->SetOwner(kTRUE);
810 
811  fCutFolder = new TList*[fnCuts];
812  fESDList = new TList*[fnCuts];
813 
814  if(fDoTHnSparse){
815  fBackList = new TList*[fnCuts];
816  fMotherList = new TList*[fnCuts];
817  }
818 
819  fHistoNEvents = new TH1F*[fnCuts];
820  if (fIsMC > 1){
821  fHistoNEventsWOWeight = new TH1F*[fnCuts];
822  }
823  if (fIsMC == 2){
824  fProfileJetJetXSection = new TProfile*[fnCuts];
825  fHistoJetJetNTrials = new TH1F*[fnCuts];
826  }
827  fHistoNGoodESDTracks = new TH1F*[fnCuts];
828  fHistoVertexZ = new TH1F*[fnCuts];
829  if(!fDoLightOutput){
830  fHistoVertexX = new TH1F*[fnCuts];
831  fHistoVertexY = new TH1F*[fnCuts];
832  }
833  fHistoNGammaCandidates = new TH1F*[fnCuts];
834  if(fIsHeavyIon==2) fProfileEtaShift = new TProfile*[fnCuts];
835  if(!fDoLightOutput){
838  fHistoNV0Tracks = new TH1F*[fnCuts];
839  fHistoConvGammaPt = new TH1F*[fnCuts];
840  }
841 
842  if (fDoPhotonQA == 2){
843  fPhotonDCAList = new TList*[fnCuts];
845  }
846  if (fDoPhotonQA > 0){
847  fHistoConvGammaR = new TH1F*[fnCuts];
848  fHistoConvGammaEta = new TH1F*[fnCuts];
849  }
850 
851  if(fDoMesonAnalysis){
854  if(!fDoLightOutput){
861  }
862  if (fDoMesonQA > 0){
871  }
872  }
873 
875  fHistoClusGammaPt = new TH1F*[fnCuts];
876  fHistoClusGammaE = new TH1F*[fnCuts];
878 
880  fGammaERM02 = new TList*[fnCuts];
881  tESDGammaERM02 = new TTree*[fnCuts];
882  }
883 
887  }
888 
889  // set common binning in pT for mesons and photons
890  Int_t nBinsPt = 200;
891  Float_t minPt = 0;
892  Float_t maxPt = 20;
893  Int_t nBinsQAPt = 200;
894  Float_t minQAPt = 0.4;
895  Float_t maxQAPt = 20;
896  Int_t nBinsClusterPt = 500;
897  Float_t minClusterPt = 0;
898  Float_t maxClusterPt = 50;
899  if (((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k8TeV ){
900  nBinsPt = 400;
901  minPt = 0;
902  maxPt = 40;
903  nBinsQAPt = 300;
904  minQAPt = 0.4;
905  maxQAPt = 40;
906  nBinsClusterPt = 800;
907  minClusterPt = 0;
908  maxClusterPt = 80;
909  } else if (((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::kpPb5TeV ){
910  nBinsPt = 400;
911  minPt = 0;
912  maxPt = 40;
913  nBinsQAPt = 300;
914  minQAPt = 0.4;
915  maxQAPt = 40;
916  nBinsClusterPt = 800;
917  minClusterPt = 0;
918  maxClusterPt = 80;
919  }
920 
921  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
922  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
923  TString cutstringPhoton = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
924  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
925  TString cutstringMeson = "NoMesonCut";
926  if(fDoMesonAnalysis)
927  cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
928 
929  fCutFolder[iCut] = new TList();
930  fCutFolder[iCut]->SetName(Form("Cut Number %s_%s_%s_%s",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
931  fCutFolder[iCut]->SetOwner(kTRUE);
932  fOutputContainer->Add(fCutFolder[iCut]);
933  fESDList[iCut] = new TList();
934  fESDList[iCut]->SetName(Form("%s_%s_%s_%s ESD histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
935  fESDList[iCut]->SetOwner(kTRUE);
936  fCutFolder[iCut]->Add(fESDList[iCut]);
937 
938  fHistoNEvents[iCut] = new TH1F("NEvents","NEvents",14,-0.5,13.5);
939  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
940  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
941  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
942  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
943  TString TriggerNames = "Not Trigger: ";
944  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
945  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
946  }else {
947  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
948  }
949  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
950  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
951  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
952  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
953  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
954  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
955  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
956  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
957  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
958  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
959  fESDList[iCut]->Add(fHistoNEvents[iCut]);
960 
961  if (fIsMC > 1){
962  fHistoNEventsWOWeight[iCut] = new TH1F("NEventsWOWeight","NEventsWOWeight",14,-0.5,13.5);
963  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
964  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
965  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
966  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
967  TString TriggerNames = "Not Trigger: ";
968  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
969  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
970  }else {
971  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
972  }
973  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
974  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
975  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
976  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
977  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
978  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
979  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
980  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
981  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
982  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
983  fESDList[iCut]->Add(fHistoNEventsWOWeight[iCut]);
984  }
985 
986  if (fIsMC == 2){
987  fProfileJetJetXSection[iCut] = new TProfile("XSection","XSection",1,-0.5,0.5);
988  fESDList[iCut]->Add(fProfileJetJetXSection[iCut]);
989  fHistoJetJetNTrials[iCut] = new TH1F("NTrials","#sum{NTrials}",1,0,1);
990  fHistoJetJetNTrials[iCut]->GetXaxis()->SetBinLabel(1,"#sum{NTrials}");
991  fESDList[iCut]->Add(fHistoJetJetNTrials[iCut]);
992  }
993 
994  if(fIsHeavyIon == 1)
995  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks","GoodESDTracks",4000,0,4000);
996  else if(fIsHeavyIon == 2)
997  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks","GoodESDTracks",400,0,400);
998  else
999  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks","GoodESDTracks",200,0,200);
1000  fHistoNGoodESDTracks[iCut]->SetXTitle("# TPC tracks");
1001  fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
1002 
1003  fHistoVertexZ[iCut] = new TH1F("VertexZ","VertexZ",1000,-50,50);
1004  fESDList[iCut]->Add(fHistoVertexZ[iCut]);
1005  if(!fDoLightOutput){
1006  fHistoVertexX[iCut] = new TH1F("VertexX","VertexX",200,-5,5);
1007  fESDList[iCut]->Add(fHistoVertexX[iCut]);
1008  fHistoVertexY[iCut] = new TH1F("VertexY","VertexY",200,-5,5);
1009  fESDList[iCut]->Add(fHistoVertexY[iCut]);
1010  }
1011 
1012  if(fIsHeavyIon == 1)
1013  fHistoNGammaCandidates[iCut] = new TH1F("GammaCandidates","GammaCandidates",100,0,100);
1014  else if(fIsHeavyIon == 2)
1015  fHistoNGammaCandidates[iCut] = new TH1F("GammaCandidates","GammaCandidates",50,0,50);
1016  else
1017  fHistoNGammaCandidates[iCut] = new TH1F("GammaCandidates","GammaCandidates",50,0,50);
1018  fHistoNGammaCandidates[iCut]->SetXTitle("# accepted #gamma_{conv}");
1019  fESDList[iCut]->Add(fHistoNGammaCandidates[iCut]);
1020 
1021  if(!fDoLightOutput){
1022  if(fIsHeavyIon == 1)
1023  fHistoNGoodESDTracksVsNGammaCandidates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",4000,0,4000,100,0,100);
1024  else if(fIsHeavyIon == 2)
1025  fHistoNGoodESDTracksVsNGammaCandidates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",400,0,400,50,0,50);
1026  else
1027  fHistoNGoodESDTracksVsNGammaCandidates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",200,0,200,50,0,50);
1028  fHistoNGoodESDTracksVsNGammaCandidates[iCut]->SetXTitle("# TPC tracks");
1029  fHistoNGoodESDTracksVsNGammaCandidates[iCut]->SetYTitle("# accepted #gamma_{conv}");
1031 
1032  fHistoSPDClusterTrackletBackground[iCut] = new TH2F("SPD tracklets vs SPD clusters","SPD tracklets vs SPD clusters",100,0,200,250,0,1000);
1033  fESDList[iCut]->Add(fHistoSPDClusterTrackletBackground[iCut]);
1034 
1035  if(fIsHeavyIon == 1)
1036  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity","V0 Multiplicity",30000,0,30000);
1037  else if(fIsHeavyIon == 2)
1038  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity","V0 Multiplicity",2500,0,2500);
1039  else
1040  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity","V0 Multiplicity",1500,0,1500);
1041  fHistoNV0Tracks[iCut]->SetXTitle("VZERO amp [arb. units]");
1042  fESDList[iCut]->Add(fHistoNV0Tracks[iCut]);
1043 
1044  fHistoConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt","ESD_ConvGamma_Pt",nBinsPt, minPt, maxPt);
1045  fHistoConvGammaPt[iCut]->SetXTitle("p_{T,conv}(GeV/c)");
1046  fESDList[iCut]->Add(fHistoConvGammaPt[iCut]);
1047  }
1048 
1049  if(fIsHeavyIon == 2){
1050  fProfileEtaShift[iCut] = new TProfile("Eta Shift","Eta Shift",1, -0.5,0.5);
1051  fESDList[iCut]->Add(fProfileEtaShift[iCut]);
1052  }
1053 
1054  if (fIsMC > 1){
1055  fHistoNEvents[iCut]->Sumw2();
1056  fHistoNGoodESDTracks[iCut]->Sumw2();
1057  fHistoVertexZ[iCut]->Sumw2();
1058  fHistoNGammaCandidates[iCut]->Sumw2();
1059  if(!fDoLightOutput){
1060  fHistoVertexX[iCut]->Sumw2();
1061  fHistoVertexY[iCut]->Sumw2();
1063  fHistoSPDClusterTrackletBackground[iCut]->Sumw2();
1064  fHistoNV0Tracks[iCut]->Sumw2();
1065  fHistoConvGammaPt[iCut]->Sumw2();
1066  }
1067  }
1068 
1069  if (fDoPhotonQA == 2 ){
1070  fPhotonDCAList[iCut] = new TList();
1071  fPhotonDCAList[iCut]->SetName(Form("%s_%s_%s_%s Photon DCA tree",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
1072  fPhotonDCAList[iCut]->SetOwner(kTRUE);
1073  fCutFolder[iCut]->Add(fPhotonDCAList[iCut]);
1074 
1075  fTreeConvGammaPtDcazCat[iCut] = new TTree("ESD_ConvGamma_Pt_Dcaz_R_Eta","ESD_ConvGamma_Pt_Dcaz_R_Eta_Cat");
1076  fTreeConvGammaPtDcazCat[iCut]->Branch("Pt",&fPtGamma,"fPtGamma/F");
1077  fTreeConvGammaPtDcazCat[iCut]->Branch("DcaZPhoton",&fDCAzPhoton,"fDCAzPhoton/F");
1078  fTreeConvGammaPtDcazCat[iCut]->Branch("cat",&fCharCatPhoton,"fCharCatPhoton/b");
1079  if(fIsMC > 0){
1080  fTreeConvGammaPtDcazCat[iCut]->Branch("photonMCInfo",&fCharPhotonMCInfo,"fCharPhotonMCInfo/b");
1081  }
1082  if (fIsMC > 1){
1083  fTreeConvGammaPtDcazCat[iCut]->Branch("weightEvent",&fWeightJetJetMC,"fWeightJetJetMC/b");
1084  }
1085  fPhotonDCAList[iCut]->Add(fTreeConvGammaPtDcazCat[iCut]);
1086  }
1087 
1088  if (fDoPhotonQA > 0){
1089  fHistoConvGammaR[iCut] = new TH1F("ESD_ConvGamma_R","ESD_ConvGamma_R",800,0,200);
1090  fHistoConvGammaR[iCut]->SetXTitle("R_{conv}(cm)");
1091  fESDList[iCut]->Add(fHistoConvGammaR[iCut]);
1092  fHistoConvGammaEta[iCut] = new TH1F("ESD_ConvGamma_Eta","ESD_ConvGamma_Eta",2000,-2,2);
1093  fHistoConvGammaEta[iCut]->SetXTitle("#eta_{conv}");
1094  fESDList[iCut]->Add(fHistoConvGammaEta[iCut]);
1095  }
1096 
1097  fClusterOutputList[iCut] = new TList();
1098  fClusterOutputList[iCut]->SetName(Form("%s_%s_%s_%s Cluster Output",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
1099  fClusterOutputList[iCut]->SetOwner(1);
1100  fCutFolder[iCut]->Add(fClusterOutputList[iCut]);
1101 
1102  fHistoClusGammaPt[iCut] = new TH1F("ClusGamma_Pt","ClusGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1103  fHistoClusGammaPt[iCut]->SetXTitle("p_{T,clus}(GeV/c)");
1104  fClusterOutputList[iCut]->Add(fHistoClusGammaPt[iCut]);
1105  fHistoClusGammaE[iCut] = new TH1F("ClusGamma_E","ClusGamma_E",nBinsClusterPt, minClusterPt, maxClusterPt);
1106  fHistoClusGammaE[iCut]->SetXTitle("E_{clus}(GeV)");
1107  fClusterOutputList[iCut]->Add(fHistoClusGammaE[iCut]);
1108  fHistoClusOverlapHeadersGammaPt[iCut] = new TH1F("ClusGammaOverlapHeaders_Pt","ClusGammaOverlapHeaders_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1109  fHistoClusOverlapHeadersGammaPt[iCut]->SetXTitle("p_{T,clus}(GeV/c), selected header w/ overlap");
1111 
1113  fGammaERM02[iCut] = new TList();
1114  fGammaERM02[iCut]->SetName(Form("%s_%s_%s_%s ConvGamma-Cluster Matched",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
1115  fGammaERM02[iCut]->SetOwner(kTRUE);
1116  fCutFolder[iCut]->Add(fGammaERM02[iCut]);
1117 
1118  tESDGammaERM02[iCut] = new TTree("ESD_ConvGamma_E_ConvR_M02_M20","ESD_ConvGamma_E_ConvR_M02_M20");
1119  tESDGammaERM02[iCut]->Branch("ClusterE",&tESDClusE,"tESDClusE/F");
1120  tESDGammaERM02[iCut]->Branch("ConvR",&tESDGammaConvR,"tESDGammaConvR/F");
1121  tESDGammaERM02[iCut]->Branch("M02",&tESDClusterM02,"tESDClusterM02/F");
1122  tESDGammaERM02[iCut]->Branch("M20",&tESDClusterM20,"tESDClusterM20/F");
1123  tESDGammaERM02[iCut]->Branch("Eta",&tESDClusterEta,"tESDClusterEta/F");
1124  tESDGammaERM02[iCut]->Branch("Phi",&tESDClusterPhi,"tESDClusterPhi/F");
1125  tESDGammaERM02[iCut]->Branch("NCells",&tESDClusterNCells,"tESDClusterNCells/F");
1126  tESDGammaERM02[iCut]->Branch("MaxECell",&tESDClusterMaxECell,"tESDClusterMaxECell/F");
1127  tESDGammaERM02[iCut]->Branch("NLM",&tESDClusterNLM,"tESDClusterNLM/F");
1128  fGammaERM02[iCut]->Add(tESDGammaERM02[iCut]);
1129  }
1130 
1132  fInvMassShowerShape[iCut] = new TList();
1133  fInvMassShowerShape[iCut]->SetName(Form("%s_%s_%s_%s InvMass_ShowerShape",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
1134  fInvMassShowerShape[iCut]->SetOwner(kTRUE);
1135  fCutFolder[iCut]->Add(fInvMassShowerShape[iCut]);
1136  tESDInvMassShowerShape[iCut] = new TTree("ESD_Meson_InvMass_Pt_ClusE_ClusM02_ClusM20","ESD_Meson_InvMass_Pt_ClusE_ClusM02_ClusM20");
1137  tESDInvMassShowerShape[iCut]->Branch("MesonInvMass",&tESDIMMesonInvMass,"tESDIMMesonInvMass/F");
1138  tESDInvMassShowerShape[iCut]->Branch("MesonPt",&tESDIMMesonPt,"tESDIMMesonPt/F");
1139  tESDInvMassShowerShape[iCut]->Branch("ClusE",&tESDIMClusE,"tESDIMClusE/F");
1140  tESDInvMassShowerShape[iCut]->Branch("ClusM02",&tESDIMClusterM02,"tESDIMClusterM02/F");
1141  tESDInvMassShowerShape[iCut]->Branch("ClusM20",&tESDIMClusterM20,"tESDIMClusterM20/F");
1142  tESDInvMassShowerShape[iCut]->Branch("ClusLeadCellID",&tESDIMClusterLeadCellID,"tESDIMClusterLeadCellID/I");
1143  if(fIsMC>0) tESDInvMassShowerShape[iCut]->Branch("ClusClassification",&tESDIMClusterClassification,"tESDIMClusterClassification/I");
1144  tESDInvMassShowerShape[iCut]->Branch("ClusMatchedTrackPt",&tESDIMClusMatchedTrackPt,"tESDIMClusMatchedTrackPt/F");
1145  tESDInvMassShowerShape[iCut]->Branch("ClusTrackDeltaEta",&tESDIMClusTrackDeltaEta,"tESDIMClusTrackDeltaEta/F");
1146  tESDInvMassShowerShape[iCut]->Branch("ClusTrackDeltaPhi",&tESDIMClusTrackDeltaPhi,"tESDIMClusTrackDeltaPhi/F");
1147  tESDInvMassShowerShape[iCut]->Branch("ClusIsoSumClusterEt",&tESDIMClusterIsoSumClusterEt,"tESDIMClusterIsoSumClusterEt/F");
1148  tESDInvMassShowerShape[iCut]->Branch("ClusIsoSumTrackEt",&tESDIMClusterIsoSumTrackEt,"tESDIMClusterIsoSumTrackEt/F");
1149  fInvMassShowerShape[iCut]->Add(tESDInvMassShowerShape[iCut]);
1150  }
1151 
1152  if (fIsMC > 1){
1153  fHistoClusGammaPt[iCut]->Sumw2();
1154  fHistoClusGammaE[iCut]->Sumw2();
1155  fHistoClusOverlapHeadersGammaPt[iCut]->Sumw2();
1156  }
1157 
1158  if(fDoMesonAnalysis){
1159  fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1160  fHistoMotherInvMassPt[iCut]->SetXTitle("M_{inv}(GeV/c^{2})");
1161  fHistoMotherInvMassPt[iCut]->SetYTitle("p_{T,pair}(GeV/c)");
1162  fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
1163 
1164  if(!fDoLightOutput){
1165  fHistoMotherMatchedInvMassPt[iCut] = new TH2F("ESD_MotherMatched_InvMass_Pt","ESD_MotherMatched_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1166  fHistoMotherMatchedInvMassPt[iCut]->SetXTitle("M_{inv}(GeV/c^{2}) matched conv e^{+/-}to cluster");
1167  fHistoMotherMatchedInvMassPt[iCut]->SetYTitle("p_{T,pair}(GeV/c)");
1168  fESDList[iCut]->Add(fHistoMotherMatchedInvMassPt[iCut]);
1169  }
1170 
1171  fHistoMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt","ESD_Background_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1172  fHistoMotherBackInvMassPt[iCut]->SetXTitle("M_{inv, mxed}(GeV/c^{2})");
1173  fHistoMotherBackInvMassPt[iCut]->SetYTitle("p_{T,BG pair}(GeV/c)");
1174  fESDList[iCut]->Add(fHistoMotherBackInvMassPt[iCut]);
1175 
1176  if(!fDoLightOutput){
1177  fHistoMotherInvMassPtAlpha[iCut] = new TH2F("ESD_Mother_InvMass_vs_Pt_Alpha","ESD_Mother_InvMass_vs_Pt_Alpha",800,0,0.8,nBinsPt, minPt, maxPt);
1178  fHistoMotherInvMassPtAlpha[iCut]->SetXTitle("M_{inv}(GeV/c^{2})");
1179  fHistoMotherInvMassPtAlpha[iCut]->SetYTitle("p_{T,pair}(GeV/c)");
1180  fESDList[iCut]->Add(fHistoMotherInvMassPtAlpha[iCut]);
1181 
1182  fHistoPhotonPairPtconv[iCut] = new TH2F("ESD_Mother_InvMass_PtConv","",800,0,0.8,nBinsPt, minPt, maxPt);
1183  fHistoPhotonPairPtconv[iCut]->SetXTitle("M_{inv}(GeV/c^{2})");
1184  fHistoPhotonPairPtconv[iCut]->SetYTitle("#gamma^{conv}p_{T}(GeV/c)");
1185  fESDList[iCut]->Add(fHistoPhotonPairPtconv[iCut]);
1186 
1187  fHistoPhotonPairMixedEventPtconv[iCut] = new TH2F("ESD_Background_InvMass_PtConv","",800,0,0.8,nBinsPt, minPt, maxPt);
1188  fHistoPhotonPairMixedEventPtconv[iCut]->SetXTitle("M_{inv,mixed}(GeV/c^{2})");
1189  fHistoPhotonPairMixedEventPtconv[iCut]->SetYTitle("#gamma^{conv}p_{T}(GeV/c)");
1190  fESDList[iCut]->Add(fHistoPhotonPairMixedEventPtconv[iCut]);
1191  }
1192 
1193  if (fIsMC > 1){
1194  fHistoMotherInvMassPt[iCut]->Sumw2();
1195  fHistoMotherBackInvMassPt[iCut]->Sumw2();
1196  if(!fDoLightOutput){
1197  fHistoMotherMatchedInvMassPt[iCut]->Sumw2();
1198  fHistoMotherInvMassPtAlpha[iCut]->Sumw2();
1199  fHistoPhotonPairPtconv[iCut]->Sumw2();
1200  fHistoPhotonPairMixedEventPtconv[iCut]->Sumw2();
1201  }
1202  }
1203 
1204  if(!fDoLightOutput){
1205  fHistoMotherInvMassECalib[iCut] = new TH2F("ESD_Mother_InvMass_E_Calib","ESD_Mother_InvMass_E_Calib",800,0,0.8,nBinsPt, minPt, maxPt);
1206  fHistoMotherInvMassECalib[iCut]->SetXTitle("M_{inv}(GeV/c^{2})");
1207  fHistoMotherInvMassECalib[iCut]->SetYTitle("E_{cluster}(GeV)");
1208  fESDList[iCut]->Add(fHistoMotherInvMassECalib[iCut]);
1209 
1210  fHistoMotherBackInvMassECalib[iCut] = new TH2F("ESD_Background_InvMass_E_Calib","ESD_Background_InvMass_E_Calib",800,0,0.8,nBinsPt, minPt, maxPt);
1211  fHistoMotherBackInvMassECalib[iCut]->SetXTitle("M_{inv}(GeV/c^{2})");
1212  fHistoMotherBackInvMassECalib[iCut]->SetYTitle("E_{cluster}(GeV)");
1213  fESDList[iCut]->Add(fHistoMotherBackInvMassECalib[iCut]);
1214 
1215  if (fIsMC > 1){
1216  fHistoMotherInvMassECalib[iCut]->Sumw2();
1217  fHistoMotherBackInvMassECalib[iCut]->Sumw2();
1218  }
1219  }
1220 
1221  if (fDoMesonQA > 0 ){
1222  fHistoMotherPi0PtY[iCut] = new TH2F("ESD_MotherPi0_Pt_Y","ESD_MotherPi0_Pt_Y",nBinsQAPt, minQAPt, maxQAPt,150,-1.5,1.5);
1223  fHistoMotherPi0PtY[iCut]->SetXTitle("p_{T, #pi^{0}cand}(GeV/c)");
1224  fHistoMotherPi0PtY[iCut]->SetYTitle("y_{#pi^{0}cand}");
1226  fESDList[iCut]->Add(fHistoMotherPi0PtY[iCut]);
1227  fHistoMotherEtaPtY[iCut] = new TH2F("ESD_MotherEta_Pt_Y","ESD_MotherEta_Pt_Y",nBinsQAPt, minQAPt, maxQAPt,150,-1.5,1.5);
1228  fHistoMotherEtaPtY[iCut]->SetXTitle("p_{T, #eta cand}(GeV/c)");
1229  fHistoMotherEtaPtY[iCut]->SetYTitle("y_{ #eta cand}");
1231  fESDList[iCut]->Add(fHistoMotherEtaPtY[iCut]);
1232  fHistoMotherPi0PtAlpha[iCut] = new TH2F("ESD_MotherPi0_Pt_Alpha","ESD_MotherPi0_Pt_Alpha",nBinsQAPt, minQAPt, maxQAPt,200,-1,1);
1233  fHistoMotherPi0PtAlpha[iCut]->SetXTitle("p_{T, #pi^{0}cand}(GeV/c)");
1234  fHistoMotherPi0PtAlpha[iCut]->SetYTitle("#alpha_{#pi^{0}cand}");
1236  fESDList[iCut]->Add(fHistoMotherPi0PtAlpha[iCut]);
1237  fHistoMotherEtaPtAlpha[iCut] = new TH2F("ESD_MotherEta_Pt_Alpha","ESD_MotherEta_Pt_Alpha",nBinsQAPt, minQAPt, maxQAPt,200,-1,1);
1238  fHistoMotherEtaPtAlpha[iCut]->SetXTitle("p_{T, #eta cand}(GeV/c)");
1239  fHistoMotherEtaPtAlpha[iCut]->SetYTitle("#alpha_{#eta cand}");
1241  fESDList[iCut]->Add(fHistoMotherEtaPtAlpha[iCut]);
1242  fHistoMotherPi0PtOpenAngle[iCut] = new TH2F("ESD_MotherPi0_Pt_OpenAngle","ESD_MotherPi0_Pt_OpenAngle",nBinsQAPt, minQAPt, maxQAPt,100,0,1);
1243  fHistoMotherPi0PtOpenAngle[iCut]->SetXTitle("p_{T, #pi^{0}cand}(GeV/c)");
1244  fHistoMotherPi0PtOpenAngle[iCut]->SetYTitle("#theta_{#pi^{0}cand}");
1246  fESDList[iCut]->Add(fHistoMotherPi0PtOpenAngle[iCut]);
1247  fHistoMotherEtaPtOpenAngle[iCut] = new TH2F("ESD_MotherEta_Pt_OpenAngle","ESD_MotherEta_Pt_OpenAngle",nBinsQAPt, minQAPt, maxQAPt,200,0,TMath::Pi());
1248  fHistoMotherEtaPtOpenAngle[iCut]->SetXTitle("p_{T, #eta cand}(GeV/c)");
1249  fHistoMotherEtaPtOpenAngle[iCut]->SetYTitle("#theta_{#eta cand}");
1251  fESDList[iCut]->Add(fHistoMotherEtaPtOpenAngle[iCut]);
1252  fHistoMotherPi0ConvPhotonEtaPhi[iCut] = new TH2F("ESD_MotherPi0ConvPhoton_Eta_Phi","ConvPhoton under #pi^{0}peak",600,0,2*TMath::Pi(),200,-1,1);
1253  fHistoMotherPi0ConvPhotonEtaPhi[iCut]->SetXTitle("#phi_{#gamma_{conv}}(rad)");
1254  fHistoMotherPi0ConvPhotonEtaPhi[iCut]->SetYTitle("#eta_{#gamma_{conv}}");
1255  fESDList[iCut]->Add(fHistoMotherPi0ConvPhotonEtaPhi[iCut]);
1256  fHistoMotherEtaConvPhotonEtaPhi[iCut] = new TH2F("ESD_MotherEtaConvPhoton_Eta_Phi","ConvPhoton under #eta peak",600,0,2*TMath::Pi(),200,-1,1);
1257  fHistoMotherEtaConvPhotonEtaPhi[iCut]->SetXTitle("#phi_{#gamma_{conv}}(rad)");
1258  fHistoMotherEtaConvPhotonEtaPhi[iCut]->SetYTitle("#eta_{#gamma_{conv}}");
1259  fESDList[iCut]->Add(fHistoMotherEtaConvPhotonEtaPhi[iCut]);
1260  if (fIsMC > 1){
1261  fHistoMotherPi0PtY[iCut]->Sumw2();
1262  fHistoMotherEtaPtY[iCut]->Sumw2();
1263  fHistoMotherPi0PtAlpha[iCut]->Sumw2();
1264  fHistoMotherEtaPtAlpha[iCut]->Sumw2();
1265  fHistoMotherPi0PtOpenAngle[iCut]->Sumw2();
1266  fHistoMotherEtaPtOpenAngle[iCut]->Sumw2();
1267  fHistoMotherPi0ConvPhotonEtaPhi[iCut]->Sumw2();
1268  fHistoMotherEtaConvPhotonEtaPhi[iCut]->Sumw2();
1269  }
1270  }
1271  }
1272  }
1273  if(fDoMesonAnalysis){
1274  InitBack(); // Init Background Handler
1275  }
1276 
1277  if(fIsMC>0){
1278  // MC Histogramms
1279  fMCList = new TList*[fnCuts];
1280  // True Histogramms
1281  fTrueList = new TList*[fnCuts];
1282 
1283  if(!fDoLightOutput){
1284  fHistoMCHeaders = new TH1I*[fnCuts];
1285  fHistoMCAllGammaPt = new TH1F*[fnCuts];
1286  fHistoMCAllGammaEMCALAccPt = new TH1F*[fnCuts];
1288  fHistoMCDecayGammaPi0Pt = new TH1F*[fnCuts];
1289  fHistoMCDecayGammaRhoPt = new TH1F*[fnCuts];
1290  fHistoMCDecayGammaEtaPt = new TH1F*[fnCuts];
1291  fHistoMCDecayGammaOmegaPt = new TH1F*[fnCuts];
1292  fHistoMCDecayGammaEtapPt = new TH1F*[fnCuts];
1293  fHistoMCDecayGammaPhiPt = new TH1F*[fnCuts];
1294  fHistoMCDecayGammaSigmaPt = new TH1F*[fnCuts];
1295  fHistoMCConvGammaPt = new TH1F*[fnCuts];
1297  fHistoTrueConvGammaPt = new TH1F*[fnCuts];
1300 
1302  fHistoTruePrimaryConvGammaPt = new TH1F*[fnCuts];
1309  }
1310 
1311  fHistoTrueClusGammaPt = new TH1F*[fnCuts];
1312  if(!fDoLightOutput){
1313  fHistoTrueClusConvGammaPt = new TH1F*[fnCuts];
1314  fHistoTruePrimaryClusGammaPt = new TH1F*[fnCuts];
1322  fHistoTrueClusElectronPt = new TH1F*[fnCuts];
1323  }
1326 
1327  if(!fDoLightOutput){
1331  fHistoTrueClusEMNonLeadingPt = new TH1F*[fnCuts];
1332  }
1333 
1334  if (fDoPhotonQA > 0){
1335  fHistoMCConvGammaR = new TH1F*[fnCuts];
1336  fHistoMCConvGammaEta = new TH1F*[fnCuts];
1337  fHistoTrueConvGammaEta = new TH1F*[fnCuts];
1338  }
1339 
1340 // fHistoTruePi0NonLinearity = new TH2F*[fnCuts];
1341 // fHistoTrueEtaNonLinearity = new TH2F*[fnCuts];
1342  if(!fDoLightOutput){
1345  }
1346 
1347  if (fDoClusterQA > 0){
1349  fHistoTrueClusMergedGammaPt = new TH1F*[fnCuts];
1351  fHistoTrueClusDalitzPt = new TH1F*[fnCuts];
1352  fHistoTrueClusDalitzMergedPt = new TH1F*[fnCuts];
1354  fHistoTrueClusShowerPt = new TH1F*[fnCuts];
1355  fHistoTrueClusSubLeadingPt = new TH1F*[fnCuts];
1356  fHistoTrueClusNMothers = new TH1F*[fnCuts];
1357  }
1358 
1359  if(fDoMesonAnalysis){
1360  fHistoMCPi0Pt = new TH1F*[fnCuts];
1361  fHistoMCPi0WOWeightPt = new TH1F*[fnCuts];
1362  fHistoMCEtaPt = new TH1F*[fnCuts];
1363  fHistoMCEtaWOWeightPt = new TH1F*[fnCuts];
1364  fHistoMCPi0InAccPt = new TH1F*[fnCuts];
1365  fHistoMCPi0WOWeightInAccPt = new TH1F*[fnCuts];
1366  fHistoMCEtaInAccPt = new TH1F*[fnCuts];
1367  fHistoMCEtaWOWeightInAccPt = new TH1F*[fnCuts];
1368  if (fIsMC > 1){
1369  fHistoMCPi0WOEvtWeightPt = new TH1F*[fnCuts];
1370  fHistoMCEtaWOEvtWeightPt = new TH1F*[fnCuts];
1373  }
1374 
1378  fHistoMCSecPi0Source = new TH1F*[fnCuts];
1379  fHistoMCSecEtaPt = new TH1F*[fnCuts];
1380  fHistoMCSecEtaSource = new TH1F*[fnCuts];
1381  if (!fDoLightOutput){
1390  }
1391 
1397  fHistoMultipleCountTruePi0 = new TH1F*[fnCuts];
1399  fHistoMultipleCountTrueEta = new TH1F*[fnCuts];
1411  if(!fDoLightOutput) {
1418  fHistoTruePrimaryPi0DCPtconv = new TH1F*[fnCuts];
1422  }
1423 
1424 
1425  if (fDoMesonQA > 0){
1426  fHistoMCPi0PtY = new TH2F*[fnCuts];
1427  fHistoMCEtaPtY = new TH2F*[fnCuts];
1428  fHistoMCPi0PtAlpha = new TH2F*[fnCuts];
1429  fHistoMCEtaPtAlpha = new TH2F*[fnCuts];
1430  if (fIsMC == 2){
1431  fHistoMCPi0PtJetPt = new TH2F*[fnCuts];
1432  fHistoMCEtaPtJetPt = new TH2F*[fnCuts];
1433  }
1434 
1435  if (fIsMC < 2){
1461  }
1462  if(fDoMesonQA > 1){
1467  }
1468  fHistoTruePi0PtY = new TH2F*[fnCuts];
1469  fHistoTrueEtaPtY = new TH2F*[fnCuts];
1476  }
1477  }
1478 
1479  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1480  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
1481  TString cutstringPhoton = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
1482  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
1483  TString cutstringMeson = "NoMesonCut";
1484  if(fDoMesonAnalysis)
1485  cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
1486 
1487  fMCList[iCut] = new TList();
1488  fMCList[iCut]->SetName(Form("%s_%s_%s_%s MC histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
1489  fMCList[iCut]->SetOwner(kTRUE);
1490  fCutFolder[iCut]->Add(fMCList[iCut]);
1491  if(!fDoLightOutput){
1492  fHistoMCHeaders[iCut] = new TH1I("MC_Headers","MC_Headers",20,0,20);
1493  fMCList[iCut]->Add(fHistoMCHeaders[iCut]);
1494  fHistoMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt","MC_AllGamma_Pt",nBinsPt, minPt, maxPt);
1495  fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);
1496  fHistoMCAllGammaEMCALAccPt[iCut] = new TH1F("MC_AllGammaEMCALAcc_Pt","MC_AllGammaEMCALAcc_Pt",nBinsPt, minPt, maxPt);
1497  fMCList[iCut]->Add(fHistoMCAllGammaEMCALAccPt[iCut]);
1498  fHistoMCAllSecondaryGammaPt[iCut] = new TH2F("MC_AllSecondaryGamma_Pt","MC_AllSecondaryGamma_Pt",nBinsPt, minPt, maxPt,4,-0.5,3.5);
1499  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1500  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1501  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1502  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1503  fMCList[iCut]->Add(fHistoMCAllSecondaryGammaPt[iCut]);
1504 
1505  fHistoMCDecayGammaPi0Pt[iCut] = new TH1F("MC_DecayGammaPi0_Pt","MC_DecayGammaPi0_Pt",nBinsPt, minPt, maxPt);
1506  fMCList[iCut]->Add(fHistoMCDecayGammaPi0Pt[iCut]);
1507  fHistoMCDecayGammaRhoPt[iCut] = new TH1F("MC_DecayGammaRho_Pt","MC_DecayGammaRho_Pt",nBinsPt, minPt, maxPt);
1508  fMCList[iCut]->Add(fHistoMCDecayGammaRhoPt[iCut]);
1509  fHistoMCDecayGammaEtaPt[iCut] = new TH1F("MC_DecayGammaEta_Pt","MC_DecayGammaEta_Pt",nBinsPt, minPt, maxPt);
1510  fMCList[iCut]->Add(fHistoMCDecayGammaEtaPt[iCut]);
1511  fHistoMCDecayGammaOmegaPt[iCut] = new TH1F("MC_DecayGammaOmega_Pt","MC_DecayGammaOmmega_Pt",nBinsPt, minPt, maxPt);
1512  fMCList[iCut]->Add(fHistoMCDecayGammaOmegaPt[iCut]);
1513  fHistoMCDecayGammaEtapPt[iCut] = new TH1F("MC_DecayGammaEtap_Pt","MC_DecayGammaEtap_Pt",nBinsPt, minPt, maxPt);
1514  fMCList[iCut]->Add(fHistoMCDecayGammaEtapPt[iCut]);
1515  fHistoMCDecayGammaPhiPt[iCut] = new TH1F("MC_DecayGammaPhi_Pt","MC_DecayGammaPhi_Pt",nBinsPt, minPt, maxPt);
1516  fMCList[iCut]->Add(fHistoMCDecayGammaPhiPt[iCut]);
1517  fHistoMCDecayGammaSigmaPt[iCut] = new TH1F("MC_DecayGammaSigma_Pt","MC_DecayGammaSigma_Pt",nBinsPt, minPt, maxPt);
1518  fMCList[iCut]->Add(fHistoMCDecayGammaSigmaPt[iCut]);
1519  fHistoMCConvGammaPt[iCut] = new TH1F("MC_ConvGamma_Pt","MC_ConvGamma_Pt",nBinsPt, minPt, maxPt);
1520  fMCList[iCut]->Add(fHistoMCConvGammaPt[iCut]);
1521  fHistoMCSecondaryConvGammaPt[iCut] = new TH2F("MC_SecondaryConvGamma_Pt","MC_SecondaryConvGamma_Pt",nBinsPt, minPt, maxPt,4,-0.5,3.5);
1522  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1523  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1524  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1525  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1526  fMCList[iCut]->Add(fHistoMCSecondaryConvGammaPt[iCut]);
1527 
1528  if (fIsMC > 1){
1529  fHistoMCAllGammaPt[iCut]->Sumw2();
1530  fHistoMCAllGammaEMCALAccPt[iCut]->Sumw2();
1531  fHistoMCAllSecondaryGammaPt[iCut]->Sumw2();
1532  fHistoMCDecayGammaPi0Pt[iCut]->Sumw2();
1533  fHistoMCDecayGammaRhoPt[iCut]->Sumw2();
1534  fHistoMCDecayGammaEtaPt[iCut]->Sumw2();
1535  fHistoMCDecayGammaOmegaPt[iCut]->Sumw2();
1536  fHistoMCDecayGammaEtapPt[iCut]->Sumw2();
1537  fHistoMCDecayGammaPhiPt[iCut]->Sumw2();
1538  fHistoMCDecayGammaSigmaPt[iCut]->Sumw2();
1539  fHistoMCConvGammaPt[iCut]->Sumw2();
1540  fHistoMCSecondaryConvGammaPt[iCut]->Sumw2();
1541  }
1542  }
1543 
1544  if (fDoPhotonQA > 0){
1545  fHistoMCConvGammaR[iCut] = new TH1F("MC_ConvGamma_R","MC_ConvGamma_R",800,0,200);
1546  fMCList[iCut]->Add(fHistoMCConvGammaR[iCut]);
1547  fHistoMCConvGammaEta[iCut] = new TH1F("MC_ConvGamma_Eta","MC_ConvGamma_Eta",2000,-2,2);
1548  fMCList[iCut]->Add(fHistoMCConvGammaEta[iCut]);
1549  }
1550 
1551  if(fDoMesonAnalysis){
1552  fHistoMCPi0Pt[iCut] = new TH1F("MC_Pi0_Pt","MC_Pi0_Pt",nBinsPt, minPt, maxPt);
1553  fHistoMCPi0Pt[iCut]->Sumw2();
1554  fMCList[iCut]->Add(fHistoMCPi0Pt[iCut]);
1555  fHistoMCPi0WOWeightPt[iCut] = new TH1F("MC_Pi0_WOWeights_Pt","MC_Pi0_WOWeights_Pt",nBinsPt, minPt, maxPt);
1556  fMCList[iCut]->Add(fHistoMCPi0WOWeightPt[iCut]);
1557 
1558  fHistoMCEtaPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",nBinsPt, minPt, maxPt);
1559  fHistoMCEtaPt[iCut]->Sumw2();
1560  fMCList[iCut]->Add(fHistoMCEtaPt[iCut]);
1561  fHistoMCEtaWOWeightPt[iCut] = new TH1F("MC_Eta_WOWeights_Pt","MC_Eta_WOWeights_Pt",nBinsPt, minPt, maxPt);
1562  fMCList[iCut]->Add(fHistoMCEtaWOWeightPt[iCut]);
1563 
1564  fHistoMCPi0InAccPt[iCut] = new TH1F("MC_Pi0InAcc_Pt","MC_Pi0InAcc_Pt",nBinsPt, minPt, maxPt);
1565  fHistoMCPi0InAccPt[iCut]->Sumw2();
1566  fMCList[iCut]->Add(fHistoMCPi0InAccPt[iCut]);
1567  fHistoMCPi0WOWeightInAccPt[iCut] = new TH1F("MC_Pi0WOWeightInAcc_Pt","MC_Pi0WOWeightInAcc_Pt",nBinsPt, minPt, maxPt);
1568  fMCList[iCut]->Add(fHistoMCPi0WOWeightInAccPt[iCut]);
1569  fHistoMCEtaInAccPt[iCut] = new TH1F("MC_EtaInAcc_Pt","MC_EtaInAcc_Pt",nBinsPt, minPt, maxPt);
1570  fHistoMCEtaInAccPt[iCut]->Sumw2();
1571  fMCList[iCut]->Add(fHistoMCEtaInAccPt[iCut]);
1572  fHistoMCEtaWOWeightInAccPt[iCut] = new TH1F("MC_EtaWOWeightInAcc_Pt","MC_EtaWOWeightInAcc_Pt",nBinsPt, minPt, maxPt);
1573  fMCList[iCut]->Add(fHistoMCEtaWOWeightInAccPt[iCut]);
1574 
1575  if (fIsMC > 1){
1576  fHistoMCPi0WOWeightPt[iCut]->Sumw2();
1577  fHistoMCEtaWOWeightPt[iCut]->Sumw2();
1578  fHistoMCPi0WOWeightInAccPt[iCut]->Sumw2();
1579  fHistoMCEtaWOWeightInAccPt[iCut]->Sumw2();
1580  fHistoMCPi0WOEvtWeightPt[iCut] = new TH1F("MC_Pi0_WOEventWeights_Pt","MC_Pi0_WOEventWeights_Pt",nBinsPt, minPt, maxPt);
1581  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightPt[iCut]);
1582  fHistoMCEtaWOEvtWeightPt[iCut] = new TH1F("MC_Eta_WOEventWeights_Pt","MC_Eta_WOEventWeights_Pt",nBinsPt, minPt, maxPt);
1583  fMCList[iCut]->Add(fHistoMCEtaWOEvtWeightPt[iCut]);
1584  fHistoMCPi0WOEvtWeightInAccPt[iCut] = new TH1F("MC_Pi0_WOEventWeightsInAcc_Pt","MC_Pi0_WOEventWeightsInAcc_Pt",nBinsPt, minPt, maxPt);
1585  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightInAccPt[iCut]);
1586  fHistoMCEtaWOEvtWeightInAccPt[iCut] = new TH1F("MC_Eta_WOEventWeightsInAcc_Pt","MC_Eta_WOEventWeightsInAcc_Pt",nBinsPt, minPt, maxPt);
1587  fMCList[iCut]->Add(fHistoMCEtaWOEvtWeightInAccPt[iCut]);
1588 
1589  if (fDoMesonQA > 0 && fIsMC == 2){
1590  fHistoMCPi0PtJetPt[iCut] = new TH2F("MC_Pi0_Pt_JetPt","MC_Pi0_Pt_JetPt",nBinsQAPt, minQAPt, maxQAPt,200,0,200);
1591  fHistoMCPi0PtJetPt[iCut]->Sumw2();
1593  fMCList[iCut]->Add(fHistoMCPi0PtJetPt[iCut]);
1594  fHistoMCEtaPtJetPt[iCut] = new TH2F("MC_Eta_Pt_JetPt","MC_Eta_Pt_JetPt",nBinsQAPt, minQAPt, maxQAPt,200,0,200);
1595  fHistoMCEtaPtJetPt[iCut]->Sumw2();
1597  fMCList[iCut]->Add(fHistoMCEtaPtJetPt[iCut]);
1598  }
1599  }
1600  fHistoMCPrimaryPtvsSource[iCut] = new TH2F("MC_Primary_Pt_Source","MC_Primary_Pt_Source",nBinsPt, minPt, maxPt, 7, -0.5, 6.5);
1601  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(1,"Pi+");
1602  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(2,"Pi-");
1603  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(3,"K+");
1604  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(4,"K-");
1605  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(5,"K0s");
1606  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(6,"K0l");
1607  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(7,"Lambda");
1608  fMCList[iCut]->Add(fHistoMCPrimaryPtvsSource[iCut]);
1609 
1610  fHistoMCSecPi0Source[iCut] = new TH1F("MC_SecPi0_Source","MC_SecPi0_Source",5000,0.,5000);
1611  fMCList[iCut]->Add(fHistoMCSecPi0Source[iCut]);
1612  fHistoMCSecEtaSource[iCut] = new TH1F("MC_SecEta_Source","MC_SecEta_Source",5000,0,5000);
1613  fMCList[iCut]->Add(fHistoMCSecEtaSource[iCut]);
1614  fHistoMCSecPi0PtvsSource[iCut] = new TH2F("MC_SecPi0_Pt_Source","MC_SecPi0_Pt_Source",nBinsPt, minPt, maxPt,16,-0.5,15.5);
1615  fMCList[iCut]->Add(fHistoMCSecPi0PtvsSource[iCut]);
1616  fHistoMCSecPi0InAccPtvsSource[iCut] = new TH2F("MC_SecPi0InAcc_Pt_Source","MC_SecPi0InAcc_Pt_Source",nBinsPt, minPt, maxPt,16,-0.5,15.5);
1617  fMCList[iCut]->Add(fHistoMCSecPi0InAccPtvsSource[iCut]);
1618  fHistoMCSecEtaPt[iCut] = new TH1F("MC_SecEta_Pt","MC_SecEta_Pt",nBinsPt, minPt, maxPt);
1619  fMCList[iCut]->Add(fHistoMCSecEtaPt[iCut]);
1620 
1621  if (fIsMC == 2){
1622  fHistoMCPrimaryPtvsSource[iCut]->Sumw2();
1623  fHistoMCSecPi0PtvsSource[iCut]->Sumw2();
1624  fHistoMCSecPi0InAccPtvsSource[iCut]->Sumw2();
1625  fHistoMCSecEtaPt[iCut]->Sumw2();
1626  }
1627 
1628  // book histograms for pure MC handling of PCM-Calo dir gamma reco
1629  if (!fDoLightOutput){
1630  fHistoMCPi0PtGammaLeg[iCut] = new TH2F("MC_Pi0_PtGamma_Leg","MC_Pi0_PtGamma_Leg",nBinsPt, minPt, maxPt, 3, -0.5, 2.5);
1631  fHistoMCPi0PtGammaLeg[iCut]->Sumw2();
1632  fMCList[iCut]->Add(fHistoMCPi0PtGammaLeg[iCut]);
1633  fHistoMCPi0WOWeightPtGammaLeg[iCut] = new TH2F("MC_Pi0_WOWeights_PtGamma_Leg","MC_Pi0_WOWeights_PtGamma_Leg",nBinsPt, minPt, maxPt, 3, -0.5, 2.5);
1634  fMCList[iCut]->Add(fHistoMCPi0WOWeightPtGammaLeg[iCut]);
1635 
1636  fHistoMCPi0InAccPtGammaLeg[iCut] = new TH2F("MC_Pi0InAcc_PtGamma_Leg","MC_Pi0InAcc_PtGamma_Leg",nBinsPt, minPt, maxPt, 3, -0.5, 2.5);
1637  fHistoMCPi0InAccPtGammaLeg[iCut]->Sumw2();
1638  fMCList[iCut]->Add(fHistoMCPi0InAccPtGammaLeg[iCut]);
1639  fHistoMCPi0WOWeightInAccPtGammaLeg[iCut] = new TH2F("MC_Pi0WOWeightInAcc_PtGamma_Leg","MC_Pi0WOWeightInAcc_PtGamma_Leg",nBinsPt, minPt, maxPt, 3, -0.5, 2.5);
1640  fMCList[iCut]->Add(fHistoMCPi0WOWeightInAccPtGammaLeg[iCut]);
1641 
1642  fHistoMCSecPi0PtGamma1vsSource[iCut] = new TH2F("MC_SecPi0_PtGamma1_Source","MC_SecPi0_PtGamma1_Source",nBinsPt, minPt, maxPt,16,-0.5,15.5);
1643  fMCList[iCut]->Add(fHistoMCSecPi0PtGamma1vsSource[iCut]);
1644  fHistoMCSecPi0PtGamma2vsSource[iCut] = new TH2F("MC_SecPi0_PtGamma2_Source","MC_SecPi0_PtGamma2_Source",nBinsPt, minPt, maxPt,16,-0.5,15.5);
1645  fMCList[iCut]->Add(fHistoMCSecPi0PtGamma2vsSource[iCut]);
1646  fHistoMCSecPi0InAccPtGamma1vsSource[iCut] = new TH2F("MC_SecPi0InAcc_PtGamma1_Source","MC_SecPi0InAcc_PtGamma1_Source",nBinsPt, minPt, maxPt,16,-0.5,15.5);
1647  fMCList[iCut]->Add(fHistoMCSecPi0InAccPtGamma1vsSource[iCut]);
1648  fHistoMCSecPi0InAccPtGamma2vsSource[iCut] = new TH2F("MC_SecPi0InAcc_PtGamma2_Source","MC_SecPi0InAcc_PtGamma2_Source",nBinsPt, minPt, maxPt,16,-0.5,15.5);
1649  fMCList[iCut]->Add(fHistoMCSecPi0InAccPtGamma2vsSource[iCut]);
1650 
1651  if (fIsMC > 1){
1652  fHistoMCPi0WOWeightPtGammaLeg[iCut]->Sumw2();
1653  fHistoMCPi0WOWeightInAccPtGammaLeg[iCut]->Sumw2();
1654  fHistoMCSecPi0PtGamma1vsSource[iCut]->Sumw2();
1655  fHistoMCSecPi0PtGamma2vsSource[iCut]->Sumw2();
1656  fHistoMCSecPi0InAccPtGamma1vsSource[iCut]->Sumw2();
1657  fHistoMCSecPi0InAccPtGamma2vsSource[iCut]->Sumw2();
1658  }
1659  }
1660 
1661  // book additional MC QA histograms
1662  if (fDoMesonQA > 0){
1663  fHistoMCPi0PtY[iCut] = new TH2F("MC_Pi0_Pt_Y","MC_Pi0_Pt_Y",nBinsQAPt, minQAPt, maxQAPt,150,-1.5,1.5);
1664  fHistoMCPi0PtY[iCut]->Sumw2();
1666  fMCList[iCut]->Add(fHistoMCPi0PtY[iCut]);
1667  fHistoMCEtaPtY[iCut] = new TH2F("MC_Eta_Pt_Y","MC_Eta_Pt_Y",nBinsQAPt, minQAPt, maxQAPt,150,-1.5,1.5);
1668  fHistoMCEtaPtY[iCut]->Sumw2();
1670  fMCList[iCut]->Add(fHistoMCEtaPtY[iCut]);
1671  fHistoMCPi0PtAlpha[iCut] = new TH2F("MC_Pi0_Pt_Alpha","MC_Pi0_Pt_Alpha",nBinsQAPt, minQAPt, maxQAPt,200,-1,1);
1673  fMCList[iCut]->Add(fHistoMCPi0PtAlpha[iCut]);
1674  fHistoMCEtaPtAlpha[iCut] = new TH2F("MC_Eta_Pt_Alpha","MC_Eta_Pt_Alpha",nBinsQAPt, minQAPt, maxQAPt,200,-1,1);
1676  fMCList[iCut]->Add(fHistoMCEtaPtAlpha[iCut]);
1677 
1678  if (fIsMC == 2){
1679  fHistoMCPi0PtAlpha[iCut]->Sumw2();
1680  fHistoMCEtaPtAlpha[iCut]->Sumw2();
1681  }
1682  }
1683  }
1684 
1685  fTrueList[iCut] = new TList();
1686  fTrueList[iCut]->SetName(Form("%s_%s_%s_%s True histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
1687  fTrueList[iCut]->SetOwner(kTRUE);
1688  fCutFolder[iCut]->Add(fTrueList[iCut]);
1689 
1690  if(!fDoLightOutput){
1691  fHistoTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt","ESD_TrueConvGamma_Pt",nBinsPt, minPt, maxPt);
1692  fTrueList[iCut]->Add(fHistoTrueConvGammaPt[iCut]);
1693 
1694  fHistoDoubleCountTrueConvGammaRPt[iCut] = new TH2F("ESD_TrueDoubleCountConvGamma_R_Pt","ESD_TrueDoubleCountConvGamma_R_Pt",800,0,200,nBinsPt, minPt, maxPt);
1695  fTrueList[iCut]->Add(fHistoDoubleCountTrueConvGammaRPt[iCut]);
1696  fHistoMultipleCountTrueConvGamma[iCut] = new TH1F("ESD_TrueMultipleCountConvGamma","ESD_TrueMultipleCountConvGamma",10,1,11);
1697  fTrueList[iCut]->Add(fHistoMultipleCountTrueConvGamma[iCut]);
1698 
1699  fHistoCombinatorialPt[iCut] = new TH2F("ESD_TrueCombinatorial_Pt","ESD_TrueCombinatorial_Pt",nBinsPt, minPt, maxPt,16,-0.5,15.5);
1700  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 1,"Elec+Elec");
1701  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 2,"Elec+Pion");
1702  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 3,"Elec+Kaon");
1703  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 4,"Elec+Proton");
1704  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 5,"Elec+Muon");
1705  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 6,"Pion+Pion");
1706  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 7,"Pion+Kaon");
1707  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 8,"Pion+Proton");
1708  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 9,"Pion+Muon");
1709  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(10,"Kaon+Kaon");
1710  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(11,"Kaon+Proton");
1711  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(12,"Kaon+Muon");
1712  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(13,"Proton+Proton");
1713  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(14,"Proton+Muon");
1714  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(15,"Muon+Muon");
1715  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(16,"Rest");
1716  fTrueList[iCut]->Add(fHistoCombinatorialPt[iCut]);
1717 
1718  fHistoTruePrimaryConvGammaPt[iCut] = new TH1F("ESD_TruePrimaryConvGamma_Pt","ESD_TruePrimaryConvGamma_Pt",nBinsPt, minPt, maxPt);
1719  fTrueList[iCut]->Add(fHistoTruePrimaryConvGammaPt[iCut]);
1720  fHistoTrueSecondaryConvGammaPt[iCut] = new TH2F("ESD_TrueSecondaryConvGamma_Pt","ESD_TrueSecondaryConvGamma_Pt",nBinsPt, minPt, maxPt,4,-0.5,3.5);
1721  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1722  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1723  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1724  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1725  fTrueList[iCut]->Add(fHistoTrueSecondaryConvGammaPt[iCut]);
1726  fHistoTrueSecondaryConvGammaMCPt[iCut] = new TH2F("ESD_TrueSecondaryConvGamma_MCPt","ESD_TrueSecondaryConvGamma_MCPt",nBinsPt, minPt, maxPt,4,-0.5,3.5);
1727  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1728  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1729  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1730  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1731  fTrueList[iCut]->Add(fHistoTrueSecondaryConvGammaMCPt[iCut]);
1732 
1733  fHistoTruePrimaryConvGammaESDPtMCPt[iCut] = new TH2F("ESD_TruePrimaryConvGammaESD_PtMCPt", "ESD_TruePrimaryConvGammaESD_PtMCPt",nBinsPt, minPt, maxPt,nBinsPt, minPt, maxPt);
1735 
1736  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromK0sESD_MCPtPt","ESD_TrueSecondaryConvGammaFromXFromK0sESD_MCPtPt",nBinsPt, minPt, maxPt,nBinsPt, minPt, maxPt);
1738  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromK0lESD_MCPtPt","ESD_TrueSecondaryConvGammaFromXFromK0lESD_MCPtPt",nBinsPt, minPt, maxPt,nBinsPt, minPt, maxPt);
1740  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromLambdaESD_MCPtPt","ESD_TrueSecondaryConvGammaFromXFromLambdaESD_MCPtPt",nBinsPt, minPt, maxPt,nBinsPt, minPt, maxPt);
1742  }
1743 
1744  fHistoTrueClusGammaPt[iCut] = new TH1F("TrueClusGamma_Pt","ESD_TrueClusGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1745  fClusterOutputList[iCut]->Add(fHistoTrueClusGammaPt[iCut]);
1746  if(!fDoLightOutput){
1747  fHistoTruePrimaryClusGammaPt[iCut] = new TH1F("TruePrimaryClusGamma_Pt","ESD_TruePrimaryClusGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1749  fHistoTruePrimaryClusGammaESDPtMCPt[iCut] = new TH2F("TruePrimaryClusGamma_Pt_MCPt","ESD_TruePrimaryClusGamma_Pt_MCPt",nBinsClusterPt, minClusterPt, maxClusterPt, nBinsClusterPt, minClusterPt, maxClusterPt);
1751  fHistoTrueClusElectronPt[iCut] = new TH1F("TrueClusElectron_Pt","TrueElectronGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1752  fClusterOutputList[iCut]->Add(fHistoTrueClusElectronPt[iCut]);
1753  fHistoTrueClusConvGammaPt[iCut] = new TH1F("TrueClusConvGamma_Pt","TrueClusConvGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1755  fHistoTruePrimaryClusConvGammaPt[iCut] = new TH1F("TruePrimaryClusConvGamma_Pt","ESD_TruePrimaryClusConvGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1757  fHistoTruePrimaryClusConvGammaESDPtMCPt[iCut] = new TH2F("TruePrimaryClusConvGamma_Pt_MCPt","ESD_TruePrimaryClusConvGamma_Pt_MCPt",nBinsClusterPt, minClusterPt, maxClusterPt, nBinsClusterPt, minClusterPt, maxClusterPt);
1759 
1760  fHistoTrueSecondaryClusGammaPt[iCut] = new TH1F("TrueSecondaryClusGamma_Pt","ESD_TrueSecondaryClusGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1762  fHistoTrueSecondaryClusGammaFromK0sPt[iCut] = new TH1F("TrueSecondaryClusGammaFromK0s_Pt","ESD_TrueSecondaryClusGammaFromK0s_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1764  fHistoTrueSecondaryClusGammaFromK0lPt[iCut] = new TH1F("TrueSecondaryClusGammaFromK0l_Pt","ESD_TrueSecondaryClusGammaFromK0l_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1766  fHistoTrueSecondaryClusGammaFromLambdaPt[iCut] = new TH1F("TrueSecondaryClusGammaFromLambda_Pt","ESD_TrueSecondaryClusGammaFromLambda_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1768  }
1769 
1770  fHistoDoubleCountTrueClusterGammaPt[iCut] = new TH2F("TrueDoubleCountClusterGamma_Pt","TrueDoubleCountClusterGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt,2,0,2);
1772  fHistoMultipleCountTrueClusterGamma[iCut] = new TH1F("TrueMultipleCountClusterGamma","TrueMultipleCountClusterGamma",10,1,11);
1774  if(!fDoLightOutput) {
1775  fHistoTrueNLabelsInClusPt[iCut] = new TH2F("TrueNLabelsInClus_Pt","TrueNLabelsInClus_Pt",100,-0.5,99.5,nBinsClusterPt, minClusterPt, maxClusterPt);
1777  fHistoTrueClusGammaEM02[iCut] = new TH2F("TrueClusGammaEM02","TrueClusGammaEM02",nBinsClusterPt, minClusterPt, maxClusterPt,400,0,5);
1778  fClusterOutputList[iCut]->Add(fHistoTrueClusGammaEM02[iCut]);
1779  fHistoTrueClusPi0EM02[iCut] = new TH2F("TrueClusPi0EM02","TrueClusPi0EM02",nBinsClusterPt, minClusterPt, maxClusterPt,400,0,5);
1780  fClusterOutputList[iCut]->Add(fHistoTrueClusPi0EM02[iCut]);
1781  fHistoTrueClusEMNonLeadingPt[iCut] = new TH1F("TrueClusEMNonLeading_Pt","TrueClusEMNonLeading_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1783  }
1784 
1785 
1786  if (fIsMC > 1){
1787  if(!fDoLightOutput){
1788  fHistoTrueConvGammaPt[iCut]->Sumw2();
1789  fHistoDoubleCountTrueConvGammaRPt[iCut]->Sumw2();
1790  fHistoMultipleCountTrueConvGamma[iCut]->Sumw2();
1791  fHistoCombinatorialPt[iCut]->Sumw2();
1792  fHistoTruePrimaryConvGammaPt[iCut]->Sumw2();
1793  fHistoTrueSecondaryConvGammaPt[iCut]->Sumw2();
1794  fHistoTrueSecondaryConvGammaMCPt[iCut]->Sumw2();
1795  fHistoTruePrimaryConvGammaESDPtMCPt[iCut]->Sumw2();
1799  }
1800  fHistoTrueClusGammaPt[iCut]->Sumw2();
1801  fHistoDoubleCountTrueClusterGammaPt[iCut]->Sumw2();
1802  fHistoMultipleCountTrueClusterGamma[iCut]->Sumw2();
1803  if(!fDoLightOutput) {
1804  fHistoTruePrimaryClusGammaPt[iCut]->Sumw2();
1805  fHistoTruePrimaryClusGammaESDPtMCPt[iCut]->Sumw2();
1806  fHistoTrueNLabelsInClusPt[iCut]->Sumw2();
1807  fHistoTrueClusGammaEM02[iCut]->Sumw2();
1808  fHistoTrueClusPi0EM02[iCut]->Sumw2();
1809  fHistoTrueClusElectronPt[iCut]->Sumw2();
1810  fHistoTrueClusConvGammaPt[iCut]->Sumw2();
1811  fHistoTruePrimaryClusConvGammaPt[iCut]->Sumw2();
1813  fHistoTrueClusEMNonLeadingPt[iCut]->Sumw2();
1814  fHistoTrueSecondaryClusGammaPt[iCut]->Sumw2();
1818  }
1819  }
1820 
1821  if (fDoPhotonQA > 0){
1822  fHistoTrueConvGammaEta[iCut] = new TH1F("ESD_TrueConvGamma_Eta","ESD_TrueConvGamma_Eta",2000,-2,2);
1823  fTrueList[iCut]->Add(fHistoTrueConvGammaEta[iCut]);
1824  }
1825 
1826 // 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);
1827 // fClusterOutputList[iCut]->Add(fHistoTruePi0NonLinearity[iCut]);
1828 // 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);
1829 // fClusterOutputList[iCut]->Add(fHistoTrueEtaNonLinearity[iCut]);
1830 
1831  if(!fDoLightOutput){
1832  fHistoTruePi0InvMassECalib[iCut] = new TH2F("True_Pi0_InvMass_E_Calib","True_Pi0_InvMass_E_Calib",800,0,0.8,nBinsPt, minPt, maxPt);
1833  fHistoTruePi0InvMassECalib[iCut]->SetXTitle("M_{inv}(GeV/c^{2})");
1834  fHistoTruePi0InvMassECalib[iCut]->SetYTitle("E_{cluster}(GeV)");
1835  fESDList[iCut]->Add(fHistoTruePi0InvMassECalib[iCut]);
1836  fHistoTruePi0PureGammaInvMassECalib[iCut] = new TH2F("True_Pi0PureGamma_InvMass_E_Calib","True_Pi0PureGamma_InvMass_E_Calib",800,0,0.8,nBinsPt, minPt, maxPt);
1837  fHistoTruePi0PureGammaInvMassECalib[iCut]->SetXTitle("M_{inv}(GeV/c^{2})");
1838  fHistoTruePi0PureGammaInvMassECalib[iCut]->SetYTitle("E_{cluster}(GeV)");
1840  }
1841 
1842  if (fDoClusterQA > 0){
1843  fHistoTrueClusConvGammaFullyPt[iCut] = new TH1F("TrueClusConvGammaFullyContained_Pt","TrueClusConvGammaFullyContained_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1845  fHistoTrueClusMergedGammaPt[iCut] = new TH1F("TrueClusMergedGamma_Pt","TrueClusMergedGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1847  fHistoTrueClusMergedPartConvGammaPt[iCut] = new TH1F("TrueClusMergedPartConvGamma_Pt","TrueClusMergedPartConvGamma_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1849  fHistoTrueClusDalitzPt[iCut] = new TH1F("TrueClusDalitz_Pt","TrueClusDalitz_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1850  fClusterOutputList[iCut]->Add(fHistoTrueClusDalitzPt[iCut]);
1851  fHistoTrueClusDalitzMergedPt[iCut] = new TH1F("TrueClusDalitzMerged_Pt","TrueClusDalitzMerged_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1853  fHistoTrueClusPhotonFromElecMotherPt[iCut] = new TH1F("TrueClusPhotonFromElecMother_Pt","TrueClusPhotonFromElecMother_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1855  fHistoTrueClusShowerPt[iCut] = new TH1F("TrueClusShower_Pt","TrueClusShower_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1856  fClusterOutputList[iCut]->Add(fHistoTrueClusShowerPt[iCut]);
1857  fHistoTrueClusSubLeadingPt[iCut] = new TH1F("TrueClusSubleading_Pt","TrueClusSubleading_Pt",nBinsClusterPt, minClusterPt, maxClusterPt);
1859  fHistoTrueClusNMothers[iCut] = new TH1F("TrueClusNParticles","TrueClusNParticles",20,0,20);
1860  fClusterOutputList[iCut]->Add(fHistoTrueClusNMothers[iCut]);
1861  if (fIsMC > 1){
1862  fHistoTrueClusConvGammaFullyPt[iCut]->Sumw2();
1863  fHistoTrueClusMergedGammaPt[iCut]->Sumw2();
1864  fHistoTrueClusMergedPartConvGammaPt[iCut]->Sumw2();
1865  fHistoTrueClusDalitzPt[iCut]->Sumw2();
1866  fHistoTrueClusDalitzMergedPt[iCut]->Sumw2();
1867  fHistoTrueClusPhotonFromElecMotherPt[iCut]->Sumw2();
1868  fHistoTrueClusShowerPt[iCut]->Sumw2();
1869  fHistoTrueClusSubLeadingPt[iCut]->Sumw2();
1870  fHistoTrueClusNMothers[iCut]->Sumw2();
1871  }
1872  }
1873 
1874  if(fDoMesonAnalysis){
1875  fHistoTruePi0InvMassPt[iCut] = new TH2F("ESD_TruePi0_InvMass_Pt","ESD_TruePi0_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1876  fHistoTruePi0InvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2})");
1877  fHistoTruePi0InvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
1878  fTrueList[iCut]->Add(fHistoTruePi0InvMassPt[iCut]);
1879  fHistoTrueEtaInvMassPt[iCut] = new TH2F("ESD_TrueEta_InvMass_Pt","ESD_TrueEta_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1880  fHistoTrueEtaInvMassPt[iCut]->SetXTitle("M_{inv,#eta}(GeV/c^{2})");
1881  fHistoTrueEtaInvMassPt[iCut]->SetYTitle("#eta p_{T}(GeV/c)");
1882  fTrueList[iCut]->Add(fHistoTrueEtaInvMassPt[iCut]);
1883  fHistoTruePi0MatchedInvMassPt[iCut] = new TH2F("ESD_TruePi0_Matched_InvMass_Pt","ESD_TruePi0_Matched_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1884  fHistoTruePi0MatchedInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2})");
1885  fHistoTruePi0MatchedInvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
1886  fTrueList[iCut]->Add(fHistoTruePi0MatchedInvMassPt[iCut]);
1887  fHistoTrueEtaMatchedInvMassPt[iCut] = new TH2F("ESD_TrueEta_Matched_InvMass_Pt","ESD_TrueEta_Matched_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1888  fHistoTrueEtaMatchedInvMassPt[iCut]->SetXTitle("M_{inv,#eta}(GeV/c^{2})");
1889  fHistoTrueEtaMatchedInvMassPt[iCut]->SetYTitle("#eta p_{T}(GeV/c)");
1890  fTrueList[iCut]->Add(fHistoTrueEtaMatchedInvMassPt[iCut]);
1891 
1892  fHistoDoubleCountTruePi0InvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountPi0_InvMass_Pt","ESD_TrueDoubleCountPi0_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1893  fTrueList[iCut]->Add(fHistoDoubleCountTruePi0InvMassPt[iCut]);
1894  fHistoMultipleCountTruePi0[iCut] = new TH1F("ESD_TrueMultipleCountPi0","ESD_TrueMultipleCountPi0",10,1,11);
1895  fTrueList[iCut]->Add(fHistoMultipleCountTruePi0[iCut]);
1896  fHistoDoubleCountTrueEtaInvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountEta_InvMass_Pt","ESD_TrueDoubleCountEta_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1897  fTrueList[iCut]->Add(fHistoDoubleCountTrueEtaInvMassPt[iCut]);
1898  fHistoMultipleCountTrueEta[iCut] = new TH1F("ESD_TrueMultipleCountEta","ESD_TrueMultipleCountEta",10,1,11);
1899  fTrueList[iCut]->Add(fHistoMultipleCountTrueEta[iCut]);
1900 
1901  fHistoTruePrimaryPi0InvMassPt[iCut] = new TH2F("ESD_TruePrimaryPi0_InvMass_Pt", "ESD_TruePrimaryPi0_InvMass_Pt", 800,0,0.8,nBinsPt, minPt, maxPt);
1902  fHistoTruePrimaryPi0InvMassPt[iCut]->SetXTitle("M_{inv,prim #pi^{0}}(GeV/c^{2})");
1903  fHistoTruePrimaryPi0InvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
1904  fHistoTruePrimaryPi0InvMassPt[iCut]->Sumw2();
1905  fTrueList[iCut]->Add(fHistoTruePrimaryPi0InvMassPt[iCut]);
1906 
1907  fHistoTruePrimaryEtaInvMassPt[iCut] = new TH2F("ESD_TruePrimaryEta_InvMass_Pt", "ESD_TruePrimaryEta_InvMass_Pt", 800,0,0.8,nBinsPt, minPt, maxPt);
1908  fHistoTruePrimaryEtaInvMassPt[iCut]->SetXTitle("M_{inv,prim #eta}(GeV/c^{2})");
1909  fHistoTruePrimaryEtaInvMassPt[iCut]->SetYTitle("#eta p_{T}(GeV/c)");
1910  fHistoTruePrimaryEtaInvMassPt[iCut]->Sumw2();
1911  fTrueList[iCut]->Add(fHistoTruePrimaryEtaInvMassPt[iCut]);
1912 
1913  fHistoTruePrimaryPi0W0WeightingInvMassPt[iCut] = new TH2F("ESD_TruePrimaryPi0W0Weights_InvMass_Pt", "ESD_TruePrimaryPi0W0Weights_InvMass_Pt", 800,0,0.8,nBinsPt, minPt, maxPt);
1914  fHistoTruePrimaryPi0W0WeightingInvMassPt[iCut]->SetXTitle("M_{inv,prim #pi^{0}}(GeV/c^{2})");
1915  fHistoTruePrimaryPi0W0WeightingInvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
1917 
1918  fHistoTruePrimaryEtaW0WeightingInvMassPt[iCut] = new TH2F("ESD_TruePrimaryEtaW0Weights_InvMass_Pt", "ESD_TruePrimaryEtaW0Weights_InvMass_Pt", 800,0,0.8,nBinsPt, minPt, maxPt);
1919  fHistoTruePrimaryEtaW0WeightingInvMassPt[iCut]->SetXTitle("M_{inv,prim #eta}(GeV/c^{2})");
1920  fHistoTruePrimaryEtaW0WeightingInvMassPt[iCut]->SetYTitle("#eta p_{T}(GeV/c)");
1922 
1923  fProfileTruePrimaryPi0WeightsInvMassPt[iCut] = new TProfile2D("ESD_TruePrimaryPi0Weights_InvMass_Pt", "ESD_TruePrimaryPi0Weights_InvMass_Pt", 800,0,0.8,nBinsPt, minPt, maxPt);
1924  fProfileTruePrimaryPi0WeightsInvMassPt[iCut]->SetXTitle("M_{inv,prim #pi^{0}}(GeV/c^{2})");
1925  fProfileTruePrimaryPi0WeightsInvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
1928  fProfileTruePrimaryEtaWeightsInvMassPt[iCut] = new TProfile2D("ESD_TruePrimaryEtaWeights_InvMass_Pt", "ESD_TruePrimaryEtaWeights_InvMass_Pt", 800,0,0.8,nBinsPt, minPt, maxPt);
1929  fProfileTruePrimaryEtaWeightsInvMassPt[iCut]->SetXTitle("M_{inv,prim #eta}(GeV/c^{2})");
1930  fProfileTruePrimaryEtaWeightsInvMassPt[iCut]->SetYTitle("#eta p_{T}(GeV/c)");
1933 
1934  fHistoTrueSecondaryPi0InvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0_InvMass_Pt", "ESD_TrueSecondaryPi0_InvMass_Pt", 800,0,0.8,nBinsPt, minPt, maxPt);
1935  fHistoTrueSecondaryPi0InvMassPt[iCut]->SetXTitle("M_{inv,sec #pi^{0}}(GeV/c^{2})");
1936  fHistoTrueSecondaryPi0InvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
1937  fHistoTrueSecondaryPi0InvMassPt[iCut]->Sumw2();
1938  fTrueList[iCut]->Add(fHistoTrueSecondaryPi0InvMassPt[iCut]);
1939 
1940  fHistoTrueSecondaryPi0FromK0sInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0FromK0s_InvMass_Pt","ESD_TrueSecondaryPi0FromK0s_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1941  fHistoTrueSecondaryPi0FromK0sInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}from K^{0}_{S}}(GeV/c^{2})");
1942  fHistoTrueSecondaryPi0FromK0sInvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
1945  fHistoTrueSecondaryPi0FromK0lInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0FromK0l_InvMass_Pt","ESD_TrueSecondaryPi0FromK0l_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1946  fHistoTrueSecondaryPi0FromK0lInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}from K^{0}_{L}}(GeV/c^{2})");
1947  fHistoTrueSecondaryPi0FromK0lInvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
1950  fHistoTrueSecondaryPi0FromEtaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0FromEta_InvMass_Pt","ESD_TrueSecondaryPi0FromEta_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1951  fHistoTrueSecondaryPi0FromEtaInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}from #eta}(GeV/c^{2})");
1952  fHistoTrueSecondaryPi0FromEtaInvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
1954  fHistoTrueSecondaryPi0FromLambdaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0FromLambda_InvMass_Pt","ESD_TrueSecondaryPi0FromLambda_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
1955  fHistoTrueSecondaryPi0FromLambdaInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}from #Lambda}(GeV/c^{2})");
1956  fHistoTrueSecondaryPi0FromLambdaInvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
1958 
1959  if(!fDoLightOutput) {
1960  fHistoTruePrimaryPi0PhotonPairPtconv[iCut] = new TH2F("ESD_TruePrimaryPi0_InvMass_PtConv","",400,0,0.4,nBinsPt, minPt, maxPt);
1961  fHistoTruePrimaryPi0PhotonPairPtconv[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2})");
1962  fHistoTruePrimaryPi0PhotonPairPtconv[iCut]->SetYTitle("#gamma^{conv}p_{T}(GeV/c)");
1963  fHistoTruePrimaryPi0PhotonPairPtconv[iCut]->Sumw2();
1965 
1966  fHistoTruePrimaryPi0W0WeightsPhotonPairPtconv[iCut] = new TH2F("ESD_TruePrimaryPi0W0Weights_InvMass_Pt","",400,0,0.4,nBinsPt, minPt, maxPt);
1967  fHistoTruePrimaryPi0W0WeightsPhotonPairPtconv[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2})");
1968  fHistoTruePrimaryPi0W0WeightsPhotonPairPtconv[iCut]->SetYTitle("#gamma^{conv}p_{T}(GeV/c)");
1970 
1971  fHistoTrueSecondaryPi0PhotonPairPtconv[iCut] = new TH2F("ESD_TrueSecondaryPi0_InvMass_PtConv","",400,0,0.4,nBinsPt, minPt, maxPt);
1972  fHistoTrueSecondaryPi0PhotonPairPtconv[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2})");
1973  fHistoTrueSecondaryPi0PhotonPairPtconv[iCut]->SetYTitle("#gamma^{conv}p_{T}(GeV/c)");
1976 
1977  fHistoTrueSecondaryPi0FromK0sPhotonPairPtconv[iCut] = new TH2F("ESD_TrueSecondaryPi0FromK0s_InvMass_PtConv","",400,0,0.4,nBinsPt, minPt, maxPt);
1978  fHistoTrueSecondaryPi0FromK0sPhotonPairPtconv[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2})");
1979  fHistoTrueSecondaryPi0FromK0sPhotonPairPtconv[iCut]->SetYTitle("#gamma^{conv}p_{T}(GeV/c)");
1982 
1983  fHistoTrueSecondaryPi0FromK0lPhotonPairPtconv[iCut] = new TH2F("ESD_TrueSecondaryPi0FromK0l_InvMass_PtConv","",400,0,0.4,nBinsPt, minPt, maxPt);
1984  fHistoTrueSecondaryPi0FromK0lPhotonPairPtconv[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2})");
1985  fHistoTrueSecondaryPi0FromK0lPhotonPairPtconv[iCut]->SetYTitle("#gamma^{conv}p_{T}(GeV/c)");
1988 
1989  fHistoTrueSecondaryPi0FromLambdaPhotonPairPtconv[iCut]= new TH2F("ESD_TrueSecondaryPi0FromLambda_InvMass_PtConv","",400,0,0.4,nBinsPt, minPt, maxPt);
1990  fHistoTrueSecondaryPi0FromLambdaPhotonPairPtconv[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2})");
1991  fHistoTrueSecondaryPi0FromLambdaPhotonPairPtconv[iCut]->SetYTitle("#gamma^{conv}p_{T}(GeV/c)");
1994 
1995  fHistoTruePrimaryPi0DCPtconv[iCut] = new TH1F("ESD_TruePrimaryPi0DC_PtConv","",nBinsPt, minPt, maxPt);
1996  fHistoTruePrimaryPi0DCPtconv[iCut]->SetXTitle("#gamma^{conv}p_{T}(GeV/c)");
1997  fHistoTruePrimaryPi0DCPtconv[iCut]->Sumw2();
1998  fTrueList[iCut]->Add(fHistoTruePrimaryPi0DCPtconv[iCut]);
1999 
2000  fHistoTrueSecondaryPi0DCPtconvSource[iCut] = new TH2F("ESD_TrueSecondaryPi0DC_PtConv_Source","",nBinsPt, minPt, maxPt, 4, -0.5,3.5);
2001  fHistoTrueSecondaryPi0DCPtconvSource[iCut]->SetXTitle("#gamma^{conv}p_{T}(GeV/c)");
2002  fHistoTrueSecondaryPi0DCPtconvSource[iCut]->SetYTitle("sec. source");
2003  fHistoTrueSecondaryPi0DCPtconvSource[iCut]->Sumw2();
2005 
2006  fHistoTruePrimaryPi0MissingPtconv[iCut] = new TH1F("ESD_TruePrimaryPi0Missing_PtConv","",nBinsPt, minPt, maxPt);
2007  fHistoTruePrimaryPi0MissingPtconv[iCut]->SetXTitle("#gamma^{conv}p_{T}(GeV/c)");
2008  fHistoTruePrimaryPi0MissingPtconv[iCut]->Sumw2();
2009  fTrueList[iCut]->Add(fHistoTruePrimaryPi0MissingPtconv[iCut]);
2010 
2011  fHistoTrueSecondaryPi0MissingPtconvSource[iCut] = new TH2F("ESD_TrueSecondaryPi0Missing_PtConv_Source","",nBinsPt, minPt, maxPt, 4, -0.5,3.5);
2012  fHistoTrueSecondaryPi0MissingPtconvSource[iCut]->SetXTitle("#gamma^{conv}p_{T}(GeV/c)");
2013  fHistoTrueSecondaryPi0MissingPtconvSource[iCut]->SetYTitle("sec. source");
2016 
2017  // put proper summing for JJ weights
2018  if (fIsMC > 1){
2020  }
2021  }
2022 
2023  if (fIsMC > 1){
2024  fHistoTruePi0InvMassPt[iCut]->Sumw2();
2025  fHistoTrueEtaInvMassPt[iCut]->Sumw2();
2026  fHistoTruePi0MatchedInvMassPt[iCut]->Sumw2();
2027  fHistoTrueEtaMatchedInvMassPt[iCut]->Sumw2();
2028  fHistoDoubleCountTruePi0InvMassPt[iCut]->Sumw2();
2029  fHistoMultipleCountTruePi0[iCut]->Sumw2();
2030  fHistoDoubleCountTrueEtaInvMassPt[iCut]->Sumw2();
2031  fHistoMultipleCountTrueEta[iCut]->Sumw2();
2036  }
2037 
2038  if (fDoMesonQA > 0){
2039  if (fIsMC < 2){
2040  fHistoTruePi0CaloPhotonInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloPhoton_InvMass_Pt","ESD_TruePi0CaloPhoton_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2041  fHistoTruePi0CaloPhotonInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2}) #gamma #gamma");
2042  fHistoTruePi0CaloPhotonInvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
2043  fTrueList[iCut]->Add(fHistoTruePi0CaloPhotonInvMassPt[iCut]);
2044 
2045  fHistoTrueEtaCaloPhotonInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloPhoton_InvMass_Pt","ESD_TrueEtaCaloPhoton_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2046  fHistoTrueEtaCaloPhotonInvMassPt[iCut]->SetXTitle("M_{inv,#eta}(GeV/c^{2}) #gamma #gamma");
2047  fHistoTrueEtaCaloPhotonInvMassPt[iCut]->SetYTitle("#eta p_{T}(GeV/c)");
2048  fTrueList[iCut]->Add(fHistoTrueEtaCaloPhotonInvMassPt[iCut]);
2049 
2050  fHistoTruePi0CaloConvertedPhotonInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloConvertedPhoton_InvMass_Pt","ESD_TruePi0CaloConvertedPhoton_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2051  fHistoTruePi0CaloConvertedPhotonInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2}) #gamma #gamma_{conv}");
2052  fHistoTruePi0CaloConvertedPhotonInvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
2054 
2055  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloConvertedPhotonMatched_InvMass_Pt","ESD_TruePi0CaloConvertedPhotonMatched_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2056  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2}) #gamma #gamma_{conv,matched}");
2057  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
2059 
2060  fHistoTruePi0CaloConvPhotonConvRPt[iCut] = new TH2F("ESD_TruePi0CaloConvPhoton_ConvR_PtE","ESD_TruePi0CaloConvPhoton_ConvR_PtE",920,0,460,nBinsPt, minPt, maxPt);
2061  fHistoTruePi0CaloConvPhotonConvRPt[iCut]->SetXTitle("R_{conv,e_{calo}}(cm)");
2062  fHistoTruePi0CaloConvPhotonConvRPt[iCut]->SetYTitle("e^{#pm}p_{T}(GeV/c)");
2064 
2065  fHistoTruePi0CaloConvPhotonConvRAlpha[iCut] = new TH2F("ESD_TruePi0CaloConvPhoton_ConvR_AlphaE","ESD_TruePi0CaloConvPhoton_ConvR_AlphaE",920,0,460,200,-1,1);
2066  fHistoTruePi0CaloConvPhotonConvRAlpha[iCut]->SetXTitle("R_{conv,e_{calo}}(cm)");
2067  fHistoTruePi0CaloConvPhotonConvRAlpha[iCut]->SetYTitle("#alpha converted e-pair");
2069 
2070  fHistoTruePi0CaloConvPhotonPtAlpha[iCut] = new TH2F("ESD_TruePi0CaloConvPhoton_PtE_AlphaE","ESD_TruePi0CaloConvPhoton_PtE_AlphaE",nBinsPt, minPt, maxPt,200,-1,1);
2071  fHistoTruePi0CaloConvPhotonPtAlpha[iCut]->SetXTitle("e^{#pm}p_{T}(GeV/c)");
2072  fHistoTruePi0CaloConvPhotonPtAlpha[iCut]->SetYTitle("#alpha converted e-pair");
2074 
2075  fHistoTrueEtaCaloConvertedPhotonInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloConvertedPhoton_InvMass_Pt","ESD_TrueEtaCaloConvertedPhoton_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2076  fHistoTrueEtaCaloConvertedPhotonInvMassPt[iCut]->SetXTitle("M_{inv,#eta}(GeV/c^{2}) #gamma #gamma_{conv}");
2077  fHistoTrueEtaCaloConvertedPhotonInvMassPt[iCut]->SetYTitle("#eta p_{T}(GeV/c)");
2079 
2080  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloConvertedPhotonMatched_InvMass_Pt","ESD_TrueEtaCaloConvertedPhotonMatched_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2081  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[iCut]->SetXTitle("M_{inv,#eta}(GeV/c^{2}) #gamma #gamma_{conv,matched}");
2082  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[iCut]->SetYTitle("#eta p_{T}(GeV/c)");
2084 
2085  fHistoTrueEtaCaloConvPhotonConvRPt[iCut] = new TH2F("ESD_TrueEtaCaloConvPhoton_ConvR_PtE","ESD_TrueEtaCaloConvPhoton_ConvR_PtE",920,0,460,nBinsPt, minPt, maxPt);
2086  fHistoTrueEtaCaloConvPhotonConvRPt[iCut]->SetXTitle("R_{conv,e_{calo}}(cm)");
2087  fHistoTrueEtaCaloConvPhotonConvRPt[iCut]->SetYTitle("e^{#pm}p_{T}(GeV/c)");
2089 
2090  fHistoTrueEtaCaloConvPhotonConvRAlpha[iCut] = new TH2F("ESD_TrueEtaCaloConvPhoton_ConvR_AlphaE","ESD_TrueEtaCaloConvPhoton_ConvR_AlphaE",920,0,460,200,-1,1);
2091  fHistoTrueEtaCaloConvPhotonConvRAlpha[iCut]->SetXTitle("R_{conv,e_{calo}}(cm)");
2092  fHistoTrueEtaCaloConvPhotonConvRAlpha[iCut]->SetYTitle("#alpha converted e-pair");
2094 
2095  fHistoTrueEtaCaloConvPhotonPtAlpha[iCut] = new TH2F("ESD_TrueEtaCaloConvPhoton_PtE_AlphaE","ESD_TrueEtaCaloConvPhoton_PtE_AlphaE",nBinsPt, minPt, maxPt,200,-1,1);
2096  fHistoTrueEtaCaloConvPhotonPtAlpha[iCut]->SetXTitle("e^{#pm}p_{T}(GeV/c)");
2097  fHistoTrueEtaCaloConvPhotonPtAlpha[iCut]->SetYTitle("#alpha converted e-pair");
2099 
2100 
2101  fHistoTruePi0CaloElectronInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloElectron_InvMass_Pt","ESD_TruePi0CaloElectron_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2102  fHistoTruePi0CaloElectronInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2}) #gamma e^{#pm}");
2103  fHistoTruePi0CaloElectronInvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
2105  fHistoTrueEtaCaloElectronInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloElectron_InvMass_Pt","ESD_TrueEtaCaloElectron_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2106  fHistoTrueEtaCaloElectronInvMassPt[iCut]->SetXTitle("M_{inv,#eta}(GeV/c^{2}) #gamma e^{#pm}");
2107  fHistoTrueEtaCaloElectronInvMassPt[iCut]->SetYTitle("#eta p_{T}(GeV/c)");
2109 
2110  fHistoTruePi0CaloMergedClusterInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloMergedCluster_InvMass_Pt","ESD_TruePi0CaloMergedCluster_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2111  fHistoTruePi0CaloMergedClusterInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2}) #gamma merged cluster");
2112  fHistoTruePi0CaloMergedClusterInvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
2114  fHistoTrueEtaCaloMergedClusterInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloMergedCluster_InvMass_Pt","ESD_TrueEtaCaloMergedCluster_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2115  fHistoTrueEtaCaloMergedClusterInvMassPt[iCut]->SetXTitle("M_{inv,#eta}(GeV/c^{2}) #gamma merged cluster");
2116  fHistoTrueEtaCaloMergedClusterInvMassPt[iCut]->SetYTitle("#eta p_{T}(GeV/c)");
2118 
2119  fHistoTrueMotherCaloEMNonLeadingInvMassPt[iCut] = new TH2F("ESD_TrueMotherCaloEMNonLeading_InvMass_Pt","ESD_TrueMotherCaloEMNonLeading_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2120  fHistoTrueMotherCaloEMNonLeadingInvMassPt[iCut]->SetXTitle("M_{inv}(GeV/c^{2}) #gamma cluster no leading EM");
2121  fHistoTrueMotherCaloEMNonLeadingInvMassPt[iCut]->SetYTitle("#pair p_{T}(GeV/c)");
2123  fHistoTruePi0CaloMergedClusterPartConvInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloMergedClusterPartConv_InvMass_Pt","ESD_TruePi0CaloMergedClusterPartConv_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2124  fHistoTruePi0CaloMergedClusterPartConvInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2}) #gamma merged cluster, part conv");
2125  fHistoTruePi0CaloMergedClusterPartConvInvMassPt[iCut]->SetYTitle("#pi^{0}p_{T}(GeV/c)");
2127  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloMergedClusterPartConv_InvMass_Pt","ESD_TrueEtaCaloMergedClusterPartConv_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2128  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[iCut]->SetXTitle("M_{inv,#eta}(GeV/c^{2}) #gamma merged cluster, part conv");
2129  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[iCut]->SetYTitle("#eta p_{T}(GeV/c)");
2131 
2132  fHistoTruePrimaryPi0MCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryPi0_MCPt_ResolPt","ESD_TruePrimaryPi0_ResolPt_MCPt",500,0.03,25,1000,-1.,1.);
2133  fHistoTruePrimaryPi0MCPtResolPt[iCut]->SetXTitle("#pi^{0}p_{T,MC}(GeV/c)");
2134  fHistoTruePrimaryPi0MCPtResolPt[iCut]->SetYTitle("#pi^{0}(p_{T,rec}-p_{T,MC})/p_{T,MC}()");
2135  fHistoTruePrimaryPi0MCPtResolPt[iCut]->Sumw2();
2137  fTrueList[iCut]->Add(fHistoTruePrimaryPi0MCPtResolPt[iCut]);
2138 
2139  fHistoTruePrimaryEtaMCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryEta_MCPt_ResolPt","ESD_TruePrimaryEta_ResolPt_MCPt",500,0.03,25,1000,-1.,1.);
2140  fHistoTruePrimaryEtaMCPtResolPt[iCut]->SetXTitle("#eta p_{T,MC}(GeV/c)");
2141  fHistoTruePrimaryEtaMCPtResolPt[iCut]->SetYTitle("#eta (p_{T,rec}-p_{T,MC})/p_{T,MC}()");
2142  fHistoTruePrimaryEtaMCPtResolPt[iCut]->Sumw2();
2144  fTrueList[iCut]->Add(fHistoTruePrimaryEtaMCPtResolPt[iCut]);
2145 
2146  fHistoTrueK0sWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueK0sWithPi0Daughter_MCPt","ESD_TrueK0sWithPi0Daughter_MCPt",nBinsPt, minPt, maxPt);
2147  fHistoTrueK0sWithPi0DaughterMCPt[iCut]->SetXTitle("K^{0}_{s}p_{MC,T}(GeV/c) for K^{0}_{s}where #pi^{0}rec ");
2148  fTrueList[iCut]->Add(fHistoTrueK0sWithPi0DaughterMCPt[iCut]);
2149  fHistoTrueK0lWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueK0lWithPi0Daughter_MCPt","ESD_TrueK0lWithPi0Daughter_MCPt",nBinsPt, minPt, maxPt);
2150  fHistoTrueK0lWithPi0DaughterMCPt[iCut]->SetXTitle("K^{0}_{s}p_{MC,T}(GeV/c) for K^{0}_{l}where #pi^{0}rec ");
2151  fTrueList[iCut]->Add(fHistoTrueK0lWithPi0DaughterMCPt[iCut]);
2152  fHistoTrueEtaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueEtaWithPi0Daughter_MCPt","ESD_TrueEtaWithPi0Daughter_MCPt",nBinsPt, minPt, maxPt);
2153  fHistoTrueEtaWithPi0DaughterMCPt[iCut]->SetXTitle("#eta p_{MC,T}(GeV/c) for #eta where #pi^{0}rec ");
2154  fTrueList[iCut]->Add(fHistoTrueEtaWithPi0DaughterMCPt[iCut]);
2155  fHistoTrueLambdaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueLambdaWithPi0Daughter_MCPt","ESD_TrueLambdaWithPi0Daughter_MCPt",nBinsPt, minPt, maxPt);
2156  fHistoTrueLambdaWithPi0DaughterMCPt[iCut]->SetXTitle("#Lambda p_{MC,T}(GeV/c) for #Lambda where #pi^{0}rec ");
2158  }
2159  if(fDoMesonQA>1){
2160  fHistoTrueBckGGInvMassPt[iCut] = new TH2F("ESD_TrueBckGG_InvMass_Pt","ESD_TrueBckGG_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2161  fHistoTrueBckGGInvMassPt[iCut]->SetXTitle("M_{inv}(GeV/c^{2}) #gamma #gamma no signal");
2162  fHistoTrueBckGGInvMassPt[iCut]->SetYTitle("#pair p_{T}(GeV/c)");
2163  fTrueList[iCut]->Add(fHistoTrueBckGGInvMassPt[iCut]);
2164  fHistoTrueBckFullMesonContainedInOneClusterInvMassPt[iCut] = new TH2F("ESD_TrueBckFullMesonContained_InvMass_Pt","ESD_TrueBckFullMesonContained_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2165  fHistoTrueBckFullMesonContainedInOneClusterInvMassPt[iCut]->SetXTitle("M_{inv}(GeV/c^{2}) #gamma #gamma, calo gamma with full pi0");
2166  fHistoTrueBckFullMesonContainedInOneClusterInvMassPt[iCut]->SetYTitle("#pair p_{T}(GeV/c)");
2168  fHistoTrueBckAsymEClustersInvMassPt[iCut] = new TH2F("ESD_TrueBckAsymEClus_InvMass_Pt","ESD_TrueBckAsymEClus_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2169  fHistoTrueBckAsymEClustersInvMassPt[iCut]->SetXTitle("M_{inv}(GeV/c^{2}) #gamma #gamma, calo gamma >70% of pi0 energy");
2170  fHistoTrueBckAsymEClustersInvMassPt[iCut]->SetYTitle("#pair p_{T}(GeV/c)");
2172  fHistoTrueBckContInvMassPt[iCut] = new TH2F("ESD_TrueBckCont_InvMass_Pt","ESD_TrueBckCont_InvMass_Pt",800,0,0.8,nBinsPt, minPt, maxPt);
2173  fHistoTrueBckContInvMassPt[iCut]->SetXTitle("M_{inv}(GeV/c^{2}) contamination");
2174  fHistoTrueBckContInvMassPt[iCut]->SetYTitle("#pair p_{T}(GeV/c)");
2175  fTrueList[iCut]->Add(fHistoTrueBckContInvMassPt[iCut]);
2176  }
2177  fHistoTruePi0PtY[iCut] = new TH2F("ESD_TruePi0_Pt_Y","ESD_TruePi0_Pt_Y",nBinsQAPt, minQAPt, maxQAPt,150,-1.5,1.5);
2178  fHistoTruePi0PtY[iCut]->SetYTitle("Y_{#pi^{0}}");
2179  fHistoTruePi0PtY[iCut]->SetXTitle("#pi^{0}p_{T}(GeV/c)");
2181  fTrueList[iCut]->Add(fHistoTruePi0PtY[iCut]);
2182  fHistoTrueEtaPtY[iCut] = new TH2F("ESD_TrueEta_Pt_Y","ESD_TrueEta_Pt_Y",nBinsQAPt, minQAPt, maxQAPt,150,-1.5,1.5);
2183  fHistoTrueEtaPtY[iCut]->SetYTitle("Y_{#eta}");
2184  fHistoTrueEtaPtY[iCut]->SetXTitle("#eta p_{T}(GeV/c)");
2186  fTrueList[iCut]->Add(fHistoTrueEtaPtY[iCut]);
2187  fHistoTruePi0PtAlpha[iCut] = new TH2F("ESD_TruePi0_Pt_Alpha","ESD_TruePi0_Pt_Alpha",nBinsQAPt, minQAPt, maxQAPt,200,-1,1);
2188  fHistoTruePi0PtAlpha[iCut]->SetYTitle("#alpha_{#pi^{0}}");
2189  fHistoTruePi0PtAlpha[iCut]->SetXTitle("#pi^{0}p_{T}(GeV/c)");
2191  fTrueList[iCut]->Add(fHistoTruePi0PtAlpha[iCut]);
2192  fHistoTrueEtaPtAlpha[iCut] = new TH2F("ESD_TrueEta_Pt_Alpha","ESD_TrueEta_Pt_Alpha",nBinsQAPt, minQAPt, maxQAPt,200,-1,1);
2193  fHistoTrueEtaPtAlpha[iCut]->SetYTitle("#alpha_{#eta}");
2194  fHistoTrueEtaPtAlpha[iCut]->SetXTitle("#eta p_{T}(GeV/c)");
2196  fTrueList[iCut]->Add(fHistoTrueEtaPtAlpha[iCut]);
2197 
2198  fHistoTruePi0PtOpenAngle[iCut] = new TH2F("ESD_TruePi0_Pt_OpenAngle","ESD_TruePi0_Pt_OpenAngle",nBinsQAPt, minQAPt, maxQAPt,100,0,1);
2199  fHistoTruePi0PtOpenAngle[iCut]->SetYTitle("#theta_{#pi^{0}}");
2200  fHistoTruePi0PtOpenAngle[iCut]->SetXTitle("#pi^{0}p_{T}(GeV/c)");
2202  fTrueList[iCut]->Add(fHistoTruePi0PtOpenAngle[iCut]);
2203  fHistoTrueEtaPtOpenAngle[iCut] = new TH2F("ESD_TrueEta_Pt_OpenAngle","ESD_TrueEta_Pt_OpenAngle",nBinsQAPt, minQAPt, maxQAPt,200,0,TMath::Pi());
2204  fHistoTrueEtaPtOpenAngle[iCut]->SetYTitle("#theta_{#eta}");
2205  fHistoTrueEtaPtOpenAngle[iCut]->SetXTitle("#eta p_{T}(GeV/c)");
2207  fTrueList[iCut]->Add(fHistoTrueEtaPtOpenAngle[iCut]);
2208 
2209  fHistoTrueMotherPi0ConvPhotonEtaPhi[iCut] = new TH2F("ESD_TrueMotherPi0ConvPhoton_Eta_Phi","conv photons for true #pi^{0}",600,0,2*TMath::Pi(),200,-1,1);
2210  fHistoTrueMotherPi0ConvPhotonEtaPhi[iCut]->SetXTitle("#phi_{#gamma_{conv}}(rad)");
2211  fHistoTrueMotherPi0ConvPhotonEtaPhi[iCut]->SetYTitle("#eta_{#gamma_{conv}}");
2213  fHistoTrueMotherEtaConvPhotonEtaPhi[iCut] = new TH2F("ESD_TrueMotherEtaConvPhoton_Eta_Phi","conv photons for true #eta",600,0,2*TMath::Pi(),200,-1,1);
2214  fHistoTrueMotherEtaConvPhotonEtaPhi[iCut]->SetXTitle("#phi_{#gamma_{conv}}(rad)");
2215  fHistoTrueMotherEtaConvPhotonEtaPhi[iCut]->SetYTitle("#eta_{#gamma_{conv}}");
2217 
2218  if (fIsMC > 1){
2219  if(fDoMesonQA>1){
2220  fHistoTrueBckGGInvMassPt[iCut]->Sumw2();
2222  fHistoTrueBckAsymEClustersInvMassPt[iCut]->Sumw2();
2223  fHistoTrueBckContInvMassPt[iCut]->Sumw2();
2224  }
2225  fHistoTruePi0PtY[iCut]->Sumw2();
2226  fHistoTrueEtaPtY[iCut]->Sumw2();
2227  fHistoTruePi0PtAlpha[iCut]->Sumw2();
2228  fHistoTrueEtaPtAlpha[iCut]->Sumw2();
2229  fHistoTruePi0PtOpenAngle[iCut]->Sumw2();
2230  fHistoTrueEtaPtOpenAngle[iCut]->Sumw2();
2231  fHistoTrueMotherPi0ConvPhotonEtaPhi[iCut]->Sumw2();
2232  fHistoTrueMotherEtaConvPhotonEtaPhi[iCut]->Sumw2();
2233  }
2234  }
2235  }
2236  }
2237  }
2238 
2243 
2244  fMapMultipleCountTruePi0s.clear();
2245  fMapMultipleCountTrueEtas.clear();
2248 
2249  fVectorRecTruePi0s.clear();
2250  fVectorRecTrueEtas.clear();
2251 
2252  if(fV0Reader)
2254  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
2255  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
2256  if(fV0Reader)
2258  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms())
2259  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
2260 
2264 
2265  for(Int_t iMatcherTask = 0; iMatcherTask < 3; iMatcherTask++){
2266  AliCaloTrackMatcher* temp = (AliCaloTrackMatcher*) (AliAnalysisManager::GetAnalysisManager()->GetTask(Form("CaloTrackMatcher_%i",iMatcherTask)));
2267  if(temp) fOutputContainer->Add(temp->GetCaloTrackMatcherHistograms());
2268  }
2269 
2270 
2271 
2272  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
2273  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))) continue;
2274  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms()){
2275  fCutFolder[iCut]->Add(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
2276  }
2277  if(!((AliConversionPhotonCuts*)fCutArray->At(iCut))) continue;
2278  if(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms()){
2279  fCutFolder[iCut]->Add(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms());
2280  }
2281  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
2282  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms()){
2283  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms());
2284  }
2285  if(fSetPlotHistsExtQA){
2286  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
2287  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetExtQAHistograms()){
2288  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetExtQAHistograms());
2289  }
2290  }
2291  if(fDoMesonAnalysis){
2292  if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
2293  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
2294  fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
2295  }
2296  }
2297  }
2298 
2299  if (fIsMC > 0){
2300  tBrokenFiles = new TTree("BrokenFiles","BrokenFiles");
2301  tBrokenFiles->Branch("fileName",&fFileNameBroken);
2303  }
2304 
2305 
2306  PostData(1, fOutputContainer);
2307 }
2308 //_____________________________________________________________________________
2310 {
2311  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
2312  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
2313  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
2314  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
2315  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
2316  }
2317 
2318  if(fIsHeavyIon == 2){
2319  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift()){
2320  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
2321  continue; // No Eta Shift requested, continue
2322  }
2323  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
2324  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
2325  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
2326  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
2327  continue;
2328  } else{
2329  printf(" Gamma Conversion Task %s :: Eta Shift Manually Set to %f \n\n",
2330  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
2331  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
2332  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
2333  }
2334  }
2335  }
2336 
2337  return kTRUE;
2338 }
2339 //_____________________________________________________________________________
2341 {
2342  //
2343  // Called for each event
2344  //
2345  fInputEvent = InputEvent();
2346 
2347  if(fIsMC > 0) fMCEvent = MCEvent();
2348 
2349  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
2350  if(fInputEvent->IsIncompleteDAQ()==kTRUE) eventQuality = 2;// incomplete event
2351  // Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1 or because it is incomplete => abort processing of this event/file
2352  if(eventQuality == 2 || eventQuality == 3){
2353  // write out name of broken file for first event
2354  if (fIsMC > 0){
2355  if (fInputEvent->IsA()==AliESDEvent::Class()){
2356  if (((AliESDEvent*)fInputEvent)->GetEventNumberInFile() == 0){
2357  fFileNameBroken = new TObjString(Form("%s",((TString)fV0Reader->GetCurrentFileName()).Data()));
2358  if (tBrokenFiles) tBrokenFiles->Fill();
2359  delete fFileNameBroken;
2360  }
2361  }
2362  }
2363 
2364  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
2365  fHistoNEvents[iCut]->Fill(eventQuality);
2366  if (fIsMC > 1) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
2367  }
2368  return;
2369  }
2370 
2371 
2372  if(fInputEvent->IsA()==AliAODEvent::Class()){
2373  fInputEvent->InitMagneticField();
2374  }
2375 
2376  fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
2377 
2378  // ------------------- BeginEvent ----------------------------
2379  AliEventplane *EventPlane = fInputEvent->GetEventplane();
2380  if(fIsHeavyIon ==1)fEventPlaneAngle = EventPlane->GetEventplane("V0",fInputEvent,2);
2381  else fEventPlaneAngle=0.0;
2382 
2383  if(fIsMC>0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
2384  RelabelAODPhotonCandidates(kTRUE);// In case of AODMC relabeling MC
2385  fV0Reader->RelabelAODs(kTRUE);
2386  }
2387 
2388  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
2389 
2390  fiCut = iCut;
2391 // cout << ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber() << "_" << ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber() <<
2392 // "_" << ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber() <<endl;
2393 
2394  Bool_t isRunningEMCALrelAna = kFALSE;
2395  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetClusterType() == 1) isRunningEMCALrelAna = kTRUE;
2396 
2397  Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon,isRunningEMCALrelAna);
2398 
2399  if(fIsMC==2){
2400  Float_t xsection = -1.;
2401  Float_t ntrials = -1.;
2402  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetXSectionAndNTrials(fMCEvent,xsection,ntrials);
2403  if((xsection==-1.) || (ntrials==-1.)) AliFatal(Form("ERROR: GetXSectionAndNTrials returned invalid xsection/ntrials, periodName from V0Reader: '%s'",fV0Reader->GetPeriodName().Data()));
2404  fProfileJetJetXSection[iCut]->Fill(0.,xsection);
2405  fHistoJetJetNTrials[iCut]->Fill("#sum{NTrials}",ntrials);
2406  }
2407 
2408  if(fIsMC>0){
2409  fWeightJetJetMC = 1;
2410  // cout << fMCEvent << endl;
2411  Bool_t isMCJet = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsJetJetMCEventAccepted( fMCEvent, fWeightJetJetMC );
2412  if (fIsMC == 3){
2413  Double_t weightMult = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetWeightForMultiplicity(fV0Reader->GetNumberOfPrimaryTracks());
2414  fWeightJetJetMC = fWeightJetJetMC*weightMult;
2415  }
2416  if(fIsMC==1) fWeightJetJetMC = 1;
2417  if (!isMCJet){
2418  fHistoNEvents[iCut]->Fill(10,fWeightJetJetMC);
2419  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(10);
2420  continue;
2421  }
2422  }
2423 
2424  Bool_t triggered = kTRUE;
2425 
2426  if(eventNotAccepted!= 0){
2427  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
2428  fHistoNEvents[iCut]->Fill(eventNotAccepted, fWeightJetJetMC); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
2429  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventNotAccepted);
2430  if (eventNotAccepted==3 && fIsMC > 0){
2431  triggered = kFALSE;
2432  }else {
2433  continue;
2434  }
2435  }
2436 
2437  if(eventQuality != 0){// Event Not Accepted
2438  //cout << "event rejected due to: " <<eventQuality << endl;
2439  fHistoNEvents[iCut]->Fill(eventQuality, fWeightJetJetMC);
2440  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
2441  continue;
2442  }
2443 
2444  if (triggered==kTRUE){
2445  fHistoNEvents[iCut]->Fill(eventQuality, fWeightJetJetMC); // Should be 0 here
2446  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventQuality); // Should be 0 here
2447 
2449  fHistoVertexZ[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetZ(), fWeightJetJetMC);
2450  if(!fDoLightOutput){
2451  fHistoVertexX[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetX(), fWeightJetJetMC);
2452  fHistoVertexY[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetY(), fWeightJetJetMC);
2453  fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)),fWeightJetJetMC);
2454  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2) fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A(), fWeightJetJetMC);
2455  else fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C(), fWeightJetJetMC);
2456  }
2457  }
2458 
2459  if(fIsMC>0){
2460  // Process MC Particle
2461  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
2462  if(fInputEvent->IsA()==AliESDEvent::Class()){
2463  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
2464  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
2465  fMCEvent);
2466  }
2467  else if(fInputEvent->IsA()==AliAODEvent::Class()){
2468  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
2469  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
2470  fInputEvent);
2471  }
2472 
2473  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader()){
2474  for(Int_t i = 0;i<(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader())->GetEntries();i++){
2475  TString nameBin= fHistoMCHeaders[iCut]->GetXaxis()->GetBinLabel(i+1);
2476  if (nameBin.CompareTo("")== 0){
2477  TString nameHeader = ((TObjString*)((TList*)((AliConvEventCuts*)fEventCutArray->At(iCut))
2478  ->GetAcceptedHeader())->At(i))->GetString();
2479  fHistoMCHeaders[iCut]->GetXaxis()->SetBinLabel(i+1,nameHeader.Data());
2480  }
2481  }
2482  }
2483  }
2484  }
2485  if(fIsMC>0){
2486  if(fInputEvent->IsA()==AliESDEvent::Class())
2488  if(fInputEvent->IsA()==AliAODEvent::Class())
2490  }
2491 
2492  if (triggered==kFALSE) continue;
2493 
2494  // 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)
2495  ProcessClusters();// process calo clusters
2496  ProcessPhotonCandidates(); // Process this cuts gammas
2497 
2498  fHistoNGammaCandidates[iCut]->Fill(fGammaCandidates->GetEntries(),fWeightJetJetMC);
2500  if(fDoMesonAnalysis){ // Meson Analysis
2501  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseMCPSmearing() && fIsMC>0){
2502  fUnsmearedPx = new Double_t[fGammaCandidates->GetEntries()]; // Store unsmeared Momenta
2503  fUnsmearedPy = new Double_t[fGammaCandidates->GetEntries()];
2504  fUnsmearedPz = new Double_t[fGammaCandidates->GetEntries()];
2505  fUnsmearedE = new Double_t[fGammaCandidates->GetEntries()];
2506 
2507  for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
2508  fUnsmearedPx[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Px();
2509  fUnsmearedPy[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Py();
2510  fUnsmearedPz[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Pz();
2511  fUnsmearedE[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->E();
2512  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->SmearParticle(dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(gamma)));
2513  }
2514  }
2515 
2516  CalculatePi0Candidates(); // Combine Gammas from conversion and from calo
2517 
2518  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
2519  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
2520  CalculateBackground(); // Combinatorial Background
2521  UpdateEventByEventData(); // Store Event for mixed Events
2522  }
2523  else{
2524  CalculateBackgroundRP(); // Combinatorial Background
2525  fBGHandlerRP[iCut]->AddEvent(fGammaCandidates,fInputEvent); // Store Event for mixed Events
2526  fBGClusHandlerRP[iCut]->AddEvent(fClusterCandidates,fInputEvent); // Store Event for mixed Events
2527  }
2528  }
2529 
2530  if(fIsMC>0 && fInputEvent->IsA()==AliAODEvent::Class()){
2531  ProcessConversionPhotonsForMissingTagsAOD(); //Count missing tags
2532  }else if (fIsMC>0 && fInputEvent->IsA()==AliESDEvent::Class()){
2533  ProcessConversionPhotonsForMissingTags(); //Count missing tags
2534  }
2535 
2536  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseMCPSmearing() && fIsMC>0){
2537  for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
2538  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPx(fUnsmearedPx[gamma]); // Reset Unsmeared Momenta
2539  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPy(fUnsmearedPy[gamma]);
2540  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPz(fUnsmearedPz[gamma]);
2541  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetE(fUnsmearedE[gamma]);
2542  }
2543  delete[] fUnsmearedPx; fUnsmearedPx = 0x0;
2544  delete[] fUnsmearedPy; fUnsmearedPy = 0x0;
2545  delete[] fUnsmearedPz; fUnsmearedPz = 0x0;
2546  delete[] fUnsmearedE;fUnsmearedE = 0x0;
2547  }
2548 
2549  if(fIsMC>0){
2550  fVectorRecTruePi0s.clear();
2551  fVectorRecTrueEtas.clear();
2556  }
2557  }
2558 
2559  if(fIsMC>0){
2564  }
2565 
2567 
2568  fGammaCandidates->Clear(); // delete this cuts good gammas
2569  fClusterCandidates->Clear(); // delete cluster candidates
2570  }
2571 
2572  if(fIsMC>0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
2573  RelabelAODPhotonCandidates(kFALSE); // Back to ESDMC Label
2574  fV0Reader->RelabelAODs(kFALSE);
2575  }
2576 
2577  PostData(1, fOutputContainer);
2578 }
2579 
2580 //________________________________________________________________________
2582 
2583  Int_t nclus = 0;
2584  nclus = fInputEvent->GetNumberOfCaloClusters();
2585 
2586 // cout << nclus << endl;
2587 
2588  if(nclus == 0) return;
2589 
2590  // plotting histograms on cell/tower level, only if extendedMatchAndQA > 1
2591  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->FillHistogramsExtendedQA(fInputEvent,fIsMC);
2592 
2593  // match tracks to clusters
2594  if(fDoPrimaryTrackMatching) ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchTracksToClusters(fInputEvent,fWeightJetJetMC,kFALSE);
2595 
2596  // vertex
2597  Double_t vertex[3] = {0,0,0};
2598  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
2599 
2600  // Loop over EMCal clusters
2601  for(Int_t i = 0; i < nclus; i++){
2602  AliVCluster* clus = NULL;
2603  if(fInputEvent->IsA()==AliESDEvent::Class()) clus = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(i));
2604  else if(fInputEvent->IsA()==AliAODEvent::Class()) clus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i));
2605 
2606  if (!clus) continue;
2607  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC,fWeightJetJetMC,i)){
2608  if(fDoInvMassShowerShapeTree && ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedBeforeTrackMatch() ) tESDmapIsClusterAcceptedWithoutTrackMatch[i] = 1;
2609  delete clus;
2610  continue;
2611  }
2612 
2613  // TLorentzvector with cluster
2614  TLorentzVector clusterVector;
2615  clus->GetMomentum(clusterVector,vertex);
2616 
2617  TLorentzVector* tmpvec = new TLorentzVector();
2618  tmpvec->SetPxPyPzE(clusterVector.Px(),clusterVector.Py(),clusterVector.Pz(),clusterVector.E());
2619 
2620  // convert to AODConversionPhoton
2621  AliAODConversionPhoton *PhotonCandidate = new AliAODConversionPhoton(tmpvec);
2622  if(!PhotonCandidate){ delete clus; delete tmpvec; continue;}
2623 
2625 
2626  // Flag Photon as CaloPhoton
2627  PhotonCandidate->SetIsCaloPhoton();
2628  PhotonCandidate->SetCaloClusterRef((Long_t)i);
2629  // get MC label
2630  if(fIsMC>0){
2631  Int_t* mclabelsCluster = clus->GetLabels();
2632  PhotonCandidate->SetNCaloPhotonMCLabels(clus->GetNLabels());
2633 // cout << clus->GetNLabels() << endl;
2634  if (clus->GetNLabels()>0){
2635  for (Int_t k =0; k<(Int_t)clus->GetNLabels(); k++){
2636  if (k<50)PhotonCandidate->SetCaloPhotonMCLabel(k,mclabelsCluster[k]);
2637 // Int_t pdgCode = fMCEvent->Particle(mclabelsCluster[k])->GetPdgCode();
2638 // cout << "label " << k << "\t" << mclabelsCluster[k] << " pdg code: " << pdgCode << endl;
2639  }
2640  }
2641  }
2642 
2643  fIsFromMBHeader = kTRUE;
2645  //TString periodName = fV0Reader->GetPeriodName();
2646  // test whether largest contribution to cluster orginates in added signals
2647  if (fIsMC>0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() > 0){
2648  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetCaloPhotonMCLabel(0), fMCEvent, fInputEvent) == 0){
2649  fIsFromMBHeader = kFALSE;
2650  }
2651  if (clus->GetNLabels()>1){
2652  Int_t* mclabelsCluster = clus->GetLabels();
2653  for (Int_t l = 1; l < (Int_t)clus->GetNLabels(); l++ ){
2654  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(mclabelsCluster[l], fMCEvent, fInputEvent) == 0){
2656  }
2657  }
2658  }
2659  }
2660 
2662  fHistoClusOverlapHeadersGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
2663 
2665  fHistoClusGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
2666  fHistoClusGammaE[fiCut]->Fill(PhotonCandidate->E(),fWeightJetJetMC);
2667  if(fIsMC>0){
2668  if(fInputEvent->IsA()==AliESDEvent::Class()){
2669  ProcessTrueClusterCandidates(PhotonCandidate,clus->GetM02());
2670  }else {
2671  ProcessTrueClusterCandidatesAOD(PhotonCandidate,clus->GetM02());
2672  }
2673  }
2674  fClusterCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
2675  }else{
2676  delete PhotonCandidate;
2677  }
2678 
2679  delete clus;
2680  delete tmpvec;
2681  }
2682 
2683 }
2684 
2685 //________________________________________________________________________
2687 {
2688 
2689  TParticle *Photon = NULL;
2690  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
2691  if (TruePhotonCandidate->GetCaloPhotonMCLabel(0) < 0) return;
2692  if(!fDoLightOutput) fHistoTrueNLabelsInClusPt[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2693 
2694  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0)Photon = fMCEvent->Particle(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
2695  else return;
2696 
2697  if(Photon == NULL){
2698  // cout << "no photon" << endl;
2699  return;
2700  }
2701 
2702  TruePhotonCandidate->SetCaloPhotonMCFlags(fMCEvent, fEnableSortForClusMC);
2703 
2704  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2705  Double_t mcProdVtxX = primVtxMC->GetX();
2706  Double_t mcProdVtxY = primVtxMC->GetY();
2707  Double_t mcProdVtxZ = primVtxMC->GetZ();
2708  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, TruePhotonCandidate->GetCaloPhotonMCLabel(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2709 
2710  // to get primary distrinction right put mother of conversion electron as particle to check
2711  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
2712  isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, Photon->GetMother(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2713 
2715  // Fill histograms for inclusive gamma corrections
2716  // --> a) all clusters with leading real or converted photons
2717  if (TruePhotonCandidate->IsLargestComponentPhoton() || (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()) ){
2718  fHistoTrueClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2719  if(!fDoLightOutput){
2720  // how many of those clusters are from converted photons
2721  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2722  fHistoTrueClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2723  }
2724  // --> b) which of these are primary
2725  if(isPrimary){
2726  fHistoTruePrimaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2727  fHistoTruePrimaryClusGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(),fWeightJetJetMC);
2728  // --> c) which are from conversions? Just additonal information
2729  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion() && (Photon->GetMother(0)>-1)){
2730  fHistoTruePrimaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2731  fHistoTruePrimaryClusConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),((TParticle*)fMCEvent->Particle(Photon->GetMother(0)))->Pt(),fWeightJetJetMC);
2732  }
2733  // --> d) how do the secondaries look like
2734  }else {
2735  Int_t secondaryClass = -1;
2736  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
2737  secondaryClass = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->SecondaryClassificationPhoton( Photon, fMCEvent, kTRUE);
2738  else
2739  secondaryClass = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->SecondaryClassificationPhoton( Photon, fMCEvent, kFALSE);
2740  // all secondaries
2741  if (secondaryClass > 0 ){
2742  fHistoTrueSecondaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2743  }
2744  // secondaries from K0s
2745  if (secondaryClass == 2)
2746  fHistoTrueSecondaryClusGammaFromK0sPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2747  // secondaries from Lambda
2748  else if (secondaryClass == 3)
2749  fHistoTrueSecondaryClusGammaFromLambdaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2750  else if (secondaryClass == 5)
2751  fHistoTrueSecondaryClusGammaFromK0lPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2752  }
2753  }
2754 
2755  // How many clusters are from electrons besides conversions
2756  }else if (TruePhotonCandidate->IsLargestComponentElectron()) {
2757  if(!fDoLightOutput) fHistoTrueClusElectronPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2758  // How many clusters don't have an electromagnetic particle as leading particle
2759  }else {
2760  if(!fDoLightOutput) fHistoTrueClusEMNonLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2761  }
2762 
2763  // Filling histogram for true photons: E vs M02 for paper
2764  if(!fDoLightOutput) {
2765  if ( TruePhotonCandidate->IsLargestComponentPhoton() && !TruePhotonCandidate->IsPhotonWithElecMother() &&
2766  !TruePhotonCandidate->IsMerged() && !TruePhotonCandidate->IsMergedPartConv() && !TruePhotonCandidate->IsDalitzMerged() )
2767  fHistoTrueClusGammaEM02[fiCut]->Fill(TruePhotonCandidate->E(),clusM02, fWeightJetJetMC);
2768  }
2769 
2770  // Some additional QA
2771  if (fDoClusterQA > 0){
2772  // how many of the converted photons are fully contained in the cluster
2773  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion() && TruePhotonCandidate->IsConversionFullyContained())
2774  fHistoTrueClusConvGammaFullyPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2775  // how often do we have merged pi0/eta...
2776  if ( (TruePhotonCandidate->IsMerged() || TruePhotonCandidate->IsDalitzMerged()) || TruePhotonCandidate->IsMergedPartConv() )
2777  fHistoTrueClusMergedGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2778  // how often do we have a merged cluster with at least one conversion
2779  if (TruePhotonCandidate->IsMergedPartConv())
2780  fHistoTrueClusMergedPartConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2781  // how often do we reconstruct Dalitz electrons
2782  if (TruePhotonCandidate->IsDalitz())
2783  fHistoTrueClusDalitzPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2784  // how often merge Dalitz decays
2785  if (TruePhotonCandidate->IsDalitzMerged())
2786  fHistoTrueClusDalitzMergedPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2787  // how often do we see Bremstrahlung
2788  if (TruePhotonCandidate->IsPhotonWithElecMother())
2789  fHistoTrueClusPhotonFromElecMotherPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2790  // how often do we see a shower in the clusters
2791  if (TruePhotonCandidate->IsShower())
2792  fHistoTrueClusShowerPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2793  // how often is the EM a subleading contributor
2794  if (TruePhotonCandidate->IsSubLeadingEM())
2795  fHistoTrueClusSubLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2796  // how many mother particles point to the cluster
2798  }
2799 
2800  // Check if we are double counting photons
2801  Int_t motherLab = Photon->GetMother(0);
2802  if (motherLab > -1){
2803  if (TruePhotonCandidate->IsLargestComponentPhoton()){
2805  fHistoDoubleCountTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),(Double_t)0,fWeightJetJetMC);
2807  }
2808  }
2809  if ( TMath::Abs(fMCEvent->Particle(motherLab)->GetPdgCode()) == 111 &&
2810  TruePhotonCandidate->IsLargestComponentPhoton() &&
2811  TruePhotonCandidate->IsMerged() &&
2812  !TruePhotonCandidate->IsDalitzMerged() &&
2813  !TruePhotonCandidate->IsMergedPartConv()
2814  ){
2815  if(!fDoLightOutput) fHistoTrueClusPi0EM02[fiCut]->Fill(TruePhotonCandidate->E(),clusM02,fWeightJetJetMC);
2816  }
2817  Int_t grandMotherLab = fMCEvent->Particle(motherLab)->GetMother(0);
2818  if (grandMotherLab > -1){
2819  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2821  fHistoDoubleCountTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),(Double_t)1,fWeightJetJetMC);
2823  }
2824  }
2825  }
2826  }
2827  }
2828  return;
2829 }
2830 
2831 
2832 //________________________________________________________________________
2834 {
2835  AliAODMCParticle *Photon = NULL;
2836  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2837  if (AODMCTrackArray){
2838  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
2839  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0) Photon = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
2840  else return;
2841  }else {
2842  AliInfo("AODMCTrackArray could not be loaded");
2843  return;
2844  }
2845 
2846  if(Photon == NULL){
2847  // cout << "no photon" << endl;
2848  return;
2849  }
2850 
2852  if(!fDoLightOutput) fHistoTrueNLabelsInClusPt[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2853 
2854  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2855  Double_t mcProdVtxX = primVtxMC->GetX();
2856  Double_t mcProdVtxY = primVtxMC->GetY();
2857  Double_t mcProdVtxZ = primVtxMC->GetZ();
2858  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2859 
2860  // to get primary distrinction right put mother of conversion electron as particle to check
2861  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2862  if (Photon->GetMother()> -1){
2863  AliAODMCParticle *Mother = (AliAODMCParticle*) AODMCTrackArray->At(Photon->GetMother());
2864  isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, Mother, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2865  }
2866  }
2867 
2868  // True Photon
2870  if (TruePhotonCandidate->IsLargestComponentPhoton() || (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()) ){
2871  fHistoTrueClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2872  if(!fDoLightOutput){
2873  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2874  fHistoTrueClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2875  }
2876  if(isPrimary){
2877  fHistoTruePrimaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2878  fHistoTruePrimaryClusGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(),fWeightJetJetMC);
2879  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2880  fHistoTruePrimaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2881  AliAODMCParticle *Mother = (AliAODMCParticle*) AODMCTrackArray->At(Photon->GetMother());
2882  fHistoTruePrimaryClusConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Mother->Pt(),fWeightJetJetMC);
2883  }
2884  }else {
2885  Int_t secondaryClass = -1;
2886  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
2887  secondaryClass = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->SecondaryClassificationPhotonAOD( Photon, AODMCTrackArray, kTRUE);
2888  else
2889  secondaryClass = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->SecondaryClassificationPhotonAOD( Photon, AODMCTrackArray, kFALSE);
2890  // all secondaries
2891  if (secondaryClass > 0 ){
2892  fHistoTrueSecondaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2893  }
2894  // secondaries from K0s
2895  if (secondaryClass == 2)
2896  fHistoTrueSecondaryClusGammaFromK0sPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2897  // secondaries from Lambda
2898  else if (secondaryClass == 3)
2899  fHistoTrueSecondaryClusGammaFromLambdaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2900  else if (secondaryClass == 5)
2901  fHistoTrueSecondaryClusGammaFromK0lPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2902  }
2903  }
2904 
2905  }else if (TruePhotonCandidate->IsLargestComponentElectron()) {
2906  if(!fDoLightOutput) fHistoTrueClusElectronPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2907  }else {
2908  if(!fDoLightOutput) fHistoTrueClusEMNonLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2909  }
2910 
2911  if(!fDoLightOutput) {
2912  if ( TruePhotonCandidate->IsLargestComponentPhoton() && !TruePhotonCandidate->IsPhotonWithElecMother() &&
2913  !TruePhotonCandidate->IsMerged() && !TruePhotonCandidate->IsMergedPartConv() && !TruePhotonCandidate->IsDalitzMerged() )
2914  fHistoTrueClusGammaEM02[fiCut]->Fill(TruePhotonCandidate->E(),clusM02, fWeightJetJetMC);
2915  }
2916  if (fDoClusterQA > 0){
2917  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion() && TruePhotonCandidate->IsConversionFullyContained())
2918  fHistoTrueClusConvGammaFullyPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2919  if (TruePhotonCandidate->IsMerged() || TruePhotonCandidate->IsMergedPartConv() || TruePhotonCandidate->IsDalitzMerged())
2920  fHistoTrueClusMergedGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2921  if (TruePhotonCandidate->IsMergedPartConv())
2922  fHistoTrueClusMergedPartConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2923  if (TruePhotonCandidate->IsDalitz())
2924  fHistoTrueClusDalitzPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2925  if (TruePhotonCandidate->IsDalitzMerged())
2926  fHistoTrueClusDalitzMergedPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2927  if (TruePhotonCandidate->IsPhotonWithElecMother())
2928  fHistoTrueClusPhotonFromElecMotherPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2929  if (TruePhotonCandidate->IsShower())
2930  fHistoTrueClusShowerPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2931  if (TruePhotonCandidate->IsSubLeadingEM())
2932  fHistoTrueClusSubLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2934 
2935  }
2936  Int_t motherLab = Photon->GetMother();
2937  if (motherLab > -1){
2938  if (TruePhotonCandidate->IsLargestComponentPhoton()){
2940  fHistoDoubleCountTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),(Double_t)0,fWeightJetJetMC);
2942  }
2943  }
2944  if(!fDoLightOutput) {
2945  if ( TMath::Abs(((AliAODMCParticle*) AODMCTrackArray->At(motherLab))->GetPdgCode()) == 111 && TruePhotonCandidate->IsLargestComponentPhoton() && TruePhotonCandidate->IsMerged() && !TruePhotonCandidate->IsDalitzMerged() && !TruePhotonCandidate->IsMergedPartConv())
2946  fHistoTrueClusPi0EM02[fiCut]->Fill(TruePhotonCandidate->E(),clusM02, fWeightJetJetMC);
2947  }
2948  Int_t grandMotherLab = ((AliAODMCParticle*) AODMCTrackArray->At(motherLab))->GetMother();
2949  if (grandMotherLab > -1){
2950  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2952  fHistoDoubleCountTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),(Double_t)1,fWeightJetJetMC);
2954  }
2955  }
2956  }
2957  }
2958 
2959  }
2960 
2961  return;
2962 }
2963 
2964 //________________________________________________________________________
2966 {
2967  Int_t nV0 = 0;
2968  TList *GammaCandidatesStepOne = new TList();
2969  TList *GammaCandidatesStepTwo = new TList();
2970  // Loop over Photon Candidates allocated by ReaderV1
2971  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
2972  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
2973  if(!PhotonCandidate) continue;
2974  fIsFromMBHeader = kTRUE;
2975  if(fIsMC>0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2976  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
2977  if(isPosFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2978  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
2979  if(isNegFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2980  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
2981  }
2982 
2983  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fInputEvent)) continue;
2984  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(PhotonCandidate->GetPhotonPhi(),fEventPlaneAngle)) continue;
2985  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
2986  !((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
2987  fGammaCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
2988 
2989  if(fIsFromMBHeader){
2990  if(!fDoLightOutput) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
2991  if (fDoPhotonQA > 0){
2992  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
2993  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
2994  }
2995  }
2996  if(fIsMC>0){
2997  if(fInputEvent->IsA()==AliESDEvent::Class())
2998  ProcessTruePhotonCandidates(PhotonCandidate);
2999  if(fInputEvent->IsA()==AliAODEvent::Class())
3000  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
3001  }
3002  if (fIsFromMBHeader && fDoPhotonQA == 2){
3003  if (fIsHeavyIon == 1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
3004  fPtGamma = PhotonCandidate->Pt();
3005  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
3006  fRConvPhoton = PhotonCandidate->GetConversionRadius();
3007  fEtaPhoton = PhotonCandidate->GetPhotonEta();
3008  fCharCatPhoton = PhotonCandidate->GetPhotonQuality();
3009  fTreeConvGammaPtDcazCat[fiCut]->Fill();
3010  }else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
3011  fPtGamma = PhotonCandidate->Pt();
3012  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
3013  fRConvPhoton = PhotonCandidate->GetConversionRadius();
3014  fEtaPhoton = PhotonCandidate->GetPhotonEta();
3015  fCharCatPhoton = PhotonCandidate->GetPhotonQuality();
3016  fTreeConvGammaPtDcazCat[fiCut]->Fill();
3017  }
3018  }
3019  }else if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
3020  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
3021  nV0++;
3022  GammaCandidatesStepOne->Add(PhotonCandidate);
3023  }else if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
3024  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
3025  GammaCandidatesStepTwo->Add(PhotonCandidate);
3026  }
3027  }
3028  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){
3029  for(Int_t i = 0;i<GammaCandidatesStepOne->GetEntries();i++){
3030  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GammaCandidatesStepOne->At(i);
3031  if(!PhotonCandidate) continue;
3032  fIsFromMBHeader = kTRUE;
3033  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3034  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
3035  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
3036  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
3037  }
3038  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GammaCandidatesStepOne->GetEntries())) continue;
3039  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
3040  fGammaCandidates->Add(PhotonCandidate);
3041  if(fIsFromMBHeader){
3042  if(!fDoLightOutput) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
3043  if (fDoPhotonQA > 0){
3044  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
3045  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
3046  }
3047  }
3048  if(fIsMC>0){
3049  if(fInputEvent->IsA()==AliESDEvent::Class())
3050  ProcessTruePhotonCandidates(PhotonCandidate);
3051  if(fInputEvent->IsA()==AliAODEvent::Class())
3052  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
3053  }
3054  if (fIsFromMBHeader && fDoPhotonQA == 2){
3055  if (fIsHeavyIon ==1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
3056  fPtGamma = PhotonCandidate->Pt();
3057  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
3058  fRConvPhoton = PhotonCandidate->GetConversionRadius();
3059  fEtaPhoton = PhotonCandidate->GetPhotonEta();
3060  fCharCatPhoton = PhotonCandidate->GetPhotonQuality();
3061  fTreeConvGammaPtDcazCat[fiCut]->Fill();
3062  }else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
3063  fPtGamma = PhotonCandidate->Pt();
3064  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
3065  fRConvPhoton = PhotonCandidate->GetConversionRadius();
3066  fEtaPhoton = PhotonCandidate->GetPhotonEta();
3067  fCharCatPhoton = PhotonCandidate->GetPhotonQuality();
3068  fTreeConvGammaPtDcazCat[fiCut]->Fill();
3069  }
3070  }
3071  } else GammaCandidatesStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
3072  }
3073  }
3074  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
3075  for(Int_t i = 0;i<GammaCandidatesStepTwo->GetEntries();i++){
3076  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GammaCandidatesStepTwo->At(i);
3077  if(!PhotonCandidate) continue;
3078  fIsFromMBHeader = kTRUE;
3079  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3080  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
3081  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
3082  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
3083  }
3084  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GammaCandidatesStepTwo,i)) continue;
3085  fGammaCandidates->Add(PhotonCandidate); // Add gamma to current cut TList
3086  if(fIsFromMBHeader){
3087  if(!fDoLightOutput) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
3088  if (fDoPhotonQA > 0){
3089  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
3090  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
3091  }
3092  }
3093  if(fIsMC>0){
3094  if(fInputEvent->IsA()==AliESDEvent::Class())
3095  ProcessTruePhotonCandidates(PhotonCandidate);
3096  if(fInputEvent->IsA()==AliAODEvent::Class())
3097  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
3098  }
3099  if (fIsFromMBHeader && fDoPhotonQA == 2){
3100  if (fIsHeavyIon == 1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
3101  fPtGamma = PhotonCandidate->Pt();
3102  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
3103  fRConvPhoton = PhotonCandidate->GetConversionRadius();
3104  fEtaPhoton = PhotonCandidate->GetPhotonEta();
3105  fCharCatPhoton = PhotonCandidate->GetPhotonQuality();
3106  fTreeConvGammaPtDcazCat[fiCut]->Fill();
3107  }else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
3108  fPtGamma = PhotonCandidate->Pt();
3109  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
3110  fRConvPhoton = PhotonCandidate->GetConversionRadius();
3111  fEtaPhoton = PhotonCandidate->GetPhotonEta();
3112  fCharCatPhoton = PhotonCandidate->GetPhotonQuality();
3113  fTreeConvGammaPtDcazCat[fiCut]->Fill();
3114  }
3115  }
3116  }
3117  }
3118 
3119  delete GammaCandidatesStepOne;
3120  GammaCandidatesStepOne = 0x0;
3121  delete GammaCandidatesStepTwo;
3122  GammaCandidatesStepTwo = 0x0;
3123 
3124 }
3125 
3126 //________________________________________________________________________
3128 {
3129  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3130  Double_t mcProdVtxX = primVtxMC->GetX();
3131  Double_t mcProdVtxY = primVtxMC->GetY();
3132  Double_t mcProdVtxZ = primVtxMC->GetZ();
3133 
3134  Double_t magField = fInputEvent->GetMagneticField();
3135  if( magField < 0.0 ){
3136  magField = 1.0;
3137  }
3138  else {
3139  magField = -1.0;
3140  }
3141 
3142  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3143  if (AODMCTrackArray == NULL) return;
3144  AliAODMCParticle *posDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelPositive());
3145  AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelNegative());
3146  fCharPhotonMCInfo = 0;
3147 
3148  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
3149  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
3150 
3151  if(posDaughter->GetMother() != negDaughter->GetMother()){
3152  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode);
3153  fCharPhotonMCInfo = 1;
3154  return;
3155  }
3156  else if(posDaughter->GetMother() == -1){
3157  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode);
3158  fCharPhotonMCInfo = 1;
3159  return;
3160  }
3161 
3162  if(pdgCode[0]!=11 || pdgCode[1]!=11){
3163  fCharPhotonMCInfo = 1;
3164  return; //One Particle is not a electron
3165  }
3166 
3167  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()){
3168  fCharPhotonMCInfo = 1;
3169  return; // Same Charge
3170  }
3171 
3172  AliAODMCParticle *Photon = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
3173  if(Photon->GetPdgCode() != 22){
3174  fCharPhotonMCInfo = 1;
3175  return; // Mother is no Photon
3176  }
3177 
3178  if(((posDaughter->GetMCProcessCode())) != 5 || ((negDaughter->GetMCProcessCode())) != 5){
3179  fCharPhotonMCInfo = 1;
3180  return;// check if the daughters come from a conversion
3181  }
3182  // STILL A BUG IN ALIROOT >>8 HAS TPO BE REMOVED AFTER FIX
3183 
3184 
3185 
3186  // True Photon
3187  if(fIsFromMBHeader){
3188  if(!fDoLightOutput) fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
3189  if (fDoPhotonQA > 0) fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta());
3190  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueConvGammas,posDaughter->GetMother())){
3191  if(!fDoLightOutput) fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
3192  FillMultipleCountMap(fMapMultipleCountTrueConvGammas,posDaughter->GetMother());
3193  }
3194  }
3195 
3196  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3197  if(isPrimary){
3198  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
3199  if(fIsFromMBHeader){
3200  fCharPhotonMCInfo = 6;
3201  if(!fDoLightOutput){
3202  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
3203  fHistoTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(),fWeightJetJetMC); // Allways Filled
3204  }
3205  }
3206  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
3207  }else {
3208  if(fIsFromMBHeader){
3209 
3210  fCharPhotonMCInfo = 2;
3211  // check for secondaries from K0s
3212  if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 &&
3213  ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 310){
3214  fCharPhotonMCInfo = 4;
3215  if(!fDoLightOutput){
3216  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC);
3217  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),0.,fWeightJetJetMC);
3218  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
3219  }
3220  // check for secondaries from K0l
3221  } else if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 &&
3222  ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 130) {
3223  fCharPhotonMCInfo = 7;
3224  if(!fDoLightOutput){
3225  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC);
3226  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),1.,fWeightJetJetMC);
3227  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
3228  }
3229  // check for secondaries from Lambda
3230  } else if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 &&
3231  ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 3122){
3232  fCharPhotonMCInfo = 5;
3233  if(!fDoLightOutput){
3234  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC);
3235  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),0.,fWeightJetJetMC);
3236  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
3237  }
3238  } else if (((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 &&
3239  ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 221) {
3240  fCharPhotonMCInfo = 3;
3241  if(!fDoLightOutput){
3242  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC);
3243  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC);
3244  }
3245  } else {
3246  if(!fDoLightOutput){
3247  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC);
3248  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC);
3249  }
3250  }
3251  }
3252  }
3253  TruePhotonCandidate->SetIsTrueConvertedPhoton();
3254 }
3255 
3256 //________________________________________________________________________
3258 {
3259  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3260  Double_t mcProdVtxX = primVtxMC->GetX();
3261  Double_t mcProdVtxY = primVtxMC->GetY();
3262  Double_t mcProdVtxZ = primVtxMC->GetZ();
3263 
3264  Double_t magField = fInputEvent->GetMagneticField();
3265  if( magField < 0.0 ){
3266  magField = 1.0;
3267  }
3268  else {
3269  magField = -1.0;
3270  }
3271 
3272  // Process True Photons
3273  TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCEvent);
3274  TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCEvent);
3275  fCharPhotonMCInfo = 0;
3276 
3277  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
3278  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
3279  fCharPhotonMCInfo = 1;
3280  if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){
3281  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode);
3282  return;
3283  }
3284  else if(posDaughter->GetMother(0) == -1){
3285  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode);
3286  return;
3287  }
3288 
3289  if(pdgCode[0]!=11 || pdgCode[1]!=11) return; //One Particle is not a electron
3290 
3291  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
3292 
3293  TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCEvent);
3294 
3295  if(Photon->GetPdgCode() != 22){
3296  return; // Mother is no Photon
3297  }
3298 
3299  if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
3300 
3301  // True Photon
3302  if(fIsFromMBHeader){
3303  if(!fDoLightOutput) fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
3304  if (fDoPhotonQA > 0) fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta());
3305  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueConvGammas,posDaughter->GetMother(0))){
3306  if(!fDoLightOutput) fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
3307  FillMultipleCountMap(fMapMultipleCountTrueConvGammas,posDaughter->GetMother(0));
3308  }
3309  }
3310  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, posDaughter->GetMother(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3311  if(isPrimary){
3312  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
3313  if(fIsFromMBHeader){
3314  fCharPhotonMCInfo = 6;
3315  if(!fDoLightOutput){
3316  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
3317  fHistoTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(),fWeightJetJetMC); // Allways Filled
3318  }
3319  }
3320  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
3321  }else {
3322  // fill secondary histograms
3323  if(fIsFromMBHeader){
3324  fCharPhotonMCInfo = 2;
3325  if( Photon->GetMother(0) > -1 && fMCEvent->Particle(Photon->GetMother(0))->GetMother(0) > -1){
3326  if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
3327  fCharPhotonMCInfo = 4;
3328  if (!fDoLightOutput){
3329  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC);
3330  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),0.,fWeightJetJetMC);
3331  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
3332  }
3333  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
3334  fCharPhotonMCInfo = 7;
3335  if (!fDoLightOutput){
3336  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC);
3337  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),1.,fWeightJetJetMC);
3338  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
3339  }
3340  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
3341  fCharPhotonMCInfo = 5;
3342  if (!fDoLightOutput){
3343  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC);
3344  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),2.,fWeightJetJetMC);
3345  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
3346  }
3347  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 221) {
3348  fCharPhotonMCInfo = 3;
3349  if (!fDoLightOutput){
3350  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC);
3351  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC);
3352  }
3353  } else {
3354  if (!fDoLightOutput){
3355  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC);
3356  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC);
3357  }
3358  }
3359  } else {
3360  if (!fDoLightOutput){
3361  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC);
3362  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC);
3363  }
3364  }
3365  }
3366  }
3367  TruePhotonCandidate->SetIsTrueConvertedPhoton();
3368  return;
3369 }
3370 //________________________________________________________________________
3372 {
3373  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3374  Double_t mcProdVtxX = primVtxMC->GetX();
3375  Double_t mcProdVtxY = primVtxMC->GetY();
3376  Double_t mcProdVtxZ = primVtxMC->GetZ();
3377 
3378  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3379  if (AODMCTrackArray == NULL) return;
3380 
3381  // Loop over all primary MC particle
3382  for(Long_t i = 0; i < AODMCTrackArray->GetEntriesFast(); i++) {
3383 
3384  AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
3385  if (!particle) continue;
3386 
3387  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, particle, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3388  if (isPrimary) {
3389 
3390  Int_t isMCFromMBHeader = -1;
3391  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3392  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
3393  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3394  }
3395 
3396  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
3397  if(!fDoLightOutput){
3398  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kFALSE)){
3399  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // All MC Gamma
3400  if (TMath::Abs(particle->Eta()) < 0.66 ){
3401  if (particle->Phi() > 1.39626 && particle->Phi() < 3.125) fHistoMCAllGammaEMCALAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3402  }
3403  if(particle->GetMother() >-1){ // Meson Decay Gamma
3404  switch((static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother())))->GetPdgCode()){
3405  case 111: // Pi0
3406  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3407  break;
3408  case 113: // Rho0
3409  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3410  break;
3411  case 221: // Eta
3412  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3413  break;
3414  case 223: // Omega
3415  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3416  break;
3417  case 331: // Eta'
3418  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3419  break;
3420  case 333: // Phi
3421  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3422  break;
3423  case 3212: // Sigma
3424  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3425  break;
3426  }
3427  }
3428  }
3429  }
3430  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kTRUE)){
3431  Double_t rConv = 0;
3432  for(Int_t daughterIndex=particle->GetDaughter(0);daughterIndex<=particle->GetDaughter(1);daughterIndex++){
3433  AliAODMCParticle *tmpDaughter = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(daughterIndex));
3434  if(!tmpDaughter) continue;
3435  if(TMath::Abs(tmpDaughter->GetPdgCode()) == 11){
3436  rConv = sqrt( (tmpDaughter->Xv()*tmpDaughter->Xv()) + (tmpDaughter->Yv()*tmpDaughter->Yv()) );
3437  }
3438  }
3439  if(!fDoLightOutput) fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3440  if (fDoPhotonQA > 0){
3441  fHistoMCConvGammaR[fiCut]->Fill(rConv);
3442  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta());
3443  }
3444  }
3445  // Converted MC Gamma
3446  if(fDoMesonAnalysis){
3447 
3448  Double_t mesonY = 10.;
3449  if(particle->E() - particle->Pz() == 0 || particle->E() + particle->Pz() == 0){
3450  mesonY=10.-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3451  }else {
3452  mesonY = 0.5*(TMath::Log((particle->E()+particle->Pz()) / (particle->E()-particle->Pz())))-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3453  }
3454 
3455  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
3456  if ( particle->GetPdgCode() == 211 ){ // positve pions
3457  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 0., fWeightJetJetMC);
3458  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
3459  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 1., fWeightJetJetMC);
3460  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
3461  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 2., fWeightJetJetMC);
3462  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
3463  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 3., fWeightJetJetMC);
3464  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
3465  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 4., fWeightJetJetMC);
3466  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
3467  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 5., fWeightJetJetMC);
3468  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
3469  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 6., fWeightJetJetMC);
3470  }
3471  }
3472 
3473  // check neutral mesons
3475  ->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3476  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
3477  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
3478  Float_t weighted= 1;
3479  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
3480  if (particle->Pt()>0.005){
3481  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, 0x0, fInputEvent);
3482  // if(particle->GetPdgCode() == 221){
3483  // cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3484  // }
3485  }
3486  }
3487  Double_t mesonY = 10.;
3488  if(particle->E() - particle->Pz() == 0 || particle->E() + particle->Pz() == 0){
3489  mesonY=10.-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3490  }else{
3491  mesonY = 0.5*(TMath::Log((particle->E()+particle->Pz()) / (particle->E()-particle->Pz())))-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3492  }
3493 
3494  Double_t alpha = -10;
3495  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
3496  alpha = (daughter0->E() - daughter1->E())/(daughter0->E() + daughter1->E());
3497  }
3498 
3499 
3500  if(particle->GetPdgCode() == 111){
3501  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Pi0
3502  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3503  if (!fDoLightOutput){
3504  // fill pi0 hists against gamma pt of first leg
3505  fHistoMCPi0PtGammaLeg[fiCut]->Fill(daughter0->Pt(),0.,weighted*fWeightJetJetMC);
3506  fHistoMCPi0WOWeightPtGammaLeg[fiCut]->Fill(daughter0->Pt(),0.,fWeightJetJetMC);
3507  // fill pi0 hists against gamma pt of second leg
3508  fHistoMCPi0PtGammaLeg[fiCut]->Fill(daughter1->Pt(),1.,weighted*fWeightJetJetMC);
3509  fHistoMCPi0WOWeightPtGammaLeg[fiCut]->Fill(daughter1->Pt(),1.,fWeightJetJetMC);
3510  // fill pi0 hists against gamma pt of both legs
3511  fHistoMCPi0PtGammaLeg[fiCut]->Fill(daughter0->Pt(),2.,weighted*fWeightJetJetMC);
3512  fHistoMCPi0WOWeightPtGammaLeg[fiCut]->Fill(daughter0->Pt(),2.,fWeightJetJetMC);
3513  fHistoMCPi0PtGammaLeg[fiCut]->Fill(daughter1->Pt(),2.,weighted*fWeightJetJetMC);
3514  fHistoMCPi0WOWeightPtGammaLeg[fiCut]->Fill(daughter1->Pt(),2.,fWeightJetJetMC);
3515  }
3516 
3517  if (fIsMC > 1) fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
3518  if (fDoMesonQA > 0){
3519  fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted*fWeightJetJetMC);
3520  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC);
3521  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
3522  }
3523  }else if(particle->GetPdgCode() == 221){
3524  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Eta
3525  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3526  if (fIsMC > 1) fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
3527  if (fDoMesonQA > 0){
3528  fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted*fWeightJetJetMC);
3529  fHistoMCEtaPtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC);
3530  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
3531  }
3532  }
3533 
3534  // Check the acceptance for both gammas
3535  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
3536  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
3537  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
3538  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
3539  // check acceptance of clusters as well, true if one of them points into the Calo acceptance
3540  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter0,AODMCTrackArray) ||
3541  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter1,AODMCTrackArray) ){
3542  if(particle->GetPdgCode() == 111){
3543  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc
3544  fHistoMCPi0WOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Pi0 with gamma in acc wo weight
3545  if(fIsMC > 1) fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 with gamma in acc wo any weight
3546  if (!fDoLightOutput){
3547  // fill pi0 hists against gamma pt of first leg
3548  fHistoMCPi0InAccPtGammaLeg[fiCut]->Fill(daughter0->Pt(),0.,weighted*fWeightJetJetMC);
3549  fHistoMCPi0WOWeightInAccPtGammaLeg[fiCut]->Fill(daughter0->Pt(),0.,fWeightJetJetMC);
3550  // fill pi0 hists against gamma pt of second leg
3551  fHistoMCPi0InAccPtGammaLeg[fiCut]->Fill(daughter1->Pt(),1.,weighted*fWeightJetJetMC);
3552  fHistoMCPi0WOWeightInAccPtGammaLeg[fiCut]->Fill(daughter1->Pt(),1.,fWeightJetJetMC);
3553  // fill pi0 hists against gamma pt of both legs
3554  fHistoMCPi0InAccPtGammaLeg[fiCut]->Fill(daughter0->Pt(),2.,weighted*fWeightJetJetMC);
3555  fHistoMCPi0WOWeightInAccPtGammaLeg[fiCut]->Fill(daughter0->Pt(),2.,fWeightJetJetMC);
3556  fHistoMCPi0InAccPtGammaLeg[fiCut]->Fill(daughter1->Pt(),2.,weighted*fWeightJetJetMC);
3557  fHistoMCPi0WOWeightInAccPtGammaLeg[fiCut]->Fill(daughter1->Pt(),2.,fWeightJetJetMC);
3558  }
3559  }else if(particle->GetPdgCode() == 221){
3560  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Eta with gamma in acc
3561  fHistoMCEtaWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Eta with gamma in acc wo weight
3562  if(fIsMC > 1) fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta with gamma in acc wo any weight
3563  }
3564  }
3565  }
3566  }
3567  }
3568  } else {
3569  // fill secondary histograms
3570  Int_t isMCFromMBHeader = -1;
3571  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3572  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
3573  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3574  }
3575  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) {
3576  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kFALSE)){
3577  if (particle->GetMother() > -1) {
3578  AliAODMCParticle *tmpMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
3579  if (tmpMother->GetMother() > -1) {
3580  AliAODMCParticle *tmpGrandMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(tmpMother->GetMother()));
3581  if(tmpGrandMother->GetPdgCode() == 310) {
3582  if (!fDoLightOutput) fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
3583  } else if (tmpGrandMother->GetPdgCode() == 130) {
3584  if (!fDoLightOutput) fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
3585  } else if (tmpGrandMother->GetPdgCode() == 3122) {
3586  if (!fDoLightOutput) fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3587  } else {
3588  if ( !(TMath::Abs(tmpMother->GetPdgCode()) == 11 && tmpGrandMother->GetPdgCode() == 22) )
3589  if (!fDoLightOutput) fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3590  }
3591  } else {
3592  if (!fDoLightOutput) fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3593  }
3594  } else {
3595  if (!fDoLightOutput) fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3596  }
3597  }
3598 
3599  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kTRUE)){
3600  if (particle->GetMother() > -1) {
3601  AliAODMCParticle *tmpMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
3602  if (tmpMother->GetMother() > -1) {
3603  AliAODMCParticle *tmpGrandMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(tmpMother->GetMother()));
3604  if(tmpGrandMother->GetPdgCode() == 310) {
3605  if (!fDoLightOutput) fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
3606  } else if (tmpGrandMother->GetPdgCode() == 130) {
3607  if (!fDoLightOutput) fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
3608  } else if (tmpGrandMother->GetPdgCode() == 3122) {
3609  if (!fDoLightOutput) fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3610  } else {
3611  if ( !(TMath::Abs(tmpMother->GetPdgCode()) == 11 && tmpGrandMother->GetPdgCode() == 22) )
3612  if (!fDoLightOutput) fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3613  }
3614  } else {
3615  if (!fDoLightOutput) fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3616  }
3617  } else {
3618  if (!fDoLightOutput) fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3619  }
3620  }
3621  }
3622 
3623  if(fDoMesonAnalysis){
3624  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3625  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
3626  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
3627  AliAODMCParticle* mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
3628  Int_t pdgCode = mother->GetPdgCode();
3629  if(particle->GetPdgCode() == 111){
3630  Int_t source = GetSourceClassification(111,pdgCode);
3631  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC); // All MC Pi0
3632  if (!fDoLightOutput){
3633  fHistoMCSecPi0PtGamma1vsSource[fiCut]->Fill(daughter0->Pt(),source,fWeightJetJetMC); // All MC Pi0
3634  fHistoMCSecPi0PtGamma2vsSource[fiCut]->Fill(daughter1->Pt(),source,fWeightJetJetMC); // All MC Pi0
3635  }
3636  fHistoMCSecPi0Source[fiCut]->Fill(pdgCode);
3637  }else if(particle->GetPdgCode() == 221){
3638 
3639  fHistoMCSecEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // All MC Pi0
3640  fHistoMCSecEtaSource[fiCut]->Fill(pdgCode);
3641  }
3642 
3643  // check if conversion where within acceptance
3644  if( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
3645  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
3646  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
3647  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
3648  // check acceptance of clusters as well, true if one of them points into the Calo acceptance
3649  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter0,AODMCTrackArray) ||
3650  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter1,AODMCTrackArray) ){
3651  if (particle->GetPdgCode() == 111){
3652  Int_t source = GetSourceClassification(111,pdgCode);
3653  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC); // All MC Pi0
3654  if (!fDoLightOutput){
3655  fHistoMCSecPi0InAccPtGamma1vsSource[fiCut]->Fill(daughter0->Pt(),source,fWeightJetJetMC); // All MC Pi0
3656  fHistoMCSecPi0InAccPtGamma2vsSource[fiCut]->Fill(daughter1->Pt(),source,fWeightJetJetMC); // All MC Pi0
3657  }
3658  }
3659  }
3660  }
3661  }
3662  }
3663  }
3664  }
3665 }
3666 
3667 //________________________________________________________________________
3669 {
3670  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3671  Double_t mcProdVtxX = primVtxMC->GetX();
3672  Double_t mcProdVtxY = primVtxMC->GetY();
3673  Double_t mcProdVtxZ = primVtxMC->GetZ();
3674 // cout << mcProdVtxX <<"\t" << mcProdVtxY << "\t" << mcProdVtxZ << endl;
3675 
3676  // Loop over all primary MC particle
3677  for(Long_t i = 0; i < fMCEvent->GetNumberOfTracks(); i++) {
3678  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
3679  // fill primary histograms
3680  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
3681  if (!particle) continue;
3682 
3683  Int_t isMCFromMBHeader = -1;
3684  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3685  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
3686  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3687  }
3688 
3689  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
3690  if(!fDoLightOutput){
3691  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
3692  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // All MC Gamma
3693  if (TMath::Abs(particle->Eta()) < 0.66 ){
3694  if (particle->Phi() > 1.39626 && particle->Phi() < 3.125) fHistoMCAllGammaEMCALAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3695  }
3696 
3697  if(particle->GetMother(0) >-1){ // Meson Decay Gamma
3698  switch(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()){
3699  case 111: // Pi0
3700  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3701  break;
3702  case 113: // Rho0
3703  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3704  break;
3705  case 221: // Eta
3706  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3707  break;
3708  case 223: // Omega
3709  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3710  break;
3711  case 331: // Eta'
3712  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3713  break;
3714  case 333: // Phi
3715  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3716  break;
3717  case 3212: // Sigma
3718  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3719  break;
3720  }
3721  }
3722  }
3723  }
3724  // Converted MC Gamma
3725  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kTRUE)){
3726  if(!fDoLightOutput) fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3727  if (fDoPhotonQA > 0){
3728  if(particle->GetFirstDaughter()>-1) fHistoMCConvGammaR[fiCut]->Fill(((TParticle*)fMCEvent->Particle(particle->GetFirstDaughter()))->R());
3729  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta());
3730  }
3731  }
3732 
3733 
3734  if(fDoMesonAnalysis ){
3735 
3736  // Fill histograms for other particles
3737  Double_t mesonY = 10.;
3738  if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
3739  mesonY=10.-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3740  }else{
3741  mesonY = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())))-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3742  }
3743 
3744  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
3745  if ( particle->GetPdgCode() == 211 ){ // positve pions
3746  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 0., fWeightJetJetMC);
3747  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
3748  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 1., fWeightJetJetMC);
3749  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
3750  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 2., fWeightJetJetMC);
3751  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
3752  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 3., fWeightJetJetMC);
3753  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
3754  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 4., fWeightJetJetMC);
3755  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
3756  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 5., fWeightJetJetMC);
3757  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
3758  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 6., fWeightJetJetMC);
3759  }
3760  }
3761 
3762  // check neutral mesons
3764  ->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3765  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
3766  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
3767 
3768  Float_t weighted= 1;
3769  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
3770  if (particle->Pt()>0.005){
3771  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
3772  }
3773  }
3774  Double_t mesonY = 10.;
3775  if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
3776  mesonY=10.-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3777  }else{
3778  mesonY = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())))-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3779  }
3780 
3781  Double_t alpha = -10;
3782  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
3783  alpha = (daughter0->Energy() - daughter1->Energy())/(daughter0->Energy() + daughter1->Energy());
3784  }
3785 
3786  if(particle->GetPdgCode() == 111){
3787  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Pi0
3788  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3789  if (!fDoLightOutput){
3790  // fill pi0 hists against gamma pt of first leg
3791  fHistoMCPi0PtGammaLeg[fiCut]->Fill(daughter0->Pt(),0.,weighted*fWeightJetJetMC);
3792  fHistoMCPi0WOWeightPtGammaLeg[fiCut]->Fill(daughter0->Pt(),0.,fWeightJetJetMC);
3793  // fill pi0 hists against gamma pt of second leg
3794  fHistoMCPi0PtGammaLeg[fiCut]->Fill(daughter1->Pt(),1.,weighted*fWeightJetJetMC);
3795  fHistoMCPi0WOWeightPtGammaLeg[fiCut]->Fill(daughter1->Pt(),1.,fWeightJetJetMC);
3796  // fill pi0 hists against gamma pt of both legs
3797  fHistoMCPi0PtGammaLeg[fiCut]->Fill(daughter0->Pt(),2.,weighted*fWeightJetJetMC);
3798  fHistoMCPi0WOWeightPtGammaLeg[fiCut]->Fill(daughter0->Pt(),2.,fWeightJetJetMC);
3799  fHistoMCPi0PtGammaLeg[fiCut]->Fill(daughter1->Pt(),2.,weighted*fWeightJetJetMC);
3800  fHistoMCPi0WOWeightPtGammaLeg[fiCut]->Fill(daughter1->Pt(),2.,fWeightJetJetMC);
3801  }
3802 
3803  if (fIsMC > 1) fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
3804  if (fDoMesonQA > 0){
3805  fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted*fWeightJetJetMC); // All MC Pi0
3806  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
3807  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
3808  }
3809  }else if(particle->GetPdgCode() == 221){
3810  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Eta
3811  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3812  if (fIsMC > 1) fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
3813  if (fDoMesonQA > 0){
3814  fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted*fWeightJetJetMC); // All MC Pi0
3815  fHistoMCEtaPtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
3816  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
3817  }
3818  }
3819 
3820  // Check the acceptance for both gammas & whether they are counted as primaries as well
3821  Bool_t kDaughter0IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetFirstDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3822  Bool_t kDaughter1IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetLastDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3823 
3824  if( kDaughter0IsPrim && kDaughter1IsPrim &&
3825  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter0,fMCEvent,kFALSE) &&
3826  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter1,fMCEvent,kFALSE) &&
3827  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
3828  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
3829  // check acceptance of clusters as well, true if one of them points into the Calo acceptance
3830  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter0,fMCEvent) ||
3831  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter1,fMCEvent) ){
3832  if(particle->GetPdgCode() == 111){
3833  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc
3834  fHistoMCPi0WOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Pi0 with gamma in acc wo weighting
3835  if(fIsMC > 1) fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 with gamma in acc wo any weight
3836  if (!fDoLightOutput){
3837  // fill pi0 hists against gamma pt of first leg
3838  fHistoMCPi0InAccPtGammaLeg[fiCut]->Fill(daughter0->Pt(),0.,weighted*fWeightJetJetMC);
3839  fHistoMCPi0WOWeightInAccPtGammaLeg[fiCut]->Fill(daughter0->Pt(),0.,fWeightJetJetMC);
3840  // fill pi0 hists against gamma pt of second leg
3841  fHistoMCPi0InAccPtGammaLeg[fiCut]->Fill(daughter1->Pt(),1.,weighted*fWeightJetJetMC);
3842  fHistoMCPi0WOWeightInAccPtGammaLeg[fiCut]->Fill(daughter1->Pt(),1.,fWeightJetJetMC);
3843  // fill pi0 hists against gamma pt of both legs
3844  fHistoMCPi0InAccPtGammaLeg[fiCut]->Fill(daughter0->Pt(),2.,weighted*fWeightJetJetMC);
3845  fHistoMCPi0WOWeightInAccPtGammaLeg[fiCut]->Fill(daughter0->Pt(),2.,fWeightJetJetMC);
3846  fHistoMCPi0InAccPtGammaLeg[fiCut]->Fill(daughter1->Pt(),2.,weighted*fWeightJetJetMC);
3847  fHistoMCPi0WOWeightInAccPtGammaLeg[fiCut]->Fill(daughter1->Pt(),2.,fWeightJetJetMC);
3848  }
3849  }else if(particle->GetPdgCode() == 221){
3850  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Eta with gamma in acc
3851  fHistoMCEtaWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Eta with gamma in acc wo weighting
3852  if(fIsMC > 1) fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta with gamma in acc wo any weight
3853  }
3854  }
3855  }
3856  }
3857  }
3858  // fill secondary histograms
3859  } else {
3860  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
3861  if (!particle) continue;
3862  Int_t isMCFromMBHeader = -1;
3863  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3864  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
3865  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3866  }
3867 
3868  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)){
3869  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
3870  if (particle->GetMother(0) > -1 && fMCEvent->Particle(particle->GetMother(0))->GetMother(0) > -1) {
3871  if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
3872  if (!fDoLightOutput) fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
3873  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
3874  if (!fDoLightOutput) fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
3875  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
3876  if (!fDoLightOutput) fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3877  } else {
3878  if ( !(TMath::Abs(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()) == 11 && fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 22) )
3879  if (!fDoLightOutput) fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3880  }
3881  } else {
3882  if (!fDoLightOutput) fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3883  }
3884  }
3885