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