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