AliPhysics  2c6b7ad (2c6b7ad)
AliAnalysisTaskGammaConvV1.cxx
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: Martin Wilde, Daniel Lohner, Friederike Bock *
5 * Version 1.0 *
6 * *
7 * based on: on older version (see aliroot up to v5-04-42-AN) *
8 * AliAnalysisTaskGammaConversion.cxx *
9 * Authors: Kathrin Koch, Kenneth Aamodt, Ana Marin *
10 * *
11 * Permission to use, copy, modify and distribute this software and its *
12 * documentation strictly for non-commercial purposes is hereby granted *
13 * without fee, provided that the above copyright notice appears in all *
14 * copies and that both the copyright notice and this permission notice *
15 * appear in the supporting documentation. The authors make no claims *
16 * about the suitability of this software for any purpose. It is *
17 * provided "as is" without express or implied warranty. *
18 **************************************************************************/
19 
21 //---------------------------------------------
22 
23 // Class used to do analysis on conversion pairs
24 //---------------------------------------------
26 #include "TChain.h"
27 #include "TTree.h"
28 #include "TBranch.h"
29 #include "TFile.h"
30 #include "TH1F.h"
31 #include "TH2F.h"
32 #include "TH3F.h"
33 #include "THnSparse.h"
34 #include "TCanvas.h"
35 #include "TNtuple.h"
36 #include "AliAnalysisTask.h"
37 #include "AliAnalysisManager.h"
38 #include "AliESDEvent.h"
39 #include "AliESDInputHandler.h"
40 #include "AliMCEventHandler.h"
41 #include "AliMCEvent.h"
42 #include "AliMCParticle.h"
43 #include "AliCentrality.h"
44 #include "AliESDVZERO.h"
45 #include "AliESDpid.h"
47 #include "AliVParticle.h"
48 #include "AliESDtrack.h"
49 #include "AliESDtrackCuts.h"
50 #include "AliKFVertex.h"
51 #include "AliGenCocktailEventHeader.h"
53 #include "AliAODMCParticle.h"
54 #include "AliAODMCHeader.h"
55 #include "AliEventplane.h"
56 #include "AliAODEvent.h"
57 #include <vector>
58 #include <map>
59 
60 
62 
63 //________________________________________________________________________
65  fV0Reader(NULL),
66  fV0ReaderName("V0ReaderV1"),
67  fDoLightOutput(kFALSE),
68  fBGHandler(NULL),
69  fBGHandlerRP(NULL),
70  fInputEvent(NULL),
71  fMCEvent(NULL),
72  fCutFolder(NULL),
73  fESDList(NULL),
74  fBackList(NULL),
75  fMotherList(NULL),
76  fTrueList(NULL),
77  fMCList(NULL),
78  fHeaderNameList(NULL),
79  fOutputContainer(0),
80  fReaderGammas(NULL),
81  fGammaCandidates(NULL),
82  fEventCutArray(NULL),
83  fCutArray(NULL),
84  fMesonCutArray(NULL),
85  fClusterCutArray(NULL),
86  fHistoCaloGammaPt(NULL),
87  fHistoCaloGammaE(NULL),
88  fHistoConvGammaPt(NULL),
89  fHistoConvGammaR(NULL),
90  fHistoConvGammaEta(NULL),
91  fHistoConvGammaPhi(NULL),
92  fHistoConvGammaPsiPairPt(NULL),
93  fHistoConvGammaInvMass(NULL),
94  fHistoConvGammaInvMassReco(NULL),
95  tESDConvGammaPtDcazCat(NULL),
96  fPtGamma(0),
97  fDCAzPhoton(0),
98  fRConvPhoton(0),
99  fEtaPhoton(0),
100  iCatPhoton(0),
101  iPhotonMCInfo(0),
102  fHistoMotherInvMassPt(NULL),
103  sESDMotherInvMassPtZM(NULL),
104  fHistoMotherBackInvMassPt(NULL),
105  sESDMotherBackInvMassPtZM(NULL),
106  fHistoMotherInvMassEalpha(NULL),
107  fHistoMotherPi0PtY(NULL),
108  fHistoMotherEtaPtY(NULL),
109  fHistoMotherPi0PtAlpha(NULL),
110  fHistoMotherEtaPtAlpha(NULL),
111  fHistoMotherPi0PtOpenAngle(NULL),
112  fHistoMotherEtaPtOpenAngle(NULL),
113  sPtRDeltaROpenAngle(NULL),
114  fHistoMCHeaders(NULL),
115  fHistoMCAllGammaPt(NULL),
116  fHistoMCAllSecondaryGammaPt(NULL),
117  fHistoMCDecayGammaPi0Pt(NULL),
118  fHistoMCDecayGammaRhoPt(NULL),
119  fHistoMCDecayGammaEtaPt(NULL),
120  fHistoMCDecayGammaOmegaPt(NULL),
121  fHistoMCDecayGammaEtapPt(NULL),
122  fHistoMCDecayGammaPhiPt(NULL),
123  fHistoMCDecayGammaSigmaPt(NULL),
124  fHistoMCConvGammaPt(NULL),
125  fHistoMCSecondaryConvGammaPt(NULL),
126  fHistoMCConvGammaR(NULL),
127  fHistoMCConvGammaEta(NULL),
128  fHistoMCPi0Pt(NULL),
129  fHistoMCPi0WOWeightPt(NULL),
130  fHistoMCPi0WOEvtWeightPt(NULL),
131  fHistoMCEtaWOEvtWeightPt(NULL),
132  fHistoMCEtaPt(NULL),
133  fHistoMCEtaWOWeightPt(NULL),
134  fHistoMCPi0WOWeightInAccPt(NULL),
135  fHistoMCEtaWOWeightInAccPt(NULL),
136  fHistoMCPi0InAccPt(NULL),
137  fHistoMCEtaInAccPt(NULL),
138  fHistoMCPi0WOEvtWeightInAccPt(NULL),
139  fHistoMCEtaWOEvtWeightInAccPt(NULL),
140  fHistoMCPi0PtY(NULL),
141  fHistoMCEtaPtY(NULL),
142  fHistoMCPi0PtAlpha(NULL),
143  fHistoMCEtaPtAlpha(NULL),
144  fHistoMCPrimaryPtvsSource(NULL),
145  fHistoMCSecPi0PtvsSource(NULL),
146  fHistoMCSecPi0RvsSource(NULL),
147  fHistoMCSecPi0Source(NULL),
148  fHistoMCSecPi0InAccPtvsSource(NULL),
149  fHistoMCSecEtaPt(NULL),
150  fHistoMCSecEtaSource(NULL),
151  fHistoMCPi0PtJetPt(NULL),
152  fHistoMCEtaPtJetPt(NULL),
153  fHistoMCPhysicalPrimariesPt(NULL),
154  fHistoTrueMotherInvMassPt(NULL),
155  fHistoTruePrimaryMotherInvMassPt(NULL),
156  fHistoTruePrimaryMotherW0WeightingInvMassPt(NULL),
157  pESDTruePrimaryMotherWeightsInvMassPt(NULL),
158  fHistoTruePrimaryPi0MCPtResolPt(NULL),
159  fHistoTruePrimaryEtaMCPtResolPt(NULL),
160  fHistoTrueSecondaryMotherInvMassPt(NULL),
161  fHistoTrueSecondaryMotherFromK0sInvMassPt(NULL),
162  fHistoTrueK0sWithPi0DaughterMCPt(NULL),
163  fHistoTrueSecondaryMotherFromK0lInvMassPt(NULL),
164  fHistoTrueK0lWithPi0DaughterMCPt(NULL),
165  fHistoTrueSecondaryMotherFromEtaInvMassPt(NULL),
166  fHistoTrueEtaWithPi0DaughterMCPt(NULL),
167  fHistoTrueSecondaryMotherFromLambdaInvMassPt(NULL),
168  fHistoTrueLambdaWithPi0DaughterMCPt(NULL),
169  fHistoTrueBckGGInvMassPt(NULL),
170  fHistoTrueBckContInvMassPt(NULL),
171  fHistoTruePi0PtY(NULL),
172  fHistoTrueEtaPtY(NULL),
173  fHistoTruePi0PtAlpha(NULL),
174  fHistoTrueEtaPtAlpha(NULL),
175  fHistoTruePi0PtOpenAngle(NULL),
176  fHistoTrueEtaPtOpenAngle(NULL),
177  fHistoTrueMotherDalitzInvMassPt(NULL),
178  fHistoTrueConvGammaPt(NULL),
179  fHistoTrueConvGammaR(NULL),
180  fHistoTrueConvGammaPtMC(NULL),
181  fHistoTrueConvGammaRMC(NULL),
182  fHistoTrueConvGammaEta(NULL),
183  fHistoTrueConvGammaPsiPairPt(NULL),
184  fHistoTrueConvGammaInvMass(NULL),
185  fHistoTrueConvGammaInvMassReco(NULL),
186  fHistoCombinatorialPt(NULL),
187  fHistoCombinatorialMothersPt(NULL),
188  fHistoCombinatorialPtDeltaPhi_ek(NULL),
189  fHistoCombinatorialPtDeltaPhi_ep(NULL),
190  fHistoCombinatorialPtDeltaPhi_epi(NULL),
191  fHistoCombinatorialPtDeltaPhi_pik(NULL),
192  fHistoCombinatorialPtDeltaPhi_pip(NULL),
193  fHistoTruePrimaryConvGammaPt(NULL),
194  fHistoTrueSecondaryConvGammaPt(NULL),
195  fHistoTrueSecondaryConvGammaMCPt(NULL),
196  fHistoTruePrimaryConvGammaESDPtMCPt(NULL),
197  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt(NULL),
198  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt(NULL),
199  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt(NULL),
200  fHistoTrueDalitzPsiPairDeltaPhi(NULL),
201  fHistoTrueGammaPsiPairDeltaPhi(NULL),
202  fHistoDoubleCountTruePi0InvMassPt(NULL),
203  fHistoDoubleCountTrueEtaInvMassPt(NULL),
204  fHistoDoubleCountTrueConvGammaRPt(NULL),
205  vecDoubleCountTruePi0s(0),
206  vecDoubleCountTrueEtas(0),
207  vecDoubleCountTrueConvGammas(0),
208  fHistoMultipleCountTruePi0(NULL),
209  fHistoMultipleCountTrueEta(NULL),
210  fHistoMultipleCountTrueConvGamma(NULL),
211  mapMultipleCountTruePi0s(),
212  mapMultipleCountTrueEtas(),
213  mapMultipleCountTrueConvGammas(),
214  fHistoNEvents(NULL),
215  fHistoNEventsWOWeight(NULL),
216  fHistoNGoodESDTracks(NULL),
217  fHistoNEventsWeighted(NULL),
218  fHistoNGoodESDTracksWeighted(NULL),
219  fHistoVertexZ(NULL),
220  fHistoVertexZWeighted(NULL),
221  fDoCentralityFlat(0),
222  fHistoCentrality(NULL),
223  fHistoCentralityFlattened(NULL),
224  fHistoCentralityVsPrimaryTracks(NULL),
225  fHistoNGammaCandidates(NULL),
226  fHistoNGoodESDTracksVsNGammaCandidates(NULL),
227  fHistoSPDClusterTrackletBackground(NULL),
228  fHistoV0MultVsNumberTPCoutTracks(NULL),
229  fHistoNV0Tracks(NULL),
230  fProfileEtaShift(NULL),
231  fProfileJetJetXSection(NULL),
232  fhJetJetNTrials(NULL),
233  fHistoEtaShift(NULL),
234  tESDMesonsInvMassPtDcazMinDcazMaxFlag(NULL),
235  fInvMass(0),
236  fPt(0),
237  fDCAzGammaMin(0),
238  fDCAzGammaMax(0),
239  iFlag(0),
240  iMesonMCInfo(0),
241  fEventPlaneAngle(-100),
242  fRandom(0),
243  fnGammaCandidates(0),
244  fUnsmearedPx(NULL),
245  fUnsmearedPy(NULL),
246  fUnsmearedPz(NULL),
247  fUnsmearedE(NULL),
248  fMCEventPos(NULL),
249  fMCEventNeg(NULL),
250  fESDArrayPos(NULL),
251  fESDArrayNeg(NULL),
252  fnCuts(0),
253  fiCut(0),
254  fMoveParticleAccordingToVertex(kTRUE),
255  fIsHeavyIon(0),
256  fDoMesonAnalysis(kTRUE),
257  fDoMesonQA(0),
258  fDoPhotonQA(0),
259  fDoChargedPrimary(kFALSE),
260  fDoPlotVsCentrality(kFALSE),
261  fIsFromSelectedHeader(kTRUE),
262  fIsMC(0),
263  fDoTHnSparse(kTRUE),
264  fWeightJetJetMC(1),
265  fWeightCentrality(NULL),
266  fEnableClusterCutsForTrigger(kFALSE),
267  fDoMaterialBudgetWeightingOfGammasForTrueMesons(kFALSE),
268  tBrokenFiles(NULL),
269  fFileNameBroken(NULL)
270 {
271 
272 }
273 
274 //________________________________________________________________________
276  AliAnalysisTaskSE(name),
277  fV0Reader(NULL),
278  fV0ReaderName("V0ReaderV1"),
279  fDoLightOutput(kFALSE),
280  fBGHandler(NULL),
281  fBGHandlerRP(NULL),
282  fInputEvent(NULL),
283  fMCEvent(NULL),
284  fCutFolder(NULL),
285  fESDList(NULL),
286  fBackList(NULL),
287  fMotherList(NULL),
288  fTrueList(NULL),
289  fMCList(NULL),
290  fHeaderNameList(NULL),
291  fOutputContainer(0),
292  fReaderGammas(NULL),
293  fGammaCandidates(NULL),
294  fEventCutArray(NULL),
295  fCutArray(NULL),
296  fMesonCutArray(NULL),
297  fClusterCutArray(NULL),
298  fHistoCaloGammaPt(NULL),
299  fHistoCaloGammaE(NULL),
300  fHistoConvGammaPt(NULL),
301  fHistoConvGammaR(NULL),
302  fHistoConvGammaEta(NULL),
303  fHistoConvGammaPhi(NULL),
304  fHistoConvGammaPsiPairPt(NULL),
305  fHistoConvGammaInvMass(NULL),
306  fHistoConvGammaInvMassReco(NULL),
307  tESDConvGammaPtDcazCat(NULL),
308  fPtGamma(0),
309  fDCAzPhoton(0),
310  fRConvPhoton(0),
311  fEtaPhoton(0),
312  iCatPhoton(0),
313  iPhotonMCInfo(0),
314  fHistoMotherInvMassPt(NULL),
315  sESDMotherInvMassPtZM(NULL),
316  fHistoMotherBackInvMassPt(NULL),
317  sESDMotherBackInvMassPtZM(NULL),
318  fHistoMotherInvMassEalpha(NULL),
319  fHistoMotherPi0PtY(NULL),
320  fHistoMotherEtaPtY(NULL),
321  fHistoMotherPi0PtAlpha(NULL),
322  fHistoMotherEtaPtAlpha(NULL),
323  fHistoMotherPi0PtOpenAngle(NULL),
324  fHistoMotherEtaPtOpenAngle(NULL),
325  sPtRDeltaROpenAngle(NULL),
326  fHistoMCHeaders(NULL),
327  fHistoMCAllGammaPt(NULL),
328  fHistoMCAllSecondaryGammaPt(NULL),
329  fHistoMCDecayGammaPi0Pt(NULL),
330  fHistoMCDecayGammaRhoPt(NULL),
331  fHistoMCDecayGammaEtaPt(NULL),
332  fHistoMCDecayGammaOmegaPt(NULL),
333  fHistoMCDecayGammaEtapPt(NULL),
334  fHistoMCDecayGammaPhiPt(NULL),
335  fHistoMCDecayGammaSigmaPt(NULL),
336  fHistoMCConvGammaPt(NULL),
337  fHistoMCSecondaryConvGammaPt(NULL),
338  fHistoMCConvGammaR(NULL),
339  fHistoMCConvGammaEta(NULL),
340  fHistoMCPi0Pt(NULL),
341  fHistoMCPi0WOWeightPt(NULL),
342  fHistoMCPi0WOEvtWeightPt(NULL),
343  fHistoMCEtaWOEvtWeightPt(NULL),
344  fHistoMCEtaPt(NULL),
345  fHistoMCEtaWOWeightPt(NULL),
346  fHistoMCPi0WOWeightInAccPt(NULL),
347  fHistoMCEtaWOWeightInAccPt(NULL),
348  fHistoMCPi0InAccPt(NULL),
349  fHistoMCEtaInAccPt(NULL),
350  fHistoMCPi0WOEvtWeightInAccPt(NULL),
351  fHistoMCEtaWOEvtWeightInAccPt(NULL),
352  fHistoMCPi0PtY(NULL),
353  fHistoMCEtaPtY(NULL),
354  fHistoMCPi0PtAlpha(NULL),
355  fHistoMCEtaPtAlpha(NULL),
356  fHistoMCPrimaryPtvsSource(NULL),
357  fHistoMCSecPi0PtvsSource(NULL),
358  fHistoMCSecPi0RvsSource(NULL),
359  fHistoMCSecPi0Source(NULL),
360  fHistoMCSecPi0InAccPtvsSource(NULL),
361  fHistoMCSecEtaPt(NULL),
362  fHistoMCSecEtaSource(NULL),
363  fHistoMCPi0PtJetPt(NULL),
364  fHistoMCEtaPtJetPt(NULL),
365  fHistoMCPhysicalPrimariesPt(NULL),
366  fHistoTrueMotherInvMassPt(NULL),
367  fHistoTruePrimaryMotherInvMassPt(NULL),
368  fHistoTruePrimaryMotherW0WeightingInvMassPt(NULL),
369  pESDTruePrimaryMotherWeightsInvMassPt(NULL),
370  fHistoTruePrimaryPi0MCPtResolPt(NULL),
371  fHistoTruePrimaryEtaMCPtResolPt(NULL),
372  fHistoTrueSecondaryMotherInvMassPt(NULL),
373  fHistoTrueSecondaryMotherFromK0sInvMassPt(NULL),
374  fHistoTrueK0sWithPi0DaughterMCPt(NULL),
375  fHistoTrueSecondaryMotherFromK0lInvMassPt(NULL),
376  fHistoTrueK0lWithPi0DaughterMCPt(NULL),
377  fHistoTrueSecondaryMotherFromEtaInvMassPt(NULL),
378  fHistoTrueEtaWithPi0DaughterMCPt(NULL),
379  fHistoTrueSecondaryMotherFromLambdaInvMassPt(NULL),
380  fHistoTrueLambdaWithPi0DaughterMCPt(NULL),
381  fHistoTrueBckGGInvMassPt(NULL),
382  fHistoTrueBckContInvMassPt(NULL),
383  fHistoTruePi0PtY(NULL),
384  fHistoTrueEtaPtY(NULL),
385  fHistoTruePi0PtAlpha(NULL),
386  fHistoTrueEtaPtAlpha(NULL),
387  fHistoTruePi0PtOpenAngle(NULL),
388  fHistoTrueEtaPtOpenAngle(NULL),
389  fHistoTrueMotherDalitzInvMassPt(NULL),
390  fHistoTrueConvGammaPt(NULL),
391  fHistoTrueConvGammaR(NULL),
392  fHistoTrueConvGammaPtMC(NULL),
393  fHistoTrueConvGammaRMC(NULL),
394  fHistoTrueConvGammaEta(NULL),
395  fHistoTrueConvGammaPsiPairPt(NULL),
396  fHistoTrueConvGammaInvMass(NULL),
397  fHistoTrueConvGammaInvMassReco(NULL),
398  fHistoCombinatorialPt(NULL),
399  fHistoCombinatorialMothersPt(NULL),
400  fHistoCombinatorialPtDeltaPhi_ek(NULL),
401  fHistoCombinatorialPtDeltaPhi_ep(NULL),
402  fHistoCombinatorialPtDeltaPhi_epi(NULL),
403  fHistoCombinatorialPtDeltaPhi_pik(NULL),
404  fHistoCombinatorialPtDeltaPhi_pip(NULL),
405  fHistoTruePrimaryConvGammaPt(NULL),
406  fHistoTrueSecondaryConvGammaPt(NULL),
407  fHistoTrueSecondaryConvGammaMCPt(NULL),
408  fHistoTruePrimaryConvGammaESDPtMCPt(NULL),
409  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt(NULL),
410  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt(NULL),
411  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt(NULL),
412  fHistoTrueDalitzPsiPairDeltaPhi(NULL),
413  fHistoTrueGammaPsiPairDeltaPhi(NULL),
414  fHistoDoubleCountTruePi0InvMassPt(NULL),
415  fHistoDoubleCountTrueEtaInvMassPt(NULL),
416  fHistoDoubleCountTrueConvGammaRPt(NULL),
417  vecDoubleCountTruePi0s(0),
418  vecDoubleCountTrueEtas(0),
419  vecDoubleCountTrueConvGammas(0),
420  fHistoMultipleCountTruePi0(NULL),
421  fHistoMultipleCountTrueEta(NULL),
422  fHistoMultipleCountTrueConvGamma(NULL),
423  mapMultipleCountTruePi0s(),
424  mapMultipleCountTrueEtas(),
425  mapMultipleCountTrueConvGammas(),
426  fHistoNEvents(NULL),
427  fHistoNEventsWOWeight(NULL),
428  fHistoNGoodESDTracks(NULL),
429  fHistoNEventsWeighted(NULL),
430  fHistoNGoodESDTracksWeighted(NULL),
431  fHistoVertexZ(NULL),
432  fHistoVertexZWeighted(NULL),
433  fDoCentralityFlat(0),
434  fHistoCentrality(NULL),
435  fHistoCentralityFlattened(NULL),
436  fHistoCentralityVsPrimaryTracks(NULL),
437  fHistoNGammaCandidates(NULL),
438  fHistoNGoodESDTracksVsNGammaCandidates(NULL),
439  fHistoSPDClusterTrackletBackground(NULL),
440  fHistoV0MultVsNumberTPCoutTracks(NULL),
441  fHistoNV0Tracks(NULL),
442  fProfileEtaShift(NULL),
443  fProfileJetJetXSection(NULL),
444  fhJetJetNTrials(NULL),
445  fHistoEtaShift(NULL),
446  tESDMesonsInvMassPtDcazMinDcazMaxFlag(NULL),
447  fInvMass(0),
448  fPt(0),
449  fDCAzGammaMin(0),
450  fDCAzGammaMax(0),
451  iFlag(0),
452  iMesonMCInfo(0),
453  fEventPlaneAngle(-100),
454  fRandom(0),
455  fnGammaCandidates(0),
456  fUnsmearedPx(NULL),
457  fUnsmearedPy(NULL),
458  fUnsmearedPz(NULL),
459  fUnsmearedE(NULL),
460  fMCEventPos(NULL),
461  fMCEventNeg(NULL),
462  fESDArrayPos(NULL),
463  fESDArrayNeg(NULL),
464  fnCuts(0),
465  fiCut(0),
466  fMoveParticleAccordingToVertex(kTRUE),
467  fIsHeavyIon(0),
468  fDoMesonAnalysis(kTRUE),
469  fDoMesonQA(0),
470  fDoPhotonQA(0),
471  fDoChargedPrimary(kFALSE),
472  fDoPlotVsCentrality(kFALSE),
473  fIsFromSelectedHeader(kTRUE),
474  fIsMC(0),
475  fDoTHnSparse(kTRUE),
476  fWeightJetJetMC(1),
477  fWeightCentrality(NULL),
478  fEnableClusterCutsForTrigger(kFALSE),
479  fDoMaterialBudgetWeightingOfGammasForTrueMesons(kFALSE),
480  tBrokenFiles(NULL),
481  fFileNameBroken(NULL)
482 {
483  // Define output slots here
484  DefineOutput(1, TList::Class());
485  DefineOutput(2, TTree::Class());
486  DefineOutput(3, TTree::Class());
487  DefineOutput(4, TTree::Class());
488  DefineOutput(5, TTree::Class());
489  DefineOutput(6, TTree::Class());
490  DefineOutput(7, TTree::Class());
491  DefineOutput(8, TTree::Class());
492  DefineOutput(9, TTree::Class());
493 }
494 
496 {
497  if(fGammaCandidates){
498  delete fGammaCandidates;
499  fGammaCandidates = 0x0;
500  }
501  if(fBGHandler){
502  delete[] fBGHandler;
503  fBGHandler = 0x0;
504  }
505  if(fBGHandlerRP){
506  delete[] fBGHandlerRP;
507  fBGHandlerRP = 0x0;
508  }
509 
510  if(fWeightCentrality){
511  delete[] fWeightCentrality;
512  fWeightCentrality = 0x0;
513  }
514 
515 }
516 //___________________________________________________________
518 
519  const Int_t nDim = 4;
520  Int_t nBins[nDim] = {800,250,7,4};
521  Double_t xMin[nDim] = {0,0, 0,0};
522  Double_t xMax[nDim] = {0.8,25,7,4};
523  Int_t nBinsRP[nDim] = {800,250,7,8};
524  Double_t xMinRP[nDim] = {0,0, 0,0};
525  Double_t xMaxRP[nDim] = {0.8,25,7,8};
526 
527  if(fDoTHnSparse){
528  sESDMotherInvMassPtZM = new THnSparseF*[fnCuts];
529  sESDMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
530  }
533  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
534  if (((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
535  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
536  TString cutstringPhoton = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
537  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
538 
539  Int_t collisionSystem = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(0,1));
540  Int_t centMin = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(1,1));
541  Int_t centMax = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(2,1));
542 
543  if(collisionSystem == 1 || collisionSystem == 2 ||
544  collisionSystem == 5 || collisionSystem == 8 ||
545  collisionSystem == 9){
546  centMin = centMin*10;
547  centMax = centMax*10;
548  if(centMax ==0 && centMax!=centMin) centMax=100;
549  } else if(collisionSystem == 3 || collisionSystem == 6) {
550  centMin = centMin*5;
551  centMax = centMax*5;
552  } else if(collisionSystem == 4 || collisionSystem == 7) {
553  centMin = ((centMin*5)+45);
554  centMax = ((centMax*5)+45);
555  }
556 
557  if(fDoTHnSparse){
558  fBackList[iCut] = new TList();
559  fBackList[iCut]->SetName(Form("%s_%s_%s Back histograms",cutstringEvent.Data(), cutstringPhoton.Data(),cutstringMeson.Data()));
560  fBackList[iCut]->SetOwner(kTRUE);
561  fCutFolder[iCut]->Add(fBackList[iCut]);
562 
563  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
564  sESDMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_m", "Back_Back_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
565  } else {
566  sESDMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_psi", "Back_Back_InvMass_Pt_z_psi",nDim,nBinsRP,xMinRP,xMaxRP);
567  }
568  if(fDoCentralityFlat > 0) sESDMotherBackInvMassPtZM[iCut]->Sumw2();
569  fBackList[iCut]->Add(sESDMotherBackInvMassPtZM[iCut]);
570 
571  fMotherList[iCut] = new TList();
572  fMotherList[iCut]->SetName(Form("%s_%s_%s Mother histograms",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
573  fMotherList[iCut]->SetOwner(kTRUE);
574  fCutFolder[iCut]->Add(fMotherList[iCut]);
575 
576  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
577  sESDMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_m", "Back_Mother_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
578  } else {
579  sESDMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_psi", "Back_Mother_InvMass_Pt_z_psi",nDim,nBinsRP,xMinRP,xMaxRP);
580  }
581  if(fDoCentralityFlat > 0) sESDMotherInvMassPtZM[iCut]->Sumw2();
582  fMotherList[iCut]->Add(sESDMotherInvMassPtZM[iCut]);
583  }
584  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
586  collisionSystem,centMin,centMax,
587  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents(),
588  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseTrackMultiplicity(),
589  0,8,5);
590  fBGHandlerRP[iCut] = NULL;
591  } else {
593  ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsHeavyIon(),
594  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity(),
595  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents());
596  fBGHandler[iCut] = NULL;
597  }
598  }
599  }
600 }
601 //________________________________________________________________________
603 
604  // get V0 Reader
605  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
606  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
607 
608 
609  // Set dimenstions for THnSparse
610  const Int_t nDim2 = 4;
611  Int_t nBins2[nDim2] = {250,180,100,100};
612  Double_t xMin2[nDim2] = {0,0, 0,0};
613  Double_t xMax2[nDim2] = {25,180,10,0.1};
614 
615  // Set maximum number of tracks, gammas and tracklets
616  Int_t nGammaCand = 50;
617  Int_t nTracks = 200;
618  Int_t nSPDTracklets = 200;
619  Int_t nSPDClusters = 400;
620  Int_t nBinsTrklCls = 100;
621  if(fIsHeavyIon == 1){
622  nGammaCand = 200;
623  nTracks = 4000;
624  nSPDTracklets = 6000;
625  nSPDClusters = 20000;
626  nBinsTrklCls = 200;
627  } else if(fIsHeavyIon == 2){
628  nGammaCand = 50;
629  nTracks = 400;
630  nSPDTracklets = 300;
631  nSPDClusters = 600;
632  nBinsTrklCls = 150;
633  }
634 
635 // Float_t binWidthPt = 0.1;
636  Int_t nBinsPt = 250;
637  Float_t minPt = 0;
638  Float_t maxPt = 25;
639  Int_t nBinsQAPt = 175;
640  Float_t maxQAPt = 25;
641  Int_t nBinsClusterPt = 500;
642  Float_t minClusterPt = 0;
643  Float_t maxClusterPt = 50;
644  Double_t *arrPtBinning = new Double_t[1200];
645  Double_t *arrQAPtBinning = new Double_t[1200];
646  Double_t *arrClusPtBinning = new Double_t[1200];
647 
648  // Set special pt binning for pPb 5TeV, pPb 8TeV
649  if (((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::kpPb5TeV ||
652 // binWidthPt = 0.05;
653  nBinsPt = 186;
654  minPt = 0;
655  maxPt = 40;
656  for(Int_t i=0; i<nBinsPt+1;i++){
657  if (i < 1) arrPtBinning[i] = 0.25*i;
658  else if(i<56) arrPtBinning[i] = 0.25+0.05*(i-1);
659  else if(i<126) arrPtBinning[i] = 3.+0.1*(i-56);
660  else if(i<166) arrPtBinning[i] = 10.+0.25*(i-126);
661  else if(i<186) arrPtBinning[i] = 20.+1.0*(i-166);
662  else arrPtBinning[i] = maxPt;
663  }
664  nBinsQAPt = 190;
665  maxQAPt = 40;
666  for(Int_t i=0; i<nBinsQAPt+1;i++){
667  if(i<60) arrQAPtBinning[i] = 0.05*i;
668  else if(i<130) arrQAPtBinning[i] = 3.+0.1*(i-60);
669  else if(i<170) arrQAPtBinning[i] = 10.+0.25*(i-130);
670  else if(i<190) arrQAPtBinning[i] = 20.+1.0*(i-170);
671  else arrQAPtBinning[i] = maxQAPt;
672  }
673  nBinsClusterPt = 301;
674  minClusterPt = 0;
675  maxClusterPt = 100;
676  for(Int_t i=0; i<nBinsClusterPt+1;i++){
677  if (i < 1) arrClusPtBinning[i] = 0.3*i;
678  else if(i<55) arrClusPtBinning[i] = 0.3+0.05*(i-1);
679  else if(i<125) arrClusPtBinning[i] = 3.+0.1*(i-55);
680  else if(i<155) arrClusPtBinning[i] = 10.+0.2*(i-125);
681  else if(i<211) arrClusPtBinning[i] = 16.+0.25*(i-155);
682  else if(i<251) arrClusPtBinning[i] = 30.+0.5*(i-211);
683  else if(i<301) arrClusPtBinning[i] = 50.+1.0*(i-251);
684  else arrClusPtBinning[i] = maxClusterPt;
685  }
686  // Set special pt binning for pp 13TeV and 5TeV
687  } else if ( ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k13TeV ||
689  ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k5TeV ){
690 // binWidthPt = 0.05;
691  nBinsPt = 199;
692  minPt = 0;
693  maxPt = 50;
694  for(Int_t i=0; i<nBinsPt+1;i++){
695  if (i < 1) arrPtBinning[i] = 0.10*i;
696  else if(i<59) arrPtBinning[i] = 0.10+0.05*(i-1);
697  else if(i<129) arrPtBinning[i] = 3.+0.1*(i-59);
698  else if(i<169) arrPtBinning[i] = 10.+0.25*(i-129);
699  else if(i<199) arrPtBinning[i] = 20.+1.0*(i-169);
700  else arrPtBinning[i] = maxPt;
701  }
702  nBinsQAPt = 200;
703  maxQAPt = 50;
704  for(Int_t i=0; i<nBinsQAPt+1;i++){
705  if(i<60) arrQAPtBinning[i] = 0.05*i;
706  else if(i<130) arrQAPtBinning[i] = 3.+0.1*(i-60);
707  else if(i<170) arrQAPtBinning[i] = 10.+0.25*(i-130);
708  else if(i<200) arrQAPtBinning[i] = 20.+1.0*(i-170);
709  else arrQAPtBinning[i] = maxQAPt;
710  }
711  nBinsClusterPt = 301;
712  minClusterPt = 0;
713  maxClusterPt = 100;
714  for(Int_t i=0; i<nBinsClusterPt+1;i++){
715  if (i < 1) arrClusPtBinning[i] = 0.3*i;
716  else if(i<55) arrClusPtBinning[i] = 0.3+0.05*(i-1);
717  else if(i<125) arrClusPtBinning[i] = 3.+0.1*(i-55);
718  else if(i<155) arrClusPtBinning[i] = 10.+0.2*(i-125);
719  else if(i<211) arrClusPtBinning[i] = 16.+0.25*(i-155);
720  else if(i<251) arrClusPtBinning[i] = 30.+0.5*(i-211);
721  else if(i<301) arrClusPtBinning[i] = 50.+1.0*(i-251);
722  else arrClusPtBinning[i] = maxClusterPt;
723  }
724  // Set special pt binning for XeXe 5.44TeV
725  } else if (((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::kXeXe5440GeV ){
726 // binWidthPt = 0.1;
727  nBinsPt = 90;
728  minPt = 0;
729  maxPt = 20;
730  for(Int_t i=0; i<nBinsPt+1;i++){
731  if (i < 1) arrPtBinning[i] = 0.3*i;
732  else if(i<58) arrPtBinning[i] = 0.3+0.1*(i-1);
733  else if(i<82) arrPtBinning[i] = 6.+0.25*(i-58);
734  else if(i<90) arrPtBinning[i] = 12.+1.0*(i-82);
735  else arrPtBinning[i] = maxPt;
736  }
737  nBinsQAPt = 92;
738  maxQAPt = 20;
739  for(Int_t i=0; i<nBinsQAPt+1;i++){
740  if(i<60) arrQAPtBinning[i] = 0.1*i;
741  else if(i<84) arrQAPtBinning[i] = 6.+0.25*(i-60);
742  else if(i<92) arrQAPtBinning[i] = 12.+1.0*(i-84);
743  else arrQAPtBinning[i] = maxQAPt;
744  }
745  nBinsClusterPt = 148;
746  minClusterPt = 0;
747  maxClusterPt = 40;
748  for(Int_t i=0; i<nBinsClusterPt+1;i++){
749  if (i < 1) arrClusPtBinning[i] = 0.3*i;
750  else if(i<98) arrClusPtBinning[i] = 0.3+0.1*(i-1);
751  else if(i<123) arrClusPtBinning[i] = 10.+0.2*(i-98);
752  else if(i<148) arrClusPtBinning[i] = 15.+1.0*(i-123);
753  else arrClusPtBinning[i] = maxClusterPt;
754  }
755  // Set special pt binning for PbPb 5TeV
756  } else if (((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::kPbPb5TeV ){
757 // binWidthPt = 0.1;
758  nBinsPt = 63;
759  minPt = 0.0;
760  maxPt = 25.0;
761  for(Int_t i=0; i<=nBinsPt;i++){
762  if(i<=30) arrPtBinning[i] = 0.0 + 0.10*i; // 0.1GeV bin width until 3GeV
763  else if(i<=38) arrPtBinning[i] = 3.0 + 0.25*(i-30); // 0.25GeV 5GeV
764  else if(i<=48) arrPtBinning[i] = 5.0 + 0.50*(i-38); // 0.5GeV 10GeV
765  else /*i<=nBinsPt*/ arrPtBinning[i] = 10.0 + 1.0*(i-48); // 1.0GeV 25GeV
766  }
767 
768  nBinsQAPt = 63;
769  maxQAPt = 25.0;
770  for(Int_t i=0; i<=nBinsQAPt;i++){
771  if(i<=30) arrQAPtBinning[i] = 0.0 + 0.10*i; // 0.1GeV bin width until 3GeV
772  else if(i<=38) arrQAPtBinning[i] = 3.0 + 0.25*(i-30); // 0.25GeV 5GeV
773  else if(i<=48) arrQAPtBinning[i] = 5.0 + 0.50*(i-38); // 0.5GeV 10GeV
774  else /*i<=nBinsPt*/ arrQAPtBinning[i] = 10.0 + 1.0*(i-48); // 1.0GeV 25GeV
775  }
776 
777  nBinsClusterPt = 148;
778  minClusterPt = 0;
779  maxClusterPt = 40;
780  for(Int_t i=0; i<nBinsClusterPt+1;i++){
781  if (i < 1) arrClusPtBinning[i] = 0.3*i;
782  else if(i<98) arrClusPtBinning[i] = 0.3+0.1*(i-1);
783  else if(i<123) arrClusPtBinning[i] = 10.+0.2*(i-98);
784  else if(i<148) arrClusPtBinning[i] = 15.+1.0*(i-123);
785  else arrClusPtBinning[i] = maxClusterPt;
786  }
787  //----------------------------------------------------------------------------------------------------------------
788  } else {
789 
790  for(Int_t i=0; i<nBinsPt+1;i++){
791  arrPtBinning[i] = ((maxPt-minPt)/nBinsPt)*i;
792  }
793  for(Int_t i=0; i<nBinsClusterPt+1;i++){
794  arrClusPtBinning[i] = ((maxClusterPt-minClusterPt)/nBinsClusterPt)*i;
795  }
796  for(Int_t i=0; i<nBinsQAPt+1;i++){
797  if(i<60) arrQAPtBinning[i] = 0.05*i;
798  else if(i<130) arrQAPtBinning[i] = 3.+0.1*(i-60);
799  else if(i<170) arrQAPtBinning[i] = 10.+0.25*(i-130);
800  else if(i<175) arrQAPtBinning[i] = 20.+1*(i-170);
801  else arrQAPtBinning[i] = maxQAPt;
802  }
803  }
804 
805 
806  if (fIsMC == 2){
807  fDoPhotonQA = 0;
808  fDoTHnSparse = kFALSE;
809  } else if (fIsMC == 3){
810  fDoTHnSparse = kFALSE;
811  }
812  // Create histograms
813  if(fOutputContainer != NULL){
814  delete fOutputContainer;
815  fOutputContainer = NULL;
816  }
817  if(fOutputContainer == NULL){
818  fOutputContainer = new TList();
819  fOutputContainer->SetOwner(kTRUE);
820  }
821 
822  // Array of current cut's gammas
823  fGammaCandidates = new TList();
824 
825  fCutFolder = new TList*[fnCuts];
826  fESDList = new TList*[fnCuts];
827  if(fDoTHnSparse){
828  fBackList = new TList*[fnCuts];
829  fMotherList = new TList*[fnCuts];
830  }
831 
832  fHistoNEvents = new TH1F*[fnCuts];
833  if (fIsMC > 1){
834  fHistoNEventsWOWeight = new TH1F*[fnCuts];
835  }
836  if (fIsMC == 2){
837  fProfileJetJetXSection = new TProfile*[fnCuts];
838  fhJetJetNTrials = new TH1F*[fnCuts];
839  }
840  fHistoNGoodESDTracks = new TH1F*[fnCuts];
841  fHistoVertexZ = new TH1F*[fnCuts];
843  fHistoCentrality = new TH1F*[fnCuts];
845  }
846  if(fDoCentralityFlat > 0){
848  fHistoNEventsWeighted = new TH1F*[fnCuts];
850  fHistoVertexZWeighted = new TH1F*[fnCuts];
851  fHistoCentralityFlattened = new TH1F*[fnCuts];
852  }
853  fHistoNGammaCandidates = new TH1F*[fnCuts];
854  if (fIsMC < 2){
857  }
859  fHistoConvGammaPt = new TH1F*[fnCuts];
860  fHistoNV0Tracks = new TH1F*[fnCuts];
861  fHistoEtaShift = new TProfile*[fnCuts];
862 
863  if (fDoPhotonQA > 0 && fIsMC < 2 ){
865  fHistoConvGammaR = new TH1F*[fnCuts];
866  fHistoConvGammaEta = new TH1F*[fnCuts];
867  fHistoConvGammaPhi = new TH1F*[fnCuts];
868  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
869  fHistoConvGammaInvMass = new TH1F*[fnCuts];
870  fHistoConvGammaInvMassReco = new TH1F*[fnCuts];
871  }
872  }
873  if ((fDoPhotonQA == 2)||(fDoPhotonQA == 5)){
875  }
876  if(fDoMesonAnalysis){
880  if(fDoMesonQA > 0){
887  }
888  if(fDoMesonQA == 2){
890  }
891  if(fDoMesonQA == 3){
892  sPtRDeltaROpenAngle = new THnSparseF*[fnCuts];
893  }
894  }
895 
897  fHistoCaloGammaPt = new TH1F*[fnCuts];
898  fHistoCaloGammaE = new TH1F*[fnCuts];
899  }
900 
901 
902  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
903 
904  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
905  TString cutstringPhoton = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
906  TString cutstringMeson = "NoMesonCut";
907  if(fDoMesonAnalysis)
908  cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
909 
910  fCutFolder[iCut] = new TList();
911  fCutFolder[iCut]->SetName(Form("Cut Number %s_%s_%s",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
912  fCutFolder[iCut]->SetOwner(kTRUE);
913  fOutputContainer->Add(fCutFolder[iCut]);
914  fESDList[iCut] = new TList();
915  fESDList[iCut]->SetName(Form("%s_%s_%s ESD histograms",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
916  fESDList[iCut]->SetOwner(kTRUE);
917  fCutFolder[iCut]->Add(fESDList[iCut]);
918 
919  if(fDoCentralityFlat > 0)
920  fHistoNEvents[iCut] = new TH1F("NEventsUnweighted", "NEventsUnweighted", 14, -0.5, 13.5);
921  else
922  fHistoNEvents[iCut] = new TH1F("NEvents", "NEvents", 14, -0.5, 13.5);
923  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
924  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
925  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
926  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
927  TString TriggerNames = "Not Trigger: ";
928  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
929  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
930  } else {
931  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
932  }
933  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
934  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
935  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
936  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
937  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
938  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
939  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
940  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
941  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
942  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
943  fESDList[iCut]->Add(fHistoNEvents[iCut]);
944  if (fIsMC > 1){
945  fHistoNEventsWOWeight[iCut] = new TH1F("NEventsWOWeight", "NEventsWOWeight", 14, -0.5, 13.5);
946  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
947  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
948  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
949  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
950  TString TriggerNames = "Not Trigger: ";
951  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
952  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
953  } else {
954  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
955  }
956  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
957  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
958  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
959  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
960  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
961  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
962  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
963  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
964  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
965  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
966  fESDList[iCut]->Add(fHistoNEventsWOWeight[iCut]);
967  }
968  if (fIsMC == 2){
969  fProfileJetJetXSection[iCut] = new TProfile("XSection", "XSection", 1, -0.5, 0.5);
970  fESDList[iCut]->Add(fProfileJetJetXSection[iCut]);
971  fhJetJetNTrials[iCut] = new TH1F("NTrials", "#sum{NTrials}", 1, 0, 1);
972  fhJetJetNTrials[iCut]->GetXaxis()->SetBinLabel(1,"#sum{NTrials}");
973  fESDList[iCut]->Add(fhJetJetNTrials[iCut]);
974  }
975  if(fDoCentralityFlat > 0){
976  fHistoNEventsWeighted[iCut] = new TH1F("NEvents", "NEvents", 14, -0.5, 13.5);//weighted histogram!!
977  fHistoNEventsWeighted[iCut]->Sumw2();
978  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
979  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
980  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
981  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
982  TString TriggerNames = "Not Trigger: ";
983  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
984  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
985  } else {
986  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
987  }
988  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
989  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
990  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
991  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
992  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
993  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
994  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
995  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
996  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
997  fHistoNEventsWeighted[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
998  fESDList[iCut]->Add(fHistoNEventsWeighted[iCut]);
999  }
1000 
1001  if(fDoCentralityFlat > 0 && fIsHeavyIon == 1){
1002  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracksUnweighted", "GoodESDTracksUnweighted", nTracks, -0.5, nTracks-0.5);
1003  fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
1004  fHistoVertexZ[iCut] = new TH1F("VertexZUnweighted", "VertexZUnweighted", 200, -10, 10);
1005  fESDList[iCut]->Add(fHistoVertexZ[iCut]);
1006 
1007  fHistoNGoodESDTracksWeighted[iCut] = new TH1F("GoodESDTracks", "GoodESDTracks", nTracks, -0.5, nTracks-0.5); //weighted histogram!!
1008  fHistoNGoodESDTracksWeighted[iCut]->Sumw2();
1009  fESDList[iCut]->Add(fHistoNGoodESDTracksWeighted[iCut]);
1010  fHistoVertexZWeighted[iCut] = new TH1F("VertexZ", "VertexZ", 200, -10, 10);
1011  fHistoVertexZWeighted[iCut]->Sumw2();
1012  fESDList[iCut]->Add(fHistoVertexZWeighted[iCut]);
1013  } else {
1014  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks", "GoodESDTracks", nTracks, -0.5, nTracks-0.5);
1015  fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
1016  fHistoVertexZ[iCut] = new TH1F("VertexZ", "VertexZ", 200, -10, 10);
1017  fESDList[iCut]->Add(fHistoVertexZ[iCut]);
1018  }
1019 
1020  if(fDoPlotVsCentrality){
1021  fHistoCentrality[iCut] = new TH1F("Centrality", "Centrality", 100, -0.5, 99.5);
1022  fESDList[iCut]->Add(fHistoCentrality[iCut]);
1023  fHistoCentralityVsPrimaryTracks[iCut] = new TH2F("Centrality vs Primary Tracks", "Centrality vs Primary Tracks ", 100, -0.5, 99.5, nTracks, -0.5, nTracks-0.5);
1024  if(fDoCentralityFlat > 0 || fIsMC > 1) fHistoCentralityVsPrimaryTracks[iCut]->Sumw2();
1025  fESDList[iCut]->Add(fHistoCentralityVsPrimaryTracks[iCut]);
1026  }
1027  if(fDoCentralityFlat > 0){
1028  fHistoCentralityFlattened[iCut] = new TH1F("CentralityFlattened", "CentralityFlattened", 100, -0.5, 99.5);
1029  fHistoCentralityFlattened[iCut]->Sumw2();
1030  fESDList[iCut]->Add(fHistoCentralityFlattened[iCut]);
1031  }
1032 
1033  fHistoNGammaCandidates[iCut] = new TH1F("GammaCandidates", "GammaCandidates", nGammaCand, -0.5, nGammaCand-0.5);
1034  if(fDoCentralityFlat > 0 || fIsMC > 1) fHistoNGammaCandidates[iCut]->Sumw2();
1035  fESDList[iCut]->Add(fHistoNGammaCandidates[iCut]);
1036  if (fIsMC < 2){
1037  fHistoNGoodESDTracksVsNGammaCandidates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates", "GoodESDTracksVsGammaCandidates", nTracks, -0.5, nTracks-0.5, nGammaCand, -0.5, nGammaCand-0.5);
1040 
1041  fHistoSPDClusterTrackletBackground[iCut] = new TH2F("SPD tracklets vs SPD clusters", "SPD tracklets vs SPD clusters", nBinsTrklCls, 0, nSPDTracklets, nBinsTrklCls, 0, nSPDClusters);
1043  fESDList[iCut]->Add(fHistoSPDClusterTrackletBackground[iCut]);
1044  }
1045 
1046  if(fIsHeavyIon == 1)
1047  fHistoV0MultVsNumberTPCoutTracks[iCut] = new TH2F("V0Mult vs TPCout Tracks", "V0Mult vs TPCout Tracks", 500, 0, 15000, 500, 0, 40000);
1048  else if(fIsHeavyIon == 2)
1049  fHistoV0MultVsNumberTPCoutTracks[iCut] = new TH2F("V0Mult vs TPCout Tracks", "V0Mult vs TPCout Tracks", 500, 0, 1000, 500, 0, 2500);
1050  else
1051  fHistoV0MultVsNumberTPCoutTracks[iCut] = new TH2F("V0Mult vs TPCout Tracks", "V0Mult vs TPCout Tracks", 200, 0, 400, 500, 0, 1500);
1052 
1053  fESDList[iCut]->Add(fHistoV0MultVsNumberTPCoutTracks[iCut]);
1054 
1055  if(fIsHeavyIon == 1)
1056  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity", "V0 Multiplicity", 20000, 0, 40000);
1057  else if(fIsHeavyIon == 2)
1058  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity", "V0 Multiplicity", 2500, 0, 2500);
1059  else
1060  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity", "V0 Multiplicity", 1500, 0, 1500);
1061  if(fDoCentralityFlat > 0 || fIsMC > 1) fHistoNV0Tracks[iCut]->Sumw2();
1062  fESDList[iCut]->Add(fHistoNV0Tracks[iCut]);
1063  fHistoEtaShift[iCut] = new TProfile("Eta Shift", "Eta Shift", 1, -0.5, 0.5);
1064  fESDList[iCut]->Add(fHistoEtaShift[iCut]);
1065 
1066  fHistoConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt", "ESD_ConvGamma_Pt", nBinsPt, arrPtBinning);
1067  if(fDoCentralityFlat > 0 ) fHistoConvGammaPt[iCut]->Sumw2();
1068  fESDList[iCut]->Add(fHistoConvGammaPt[iCut]);
1069 
1071  fHistoConvGammaPt[iCut]->Sumw2();
1072  }
1073 
1074  if (fIsMC > 1){
1075  fHistoNEvents[iCut]->Sumw2();
1076  fHistoNGoodESDTracks[iCut]->Sumw2();
1077  fHistoVertexZ[iCut]->Sumw2();
1078  fHistoEtaShift[iCut]->Sumw2();
1079  if(fDoPlotVsCentrality){
1080  fHistoCentrality[iCut]->Sumw2();
1081  }
1082  }
1083 
1085  fHistoCaloGammaPt[iCut] = new TH1F("ClusGamma_Pt", "ClusGamma_Pt", nBinsClusterPt, arrClusPtBinning);
1086  fHistoCaloGammaPt[iCut]->SetXTitle("p_{T,clus}(GeV/c)");
1087  fESDList[iCut]->Add(fHistoCaloGammaPt[iCut]);
1088  if (fIsMC > 1) fHistoCaloGammaPt[iCut]->Sumw2();
1089  fHistoCaloGammaE[iCut] = new TH1F("ClusGamma_E", "ClusGamma_E", nBinsClusterPt, arrClusPtBinning);
1090  fHistoCaloGammaE[iCut]->SetXTitle("E_{clus}(GeV)");
1091  fESDList[iCut]->Add(fHistoCaloGammaE[iCut]);
1092  if (fIsMC > 1) fHistoCaloGammaE[iCut]->Sumw2();
1093  }
1094 
1095  if ((fDoPhotonQA == 2)||(fDoPhotonQA == 5)){
1096  tESDConvGammaPtDcazCat[iCut]= new TTree(Form("%s_%s_%s Photon DCA tree", cutstringEvent.Data(), cutstringPhoton.Data(), cutstringMeson.Data()), "ESD_ConvGamma_Pt_Dcaz_R_Eta_Cat");
1097  tESDConvGammaPtDcazCat[iCut]->Branch("Pt",&fPtGamma,"fPtGamma/F");
1098  tESDConvGammaPtDcazCat[iCut]->Branch("DcaZPhoton",&fDCAzPhoton,"fDCAzPhoton/F");
1099  tESDConvGammaPtDcazCat[iCut]->Branch("cat",&iCatPhoton,"iCatPhoton/b");
1100  if(fIsMC>0){
1101  tESDConvGammaPtDcazCat[iCut]->Branch("photonMCInfo",&iPhotonMCInfo,"iPhotonMCInfo/b");
1102  }
1103  if (fIsMC > 1){
1104  tESDConvGammaPtDcazCat[iCut]->Branch("weightEvent",&fWeightJetJetMC,"fWeightJetJetMC/F");
1105  }
1106  }
1107 
1108  if(fDoPhotonQA > 0 && fIsMC < 2){
1109 
1110  fHistoConvGammaPsiPairPt[iCut]= new TH2F("ESD_ConvGamma_PsiPair_Pt", "ESD_ConvGamma_PsiPair_Pt", 500, 0, 5, nBinsQAPt, arrQAPtBinning);
1111  if(fDoCentralityFlat > 0) fHistoConvGammaPsiPairPt[iCut]->Sumw2();
1112  fESDList[iCut]->Add(fHistoConvGammaPsiPairPt[iCut]);
1113 
1114  fHistoConvGammaR[iCut] = new TH1F("ESD_ConvGamma_R", "ESD_ConvGamma_R", 800, 0, 200);
1115  if(fDoCentralityFlat > 0) fHistoConvGammaR[iCut]->Sumw2();
1116  fESDList[iCut]->Add(fHistoConvGammaR[iCut]);
1117  fHistoConvGammaEta[iCut] = new TH1F("ESD_ConvGamma_Eta", "ESD_ConvGamma_Eta", 1000, -2, 2);
1118  if(fDoCentralityFlat > 0) fHistoConvGammaEta[iCut]->Sumw2();
1119  fESDList[iCut]->Add(fHistoConvGammaEta[iCut]);
1120  fHistoConvGammaPhi[iCut] = new TH1F("ESD_ConvGamma_Phi", "ESD_ConvGamma_Phi", 360, 0, 2*TMath::Pi());
1121  if(fDoCentralityFlat > 0) fHistoConvGammaPhi[iCut]->Sumw2();
1122  fESDList[iCut]->Add(fHistoConvGammaPhi[iCut]);
1123  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
1124  fHistoConvGammaInvMass[iCut] = new TH1F("ESD_ConvGamma_InvMass", "ESD_ConvGamma_InvMass", 500, 0., 5.);
1125  if(fDoCentralityFlat > 0) fHistoConvGammaInvMass[iCut]->Sumw2();
1126  fESDList[iCut]->Add(fHistoConvGammaInvMass[iCut]);
1127  fHistoConvGammaInvMassReco[iCut] = new TH1F("ESD_ConvGamma_InvMassReco", "ESD_ConvGamma_InvMassReco", 500, 0., 5.);
1128  if(fDoCentralityFlat > 0) fHistoConvGammaInvMassReco[iCut]->Sumw2();
1129  fESDList[iCut]->Add(fHistoConvGammaInvMassReco[iCut]);
1130  }
1131  }
1132 
1133  if(fDoMesonAnalysis){
1134  fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt", "ESD_Mother_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1135  fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
1136  fHistoMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt", "ESD_Background_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1137  fESDList[iCut]->Add(fHistoMotherBackInvMassPt[iCut]);
1138  fHistoMotherInvMassEalpha[iCut] = new TH2F("ESD_Mother_InvMass_vs_E_alpha", "ESD_Mother_InvMass_vs_E_alpha", 800, 0, 0.8, nBinsPt, arrPtBinning);
1139  fESDList[iCut]->Add(fHistoMotherInvMassEalpha[iCut]);
1140 
1141  if (fIsMC > 1 || fDoCentralityFlat > 0){
1142  fHistoMotherInvMassPt[iCut]->Sumw2();
1143  fHistoMotherBackInvMassPt[iCut]->Sumw2();
1144  fHistoMotherInvMassEalpha[iCut]->Sumw2();
1145  }
1146 
1147  if(fDoMesonQA == 2){
1148  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut] = new TTree(Form("%s_%s_%s Meson DCA tree",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()), "ESD_Mesons_InvMass_Pt_DcazMin_DcazMax_Flag");
1149  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("InvMass",&fInvMass,"fInvMass/F");
1150  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("Pt",&fPt,"fPt/F");
1151  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("DcaZMin",&fDCAzGammaMin,"fDCAzGammaMin/F");
1152  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("DcaZMax",&fDCAzGammaMax,"fDCAzGammaMax/F");
1153  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("kind",&iFlag,"iFlag/b");
1154  if(fIsMC>0){
1155  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("mesonMCInfo",&iMesonMCInfo,"iMesonMCInfo/b");
1156  }
1157  }
1158  if(fDoMesonQA > 0 ){
1159  if (fIsMC < 2){
1160  fHistoMotherPi0PtY[iCut] = new TH2F("ESD_MotherPi0_Pt_Y", "ESD_MotherPi0_Pt_Y", nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
1161  fESDList[iCut]->Add(fHistoMotherPi0PtY[iCut]);
1162  fHistoMotherEtaPtY[iCut] = new TH2F("ESD_MotherEta_Pt_Y", "ESD_MotherEta_Pt_Y", nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
1163  fESDList[iCut]->Add(fHistoMotherEtaPtY[iCut]);
1164  fHistoMotherPi0PtOpenAngle[iCut] = new TH2F("ESD_MotherPi0_Pt_OpenAngle", "ESD_MotherPi0_Pt_OpenAngle", nBinsQAPt, arrQAPtBinning, 100, 0, TMath::Pi());
1165  fESDList[iCut]->Add(fHistoMotherPi0PtOpenAngle[iCut]);
1166  fHistoMotherEtaPtOpenAngle[iCut] = new TH2F("ESD_MotherEta_Pt_OpenAngle", "ESD_MotherEta_Pt_OpenAngle", nBinsQAPt, arrQAPtBinning, 100, 0, TMath::Pi());
1167  fESDList[iCut]->Add(fHistoMotherEtaPtOpenAngle[iCut]);
1168  }
1169  fHistoMotherPi0PtAlpha[iCut] = new TH2F("ESD_MotherPi0_Pt_Alpha", "ESD_MotherPi0_Pt_Alpha", nBinsQAPt, arrQAPtBinning, 100, 0, 1);
1170  fESDList[iCut]->Add(fHistoMotherPi0PtAlpha[iCut]);
1171  fHistoMotherEtaPtAlpha[iCut] = new TH2F("ESD_MotherEta_Pt_Alpha", "ESD_MotherEta_Pt_Alpha", nBinsQAPt, arrQAPtBinning, 100, 0, 1);
1172  fESDList[iCut]->Add(fHistoMotherEtaPtAlpha[iCut]);
1173  if(fIsMC > 1){
1174  fHistoMotherPi0PtAlpha[iCut]->Sumw2();
1175  fHistoMotherEtaPtAlpha[iCut]->Sumw2();
1176  }
1177 
1178  }
1179  if(fDoMesonQA == 3){
1180  sPtRDeltaROpenAngle[iCut] = new THnSparseF("PhotonPair_Pt_R_DeltaR_OpenAngle", "PhotonPair_Pt_R_DeltaR_OpenAngle", nDim2, nBins2, xMin2, xMax2);
1181  fESDList[iCut]->Add(sPtRDeltaROpenAngle[iCut]);
1182  }
1183  }
1184 
1185 
1186  }
1187  if(fDoMesonAnalysis){
1188  InitBack(); // Init Background Handler
1189  }
1190 
1191  if(fIsMC>0){
1192  // MC Histogramms
1193  fMCList = new TList*[fnCuts];
1194  // True Histogramms
1195  fTrueList = new TList*[fnCuts];
1196  // Selected Header List
1197  fHeaderNameList = new TList*[fnCuts];
1198  fHistoMCHeaders = new TH1I*[fnCuts];
1199  fHistoMCAllGammaPt = new TH1F*[fnCuts];
1201  fHistoMCDecayGammaPi0Pt = new TH1F*[fnCuts];
1202  fHistoMCDecayGammaRhoPt = new TH1F*[fnCuts];
1203  fHistoMCDecayGammaEtaPt = new TH1F*[fnCuts];
1204  fHistoMCDecayGammaOmegaPt = new TH1F*[fnCuts];
1205  fHistoMCDecayGammaEtapPt = new TH1F*[fnCuts];
1206  fHistoMCDecayGammaPhiPt = new TH1F*[fnCuts];
1207  fHistoMCDecayGammaSigmaPt = new TH1F*[fnCuts];
1208  fHistoMCConvGammaPt = new TH1F*[fnCuts];
1210  fHistoTrueConvGammaPt = new TH1F*[fnCuts];
1213 
1215  if (fDoPhotonQA == 3){
1222  }
1223  fHistoTruePrimaryConvGammaPt = new TH1F*[fnCuts];
1230 
1233 
1234  if (fDoPhotonQA > 0 ){
1235  if (fIsMC < 2 ){
1236  fHistoMCConvGammaR = new TH1F*[fnCuts];
1237  fHistoMCConvGammaEta = new TH1F*[fnCuts];
1239  fHistoTrueConvGammaEta = new TH1F*[fnCuts];
1240  fHistoTrueConvGammaR = new TH1F*[fnCuts];
1241  fHistoTrueConvGammaRMC = new TH1F*[fnCuts];
1242  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
1243  fHistoTrueConvGammaInvMass = new TH1F*[fnCuts];
1245  }
1246  }
1247  fHistoTrueConvGammaPtMC = new TH1F*[fnCuts];
1248  }
1249 
1250  if(fDoMesonAnalysis){
1251  fHistoMCPi0Pt = new TH1F*[fnCuts];
1252  fHistoMCPi0WOWeightPt = new TH1F*[fnCuts];
1253  fHistoMCEtaPt = new TH1F*[fnCuts];
1254  fHistoMCEtaWOWeightPt = new TH1F*[fnCuts];
1255  fHistoMCPi0WOWeightInAccPt = new TH1F*[fnCuts];
1256  fHistoMCEtaWOWeightInAccPt = new TH1F*[fnCuts];
1257  fHistoMCPi0InAccPt = new TH1F*[fnCuts];
1258  fHistoMCEtaInAccPt = new TH1F*[fnCuts];
1259 
1260  if(fIsMC > 1){
1261  fHistoMCPi0WOEvtWeightPt = new TH1F*[fnCuts];
1262  fHistoMCEtaWOEvtWeightPt = new TH1F*[fnCuts];
1265  }
1266 
1269  fHistoMultipleCountTruePi0 = new TH1F*[fnCuts];
1271  fHistoMultipleCountTrueEta = new TH1F*[fnCuts];
1274  pESDTruePrimaryMotherWeightsInvMassPt = new TProfile2D*[fnCuts];
1281 
1285  fHistoMCSecPi0Source = new TH1F*[fnCuts];
1286  fHistoMCSecEtaPt = new TH1F*[fnCuts];
1287  fHistoMCSecEtaSource = new TH1F*[fnCuts];
1288 
1289  if (fDoMesonQA > 0){
1290  fHistoMCPi0PtAlpha = new TH2F*[fnCuts];
1291  fHistoMCEtaPtAlpha = new TH2F*[fnCuts];
1292  if (fIsMC == 2){
1293  fHistoMCPi0PtJetPt = new TH2F*[fnCuts];
1294  fHistoMCEtaPtJetPt = new TH2F*[fnCuts];
1295  }
1296 
1297  if (fIsMC < 2){
1299  fHistoMCPi0PtY = new TH2F*[fnCuts];
1300  fHistoMCEtaPtY = new TH2F*[fnCuts];
1309  fHistoTruePi0PtY = new TH2F*[fnCuts];
1310  fHistoTrueEtaPtY = new TH2F*[fnCuts];
1313  }
1316 
1317  }
1318  }
1319 
1320  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1321  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
1322  TString cutstringPhoton = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
1323  TString cutstringMeson = "NoMesonCut";
1324  if(fDoMesonAnalysis)
1325  cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
1326 
1327  fMCList[iCut] = new TList();
1328  fMCList[iCut]->SetName(Form("%s_%s_%s MC histograms",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
1329  fMCList[iCut]->SetOwner(kTRUE);
1330  fCutFolder[iCut]->Add(fMCList[iCut]);
1331  if (fIsMC < 2){
1332  fHistoMCHeaders[iCut] = new TH1I("MC_Headers", "MC_Headers", 20, 0, 20);
1333  fMCList[iCut]->Add(fHistoMCHeaders[iCut]);
1334  }
1335  fHistoMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt", "MC_AllGamma_Pt", nBinsPt, arrPtBinning);
1336  fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);
1337  fHistoMCAllSecondaryGammaPt[iCut] = new TH2F("MC_AllSecondaryGamma_Pt", "MC_AllSecondaryGamma_Pt", nBinsPt, arrPtBinning, 4, -0.5, 3.5);
1338  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1339  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1340  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1341  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1342  fMCList[iCut]->Add(fHistoMCAllSecondaryGammaPt[iCut]);
1343  fHistoMCDecayGammaPi0Pt[iCut] = new TH1F("MC_DecayGammaPi0_Pt", "MC_DecayGammaPi0_Pt", nBinsPt, arrPtBinning);
1344  fMCList[iCut]->Add(fHistoMCDecayGammaPi0Pt[iCut]);
1345  fHistoMCDecayGammaRhoPt[iCut] = new TH1F("MC_DecayGammaRho_Pt", "MC_DecayGammaRho_Pt", nBinsPt, arrPtBinning);
1346  fMCList[iCut]->Add(fHistoMCDecayGammaRhoPt[iCut]);
1347  fHistoMCDecayGammaEtaPt[iCut] = new TH1F("MC_DecayGammaEta_Pt", "MC_DecayGammaEta_Pt", nBinsPt, arrPtBinning);
1348  fMCList[iCut]->Add(fHistoMCDecayGammaEtaPt[iCut]);
1349  fHistoMCDecayGammaOmegaPt[iCut] = new TH1F("MC_DecayGammaOmega_Pt", "MC_DecayGammaOmmega_Pt", nBinsPt, arrPtBinning);
1350  fMCList[iCut]->Add(fHistoMCDecayGammaOmegaPt[iCut]);
1351  fHistoMCDecayGammaEtapPt[iCut] = new TH1F("MC_DecayGammaEtap_Pt", "MC_DecayGammaEtap_Pt", nBinsPt, arrPtBinning);
1352  fMCList[iCut]->Add(fHistoMCDecayGammaEtapPt[iCut]);
1353  fHistoMCDecayGammaPhiPt[iCut] = new TH1F("MC_DecayGammaPhi_Pt", "MC_DecayGammaPhi_Pt", nBinsPt, arrPtBinning);
1354  fMCList[iCut]->Add(fHistoMCDecayGammaPhiPt[iCut]);
1355  fHistoMCDecayGammaSigmaPt[iCut] = new TH1F("MC_DecayGammaSigma_Pt", "MC_DecayGammaSigma_Pt", nBinsPt, arrPtBinning);
1356  fMCList[iCut]->Add(fHistoMCDecayGammaSigmaPt[iCut]);
1357  fHistoMCConvGammaPt[iCut] = new TH1F("MC_ConvGamma_Pt", "MC_ConvGamma_Pt", nBinsPt, arrPtBinning);
1358  fMCList[iCut]->Add(fHistoMCConvGammaPt[iCut]);
1359  fHistoMCSecondaryConvGammaPt[iCut] = new TH2F("MC_SecondaryConvGamma_Pt", "MC_SecondaryConvGamma_Pt", nBinsPt, arrPtBinning, 4, -0.5, 3.5);
1360  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1361  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1362  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1363  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1364  fMCList[iCut]->Add(fHistoMCSecondaryConvGammaPt[iCut]);
1365 
1366  if (fIsMC > 1){
1367  fHistoMCAllGammaPt[iCut]->Sumw2();
1368  fHistoMCAllSecondaryGammaPt[iCut]->Sumw2();
1369  fHistoMCDecayGammaPi0Pt[iCut]->Sumw2();
1370  fHistoMCDecayGammaRhoPt[iCut]->Sumw2();
1371  fHistoMCDecayGammaEtaPt[iCut]->Sumw2();
1372  fHistoMCDecayGammaOmegaPt[iCut]->Sumw2();
1373  fHistoMCDecayGammaEtapPt[iCut]->Sumw2();
1374  fHistoMCDecayGammaPhiPt[iCut]->Sumw2();
1375  fHistoMCDecayGammaSigmaPt[iCut]->Sumw2();
1376  fHistoMCConvGammaPt[iCut]->Sumw2();
1377  fHistoMCSecondaryConvGammaPt[iCut]->Sumw2();
1378  }
1379 
1380  if (fDoPhotonQA > 0 && fIsMC < 2){
1381  fHistoMCConvGammaR[iCut] = new TH1F("MC_ConvGamma_R", "MC_ConvGamma_R", 800, 0, 200);
1382  fMCList[iCut]->Add(fHistoMCConvGammaR[iCut]);
1383  fHistoMCConvGammaEta[iCut] = new TH1F("MC_ConvGamma_Eta", "MC_ConvGamma_Eta", 1000, -2, 2);
1384  fMCList[iCut]->Add(fHistoMCConvGammaEta[iCut]);
1385  }
1386 
1387  if(fDoMesonAnalysis){
1388  fHistoMCPi0Pt[iCut] = new TH1F("MC_Pi0_Pt", "MC_Pi0_Pt", nBinsPt, arrPtBinning);
1389  fHistoMCPi0Pt[iCut]->Sumw2();
1390  fMCList[iCut]->Add(fHistoMCPi0Pt[iCut]);
1391  fHistoMCPi0WOWeightPt[iCut] = new TH1F("MC_Pi0_WOWeights_Pt", "MC_Pi0_WOWeights_Pt", nBinsPt, arrPtBinning);
1392  fHistoMCPi0WOWeightPt[iCut]->Sumw2();
1393  fMCList[iCut]->Add(fHistoMCPi0WOWeightPt[iCut]);
1394 
1395  fHistoMCEtaPt[iCut] = new TH1F("MC_Eta_Pt", "MC_Eta_Pt", nBinsPt, arrPtBinning);
1396  fHistoMCEtaPt[iCut]->Sumw2();
1397  fMCList[iCut]->Add(fHistoMCEtaPt[iCut]);
1398  fHistoMCEtaWOWeightPt[iCut] = new TH1F("MC_Eta_WOWeights_Pt", "MC_Eta_WOWeights_Pt", nBinsPt, arrPtBinning);
1399  fHistoMCEtaWOWeightPt[iCut]->Sumw2();
1400  fMCList[iCut]->Add(fHistoMCEtaWOWeightPt[iCut]);
1401 
1402  fHistoMCPi0WOWeightInAccPt[iCut] = new TH1F("MC_Pi0WOWeightInAcc_Pt", "MC_Pi0WOWeightInAcc_Pt", nBinsPt, arrPtBinning);
1403  fHistoMCPi0WOWeightInAccPt[iCut]->Sumw2();
1404  fMCList[iCut]->Add(fHistoMCPi0WOWeightInAccPt[iCut]);
1405  fHistoMCEtaWOWeightInAccPt[iCut] = new TH1F("MC_EtaWOWeightInAcc_Pt", "MC_EtaWOWeightInAcc_Pt", nBinsPt, arrPtBinning);
1406  fHistoMCEtaWOWeightInAccPt[iCut]->Sumw2();
1407  fMCList[iCut]->Add(fHistoMCEtaWOWeightInAccPt[iCut]);
1408  fHistoMCPi0InAccPt[iCut] = new TH1F("MC_Pi0InAcc_Pt", "MC_Pi0InAcc_Pt", nBinsPt, arrPtBinning);
1409  fHistoMCPi0InAccPt[iCut]->Sumw2();
1410  fMCList[iCut]->Add(fHistoMCPi0InAccPt[iCut]);
1411  fHistoMCEtaInAccPt[iCut] = new TH1F("MC_EtaInAcc_Pt", "MC_EtaInAcc_Pt", nBinsPt, arrPtBinning);
1412  fHistoMCEtaInAccPt[iCut]->Sumw2();
1413  fMCList[iCut]->Add(fHistoMCEtaInAccPt[iCut]);
1414 
1415  if (fIsMC > 1){
1416  fHistoMCPi0WOEvtWeightPt[iCut] = new TH1F("MC_Pi0_WOEventWeights_Pt", "MC_Pi0_WOEventWeights_Pt", nBinsPt, arrPtBinning);
1417  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightPt[iCut]);
1418  fHistoMCEtaWOEvtWeightPt[iCut] = new TH1F("MC_Eta_WOEventWeights_Pt", "MC_Eta_WOEventWeights_Pt", nBinsPt, arrPtBinning);
1419  fMCList[iCut]->Add(fHistoMCEtaWOEvtWeightPt[iCut]);
1420  fHistoMCPi0WOEvtWeightInAccPt[iCut] = new TH1F("MC_Pi0WOEvtWeightInAcc_Pt", "MC_Pi0WOEvtWeightInAcc_Pt", nBinsPt, arrPtBinning);
1421  fHistoMCPi0WOEvtWeightInAccPt[iCut]->Sumw2();
1422  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightInAccPt[iCut]);
1423  fHistoMCEtaWOEvtWeightInAccPt[iCut] = new TH1F("MC_EtaWOEvtWeightInAcc_Pt", "MC_EtaWOEvtWeightInAcc_Pt", nBinsPt, arrPtBinning);
1424  fHistoMCEtaWOEvtWeightInAccPt[iCut]->Sumw2();
1425  fMCList[iCut]->Add(fHistoMCEtaWOEvtWeightInAccPt[iCut]);
1426 
1427  if (fDoMesonQA > 0 && fIsMC == 2){
1428  fHistoMCPi0PtJetPt[iCut] = new TH2F("MC_Pi0_Pt_JetPt", "MC_Pi0_Pt_JetPt", nBinsPt, arrPtBinning, 200, 0, 200);
1429  fHistoMCPi0PtJetPt[iCut]->Sumw2();
1430  fMCList[iCut]->Add(fHistoMCPi0PtJetPt[iCut]);
1431  fHistoMCEtaPtJetPt[iCut] = new TH2F("MC_Eta_Pt_JetPt", "MC_Eta_Pt_JetPt", nBinsPt, arrPtBinning, 200, 0, 200);
1432  fHistoMCEtaPtJetPt[iCut]->Sumw2();
1433  fMCList[iCut]->Add(fHistoMCEtaPtJetPt[iCut]);
1434  }
1435  }
1436 
1437  fHistoMCPrimaryPtvsSource[iCut] = new TH2F("MC_Primary_Pt_Source", "MC_Primary_Pt_Source", nBinsPt, arrPtBinning, 10, -0.5, 9.5);
1438  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(1,"Pi+");
1439  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(2,"Pi-");
1440  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(3,"K+");
1441  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(4,"K-");
1442  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(5,"K0s");
1443  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(6,"K0l");
1444  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(7,"Lambda");
1445  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(8,"Omega");
1446  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(9,"Phi");
1447  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(10,"Rho0");
1448  fMCList[iCut]->Add(fHistoMCPrimaryPtvsSource[iCut]);
1449  fHistoMCSecPi0Source[iCut] = new TH1F("MC_SecPi0_Source", "MC_SecPi0_Source", 5000, 0., 5000);
1450  fMCList[iCut]->Add(fHistoMCSecPi0Source[iCut]);
1451  fHistoMCSecEtaSource[iCut] = new TH1F("MC_SecEta_Source", "MC_SecEta_Source", 5000, 0, 5000);
1452  fMCList[iCut]->Add(fHistoMCSecEtaSource[iCut]);
1453  fHistoMCSecPi0PtvsSource[iCut] = new TH2F("MC_SecPi0_Pt_Source", "MC_SecPi0_Pt_Source", nBinsPt, arrPtBinning, 16, -0.5, 15.5);
1454  fMCList[iCut]->Add(fHistoMCSecPi0PtvsSource[iCut]);
1455  fHistoMCSecPi0InAccPtvsSource[iCut] = new TH2F("MC_SecPi0InAcc_Pt_Source", "MC_SecPi0InAcc_Pt_Source", nBinsPt, arrPtBinning, 16, -0.5, 15.5);
1456  fMCList[iCut]->Add(fHistoMCSecPi0InAccPtvsSource[iCut]);
1457  fHistoMCSecEtaPt[iCut] = new TH1F("MC_SecEta_Pt", "MC_SecEta_Pt", nBinsPt, arrPtBinning);
1458  fMCList[iCut]->Add(fHistoMCSecEtaPt[iCut]);
1459 
1460  if (fIsMC > 1){
1461  fHistoMCPrimaryPtvsSource[iCut]->Sumw2();
1462  fHistoMCSecPi0PtvsSource[iCut]->Sumw2();
1463  fHistoMCSecPi0InAccPtvsSource[iCut]->Sumw2();
1464  fHistoMCSecEtaPt[iCut]->Sumw2();
1465  }
1466 
1467  if (fDoMesonQA > 0){
1468  fHistoMCPi0PtAlpha[iCut] = new TH2F("MC_Pi0_Pt_Alpha", "MC_Pi0_Pt_Alpha", nBinsQAPt, arrQAPtBinning, 100, 0, 1);
1469  fMCList[iCut]->Add(fHistoMCPi0PtAlpha[iCut]);
1470  fHistoMCEtaPtAlpha[iCut] = new TH2F("MC_Eta_Pt_Alpha", "MC_Eta_Pt_Alpha", nBinsQAPt, arrQAPtBinning, 100, 0, 1);
1471  fMCList[iCut]->Add(fHistoMCEtaPtAlpha[iCut]);
1472 
1473  if (fIsMC < 2){
1474  fHistoMCPi0PtY[iCut] = new TH2F("MC_Pi0_Pt_Y", "MC_Pi0_Pt_Y", nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
1475  fHistoMCPi0PtY[iCut]->Sumw2();
1476  fMCList[iCut]->Add(fHistoMCPi0PtY[iCut]);
1477  fHistoMCEtaPtY[iCut] = new TH2F("MC_Eta_Pt_Y", "MC_Eta_Pt_Y", nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
1478  fHistoMCEtaPtY[iCut]->Sumw2();
1479  fMCList[iCut]->Add(fHistoMCEtaPtY[iCut]);
1480  fHistoMCSecPi0RvsSource[iCut] = new TH2F("MC_SecPi0_R3D_Source", "MC_SecPi0_R3D_Source", 500, 0.0, 20., 16, -0.5, 15.5);
1481  fHistoMCSecPi0RvsSource[iCut]->Sumw2();
1482  fMCList[iCut]->Add(fHistoMCSecPi0RvsSource[iCut]);
1483  }
1484  }
1485 
1486  }
1487 
1488  fTrueList[iCut] = new TList();
1489  fTrueList[iCut]->SetName(Form("%s_%s_%s True histograms",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
1490  fTrueList[iCut]->SetOwner(kTRUE);
1491  fCutFolder[iCut]->Add(fTrueList[iCut]);
1492 
1493  fHistoTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt", "ESD_TrueConvGamma_Pt", nBinsPt, arrPtBinning);
1494  fTrueList[iCut]->Add(fHistoTrueConvGammaPt[iCut]);
1495 
1496  fHistoDoubleCountTrueConvGammaRPt[iCut] = new TH2F("ESD_TrueDoubleCountConvGamma_R_Pt", "ESD_TrueDoubleCountConvGamma_R_Pt", 800, 0, 200, nBinsQAPt, arrQAPtBinning);
1497  fTrueList[iCut]->Add(fHistoDoubleCountTrueConvGammaRPt[iCut]);
1498  fHistoMultipleCountTrueConvGamma[iCut] = new TH1F("ESD_TrueMultipleCountConvGamma", "ESD_TrueMultipleCountConvGamma", 10, 1, 11);
1499  fTrueList[iCut]->Add(fHistoMultipleCountTrueConvGamma[iCut]);
1500 
1501  fHistoCombinatorialPt[iCut] = new TH2F("ESD_TrueCombinatorial_Pt", "ESD_TrueCombinatorial_Pt", nBinsPt, arrPtBinning, 16, -0.5, 15.5);
1502  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 1,"Elec+Elec");
1503  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 2,"Elec+Pion");
1504  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 3,"Elec+Kaon");
1505  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 4,"Elec+Proton");
1506  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 5,"Elec+Muon");
1507  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 6,"Pion+Pion");
1508  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 7,"Pion+Kaon");
1509  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 8,"Pion+Proton");
1510  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 9,"Pion+Muon");
1511  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(10,"Kaon+Kaon");
1512  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(11,"Kaon+Proton");
1513  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(12,"Kaon+Muon");
1514  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(13,"Proton+Proton");
1515  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(14,"Proton+Muon");
1516  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(15,"Muon+Muon");
1517  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(16,"Rest");
1518  fTrueList[iCut]->Add(fHistoCombinatorialPt[iCut]);
1519 
1520  fHistoTruePrimaryConvGammaPt[iCut] = new TH1F("ESD_TruePrimaryConvGamma_Pt", "ESD_TruePrimaryConvGamma_Pt", nBinsPt, arrPtBinning);
1521  fTrueList[iCut]->Add(fHistoTruePrimaryConvGammaPt[iCut]);
1522  fHistoTrueSecondaryConvGammaPt[iCut] = new TH2F("ESD_TrueSecondaryConvGamma_Pt", "ESD_TrueSecondaryConvGamma_Pt", nBinsPt, arrPtBinning, 4, -0.5, 3.5);
1523  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1524  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1525  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1526  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1527  fTrueList[iCut]->Add(fHistoTrueSecondaryConvGammaPt[iCut]);
1528  fHistoTrueSecondaryConvGammaMCPt[iCut] = new TH2F("ESD_TrueSecondaryConvGamma_MCPt", "ESD_TrueSecondaryConvGamma_MCPt", nBinsPt, arrPtBinning, 4, -0.5, 3.5);
1529  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1530  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1531  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1532  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1533  fTrueList[iCut]->Add(fHistoTrueSecondaryConvGammaMCPt[iCut]);
1534 
1535  if(fDoPhotonQA == 3 && fIsMC < 2){
1536  if(fIsHeavyIon == 1){
1537  fHistoCombinatorialMothersPt[iCut] = new TH3F("ESD_TrueCombinatorialMothers_Pt", "ESD_TrueCombinatorialMothers_Pt", 6, 0, 6, 13, 0, 13, 250, 0., 25);
1538  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 1,"Elec");
1539  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 2,"Pion");
1540  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 3,"Kaon");
1541  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 4,"Proton");
1542  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 5,"Rest");
1543  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 6,"Ancestor NP");
1544  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 1,"Elec");
1545  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 2,"Pion");
1546  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 3,"Kaon");
1547  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 4,"Proton");
1548  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 5,"Pi0");
1549  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 6,"#eta");
1550  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 7,"#omega");
1551  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 8,"#phi");
1552  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 9,"#eta'");
1553  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel(10,"K0s");
1554  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel(11,"#Lambda");
1555  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel(12,"#rho^{0}, #rho^{#pm}");
1556  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel(13,"Other");
1557  fTrueList[iCut]->Add(fHistoCombinatorialMothersPt[iCut]);
1558  }
1559 
1560  fHistoCombinatorialPtDeltaPhi_ek[iCut] = new TH2F("ESD_TrueCombinatorial_Pt_DeltaPhi_ek", "ESD_TrueCombinatorial_Pt_DeltaPhi_ek", nBinsQAPt, arrQAPtBinning, 90, -0.5*TMath::Pi(), 0.5*TMath::Pi());
1561  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_ek[iCut]);
1562  fHistoCombinatorialPtDeltaPhi_ep[iCut] = new TH2F("ESD_TrueCombinatorial_Pt_DeltaPhi_ep", "ESD_TrueCombinatorial_Pt_DeltaPhi_ep", nBinsQAPt, arrQAPtBinning, 90, -0.5*TMath::Pi(), 0.5*TMath::Pi());
1563  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_ep[iCut]);
1564  fHistoCombinatorialPtDeltaPhi_epi[iCut] = new TH2F("ESD_TrueCombinatorial_Pt_DeltaPhi_epi", "ESD_TrueCombinatorial_Pt_DeltaPhi_epi", nBinsQAPt, arrQAPtBinning, 90, -0.5*TMath::Pi(), 0.5*TMath::Pi());
1565  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_epi[iCut]);
1566  fHistoCombinatorialPtDeltaPhi_pik[iCut] = new TH2F("ESD_TrueCombinatorial_Pt_DeltaPhi_pik", "ESD_TrueCombinatorial_Pt_DeltaPhi_pik", nBinsQAPt, arrQAPtBinning, 90, -0.5*TMath::Pi(), 0.5*TMath::Pi());
1567  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_pik[iCut]);
1568  fHistoCombinatorialPtDeltaPhi_pip[iCut] = new TH2F("ESD_TrueCombinatorial_Pt_DeltaPhi_pip", "ESD_TrueCombinatorial_Pt_DeltaPhi_pip", nBinsQAPt, arrQAPtBinning, 90, -0.5*TMath::Pi(), 0.5*TMath::Pi());
1569  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_pip[iCut]);
1570  }
1571 
1572  fHistoTrueDalitzPsiPairDeltaPhi[iCut] = new TH2F("ESD_TrueDalitzPsiPairDeltaPhi", "ESD_TrueDalitzPsiPairDeltaPhi", 100, -0.5, 2, 100, -0.5, 0.5);
1573  fTrueList[iCut]->Add(fHistoTrueDalitzPsiPairDeltaPhi[iCut]);
1574  fHistoTrueGammaPsiPairDeltaPhi[iCut] = new TH2F("ESD_TrueGammaPsiPairDeltaPhi", "ESD_TrueGammaPsiPairDeltaPhi", 100, -0.5, 2, 100, -0.5, 0.5);
1575  fTrueList[iCut]->Add(fHistoTrueGammaPsiPairDeltaPhi[iCut]);
1576 
1577  fHistoTruePrimaryConvGammaESDPtMCPt[iCut] = new TH2F("ESD_TruePrimaryConvGammaESD_PtMCPt", "ESD_TruePrimaryConvGammaESD_PtMCPt",
1578  nBinsPt, arrPtBinning, nBinsPt, arrPtBinning);
1580 
1581 
1582  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromK0sESD_MCPtPt", "ESD_TrueSecondaryConvGammaFromXFromK0sESD_MCPtPt",
1583  nBinsPt, arrPtBinning, nBinsPt, arrPtBinning);
1585  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromK0lESD_MCPtPt", "ESD_TrueSecondaryConvGammaFromXFromK0lESD_MCPtPt",
1586  nBinsPt, arrPtBinning, nBinsPt, arrPtBinning);
1588  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromLambdaESD_MCPtPt", "ESD_TrueSecondaryConvGammaFromXFromLambdaESD_MCPtPt",
1589  nBinsPt, arrPtBinning, nBinsPt, arrPtBinning);
1591 
1592 
1594  fHistoTrueConvGammaPt[iCut]->Sumw2();
1595  fHistoDoubleCountTrueConvGammaRPt[iCut]->Sumw2();
1596  fHistoMultipleCountTrueConvGamma[iCut]->Sumw2();
1597  fHistoCombinatorialPt[iCut]->Sumw2();
1598  fHistoTruePrimaryConvGammaPt[iCut]->Sumw2();
1599  fHistoTrueSecondaryConvGammaPt[iCut]->Sumw2();
1600  fHistoTrueSecondaryConvGammaMCPt[iCut]->Sumw2();
1601  fHistoTruePrimaryConvGammaESDPtMCPt[iCut]->Sumw2();
1605  fHistoTrueDalitzPsiPairDeltaPhi[iCut]->Sumw2();
1606  fHistoTrueGammaPsiPairDeltaPhi[iCut]->Sumw2();
1607  }
1608 
1609  if (fDoPhotonQA > 0 ){
1610  if (fIsMC < 2){
1611  fHistoTrueConvGammaPsiPairPt[iCut] = new TH2F("ESD_TrueConvGamma_PsiPair_Pt", "ESD_TrueConvGamma_PsiPair_Pt", 500, 0, 5, nBinsPt, arrPtBinning);
1612  fTrueList[iCut]->Add(fHistoTrueConvGammaPsiPairPt[iCut]);
1613  fHistoTrueConvGammaEta[iCut] = new TH1F("ESD_TrueConvGamma_Eta", "ESD_TrueConvGamma_Eta", 1000, -2, 2);
1614  fTrueList[iCut]->Add(fHistoTrueConvGammaEta[iCut]);
1615  fHistoTrueConvGammaR[iCut] = new TH1F("ESD_TrueConvGamma_R", "ESD_TrueConvGamma_R", 800, 0, 200);
1616  fTrueList[iCut]->Add(fHistoTrueConvGammaR[iCut]);
1617  fHistoTrueConvGammaRMC[iCut] = new TH1F("ESD_TrueConvGamma_RMC", "ESD_TrueConvGamma_RMC", 800, 0, 200);
1618  fTrueList[iCut]->Add(fHistoTrueConvGammaRMC[iCut]);
1619  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
1620  fHistoTrueConvGammaInvMass[iCut] = new TH1F("ESD_TrueConvGamma_InvMass", "ESD_TrueConvGamma_InvMass", 500, 0., 5.);
1621  fTrueList[iCut]->Add(fHistoTrueConvGammaInvMass[iCut]);
1622  fHistoTrueConvGammaInvMassReco[iCut] = new TH1F("ESD_TrueConvGamma_InvMassReco", "ESD_TrueConvGamma_InvMassReco", 500, 0., 5.);
1623  fTrueList[iCut]->Add(fHistoTrueConvGammaInvMassReco[iCut]);
1624  }
1625  }
1626  fHistoTrueConvGammaPtMC[iCut] = new TH1F("ESD_TrueConvGamma_PtMC", "ESD_TrueConvGamma_PtMC", nBinsPt, arrPtBinning);
1627  fTrueList[iCut]->Add(fHistoTrueConvGammaPtMC[iCut]);
1629  fHistoTrueConvGammaPtMC[iCut]->Sumw2();
1630 
1631  }
1632 
1633  if(fDoMesonAnalysis){
1634  fHistoTrueMotherInvMassPt[iCut] = new TH2F("ESD_TrueMother_InvMass_Pt", "ESD_TrueMother_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1635  fTrueList[iCut]->Add(fHistoTrueMotherInvMassPt[iCut]);
1636  fHistoDoubleCountTruePi0InvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountPi0_InvMass_Pt", "ESD_TrueDoubleCountPi0_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1637  fTrueList[iCut]->Add(fHistoDoubleCountTruePi0InvMassPt[iCut]);
1638  fHistoMultipleCountTruePi0[iCut] = new TH1F("ESD_TrueMultipleCountPi0", "ESD_TrueMultipleCountPi0", 10, 1, 11);
1639  fTrueList[iCut]->Add(fHistoMultipleCountTruePi0[iCut]);
1640  fHistoDoubleCountTrueEtaInvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountEta_InvMass_Pt", "ESD_TrueDoubleCountEta_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1641  fTrueList[iCut]->Add(fHistoDoubleCountTrueEtaInvMassPt[iCut]);
1642  fHistoMultipleCountTrueEta[iCut] = new TH1F("ESD_TrueMultipleCountEta", "ESD_TrueMultipleCountEta", 10, 1, 11);
1643  fTrueList[iCut]->Add(fHistoMultipleCountTrueEta[iCut]);
1644  fHistoTruePrimaryMotherInvMassPt[iCut] = new TH2F("ESD_TruePrimaryMother_InvMass_Pt", "ESD_TruePrimaryMother_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1645  fHistoTruePrimaryMotherInvMassPt[iCut]->Sumw2();
1646  fTrueList[iCut]->Add(fHistoTruePrimaryMotherInvMassPt[iCut]);
1647  fHistoTruePrimaryMotherW0WeightingInvMassPt[iCut] = new TH2F("ESD_TruePrimaryMotherW0Weights_InvMass_Pt", "ESD_TruePrimaryMotherW0Weights_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1650  pESDTruePrimaryMotherWeightsInvMassPt[iCut] = new TProfile2D("ESD_TruePrimaryMotherWeights_InvMass_Pt", "ESD_TruePrimaryMotherWeights_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1653  fHistoTrueSecondaryMotherInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMother_InvMass_Pt", "ESD_TrueSecondaryMother_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1654  fHistoTrueSecondaryMotherInvMassPt[iCut]->Sumw2();
1656  fHistoTrueSecondaryMotherFromK0sInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromK0s_InvMass_Pt", "ESD_TrueSecondaryMotherFromK0s_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1659  fHistoTrueSecondaryMotherFromK0lInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromK0l_InvMass_Pt", "ESD_TrueSecondaryMotherFromK0l_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1662  fHistoTrueSecondaryMotherFromEtaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromEta_InvMass_Pt", "ESD_TrueSecondaryMotherFromEta_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1665  fHistoTrueSecondaryMotherFromLambdaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromLambda_InvMass_Pt", "ESD_TrueSecondaryMotherFromLambda_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1668 
1669  if(fIsMC < 2){
1670  fHistoTrueMotherDalitzInvMassPt[iCut] = new TH2F("ESD_TrueDalitz_InvMass_Pt", "ESD_TrueDalitz_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1671  fTrueList[iCut]->Add(fHistoTrueMotherDalitzInvMassPt[iCut]);
1672  }
1673 
1674  if (fIsMC > 1){
1675  fHistoTrueMotherInvMassPt[iCut]->Sumw2();
1676  fHistoDoubleCountTruePi0InvMassPt[iCut]->Sumw2();
1677  fHistoMultipleCountTruePi0[iCut]->Sumw2();
1678 
1679  fHistoDoubleCountTrueEtaInvMassPt[iCut]->Sumw2();
1680  fHistoMultipleCountTrueEta[iCut]->Sumw2();
1681  }
1682 
1683  if (fDoMesonQA > 0){
1684  if (fIsMC < 2){
1685  fHistoTruePrimaryPi0MCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryPi0_MCPt_ResolPt", "ESD_TruePrimaryPi0_ResolPt_MCPt", nBinsPt, arrPtBinning, 1000, -1., 1.);
1686  fHistoTruePrimaryPi0MCPtResolPt[iCut]->Sumw2();
1687  fTrueList[iCut]->Add(fHistoTruePrimaryPi0MCPtResolPt[iCut]);
1688  fHistoTruePrimaryEtaMCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryEta_MCPt_ResolPt", "ESD_TruePrimaryEta_ResolPt_MCPt", nBinsPt, arrPtBinning, 1000, -1., 1.);
1689  fHistoTruePrimaryEtaMCPtResolPt[iCut]->Sumw2();
1690  fTrueList[iCut]->Add(fHistoTruePrimaryEtaMCPtResolPt[iCut]);
1691  fHistoTrueBckGGInvMassPt[iCut] = new TH2F("ESD_TrueBckGG_InvMass_Pt", "ESD_TrueBckGG_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1692  fTrueList[iCut]->Add(fHistoTrueBckGGInvMassPt[iCut]);
1693  fHistoTrueBckContInvMassPt[iCut] = new TH2F("ESD_TrueBckCont_InvMass_Pt", "ESD_TrueBckCont_InvMass_Pt", 800, 0, 0.8, nBinsPt, arrPtBinning);
1694  fTrueList[iCut]->Add(fHistoTrueBckContInvMassPt[iCut]);
1695  fHistoTrueK0sWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueK0sWithPi0Daughter_MCPt", "ESD_TrueK0sWithPi0Daughter_MCPt", nBinsPt, arrPtBinning);
1696  fTrueList[iCut]->Add(fHistoTrueK0sWithPi0DaughterMCPt[iCut]);
1697  fHistoTrueK0lWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueK0lWithPi0Daughter_MCPt", "ESD_TrueK0lWithPi0Daughter_MCPt", nBinsPt, arrPtBinning);
1698  fTrueList[iCut]->Add(fHistoTrueK0lWithPi0DaughterMCPt[iCut]);
1699  fHistoTrueEtaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueEtaWithPi0Daughter_MCPt", "ESD_TrueEtaWithPi0Daughter_MCPt", nBinsPt, arrPtBinning);
1700  fTrueList[iCut]->Add(fHistoTrueEtaWithPi0DaughterMCPt[iCut]);
1701  fHistoTrueLambdaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueLambdaWithPi0Daughter_MCPt", "ESD_TrueLambdaWithPi0Daughter_MCPt", nBinsPt, arrPtBinning);
1703 
1704  fHistoTruePi0PtY[iCut] = new TH2F("ESD_TruePi0_Pt_Y", "ESD_TruePi0_Pt_Y", nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
1705  fTrueList[iCut]->Add(fHistoTruePi0PtY[iCut]);
1706  fHistoTrueEtaPtY[iCut] = new TH2F("ESD_TrueEta_Pt_Y", "ESD_TrueEta_Pt_Y", nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
1707  fTrueList[iCut]->Add(fHistoTrueEtaPtY[iCut]);
1708  fHistoTruePi0PtOpenAngle[iCut] = new TH2F("ESD_TruePi0_Pt_OpenAngle", "ESD_TruePi0_Pt_OpenAngle", nBinsQAPt, arrQAPtBinning, 200, 0, 2*TMath::Pi());
1709  fTrueList[iCut]->Add(fHistoTruePi0PtOpenAngle[iCut]);
1710  fHistoTrueEtaPtOpenAngle[iCut] = new TH2F("ESD_TrueEta_Pt_OpenAngle", "ESD_TrueEta_Pt_OpenAngle", nBinsQAPt, arrQAPtBinning, 200, 0, 2*TMath::Pi());
1711  fTrueList[iCut]->Add(fHistoTrueEtaPtOpenAngle[iCut]);
1712  }
1713 
1714  fHistoTruePi0PtAlpha[iCut] = new TH2F("ESD_TruePi0_Pt_Alpha", "ESD_TruePi0_Pt_Alpha", nBinsQAPt, arrQAPtBinning, 100, 0, 1);
1715  fTrueList[iCut]->Add(fHistoTruePi0PtAlpha[iCut]);
1716  fHistoTrueEtaPtAlpha[iCut] = new TH2F("ESD_TrueEta_Pt_Alpha", "ESD_TrueEta_Pt_Alpha", nBinsQAPt, arrQAPtBinning, 100, 0, 1);
1717  fTrueList[iCut]->Add(fHistoTrueEtaPtAlpha[iCut]);
1718 
1719  }
1720  }
1721  }
1722  }
1723 
1724  vecDoubleCountTruePi0s.clear();
1725  vecDoubleCountTrueEtas.clear();
1727 
1728  mapMultipleCountTruePi0s.clear();
1729  mapMultipleCountTrueEtas.clear();
1731 
1732  if(fV0Reader)
1734  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms())
1735  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
1736 
1737  if(fV0Reader)
1739  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
1740  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
1741 
1745 
1747 
1748  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1749  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))) continue;
1750  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms()){
1751  fCutFolder[iCut]->Add(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
1752  }
1753  if(!((AliConversionPhotonCuts*)fCutArray->At(iCut))) continue;
1754  if(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms()){
1755  fCutFolder[iCut]->Add(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms());
1756  }
1757  if(fDoMesonAnalysis){
1758  if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
1759  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
1760  fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
1761  }
1762  }
1764  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
1765  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms()){
1766  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms());
1767  }
1768  }
1769 
1770  }
1771  if (fIsMC > 0){
1772  tBrokenFiles = new TTree("BrokenFiles", "BrokenFiles");
1773  tBrokenFiles->Branch("fileName",&fFileNameBroken);
1775  }
1776  OpenFile(1);
1777  PostData(1, fOutputContainer);
1778  Int_t nContainerOutput = 2;
1779  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1780  if((fDoPhotonQA == 2)||(fDoPhotonQA == 5)){
1781  OpenFile(nContainerOutput);
1782  PostData(nContainerOutput, tESDConvGammaPtDcazCat[iCut]);
1783  nContainerOutput++;
1784  }
1785  if(fDoMesonQA == 2){
1786  OpenFile(nContainerOutput);
1787  PostData(nContainerOutput, tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]);
1788  nContainerOutput++;
1789  }
1790  }
1791 
1792 }
1793 //_____________________________________________________________________________
1795 {
1796  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1797  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
1798  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
1799  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
1800  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
1801  }
1802 
1803  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift()){
1804  fHistoEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1805  continue; // No Eta Shift requested, continue
1806  }
1807  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
1808  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
1809  fHistoEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1810  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1811  continue;
1812  }
1813  else{
1814  printf(" Gamma Conversion Task %s :: Eta Shift Manually Set to %f \n\n",
1815  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
1816  fHistoEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1817  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1818  }
1819  }
1820  return kTRUE;
1821 }
1822 //_____________________________________________________________________________
1824 {
1825  //
1826  // Called for each event
1827  //
1828  fInputEvent = InputEvent();
1829 
1830  // Set MC events
1831  if(fIsMC>0) fMCEvent = MCEvent();
1832 
1833  //calculating the weight for the centrality flattening
1834  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1835  if(fDoCentralityFlat > 0){
1836  fWeightCentrality[iCut] = 1.;
1837  fWeightCentrality[iCut] = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetWeightForCentralityFlattening(fInputEvent);
1838  }
1839  }
1840 
1841  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
1842  if(fInputEvent->IsIncompleteDAQ()==kTRUE) eventQuality = 2; // incomplete event
1843  // Event Not Accepted due to MC event missing or because it is incomplere or wrong trigger for V0ReaderV1 => skip broken events/files
1844  if(eventQuality == 2 || eventQuality == 3){
1845  // write out name of broken file for first event
1846  if (fIsMC > 0){
1847  if (fInputEvent->IsA()==AliESDEvent::Class()){
1848  if (((AliESDEvent*)fInputEvent)->GetEventNumberInFile() == 0){
1849  fFileNameBroken = new TObjString(Form("%s",((TString)fV0Reader->GetCurrentFileName()).Data()));
1850  if (tBrokenFiles) tBrokenFiles->Fill();
1851  delete fFileNameBroken;
1852  }
1853  }
1854  }
1855 
1856  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1857  fHistoNEvents[iCut]->Fill(eventQuality);
1858  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
1859  if( fDoCentralityFlat > 0) fHistoNEventsWeighted[iCut]->Fill(eventQuality, fWeightCentrality[iCut]);
1860  }
1861  return;
1862  }
1863 
1864  fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
1865 
1866  // ------------------- BeginEvent ----------------------------
1867 
1868  AliEventplane *EventPlane = fInputEvent->GetEventplane();
1869  if(fIsHeavyIon ==1)fEventPlaneAngle = EventPlane->GetEventplane("V0",fInputEvent,2);
1870  else fEventPlaneAngle=0.0;
1871 
1872  if(fIsMC > 0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
1873  RelabelAODPhotonCandidates(kTRUE); // In case of AODMC relabeling MC
1874  fV0Reader->RelabelAODs(kTRUE);
1875  }
1876  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1877  fiCut = iCut;
1878 
1879  Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon,kFALSE);
1880 
1881  if( fIsMC == 2 ){
1882  Float_t xsection = -1.;
1883  Float_t ntrials = -1.;
1884  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetXSectionAndNTrials(fMCEvent,xsection,ntrials,fInputEvent);
1885  if((xsection==-1.) || (ntrials==-1.)) AliFatal(Form("ERROR: GetXSectionAndNTrials returned invalid xsection/ntrials, periodName from V0Reader: '%s'",fV0Reader->GetPeriodName().Data()));
1886  fProfileJetJetXSection[iCut]->Fill(0.,xsection);
1887  fhJetJetNTrials[iCut]->Fill("#sum{NTrials}",ntrials);
1888  }
1889 
1890  if( fIsMC > 0 ){
1891  fWeightJetJetMC = 1;
1892  Bool_t isMCJet = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsJetJetMCEventAccepted( fMCEvent, fWeightJetJetMC , fInputEvent);
1893  if (fIsMC == 3){
1894  Double_t weightMult = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetWeightForMultiplicity(fV0Reader->GetNumberOfPrimaryTracks());
1895  fWeightJetJetMC = fWeightJetJetMC*weightMult;
1896  }
1897 
1898  if( fIsMC == 1 ) fWeightJetJetMC = 1;
1899  if(!isMCJet){
1900  fHistoNEvents[iCut]->Fill(10,fWeightJetJetMC);
1901  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(10);
1902  continue;
1903  }
1904  }
1905 
1906  if(eventNotAccepted){
1907  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
1908  fHistoNEvents[iCut]->Fill(eventNotAccepted,fWeightJetJetMC); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
1909  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(eventNotAccepted);
1910  if(fDoCentralityFlat > 0) fHistoNEventsWeighted[iCut]->Fill(eventNotAccepted, fWeightCentrality[iCut]*fWeightJetJetMC);
1911  continue;
1912  }
1913 
1914  if(eventQuality != 0){// Event Not Accepted
1915  // cout << "event rejected due to: " <<eventQuality << endl;
1916  fHistoNEvents[iCut]->Fill(eventQuality,fWeightJetJetMC);
1917  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
1918  if(fDoCentralityFlat > 0) fHistoNEventsWeighted[iCut]->Fill(eventQuality, fWeightCentrality[iCut]*fWeightJetJetMC);
1919  continue;
1920  }
1921 
1922  fHistoNEvents[iCut]->Fill(eventQuality,fWeightJetJetMC); // Should be 0 here
1923  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
1924  if(fDoCentralityFlat > 0) fHistoNEventsWeighted[iCut]->Fill(eventQuality, fWeightCentrality[iCut]*fWeightJetJetMC); // Should be 0 here
1925 
1928 
1929  fHistoVertexZ[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetZ(),fWeightJetJetMC);
1930  if(fDoCentralityFlat > 0) fHistoVertexZWeighted[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetZ(), fWeightCentrality[iCut]*fWeightJetJetMC);
1931 
1932  if( fIsMC < 2 ){
1933  if(fDoCentralityFlat > 0) fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)), fWeightCentrality[iCut]);
1934  else fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)));
1935  }
1936 
1937  if(fDoPlotVsCentrality) fHistoCentrality[iCut]->Fill(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCentrality(fInputEvent),fWeightJetJetMC);
1939 
1942 
1943  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2){
1944  fHistoV0MultVsNumberTPCoutTracks[iCut]->Fill(fV0Reader->GetNumberOfTPCoutTracks(), fInputEvent->GetVZEROData()->GetMTotV0A());
1945  } else {
1946  fHistoV0MultVsNumberTPCoutTracks[iCut]->Fill(fV0Reader->GetNumberOfTPCoutTracks(), fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C());
1947  }
1948 
1949  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2) fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A(),fWeightJetJetMC);
1950  else if(fDoCentralityFlat > 0){
1951  fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C(), fWeightCentrality[iCut]*fWeightJetJetMC);
1952  } else {
1953  fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C(),fWeightJetJetMC);
1954  }
1955 
1957  ProcessClusters();
1958  }
1959 
1960  if(fIsMC > 0){
1961  // Process MC Particle
1962  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
1963  if(fInputEvent->IsA()==AliESDEvent::Class()){
1964  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1965  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1966  fMCEvent);
1967  }
1968  else if(fInputEvent->IsA()==AliAODEvent::Class()){
1969  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1970  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1971  fInputEvent);
1972  }
1973 
1974  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader()){
1975  for(Int_t i = 0;i<(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader())->GetEntries();i++){
1976  if(fIsMC < 2){
1977  TString nameBin= fHistoMCHeaders[iCut]->GetXaxis()->GetBinLabel(i+1);
1978  if (nameBin.CompareTo("")== 0){
1979  TString nameHeader = ((TObjString*)((TList*)((AliConvEventCuts*)fEventCutArray->At(iCut))
1980  ->GetAcceptedHeader())->At(i))->GetString();
1981  // cout << nameHeader << endl;
1982  fHistoMCHeaders[iCut]->GetXaxis()->SetBinLabel(i+1,nameHeader.Data());
1983  }
1984  }
1985  }
1986  }
1987  }
1988  }
1989 
1990  if( fIsMC > 0 ){
1991  if(fInputEvent->IsA()==AliESDEvent::Class()) ProcessMCParticles();
1992  if(fInputEvent->IsA()==AliAODEvent::Class()) ProcessAODMCParticles();
1993  }
1994 
1995  ProcessPhotonCandidates(); // Process this cuts gammas
1996 
1997  if(fDoCentralityFlat > 0){
2000  } else {
2001  fHistoNGammaCandidates[iCut]->Fill(fGammaCandidates->GetEntries(),fWeightJetJetMC);
2003  }
2004 
2005  if(fDoMesonAnalysis){ // Meson Analysis
2006  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseMCPSmearing() && fIsMC > 0 ){
2007  fUnsmearedPx = new Double_t[fGammaCandidates->GetEntries()]; // Store unsmeared Momenta
2008  fUnsmearedPy = new Double_t[fGammaCandidates->GetEntries()];
2009  fUnsmearedPz = new Double_t[fGammaCandidates->GetEntries()];
2010  fUnsmearedE = new Double_t[fGammaCandidates->GetEntries()];
2011 
2012  for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
2013  fUnsmearedPx[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Px();
2014  fUnsmearedPy[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Py();
2015  fUnsmearedPz[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Pz();
2016  fUnsmearedE[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->E();
2017  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->SmearParticle(dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(gamma)));
2018  }
2019  }
2020 
2021  CalculatePi0Candidates(); // Combine Gammas
2022  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
2023  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
2024  CalculateBackground(); // Combinatorial Background
2025  UpdateEventByEventData(); // Store Event for mixed Events
2026  } else {
2027  CalculateBackgroundRP(); // Combinatorial Background
2028  fBGHandlerRP[iCut]->AddEvent(fGammaCandidates,fInputEvent); // Store Event for mixed Events
2029  }
2030  }
2031  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseMCPSmearing() && fIsMC > 0 ){
2032  for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
2033  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPx(fUnsmearedPx[gamma]); // Reset Unsmeared Momenta
2034  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPy(fUnsmearedPy[gamma]);
2035  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPz(fUnsmearedPz[gamma]);
2036  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetE(fUnsmearedE[gamma]);
2037  }
2038  delete[] fUnsmearedPx; fUnsmearedPx = 0x0;
2039  delete[] fUnsmearedPy; fUnsmearedPy = 0x0;
2040  delete[] fUnsmearedPz; fUnsmearedPz = 0x0;
2041  delete[] fUnsmearedE; fUnsmearedE = 0x0;
2042  }
2043 
2044  if( fIsMC > 0 ){
2045  vecDoubleCountTruePi0s.clear();
2046  vecDoubleCountTrueEtas.clear();
2049  }
2050  }
2051 
2052  if( fIsMC > 0 ){
2055  }
2056 
2057  fGammaCandidates->Clear(); // delete this cuts good gammas
2058  }
2059 
2060  if( fIsMC > 0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
2061  RelabelAODPhotonCandidates(kFALSE); // Back to ESDMC Label
2062  fV0Reader->RelabelAODs(kFALSE);
2063  }
2064 
2065  PostData(1, fOutputContainer);
2066 }
2067 //________________________________________________________________________
2069 {
2070  Int_t nV0 = 0;
2071  TList *GammaCandidatesStepOne = new TList();
2072  TList *GammaCandidatesStepTwo = new TList();
2073  // Loop over Photon Candidates allocated by ReaderV1
2074  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
2075  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
2076  if(!PhotonCandidate) continue;
2077  fIsFromSelectedHeader = kTRUE;
2078 
2079  Float_t weightMatBudgetGamma = 1.;
2080  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2081  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(PhotonCandidate);
2082  }
2083 
2084 
2085  if( fIsMC > 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2086  Int_t isPosFromMBHeader
2087  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
2088  if(isPosFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2089  Int_t isNegFromMBHeader
2090  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
2091  if(isNegFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2092 
2093  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromSelectedHeader = kFALSE;
2094  }
2095 
2096 
2097  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fInputEvent)) continue;
2098  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(PhotonCandidate->GetPhotonPhi(),fEventPlaneAngle)) continue;
2099  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
2100  !((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
2101  fGammaCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
2102 
2104  if(fDoCentralityFlat > 0) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2105  else fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightJetJetMC*weightMatBudgetGamma);
2106  if (fDoPhotonQA > 0 && fIsMC < 2){
2107  if(fDoCentralityFlat > 0){
2108  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2109  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2110  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2111  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2112  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
2113  fHistoConvGammaInvMass[fiCut]->Fill(PhotonCandidate->GetMass(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2115  }
2116  } else {
2117  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2118  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
2119  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
2120  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(),fWeightJetJetMC*weightMatBudgetGamma);
2121  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
2122  fHistoConvGammaInvMass[fiCut]->Fill(PhotonCandidate->GetMass(),fWeightJetJetMC*weightMatBudgetGamma);
2123  fHistoConvGammaInvMassReco[fiCut]->Fill(GetOriginalInvMass(PhotonCandidate,fInputEvent),fWeightJetJetMC*weightMatBudgetGamma);
2124  }
2125  }
2126  }
2127  if( fIsMC > 0 ){
2128  if(fInputEvent->IsA()==AliESDEvent::Class())
2129  ProcessTruePhotonCandidates(PhotonCandidate);
2130  if(fInputEvent->IsA()==AliAODEvent::Class())
2131  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
2132  }
2133  if ((fDoPhotonQA == 2)||(fDoPhotonQA == 5)){
2134  if (fIsHeavyIon == 1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
2135  fPtGamma = PhotonCandidate->Pt();
2136  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2137  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2138  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2139  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2140  tESDConvGammaPtDcazCat[fiCut]->Fill();
2141  } else if ( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetSingleElectronPtCut() < 0.04 && PhotonCandidate->Pt() > 0.099 && PhotonCandidate->Pt() < 16.){
2142  fPtGamma = PhotonCandidate->Pt();
2143  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2144  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2145  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2146  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2147  tESDConvGammaPtDcazCat[fiCut]->Fill();
2148  } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
2149  fPtGamma = PhotonCandidate->Pt();
2150  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2151  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2152  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2153  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2154  tESDConvGammaPtDcazCat[fiCut]->Fill();
2155  }
2156  }
2157  }
2158  } else if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
2159  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
2160  nV0++;
2161  GammaCandidatesStepOne->Add(PhotonCandidate);
2162  } else if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
2163  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
2164  GammaCandidatesStepTwo->Add(PhotonCandidate);
2165  }
2166  }
2167  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){
2168  for(Int_t i = 0;i<GammaCandidatesStepOne->GetEntries();i++){
2169  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GammaCandidatesStepOne->At(i);
2170  if(!PhotonCandidate) continue;
2171  fIsFromSelectedHeader = kTRUE;
2172 
2173  Float_t weightMatBudgetGamma = 1.;
2174  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2175  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(PhotonCandidate);
2176  }
2177 
2178 
2179  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2180  Int_t isPosFromMBHeader
2181  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
2182  Int_t isNegFromMBHeader
2183  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
2184  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromSelectedHeader = kFALSE;
2185  }
2186  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GammaCandidatesStepOne->GetEntries())) continue;
2187  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
2188  fGammaCandidates->Add(PhotonCandidate);
2189 
2191  if(fDoCentralityFlat > 0) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2192  else fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2193  if (fDoPhotonQA > 0 && fIsMC < 2){
2194  if(fDoCentralityFlat > 0){
2195  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2196  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2197  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2198  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2199  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
2200  fHistoConvGammaInvMass[fiCut]->Fill(PhotonCandidate->GetMass(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2202  }
2203  } else {
2204  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2205  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
2206  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
2207  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(),fWeightJetJetMC*weightMatBudgetGamma);
2208  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
2209  fHistoConvGammaInvMass[fiCut]->Fill(PhotonCandidate->GetMass(),fWeightJetJetMC*weightMatBudgetGamma);
2210  fHistoConvGammaInvMassReco[fiCut]->Fill(GetOriginalInvMass(PhotonCandidate,fInputEvent),fWeightJetJetMC*weightMatBudgetGamma);
2211  }
2212  }
2213  }
2214  if( fIsMC > 0 ){
2215  if(fInputEvent->IsA()==AliESDEvent::Class())
2216  ProcessTruePhotonCandidates(PhotonCandidate);
2217  if(fInputEvent->IsA()==AliAODEvent::Class())
2218  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
2219  }
2220  if ((fDoPhotonQA == 2)||(fDoPhotonQA == 5)){
2221  if (fIsHeavyIon ==1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
2222  fPtGamma = PhotonCandidate->Pt();
2223  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2224  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2225  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2226  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2227  tESDConvGammaPtDcazCat[fiCut]->Fill();
2228  } else if ( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetSingleElectronPtCut() < 0.04 && PhotonCandidate->Pt() > 0.099 && PhotonCandidate->Pt() < 16.){
2229  fPtGamma = PhotonCandidate->Pt();
2230  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2231  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2232  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2233  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2234  tESDConvGammaPtDcazCat[fiCut]->Fill();
2235  } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
2236  fPtGamma = PhotonCandidate->Pt();
2237  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2238  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2239  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2240  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2241  tESDConvGammaPtDcazCat[fiCut]->Fill();
2242  }
2243  }
2244  }
2245  } else GammaCandidatesStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
2246  }
2247  }
2248  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
2249  for(Int_t i = 0;i<GammaCandidatesStepTwo->GetEntries();i++){
2250  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GammaCandidatesStepTwo->At(i);
2251  if(!PhotonCandidate) continue;
2252  fIsFromSelectedHeader = kTRUE;
2253 
2254  Float_t weightMatBudgetGamma = 1.;
2255  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2256  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(PhotonCandidate);
2257  }
2258 
2259  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2260  Int_t isPosFromMBHeader
2261  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
2262  Int_t isNegFromMBHeader
2263  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
2264  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromSelectedHeader = kFALSE;
2265  }
2266  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GammaCandidatesStepTwo,i)) continue;
2267  fGammaCandidates->Add(PhotonCandidate); // Add gamma to current cut TList
2268 
2270  if(fDoCentralityFlat > 0) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2271  else fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2272  if (fDoPhotonQA > 0 && fIsMC < 2 ){
2273  if(fDoCentralityFlat > 0){
2274  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2275  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2276  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2277  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2278  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
2279  fHistoConvGammaInvMass[fiCut]->Fill(PhotonCandidate->GetMass(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2281  }
2282  } else {
2283  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2284  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
2285  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
2286  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(),fWeightJetJetMC*weightMatBudgetGamma);
2287  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
2288  fHistoConvGammaInvMass[fiCut]->Fill(PhotonCandidate->GetMass(),fWeightJetJetMC*weightMatBudgetGamma);
2289  fHistoConvGammaInvMassReco[fiCut]->Fill(GetOriginalInvMass(PhotonCandidate,fInputEvent),fWeightJetJetMC*weightMatBudgetGamma);
2290  }
2291  }
2292  }
2293  if( fIsMC > 0 ){
2294  if(fInputEvent->IsA()==AliESDEvent::Class())
2295  ProcessTruePhotonCandidates(PhotonCandidate);
2296  if(fInputEvent->IsA()==AliAODEvent::Class())
2297  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
2298  }
2299  if ((fDoPhotonQA == 2)||(fDoPhotonQA == 5)){
2300  if (fIsHeavyIon == 1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
2301  fPtGamma = PhotonCandidate->Pt();
2302  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2303  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2304  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2305  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2306  tESDConvGammaPtDcazCat[fiCut]->Fill();
2307  } else if ( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetSingleElectronPtCut() < 0.04 && PhotonCandidate->Pt() > 0.099 && PhotonCandidate->Pt() < 16.){
2308  fPtGamma = PhotonCandidate->Pt();
2309  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2310  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2311  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2312  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2313  tESDConvGammaPtDcazCat[fiCut]->Fill();
2314  } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
2315  fPtGamma = PhotonCandidate->Pt();
2316  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2317  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2318  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2319  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2320  tESDConvGammaPtDcazCat[fiCut]->Fill();
2321  }
2322  }
2323  }
2324  }
2325  }
2326 
2327  delete GammaCandidatesStepOne;
2328  GammaCandidatesStepOne = 0x0;
2329  delete GammaCandidatesStepTwo;
2330  GammaCandidatesStepTwo = 0x0;
2331 
2332 }
2333 //________________________________________________________________________
2335 {
2336  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2337  Double_t mcProdVtxX = primVtxMC->GetX();
2338  Double_t mcProdVtxY = primVtxMC->GetY();
2339  Double_t mcProdVtxZ = primVtxMC->GetZ();
2340 
2341  Double_t magField = fInputEvent->GetMagneticField();
2342  if( magField < 0.0 ){
2343  magField = 1.0;
2344  }
2345  else {
2346  magField = -1.0;
2347  }
2348 
2349  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2350  if (AODMCTrackArray != NULL && TruePhotonCandidate != NULL){
2351 
2352  AliAODMCParticle *posDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelPositive());
2353  AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelNegative());
2354  iPhotonMCInfo = 0;
2355 
2356  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
2357  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
2358 
2359  Double_t PhiParticle[2] = {posDaughter->Phi(),negDaughter->Phi()};
2360 
2361  if(posDaughter->GetMother() != negDaughter->GetMother()){
2362  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
2363  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
2364  if(posDaughter->GetMother() > -1){ //contamination is not a primary
2365  AliAODMCParticle *Mom = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
2366  if(Mom->GetMother() == -1){
2367  FillPhotonCombinatorialMothersHistAOD(posDaughter,Mom);
2368  } else {
2369  AliAODMCParticle *GranMom = (AliAODMCParticle*) AODMCTrackArray->At(Mom->GetMother());
2370  if(GranMom->GetMother() == -1){
2371  FillPhotonCombinatorialMothersHistAOD(posDaughter,GranMom);
2372  } else {
2373  AliAODMCParticle *GranGranMom = (AliAODMCParticle*) AODMCTrackArray->At(GranMom->GetMother());
2374  if(GranGranMom->GetMother() == -1){
2375  FillPhotonCombinatorialMothersHistAOD(posDaughter,GranGranMom);
2376  } else FillPhotonCombinatorialMothersHistAOD(posDaughter,GranGranMom);
2377  }
2378  }
2379  }
2380  if(negDaughter->GetMother() > -1){ //contamination is not a primary
2381  AliAODMCParticle *Mom = (AliAODMCParticle*) AODMCTrackArray->At(negDaughter->GetMother());
2382  if(Mom->GetMother() == -1){
2383  FillPhotonCombinatorialMothersHistAOD(negDaughter,Mom);
2384  } else {
2385  AliAODMCParticle *GranMom = (AliAODMCParticle*) AODMCTrackArray->At(Mom->GetMother());
2386  if(GranMom->GetMother() == -1){
2387  FillPhotonCombinatorialMothersHistAOD(negDaughter,GranMom);
2388  } else {
2389  AliAODMCParticle *GranGranMom = (AliAODMCParticle*) AODMCTrackArray->At(GranMom->GetMother());
2390  if(GranGranMom->GetMother() == -1){
2391  FillPhotonCombinatorialMothersHistAOD(negDaughter,GranGranMom);
2392  } else FillPhotonCombinatorialMothersHistAOD(posDaughter,GranGranMom);
2393  }
2394  }
2395  }
2396  }
2397  iPhotonMCInfo = 1;
2398  return;
2399  }
2400  else if(posDaughter->GetMother() == -1){
2401  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
2402  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
2403  FillPhotonCombinatorialMothersHistAOD(posDaughter,posDaughter);
2404  FillPhotonCombinatorialMothersHistAOD(negDaughter,negDaughter);
2405  }
2406  iPhotonMCInfo = 1;
2407  return;
2408  }
2409 
2410  if(pdgCode[0]!=11 || pdgCode[1]!=11){
2411  iPhotonMCInfo = 1;
2412  return; //One Particle is not a electron
2413  }
2414  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()){
2415  iPhotonMCInfo = 1;
2416  return; // Same Charge
2417  }
2418 
2419  AliAODMCParticle *Photon = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
2420  AliVTrack * electronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelNegative() );
2421  AliVTrack * positronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelPositive() );
2422  Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->Phi()-positronCandidate->Phi());
2423 
2424  if(Photon->GetPdgCode() != 22){
2425  fHistoTrueDalitzPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC);
2426  iPhotonMCInfo = 1;
2427  return; // Mother is no Photon
2428  }
2429 
2430  if(((posDaughter->GetMCProcessCode())) != 5 || ((negDaughter->GetMCProcessCode())) != 5){
2431  iPhotonMCInfo = 1;
2432  return;// check if the daughters come from a conversion
2433  }
2434  // STILL A BUG IN ALIROOT >>8 HAS TPO BE REMOVED AFTER FIX
2435 
2436  Double_t rConv=0.;
2437  rConv = sqrt( (posDaughter->Xv()*posDaughter->Xv()) + (posDaughter->Yv()*posDaughter->Yv()) );
2438 
2439  // True Photon
2440 
2441  Float_t weightMatBudgetGamma = 1.;
2442  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2443  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TruePhotonCandidate);
2444  }
2445 
2446  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2447  if (CheckVectorForDoubleCount(vecDoubleCountTrueConvGammas,posDaughter->GetMother())){
2448  fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2449  FillMultipleCountMap(mapMultipleCountTrueConvGammas,posDaughter->GetMother());
2450  }
2451  if (fDoPhotonQA > 0 ){
2452  if (fIsMC < 2){
2453  fHistoTrueConvGammaPsiPairPt[fiCut]->Fill(TruePhotonCandidate->GetPsiPair(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2454  fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
2455  fHistoTrueConvGammaR[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
2456  fHistoTrueConvGammaRMC[fiCut]->Fill(rConv,fWeightJetJetMC*weightMatBudgetGamma);
2457  }
2458  fHistoTrueConvGammaPtMC[fiCut]->Fill(Photon->Pt(), fWeightJetJetMC*weightMatBudgetGamma);
2459  }
2460  fHistoTrueGammaPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC*weightMatBudgetGamma);
2461 
2462  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2463  if(isPrimary){
2464  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
2465  iPhotonMCInfo = 6;
2466  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2467  fHistoTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(),fWeightJetJetMC*weightMatBudgetGamma); // Allways Filled
2468  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
2469  } else {
2470  iPhotonMCInfo = 2;
2471  if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 && ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetMother() > -1 ){
2472  if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 310){
2473  iPhotonMCInfo = 4;
2474  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
2475  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
2476  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2477  } else if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 130) {
2478  iPhotonMCInfo = 7;
2479  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
2480  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
2481  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2482  } else if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 3122) {
2483  iPhotonMCInfo = 5;
2484  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
2485  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
2486  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2487  } else if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 221) {
2488  iPhotonMCInfo = 3;
2489  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2490  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2491  } else {
2492  // if ( !(TMath::Abs(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetPdgCode()) == 11 && ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 22) ) {
2493  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2494  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2495  // }
2496  }
2497  }
2498  }
2499  }
2500  return;
2501 }
2502 //________________________________________________________________________
2504 {
2505 
2506  Double_t magField = fInputEvent->GetMagneticField();
2507  if( magField < 0.0 ){
2508  magField = 1.0;
2509  }
2510  else {
2511  magField = -1.0;
2512  }
2513 
2514  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2515  Double_t mcProdVtxX = primVtxMC->GetX();
2516  Double_t mcProdVtxY = primVtxMC->GetY();
2517  Double_t mcProdVtxZ = primVtxMC->GetZ();
2518 
2519  // Process True Photons
2520  TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCEvent);
2521  TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCEvent);
2522 
2523  iPhotonMCInfo = 0;
2524 
2525  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
2526  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
2527 
2528  Double_t PhiParticle[2] = {posDaughter->Phi(),negDaughter->Phi()};
2529 
2530  iPhotonMCInfo = 1;
2531  if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){
2532  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
2533  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
2534  if(posDaughter->GetMother(0) > -1){ //contamination is not a primary
2535  TParticle *Mom = fMCEvent->Particle(posDaughter->GetMother(0));
2536  if(Mom->GetMother(0) == -1){
2537  FillPhotonCombinatorialMothersHistESD(posDaughter,Mom);
2538  } else {
2539  TParticle *GranMom = fMCEvent->Particle(Mom->GetMother(0));
2540  if(GranMom->GetMother(0) == -1){
2541  FillPhotonCombinatorialMothersHistESD(posDaughter,GranMom);
2542  } else {
2543  TParticle *GranGranMom = fMCEvent->Particle(GranMom->GetMother(0));
2544  if(GranGranMom->GetMother(0) == -1){
2545  FillPhotonCombinatorialMothersHistESD(posDaughter,GranGranMom);
2546  } else FillPhotonCombinatorialMothersHistESD(posDaughter,GranGranMom);
2547  }
2548  }
2549  }
2550  if(negDaughter->GetMother(0) > -1){ //contamination is not a primary
2551  TParticle *Mom = fMCEvent->Particle(negDaughter->GetMother(0));
2552  if(Mom->GetMother(0) == -1){
2553  FillPhotonCombinatorialMothersHistESD(negDaughter,Mom);
2554  } else {
2555  TParticle *GranMom = fMCEvent->Particle(Mom->GetMother(0));
2556  if(GranMom->GetMother(0) == -1){
2557  FillPhotonCombinatorialMothersHistESD(negDaughter,GranMom);
2558  } else {
2559  TParticle *GranGranMom = fMCEvent->Particle(GranMom->GetMother(0));
2560  if(GranGranMom->GetMother(0) == -1){
2561  FillPhotonCombinatorialMothersHistESD(negDaughter,GranGranMom);
2562  } else FillPhotonCombinatorialMothersHistESD(posDaughter,GranGranMom);
2563  }
2564  }
2565  }
2566  }
2567  return;
2568  } else if(posDaughter->GetMother(0) == -1){ //gamma contamination is a primary
2569  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
2570  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
2571  FillPhotonCombinatorialMothersHistESD(posDaughter,posDaughter);
2572  FillPhotonCombinatorialMothersHistESD(negDaughter,negDaughter);
2573  }
2574  return;
2575  }
2576 
2577  if(pdgCode[0]!=11 || pdgCode[1]!=11) return; //One Particle is not a electron
2578 
2579  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
2580 
2581  TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCEvent);
2582  AliVTrack * electronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelNegative() );
2583  AliVTrack * positronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelPositive() );
2584  Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->Phi()-positronCandidate->Phi());
2585 
2586  if(Photon->GetPdgCode() != 22){
2587  fHistoTrueDalitzPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC);
2588  return; // Mother is no Photon
2589  }
2590 
2591  if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
2592 
2593  // True Photon
2594  Float_t weightMatBudgetGamma = 1.;
2595  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2596  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TruePhotonCandidate);
2597  }
2598 
2599  // cout<< " AM- Material Budget weight Gamma::"<< weightMatBudgetGamma << " "<< TruePhotonCandidate->GetConversionRadius() << endl;
2600 
2601  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2602  if (CheckVectorForDoubleCount(vecDoubleCountTrueConvGammas,posDaughter->GetMother(0))){
2603  fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2604  FillMultipleCountMap(mapMultipleCountTrueConvGammas,posDaughter->GetMother(0));
2605  }
2606  if (fDoPhotonQA > 0){
2607  if (fIsMC < 2){
2608  fHistoTrueConvGammaPsiPairPt[fiCut]->Fill(TruePhotonCandidate->GetPsiPair(),TruePhotonCandidate->Pt(),weightMatBudgetGamma);
2609  fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta(),weightMatBudgetGamma);
2610  fHistoTrueConvGammaR[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),weightMatBudgetGamma);
2611  fHistoTrueConvGammaRMC[fiCut]->Fill(posDaughter->R(),weightMatBudgetGamma);
2612  if ((fDoPhotonQA == 4)||(fDoPhotonQA == 5)){
2613  fHistoTrueConvGammaInvMass[fiCut]->Fill(TruePhotonCandidate->GetMass(),weightMatBudgetGamma);
2614  fHistoTrueConvGammaInvMassReco[fiCut]->Fill(GetOriginalInvMass(TruePhotonCandidate,fInputEvent),weightMatBudgetGamma);
2615  }
2616  }
2617  fHistoTrueConvGammaPtMC[fiCut]->Fill(Photon->Pt(), fWeightJetJetMC*weightMatBudgetGamma);
2618  }
2619 
2620  fHistoTrueGammaPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC*weightMatBudgetGamma);
2621  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, posDaughter->GetMother(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
2622  // filling primary histograms
2623  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
2624  iPhotonMCInfo = 6;
2625  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2626  fHistoTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(),fWeightJetJetMC*weightMatBudgetGamma); // Allways Filled
2627  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
2628  } else {
2629  // filling secondary photon histograms
2630  iPhotonMCInfo = 2;
2631  if( Photon->GetMother(0) > -1 && fMCEvent->Particle(Photon->GetMother(0))->GetMother(0) > -1){
2632  if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
2633  iPhotonMCInfo = 4;
2634  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
2635  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
2636  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2637  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
2638  iPhotonMCInfo = 7;
2639  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
2640  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
2641  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2642  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
2643  iPhotonMCInfo = 5;
2644  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
2645  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
2646  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2647  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 221) {
2648  iPhotonMCInfo = 3;
2649  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2650  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2651  } else {
2652 // if ( !(TMath::Abs(fMCEvent->Particle(Photon->GetMother(0))->GetPdgCode()) == 11 && fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 22) ) {
2653  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2654  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2655 // }
2656  }
2657  } else {
2658  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2659  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2660  }
2661  }
2662 }
2663 //________________________________________________________________________
2665 {
2666  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2667  Double_t mcProdVtxX = primVtxMC->GetX();
2668  Double_t mcProdVtxY = primVtxMC->GetY();
2669  Double_t mcProdVtxZ = primVtxMC->GetZ();
2670 
2671  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2672 
2673  if (AODMCTrackArray){
2674  // Loop over all primary MC particle
2675  for(Int_t i = 0; i < AODMCTrackArray->GetEntriesFast(); i++) {
2676 
2677  AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
2678  if (!particle) continue;
2679 
2680  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, particle, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2681  if (isPrimary){
2682 
2683  Int_t isMCFromMBHeader = -1;
2684  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2685  isMCFromMBHeader
2686  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2687  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2688  }
2689 
2690  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
2691  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kFALSE)){
2692  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // All MC Gamma
2693  if(particle->GetMother() >-1){ // Meson Decay Gamma
2694  switch((static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother())))->GetPdgCode()){
2695  case 111: // Pi0
2696  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2697  break;
2698  case 113: // Rho0
2699  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2700  break;
2701  case 221: // Eta
2702  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2703  break;
2704  case 223: // Omega
2705  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2706  break;
2707  case 331: // Eta'
2708  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2709  break;
2710  case 333: // Phi
2711  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2712  break;
2713  case 3212: // Sigma
2714  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2715  break;
2716  }
2717  }
2718  }
2719  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kTRUE)){
2720  Double_t rConv = 0;
2721  for(Int_t daughterIndex=particle->GetDaughter(0);daughterIndex<=particle->GetDaughter(1);daughterIndex++){
2722  AliAODMCParticle *tmpDaughter = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(daughterIndex));
2723  if(!tmpDaughter) continue;
2724  if(TMath::Abs(tmpDaughter->GetPdgCode()) == 11){
2725  rConv = sqrt( (tmpDaughter->Xv()*tmpDaughter->Xv()) + (tmpDaughter->Yv()*tmpDaughter->Yv()) );
2726  }
2727  }
2728  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2729  if ( fDoPhotonQA > 0 && fIsMC < 2){
2731  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta(),fWeightJetJetMC);
2732  }
2733  }
2734  // Converted MC Gamma
2735  if(fDoMesonAnalysis){
2736 
2737  Double_t mesonY = 1.e30;
2738  Double_t ratio = 0;
2739  if (particle->E() != TMath::Abs(particle->Pz())){
2740  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2741  }
2742  if( !(ratio <= 0) ){
2743  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2744  }
2745 
2746  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
2747  if ( particle->GetPdgCode() == 211 ){ // positve pions
2748  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2749  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2750  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2751  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2752  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
2753  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
2754  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2755  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
2756  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),4.,fWeightJetJetMC);
2757  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
2758  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),5.,fWeightJetJetMC);
2759  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
2760  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),6.,fWeightJetJetMC);
2761  } else if ( TMath::Abs(particle->GetPdgCode()) == 223 ){ // Omega
2762  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),7.,fWeightJetJetMC);
2763  } else if ( TMath::Abs(particle->GetPdgCode()) == 333 ){ // Phi
2764  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),8.,fWeightJetJetMC);
2765  } else if ( TMath::Abs(particle->GetPdgCode()) == 113 ){ // Rho0
2766  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),9.,fWeightJetJetMC);
2767  }
2768  }
2769 
2770  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2771  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
2772  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
2773  Float_t weighted= 1;
2774  if (particle->Pt()>0.005){
2775  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, 0x0, fInputEvent);
2776  // if(particle->GetPdgCode() == 221){
2777  // cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
2778  // }
2779  }
2780 
2781  Double_t mesonY = 1.e30;
2782  Double_t ratio = 0;
2783  if (particle->E() != TMath::Abs(particle->Pz())){
2784  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2785  }
2786  if( !(ratio <= 0) ){
2787  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2788  }
2789 
2790  Double_t alpha = -1;
2791  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
2792  alpha = TMath::Abs((daughter0->E() - daughter1->E()))/(daughter0->E() + daughter1->E());
2793  }
2794 
2795  if(particle->GetPdgCode() == 111){
2796  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Pi0
2797  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2798  if ( fIsMC > 1 ) fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
2799  if (fDoMesonQA > 0){
2800  if ( fIsMC < 2 )fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
2801  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
2802  if ( fIsMC == 2 ) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2803  }
2804  } else if(particle->GetPdgCode() == 221){
2805  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Eta
2806  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2807  if ( fIsMC > 1 ) fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2808  if (fDoMesonQA > 0){
2809  if ( fIsMC < 2 )fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
2810  fHistoMCEtaPtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
2811  if ( fIsMC == 2 ) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2812  }
2813  }
2814 
2815  // Check the acceptance for both gammas
2816  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
2817  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
2818  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2819  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2820 
2821  if(particle->GetPdgCode() == 111){
2822  if(fIsMC > 1) fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 with gamma in acc NOT weighted at all
2823  fHistoMCPi0WOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Pi0 with gamma in acc NOT weighted
2824  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc
2825  } else if(particle->GetPdgCode() == 221){
2826  if(fIsMC > 1) fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta with gamma in acc NOT weighted at all
2827  fHistoMCEtaWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Eta with gamma in acc NOT weighted
2828  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Eta with gamma in acc
2829  }
2830  }
2831  }
2832  }
2833  // fill secondary histograms
2834  } else {
2835  Int_t isMCFromMBHeader = -1;
2836  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2837  isMCFromMBHeader
2838  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2839  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2840  }
2841 
2842  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) {
2843  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kFALSE)){
2844  if (particle->GetMother() > -1) {
2845  AliAODMCParticle *tmpMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2846  if (tmpMother->GetMother() > -1) {
2847  AliAODMCParticle *tmpGrandMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(tmpMother->GetMother()));
2848  if(tmpGrandMother->GetPdgCode() == 310) {
2849  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2850  } else if (tmpGrandMother->GetPdgCode() == 130) {
2851  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2852  } else if (tmpGrandMother->GetPdgCode() == 3122) {
2853  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
2854  } else {
2855  if ( !(TMath::Abs(tmpMother->GetPdgCode()) == 11 && tmpGrandMother->GetPdgCode() == 22) )
2856  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2857  }
2858  } else {
2859  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2860  }
2861  } else {
2862  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2863  }
2864  }
2865 
2866  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kTRUE)){
2867  if (particle->GetMother() > -1) {
2868  AliAODMCParticle *tmpMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2869  if (tmpMother->GetMother() > -1) {
2870  AliAODMCParticle *tmpGrandMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(tmpMother->GetMother()));
2871  if(tmpGrandMother->GetPdgCode() == 310) {
2872  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2873  } else if (tmpGrandMother->GetPdgCode() == 130) {
2874  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2875  } else if (tmpGrandMother->GetPdgCode() == 3122) {
2876  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
2877  } else {
2878  if ( !(TMath::Abs(tmpMother->GetPdgCode()) == 11 && tmpGrandMother->GetPdgCode() == 22) )
2879  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2880  }
2881  } else {
2882  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2883  }
2884  } else {
2885  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2886  }
2887  }
2888  }
2889 
2890  if(fDoMesonAnalysis){
2891  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2892  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
2893  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
2894  AliAODMCParticle* mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2895  Int_t pdgCode = mother->GetPdgCode();
2896  if(particle->GetPdgCode() == 111){
2897  Int_t source = GetSourceClassification(111,pdgCode);
2898  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
2899  fHistoMCSecPi0Source[fiCut]->Fill(pdgCode);
2900  } else if(particle->GetPdgCode() == 221){
2901  fHistoMCSecEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2902  fHistoMCSecEtaSource[fiCut]->Fill(pdgCode);
2903  }
2904 
2905  // pi0 really in acceptance/
2906  if( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
2907  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
2908  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2909  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2910  if(particle->GetPdgCode() == 111){
2911  Int_t source = GetSourceClassification(111,pdgCode);
2912  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
2913  }
2914  }
2915  }
2916  }
2917  }
2918  }
2919  }
2920  return;
2921 }
2922 //________________________________________________________________________
2924 {
2925  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2926  Double_t mcProdVtxX = primVtxMC->GetX();
2927  Double_t mcProdVtxY = primVtxMC->GetY();
2928  Double_t mcProdVtxZ = primVtxMC->GetZ();
2929 // cout << mcProdVtxX <<"\t" << mcProdVtxY << "\t" << mcProdVtxZ << endl;
2930 
2931  // Loop over all primary MC particle
2932  for(Long_t i = 0; i < fMCEvent->GetNumberOfTracks(); i++) {
2933 
2934  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
2935  // fill primary histogram
2936  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
2937  if (!particle) continue;
2938 
2939  Int_t isMCFromMBHeader = -1;
2940  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2941  isMCFromMBHeader
2942  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2943  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2944  }
2945 
2946  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
2947  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
2948  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // All MC Gamma
2949  if(particle->GetMother(0) >-1){ // Meson Decay Gamma
2950  switch(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()){
2951  case 111: // Pi0
2952  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2953  break;
2954  case 113: // Rho0
2955  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2956  break;
2957  case 221: // Eta
2958  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2959  break;
2960  case 223: // Omega
2961  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2962  break;
2963  case 331: // Eta'
2964  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2965  break;
2966  case 333: // Phi
2967  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2968  break;
2969  case 3212: // Sigma
2970  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2971  break;
2972  }
2973  }
2974  }
2975  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kTRUE)){
2976  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2977  if (fDoPhotonQA > 0 && fIsMC < 2){
2978  fHistoMCConvGammaR[fiCut]->Fill(((TParticle*)fMCEvent->Particle(particle->GetFirstDaughter()))->R(),fWeightJetJetMC);
2979  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta(),fWeightJetJetMC);
2980  }
2981  } // Converted MC Gamma
2982  if(fDoMesonAnalysis){
2983 
2984  Double_t mesonY = 1.e30;
2985  Double_t ratio = 0;
2986  if (particle->Energy() != TMath::Abs(particle->Pz())){
2987  ratio = (particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz());
2988  }
2989  if( !(ratio <= 0) ){
2990  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2991  }
2992 
2993  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
2994  if ( particle->GetPdgCode() == 211 ){ // positve pions
2995  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2996  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2997  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2998  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2999  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3000  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
3001  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3002  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
3003  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),4.,fWeightJetJetMC);
3004  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
3005  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),5.,fWeightJetJetMC);
3006  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
3007  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),6.,fWeightJetJetMC);
3008  } else if ( TMath::Abs(particle->GetPdgCode()) == 223 ){ // Omega
3009  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),7.,fWeightJetJetMC);
3010  } else if ( TMath::Abs(particle->GetPdgCode()) == 333 ){ // Phi
3011  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),8.,fWeightJetJetMC);
3012  } else if ( TMath::Abs(particle->GetPdgCode()) == 113 ){ // Rho0
3013  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),9.,fWeightJetJetMC);
3014  }
3015  }
3016 
3018  ->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3019  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
3020  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
3021 
3022  Float_t weighted= 1;
3023  if (particle->Pt()>0.005){
3024  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
3025  // if(particle->GetPdgCode() == 221){
3026  // cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3027  // }
3028  }
3029  Double_t mesonY = 1.e30;
3030  Double_t ratio = 0;
3031  if (particle->Energy() != TMath::Abs(particle->Pz())){
3032  ratio = (particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz());
3033  }
3034  if( !(ratio <= 0) ){
3035  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
3036  }
3037 
3038  Double_t alpha = -1;
3039  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
3040  alpha = TMath::Abs((daughter0->Energy() - daughter1->Energy()))/(daughter0->Energy() + daughter1->Energy());
3041  }
3042 
3043  if(particle->GetPdgCode() == 111){
3044  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Pi0
3045  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3046  if (fIsMC > 1) fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
3047  if (fDoMesonQA > 0){
3048  if (fIsMC < 2)fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
3049  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
3050  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
3051  }
3052  } else if(particle->GetPdgCode() == 221){
3053  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Eta
3054  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3055  if (fIsMC > 1) fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
3056  if (fDoMesonQA > 0){
3057  if (fIsMC < 2)fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
3058  fHistoMCEtaPtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
3059  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
3060  }
3061  }
3062 
3063  // Check the acceptance for both gammas & whether they are counted as primaries as well
3064  Bool_t kDaughter0IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetFirstDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3065  Bool_t kDaughter1IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetLastDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3066 
3067  if( kDaughter0IsPrim && kDaughter1IsPrim &&
3068  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter0,fMCEvent,kFALSE) &&
3069  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter1,fMCEvent,kFALSE) &&
3070  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
3071  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
3072 
3073  if(particle->GetPdgCode() == 111){
3074  if(fIsMC > 1) fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 with gamma in acc NOT weighted at all
3075  fHistoMCPi0WOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Pi0 with gamma in acc NOT weighted
3076  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc
3077  } else if(particle->GetPdgCode() == 221){
3078  if(fIsMC > 1) fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta with gamma in acc NOT weighted at all
3079  fHistoMCEtaWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Eta with gamma in acc NOT weighted
3080  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Eta with gamma in acc
3081  }
3082  }
3083  }
3084  }
3085  } else {
3086  // fill secondary histograms
3087  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
3088  if (!particle) continue;
3089 
3090  Int_t isMCFromMBHeader = -1;
3091  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3092  isMCFromMBHeader
3093  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
3094  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3095  }
3096 
3097  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)){
3098  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
3099  if (particle->GetMother(0) > -1 && fMCEvent->Particle(particle->GetMother(0))->GetMother(0) > -1) {
3100  if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
3101  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
3102  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
3103  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
3104  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
3105  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3106  } else {
3107  if ( !(TMath::Abs(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()) == 11 && fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 22) )
3108  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3109  }
3110  } else {
3111  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3112  }
3113  }
3114 
3115  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kTRUE)){
3116  if (particle->GetMother(0) > -1 && fMCEvent->Particle(particle->GetMother(0))->GetMother(0) > -1) {
3117  if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
3118  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
3119  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
3120  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
3121  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
3122  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3123  } else {
3124  if ( !(TMath::Abs(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()) == 11 && fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 22) )
3125  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3126  }
3127  } else {
3128  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3129  }
3130  }
3131  }
3132 
3133  if(fDoMesonAnalysis){
3134  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3135  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
3136  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
3137  Int_t pdgCode = -1;
3138  if(particle->GetFirstMother()>-1) pdgCode = ((TParticle*)fMCEvent->Particle( particle->GetFirstMother() ))->GetPdgCode();
3139  if(particle->GetPdgCode() == 111){
3140  Int_t source = GetSourceClassification(111,pdgCode);
3141  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
3142 
3143  Double_t deltaX = particle->Vx() - mcProdVtxX;
3144  Double_t deltaY = particle->Vy() - mcProdVtxY;
3145  Double_t deltaZ = particle->Vz() - mcProdVtxZ;
3146  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
3147  if(fDoMesonQA > 0 && fIsMC < 2) fHistoMCSecPi0RvsSource[fiCut]->Fill(realRadius3D,source);
3148  fHistoMCSecPi0Source[fiCut]->Fill(pdgCode);
3149  } else if(particle->GetPdgCode() == 221){
3150  fHistoMCSecEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3151  fHistoMCSecEtaSource[fiCut]->Fill(pdgCode);
3152  }
3153 
3154  // pi0 really in acceptance/
3155  if( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter0,fMCEvent,kFALSE) &&
3156  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter1,fMCEvent,kFALSE) &&
3157  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
3158  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
3159  if(particle->GetPdgCode() == 111){
3160  Int_t source = GetSourceClassification(111,pdgCode);
3161  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
3162  }
3163  }
3164  }
3165  }
3166  }
3167  }
3168 }
3169 
3170 //________________________________________________________________________
3172 
3173  // Conversion Gammas
3174  if(fGammaCandidates->GetEntries()>1){
3175  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries()-1;firstGammaIndex++){
3176  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
3177  if (gamma0==NULL) continue;
3178  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGammaCandidates->GetEntries();secondGammaIndex++){
3179  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(secondGammaIndex));
3180  //Check for same Electron ID
3181  if (gamma1==NULL) continue;
3182  if(gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelPositive() ||
3183  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelNegative() ||
3184  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelPositive() ||
3185  gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelNegative() ) continue;
3186 
3187  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0,gamma1);
3188  pi0cand->SetLabels(firstGammaIndex,secondGammaIndex);
3189  pi0cand->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3190 
3191  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3192  if(fDoCentralityFlat > 0){
3193  fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3194  if(TMath::Abs(pi0cand->GetAlpha())<0.1) fHistoMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3195  } else {
3196  fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(),fWeightJetJetMC);
3197  if(TMath::Abs(pi0cand->GetAlpha())<0.1) fHistoMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E(),fWeightJetJetMC);
3198  }
3199 
3200  if (fDoMesonQA > 0){
3201 
3202  if(fDoMesonQA == 3 && TMath::Abs(gamma0->GetConversionRadius()-gamma1->GetConversionRadius())<10 && pi0cand->GetOpeningAngle()<0.1){
3203  Double_t sparesFill[4] = {gamma0->GetPhotonPt(),gamma0->GetConversionRadius(),TMath::Abs(gamma0->GetConversionRadius()-gamma1->GetConversionRadius()),pi0cand->GetOpeningAngle()};
3204  sPtRDeltaROpenAngle[fiCut]->Fill(sparesFill, 1);
3205  }
3206 
3207  if ( pi0cand->M() > 0.05 && pi0cand->M() < 0.17){
3208  if (fIsMC < 2){
3209  fHistoMotherPi0PtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3210  fHistoMotherPi0PtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());
3211  }
3212  fHistoMotherPi0PtAlpha[fiCut]->Fill(pi0cand->Pt(),TMath::Abs(pi0cand->GetAlpha()),fWeightJetJetMC);
3213 
3214  }
3215  if ( pi0cand->M() > 0.45 && pi0cand->M() < 0.65){
3216  if (fIsMC < 2){
3217  fHistoMotherEtaPtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3218  fHistoMotherEtaPtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());
3219  }
3220  fHistoMotherEtaPtAlpha[fiCut]->Fill(pi0cand->Pt(),TMath::Abs(pi0cand->GetAlpha()),fWeightJetJetMC);
3221  }
3222  }
3223  if(fDoTHnSparse && ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
3224  Int_t psibin = 0;
3225  Int_t zbin = 0;
3226  Int_t mbin = 0;
3227 
3228  Double_t sparesFill[4];
3229  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
3230  zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3231  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3233  } else {
3234  mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
3235  }
3236  sparesFill[0] = pi0cand->M();
3237  sparesFill[1] = pi0cand->Pt();
3238  sparesFill[2] = (Double_t)zbin;
3239  sparesFill[3] = (Double_t)mbin;
3240  } else {
3241  psibin = fBGHandlerRP[fiCut]->GetRPBinIndex(TMath::Abs(fEventPlaneAngle));
3242  zbin = fBGHandlerRP[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3243 // if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3244 // mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
3245 // } else {
3246 // mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
3247 // }
3248  sparesFill[0] = pi0cand->M();
3249  sparesFill[1] = pi0cand->Pt();
3250  sparesFill[2] = (Double_t)zbin;
3251  sparesFill[3] = (Double_t)psibin;
3252  }
3253 // Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
3254  if(fDoCentralityFlat > 0) sESDMotherInvMassPtZM[fiCut]->Fill(sparesFill, fWeightCentrality[fiCut]*fWeightJetJetMC); //instead of weight 1
3255  else sESDMotherInvMassPtZM[fiCut]->Fill(sparesFill, fWeightJetJetMC);
3256  }
3257 
3258 
3259  if( fIsMC > 0 ){
3260  if(fInputEvent->IsA()==AliESDEvent::Class())
3261  ProcessTrueMesonCandidates(pi0cand,gamma0,gamma1);
3262  if(fInputEvent->IsA()==AliAODEvent::Class())
3263  ProcessTrueMesonCandidatesAOD(pi0cand,gamma0,gamma1);
3264  }
3265  if (fDoMesonQA == 2){
3266  fInvMass = pi0cand->M();
3267  fPt = pi0cand->Pt();
3268  if (TMath::Abs(gamma0->GetDCAzToPrimVtx()) < TMath::Abs(gamma1->GetDCAzToPrimVtx())){
3269  fDCAzGammaMin = gamma0->GetDCAzToPrimVtx();
3270  fDCAzGammaMax = gamma1->GetDCAzToPrimVtx();
3271  } else {
3272  fDCAzGammaMin = gamma1->GetDCAzToPrimVtx();
3273  fDCAzGammaMax = gamma0->GetDCAzToPrimVtx();
3274  }
3275  iFlag = pi0cand->GetMesonQuality();
3276  // cout << "gamma 0: " << gamma0->GetV0Index()<< "\t" << gamma0->GetPx() << "\t" << gamma0->GetPy() << "\t" << gamma0->GetPz() << "\t" << endl;
3277  // cout << "gamma 1: " << gamma1->GetV0Index()<< "\t"<< gamma1->GetPx() << "\t" << gamma1->GetPy() << "\t" << gamma1->GetPz() << "\t" << endl;
3278  // cout << "pi0: "<<fInvMass << "\t" << fPt <<"\t" << fDCAzGammaMin << "\t" << fDCAzGammaMax << "\t" << (Int_t)iFlag << "\t" << (Int_t)iMesonMCInfo <<endl;
3279  if (fIsHeavyIon == 1 && fPt > 0.399 && fPt < 20. ) {
3280  if (fInvMass > 0.08 && fInvMass < 0.2) tESDMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
3281  if ((fInvMass > 0.45 && fInvMass < 0.6) && (fPt > 0.999 && fPt < 20.) )tESDMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
3282  } else if (((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetSingleElectronPtCut() < 0.04 && fPt > 0.099 && fPt < 20. ) {
3283  if ( (fInvMass > 0.08 && fInvMass < 0.6) ) tESDMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
3284  } else if (fPt > 0.299 && fPt < 20. ) {
3285  if ( (fInvMass > 0.08 && fInvMass < 0.6) ) tESDMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
3286  }
3287  }
3288  }
3289  delete pi0cand;
3290  pi0cand=0x0;
3291  }
3292  }
3293  }
3294 }
3295 
3296 //______________________________________________________________________
3298 {
3299  // Process True Mesons
3300  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3301  Double_t mcProdVtxX = primVtxMC->GetX();
3302  Double_t mcProdVtxY = primVtxMC->GetY();
3303  Double_t mcProdVtxZ = primVtxMC->GetZ();
3304 
3305  iMesonMCInfo = 0;
3306  if(TrueGammaCandidate0->GetV0Index()<fInputEvent->GetNumberOfV0s()){
3307  Bool_t isTruePi0 = kFALSE;
3308  Bool_t isTrueEta = kFALSE;
3309  Bool_t isTruePi0Dalitz = kFALSE;
3310  Bool_t isTrueEtaDalitz = kFALSE;
3311  Bool_t gamma0DalitzCand = kFALSE;
3312  Bool_t gamma1DalitzCand = kFALSE;
3313  Int_t gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCEvent);
3314  Int_t gamma0MotherLabel = -1;
3315  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3316  // Daughters Gamma 0
3317  TParticle * negativeMC = (TParticle*)TrueGammaCandidate0->GetNegativeMCDaughter(fMCEvent);
3318  TParticle * positiveMC = (TParticle*)TrueGammaCandidate0->GetPositiveMCDaughter(fMCEvent);
3319  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
3320  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3321  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
3322  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
3323  gamma0MotherLabel=gammaMC0->GetFirstMother();
3324  }
3325  }
3326  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
3327  gamma0DalitzCand = kTRUE;
3328  gamma0MotherLabel=-111;
3329  }
3330  if(gammaMC0->GetPdgCode() ==221){ // Dalitz candidate
3331  gamma0DalitzCand = kTRUE;
3332  gamma0MotherLabel=-221;
3333  }
3334  }
3335  }
3336  if(TrueGammaCandidate1->GetV0Index()<fInputEvent->GetNumberOfV0s()){
3337  Int_t gamma1MCLabel = TrueGammaCandidate1->GetMCParticleLabel(fMCEvent);
3338  Int_t gamma1MotherLabel = -1;
3339  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3340  // Daughters Gamma 1
3341  TParticle * negativeMC = (TParticle*)TrueGammaCandidate1->GetNegativeMCDaughter(fMCEvent);
3342  TParticle * positiveMC = (TParticle*)TrueGammaCandidate1->GetPositiveMCDaughter(fMCEvent);
3343  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
3344  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3345  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
3346  if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
3347  gamma1MotherLabel=gammaMC1->GetFirstMother();
3348  }
3349  }
3350  if(gammaMC1->GetPdgCode() ==111 ){ // Dalitz candidate
3351  gamma1DalitzCand = kTRUE;
3352  gamma1MotherLabel=-111;
3353  }
3354  if(gammaMC1->GetPdgCode() ==221){ // Dalitz candidate
3355  gamma1DalitzCand = kTRUE;
3356  gamma1MotherLabel=-221;
3357  }
3358  }
3359  }
3360  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3361  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
3362  isTruePi0=kTRUE;
3363  if (CheckVectorForDoubleCount(vecDoubleCountTruePi0s,gamma0MotherLabel)){
3364  fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3366  }
3367  }
3368  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 221){
3369  isTrueEta=kTRUE;
3370  if (CheckVectorForDoubleCount(vecDoubleCountTrueEtas,gamma0MotherLabel)){
3371  fHistoDoubleCountTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3373  }
3374  }
3375  }
3376 
3377  //Identify Dalitz candidate
3378  if (gamma1DalitzCand || gamma0DalitzCand){
3379  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
3380  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
3381  if (gamma0MotherLabel == -221) isTrueEtaDalitz = kTRUE;
3382  }
3383  if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
3384  if (gamma1MotherLabel == -111) isTruePi0Dalitz = kTRUE;
3385  if (gamma1MotherLabel == -221) isTrueEtaDalitz = kTRUE;
3386  }
3387  }
3388 
3389 
3390  if(isTruePi0 || isTrueEta){// True Pion or Eta
3391 
3392  Float_t weightMatBudget = 1.;
3393  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
3394  weightMatBudget = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueGammaCandidate0) * ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueGammaCandidate1);
3395  }
3396 
3397  fHistoTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightMatBudget*fWeightJetJetMC);
3398  if (fDoMesonQA > 0){
3399  if (isTruePi0){
3400  if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
3401  if(fIsMC < 2){
3402  fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3403  fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3404  }
3405  fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()),fWeightJetJetMC);
3406 
3407  }
3408  } else if (isTrueEta){
3409  if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
3410  if(fIsMC < 2){
3411  fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3412  fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3413  }
3414  fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()),fWeightJetJetMC);
3415  }
3416  }
3417  }
3418 
3419  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, gamma0MotherLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3420 
3421  if(!isPrimary && gamma1MotherLabel>-1){ // Secondary Meson
3422  Long_t secMotherLabel = ((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetMother(0);
3423  Float_t weightedSec= 1;
3424  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310){
3425  weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(secMotherLabel, fMCEvent, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
3426  //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3427  }
3428  fHistoTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3429  iMesonMCInfo = 2;
3430  if (secMotherLabel >-1){
3431  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310){
3432  iMesonMCInfo = 4;
3433  fHistoTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3434  if (fDoMesonQA > 0 && fIsMC < 2 )fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3435  }
3436  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==130){
3437  iMesonMCInfo = 8;
3438  fHistoTrueSecondaryMotherFromK0lInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3439  if (fDoMesonQA > 0 && fIsMC < 2 )fHistoTrueK0lWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3440  }
3441  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==221){
3442  iMesonMCInfo = 3;
3443  fHistoTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3444  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3445  }
3446  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==3122){
3447  iMesonMCInfo = 7;
3448  fHistoTrueSecondaryMotherFromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3449  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3450  }
3451  }
3452  } else { // Only primary pi0 for efficiency calculation
3453  iMesonMCInfo = 6;
3454  Float_t weighted= 1;
3455  if (((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt()>0.005){
3456  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, fMCEvent, fInputEvent);
3457  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3458  }
3459 
3460  fHistoTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget*fWeightJetJetMC);
3461  fHistoTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3462  pESDTruePrimaryMotherWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget*fWeightJetJetMC);
3463 
3464 
3465  if (fDoMesonQA > 0 && fIsMC < 2){
3466  if(isTruePi0){ // Only primary pi0 for resolution
3467  fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted*weightMatBudget);
3468  }
3469  if (isTrueEta){ // Only primary eta for resolution
3470  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted*weightMatBudget);
3471  }
3472  }
3473  }
3474  } else if(!isTruePi0 && !isTrueEta){ // Background
3475  if (fDoMesonQA > 0 && fIsMC < 2){
3476  if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
3477  fHistoTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3478  iMesonMCInfo = 1;
3479  } else { // No photon or without mother
3480  fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3481  }
3482  }
3483  if( isTruePi0Dalitz || isTrueEtaDalitz ){
3484  // Dalitz
3485  iMesonMCInfo = 5;
3486  if (fIsMC < 2) fHistoTrueMotherDalitzInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3487  } else if (gamma0DalitzCand || gamma1DalitzCand){
3488  if (fDoMesonQA > 0 && fIsMC < 2) fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3489  }
3490  }
3491  }
3492  }
3493 }
3494 
3495 //______________________________________________________________________
3497 {
3498  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3499  Double_t mcProdVtxX = primVtxMC->GetX();
3500  Double_t mcProdVtxY = primVtxMC->GetY();
3501  Double_t mcProdVtxZ = primVtxMC->GetZ();
3502 
3503  // Process True Mesons
3504  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3505  Bool_t isTruePi0 = kFALSE;
3506  Bool_t isTrueEta = kFALSE;
3507  Bool_t isTruePi0Dalitz = kFALSE;
3508  Bool_t isTrueEtaDalitz = kFALSE;
3509  Bool_t gamma0DalitzCand = kFALSE;
3510  Bool_t gamma1DalitzCand = kFALSE;
3511 
3512  if (AODMCTrackArray!=NULL && TrueGammaCandidate0 != NULL){
3513  AliAODMCParticle *positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
3514  AliAODMCParticle *negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
3515 
3516  iMesonMCInfo = 0;
3517  Int_t gamma0MCLabel = -1;
3518  Int_t gamma0MotherLabel = -1;
3519  if(!positiveMC||!negativeMC)
3520  return;
3521 
3522  if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
3523  gamma0MCLabel = positiveMC->GetMother();
3524  }
3525 
3526  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3527  // Daughters Gamma 0
3528  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3529  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3530  if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
3531  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
3532  gamma0MotherLabel=gammaMC0->GetMother();
3533  }
3534  }
3535  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
3536  gamma0DalitzCand = kTRUE;
3537  gamma0MotherLabel=-111;
3538  }
3539  if(gammaMC0->GetPdgCode() ==221){ // Dalitz candidate
3540  gamma0DalitzCand = kTRUE;
3541  gamma0MotherLabel=-221;
3542  }
3543  }
3544  }
3545  positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelPositive()));
3546  negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelNegative()));
3547 
3548  Int_t gamma1MCLabel = -1;
3549  Int_t gamma1MotherLabel = -1;
3550  if(!positiveMC||!negativeMC)
3551  return;
3552 
3553  if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
3554  gamma1MCLabel = positiveMC->GetMother();
3555  }
3556  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3557  // Daughters Gamma 1
3558  AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3559  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3560  if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
3561  if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
3562  gamma1MotherLabel=gammaMC1->GetMother();
3563  }
3564  }
3565  if(gammaMC1->GetPdgCode() ==111 ){ // Dalitz candidate
3566  gamma1DalitzCand = kTRUE;
3567  gamma1MotherLabel=-111;
3568  }
3569  if(gammaMC1->GetPdgCode() ==221){ // Dalitz candidate
3570  gamma1DalitzCand = kTRUE;
3571  gamma1MotherLabel=-221;
3572  }
3573  }
3574  }
3575  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3576  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
3577  isTruePi0=kTRUE;
3578  if (CheckVectorForDoubleCount(vecDoubleCountTruePi0s,gamma0MotherLabel)){
3579  fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3581  }
3582  }
3583  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 221){
3584  isTrueEta=kTRUE;
3585  if (CheckVectorForDoubleCount(vecDoubleCountTrueEtas,gamma0MotherLabel)){
3586  fHistoDoubleCountTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3588  }
3589  }
3590  }
3591 
3592  //Identify Dalitz candidate
3593  if (gamma1DalitzCand || gamma0DalitzCand){
3594  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
3595  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
3596  if (gamma0MotherLabel == -221) isTrueEtaDalitz = kTRUE;
3597  }
3598  if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
3599  if (gamma1MotherLabel == -111) isTruePi0Dalitz = kTRUE;
3600  if (gamma1MotherLabel == -221) isTrueEtaDalitz = kTRUE;
3601  }
3602  }
3603 
3604  if(isTruePi0 || isTrueEta){// True Pion or Eta
3605 
3606  Float_t weightMatBudget = 1.;
3607  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
3608  weightMatBudget = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueGammaCandidate0) * ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueGammaCandidate1);
3609  }
3610 
3611  fHistoTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightMatBudget*fWeightJetJetMC);
3612  if (fDoMesonQA > 0){
3613  if (isTruePi0){
3614  if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
3615  if(fIsMC < 2){
3616  fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3617  fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3618  }
3619  fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()),fWeightJetJetMC);
3620  }
3621  } else if (isTrueEta){
3622  if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
3623  if(fIsMC < 2){
3624  fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3625  fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3626  }
3627  fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()),fWeightJetJetMC);
3628  }
3629  }
3630  }
3631  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel)), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3632 
3633  if(!isPrimary){ // Secondary Meson
3634  Long_t secMotherLabel = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetMother();
3635  Float_t weightedSec= 1;
3636  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
3637  weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(secMotherLabel, 0x0, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
3638  //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3639  }
3640  fHistoTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3641  iMesonMCInfo = 2;
3642  if (secMotherLabel >-1){
3643  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
3644  iMesonMCInfo = 4;
3645  fHistoTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3646  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3647  }
3648  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==130){
3649  iMesonMCInfo = 8;
3650  fHistoTrueSecondaryMotherFromK0lInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3651  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueK0lWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3652  }
3653  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==221){
3654  iMesonMCInfo = 3;
3655  fHistoTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3656  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3657  }
3658  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==3122){
3659  iMesonMCInfo = 7;
3660  fHistoTrueSecondaryMotherFromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3661  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3662  }
3663  }
3664  } else { // Only primary pi0 for efficiency calculation
3665  Float_t weighted= 1;
3666  iMesonMCInfo = 6;
3667  if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt()>0.005){
3668  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, 0x0, fInputEvent);
3669  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3670  }
3671  fHistoTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget*fWeightJetJetMC);
3672  fHistoTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3673  pESDTruePrimaryMotherWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget*fWeightJetJetMC);
3674 
3675  if (fDoMesonQA > 0 && fIsMC < 2){
3676  if(isTruePi0){ // Only primary pi0 for resolution
3677  fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
3678  (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted*weightMatBudget);
3679 
3680  }
3681  if (isTrueEta){ // Only primary eta for resolution
3682  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
3683  (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted*weightMatBudget);
3684  }
3685  }
3686  }
3687  } else if(!isTruePi0 && !isTrueEta) { // Background
3688  if (fDoMesonQA > 0 && fIsMC < 2){
3689  if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
3690  fHistoTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3691  iMesonMCInfo = 1;
3692  } else { // No photon or without mother
3693  fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3694  }
3695  }
3696  if( isTruePi0Dalitz || isTrueEtaDalitz ){
3697  // Dalitz
3698  iMesonMCInfo = 5;
3699  if (fIsMC < 2)fHistoTrueMotherDalitzInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3700  } else if (gamma0DalitzCand || gamma1DalitzCand){
3701  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3702  }
3703  }
3704  }
3705  return;
3706 }
3707 //________________________________________________________________________
3709 
3710  Int_t zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3711  Int_t mbin = 0;
3712 
3713  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3715  } else {
3716  mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
3717  }
3718 
3719  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseRotationMethod()){
3720 
3721  for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
3722  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
3723  for(Int_t iCurrent2=iCurrent+1;iCurrent2<fGammaCandidates->GetEntries();iCurrent2++){
3724  for(Int_t nRandom=0;nRandom<((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents();nRandom++){
3725  AliAODConversionPhoton currentEventGoodV02 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent2));
3726 
3727  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGProbability()){
3728  AliAODConversionMother *backgroundCandidateProb = new AliAODConversionMother(&currentEventGoodV0,&currentEventGoodV02);
3729  Double_t massBGprob = backgroundCandidateProb->M();
3730  if(massBGprob>0.1 && massBGprob<0.14){
3731  if(fRandom.Rndm()>fBGHandler[fiCut]->GetBGProb(zbin,mbin)){
3732  delete backgroundCandidateProb;
3733  continue;
3734  }
3735  }
3736  delete backgroundCandidateProb;
3737  backgroundCandidateProb = 0x0;
3738  }
3739 
3740  RotateParticle(&currentEventGoodV02);
3741  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&currentEventGoodV02);
3742  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3744  ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3745  if(fDoCentralityFlat > 0) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3746  else fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(),fWeightJetJetMC);
3747  if(fDoTHnSparse){
3748  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3749  if(fDoCentralityFlat > 0) sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightCentrality[fiCut]*fWeightJetJetMC); //instead of weight 1
3750  else sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightJetJetMC);
3751  }
3752  }
3753  delete backgroundCandidate;
3754  backgroundCandidate = 0x0;
3755  }
3756  }
3757  }
3758  } else {
3760 
3761  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3762  for(Int_t nEventsInBG=0;nEventsInBG<fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
3763  AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
3764  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3765  bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
3766  }
3767 
3768  for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
3769  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
3770  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3771  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
3772  if(fMoveParticleAccordingToVertex == kTRUE){
3773  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3774  }
3775  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3776  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
3777  }
3778 
3779  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
3780  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3782  ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3783  if(fDoCentralityFlat > 0) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3784  else fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(),fWeightJetJetMC);
3785  if(fDoTHnSparse){
3786  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3787  if(fDoCentralityFlat > 0) sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightCentrality[fiCut]*fWeightJetJetMC); //instead of weight 1
3788  else sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightJetJetMC);
3789  }
3790  }
3791  delete backgroundCandidate;
3792  backgroundCandidate = 0x0;
3793  }
3794  }
3795  }
3796  } else {
3797  for(Int_t nEventsInBG=0;nEventsInBG <fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
3798  AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
3799  if(previousEventV0s){
3800  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3801  bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
3802  }
3803  for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
3804  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
3805  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3806 
3807  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
3808 
3809  if(fMoveParticleAccordingToVertex == kTRUE){
3810  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3811  }
3812  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3813  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
3814  }
3815 
3816 
3817  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
3818  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3820  ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3821  if(fDoCentralityFlat > 0) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3822  else fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(),fWeightJetJetMC);
3823  if(fDoTHnSparse){
3824  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3825  if(fDoCentralityFlat > 0) sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightCentrality[fiCut]*fWeightJetJetMC); //instead of weight 1
3826  else sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightJetJetMC);
3827  }
3828  }
3829  delete backgroundCandidate;
3830  backgroundCandidate = 0x0;
3831  }
3832  }
3833  }
3834  }
3835  }
3836  }
3837 }
3838 //________________________________________________________________________
3840 
3841  Int_t psibin = 0;
3842  Int_t zbin = 0;
3843 
3844  if(fDoTHnSparse){
3845  psibin = fBGHandlerRP[fiCut]->GetRPBinIndex(TMath::Abs(fEventPlaneAngle));
3846  zbin = fBGHandlerRP[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3847 // if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3848 // mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
3849 // } else {
3850 // mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
3851 // }
3852  }
3853 
3854  //Rotation Method
3855  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseRotationMethod()){
3856  // Correct for the number of rotations
3857  // BG is for rotation the same, except for factor NRotations
3858  Double_t weight=1./Double_t(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents());
3859 
3860  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
3861 
3862  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
3863  if (gamma0==NULL) continue;
3864  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGammaCandidates->GetEntries();secondGammaIndex++){
3865  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(secondGammaIndex));
3866  if (gamma1 == NULL) continue;
3867  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelected(gamma1,fInputEvent))continue;
3868  for(Int_t nRandom=0;nRandom<((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents();nRandom++){
3869  RotateParticle(gamma1);
3870  AliAODConversionMother backgroundCandidate(gamma0,gamma1);
3871  backgroundCandidate.CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3872  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(&backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3873  if(fDoCentralityFlat > 0) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3874  else fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt(),fWeightJetJetMC);
3875  if(fDoTHnSparse){
3876 // Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)mbin};
3877  Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)psibin};
3879  else sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,weight*fWeightJetJetMC);
3880  }
3881  }
3882  }
3883  }
3884  }
3885 
3886  } else {
3887  // Do Event Mixing
3888  for(Int_t nEvent