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