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