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