AliPhysics  9c7580a (9c7580a)
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
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", nBinsQAPt, arrQAPtBinning);
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/b");
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", nBinsQAPt, arrQAPtBinning);
1324  fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);
1325  fHistoMCAllSecondaryGammaPt[iCut] = new TH2F("MC_AllSecondaryGamma_Pt", "MC_AllSecondaryGamma_Pt", nBinsQAPt, arrQAPtBinning, 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", nBinsQAPt, arrQAPtBinning);
1332  fMCList[iCut]->Add(fHistoMCDecayGammaPi0Pt[iCut]);
1333  fHistoMCDecayGammaRhoPt[iCut] = new TH1F("MC_DecayGammaRho_Pt", "MC_DecayGammaRho_Pt", nBinsQAPt, arrQAPtBinning);
1334  fMCList[iCut]->Add(fHistoMCDecayGammaRhoPt[iCut]);
1335  fHistoMCDecayGammaEtaPt[iCut] = new TH1F("MC_DecayGammaEta_Pt", "MC_DecayGammaEta_Pt", nBinsQAPt, arrQAPtBinning);
1336  fMCList[iCut]->Add(fHistoMCDecayGammaEtaPt[iCut]);
1337  fHistoMCDecayGammaOmegaPt[iCut] = new TH1F("MC_DecayGammaOmega_Pt", "MC_DecayGammaOmmega_Pt", nBinsQAPt, arrQAPtBinning);
1338  fMCList[iCut]->Add(fHistoMCDecayGammaOmegaPt[iCut]);
1339  fHistoMCDecayGammaEtapPt[iCut] = new TH1F("MC_DecayGammaEtap_Pt", "MC_DecayGammaEtap_Pt", nBinsQAPt, arrQAPtBinning);
1340  fMCList[iCut]->Add(fHistoMCDecayGammaEtapPt[iCut]);
1341  fHistoMCDecayGammaPhiPt[iCut] = new TH1F("MC_DecayGammaPhi_Pt", "MC_DecayGammaPhi_Pt", nBinsQAPt, arrQAPtBinning);
1342  fMCList[iCut]->Add(fHistoMCDecayGammaPhiPt[iCut]);
1343  fHistoMCDecayGammaSigmaPt[iCut] = new TH1F("MC_DecayGammaSigma_Pt", "MC_DecayGammaSigma_Pt", nBinsQAPt, arrQAPtBinning);
1344  fMCList[iCut]->Add(fHistoMCDecayGammaSigmaPt[iCut]);
1345  fHistoMCConvGammaPt[iCut] = new TH1F("MC_ConvGamma_Pt", "MC_ConvGamma_Pt", nBinsQAPt, arrQAPtBinning);
1346  fMCList[iCut]->Add(fHistoMCConvGammaPt[iCut]);
1347  fHistoMCSecondaryConvGammaPt[iCut] = new TH2F("MC_SecondaryConvGamma_Pt", "MC_SecondaryConvGamma_Pt", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt, 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", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1377  fHistoMCPi0Pt[iCut]->Sumw2();
1378  fMCList[iCut]->Add(fHistoMCPi0Pt[iCut]);
1379  fHistoMCPi0WOWeightPt[iCut] = new TH1F("MC_Pi0_WOWeights_Pt", "MC_Pi0_WOWeights_Pt", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1380  fHistoMCPi0WOWeightPt[iCut]->Sumw2();
1381  fMCList[iCut]->Add(fHistoMCPi0WOWeightPt[iCut]);
1382 
1383  fHistoMCEtaPt[iCut] = new TH1F("MC_Eta_Pt", "MC_Eta_Pt", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1384  fHistoMCEtaPt[iCut]->Sumw2();
1385  fMCList[iCut]->Add(fHistoMCEtaPt[iCut]);
1386  fHistoMCEtaWOWeightPt[iCut] = new TH1F("MC_Eta_WOWeights_Pt", "MC_Eta_WOWeights_Pt", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1387  fHistoMCEtaWOWeightPt[iCut]->Sumw2();
1388  fMCList[iCut]->Add(fHistoMCEtaWOWeightPt[iCut]);
1389 
1390  fHistoMCPi0WOWeightInAccPt[iCut] = new TH1F("MC_Pi0WOWeightInAcc_Pt", "MC_Pi0WOWeightInAcc_Pt", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1391  fHistoMCPi0WOWeightInAccPt[iCut]->Sumw2();
1392  fMCList[iCut]->Add(fHistoMCPi0WOWeightInAccPt[iCut]);
1393  fHistoMCEtaWOWeightInAccPt[iCut] = new TH1F("MC_EtaWOWeightInAcc_Pt", "MC_EtaWOWeightInAcc_Pt", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1394  fHistoMCEtaWOWeightInAccPt[iCut]->Sumw2();
1395  fMCList[iCut]->Add(fHistoMCEtaWOWeightInAccPt[iCut]);
1396  fHistoMCPi0InAccPt[iCut] = new TH1F("MC_Pi0InAcc_Pt", "MC_Pi0InAcc_Pt", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1397  fHistoMCPi0InAccPt[iCut]->Sumw2();
1398  fMCList[iCut]->Add(fHistoMCPi0InAccPt[iCut]);
1399  fHistoMCEtaInAccPt[iCut] = new TH1F("MC_EtaInAcc_Pt", "MC_EtaInAcc_Pt", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
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", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1405  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightPt[iCut]);
1406  fHistoMCEtaWOEvtWeightPt[iCut] = new TH1F("MC_Eta_WOEventWeights_Pt", "MC_Eta_WOEventWeights_Pt", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1407  fMCList[iCut]->Add(fHistoMCEtaWOEvtWeightPt[iCut]);
1408  fHistoMCPi0WOEvtWeightInAccPt[iCut] = new TH1F("MC_Pi0WOEvtWeightInAcc_Pt", "MC_Pi0WOEvtWeightInAcc_Pt", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1409  fHistoMCPi0WOEvtWeightInAccPt[iCut]->Sumw2();
1410  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightInAccPt[iCut]);
1411  fHistoMCEtaWOEvtWeightInAccPt[iCut] = new TH1F("MC_EtaWOEvtWeightInAcc_Pt", "MC_EtaWOEvtWeightInAcc_Pt", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
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", nBinsQAPt, arrQAPtBinning, 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", nBinsQAPt, arrQAPtBinning, 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", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt, 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", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt, 16, -0.5, 15.5);
1442  fMCList[iCut]->Add(fHistoMCSecPi0PtvsSource[iCut]);
1443  fHistoMCSecPi0InAccPtvsSource[iCut] = new TH2F("MC_SecPi0InAcc_Pt_Source", "MC_SecPi0InAcc_Pt_Source", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt, 16, -0.5, 15.5);
1444  fMCList[iCut]->Add(fHistoMCSecPi0InAccPtvsSource[iCut]);
1445  fHistoMCSecEtaPt[iCut] = new TH1F("MC_SecEta_Pt", "MC_SecEta_Pt", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
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", nBinsQAPt, arrQAPtBinning);
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", nBinsQAPt, arrQAPtBinning, 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", nBinsQAPt, arrQAPtBinning);
1509  fTrueList[iCut]->Add(fHistoTruePrimaryConvGammaPt[iCut]);
1510  fHistoTrueSecondaryConvGammaPt[iCut] = new TH2F("ESD_TrueSecondaryConvGamma_Pt", "ESD_TrueSecondaryConvGamma_Pt", nBinsQAPt, arrQAPtBinning, 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", nBinsQAPt, arrQAPtBinning, 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  nBinsQAPt, arrQAPtBinning, nBinsQAPt, arrQAPtBinning);
1568 
1569 
1570  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromK0sESD_MCPtPt", "ESD_TrueSecondaryConvGammaFromXFromK0sESD_MCPtPt",
1571  nBinsQAPt, arrQAPtBinning, nBinsQAPt, arrQAPtBinning);
1573  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromK0lESD_MCPtPt", "ESD_TrueSecondaryConvGammaFromXFromK0lESD_MCPtPt",
1574  nBinsQAPt, arrQAPtBinning, nBinsQAPt, arrQAPtBinning);
1576  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromLambdaESD_MCPtPt", "ESD_TrueSecondaryConvGammaFromXFromLambdaESD_MCPtPt",
1577  nBinsQAPt, arrQAPtBinning, nBinsQAPt, arrQAPtBinning);
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, nBinsQAPt, arrQAPtBinning);
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", nBinsQAPt, arrQAPtBinning);
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", nBinsQAPt, arrQAPtBinning, 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", nBinsQAPt, arrQAPtBinning, 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 ( PhotonCandidate->Pt() > 0.299 && 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  }
2109  }
2110  }
2111  } else if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
2112  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
2113  nV0++;
2114  GammaCandidatesStepOne->Add(PhotonCandidate);
2115  } else if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
2116  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
2117  GammaCandidatesStepTwo->Add(PhotonCandidate);
2118  }
2119  }
2120  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){
2121  for(Int_t i = 0;i<GammaCandidatesStepOne->GetEntries();i++){
2122  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GammaCandidatesStepOne->At(i);
2123  if(!PhotonCandidate) continue;
2124  fIsFromSelectedHeader = kTRUE;
2125 
2126  Float_t weightMatBudgetGamma = 1.;
2127  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2128  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(PhotonCandidate);
2129  }
2130 
2131 
2132  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2133  Int_t isPosFromMBHeader
2134  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
2135  Int_t isNegFromMBHeader
2136  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
2137  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromSelectedHeader = kFALSE;
2138  }
2139  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GammaCandidatesStepOne->GetEntries())) continue;
2140  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
2141  fGammaCandidates->Add(PhotonCandidate);
2142 
2144  if(fDoCentralityFlat > 0) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2145  else fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2146  if (fDoPhotonQA > 0 && fIsMC < 2){
2147  if(fDoCentralityFlat > 0){
2148  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2149  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2150  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2151  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2152  } else {
2153  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2154  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
2155  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
2156  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(),fWeightJetJetMC*weightMatBudgetGamma);
2157  }
2158  }
2159  if( fIsMC > 0 ){
2160  if(fInputEvent->IsA()==AliESDEvent::Class())
2161  ProcessTruePhotonCandidates(PhotonCandidate);
2162  if(fInputEvent->IsA()==AliAODEvent::Class())
2163  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
2164  }
2165  if (fDoPhotonQA == 2){
2166  if (fIsHeavyIon ==1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
2167  fPtGamma = PhotonCandidate->Pt();
2168  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2169  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2170  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2171  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2172  tESDConvGammaPtDcazCat[fiCut]->Fill();
2173  } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
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  }
2181  }
2182  }
2183  } else GammaCandidatesStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
2184  }
2185  }
2186  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
2187  for(Int_t i = 0;i<GammaCandidatesStepTwo->GetEntries();i++){
2188  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GammaCandidatesStepTwo->At(i);
2189  if(!PhotonCandidate) continue;
2190  fIsFromSelectedHeader = kTRUE;
2191 
2192  Float_t weightMatBudgetGamma = 1.;
2193  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2194  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(PhotonCandidate);
2195  }
2196 
2197  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2198  Int_t isPosFromMBHeader
2199  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
2200  Int_t isNegFromMBHeader
2201  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
2202  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromSelectedHeader = kFALSE;
2203  }
2204  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GammaCandidatesStepTwo,i)) continue;
2205  fGammaCandidates->Add(PhotonCandidate); // Add gamma to current cut TList
2206 
2208  if(fDoCentralityFlat > 0) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2209  else fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2210  if (fDoPhotonQA > 0 && fIsMC < 2 ){
2211  if(fDoCentralityFlat > 0){
2212  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2213  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2214  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2215  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2216  } else {
2217  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2218  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
2219  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
2220  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(),fWeightJetJetMC*weightMatBudgetGamma);
2221  }
2222  }
2223  if( fIsMC > 0 ){
2224  if(fInputEvent->IsA()==AliESDEvent::Class())
2225  ProcessTruePhotonCandidates(PhotonCandidate);
2226  if(fInputEvent->IsA()==AliAODEvent::Class())
2227  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
2228  }
2229  if (fDoPhotonQA == 2){
2230  if (fIsHeavyIon == 1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
2231  fPtGamma = PhotonCandidate->Pt();
2232  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2233  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2234  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2235  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2236  tESDConvGammaPtDcazCat[fiCut]->Fill();
2237  } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
2238  fPtGamma = PhotonCandidate->Pt();
2239  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2240  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2241  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2242  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2243  tESDConvGammaPtDcazCat[fiCut]->Fill();
2244  }
2245  }
2246  }
2247  }
2248  }
2249 
2250  delete GammaCandidatesStepOne;
2251  GammaCandidatesStepOne = 0x0;
2252  delete GammaCandidatesStepTwo;
2253  GammaCandidatesStepTwo = 0x0;
2254 
2255 }
2256 //________________________________________________________________________
2258 {
2259  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2260  Double_t mcProdVtxX = primVtxMC->GetX();
2261  Double_t mcProdVtxY = primVtxMC->GetY();
2262  Double_t mcProdVtxZ = primVtxMC->GetZ();
2263 
2264  Double_t magField = fInputEvent->GetMagneticField();
2265  if( magField < 0.0 ){
2266  magField = 1.0;
2267  }
2268  else {
2269  magField = -1.0;
2270  }
2271 
2272  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2273  if (AODMCTrackArray != NULL && TruePhotonCandidate != NULL){
2274 
2275  AliAODMCParticle *posDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelPositive());
2276  AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelNegative());
2277  iPhotonMCInfo = 0;
2278 
2279  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
2280  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
2281 
2282  Double_t PhiParticle[2] = {posDaughter->Phi(),negDaughter->Phi()};
2283 
2284  if(posDaughter->GetMother() != negDaughter->GetMother()){
2285  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
2286  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
2287  if(posDaughter->GetMother() > -1){ //contamination is not a primary
2288  AliAODMCParticle *Mom = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
2289  if(Mom->GetMother() == -1){
2290  FillPhotonCombinatorialMothersHistAOD(posDaughter,Mom);
2291  } else {
2292  AliAODMCParticle *GranMom = (AliAODMCParticle*) AODMCTrackArray->At(Mom->GetMother());
2293  if(GranMom->GetMother() == -1){
2294  FillPhotonCombinatorialMothersHistAOD(posDaughter,GranMom);
2295  } else {
2296  AliAODMCParticle *GranGranMom = (AliAODMCParticle*) AODMCTrackArray->At(GranMom->GetMother());
2297  if(GranGranMom->GetMother() == -1){
2298  FillPhotonCombinatorialMothersHistAOD(posDaughter,GranGranMom);
2299  } else FillPhotonCombinatorialMothersHistAOD(posDaughter,GranGranMom);
2300  }
2301  }
2302  }
2303  if(negDaughter->GetMother() > -1){ //contamination is not a primary
2304  AliAODMCParticle *Mom = (AliAODMCParticle*) AODMCTrackArray->At(negDaughter->GetMother());
2305  if(Mom->GetMother() == -1){
2306  FillPhotonCombinatorialMothersHistAOD(negDaughter,Mom);
2307  } else {
2308  AliAODMCParticle *GranMom = (AliAODMCParticle*) AODMCTrackArray->At(Mom->GetMother());
2309  if(GranMom->GetMother() == -1){
2310  FillPhotonCombinatorialMothersHistAOD(negDaughter,GranMom);
2311  } else {
2312  AliAODMCParticle *GranGranMom = (AliAODMCParticle*) AODMCTrackArray->At(GranMom->GetMother());
2313  if(GranGranMom->GetMother() == -1){
2314  FillPhotonCombinatorialMothersHistAOD(negDaughter,GranGranMom);
2315  } else FillPhotonCombinatorialMothersHistAOD(posDaughter,GranGranMom);
2316  }
2317  }
2318  }
2319  }
2320  iPhotonMCInfo = 1;
2321  return;
2322  }
2323  else if(posDaughter->GetMother() == -1){
2324  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
2325  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
2326  FillPhotonCombinatorialMothersHistAOD(posDaughter,posDaughter);
2327  FillPhotonCombinatorialMothersHistAOD(negDaughter,negDaughter);
2328  }
2329  iPhotonMCInfo = 1;
2330  return;
2331  }
2332 
2333  if(pdgCode[0]!=11 || pdgCode[1]!=11){
2334  iPhotonMCInfo = 1;
2335  return; //One Particle is not a electron
2336  }
2337  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()){
2338  iPhotonMCInfo = 1;
2339  return; // Same Charge
2340  }
2341 
2342  AliAODMCParticle *Photon = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
2343  AliVTrack * electronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelNegative() );
2344  AliVTrack * positronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelPositive() );
2345  Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->Phi()-positronCandidate->Phi());
2346 
2347  if(Photon->GetPdgCode() != 22){
2348  fHistoTrueDalitzPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC);
2349  iPhotonMCInfo = 1;
2350  return; // Mother is no Photon
2351  }
2352 
2353  if(((posDaughter->GetMCProcessCode())) != 5 || ((negDaughter->GetMCProcessCode())) != 5){
2354  iPhotonMCInfo = 1;
2355  return;// check if the daughters come from a conversion
2356  }
2357  // STILL A BUG IN ALIROOT >>8 HAS TPO BE REMOVED AFTER FIX
2358 
2359  Double_t rConv=0.;
2360  rConv = sqrt( (posDaughter->Xv()*posDaughter->Xv()) + (posDaughter->Yv()*posDaughter->Yv()) );
2361 
2362  // True Photon
2363 
2364  Float_t weightMatBudgetGamma = 1.;
2365  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2366  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TruePhotonCandidate);
2367  }
2368 
2369  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2370  if (CheckVectorForDoubleCount(vecDoubleCountTrueConvGammas,posDaughter->GetMother())){
2371  fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2372  FillMultipleCountMap(mapMultipleCountTrueConvGammas,posDaughter->GetMother());
2373  }
2374  if (fDoPhotonQA > 0 ){
2375  if (fIsMC < 2){
2376  fHistoTrueConvGammaPsiPairPt[fiCut]->Fill(TruePhotonCandidate->GetPsiPair(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2377  fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
2378  fHistoTrueConvGammaR[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
2379  fHistoTrueConvGammaRMC[fiCut]->Fill(rConv,fWeightJetJetMC*weightMatBudgetGamma);
2380  }
2381  fHistoTrueConvGammaPtMC[fiCut]->Fill(Photon->Pt(), fWeightJetJetMC*weightMatBudgetGamma);
2382  }
2383  fHistoTrueGammaPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC*weightMatBudgetGamma);
2384 
2385  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2386  if(isPrimary){
2387  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
2388  iPhotonMCInfo = 6;
2389  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2390  fHistoTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(),fWeightJetJetMC*weightMatBudgetGamma); // Allways Filled
2391  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
2392  } else {
2393  iPhotonMCInfo = 2;
2394  if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 && ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetMother() > -1 ){
2395  if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 310){
2396  iPhotonMCInfo = 4;
2397  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
2398  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
2399  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2400  } else if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 130) {
2401  iPhotonMCInfo = 7;
2402  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
2403  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
2404  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2405  } else if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 3122) {
2406  iPhotonMCInfo = 5;
2407  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
2408  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
2409  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2410  } else if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 221) {
2411  iPhotonMCInfo = 3;
2412  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2413  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2414  } else {
2415  // if ( !(TMath::Abs(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetPdgCode()) == 11 && ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 22) ) {
2416  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2417  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2418  // }
2419  }
2420  }
2421  }
2422  }
2423  return;
2424 }
2425 //________________________________________________________________________
2427 {
2428 
2429  Double_t magField = fInputEvent->GetMagneticField();
2430  if( magField < 0.0 ){
2431  magField = 1.0;
2432  }
2433  else {
2434  magField = -1.0;
2435  }
2436 
2437  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2438  Double_t mcProdVtxX = primVtxMC->GetX();
2439  Double_t mcProdVtxY = primVtxMC->GetY();
2440  Double_t mcProdVtxZ = primVtxMC->GetZ();
2441 
2442  // Process True Photons
2443  TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCEvent);
2444  TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCEvent);
2445 
2446  iPhotonMCInfo = 0;
2447 
2448  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
2449  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
2450 
2451  Double_t PhiParticle[2] = {posDaughter->Phi(),negDaughter->Phi()};
2452 
2453  iPhotonMCInfo = 1;
2454  if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){
2455  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
2456  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
2457  if(posDaughter->GetMother(0) > -1){ //contamination is not a primary
2458  TParticle *Mom = fMCEvent->Particle(posDaughter->GetMother(0));
2459  if(Mom->GetMother(0) == -1){
2460  FillPhotonCombinatorialMothersHistESD(posDaughter,Mom);
2461  } else {
2462  TParticle *GranMom = fMCEvent->Particle(Mom->GetMother(0));
2463  if(GranMom->GetMother(0) == -1){
2464  FillPhotonCombinatorialMothersHistESD(posDaughter,GranMom);
2465  } else {
2466  TParticle *GranGranMom = fMCEvent->Particle(GranMom->GetMother(0));
2467  if(GranGranMom->GetMother(0) == -1){
2468  FillPhotonCombinatorialMothersHistESD(posDaughter,GranGranMom);
2469  } else FillPhotonCombinatorialMothersHistESD(posDaughter,GranGranMom);
2470  }
2471  }
2472  }
2473  if(negDaughter->GetMother(0) > -1){ //contamination is not a primary
2474  TParticle *Mom = fMCEvent->Particle(negDaughter->GetMother(0));
2475  if(Mom->GetMother(0) == -1){
2476  FillPhotonCombinatorialMothersHistESD(negDaughter,Mom);
2477  } else {
2478  TParticle *GranMom = fMCEvent->Particle(Mom->GetMother(0));
2479  if(GranMom->GetMother(0) == -1){
2480  FillPhotonCombinatorialMothersHistESD(negDaughter,GranMom);
2481  } else {
2482  TParticle *GranGranMom = fMCEvent->Particle(GranMom->GetMother(0));
2483  if(GranGranMom->GetMother(0) == -1){
2484  FillPhotonCombinatorialMothersHistESD(negDaughter,GranGranMom);
2485  } else FillPhotonCombinatorialMothersHistESD(posDaughter,GranGranMom);
2486  }
2487  }
2488  }
2489  }
2490  return;
2491  } else if(posDaughter->GetMother(0) == -1){ //gamma contamination is a primary
2492  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
2493  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
2494  FillPhotonCombinatorialMothersHistESD(posDaughter,posDaughter);
2495  FillPhotonCombinatorialMothersHistESD(negDaughter,negDaughter);
2496  }
2497  return;
2498  }
2499 
2500  if(pdgCode[0]!=11 || pdgCode[1]!=11) return; //One Particle is not a electron
2501 
2502  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
2503 
2504  TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCEvent);
2505  AliVTrack * electronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelNegative() );
2506  AliVTrack * positronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelPositive() );
2507  Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->Phi()-positronCandidate->Phi());
2508 
2509  if(Photon->GetPdgCode() != 22){
2510  fHistoTrueDalitzPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC);
2511  return; // Mother is no Photon
2512  }
2513 
2514  if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
2515 
2516  // True Photon
2517  Float_t weightMatBudgetGamma = 1.;
2518  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2519  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TruePhotonCandidate);
2520  }
2521 
2522  // cout<< " AM- Material Budget weight Gamma::"<< weightMatBudgetGamma << " "<< TruePhotonCandidate->GetConversionRadius() << endl;
2523 
2524  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2525  if (CheckVectorForDoubleCount(vecDoubleCountTrueConvGammas,posDaughter->GetMother(0))){
2526  fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2527  FillMultipleCountMap(mapMultipleCountTrueConvGammas,posDaughter->GetMother(0));
2528  }
2529  if (fDoPhotonQA > 0){
2530  if (fIsMC < 2){
2531  fHistoTrueConvGammaPsiPairPt[fiCut]->Fill(TruePhotonCandidate->GetPsiPair(),TruePhotonCandidate->Pt(),weightMatBudgetGamma);
2532  fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta(),weightMatBudgetGamma);
2533  fHistoTrueConvGammaR[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),weightMatBudgetGamma);
2534  fHistoTrueConvGammaRMC[fiCut]->Fill(posDaughter->R(),weightMatBudgetGamma);
2535  }
2536  fHistoTrueConvGammaPtMC[fiCut]->Fill(Photon->Pt(), fWeightJetJetMC*weightMatBudgetGamma);
2537  }
2538 
2539  fHistoTrueGammaPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC*weightMatBudgetGamma);
2540  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, posDaughter->GetMother(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
2541  // filling primary histograms
2542  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
2543  iPhotonMCInfo = 6;
2544  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2545  fHistoTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(),fWeightJetJetMC*weightMatBudgetGamma); // Allways Filled
2546  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
2547  } else {
2548  // filling secondary photon histograms
2549  iPhotonMCInfo = 2;
2550  if( Photon->GetMother(0) > -1 && fMCEvent->Particle(Photon->GetMother(0))->GetMother(0) > -1){
2551  if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
2552  iPhotonMCInfo = 4;
2553  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
2554  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
2555  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2556  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
2557  iPhotonMCInfo = 7;
2558  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
2559  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
2560  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2561  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
2562  iPhotonMCInfo = 5;
2563  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
2564  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
2565  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2566  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 221) {
2567  iPhotonMCInfo = 3;
2568  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2569  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2570  } else {
2571 // if ( !(TMath::Abs(fMCEvent->Particle(Photon->GetMother(0))->GetPdgCode()) == 11 && fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 22) ) {
2572  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2573  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2574 // }
2575  }
2576  } else {
2577  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2578  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2579  }
2580  }
2581 }
2582 //________________________________________________________________________
2584 {
2585  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2586  Double_t mcProdVtxX = primVtxMC->GetX();
2587  Double_t mcProdVtxY = primVtxMC->GetY();
2588  Double_t mcProdVtxZ = primVtxMC->GetZ();
2589 
2590  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2591 
2592  if (AODMCTrackArray){
2593  // Loop over all primary MC particle
2594  for(Int_t i = 0; i < AODMCTrackArray->GetEntriesFast(); i++) {
2595 
2596  AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
2597  if (!particle) continue;
2598 
2599  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, particle, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2600  if (isPrimary){
2601 
2602  Int_t isMCFromMBHeader = -1;
2603  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2604  isMCFromMBHeader
2605  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2606  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2607  }
2608 
2609  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
2610  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kFALSE)){
2611  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // All MC Gamma
2612  if(particle->GetMother() >-1){ // Meson Decay Gamma
2613  switch((static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother())))->GetPdgCode()){
2614  case 111: // Pi0
2615  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2616  break;
2617  case 113: // Rho0
2618  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2619  break;
2620  case 221: // Eta
2621  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2622  break;
2623  case 223: // Omega
2624  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2625  break;
2626  case 331: // Eta'
2627  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2628  break;
2629  case 333: // Phi
2630  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2631  break;
2632  case 3212: // Sigma
2633  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2634  break;
2635  }
2636  }
2637  }
2638  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kTRUE)){
2639  Double_t rConv = 0;
2640  for(Int_t daughterIndex=particle->GetDaughter(0);daughterIndex<=particle->GetDaughter(1);daughterIndex++){
2641  AliAODMCParticle *tmpDaughter = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(daughterIndex));
2642  if(!tmpDaughter) continue;
2643  if(TMath::Abs(tmpDaughter->GetPdgCode()) == 11){
2644  rConv = sqrt( (tmpDaughter->Xv()*tmpDaughter->Xv()) + (tmpDaughter->Yv()*tmpDaughter->Yv()) );
2645  }
2646  }
2647  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2648  if ( fDoPhotonQA > 0 && fIsMC < 2){
2650  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta(),fWeightJetJetMC);
2651  }
2652  }
2653  // Converted MC Gamma
2654  if(fDoMesonAnalysis){
2655 
2656  Double_t mesonY = 1.e30;
2657  Double_t ratio = 0;
2658  if (particle->E() != TMath::Abs(particle->Pz())){
2659  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2660  }
2661  if( !(ratio <= 0) ){
2662  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2663  }
2664 
2665  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
2666  if ( particle->GetPdgCode() == 211 ){ // positve pions
2667  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2668  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2669  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2670  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2671  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
2672  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
2673  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2674  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
2675  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),4.,fWeightJetJetMC);
2676  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
2677  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),5.,fWeightJetJetMC);
2678  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
2679  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),6.,fWeightJetJetMC);
2680  } else if ( TMath::Abs(particle->GetPdgCode()) == 223 ){ // Omega
2681  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),7.,fWeightJetJetMC);
2682  } else if ( TMath::Abs(particle->GetPdgCode()) == 333 ){ // Phi
2683  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),8.,fWeightJetJetMC);
2684  } else if ( TMath::Abs(particle->GetPdgCode()) == 113 ){ // Rho0
2685  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),9.,fWeightJetJetMC);
2686  }
2687  }
2688 
2689  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2690  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
2691  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
2692  Float_t weighted= 1;
2693  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2694  if (particle->Pt()>0.005){
2695  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, 0x0, fInputEvent);
2696  // if(particle->GetPdgCode() == 221){
2697  // cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
2698  // }
2699  }
2700  }
2701 
2702  Double_t mesonY = 1.e30;
2703  Double_t ratio = 0;
2704  if (particle->E() != TMath::Abs(particle->Pz())){
2705  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2706  }
2707  if( !(ratio <= 0) ){
2708  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2709  }
2710 
2711  Double_t alpha = -1;
2712  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
2713  alpha = TMath::Abs((daughter0->E() - daughter1->E()))/(daughter0->E() + daughter1->E());
2714  }
2715 
2716  if(particle->GetPdgCode() == 111){
2717  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Pi0
2718  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2719  if ( fIsMC > 1 ) fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
2720  if (fDoMesonQA > 0){
2721  if ( fIsMC < 2 )fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
2722  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
2723  if ( fIsMC == 2 ) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2724  }
2725  } else if(particle->GetPdgCode() == 221){
2726  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Eta
2727  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2728  if ( fIsMC > 1 ) fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2729  if (fDoMesonQA > 0){
2730  if ( fIsMC < 2 )fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
2731  fHistoMCEtaPtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
2732  if ( fIsMC == 2 ) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2733  }
2734  }
2735 
2736  // Check the acceptance for both gammas
2737  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
2738  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
2739  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2740  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2741 
2742  if(particle->GetPdgCode() == 111){
2743  if(fIsMC > 1) fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 with gamma in acc NOT weighted at all
2744  fHistoMCPi0WOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Pi0 with gamma in acc NOT weighted
2745  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc
2746  } else if(particle->GetPdgCode() == 221){
2747  if(fIsMC > 1) fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta with gamma in acc NOT weighted at all
2748  fHistoMCEtaWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Eta with gamma in acc NOT weighted
2749  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Eta with gamma in acc
2750  }
2751  }
2752  }
2753  }
2754  // fill secondary histograms
2755  } else {
2756  Int_t isMCFromMBHeader = -1;
2757  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2758  isMCFromMBHeader
2759  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2760  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2761  }
2762 
2763  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) {
2764  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kFALSE)){
2765  if (particle->GetMother() > -1) {
2766  AliAODMCParticle *tmpMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2767  if (tmpMother->GetMother() > -1) {
2768  AliAODMCParticle *tmpGrandMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(tmpMother->GetMother()));
2769  if(tmpGrandMother->GetPdgCode() == 310) {
2770  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2771  } else if (tmpGrandMother->GetPdgCode() == 130) {
2772  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2773  } else if (tmpGrandMother->GetPdgCode() == 3122) {
2774  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
2775  } else {
2776  if ( !(TMath::Abs(tmpMother->GetPdgCode()) == 11 && tmpGrandMother->GetPdgCode() == 22) )
2777  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2778  }
2779  } else {
2780  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2781  }
2782  } else {
2783  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2784  }
2785  }
2786 
2787  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kTRUE)){
2788  if (particle->GetMother() > -1) {
2789  AliAODMCParticle *tmpMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2790  if (tmpMother->GetMother() > -1) {
2791  AliAODMCParticle *tmpGrandMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(tmpMother->GetMother()));
2792  if(tmpGrandMother->GetPdgCode() == 310) {
2793  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2794  } else if (tmpGrandMother->GetPdgCode() == 130) {
2795  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2796  } else if (tmpGrandMother->GetPdgCode() == 3122) {
2797  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
2798  } else {
2799  if ( !(TMath::Abs(tmpMother->GetPdgCode()) == 11 && tmpGrandMother->GetPdgCode() == 22) )
2800  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2801  }
2802  } else {
2803  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2804  }
2805  } else {
2806  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2807  }
2808  }
2809  }
2810 
2811  if(fDoMesonAnalysis){
2812  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2813  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
2814  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
2815  AliAODMCParticle* mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2816  Int_t pdgCode = mother->GetPdgCode();
2817  if(particle->GetPdgCode() == 111){
2818  Int_t source = GetSourceClassification(111,pdgCode);
2819  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
2820  fHistoMCSecPi0Source[fiCut]->Fill(pdgCode);
2821  } else if(particle->GetPdgCode() == 221){
2822  fHistoMCSecEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2823  fHistoMCSecEtaSource[fiCut]->Fill(pdgCode);
2824  }
2825 
2826  // pi0 really in acceptance/
2827  if( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
2828  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
2829  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2830  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2831  if(particle->GetPdgCode() == 111){
2832  Int_t source = GetSourceClassification(111,pdgCode);
2833  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
2834  }
2835  }
2836  }
2837  }
2838  }
2839  }
2840  }
2841  return;
2842 }
2843 //________________________________________________________________________
2845 {
2846  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2847  Double_t mcProdVtxX = primVtxMC->GetX();
2848  Double_t mcProdVtxY = primVtxMC->GetY();
2849  Double_t mcProdVtxZ = primVtxMC->GetZ();
2850 // cout << mcProdVtxX <<"\t" << mcProdVtxY << "\t" << mcProdVtxZ << endl;
2851 
2852  // Loop over all primary MC particle
2853  for(Long_t i = 0; i < fMCEvent->GetNumberOfTracks(); i++) {
2854 
2855  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
2856  // fill primary histogram
2857  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
2858  if (!particle) continue;
2859 
2860  Int_t isMCFromMBHeader = -1;
2861  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2862  isMCFromMBHeader
2863  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2864  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2865  }
2866 
2867  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
2868  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
2869  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // All MC Gamma
2870  if(particle->GetMother(0) >-1){ // Meson Decay Gamma
2871  switch(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()){
2872  case 111: // Pi0
2873  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2874  break;
2875  case 113: // Rho0
2876  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2877  break;
2878  case 221: // Eta
2879  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2880  break;
2881  case 223: // Omega
2882  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2883  break;
2884  case 331: // Eta'
2885  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2886  break;
2887  case 333: // Phi
2888  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2889  break;
2890  case 3212: // Sigma
2891  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2892  break;
2893  }
2894  }
2895  }
2896  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kTRUE)){
2897  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2898  if (fDoPhotonQA > 0 && fIsMC < 2){
2899  fHistoMCConvGammaR[fiCut]->Fill(((TParticle*)fMCEvent->Particle(particle->GetFirstDaughter()))->R(),fWeightJetJetMC);
2900  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta(),fWeightJetJetMC);
2901  }
2902  } // Converted MC Gamma
2903  if(fDoMesonAnalysis){
2904 
2905  Double_t mesonY = 1.e30;
2906  Double_t ratio = 0;
2907  if (particle->Energy() != TMath::Abs(particle->Pz())){
2908  ratio = (particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz());
2909  }
2910  if( !(ratio <= 0) ){
2911  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2912  }
2913 
2914  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
2915  if ( particle->GetPdgCode() == 211 ){ // positve pions
2916  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2917  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2918  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2919  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2920  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
2921  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
2922  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2923  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
2924  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),4.,fWeightJetJetMC);
2925  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
2926  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),5.,fWeightJetJetMC);
2927  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
2928  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),6.,fWeightJetJetMC);
2929  } else if ( TMath::Abs(particle->GetPdgCode()) == 223 ){ // Omega
2930  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),7.,fWeightJetJetMC);
2931  } else if ( TMath::Abs(particle->GetPdgCode()) == 333 ){ // Phi
2932  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),8.,fWeightJetJetMC);
2933  } else if ( TMath::Abs(particle->GetPdgCode()) == 113 ){ // Rho0
2934  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),9.,fWeightJetJetMC);
2935  }
2936  }
2937 
2939  ->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2940  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
2941  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
2942 
2943  Float_t weighted= 1;
2944  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2945  if (particle->Pt()>0.005){
2946  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
2947  // if(particle->GetPdgCode() == 221){
2948  // cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
2949  // }
2950  }
2951  }
2952  Double_t mesonY = 1.e30;
2953  Double_t ratio = 0;
2954  if (particle->Energy() != TMath::Abs(particle->Pz())){
2955  ratio = (particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz());
2956  }
2957  if( !(ratio <= 0) ){
2958  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2959  }
2960 
2961  Double_t alpha = -1;
2962  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
2963  alpha = TMath::Abs((daughter0->Energy() - daughter1->Energy()))/(daughter0->Energy() + daughter1->Energy());
2964  }
2965 
2966  if(particle->GetPdgCode() == 111){
2967  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Pi0
2968  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2969  if (fIsMC > 1) fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
2970  if (fDoMesonQA > 0){
2971  if (fIsMC < 2)fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
2972  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
2973  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2974  }
2975  } else if(particle->GetPdgCode() == 221){
2976  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Eta
2977  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2978  if (fIsMC > 1) fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2979  if (fDoMesonQA > 0){
2980  if (fIsMC < 2)fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
2981  fHistoMCEtaPtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
2982  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2983  }
2984  }
2985 
2986  // Check the acceptance for both gammas & whether they are counted as primaries as well
2987  Bool_t kDaughter0IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetFirstDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2988  Bool_t kDaughter1IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetLastDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2989 
2990  if( kDaughter0IsPrim && kDaughter1IsPrim &&
2991  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter0,fMCEvent,kFALSE) &&
2992  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter1,fMCEvent,kFALSE) &&
2993  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2994  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2995 
2996  if(particle->GetPdgCode() == 111){
2997  if(fIsMC > 1) fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 with gamma in acc NOT weighted at all
2998  fHistoMCPi0WOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Pi0 with gamma in acc NOT weighted
2999  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc
3000  } else if(particle->GetPdgCode() == 221){
3001  if(fIsMC > 1) fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta with gamma in acc NOT weighted at all
3002  fHistoMCEtaWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Eta with gamma in acc NOT weighted
3003  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Eta with gamma in acc
3004  }
3005  }
3006  }
3007  }
3008  } else {
3009  // fill secondary histograms
3010  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
3011  if (!particle) continue;
3012 
3013  Int_t isMCFromMBHeader = -1;
3014  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3015  isMCFromMBHeader
3016  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
3017  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3018  }
3019 
3020  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)){
3021  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
3022  if (particle->GetMother(0) > -1 && fMCEvent->Particle(particle->GetMother(0))->GetMother(0) > -1) {
3023  if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
3024  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
3025  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
3026  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
3027  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
3028  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3029  } else {
3030  if ( !(TMath::Abs(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()) == 11 && fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 22) )
3031  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3032  }
3033  } else {
3034  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3035  }
3036  }
3037 
3038  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kTRUE)){
3039  if (particle->GetMother(0) > -1 && fMCEvent->Particle(particle->GetMother(0))->GetMother(0) > -1) {
3040  if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
3041  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
3042  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
3043  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
3044  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
3045  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
3046  } else {
3047  if ( !(TMath::Abs(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()) == 11 && fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 22) )
3048  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3049  }
3050  } else {
3051  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
3052  }
3053  }
3054  }
3055 
3056  if(fDoMesonAnalysis){
3057  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3058  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
3059  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
3060  Int_t pdgCode = -1;
3061  if(particle->GetFirstMother()>-1) pdgCode = ((TParticle*)fMCEvent->Particle( particle->GetFirstMother() ))->GetPdgCode();
3062  if(particle->GetPdgCode() == 111){
3063  Int_t source = GetSourceClassification(111,pdgCode);
3064  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
3065 
3066  Double_t deltaX = particle->Vx() - mcProdVtxX;
3067  Double_t deltaY = particle->Vy() - mcProdVtxY;
3068  Double_t deltaZ = particle->Vz() - mcProdVtxZ;
3069  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
3070  if(fDoMesonQA > 0 && fIsMC < 2) fHistoMCSecPi0RvsSource[fiCut]->Fill(realRadius3D,source);
3071  fHistoMCSecPi0Source[fiCut]->Fill(pdgCode);
3072  } else if(particle->GetPdgCode() == 221){
3073  fHistoMCSecEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
3074  fHistoMCSecEtaSource[fiCut]->Fill(pdgCode);
3075  }
3076 
3077  // pi0 really in acceptance/
3078  if( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter0,fMCEvent,kFALSE) &&
3079  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter1,fMCEvent,kFALSE) &&
3080  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
3081  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
3082  if(particle->GetPdgCode() == 111){
3083  Int_t source = GetSourceClassification(111,pdgCode);
3084  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
3085  }
3086  }
3087  }
3088  }
3089  }
3090  }
3091 }
3092 
3093 //________________________________________________________________________
3095 
3096  // Conversion Gammas
3097  if(fGammaCandidates->GetEntries()>1){
3098  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries()-1;firstGammaIndex++){
3099  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
3100  if (gamma0==NULL) continue;
3101  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGammaCandidates->GetEntries();secondGammaIndex++){
3102  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(secondGammaIndex));
3103  //Check for same Electron ID
3104  if (gamma1==NULL) continue;
3105  if(gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelPositive() ||
3106  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelNegative() ||
3107  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelPositive() ||
3108  gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelNegative() ) continue;
3109 
3110  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0,gamma1);
3111  pi0cand->SetLabels(firstGammaIndex,secondGammaIndex);
3112  pi0cand->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3113 
3114  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3115  if(fDoCentralityFlat > 0){
3116  fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3117  if(TMath::Abs(pi0cand->GetAlpha())<0.1) fHistoMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3118  } else {
3119  fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(),fWeightJetJetMC);
3120  if(TMath::Abs(pi0cand->GetAlpha())<0.1) fHistoMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E(),fWeightJetJetMC);
3121  }
3122 
3123  if (fDoMesonQA > 0){
3124 
3125  if(fDoMesonQA == 3 && TMath::Abs(gamma0->GetConversionRadius()-gamma1->GetConversionRadius())<10 && pi0cand->GetOpeningAngle()<0.1){
3126  Double_t sparesFill[4] = {gamma0->GetPhotonPt(),gamma0->GetConversionRadius(),TMath::Abs(gamma0->GetConversionRadius()-gamma1->GetConversionRadius()),pi0cand->GetOpeningAngle()};
3127  sPtRDeltaROpenAngle[fiCut]->Fill(sparesFill, 1);
3128  }
3129 
3130  if ( pi0cand->M() > 0.05 && pi0cand->M() < 0.17){
3131  if (fIsMC < 2){
3132  fHistoMotherPi0PtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3133  fHistoMotherPi0PtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());
3134  }
3135  fHistoMotherPi0PtAlpha[fiCut]->Fill(pi0cand->Pt(),TMath::Abs(pi0cand->GetAlpha()),fWeightJetJetMC);
3136 
3137  }
3138  if ( pi0cand->M() > 0.45 && pi0cand->M() < 0.65){
3139  if (fIsMC < 2){
3140  fHistoMotherEtaPtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3141  fHistoMotherEtaPtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());
3142  }
3143  fHistoMotherEtaPtAlpha[fiCut]->Fill(pi0cand->Pt(),TMath::Abs(pi0cand->GetAlpha()),fWeightJetJetMC);
3144  }
3145  }
3146  if(fDoTHnSparse && ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
3147  Int_t psibin = 0;
3148  Int_t zbin = 0;
3149  Int_t mbin = 0;
3150 
3151  Double_t sparesFill[4];
3152  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
3153  zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3154  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3156  } else {
3157  mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
3158  }
3159  sparesFill[0] = pi0cand->M();
3160  sparesFill[1] = pi0cand->Pt();
3161  sparesFill[2] = (Double_t)zbin;
3162  sparesFill[3] = (Double_t)mbin;
3163  } else {
3164  psibin = fBGHandlerRP[fiCut]->GetRPBinIndex(TMath::Abs(fEventPlaneAngle));
3165  zbin = fBGHandlerRP[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3166 // if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3167 // mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
3168 // } else {
3169 // mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
3170 // }
3171  sparesFill[0] = pi0cand->M();
3172  sparesFill[1] = pi0cand->Pt();
3173  sparesFill[2] = (Double_t)zbin;
3174  sparesFill[3] = (Double_t)psibin;
3175  }
3176 // Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
3177  if(fDoCentralityFlat > 0) sESDMotherInvMassPtZM[fiCut]->Fill(sparesFill, fWeightCentrality[fiCut]*fWeightJetJetMC); //instead of weight 1
3178  else sESDMotherInvMassPtZM[fiCut]->Fill(sparesFill, fWeightJetJetMC);
3179  }
3180 
3181 
3182  if( fIsMC > 0 ){
3183  if(fInputEvent->IsA()==AliESDEvent::Class())
3184  ProcessTrueMesonCandidates(pi0cand,gamma0,gamma1);
3185  if(fInputEvent->IsA()==AliAODEvent::Class())
3186  ProcessTrueMesonCandidatesAOD(pi0cand,gamma0,gamma1);
3187  }
3188  if (fDoMesonQA == 2){
3189  fInvMass = pi0cand->M();
3190  fPt = pi0cand->Pt();
3191  if (TMath::Abs(gamma0->GetDCAzToPrimVtx()) < TMath::Abs(gamma1->GetDCAzToPrimVtx())){
3192  fDCAzGammaMin = gamma0->GetDCAzToPrimVtx();
3193  fDCAzGammaMax = gamma1->GetDCAzToPrimVtx();
3194  } else {
3195  fDCAzGammaMin = gamma1->GetDCAzToPrimVtx();
3196  fDCAzGammaMax = gamma0->GetDCAzToPrimVtx();
3197  }
3198  iFlag = pi0cand->GetMesonQuality();
3199  // cout << "gamma 0: " << gamma0->GetV0Index()<< "\t" << gamma0->GetPx() << "\t" << gamma0->GetPy() << "\t" << gamma0->GetPz() << "\t" << endl;
3200  // cout << "gamma 1: " << gamma1->GetV0Index()<< "\t"<< gamma1->GetPx() << "\t" << gamma1->GetPy() << "\t" << gamma1->GetPz() << "\t" << endl;
3201  // cout << "pi0: "<<fInvMass << "\t" << fPt <<"\t" << fDCAzGammaMin << "\t" << fDCAzGammaMax << "\t" << (Int_t)iFlag << "\t" << (Int_t)iMesonMCInfo <<endl;
3202  if (fIsHeavyIon == 1 && fPt > 0.399 && fPt < 20. ) {
3203  if (fInvMass > 0.08 && fInvMass < 0.2) tESDMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
3204  if ((fInvMass > 0.45 && fInvMass < 0.6) && (fPt > 0.999 && fPt < 20.) )tESDMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
3205  } else if (fPt > 0.299 && fPt < 20. ) {
3206  if ( (fInvMass > 0.08 && fInvMass < 0.6) ) tESDMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
3207  }
3208  }
3209  }
3210  delete pi0cand;
3211  pi0cand=0x0;
3212  }
3213  }
3214  }
3215 }
3216 
3217 //______________________________________________________________________
3219 {
3220  // Process True Mesons
3221  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3222  Double_t mcProdVtxX = primVtxMC->GetX();
3223  Double_t mcProdVtxY = primVtxMC->GetY();
3224  Double_t mcProdVtxZ = primVtxMC->GetZ();
3225 
3226  iMesonMCInfo = 0;
3227  if(TrueGammaCandidate0->GetV0Index()<fInputEvent->GetNumberOfV0s()){
3228  Bool_t isTruePi0 = kFALSE;
3229  Bool_t isTrueEta = kFALSE;
3230  Bool_t isTruePi0Dalitz = kFALSE;
3231  Bool_t isTrueEtaDalitz = kFALSE;
3232  Bool_t gamma0DalitzCand = kFALSE;
3233  Bool_t gamma1DalitzCand = kFALSE;
3234  Int_t gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCEvent);
3235  Int_t gamma0MotherLabel = -1;
3236  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3237  // Daughters Gamma 0
3238  TParticle * negativeMC = (TParticle*)TrueGammaCandidate0->GetNegativeMCDaughter(fMCEvent);
3239  TParticle * positiveMC = (TParticle*)TrueGammaCandidate0->GetPositiveMCDaughter(fMCEvent);
3240  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
3241  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3242  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
3243  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
3244  gamma0MotherLabel=gammaMC0->GetFirstMother();
3245  }
3246  }
3247  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
3248  gamma0DalitzCand = kTRUE;
3249  gamma0MotherLabel=-111;
3250  }
3251  if(gammaMC0->GetPdgCode() ==221){ // Dalitz candidate
3252  gamma0DalitzCand = kTRUE;
3253  gamma0MotherLabel=-221;
3254  }
3255  }
3256  }
3257  if(TrueGammaCandidate1->GetV0Index()<fInputEvent->GetNumberOfV0s()){
3258  Int_t gamma1MCLabel = TrueGammaCandidate1->GetMCParticleLabel(fMCEvent);
3259  Int_t gamma1MotherLabel = -1;
3260  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3261  // Daughters Gamma 1
3262  TParticle * negativeMC = (TParticle*)TrueGammaCandidate1->GetNegativeMCDaughter(fMCEvent);
3263  TParticle * positiveMC = (TParticle*)TrueGammaCandidate1->GetPositiveMCDaughter(fMCEvent);
3264  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
3265  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3266  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
3267  if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
3268  gamma1MotherLabel=gammaMC1->GetFirstMother();
3269  }
3270  }
3271  if(gammaMC1->GetPdgCode() ==111 ){ // Dalitz candidate
3272  gamma1DalitzCand = kTRUE;
3273  gamma1MotherLabel=-111;
3274  }
3275  if(gammaMC1->GetPdgCode() ==221){ // Dalitz candidate
3276  gamma1DalitzCand = kTRUE;
3277  gamma1MotherLabel=-221;
3278  }
3279  }
3280  }
3281  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3282  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
3283  isTruePi0=kTRUE;
3284  if (CheckVectorForDoubleCount(vecDoubleCountTruePi0s,gamma0MotherLabel)){
3285  fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3287  }
3288  }
3289  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 221){
3290  isTrueEta=kTRUE;
3291  if (CheckVectorForDoubleCount(vecDoubleCountTrueEtas,gamma0MotherLabel)){
3292  fHistoDoubleCountTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3294  }
3295  }
3296  }
3297 
3298  //Identify Dalitz candidate
3299  if (gamma1DalitzCand || gamma0DalitzCand){
3300  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
3301  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
3302  if (gamma0MotherLabel == -221) isTrueEtaDalitz = kTRUE;
3303  }
3304  if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
3305  if (gamma1MotherLabel == -111) isTruePi0Dalitz = kTRUE;
3306  if (gamma1MotherLabel == -221) isTrueEtaDalitz = kTRUE;
3307  }
3308  }
3309 
3310 
3311  if(isTruePi0 || isTrueEta){// True Pion or Eta
3312 
3313  Float_t weightMatBudget = 1.;
3314  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
3315  weightMatBudget = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueGammaCandidate0) * ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueGammaCandidate1);
3316  }
3317 
3318  fHistoTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightMatBudget*fWeightJetJetMC);
3319  if (fDoMesonQA > 0){
3320  if (isTruePi0){
3321  if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
3322  if(fIsMC < 2){
3323  fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3324  fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3325  }
3326  fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()),fWeightJetJetMC);
3327 
3328  }
3329  } else if (isTrueEta){
3330  if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
3331  if(fIsMC < 2){
3332  fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3333  fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3334  }
3335  fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()),fWeightJetJetMC);
3336  }
3337  }
3338  }
3339 
3340  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, gamma0MotherLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3341 
3342  if(!isPrimary && gamma1MotherLabel>-1){ // Secondary Meson
3343  Long_t secMotherLabel = ((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetMother(0);
3344  Float_t weightedSec= 1;
3345  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, fMCEvent, fInputEvent) && fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310){
3346  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
3347  //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3348  }
3349  fHistoTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3350  iMesonMCInfo = 2;
3351  if (secMotherLabel >-1){
3352  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310){
3353  iMesonMCInfo = 4;
3354  fHistoTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3355  if (fDoMesonQA > 0 && fIsMC < 2 )fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3356  }
3357  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==130){
3358  iMesonMCInfo = 8;
3359  fHistoTrueSecondaryMotherFromK0lInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3360  if (fDoMesonQA > 0 && fIsMC < 2 )fHistoTrueK0lWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3361  }
3362  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==221){
3363  iMesonMCInfo = 3;
3364  fHistoTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3365  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3366  }
3367  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==3122){
3368  iMesonMCInfo = 7;
3369  fHistoTrueSecondaryMotherFromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3370  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3371  }
3372  }
3373  } else { // Only primary pi0 for efficiency calculation
3374  iMesonMCInfo = 6;
3375  Float_t weighted= 1;
3376  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCEvent, fInputEvent)){
3377  if (((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt()>0.005){
3378  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, fMCEvent, fInputEvent);
3379  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3380  }
3381  }
3382 
3383  fHistoTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget*fWeightJetJetMC);
3384  fHistoTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3385  pESDTruePrimaryMotherWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget*fWeightJetJetMC);
3386 
3387 
3388  if (fDoMesonQA > 0 && fIsMC < 2){
3389  if(isTruePi0){ // Only primary pi0 for resolution
3390  fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted*weightMatBudget);
3391  }
3392  if (isTrueEta){ // Only primary eta for resolution
3393  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted*weightMatBudget);
3394  }
3395  }
3396  }
3397  } else if(!isTruePi0 && !isTrueEta){ // Background
3398  if (fDoMesonQA > 0 && fIsMC < 2){
3399  if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
3400  fHistoTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3401  iMesonMCInfo = 1;
3402  } else { // No photon or without mother
3403  fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3404  }
3405  }
3406  if( isTruePi0Dalitz || isTrueEtaDalitz ){
3407  // Dalitz
3408  iMesonMCInfo = 5;
3409  if (fIsMC < 2) fHistoTrueMotherDalitzInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3410  } else if (gamma0DalitzCand || gamma1DalitzCand){
3411  if (fDoMesonQA > 0 && fIsMC < 2) fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3412  }
3413  }
3414  }
3415  }
3416 }
3417 
3418 //______________________________________________________________________
3420 {
3421  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3422  Double_t mcProdVtxX = primVtxMC->GetX();
3423  Double_t mcProdVtxY = primVtxMC->GetY();
3424  Double_t mcProdVtxZ = primVtxMC->GetZ();
3425 
3426  // Process True Mesons
3427  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3428  Bool_t isTruePi0 = kFALSE;
3429  Bool_t isTrueEta = kFALSE;
3430  Bool_t isTruePi0Dalitz = kFALSE;
3431  Bool_t isTrueEtaDalitz = kFALSE;
3432  Bool_t gamma0DalitzCand = kFALSE;
3433  Bool_t gamma1DalitzCand = kFALSE;
3434 
3435  if (AODMCTrackArray!=NULL && TrueGammaCandidate0 != NULL){
3436  AliAODMCParticle *positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
3437  AliAODMCParticle *negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
3438 
3439  iMesonMCInfo = 0;
3440  Int_t gamma0MCLabel = -1;
3441  Int_t gamma0MotherLabel = -1;
3442  if(!positiveMC||!negativeMC)
3443  return;
3444 
3445  if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
3446  gamma0MCLabel = positiveMC->GetMother();
3447  }
3448 
3449  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3450  // Daughters Gamma 0
3451  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3452  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3453  if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
3454  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
3455  gamma0MotherLabel=gammaMC0->GetMother();
3456  }
3457  }
3458  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
3459  gamma0DalitzCand = kTRUE;
3460  gamma0MotherLabel=-111;
3461  }
3462  if(gammaMC0->GetPdgCode() ==221){ // Dalitz candidate
3463  gamma0DalitzCand = kTRUE;
3464  gamma0MotherLabel=-221;
3465  }
3466  }
3467  }
3468  positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelPositive()));
3469  negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelNegative()));
3470 
3471  Int_t gamma1MCLabel = -1;
3472  Int_t gamma1MotherLabel = -1;
3473  if(!positiveMC||!negativeMC)
3474  return;
3475 
3476  if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
3477  gamma1MCLabel = positiveMC->GetMother();
3478  }
3479  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3480  // Daughters Gamma 1
3481  AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3482  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3483  if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
3484  if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
3485  gamma1MotherLabel=gammaMC1->GetMother();
3486  }
3487  }
3488  if(gammaMC1->GetPdgCode() ==111 ){ // Dalitz candidate
3489  gamma1DalitzCand = kTRUE;
3490  gamma1MotherLabel=-111;
3491  }
3492  if(gammaMC1->GetPdgCode() ==221){ // Dalitz candidate
3493  gamma1DalitzCand = kTRUE;
3494  gamma1MotherLabel=-221;
3495  }
3496  }
3497  }
3498  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3499  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
3500  isTruePi0=kTRUE;
3501  if (CheckVectorForDoubleCount(vecDoubleCountTruePi0s,gamma0MotherLabel)){
3502  fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3504  }
3505  }
3506  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 221){
3507  isTrueEta=kTRUE;
3508  if (CheckVectorForDoubleCount(vecDoubleCountTrueEtas,gamma0MotherLabel)){
3509  fHistoDoubleCountTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3511  }
3512  }
3513  }
3514 
3515  //Identify Dalitz candidate
3516  if (gamma1DalitzCand || gamma0DalitzCand){
3517  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
3518  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
3519  if (gamma0MotherLabel == -221) isTrueEtaDalitz = kTRUE;
3520  }
3521  if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
3522  if (gamma1MotherLabel == -111) isTruePi0Dalitz = kTRUE;
3523  if (gamma1MotherLabel == -221) isTrueEtaDalitz = kTRUE;
3524  }
3525  }
3526 
3527  if(isTruePi0 || isTrueEta){// True Pion or Eta
3528 
3529  Float_t weightMatBudget = 1.;
3530  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
3531  weightMatBudget = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueGammaCandidate0) * ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueGammaCandidate1);
3532  }
3533 
3534  fHistoTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightMatBudget*fWeightJetJetMC);
3535  if (fDoMesonQA > 0){
3536  if (isTruePi0){
3537  if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
3538  if(fIsMC < 2){
3539  fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3540  fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3541  }
3542  fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()),fWeightJetJetMC);
3543  }
3544  } else if (isTrueEta){
3545  if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
3546  if(fIsMC < 2){
3547  fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3548  fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3549  }
3550  fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()),fWeightJetJetMC);
3551  }
3552  }
3553  }
3554  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel)), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3555 
3556  if(!isPrimary){ // Secondary Meson
3557  Long_t secMotherLabel = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetMother();
3558  Float_t weightedSec= 1;
3559  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, 0x0, fInputEvent) && static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
3560  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
3561  //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3562  }
3563  fHistoTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3564  iMesonMCInfo = 2;
3565  if (secMotherLabel >-1){
3566  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
3567  iMesonMCInfo = 4;
3568  fHistoTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3569  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3570  }
3571  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==130){
3572  iMesonMCInfo = 8;
3573  fHistoTrueSecondaryMotherFromK0lInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3574  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueK0lWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3575  }
3576  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==221){
3577  iMesonMCInfo = 3;
3578  fHistoTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3579  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3580  }
3581  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==3122){
3582  iMesonMCInfo = 7;
3583  fHistoTrueSecondaryMotherFromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3584  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3585  }
3586  }
3587  } else { // Only primary pi0 for efficiency calculation
3588  Float_t weighted= 1;
3589  iMesonMCInfo = 6;
3590  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, 0x0, fInputEvent)){
3591  if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt()>0.005){
3592  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, 0x0, fInputEvent);
3593  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3594  }
3595  }
3596  fHistoTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget*fWeightJetJetMC);
3597  fHistoTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3598  pESDTruePrimaryMotherWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget*fWeightJetJetMC);
3599 
3600  if (fDoMesonQA > 0 && fIsMC < 2){
3601  if(isTruePi0){ // Only primary pi0 for resolution
3602  fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
3603  (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted*weightMatBudget);
3604 
3605  }
3606  if (isTrueEta){ // Only primary eta for resolution
3607  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
3608  (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted*weightMatBudget);
3609  }
3610  }
3611  }
3612  } else if(!isTruePi0 && !isTrueEta) { // Background
3613  if (fDoMesonQA > 0 && fIsMC < 2){
3614  if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
3615  fHistoTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3616  iMesonMCInfo = 1;
3617  } else { // No photon or without mother
3618  fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3619  }
3620  }
3621  if( isTruePi0Dalitz || isTrueEtaDalitz ){
3622  // Dalitz
3623  iMesonMCInfo = 5;
3624  if (fIsMC < 2)fHistoTrueMotherDalitzInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3625  } else if (gamma0DalitzCand || gamma1DalitzCand){
3626  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3627  }
3628  }
3629  }
3630  return;
3631 }
3632 //________________________________________________________________________
3634 
3635  Int_t zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3636  Int_t mbin = 0;
3637 
3638  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3640  } else {
3641  mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
3642  }
3643 
3644  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseRotationMethod()){
3645 
3646  for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
3647  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
3648  for(Int_t iCurrent2=iCurrent+1;iCurrent2<fGammaCandidates->GetEntries();iCurrent2++){
3649  for(Int_t nRandom=0;nRandom<((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents();nRandom++){
3650  AliAODConversionPhoton currentEventGoodV02 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent2));
3651 
3652  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGProbability()){
3653  AliAODConversionMother *backgroundCandidateProb = new AliAODConversionMother(&currentEventGoodV0,&currentEventGoodV02);
3654  Double_t massBGprob = backgroundCandidateProb->M();
3655  if(massBGprob>0.1 && massBGprob<0.14){
3656  if(fRandom.Rndm()>fBGHandler[fiCut]->GetBGProb(zbin,mbin)){
3657  delete backgroundCandidateProb;
3658  continue;
3659  }
3660  }
3661  delete backgroundCandidateProb;
3662  backgroundCandidateProb = 0x0;
3663  }
3664 
3665  RotateParticle(&currentEventGoodV02);
3666  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&currentEventGoodV02);
3667  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3669  ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3670  if(fDoCentralityFlat > 0) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3671  else fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(),fWeightJetJetMC);
3672  if(fDoTHnSparse){
3673  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3674  if(fDoCentralityFlat > 0) sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightCentrality[fiCut]*fWeightJetJetMC); //instead of weight 1
3675  else sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightJetJetMC);
3676  }
3677  }
3678  delete backgroundCandidate;
3679  backgroundCandidate = 0x0;
3680  }
3681  }
3682  }
3683  } else {
3685 
3686  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3687  for(Int_t nEventsInBG=0;nEventsInBG<fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
3688  AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
3689  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3690  bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
3691  }
3692 
3693  for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
3694  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
3695  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3696  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
3697  if(fMoveParticleAccordingToVertex == kTRUE){
3698  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3699  }
3700  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3701  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
3702  }
3703 
3704  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
3705  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3707  ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3708  if(fDoCentralityFlat > 0) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3709  else fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(),fWeightJetJetMC);
3710  if(fDoTHnSparse){
3711  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3712  if(fDoCentralityFlat > 0) sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightCentrality[fiCut]*fWeightJetJetMC); //instead of weight 1
3713  else sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightJetJetMC);
3714  }
3715  }
3716  delete backgroundCandidate;
3717  backgroundCandidate = 0x0;
3718  }
3719  }
3720  }
3721  } else {
3722  for(Int_t nEventsInBG=0;nEventsInBG <fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
3723  AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
3724  if(previousEventV0s){
3725  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3726  bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
3727  }
3728  for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
3729  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
3730  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3731 
3732  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
3733 
3734  if(fMoveParticleAccordingToVertex == kTRUE){
3735  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3736  }
3737  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3738  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
3739  }
3740 
3741 
3742  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
3743  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3745  ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3746  if(fDoCentralityFlat > 0) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3747  else fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(),fWeightJetJetMC);
3748  if(fDoTHnSparse){
3749  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3750  if(fDoCentralityFlat > 0) sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightCentrality[fiCut]*fWeightJetJetMC); //instead of weight 1
3751  else sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightJetJetMC);
3752  }
3753  }
3754  delete backgroundCandidate;
3755  backgroundCandidate = 0x0;
3756  }
3757  }
3758  }
3759  }
3760  }
3761  }
3762 }
3763 //________________________________________________________________________
3765 
3766  Int_t psibin = 0;
3767  Int_t zbin = 0;
3768 
3769  if(fDoTHnSparse){
3770  psibin = fBGHandlerRP[fiCut]->GetRPBinIndex(TMath::Abs(fEventPlaneAngle));
3771  zbin = fBGHandlerRP[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3772 // if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3773 // mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
3774 // } else {
3775 // mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
3776 // }
3777  }
3778 
3779  //Rotation Method
3780  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseRotationMethod()){
3781  // Correct for the number of rotations
3782  // BG is for rotation the same, except for factor NRotations
3783  Double_t weight=1./Double_t(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents());
3784 
3785  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
3786 
3787  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
3788  if (gamma0==NULL) continue;
3789  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGammaCandidates->GetEntries();secondGammaIndex++){
3790  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(secondGammaIndex));
3791  if (gamma1 == NULL) continue;
3792  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelected(gamma1,fInputEvent))continue;
3793  for(Int_t nRandom=0;nRandom<((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents();nRandom++){
3794  RotateParticle(gamma1);
3795  AliAODConversionMother backgroundCandidate(gamma0,gamma1);
3796  backgroundCandidate.CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3797  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(&backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3798  if(fDoCentralityFlat > 0) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3799  else fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt(),fWeightJetJetMC);
3800  if(fDoTHnSparse){
3801 // Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)mbin};
3802  Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)psibin};
3804  else sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,weight*fWeightJetJetMC);
3805  }
3806  }
3807  }
3808  }
3809  }
3810 
3811  } else {
3812  // Do Event Mixing
3813  for(Int_t nEventsInBG=0;nEventsInBG <fBGHandlerRP[fiCut]->GetNBGEvents(fGammaCandidates,fInputEvent);nEventsInBG++){
3814 
3816 
3817  if(previousEventGammas){
3818  // test weighted background
3819  Double_t weight=1.0;
3820  // Correct for the number of eventmixing:
3821  // N gammas -> (N-1) + (N-2) +(N-3) ...+ (N-(N-1)) using sum formula sum(i)=N*(N-1)/2 -> N*(N-1)/2
3822  // real combinations (since you cannot combine a photon with its own)
3823  // but BG leads to N_{a}*N_{b} combinations
3824  weight*=0.5*(Double_t(fGammaCandidates->GetEntries()-1))/Double_t(previousEventGammas->size());
3825 
3826  for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
3827 
3829 
3830  for(UInt_t iPrevious=0;iPrevious<previousEventGammas->size();iPrevious++){
3831 
3832  AliAODConversionPhoton *gamma1 = (AliAODConversionPhoton*)(previousEventGammas->at(iPrevious));
3833 
3834  AliAODConversionMother backgroundCandidate(gamma0,gamma1);
3835  backgroundCandidate.CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3837  ->MesonIsSelected(&backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3838  if(fDoCentralityFlat > 0) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3839  else fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt(),fWeightJetJetMC);
3840  if(fDoTHnSparse){
3841 // Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)mbin};
3842  Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)psibin};
3844  else sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,weight*fWeightJetJetMC);
3845  }
3846  }
3847  }
3848  }
3849  }
3850  }
3851  }
3852 }
3853 
3854 //________________________________________________________________________
3856  Int_t fNDegreesPMBackground= ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->NDegreesRotation();
3857  Double_t nRadiansPM = fNDegreesPMBackground*TMath::Pi()/180;
3858  Double_t rotationValue = fRandom.Rndm()*2*nRadiansPM + TMath::Pi()-nRadiansPM;
3859  gamma->RotateZ(rotationValue);
3860 }
3861 
3862 //________________________________________________________________________
3864 
3865  previousEventEP=previousEventEP+TMath::Pi();
3866  thisEventEP=thisEventEP+TMath::Pi();
3867  Double_t rotationValue= thisEventEP-previousEventEP;
3868  gamma->RotateZ(rotationValue);
3869 }
3870 
3871 //________________________________________________________________________
3873  //see header file for documentation
3874 
3875  Double_t dx = vertex->fX - fInputEvent->GetPrimaryVertex()->GetX();
3876  Double_t dy = vertex->fY - fInputEvent->GetPrimaryVertex()->GetY();
3877  Double_t dz = vertex->fZ - fInputEvent->GetPrimaryVertex()->GetZ();
3878 
3879  Double_t movedPlace[3] = {particle->GetConversionX() - dx,particle->GetConversionY() - dy,particle->GetConversionZ() - dz};
3880  particle->SetConversionPoint(movedPlace);
3881 }
3882 
3883 //________________________________________________________________________
3885  //see header file for documentation
3886  if(fGammaCandidates->GetEntries() >0 ){
3887  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3888  fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),fEventPlaneAngle);
3889  }
3890  else{ // means we use #V0s for multiplicity
3891  fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGammaCandidates->GetEntries(),fEventPlaneAngle);
3892  }
3893  }
3894 }
3895 
3896 //________________________________________________________________________