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