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