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