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