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