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