AliPhysics  ff07904 (ff07904)
AliAnalysisTaskGammaConvDalitzV1.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, Pedro Ladron de Guevara, Ernesto Lopez Torres, *
5 * Eulogio Serradilla, Ana Marin, Friederike Bock *
6 * Version 2 *
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 
17 // Analysis task for pi0->e+e-gamma (Dalitz decay)
18 // Analysis task for chic->JPsi+gamma
19 
20 #include <vector>
21 
22 #include "TParticle.h"
23 #include "TPDGCode.h"
24 #include "TMCProcess.h"
25 #include "TDatabasePDG.h"
26 #include "TList.h"
27 #include "TChain.h"
28 #include "TDirectory.h"
29 #include "TTree.h"
30 #include "TH1.h"
31 #include "TH1F.h"
32 #include "THnSparse.h"
33 #include "TH2F.h"
34 #include "AliAnalysisManager.h"
35 #include "AliESDInputHandler.h"
36 #include "AliESDtrack.h"
37 #include "AliMCEvent.h"
38 #include "AliMCEventHandler.h"
39 #include "AliPID.h"
40 #include "AliLog.h"
41 #include "AliESDtrackCuts.h"
42 #include "AliESDpidCuts.h"
43 #include "AliMCEvent.h"
44 #include "AliESDv0.h"
45 #include "AliESDEvent.h"
46 #include "AliESDpid.h"
47 #include "AliKFParticle.h"
48 #include "AliMCEventHandler.h"
49 #include "AliKFVertex.h"
50 #include "AliTriggerAnalysis.h"
51 #include "AliCentrality.h"
52 #include "AliMultiplicity.h"
54 #include "AliEventplane.h"
55 #include <vector>
56 
57 
59 
60 //-----------------------------------------------------------------------------------------------
62  fV0Reader(NULL),
63  fV0ReaderName("V0ReaderV1"),
64  fElecSelector(NULL),
65  fBGHandler(NULL),
66  fESDEvent(NULL),
67  fMCEvent(NULL),
68  fCutFolder(NULL),
69  fESDList(NULL),
70  fBackList(NULL),
71  fMotherList(NULL),
72  fTrueList(NULL),
73  fMCList(NULL),
74  fQAFolder(NULL),
75  fOutputContainer(0),
76  fReaderGammas(NULL),
77  fSelectorElectronIndex(0),
78  fSelectorPositronIndex(0),
79  fGoodGammas(NULL),
80  fGoodVirtualGammas(NULL),
81  fGoodElectrons(NULL),
82  fGoodPositrons(NULL),
83  fCutEventArray(NULL),
84  fCutGammaArray(NULL),
85  fCutElectronArray(NULL),
86  fCutMesonArray(NULL),
87  fEventCuts(NULL),
88  fConversionCuts(NULL),
89  hESDConvGammaPt(NULL),
90  hESDConvGammaEta(NULL),
91  //hESDConvGammaZR(NULL),
92  sESDConvGammaZR(NULL),
93  sESDConvGammaXY(NULL),
94  hESDDalitzElectronPt(NULL),
95  hESDDalitzPositronPt(NULL),
96  hESDDalitzElectronPhi(NULL),
97  hESDDalitzPositronPhi(NULL),
98  hESDDalitzElectronAfterPt(NULL),
99  hESDDalitzPositronAfterPt(NULL),
100  hESDDalitzElectronAfterEta(NULL),
101  hESDDalitzElectronAfterEtaPCut(NULL),
102  hESDDalitzPositronAfterEta(NULL),
103  hESDDalitzPositronAfterEtaPCut(NULL),
104  hESDDalitzElectronAfterPhi(NULL),
105  hESDDalitzPositronAfterPhi(NULL),
106  hESDDalitzElectronAfterNClsITS(NULL),
107  hESDDalitzElectronAfterNClsITSPCut(NULL),
108  hESDDalitzPositronAfterNClsITS(NULL),
109  hESDDalitzPositronAfterNClsITSPCut(NULL),
110  hESDDalitzElectronAfterNFindClsTPC(NULL),
111  hESDDalitzElectronAfterNFindClsTPCPCut(NULL),
112  hESDDalitzPositronAfterNFindClsTPC(NULL),
113  hESDDalitzPositronAfterNFindClsTPCPCut(NULL),
114  hESDDalitzElectronAfterNClsTPC(NULL),
115  hESDDalitzElectronAfterNClsTPCPCut(NULL),
116  hESDDalitzPositronAfterNClsTPC(NULL),
117  hESDDalitzPositronAfterNClsTPCPCut(NULL),
118  hESDDalitzElectronAfterNCrossedRowsTPC(NULL),
119  hESDDalitzElectronAfterNCrossedRowsTPCPCut(NULL),
120  hESDDalitzPositronAfterNCrossedRowsTPC(NULL),
121  hESDDalitzPositronAfterNCrossedRowsTPCPCut(NULL),
122  hESDDalitzPosEleAfterDCAxy(NULL),
123  hESDDalitzPosEleAfterDCAz(NULL),
124  hESDDalitzElectronAfterTPCdEdxVsP(NULL),
125  hESDDalitzPositronAfterTPCdEdxVsP(NULL),
126  hESDDalitzElectronAfterTPCdEdxSignalVsP(NULL),
127  hESDDalitzPositronAfterTPCdEdxSignalVsP(NULL),
128  hESDDalitzElectronAfterTPCdEdxVsEta(NULL),
129  hESDDalitzPositronAfterTPCdEdxVsEta(NULL),
130  hESDDalitzElectronAfterTPCdEdxVsPhi(NULL),
131  hESDDalitzPositronAfterTPCdEdxVsPhi(NULL),
132  hESDEposEnegPsiPairDPhi(NULL),
133  hESDEposEnegPsiPairEta(NULL),
134  hESDEposEnegDPhiEta(NULL),
135  hESDEposEnegInvMassPt(NULL),
136  hESDTruePi0EposEnegInvMassPi0Pt(NULL),
137  hESDEposEnegLikeSignBackInvMassPt(NULL),
138  hESDMotherInvMassPt(NULL),
139  hESDPi0MotherInvMassPt(NULL),
140  hESDPi0MotherDiffInvMassPt(NULL),
141  hESDPi0MotherDiffLimInvMassPt(NULL),
142  hESDEposEnegInvMassPi0MotherPt(NULL),
143  hESDMotherInvMassOpeningAngleGammaElectron(NULL),
144  sESDMotherInvMassPtZM(NULL),
145  hESDMotherBackInvMassPt(NULL),
146  sESDMotherBackInvMassPtZM(NULL),
147  hESDMotherPi0PtY(NULL),
148  hESDMotherPi0PtAlpha(NULL),
149  hESDMotherPi0PtOpenAngle(NULL),
150  sESDMotherDalitzPlot(NULL),
151  hMCAllGammaPt(NULL),
152  hMCAllGammaPi0Pt(NULL),
153  hMCConvGammaPt(NULL),
154  hMCConvGammaPtR(NULL),
155  hMCConvGammaRSPt(NULL),
156  hMCConvGammaPi0Pt(NULL),
157  hMCAllPositronsPt(NULL),
158  hMCDecayPositronPi0Pt(NULL),
159  hMCAllElectronsPt(NULL),
160  hMCDecayElectronPi0Pt(NULL),
161  hMCConvGammaEta(NULL),
162  hMCConvGammaR(NULL),
163  hMCAllPositronsEta(NULL),
164  hMCAllElectronsEta(NULL),
165  hMCPi0DalitzGammaPt(NULL),
166  hMCPi0DalitzElectronPt(NULL),
167  hMCPi0DalitzPositronPt(NULL),
168  hMCPi0Pt(NULL),
169  hMCPi0WOWeightPt(NULL),
170  hMCPi0GGPt(NULL),
171  hMCEtaPt(NULL),
172  hMCEtaGGPt(NULL),
173  hMCPi0InAccPt(NULL),
174  hMCPi0WOWeightInAccPt(NULL),
175  hMCPi0InAccOpeningAngleGammaElectron(NULL),
176  sMCPi0DalitzPlot(NULL),
177  hMCEtaInAccPt(NULL),
178  hMCChiCPt(NULL),
179  hMCChiCInAccPt(NULL),
180  hMCPi0EposEnegInvMassPt(NULL),
181  hMCEtaEposEnegInvMassPt(NULL),
182  hESDEposEnegTruePi0DalitzInvMassPt(NULL),
183  hESDEposEnegTruePrimPi0DalitzInvMass(NULL),
184  hESDEposEnegTruePi0DalitzPsiPairDPhi(NULL),
185  hESDEposEnegTruePi0DalitzPsiPairMC(NULL),
186  hESDEposEnegTruePi0DalitzPsiPairEta(NULL),
187  hESDEposEnegTruePi0DalitzDPhiEta(NULL),
188  hESDEposEnegTrueEtaDalitzInvMassPt(NULL),
189  hESDEposEnegTruePrimEtaDalitzInvMass(NULL),
190  hESDEposEnegTrueEtaDalitzPsiPairDPhi(NULL),
191  hESDEposEnegTruePhotonInvMassPt(NULL),
192  hESDEposEnegTrueInvMassPt(NULL),
193  hESDEposEnegTrueMotherInvMassPt(NULL),
194  hESDEposEnegTruePhotonPsiPairDPhi(NULL),
195  hESDEposEnegTruePhotonPsiPairDPhiPtCut(NULL),
196  hESDEposEnegTrueJPsiInvMassPt(NULL),
197  hESDTrueMotherChiCInvMassPt(NULL),
198  hESDTrueMotherChiCDiffInvMassPt(NULL),
199  hESDTrueMotherInvMassPt(NULL),
200  hESDTrueMotherW0WeightsInvMassPt(NULL),
201  hESDTrueMotherDalitzInvMassPt(NULL),
202  hESDTrueMotherPi0GGInvMassPt(NULL),
203  hESDTrueMotherPi0GGW0WeightsInvMassPt(NULL),
204  hESDTruePi0PtY(NULL),
205  hESDTruePi0PtAlpha(NULL),
206  hESDTruePi0PtOpenAngle(NULL),
207  sESDTruePi0DalitzPlot(NULL),
208  hESDTruePrimaryMotherPi0GGInvMassPt(NULL),
209  hESDTrueSecondaryMotherPi0GGInvMassPt(NULL),
210  hESDTruePrimaryMotherInvMassMCPt(NULL),
211  hESDTruePrimaryMotherInvMassPt(NULL),
212  hESDTruePrimaryMotherW0WeightingInvMassPt(NULL),
213  hESDTruePrimaryPi0DalitzESDPtMCPt(NULL),
214  hESDTrueSecondaryMotherInvMassPt(NULL),
215  hESDTrueSecondaryMotherFromK0sInvMassPt(NULL),
216  hESDTrueBckGGInvMassPt(NULL),
217  hESDTrueBckContInvMassPt(NULL),
218  hESDTrueMotherGGInvMassPt(NULL),
219  hESDTrueConvGammaPt(NULL),
220  hESDTrueConvGammaPtMC(NULL),
221  hESDTrueConvGammaR(NULL),
222  hESDTrueConvGammaRMC(NULL),
223  hESDTruePositronPt(NULL),
224  hESDTrueElectronPt(NULL),
225  hESDTrueSecConvGammaPt(NULL),
226  hESDTrueSecPositronPt(NULL),
227  hESDTrueSecElectronPt(NULL),
228  hESDTruePi0DalitzConvGammaPt(NULL),
229  hESDTruePi0DalitzConvGammaR(NULL),
230  hESDTruePi0DalitzPositronPt(NULL),
231  hESDTruePi0DalitzPositronPtMB(NULL),
232  hESDTruePi0DalitzElectronPt(NULL),
233  hESDTruePi0DalitzElectronPtMB(NULL),
234  hESDTruePi0DalitzSecConvGammaPt(NULL),
235  hESDTruePi0DalitzSecPositronPt(NULL),
236  hESDTruePi0DalitzSecElectronPt(NULL),
237  hNEvents(NULL),
238  hNGoodESDTracks(NULL),
239  hNGoodESDTracksVsNGoodGammas(NULL),
240  hNGoodESDTracksVsNGoodVGammas(NULL),
241  fHistoSPDClusterTrackletBackground(NULL),
242  hNV0Tracks(NULL),
243  hEtaShift(NULL),
244  fHistoDoubleCountTruePi0InvMassPt(NULL),
245  fHistoDoubleCountTrueEtaInvMassPt(NULL),
246  fHistoDoubleCountTrueConvGammaRPt(NULL),
247  fVectorDoubleCountTruePi0s(0),
248  fVectorDoubleCountTrueEtas(0),
249  fVectorDoubleCountTrueConvGammas(0),
250  fRandom(0),
251  fEventPlaneAngle(-100),
252  fUnsmearedPx(NULL),
253  fUnsmearedPy(NULL),
254  fUnsmearedPz(NULL),
255  fUnsmearedE(NULL),
256  fUnsmearedVPx(NULL),
257  fUnsmearedVPy(NULL),
258  fUnsmearedVPz(NULL),
259  fUnsmearedVE(NULL),
260  fnCuts(0),
261  fiCut(0),
262  fNumberOfESDTracks(0),
263  fNumberOfESDTrackskBoth(0),
264  fNVirtualGammas(0),
265  fMoveParticleAccordingToVertex(kFALSE),
266  fIsHeavyIon(0),
267  fDoMesonAnalysis(kTRUE),
268  fDoChicAnalysis(kFALSE),
269  fDoMesonQA(0),
270  fSetProductionVertextoVGamma(kTRUE),
271  fIsFromMBHeader(kTRUE),
272  fIsMC(kFALSE),
273  fDoTHnSparse(kTRUE),
274  fDoHistoDalitzMassLog(kFALSE),
275  fDoMaterialBudgetWeightingOfGammasForTrueMesons(kFALSE)
276 {
277 
278 }
279 
280 //-----------------------------------------------------------------------------------------------
282  AliAnalysisTaskSE(name),
283  fV0Reader(NULL),
284  fV0ReaderName("V0ReaderV1"),
285  fElecSelector(NULL),
286  fBGHandler(NULL),
287  fESDEvent(NULL),
288  fMCEvent(NULL),
289  fCutFolder(NULL),
290  fESDList(NULL),
291  fBackList(NULL),
292  fMotherList(NULL),
293  fTrueList(NULL),
294  fMCList(NULL),
295  fQAFolder(NULL),
296  fOutputContainer(0),
297  fReaderGammas(NULL),
298  fSelectorElectronIndex(0),
299  fSelectorPositronIndex(0),
300  fGoodGammas(NULL),
301  fGoodVirtualGammas(NULL),
302  fGoodElectrons(NULL),
303  fGoodPositrons(NULL),
304  fCutEventArray(NULL),
305  fCutGammaArray(NULL),
306  fCutElectronArray(NULL),
307  fCutMesonArray(NULL),
308  fEventCuts(NULL),
309  fConversionCuts(NULL),
310  hESDConvGammaPt(NULL),
311  hESDConvGammaEta(NULL),
312  //hESDConvGammaZR(NULL),
313  sESDConvGammaZR(NULL),
314  sESDConvGammaXY(NULL),
315  hESDDalitzElectronPt(NULL),
316  hESDDalitzPositronPt(NULL),
317  hESDDalitzElectronPhi(NULL),
318  hESDDalitzPositronPhi(NULL),
319  hESDDalitzElectronAfterPt(NULL),
320  hESDDalitzPositronAfterPt(NULL),
321  hESDDalitzElectronAfterEta(NULL),
322  hESDDalitzElectronAfterEtaPCut(NULL),
323  hESDDalitzPositronAfterEta(NULL),
324  hESDDalitzPositronAfterEtaPCut(NULL),
325  hESDDalitzElectronAfterPhi(NULL),
326  hESDDalitzPositronAfterPhi(NULL),
327  hESDDalitzElectronAfterNClsITS(NULL),
328  hESDDalitzElectronAfterNClsITSPCut(NULL),
329  hESDDalitzPositronAfterNClsITS(NULL),
330  hESDDalitzPositronAfterNClsITSPCut(NULL),
331  hESDDalitzElectronAfterNFindClsTPC(NULL),
332  hESDDalitzElectronAfterNFindClsTPCPCut(NULL),
333  hESDDalitzPositronAfterNFindClsTPC(NULL),
334  hESDDalitzPositronAfterNFindClsTPCPCut(NULL),
335  hESDDalitzElectronAfterNClsTPC(NULL),
336  hESDDalitzElectronAfterNClsTPCPCut(NULL),
337  hESDDalitzPositronAfterNClsTPC(NULL),
338  hESDDalitzPositronAfterNClsTPCPCut(NULL),
339  hESDDalitzElectronAfterNCrossedRowsTPC(NULL),
340  hESDDalitzElectronAfterNCrossedRowsTPCPCut(NULL),
341  hESDDalitzPositronAfterNCrossedRowsTPC(NULL),
342  hESDDalitzPositronAfterNCrossedRowsTPCPCut(NULL),
343  hESDDalitzPosEleAfterDCAxy(NULL),
344  hESDDalitzPosEleAfterDCAz(NULL),
345  hESDDalitzElectronAfterTPCdEdxVsP(NULL),
346  hESDDalitzPositronAfterTPCdEdxVsP(NULL),
347  hESDDalitzElectronAfterTPCdEdxSignalVsP(NULL),
348  hESDDalitzPositronAfterTPCdEdxSignalVsP(NULL),
349  hESDDalitzElectronAfterTPCdEdxVsEta(NULL),
350  hESDDalitzPositronAfterTPCdEdxVsEta(NULL),
351  hESDDalitzElectronAfterTPCdEdxVsPhi(NULL),
352  hESDDalitzPositronAfterTPCdEdxVsPhi(NULL),
353  hESDEposEnegPsiPairDPhi(NULL),
354  hESDEposEnegPsiPairEta(NULL),
355  hESDEposEnegDPhiEta(NULL),
356  hESDEposEnegInvMassPt(NULL),
357  hESDTruePi0EposEnegInvMassPi0Pt(NULL),
358  hESDEposEnegLikeSignBackInvMassPt(NULL),
359  hESDMotherInvMassPt(NULL),
360  hESDPi0MotherInvMassPt(NULL),
361  hESDPi0MotherDiffInvMassPt(NULL),
362  hESDPi0MotherDiffLimInvMassPt(NULL),
363  hESDEposEnegInvMassPi0MotherPt(NULL),
364  hESDMotherInvMassOpeningAngleGammaElectron(NULL),
365  sESDMotherInvMassPtZM(NULL),
366  hESDMotherBackInvMassPt(NULL),
367  sESDMotherBackInvMassPtZM(NULL),
368  hESDMotherPi0PtY(NULL),
369  hESDMotherPi0PtAlpha(NULL),
370  hESDMotherPi0PtOpenAngle(NULL),
371  sESDMotherDalitzPlot(NULL),
372  hMCAllGammaPt(NULL),
373  hMCAllGammaPi0Pt(NULL),
374  hMCConvGammaPt(NULL),
375  hMCConvGammaPtR(NULL),
376  hMCConvGammaRSPt(NULL),
377  hMCConvGammaPi0Pt(NULL),
378  hMCAllPositronsPt(NULL),
379  hMCDecayPositronPi0Pt(NULL),
380  hMCAllElectronsPt(NULL),
381  hMCDecayElectronPi0Pt(NULL),
382  hMCConvGammaEta(NULL),
383  hMCConvGammaR(NULL),
384  hMCAllPositronsEta(NULL),
385  hMCAllElectronsEta(NULL),
386  hMCPi0DalitzGammaPt(NULL),
387  hMCPi0DalitzElectronPt(NULL),
388  hMCPi0DalitzPositronPt(NULL),
389  hMCPi0Pt(NULL),
390  hMCPi0WOWeightPt(NULL),
391  hMCPi0GGPt(NULL),
392  hMCEtaPt(NULL),
393  hMCEtaGGPt(NULL),
394  hMCPi0InAccPt(NULL),
395  hMCPi0WOWeightInAccPt(NULL),
396  hMCPi0InAccOpeningAngleGammaElectron(NULL),
397  sMCPi0DalitzPlot(NULL),
398  hMCEtaInAccPt(NULL),
399  hMCChiCPt(NULL),
400  hMCChiCInAccPt(NULL),
401  hMCPi0EposEnegInvMassPt(NULL),
402  hMCEtaEposEnegInvMassPt(NULL),
403  hESDEposEnegTruePi0DalitzInvMassPt(NULL),
404  hESDEposEnegTruePrimPi0DalitzInvMass(NULL),
405  hESDEposEnegTruePi0DalitzPsiPairDPhi(NULL),
406  hESDEposEnegTruePi0DalitzPsiPairMC(NULL),
407  hESDEposEnegTruePi0DalitzPsiPairEta(NULL),
408  hESDEposEnegTruePi0DalitzDPhiEta(NULL),
409  hESDEposEnegTrueEtaDalitzInvMassPt(NULL),
410  hESDEposEnegTruePrimEtaDalitzInvMass(NULL),
411  hESDEposEnegTrueEtaDalitzPsiPairDPhi(NULL),
412  hESDEposEnegTruePhotonInvMassPt(NULL),
413  hESDEposEnegTrueInvMassPt(NULL),
414  hESDEposEnegTrueMotherInvMassPt(NULL),
415  hESDEposEnegTruePhotonPsiPairDPhi(NULL),
416  hESDEposEnegTruePhotonPsiPairDPhiPtCut(NULL),
417  hESDEposEnegTrueJPsiInvMassPt(NULL),
418  hESDTrueMotherChiCInvMassPt(NULL),
419  hESDTrueMotherChiCDiffInvMassPt(NULL),
420  hESDTrueMotherInvMassPt(NULL),
421  hESDTrueMotherW0WeightsInvMassPt(NULL),
422  hESDTrueMotherDalitzInvMassPt(NULL),
423  hESDTrueMotherPi0GGInvMassPt(NULL),
424  hESDTrueMotherPi0GGW0WeightsInvMassPt(NULL),
425  hESDTruePi0PtY(NULL),
426  hESDTruePi0PtAlpha(NULL),
427  hESDTruePi0PtOpenAngle(NULL),
428  sESDTruePi0DalitzPlot(NULL),
429  hESDTruePrimaryMotherPi0GGInvMassPt(NULL),
430  hESDTrueSecondaryMotherPi0GGInvMassPt(NULL),
431  hESDTruePrimaryMotherInvMassMCPt(NULL),
432  hESDTruePrimaryMotherInvMassPt(NULL),
433  hESDTruePrimaryMotherW0WeightingInvMassPt(NULL),
434  hESDTruePrimaryPi0DalitzESDPtMCPt(NULL),
435  hESDTrueSecondaryMotherInvMassPt(NULL),
436  hESDTrueSecondaryMotherFromK0sInvMassPt(NULL),
437  hESDTrueBckGGInvMassPt(NULL),
438  hESDTrueBckContInvMassPt(NULL),
439  hESDTrueMotherGGInvMassPt(NULL),
440  hESDTrueConvGammaPt(NULL),
441  hESDTrueConvGammaPtMC(NULL),
442  hESDTrueConvGammaR(NULL),
443  hESDTrueConvGammaRMC(NULL),
444  hESDTruePositronPt(NULL),
445  hESDTrueElectronPt(NULL),
446  hESDTrueSecConvGammaPt(NULL),
447  hESDTrueSecPositronPt(NULL),
448  hESDTrueSecElectronPt(NULL),
449  hESDTruePi0DalitzConvGammaPt(NULL),
450  hESDTruePi0DalitzConvGammaR(NULL),
451  hESDTruePi0DalitzPositronPt(NULL),
452  hESDTruePi0DalitzPositronPtMB(NULL),
453  hESDTruePi0DalitzElectronPt(NULL),
454  hESDTruePi0DalitzElectronPtMB(NULL),
455  hESDTruePi0DalitzSecConvGammaPt(NULL),
456  hESDTruePi0DalitzSecPositronPt(NULL),
457  hESDTruePi0DalitzSecElectronPt(NULL),
458  hNEvents(NULL),
459  hNGoodESDTracks(NULL),
460  hNGoodESDTracksVsNGoodGammas(NULL),
461  hNGoodESDTracksVsNGoodVGammas(NULL),
462  fHistoSPDClusterTrackletBackground(NULL),
463  hNV0Tracks(NULL),
464  hEtaShift(NULL),
465  fHistoDoubleCountTruePi0InvMassPt(NULL),
466  fHistoDoubleCountTrueEtaInvMassPt(NULL),
467  fHistoDoubleCountTrueConvGammaRPt(NULL),
468  fVectorDoubleCountTruePi0s(0),
469  fVectorDoubleCountTrueEtas(0),
470  fVectorDoubleCountTrueConvGammas(0),
471  fRandom(0),
472  fEventPlaneAngle(-100),
473  fUnsmearedPx(NULL),
474  fUnsmearedPy(NULL),
475  fUnsmearedPz(NULL),
476  fUnsmearedE(NULL),
477  fUnsmearedVPx(NULL),
478  fUnsmearedVPy(NULL),
479  fUnsmearedVPz(NULL),
480  fUnsmearedVE(NULL),
481  fnCuts(0),
482  fiCut(0),
483  fNumberOfESDTracks(0),
484  fNumberOfESDTrackskBoth(0),
485  fNVirtualGammas(0),
486  fMoveParticleAccordingToVertex(kFALSE),
487  fIsHeavyIon(0),
488  fDoMesonAnalysis(kTRUE),
489  fDoChicAnalysis(kFALSE),
490  fDoMesonQA(0),
491  fSetProductionVertextoVGamma(kTRUE),
492  fIsFromMBHeader(kTRUE),
493  fIsMC(kFALSE),
494  fDoTHnSparse(kTRUE),
495  fDoHistoDalitzMassLog(kFALSE),
496  fDoMaterialBudgetWeightingOfGammasForTrueMesons(kFALSE)
497 {
498  DefineOutput(1, TList::Class());
499 }
500 
501 //-----------------------------------------------------------------------------------------------
503 {
504  //
505  // virtual destructor
506  //
507 
508  cout<<"Destructor"<<endl;
509 
510  if(fGoodGammas){
511  delete fGoodGammas;
512  fGoodGammas = 0x0;
513  }
514  if(fGoodVirtualGammas){
515  delete fGoodVirtualGammas;
516  fGoodVirtualGammas = 0x0;
517  }
518  if(fGoodElectrons){
519  delete fGoodElectrons;
520  fGoodElectrons = 0x0;
521  }
522  if(fGoodPositrons){
523  delete fGoodPositrons;
524  fGoodPositrons = 0x0;
525  }
526  if(fBGHandler){
527  delete[] fBGHandler;
528  fBGHandler = 0x0;
529  }
530 
531 }
532 
533 //___________________________________________________________
535 
536  const Int_t nDim = 4;
537  Int_t nBins[nDim] = {800,250,7,4};
538  Double_t xMin[nDim] = {0,0, 0,0};
539  Double_t xMax[nDim] = {0.8,25,7,4};
540 
541  if( fDoTHnSparse ) {
542  sESDMotherInvMassPtZM = new THnSparseF*[fnCuts];
543  sESDMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
544  }
545 
547 
548  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
549 
550  TString cutstringEvent = ((AliConvEventCuts*)fCutEventArray->At(iCut))->GetCutNumber();
551  TString cutstringElectron = ((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutNumber();
552  TString cutstringMeson = ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutNumber();
553  TString cutstringGamma = ((AliConversionPhotonCuts*)fCutGammaArray->At(iCut))->GetCutNumber();
554 
555  Int_t collisionSystem = atoi((TString)(((AliConvEventCuts*)fCutEventArray->At(iCut))->GetCutNumber())(0,1));
556  Int_t centMin = atoi((TString)(((AliConvEventCuts*)fCutEventArray->At(iCut))->GetCutNumber())(1,1));
557  Int_t centMax = atoi((TString)(((AliConvEventCuts*)fCutEventArray->At(iCut))->GetCutNumber())(2,1));
558 
559  if(collisionSystem == 1 || collisionSystem == 2 ||
560  collisionSystem == 5 || collisionSystem == 8 ||
561  collisionSystem == 9){
562  centMin = centMin*10;
563  centMax = centMax*10;
564  if(centMax ==0 && centMax!=centMin) centMax=100;
565  } else if(collisionSystem == 3 || collisionSystem == 6){
566  centMin = centMin*5;
567  centMax = centMax*5;
568  } else if(collisionSystem == 4 || collisionSystem == 7){
569  centMin = ((centMin*5)+45);
570  centMax = ((centMax*5)+45);
571  }
572 
573  if( fDoTHnSparse ) {
574  fBackList[iCut] = new TList();
575  fBackList[iCut]->SetName(Form("%s_%s_%s_%s Back histograms",cutstringEvent.Data(),cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
576  fBackList[iCut]->SetOwner(kTRUE);
577  fCutFolder[iCut]->Add(fBackList[iCut]);
578 
579  sESDMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_m","Back_Back_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
580  fBackList[iCut]->Add(sESDMotherBackInvMassPtZM[iCut]);
581 
582  fMotherList[iCut] = new TList();
583  fMotherList[iCut]->SetName(Form("%s_%s_%s_%s Mother histograms",cutstringEvent.Data(),cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
584  fMotherList[iCut]->SetOwner(kTRUE);
585  fCutFolder[iCut]->Add(fMotherList[iCut]);
586 
587  sESDMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_m","Back_Mother_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
588  fMotherList[iCut]->Add(sESDMotherInvMassPtZM[iCut]);
589  }
590 
591  if(((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->BackgroundHandlerType() == 0){
592 
593 
595  collisionSystem,centMin,centMax,
596  ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetNumberOfBGEvents(),
597  ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->UseTrackMultiplicity(),
598  1,8,5);
599  }
600 
601 
602 
603  }
604 }
605 
606 //______________________________________________________________________
608 {
609  //
610  // Create ouput objects
611  //
612 
613  // Create the output container
614  if(fOutputContainer != NULL){
615  delete fOutputContainer;
616  fOutputContainer = NULL;
617  }
618  if(fOutputContainer == NULL){
619  fOutputContainer = new TList();
620  fOutputContainer->SetOwner(kTRUE);
621  }
622 
623  fGoodGammas = new TList();
624 
625  fGoodVirtualGammas = new TList();
626  fGoodVirtualGammas->SetOwner(kTRUE);
627 
628 
629  fCutFolder = new TList*[fnCuts];
630  fESDList = new TList*[fnCuts];
631 
632  if( fDoTHnSparse ){
633  fBackList = new TList*[fnCuts];
634  fMotherList = new TList*[fnCuts];
635  }
636  hNEvents = new TH1I*[fnCuts];
637  hNGoodESDTracks = new TH1I*[fnCuts];
638  hNV0Tracks = new TH1I*[fnCuts];
639  hEtaShift = new TProfile*[fnCuts];
640  hESDConvGammaPt = new TH1F*[fnCuts];
641  hESDConvGammaEta = new TH1F*[fnCuts];
642 
643  hESDDalitzElectronPt = new TH1F*[fnCuts];
644  hESDDalitzPositronPt = new TH1F*[fnCuts];
645  hESDDalitzElectronPhi = new TH1F*[fnCuts];
646  hESDDalitzPositronPhi = new TH1F*[fnCuts];
647 
648  const Int_t nBinsMassPair = 800;
649  Double_t xMinMassPair = 0.0;
650  Double_t xMaxMassPair = 0.8;
651 
652  if( fDoMesonQA > 0) {
653  fQAFolder = new TList*[fnCuts];
657  hESDDalitzElectronAfterPt = new TH1F*[fnCuts];
658  hESDDalitzPositronAfterPt = new TH1F*[fnCuts];
659  hESDDalitzElectronAfterEta = new TH1F*[fnCuts];
661  hESDDalitzPositronAfterEta = new TH1F*[fnCuts];
663  hESDDalitzElectronAfterPhi = new TH1F*[fnCuts];
664  hESDDalitzPositronAfterPhi = new TH1F*[fnCuts];
699  hESDMotherPi0PtY = new TH2F*[fnCuts];
702 
703 
704  if ( fDoMesonQA > 1 ){
705  sESDConvGammaZR = new THnSparseF*[fnCuts];
706  sESDConvGammaXY = new THnSparseF*[fnCuts];
707  sESDMotherDalitzPlot = new THnSparseF*[fnCuts];
708  }
709 
710  if( fDoHistoDalitzMassLog ){
711  xMinMassPair = 0.001;
712  xMaxMassPair = 0.801;
713  }
714  }
715 
717 
718  if(fDoChicAnalysis) {
723  }
725 
726 
727  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
728 
729  TString cutstringEvent = ((AliConvEventCuts*)fCutEventArray->At(iCut))->GetCutNumber();
730  TString cutstringElectron = ((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutNumber();
731  TString cutstringMeson = ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutNumber();
732  TString cutstringGamma = ((AliConversionPhotonCuts*)fCutGammaArray->At(iCut))->GetCutNumber();
733 
734  fCutFolder[iCut] = new TList();
735  fCutFolder[iCut]->SetName(Form("Cut Number %s_%s_%s_%s",cutstringEvent.Data(),cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
736  fCutFolder[iCut]->SetOwner(kTRUE);
737  fOutputContainer->Add(fCutFolder[iCut]);
738 
739  fESDList[iCut] = new TList();
740  fESDList[iCut]->SetName(Form("%s_%s_%s_%s ESD histograms",cutstringEvent.Data(),cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
741  fESDList[iCut]->SetOwner(kTRUE);
742 
743  hNEvents[iCut] = new TH1I("NEvents","NEvents",13,-0.5,12.5);
744  hNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
745  hNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
746  hNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Missing MC");
747  hNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
748  hNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
749  hNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
750  hNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
751  hNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
752  hNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
753  hNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
754  hNEvents[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
755  hNEvents[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
756  fESDList[iCut]->Add(hNEvents[iCut]);
757 
758  if(fIsHeavyIon == 1 || fIsHeavyIon == 2) hNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",3000,0,3000);
759  else hNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
760  fESDList[iCut]->Add(hNGoodESDTracks[iCut]);
761 
762 
763  if(fIsHeavyIon == 1) hNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",30000,0,30000);
764  else if(fIsHeavyIon == 2) hNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",2500,0,2500);
765  else hNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",1500,0,1500);
766  fESDList[iCut]->Add(hNV0Tracks[iCut]);
767 
768  hEtaShift[iCut] = new TProfile("Eta Shift","Eta Shift",1, -0.5,0.5);
769  fESDList[iCut]->Add(hEtaShift[iCut]);
770 
771  hESDConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt","ESD_ConvGamma_Pt",250,0,25);
772  fESDList[iCut]->Add(hESDConvGammaPt[iCut]);
773 
774  hESDConvGammaEta[iCut] = new TH1F("ESD_ConvGamma_Eta","ESD_ConvGamma_Eta",600,-1.5,1.5);
775  fESDList[iCut]->Add(hESDConvGammaEta[iCut]);
776 
777  hESDDalitzElectronPt[iCut] = new TH1F("ESD_DalitzElectron_Pt","ESD_DalitzElectron_Pt",1000,0,25);
778  fESDList[iCut]->Add(hESDDalitzElectronPt[iCut]);
779 
780  hESDDalitzPositronPt[iCut] = new TH1F("ESD_DalitzPositron_Pt","ESD_DalitzPositron_Pt",1000,0,25);
781  fESDList[iCut]->Add(hESDDalitzPositronPt[iCut]);
782 
783 
784  hESDDalitzElectronPhi[iCut] = new TH1F("ESD_DalitzElectron_Phi","ESD_DalitzElectron_Phi",360,0,2*TMath::Pi());
785  fESDList[iCut]->Add(hESDDalitzElectronPhi[iCut]);
786 
787  hESDDalitzPositronPhi[iCut] = new TH1F("ESD_DalitzPositron_Phi","ESD_DalitzPositron_Phi",360,0,2*TMath::Pi());
788  fESDList[iCut]->Add(hESDDalitzPositronPhi[iCut]);
789 
790  if ( fDoMesonQA > 0 ) {
791 
792  fQAFolder[iCut] = new TList();
793  fQAFolder[iCut]->SetName(Form("%s_%s_%s_%s QA histograms",cutstringEvent.Data(),cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
794  fQAFolder[iCut]->SetOwner(kTRUE);
795 
796  const Int_t kPtBins=110;
797  Double_t binsPtDummy[kPtBins+1];
798  const Int_t kPBins = 109;
799  Double_t binsPDummy[kPBins+1];
800  binsPtDummy[0]=0.0;
801  binsPDummy[0]=0.05;
802 
803  for(Int_t i=1;i<kPtBins+1;i++){
804  if(binsPtDummy[i-1]+0.05<1.01)
805  binsPtDummy[i]=binsPtDummy[i-1]+0.05;
806  else
807  binsPtDummy[i]=binsPtDummy[i-1]+0.1;
808  }
809  for(Int_t i=1; i<kPBins+1;i++){
810  if( binsPDummy[i-1]+0.05<1.01)
811  binsPDummy[i] = binsPDummy[i-1]+0.05;
812  else
813  binsPDummy[i] = binsPDummy[i-1]+0.1;
814  }
815 
816  hNGoodESDTracksVsNGoodGammas[iCut] = new TH2F("hNGoodESDTracksVsNGoodGammas","hNGoodESDTracksVsNGoodGammas",200,-0.5,199.5,100,-0.5,99.5);
817  fQAFolder[iCut]->Add(hNGoodESDTracksVsNGoodGammas[iCut]);
818 
819  hNGoodESDTracksVsNGoodVGammas[iCut] = new TH2F("hNGoodESDTracksVsNVGoodVGammas","hNGoodESDTracksVsNGoodVGammas",200,-0.5,199.5,100,-0.5,99.5);
820  fQAFolder[iCut]->Add(hNGoodESDTracksVsNGoodVGammas[iCut]);
821 
822  fHistoSPDClusterTrackletBackground[iCut] = new TH2F("SPD tracklets vs SPD clusters","SPD tracklets vs SPD clusters",100,0,200,250,0,1000);
824 
825  hESDDalitzElectronAfterPt[iCut] = new TH1F("ESD_DalitzElectron_After_Pt","ESD_DalitzElectron_After_Pt",1000,0,25);
826  fQAFolder[iCut]->Add(hESDDalitzElectronAfterPt[iCut]);
827 
828  hESDDalitzPositronAfterPt[iCut] = new TH1F("ESD_DalitzPositron_After_Pt","ESD_DalitzPositron_After_Pt",1000,0,25);
829  fQAFolder[iCut]->Add(hESDDalitzPositronAfterPt[iCut]);
830 
831  hESDDalitzElectronAfterEta[iCut] = new TH1F("ESD_DalitzElectron_After_Eta","ESD_DalitzElectron_After_Eta",600,-1.5,1.5);
832  fQAFolder[iCut]->Add(hESDDalitzElectronAfterEta[iCut]);
833 
834  hESDDalitzElectronAfterEtaPCut[iCut] = new TH1F("ESD_DalitzElectron_After_Eta_PCut","ESD_DalitzElectron_After_Eta_PCut",600,-1.5,1.5);
835  fQAFolder[iCut]->Add(hESDDalitzElectronAfterEtaPCut[iCut]);
836 
837  hESDDalitzPositronAfterEta[iCut] = new TH1F("ESD_DalitzPositron_After_Eta","ESD_DalitzElectron_After_Eta",600,-1.5,1.5);
838  fQAFolder[iCut]->Add(hESDDalitzPositronAfterEta[iCut]);
839 
840  hESDDalitzPositronAfterEtaPCut[iCut] = new TH1F("ESD_DalitzPositron_After_Eta_PCut","ESD_DalitzElectron_After_Eta_PCut",600,-1.5,1.5);
841  fQAFolder[iCut]->Add(hESDDalitzPositronAfterEtaPCut[iCut]);
842 
843  hESDDalitzElectronAfterPhi[iCut] = new TH1F("ESD_DalitzElectron_After_Phi","ESD_DalitzElectron_After_Phi",360,0,2*TMath::Pi());
844  fQAFolder[iCut]->Add(hESDDalitzElectronAfterPhi[iCut]);
845 
846  hESDDalitzPositronAfterPhi[iCut] = new TH1F("ESD_DalitzPositron_After_Phi","ESD_DalitzPositron_After_Phi",360,0,2*TMath::Pi());
847  fQAFolder[iCut]->Add(hESDDalitzPositronAfterPhi[iCut]);
848 
849  hESDDalitzElectronAfterNClsITS[iCut] = new TH1F("ESD_DalitzElectron_After_NClsITS","ESD_DalitzElectron_After_NClsITS",7,-0.5,6.5);
850  fQAFolder[iCut]->Add(hESDDalitzElectronAfterNClsITS[iCut]);
851 
852  hESDDalitzElectronAfterNClsITSPCut[iCut] = new TH1F("ESD_DalitzElectron_After_NClsITS_PCut","ESD_DalitzElectron_After_NClsITS_PCut",7,-0.5,6.5);
854 
855  hESDDalitzPositronAfterNClsITS[iCut] = new TH1F("ESD_DalitzPositron_After_NClsITS","ESD_DalitzPositron_After_NClsITS",7,-0.5,6.5);
856  fQAFolder[iCut]->Add(hESDDalitzPositronAfterNClsITS[iCut]);
857 
858  hESDDalitzPositronAfterNClsITSPCut[iCut] = new TH1F("ESD_DalitzPositron_After_NClsITS_PCut","ESD_DalitzPositron_After_NClsITS_PCut",7,-0.5,6.5);
860 
861  hESDDalitzElectronAfterNFindClsTPC[iCut] = new TH2F("ESD_DalitzElectron_After_NFindClsTPC","ESD_DalitzElectron_After_NFindClsTPC",60,0,1.5,kPtBins,binsPtDummy);
863 
864  hESDDalitzElectronAfterNFindClsTPCPCut[iCut] = new TH1F("ESD_DalitzElectron_After_NFindClsTPC_PCut","ESD_DalitzElectron_After_NFindClsTPC_PCut",60,0,1.5);
866 
867 
868  hESDDalitzPositronAfterNFindClsTPC[iCut] = new TH2F("ESD_DalitzPositron_After_NFindClsTPC","ESD_DalitzPositron_After_NFindClsTPC",60,0,1.5,kPtBins,binsPtDummy);
870 
871  hESDDalitzPositronAfterNFindClsTPCPCut[iCut] = new TH1F("ESD_DalitzPositron_After_NFindClsTPC_PCut","ESD_DalitzPositron_After_NFindClsTPC_PCut",60,0,1.5);
873 
874  hESDDalitzElectronAfterNClsTPC[iCut] = new TH2F("ESD_DalitzElectron_After_NClsTPC","ESD_DalitzElectron_After_NClsTPC",200,-0.5,199.5,kPtBins,binsPtDummy);
875  fQAFolder[iCut]->Add(hESDDalitzElectronAfterNClsTPC[iCut]);
876 
877  hESDDalitzElectronAfterNClsTPCPCut[iCut] = new TH1F("ESD_DalitzElectron_After_NClsTPC_PCut","ESD_DalitzElectron_After_NClsTPC_PCut",200,-0.5,199.5);
879 
880  hESDDalitzPositronAfterNClsTPC[iCut] = new TH2F("ESD_DalitzPositron_After_NClsTPC","ESD_DalitzPositron_After_NClsTPC",200,-0.5,199.5,kPtBins,binsPtDummy);
881  fQAFolder[iCut]->Add(hESDDalitzPositronAfterNClsTPC[iCut]);
882 
883  hESDDalitzPositronAfterNClsTPCPCut[iCut] = new TH1F("ESD_DalitzPositron_After_NClsTPC_PCut","ESD_DalitzPositron_After_NClsTPC_PCut",200,-0.5,199.5);
885 
886  hESDDalitzPositronAfterNCrossedRowsTPC[iCut] = new TH2F("ESD_DalitzPositron_After_NCrossedRowsTPC","ESD_DalitzPositron_After_NCrossedRowsTPC",165,-0.5,164.5,kPtBins,binsPtDummy);
888 
889  hESDDalitzPositronAfterNCrossedRowsTPCPCut[iCut] = new TH1F("ESD_DalitzPositron_After_NCrossedRowsTPC_PCut","ESD_DalitzPositron_After_NCrossedRowsTPC_PCut",165,-0.5,164.5);
891 
892  hESDDalitzElectronAfterNCrossedRowsTPC[iCut] = new TH2F("ESD_DalitzElectron_After_NCrossedRowsTPC","ESD_DalitzElectron_After_NCrossedRowsTPC",165,-0.5,164.5,kPtBins,binsPtDummy);
894 
895  hESDDalitzElectronAfterNCrossedRowsTPCPCut[iCut] = new TH1F("ESD_DalitzElectron_After_NCrossedRowsTPC_PCut","ESD_DalitzElectron_After_NCrossedRowsTPC_PCut",165,-0.5,164.5);
897 
898  hESDDalitzPosEleAfterDCAxy[iCut] = new TH2F("ESD_DalitzPosEle_After_DCAxy","ESD_DalitzPosEle_After_DCAxy",124,-0.62,0.62,kPtBins,binsPtDummy);
899  fQAFolder[iCut]->Add(hESDDalitzPosEleAfterDCAxy[iCut]);
900 
901  hESDDalitzPosEleAfterDCAz[iCut] = new TH2F("ESD_DalitzPosEle_After_DCAz","ESD_DalitzPosEle_After_DCAz",200,-1.0,1.0,kPtBins,binsPtDummy);
902  fQAFolder[iCut]->Add(hESDDalitzPosEleAfterDCAz[iCut]);
903 
904  hESDDalitzElectronAfterTPCdEdxVsP[iCut] = new TH2F("ESD_DalitzElectron_After_TPCdEdxVsP","ESD_DalitzElectron_After_TPCdEdxVsP_After_TPCdEdx",kPBins,binsPDummy,200,-10,10);
907 
908  hESDDalitzPositronAfterTPCdEdxVsP[iCut] = new TH2F("ESD_DalitzPositron_After_TPCdEdxVsP","ESD_DalitzPositron_After_TPCdEdxVsP",kPBins,binsPDummy,200,-10,10);
911 
912  hESDDalitzElectronAfterTPCdEdxSignalVsP[iCut] =new TH2F("ESD_DalitzElectron_After_TPCdEdxSignalVsP","ESD_DalitzElectron_After_TPCdEdxSignalVsP" ,kPBins,binsPDummy,200,0.0,200);
915 
916  hESDDalitzPositronAfterTPCdEdxSignalVsP[iCut] =new TH2F("ESD_DalitzPositron_After_TPCdEdxSignalVsP","ESD_DalitzPositron_After_TPCdEdxSignalVsP" ,kPBins,binsPDummy,200,0.0,200);
919 
920  hESDDalitzElectronAfterTPCdEdxVsEta[iCut] = new TH2F("ESD_DalitzElectron_After_TPCdEdxVsEta","ESD_DalitzElectron_After_TPCdEdxVsEta",140,-1.4,1.4,200,-10,10);
922 
923  hESDDalitzPositronAfterTPCdEdxVsEta[iCut] = new TH2F("ESD_DalitzPositron_After_TPCdEdxVsEta","ESD_DalitzPositron_After_TPCdEdxVsEta",140,-1.4,1.4,200,-10,10);
925 
926  hESDDalitzElectronAfterTPCdEdxVsPhi[iCut] = new TH2F("ESD_DalitzElectron_After_TPCdEdxVsPhi","ESD_DalitzElectron_After_TPCdEdxVsPhi",180,0,2*TMath::Pi(),200,-10,10);
928 
929  hESDDalitzPositronAfterTPCdEdxVsPhi[iCut] = new TH2F("ESD_DalitzPositron_After_TPCdEdxVsPhi","ESD_DalitzPositron_After_TPCdEdxVsPhi",180,0,2*TMath::Pi(),200,-10,10);
931 
932  hESDEposEnegPsiPairDPhi[iCut] = new TH2F("ESD_EposEneg_PsiPair_DPhi","ESD_EposEneg_PsiPair_DPhi",100,-1.0,1.0,100,-1.0,1.0 );
933  fQAFolder[iCut]->Add(hESDEposEnegPsiPairDPhi[iCut]);
934 
935  hESDEposEnegPsiPairEta[iCut] = new TH2F("ESD_EposEneg_PsiPair_Eta","ESD_EposEneg_PsiPair_Eta",100,-1.0,1.0,600,-1.5,1.5);
936  fQAFolder[iCut]->Add(hESDEposEnegPsiPairEta[iCut]);
937 
938  hESDEposEnegDPhiEta[iCut] = new TH2F("ESD_EposEneg_DPhi_Eta","ESD_EposEneg_DPhi_Eta",100,-1.0,1.0,600,-1.5,1.5);
939  fQAFolder[iCut]->Add(hESDEposEnegDPhiEta[iCut]);
940 
941  hESDEposEnegInvMassPt[iCut] = new TH2F("ESD_EposEneg_InvMassPt","ESD_EposEneg_InvMassPt",nBinsMassPair,xMinMassPair,xMaxMassPair,100,0.,10.);
943  fQAFolder[iCut]->Add(hESDEposEnegInvMassPt[iCut]);
944 
945  hESDEposEnegLikeSignBackInvMassPt[iCut] = new TH2F("ESD_EposEneg_LikeSignBack_InvMassPt","ESD_EposEneg_LikeSignBack_InvMassPt",4000,0.0,2.,100,0.,10.);
947 
948  if( fDoMesonQA > 1 ) {
949  const Int_t nDimRZ = 2;
950  Int_t nBinsRZ[nDimRZ] = { 1200, 800};
951  Double_t xMinRZ[nDimRZ] = { -150, 0};
952  Double_t xMaxRZ[nDimRZ] = { 150, 200};
953 
954  const Int_t nDimXY = 2;
955  Int_t nBinsXY[nDimXY] = { 1200, 1200};
956  Double_t xMinXY[nDimXY] = { -150, -150};
957  Double_t xMaxXY[nDimXY] = { 150, 150};
958 
959  sESDConvGammaZR[iCut] = new THnSparseF("ESD_ConvGamma_ZR","ESD_ConvGamma_ZR",nDimRZ,nBinsRZ,xMinRZ,xMaxRZ);
960  fQAFolder[iCut]->Add(sESDConvGammaZR[iCut]);
961 
962  sESDConvGammaXY[iCut] = new THnSparseF("ESD_ConvGamma_XY","ESD_ConvGamma_XY",nDimXY,nBinsXY,xMinXY,xMaxXY);
963  fQAFolder[iCut]->Add(sESDConvGammaXY[iCut]);
964 
965  const Int_t nDimDalPlot = 2;
966  Int_t nBinsDalPlot[nDimDalPlot] = { 4000, 4000};
967  Double_t xMinDalPlot[nDimDalPlot] = { 0, 0};
968  Double_t xMaxDalPlot[nDimDalPlot] = { 4.0, 4.0};
969 
970  sESDMotherDalitzPlot[iCut] = new THnSparseF("ESD_Mother_DalitzPlot","ESD_Mother_DalitzPlot",nDimDalPlot,nBinsDalPlot,xMinDalPlot,xMaxDalPlot);
971  fQAFolder[iCut]->Add(sESDMotherDalitzPlot[iCut]);
972  }
973  fCutFolder[iCut]->Add(fQAFolder[iCut]);
974  }
975 
976  hESDMotherInvMassPt[iCut] = new TH2F("ESD_DalitzMother_InvMass_Pt","ESD_DalitzMother_InvMass_Pt",800,0,0.8,250,0,25);
977  fESDList[iCut]->Add(hESDMotherInvMassPt[iCut]);
978 
979  if( fDoMesonQA > 0 ) {
980  hESDMotherInvMassOpeningAngleGammaElectron[iCut] = new TH1F("ESD_MotherInvMass_OpeningAngle_GammaElectron", "ESD_MotherInvMass_OpeningAngle_GammaElectron",100,0.,TMath::Pi());
982 
983  hESDMotherPi0PtY[iCut] = new TH2F("ESD_MotherPi0_Pt_Y","ESD_MotherPi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
985  fESDList[iCut]->Add(hESDMotherPi0PtY[iCut]);
986  hESDMotherPi0PtAlpha[iCut] = new TH2F("ESD_MotherPi0_Pt_Alpha","ESD_MotherPi0_Pt_Alpha",150,0.03,15.,100,0,1);
988  fESDList[iCut]->Add(hESDMotherPi0PtAlpha[iCut]);
989  hESDMotherPi0PtOpenAngle[iCut] = new TH2F("ESD_MotherPi0_Pt_OpenAngle","ESD_MotherPi0_Pt_OpenAngle",150,0.03,15.,100,0,TMath::Pi());
991  fESDList[iCut]->Add(hESDMotherPi0PtOpenAngle[iCut]);
992  }
993 
994  if( fDoChicAnalysis) {
995  hESDPi0MotherInvMassPt[iCut] = new TH2F("ESD_Pi0Mother_InvMass_Pt","ESD_Pi0Mother_InvMass_Pt",4000,0,4,200,0,20);
996  fESDList[iCut]->Add(hESDPi0MotherInvMassPt[iCut]);
997  hESDPi0MotherDiffInvMassPt[iCut] = new TH2F("ESD_Pi0Mother_DiffInvMass_Pt","ESD_Pi0Mother_DiffInvMass_Pt",2000,0,2,200,0,20);
998  fESDList[iCut]->Add(hESDPi0MotherDiffInvMassPt[iCut]);
999  hESDPi0MotherDiffLimInvMassPt[iCut] = new TH2F("ESD_Pi0Mother_DiffLimInvMass_Pt","ESD_Pi0Mother_DiffLimInvMass_Pt",2000,0,2,200,0,20);
1000  fESDList[iCut]->Add(hESDPi0MotherDiffLimInvMassPt[iCut]);
1001  hESDEposEnegInvMassPi0MotherPt[iCut] = new TH2F("ESD_EposEnegInvMass_Pi0MotherPt","ESD_EposEnegInvMass_Pi0MotherPt",4000,0,4,200,0,20);
1002  fESDList[iCut]->Add(hESDEposEnegInvMassPi0MotherPt[iCut]);
1003  }
1004 
1005  hESDMotherBackInvMassPt[iCut] = new TH2F("ESD_DalitzBackground_InvMass_Pt","ESD_DalitzBackground_InvMass_Pt",800,0,0.8,250,0,25);
1006  fESDList[iCut]->Add(hESDMotherBackInvMassPt[iCut]);
1007 
1008  fCutFolder[iCut]->Add(fESDList[iCut]);
1009  }
1010 
1011 
1012  InitBack(); // Init Background Handler
1013 
1014 
1015  if( fIsMC ){
1016  // MC Histogramms
1017  fMCList = new TList*[fnCuts];
1018  // True Histogramms
1019  fTrueList = new TList*[fnCuts];
1020  hESDTrueConvGammaPt = new TH1F*[fnCuts];
1022  hESDTruePositronPt = new TH1F*[fnCuts];
1023  hESDTrueElectronPt = new TH1F*[fnCuts];
1024  hESDTrueSecConvGammaPt = new TH1F*[fnCuts];
1025  hESDTrueSecPositronPt = new TH1F*[fnCuts];
1026  hESDTrueSecElectronPt = new TH1F*[fnCuts];
1027  hESDTruePi0DalitzConvGammaPt = new TH1F*[fnCuts];
1028 
1031  hESDTruePi0DalitzPositronPt = new TH1F*[fnCuts];
1033  hESDTruePi0DalitzElectronPt = new TH1F*[fnCuts];
1038 
1039  hMCAllGammaPt = new TH1F*[fnCuts];
1040  hMCAllGammaPi0Pt = new TH1F*[fnCuts];
1041  hMCConvGammaPt = new TH1F*[fnCuts];
1042  hMCConvGammaRSPt = new TH1F*[fnCuts];
1043  hMCConvGammaPi0Pt = new TH1F*[fnCuts];
1044  hMCAllPositronsPt = new TH1F*[fnCuts];
1045  hMCDecayPositronPi0Pt = new TH1F*[fnCuts];
1046  hMCAllElectronsPt = new TH1F*[fnCuts];
1047  hMCDecayElectronPi0Pt = new TH1F*[fnCuts];
1048 
1049  if( fDoMesonQA > 0 ) {
1050  hMCConvGammaEta = new TH1F*[fnCuts];
1051  hMCConvGammaR = new TH1F*[fnCuts];
1052  hMCAllPositronsEta = new TH1F*[fnCuts];
1053  hMCAllElectronsEta = new TH1F*[fnCuts];
1054  hMCConvGammaPtR = new TH2F*[fnCuts];
1055  }
1056  hMCPi0DalitzGammaPt = new TH1F*[fnCuts];
1057  hMCPi0DalitzElectronPt = new TH1F*[fnCuts];
1058  hMCPi0DalitzPositronPt = new TH1F*[fnCuts];
1059 
1060  hMCPi0Pt = new TH1F*[fnCuts];
1061  hMCPi0WOWeightPt = new TH1F*[fnCuts];
1062  hMCPi0GGPt = new TH1F*[fnCuts];
1063  hMCEtaPt = new TH1F*[fnCuts];
1064  hMCEtaGGPt = new TH1F*[fnCuts];
1065  hMCPi0InAccPt = new TH1F*[fnCuts];
1066  hMCPi0WOWeightInAccPt = new TH1F*[fnCuts];
1068  hMCEtaInAccPt = new TH1F*[fnCuts];
1069  hMCChiCPt = new TH1F*[fnCuts];
1070  hMCChiCInAccPt = new TH1F*[fnCuts];
1071 
1072  if ( fDoMesonQA > 0 ) {
1090  hESDTrueConvGammaR = new TH1F*[fnCuts];
1091  hESDTrueConvGammaRMC = new TH1F*[fnCuts];
1092  hESDTrueConvGammaPtMC = new TH1F*[fnCuts];
1093  hESDTruePi0PtY = new TH2F*[fnCuts];
1094  hESDTruePi0PtAlpha = new TH2F*[fnCuts];
1096 
1097  if ( fDoMesonQA > 1 ) {
1098  hESDTruePi0DalitzConvGammaR = new TH1F*[fnCuts];
1099  sESDTruePi0DalitzPlot = new THnSparseF*[fnCuts];
1100  sMCPi0DalitzPlot = new THnSparseF*[fnCuts];
1101  }
1102  }
1103 
1104  if( fDoChicAnalysis ){
1107  }
1108 
1125  //}
1126 
1127  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1128  TString cutstringEvent = ((AliConvEventCuts*)fCutEventArray->At(iCut))->GetCutNumber();
1129  TString cutstringElectron = ((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutNumber();
1130  TString cutstringMeson = ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutNumber();
1131  TString cutstringGamma = ((AliConversionPhotonCuts*)fCutGammaArray->At(iCut))->GetCutNumber();
1132 
1133  fMCList[iCut] = new TList();
1134  fMCList[iCut]->SetName(Form("%s_%s_%s_%s MC histograms",cutstringEvent.Data(),cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
1135  fMCList[iCut]->SetOwner(kTRUE);
1136  fCutFolder[iCut]->Add(fMCList[iCut]);
1137 
1138  hMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt","MC_AllGamma_Pt",250,0,25);
1139  fMCList[iCut]->Add(hMCAllGammaPt[iCut]);
1140 
1141  hMCAllGammaPi0Pt[iCut] = new TH1F("MC_AllGammaPi0_Pt","MC_AllGammaPi0_Pt",250,0,25);
1142  fMCList[iCut]->Add(hMCAllGammaPi0Pt[iCut]);
1143 
1144  hMCConvGammaPt[iCut] = new TH1F("MC_ConvGamma_Pt","MC_ConvGamma_Pt",250,0,25);
1145  fMCList[iCut]->Add(hMCConvGammaPt[iCut]);
1146 
1147  hMCConvGammaRSPt[iCut] = new TH1F("MC_ConvGamma_RS_Pt","MC_ConvGamma_RS_Pt",250,0,25);
1148  fMCList[iCut]->Add(hMCConvGammaRSPt[iCut]);
1149 
1150  hMCConvGammaPi0Pt[iCut] = new TH1F("MC_ConvGammaPi0_Pt","MC_ConvGammaPi0_Pt",250,0,25);
1151  fMCList[iCut]->Add(hMCConvGammaPi0Pt[iCut]);
1152 
1153  hMCAllPositronsPt[iCut] = new TH1F("MC_AllPositrons_Pt","MC_AllPositrons_Pt",1000,0,25);
1154  fMCList[iCut]->Add(hMCAllPositronsPt[iCut]);
1155 
1156  hMCDecayPositronPi0Pt[iCut] = new TH1F("MC_DecayPositronPi0_Pt","MC_DecayPositronPi0_Pt",1000,0,25);
1157  fMCList[iCut]->Add(hMCDecayPositronPi0Pt[iCut]);
1158 
1159  hMCAllElectronsPt[iCut] = new TH1F("MC_AllElectrons_Pt","MC_AllElectrons_Pt",1000,0,25);
1160  fMCList[iCut]->Add(hMCAllElectronsPt[iCut]);
1161 
1162  hMCDecayElectronPi0Pt[iCut] = new TH1F("MC_DecayElectronPi0_Pt","MC_DecayElectronPi0_Pt",1000,0,25);
1163  fMCList[iCut]->Add(hMCDecayElectronPi0Pt[iCut]);
1164 
1165  hMCPi0DalitzGammaPt[iCut] = new TH1F("MC_Pi0DalitzGamma_Pt","MC_Pi0DalitzGamma_Pt",250,0,25);
1166  hMCPi0DalitzGammaPt[iCut]->Sumw2();
1167  fMCList[iCut]->Add(hMCPi0DalitzGammaPt[iCut]);
1168 
1169  if ( fDoMesonQA > 0 ){
1170  hMCConvGammaEta[iCut] = new TH1F("MC_ConvGamma_Eta","MC_ConvGamma_Eta",600,-1.5,1.5);
1171  fMCList[iCut]->Add(hMCConvGammaEta[iCut]);
1172  hMCConvGammaR[iCut] = new TH1F("MC_ConvGamma_R","MC_ConvGamma_R",800,0,200);
1173  fMCList[iCut]->Add(hMCConvGammaR[iCut]);
1174  hMCAllPositronsEta[iCut] = new TH1F("MC_AllPositrons_Eta","MC_AllPositrons_Eta",600,-1.5,1.5);
1175  fMCList[iCut]->Add(hMCAllPositronsEta[iCut]);
1176  hMCAllElectronsEta[iCut] = new TH1F("MC_AllElectrons_Eta","MC_AllElectrons_Eta",600,-1.5,1.5);
1177  fMCList[iCut]->Add(hMCAllElectronsEta[iCut]);
1178  hMCConvGammaPtR[iCut] = new TH2F("MC_ConvGamma_Pt_R","MC_ConvGamma_Pt_R",250,0,25,180,0.,180.0);
1179  fMCList[iCut]->Add(hMCConvGammaPtR[iCut]);
1180 
1181  }
1182 
1183  hMCPi0DalitzPositronPt[iCut] = new TH1F("MC_Pi0DalitzPositron_Pt","MC_Pi0DalitzPositron_Pt",1000,0,25);
1184  hMCPi0DalitzPositronPt[iCut]->Sumw2();
1185  fMCList[iCut]->Add(hMCPi0DalitzPositronPt[iCut]);
1186 
1187  hMCPi0DalitzElectronPt[iCut] = new TH1F("MC_Pi0DalitzElectron_Pt","MC_Pi0DalitzElectron_Pt",1000,0,25);
1188  hMCPi0DalitzElectronPt[iCut]->Sumw2();
1189  fMCList[iCut]->Add(hMCPi0DalitzElectronPt[iCut]);
1190 
1191  hMCPi0Pt[iCut] = new TH1F("MC_Pi0_Pt","MC_Pi0_Pt",250,0,25);
1192  hMCPi0Pt[iCut]->Sumw2();
1193  fMCList[iCut]->Add(hMCPi0Pt[iCut]);
1194 
1195  hMCPi0WOWeightPt[iCut] = new TH1F("MC_Pi0_WOWeights_Pt","MC_Pi0_WOWeights_Pt",250,0,25);
1196  hMCPi0WOWeightPt[iCut]->Sumw2();
1197  fMCList[iCut]->Add(hMCPi0WOWeightPt[iCut]);
1198 
1199  hMCPi0GGPt[iCut] = new TH1F("MC_Pi0_GG_Pt","MC_Pi0_GG_Pt",250,0,25);
1200  hMCPi0GGPt[iCut]->Sumw2();
1201  fMCList[iCut]->Add(hMCPi0GGPt[iCut]);
1202 
1203  hMCEtaPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",250,0,25);
1204  hMCEtaPt[iCut]->Sumw2();
1205  fMCList[iCut]->Add(hMCEtaPt[iCut]);
1206 
1207  hMCEtaGGPt[iCut] = new TH1F("MC_Eta_GG_Pt","MC_Eta_GG_Pt",250,0,25);
1208  hMCEtaGGPt[iCut]->Sumw2();
1209  fMCList[iCut]->Add(hMCEtaGGPt[iCut]);
1210 
1211  hMCPi0InAccPt[iCut] = new TH1F("MC_Pi0DalitzInAcc_Pt","MC_Pi0DalitzInAcc_Pt",250,0,25);
1212  hMCPi0InAccPt[iCut]->Sumw2();
1213  fMCList[iCut]->Add(hMCPi0InAccPt[iCut]);
1214 
1215  hMCPi0WOWeightInAccPt[iCut] = new TH1F("MC_Pi0WOWeightInAcc_Pt","MC_Pi0WOWeightInAcc_Pt",250,0,25);
1216  hMCPi0WOWeightInAccPt[iCut]->Sumw2();
1217  fMCList[iCut]->Add(hMCPi0WOWeightInAccPt[iCut]);
1218 
1219  hMCPi0InAccOpeningAngleGammaElectron[iCut] = new TH1F("MC_Pi0InAcc_OpeningAngle_GammaElectron","MC_Pi0InAcc_OpeningAngle_GammaElectron",100,0,TMath::Pi());
1221 
1222  hMCEtaInAccPt[iCut] = new TH1F("MC_EtaDalitzInAcc_Pt","MC_EtaDalitzInAcc_Pt",250,0,25);
1223  hMCEtaInAccPt[iCut]->Sumw2();
1224  fMCList[iCut]->Add(hMCEtaInAccPt[iCut]);
1225 
1226  hMCChiCPt[iCut] = new TH1F("MC_ChiC_Pt","MC_ChiC_Pt",250,0,25);
1227  fMCList[iCut]->Add(hMCChiCPt[iCut]);
1228 
1229  hMCChiCInAccPt[iCut] = new TH1F("MC_ChiCInAcc_Pt","MC_ChiCInAcc_Pt",250,0,25);
1230  fMCList[iCut]->Add(hMCChiCInAccPt[iCut]);
1231 
1232  if ( fDoMesonQA > 0 ) {
1233  hMCPi0EposEnegInvMassPt[iCut] = new TH2F("MC_Pi0EposEneg_InvMassPt","MC_Pi0EposEneg_InvMassPt",100,0.0,0.5,100,0.,10.);
1234  fMCList[iCut]->Add(hMCPi0EposEnegInvMassPt[iCut]);
1235  hMCEtaEposEnegInvMassPt[iCut] = new TH2F("MC_EtaEposEneg_InvMassPt","MC_EtaEposEneg_InvMassPt",140,0.,0.7,100,0.,10.);
1236  fMCList[iCut]->Add(hMCEtaEposEnegInvMassPt[iCut]);
1237  }
1238 
1239  fTrueList[iCut] = new TList();
1240  fTrueList[iCut]->SetName(Form("%s_%s_%s_%s True histograms",cutstringEvent.Data(),cutstringGamma.Data(),cutstringElectron.Data(),cutstringMeson.Data()));
1241  fTrueList[iCut]->SetOwner(kTRUE);
1242  fCutFolder[iCut]->Add(fTrueList[iCut]);
1243 
1244  if ( fDoMesonQA > 0 ) {
1245  hESDEposEnegTruePi0DalitzInvMassPt[iCut] = new TH2F("ESD_EposEneg_TruePi0Dalitz_InvMassPt","ESD_EposEneg_TruePi0Dalitz_InvMassPt",nBinsMassPair,xMinMassPair,xMaxMassPair,100,0.,10.);
1248 
1249  hESDEposEnegTruePrimPi0DalitzInvMass[iCut] = new TH1F("ESD_EposEneg_TruePrimPi0Dalitz_InvMass","ESD_EposEneg_TruePrimPi0Dalitz_InvMass",nBinsMassPair,xMinMassPair,xMaxMassPair);
1251 
1252  hESDEposEnegTrueInvMassPt[iCut] = new TH2F("ESD_EposEneg_True_InvMassPt","ESD_EposEneg_True_InvMassPt",nBinsMassPair,xMinMassPair,xMaxMassPair,100,0.,10.);
1254  fTrueList[iCut]->Add(hESDEposEnegTrueInvMassPt[iCut]);
1255 
1256  hESDEposEnegTrueMotherInvMassPt[iCut] = new TH2F("ESD_EposEneg_TrueMother_InvMassPt","ESD_EposEneg_TrueMother_InvMassPt",nBinsMassPair,xMinMassPair,xMaxMassPair,100,0.,10.);
1258  fTrueList[iCut]->Add(hESDEposEnegTrueMotherInvMassPt[iCut]);
1259 
1260  hESDEposEnegTrueEtaDalitzInvMassPt[iCut] = new TH2F("ESD_EposEneg_TrueEtaDalitz_InvMassPt","ESD_EposEneg_TrueEtaDalitz_InvMassPt",nBinsMassPair,xMinMassPair,xMaxMassPair,100,0.,10.);
1263 
1264  hESDEposEnegTruePrimEtaDalitzInvMass[iCut] = new TH1F("ESD_EposEneg_TruePrimEtaDalitz_InvMass","ESD_EposEneg_TruePrimEtaDalitz_InvMass",nBinsMassPair,xMinMassPair,xMaxMassPair);
1265  //if(fDoHistoDalitzMassLog)SetLogBinningXTH2(hESDEposEnegTruePrimEtaDalitzInvMass[iCut]);
1267 
1268  hESDEposEnegTruePhotonInvMassPt[iCut] = new TH2F("ESD_EposEneg_TruePhoton_InvMassPt","ESD_EposEneg_TruePhoton_InvMassPt",nBinsMassPair,xMinMassPair,xMaxMassPair,100,0.,10.);
1270  fTrueList[iCut]->Add(hESDEposEnegTruePhotonInvMassPt[iCut]);
1271 
1272  hESDEposEnegTrueJPsiInvMassPt[iCut] = new TH2F("ESD_EposEneg_TrueJPsi_InvMassPt","ESD_EposEneg_TrueJPsi_InvMassPt",1000,0.,5.,100,0.,10.);
1273  fTrueList[iCut]->Add(hESDEposEnegTrueJPsiInvMassPt[iCut]);
1274 
1275  hESDEposEnegTruePi0DalitzPsiPairDPhi[iCut] = new TH2F("ESD_EposEneg_TruePi0Dalitz_PsiPair_DPhi","ESD_EposEneg_TruePi0Dalitz_PsiPair_DPhi", 100, -1.0,1.0,100,-1.0,1.0 );
1277 
1278  hESDEposEnegTruePi0DalitzPsiPairMC[iCut] = new TH1F("ESD_EposEneg_TruePi0Dalitz_PsiPairMC","ESD_EposEneg_TruePi0Dalitz_PsiPairMC", 100, -1.0,1.0);
1280 
1281  hESDEposEnegTruePi0DalitzPsiPairEta[iCut] = new TH2F("ESD_EposEneg_TruePi0Dalitz_PsiPair_Eta","ESD_EposEneg_TruePi0Dalitz_PsiPair_Eta", 100, -1.0,1.0,600,-1.5,1.5 );
1283 
1284  hESDEposEnegTruePi0DalitzDPhiEta[iCut] = new TH2F("ESD_EposEneg_TruePi0Dalitz_DPhi_Eta","ESD_EposEneg_TruePi0Dalitz_DPhi_Eta", 100, -1.0,1.0,600,-1.5,1.5 );
1285  fTrueList[iCut]->Add(hESDEposEnegTruePi0DalitzDPhiEta[iCut]);
1286 
1287  hESDEposEnegTrueEtaDalitzPsiPairDPhi[iCut] = new TH2F("ESD_EposEneg_TrueEtaDalitz_PsiPair_DPhi","ESD_EposEneg_TrueEtaDalitz_PsiPair_DPhi", 100, -1.0,1.0,100,-1.0,1.0 );
1289 
1290  hESDEposEnegTruePhotonPsiPairDPhi[iCut] = new TH2F("ESD_EposEneg_TruePhoton_PsiPair_DPhi","ESD_EposEneg_TruePhoton_PsiPair_DPhi", 100, -1.0,1.0,100,-1.0,1.0 );
1291  fTrueList[iCut]->Add(hESDEposEnegTruePhotonPsiPairDPhi[iCut]);
1292 
1293  hESDEposEnegTruePhotonPsiPairDPhiPtCut[iCut] = new TH2F("ESD_EposEneg_TruePhoton_PsiPair_DPhi_PtCut","ESD_EposEneg_TruePhoton_PsiPair_DPhi_PtCut", 100, -1.0,1.0,100,-1.0,1.0 );
1295 
1296  hESDTrueConvGammaR[iCut] = new TH1F("ESD_TrueConvGamma_R","ESD_TrueConvGamma_R",800,0,200);
1297  fTrueList[iCut]->Add(hESDTrueConvGammaR[iCut]);
1298 
1299  hESDTrueConvGammaRMC[iCut] = new TH1F("ESD_TrueConvGamma_R_MC","ESD_TrueConvGamma_R_MC",800,0,200);
1300  fTrueList[iCut]->Add(hESDTrueConvGammaRMC[iCut]);
1301 
1302  hESDTrueConvGammaPtMC[iCut] = new TH1F("ESD_TrueConvGamma_Pt_MC","ESD_TrueConvGamma_Pt_MC",250,0,25);
1303  fTrueList[iCut]->Add(hESDTrueConvGammaPtMC[iCut]);
1304 
1305  hESDTruePi0EposEnegInvMassPi0Pt[iCut] = new TH2F("ESD_TruePi0EposEnegInvMass_Pi0Pt","ESD_TruePi0EposEnegInvMass_Pi0Pt",100,0.0,0.5,100,0.,10.);
1306  fTrueList[iCut]->Add(hESDTruePi0EposEnegInvMassPi0Pt[iCut]);
1307 
1308  hESDTruePi0PtY[iCut] = new TH2F("ESD_TruePi0_Pt_Y","ESD_TruePi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1310  fTrueList[iCut]->Add(hESDTruePi0PtY[iCut]);
1311 
1312  hESDTruePi0PtAlpha[iCut] = new TH2F("ESD_TruePi0_Pt_Alpha","ESD_TruePi0_Pt_Alpha",150,0.03,15.,100,0,1);
1314  fTrueList[iCut]->Add(hESDTruePi0PtAlpha[iCut]);
1315 
1316  hESDTruePi0PtOpenAngle[iCut] = new TH2F("ESD_TruePi0_Pt_OpenAngle","ESD_TruePi0_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());
1318  fTrueList[iCut]->Add(hESDTruePi0PtOpenAngle[iCut]);
1319 
1320  if(fDoMesonQA > 1 ) {
1321  hESDTruePi0DalitzConvGammaR[iCut] = new TH1F("ESD_TruePi0DalitzConvGamma_R","hESDTruePi0DalitzConvGammaR",800,0,200);
1322  fTrueList[iCut]->Add(hESDTruePi0DalitzConvGammaR[iCut]);
1323 
1324  const Int_t nDimDalPlot = 2;
1325  Int_t nBinsDalPlot[nDimDalPlot] = { 4000, 4000};
1326  Double_t xMinDalPlot[nDimDalPlot] = { 0, 0};
1327  Double_t xMaxDalPlot[nDimDalPlot] = { 4.0, 4.0};
1328 
1329  sESDTruePi0DalitzPlot[iCut] = new THnSparseF("ESD_TruePi0Dalitz_DalitzPlot","ESD_TruePi0Dalitz_DalitzPlot",nDimDalPlot,nBinsDalPlot,xMinDalPlot,xMaxDalPlot);
1330  fQAFolder[iCut]->Add(sESDTruePi0DalitzPlot[iCut]);
1331 
1332  sMCPi0DalitzPlot[iCut] = new THnSparseF("MC_Pi0Dalitz_DalitzPlot","MC_Pi0Dalitz_DalitzPlot",nDimDalPlot,nBinsDalPlot,xMinDalPlot,xMaxDalPlot);
1333  fQAFolder[iCut]->Add(sMCPi0DalitzPlot[iCut]);
1334  }
1335  }
1336 
1337  hESDTruePositronPt[iCut] = new TH1F("ESD_TruePositron_Pt","ESD_TruePositron_Pt",1000,0,25);
1338  fTrueList[iCut]->Add(hESDTruePositronPt[iCut]);
1339 
1340  hESDTrueElectronPt[iCut] = new TH1F("ESD_TrueElectron_Pt","ESD_TrueElectron_Pt",1000,0,25);
1341  fTrueList[iCut]->Add(hESDTrueElectronPt[iCut]);
1342 
1343  hESDTrueSecPositronPt[iCut] = new TH1F("ESD_TrueSecPositron_Pt","ESD_TrueSecPositron_Pt",1000,0,25);
1344  fTrueList[iCut]->Add(hESDTrueSecPositronPt[iCut]);
1345 
1346  hESDTrueSecElectronPt[iCut] = new TH1F("ESD_TrueSecElectron_Pt","ESD_TrueSecElectron_Pt",1000,0,25);
1347  fTrueList[iCut]->Add(hESDTrueSecElectronPt[iCut]);
1348 
1349  hESDTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt","ESD_TrueConvGamma_Pt",250,0,25);
1350  fTrueList[iCut]->Add(hESDTrueConvGammaPt[iCut]);
1351 
1352  fHistoDoubleCountTrueConvGammaRPt[iCut] = new TH2F("ESD_TrueDoubleCountConvGamma_R_Pt","ESD_TrueDoubleCountConvGamma_R_Pt",800,0,200,300,0,30);
1353  fTrueList[iCut]->Add(fHistoDoubleCountTrueConvGammaRPt[iCut]);
1354 
1355  hESDTrueSecConvGammaPt[iCut] = new TH1F("ESD_TrueSecConvGamma_Pt","ESD_TrueSecConvGamma_Pt",250,0,25);
1356  fTrueList[iCut]->Add(hESDTrueSecConvGammaPt[iCut]);
1357 
1358  hESDTruePi0DalitzConvGammaPt[iCut] = new TH1F("ESD_TruePi0DalitzConvGamma_Pt","ESD_TruePi0DalitzConvGamma_Pt",250,0,25);
1359  fTrueList[iCut]->Add(hESDTruePi0DalitzConvGammaPt[iCut]);
1360 
1361  fHistoDoubleCountTruePi0InvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountPi0_InvMass_Pt","ESD_TrueDoubleCountPi0_InvMass_Pt",800,0,0.8,300,0,30);
1362  fTrueList[iCut]->Add(fHistoDoubleCountTruePi0InvMassPt[iCut]);
1363  fHistoDoubleCountTrueEtaInvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountEta_InvMass_Pt","ESD_TrueDoubleCountEta_InvMass_Pt",800,0,0.8,300,0,30);
1364  fTrueList[iCut]->Add(fHistoDoubleCountTrueEtaInvMassPt[iCut]);
1365 
1366  hESDTruePi0DalitzElectronPt[iCut] = new TH1F("ESD_TruePi0DalitzElectron_Pt","ESD_TruePi0DalitzElectron_Pt",1000,0,25);
1367  fTrueList[iCut]->Add(hESDTruePi0DalitzElectronPt[iCut]);
1368 
1369  hESDTruePi0DalitzElectronPtMB[iCut] = new TH1F("ESD_TruePi0DalitzElectron_Pt_MB","ESD_TruePi0DalitzElectron_Pt_MB",1000,0,25);
1370  fTrueList[iCut]->Add(hESDTruePi0DalitzElectronPtMB[iCut]);
1371 
1372  hESDTruePi0DalitzPositronPt[iCut] = new TH1F("ESD_TruePi0DalitzPositron_Pt","ESD_TruePi0DalitzPositron_Pt",1000,0,25);
1373  fTrueList[iCut]->Add(hESDTruePi0DalitzPositronPt[iCut]);
1374 
1375  hESDTruePi0DalitzPositronPtMB[iCut] = new TH1F("ESD_TruePi0DalitzPositron_Pt_MB","ESD_TruePi0DalitzPositron_Pt_MB",1000,0,25);
1376  fTrueList[iCut]->Add(hESDTruePi0DalitzPositronPtMB[iCut]);
1377 
1378  hESDTruePi0DalitzSecConvGammaPt[iCut] = new TH1F("ESD_TruePi0DalitzSecConvGamma_Pt","ESD_TruePi0DalitzSecConvGamma_Pt",250,0,25);
1379  fTrueList[iCut]->Add(hESDTruePi0DalitzSecConvGammaPt[iCut]);
1380 
1381  hESDTruePi0DalitzSecElectronPt[iCut] = new TH1F("ESD_TruePi0DalitzSecElectron_Pt","ESD_TruePi0DalitzSecElectron_Pt",1000,0,25);
1382  fTrueList[iCut]->Add(hESDTruePi0DalitzSecElectronPt[iCut]);
1383 
1384  hESDTruePi0DalitzSecPositronPt[iCut] = new TH1F("ESD_TruePi0DalitzSecPositron_Pt","ESD_TruePi0DalitzSecPositron_Pt",1000,0,25);
1385  fTrueList[iCut]->Add(hESDTruePi0DalitzSecPositronPt[iCut]);
1386 
1387  if( fDoChicAnalysis) {
1388  hESDTrueMotherChiCInvMassPt[iCut] = new TH2F("ESD_TrueMotherChiC_InvMass_Pt","ESD_TrueMotherChiC_InvMass_Pt",4000,0,4,250,0,25);
1389  fTrueList[iCut]->Add(hESDTrueMotherChiCInvMassPt[iCut]);
1390  hESDTrueMotherChiCDiffInvMassPt[iCut] = new TH2F("ESD_TrueMotherChiCDiff_InvMass_Pt","ESD_TrueMotherChiCDiff_InvMass_Pt",2000,0,2,250,0,25);
1391  fTrueList[iCut]->Add(hESDTrueMotherChiCDiffInvMassPt[iCut]);
1392  }
1393 
1394  hESDTrueMotherInvMassPt[iCut] = new TH2F("ESD_TrueMother_InvMass_Pt","ESD_TrueMother_InvMass_Pt",800,0,0.8,250,0,25);
1395  hESDTrueMotherInvMassPt[iCut]->Sumw2();
1396  fTrueList[iCut]->Add(hESDTrueMotherInvMassPt[iCut]);
1397 
1398  hESDTrueMotherW0WeightsInvMassPt[iCut] = new TH2F("ESD_TrueMotherW0Weights_InvMass_Pt","ESD_TrueMotherW0Weights_InvMass_Pt",800,0,0.8,250,0,25);
1399  hESDTrueMotherW0WeightsInvMassPt[iCut]->Sumw2();
1400  fTrueList[iCut]->Add(hESDTrueMotherW0WeightsInvMassPt[iCut]);
1401 
1402  hESDTrueMotherDalitzInvMassPt[iCut] = new TH2F("ESD_TrueMother_Dalitz_InvMass_Pt","ESD_TrueMother_Dalitz_InvMass_Pt",800,0,0.8,250,0,25);
1403  hESDTrueMotherDalitzInvMassPt[iCut]->Sumw2();
1404  fTrueList[iCut]->Add(hESDTrueMotherDalitzInvMassPt[iCut]);
1405 
1406  hESDTrueMotherPi0GGInvMassPt[iCut] = new TH2F("ESD_TrueMotherPi0GG_InvMass_Pt","ESD_TrueMotherPi0GG_InvMass_Pt",800,0,0.8,250,0,25);
1407  hESDTrueMotherPi0GGInvMassPt[iCut]->Sumw2();
1408  fTrueList[iCut]->Add(hESDTrueMotherPi0GGInvMassPt[iCut]);
1409 
1410  hESDTrueMotherPi0GGW0WeightsInvMassPt[iCut] = new TH2F("ESD_TrueMotherPi0GGW0Weights_InvMass_Pt","ESD_TrueMotherPi0GGW0Weights_InvMass_Pt",800,0,0.8,250,0,25);
1413 
1414  hESDTruePrimaryMotherPi0GGInvMassPt[iCut] = new TH2F("ESD_TruePrimaryMotherPi0GG_InvMass_Pt","ESD_TruePrimaryMotherPi0GG_InvMass_Pt",800,0,0.8,250,0,25);
1415  hESDTruePrimaryMotherPi0GGInvMassPt[iCut]->Sumw2();
1417 
1418  hESDTrueSecondaryMotherPi0GGInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherPi0GG_InvMass_Pt","ESD_TrueSecondaryMotherPi0GG_InvMass_Pt",800,0,0.8,250,0,25);
1421 
1422  hESDTruePrimaryPi0DalitzESDPtMCPt[iCut] = new TH2F("ESD_TruePrimaryPi0Dalitz_ESDPt_MCPt","ESD_TruePrimaryPi0Dalitz_ESDPt_MCPt",250,0,25,250,0,25);
1423  hESDTruePrimaryPi0DalitzESDPtMCPt[iCut]->Sumw2();
1424  fTrueList[iCut]->Add(hESDTruePrimaryPi0DalitzESDPtMCPt[iCut]);
1425  hESDTruePrimaryMotherInvMassMCPt[iCut] = new TH2F("ESD_TruePrimaryMother_InvMass_MCPt","ESD_TrueDalitzPrimaryMother_InvMass_MCPt",800,0,0.8,250,0,25);
1426  hESDTruePrimaryMotherInvMassMCPt[iCut]->Sumw2();
1427  fTrueList[iCut]->Add(hESDTruePrimaryMotherInvMassMCPt[iCut]);
1428  hESDTruePrimaryMotherInvMassPt[iCut] = new TH2F("ESD_TruePrimaryMother_InvMass_Pt","ESD_TruePrimaryMother_InvMass_Pt",800,0,0.8,250,0,25);
1429  hESDTruePrimaryMotherInvMassPt[iCut]->Sumw2();
1430  fTrueList[iCut]->Add(hESDTruePrimaryMotherInvMassPt[iCut]);
1431  hESDTruePrimaryMotherW0WeightingInvMassPt[iCut] = new TH2F("ESD_TruePrimaryMotherW0Weighting_InvMass_Pt","ESD_TruePrimaryMotherW0Weighting_InvMass_Pt",800,0,0.8,250,0,25);
1434 
1435  hESDTrueSecondaryMotherInvMassPt[iCut] = new TH2F("ESD_TrueDalitzSecondaryMother_InvMass_Pt","ESD_TrueDalitzSecondaryMother_InvMass_Pt",800,0,0.8,250,0,25);
1436  hESDTrueSecondaryMotherInvMassPt[iCut]->Sumw2();
1437  fTrueList[iCut]->Add(hESDTrueSecondaryMotherInvMassPt[iCut]);
1438  // hESDTrueSecondaryMotherFromK0sInvMassPt[iCut] = new TH2F("ESD_TrueDalitzSecondaryMotherFromK0s_InvMass_Pt","ESD_TrueDalitzSecondaryMotherFromK0s_InvMass_Pt",1000,0,1,250,0,25);
1439  // fTrueList[iCut]->Add(hESDTrueSecondaryMotherFromK0sInvMassPt[iCut]);
1440  hESDTrueBckGGInvMassPt[iCut] = new TH2F("ESD_TrueDalitzBckGG_InvMass_Pt","ESD_TrueDalitzBckGG_InvMass_Pt",800,0,0.8,250,0,25);
1441  fTrueList[iCut]->Add(hESDTrueBckGGInvMassPt[iCut]);
1442  hESDTrueBckContInvMassPt[iCut] = new TH2F("ESD_TrueDalitzBckCont_InvMass_Pt","ESD_TrueDalitzBckCont_InvMass_Pt",800,0,0.8,250,0,25);
1443  fTrueList[iCut]->Add(hESDTrueBckContInvMassPt[iCut]);
1444  // hESDTrueMotherGGInvMassPt[iCut] = new TH2F("ESD_TrueGammaGamma_InvMass_Pt","ESD_TrueGammaGamma_InvMass_Pt",1000,0,1,250,0,25);
1445  // fTrueList[iCut]->Add(hESDTrueMotherGGInvMassPt[iCut]);
1446 
1447  }
1448  }
1449 
1453 
1454  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
1455  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
1456 
1457  if(fV0Reader)
1459  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms())
1460  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
1461 
1462  if(fV0Reader)
1464  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
1465  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
1466 
1470 
1471  fElecSelector=(AliDalitzElectronSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("ElectronSelector");
1472  if(!fElecSelector){printf("Error: No ElectronSelector");return;} // GetV0Reader
1473 
1474  if( fElecSelector ){
1475  if ( ((AliDalitzElectronCuts*)fElecSelector->GetDalitzElectronCuts())->GetCutHistograms() ){
1477  }
1478  }
1479 
1480  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1481 
1482  if( fCutElectronArray ){
1483  if( ((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutHistograms() ) {
1484  fCutFolder[iCut]->Add( ((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetCutHistograms() );
1485  }
1486  }
1487 
1488  if( fCutMesonArray ) {
1489  if( ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutHistograms() ) {
1490  fCutFolder[iCut]->Add( ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->GetCutHistograms());
1491  }
1492  }
1493 
1494  if( fCutGammaArray ) {
1495  if( ((AliConversionPhotonCuts*)fCutGammaArray->At(iCut))->GetCutHistograms() ) {
1496  fCutFolder[iCut]->Add( ((AliConversionPhotonCuts*)fCutGammaArray->At(iCut))->GetCutHistograms() );
1497  }
1498  }
1499 
1500  if( fCutEventArray )
1501  if( ((AliConvEventCuts*)fCutEventArray->At(iCut))->GetCutHistograms()){
1502  fCutFolder[iCut]->Add(((AliConvEventCuts*)fCutEventArray->At(iCut))->GetCutHistograms());
1503  }
1504  }
1505 
1506  PostData(1, fOutputContainer);
1507 
1508 }
1509 
1510 //______________________________________________________________________
1512 
1513  //
1514  // Execute analysis for current event
1515  //
1516  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
1517  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
1518  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
1519  // Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1
1520  if(eventQuality == 2 || eventQuality == 3){
1521  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1522  hNEvents[iCut]->Fill(eventQuality);
1523  }
1524  return;
1525  }
1526 
1527  fElecSelector=(AliDalitzElectronSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("ElectronSelector");
1528  if(!fElecSelector){printf("Error: No ElectronSelector");return;} // GetV0Reader
1529 
1530  if(fIsMC)
1531  fMCEvent = MCEvent();
1532  fESDEvent = (AliESDEvent*)InputEvent();
1533  fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
1534 
1535  AliEventplane *EventPlane = fInputEvent->GetEventplane();
1536  if(fIsHeavyIon == 1)fEventPlaneAngle = EventPlane->GetEventplane("V0",fInputEvent,2);
1537  else fEventPlaneAngle=0.0;
1538 
1539  fSelectorElectronIndex = fElecSelector->GetReconstructedElectronsIndex(); // Electrons from default Cut
1540  fSelectorPositronIndex = fElecSelector->GetReconstructedPositronsIndex(); // Positrons from default Cut
1541 
1542  CountESDTracks(); // Estimate Event Multiplicity
1544  //AddTaskContainers(); //Add conatiner
1545 
1546  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1547  fiCut = iCut;
1548  fNVirtualGammas = 0;
1549 
1550  Int_t eventNotAccepted = ((AliConvEventCuts*)fCutEventArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon,kFALSE);
1551 
1552  if(eventNotAccepted){
1553  hNEvents[iCut]->Fill(eventNotAccepted); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
1554  continue;
1555  }
1556 
1557  if(eventQuality != 0){// Event Not Accepted
1558  hNEvents[iCut]->Fill(eventQuality);
1559  continue;
1560  }
1561 
1562  hNEvents[iCut]->Fill(eventQuality);
1563  hNGoodESDTracks[iCut]->Fill(fNumberOfESDTracks);
1564 
1565  if(((AliConvEventCuts*)fCutEventArray->At(iCut))->IsHeavyIon() == 2) hNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A());
1566  else hNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C());
1567 
1568  if(fMCEvent){ // Process MC Particle
1569  if(((AliConvEventCuts*)fCutEventArray->At(iCut))->GetSignalRejection() != 0){
1570  ((AliConvEventCuts*)fCutEventArray->At(iCut))->GetNotRejectedParticles( ((AliConvEventCuts*)fCutEventArray->At(iCut))->GetSignalRejection(),
1571  ((AliConvEventCuts*)fCutEventArray->At(iCut))->GetAcceptedHeader(),
1572  fMCEvent);
1573  }
1575  }
1576 
1577  ProcessPhotonCandidates(); // Process this cuts gammas
1578  ProcessElectronCandidates(); // Process this cuts gammas
1579 
1580  if(((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->UseMCPSmearing() && fMCEvent){
1581 
1582  fUnsmearedPx = new Double_t[fGoodGammas->GetEntries()]; // Store unsmeared Momenta
1583  fUnsmearedPy = new Double_t[fGoodGammas->GetEntries()];
1584  fUnsmearedPz = new Double_t[fGoodGammas->GetEntries()];
1585  fUnsmearedE = new Double_t[fGoodGammas->GetEntries()];
1586 
1587  for(Int_t gamma=0;gamma<fGoodGammas->GetEntries();gamma++){ // Smear the AODPhotons in MC
1588  fUnsmearedPx[gamma] = ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->Px();
1589  fUnsmearedPy[gamma] = ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->Py();
1590  fUnsmearedPz[gamma] = ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->Pz();
1591  fUnsmearedE[gamma] = ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->E();
1592  ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->SmearParticle(dynamic_cast<AliAODConversionPhoton*>(fGoodGammas->At(gamma)));
1593  }
1594  }
1595 
1596  if( ((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetUseVPhotonMCPmearing() && ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->UseMCPSmearing() && fMCEvent){
1597  // cout<<"Entro virtual photon smearing"<<endl;
1598  fUnsmearedVPx = new Double_t[fGoodVirtualGammas->GetEntries()]; // Store unsmeared Momenta
1599  fUnsmearedVPy = new Double_t[fGoodVirtualGammas->GetEntries()];
1600  fUnsmearedVPz = new Double_t[fGoodVirtualGammas->GetEntries()];
1601  fUnsmearedVE = new Double_t[fGoodVirtualGammas->GetEntries()];
1602 
1603  for(Int_t Vgamma=0;Vgamma<fGoodVirtualGammas->GetEntries();Vgamma++){ // Smear the AODPhotons in MC
1604  fUnsmearedVPx[Vgamma] = ((AliAODConversionPhoton*)fGoodVirtualGammas->At(Vgamma))->Px();
1605  fUnsmearedVPy[Vgamma] = ((AliAODConversionPhoton*)fGoodVirtualGammas->At(Vgamma))->Py();
1606  fUnsmearedVPz[Vgamma] = ((AliAODConversionPhoton*)fGoodVirtualGammas->At(Vgamma))->Pz();
1607  fUnsmearedVE[Vgamma] = ((AliAODConversionPhoton*)fGoodVirtualGammas->At(Vgamma))->E();
1608  ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->SmearVirtualPhoton(dynamic_cast<AliAODConversionPhoton*>(fGoodVirtualGammas->At(Vgamma)));
1609  }
1610  }
1613 
1614  if(((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->DoBGCalculation()){
1615  if(((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->BackgroundHandlerType() == 0){
1618  }
1619  }
1620 
1621  if ( fDoMesonQA > 0) {
1624  fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)));
1625  }
1626 
1627 
1628  if(((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->UseMCPSmearing() && fMCEvent){
1629  for(Int_t gamma=0;gamma<fGoodGammas->GetEntries();gamma++){ // Smear the AODPhotons in MC
1630  ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->SetPx(fUnsmearedPx[gamma]); // Reset Unsmeared Momenta
1631  ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->SetPy(fUnsmearedPy[gamma]);
1632  ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->SetPz(fUnsmearedPz[gamma]);
1633  ((AliAODConversionPhoton*)fGoodGammas->At(gamma))->SetE(fUnsmearedE[gamma]);
1634  }
1635  delete[] fUnsmearedPx; fUnsmearedPx = 0x0;
1636  delete[] fUnsmearedPy; fUnsmearedPy = 0x0;
1637  delete[] fUnsmearedPz; fUnsmearedPz = 0x0;
1638  delete[] fUnsmearedE; fUnsmearedE = 0x0;
1639  }
1640 
1641  if( ((AliDalitzElectronCuts*)fCutElectronArray->At(iCut))->GetUseVPhotonMCPmearing() && ((AliConversionMesonCuts*)fCutMesonArray->At(iCut))->UseMCPSmearing() && fMCEvent){
1642  for(Int_t Vgamma=0;Vgamma<fGoodVirtualGammas->GetEntries();Vgamma++){ // Smear the AODPhotons in MC
1643  ((AliAODConversionPhoton*)fGoodVirtualGammas->At(Vgamma))->SetPx(fUnsmearedVPx[Vgamma]); // Reset Unsmeared Momenta
1644  ((AliAODConversionPhoton*)fGoodVirtualGammas->At(Vgamma))->SetPy(fUnsmearedVPy[Vgamma]);
1645  ((AliAODConversionPhoton*)fGoodVirtualGammas->At(Vgamma))->SetPz(fUnsmearedVPz[Vgamma]);
1646  ((AliAODConversionPhoton*)fGoodVirtualGammas->At(Vgamma))->SetE(fUnsmearedVE[Vgamma]);
1647  }
1648  delete[] fUnsmearedVPx; fUnsmearedVPx = 0x0;
1649  delete[] fUnsmearedVPy; fUnsmearedVPy = 0x0;
1650  delete[] fUnsmearedVPz; fUnsmearedVPz = 0x0;
1651  delete[] fUnsmearedVE; fUnsmearedVE = 0x0;
1652  }
1656  fGoodGammas->Clear(); // delete this cuts good gammas
1657  fGoodVirtualGammas->Clear(); // delete this cuts good gammas
1658  }
1659 
1660  fSelectorElectronIndex.clear();
1661  fSelectorPositronIndex.clear();
1662 
1663  PostData( 1, fOutputContainer );
1664 }
1665 
1667  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1668  if (((AliConvEventCuts*)fCutEventArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
1669  ((AliConvEventCuts*)fCutEventArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
1670  } else if (((AliConvEventCuts*)fCutEventArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
1671  ((AliConvEventCuts*)fCutEventArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
1672  }
1673 
1674  if( !((AliConvEventCuts*)fCutEventArray->At(iCut))->GetDoEtaShift() ){
1675 
1676  hEtaShift[iCut]->Fill(0.,0.);
1677  continue; // No Eta Shift requested, continue
1678  }
1679 
1680  if( ((AliConvEventCuts*)fCutEventArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
1681  ((AliConvEventCuts*)fCutEventArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
1682  ((AliConvEventCuts*)fCutEventArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1683  hEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fCutEventArray->At(iCut))->GetEtaShift()));
1684  continue;
1685  } else {
1686  printf(" Gamma Conversion Dalitz Task %s :: Eta Shift Manually Set to %f \n\n",
1687  (((AliConvEventCuts*)fCutEventArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fCutEventArray->At(iCut))->GetEtaShift());
1688  ((AliConvEventCuts*)fCutEventArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1689  hEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fCutEventArray->At(iCut))->GetEtaShift()));
1690  }
1691  }
1692 
1693  return kTRUE;
1694 }
1695 
1696 //________________________________________________________________________
1698 {
1700 }
1701 
1702 //________________________________________________________________________
1704 
1705  Int_t nV0 = 0;
1706  TList *GoodGammasStepOne = new TList();
1707  TList *GoodGammasStepTwo = new TList();
1708  // Loop over Photon Candidates allocated by ReaderV1
1709 
1710  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
1711  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
1712  if(!PhotonCandidate) continue;
1713  fIsFromMBHeader = kTRUE;
1714  if( fMCEvent && ((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetSignalRejection() != 0 ){
1715  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
1716  if(isPosFromMBHeader == 0 && ((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetSignalRejection() != 3) continue;
1717  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent,fInputEvent);
1718  if(isNegFromMBHeader == 0 && ((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetSignalRejection() != 3) continue;
1719  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
1720  }
1721 
1722  if(!((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fESDEvent)) continue;
1723 
1724  if(!((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->UseElecSharingCut() &&
1725  !((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->UseToCloseV0sCut()){ // if no post reader loop is required add to events good gammas
1726 
1727  fGoodGammas->Add(PhotonCandidate);
1728  if(fIsFromMBHeader){
1729  hESDConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
1730  hESDConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1731  if( fDoMesonQA > 1 ) {
1732  Double_t sparesFillZR[2] = {PhotonCandidate->GetConversionZ(),PhotonCandidate->GetConversionRadius()};
1733  sESDConvGammaZR[fiCut]->Fill(sparesFillZR);
1734  Double_t sparesFillXY[2] = {PhotonCandidate->GetConversionX(),PhotonCandidate->GetConversionY()};
1735  sESDConvGammaXY[fiCut]->Fill(sparesFillXY);
1736  }
1737  }
1738  if(fMCEvent){
1739  ProcessTruePhotonCandidates(PhotonCandidate);
1740  }
1741  } else if(((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
1742  ((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
1743  nV0++;
1744  GoodGammasStepOne->Add(PhotonCandidate);
1745  } else if(!((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->UseElecSharingCut() &&
1746  ((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
1747  GoodGammasStepTwo->Add(PhotonCandidate);
1748  }
1749  }
1750 
1751 
1752  if(((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->UseElecSharingCut()){
1753  for(Int_t i = 0;i<GoodGammasStepOne->GetEntries();i++){
1754  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GoodGammasStepOne->At(i);
1755  if(!PhotonCandidate) continue;
1756  fIsFromMBHeader = kTRUE;
1757  if(fMCEvent && ((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetSignalRejection() != 0){
1758  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent,fInputEvent);
1759  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent,fInputEvent);
1760  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
1761  }
1762 
1763  if(!((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GoodGammasStepOne->GetEntries())) continue;
1764  if(!((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
1765  fGoodGammas->Add(PhotonCandidate);
1766  if(fIsFromMBHeader){
1767  hESDConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
1768  hESDConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1769  if( fDoMesonQA > 1 ){
1770  Double_t sparesFillZR[2] = {PhotonCandidate->GetConversionZ(),PhotonCandidate->GetConversionRadius()};
1771  sESDConvGammaZR[fiCut]->Fill(sparesFillZR);
1772  Double_t sparesFillXY[2] = {PhotonCandidate->GetConversionX(),PhotonCandidate->GetConversionY()};
1773  sESDConvGammaXY[fiCut]->Fill(sparesFillXY);
1774  }
1775  }
1776 
1777  if(fMCEvent){
1778  ProcessTruePhotonCandidates(PhotonCandidate);
1779  }
1780  } else GoodGammasStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
1781  }
1782  }
1783  if(((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->UseToCloseV0sCut()){
1784  for(Int_t i = 0;i<GoodGammasStepTwo->GetEntries();i++){
1785  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GoodGammasStepTwo->At(i);
1786  if(!PhotonCandidate) continue;
1787  if(fMCEvent && ((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetSignalRejection() != 0){
1788  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent,fInputEvent);
1789  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent,fInputEvent);
1790  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
1791  }
1792  if(!((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GoodGammasStepTwo,i)) continue;
1793  fGoodGammas->Add(PhotonCandidate); // Add gamma to current cut TList
1794 
1795  if(fIsFromMBHeader){
1796  hESDConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt()); // Differences to old V0Reader in p_t due to conversion KF->TLorentzVector
1797  hESDConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1798  if(fDoMesonQA > 1 ){
1799  Double_t sparesFillZR[2] = {PhotonCandidate->GetConversionZ(),PhotonCandidate->GetConversionRadius()};
1800  sESDConvGammaZR[fiCut]->Fill(sparesFillZR);
1801  Double_t sparesFillXY[2] = {PhotonCandidate->GetConversionX(),PhotonCandidate->GetConversionY()};
1802  sESDConvGammaXY[fiCut]->Fill(sparesFillXY);
1803  }
1804  }
1805 
1806  if(fMCEvent){
1807  ProcessTruePhotonCandidates(PhotonCandidate);
1808  }
1809  }
1810  }
1811 
1812  delete GoodGammasStepOne;
1813  GoodGammasStepOne = 0x0;
1814  delete GoodGammasStepTwo;
1815  GoodGammasStepTwo = 0x0;
1816 }
1817 
1818 //________________________________________________________________________
1820 {
1821  // Process True Photons
1822  TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCEvent);
1823  TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCEvent);
1824 
1825  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
1826  if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){ // Not Same Mother == Combinatorial Bck
1827  return;
1828  } else if (posDaughter->GetMother(0) == -1){
1829  return;
1830  }
1831 
1832  if(TMath::Abs(posDaughter->GetPdgCode())!=11 || TMath::Abs(negDaughter->GetPdgCode())!=11) return; //One Particle is not electron
1833  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
1834  if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
1835 
1836  TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCEvent);
1837  if(Photon->GetPdgCode() != 22) return; // Mother is no Photon
1838 
1839  // True Photon
1840 
1841  Int_t labelGamma = TruePhotonCandidate->GetMCParticleLabel(fMCEvent);
1842 
1843  if( labelGamma < fMCEvent->GetNumberOfPrimaries() ){
1844  if( fIsFromMBHeader ){
1845  hESDTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1846  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueConvGammas,posDaughter->GetMother(0))) fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt());
1847  if( fDoMesonQA > 0 ){
1848  hESDTrueConvGammaR[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius());
1849  hESDTrueConvGammaRMC[fiCut]->Fill( posDaughter->R() );
1850  hESDTrueConvGammaPtMC[fiCut]->Fill( Photon->Pt());
1851  }
1852  }
1853  } else {
1854  if( fIsFromMBHeader){
1855  hESDTrueSecConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1856  }
1857  }
1858 
1859  if( IsPi0DalitzDaughter(labelGamma) == kTRUE ) {
1860  if( labelGamma < fMCEvent->GetNumberOfPrimaries() ) {
1861  if( fIsFromMBHeader ){
1862  hESDTruePi0DalitzConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1863  if( fDoMesonQA > 1 ){
1864  hESDTruePi0DalitzConvGammaR[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius());
1865  }
1866  }
1867  } else {
1868  if( fIsFromMBHeader ) {
1869  hESDTruePi0DalitzSecConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1870  }
1871  }
1872  }
1873 }
1874 
1875 //________________________________________________________________________
1877 
1878  Double_t magField = fInputEvent->GetMagneticField();
1879  if( magField < 0.0 ){
1880  magField = 1.0;
1881  } else {
1882  magField = -1.0;
1883  }
1884 
1885  for(Int_t virtualGammaIndex=0; virtualGammaIndex < fGoodVirtualGammas->GetEntries(); virtualGammaIndex++ ){
1886  AliAODConversionPhoton *Vgamma=dynamic_cast<AliAODConversionPhoton*>(fGoodVirtualGammas->At(virtualGammaIndex));
1887 
1888  AliESDtrack* positronVgamma = fESDEvent->GetTrack( Vgamma->GetTrackLabelPositive() );
1889  AliESDtrack* electronVgamma = fESDEvent->GetTrack( Vgamma->GetTrackLabelNegative() );
1890 
1891  Bool_t isPhoton = kFALSE;
1892  Bool_t isPi0Dalitz = kFALSE;
1893  Bool_t isEtaDalitz = kFALSE;
1894  Bool_t isJPsi = kFALSE;
1895  Bool_t isTrueEposENeg = kFALSE;
1896  Bool_t isMotherPrimary = kFALSE;
1897 
1898  if ( fDoMesonQA > 0 ) {
1899  Double_t psiPair = GetPsiPair(positronVgamma,electronVgamma);
1900  Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronVgamma->GetConstrainedParam()->Phi()-positronVgamma->GetConstrainedParam()->Phi());
1901  hESDEposEnegPsiPairDPhi[fiCut]->Fill(deltaPhi,psiPair);
1902  hESDEposEnegPsiPairEta[fiCut]->Fill(psiPair,Vgamma->Eta());
1903  hESDEposEnegDPhiEta[fiCut]->Fill(deltaPhi,Vgamma->Eta());
1904  hESDEposEnegInvMassPt[fiCut]->Fill(Vgamma->M(),Vgamma->Pt());
1905 
1906  if( fMCEvent ) {
1907  Int_t virtualGammaMCLabel = Vgamma->GetMCParticleLabel(fMCEvent);
1908 
1909  TParticle * negativeMC = 0x0;
1910  TParticle * positiveMC = 0x0;
1911  TParticle * mcVgamma = 0x0;
1912 
1913  if( virtualGammaMCLabel != -1 ){
1914  mcVgamma = (TParticle*)fMCEvent->Particle(virtualGammaMCLabel);
1915  }
1916 
1917  negativeMC = (TParticle*)Vgamma->GetNegativeMCDaughter(fMCEvent);
1918  positiveMC = (TParticle*)Vgamma->GetPositiveMCDaughter(fMCEvent);
1919 
1920  if( negativeMC && positiveMC ) {
1921  if( positiveMC->GetPdgCode() == ::kPositron && negativeMC->GetPdgCode() == ::kElectron )
1922  isTrueEposENeg = kTRUE;
1923  if( positiveMC->GetMother(0) > -1 && positiveMC->GetMother(0) < fMCEvent->GetNumberOfPrimaries() )
1924  isMotherPrimary = kTRUE;
1925  }
1926  if(mcVgamma){
1927  // Check if it is a true photon
1928  if(mcVgamma->GetPdgCode() == 22){
1929  isPhoton = kTRUE;
1930  } else if(mcVgamma->GetPdgCode() == 443){
1931  isJPsi = kTRUE;
1932  } else if( IsDalitz( mcVgamma ) ){
1933  if ( mcVgamma->GetPdgCode() == 111 ) isPi0Dalitz = kTRUE;
1934  else if( mcVgamma->GetPdgCode() == 221 ) isEtaDalitz = kTRUE;
1935  }
1936  }
1937 
1938  if(isPhoton){
1939  hESDEposEnegTruePhotonInvMassPt[fiCut]->Fill(Vgamma->M(),Vgamma->Pt());
1940  hESDEposEnegTruePhotonPsiPairDPhi[fiCut]->Fill(deltaPhi,psiPair);
1941  if( Vgamma->Pt() > 1.5 ){
1942  hESDEposEnegTruePhotonPsiPairDPhiPtCut[fiCut]->Fill(deltaPhi,psiPair);
1943  }
1944  } else if(isJPsi){
1945  hESDEposEnegTrueJPsiInvMassPt[fiCut]->Fill(Vgamma->M(),Vgamma->Pt());
1946  } else if(isPi0Dalitz){
1947  Double_t psiPairMC = GetPsiPairMC(positiveMC, negativeMC);
1948  hESDEposEnegTruePi0DalitzPsiPairMC[fiCut]->Fill(psiPairMC);
1949  hESDEposEnegTruePi0DalitzInvMassPt[fiCut]->Fill(Vgamma->M(),Vgamma->Pt());
1950  hESDEposEnegTruePi0DalitzPsiPairDPhi[fiCut]->Fill(deltaPhi,psiPair);
1951  hESDEposEnegTruePi0DalitzPsiPairEta[fiCut]->Fill(psiPair,Vgamma->Eta());
1952  hESDEposEnegTruePi0DalitzDPhiEta[fiCut]->Fill(deltaPhi,Vgamma->Eta());
1953 
1954  if( isMotherPrimary ) hESDEposEnegTruePrimPi0DalitzInvMass[fiCut]->Fill( Vgamma->M() );
1955  } else if(isEtaDalitz){
1956  hESDEposEnegTrueEtaDalitzInvMassPt[fiCut]->Fill(Vgamma->M(),Vgamma->Pt());
1957  hESDEposEnegTrueEtaDalitzPsiPairDPhi[fiCut]->Fill(deltaPhi,psiPair);
1958  if( isMotherPrimary ) hESDEposEnegTruePrimEtaDalitzInvMass[fiCut]->Fill( Vgamma->M() );
1959  } else if ( isTrueEposENeg && mcVgamma ){
1960  hESDEposEnegTrueMotherInvMassPt[fiCut]->Fill(Vgamma->M(), Vgamma->Pt());
1961  }
1962 
1963  if ( isTrueEposENeg ) hESDEposEnegTrueInvMassPt[fiCut]->Fill(Vgamma->M(), Vgamma->Pt());
1964 
1965  }
1966  }
1967  }
1968 }
1969 
1970 //________________________________________________________________________
1972 
1973  Double_t magField = fInputEvent->GetMagneticField();
1974 
1975  if( magField < 0.0 ){
1976  magField = 1.0;
1977  } else {
1978  magField = -1.0;
1979  }
1980 
1981  vector<Int_t> lGoodElectronIndexPrev(0);
1982  vector<Int_t> lGoodPositronIndexPrev(0);
1983 
1984  for(UInt_t i = 0; i < fSelectorElectronIndex.size(); i++){
1985  AliESDtrack* electronCandidate = fESDEvent->GetTrack(fSelectorElectronIndex[i]);
1986  Bool_t IsMCFromMBHeader = kTRUE;
1987 
1988  if( fMCEvent ) {
1989  Int_t isMCFromMBHeader = -1;
1990  Int_t labelelectron = TMath::Abs( electronCandidate->GetLabel() );
1991 
1992  if(((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetSignalRejection() != 0) {
1993  isMCFromMBHeader = ((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(labelelectron,fMCEvent,fInputEvent);
1994  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetSignalRejection() != 3) continue;
1995  }
1996 
1997  if( isMCFromMBHeader != 2 ) IsMCFromMBHeader = kFALSE;
1998  }
1999 
2000  if(! ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->ElectronIsSelected(electronCandidate) ) continue;
2001 
2002  lGoodElectronIndexPrev.push_back( fSelectorElectronIndex[i] );
2003  hESDDalitzElectronPt[fiCut]->Fill(electronCandidate->Pt());
2004  hESDDalitzElectronPhi[fiCut]->Fill(electronCandidate->Phi());
2005 
2006  if( fMCEvent ) {
2007  Int_t labelelectron = TMath::Abs( electronCandidate->GetLabel() );
2008  if( labelelectron < fMCEvent->GetNumberOfTracks() ){
2009  TParticle* electron = fMCEvent->Particle(labelelectron);
2010  if( electron->GetPdgCode() == 11 ){
2011  if( labelelectron < fMCEvent->GetNumberOfPrimaries() ){
2012  hESDTrueElectronPt[fiCut]->Fill(electronCandidate->Pt()); //primary electron
2013  } else {
2014  hESDTrueSecElectronPt[fiCut]->Fill(electronCandidate->Pt()); //secondary electron
2015  }
2016  if( IsPi0DalitzDaughter(labelelectron) == kTRUE && labelelectron < fMCEvent->GetNumberOfPrimaries() ) {
2017  if( electron->GetMother(0) < fMCEvent->GetNumberOfPrimaries() ) {
2018  hESDTruePi0DalitzElectronPt[fiCut]->Fill(electronCandidate->Pt());
2019  if( IsMCFromMBHeader == kTRUE ) hESDTruePi0DalitzElectronPtMB[fiCut]->Fill(electronCandidate->Pt());
2020  } else {
2021  hESDTruePi0DalitzSecElectronPt[fiCut]->Fill(electronCandidate->Pt());
2022  }
2023  }
2024  }
2025  }
2026  }
2027  }
2028 
2029  for(UInt_t i = 0; i < fSelectorPositronIndex.size(); i++){
2030 
2031  AliESDtrack* positronCandidate = fESDEvent->GetTrack( fSelectorPositronIndex[i] );
2032  Bool_t IsMCFromMBHeader = kTRUE;
2033 
2034  if( fMCEvent ) {
2035  Int_t isMCFromMBHeader = -1;
2036  Int_t labelpositron = TMath::Abs( positronCandidate->GetLabel() );
2037  if(((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetSignalRejection() != 0) {
2038  isMCFromMBHeader = ((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(labelpositron,fMCEvent,fInputEvent);
2039  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetSignalRejection() != 3) continue;
2040  }
2041 
2042  if( isMCFromMBHeader != 2 ) IsMCFromMBHeader = kFALSE;
2043  }
2044 
2045  if(! ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->ElectronIsSelected(positronCandidate) ) continue;
2046 
2047  lGoodPositronIndexPrev.push_back( fSelectorPositronIndex[i] );
2048  hESDDalitzPositronPt[fiCut]->Fill( positronCandidate->Pt() );
2049  hESDDalitzPositronPhi[fiCut]->Fill( positronCandidate->Phi() );
2050 
2051  if( fMCEvent ) {
2052  Int_t labelpositron = TMath::Abs( positronCandidate->GetLabel() );
2053  if( labelpositron < fMCEvent->GetNumberOfTracks() ) {
2054  TParticle* positron = fMCEvent->Particle(labelpositron);
2055  if( positron->GetPdgCode() == -11 ){
2056  if( labelpositron < fMCEvent->GetNumberOfPrimaries() ){
2057  hESDTruePositronPt[fiCut]->Fill(positronCandidate->Pt());
2058  } else {
2059  hESDTrueSecPositronPt[fiCut]->Fill(positronCandidate->Pt());
2060  }
2061  if( IsPi0DalitzDaughter(labelpositron) == kTRUE && labelpositron < fMCEvent->GetNumberOfPrimaries() ) {
2062  if( positron->GetMother(0) < fMCEvent->GetNumberOfPrimaries() ){
2063  hESDTruePi0DalitzPositronPt[fiCut]->Fill(positronCandidate->Pt());
2064  if ( IsMCFromMBHeader == kTRUE )hESDTruePi0DalitzPositronPtMB[fiCut]->Fill(positronCandidate->Pt());
2065  } else {
2066  hESDTruePi0DalitzSecPositronPt[fiCut]->Fill(positronCandidate->Pt());
2067  }
2068  }
2069  }
2070  }
2071  }
2072  }
2073 
2074  vector<Bool_t> lElectronPsiIndex(lGoodElectronIndexPrev.size(), kTRUE);
2075  vector<Bool_t> lPositronPsiIndex(lGoodPositronIndexPrev.size(), kTRUE);
2076 
2077  if( ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->DoPsiPairCut() == kTRUE ){
2078  for( UInt_t i = 0; i < lGoodElectronIndexPrev.size(); i++ ) {
2079  AliESDtrack *electronCandidate = fESDEvent->GetTrack(lGoodElectronIndexPrev[i]);
2080  for(UInt_t j = 0; j < lGoodPositronIndexPrev.size(); j++){
2081  AliESDtrack *positronCandidate = fESDEvent->GetTrack(lGoodPositronIndexPrev[j]);
2082  Double_t psiPair = GetPsiPair(positronCandidate,electronCandidate);
2083  Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->GetConstrainedParam()->Phi()-positronCandidate->GetConstrainedParam()->Phi());
2084 
2085  if( ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->IsFromGammaConversion(psiPair,deltaPhi ) ){
2086  lElectronPsiIndex[i] = kFALSE;
2087  lPositronPsiIndex[j] = kFALSE;
2088  }
2089  }
2090  }
2091  }
2092 
2093  vector<Int_t> lGoodElectronIndex(0);
2094  vector<Int_t> lGoodPositronIndex(0);
2095 
2096  for( UInt_t i = 0; i < lGoodElectronIndexPrev.size(); i++ ) {
2097  if( lElectronPsiIndex[i] == kTRUE )
2098  lGoodElectronIndex.push_back( lGoodElectronIndexPrev[i] );
2099  }
2100 
2101  for( UInt_t i = 0; i < lGoodPositronIndexPrev.size(); i++ ) {
2102  if( lPositronPsiIndex[i] == kTRUE )
2103  lGoodPositronIndex.push_back( lGoodPositronIndexPrev[i] );
2104  }
2105 
2106  for(UInt_t i = 0; i < lGoodElectronIndex.size(); i++){
2107  AliESDtrack *electronCandidate = fESDEvent->GetTrack(lGoodElectronIndex[i]);
2108  AliKFParticle electronCandidateKF( *electronCandidate->GetConstrainedParam(), ::kElectron );
2109  TLorentzVector electronCandidateTLV;
2110  electronCandidateTLV.SetXYZM(electronCandidate->GetConstrainedParam()->Px(),electronCandidate->GetConstrainedParam()->Py(),electronCandidate->GetConstrainedParam()->Pz(),TDatabasePDG::Instance()->GetParticle( ::kElectron )->Mass());
2111 
2112  for(UInt_t j = 0; j < lGoodPositronIndex.size(); j++){
2113 
2114  AliESDtrack *positronCandidate = fESDEvent->GetTrack(lGoodPositronIndex[j]);
2115  AliKFParticle positronCandidateKF( *positronCandidate->GetConstrainedParam(), ::kPositron );
2116  TLorentzVector positronCandidateTLV;
2117 
2118  positronCandidateTLV.SetXYZM(positronCandidate->GetConstrainedParam()->Px(),positronCandidate->GetConstrainedParam()->Py(),positronCandidate->GetConstrainedParam()->Pz(),TDatabasePDG::Instance()->GetParticle( ::kPositron )->Mass());
2119  TLorentzVector *virtualPhotonTLV = 0;
2120  AliKFConversionPhoton* virtualPhoton = NULL;
2121  AliAODConversionPhoton *vphoton;
2122 
2123  if( ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->GetUseElectronMCSmearing() && ((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->UseMCPSmearing() && fMCEvent){
2124  TLorentzVector smearelectronCandidateTLV = ((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->SmearElectron(electronCandidateTLV);
2125  TLorentzVector smearpositronCandidateTLV = ((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->SmearElectron(positronCandidateTLV);
2126  virtualPhotonTLV = new TLorentzVector( smearelectronCandidateTLV + smearpositronCandidateTLV );
2127  //TLorentzVector temp = electronCandidateTLV + positronCandidateTLV;
2128  //cout<<"Mass: "<<"NoSmearElectrons "<<temp.M() <<" SmearElectrons "<<virtualPhotonTLV->M()<<endl;
2129  vphoton= new AliAODConversionPhoton(virtualPhotonTLV);
2130  vphoton->SetMass(virtualPhotonTLV->M());
2131  } else {
2132  virtualPhoton = new AliKFConversionPhoton(electronCandidateKF,positronCandidateKF);
2133  if( fSetProductionVertextoVGamma == kTRUE ){
2134  AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex());
2135  primaryVertexImproved+=*virtualPhoton;
2136  virtualPhoton->SetProductionVertex(primaryVertexImproved);
2137  }
2138  vphoton= new AliAODConversionPhoton(virtualPhoton);
2139  }
2140  //virtualPhoton->SetTrackLabels( lGoodPositronIndex[j], lGoodElectronIndex[i]);
2141  vphoton->SetTrackLabels( lGoodPositronIndex[j], lGoodElectronIndex[i]);
2142 
2143  if( fMCEvent ) {
2144  Int_t labeln=TMath::Abs(electronCandidate->GetLabel());
2145  Int_t labelp=TMath::Abs(positronCandidate->GetLabel());
2146  TParticle *fNegativeMCParticle = fMCEvent->Particle(labeln);
2147  TParticle *fPositiveMCParticle = fMCEvent->Particle(labelp);
2148  if( fPositiveMCParticle && fNegativeMCParticle) {
2149  //virtualPhoton->SetMCLabelPositive(labelp);
2150  //virtualPhoton->SetMCLabelNegative(labeln);
2151  vphoton->SetMCLabelPositive(labelp);
2152  vphoton->SetMCLabelNegative(labeln);
2153 
2154  }
2155  }
2156 
2157  fGoodVirtualGammas->Add( vphoton );
2158 
2159  if( virtualPhoton ){
2160  delete virtualPhoton;
2161  virtualPhoton=NULL;
2162  }
2163  if ( virtualPhotonTLV ){
2164  delete virtualPhotonTLV;
2165  virtualPhotonTLV=NULL;
2166  }
2167  }
2168  }
2169 
2170  //Computing mixing event
2171  if( fDoMesonQA > 0 ) {
2172  for(UInt_t i = 0; i < lGoodElectronIndex.size(); i++){
2173  AliESDtrack *electronCandidate1 = fESDEvent->GetTrack(lGoodElectronIndex[i]);
2174  AliKFParticle electronCandidate1KF( *electronCandidate1->GetConstrainedParam(), ::kElectron );
2175 
2176  for(UInt_t j = i+1; j < lGoodElectronIndex.size(); j++){
2177 
2178  AliESDtrack *electronCandidate2 = fESDEvent->GetTrack(lGoodElectronIndex[j]);
2179  AliKFParticle electronCandidate2KF( *electronCandidate2->GetConstrainedParam(), ::kElectron );
2180  AliKFConversionPhoton* virtualPhoton = new AliKFConversionPhoton(electronCandidate1KF,electronCandidate2KF);
2181 
2182  //AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex());
2183  //primaryVertexImproved+=*virtualPhoton;
2184  //virtualPhoton->SetProductionVertex(primaryVertexImproved);
2185 
2186  AliAODConversionPhoton *vphoton = new AliAODConversionPhoton(virtualPhoton);
2187  hESDEposEnegLikeSignBackInvMassPt[fiCut]->Fill(vphoton->M(),vphoton->Pt());
2188  delete vphoton;
2189  delete virtualPhoton;
2190  vphoton = 0x0;
2191  virtualPhoton = 0x0;
2192  }
2193  }
2194 
2195  for(UInt_t i = 0; i < lGoodPositronIndex.size(); i++){
2196  AliESDtrack *positronCandidate1 = fESDEvent->GetTrack(lGoodPositronIndex[i]);
2197  AliKFParticle positronCandidate1KF( *positronCandidate1->GetConstrainedParam(), ::kPositron );
2198 
2199  for(UInt_t j = i+1; j < lGoodPositronIndex.size(); j++){
2200 
2201  AliESDtrack *positronCandidate2 = fESDEvent->GetTrack(lGoodPositronIndex[j]);
2202  AliKFParticle positronCandidate2KF( *positronCandidate2->GetConstrainedParam(), ::kPositron );
2203  AliKFConversionPhoton* virtualPhoton = new AliKFConversionPhoton(positronCandidate1KF,positronCandidate2KF);
2204  //AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex());
2205  //primaryVertexImproved+=*virtualPhoton;
2206  //virtualPhoton->SetProductionVertex(primaryVertexImproved);
2207 
2208  AliAODConversionPhoton *vphoton = new AliAODConversionPhoton(virtualPhoton);
2209  hESDEposEnegLikeSignBackInvMassPt[fiCut]->Fill(vphoton->M(),vphoton->Pt());
2210  delete vphoton;
2211  delete virtualPhoton;
2212  vphoton = 0x0;
2213  virtualPhoton = 0x0;
2214 
2215  }
2216  }
2217  }
2218 }
2219 
2220 //________________________________________________________________________
2222 
2223 // cout << "have " << fGoodGammas->GetEntries() << " real gamma's and " << fGoodVirtualGammas->GetEntries() << " virtual gamma's" << endl;
2224  // Conversion Gammas
2225  if( fGoodGammas->GetEntries() > 0 && fGoodVirtualGammas->GetEntries() > 0 ){
2226  vector<Bool_t> lGoodVirtualGamma(fGoodVirtualGammas->GetEntries(), kFALSE);
2227 
2228  for(Int_t GammaIndex=0; GammaIndex<fGoodGammas->GetEntries(); GammaIndex++){
2229  AliAODConversionPhoton *gamma=dynamic_cast<AliAODConversionPhoton*>(fGoodGammas->At(GammaIndex));
2230  if (gamma==NULL) continue;
2231  for(Int_t virtualGammaIndex=0;virtualGammaIndex<fGoodVirtualGammas->GetEntries();virtualGammaIndex++){
2232  AliAODConversionPhoton *Vgamma=dynamic_cast<AliAODConversionPhoton*>(fGoodVirtualGammas->At(virtualGammaIndex));
2233  if (Vgamma==NULL) continue;
2234  //Check for same Electron ID
2235  if( gamma->GetTrackLabelPositive() == Vgamma->GetTrackLabelPositive() ||
2236  gamma->GetTrackLabelNegative() == Vgamma->GetTrackLabelNegative() ||
2237  gamma->GetTrackLabelNegative() == Vgamma->GetTrackLabelPositive() ||
2238  gamma->GetTrackLabelPositive() == Vgamma->GetTrackLabelNegative() ) continue;
2239 
2240  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma,Vgamma);
2241  pi0cand->SetLabels(GammaIndex,virtualGammaIndex);
2242 
2243  if( ( ((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetEtaShift())) ){
2244  //cout<< "Meson Accepted "<<endl;
2245  Int_t zbin = 0;
2246  Int_t mbin = 0;
2247  if(fDoTHnSparse && ((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->DoBGCalculation()){
2248  if(((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->BackgroundHandlerType() == 0){
2249 
2250  zbin= fBGHandler[fiCut]->GetZBinIndex(fESDEvent->GetPrimaryVertex()->GetZ());
2251  if( ((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->UseTrackMultiplicity() ){
2253  } else {
2254  mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGoodGammas->GetEntries());
2255  }
2256  }
2257  }
2258  if ( fDoMesonQA > 0 ) {
2259  if( fMCEvent ) {
2260  Int_t virtualGammaMCLabel = Vgamma->GetMCParticleLabel(fMCEvent);
2261  if( virtualGammaMCLabel > -1 ) {
2262 
2263  TParticle * negativeMC = (TParticle*)Vgamma->GetNegativeMCDaughter(fMCEvent);
2264  TParticle * positiveMC = (TParticle*)Vgamma->GetPositiveMCDaughter(fMCEvent);
2265  // TParticle * virtualGammaMotherMC = (TParticle*)fMCEvent->Particle(virtualGammaMCLabel);
2266 
2267  if( negativeMC->GetPdgCode() == 11 && positiveMC->GetPdgCode() == -11) { // Electrons ...
2268  if( IsPi0DalitzDaughter( Vgamma->GetMCLabelPositive() ) ){
2269  hESDTruePi0EposEnegInvMassPi0Pt[fiCut]->Fill( Vgamma->M(), pi0cand->Pt() );
2270  }
2271  }
2272  }
2273  }
2274  }
2275 
2276  if( ((AliDalitzElectronCuts*) fCutElectronArray->At(fiCut))->DoMassCut() == kTRUE ) {
2277  if( ((AliDalitzElectronCuts*) fCutElectronArray->At(fiCut))->MassCut( pi0cand->Pt() , Vgamma->M() ) == kTRUE ){
2278  hESDMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
2279  if( fDoTHnSparse ){
2280  Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
2281  sESDMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
2282  }
2283 
2284  if(fMCEvent){
2285  ProcessTrueMesonCandidates(pi0cand,gamma,Vgamma);
2286  }
2287 
2288  if ( fDoMesonQA > 0 ) {
2289  AliESDtrack* positronVgamma = fESDEvent->GetTrack( Vgamma->GetTrackLabelPositive() );
2290  Double_t momPositron[3];
2291  positronVgamma->GetConstrainedPxPyPz(momPositron);
2292 
2293  AliESDtrack* electronVgamma = fESDEvent->GetTrack( Vgamma->GetTrackLabelNegative() );
2294  Double_t momElectron[3];
2295  electronVgamma->GetConstrainedPxPyPz(momElectron);
2296 
2297  TVector3 vGamma(gamma->GetPx(),gamma->GetPy(),gamma->GetPz());;
2298  TVector3 vPositron(momPositron[0],momPositron[1],momPositron[2]);
2299  TVector3 vElectron(momElectron[0],momElectron[1],momElectron[2]);
2300 
2301  hESDMotherInvMassOpeningAngleGammaElectron[fiCut]->Fill( vGamma.Angle(vPositron) );
2302  hESDMotherInvMassOpeningAngleGammaElectron[fiCut]->Fill( vGamma.Angle(vElectron) );
2303 
2304  if ( pi0cand->M() > 0.05 && pi0cand->M() < 0.17){
2305 
2306  if( fDoMesonQA > 1 ){
2307  TLorentzVector electronCandidateTLV(vElectron,TDatabasePDG::Instance()->GetParticle( ::kElectron )->Mass());
2308  TLorentzVector positronCandidateTLV(vPositron,TDatabasePDG::Instance()->GetParticle( ::kPositron )->Mass());
2309  TLorentzVector gammaTLV(vGamma,0);
2310  TLorentzVector GammaElectronCandidateTLV = gammaTLV + electronCandidateTLV;
2311  TLorentzVector GammaPositronCandidateTLV = gammaTLV + positronCandidateTLV;
2312  Double_t sparesDalitzPlot[2] = {GammaElectronCandidateTLV.M()*GammaElectronCandidateTLV.M(),GammaPositronCandidateTLV.M()*GammaPositronCandidateTLV.M()};
2313  sESDMotherDalitzPlot[fiCut]->Fill(sparesDalitzPlot);
2314  }
2315  hESDMotherPi0PtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetEtaShift());
2316  hESDMotherPi0PtAlpha[fiCut]->Fill(pi0cand->Pt(),TMath::Abs(pi0cand->GetAlpha()));
2317  hESDMotherPi0PtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());
2318  }
2319 
2320  if( lGoodVirtualGamma[virtualGammaIndex] == kFALSE ) {
2321  if( pi0cand->M() > 0.1 && pi0cand->M() < 0.145 ){
2322  FillElectronQAHistos(Vgamma);
2323  lGoodVirtualGamma[virtualGammaIndex] = kTRUE;
2324  fNVirtualGammas++;
2325  }
2326  }
2327  }
2328  }
2329  } else {
2330  hESDMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
2331  if( fDoTHnSparse ){
2332  Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
2333  sESDMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
2334  }
2335 
2336  if(fMCEvent){
2337  ProcessTrueMesonCandidates(pi0cand,gamma,Vgamma);
2338  }
2339 
2340  if ( fDoMesonQA > 0 ) {
2341  if ( pi0cand->M() > 0.05 && pi0cand->M() < 0.17){
2342  hESDMotherPi0PtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetEtaShift());
2343  hESDMotherPi0PtAlpha[fiCut]->Fill(pi0cand->Pt(),TMath::Abs(pi0cand->GetAlpha()));
2344  hESDMotherPi0PtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());
2345  }
2346  if( lGoodVirtualGamma[virtualGammaIndex] == kFALSE ) {
2347  if( pi0cand->M() > 0.1 && pi0cand->M() < 0.145 ){
2348  FillElectronQAHistos(Vgamma);
2349  lGoodVirtualGamma[virtualGammaIndex] = kTRUE;
2350  fNVirtualGammas++;
2351  }
2352  }
2353  }
2354  }
2355 
2356  if( fDoChicAnalysis) {
2357  hESDPi0MotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
2358  hESDEposEnegInvMassPi0MotherPt[fiCut]->Fill(Vgamma->M(),pi0cand->Pt());
2359  Double_t diffMass = pi0cand->M() - Vgamma->M();
2360  hESDPi0MotherDiffInvMassPt[fiCut]->Fill( diffMass , pi0cand->Pt() );
2361 
2362  if( Vgamma->M() > 2.5 && Vgamma->M() < 3.4){
2363  hESDPi0MotherDiffLimInvMassPt[fiCut]->Fill( diffMass , pi0cand->Pt() );
2364  }
2365 
2366  if(fMCEvent){
2367  ProcessTrueChicCandidates(pi0cand,gamma,Vgamma);
2368  }
2369  }
2370  }
2371  delete pi0cand;
2372  pi0cand=0x0;
2373  }
2374  }
2375  }
2376 }
2377 
2378 //________________________________________________________________________
2380 
2381  Int_t zbin= fBGHandler[fiCut]->GetZBinIndex(fESDEvent->GetPrimaryVertex()->GetZ());
2382  Int_t mbin = 0;
2383 
2384 
2385  if(((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->UseTrackMultiplicity()){
2387  } else {
2388  mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGoodGammas->GetEntries());
2389  }
2390 
2392 
2393  if(((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->UseTrackMultiplicity()){
2394  for(Int_t nEventsInBG=0;nEventsInBG<fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
2395 
2396  AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
2397  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0 ){
2398  bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
2399  }
2400 
2401  for(Int_t iCurrent=0;iCurrent<fGoodVirtualGammas->GetEntries();iCurrent++){
2402  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGoodVirtualGammas->At(iCurrent));
2403 
2404  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2405  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
2406 
2407  if(fMoveParticleAccordingToVertex == kTRUE ){
2408  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
2409  }
2410 
2411  if(((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
2412  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
2413  }
2414 
2415  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
2416  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
2417 
2418  if( ( ((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE, ((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetEtaShift()))){
2419  if( ((AliDalitzElectronCuts*) fCutElectronArray->At(fiCut))->DoMassCut() == kTRUE ) {
2420 
2421  if( ((AliDalitzElectronCuts*) fCutElectronArray->At(fiCut))->MassCut( backgroundCandidate->Pt() , currentEventGoodV0.M() ) == kTRUE ){
2422 
2423  hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
2424  if(fDoTHnSparse){
2425  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
2426  sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
2427  }
2428  }
2429  } else {
2430  hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
2431  if(fDoTHnSparse){
2432  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
2433  sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
2434  }
2435  }
2436  }
2437  delete backgroundCandidate;
2438  backgroundCandidate = 0x0;
2439  }
2440  }
2441  }
2442  } else {
2443  for(Int_t nEventsInBG=0;nEventsInBG <fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
2444  AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
2445  if(previousEventV0s){
2446  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0 ){
2447  bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
2448  }
2449  for(Int_t iCurrent=0;iCurrent<fGoodVirtualGammas->GetEntries();iCurrent++){
2450  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGoodVirtualGammas->At(iCurrent));
2451  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
2452  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
2453  if(fMoveParticleAccordingToVertex == kTRUE ){
2454  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
2455  }
2456 
2457  if(((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
2458  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
2459  }
2460 
2461  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
2462  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
2463 
2464  if((((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetEtaShift()))){
2465  if( ((AliDalitzElectronCuts*) fCutElectronArray->At(fiCut))->DoMassCut() == kTRUE ) {
2466  if( ((AliDalitzElectronCuts*) fCutElectronArray->At(fiCut))->MassCut( backgroundCandidate->Pt() , currentEventGoodV0.M() ) == kTRUE ){
2467  hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
2468  if(fDoTHnSparse){
2469  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
2470  sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
2471  }
2472  }
2473  } else {
2474  hESDMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
2475  if(fDoTHnSparse){
2476  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
2477  sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
2478  }
2479  }
2480  }
2481  delete backgroundCandidate;
2482  backgroundCandidate = 0x0;
2483  }
2484  }
2485  }
2486  }
2487  }
2488 
2489 }
2490 
2491 
2492 //________________________________________________________________________
2494  //see header file for documentation
2495 
2496  if(fGoodGammas->GetEntries() > 0 ){
2497  if( ((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->UseTrackMultiplicity() ){
2498  fBGHandler[fiCut]->AddEvent(fGoodGammas,fESDEvent->GetPrimaryVertex()->GetX(),fESDEvent->GetPrimaryVertex()->GetY(),fESDEvent->GetPrimaryVertex()->GetZ(),fNumberOfESDTracks,fEventPlaneAngle);
2499  } else { // means we use #V0s for multiplicity
2500  fBGHandler[fiCut]->AddEvent(fGoodGammas,fESDEvent->GetPrimaryVertex()->GetX(),fESDEvent->GetPrimaryVertex()->GetY(),fESDEvent->GetPrimaryVertex()->GetZ(),fGoodGammas->GetEntries(),fEventPlaneAngle);
2501  }
2502  }
2503 
2504 }
2505 
2506 //______________________________________________________________________
2508 {
2509  // Process True Mesons
2510 
2511  if( TrueGammaCandidate->GetV0Index() < fESDEvent->GetNumberOfV0s() ){
2512  Bool_t isTruePi0 = kFALSE;
2513  Bool_t isTrueEta = kFALSE;
2514  Int_t gammaMCLabel = TrueGammaCandidate->GetMCParticleLabel(fMCEvent);
2515  Int_t gammaMotherLabel = -1;
2516 
2517  //Checking if the gamma candidate is a real gamma
2518  if(gammaMCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2519  // Daughters Gamma 0
2520  TParticle * negativeMC = (TParticle*)TrueGammaCandidate->GetNegativeMCDaughter(fMCEvent);
2521  TParticle * positiveMC = (TParticle*)TrueGammaCandidate->GetPositiveMCDaughter(fMCEvent);
2522  TParticle * gammaMC = (TParticle*)fMCEvent->Particle(gammaMCLabel);
2523 
2524  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2525  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
2526  if(gammaMC->GetPdgCode() == 22){ // ... with Gamma Mother
2527  gammaMotherLabel=gammaMC->GetFirstMother();
2528  }
2529  }
2530  }
2531  }
2532 
2533  //Checking if the virtual gamma is a real virtual gamma
2534  Int_t virtualGammaMCLabel = TrueVirtualGammaCandidate->GetMCParticleLabel(fMCEvent);
2535  Int_t virtualGammaMotherLabel = -1;
2536  Int_t virtualGamma = -1;
2537 
2538  if( virtualGammaMCLabel != -1 ){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2539  // Daughters Gamma 1
2540  TParticle * negativeMC = (TParticle*)TrueVirtualGammaCandidate->GetNegativeMCDaughter(fMCEvent);
2541  TParticle * positiveMC = (TParticle*)TrueVirtualGammaCandidate->GetPositiveMCDaughter(fMCEvent);
2542  TParticle * virtualGammaMotherMC = (TParticle*)fMCEvent->Particle(virtualGammaMCLabel);
2543 
2544  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2545  if( virtualGammaMotherMC->GetPdgCode() != 22 ){
2546  virtualGammaMotherLabel=virtualGammaMCLabel;
2547  virtualGamma = 1;
2548  } else if (negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
2549  virtualGammaMotherLabel=virtualGammaMotherMC->GetFirstMother();
2550  virtualGamma = 0; //no virtual gamma
2551  }
2552  }
2553  }
2554 
2555  //Checking if both gamma and virtual gamma comming from Pi0 or Eta
2556  if( gammaMotherLabel >= 0 && ( gammaMotherLabel == virtualGammaMotherLabel) ){
2557  if(((TParticle*)fMCEvent->Particle(virtualGammaMotherLabel))->GetPdgCode() == 111){
2558  isTruePi0=kTRUE;
2559  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gammaMotherLabel)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2560  }
2561  if(((TParticle*)fMCEvent->Particle(virtualGammaMotherLabel))->GetPdgCode() == 221){
2562  isTrueEta=kTRUE;
2563  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueEtas,gammaMotherLabel)) fHistoDoubleCountTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2564  }
2565  }
2566 
2567  if( isTruePi0 || isTrueEta ){ // True Pion or Eta
2568  if ( virtualGamma == 1 ) { //True Dalitz
2569  Float_t weighted= 1;
2570  Float_t weightMatBudget = 1.;
2571  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->GetMaterialBudgetWeightsInitialized ()) {
2572  weightMatBudget = ((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueGammaCandidate);
2573  }
2574  if ( isTruePi0 && fDoMesonQA > 0 ) {
2575  if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
2576  hESDTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetEtaShift());
2577  hESDTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()));
2578  hESDTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
2579 
2580  if( fDoMesonQA > 1 ) {
2581  AliESDtrack* positronVgamma = fESDEvent->GetTrack( TrueVirtualGammaCandidate->GetTrackLabelPositive() );
2582  Double_t momPositron[3];
2583  positronVgamma->GetConstrainedPxPyPz(momPositron);
2584 
2585  AliESDtrack* electronVgamma = fESDEvent->GetTrack( TrueVirtualGammaCandidate->GetTrackLabelNegative() );
2586  Double_t momElectron[3];
2587  electronVgamma->GetConstrainedPxPyPz(momElectron);
2588 
2589  TVector3 vGamma(TrueGammaCandidate->GetPx(),TrueGammaCandidate->GetPy(),TrueGammaCandidate->GetPz());;
2590  TVector3 vPositron(momPositron[0],momPositron[1],momPositron[2]);
2591  TVector3 vElectron(momElectron[0],momElectron[1],momElectron[2]);
2592 
2593  TLorentzVector electronCandidateTLV(vElectron,TDatabasePDG::Instance()->GetParticle( ::kElectron )->Mass());
2594  TLorentzVector positronCandidateTLV(vPositron,TDatabasePDG::Instance()->GetParticle( ::kPositron )->Mass());
2595  TLorentzVector gammaTLV(vGamma,0);
2596  TLorentzVector GammaElectronCandidateTLV = gammaTLV + electronCandidateTLV;
2597  TLorentzVector GammaPositronCandidateTLV = gammaTLV + positronCandidateTLV;
2598  Double_t sparesDalitzPlot[2] = {GammaElectronCandidateTLV.M()*GammaElectronCandidateTLV.M(),GammaPositronCandidateTLV.M()*GammaPositronCandidateTLV.M()};
2599  sESDTruePi0DalitzPlot[fiCut]->Fill(sparesDalitzPlot);
2600  }
2601  }
2602  }
2603 
2604 
2605 
2606  if( ((AliDalitzElectronCuts*) fCutElectronArray->At(fiCut))->DoWeights() ) {
2607  if(((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(gammaMotherLabel, fMCEvent,fInputEvent)){
2608  if (((TParticle*)fMCEvent->Particle(gammaMotherLabel))->Pt()>0.005){
2609  weighted= ((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetWeightForMeson(gammaMotherLabel,fMCEvent,fInputEvent);
2610  }
2611  }
2612  }
2613 
2614  hESDTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget);
2615  hESDTrueMotherW0WeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2616  hESDTrueMotherDalitzInvMassPt[fiCut]->Fill( TrueVirtualGammaCandidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget);
2617 
2618  if(gammaMotherLabel < fMCEvent->GetNumberOfPrimaries()){ // Only primary pi0 for efficiency calculation
2619  hESDTruePrimaryMotherInvMassPt[fiCut]->Fill( Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget);
2620  hESDTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill( Pi0Candidate->M(), Pi0Candidate->Pt() );
2621  hESDTruePrimaryMotherInvMassMCPt[fiCut]->Fill(Pi0Candidate->M(),((TParticle*)fMCEvent->Particle(virtualGammaMotherLabel))->Pt(),weighted*weightMatBudget);
2622  if(isTruePi0){ // Only primaries for unfolding
2623  hESDTruePrimaryPi0DalitzESDPtMCPt[fiCut]->Fill(Pi0Candidate->Pt(),((TParticle*)fMCEvent->Particle(virtualGammaMotherLabel))->Pt(),weighted*weightMatBudget);
2624  }
2625  } else { // Secondary Meson
2626  Float_t weightedSec= 1;
2627  if( ((AliDalitzElectronCuts*) fCutElectronArray->At(fiCut))->DoWeights() ) {
2628  Int_t secMotherLabel = ((TParticle*)fMCEvent->Particle(gammaMotherLabel))->GetMother(0);
2629  if(((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(gammaMotherLabel, fMCEvent, fInputEvent) && fMCEvent->Particle(gammaMotherLabel)->GetPdgCode()==310){
2630  weightedSec= ((AliConvEventCuts*)fCutEventArray->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
2631  }
2632  }
2633  hESDTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget);
2634  }
2635  } else if ( virtualGamma == 0 ){
2636  Float_t weightMatBudget = 1.;
2637  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->GetMaterialBudgetWeightsInitialized ()) {
2638  weightMatBudget = ((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueGammaCandidate) * ((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueVirtualGammaCandidate);
2639  }
2640  Float_t weighted= 1;
2641  if( ((AliDalitzElectronCuts*) fCutElectronArray->At(fiCut))->DoWeights() ) {
2642  if(((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(gammaMotherLabel, fMCEvent,fInputEvent)){
2643  if (((TParticle*)fMCEvent->Particle(gammaMotherLabel))->Pt()>0.005){
2644  weighted= ((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetWeightForMeson(gammaMotherLabel,fMCEvent,fInputEvent);
2645  }
2646  }
2647  }
2648  hESDTrueMotherPi0GGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget); // Pi0 from GG
2649  hESDTrueMotherPi0GGW0WeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2650 
2651  if( gammaMotherLabel < fMCEvent->GetNumberOfPrimaries() ){
2652  hESDTruePrimaryMotherPi0GGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget);
2653  } else {
2654  Float_t weightedSec= 1;
2655  if( ((AliDalitzElectronCuts*) fCutElectronArray->At(fiCut))->DoWeights() ) {
2656  Int_t secMotherLabel = ((TParticle*)fMCEvent->Particle(gammaMotherLabel))->GetMother(0);
2657  if(((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(gammaMotherLabel, fMCEvent, fInputEvent) && fMCEvent->Particle(gammaMotherLabel)->GetPdgCode()==310){
2658  weightedSec= ((AliConvEventCuts*)fCutEventArray->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
2659  }
2660  }
2661  hESDTrueSecondaryMotherPi0GGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget);
2662  }
2663  }
2664  }
2665 
2666  if( !isTruePi0 && !isTrueEta ){ // Background
2667  if( gammaMotherLabel > -1 && virtualGammaMotherLabel > -1 && virtualGamma == 0 ){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
2668  hESDTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2669  } else { // No photon or without mother
2670  hESDTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2671  }
2672  }
2673  }
2674 }
2675 
2676 //______________________________________________________________________
2678  if( TrueGammaCandidate->GetV0Index() < fESDEvent->GetNumberOfV0s()){
2679 
2680  //Checking gamma
2681  Int_t gammaMCLabel = TrueGammaCandidate->GetMCParticleLabel(fMCEvent);
2682  Int_t gammaMotherLabel = -1;
2683 
2684  if( gammaMCLabel != -1){// Gamma is Combinatorial; MC Particles don't belong to the same Mother
2685  // Daughters Gamma 0
2686  TParticle * negativeMC = (TParticle*)TrueGammaCandidate->GetNegativeMCDaughter(fMCEvent);
2687  TParticle * positiveMC = (TParticle*)TrueGammaCandidate->GetPositiveMCDaughter(fMCEvent);
2688  TParticle * gammaMC = (TParticle*)fMCEvent->Particle(gammaMCLabel);
2689 
2690  if( TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11 ){ // Electrons ...
2691  if( negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() == 5 ){ // ... From Conversion ...
2692  if(gammaMC->GetPdgCode() == 22){ // ... with Gamma Mother
2693  gammaMotherLabel=gammaMC->GetFirstMother();
2694  }
2695  }
2696  }
2697  }
2698 
2699  //Checking jpsi
2700  Int_t jpsiMCLabel = TruejpsiCandidate->GetMCParticleLabel(fMCEvent);
2701  Int_t jpsiMotherLabel = -1;
2702 
2703  if( jpsiMCLabel != -1 ){
2704  TParticle * negativeMC = (TParticle*)TruejpsiCandidate->GetNegativeMCDaughter(fMCEvent);
2705  TParticle * positiveMC = (TParticle*)TruejpsiCandidate->GetPositiveMCDaughter(fMCEvent);
2706  TParticle * jpsiMC = (TParticle*)fMCEvent->Particle(jpsiMCLabel);
2707  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2708  if(jpsiMC->GetPdgCode() == 443){
2709  jpsiMotherLabel=jpsiMC->GetFirstMother();
2710  }
2711  }
2712  }
2713 
2714  if( gammaMotherLabel>=0 && ( gammaMotherLabel == jpsiMotherLabel) ){
2715  if( ((TParticle*)fMCEvent->Particle(jpsiMotherLabel))->GetPdgCode() == 445 ||
2716  ((TParticle*)fMCEvent->Particle(jpsiMotherLabel))->GetPdgCode() == 10443 ||
2717  ((TParticle*)fMCEvent->Particle(jpsiMotherLabel))->GetPdgCode() == 20443 ){
2718  hESDTrueMotherChiCInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2719  hESDTrueMotherChiCDiffInvMassPt[fiCut]->Fill(Pi0Candidate->M()-TruejpsiCandidate->M(),Pi0Candidate->Pt());
2720  }
2721  }
2722  }
2723 }
2724 
2725 //________________________________________________________________________
2727 
2728  previousEventEP=previousEventEP+TMath::Pi();
2729  thisEventEP=thisEventEP+TMath::Pi();
2730  Double_t rotationValue= thisEventEP-previousEventEP;
2731  gamma->RotateZ(rotationValue);
2732 }
2733 
2734 //________________________________________________________________________
2736  //see header file for documentation
2737 
2738  Double_t dx = vertex->fX - fESDEvent->GetPrimaryVertex()->GetX();
2739  Double_t dy = vertex->fY - fESDEvent->GetPrimaryVertex()->GetY();
2740  Double_t dz = vertex->fZ - fESDEvent->GetPrimaryVertex()->GetZ();
2741 
2742  Double_t movedPlace[3] = {particle->GetConversionX() - dx,particle->GetConversionY() - dy,particle->GetConversionZ() - dz};
2743  particle->SetConversionPoint(movedPlace);
2744 }
2745 
2746 //________________________________________________________________________
2748  Bool_t selectPrimaries = kTRUE;
2749  static AliESDtrackCuts *EsdTrackCuts = 0x0;
2750  static int prevRun = -1;
2751  // Using standard function for setting Cuts
2752  Int_t runNumber = fInputEvent->GetRunNumber();
2753  if (prevRun!=runNumber) {
2754  delete EsdTrackCuts;
2755  EsdTrackCuts = 0;
2756  prevRun = runNumber;
2757  }
2758 
2759  if (!EsdTrackCuts) {
2760  // if LHC11a or earlier or if LHC13g or if LHC12a-i -> use 2010 cuts
2761  if( (runNumber<=146860) || (runNumber>=197470 && runNumber<=197692) || (runNumber>=172440 && runNumber<=193766) ){
2762  EsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(selectPrimaries);
2763  // else if run2 data use 2015 PbPb cuts
2764  } else if (runNumber>=209122){
2765  //EsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2015PbPb();
2766  // hard coded track cuts for the moment, because AliESDtrackCuts::GetStandardITSTPCTrackCuts2015PbPb() gives spams warnings
2767  EsdTrackCuts = new AliESDtrackCuts();
2768  // TPC; clusterCut = 1, cutAcceptanceEdges = kTRUE, removeDistortedRegions = kFALSE
2769  EsdTrackCuts->AliESDtrackCuts::SetMinNCrossedRowsTPC(70);
2770  EsdTrackCuts->AliESDtrackCuts::SetMinRatioCrossedRowsOverFindableClustersTPC(0.8);
2771  EsdTrackCuts->SetCutGeoNcrNcl(2., 130., 1.5, 0.0, 0.0); // only dead zone and not clusters per length
2772  //EsdTrackCuts->AliESDtrackCuts::SetCutOutDistortedRegionsTPC(kTRUE);
2773  EsdTrackCuts->AliESDtrackCuts::SetMaxChi2PerClusterTPC(4);
2774  EsdTrackCuts->AliESDtrackCuts::SetAcceptKinkDaughters(kFALSE);
2775  EsdTrackCuts->AliESDtrackCuts::SetRequireTPCRefit(kTRUE);
2776  // ITS; selPrimaries = 1
2777  EsdTrackCuts->AliESDtrackCuts::SetRequireITSRefit(kTRUE);
2778  EsdTrackCuts->AliESDtrackCuts::SetClusterRequirementITS(AliESDtrackCuts::kSPD,
2779  AliESDtrackCuts::kAny);
2780  EsdTrackCuts->AliESDtrackCuts::SetMaxDCAToVertexXYPtDep("0.0105+0.0350/pt^1.1");
2781  EsdTrackCuts->AliESDtrackCuts::SetMaxChi2TPCConstrainedGlobal(36);
2782  EsdTrackCuts->AliESDtrackCuts::SetMaxDCAToVertexZ(2);
2783  EsdTrackCuts->AliESDtrackCuts::SetDCAToVertex2D(kFALSE);
2784  EsdTrackCuts->AliESDtrackCuts::SetRequireSigmaToVertex(kFALSE);
2785  EsdTrackCuts->AliESDtrackCuts::SetMaxChi2PerClusterITS(36);
2786  // else use 2011 version of track cuts
2787  }else{
2788  EsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011();
2789  }
2790  EsdTrackCuts->SetMaxDCAToVertexZ(2);
2791  EsdTrackCuts->SetEtaRange(-0.8, 0.8);
2792  EsdTrackCuts->SetPtRange(0.15);
2793  EsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kBoth);
2794  }
2795 
2797  for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
2798  AliESDtrack* curTrack = fESDEvent->GetTrack(iTracks);
2799  if(!curTrack) continue;
2800  if(EsdTrackCuts->AcceptTrack(curTrack) ) fNumberOfESDTrackskBoth++;
2801  }
2802  return;
2803 }
2804 
2805 //_____________________________________________________________________________
2807 
2808  // Loop over all primary MC particle
2809  for(Int_t i = 0; i < fMCEvent->GetNumberOfPrimaries(); i++) {
2810  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
2811  if (!particle) continue;
2812 
2813  Bool_t mcIsFromMB = kTRUE;
2814  Int_t isMCFromMBHeader = -1;
2815 
2816  if(((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetSignalRejection() != 0) {
2817  isMCFromMBHeader = ((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(i,fMCEvent,fInputEvent);
2818  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetSignalRejection() != 3) continue;
2819  if(isMCFromMBHeader != 2) mcIsFromMB = kFALSE;
2820  }
2821 
2822  if(((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
2823  hMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma
2824  if( IsPi0DalitzDaughter( i ) == kTRUE ){
2825  hMCAllGammaPi0Pt[fiCut]->Fill(particle->Pt());
2826  }
2827  }
2828 
2829  if(((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kTRUE)){
2830  hMCConvGammaPt[fiCut]->Fill(particle->Pt());
2831 
2832  if(fDoMesonQA > 0 ) {
2833  hMCConvGammaEta[fiCut]->Fill( particle->Eta());
2834  if(mcIsFromMB) {
2835  hMCConvGammaR[fiCut]->Fill( ((TParticle*)fMCEvent->Particle(particle->GetFirstDaughter()))->R() );
2836  hMCConvGammaPtR[fiCut]->Fill( particle->Pt(), ((TParticle*)fMCEvent->Particle(particle->GetFirstDaughter()))->R() );
2837  }
2838  }
2839 
2840  if(mcIsFromMB){
2841  hMCConvGammaRSPt[fiCut]->Fill(particle->Pt());
2842  }
2843 
2844  if( IsPi0DalitzDaughter( i ) == kTRUE ){
2845  hMCConvGammaPi0Pt[fiCut]->Fill(particle->Pt());
2846  }
2847  } // Converted MC Gamma
2848 
2849  if(((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->ElectronIsSelectedMC(i,fMCEvent)){
2850  if( particle->GetPdgCode() == -11) {
2851  hMCAllPositronsPt[fiCut]->Fill(particle->Pt()); // All positrons
2852  if(fDoMesonQA > 0 ) hMCAllPositronsEta[fiCut]->Fill( particle->Eta() );
2853  if ( particle->GetMother(0) > -1 && particle->GetMother(0) < fMCEvent->GetNumberOfPrimaries() ) {
2854  if( IsPi0DalitzDaughter( i ) == kTRUE ){
2855  hMCDecayPositronPi0Pt[fiCut]->Fill(particle->Pt()); //Positrons from Pi0->Dalitz
2856  }
2857  }
2858  }
2859  if( particle->GetPdgCode() == 11){
2860  hMCAllElectronsPt[fiCut]->Fill(particle->Pt()); // All electrons
2861  if (fDoMesonQA > 0 ) hMCAllElectronsEta[fiCut]->Fill(particle->Eta()); // All electrons
2862  if ( particle->GetMother(0) > -1 && particle->GetMother(0) < fMCEvent->GetNumberOfPrimaries() ) {
2863  if( IsPi0DalitzDaughter( i ) == kTRUE ){
2864  hMCDecayElectronPi0Pt[fiCut]->Fill(particle->Pt()); //Electrons from Pi0->Dalitz
2865  }
2866  }
2867  }
2868  }
2869 
2870  if(((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->MesonIsSelectedMC( particle,fMCEvent,((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetEtaShift() ) ){
2871  Float_t weighted= 1;
2872  if( ((AliDalitzElectronCuts*) fCutElectronArray->At(fiCut))->DoWeights() ) {
2873  if(((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2874  if (particle->Pt()>0.005){
2875  weighted= ((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetWeightForMeson(i, fMCEvent,fInputEvent);
2876  }
2877  }
2878  }
2879  if(particle->GetPdgCode() == 111)hMCPi0GGPt[fiCut]->Fill( particle->Pt() , weighted); // All MC Pi0 GG decay
2880  if(particle->GetPdgCode() == 221)hMCEtaGGPt[fiCut]->Fill( particle->Pt() , weighted); // All MC Eta GG decay
2881  }
2882 
2883  Int_t labelgamma = -1;
2884  Int_t labelelectron = -1;
2885  Int_t labelpositron = -1;
2886 
2887 
2888  if( ((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->MesonIsSelectedMCDalitz(particle,fMCEvent,labelelectron,labelpositron,labelgamma,((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetEtaShift())){
2889  Float_t weighted= 1;
2890  if( ((AliDalitzElectronCuts*) fCutElectronArray->At(fiCut))->DoWeights() ) {
2891  if(((AliConvEventCuts*)fCutEventArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent,fInputEvent)){
2892  if (particle->Pt()>0.005){
2893  weighted= ((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetWeightForMeson(i, fMCEvent,fInputEvent);
2894  }
2895  }
2896  }
2897  if(particle->GetPdgCode() == 111){
2898  hMCPi0Pt[fiCut]->Fill(particle->Pt(), weighted); // All MC Pi0
2899  hMCPi0WOWeightPt[fiCut]->Fill(particle->Pt());
2900  }
2901 
2902  if(particle->GetPdgCode() == 221)hMCEtaPt[fiCut]->Fill(particle->Pt(), weighted); // All MC Eta
2903  // Check the acceptance for gamma and electrons
2904  TParticle *gamma = fMCEvent->Particle(labelgamma);
2905  TParticle *electron = fMCEvent->Particle(labelelectron);
2906  TParticle *positron = fMCEvent->Particle(labelpositron);
2907 
2908  if(((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->PhotonIsSelectedMC(gamma,fMCEvent,kFALSE) &&
2909  ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->ElectronIsSelectedMC(labelelectron,fMCEvent) &&
2910  ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->ElectronIsSelectedMC(labelpositron,fMCEvent) ) {
2911 
2912  Double_t massDalitz = -1;
2913  Double_t angleGammaEpos = -1;
2914  Double_t angleGammaEneg = -1;
2915  Double_t massGammaEpos = -1;
2916  Double_t massGammaEneg = -1;
2917 
2918  if( fDoMesonQA > 0 ){
2919  TLorentzVector TLVEpos,TLVEneg,TLVgamma,TLVDalitz,TLVGammaEpos,TLVGammaEneg;
2920  Double_t electronMass = TDatabasePDG::Instance()->GetParticle( ::kElectron )->Mass();
2921  TLVEpos.SetXYZM(positron->Px(),positron->Py(),positron->Pz(),electronMass);
2922  TLVEneg.SetXYZM(electron->Px(),electron->Py(),electron->Pz(),electronMass);
2923  TLVgamma.SetXYZM(gamma->Px(),gamma->Py(),gamma->Pz(),0);
2924 
2925  TVector3 V3gamma(gamma->Px(),gamma->Py(),gamma->Pz());
2926  angleGammaEpos = V3gamma.Angle(TLVEpos.Vect());
2927  angleGammaEneg = V3gamma.Angle(TLVEneg.Vect());
2928 
2929  TLVDalitz = TLVEpos + TLVEneg ;
2930  massDalitz = TLVDalitz.M();
2931  TLVGammaEpos = TLVEpos + TLVgamma;
2932  TLVGammaEneg = TLVEneg + TLVgamma;
2933 
2934  massGammaEpos = TLVGammaEpos.M();
2935  massGammaEneg = TLVGammaEneg.M();
2936  }
2937 
2938  if(particle->GetPdgCode() == 111){
2939 
2940  hMCPi0InAccPt[fiCut]->Fill(particle->Pt() , weighted); // MC Pi0Dalitz with gamma and e+e- in acc
2941  hMCPi0WOWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 with gamma in acc NOT weighted
2942  hMCPi0DalitzGammaPt[fiCut]->Fill( gamma->Pt() );
2943  hMCPi0DalitzPositronPt[fiCut]->Fill( positron->Pt() );
2944  hMCPi0DalitzElectronPt[fiCut]->Fill( electron->Pt() );
2945 
2946  if ( fDoMesonQA > 0 ){
2947  hMCPi0EposEnegInvMassPt[fiCut]->Fill(massDalitz,particle->Pt());
2948  hMCPi0InAccOpeningAngleGammaElectron[fiCut]->Fill(angleGammaEpos);
2949  hMCPi0InAccOpeningAngleGammaElectron[fiCut]->Fill(angleGammaEneg);
2950 
2951  if ( fDoMesonQA > 1 ) {
2952  Double_t sMCDalitzPlot[2] = {massGammaEneg*massGammaEneg,massGammaEpos*massGammaEpos};
2953  sMCPi0DalitzPlot[fiCut]->Fill(sMCDalitzPlot);
2954  }
2955  }
2956  }
2957  if(particle->GetPdgCode() == 221){
2958  hMCEtaInAccPt[fiCut]->Fill(particle->Pt(), weighted ); // MC EtaDalitz with gamma and e+e- in acc
2959  if( fDoMesonQA > 0 ) hMCEtaEposEnegInvMassPt[fiCut]->Fill( massDalitz, particle->Pt());
2960  }
2961  }
2962  }
2963 
2964  Int_t labelgammaChiC=-1;
2965  Int_t labelpositronChiC=-1;
2966  Int_t labelelectronChiC=-1;
2967 
2968  if(((AliConversionMesonCuts*)fCutMesonArray->At(fiCut))->MesonIsSelectedMCChiC(particle,fMCEvent,labelelectronChiC,labelpositronChiC,labelgammaChiC,((AliConvEventCuts*)fCutEventArray->At(fiCut))->GetEtaShift())){
2969 
2970  hMCChiCPt[fiCut]->Fill(particle->Pt()); // All MC ChiC
2971  TParticle * gammaChiC =fMCEvent->Particle(labelgammaChiC);
2972  if( ((AliConversionPhotonCuts*)fCutGammaArray->At(fiCut))->PhotonIsSelectedMC( gammaChiC,fMCEvent,kFALSE) &&
2973  ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->ElectronIsSelectedMC(labelelectronChiC,fMCEvent) &&
2974  ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->ElectronIsSelectedMC(labelpositronChiC,fMCEvent) ){
2975  hMCChiCInAccPt[fiCut]->Fill(particle->Pt()); // All MC ChiC
2976  }
2977  }
2978  }
2979 }
2980 
2981 //_____________________________________________________________________________
2983 
2984  if( fMCMother->GetNDaughters() != 3 ) return kFALSE;
2985  if( fMCMother->GetPdgCode() != 111 && fMCMother->GetPdgCode() != 221 ) return kFALSE;
2986 
2987  TParticle *positron = 0x0;
2988  TParticle *electron = 0x0;
2989  TParticle *gamma = 0x0;
2990 
2991  for(Int_t index= fMCMother->GetFirstDaughter();index<= fMCMother->GetLastDaughter();index++){
2992  TParticle* temp = (TParticle*)fMCEvent->Particle( index );
2993  switch( temp->GetPdgCode() ) {
2994  case ::kPositron:
2995  positron = temp;
2996  break;
2997  case ::kElectron:
2998  electron = temp;
2999  break;
3000  case ::kGamma:
3001  gamma = temp;
3002  break;
3003  }
3004  }
3005 
3006  if( positron && electron && gamma) return kTRUE;
3007  return kFALSE;
3008 }
3009 
3010 //_____________________________________________________________________________________
3012 //
3013 // Returns true if the particle comes from Pi0 -> e+ e- gamma
3014 //
3015  Int_t motherLabel = fMCEvent->Particle( label )->GetMother(0);
3016  if( motherLabel < 0 || motherLabel >= fMCEvent->GetNumberOfTracks() ) return kFALSE;
3017  TParticle* mother = fMCEvent->Particle( motherLabel );
3018  if( mother->GetPdgCode() != 111 ) return kFALSE;
3019  if( IsDalitz( mother ) ) return kTRUE;
3020  return kFALSE;
3021 }
3022 
3024 
3025  AliESDtrack *positronVgamma = 0;
3026  AliESDtrack *electronVgamma = 0;
3027 
3028  Double_t clsToFPos = -1.0;
3029  Double_t clsToFNeg = -1.0;
3030 
3031  Double_t NumClsITSPos = -1.0;
3032  Double_t NumClsITSNeg = -1.0;
3033  Double_t NumClsTPCPos = -1.0;
3034  Double_t NumClsTPCNeg = -1.0;
3035  Double_t nCrossedRowsTPCPos = -1.0;
3036  Double_t nCrossedRowsTPCNeg = -1.0;
3037 
3038  Float_t dcaToVertexXYPos = -1.0;
3039  Float_t dcaToVertexZPos = -1.0;
3040  Float_t dcaToVertexXYNeg = -1.0;
3041  Float_t dcaToVertexZNeg = -1.0;
3042 
3043  Double_t nSigmaPosTPC = -999.;
3044  Double_t nSigmaNegTPC = -999.;
3045 
3046  positronVgamma = fESDEvent->GetTrack( Vgamma->GetTrackLabelPositive() );
3047  electronVgamma = fESDEvent->GetTrack( Vgamma->GetTrackLabelNegative() );
3048  clsToFPos = ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->GetNFindableClustersTPC(positronVgamma);
3049  clsToFNeg = ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->GetNFindableClustersTPC(electronVgamma);
3050 
3051  nSigmaPosTPC = ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->GetPIDResponse()->NumberOfSigmasTPC(positronVgamma, AliPID::kElectron) ;
3052  nSigmaNegTPC = ((AliDalitzElectronCuts*)fCutElectronArray->At(fiCut))->GetPIDResponse()->NumberOfSigmasTPC(electronVgamma, AliPID::kElectron) ;
3053 
3054  NumClsITSPos = positronVgamma->GetNcls(0); //Get number of ITS clusters
3055  NumClsITSNeg = electronVgamma->GetNcls(0);
3056  NumClsTPCPos = positronVgamma->GetNcls(1); //Get number of TPC clusters
3057  NumClsTPCNeg = electronVgamma->GetNcls(1);
3058 
3059  nCrossedRowsTPCPos = positronVgamma->GetTPCCrossedRows();
3060  nCrossedRowsTPCNeg = electronVgamma->GetTPCCrossedRows();
3061 
3062  Float_t bPos[2];
3063  Float_t bCovPos[3];
3064  positronVgamma->GetImpactParameters(bPos,bCovPos);
3065 
3066  if (bCovPos[0]<=0 || bCovPos[2]<=0) {
3067  AliDebug(1, "Estimated b resolution lower or equal zero!");
3068  bCovPos[0]=0; bCovPos[2]=0;
3069  }
3070 
3071  Float_t bNeg[2];
3072  Float_t bCovNeg[3];
3073  positronVgamma->GetImpactParameters(bNeg,bCovNeg);
3074 
3075  if (bCovNeg[0]<=0 || bCovNeg[2]<=0) {
3076  AliDebug(1, "Estimated b resolution lower or equal zero!");
3077  bCovNeg[0]=0; bCovNeg[2]=0;
3078  }
3079 
3080  dcaToVertexXYPos = bPos[0];
3081  dcaToVertexZPos = bPos[1];
3082  dcaToVertexXYNeg = bNeg[0];
3083  dcaToVertexZNeg = bNeg[1];
3084 
3085  if( electronVgamma->P() > 0.3 && electronVgamma->P() < 0.45 ){
3086  hESDDalitzElectronAfterEtaPCut[fiCut]->Fill( electronVgamma->Eta() );
3087  hESDDalitzElectronAfterNClsITSPCut[fiCut]->Fill( NumClsITSNeg );
3089  hESDDalitzElectronAfterNClsTPCPCut[fiCut]->Fill( NumClsTPCNeg );
3090  hESDDalitzElectronAfterNCrossedRowsTPCPCut[fiCut]->Fill( nCrossedRowsTPCNeg );
3091  }
3092  if( positronVgamma->P() > 0.3 && positronVgamma->P() < 0.45 ){
3093  hESDDalitzPositronAfterEtaPCut[fiCut]->Fill( positronVgamma->Eta() );
3094  hESDDalitzPositronAfterNClsITSPCut[fiCut]->Fill( NumClsITSPos );
3096  hESDDalitzPositronAfterNClsTPCPCut[fiCut]->Fill( NumClsTPCPos );
3097  hESDDalitzPositronAfterNCrossedRowsTPCPCut[fiCut]->Fill( nCrossedRowsTPCPos );
3098  }
3099 
3100  hESDDalitzElectronAfterPt[fiCut]->Fill( electronVgamma->Pt() );
3101  hESDDalitzPositronAfterPt[fiCut]->Fill( positronVgamma->Pt() );
3102 
3103  hESDDalitzElectronAfterEta[fiCut]->Fill( electronVgamma->Eta() );
3104  hESDDalitzPositronAfterEta[fiCut]->Fill( positronVgamma->Eta() );
3105 
3106  hESDDalitzElectronAfterPhi[fiCut]->Fill( electronVgamma->Phi() );
3107  hESDDalitzPositronAfterPhi[fiCut]->Fill( positronVgamma->Phi() );
3108 
3109  hESDDalitzElectronAfterNFindClsTPC[fiCut]->Fill(clsToFNeg,electronVgamma->Pt());
3110  hESDDalitzPositronAfterNFindClsTPC[fiCut]->Fill(clsToFPos,positronVgamma->Pt());
3111 
3112  hESDDalitzElectronAfterNClsTPC[fiCut]->Fill( NumClsTPCNeg,electronVgamma->Pt());
3113  hESDDalitzPositronAfterNClsTPC[fiCut]->Fill( NumClsTPCPos,positronVgamma->Pt());
3114 
3115  hESDDalitzElectronAfterNCrossedRowsTPC[fiCut]->Fill( nCrossedRowsTPCNeg, electronVgamma->Pt() );
3116  hESDDalitzPositronAfterNCrossedRowsTPC[fiCut]->Fill( nCrossedRowsTPCPos, positronVgamma->Pt() );
3117 
3118  hESDDalitzElectronAfterNClsITS[fiCut]->Fill( NumClsITSNeg);
3119  hESDDalitzPositronAfterNClsITS[fiCut]->Fill( NumClsITSPos);
3120 
3121  hESDDalitzPosEleAfterDCAxy[fiCut]->Fill( dcaToVertexXYNeg, electronVgamma->Pt() );
3122  hESDDalitzPosEleAfterDCAz[fiCut]->Fill( dcaToVertexZNeg, electronVgamma->Pt() );
3123  hESDDalitzPosEleAfterDCAxy[fiCut]->Fill( dcaToVertexXYPos, positronVgamma->Pt() );
3124  hESDDalitzPosEleAfterDCAz[fiCut]->Fill( dcaToVertexZPos, positronVgamma->Pt() );
3125 
3126  hESDDalitzElectronAfterTPCdEdxVsP[fiCut]->Fill( electronVgamma->P(),nSigmaNegTPC);
3127  hESDDalitzPositronAfterTPCdEdxVsP[fiCut]->Fill( positronVgamma->P(), nSigmaPosTPC);
3128 
3129  hESDDalitzElectronAfterTPCdEdxVsEta[fiCut]->Fill( electronVgamma->Eta(),nSigmaNegTPC);
3130  hESDDalitzPositronAfterTPCdEdxVsEta[fiCut]->Fill( positronVgamma->Eta(),nSigmaPosTPC);
3131 
3132  hESDDalitzElectronAfterTPCdEdxVsPhi[fiCut]->Fill( electronVgamma->Phi(),nSigmaNegTPC);
3133  hESDDalitzPositronAfterTPCdEdxVsPhi[fiCut]->Fill( positronVgamma->Phi(),nSigmaPosTPC);
3134 
3135  hESDDalitzElectronAfterTPCdEdxSignalVsP[fiCut]->Fill( electronVgamma->P(), TMath::Abs(electronVgamma->GetTPCsignal()));
3136  hESDDalitzPositronAfterTPCdEdxSignalVsP[fiCut]->Fill( positronVgamma->P(), TMath::Abs(positronVgamma->GetTPCsignal()));
3137 
3138 }
3139 
3140 //_____________________________________________________________________________
3141 Double_t AliAnalysisTaskGammaConvDalitzV1::GetPsiPairMC(const TParticle *fMCPosParticle, const TParticle *fMCNegParticle) const {
3142 
3143  TVector3 posDaughter;
3144  TVector3 negDaughter;
3145 
3146  posDaughter.SetXYZ( fMCPosParticle->Px(), fMCPosParticle->Py(), fMCPosParticle->Pz() );
3147  negDaughter.SetXYZ( fMCNegParticle->Px(), fMCNegParticle->Py(), fMCNegParticle->Pz() );
3148  Double_t deltaTheta = negDaughter.Theta() - posDaughter.Theta();
3149  Double_t openingAngle = posDaughter.Angle( negDaughter ); //TMath::ACos( posDaughter.Dot(negDaughter)/(negDaughter.Mag()*posDaughter.Mag()) );
3150  if( openingAngle < 1e-20 ) return 0.;
3151  Double_t psiAngle = TMath::ASin( deltaTheta/openingAngle );
3152  return psiAngle;
3153 }
3154 
3155 
3156 
3157 //_____________________________________________________________________________
3158 Double_t AliAnalysisTaskGammaConvDalitzV1::GetPsiPair( const AliESDtrack *trackPos, const AliESDtrack *trackNeg ) const {
3159  //
3160  // This angle is a measure for the contribution of the opening in polar
3161  // direction ?0 to the opening angle ? Pair
3162  //
3163  // Ref. Measurement of photons via conversion pairs with the PHENIX experiment at RHIC
3164  // Mas ter Thesis. Thorsten Dahms. 2005
3165  // https://twiki.cern.ch/twiki/pub/ALICE/GammaPhysicsPublications/tdahms_thesis.pdf
3166  //
3167  Double_t momPos[3];
3168  Double_t momNeg[3];
3169  if( trackPos->GetConstrainedPxPyPz(momPos) == 0 ) trackPos->GetPxPyPz( momPos );
3170  if( trackNeg->GetConstrainedPxPyPz(momNeg) == 0 ) trackNeg->GetPxPyPz( momNeg );
3171 
3172  TVector3 posDaughter;
3173  TVector3 negDaughter;
3174 
3175  posDaughter.SetXYZ( momPos[0], momPos[1], momPos[2] );
3176  negDaughter.SetXYZ( momNeg[0], momNeg[1], momNeg[2] );
3177 
3178  Double_t deltaTheta = negDaughter.Theta() - posDaughter.Theta();
3179  Double_t openingAngle = posDaughter.Angle( negDaughter ); //TMath::ACos( posDaughter.Dot(negDaughter)/(negDaughter.Mag()*posDaughter.Mag()) );
3180 
3181  if( openingAngle < 1e-20 ) return 0.;
3182 
3183  Double_t psiAngle = TMath::ASin( deltaTheta/openingAngle );
3184 
3185  return psiAngle;
3186 }
3187 
3188 //________________________________________________________________________
3190  TAxis *axisafter = histoRebin->GetXaxis();
3191  Int_t bins = axisafter->GetNbins();
3192  Double_t from = axisafter->GetXmin();
3193  Double_t to = axisafter->GetXmax();
3194  Double_t *newbins = new Double_t[bins+1];
3195  newbins[0] = from;
3196  Double_t factor = TMath::Power(to/from, 1./bins);
3197  for(Int_t i=1; i<=bins; ++i) newbins[i] = factor * newbins[i-1];
3198  axisafter->Set(bins, newbins);
3199  delete [] newbins;
3200 }
3201 
3202 
3203 //_________________________________________________________________________________
3205  if(tobechecked > -1){
3206  vector<Int_t>::iterator it;
3207  it = find (vec.begin(), vec.end(), tobechecked);
3208  if (it != vec.end()) return true;
3209  else{
3210  vec.push_back(tobechecked);
3211  return false;
3212  }
3213  }
3214  return false;
3215 }
TParticle * GetMCParticle(AliMCEvent *mcEvent)
virtual Double_t GetPy() const
void ProcessTruePhotonCandidates(AliAODConversionPhoton *)
vector< Int_t > fVectorDoubleCountTruePi0s
array of histos with double counted photons, R, pT
void SetLabels(Int_t label1, Int_t label2, Int_t label3=0)
double Double_t
Definition: External.C:58
GammaConversionVertex * GetBGEventVertex(Int_t zbin, Int_t mbin, Int_t event)
Definition: External.C:236
Double_t GetPsiPair(const AliESDtrack *trackPos, const AliESDtrack *trackNeg) const
void SetConversionPoint(Double_t convpoint[3])
vector< Int_t > GetReconstructedPositronsIndex()
virtual Double_t GetPz() const
void SetMCLabelNegative(Int_t label)
void MoveParticleAccordingToVertex(AliAODConversionPhoton *particle, const AliGammaConversionAODBGHandler::GammaConversionVertex *vertex)
Int_t GetNumberOfPrimaryTracks()
TH2F ** fHistoDoubleCountTrueEtaInvMassPt
array of histos with double counted pi0s, invMass, pT
void RotateParticleAccordingToEP(AliAODConversionPhoton *gamma, Double_t previousEventEP, Double_t thisEventEP)
TString GetPeriodName()
TParticle * GetPositiveMCDaughter(AliMCEvent *mcEvent)
void FillElectronQAHistos(AliAODConversionPhoton *Vgamma) const
Bool_t GetProduceV0FindingEfficiency()
TParticle * GetNegativeMCDaughter(AliMCEvent *mcEvent)
std::vector< AliAODConversionPhoton * > AliGammaConversionAODVector
vector< Int_t > fVectorDoubleCountTrueEtas
vector containing labels of validated pi0
int Int_t
Definition: External.C:63
Definition: External.C:204
unsigned int UInt_t
Definition: External.C:33
vector< Int_t > GetReconstructedElectronsIndex()
float Float_t
Definition: External.C:68
void SetMCLabelPositive(Int_t label)
void AddEvent(TList *const eventGammas, Double_t xvalue, Double_t yvalue, Double_t zvalue, Int_t multiplicity, Double_t epvalue=-100)
TH2F ** fHistoDoubleCountTrueConvGammaRPt
array of histos with double counted etas, invMass, pT
TH1I ** hNV0Tracks
array of histos with SPD tracklets vs SPD clusters for background rejection
AliConversionPhotonCuts * GetConversionCuts()
Definition: AliV0ReaderV1.h:89
vector< Int_t > fVectorDoubleCountTrueConvGammas
vector containing labels of validated eta
Class handling all kinds of selection cuts for Gamma Conversion analysis.
Int_t GetMCParticleLabel(AliMCEvent *mcEvent)
Double_t GetOpeningAngle() const
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
AliDalitzElectronCuts * GetDalitzElectronCuts()
Double_t centMax
void SetTrackLabels(Int_t label1, Int_t label2)
AliGammaConversionAODVector * GetBGGoodV0s(Int_t zbin, Int_t mbin, Int_t event)
virtual Double_t GetPx() const
Definition: External.C:220
Class handling all kinds of selection cuts for Gamma Conversion analysis.
TClonesArray * GetReconstructedGammas() const
Definition: AliV0ReaderV1.h:85
Class handling all kinds of selection cuts for Gamma Conversion analysis.
Bool_t IsDalitz(TParticle *fMCMother) const
AliConvEventCuts * GetEventCuts()
Definition: AliV0ReaderV1.h:90
const char Option_t
Definition: External.C:48
void ProcessTrueChicCandidates(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate, AliAODConversionPhoton *TruejpsiCandidate)
bool Bool_t
Definition: External.C:53
Bool_t CheckVectorForDoubleCount(vector< Int_t > &vec, Int_t tobechecked)
void ProcessTrueMesonCandidates(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate, AliAODConversionPhoton *TrueVirtualGammaCandidate)
Double_t GetPsiPairMC(const TParticle *fMCPosParticle, const TParticle *fMCNegParticle) const
void CalculateDistanceOfClossetApproachToPrimVtx(const AliVVertex *primVertex)
AliGammaConversionAODBGHandler ** fBGHandler
Double_t GetConversionRadius() const
TList * GetV0FindingEfficiencyHistograms()
Double_t centMin