AliPhysics  608b256 (608b256)
AliAnalysisTaskGammaCaloDalitzV1.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: Pedro Gonzalez, Baldo Sahlmueller, Friederike Bock *
5  * Version 1.0 *
6  * *
7  * *
8  * Permission to use, copy, modify and distribute this software and its *
9  * documentation strictly for non-commercial purposes is hereby granted *
10  * without fee, provided that the above copyright notice appears in all *
11  * copies and that both the copyright notice and this permission notice *
12  * appear in the supporting documentation. The authors make no claims *
13  * about the suitability of this software for any purpose. It is *
14  * provided "as is" without express or implied warranty. *
15  **************************************************************************/
16 
18 //----------------------------------------------------------------
19 // Class used to do analysis on conversion photons + calo photons
20 //----------------------------------------------------------------
22 #include "TChain.h"
23 #include "TTree.h"
24 #include "TBranch.h"
25 #include "TFile.h"
26 #include "TH1F.h"
27 #include "TH2F.h"
28 #include "TH3F.h"
29 #include "THnSparse.h"
30 #include "TCanvas.h"
31 #include "TNtuple.h"
32 #include "TDatabasePDG.h"
33 #include "AliAnalysisTask.h"
34 #include "AliAnalysisManager.h"
35 #include "AliESDEvent.h"
36 #include "AliESDInputHandler.h"
37 #include "AliMCEventHandler.h"
38 #include "AliMCEvent.h"
39 #include "AliMCParticle.h"
40 #include "AliCentrality.h"
41 #include "AliESDVZERO.h"
42 #include "AliESDpid.h"
44 #include "AliVParticle.h"
45 #include "AliESDtrack.h"
46 #include "AliESDtrackCuts.h"
47 #include "AliKFVertex.h"
48 #include "AliV0ReaderV1.h"
49 #include "AliGenCocktailEventHeader.h"
51 #include "AliAODMCParticle.h"
52 #include "AliAODMCHeader.h"
53 #include "AliEventplane.h"
55 #include "AliAODEvent.h"
56 #include "AliAODInputHandler.h"
57 #include "AliESDEvent.h"
58 #include "AliESDInputHandler.h"
59 #include "AliInputEventHandler.h"
60 #include "AliCaloTrackMatcher.h"
61 #include <vector>
62 
64 
65 //________________________________________________________________________
67  fV0Reader(NULL),
68  fV0ReaderName("V0ReaderV1"),
69  fElecSelector(NULL),
70  fBGClusHandler(NULL),
71  fInputEvent(NULL),
72  fMCEvent(NULL),
73  fCutFolder(NULL),
74  fESDList(NULL),
75  fBackList(NULL),
76  fMotherList(NULL),
77  fPhotonDCAList(NULL),
78  fTrueList(NULL),
79  fMCList(NULL),
80  fHeaderNameList(NULL),
81  fClusterOutputList(NULL),
82  fOutputContainer(NULL),
83  fReaderGammas(NULL),
84  fSelectorElectronIndex(0),
85  fSelectorPositronIndex(0),
86  fGammaCandidates(NULL),
87  fClusterCandidates(NULL),
88  fVirtualGammaCandidates(NULL),
89  fEventCutArray(NULL),
90  fEventCuts(NULL),
91  fGammaCutArray(NULL),
92  fElectronCutArray(NULL),
93  fConversionCuts(NULL),
94  fClusterCutArray(NULL),
95  fCaloPhotonCuts(NULL),
96  fMesonCutArray(NULL),
97  fMesonCuts(NULL),
98  fHistoConvGammaPt(NULL),
99  fHistoConvGammaR(NULL),
100  fHistoConvGammaEta(NULL),
101  fHistoDalitzElectronPt(NULL),
102  fHistoDalitzPositronPt(NULL),
103  fHistoDalitzElectronPhi(NULL),
104  fHistoDalitzPositronPhi(NULL),
105  fPtGamma(0),
106  fDCAzPhoton(0),
107  fRConvPhoton(0),
108  fEtaPhoton(0),
109  fCharCatPhoton(0),
110  fCharPhotonMCInfo(0),
111  fHistoMotherInvMassPt(NULL),
112  fHistoMotherInvMassOpeningAngleGammaElectron(NULL),
113  fHistoMotherMatchedInvMassPt(NULL),
114  fSparseMotherInvMassPtZM(NULL),
115  fHistoMotherBackInvMassPt(NULL),
116  fSparseMotherBackInvMassPtZM(NULL),
117  fHistoMotherInvMassEalpha(NULL),
118  fHistoMotherPi0PtY(NULL),
119  fHistoMotherEtaPtY(NULL),
120  fHistoMotherPi0PtAlpha(NULL),
121  fHistoMotherEtaPtAlpha(NULL),
122  fHistoMotherPi0PtOpenAngle(NULL),
123  fHistoMotherEtaPtOpenAngle(NULL),
124  fHistoMotherPi0ConvPhotonEtaPhi(NULL),
125  fHistoMotherEtaConvPhotonEtaPhi(NULL),
126  fHistoMotherInvMassECalib(NULL),
127  fHistoMotherInvMassECalibalpha(NULL),
128  fHistoClusGammaPt(NULL),
129  fHistoClusOverlapHeadersGammaPt(NULL),
130  fHistoMCHeaders(NULL),
131  fHistoMCAllGammaPt(NULL),
132  fHistoMCAllGammaPi0Pt(NULL),
133  fHistoMCAllGammaEMCALAccPt(NULL),
134  fHistoMCDecayGammaPi0Pt(NULL),
135  fHistoMCDecayGammaRhoPt(NULL),
136  fHistoMCDecayGammaEtaPt(NULL),
137  fHistoMCDecayGammaOmegaPt(NULL),
138  fHistoMCDecayGammaEtapPt(NULL),
139  fHistoMCDecayGammaPhiPt(NULL),
140  fHistoMCDecayGammaSigmaPt(NULL),
141  fHistoMCConvGammaPt(NULL),
142  fHistoMCConvGammaR(NULL),
143  fHistoMCConvGammaEta(NULL),
144  fHistoMCAllPositronsPt(NULL),
145  fHistoMCDecayPositronPi0Pt(NULL),
146  fHistoMCAllElectronsPt(NULL),
147  fHistoMCDecayElectronPi0Pt(NULL),
148  fHistoMCDecayNoPrimElectronPi0DalitzR(NULL),
149  fHistoMCDecayNoPrimPositronPi0DalitzR(NULL),
150  fHistoMCDecayNoPrimElectronPi0DalitzID(NULL),
151  fHistoMCDecayNoPrimPositronPi0DalitzID(NULL),
152  fHistoMCPi0GGPt(NULL),
153  fHistoMCPi0GGWOWeightPt(NULL),
154  fHistoMCPi0Pt(NULL),
155  fHistoMCPi0WOWeightPt(NULL),
156  fHistoMCEtaGGPt(NULL),
157  fHistoMCEtaGGWOWeightPt(NULL),
158  fHistoMCEtaPt(NULL),
159  fHistoMCEtaWOWeightPt(NULL),
160  fHistoMCPi0InAccPt(NULL),
161  fHistoMCPi0InAccOpeningAngleGammaElectron(NULL),
162  fHistoMCEtaInAccPt(NULL),
163  fHistoMCPi0PtY(NULL),
164  fHistoMCEtaPtY(NULL),
165  fHistoMCPi0PtAlpha(NULL),
166  fHistoMCEtaPtAlpha(NULL),
167  fHistoMCK0sPt(NULL),
168  fHistoMCK0sWOWeightPt(NULL),
169  fHistoMCK0sPtY(NULL),
170  fHistoTruePi0InvMassPt(NULL),
171  fHistoTrueEtaInvMassPt(NULL),
172  fHistoTruePi0ShowerInvMassPt(NULL),
173  fHistoTrueEtaShowerInvMassPt(NULL),
174  fHistoTruePi0NoShowerInvMassPt(NULL),
175  fHistoTrueEtaNoShowerInvMassPt(NULL),
176  fHistoTruePi0OpeningAngleGammaElectron(NULL),
177  fHistoTruePi0GGInvMassPt(NULL),
178  fHistoTrueEtaGGInvMassPt(NULL),
179  fHistoTruePi0CaloPhotonInvMassPt(NULL),
180  fHistoTrueEtaCaloPhotonInvMassPt(NULL),
181  fHistoTruePi0CaloConvertedPhotonInvMassPt(NULL),
182  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt(NULL),
183  fHistoTrueEtaCaloConvertedPhotonInvMassPt(NULL),
184  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt(NULL),
185  fHistoTruePi0CaloElectronInvMassPt(NULL),
186  fHistoTrueEtaCaloElectronInvMassPt(NULL),
187  fHistoTruePi0CaloMergedClusterInvMassPt(NULL),
188  fHistoTrueEtaCaloMergedClusterInvMassPt(NULL),
189  fHistoTrueMotherCaloEMNonLeadingInvMassPt(NULL),
190  fHistoTruePi0CaloMergedClusterPartConvInvMassPt(NULL),
191  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt(NULL),
192  fHistoTruePrimaryPi0InvMassPt(NULL),
193  fHistoTruePrimaryPi0GGInvMassPt(NULL),
194  fHistoTruePrimaryEtaInvMassPt(NULL),
195  fHistoTruePrimaryEtaGGInvMassPt(NULL),
196  fHistoTruePrimaryPi0W0WeightingInvMassPt(NULL),
197  fHistoTruePrimaryEtaW0WeightingInvMassPt(NULL),
198  fProfileTruePrimaryPi0WeightsInvMassPt(NULL),
199  fProfileTruePrimaryEtaWeightsInvMassPt(NULL),
200  fHistoTruePrimaryPi0MCPtResolPt(NULL),
201  fHistoTruePrimaryEtaMCPtResolPt(NULL),
202  fHistoTrueMotherPi0ConvPhotonEtaPhi(NULL),
203  fHistoTrueMotherEtaConvPhotonEtaPhi(NULL),
204  fHistoTrueSecondaryPi0InvMassPt(NULL),
205  fHistoTrueSecondaryPi0GGInvMassPt(NULL),
206  fHistoTrueSecondaryPi0FromK0sInvMassPt(NULL),
207  fHistoTrueK0sWithPi0DaughterMCPt(NULL),
208  fHistoTrueSecondaryPi0FromEtaInvMassPt(NULL),
209  fHistoTrueEtaWithPi0DaughterMCPt(NULL),
210  fHistoTrueSecondaryPi0FromLambdaInvMassPt(NULL),
211  fHistoTrueLambdaWithPi0DaughterMCPt(NULL),
212  fHistoTrueBckGGInvMassPt(NULL),
213  fHistoTrueBckContInvMassPt(NULL),
214  fHistoTruePi0PtY(NULL),
215  fHistoTrueEtaPtY(NULL),
216  fHistoTruePi0PtAlpha(NULL),
217  fHistoTrueEtaPtAlpha(NULL),
218  fHistoTruePi0PtOpenAngle(NULL),
219  fHistoTrueEtaPtOpenAngle(NULL),
220  fHistoTrueConvGammaPt(NULL),
221  fHistoTrueConvPi0GammaPt(NULL),
222  fHistoTrueConvGammaEta(NULL),
223  fHistoTruePositronPt(NULL),
224  fHistoTrueElectronPt(NULL),
225  fHistoTrueSecPositronPt(NULL),
226  fHistoTrueSecElectronPt(NULL),
227  fHistoTruePi0DalitzPositronPt(NULL),
228  fHistoTruePi0DalitzElectronPt(NULL),
229  fHistoTruePi0DalitzSecPositronPt(NULL),
230  fHistoTruePi0DalitzSecElectronPt(NULL),
231  fHistoTruePrimaryConvGammaPt(NULL),
232  fHistoTruePrimaryConvGammaESDPtMCPt(NULL),
233  fHistoTrueSecondaryConvGammaPt(NULL),
234  fHistoTrueSecondaryConvGammaFromXFromK0sPt(NULL),
235  fHistoTrueSecondaryConvGammaFromXFromLambdaPt(NULL),
236  fHistoTrueClusGammaPt(NULL),
237  fHistoTrueClusUnConvGammaPt(NULL),
238  fHistoTrueClusUnConvGammaMCPt(NULL),
239  fHistoTrueClusElectronPt(NULL),
240  fHistoTrueClusConvGammaPt(NULL),
241  fHistoTrueClusConvGammaMCPt(NULL),
242  fHistoTrueClusConvGammaFullyPt(NULL),
243  fHistoTrueClusMergedGammaPt(NULL),
244  fHistoTrueClusMergedPartConvGammaPt(NULL),
245  fHistoTrueClusDalitzPt(NULL),
246  fHistoTrueClusDalitzMergedPt(NULL),
247  fHistoTrueClusPhotonFromElecMotherPt(NULL),
248  fHistoTrueClusShowerPt(NULL),
249  fHistoTrueClusSubLeadingPt(NULL),
250  fHistoTrueClusNParticles(NULL),
251  fHistoTrueClusEMNonLeadingPt(NULL),
252  fHistoTrueNLabelsInClus(NULL),
253  fHistoTruePrimaryClusGammaPt(NULL),
254  fHistoTruePrimaryClusGammaESDPtMCPt(NULL),
255  fHistoTruePi0DalitzClusGammaPt(NULL),
256  fHistoTruePi0DalitzAllClusGammaPt(NULL),
257  fHistoTruePi0DalitzClusGammaMCPt(NULL),
258  fHistoTruePrimaryPi0PhotonPairPtconv(NULL),
259  fHistoTruePrimaryPi0DCPtconv(NULL),
260  fHistoTruePrimaryPi0MissingPtconv(NULL),
261  fHistoTruePrimaryEtaPhotonPairPtconv(NULL),
262  fHistoTruePrimaryEtaDCPtconv(NULL),
263  fHistoTruePrimaryEtaMissingPtconv(NULL),
264  fHistoTrueSecondaryPi0PhotonPairPtconv(NULL),
265  fHistoTrueSecondaryPi0DCPtconv(NULL),
266  fHistoTrueSecondaryPi0MissingPtconv(NULL),
267  fStringRecTruePi0s(NULL),
268  fStringRecTrueEtas(NULL),
269  fHistoDoubleCountTruePi0InvMassPt(NULL),
270  fHistoDoubleCountTrueEtaInvMassPt(NULL),
271  fHistoDoubleCountTrueConvGammaRPt(NULL),
272  fVectorDoubleCountTruePi0s(0),
273  fVectorDoubleCountTrueEtas(0),
274  fVectorDoubleCountTrueConvGammas(0),
275  fHistoNEvents(NULL),
276  fHistoNGoodESDTracks(NULL),
277  fHistoNGammaCandidates(NULL),
278  fHistoNGoodESDTracksVsNGammaCanditates(NULL),
279  fHistoSPDClusterTrackletBackground(NULL),
280  fHistoNV0Tracks(NULL),
281  fProfileEtaShift(NULL),
282  fEventPlaneAngle(-100),
283  fRandom(0),
284  fNGammaCandidates(0),
285  fUnsmearedPx(NULL),
286  fUnsmearedPy(NULL),
287  fUnsmearedPz(NULL),
288  fUnsmearedE(NULL),
289  fMCEventPos(NULL),
290  fMCEventNeg(NULL),
291  fESDArrayPos(NULL),
292  fESDArrayNeg(NULL),
293  fnCuts(0),
294  fiCut(0),
295  fMoveParticleAccordingToVertex(kTRUE),
296  fIsHeavyIon(0),
297  fDoMesonAnalysis(kTRUE),
298  fDoMesonQA(0),
299  fDoPhotonQA(0),
300  fDoClusterQA(0),
301  fIsFromMBHeader(kTRUE),
302  fIsOverlappingWithOtherHeader(kFALSE),
303  fIsMC(kFALSE),
304  fDoTHnSparse(kTRUE),
305  fTrackMatcherRunningMode(0)
306 {
307 
308 }
309 
310 //________________________________________________________________________
312  AliAnalysisTaskSE(name),
313  fV0Reader(NULL),
314  fV0ReaderName("V0ReaderV1"),
315  fElecSelector(NULL),
316  fBGClusHandler(NULL),
317  fInputEvent(NULL),
318  fMCEvent(NULL),
319  fCutFolder(NULL),
320  fESDList(NULL),
321  fBackList(NULL),
322  fMotherList(NULL),
323  fPhotonDCAList(NULL),
324  fTrueList(NULL),
325  fMCList(NULL),
326  fHeaderNameList(NULL),
327  fClusterOutputList(NULL),
328  fOutputContainer(0),
329  fReaderGammas(NULL),
330  fSelectorElectronIndex(0),
331  fSelectorPositronIndex(0),
332  fGammaCandidates(NULL),
333  fClusterCandidates(NULL),
334  fVirtualGammaCandidates(NULL),
335  fEventCutArray(NULL),
336  fEventCuts(NULL),
337  fGammaCutArray(NULL),
338  fElectronCutArray(NULL),
339  fConversionCuts(NULL),
340  fClusterCutArray(NULL),
341  fCaloPhotonCuts(NULL),
342  fMesonCutArray(NULL),
343  fMesonCuts(NULL),
344  fHistoConvGammaPt(NULL),
345  fHistoConvGammaR(NULL),
346  fHistoConvGammaEta(NULL),
347  fHistoDalitzElectronPt(NULL),
348  fHistoDalitzPositronPt(NULL),
349  fHistoDalitzElectronPhi(NULL),
350  fHistoDalitzPositronPhi(NULL),
351  fPtGamma(0),
352  fDCAzPhoton(0),
353  fRConvPhoton(0),
354  fEtaPhoton(0),
355  fCharCatPhoton(0),
356  fCharPhotonMCInfo(0),
357  fHistoMotherInvMassPt(NULL),
358  fHistoMotherInvMassOpeningAngleGammaElectron(NULL),
359  fHistoMotherMatchedInvMassPt(NULL),
360  fSparseMotherInvMassPtZM(NULL),
361  fHistoMotherBackInvMassPt(NULL),
362  fSparseMotherBackInvMassPtZM(NULL),
363  fHistoMotherInvMassEalpha(NULL),
364  fHistoMotherPi0PtY(NULL),
365  fHistoMotherEtaPtY(NULL),
366  fHistoMotherPi0PtAlpha(NULL),
367  fHistoMotherEtaPtAlpha(NULL),
368  fHistoMotherPi0PtOpenAngle(NULL),
369  fHistoMotherEtaPtOpenAngle(NULL),
370  fHistoMotherPi0ConvPhotonEtaPhi(NULL),
371  fHistoMotherEtaConvPhotonEtaPhi(NULL),
372  fHistoMotherInvMassECalib(NULL),
373  fHistoMotherInvMassECalibalpha(NULL),
374  fHistoClusGammaPt(NULL),
375  fHistoClusOverlapHeadersGammaPt(NULL),
376  fHistoMCHeaders(NULL),
377  fHistoMCAllGammaPt(NULL),
378  fHistoMCAllGammaPi0Pt(NULL),
379  fHistoMCAllGammaEMCALAccPt(NULL),
380  fHistoMCDecayGammaPi0Pt(NULL),
381  fHistoMCDecayGammaRhoPt(NULL),
382  fHistoMCDecayGammaEtaPt(NULL),
383  fHistoMCDecayGammaOmegaPt(NULL),
384  fHistoMCDecayGammaEtapPt(NULL),
385  fHistoMCDecayGammaPhiPt(NULL),
386  fHistoMCDecayGammaSigmaPt(NULL),
387  fHistoMCConvGammaPt(NULL),
388  fHistoMCConvGammaR(NULL),
389  fHistoMCConvGammaEta(NULL),
390  fHistoMCAllPositronsPt(NULL),
391  fHistoMCDecayPositronPi0Pt(NULL),
392  fHistoMCAllElectronsPt(NULL),
393  fHistoMCDecayElectronPi0Pt(NULL),
394  fHistoMCDecayNoPrimElectronPi0DalitzR(NULL),
395  fHistoMCDecayNoPrimPositronPi0DalitzR(NULL),
396  fHistoMCDecayNoPrimElectronPi0DalitzID(NULL),
397  fHistoMCDecayNoPrimPositronPi0DalitzID(NULL),
398  fHistoMCPi0GGPt(NULL),
399  fHistoMCPi0GGWOWeightPt(NULL),
400  fHistoMCPi0Pt(NULL),
401  fHistoMCPi0WOWeightPt(NULL),
402  fHistoMCEtaGGPt(NULL),
403  fHistoMCEtaGGWOWeightPt(NULL),
404  fHistoMCEtaPt(NULL),
405  fHistoMCEtaWOWeightPt(NULL),
406  fHistoMCPi0InAccPt(NULL),
407  fHistoMCPi0InAccOpeningAngleGammaElectron(NULL),
408  fHistoMCEtaInAccPt(NULL),
409  fHistoMCPi0PtY(NULL),
410  fHistoMCEtaPtY(NULL),
411  fHistoMCPi0PtAlpha(NULL),
412  fHistoMCEtaPtAlpha(NULL),
413  fHistoMCK0sPt(NULL),
414  fHistoMCK0sWOWeightPt(NULL),
415  fHistoMCK0sPtY(NULL),
416  fHistoTruePi0InvMassPt(NULL),
417  fHistoTrueEtaInvMassPt(NULL),
418  fHistoTruePi0ShowerInvMassPt(NULL),
419  fHistoTrueEtaShowerInvMassPt(NULL),
420  fHistoTruePi0NoShowerInvMassPt(NULL),
421  fHistoTrueEtaNoShowerInvMassPt(NULL),
422  fHistoTruePi0OpeningAngleGammaElectron(NULL),
423  fHistoTruePi0GGInvMassPt(NULL),
424  fHistoTrueEtaGGInvMassPt(NULL),
425  fHistoTruePi0CaloPhotonInvMassPt(NULL),
426  fHistoTrueEtaCaloPhotonInvMassPt(NULL),
427  fHistoTruePi0CaloConvertedPhotonInvMassPt(NULL),
428  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt(NULL),
429  fHistoTrueEtaCaloConvertedPhotonInvMassPt(NULL),
430  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt(NULL),
431  fHistoTruePi0CaloElectronInvMassPt(NULL),
432  fHistoTrueEtaCaloElectronInvMassPt(NULL),
433  fHistoTruePi0CaloMergedClusterInvMassPt(NULL),
434  fHistoTrueEtaCaloMergedClusterInvMassPt(NULL),
435  fHistoTrueMotherCaloEMNonLeadingInvMassPt(NULL),
436  fHistoTruePi0CaloMergedClusterPartConvInvMassPt(NULL),
437  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt(NULL),
438  fHistoTruePrimaryPi0InvMassPt(NULL),
439  fHistoTruePrimaryPi0GGInvMassPt(NULL),
440  fHistoTruePrimaryEtaInvMassPt(NULL),
441  fHistoTruePrimaryEtaGGInvMassPt(NULL),
442  fHistoTruePrimaryPi0W0WeightingInvMassPt(NULL),
443  fHistoTruePrimaryEtaW0WeightingInvMassPt(NULL),
444  fProfileTruePrimaryPi0WeightsInvMassPt(NULL),
445  fProfileTruePrimaryEtaWeightsInvMassPt(NULL),
446  fHistoTruePrimaryPi0MCPtResolPt(NULL),
447  fHistoTruePrimaryEtaMCPtResolPt(NULL),
448  fHistoTrueMotherPi0ConvPhotonEtaPhi(NULL),
449  fHistoTrueMotherEtaConvPhotonEtaPhi(NULL),
450  fHistoTrueSecondaryPi0InvMassPt(NULL),
451  fHistoTrueSecondaryPi0GGInvMassPt(NULL),
452  fHistoTrueSecondaryPi0FromK0sInvMassPt(NULL),
453  fHistoTrueK0sWithPi0DaughterMCPt(NULL),
454  fHistoTrueSecondaryPi0FromEtaInvMassPt(NULL),
455  fHistoTrueEtaWithPi0DaughterMCPt(NULL),
456  fHistoTrueSecondaryPi0FromLambdaInvMassPt(NULL),
457  fHistoTrueLambdaWithPi0DaughterMCPt(NULL),
458  fHistoTrueBckGGInvMassPt(NULL),
459  fHistoTrueBckContInvMassPt(NULL),
460  fHistoTruePi0PtY(NULL),
461  fHistoTrueEtaPtY(NULL),
462  fHistoTruePi0PtAlpha(NULL),
463  fHistoTrueEtaPtAlpha(NULL),
464  fHistoTruePi0PtOpenAngle(NULL),
465  fHistoTrueEtaPtOpenAngle(NULL),
466  fHistoTrueConvGammaPt(NULL),
467  fHistoTrueConvPi0GammaPt(NULL),
468  fHistoTrueConvGammaEta(NULL),
469  fHistoTruePositronPt(NULL),
470  fHistoTrueElectronPt(NULL),
471  fHistoTrueSecPositronPt(NULL),
472  fHistoTrueSecElectronPt(NULL),
473  fHistoTruePi0DalitzPositronPt(NULL),
474  fHistoTruePi0DalitzElectronPt(NULL),
475  fHistoTruePi0DalitzSecPositronPt(NULL),
476  fHistoTruePi0DalitzSecElectronPt(NULL),
477  fHistoTruePrimaryConvGammaPt(NULL),
478  fHistoTruePrimaryConvGammaESDPtMCPt(NULL),
479  fHistoTrueSecondaryConvGammaPt(NULL),
480  fHistoTrueSecondaryConvGammaFromXFromK0sPt(NULL),
481  fHistoTrueSecondaryConvGammaFromXFromLambdaPt(NULL),
482  fHistoTrueClusGammaPt(NULL),
483  fHistoTrueClusUnConvGammaPt(NULL),
484  fHistoTrueClusUnConvGammaMCPt(NULL),
485  fHistoTrueClusElectronPt(NULL),
486  fHistoTrueClusConvGammaPt(NULL),
487  fHistoTrueClusConvGammaMCPt(NULL),
488  fHistoTrueClusConvGammaFullyPt(NULL),
489  fHistoTrueClusMergedGammaPt(NULL),
490  fHistoTrueClusMergedPartConvGammaPt(NULL),
491  fHistoTrueClusDalitzPt(NULL),
492  fHistoTrueClusDalitzMergedPt(NULL),
493  fHistoTrueClusPhotonFromElecMotherPt(NULL),
494  fHistoTrueClusShowerPt(NULL),
495  fHistoTrueClusSubLeadingPt(NULL),
496  fHistoTrueClusNParticles(NULL),
497  fHistoTrueClusEMNonLeadingPt(NULL),
498  fHistoTrueNLabelsInClus(NULL),
499  fHistoTruePrimaryClusGammaPt(NULL),
500  fHistoTruePrimaryClusGammaESDPtMCPt(NULL),
501  fHistoTruePi0DalitzClusGammaPt(NULL),
502  fHistoTruePi0DalitzAllClusGammaPt(NULL),
503  fHistoTruePi0DalitzClusGammaMCPt(NULL),
504  fHistoTruePrimaryPi0PhotonPairPtconv(NULL),
505  fHistoTruePrimaryPi0DCPtconv(NULL),
506  fHistoTruePrimaryPi0MissingPtconv(NULL),
507  fHistoTruePrimaryEtaPhotonPairPtconv(NULL),
508  fHistoTruePrimaryEtaDCPtconv(NULL),
509  fHistoTruePrimaryEtaMissingPtconv(NULL),
510  fHistoTrueSecondaryPi0PhotonPairPtconv(NULL),
511  fHistoTrueSecondaryPi0DCPtconv(NULL),
512  fHistoTrueSecondaryPi0MissingPtconv(NULL),
513  fStringRecTruePi0s(NULL),
514  fStringRecTrueEtas(NULL),
515  fHistoDoubleCountTruePi0InvMassPt(NULL),
516  fHistoDoubleCountTrueEtaInvMassPt(NULL),
517  fHistoDoubleCountTrueConvGammaRPt(NULL),
518  fVectorDoubleCountTruePi0s(0),
519  fVectorDoubleCountTrueEtas(0),
520  fVectorDoubleCountTrueConvGammas(0),
521  fHistoNEvents(NULL),
522  fHistoNGoodESDTracks(NULL),
523  fHistoNGammaCandidates(NULL),
524  fHistoNGoodESDTracksVsNGammaCanditates(NULL),
525  fHistoSPDClusterTrackletBackground(NULL),
526  fHistoNV0Tracks(NULL),
527  fProfileEtaShift(NULL),
528  fEventPlaneAngle(-100),
529  fRandom(0),
530  fNGammaCandidates(0),
531  fUnsmearedPx(NULL),
532  fUnsmearedPy(NULL),
533  fUnsmearedPz(NULL),
534  fUnsmearedE(NULL),
535  fMCEventPos(NULL),
536  fMCEventNeg(NULL),
537  fESDArrayPos(NULL),
538  fESDArrayNeg(NULL),
539  fnCuts(0),
540  fiCut(0),
541  fMoveParticleAccordingToVertex(kTRUE),
542  fIsHeavyIon(0),
543  fDoMesonAnalysis(kTRUE),
544  fDoMesonQA(0),
545  fDoPhotonQA(0),
546  fDoClusterQA(0),
547  fIsFromMBHeader(kTRUE),
548  fIsOverlappingWithOtherHeader(kFALSE),
549  fIsMC(kFALSE),
550  fDoTHnSparse(kTRUE),
551  fTrackMatcherRunningMode(0)
552 {
553  // Define output slots here
554  DefineOutput(1, TList::Class());
555 }
556 
558 {
559  if(fGammaCandidates){
560  delete fGammaCandidates;
561  fGammaCandidates = 0x0;
562  }
563  if(fClusterCandidates){
564  delete fClusterCandidates;
565  fClusterCandidates = 0x0;
566  }
570  }
571 
572  if(fBGClusHandler){
573  delete[] fBGClusHandler;
574  fBGClusHandler = 0x0;
575  }
576 
577 }
578 //___________________________________________________________
580 
581  const Int_t nDim = 4;
582  Int_t nBins[nDim] = {800,250,7,4};
583  Double_t xMin[nDim] = {0,0, 0,0};
584  Double_t xMax[nDim] = {0.8,25,7,4};
585 
586  if( fDoTHnSparse ) {
587 
588  fSparseMotherInvMassPtZM = new THnSparseF*[fnCuts];
589  fSparseMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
590 
591  }
592 
593 
595 
596  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
597 
598  if (((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
599  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
600  TString cutstringPhoton = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
601  TString cutstringElectron = ((AliDalitzElectronCuts*)fElectronCutArray->At(iCut))->GetCutNumber();
602  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
603  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
604 
605  Int_t collisionSystem = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(0,1));
606  Int_t centMin = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(1,1));
607  Int_t centMax = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(2,1));
608 
609  if(collisionSystem == 1 || collisionSystem == 2 ||
610  collisionSystem == 5 || collisionSystem == 8 ||
611  collisionSystem == 9){
612  centMin = centMin*10;
613  centMax = centMax*10;
614  if(centMax ==0 && centMax!=centMin) centMax=100;
615  } else if(collisionSystem == 3 || collisionSystem == 6){
616  centMin = centMin*5;
617  centMax = centMax*5;
618  } else if(collisionSystem == 4 || collisionSystem == 7){
619  centMin = ((centMin*5)+45);
620  centMax = ((centMax*5)+45);
621  }
622 
623  if( fDoTHnSparse ) {
624 
625  fBackList[iCut] = new TList();
626  fBackList[iCut]->SetName(Form("%s_%s_%s_%s_%s Back histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringElectron.Data(),cutstringCalo.Data(), cutstringMeson.Data()));
627  fBackList[iCut]->SetOwner(kTRUE);
628  fCutFolder[iCut]->Add(fBackList[iCut]);
629 
630  fSparseMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_m","Back_Back_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
631  fBackList[iCut]->Add(fSparseMotherBackInvMassPtZM[iCut]);
632 
633  fMotherList[iCut] = new TList();
634  fMotherList[iCut]->SetName(Form("%s_%s_%s_%s_%s Mother histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringElectron.Data(),cutstringCalo.Data(), cutstringMeson.Data()));
635  fMotherList[iCut]->SetOwner(kTRUE);
636  fCutFolder[iCut]->Add(fMotherList[iCut]);
637 
638  fSparseMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_m","Back_Mother_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
639  fMotherList[iCut]->Add(fSparseMotherInvMassPtZM[iCut]);
640 
641  }
642 
643  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
644 
645 
647  collisionSystem,centMin,centMax,
648  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents(),
649  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseTrackMultiplicity(),
650  2,8,7);
651 
652  }
653  }
654  }
655 }
656 //________________________________________________________________________
658 
659  // Create histograms
660  if(fOutputContainer != NULL){
661  delete fOutputContainer;
662  fOutputContainer = NULL;
663  }
664  if(fOutputContainer == NULL){
665  fOutputContainer = new TList();
666  fOutputContainer->SetOwner(kTRUE);
667  }
668 
669  // Array of current cut's gammas
670  fGammaCandidates = new TList();
671  fClusterCandidates = new TList();
672  fClusterCandidates->SetOwner(kTRUE);
674  fVirtualGammaCandidates->SetOwner(kTRUE);
675 
676  fCutFolder = new TList*[fnCuts];
677  fESDList = new TList*[fnCuts];
678  fBackList = new TList*[fnCuts];
679  fMotherList = new TList*[fnCuts];
680  fHistoNEvents = new TH1I*[fnCuts];
685  fHistoNV0Tracks = new TH1I*[fnCuts];
686  fProfileEtaShift = new TProfile*[fnCuts];
687  fHistoConvGammaPt = new TH1F*[fnCuts];
688 
689  if (fDoPhotonQA == 2){
690  fPhotonDCAList = new TList*[fnCuts];
691 
692  }
693  if (fDoPhotonQA > 0){
694  fHistoConvGammaR = new TH1F*[fnCuts];
695  fHistoConvGammaEta = new TH1F*[fnCuts];
696  }
697 
698  fHistoDalitzElectronPt = new TH1F*[fnCuts];
699  fHistoDalitzPositronPt = new TH1F*[fnCuts];
700  fHistoDalitzElectronPhi = new TH1F*[fnCuts];
701  fHistoDalitzPositronPhi = new TH1F*[fnCuts];
702 
703 
704  if(fDoMesonAnalysis){
709  if (fDoMesonQA > 0){
719  }
720  if(fDoMesonQA == 1){
723  }
724  }
725 
727  fHistoClusGammaPt = new TH1F*[fnCuts];
729 
730  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
731  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
732  TString cutstringPhoton = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
733  TString cutstringElectron = ((AliDalitzElectronCuts*)fElectronCutArray->At(iCut))->GetCutNumber();
734  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
735  TString cutstringMeson = "NoMesonCut";
736  if(fDoMesonAnalysis)cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
737 
738  fCutFolder[iCut] = new TList();
739  fCutFolder[iCut]->SetName(Form("Cut Number %s_%s_%s_%s_%s",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringElectron.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
740  fCutFolder[iCut]->SetOwner(kTRUE);
741  fOutputContainer->Add(fCutFolder[iCut]);
742  fESDList[iCut] = new TList();
743  fESDList[iCut]->SetName(Form("%s_%s_%s_%s_%s ESD histograms", cutstringEvent.Data(),cutstringPhoton.Data(),cutstringElectron.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
744  fESDList[iCut]->SetOwner(kTRUE);
745  fCutFolder[iCut]->Add(fESDList[iCut]);
746 
747  fHistoNEvents[iCut] = new TH1I("NEvents","NEvents",14,-0.5,13.5);
748  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
749  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
750  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Missing MC");
751  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
752  TString TriggerNames = "Not Trigger: ";
753  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
754  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
755  } else {
756  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
757  }
758  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
759  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
760  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
761  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
762  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
763  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
764  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
765  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
766  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
767  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
768  fESDList[iCut]->Add(fHistoNEvents[iCut]);
769 
770  if(fIsHeavyIon == 1) fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",4000,0,4000);
771  else if(fIsHeavyIon == 2) fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",400,0,400);
772  else fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
773  fHistoNGoodESDTracks[iCut]->SetXTitle("# TPC tracks");
774  fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
775 
776  if(fIsHeavyIon == 1) fHistoNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",100,0,100);
777  else if(fIsHeavyIon == 2) fHistoNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",50,0,50);
778  else fHistoNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",50,0,50);
779  fHistoNGammaCandidates[iCut]->SetXTitle("# accepted $#gamma_{conv}");
780  fESDList[iCut]->Add(fHistoNGammaCandidates[iCut]);
781 
782  if(fIsHeavyIon == 1) fHistoNGoodESDTracksVsNGammaCanditates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",4000,0,4000,100,0,100);
783  else if(fIsHeavyIon == 2) fHistoNGoodESDTracksVsNGammaCanditates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",400,0,400,50,0,50);
784  else fHistoNGoodESDTracksVsNGammaCanditates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",200,0,200,50,0,50);
785  fHistoNGoodESDTracksVsNGammaCanditates[iCut]->SetXTitle("# TPC tracks");
786  fHistoNGoodESDTracksVsNGammaCanditates[iCut]->SetYTitle("# accepted $#gamma_{calo}");
788 
789  fHistoSPDClusterTrackletBackground[iCut] = new TH2F("SPD tracklets vs SPD clusters","SPD tracklets vs SPD clusters",100,0,200,250,0,1000);
791 
792  if(fIsHeavyIon == 1) fHistoNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",30000,0,30000);
793  else if(fIsHeavyIon == 2) fHistoNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",2500,0,2500);
794  else fHistoNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",1500,0,1500);
795  fHistoNV0Tracks[iCut]->SetXTitle("VZERO amp [arb. units]");
796  fESDList[iCut]->Add(fHistoNV0Tracks[iCut]);
797  fProfileEtaShift[iCut] = new TProfile("Eta Shift","Eta Shift",1, -0.5,0.5);
798  fESDList[iCut]->Add(fProfileEtaShift[iCut]);
799  fHistoConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt","ESD_ConvGamma_Pt",250,0,25);
800  fHistoConvGammaPt[iCut]->SetXTitle("p_{T,conv} (GeV/c)");
801  fESDList[iCut]->Add(fHistoConvGammaPt[iCut]);
802 
803  if (fDoPhotonQA == 2){
804  fPhotonDCAList[iCut] = new TList();
805  fPhotonDCAList[iCut]->SetName(Form("%s_%s_%s_%s Photon DCA tree",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
806  fPhotonDCAList[iCut]->SetOwner(kTRUE);
807  fCutFolder[iCut]->Add(fPhotonDCAList[iCut]);
808 
809 
810  }
811 
812  if (fDoPhotonQA > 0){
813  fHistoConvGammaR[iCut] = new TH1F("ESD_ConvGamma_R","ESD_ConvGamma_R",800,0,200);
814  fHistoConvGammaR[iCut]->SetXTitle("R_{conv} (cm)");
815  fESDList[iCut]->Add(fHistoConvGammaR[iCut]);
816  fHistoConvGammaEta[iCut] = new TH1F("ESD_ConvGamma_Eta","ESD_ConvGamma_Eta",2000,-2,2);
817  fHistoConvGammaEta[iCut]->SetXTitle("#eta_{conv}");
818  fESDList[iCut]->Add(fHistoConvGammaEta[iCut]);
819  }
820 
821 
822 
823 
824 
825  fHistoDalitzElectronPt[iCut] = new TH1F("ESD_DalitzElectron_Pt","ESD_DalitzElectron_Pt",1000,0,25);
826  fESDList[iCut]->Add(fHistoDalitzElectronPt[iCut]);
827 
828  fHistoDalitzPositronPt[iCut] = new TH1F("ESD_DalitzPositron_Pt","ESD_DalitzPositron_Pt",1000,0,25);
829  fESDList[iCut]->Add(fHistoDalitzPositronPt[iCut]);
830 
831  fHistoDalitzElectronPhi[iCut] = new TH1F("ESD_DalitzElectron_Phi","ESD_DalitzElectron_Phi",360,0,2*TMath::Pi());
832  fESDList[iCut]->Add(fHistoDalitzElectronPhi[iCut]);
833 
834  fHistoDalitzPositronPhi[iCut] = new TH1F("ESD_DalitzPositron_Phi","ESD_DalitzPositron_Phi",360,0,2*TMath::Pi());
835  fESDList[iCut]->Add(fHistoDalitzPositronPhi[iCut]);
836 
837 
838 
839 
840 
841 
842 
843  fClusterOutputList[iCut] = new TList();
844  fClusterOutputList[iCut]->SetName(Form("%s_%s_%s_%s_%s Cluster Output",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringElectron.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
845  fClusterOutputList[iCut]->SetOwner(1);
846  fCutFolder[iCut]->Add(fClusterOutputList[iCut]);
847 
848  fHistoClusGammaPt[iCut] = new TH1F("ClusGamma_Pt","ClusGamma_Pt",250,0,25);
849  fHistoClusGammaPt[iCut]->SetXTitle("p_{T,clus} (GeV/c)");
850  fClusterOutputList[iCut]->Add(fHistoClusGammaPt[iCut]);
851  fHistoClusOverlapHeadersGammaPt[iCut] = new TH1F("ClusGammaOverlapHeaders_Pt","ClusGammaOverlapHeaders_Pt",250,0,25);
852  fHistoClusOverlapHeadersGammaPt[iCut]->SetXTitle("p_{T,clus} (GeV/c), selected header w/ overlap");
854 
855  if(fDoMesonAnalysis){
856 
857  fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",800,0,0.8,250,0,25);
858  fHistoMotherInvMassPt[iCut]->SetXTitle("M_{inv} (GeV/c^{2})");
859  fHistoMotherInvMassPt[iCut]->SetYTitle("p_{T,pair} (GeV/c)");
860  fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
861 
862  fHistoMotherMatchedInvMassPt[iCut] = new TH2F("ESD_MotherMatched_InvMass_Pt","ESD_MotherMatched_InvMass_Pt",800,0,0.8,250,0,25);
863  fHistoMotherMatchedInvMassPt[iCut]->SetXTitle("M_{inv} (GeV/c^{2}) matched conv e^{+/-} to cluster");
864  fHistoMotherMatchedInvMassPt[iCut]->SetYTitle("p_{T,pair} (GeV/c)");
865  fESDList[iCut]->Add(fHistoMotherMatchedInvMassPt[iCut]);
866 
867  fHistoMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt","ESD_Background_InvMass_Pt",800,0,0.8,250,0,25);
868  fHistoMotherBackInvMassPt[iCut]->SetXTitle("M_{inv, mxed} (GeV/c^{2})");
869  fHistoMotherBackInvMassPt[iCut]->SetYTitle("p_{T,BG pair} (GeV/c)");
870  fESDList[iCut]->Add(fHistoMotherBackInvMassPt[iCut]);
871 
872  fHistoMotherInvMassEalpha[iCut] = new TH2F("ESD_Mother_InvMass_vs_E_alpha","ESD_Mother_InvMass_vs_E_alpha",800,0,0.8,250,0,25);
873  fHistoMotherInvMassEalpha[iCut]->SetXTitle("M_{inv} (GeV/c^{2})");
874  fHistoMotherInvMassEalpha[iCut]->SetYTitle("p_{T,pair} (GeV/c)");
875  fESDList[iCut]->Add(fHistoMotherInvMassEalpha[iCut]);
876 
877  if( fDoMesonQA > 0 ) {
878  fHistoMotherInvMassOpeningAngleGammaElectron[iCut] = new TH1F("ESD_MotherInvMass_OpeningAngle_GammaElectron", "ESD_MotherInvMass_OpeningAngle_GammaElectron",100,0.,TMath::Pi());
880  }
881 
882  }
883  }
884 
885  if(fDoMesonAnalysis){
886  InitBack(); // Init Background Handler
887  }
888 
889  if(fIsMC){
890  // MC Histogramms
891  fMCList = new TList*[fnCuts];
892  // True Histogramms
893  fTrueList = new TList*[fnCuts];
894  // Selected Header List
895  fHeaderNameList = new TList*[fnCuts];
896  fHistoMCHeaders = new TH1I*[fnCuts];
897  fHistoMCAllGammaPt = new TH1F*[fnCuts];
898  fHistoMCAllGammaPi0Pt = new TH1F*[fnCuts];
899  fHistoMCAllGammaEMCALAccPt = new TH1F*[fnCuts];
900  fHistoMCDecayGammaPi0Pt = new TH1F*[fnCuts];
901  fHistoMCDecayGammaRhoPt = new TH1F*[fnCuts];
902  fHistoMCDecayGammaEtaPt = new TH1F*[fnCuts];
903  fHistoMCDecayGammaOmegaPt = new TH1F*[fnCuts];
904  fHistoMCDecayGammaEtapPt = new TH1F*[fnCuts];
905  fHistoMCDecayGammaPhiPt = new TH1F*[fnCuts];
906  fHistoMCDecayGammaSigmaPt = new TH1F*[fnCuts];
907  fHistoMCConvGammaPt = new TH1F*[fnCuts];
908  fHistoMCAllPositronsPt = new TH1F*[fnCuts];
909  fHistoMCDecayPositronPi0Pt = new TH1F*[fnCuts];
910  fHistoMCAllElectronsPt = new TH1F*[fnCuts];
911  fHistoMCDecayElectronPi0Pt = new TH1F*[fnCuts];
916 
917 
918  fHistoTrueConvGammaPt = new TH1F*[fnCuts];
920  fHistoTrueConvPi0GammaPt = new TH1F*[fnCuts];
921  fHistoTruePositronPt = new TH1F*[fnCuts];
922  fHistoTrueElectronPt = new TH1F*[fnCuts];
923  fHistoTrueSecPositronPt = new TH1F*[fnCuts];
924  fHistoTrueSecElectronPt = new TH1F*[fnCuts];
929 
930 
931 
932 
938 
939  fHistoTrueClusGammaPt = new TH1F*[fnCuts];
942 
946 
947  if (fDoPhotonQA > 0){
948 
949  fHistoMCConvGammaR = new TH1F*[fnCuts];
950  fHistoMCConvGammaEta = new TH1F*[fnCuts];
951  fHistoTrueConvGammaEta = new TH1F*[fnCuts];
952 
953  }
954 
955 
956  if (fDoClusterQA > 0){
957 
958  fHistoTrueClusUnConvGammaPt = new TH1F*[fnCuts];
960  fHistoTrueClusElectronPt = new TH1F*[fnCuts];
961  fHistoTrueClusConvGammaPt = new TH1F*[fnCuts];
962  fHistoTrueClusConvGammaMCPt = new TH1F*[fnCuts];
964  fHistoTrueClusMergedGammaPt = new TH1F*[fnCuts];
966  fHistoTrueClusDalitzPt = new TH1F*[fnCuts];
969  fHistoTrueClusShowerPt = new TH1F*[fnCuts];
970  fHistoTrueClusSubLeadingPt = new TH1F*[fnCuts];
973  fHistoTrueNLabelsInClus = new TH1F*[fnCuts];
974  }
975 
976 
977  if(fDoMesonAnalysis){
978 
979  fHistoMCPi0GGPt = new TH1F*[fnCuts];
980  fHistoMCPi0GGWOWeightPt = new TH1F*[fnCuts];
981  fHistoMCPi0Pt = new TH1F*[fnCuts];
982  fHistoMCPi0WOWeightPt = new TH1F*[fnCuts];
983 
984  fHistoMCEtaGGPt = new TH1F*[fnCuts];
985  fHistoMCEtaGGWOWeightPt = new TH1F*[fnCuts];
986  fHistoMCEtaPt = new TH1F*[fnCuts];
987  fHistoMCEtaWOWeightPt = new TH1F*[fnCuts];
988 
989  fHistoMCPi0InAccPt = new TH1F*[fnCuts];
990 
991  fHistoMCEtaInAccPt = new TH1F*[fnCuts];
992 
1015  fHistoTruePrimaryPi0DCPtconv = new TH1F*[fnCuts];
1017  fHistoTruePrimaryEtaDCPtconv = new TH1F*[fnCuts];
1023 
1024 
1025  if (fDoMesonQA > 0){
1026 
1027  fHistoMCPi0PtY = new TH2F*[fnCuts];
1028  fHistoMCEtaPtY = new TH2F*[fnCuts];
1029  fHistoMCPi0PtAlpha = new TH2F*[fnCuts];
1030  fHistoMCEtaPtAlpha = new TH2F*[fnCuts];
1031  fHistoMCK0sPt = new TH1F*[fnCuts];
1032  fHistoMCK0sWOWeightPt = new TH1F*[fnCuts];
1033  fHistoMCK0sPtY = new TH2F*[fnCuts];
1054  fHistoTruePi0PtY = new TH2F*[fnCuts];
1055  fHistoTrueEtaPtY = new TH2F*[fnCuts];
1068 
1069  }
1070  }
1071 
1072  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1073 
1074  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
1075  TString cutstringPhoton = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
1076  TString cutstringElectron = ((AliDalitzElectronCuts*)fElectronCutArray->At(iCut))->GetCutNumber();
1077  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
1078  TString cutstringMeson = "NoMesonCut";
1079  if(fDoMesonAnalysis)cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
1080 
1081  fMCList[iCut] = new TList();
1082  fMCList[iCut]->SetName(Form("%s_%s_%s_%s_%s MC histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringElectron.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
1083  fMCList[iCut]->SetOwner(kTRUE);
1084  fCutFolder[iCut]->Add(fMCList[iCut]);
1085  fHistoMCHeaders[iCut] = new TH1I("MC_Headers","MC_Headers",20,0,20);
1086  fMCList[iCut]->Add(fHistoMCHeaders[iCut]);
1087  fHistoMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt","MC_AllGamma_Pt",250,0,25);
1088  fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);
1089 
1090  fHistoMCAllGammaPi0Pt[iCut] = new TH1F("MC_AllGammaPi0_Pt","MC_AllGammaPi0_Pt",250,0,25);
1091  fMCList[iCut]->Add(fHistoMCAllGammaPi0Pt[iCut]);
1092 
1093  fHistoMCAllGammaEMCALAccPt[iCut] = new TH1F("MC_AllGammaEMCALAcc_Pt","MC_AllGammaEMCALAcc_Pt",250,0,25);
1094  fMCList[iCut]->Add(fHistoMCAllGammaEMCALAccPt[iCut]);
1095  fHistoMCDecayGammaPi0Pt[iCut] = new TH1F("MC_DecayGammaPi0_Pt","MC_DecayGammaPi0_Pt",250,0,25);
1096  fMCList[iCut]->Add(fHistoMCDecayGammaPi0Pt[iCut]);
1097  fHistoMCDecayGammaRhoPt[iCut] = new TH1F("MC_DecayGammaRho_Pt","MC_DecayGammaRho_Pt",250,0,25);
1098  fMCList[iCut]->Add(fHistoMCDecayGammaRhoPt[iCut]);
1099  fHistoMCDecayGammaEtaPt[iCut] = new TH1F("MC_DecayGammaEta_Pt","MC_DecayGammaEta_Pt",250,0,25);
1100  fMCList[iCut]->Add(fHistoMCDecayGammaEtaPt[iCut]);
1101  fHistoMCDecayGammaOmegaPt[iCut] = new TH1F("MC_DecayGammaOmega_Pt","MC_DecayGammaOmmega_Pt",250,0,25);
1102  fMCList[iCut]->Add(fHistoMCDecayGammaOmegaPt[iCut]);
1103  fHistoMCDecayGammaEtapPt[iCut] = new TH1F("MC_DecayGammaEtap_Pt","MC_DecayGammaEtap_Pt",250,0,25);
1104  fMCList[iCut]->Add(fHistoMCDecayGammaEtapPt[iCut]);
1105  fHistoMCDecayGammaPhiPt[iCut] = new TH1F("MC_DecayGammaPhi_Pt","MC_DecayGammaPhi_Pt",250,0,25);
1106  fMCList[iCut]->Add(fHistoMCDecayGammaPhiPt[iCut]);
1107  fHistoMCDecayGammaSigmaPt[iCut] = new TH1F("MC_DecayGammaSigma_Pt","MC_DecayGammaSigma_Pt",250,0,25);
1108  fMCList[iCut]->Add(fHistoMCDecayGammaSigmaPt[iCut]);
1109  fHistoMCConvGammaPt[iCut] = new TH1F("MC_ConvGamma_Pt","MC_ConvGamma_Pt",250,0,25);
1110  fMCList[iCut]->Add(fHistoMCConvGammaPt[iCut]);
1111 
1112  fHistoMCAllPositronsPt[iCut] = new TH1F("MC_AllPositrons_Pt","MC_AllPositrons_Pt",1000,0,25);
1113  fMCList[iCut]->Add(fHistoMCAllPositronsPt[iCut]);
1114 
1115 
1116  fHistoMCDecayPositronPi0Pt[iCut] = new TH1F("MC_DecayPositronPi0_Pt","MC_DecayPositronPi0_Pt",1000,0,25);
1117  fMCList[iCut]->Add(fHistoMCDecayPositronPi0Pt[iCut]);
1118 
1119  fHistoMCAllElectronsPt[iCut] = new TH1F("MC_AllElectrons_Pt","MC_AllElectrons_Pt",1000,0,25);
1120  fMCList[iCut]->Add(fHistoMCAllElectronsPt[iCut]);
1121 
1122  fHistoMCDecayElectronPi0Pt[iCut] = new TH1F("MC_DecayElectronPi0_Pt","MC_DecayElectronPi0_Pt",1000,0,25);
1123  fMCList[iCut]->Add(fHistoMCDecayElectronPi0Pt[iCut]);
1124 
1125  fHistoMCDecayNoPrimElectronPi0DalitzR[iCut] = new TH1F("MC_DecayNoPrimElectronPi0Dalitz_R","MC_DecayNoPrimElectronPi0Dalitz_R",200,0,200);
1127 
1128  fHistoMCDecayNoPrimPositronPi0DalitzR[iCut] = new TH1F("MC_DecayNoPrimPositronPi0Dalitz_R","MC_DecayNoPrimPositronPi0Dalitz_R",200,0,200);
1130 
1131  fHistoMCDecayNoPrimElectronPi0DalitzID[iCut] = new TH1F("MC_DecayNoPrimElectronPi0Dalitz_ID","MC_DecayNoPrimElectronPi0Dalitz_ID",51,-1,50);
1133 
1134  fHistoMCDecayNoPrimPositronPi0DalitzID[iCut] = new TH1F("MC_DecayNoPrimPositronPi0Dalitz_ID","MC_DecayNoPrimPositronPi0Dalitz_ID",51,-1,50);
1136 
1137 
1138 
1139  if (fDoPhotonQA > 0){
1140 
1141  fHistoMCConvGammaR[iCut] = new TH1F("MC_ConvGamma_R","MC_ConvGamma_R",800,0,200);
1142  fMCList[iCut]->Add(fHistoMCConvGammaR[iCut]);
1143  fHistoMCConvGammaEta[iCut] = new TH1F("MC_ConvGamma_Eta","MC_ConvGamma_Eta",2000,-2,2);
1144  fMCList[iCut]->Add(fHistoMCConvGammaEta[iCut]);
1145 
1146  }
1147 
1148  if(fDoMesonAnalysis){
1149 
1150  fHistoMCPi0GGPt[iCut] = new TH1F("MC_Pi0_GG_Pt","MC_Pi0_GG_Pt",250,0,25);
1151  fHistoMCPi0GGPt[iCut]->Sumw2();
1152  fMCList[iCut]->Add(fHistoMCPi0GGPt[iCut]);
1153  fHistoMCPi0GGWOWeightPt[iCut] = new TH1F("MC_Pi0_GG_WOWeights_Pt","MC_Pi0_GG_WOWeights_Pt",250,0,25);
1154  fHistoMCPi0GGWOWeightPt[iCut]->Sumw2();
1155  fMCList[iCut]->Add(fHistoMCPi0GGWOWeightPt[iCut]);
1156 
1157  fHistoMCPi0Pt[iCut] = new TH1F("MC_Pi0_Pt","MC_Pi0_Pt",250,0,25);
1158  fHistoMCPi0Pt[iCut]->Sumw2();
1159 
1160  fMCList[iCut]->Add(fHistoMCPi0Pt[iCut]);
1161  fHistoMCPi0WOWeightPt[iCut] = new TH1F("MC_Pi0_WOWeights_Pt","MC_Pi0_WOWeights_Pt",250,0,25);
1162  fHistoMCPi0WOWeightPt[iCut]->Sumw2();
1163  fMCList[iCut]->Add(fHistoMCPi0WOWeightPt[iCut]);
1164 
1165 
1166  fHistoMCEtaGGPt[iCut] = new TH1F("MC_Eta_GG_Pt","MC_Eta_GG_Pt",250,0,25);
1167  fHistoMCEtaGGPt[iCut]->Sumw2();
1168  fMCList[iCut]->Add(fHistoMCEtaGGPt[iCut]);
1169  fHistoMCEtaGGWOWeightPt[iCut] = new TH1F("MC_Eta_GG_WOWeights_Pt","MC_Eta_GG_WOWeights_Pt",250,0,25);
1170  fHistoMCEtaGGWOWeightPt[iCut]->Sumw2();
1171  fMCList[iCut]->Add(fHistoMCEtaGGWOWeightPt[iCut]);
1172 
1173  fHistoMCEtaPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",250,0,25);
1174  fHistoMCEtaPt[iCut]->Sumw2();
1175  fMCList[iCut]->Add(fHistoMCEtaPt[iCut]);
1176  fHistoMCEtaWOWeightPt[iCut] = new TH1F("MC_Eta_WOWeights_Pt","MC_Eta_WOWeights_Pt",250,0,25);
1177  fHistoMCEtaWOWeightPt[iCut]->Sumw2();
1178  fMCList[iCut]->Add(fHistoMCEtaWOWeightPt[iCut]);
1179 
1180 
1181 
1182  fHistoMCPi0InAccPt[iCut] = new TH1F("MC_Pi0InAcc_Pt","MC_Pi0InAcc_Pt",250,0,25);
1183  fHistoMCPi0InAccPt[iCut]->Sumw2();
1184  fMCList[iCut]->Add(fHistoMCPi0InAccPt[iCut]);
1185  fHistoMCEtaInAccPt[iCut] = new TH1F("MC_EtaInAcc_Pt","MC_EtaInAcc_Pt",250,0,25);
1186  fHistoMCEtaInAccPt[iCut]->Sumw2();
1187  fMCList[iCut]->Add(fHistoMCEtaInAccPt[iCut]);
1188 
1189 
1190 
1191  if (fDoMesonQA > 0){
1192 
1193  fHistoMCPi0PtY[iCut] = new TH2F("MC_Pi0_Pt_Y","MC_Pi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1194  fHistoMCPi0PtY[iCut]->Sumw2();
1196  fMCList[iCut]->Add(fHistoMCPi0PtY[iCut]);
1197  fHistoMCEtaPtY[iCut] = new TH2F("MC_Eta_Pt_Y","MC_Eta_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1198  fHistoMCEtaPtY[iCut]->Sumw2();
1200  fMCList[iCut]->Add(fHistoMCEtaPtY[iCut]);
1201  fHistoMCPi0PtAlpha[iCut] = new TH2F("MC_Pi0_Pt_Alpha","MC_Pi0_Pt_Alpha",150,0.03,15.,100,0,1);
1203  fMCList[iCut]->Add(fHistoMCPi0PtAlpha[iCut]);
1204  fHistoMCEtaPtAlpha[iCut] = new TH2F("MC_Eta_Pt_Alpha","MC_Eta_Pt_Alpha",150,0.03,15.,100,0,1);
1206  fMCList[iCut]->Add(fHistoMCEtaPtAlpha[iCut]);
1207 
1208  fHistoMCK0sPt[iCut] = new TH1F("MC_K0s_Pt","MC_K0s_Pt",150,0,15);
1209  fHistoMCK0sPt[iCut]->Sumw2();
1210  fMCList[iCut]->Add(fHistoMCK0sPt[iCut]);
1211  fHistoMCK0sWOWeightPt[iCut] = new TH1F("MC_K0s_WOWeights_Pt","MC_K0s_WOWeights_Pt",150,0,15);
1212  fHistoMCK0sWOWeightPt[iCut]->Sumw2();
1213  fMCList[iCut]->Add(fHistoMCK0sWOWeightPt[iCut]);
1214  fHistoMCK0sPtY[iCut] = new TH2F("MC_K0s_Pt_Y","MC_K0s_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1215  fHistoMCK0sPtY[iCut]->Sumw2();
1217  fMCList[iCut]->Add(fHistoMCK0sPtY[iCut]);
1218 
1219  fHistoMCPi0InAccOpeningAngleGammaElectron[iCut] = new TH1F("MC_Pi0InAcc_OpeningAngle_GammaElectron","MC_Pi0InAcc_OpeningAngle_GammaElectron",100,0,TMath::Pi());
1221 
1222 
1223  }
1224 
1225  }
1226  fTrueList[iCut] = new TList();
1227  fTrueList[iCut]->SetName(Form("%s_%s_%s_%s_%s True histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringElectron.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
1228  fTrueList[iCut]->SetOwner(kTRUE);
1229  fCutFolder[iCut]->Add(fTrueList[iCut]);
1230 
1231  fHistoTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt","ESD_TrueConvGamma_Pt",250,0,25);
1232  fTrueList[iCut]->Add(fHistoTrueConvGammaPt[iCut]);
1233 
1234  fHistoDoubleCountTrueConvGammaRPt[iCut] = new TH2F("ESD_TrueDoubleCountConvGamma_R_Pt","ESD_TrueDoubleCountConvGamma_R_Pt",800,0,200,300,0,30);
1235  fTrueList[iCut]->Add(fHistoDoubleCountTrueConvGammaRPt[iCut]);
1236 
1237  fHistoTrueConvPi0GammaPt[iCut] = new TH1F("ESD_TrueConvPi0Gamma_Pt","ESD_TrueConvPi0Gamma_Pt",250,0,25);
1238  fTrueList[iCut]->Add(fHistoTrueConvPi0GammaPt[iCut]);
1239 
1240 
1241  fHistoTruePositronPt[iCut] = new TH1F("ESD_TruePositron_Pt","ESD_TruePositron_Pt",1000,0,25);
1242  fTrueList[iCut]->Add(fHistoTruePositronPt[iCut]);
1243 
1244  fHistoTrueElectronPt[iCut] = new TH1F("ESD_TrueElectron_Pt","ESD_TrueElectron_Pt",1000,0,25);
1245  fTrueList[iCut]->Add(fHistoTrueElectronPt[iCut]);
1246 
1247  fHistoTrueSecPositronPt[iCut] = new TH1F("ESD_TrueSecPositron_Pt","ESD_TrueSecPositron_Pt",1000,0,25);
1248  fTrueList[iCut]->Add(fHistoTrueSecPositronPt[iCut]);
1249 
1250  fHistoTrueSecElectronPt[iCut] = new TH1F("ESD_TrueSecElectron_Pt","ESD_TrueSecElectron_Pt",1000,0,25);
1251  fTrueList[iCut]->Add(fHistoTrueSecElectronPt[iCut]);
1252 
1253  fHistoTruePi0DalitzElectronPt[iCut] = new TH1F("ESD_TruePi0DalitzElectron_Pt","ESD_TruePi0DalitzElectron_Pt",1000,0,25);
1254  fTrueList[iCut]->Add(fHistoTruePi0DalitzElectronPt[iCut]);
1255 
1256  fHistoTruePi0DalitzPositronPt[iCut] = new TH1F("ESD_TruePi0DalitzPositron_Pt","ESD_TruePi0DalitzPositron_Pt",1000,0,25);
1257  fTrueList[iCut]->Add(fHistoTruePi0DalitzPositronPt[iCut]);
1258 
1259  fHistoTruePi0DalitzSecElectronPt[iCut] = new TH1F("ESD_TruePi0DalitzSecElectron_Pt","ESD_TruePi0DalitzSecElectron_Pt",1000,0,25);
1260  fTrueList[iCut]->Add(fHistoTruePi0DalitzSecElectronPt[iCut]);
1261 
1262  fHistoTruePi0DalitzSecPositronPt[iCut] = new TH1F("ESD_TruePi0DalitzSecPositron_Pt","ESD_TruePi0DalitzSecPositron_Pt",1000,0,25);
1263  fTrueList[iCut]->Add(fHistoTruePi0DalitzSecPositronPt[iCut]);
1264 
1265 
1266 
1267  fHistoTruePrimaryConvGammaPt[iCut] = new TH1F("ESD_TruePrimaryConvGamma_Pt","ESD_TruePrimaryConvGamma_Pt",250,0,25);
1268  fTrueList[iCut]->Add(fHistoTruePrimaryConvGammaPt[iCut]);
1269  fHistoTrueSecondaryConvGammaPt[iCut] = new TH1F("ESD_TrueSecondaryConvGamma_Pt","ESD_TrueSecondaryConvGamma_Pt",250,0,25);
1270  fTrueList[iCut]->Add(fHistoTrueSecondaryConvGammaPt[iCut]);
1271 
1272  fHistoTrueSecondaryConvGammaFromXFromK0sPt[iCut] = new TH1F("ESD_TrueSecondaryConvGammaFromXFromK0s_Pt", "ESD_TrueSecondaryConvGammaFromXFromK0s_Pt",250,0,25);
1274  fHistoTrueSecondaryConvGammaFromXFromLambdaPt[iCut] = new TH1F("ESD_TrueSecondaryConvGammaFromXFromLambda_Pt", "ESD_TrueSecondaryConvGammaFromXFromLambda_Pt",250,0,25);
1276 
1277  fHistoTruePrimaryConvGammaESDPtMCPt[iCut] = new TH2F("ESD_TruePrimaryConvGammaESD_PtMCPt", "ESD_TruePrimaryConvGammaESD_PtMCPt",250,0,25,250,0,25);
1279 
1280  fHistoTrueClusGammaPt[iCut] = new TH1F("TrueClusGamma_Pt","ESD_TrueClusGamma_Pt",250,0,25);
1281  fClusterOutputList[iCut]->Add(fHistoTrueClusGammaPt[iCut]);
1282  fHistoTruePrimaryClusGammaPt[iCut] = new TH1F("TruePrimaryClusGamma_Pt","ESD_TruePrimaryClusGamma_Pt",250,0,25);
1284  fHistoTruePrimaryClusGammaESDPtMCPt[iCut] = new TH2F("TruePrimaryClusGamma_Pt_MCPt","ESD_TruePrimaryClusGamma_MCPt",250,0,25,250,0,25);
1286 
1287  fHistoTruePi0DalitzClusGammaPt[iCut] = new TH1F("TruePi0DalitzClusGamma_Pt","fHistoTruePi0DalitzClusGamma_Pt",250,0,25);
1289 
1290  fHistoTruePi0DalitzClusGammaMCPt[iCut]= new TH1F("TruePi0DalitzClusGamma_MCPt","fHistoTruePi0DalitzClusGamma_MCPt",250,0,25);
1292 
1293 
1294  fHistoTruePi0DalitzAllClusGammaPt[iCut] = new TH1F("TruePi0DalitzAllClusGamma_Pt","TruePi0DalitzAllClusGamma_Pt",250,0,25);
1296 
1297 
1298 
1299 
1300  if (fDoPhotonQA > 0){
1301  fHistoTrueConvGammaEta[iCut] = new TH1F("ESD_TrueConvGamma_Eta","ESD_TrueConvGamma_Eta",2000,-2,2);
1302  fTrueList[iCut]->Add(fHistoTrueConvGammaEta[iCut]);
1303  }
1304  if (fDoClusterQA > 0){
1305  fHistoTrueClusUnConvGammaPt[iCut] = new TH1F("TrueClusUnConvGamma_Pt","TrueClusUnConvGamma_Pt",250,0,25);
1307  fHistoTrueClusUnConvGammaMCPt[iCut] = new TH1F("TrueClusUnConvGamma_MCPt","TrueClusUnConvGamma_MCPt",250,0,25);
1309  fHistoTrueClusElectronPt[iCut] = new TH1F("TrueClusElectron_Pt","TrueElectronGamma_Pt",250,0,25);
1310  fClusterOutputList[iCut]->Add(fHistoTrueClusElectronPt[iCut]);
1311  fHistoTrueClusConvGammaPt[iCut] = new TH1F("TrueClusConvGamma_Pt","TrueClusConvGamma_Pt",250,0,25);
1313  fHistoTrueClusConvGammaMCPt[iCut] = new TH1F("TrueClusConvGamma_MCPt","TrueClusConvGamma_MCPt",250,0,25);
1315  fHistoTrueClusConvGammaFullyPt[iCut] = new TH1F("TrueClusConvGammaFullyContained_Pt","TrueClusConvGammaFullyContained_Pt",250,0,25);
1317  fHistoTrueClusMergedGammaPt[iCut] = new TH1F("TrueClusMergedGamma_Pt","TrueClusMergedGamma_Pt",250,0,25);
1319  fHistoTrueClusMergedPartConvGammaPt[iCut] = new TH1F("TrueClusMergedPartConvGamma_Pt","TrueClusMergedPartConvGamma_Pt",250,0,25);
1321  fHistoTrueClusDalitzPt[iCut] = new TH1F("TrueClusDalitz_Pt","TrueClusDalitz_Pt",250,0,25);
1322  fClusterOutputList[iCut]->Add(fHistoTrueClusDalitzPt[iCut]);
1323  fHistoTrueClusDalitzMergedPt[iCut] = new TH1F("TrueClusDalitzMerged_Pt","TrueClusDalitzMerged_Pt",250,0,25);
1325  fHistoTrueClusPhotonFromElecMotherPt[iCut] = new TH1F("TrueClusPhotonFromElecMother_Pt","TrueClusPhotonFromElecMother_Pt",250,0,25);
1327  fHistoTrueClusShowerPt[iCut] = new TH1F("TrueClusShower_Pt","TrueClusShower_Pt",250,0,25);
1328  fClusterOutputList[iCut]->Add(fHistoTrueClusShowerPt[iCut]);
1329  fHistoTrueClusSubLeadingPt[iCut] = new TH1F("TrueClusSubleading_Pt","TrueClusSubleading_Pt",250,0,25);
1331  fHistoTrueClusNParticles[iCut] = new TH1I("TrueClusNParticles","TrueClusNParticles",20,0,20);
1332  fClusterOutputList[iCut]->Add(fHistoTrueClusNParticles[iCut]);
1333  fHistoTrueClusEMNonLeadingPt[iCut] = new TH1F("TrueClusEMNonLeading_Pt","TrueClusEMNonLeading_Pt",250,0,25);
1335  fHistoTrueNLabelsInClus[iCut] = new TH1F("TrueNLabelsInClus","TrueNLabelsInClus",100,-0.5,99.5);
1336  fClusterOutputList[iCut]->Add(fHistoTrueNLabelsInClus[iCut]);
1337  }
1338 
1339  if(fDoMesonAnalysis){
1340  fHistoTruePi0InvMassPt[iCut] = new TH2F("ESD_TruePi0_InvMass_Pt","ESD_TruePi0_InvMass_Pt",800,0,0.8,250,0,25);
1341  fHistoTruePi0InvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2})");
1342  fHistoTruePi0InvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1343  fTrueList[iCut]->Add(fHistoTruePi0InvMassPt[iCut]);
1344 
1345  fHistoTrueEtaInvMassPt[iCut] = new TH2F("ESD_TrueEta_InvMass_Pt","ESD_TrueEta_InvMass_Pt",800,0,0.8,250,0,25);
1346  fHistoTrueEtaInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2})");
1347  fHistoTrueEtaInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1348  fTrueList[iCut]->Add(fHistoTrueEtaInvMassPt[iCut]);
1349 
1350  fHistoDoubleCountTruePi0InvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountPi0_InvMass_Pt","ESD_TrueDoubleCountPi0_InvMass_Pt",800,0,0.8,300,0,30);
1351  fTrueList[iCut]->Add(fHistoDoubleCountTruePi0InvMassPt[iCut]);
1352  fHistoDoubleCountTrueEtaInvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountEta_InvMass_Pt","ESD_TrueDoubleCountEta_InvMass_Pt",800,0,0.8,300,0,30);
1353  fTrueList[iCut]->Add(fHistoDoubleCountTrueEtaInvMassPt[iCut]);
1354 
1355  fHistoTruePi0GGInvMassPt[iCut] = new TH2F("ESD_TruePi0GG_InvMass_Pt","ESD_TruePi0GG_InvMass_Pt",800,0,0.8,250,0,25);
1356  fHistoTruePi0GGInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2})");
1357  fHistoTruePi0GGInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1358  fTrueList[iCut]->Add(fHistoTruePi0GGInvMassPt[iCut]);
1359 
1360  fHistoTrueEtaGGInvMassPt[iCut] = new TH2F("ESD_TrueEtaGG_InvMass_Pt","ESD_TrueEtaGG_InvMass_Pt",800,0,0.8,250,0,25);
1361  fHistoTrueEtaGGInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2})");
1362  fHistoTrueEtaGGInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1363  fTrueList[iCut]->Add(fHistoTrueEtaGGInvMassPt[iCut]);
1364 
1365 
1366 
1367  fHistoTruePrimaryPi0InvMassPt[iCut] = new TH2F("ESD_TruePrimaryPi0_InvMass_Pt", "ESD_TruePrimaryPi0_InvMass_Pt", 800,0,0.8,250,0,25);
1368  fHistoTruePrimaryPi0InvMassPt[iCut]->SetXTitle("M_{inv,prim #pi^{0}} (GeV/c^{2})");
1369  fHistoTruePrimaryPi0InvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1370  fHistoTruePrimaryPi0InvMassPt[iCut]->Sumw2();
1371  fTrueList[iCut]->Add(fHistoTruePrimaryPi0InvMassPt[iCut]);
1372 
1373 
1374  fHistoTruePrimaryPi0GGInvMassPt[iCut] = new TH2F("ESD_TruePrimaryPi0GG_InvMass_Pt", "ESD_TruePrimaryPi0GG_InvMass_Pt", 800,0,0.8,250,0,25);
1375  fHistoTruePrimaryPi0GGInvMassPt[iCut]->SetXTitle("M_{inv,prim #pi^{0}} (GeV/c^{2})");
1376  fHistoTruePrimaryPi0GGInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1377  fHistoTruePrimaryPi0GGInvMassPt[iCut]->Sumw2();
1378  fTrueList[iCut]->Add(fHistoTruePrimaryPi0GGInvMassPt[iCut]);
1379 
1380 
1381  fHistoTruePrimaryEtaInvMassPt[iCut] = new TH2F("ESD_TruePrimaryEta_InvMass_Pt", "ESD_TruePrimaryEta_InvMass_Pt", 800,0,0.8,250,0,25);
1382  fHistoTruePrimaryEtaInvMassPt[iCut]->SetXTitle("M_{inv,prim #eta} (GeV/c^{2})");
1383  fHistoTruePrimaryEtaInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1384  fHistoTruePrimaryEtaInvMassPt[iCut]->Sumw2();
1385  fTrueList[iCut]->Add(fHistoTruePrimaryEtaInvMassPt[iCut]);
1386 
1387  fHistoTruePrimaryEtaGGInvMassPt[iCut] = new TH2F("ESD_TruePrimaryEtaGG_InvMass_Pt", "ESD_TruePrimaryEtaGG_InvMass_Pt", 800,0,0.8,250,0,25);
1388  fHistoTruePrimaryEtaGGInvMassPt[iCut]->SetXTitle("M_{inv,prim #eta} (GeV/c^{2})");
1389  fHistoTruePrimaryEtaGGInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1390  fHistoTruePrimaryEtaGGInvMassPt[iCut]->Sumw2();
1391  fTrueList[iCut]->Add(fHistoTruePrimaryEtaGGInvMassPt[iCut]);
1392 
1393 
1394  fHistoTruePrimaryPi0W0WeightingInvMassPt[iCut] = new TH2F("ESD_TruePrimaryPi0W0Weights_InvMass_Pt", "ESD_TruePrimaryPi0W0Weights_InvMass_Pt", 800,0,0.8,250,0,25);
1395  fHistoTruePrimaryPi0W0WeightingInvMassPt[iCut]->SetXTitle("M_{inv,prim #pi^{0}} (GeV/c^{2})");
1396  fHistoTruePrimaryPi0W0WeightingInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1398 
1399  fHistoTruePrimaryEtaW0WeightingInvMassPt[iCut] = new TH2F("ESD_TruePrimaryEtaW0Weights_InvMass_Pt", "ESD_TruePrimaryEtaW0Weights_InvMass_Pt", 800,0,0.8,250,0,25);
1400  fHistoTruePrimaryEtaW0WeightingInvMassPt[iCut]->SetXTitle("M_{inv,prim #eta} (GeV/c^{2})");
1401  fHistoTruePrimaryEtaW0WeightingInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1403 
1404  fProfileTruePrimaryPi0WeightsInvMassPt[iCut] = new TProfile2D("ESD_TruePrimaryPi0Weights_InvMass_Pt", "ESD_TruePrimaryPi0Weights_InvMass_Pt", 800,0,0.8,250,0,25);
1405  fProfileTruePrimaryPi0WeightsInvMassPt[iCut]->SetXTitle("M_{inv,prim #pi^{0}} (GeV/c^{2})");
1406  fProfileTruePrimaryPi0WeightsInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1409  fProfileTruePrimaryEtaWeightsInvMassPt[iCut] = new TProfile2D("ESD_TruePrimaryEtaWeights_InvMass_Pt", "ESD_TruePrimaryEtaWeights_InvMass_Pt", 800,0,0.8,250,0,25);
1410  fProfileTruePrimaryEtaWeightsInvMassPt[iCut]->SetXTitle("M_{inv,prim #eta} (GeV/c^{2})");
1411  fProfileTruePrimaryEtaWeightsInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1414 
1415  fHistoTrueSecondaryPi0InvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0_InvMass_Pt", "ESD_TrueSecondaryPi0_InvMass_Pt", 800,0,0.8,250,0,25);
1416  fHistoTrueSecondaryPi0InvMassPt[iCut]->SetXTitle("M_{inv,sec #pi^{0}} (GeV/c^{2})");
1417  fHistoTrueSecondaryPi0InvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1418  fHistoTrueSecondaryPi0InvMassPt[iCut]->Sumw2();
1419  fTrueList[iCut]->Add(fHistoTrueSecondaryPi0InvMassPt[iCut]);
1420 
1421 
1422  fHistoTrueSecondaryPi0GGInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0GG_InvMass_Pt", "ESD_TrueSecondaryPi0GG_InvMass_Pt", 800,0,0.8,250,0,25);
1423  fHistoTrueSecondaryPi0GGInvMassPt[iCut]->SetXTitle("M_{inv,sec #pi^{0}} (GeV/c^{2})");
1424  fHistoTrueSecondaryPi0GGInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1425  fHistoTrueSecondaryPi0GGInvMassPt[iCut]->Sumw2();
1426  fTrueList[iCut]->Add(fHistoTrueSecondaryPi0GGInvMassPt[iCut]);
1427 
1428 
1429 
1430 
1431  fHistoTrueSecondaryPi0FromK0sInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0FromK0s_InvMass_Pt","ESD_TrueSecondaryPi0FromK0s_InvMass_Pt",800,0,0.8,250,0,25);
1432  fHistoTrueSecondaryPi0FromK0sInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0} from K^{0}_{S}} (GeV/c^{2})");
1433  fHistoTrueSecondaryPi0FromK0sInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1436  fHistoTrueSecondaryPi0FromEtaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0FromEta_InvMass_Pt","ESD_TrueSecondaryPi0FromEta_InvMass_Pt",800,0,0.8,250,0,25);
1437  fHistoTrueSecondaryPi0FromEtaInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0} from #eta} (GeV/c^{2})");
1438  fHistoTrueSecondaryPi0FromEtaInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1440  fHistoTrueSecondaryPi0FromLambdaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0FromLambda_InvMass_Pt","ESD_TrueSecondaryPi0FromLambda_InvMass_Pt",800,0,0.8,250,0,25);
1441  fHistoTrueSecondaryPi0FromLambdaInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0} from #Lambda} (GeV/c^{2})");
1442  fHistoTrueSecondaryPi0FromLambdaInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1444 
1445  fHistoTruePrimaryPi0PhotonPairPtconv[iCut] = new TH2F("ESD_TruePrimaryPi0_InvMass_PtConv","",800,0,0.8,250,0,25);
1446  fHistoTruePrimaryPi0PhotonPairPtconv[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2})");
1447  fHistoTruePrimaryPi0PhotonPairPtconv[iCut]->SetYTitle("#gamma^{conv} p_{T} (GeV/c)");
1448  fHistoTruePrimaryPi0PhotonPairPtconv[iCut]->Sumw2();
1450 
1451  fHistoTrueSecondaryPi0PhotonPairPtconv[iCut] = new TH2F("ESD_TrueSecondaryPi0_InvMass_PtConv","",800,0,0.8,250,0,25);
1452  fHistoTrueSecondaryPi0PhotonPairPtconv[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2})");
1453  fHistoTrueSecondaryPi0PhotonPairPtconv[iCut]->SetYTitle("#gamma^{conv} p_{T} (GeV/c)");
1456 
1457  fHistoTruePrimaryEtaPhotonPairPtconv[iCut] = new TH2F("ESD_TruePrimaryEta_InvMass_PtConv","",800,0,0.8,250,0,25);
1458  fHistoTruePrimaryEtaPhotonPairPtconv[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2})");
1459  fHistoTruePrimaryEtaPhotonPairPtconv[iCut]->SetYTitle("#gamma^{conv} p_{T} (GeV/c)");
1460  fHistoTruePrimaryEtaPhotonPairPtconv[iCut]->Sumw2();
1462 
1463  fHistoTruePrimaryPi0DCPtconv[iCut] = new TH1F("ESD_TruePrimaryPi0DC_PtConv","",250,0,25);
1464  fHistoTruePrimaryPi0DCPtconv[iCut]->SetXTitle("#gamma^{conv} p_{T} (GeV/c)");
1465  fHistoTruePrimaryPi0DCPtconv[iCut]->Sumw2();
1466  fTrueList[iCut]->Add(fHistoTruePrimaryPi0DCPtconv[iCut]);
1467 
1468  fHistoTrueSecondaryPi0DCPtconv[iCut] = new TH1F("ESD_TrueSecondaryPi0DC_PtConv","",250,0,25);
1469  fHistoTrueSecondaryPi0DCPtconv[iCut]->SetXTitle("#gamma^{conv} p_{T} (GeV/c)");
1470  fHistoTrueSecondaryPi0DCPtconv[iCut]->Sumw2();
1471  fTrueList[iCut]->Add(fHistoTrueSecondaryPi0DCPtconv[iCut]);
1472 
1473  fHistoTruePrimaryEtaDCPtconv[iCut] = new TH1F("ESD_TruePrimaryEtaDC_PtConv","",250,0,25);
1474  fHistoTruePrimaryEtaDCPtconv[iCut]->SetXTitle("#gamma^{conv} p_{T} (GeV/c)");
1475  fHistoTruePrimaryEtaDCPtconv[iCut]->Sumw2();
1476  fTrueList[iCut]->Add(fHistoTruePrimaryEtaDCPtconv[iCut]);
1477 
1478  fHistoTruePrimaryPi0MissingPtconv[iCut] = new TH1F("ESD_TruePrimaryPi0Missing_PtConv","",250,0,25);
1479  fHistoTruePrimaryPi0MissingPtconv[iCut]->SetXTitle("#gamma^{conv} p_{T} (GeV/c)");
1480  fHistoTruePrimaryPi0MissingPtconv[iCut]->Sumw2();
1481  fTrueList[iCut]->Add(fHistoTruePrimaryPi0MissingPtconv[iCut]);
1482 
1483  fHistoTrueSecondaryPi0MissingPtconv[iCut] = new TH1F("ESD_TrueSecondaryPi0Missing_PtConv","",250,0,25);
1484  fHistoTrueSecondaryPi0MissingPtconv[iCut]->SetXTitle("#gamma^{conv} p_{T} (GeV/c)");
1485  fHistoTrueSecondaryPi0MissingPtconv[iCut]->Sumw2();
1487 
1488  fHistoTruePrimaryEtaMissingPtconv[iCut] = new TH1F("ESD_TruePrimaryEtaMissing_PtConv","",250,0,25);
1489  fHistoTruePrimaryEtaMissingPtconv[iCut]->SetXTitle("#gamma^{conv} p_{T} (GeV/c)");
1490  fHistoTruePrimaryEtaMissingPtconv[iCut]->Sumw2();
1491  fTrueList[iCut]->Add(fHistoTruePrimaryEtaMissingPtconv[iCut]);
1492 
1493 
1494  if (fDoMesonQA > 0){
1495  fHistoTruePi0CaloPhotonInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloPhoton_InvMass_Pt","ESD_TruePi0CaloPhoton_InvMass_Pt",800,0,0.8,250,0,25);
1496  fHistoTruePi0CaloPhotonInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2}) #gamma #gamma");
1497  fHistoTruePi0CaloPhotonInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1498  fTrueList[iCut]->Add(fHistoTruePi0CaloPhotonInvMassPt[iCut]);
1499 
1500  fHistoTrueEtaCaloPhotonInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloPhoton_InvMass_Pt","ESD_TrueEtaCaloPhoton_InvMass_Pt",800,0,0.8,250,0,25);
1501  fHistoTrueEtaCaloPhotonInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2}) #gamma #gamma");
1502  fHistoTrueEtaCaloPhotonInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1503  fTrueList[iCut]->Add(fHistoTrueEtaCaloPhotonInvMassPt[iCut]);
1504 
1505  fHistoTruePi0CaloConvertedPhotonInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloConvertedPhoton_InvMass_Pt","ESD_TruePi0CaloConvertedPhoton_InvMass_Pt",800,0,0.8,250,0,25);
1506  fHistoTruePi0CaloConvertedPhotonInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2}) #gamma #gamma_{conv}");
1507  fHistoTruePi0CaloConvertedPhotonInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1509 
1510  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloConvertedPhotonMatched_InvMass_Pt","ESD_TruePi0CaloConvertedPhotonMatched_InvMass_Pt",800,0,0.8,250,0,25);
1511  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2}) #gamma #gamma_{conv,matched}");
1512  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1514 
1515  fHistoTrueEtaCaloConvertedPhotonInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloConvertedPhoton_InvMass_Pt","ESD_TrueEtaCaloConvertedPhoton_InvMass_Pt",800,0,0.8,250,0,25);
1516  fHistoTrueEtaCaloConvertedPhotonInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2}) #gamma #gamma_{conv}");
1517  fHistoTrueEtaCaloConvertedPhotonInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1519 
1520  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloConvertedPhotonMatched_InvMass_Pt","ESD_TrueEtaCaloConvertedPhotonMatched_InvMass_Pt",800,0,0.8,250,0,25);
1521  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2}) #gamma #gamma_{conv,matched}");
1522  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1524 
1525  fHistoTruePi0CaloElectronInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloElectron_InvMass_Pt","ESD_TruePi0CaloElectron_InvMass_Pt",800,0,0.8,250,0,25);
1526  fHistoTruePi0CaloElectronInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2}) #gamma e^{#pm}");
1527  fHistoTruePi0CaloElectronInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1529  fHistoTrueEtaCaloElectronInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloElectron_InvMass_Pt","ESD_TrueEtaCaloElectron_InvMass_Pt",800,0,0.8,250,0,25);
1530  fHistoTrueEtaCaloElectronInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2}) #gamma e^{#pm}");
1531  fHistoTrueEtaCaloElectronInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1533 
1534  fHistoTruePi0CaloMergedClusterInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloMergedCluster_InvMass_Pt","ESD_TruePi0CaloMergedCluster_InvMass_Pt",800,0,0.8,250,0,25);
1535  fHistoTruePi0CaloMergedClusterInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2}) #gamma merged cluster");
1536  fHistoTruePi0CaloMergedClusterInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1538  fHistoTrueEtaCaloMergedClusterInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloMergedCluster_InvMass_Pt","ESD_TrueEtaCaloMergedCluster_InvMass_Pt",800,0,0.8,250,0,25);
1539  fHistoTrueEtaCaloMergedClusterInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2}) #gamma merged cluster");
1540  fHistoTrueEtaCaloMergedClusterInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1542 
1543  fHistoTrueMotherCaloEMNonLeadingInvMassPt[iCut] = new TH2F("ESD_TrueMotherCaloEMNonLeading_InvMass_Pt","ESD_TrueMotherCaloEMNonLeading_InvMass_Pt",800,0,0.8,250,0,25);
1544  fHistoTrueMotherCaloEMNonLeadingInvMassPt[iCut]->SetXTitle("M_{inv} (GeV/c^{2}) #gamma cluster no leading EM");
1545  fHistoTrueMotherCaloEMNonLeadingInvMassPt[iCut]->SetYTitle("#pair p_{T} (GeV/c)");
1547  fHistoTruePi0CaloMergedClusterPartConvInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloMergedClusterPartConv_InvMass_Pt","ESD_TruePi0CaloMergedClusterPartConv_InvMass_Pt",800,0,0.8,250,0,25);
1548  fHistoTruePi0CaloMergedClusterPartConvInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2}) #gamma merged cluster, part conv");
1549  fHistoTruePi0CaloMergedClusterPartConvInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1551  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloMergedClusterPartConv_InvMass_Pt","ESD_TrueEtaCaloMergedClusterPartConv_InvMass_Pt",800,0,0.8,250,0,25);
1552  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2}) #gamma merged cluster, part conv");
1553  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1555 
1556  fHistoTruePrimaryPi0MCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryPi0_MCPt_ResolPt","ESD_TruePrimaryPi0_ResolPt_MCPt",500,0.03,25,1000,-1.,1.);
1557  fHistoTruePrimaryPi0MCPtResolPt[iCut]->SetXTitle("#pi^{0} p_{T,MC} (GeV/c)");
1558  fHistoTruePrimaryPi0MCPtResolPt[iCut]->SetYTitle("#pi^{0} (p_{T,rec}-p_{T,MC})/p_{T,MC} ()");
1559  fHistoTruePrimaryPi0MCPtResolPt[iCut]->Sumw2();
1561  fTrueList[iCut]->Add(fHistoTruePrimaryPi0MCPtResolPt[iCut]);
1562 
1563  fHistoTruePrimaryEtaMCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryEta_MCPt_ResolPt","ESD_TruePrimaryEta_ResolPt_MCPt",500,0.03,25,1000,-1.,1.);
1564  fHistoTruePrimaryEtaMCPtResolPt[iCut]->SetXTitle("#eta p_{T,MC} (GeV/c)");
1565  fHistoTruePrimaryEtaMCPtResolPt[iCut]->SetYTitle("#eta (p_{T,rec}-p_{T,MC})/p_{T,MC} ()");
1566  fHistoTruePrimaryEtaMCPtResolPt[iCut]->Sumw2();
1568  fTrueList[iCut]->Add(fHistoTruePrimaryEtaMCPtResolPt[iCut]);
1569 
1570  fHistoTrueBckGGInvMassPt[iCut] = new TH2F("ESD_TrueBckGG_InvMass_Pt","ESD_TrueBckGG_InvMass_Pt",800,0,0.8,250,0,25);
1571  fHistoTrueBckGGInvMassPt[iCut]->SetXTitle("M_{inv} (GeV/c^{2}) #gamma #gamma no signal");
1572  fHistoTrueBckGGInvMassPt[iCut]->SetYTitle("#pair p_{T} (GeV/c)");
1573  fTrueList[iCut]->Add(fHistoTrueBckGGInvMassPt[iCut]);
1574  fHistoTrueBckContInvMassPt[iCut] = new TH2F("ESD_TrueBckCont_InvMass_Pt","ESD_TrueBckCont_InvMass_Pt",800,0,0.8,250,0,25);
1575  fHistoTrueBckContInvMassPt[iCut]->SetXTitle("M_{inv} (GeV/c^{2}) contamination");
1576  fHistoTrueBckContInvMassPt[iCut]->SetYTitle("#pair p_{T} (GeV/c)");
1577  fTrueList[iCut]->Add(fHistoTrueBckContInvMassPt[iCut]);
1578  fHistoTrueK0sWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueK0sWithPi0Daughter_MCPt","ESD_TrueK0sWithPi0Daughter_MCPt",250,0,25);
1579  fHistoTrueK0sWithPi0DaughterMCPt[iCut]->SetXTitle("K^{0}_{s} p_{MC,T} (GeV/c) for K^{0}_{s} where #pi^{0} rec ");
1580  fTrueList[iCut]->Add(fHistoTrueK0sWithPi0DaughterMCPt[iCut]);
1581  fHistoTrueEtaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueEtaWithPi0Daughter_MCPt","ESD_TrueEtaWithPi0Daughter_MCPt",250,0,25);
1582  fHistoTrueEtaWithPi0DaughterMCPt[iCut]->SetXTitle("#eta p_{MC,T} (GeV/c) for #eta where #pi^{0} rec ");
1583  fTrueList[iCut]->Add(fHistoTrueEtaWithPi0DaughterMCPt[iCut]);
1584  fHistoTrueLambdaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueLambdaWithPi0Daughter_MCPt","ESD_TrueLambdaWithPi0Daughter_MCPt",250,0,25);
1585  fHistoTrueLambdaWithPi0DaughterMCPt[iCut]->SetXTitle("#Lambda p_{MC,T} (GeV/c) for #Lambda where #pi^{0} rec ");
1587 
1588  fHistoTruePi0PtY[iCut] = new TH2F("ESD_TruePi0_Pt_Y","ESD_TruePi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1589  fHistoTruePi0PtY[iCut]->SetYTitle("Y_{#pi^{0}}");
1590  fHistoTruePi0PtY[iCut]->SetXTitle("#pi^{0} p_{T} (GeV/c)");
1592  fTrueList[iCut]->Add(fHistoTruePi0PtY[iCut]);
1593  fHistoTrueEtaPtY[iCut] = new TH2F("ESD_TrueEta_Pt_Y","ESD_TrueEta_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1594  fHistoTrueEtaPtY[iCut]->SetYTitle("Y_{#eta}");
1595  fHistoTrueEtaPtY[iCut]->SetXTitle("#eta p_{T} (GeV/c)");
1597  fTrueList[iCut]->Add(fHistoTrueEtaPtY[iCut]);
1598  fHistoTruePi0PtAlpha[iCut] = new TH2F("ESD_TruePi0_Pt_Alpha","ESD_TruePi0_Pt_Alpha",150,0.03,15.,100,0,1);
1599  fHistoTruePi0PtAlpha[iCut]->SetYTitle("#alpha_{#pi^{0}}");
1600  fHistoTruePi0PtAlpha[iCut]->SetXTitle("#pi^{0} p_{T} (GeV/c)");
1602  fTrueList[iCut]->Add(fHistoTruePi0PtAlpha[iCut]);
1603  fHistoTrueEtaPtAlpha[iCut] = new TH2F("ESD_TrueEta_Pt_Alpha","ESD_TrueEta_Pt_Alpha",150,0.03,15.,100,0,1);
1604  fHistoTrueEtaPtAlpha[iCut]->SetYTitle("#alpha_{#eta}");
1605  fHistoTrueEtaPtAlpha[iCut]->SetXTitle("#eta p_{T} (GeV/c)");
1607  fTrueList[iCut]->Add(fHistoTrueEtaPtAlpha[iCut]);
1608 
1609  fHistoTruePi0PtOpenAngle[iCut] = new TH2F("ESD_TruePi0_Pt_OpenAngle","ESD_TruePi0_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());
1610  fHistoTruePi0PtOpenAngle[iCut]->SetYTitle("#theta_{#pi^{0}}");
1611  fHistoTruePi0PtOpenAngle[iCut]->SetXTitle("#pi^{0} p_{T} (GeV/c)");
1613  fTrueList[iCut]->Add(fHistoTruePi0PtOpenAngle[iCut]);
1614  fHistoTrueEtaPtOpenAngle[iCut] = new TH2F("ESD_TrueEta_Pt_OpenAngle","ESD_TrueEta_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());
1615  fHistoTrueEtaPtOpenAngle[iCut]->SetYTitle("#theta_{#eta}");
1616  fHistoTrueEtaPtOpenAngle[iCut]->SetXTitle("#eta p_{T} (GeV/c)");
1618  fTrueList[iCut]->Add(fHistoTrueEtaPtOpenAngle[iCut]);
1619 
1620  fHistoTrueMotherPi0ConvPhotonEtaPhi[iCut] = new TH2F("ESD_TrueMotherPi0ConvPhoton_Eta_Phi","conv photons for true #pi^{0}",600,0,2*TMath::Pi(),200,-1,1);
1621  fHistoTrueMotherPi0ConvPhotonEtaPhi[iCut]->SetXTitle("#phi_{#gamma_{conv}} (rad)");
1622  fHistoTrueMotherPi0ConvPhotonEtaPhi[iCut]->SetYTitle("#eta_{#gamma_{conv}}");
1624  fHistoTrueMotherEtaConvPhotonEtaPhi[iCut] = new TH2F("ESD_TrueMotherEtaConvPhoton_Eta_Phi","conv photons for true #eta",600,0,2*TMath::Pi(),200,-1,1);
1625  fHistoTrueMotherEtaConvPhotonEtaPhi[iCut]->SetXTitle("#phi_{#gamma_{conv}} (rad)");
1626  fHistoTrueMotherEtaConvPhotonEtaPhi[iCut]->SetYTitle("#eta_{#gamma_{conv}}");
1628 
1629 
1630  fHistoTruePi0ShowerInvMassPt[iCut] = new TH2F("ESD_TruePi0Shower_InvMass_Pt","ESD_TruePi0Shower_InvMass_Pt",800,0,0.8,250,0,25);
1631  fHistoTruePi0ShowerInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2})");
1632  fHistoTruePi0ShowerInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1633  fTrueList[iCut]->Add(fHistoTruePi0ShowerInvMassPt[iCut]);
1634 
1635  fHistoTrueEtaShowerInvMassPt[iCut] = new TH2F("ESD_TrueEtaShower_InvMass_Pt","ESD_TrueEtaShower_InvMass_Pt",800,0,0.8,250,0,25);
1636  fHistoTrueEtaShowerInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2})");
1637  fHistoTrueEtaShowerInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1638  fTrueList[iCut]->Add(fHistoTrueEtaShowerInvMassPt[iCut]);
1639 
1640  fHistoTruePi0NoShowerInvMassPt[iCut] = new TH2F("ESD_TruePi0NoShower_InvMass_Pt","ESD_TruePi0NoShower_InvMass_Pt",800,0,0.8,250,0,25);
1641  fHistoTruePi0NoShowerInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2})");
1642  fHistoTruePi0NoShowerInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1643  fTrueList[iCut]->Add(fHistoTruePi0NoShowerInvMassPt[iCut]);
1644 
1645  fHistoTrueEtaNoShowerInvMassPt[iCut] = new TH2F("ESD_TrueEtaNoShower_InvMass_Pt","ESD_TrueEtaNoShower_InvMass_Pt",800,0,0.8,250,0,25);
1646  fHistoTrueEtaNoShowerInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2})");
1647  fHistoTrueEtaNoShowerInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1648  fTrueList[iCut]->Add(fHistoTrueEtaNoShowerInvMassPt[iCut]);
1649 
1650  fHistoTruePi0OpeningAngleGammaElectron[iCut] = new TH1F("ESD_TruePi0_OpeningAngle_GammaElectron", "ESD_TruePi0_OpeningAngle_GammaElectron",100,0.,TMath::Pi());
1652 
1653 
1654 
1655  }
1656  }
1657  }
1658  }
1659 
1663 
1664  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
1665  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
1666 
1667  if(fV0Reader)
1669  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
1670  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
1671  if(fV0Reader)
1673  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms())
1674  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
1675 
1676  for(Int_t iMatcherTask = 0; iMatcherTask < 3; iMatcherTask++){
1677  AliCaloTrackMatcher* temp = (AliCaloTrackMatcher*) (AliAnalysisManager::GetAnalysisManager()->GetTask(Form("CaloTrackMatcher_%i_%i",iMatcherTask,fTrackMatcherRunningMode)));
1678  if(temp) fOutputContainer->Add(temp->GetCaloTrackMatcherHistograms());
1679  }
1680 
1681  fElecSelector=(AliDalitzElectronSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("ElectronSelector");
1682  if(!fElecSelector){printf("Error: No ElectronSelector");return;} // GetV0Reader
1683 
1684  if( fElecSelector ){
1685  if ( ((AliDalitzElectronCuts*)fElecSelector->GetDalitzElectronCuts())->GetCutHistograms() ){
1687  }
1688  }
1689 
1690 
1691  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1692 
1693  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))) continue;
1694  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms()){
1695  fCutFolder[iCut]->Add(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
1696  }
1697  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))) continue;
1698  if(((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutHistograms()){
1699  fCutFolder[iCut]->Add(((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutHistograms());
1700  }
1701  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
1702  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms()){
1703  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms());
1704  }
1705  if(!((AliDalitzElectronCuts*)fElectronCutArray->At(iCut))) continue;
1706  if( ((AliDalitzElectronCuts*)fElectronCutArray->At(iCut))->GetCutHistograms() ) {
1707  fCutFolder[iCut]->Add( ((AliDalitzElectronCuts*)fElectronCutArray->At(iCut))->GetCutHistograms() );
1708  }
1709 
1710  if(fDoMesonAnalysis){
1711  if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
1712  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
1713  fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
1714  }
1715  }
1716 
1717  }
1718  PostData(1, fOutputContainer);
1719 }
1720 //_____________________________________________________________________________
1722 {
1723  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1724  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
1725  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
1726  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
1727  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
1728  }
1729 
1730  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift()){
1731  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1732  continue; // No Eta Shift requested, continue
1733  }
1734  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
1735  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
1736  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1737  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1738  continue;
1739  }
1740  else{
1741  printf(" Gamma Conversion Task %s :: Eta Shift Manually Set to %f \n\n",
1742  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
1743  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1744  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1745  }
1746  }
1747 
1748  return kTRUE;
1749 }
1750 //_____________________________________________________________________________
1752 {
1753  //
1754  // Called for each event
1755  //
1756 
1757  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
1758  if(eventQuality == 2 || eventQuality == 3){// Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1
1759 
1760  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1761  fHistoNEvents[iCut]->Fill(eventQuality);
1762  }
1763  return;
1764  }
1765 
1766  if(fIsMC) fMCEvent = MCEvent();
1767 
1768  fInputEvent = InputEvent();
1769 
1770  if(fInputEvent->IsA()==AliAODEvent::Class()){
1771  fInputEvent->InitMagneticField();
1772  }
1773 
1774  fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
1775  fSelectorElectronIndex = fElecSelector->GetReconstructedElectronsIndex(); // Electrons from default Cut
1776  fSelectorPositronIndex = fElecSelector->GetReconstructedPositronsIndex(); // Positrons from default Cut
1777 
1778 
1779 
1780  // ------------------- BeginEvent ----------------------------
1781 
1782  AliEventplane *EventPlane = fInputEvent->GetEventplane();
1783  if(fIsHeavyIon ==1)fEventPlaneAngle = EventPlane->GetEventplane("V0",fInputEvent,2);
1784  else fEventPlaneAngle=0.0;
1785 
1786  if(fIsMC && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
1787  RelabelAODPhotonCandidates(kTRUE); // In case of AODMC relabeling MC
1788  fV0Reader->RelabelAODs(kTRUE);
1789  }
1790 
1791 
1792  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1793 
1794  fiCut = iCut;
1795 
1796  Bool_t isRunningEMCALrelAna = kFALSE;
1797 
1798  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetClusterType() == 1) isRunningEMCALrelAna = kTRUE;
1799 
1800  Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon,isRunningEMCALrelAna);
1801 
1802  if(eventNotAccepted){
1803  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
1804  fHistoNEvents[iCut]->Fill(eventNotAccepted); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
1805  continue;
1806  }
1807 
1808  if(eventQuality != 0){// Event Not Accepted
1809  //cout << "event rejected due to: " <<eventQuality << endl;
1810  fHistoNEvents[iCut]->Fill(eventQuality);
1811  continue;
1812  }
1813 
1814  fHistoNEvents[iCut]->Fill(eventQuality); // Should be 0 here
1816  fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)));
1817 
1818  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2) fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A());
1819  else fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C());
1820 
1821  if(fIsMC){
1822 
1823 
1824  // Process MC Particle
1825  fStringRecTruePi0s[iCut] = "";
1826  fStringRecTrueEtas[iCut] = "";
1827 
1828  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
1829  if(fInputEvent->IsA()==AliESDEvent::Class()){
1830 
1831  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1832  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1833  fMCEvent);
1834  }
1835  else if(fInputEvent->IsA()==AliAODEvent::Class()){
1836  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1837  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1838  fInputEvent);
1839  }
1840 
1841  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader()){
1842  for(Int_t i = 0;i<(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader())->GetEntries();i++){
1843  TString nameBin= fHistoMCHeaders[iCut]->GetXaxis()->GetBinLabel(i+1);
1844  if (nameBin.CompareTo("")== 0){
1845  TString nameHeader = ((TObjString*)((TList*)((AliConvEventCuts*)fEventCutArray->At(iCut))
1846  ->GetAcceptedHeader())->At(i))->GetString();
1847  fHistoMCHeaders[iCut]->GetXaxis()->SetBinLabel(i+1,nameHeader.Data());
1848  }
1849  }
1850  }
1851  }
1852 
1853  if(fInputEvent->IsA()==AliESDEvent::Class())
1855  if(fInputEvent->IsA()==AliAODEvent::Class())
1857 
1858  }
1859 
1860 
1861  // 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)
1862  ProcessClusters(); // process calo clusters
1863  ProcessPhotonCandidates(); // Process this cuts gammas
1865 
1866  fHistoNGammaCandidates[iCut]->Fill(fClusterCandidates->GetEntries());
1868 
1869  if(fDoMesonAnalysis){ // Meson Analysis
1870  CalculatePi0DalitzCandidates(); //Combine gamma candidates
1871 
1872  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
1873 
1874  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
1875  CalculateBackground(); // Combinatorial Background
1876  UpdateEventByEventData(); // Store Event for mixed Events
1877  }
1878 
1879  }
1880 
1881  if(fIsMC && fInputEvent->IsA()==AliAODEvent::Class()){
1882  ProcessConversionPhotonsForMissingTagsAOD(); //Count missing tags
1883  } else if (fIsMC && fInputEvent->IsA()==AliESDEvent::Class()){
1884  ProcessConversionPhotonsForMissingTags(); //Count missing tags
1885  }
1888  }
1889 
1891 
1892  fGammaCandidates->Clear(); // delete this cuts good gammas
1893  fClusterCandidates->Clear(); // delete cluster candidates
1894  fVirtualGammaCandidates->Clear(); // delete this cuts good virtual gammas
1895  }
1896 
1897  if(fIsMC && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
1898  RelabelAODPhotonCandidates(kFALSE); // Back to ESDMC Label
1899  fV0Reader->RelabelAODs(kFALSE);
1900  }
1901 
1902  fSelectorElectronIndex.clear();
1903  fSelectorPositronIndex.clear();
1904 
1905  PostData(1, fOutputContainer);
1906 }
1907 
1908 //________________________________________________________________________
1910 {
1911 
1912  Int_t nclus = 0;
1913  nclus = fInputEvent->GetNumberOfCaloClusters();
1914 
1915 
1916  if(nclus == 0) return;
1917 
1918 
1919  // vertex
1920  Double_t vertex[3] = {0};
1921  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1922 
1923 
1924  // Loop over EMCal clusters
1925  for(Long_t i = 0; i < nclus; i++){
1926 
1927  AliVCluster* clus = NULL;
1928  if(fInputEvent->IsA()==AliESDEvent::Class()) clus = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(i));
1929  else if(fInputEvent->IsA()==AliAODEvent::Class()) clus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i));
1930 
1931  if ( !clus ) continue;
1932  if ( !((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC,1.,i) ){ delete clus; continue;}
1933 
1934  // TLorentzvector with cluster
1935  TLorentzVector clusterVector;
1936  clus->GetMomentum(clusterVector,vertex);
1937 
1938  TLorentzVector* tmpvec = new TLorentzVector();
1939  tmpvec->SetPxPyPzE(clusterVector.Px(),clusterVector.Py(),clusterVector.Pz(),clusterVector.E());
1940 
1941  // convert to AODConversionPhoton
1942  AliAODConversionPhoton *PhotonCandidate=new AliAODConversionPhoton(tmpvec);
1943  if(!PhotonCandidate){ delete clus; delete tmpvec; continue;}
1944 
1945  // Flag Photon as CaloPhoton
1946  PhotonCandidate->SetIsCaloPhoton();
1947  PhotonCandidate->SetCaloClusterRef(i);
1948  // get MC label
1949  if(fIsMC){
1950  Int_t* mclabelsCluster = clus->GetLabels();
1951  PhotonCandidate->SetNCaloPhotonMCLabels(clus->GetNLabels());
1952 // cout << clus->GetNLabels() << endl;
1953  if (clus->GetNLabels()>0){
1954  for (Int_t k =0; k< (Int_t)clus->GetNLabels(); k++){
1955  if (k< 50)PhotonCandidate->SetCaloPhotonMCLabel(k,mclabelsCluster[k]);
1956 // Int_t pdgCode = fMCEvent->Particle(mclabelsCluster[k])->GetPdgCode();
1957 // cout << "label " << k << "\t" << mclabelsCluster[k] << " pdg code: " << pdgCode << endl;
1958  }
1959  }
1960  }
1961 
1962  fIsFromMBHeader = kTRUE;
1964  // test whether largest contribution to cluster orginates in added signals
1965 
1966  if ( fIsMC && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() > 0 ){
1967 
1968  if ( ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetCaloPhotonMCLabel(0), fMCEvent, fInputEvent) == 0 ) fIsFromMBHeader = kFALSE;
1969 
1970 
1971  if (clus->GetNLabels()>1){
1972  Int_t* mclabelsCluster = clus->GetLabels();
1973  for (Int_t l = 1; l < (Int_t)clus->GetNLabels(); l++ ){
1974  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(mclabelsCluster[l], fMCEvent, fInputEvent) == 0) fIsOverlappingWithOtherHeader = kTRUE;
1975  }
1976  }
1977  }
1978 
1979  if(fIsMC){
1980  if(fInputEvent->IsA()==AliESDEvent::Class()){
1981  ProcessTrueClusterCandidates(PhotonCandidate);
1982  } else {
1983  ProcessTrueClusterCandidatesAOD(PhotonCandidate);
1984  }
1985  }
1986 
1989  fHistoClusGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
1990  fClusterCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
1991  } else{
1992  delete PhotonCandidate;
1993  }
1994 
1995  delete clus;
1996  delete tmpvec;
1997  }
1998 
1999 }
2000 
2001 //________________________________________________________________________
2003 {
2004 
2005  TParticle *Photon = NULL;
2006  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
2007  fHistoTrueNLabelsInClus[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels());
2008 
2009  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0)Photon = fMCEvent->Particle(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
2010  else return;
2011 
2012  if(Photon == NULL){
2013  // cout << "no photon" << endl;
2014  return;
2015  }
2016 
2017  TruePhotonCandidate->SetCaloPhotonMCFlags(fMCEvent,kFALSE);
2018 
2019  // True Photon
2021 
2022  if (TruePhotonCandidate->IsLargestComponentPhoton() || TruePhotonCandidate->IsLargestComponentElectron() ) {
2023 
2024  fHistoTrueClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2025 
2026 
2027 
2028  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2029  Double_t mcProdVtxX = primVtxMC->GetX();
2030  Double_t mcProdVtxY = primVtxMC->GetY();
2031  Double_t mcProdVtxZ = primVtxMC->GetZ();
2032  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, TruePhotonCandidate->GetCaloPhotonMCLabel(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2033 
2034 
2035 
2036  if(isPrimary){
2037 
2038  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
2039 
2040  fHistoTruePrimaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2041  fHistoTruePrimaryClusGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
2042 
2043 
2044  Int_t gammaMotherLabel = -1;
2045 
2046  if (TruePhotonCandidate->IsLargestComponentPhoton()){ // for photons its the direct mother
2047 
2048  gammaMotherLabel=Photon->GetMother(0);
2049 
2050 
2051  } else if ( TruePhotonCandidate->IsLargestComponentElectron() ){ // for electrons its either the direct mother or for conversions the grandmother
2052 
2053  if (TruePhotonCandidate->IsConversion()) gammaMotherLabel=fMCEvent->Particle(Photon->GetMother(0))->GetMother(0);
2054  else gammaMotherLabel=Photon->GetMother(0);
2055 
2056  }
2057 
2058  if( gammaMotherLabel > -1 ){
2059 
2060  Int_t motherFromShower = -1;
2061 
2062 
2063  TParticle* motherGamma = fMCEvent->Particle( gammaMotherLabel );
2064 
2065  //if( IsDalitz ( motherGamma ) == kTRUE ){
2066  if( motherGamma->GetPdgCode() == 111 ) {
2067 
2068  if( IsDalitz( motherGamma ) == kTRUE ){
2069 
2070  fHistoTruePi0DalitzClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2071  fHistoTruePi0DalitzClusGammaMCPt[fiCut]->Fill(Photon->Pt());
2072  }
2073 
2074 
2075  } else if ( ( motherFromShower = FindMotherOfPhoton( gammaMotherLabel ) ) > -1 ){
2076 
2077 
2078 
2079 
2080  TParticle* motherGammaShower = fMCEvent->Particle( motherFromShower );
2081 
2082 
2083 
2084 
2085  if( motherGammaShower->GetPdgCode() == 111 ) {
2086  if( IsDalitz ( motherGammaShower ) ) {
2087 
2088  fHistoTruePi0DalitzClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2089  fHistoTruePi0DalitzAllClusGammaPt[fiCut]->Fill( TruePhotonCandidate->Pt() );
2090  fHistoTruePi0DalitzClusGammaMCPt[fiCut]->Fill(Photon->Pt());
2091 
2092 
2093  }
2094 
2095  }
2096  }
2097  }
2098 
2099  }
2100 
2101  }
2102  else fHistoTrueClusEMNonLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2103 
2104 
2105  if (fDoClusterQA > 0){
2106  if (TruePhotonCandidate->IsLargestComponentPhoton()){
2107  fHistoTrueClusUnConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2108  fHistoTrueClusUnConvGammaMCPt[fiCut]->Fill(Photon->Pt());
2109  }
2110  if (TruePhotonCandidate->IsLargestComponentElectron())
2111  fHistoTrueClusElectronPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2112  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2113  fHistoTrueClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2114  fHistoTrueClusConvGammaMCPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(Photon->GetMother(0)))->Pt());
2115  }
2116  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion() && TruePhotonCandidate->IsConversionFullyContained())
2117  fHistoTrueClusConvGammaFullyPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2118  if (TruePhotonCandidate->IsMerged() || TruePhotonCandidate->IsMergedPartConv() || TruePhotonCandidate->IsDalitzMerged())
2119  fHistoTrueClusMergedGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2120  if (TruePhotonCandidate->IsMergedPartConv())
2121  fHistoTrueClusMergedPartConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2122  if (TruePhotonCandidate->IsDalitz())
2123  fHistoTrueClusDalitzPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2124  if (TruePhotonCandidate->IsDalitzMerged())
2125  fHistoTrueClusDalitzMergedPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2126  if (TruePhotonCandidate->IsPhotonWithElecMother())
2127  fHistoTrueClusPhotonFromElecMotherPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2128  if (TruePhotonCandidate->IsShower())
2129  fHistoTrueClusShowerPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2130  if (TruePhotonCandidate->IsSubLeadingEM())
2131  fHistoTrueClusSubLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2132  fHistoTrueClusNParticles[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels());
2133  }
2134  }
2135 
2136 
2137  return;
2138 }
2139 
2140 
2141 //________________________________________________________________________
2143 {
2144  AliAODMCParticle *Photon = NULL;
2145  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2146  if (AODMCTrackArray){
2147  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
2148  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0) Photon = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
2149  else return;
2150  } else {
2151  AliInfo("AODMCTrackArray could not be loaded");
2152  return;
2153  }
2154 
2155  if(Photon == NULL){
2156  // cout << "no photon" << endl;
2157  return;
2158  }
2159  TruePhotonCandidate->SetCaloPhotonMCFlagsAOD(fInputEvent, kFALSE);
2160  fHistoTrueNLabelsInClus[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels());
2161  // True Photon
2163  if (TruePhotonCandidate->IsLargestComponentPhoton() || TruePhotonCandidate->IsLargestComponentElectron() )fHistoTrueClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2164  else fHistoTrueClusEMNonLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2165  if (fDoClusterQA > 0){
2166  if (TruePhotonCandidate->IsLargestComponentPhoton()) {
2167  fHistoTrueClusUnConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2168  fHistoTrueClusUnConvGammaMCPt[fiCut]->Fill(Photon->Pt());
2169  }
2170  if (TruePhotonCandidate->IsLargestComponentElectron())
2171  fHistoTrueClusElectronPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2172  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()) {
2173  fHistoTrueClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2174  AliAODMCParticle *Mother = (AliAODMCParticle*) AODMCTrackArray->At(Photon->GetMother());
2175  fHistoTrueClusConvGammaMCPt[fiCut]->Fill(Mother->Pt());
2176  }
2177  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion() && TruePhotonCandidate->IsConversionFullyContained())
2178  fHistoTrueClusConvGammaFullyPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2179  if (TruePhotonCandidate->IsMerged() || TruePhotonCandidate->IsMergedPartConv() || TruePhotonCandidate->IsDalitzMerged())
2180  fHistoTrueClusMergedGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2181  if (TruePhotonCandidate->IsMergedPartConv())
2182  fHistoTrueClusMergedPartConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2183  if (TruePhotonCandidate->IsDalitz())
2184  fHistoTrueClusDalitzPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2185  if (TruePhotonCandidate->IsDalitzMerged())
2186  fHistoTrueClusDalitzMergedPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2187  if (TruePhotonCandidate->IsPhotonWithElecMother())
2188  fHistoTrueClusPhotonFromElecMotherPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2189  if (TruePhotonCandidate->IsShower())
2190  fHistoTrueClusShowerPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2191  if (TruePhotonCandidate->IsSubLeadingEM())
2192  fHistoTrueClusSubLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2193  fHistoTrueClusNParticles[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels());
2194  }
2195  }
2196 
2197  // True Photon
2198  if(fIsFromMBHeader){
2199  fHistoTrueClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2200  if (fDoPhotonQA > 0) fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta());
2201  }
2202 
2203  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2204  Double_t mcProdVtxX = primVtxMC->GetX();
2205  Double_t mcProdVtxY = primVtxMC->GetY();
2206  Double_t mcProdVtxZ = primVtxMC->GetZ();
2207  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2208 
2209  if(isPrimary){
2210  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
2211  if(fIsFromMBHeader){
2212  fHistoTruePrimaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2213  fHistoTruePrimaryClusGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
2214  }
2215  }
2216 }
2217 
2218 //________________________________________________________________________
2220 {
2221  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2222  Double_t mcProdVtxX = primVtxMC->GetX();
2223  Double_t mcProdVtxY = primVtxMC->GetY();
2224  Double_t mcProdVtxZ = primVtxMC->GetZ();
2225 
2226  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2227 
2228  // Loop over all primary MC particle
2229  for(Int_t i = 0; i < AODMCTrackArray->GetEntriesFast(); i++) {
2230 
2231  AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
2232  if (!particle) continue;
2233 
2234  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, particle, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2235  if (!isPrimary) continue;
2236 
2237  Int_t isMCFromMBHeader = -1;
2238  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2239  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2240  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2241  }
2242 
2243  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
2244  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kFALSE)){
2245  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma
2246  if (TMath::Abs(particle->Eta()) < 0.66 ){
2247  if (particle->Phi() > 1.39626 && particle->Phi() < 3.125) fHistoMCAllGammaEMCALAccPt[fiCut]->Fill(particle->Pt());
2248  }
2249  if(particle->GetMother() >-1){ // Meson Decay Gamma
2250  switch((static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother())))->GetPdgCode()){
2251  case 111: // Pi0
2252  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt());
2253  break;
2254  case 113: // Rho0
2255  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt());
2256  break;
2257  case 221: // Eta
2258  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt());
2259  break;
2260  case 223: // Omega
2261  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt());
2262  break;
2263  case 331: // Eta'
2264  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt());
2265  break;
2266  case 333: // Phi
2267  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt());
2268  break;
2269  case 3212: // Sigma
2270  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt());
2271  break;
2272  }
2273  }
2274  }
2275  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kTRUE)){
2276  Double_t rConv = 0;
2277  for(Int_t daughterIndex=particle->GetDaughterLabel(0);daughterIndex<=particle->GetDaughterLabel(1);daughterIndex++){
2278  AliAODMCParticle *tmpDaughter = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(daughterIndex));
2279  if(!tmpDaughter) continue;
2280  if(TMath::Abs(tmpDaughter->GetPdgCode()) == 11){
2281  rConv = sqrt( (tmpDaughter->Xv()*tmpDaughter->Xv()) + (tmpDaughter->Yv()*tmpDaughter->Yv()) );
2282  }
2283  }
2284  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt());
2285  if (fDoPhotonQA > 0){
2286  fHistoMCConvGammaR[fiCut]->Fill(rConv);
2287  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta());
2288  }
2289  }
2290  // Converted MC Gamma
2291  if(fDoMesonAnalysis){
2292  if(particle->GetPdgCode() == 310 && fDoMesonQA > 0){
2293  Double_t mesonY = 1.e30;
2294  Double_t ratio = 0;
2295  if (particle->E() != TMath::Abs(particle->Pz())){
2296  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2297  }
2298  if( !(ratio <= 0) ){
2299  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2300  }
2301  Float_t weightedK0s= 1;
2302  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2303  if (particle->Pt()>0.005){
2304  weightedK0s= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, 0x0, fInputEvent);
2305  //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
2306  }
2307  }
2308  fHistoMCK0sPt[fiCut]->Fill(particle->Pt(),weightedK0s);
2309  fHistoMCK0sWOWeightPt[fiCut]->Fill(particle->Pt());
2310  fHistoMCK0sPtY[fiCut]->Fill(particle->Pt(),mesonY,weightedK0s);
2311  }
2313  ->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2314  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughterLabel(0)));
2315  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughterLabel(1)));
2316  Float_t weighted= 1;
2317  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2318  if (particle->Pt()>0.005){
2319  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, 0x0, fInputEvent);
2320  // if(particle->GetPdgCode() == 221){
2321  // cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
2322  // }
2323  }
2324  }
2325  Double_t mesonY = 1.e30;
2326  Double_t ratio = 0;
2327  if (particle->E() != TMath::Abs(particle->Pz())){
2328  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2329  }
2330  if( !(ratio <= 0) ){
2331  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2332  }
2333 
2334  Double_t alpha = -1;
2335  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
2336  alpha = TMath::Abs((daughter0->E() - daughter1->E()))/(daughter0->E() + daughter1->E());
2337  }
2338 
2339 
2340  if(particle->GetPdgCode() == 111){
2341  fHistoMCPi0GGPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Pi0
2342  fHistoMCPi0GGWOWeightPt[fiCut]->Fill(particle->Pt());
2343  if (fDoMesonQA > 0){
2344  fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
2345  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha); // All MC Pi0
2346  }
2347  } else if(particle->GetPdgCode() == 221){
2348  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Eta
2349  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt());
2350  if (fDoMesonQA > 0){
2351  fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
2352  fHistoMCEtaPtAlpha[fiCut]->Fill(particle->Pt(),alpha); // All MC Pi0
2353  }
2354  }
2355 
2356  // Check the acceptance for both gammas
2357  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
2358  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
2359  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2360  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2361 
2362  if(particle->GetPdgCode() == 111){
2363  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted); // MC Pi0 with gamma in acc
2364  } else if(particle->GetPdgCode() == 221){
2365  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted); // MC Eta with gamma in acc
2366  }
2367  }
2368  }
2369  }
2370  }
2371 
2372 }
2373 //________________________________________________________________________
2375 {
2376 
2377  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2378  Double_t mcProdVtxX = primVtxMC->GetX();
2379  Double_t mcProdVtxY = primVtxMC->GetY();
2380  Double_t mcProdVtxZ = primVtxMC->GetZ();
2381 
2382 
2383 
2384  // Loop over all primary MC particle
2385  for(Int_t i = 0; i < fMCEvent->GetNumberOfTracks(); i++) {
2386 
2387 
2388 
2389  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
2390 
2391  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
2392  if (!particle) continue;
2393 
2394 
2395 
2396  Int_t isMCFromMBHeader = -1;
2397  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2398 
2399  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2400  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2401 
2402  }
2403 
2404 
2405 
2406 
2407  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
2408 
2409 
2410  if ( ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(particle,fMCEvent) == kTRUE ){
2411 
2412  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma
2413 
2414 
2415  if( IsPi0DalitzDaughter ( i ) == kTRUE ) {
2416 
2417  fHistoMCAllGammaPi0Pt[fiCut]->Fill(particle->Pt());
2418  }
2419 
2420  }
2421 
2422 
2423  if(((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->ElectronIsSelectedMC(i,fMCEvent) == kTRUE){
2424 
2425  Double_t deltaX = particle->Vx() - mcProdVtxX;
2426  Double_t deltaY = particle->Vy() - mcProdVtxY;
2427  Double_t deltaZ = particle->Vz() - mcProdVtxZ;
2428 
2429  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
2430 
2431 
2432  if( particle->GetPdgCode() == -11) {
2433  fHistoMCAllPositronsPt[fiCut]->Fill(particle->Pt()); // All positrons
2434 
2435 
2436 
2437  if ( particle->GetMother(0) > -1 ) {
2438 
2439  if( IsPi0DalitzDaughter( i ) == kTRUE ){
2440  fHistoMCDecayPositronPi0Pt[fiCut]->Fill(particle->Pt()); //Positrons from Pi0->Dalitz
2441 
2442  if( i >= fMCEvent->GetNumberOfPrimaries() ){
2443 
2444  fHistoMCDecayNoPrimPositronPi0DalitzR[fiCut]->Fill(realRadius3D);
2445  fHistoMCDecayNoPrimPositronPi0DalitzID[fiCut]->Fill( particle->GetUniqueID());
2446 
2447  }
2448 
2449  }
2450 
2451  }
2452  }
2453  if( particle->GetPdgCode() == 11){
2454 
2455  fHistoMCAllElectronsPt[fiCut]->Fill(particle->Pt()); // All electrons
2456 
2457  if ( particle->GetMother(0) > -1 ) {
2458 
2459  if( IsPi0DalitzDaughter( i ) == kTRUE ){
2460  fHistoMCDecayElectronPi0Pt[fiCut]->Fill(particle->Pt()); //Electrons from Pi0->Dalitz
2461  }
2462 
2463  if( i >= fMCEvent->GetNumberOfPrimaries() ){
2464 
2465  fHistoMCDecayNoPrimElectronPi0DalitzR[fiCut]->Fill(realRadius3D);
2466  fHistoMCDecayNoPrimElectronPi0DalitzID[fiCut]->Fill( particle->GetUniqueID());
2467 
2468  }
2469 
2470  }
2471 
2472  }
2473  }
2474 
2475 
2476  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
2477 
2478 
2479 
2480  if ( TMath::Abs(particle->Eta()) < 0.66 ){
2481  if (particle->Phi() > 1.39626 && particle->Phi() < 3.125) fHistoMCAllGammaEMCALAccPt[fiCut]->Fill(particle->Pt());
2482  }
2483 
2484  if(particle->GetMother(0) >-1){ // Meson Decay Gamma
2485  switch(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()){
2486  case 111: // Pi0
2487  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt());
2488  break;
2489  case 113: // Rho0
2490  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt());
2491  break;
2492  case 221: // Eta
2493  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt());
2494  break;
2495  case 223: // Omega
2496  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt());
2497  break;
2498  case 331: // Eta'
2499  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt());
2500  break;
2501  case 333: // Phi
2502  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt());
2503  break;
2504  case 3212: // Sigma
2505  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt());
2506  break;
2507  }
2508  }
2509  }
2510  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kTRUE)){
2511  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt());
2512  if (fDoPhotonQA > 0){
2513  fHistoMCConvGammaR[fiCut]->Fill(((TParticle*)fMCEvent->Particle(particle->GetFirstDaughter()))->R());
2514  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta());
2515  }
2516  } // Converted MC Gamma
2517 
2518  if(fDoMesonAnalysis){
2519 
2520 
2522  ->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2523 
2524  Float_t weighted= 1;
2525 
2526  if( ((AliDalitzElectronCuts*) fElectronCutArray->At(fiCut))->DoWeights() ) {
2527 
2528  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2529 
2530  if (particle->Pt()>0.005){
2531  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
2532 
2533  }
2534  }
2535  }
2536 
2537  if(particle->GetPdgCode() == 111){
2538 
2539  fHistoMCPi0GGPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Pi0
2540  fHistoMCPi0GGWOWeightPt[fiCut]->Fill(particle->Pt());
2541 
2542 
2543  } else if(particle->GetPdgCode() == 221){
2544 
2545  fHistoMCEtaGGPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Eta
2546  fHistoMCEtaGGWOWeightPt[fiCut]->Fill(particle->Pt());
2547 
2548  }
2549 
2550 
2551  }
2552 
2553 
2554  Int_t labelgamma = -1;
2555  Int_t labelelectron = -1;
2556  Int_t labelpositron = -1;
2557 
2558 
2559  if( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMCDalitz(particle,fMCEvent,labelelectron,labelpositron,labelgamma,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2560 
2561  Float_t weighted= 1;
2562 
2563  if( ((AliDalitzElectronCuts*) fElectronCutArray->At(fiCut))->DoWeights() ) {
2564  if( ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent,fInputEvent) ) {
2565  if (particle->Pt()>0.005){
2566  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent,fInputEvent);
2567  }
2568  }
2569  }
2570 
2571  if(particle->GetPdgCode() == 111){
2572  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(), weighted); // All MC Pi0 Dalitz
2573  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt() ); //All MC Pi0 Dalitz without weights
2574  }
2575  if(particle->GetPdgCode() == 221){
2576  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(), weighted); // All MC Eta
2577  fHistoMCEtaWOWeightPt[fiCut]->Fill( particle->Pt() ); //All MC Eta Dalitz without weights
2578  }
2579 
2580  // Check the acceptance for gamma and electrons
2581 
2582  TParticle *gamma = fMCEvent->Particle(labelgamma);
2583  TParticle *electron = fMCEvent->Particle(labelelectron);
2584  TParticle *positron = fMCEvent->Particle(labelpositron);
2585 
2586 
2587 
2588 
2589 
2590  Bool_t kDaughGammaIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelgamma, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2591  Bool_t kDaughElectIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelelectron, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2592  Bool_t kDaughPositIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelpositron, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2593 
2594 
2595 
2596  if( kDaughElectIsPrim && kDaughPositIsPrim && kDaughGammaIsPrim &&
2597  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma,fMCEvent) &&
2598  ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->ElectronIsSelectedMC(labelelectron,fMCEvent) &&
2599  ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->ElectronIsSelectedMC(labelpositron,fMCEvent) ) {
2600 
2601 
2602  TLorentzVector TLVEpos,TLVEneg,TLVDalitz;
2603 
2604  Double_t electronMass = TDatabasePDG::Instance()->GetParticle( ::kElectron )->Mass();
2605 
2606  TLVEpos.SetXYZM(positron->Px(),positron->Py(),positron->Pz(),electronMass);
2607  TLVEneg.SetXYZM(electron->Px(),electron->Py(),electron->Pz(),electronMass);
2608  TVector3 V3gamma(gamma->Px(),gamma->Py(),gamma->Pz());
2609  Double_t angleGammaEpos = V3gamma.Angle(TLVEpos.Vect());
2610  Double_t angleGammaEneg = V3gamma.Angle(TLVEneg.Vect());
2611 
2612 
2613 
2614 
2615 
2616 
2617  if( particle->GetPdgCode() == 111 ){
2618 
2619 
2620  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt() , weighted); // MC Pi0Dalitz with gamma and e+e- in acc
2621 
2622  if( fDoMesonQA > 0 ) {
2623 
2624  fHistoMCPi0InAccOpeningAngleGammaElectron[fiCut]->Fill(angleGammaEpos);
2625  fHistoMCPi0InAccOpeningAngleGammaElectron[fiCut]->Fill(angleGammaEneg);
2626 
2627  }
2628 
2629 
2630  }
2631  if( particle->GetPdgCode() == 221 ){
2632 
2633  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(), weighted); // MC EtaDalitz with gamma and e+e- in acc
2634 
2635  }
2636  }
2637  }
2638  }
2639  }
2640  }
2641 }
2642 
2643 
2644 //________________________________________________________________________
2646 
2647  // Conversion Gammas
2648 
2649  if( fClusterCandidates->GetEntries() > 0 && fVirtualGammaCandidates->GetEntries() > 0 ){
2650 
2651  vector<Bool_t> lGoodVirtualGamma(fVirtualGammaCandidates->GetEntries(), kFALSE);
2652 
2653  for(Int_t GammaIndex=0; GammaIndex<fClusterCandidates->GetEntries(); GammaIndex++){
2654 
2655  AliAODConversionPhoton *gamma=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(GammaIndex));
2656 
2657  if (gamma==NULL) continue;
2658 
2659 
2660  for(Int_t virtualGammaIndex=0;virtualGammaIndex<fVirtualGammaCandidates->GetEntries();virtualGammaIndex++){
2661 
2662  Bool_t matched = kFALSE;
2663 
2664  AliAODConversionPhoton *Vgamma=dynamic_cast<AliAODConversionPhoton*>(fVirtualGammaCandidates->At(virtualGammaIndex));
2665  if (Vgamma==NULL) continue;
2666 
2667  //Check for same Electron ID
2668  if ( gamma->GetIsCaloPhoton() ){
2669 
2670  AliVCluster* cluster = fInputEvent->GetCaloCluster(gamma->GetCaloClusterRef());
2671  matched = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(Vgamma,cluster,fInputEvent );
2672 
2673  }
2674 
2675 
2676  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma,Vgamma);
2677  pi0cand->SetLabels(GammaIndex,virtualGammaIndex);
2678 
2679 
2680 
2681 
2682  if( (((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())) ){
2683 
2684  Int_t zbin = 0;
2685  Int_t mbin = 0;
2686 
2687  Double_t angleGammaPositron = -999;
2688  Double_t angleGammaElectron = -999;
2689 
2690 
2691  if ( fDoMesonQA > 0 ) {
2692 
2693  AliESDtrack* positronVgamma = (AliESDtrack*)fInputEvent->GetTrack( Vgamma->GetTrackLabelPositive() );
2694  Double_t momPositron[3];
2695  positronVgamma->GetConstrainedPxPyPz(momPositron);
2696 
2697 
2698  AliESDtrack* electronVgamma = (AliESDtrack*)fInputEvent->GetTrack( Vgamma->GetTrackLabelNegative() );
2699  Double_t momElectron[3];
2700  electronVgamma->GetConstrainedPxPyPz(momElectron);
2701 
2702 
2703  TVector3 vGamma(gamma->GetPx(),gamma->GetPy(),gamma->GetPz());;
2704  TVector3 vPositron(momPositron[0],momPositron[1],momPositron[2]);
2705  TVector3 vElectron(momElectron[0],momElectron[1],momElectron[2]);
2706 
2707  angleGammaPositron = vGamma.Angle(vPositron);
2708  angleGammaElectron = vGamma.Angle(vElectron);
2709 
2710  }
2711 
2712 
2713 
2714  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
2715 
2716  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
2717 
2718  zbin = fBGClusHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
2719 
2720  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
2722  } else {
2724  }
2725  }
2726  }
2727 
2728  if( ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->DoMassCut() == kTRUE ) {
2729  if( ((AliDalitzElectronCuts*) fElectronCutArray->At(fiCut))->MassCut( pi0cand->Pt() , Vgamma->M() ) == kTRUE ){
2730 
2731  if (matched){
2732 
2733  fHistoMotherMatchedInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
2734 
2735  } else {
2736 
2737  fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
2738 
2739  if(TMath::Abs(pi0cand->GetAlpha())<0.1) fHistoMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E());
2740 
2741 
2742  if( fDoMesonQA > 0 ) {
2743 
2744  fHistoMotherInvMassOpeningAngleGammaElectron[fiCut]->Fill( angleGammaPositron );
2745  fHistoMotherInvMassOpeningAngleGammaElectron[fiCut]->Fill( angleGammaElectron );
2746 
2747 
2748  }
2749 
2750 
2751  if( fDoTHnSparse ) {
2752  Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
2753  fSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
2754  }
2755 
2756  if(fMCEvent){
2757  ProcessTrueMesonCandidates(pi0cand,Vgamma,gamma,matched);
2758  }
2759 
2760  }
2761  }
2762  } else {
2763 
2764  if (matched){
2765  fHistoMotherMatchedInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
2766  } else {
2767 
2768  fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
2769 
2770  if(TMath::Abs( pi0cand->GetAlpha()) < 0.1 ) fHistoMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E());
2771 
2772  if ( fDoTHnSparse ) {
2773  Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
2774  fSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
2775  }
2776 
2777  if( fDoMesonQA > 0 ) {
2778 
2779  fHistoMotherInvMassOpeningAngleGammaElectron[fiCut]->Fill( angleGammaPositron );
2780  fHistoMotherInvMassOpeningAngleGammaElectron[fiCut]->Fill( angleGammaElectron );
2781 
2782  }
2783 
2784 
2785  if(fMCEvent){
2786  ProcessTrueMesonCandidates(pi0cand,Vgamma,gamma,matched);
2787  }
2788  }
2789 
2790  }
2791  }
2792  delete pi0cand;
2793  pi0cand=0x0;
2794  }
2795  }
2796  }
2797 }
2798 
2799 //______________________________________________________________________
2801 {
2802  // Process True Mesons
2803 
2804  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2805  Double_t mcProdVtxX = primVtxMC->GetX();
2806  Double_t mcProdVtxY = primVtxMC->GetY();
2807  Double_t mcProdVtxZ = primVtxMC->GetZ();
2808 
2809 
2810  Bool_t isTruePi0 = kFALSE;
2811  Bool_t isTrueEta = kFALSE;
2812 
2813 
2814  Int_t virtualGammaMCLabel = TrueVirtualGammaCandidate->GetMCParticleLabel(fMCEvent);
2815  Int_t virtualGammaMotherLabel = -1;
2816  Int_t virtualGamma = -1;
2817 
2818  Bool_t motherFromShower = kFALSE;
2819 
2820  Double_t angleGammaPositron = -999;
2821  Double_t angleGammaElectron = -999;
2822 
2823 
2824  if( fDoMesonQA > 0 ) {
2825 
2826  AliESDtrack* positronVgamma = (AliESDtrack*)fInputEvent->GetTrack( TrueVirtualGammaCandidate->GetTrackLabelPositive() );
2827  Double_t momPositron[3];
2828  positronVgamma->GetConstrainedPxPyPz(momPositron);
2829 
2830 
2831  AliESDtrack* electronVgamma = (AliESDtrack*)fInputEvent->GetTrack( TrueVirtualGammaCandidate->GetTrackLabelNegative() );
2832  Double_t momElectron[3];
2833  electronVgamma->GetConstrainedPxPyPz(momElectron);
2834 
2835 
2836  TVector3 vGamma(TrueGammaCandidate1->GetPx(),TrueGammaCandidate1->GetPy(),TrueGammaCandidate1->GetPz());;
2837  TVector3 vPositron(momPositron[0],momPositron[1],momPositron[2]);
2838  TVector3 vElectron(momElectron[0],momElectron[1],momElectron[2]);
2839 
2840  angleGammaPositron = vGamma.Angle(vPositron);
2841  angleGammaElectron = vGamma.Angle(vElectron);
2842 
2843  }
2844 
2845 
2846 
2847  if( virtualGammaMCLabel != -1 ){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2848  // Daughters Gamma 1
2849  TParticle * negativeMC = (TParticle*)TrueVirtualGammaCandidate->GetNegativeMCDaughter(fMCEvent);
2850  TParticle * positiveMC = (TParticle*)TrueVirtualGammaCandidate->GetPositiveMCDaughter(fMCEvent);
2851  TParticle * virtualGammaMotherMC = (TParticle*)fMCEvent->Particle(virtualGammaMCLabel);
2852 
2853  if( TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11) { // Electrons ...
2854 
2855  if( virtualGammaMotherMC->GetPdgCode() != 22 ){
2856  virtualGammaMotherLabel=virtualGammaMCLabel;
2857  virtualGamma = 1;
2858 
2859  } else if (negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
2860  virtualGammaMotherLabel=virtualGammaMotherMC->GetMother(0);
2861  virtualGamma = 0; //no virtual gamma
2862  }
2863  }
2864  }
2865 
2866  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2867 
2868  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
2869  Int_t gamma1MotherLabel = -1;
2870  // check if
2871 
2872  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2873 
2874  // Daughters Gamma 1
2875  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
2876 
2877  if ( TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron() ){ // largest component is electro magnetic
2878  // get mother of interest (pi0 or eta)
2879  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
2880  gamma1MotherLabel=gammaMC1->GetMother(0);
2881  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
2882  if (TrueGammaCandidate1->IsConversion()) gamma1MotherLabel=fMCEvent->Particle(gammaMC1->GetMother(0))->GetMother(0);
2883  else gamma1MotherLabel=gammaMC1->GetMother(0);
2884  }
2885 
2886 
2887  if( gamma1MotherLabel > -1 ){
2888 
2889  Int_t pdgCodeMother = ((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode();
2890 
2891  if( pdgCodeMother != 111 && pdgCodeMother != 221 ){ //The mother is not and eta and MC
2892 
2893  gamma1MotherLabel = FindMotherOfPhoton( gamma1MotherLabel );
2894  motherFromShower = kTRUE;
2895 
2896  }
2897  }
2898 
2899 
2900 
2901  } else {
2902  if (fDoMesonQA > 0) fHistoTrueMotherCaloEMNonLeadingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2903  }
2904  }
2905 
2906  if(virtualGammaMotherLabel >= 0 && virtualGammaMotherLabel==gamma1MotherLabel){
2907 
2908  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
2909  isTruePi0=kTRUE;
2910  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma1MotherLabel)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2911  }
2912 
2913  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 221){
2914  isTrueEta=kTRUE;
2915  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueEtas,gamma1MotherLabel)) fHistoDoubleCountTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2916  }
2917 
2918  }
2919 
2920  if(isTruePi0 || isTrueEta){// True Pion or Eta
2921 
2922 
2923  if( virtualGamma == 1 ){
2924 
2925  if( !matched ) {
2926 
2927  if( isTruePi0 ) {
2928 
2929  fHistoTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2930  if( fDoMesonQA > 0 ) {
2931  fHistoTruePi0OpeningAngleGammaElectron[fiCut]->Fill(angleGammaPositron);
2932  fHistoTruePi0OpeningAngleGammaElectron[fiCut]->Fill(angleGammaElectron);
2933  }
2934  }
2935  if (isTrueEta)fHistoTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2936 
2937  }
2938 
2939 
2940  if (fDoMesonQA > 0){
2941 
2942 
2943  if( motherFromShower == kTRUE && !matched ){
2944 
2945  if (isTruePi0)fHistoTruePi0ShowerInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2946  if (isTrueEta)fHistoTrueEtaShowerInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2947 
2948  } else if ( motherFromShower == kFALSE && !matched ){
2949 
2950  if (isTruePi0)fHistoTruePi0NoShowerInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2951  if (isTrueEta)fHistoTrueEtaNoShowerInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2952 
2953  }
2954 
2955  if (TrueGammaCandidate1->IsLargestComponentPhoton() && !matched){
2956  if(isTruePi0) fHistoTruePi0CaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2957  if(isTrueEta) fHistoTrueEtaCaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2958  }
2959  if (TrueGammaCandidate1->IsLargestComponentElectron() && !matched){
2960  if(isTruePi0) fHistoTruePi0CaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2961  if(isTrueEta) fHistoTrueEtaCaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2962  }
2963  if (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion() ){
2964  if (isTruePi0 && !matched)fHistoTruePi0CaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2965  if (isTrueEta && !matched)fHistoTrueEtaCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2966  if ((TrueVirtualGammaCandidate->GetMCLabelPositive() == gamma1MCLabel || TrueVirtualGammaCandidate->GetMCLabelNegative() == gamma1MCLabel) && isTruePi0){
2967  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2968  }
2969  if ((TrueVirtualGammaCandidate->GetMCLabelPositive() == gamma1MCLabel || TrueVirtualGammaCandidate->GetMCLabelNegative() == gamma1MCLabel) && isTrueEta){
2970  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2971  }
2972  }
2973  if ((TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged()) && !matched ){
2974  if (isTruePi0 )fHistoTruePi0CaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2975  if (isTrueEta )fHistoTrueEtaCaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2976  }
2977  if (TrueGammaCandidate1->IsMergedPartConv() && !matched){
2978  if (isTruePi0) fHistoTruePi0CaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2979  if (isTrueEta) fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2980  }
2981  }
2982 
2983  if ( !matched ) {
2984 
2985  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, gamma1MotherLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2986 
2987 
2988  if(!isPrimary){ // Secondary Meson
2989 
2990  Int_t secMotherLabel = ((TParticle*)fMCEvent->Particle(virtualGammaMotherLabel))->GetMother(0);
2991  Float_t weightedSec = 1;
2992 
2993  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, fMCEvent, fInputEvent) && fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310){
2994  weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(secMotherLabel, fMCEvent, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
2995 
2996  }
2997 
2998  if (isTruePi0){
2999  fHistoTrueSecondaryPi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3000  fHistoTrueSecondaryPi0PhotonPairPtconv[fiCut]->Fill(Pi0Candidate->M(),TrueGammaCandidate1->Pt(),weightedSec);
3001  if(CheckIfContainedInString(fStringRecTruePi0s[fiCut],virtualGammaMotherLabel)){
3002  fHistoTrueSecondaryPi0DCPtconv[fiCut]->Fill(TrueGammaCandidate1->Pt(),weightedSec);
3003  }
3004  }
3005 
3006  if (secMotherLabel >-1){
3007  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310 && isTruePi0 ){
3008  fHistoTrueSecondaryPi0FromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3009  if (fDoMesonQA > 0)fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3010  }
3011  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==221 && isTruePi0){
3012  fHistoTrueSecondaryPi0FromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3013  if (fDoMesonQA > 0)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3014  }
3015  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==3122 && isTruePi0){
3016  fHistoTrueSecondaryPi0FromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3017  if (fDoMesonQA > 0)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3018  }
3019  }
3020  } else { // Only primary pi0 for efficiency calculation
3021  Float_t weighted= 1;
3022  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCEvent, fInputEvent)){
3023  if (((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt()>0.005){
3024  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, fMCEvent, fInputEvent);
3025  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3026  }
3027  }
3028  if (isTruePi0){
3029  fHistoTruePrimaryPi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3030  fHistoTruePrimaryPi0PhotonPairPtconv[fiCut]->Fill(Pi0Candidate->M(),TrueGammaCandidate1->Pt(),weighted);
3031  fHistoTruePrimaryPi0W0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3032  fProfileTruePrimaryPi0WeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3033  if(CheckIfContainedInString(fStringRecTruePi0s[fiCut],virtualGammaMotherLabel)){
3034  fHistoTruePrimaryPi0DCPtconv[fiCut]->Fill(TrueGammaCandidate1->Pt(),weighted);
3035  }
3036 
3037  } else if (isTrueEta) {
3038  fHistoTruePrimaryEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3039  fHistoTruePrimaryEtaPhotonPairPtconv[fiCut]->Fill(Pi0Candidate->M(),TrueGammaCandidate1->Pt(),weighted);
3040  fHistoTruePrimaryEtaW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3041  fProfileTruePrimaryEtaWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3042  if(CheckIfContainedInString(fStringRecTrueEtas[fiCut],virtualGammaMotherLabel)){
3043  fHistoTruePrimaryEtaDCPtconv[fiCut]->Fill(TrueGammaCandidate1->Pt(),weighted);
3044  }
3045  }
3046 
3047  if (fDoMesonQA > 0){
3048  if(isTruePi0){ // Only primary pi0 for resolution
3049  fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted);
3050  }
3051  if (isTrueEta){ // Only primary eta for resolution
3052  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted);
3053  }
3054  }
3055  }
3056  }
3057  } else if ( virtualGamma == 0 ) {
3058 
3059  if( !matched ) {
3060 
3061  if (isTruePi0)fHistoTruePi0GGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3062  if (isTrueEta)fHistoTrueEtaGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3063 
3064  if(virtualGammaMotherLabel >= fMCEvent->GetNumberOfPrimaries()){ // Secondary Meson
3065 
3066  Int_t secMotherLabel = ((TParticle*)fMCEvent->Particle(virtualGammaMotherLabel))->GetMother(0);
3067  Float_t weightedSec= 1;
3068 
3069  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, fMCEvent, fInputEvent) && fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310){
3070  weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(secMotherLabel, fMCEvent, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
3071  //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3072  }
3073  if (isTruePi0){
3074  fHistoTrueSecondaryPi0GGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3075  }
3076 
3077  } else { // Only primary pi0 for efficiency calculation
3078  Float_t weighted= 1;
3079  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCEvent, fInputEvent)){
3080  if (((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt()>0.005){
3081  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, fMCEvent, fInputEvent);
3082  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3083  }
3084  }
3085  if (isTruePi0){
3086  fHistoTruePrimaryPi0GGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3087 
3088  } else if (isTrueEta) {
3089  fHistoTruePrimaryEtaGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3090  }
3091 
3092  }
3093  }
3094 
3095  }
3096 
3097  } else if( !isTruePi0 && !isTrueEta ){ // Background
3098 
3099  if (fDoMesonQA > 0){
3100  if(virtualGammaMotherLabel>-1 && gamma1MotherLabel>-1 && virtualGamma == 0){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
3101  fHistoTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3102  } else { // No photon or without mother
3103  fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3104  }
3105  }
3106  }
3107 
3108 
3109  if (isTrueEta && !matched){
3110  fStringRecTrueEtas[fiCut].Append(Form("%i,",virtualGammaMotherLabel));
3111  }
3112  if (isTruePi0 && !matched){
3113  fStringRecTruePi0s[fiCut].Append(Form("%i,",virtualGammaMotherLabel));
3114  }
3115 
3116 }
3117 //______________________________________________________________________
3119 {
3120  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3121  Double_t mcProdVtxX = primVtxMC->GetX();
3122  Double_t mcProdVtxY = primVtxMC->GetY();
3123  Double_t mcProdVtxZ = primVtxMC->GetZ();
3124 
3125  // Process True Mesons
3126  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3127  Bool_t isTruePi0 = kFALSE;
3128  Bool_t isTrueEta = kFALSE;
3129 
3130  AliAODMCParticle *positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
3131  AliAODMCParticle *negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
3132 
3133  Int_t gamma0MCLabel = -1;
3134  Int_t gamma0MotherLabel = -1;
3135  if(!positiveMC||!negativeMC)
3136  return;
3137 
3138  if (TrueGammaCandidate0->IsTrueConvertedPhoton()){
3139  gamma0MCLabel = positiveMC->GetMother();
3140  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3141  gamma0MotherLabel=gammaMC0->GetMother();
3142  }
3143 
3144  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3145  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
3146  Int_t gamma1MotherLabel = -1;
3147  // check if
3148 
3149  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3150  // Daughters Gamma 1
3151  AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3152  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
3153  // get mother of interest (pi0 or eta)
3154  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
3155  gamma1MotherLabel=gammaMC1->GetMother();
3156  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
3157  if (TrueGammaCandidate1->IsConversion()){
3158  AliAODMCParticle * gammaGrandMotherMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC1->GetMother()));
3159  gamma1MotherLabel=gammaGrandMotherMC1->GetMother();
3160  } else gamma1MotherLabel=gammaMC1->GetMother();
3161  }
3162  } else {
3163  if (fDoMesonQA > 0) fHistoTrueMotherCaloEMNonLeadingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3164  }
3165  }
3166 
3167  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3168  if(((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
3169  isTruePi0=kTRUE;
3170  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma1MotherLabel)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3171  }
3172  if(((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 221){
3173  isTrueEta=kTRUE;
3174  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueEtas,gamma1MotherLabel)) fHistoDoubleCountTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3175  }
3176  }
3177 
3178  if(isTruePi0 || isTrueEta){// True Pion or Eta
3179  if (!matched){
3180  if (isTruePi0)fHistoTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3181  if (isTrueEta)fHistoTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3182  }
3183  if (fDoMesonQA > 0){
3184  if (TrueGammaCandidate1->IsLargestComponentPhoton() && !matched){
3185  if (isTruePi0) fHistoTruePi0CaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3186  if (isTrueEta) fHistoTrueEtaCaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3187  }
3188  if (TrueGammaCandidate1->IsLargestComponentElectron() && !matched) {
3189  if (isTruePi0) fHistoTruePi0CaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3190  if (isTrueEta) fHistoTrueEtaCaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3191  }
3192  if (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()){
3193 
3194  if (isTruePi0 && !matched)fHistoTruePi0CaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3195  if (isTrueEta && !matched)fHistoTrueEtaCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3196  if ((TrueGammaCandidate0->GetMCLabelPositive() == gamma1MCLabel || TrueGammaCandidate0->GetMCLabelNegative() == gamma1MCLabel) && isTruePi0)
3197  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3198  if ((TrueGammaCandidate0->GetMCLabelPositive() == gamma1MCLabel || TrueGammaCandidate0->GetMCLabelNegative() == gamma1MCLabel) && isTrueEta)
3199  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3200  }
3201  if ((TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged()) && !matched ){
3202  if (isTruePi0) fHistoTruePi0CaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3203  if (isTrueEta) fHistoTrueEtaCaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3204  }
3205  if (TrueGammaCandidate1->IsMergedPartConv() && !matched) {
3206  if (isTruePi0) fHistoTruePi0CaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3207  if (isTrueEta) fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3208  }
3209  }
3210 
3211  if ( !matched){
3212  if (fDoMesonQA > 0){
3213  if (isTruePi0){
3214  if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
3215  fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3216  fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()));
3217  fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3218  fHistoTrueMotherPi0ConvPhotonEtaPhi[fiCut]->Fill(TrueGammaCandidate0->GetPhotonPhi(), TrueGammaCandidate0->GetPhotonEta());
3219  }
3220  } else if (isTrueEta){
3221  if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
3222  fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3223  fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()));
3224  fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3225  fHistoTrueMotherEtaConvPhotonEtaPhi[fiCut]->Fill(TrueGammaCandidate0->GetPhotonPhi(), TrueGammaCandidate0->GetPhotonEta());
3226  }
3227  }
3228  }
3229  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel)), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3230  if(isPrimary){ // Secondary Meson
3231  Int_t secMotherLabel = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetMother();
3232  Float_t weightedSec= 1;
3233  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, 0x0, fInputEvent) && static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
3234  weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(secMotherLabel, 0x0, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
3235  //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3236  }
3237  if (isTruePi0){
3238  fHistoTrueSecondaryPi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3239  fHistoTrueSecondaryPi0PhotonPairPtconv[fiCut]->Fill(Pi0Candidate->M(),TrueGammaCandidate0->Pt(),weightedSec);
3240  if(CheckIfContainedInString(fStringRecTruePi0s[fiCut],gamma0MotherLabel)){
3241  fHistoTrueSecondaryPi0DCPtconv[fiCut]->Fill(TrueGammaCandidate0->Pt(),weightedSec);
3242  }
3243  }
3244  if (secMotherLabel >-1){
3245  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310 && isTruePi0){
3246  fHistoTrueSecondaryPi0FromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3247  if (fDoMesonQA > 0)fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3248  }
3249  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==221 && isTruePi0){
3250  fHistoTrueSecondaryPi0FromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3251  if (fDoMesonQA > 0)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3252  }
3253  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==3122 && isTruePi0){
3254  fHistoTrueSecondaryPi0FromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3255  if (fDoMesonQA > 0)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3256  }
3257  }
3258  } else{ // Only primary pi0 for efficiency calculation
3259  Float_t weighted= 1;
3260  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, 0x0, fInputEvent)){
3261  if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt()>0.005){
3262  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, 0x0, fInputEvent);
3263  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3264  }
3265  }
3266  if (isTruePi0){
3267  fHistoTruePrimaryPi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3268  fHistoTruePrimaryPi0W0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3269  fHistoTruePrimaryPi0PhotonPairPtconv[fiCut]->Fill(Pi0Candidate->M(),TrueGammaCandidate0->Pt(),weighted);
3270  fProfileTruePrimaryPi0WeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3271  if(CheckIfContainedInString(fStringRecTruePi0s[fiCut],gamma0MotherLabel)){
3272  fHistoTruePrimaryPi0DCPtconv[fiCut]->Fill(TrueGammaCandidate0->Pt(),weighted);
3273  }
3274  } else if (isTrueEta){
3275  fHistoTruePrimaryEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3276  fHistoTruePrimaryEtaW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3277  fHistoTruePrimaryEtaPhotonPairPtconv[fiCut]->Fill(Pi0Candidate->M(),TrueGammaCandidate0->Pt(),weighted);
3278  fProfileTruePrimaryEtaWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3279  if(CheckIfContainedInString(fStringRecTrueEtas[fiCut],gamma0MotherLabel)){
3280  fHistoTruePrimaryEtaDCPtconv[fiCut]->Fill(TrueGammaCandidate0->Pt(),weighted);
3281  }
3282  }
3283  if (fDoMesonQA > 0){
3284  if(isTruePi0){ // Only primary pi0 for resolution
3285  fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
3286  (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
3287 
3288  }
3289  if (isTrueEta){ // Only primary eta for resolution
3290  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
3291  (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
3292  }
3293  }
3294  }
3295  }
3296  } else if(!isTruePi0 && !isTrueEta) { // Background
3297  if (fDoMesonQA > 0){
3298  if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
3299  fHistoTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3300  } else { // No photon or without mother
3301  fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3302  }
3303  }
3304  }
3305 
3306  if (isTrueEta && !matched){
3307  fStringRecTrueEtas[fiCut].Append(Form("%i,",gamma0MotherLabel));
3308  }
3309  if (isTruePi0 && !matched){
3310  fStringRecTruePi0s[fiCut].Append(Form("%i,",gamma0MotherLabel));
3311  }
3312 
3313 
3314 
3315 }
3316 
3317 //________________________________________________________________________
3319 {
3320  Int_t nV0 = 0;
3321  TList *GammaCandidatesStepOne = new TList();
3322  TList *GammaCandidatesStepTwo = new TList();
3323  // Loop over Photon Candidates allocated by ReaderV1
3324  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
3325  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
3326  if(!PhotonCandidate) continue;
3327  fIsFromMBHeader = kTRUE;
3328 
3329  if(fIsMC && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3330 
3331  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
3332  if(isPosFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3333  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
3334  if(isNegFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3335  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
3336  }
3337 
3338  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fInputEvent)) continue;
3339  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->InPlaneOutOfPlaneCut(PhotonCandidate->GetPhotonPhi(),fEventPlaneAngle)) continue;
3340  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut() &&
3341  !((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){
3342  fGammaCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
3343 
3344  if(fIsFromMBHeader){
3345  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
3346  if (fDoPhotonQA > 0){
3347  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
3348  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
3349  }
3350  }
3351  if(fIsMC){
3352  if(fInputEvent->IsA()==AliESDEvent::Class())
3353  ProcessTruePhotonCandidates(PhotonCandidate);
3354  if(fInputEvent->IsA()==AliAODEvent::Class())
3355  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
3356  }
3357 
3358  } else if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
3359  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
3360  nV0++;
3361  GammaCandidatesStepOne->Add(PhotonCandidate);
3362  } else if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut() &&
3363  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
3364  GammaCandidatesStepTwo->Add(PhotonCandidate);
3365  }
3366  }
3367 
3368  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut()){
3369  for(Int_t i = 0;i<GammaCandidatesStepOne->GetEntries();i++){
3370  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GammaCandidatesStepOne->At(i);
3371  if(!PhotonCandidate) continue;
3372  fIsFromMBHeader = kTRUE;
3373  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3374  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
3375  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
3376  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
3377  }
3378  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GammaCandidatesStepOne->GetEntries())) continue;
3379  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
3380  fGammaCandidates->Add(PhotonCandidate);
3381  if(fIsFromMBHeader){
3382  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
3383  if (fDoPhotonQA > 0){
3384  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
3385  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
3386  }
3387  }
3388 
3389  if(fIsMC){
3390  if(fInputEvent->IsA()==AliESDEvent::Class())
3391  ProcessTruePhotonCandidates(PhotonCandidate);
3392  if(fInputEvent->IsA()==AliAODEvent::Class())
3393  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
3394  }
3395 
3396  }
3397  else GammaCandidatesStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
3398 
3399 
3400  }
3401  }
3402  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){
3403  for(Int_t i = 0;i<GammaCandidatesStepTwo->GetEntries();i++){
3404  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GammaCandidatesStepTwo->At(i);
3405  if(!PhotonCandidate) continue;
3406  fIsFromMBHeader = kTRUE;
3407  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3408  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
3409  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
3410  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
3411  }
3412  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GammaCandidatesStepTwo,i)) continue;
3413  fGammaCandidates->Add(PhotonCandidate); // Add gamma to current cut TList
3414  if(fIsFromMBHeader){
3415  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
3416  if (fDoPhotonQA > 0){
3417  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
3418  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
3419  }
3420  }
3421  if(fIsMC){
3422  if(fInputEvent->IsA()==AliESDEvent::Class())
3423  ProcessTruePhotonCandidates(PhotonCandidate);
3424  if(fInputEvent->IsA()==AliAODEvent::Class())
3425  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
3426  }
3427 
3428  }
3429  }
3430 
3431  delete GammaCandidatesStepOne;
3432  GammaCandidatesStepOne = 0x0;
3433  delete GammaCandidatesStepTwo;
3434  GammaCandidatesStepTwo = 0x0;
3435 
3436 }
3437 //________________________________________________________________________
3439 {
3440 
3441  Double_t magField = fInputEvent->GetMagneticField();
3442  if( magField < 0.0 ){
3443  magField = 1.0;
3444  }
3445  else {
3446  magField = -1.0;
3447  }
3448 
3449  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3450  if (AODMCTrackArray == NULL) return;
3451  AliAODMCParticle *posDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelPositive());
3452  AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelNegative());
3453  fCharPhotonMCInfo = 0;
3454 
3455  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
3456  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
3457 
3458  if(posDaughter->GetMother() != negDaughter->GetMother()){
3459 
3460  fCharPhotonMCInfo = 1;
3461  return;
3462  }
3463  else if(posDaughter->GetMother() == -1){
3464 
3465  fCharPhotonMCInfo = 1;
3466  return;
3467  }
3468 
3469  if(pdgCode[0]!=11 || pdgCode[1]!=11){
3470  fCharPhotonMCInfo = 1;
3471  return; //One Particle is not a electron
3472  }
3473 
3474  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()){
3475  fCharPhotonMCInfo = 1;
3476  return; // Same Charge
3477  }
3478 
3479  AliAODMCParticle *Photon = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
3480  if(Photon->GetPdgCode() != 22){
3481  fCharPhotonMCInfo = 1;
3482  return; // Mother is no Photon
3483  }
3484 
3485  if(((posDaughter->GetMCProcessCode())) != 5 || ((negDaughter->GetMCProcessCode())) != 5){
3486  fCharPhotonMCInfo = 1;
3487  return;// check if the daughters come from a conversion
3488  }
3489  // STILL A BUG IN ALIROOT >>8 HAS TPO BE REMOVED AFTER FIX
3490 
3491 
3492 
3493  // True Photon
3494  if(fIsFromMBHeader){
3495  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3496  if (fDoPhotonQA > 0) fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta());
3497  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueConvGammas,posDaughter->GetMother())) fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt());
3498  }
3499 
3500  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3501  Double_t mcProdVtxX = primVtxMC->GetX();
3502  Double_t mcProdVtxY = primVtxMC->GetY();
3503  Double_t mcProdVtxZ = primVtxMC->GetZ();
3504  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3505 
3506  if(isPrimary){
3507  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
3508  if(fIsFromMBHeader){
3509  fCharPhotonMCInfo = 6;
3510  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3511  fHistoTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
3512  }
3513  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
3514  } else {
3515  if(fIsFromMBHeader){
3516  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3517  fCharPhotonMCInfo = 2;
3518  if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 &&
3519  ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 3122){
3520  fCharPhotonMCInfo = 5;
3521  fHistoTrueSecondaryConvGammaFromXFromLambdaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3522  }
3523  if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 &&
3524  ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 310){
3525  fCharPhotonMCInfo = 4;
3526  fHistoTrueSecondaryConvGammaFromXFromK0sPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3527  }
3528  if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 &&
3529  ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 221){
3530  fCharPhotonMCInfo = 3;
3531  }
3532  }
3533  }
3534  TruePhotonCandidate->SetIsTrueConvertedPhoton();
3535 }
3536 
3537 //________________________________________________________________________
3539 {
3540  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3541  Double_t mcProdVtxX = primVtxMC->GetX();
3542  Double_t mcProdVtxY = primVtxMC->GetY();
3543  Double_t mcProdVtxZ = primVtxMC->GetZ();
3544 
3545  Double_t magField = fInputEvent->GetMagneticField();
3546  if( magField < 0.0 ){
3547  magField = 1.0;
3548  }
3549  else {
3550  magField = -1.0;
3551  }
3552 
3553  // Process True Photons
3554  TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCEvent);
3555  TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCEvent);
3556  fCharPhotonMCInfo = 0;
3557 
3558  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
3559  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
3560  fCharPhotonMCInfo = 1;
3561  if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){
3562 
3563  return;
3564  }
3565  else if(posDaughter->GetMother(0) == -1){
3566 
3567  return;
3568  }
3569 
3570  if(pdgCode[0]!=11 || pdgCode[1]!=11) return; //One Particle is not a electron
3571 
3572  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
3573 
3574  TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCEvent);
3575 
3576  if(Photon->GetPdgCode() != 22){
3577  return; // Mother is no Photon
3578  }
3579 
3580  if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
3581 
3582  // True Photon
3583  if(fIsFromMBHeader){
3584  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3585  if (fDoPhotonQA > 0) fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta());
3586  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueConvGammas,posDaughter->GetMother(0))) fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt());
3587  }
3588  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, posDaughter->GetMother(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3589  if(isPrimary){
3590  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
3591  if(fIsFromMBHeader){
3592  fCharPhotonMCInfo = 6;
3593  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3594  fHistoTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
3595  }
3596  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
3597  } else {
3598  // fill secondary histograms
3599  if(fIsFromMBHeader){
3600  fCharPhotonMCInfo = 2;
3601  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3602  if(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0) > -1 &&
3603  fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 3122){
3604  fHistoTrueSecondaryConvGammaFromXFromLambdaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3605  fCharPhotonMCInfo = 5;
3606  }
3607  if(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0) > -1 &&
3608  fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
3609  fHistoTrueSecondaryConvGammaFromXFromK0sPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3610  fCharPhotonMCInfo = 4;
3611  }
3612  if(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0) > -1 &&
3613  fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 221){
3614  fCharPhotonMCInfo = 3;
3615  }
3616  }
3617  }
3618  TruePhotonCandidate->SetIsTrueConvertedPhoton();
3619  return;
3620 }
3621 //________________________________________________________________________
3623 
3624  Int_t zbin= fBGClusHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3625  Int_t mbin = 0;
3626 
3627 
3628  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3630  } else {
3632  }
3633 
3634 
3636 
3637  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3638 
3639  for(Int_t nEventsInBG=0;nEventsInBG<fBGClusHandler[fiCut]->GetNBGEvents();nEventsInBG++){
3640 
3641  AliGammaConversionAODVector *previousEventV0s = fBGClusHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
3642  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3643  bgEventVertex = fBGClusHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
3644  }
3645 
3646  for(Int_t iCurrent=0;iCurrent<fVirtualGammaCandidates->GetEntries();iCurrent++){
3647 
3648  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fVirtualGammaCandidates->At(iCurrent));
3649 
3650  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3651  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
3652 
3653  if(fMoveParticleAccordingToVertex == kTRUE){
3654  if (bgEventVertex){
3655  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3656  }
3657  }
3658  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3659  if (bgEventVertex){
3660  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
3661  }
3662  }
3663 
3664  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
3665  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3667  ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3668 
3669 
3670  if( ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->DoMassCut() == kTRUE ) {
3671 
3672  if( ((AliDalitzElectronCuts*) fElectronCutArray->At(fiCut))->MassCut( backgroundCandidate->Pt() , currentEventGoodV0.M() ) == kTRUE ){
3673 
3674 
3675  fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
3676 
3677  if(fDoTHnSparse){
3678  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3679  fSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
3680  }
3681  }
3682  }
3683  }
3684  delete backgroundCandidate;
3685  backgroundCandidate = 0x0;
3686  }
3687  }
3688  }
3689  } else {
3690  for(Int_t nEventsInBG=0;nEventsInBG <fBGClusHandler[fiCut]->GetNBGEvents();nEventsInBG++){
3691  AliGammaConversionAODVector *previousEventV0s = fBGClusHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
3692  if(previousEventV0s){
3693  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0 ){
3694  bgEventVertex = fBGClusHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
3695  }
3696  for(Int_t iCurrent=0;iCurrent<fVirtualGammaCandidates->GetEntries();iCurrent++){
3697  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fVirtualGammaCandidates->At(iCurrent));
3698  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3699 
3700  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
3701 
3702  if(fMoveParticleAccordingToVertex == kTRUE){
3703  if (bgEventVertex){
3704  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3705  }
3706  }
3707  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3708  if (bgEventVertex){
3709  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
3710  }
3711  }
3712 
3713  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
3714  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3715  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3716 
3717  if( ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->DoMassCut() == kTRUE ) {
3718 
3719  if( ((AliDalitzElectronCuts*) fElectronCutArray->At(fiCut))->MassCut( backgroundCandidate->Pt() , currentEventGoodV0.M() ) == kTRUE ){
3720 
3721 
3722  fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
3723 
3724  if(fDoTHnSparse){
3725  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3726  fSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
3727  }
3728  }
3729  }
3730  }
3731  delete backgroundCandidate;
3732  backgroundCandidate = 0x0;
3733  }
3734  }
3735  }
3736  }
3737  }
3738 }
3739 
3740 //________________________________________________________________________
3742  Int_t fNDegreesPMBackground= ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->NDegreesRotation();
3743  Double_t nRadiansPM = fNDegreesPMBackground*TMath::Pi()/180;
3744  Double_t rotationValue = fRandom.Rndm()*2*nRadiansPM + TMath::Pi()-nRadiansPM;
3745  gamma->RotateZ(rotationValue);
3746 }
3747 
3748 //________________________________________________________________________
3750 
3751  previousEventEP=previousEventEP+TMath::Pi();
3752  thisEventEP=thisEventEP+TMath::Pi();
3753  Double_t rotationValue= thisEventEP-previousEventEP;
3754  gamma->RotateZ(rotationValue);
3755 }
3756 
3757 //________________________________________________________________________
3759  //see header file for documentation
3760 
3761  Double_t dx = vertex->fX - fInputEvent->GetPrimaryVertex()->GetX();
3762  Double_t dy = vertex->fY - fInputEvent->GetPrimaryVertex()->GetY();
3763  Double_t dz = vertex->fZ - fInputEvent->GetPrimaryVertex()->GetZ();
3764 
3765  Double_t movedPlace[3] = {particle->GetConversionX() - dx,particle->GetConversionY() - dy,particle->GetConversionZ() - dz};
3766  particle->SetConversionPoint(movedPlace);
3767 }
3768 //________________________________________________________________________
3770  //see header file for documentation
3771  if( fClusterCandidates->GetEntries() > 0 ){
3772  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3773  fBGClusHandler[fiCut]->AddEvent(fClusterCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),fEventPlaneAngle);
3774  } else { // means we use #V0s for multiplicity
3775  fBGClusHandler[fiCut]->AddEvent(fClusterCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fClusterCandidates->GetEntries(),fEventPlaneAngle);
3776  }
3777  }
3778 }
3779 
3780 //________________________________________________________________________
3782 
3783  // Relabeling For AOD Event
3784  // ESDiD -> AODiD
3785  // MCLabel -> AODMCLabel
3786 
3787  if(mode){
3788  fMCEventPos = new Int_t[fReaderGammas->GetEntries()];
3789  fMCEventNeg = new Int_t[fReaderGammas->GetEntries()];
3790  fESDArrayPos = new Int_t[fReaderGammas->GetEntries()];
3791  fESDArrayNeg = new Int_t[fReaderGammas->GetEntries()];
3792  }
3793 
3794  for(Int_t iGamma = 0;iGamma<fReaderGammas->GetEntries();iGamma++){
3795  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(iGamma);
3796  if(!PhotonCandidate) continue;
3797  if(!mode){// Back to ESD Labels
3798  PhotonCandidate->SetMCLabelPositive(fMCEventPos[iGamma]);
3799  PhotonCandidate->SetMCLabelNegative(fMCEventNeg[iGamma]);
3800  PhotonCandidate->SetLabelPositive(fESDArrayPos[iGamma]);
3801  PhotonCandidate->SetLabelNegative(fESDArrayNeg[iGamma]);
3802  continue;
3803  }
3804  fMCEventPos[iGamma] = PhotonCandidate->GetMCLabelPositive();
3805  fMCEventNeg[iGamma] = PhotonCandidate->GetMCLabelNegative();
3806  fESDArrayPos[iGamma] = PhotonCandidate->GetTrackLabelPositive();
3807  fESDArrayNeg[iGamma] = PhotonCandidate->GetTrackLabelNegative();
3808 
3809  Bool_t AODLabelPos = kFALSE;
3810  Bool_t AODLabelNeg = kFALSE;
3811 
3812  for(Int_t i = 0; i<fInputEvent->GetNumberOfTracks();i++){
3813  AliAODTrack *tempDaughter = static_cast<AliAODTrack*>(fInputEvent->GetTrack(i));
3814  if(!AODLabelPos){
3815  if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelPositive() ){
3816  PhotonCandidate->SetMCLabelPositive(TMath::Abs(tempDaughter->GetLabel()));
3817  PhotonCandidate->SetLabelPositive(i);
3818  AODLabelPos = kTRUE;
3819  }
3820  }
3821  if(!AODLabelNeg){
3822  if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelNegative()){
3823  PhotonCandidate->SetMCLabelNegative(TMath::Abs(tempDaughter->GetLabel()));
3824  PhotonCandidate->SetLabelNegative(i);
3825  AODLabelNeg = kTRUE;
3826  }
3827  }
3828  if(AODLabelNeg && AODLabelPos){
3829  break;
3830  }
3831  }
3832  if(!AODLabelPos || !AODLabelNeg){
3833  cout<<"WARNING!!! AOD TRACKS NOT FOUND FOR"<<endl;
3834  }
3835  }
3836 
3837 
3838  if(!mode){
3839  delete[] fMCEventPos;
3840  delete[] fMCEventNeg;
3841  delete[] fESDArrayPos;
3842  delete[] fESDArrayNeg;
3843  }
3844 }
3845 
3847  TAxis *axisafter = histoRebin->GetXaxis();
3848  Int_t bins = axisafter->GetNbins();
3849  Double_t from = axisafter->GetXmin();
3850  Double_t to = axisafter->GetXmax();
3851  Double_t *newbins = new Double_t[bins+1];
3852  newbins[0] = from;
3853  Double_t factor = TMath::Power(to/from, 1./bins);
3854  for(Int_t i=1; i<=bins; ++i) newbins[i] = factor * newbins[i-1];
3855  axisafter->Set(bins, newbins);
3856  delete [] newbins;
3857 }
3858 
3859 //________________________________________________________________________
3861 {
3862 
3863  //fOutputContainer->Print(); // Will crash on GRID
3864 }
3865 
3866 //________________________________________________________________________
3868 
3869  if (daughter == 111) {
3870  if (TMath::Abs(pdgCode) == 310) return 1; // k0s
3871  else if (TMath::Abs(pdgCode) == 3122) return 2; // Lambda
3872  else if (TMath::Abs(pdgCode) == 130) return 3; // K0L
3873  else if (TMath::Abs(pdgCode) == 2212) return 4; // proton
3874  else if (TMath::Abs(pdgCode) == 2112) return 5; // neutron
3875  else if (TMath::Abs(pdgCode) == 211) return 6; // pion
3876  else if (TMath::Abs(pdgCode) == 321) return 7; // kaon
3877  else if (TMath::Abs(pdgCode) == 113 || TMath::Abs(pdgCode) == 213 ) return 8; // rho 0,+,-
3878  else if (TMath::Abs(pdgCode) == 3222 || TMath::Abs(pdgCode) == 3212 || TMath::Abs(pdgCode) == 3112 ) return 9; // Sigma
3879  else if (TMath::Abs(pdgCode) == 2224 || TMath::Abs(pdgCode) == 2214 || TMath::Abs(pdgCode) == 2114 || TMath::Abs(pdgCode) == 1114 ) return 10; // Delta
3880  else if (TMath::Abs(pdgCode) == 313 || TMath::Abs(pdgCode) == 323 ) return 11; // K*
3881  else return 15;
3882  }
3883  return 15;
3884 
3885 }
3886 
3887 //_________________________________________________________________________________
3889  TObjArray *arr = input.Tokenize(",");
3890  for (Int_t i = 0; i < arr->GetEntriesFast();i++){
3891  TString tempStr = ((TObjString*)arr->At(i))->GetString();
3892  if (tempStr.Atoi() == tobechecked) return kTRUE;
3893  }
3894  return kFALSE;
3895 }
3896 
3897 //_________________________________________________________________________________
3899  TObjArray *arr = input.Tokenize(",");
3900  Bool_t isContained = kFALSE;
3901  for (Int_t i = 0; i < arr->GetEntriesFast();i++){
3902  TString tempStr = ((TObjString*)arr->At(i))->GetString();
3903  if (tempStr.Atoi() == tobechecked) isContained= kTRUE;
3904  }
3905  if (!isContained)input.Append(Form("%i,",tobechecked));
3906  return isContained;
3907 }
3908 
3909 //_________________________________________________________________________________
3911 
3912  if (!fMCEvent) return;
3913 
3914  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3915  Double_t mcProdVtxX = primVtxMC->GetX();
3916  Double_t mcProdVtxY = primVtxMC->GetY();
3917  Double_t mcProdVtxZ = primVtxMC->GetZ();
3918 
3919  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
3920 
3921  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
3922 
3923  if (gamma0->IsTrueConvertedPhoton()){
3924  Int_t gamma0MotherLabel = -1;
3925  Int_t gamma0MCLabel = gamma0->GetMCParticleLabel(fMCEvent);
3926  if(gamma0MCLabel != -1){
3927  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
3928  gamma0MotherLabel=gammaMC0->GetFirstMother();
3929  if (gamma0MotherLabel>-1){
3930  if(((TParticle*)fMCEvent->Particle(gamma0MotherLabel))->GetPdgCode() == 111){
3932 
3933  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, gamma0MotherLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3934 
3935  if (!isPrimary){
3936  Int_t secMotherLabel = ((TParticle*)fMCEvent->Particle(gamma0MotherLabel))->GetMother(0);
3937  Float_t weightedSec= 1;
3938  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, fMCEvent, fInputEvent) && fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310){
3939  weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(secMotherLabel, fMCEvent, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
3940  }
3941  fHistoTrueSecondaryPi0MissingPtconv[fiCut]->Fill(gamma0->Pt(),weightedSec);
3942  } else {
3943  Float_t weighted= 1;
3944  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma0MotherLabel, fMCEvent, fInputEvent)){
3945  if (((TParticle*)fMCEvent->Particle(gamma0MotherLabel))->Pt()>0.005){
3946  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma0MotherLabel, fMCEvent, fInputEvent);
3947  }
3948  }
3949  fHistoTruePrimaryPi0MissingPtconv[fiCut]->Fill(gamma0->Pt(),weighted);
3950  }
3951  }
3952  } else if(((TParticle*)fMCEvent->Particle(gamma0MotherLabel))->GetPdgCode() == 221){
3954  Float_t weighted= 1;
3955  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma0MotherLabel, fMCEvent, fInputEvent)){
3956  if (((TParticle*)fMCEvent->Particle(gamma0MotherLabel))->Pt()>0.005){
3957  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma0MotherLabel, fMCEvent, fInputEvent);
3958  }
3959  }
3960  fHistoTruePrimaryEtaMissingPtconv[fiCut]->Fill(gamma0->Pt(),weighted);
3961  }
3962  }
3963  }
3964  }
3965  }
3966  }
3967 
3968 }
3969 
3970 //_________________________________________________________________________________
3972 
3973  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3974  Double_t mcProdVtxX = primVtxMC->GetX();
3975  Double_t mcProdVtxY = primVtxMC->GetY();
3976  Double_t mcProdVtxZ = primVtxMC->GetZ();
3977 
3978  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3979 
3980  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
3981  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
3982 
3983  if (gamma0->IsTrueConvertedPhoton()){
3984  AliAODMCParticle *positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0->GetMCLabelPositive()));
3985  AliAODMCParticle *negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0->GetMCLabelNegative()));
3986 
3987  Int_t gamma0MCLabel = -1;
3988  Int_t gamma0MotherLabel = -1;
3989  if(!positiveMC||!negativeMC)
3990  return;
3991 
3992  if (gamma0->IsTrueConvertedPhoton()){
3993  gamma0MCLabel = positiveMC->GetMother();
3994  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3995  gamma0MotherLabel=gammaMC0->GetMother();
3996 
3997  if (gamma0MotherLabel>-1){
3998  if(((AliAODMCParticle*)AODMCTrackArray->At(gamma0MotherLabel))->GetPdgCode() == 111){
4000  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel)), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
4001  if (isPrimary){
4002  Int_t secMotherLabel = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel))->GetMother();
4003  Float_t weightedSec= 1;
4004  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, 0x0, fInputEvent) && static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
4005  weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(secMotherLabel, 0x0, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
4006  }
4007  fHistoTrueSecondaryPi0MissingPtconv[fiCut]->Fill(gamma0->Pt(),weightedSec);
4008  } else {
4009  Float_t weighted= 1;
4010  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma0MotherLabel, 0x0, fInputEvent)){
4011  if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel))->Pt()>0.005){
4012  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma0MotherLabel, 0x0, fInputEvent);
4013  }
4014  }
4015  fHistoTruePrimaryPi0MissingPtconv[fiCut]->Fill(gamma0->Pt(),weighted);
4016  }
4017  }
4018  } else if(((AliAODMCParticle*)AODMCTrackArray->At(gamma0MotherLabel))->GetPdgCode() == 221){
4020  Float_t weighted= 1;
4021  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma0MotherLabel, 0x0, fInputEvent)){
4022  if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel))->Pt()>0.005){
4023  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma0MotherLabel, 0x0, fInputEvent);
4024  }
4025  }
4026  fHistoTruePrimaryEtaMissingPtconv[fiCut]->Fill(gamma0->Pt(),weighted);
4027  }
4028  }
4029  }
4030  }
4031  }
4032  }
4033 
4034  return;
4035 }
4036 
4037 //________________________________________________________________________
4039 
4040  const AliVVertex* primVtxMC = 0;
4041  Double_t mcProdVtxX = 0;
4042  Double_t mcProdVtxY = 0;
4043  Double_t mcProdVtxZ = 0;
4044 
4045 
4046 
4047 
4048  if ( fMCEvent ) {
4049 
4050  primVtxMC = fMCEvent->GetPrimaryVertex();
4051  mcProdVtxX = primVtxMC->GetX();
4052  mcProdVtxY = primVtxMC->GetY();
4053  mcProdVtxZ = primVtxMC->GetZ();
4054 
4055  }
4056 
4057 
4058 
4059  Double_t magField = fInputEvent->GetMagneticField();
4060 
4061 
4062  if( magField < 0.0 ){
4063 
4064  magField = 1.0;
4065 
4066  } else {
4067 
4068  magField = -1.0;
4069  }
4070 
4071 
4072  vector<Int_t> lGoodElectronIndexPrev(0);
4073  vector<Int_t> lGoodPositronIndexPrev(0);
4074 
4075 
4076 
4077  for(UInt_t i = 0; i < fSelectorElectronIndex.size(); i++){
4078 
4079  AliESDtrack* electronCandidate = (AliESDtrack*)fInputEvent->GetTrack(fSelectorElectronIndex[i]);
4080 
4081  if( fMCEvent ) {
4082 
4083  Int_t labelelectron = TMath::Abs( electronCandidate->GetLabel() );
4084  Int_t isMCFromMBHeader = -1;
4085 
4086  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0) {
4087  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(labelelectron,fMCEvent,fInputEvent);
4088  if( isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut) )->GetSignalRejection() != 3) continue;
4089  }
4090 
4091  }
4092 
4093 
4094  if(! ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->ElectronIsSelected(electronCandidate) ) continue;
4095 
4096  lGoodElectronIndexPrev.push_back( fSelectorElectronIndex[i] );
4097  fHistoDalitzElectronPt[fiCut]->Fill(electronCandidate->Pt());
4098  fHistoDalitzElectronPhi[fiCut]->Fill(electronCandidate->Phi());
4099 
4100 
4101  if( fMCEvent ) {
4102 
4103  Int_t labelelectron = TMath::Abs( electronCandidate->GetLabel() );
4104 
4105  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelelectron, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
4106 
4107 
4108  if( labelelectron >=0 && labelelectron < fMCEvent->GetNumberOfTracks() ){
4109  TParticle* electron = fMCEvent->Particle(labelelectron);
4110  if( electron->GetPdgCode() == 11 ){
4111  if( isPrimary ){
4112  fHistoTrueElectronPt[fiCut]->Fill(electronCandidate->Pt()); //primary electron
4113  } else {
4114  fHistoTrueSecElectronPt[fiCut]->Fill(electronCandidate->Pt()); //secondary electron
4115  }
4116  if( IsPi0DalitzDaughter(labelelectron) == kTRUE ) {
4117  if( isPrimary ) {
4118  fHistoTruePi0DalitzElectronPt[fiCut]->Fill(electronCandidate->Pt());
4119  } else {
4120  fHistoTruePi0DalitzSecElectronPt[fiCut]->Fill(electronCandidate->Pt());
4121  }
4122  }
4123  }
4124  }
4125  }
4126 
4127  }
4128 
4129 
4130 
4131  for(UInt_t i = 0; i < fSelectorPositronIndex.size(); i++){
4132 
4133 
4134  AliESDtrack* positronCandidate = (AliESDtrack*)fInputEvent->GetTrack( fSelectorPositronIndex[i] );
4135 
4136  if( fMCEvent ) {
4137 
4138  Int_t labelpositron = TMath::Abs( positronCandidate->GetLabel() );
4139  Int_t isMCFromMBHeader = -1;
4140 
4141  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0) {
4142  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(labelpositron,fMCEvent,fInputEvent);
4143  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
4144  }
4145  }
4146 
4147 
4148  if(! ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->ElectronIsSelected(positronCandidate) ) continue;
4149 
4150  lGoodPositronIndexPrev.push_back( fSelectorPositronIndex[i] );
4151  fHistoDalitzPositronPt[fiCut]->Fill( positronCandidate->Pt() );
4152  fHistoDalitzPositronPhi[fiCut]->Fill( positronCandidate->Phi() );
4153 
4154  if( fMCEvent ) {
4155  Int_t labelpositron = TMath::Abs( positronCandidate->GetLabel() );
4156  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelpositron, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
4157 
4158 
4159  if( labelpositron >=0 && labelpositron < fMCEvent->GetNumberOfTracks() ) {
4160  TParticle* positron = fMCEvent->Particle(labelpositron);
4161  if( positron->GetPdgCode() == -11 ){
4162  if( isPrimary ){
4163  fHistoTruePositronPt[fiCut]->Fill(positronCandidate->Pt());
4164  } else {
4165  fHistoTrueSecPositronPt[fiCut]->Fill(positronCandidate->Pt());
4166  }
4167  if( IsPi0DalitzDaughter(labelpositron) == kTRUE ) {
4168  if( isPrimary ){
4169  fHistoTruePi0DalitzPositronPt[fiCut]->Fill(positronCandidate->Pt());
4170  } else {
4171  fHistoTruePi0DalitzSecPositronPt[fiCut]->Fill(positronCandidate->Pt());
4172  }
4173  }
4174  }
4175  }
4176  }
4177  }
4178 
4179  vector<Bool_t> lElectronPsiIndex(lGoodElectronIndexPrev.size(), kTRUE);
4180  vector<Bool_t> lPositronPsiIndex(lGoodPositronIndexPrev.size(), kTRUE);
4181 
4182  if( ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->DoPsiPairCut() == kTRUE ){
4183  for( UInt_t i = 0; i < lGoodElectronIndexPrev.size(); i++ ) {
4184  AliESDtrack *electronCandidate = (AliESDtrack*) fInputEvent->GetTrack(lGoodElectronIndexPrev[i]);
4185  for(UInt_t j = 0; j < lGoodPositronIndexPrev.size(); j++){
4186 
4187  AliESDtrack *positronCandidate = (AliESDtrack*) fInputEvent->GetTrack(lGoodPositronIndexPrev[j]);
4188  Double_t psiPair = GetPsiPair(positronCandidate,electronCandidate);
4189  Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->GetConstrainedParam()->Phi()-positronCandidate->GetConstrainedParam()->Phi());
4190 
4191  if( ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->IsFromGammaConversion(psiPair,deltaPhi ) ){
4192  lElectronPsiIndex[i] = kFALSE;
4193  lPositronPsiIndex[j] = kFALSE;
4194  }
4195  }
4196  }
4197  }
4198 
4199  vector<Int_t> lGoodElectronIndex(0);
4200  vector<Int_t> lGoodPositronIndex(0);
4201 
4202  for( UInt_t i = 0; i < lGoodElectronIndexPrev.size(); i++ ) {
4203  if( lElectronPsiIndex[i] == kTRUE )
4204  lGoodElectronIndex.push_back( lGoodElectronIndexPrev[i] );
4205  }
4206 
4207  for( UInt_t i = 0; i < lGoodPositronIndexPrev.size(); i++ ) {
4208  if( lPositronPsiIndex[i] == kTRUE )
4209  lGoodPositronIndex.push_back( lGoodPositronIndexPrev[i] );
4210  }
4211 
4212 
4213  for(UInt_t i = 0; i < lGoodElectronIndex.size(); i++){
4214 
4215  AliESDtrack *electronCandidate = (AliESDtrack*)fInputEvent->GetTrack(lGoodElectronIndex[i]);
4216  AliKFParticle electronCandidateKF( *electronCandidate->GetConstrainedParam(), ::kElectron );
4217 
4218  TLorentzVector electronCandidateTLV;
4219 
4220  electronCandidateTLV.SetXYZM(electronCandidate->GetConstrainedParam()->Px(),electronCandidate->GetConstrainedParam()->Py(),electronCandidate->GetConstrainedParam()->Pz(),TDatabasePDG::Instance()->GetParticle( ::kElectron )->Mass());
4221 
4222 
4223  for(UInt_t j = 0; j < lGoodPositronIndex.size(); j++){
4224 
4225  AliESDtrack *positronCandidate = (AliESDtrack*) fInputEvent->GetTrack(lGoodPositronIndex[j]);
4226  AliKFParticle positronCandidateKF( *positronCandidate->GetConstrainedParam(), ::kPositron );
4227  TLorentzVector positronCandidateTLV;
4228 
4229  positronCandidateTLV.SetXYZM(positronCandidate->GetConstrainedParam()->Px(),positronCandidate->GetConstrainedParam()->Py(),positronCandidate->GetConstrainedParam()->Pz(),TDatabasePDG::Instance()->GetParticle( ::kPositron )->Mass());
4230 
4231  TLorentzVector *virtualPhotonTLV = 0;
4232  AliKFConversionPhoton* virtualPhoton = NULL;
4233  AliAODConversionPhoton *vphoton;
4234 
4235  if( ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->GetUseElectronMCSmearing() && ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseMCPSmearing() && fMCEvent){
4236  TLorentzVector smearelectronCandidateTLV = ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->SmearElectron(electronCandidateTLV);
4237  TLorentzVector smearpositronCandidateTLV = ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->SmearElectron(positronCandidateTLV);
4238  virtualPhotonTLV = new TLorentzVector( smearelectronCandidateTLV + smearpositronCandidateTLV );
4239  vphoton= new AliAODConversionPhoton(virtualPhotonTLV);
4240  vphoton->SetMass(virtualPhotonTLV->M());
4241  } else {
4242  virtualPhoton = new AliKFConversionPhoton(electronCandidateKF,positronCandidateKF);
4243 
4244  AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex());
4245  primaryVertexImproved+=*virtualPhoton;
4246  virtualPhoton->SetProductionVertex(primaryVertexImproved);
4247 
4248  vphoton= new AliAODConversionPhoton(virtualPhoton);
4249  }
4250  vphoton->SetTrackLabels( lGoodPositronIndex[j], lGoodElectronIndex[i]);
4251 
4252  if( fMCEvent ) {
4253  Int_t labeln=TMath::Abs(electronCandidate->GetLabel());
4254  Int_t labelp=TMath::Abs(positronCandidate->GetLabel());
4255  TParticle *fNegativeMCParticle = fMCEvent->Particle(labeln);
4256  TParticle *fPositiveMCParticle = fMCEvent->Particle(labelp);
4257 
4258  if( fPositiveMCParticle && fNegativeMCParticle) {
4259  vphoton->SetMCLabelPositive(labelp);
4260  vphoton->SetMCLabelNegative(labeln);
4261 
4262  }
4263  }
4264 
4265 
4266  fVirtualGammaCandidates->Add( vphoton );
4267 
4268  if( virtualPhoton ){
4269  delete virtualPhoton;
4270  virtualPhoton=NULL;
4271  }
4272  if ( virtualPhotonTLV ){
4273  delete virtualPhotonTLV;
4274  virtualPhotonTLV=NULL;
4275  }
4276 
4277  }
4278  }
4279 
4280 }
4281 
4282 //_____________________________________________________________________________________
4284 {
4285 //
4286 // Returns true if the particle comes from Pi0 -> e+ e- gamma
4287 //
4288  Int_t motherLabel = fMCEvent->Particle( label )->GetMother(0);
4289 
4290  if( motherLabel < 0 || motherLabel >= fMCEvent->GetNumberOfTracks() ) return kFALSE;
4291 
4292  TParticle* mother = fMCEvent->Particle( motherLabel );
4293 
4294  if( mother->GetPdgCode() != 111 ) return kFALSE;
4295 
4296  if( IsDalitz( mother ) ) return kTRUE;
4297 
4298  return kFALSE;
4299 
4300 }
4301 //_____________________________________________________________________________
4302 Double_t AliAnalysisTaskGammaCaloDalitzV1::GetPsiPair( const AliESDtrack *trackPos, const AliESDtrack *trackNeg ) const
4303 {
4304  //
4305  // This angle is a measure for the contribution of the opening in polar
4306  // direction ?0 to the opening angle ? Pair
4307  //
4308  // Ref. Measurement of photons via conversion pairs with the PHENIX experiment at RHIC
4309  // Master Thesis. Thorsten Dahms. 2005
4310  // https://twiki.cern.ch/twiki/pub/ALICE/GammaPhysicsPublications/tdahms_thesis.pdf
4311  //
4312  Double_t momPos[3];
4313  Double_t momNeg[3];
4314  if( trackPos->GetConstrainedPxPyPz(momPos) == 0 ) trackPos->GetPxPyPz( momPos );
4315  if( trackNeg->GetConstrainedPxPyPz(momNeg) == 0 ) trackNeg->GetPxPyPz( momNeg );
4316 
4317  TVector3 posDaughter;
4318  TVector3 negDaughter;
4319 
4320  posDaughter.SetXYZ( momPos[0], momPos[1], momPos[2] );
4321  negDaughter.SetXYZ( momNeg[0], momNeg[1], momNeg[2] );
4322 
4323  Double_t deltaTheta = negDaughter.Theta() - posDaughter.Theta();
4324  Double_t openingAngle = posDaughter.Angle( negDaughter ); //TMath::ACos( posDaughter.Dot(negDaughter)/(negDaughter.Mag()*posDaughter.Mag()) );
4325 
4326  if( openingAngle < 1e-20 ) return 0.;
4327 
4328  Double_t psiAngle = TMath::ASin( deltaTheta/openingAngle );
4329 
4330  return psiAngle;
4331 }
4332 //_____________________________________________________________________________
4334 {
4335 
4336  if( fMCMother->GetNDaughters() != 3 ) return kFALSE;
4337  if( fMCMother->GetPdgCode() != 111 && fMCMother->GetPdgCode() != 221 ) return kFALSE;
4338 
4339 
4340  TParticle *positron = 0x0;
4341  TParticle *electron = 0x0;
4342  TParticle *gamma = 0x0;
4343 
4344  for(Int_t index= fMCMother->GetFirstDaughter();index<= fMCMother->GetLastDaughter();index++){
4345  TParticle* temp = (TParticle*)fMCEvent->Particle( index );
4346  switch( temp->GetPdgCode() ) {
4347  case ::kPositron:
4348  positron = temp;
4349  break;
4351  electron = temp;
4352  break;
4353  case ::kGamma:
4354  gamma = temp;
4355  break;
4356  }
4357  }
4358 
4359  if( positron && electron && gamma) return kTRUE;
4360 
4361  return kFALSE;
4362 }
4363 
4364 //_________________________________________________________________
4366 
4367 
4368 
4369  if( particleLabel < 0 ) return -1;
4370 
4371  TParticle* particle = (TParticle*)fMCEvent->Particle( particleLabel );
4372 
4373  if( particle->GetMother(0) < 0 ) return -1;
4374 
4375  else if ( ((TParticle*)fMCEvent->Particle( particle->GetMother(0) ) )->GetPdgCode() == 111 ||
4376  ((TParticle*)fMCEvent->Particle( particle->GetMother(0) ) )->GetPdgCode() == 221 ) {
4377 
4378  return particle->GetMother(0);
4379  }
4380 
4381  else return FindMotherOfPhoton( particle->GetMother(0) );
4382 
4383 
4384 }
4385 
4386 //_________________________________________________________________________________
4388 {
4389  if(tobechecked > -1)
4390  {