AliPhysics  04715ba (04715ba)
 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 
876  fHistoConvGammaPt[iCut]->Sumw2();
877  }
878 
879  if (fIsMC > 1){
880  fHistoNEvents[iCut]->Sumw2();
881  fHistoNGoodESDTracks[iCut]->Sumw2();
882  fHistoVertexZ[iCut]->Sumw2();
883  fHistoEtaShift[iCut]->Sumw2();
885  fHistoCentrality[iCut]->Sumw2();
886  }
887  }
888 
890  fHistoCaloGammaPt[iCut] = new TH1F("ClusGamma_Pt","ClusGamma_Pt",500,0,50);
891  fHistoCaloGammaPt[iCut]->SetXTitle("p_{T,clus}(GeV/c)");
892  fESDList[iCut]->Add(fHistoCaloGammaPt[iCut]);
893  if (fIsMC > 1) fHistoCaloGammaPt[iCut]->Sumw2();
894  fHistoCaloGammaE[iCut] = new TH1F("ClusGamma_E","ClusGamma_E",500,0,50);
895  fHistoCaloGammaE[iCut]->SetXTitle("E_{clus}(GeV)");
896  fESDList[iCut]->Add(fHistoCaloGammaE[iCut]);
897  if (fIsMC > 1) fHistoCaloGammaE[iCut]->Sumw2();
898  }
899 
900  if (fDoPhotonQA == 2){
901  fPhotonDCAList[iCut] = new TList();
902  fPhotonDCAList[iCut]->SetName(Form("%s_%s_%s Photon DCA tree",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringMeson.Data()));
903  fPhotonDCAList[iCut]->SetOwner(kTRUE);
904  fCutFolder[iCut]->Add(fPhotonDCAList[iCut]);
905 
906  tESDConvGammaPtDcazCat[iCut]= new TTree("ESD_ConvGamma_Pt_Dcaz_R_Eta","ESD_ConvGamma_Pt_Dcaz_R_Eta_Cat");
907  tESDConvGammaPtDcazCat[iCut]->Branch("Pt",&fPtGamma,"fPtGamma/F");
908  tESDConvGammaPtDcazCat[iCut]->Branch("DcaZPhoton",&fDCAzPhoton,"fDCAzPhoton/F");
909  // tESDConvGammaPtDcazCat[iCut]->Branch("R",&fRConvPhoton,"fRConvPhoton/F");
910  // tESDConvGammaPtDcazCat[iCut]->Branch("Eta",&fEtaPhoton,"fEtaPhoton/F");
911 
912  tESDConvGammaPtDcazCat[iCut]->Branch("cat",&iCatPhoton,"iCatPhoton/b");
913  if(fIsMC>0){
914  tESDConvGammaPtDcazCat[iCut]->Branch("photonMCInfo",&iPhotonMCInfo,"iPhotonMCInfo/b");
915  }
916  if (fIsMC > 1){
917  tESDConvGammaPtDcazCat[iCut]->Branch("weightEvent",&fWeightJetJetMC,"fWeightJetJetMC/b");
918  }
919 
920  fPhotonDCAList[iCut]->Add(tESDConvGammaPtDcazCat[iCut]);
921  }
922 
923  if(fDoPhotonQA > 0 && fIsMC < 2){
924 
925  fHistoConvGammaPsiPairPt[iCut]= new TH2F("ESD_ConvGamma_PsiPair_Pt","ESD_ConvGamma_PsiPair_Pt",500,0,5,250,0,25);
926  if(fDoCentralityFlat > 0) fHistoConvGammaPsiPairPt[iCut]->Sumw2();
927  fESDList[iCut]->Add(fHistoConvGammaPsiPairPt[iCut]);
928 
929  fHistoConvGammaR[iCut] = new TH1F("ESD_ConvGamma_R","ESD_ConvGamma_R",800,0,200);
930  if(fDoCentralityFlat > 0) fHistoConvGammaR[iCut]->Sumw2();
931  fESDList[iCut]->Add(fHistoConvGammaR[iCut]);
932  fHistoConvGammaEta[iCut] = new TH1F("ESD_ConvGamma_Eta","ESD_ConvGamma_Eta",2000,-2,2);
933  if(fDoCentralityFlat > 0) fHistoConvGammaEta[iCut]->Sumw2();
934  fESDList[iCut]->Add(fHistoConvGammaEta[iCut]);
935  fHistoConvGammaPhi[iCut] = new TH1F("ESD_ConvGamma_Phi","ESD_ConvGamma_Phi",360,0,2*TMath::Pi());
936  if(fDoCentralityFlat > 0) fHistoConvGammaPhi[iCut]->Sumw2();
937  fESDList[iCut]->Add(fHistoConvGammaPhi[iCut]);
938  }
939 
940  if(fDoMesonAnalysis){
941  fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",800,0,0.8,250,0,25);
942  fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
943  fHistoMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt","ESD_Background_InvMass_Pt",800,0,0.8,250,0,25);
944  fESDList[iCut]->Add(fHistoMotherBackInvMassPt[iCut]);
945  fHistoMotherInvMassEalpha[iCut] = new TH2F("ESD_Mother_InvMass_vs_E_alpha","ESD_Mother_InvMass_vs_E_alpha",800,0,0.8,250,0,25);
946  fESDList[iCut]->Add(fHistoMotherInvMassEalpha[iCut]);
947 
948  if (fIsMC > 1 || fDoCentralityFlat > 0){
949  fHistoMotherInvMassPt[iCut]->Sumw2();
950  fHistoMotherBackInvMassPt[iCut]->Sumw2();
951  fHistoMotherInvMassEalpha[iCut]->Sumw2();
952  }
953 
954  if(fDoMesonQA == 2){
955  fMesonDCAList[iCut] = new TList();
956  fMesonDCAList[iCut]->SetName(Form("%s_%s_%s Meson DCA tree",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
957  fMesonDCAList[iCut]->SetOwner(kTRUE);
958  fCutFolder[iCut]->Add(fMesonDCAList[iCut]);
959 
960  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut] = new TTree("ESD_Mesons_InvMass_Pt_DcazMin_DcazMax_Flag","ESD_Mesons_InvMass_Pt_DcazMin_DcazMax_Flag");
961  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("InvMass",&fInvMass,"fInvMass/F");
962  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("Pt",&fPt,"fPt/F");
963  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("DcaZMin",&fDCAzGammaMin,"fDCAzGammaMin/F");
964  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("DcaZMax",&fDCAzGammaMax,"fDCAzGammaMax/F");
965  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("kind",&iFlag,"iFlag/b");
966  if(fIsMC>0){
967  tESDMesonsInvMassPtDcazMinDcazMaxFlag[iCut]->Branch("mesonMCInfo",&iMesonMCInfo,"iMesonMCInfo/b");
968  }
970 
971  }
972  if(fDoMesonQA > 0 ){
973  if (fIsMC < 2){
974  fHistoMotherPi0PtY[iCut] = new TH2F("ESD_MotherPi0_Pt_Y","ESD_MotherPi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
976  fESDList[iCut]->Add(fHistoMotherPi0PtY[iCut]);
977  fHistoMotherEtaPtY[iCut] = new TH2F("ESD_MotherEta_Pt_Y","ESD_MotherEta_Pt_Y",150,0.03,15.,150,-1.5,1.5);
979  fESDList[iCut]->Add(fHistoMotherEtaPtY[iCut]);
980  fHistoMotherPi0PtOpenAngle[iCut] = new TH2F("ESD_MotherPi0_Pt_OpenAngle","ESD_MotherPi0_Pt_OpenAngle",150,0.03,15.,100,0,TMath::Pi());
982  fESDList[iCut]->Add(fHistoMotherPi0PtOpenAngle[iCut]);
983  fHistoMotherEtaPtOpenAngle[iCut] = new TH2F("ESD_MotherEta_Pt_OpenAngle","ESD_MotherEta_Pt_OpenAngle",150,0.03,15.,100,0,TMath::Pi());
985  fESDList[iCut]->Add(fHistoMotherEtaPtOpenAngle[iCut]);
986  }
987  fHistoMotherPi0PtAlpha[iCut] = new TH2F("ESD_MotherPi0_Pt_Alpha","ESD_MotherPi0_Pt_Alpha",150,0.03,15.,100,0,1);
989  fESDList[iCut]->Add(fHistoMotherPi0PtAlpha[iCut]);
990  fHistoMotherEtaPtAlpha[iCut] = new TH2F("ESD_MotherEta_Pt_Alpha","ESD_MotherEta_Pt_Alpha",150,0.03,15.,100,0,1);
992  fESDList[iCut]->Add(fHistoMotherEtaPtAlpha[iCut]);
993  if(fIsMC > 1){
994  fHistoMotherPi0PtAlpha[iCut]->Sumw2();
995  fHistoMotherEtaPtAlpha[iCut]->Sumw2();
996  }
997 
998  }
999  if(fDoMesonQA == 3){
1000  sPtRDeltaROpenAngle[iCut] = new THnSparseF("PhotonPair_Pt_R_DeltaR_OpenAngle","PhotonPair_Pt_R_DeltaR_OpenAngle",nDim2,nBins2,xMin2,xMax2);
1001  fESDList[iCut]->Add(sPtRDeltaROpenAngle[iCut]);
1002  }
1003  }
1004 
1005 
1006  }
1007  if(fDoMesonAnalysis){
1008  InitBack(); // Init Background Handler
1009  }
1010 
1011  if(fIsMC>0){
1012  // MC Histogramms
1013  fMCList = new TList*[fnCuts];
1014  // True Histogramms
1015  fTrueList = new TList*[fnCuts];
1016  // Selected Header List
1017  fHeaderNameList = new TList*[fnCuts];
1018  fHistoMCHeaders = new TH1I*[fnCuts];
1019  fHistoMCAllGammaPt = new TH1F*[fnCuts];
1021  fHistoMCDecayGammaPi0Pt = new TH1F*[fnCuts];
1022  fHistoMCDecayGammaRhoPt = new TH1F*[fnCuts];
1023  fHistoMCDecayGammaEtaPt = new TH1F*[fnCuts];
1024  fHistoMCDecayGammaOmegaPt = new TH1F*[fnCuts];
1025  fHistoMCDecayGammaEtapPt = new TH1F*[fnCuts];
1026  fHistoMCDecayGammaPhiPt = new TH1F*[fnCuts];
1027  fHistoMCDecayGammaSigmaPt = new TH1F*[fnCuts];
1028  fHistoMCConvGammaPt = new TH1F*[fnCuts];
1030  fHistoTrueConvGammaPt = new TH1F*[fnCuts];
1033 
1035  if (fDoPhotonQA == 3){
1042  }
1043  fHistoTruePrimaryConvGammaPt = new TH1F*[fnCuts];
1050 
1053 
1054  if (fDoPhotonQA > 0 ){
1055  if (fIsMC < 2 ){
1056  fHistoMCConvGammaR = new TH1F*[fnCuts];
1057  fHistoMCConvGammaEta = new TH1F*[fnCuts];
1059  fHistoTrueConvGammaEta = new TH1F*[fnCuts];
1060  fHistoTrueConvGammaR = new TH1F*[fnCuts];
1061  fHistoTrueConvGammaRMC = new TH1F*[fnCuts];
1062  }
1063  fHistoTrueConvGammaPtMC = new TH1F*[fnCuts];
1064  }
1065 
1066  if(fDoMesonAnalysis){
1067  fHistoMCPi0Pt = new TH1F*[fnCuts];
1068  fHistoMCPi0WOWeightPt = new TH1F*[fnCuts];
1069  fHistoMCEtaPt = new TH1F*[fnCuts];
1070  fHistoMCEtaWOWeightPt = new TH1F*[fnCuts];
1071  fHistoMCPi0WOWeightInAccPt = new TH1F*[fnCuts];
1072  fHistoMCEtaWOWeightInAccPt = new TH1F*[fnCuts];
1073  fHistoMCPi0InAccPt = new TH1F*[fnCuts];
1074  fHistoMCEtaInAccPt = new TH1F*[fnCuts];
1075 
1076  if(fIsMC > 1){
1077  fHistoMCPi0WOEvtWeightPt = new TH1F*[fnCuts];
1078  fHistoMCEtaWOEvtWeightPt = new TH1F*[fnCuts];
1081  }
1082 
1085  fHistoMultipleCountTruePi0 = new TH1F*[fnCuts];
1087  fHistoMultipleCountTrueEta = new TH1F*[fnCuts];
1090  pESDTruePrimaryMotherWeightsInvMassPt = new TProfile2D*[fnCuts];
1097 
1101  fHistoMCSecPi0Source = new TH1F*[fnCuts];
1102  fHistoMCSecEtaPt = new TH1F*[fnCuts];
1103  fHistoMCSecEtaSource = new TH1F*[fnCuts];
1104 
1105  if (fDoMesonQA > 0){
1106  fHistoMCPi0PtAlpha = new TH2F*[fnCuts];
1107  fHistoMCEtaPtAlpha = new TH2F*[fnCuts];
1108  if (fIsMC == 2){
1109  fHistoMCPi0PtJetPt = new TH2F*[fnCuts];
1110  fHistoMCEtaPtJetPt = new TH2F*[fnCuts];
1111  }
1112 
1113  if (fIsMC < 2){
1115  fHistoMCPi0PtY = new TH2F*[fnCuts];
1116  fHistoMCEtaPtY = new TH2F*[fnCuts];
1125  fHistoTruePi0PtY = new TH2F*[fnCuts];
1126  fHistoTrueEtaPtY = new TH2F*[fnCuts];
1129  }
1132 
1133  }
1134  }
1135 
1136  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1137  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
1138  TString cutstringPhoton = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
1139  TString cutstringMeson = "NoMesonCut";
1140  if(fDoMesonAnalysis)
1141  cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
1142 
1143  fMCList[iCut] = new TList();
1144  fMCList[iCut]->SetName(Form("%s_%s_%s MC histograms",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
1145  fMCList[iCut]->SetOwner(kTRUE);
1146  fCutFolder[iCut]->Add(fMCList[iCut]);
1147  if (fIsMC < 2){
1148  fHistoMCHeaders[iCut] = new TH1I("MC_Headers","MC_Headers",20,0,20);
1149  fMCList[iCut]->Add(fHistoMCHeaders[iCut]);
1150  }
1151  fHistoMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt","MC_AllGamma_Pt",250,0,25);
1152  fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);
1153  fHistoMCAllSecondaryGammaPt[iCut] = new TH2F("MC_AllSecondaryGamma_Pt","MC_AllSecondaryGamma_Pt",250,0,25,4,-0.5,3.5);
1154  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1155  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1156  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1157  fHistoMCAllSecondaryGammaPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1158  fMCList[iCut]->Add(fHistoMCAllSecondaryGammaPt[iCut]);
1159  fHistoMCDecayGammaPi0Pt[iCut] = new TH1F("MC_DecayGammaPi0_Pt","MC_DecayGammaPi0_Pt",250,0,25);
1160  fMCList[iCut]->Add(fHistoMCDecayGammaPi0Pt[iCut]);
1161  fHistoMCDecayGammaRhoPt[iCut] = new TH1F("MC_DecayGammaRho_Pt","MC_DecayGammaRho_Pt",250,0,25);
1162  fMCList[iCut]->Add(fHistoMCDecayGammaRhoPt[iCut]);
1163  fHistoMCDecayGammaEtaPt[iCut] = new TH1F("MC_DecayGammaEta_Pt","MC_DecayGammaEta_Pt",250,0,25);
1164  fMCList[iCut]->Add(fHistoMCDecayGammaEtaPt[iCut]);
1165  fHistoMCDecayGammaOmegaPt[iCut] = new TH1F("MC_DecayGammaOmega_Pt","MC_DecayGammaOmmega_Pt",250,0,25);
1166  fMCList[iCut]->Add(fHistoMCDecayGammaOmegaPt[iCut]);
1167  fHistoMCDecayGammaEtapPt[iCut] = new TH1F("MC_DecayGammaEtap_Pt","MC_DecayGammaEtap_Pt",250,0,25);
1168  fMCList[iCut]->Add(fHistoMCDecayGammaEtapPt[iCut]);
1169  fHistoMCDecayGammaPhiPt[iCut] = new TH1F("MC_DecayGammaPhi_Pt","MC_DecayGammaPhi_Pt",250,0,25);
1170  fMCList[iCut]->Add(fHistoMCDecayGammaPhiPt[iCut]);
1171  fHistoMCDecayGammaSigmaPt[iCut] = new TH1F("MC_DecayGammaSigma_Pt","MC_DecayGammaSigma_Pt",250,0,25);
1172  fMCList[iCut]->Add(fHistoMCDecayGammaSigmaPt[iCut]);
1173  fHistoMCConvGammaPt[iCut] = new TH1F("MC_ConvGamma_Pt","MC_ConvGamma_Pt",250,0,25);
1174  fMCList[iCut]->Add(fHistoMCConvGammaPt[iCut]);
1175  fHistoMCSecondaryConvGammaPt[iCut] = new TH2F("MC_SecondaryConvGamma_Pt","MC_SecondaryConvGamma_Pt",250,0,25,4,-0.5,3.5);
1176  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1177  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1178  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1179  fHistoMCSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1180  fMCList[iCut]->Add(fHistoMCSecondaryConvGammaPt[iCut]);
1181 
1182  if (fIsMC > 1){
1183  fHistoMCAllGammaPt[iCut]->Sumw2();
1184  fHistoMCAllSecondaryGammaPt[iCut]->Sumw2();
1185  fHistoMCDecayGammaPi0Pt[iCut]->Sumw2();
1186  fHistoMCDecayGammaRhoPt[iCut]->Sumw2();
1187  fHistoMCDecayGammaEtaPt[iCut]->Sumw2();
1188  fHistoMCDecayGammaOmegaPt[iCut]->Sumw2();
1189  fHistoMCDecayGammaEtapPt[iCut]->Sumw2();
1190  fHistoMCDecayGammaPhiPt[iCut]->Sumw2();
1191  fHistoMCDecayGammaSigmaPt[iCut]->Sumw2();
1192  fHistoMCConvGammaPt[iCut]->Sumw2();
1193  fHistoMCSecondaryConvGammaPt[iCut]->Sumw2();
1194  }
1195 
1196  if (fDoPhotonQA > 0 && fIsMC < 2){
1197  fHistoMCConvGammaR[iCut] = new TH1F("MC_ConvGamma_R","MC_ConvGamma_R",800,0,200);
1198  fMCList[iCut]->Add(fHistoMCConvGammaR[iCut]);
1199  fHistoMCConvGammaEta[iCut] = new TH1F("MC_ConvGamma_Eta","MC_ConvGamma_Eta",2000,-2,2);
1200  fMCList[iCut]->Add(fHistoMCConvGammaEta[iCut]);
1201  }
1202 
1203  if(fDoMesonAnalysis){
1204  fHistoMCPi0Pt[iCut] = new TH1F("MC_Pi0_Pt","MC_Pi0_Pt",250,0,25);
1205  fHistoMCPi0Pt[iCut]->Sumw2();
1206  fMCList[iCut]->Add(fHistoMCPi0Pt[iCut]);
1207  fHistoMCPi0WOWeightPt[iCut] = new TH1F("MC_Pi0_WOWeights_Pt","MC_Pi0_WOWeights_Pt",250,0,25);
1208  fHistoMCPi0WOWeightPt[iCut]->Sumw2();
1209  fMCList[iCut]->Add(fHistoMCPi0WOWeightPt[iCut]);
1210 
1211  fHistoMCEtaPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",250,0,25);
1212  fHistoMCEtaPt[iCut]->Sumw2();
1213  fMCList[iCut]->Add(fHistoMCEtaPt[iCut]);
1214  fHistoMCEtaWOWeightPt[iCut] = new TH1F("MC_Eta_WOWeights_Pt","MC_Eta_WOWeights_Pt",250,0,25);
1215  fHistoMCEtaWOWeightPt[iCut]->Sumw2();
1216  fMCList[iCut]->Add(fHistoMCEtaWOWeightPt[iCut]);
1217 
1218  fHistoMCPi0WOWeightInAccPt[iCut] = new TH1F("MC_Pi0WOWeightInAcc_Pt","MC_Pi0WOWeightInAcc_Pt",250,0,25);
1219  fHistoMCPi0WOWeightInAccPt[iCut]->Sumw2();
1220  fMCList[iCut]->Add(fHistoMCPi0WOWeightInAccPt[iCut]);
1221  fHistoMCEtaWOWeightInAccPt[iCut] = new TH1F("MC_EtaWOWeightInAcc_Pt","MC_EtaWOWeightInAcc_Pt",250,0,25);
1222  fHistoMCEtaWOWeightInAccPt[iCut]->Sumw2();
1223  fMCList[iCut]->Add(fHistoMCEtaWOWeightInAccPt[iCut]);
1224  fHistoMCPi0InAccPt[iCut] = new TH1F("MC_Pi0InAcc_Pt","MC_Pi0InAcc_Pt",250,0,25);
1225  fHistoMCPi0InAccPt[iCut]->Sumw2();
1226  fMCList[iCut]->Add(fHistoMCPi0InAccPt[iCut]);
1227  fHistoMCEtaInAccPt[iCut] = new TH1F("MC_EtaInAcc_Pt","MC_EtaInAcc_Pt",250,0,25);
1228  fHistoMCEtaInAccPt[iCut]->Sumw2();
1229  fMCList[iCut]->Add(fHistoMCEtaInAccPt[iCut]);
1230 
1231  if (fIsMC > 1){
1232  fHistoMCPi0WOEvtWeightPt[iCut] = new TH1F("MC_Pi0_WOEventWeights_Pt","MC_Pi0_WOEventWeights_Pt",300,0,30);
1233  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightPt[iCut]);
1234  fHistoMCEtaWOEvtWeightPt[iCut] = new TH1F("MC_Eta_WOEventWeights_Pt","MC_Eta_WOEventWeights_Pt",300,0,30);
1235  fMCList[iCut]->Add(fHistoMCEtaWOEvtWeightPt[iCut]);
1236  fHistoMCPi0WOEvtWeightInAccPt[iCut] = new TH1F("MC_Pi0WOEvtWeightInAcc_Pt","MC_Pi0WOEvtWeightInAcc_Pt",250,0,25);
1237  fHistoMCPi0WOEvtWeightInAccPt[iCut]->Sumw2();
1238  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightInAccPt[iCut]);
1239  fHistoMCEtaWOEvtWeightInAccPt[iCut] = new TH1F("MC_EtaWOEvtWeightInAcc_Pt","MC_EtaWOEvtWeightInAcc_Pt",250,0,25);
1240  fHistoMCEtaWOEvtWeightInAccPt[iCut]->Sumw2();
1241  fMCList[iCut]->Add(fHistoMCEtaWOEvtWeightInAccPt[iCut]);
1242 
1243  if (fDoMesonQA > 0 && fIsMC == 2){
1244  fHistoMCPi0PtJetPt[iCut] = new TH2F("MC_Pi0_Pt_JetPt","MC_Pi0_Pt_JetPt",150,0.03,15.,200,0,200);
1245  fHistoMCPi0PtJetPt[iCut]->Sumw2();
1247  fMCList[iCut]->Add(fHistoMCPi0PtJetPt[iCut]);
1248  fHistoMCEtaPtJetPt[iCut] = new TH2F("MC_Eta_Pt_JetPt","MC_Eta_Pt_JetPt",150,0.03,15.,200,0,200);
1249  fHistoMCEtaPtJetPt[iCut]->Sumw2();
1251  fMCList[iCut]->Add(fHistoMCEtaPtJetPt[iCut]);
1252  }
1253  }
1254 
1255  fHistoMCPrimaryPtvsSource[iCut] = new TH2F("MC_Primary_Pt_Source","MC_Primary_Pt_Source",250,0.,25.,10,-0.5,9.5);
1256  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(1,"Pi+");
1257  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(2,"Pi-");
1258  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(3,"K+");
1259  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(4,"K-");
1260  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(5,"K0s");
1261  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(6,"K0l");
1262  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(7,"Lambda");
1263  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(8,"Omega");
1264  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(9,"Phi");
1265  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(10,"Rho0");
1266  fMCList[iCut]->Add(fHistoMCPrimaryPtvsSource[iCut]);
1267  fHistoMCSecPi0Source[iCut] = new TH1F("MC_SecPi0_Source","MC_SecPi0_Source",5000,0.,5000);
1268  fMCList[iCut]->Add(fHistoMCSecPi0Source[iCut]);
1269  fHistoMCSecEtaSource[iCut] = new TH1F("MC_SecEta_Source","MC_SecEta_Source",5000,0,5000);
1270  fMCList[iCut]->Add(fHistoMCSecEtaSource[iCut]);
1271  fHistoMCSecPi0PtvsSource[iCut] = new TH2F("MC_SecPi0_Pt_Source","MC_SecPi0_Pt_Source",250,0.0,25.,16,-0.5,15.5);
1272  fMCList[iCut]->Add(fHistoMCSecPi0PtvsSource[iCut]);
1273  fHistoMCSecPi0InAccPtvsSource[iCut] = new TH2F("MC_SecPi0InAcc_Pt_Source","MC_SecPi0InAcc_Pt_Source",250,0.0,25.,16,-0.5,15.5);
1274  fMCList[iCut]->Add(fHistoMCSecPi0InAccPtvsSource[iCut]);
1275  fHistoMCSecEtaPt[iCut] = new TH1F("MC_SecEta_Pt","MC_SecEta_Pt",250,0,25);
1276  fMCList[iCut]->Add(fHistoMCSecEtaPt[iCut]);
1277 
1278  if (fIsMC > 1){
1279  fHistoMCPrimaryPtvsSource[iCut]->Sumw2();
1280  fHistoMCSecPi0PtvsSource[iCut]->Sumw2();
1281  fHistoMCSecPi0InAccPtvsSource[iCut]->Sumw2();
1282  fHistoMCSecEtaPt[iCut]->Sumw2();
1283  }
1284 
1285  if (fDoMesonQA > 0){
1286  fHistoMCPi0PtAlpha[iCut] = new TH2F("MC_Pi0_Pt_Alpha","MC_Pi0_Pt_Alpha",150,0.03,15.,100,0,1);
1288  fMCList[iCut]->Add(fHistoMCPi0PtAlpha[iCut]);
1289  fHistoMCEtaPtAlpha[iCut] = new TH2F("MC_Eta_Pt_Alpha","MC_Eta_Pt_Alpha",150,0.03,15.,100,0,1);
1291  fMCList[iCut]->Add(fHistoMCEtaPtAlpha[iCut]);
1292 
1293  if (fIsMC < 2){
1294  fHistoMCPi0PtY[iCut] = new TH2F("MC_Pi0_Pt_Y","MC_Pi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1295  fHistoMCPi0PtY[iCut]->Sumw2();
1297  fMCList[iCut]->Add(fHistoMCPi0PtY[iCut]);
1298  fHistoMCEtaPtY[iCut] = new TH2F("MC_Eta_Pt_Y","MC_Eta_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1299  fHistoMCEtaPtY[iCut]->Sumw2();
1301  fMCList[iCut]->Add(fHistoMCEtaPtY[iCut]);
1302  fHistoMCSecPi0RvsSource[iCut] = new TH2F("MC_SecPi0_R3D_Source","MC_SecPi0_R3D_Source",500,0.0,20.,16,-0.5,15.5);
1303  fHistoMCSecPi0RvsSource[iCut]->Sumw2();
1304  fMCList[iCut]->Add(fHistoMCSecPi0RvsSource[iCut]);
1305  }
1306  }
1307 
1308  }
1309 
1310  fTrueList[iCut] = new TList();
1311  fTrueList[iCut]->SetName(Form("%s_%s_%s True histograms",cutstringEvent.Data() ,cutstringPhoton.Data(),cutstringMeson.Data()));
1312  fTrueList[iCut]->SetOwner(kTRUE);
1313  fCutFolder[iCut]->Add(fTrueList[iCut]);
1314 
1315  fHistoTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt","ESD_TrueConvGamma_Pt",250,0,25);
1316  fTrueList[iCut]->Add(fHistoTrueConvGammaPt[iCut]);
1317 
1318  fHistoDoubleCountTrueConvGammaRPt[iCut] = new TH2F("ESD_TrueDoubleCountConvGamma_R_Pt","ESD_TrueDoubleCountConvGamma_R_Pt",800,0,200,300,0,30);
1319  fTrueList[iCut]->Add(fHistoDoubleCountTrueConvGammaRPt[iCut]);
1320  fHistoMultipleCountTrueConvGamma[iCut] = new TH1F("ESD_TrueMultipleCountConvGamma","ESD_TrueMultipleCountConvGamma",10,1,11);
1321  fTrueList[iCut]->Add(fHistoMultipleCountTrueConvGamma[iCut]);
1322 
1323  fHistoCombinatorialPt[iCut] = new TH2F("ESD_TrueCombinatorial_Pt","ESD_TrueCombinatorial_Pt",250,0,25,16,-0.5,15.5);
1324  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 1,"Elec+Elec");
1325  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 2,"Elec+Pion");
1326  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 3,"Elec+Kaon");
1327  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 4,"Elec+Proton");
1328  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 5,"Elec+Muon");
1329  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 6,"Pion+Pion");
1330  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 7,"Pion+Kaon");
1331  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 8,"Pion+Proton");
1332  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel( 9,"Pion+Muon");
1333  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(10,"Kaon+Kaon");
1334  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(11,"Kaon+Proton");
1335  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(12,"Kaon+Muon");
1336  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(13,"Proton+Proton");
1337  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(14,"Proton+Muon");
1338  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(15,"Muon+Muon");
1339  fHistoCombinatorialPt[iCut]->GetYaxis()->SetBinLabel(16,"Rest");
1340  fTrueList[iCut]->Add(fHistoCombinatorialPt[iCut]);
1341 
1342  fHistoTruePrimaryConvGammaPt[iCut] = new TH1F("ESD_TruePrimaryConvGamma_Pt","ESD_TruePrimaryConvGamma_Pt",250,0,25);
1343  fTrueList[iCut]->Add(fHistoTruePrimaryConvGammaPt[iCut]);
1344  fHistoTrueSecondaryConvGammaPt[iCut] = new TH2F("ESD_TrueSecondaryConvGamma_Pt","ESD_TrueSecondaryConvGamma_Pt",250,0,25,4,-0.5,3.5);
1345  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1346  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1347  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1348  fHistoTrueSecondaryConvGammaPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1349  fTrueList[iCut]->Add(fHistoTrueSecondaryConvGammaPt[iCut]);
1350  fHistoTrueSecondaryConvGammaMCPt[iCut] = new TH2F("ESD_TrueSecondaryConvGamma_MCPt","ESD_TrueSecondaryConvGamma_MCPt",250,0,25,4,-0.5,3.5);
1351  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(1,"K0s");
1352  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(2,"K0l");
1353  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(3,"Lambda");
1354  fHistoTrueSecondaryConvGammaMCPt[iCut]->GetYaxis()->SetBinLabel(4,"rest");
1355  fTrueList[iCut]->Add(fHistoTrueSecondaryConvGammaMCPt[iCut]);
1356 
1357  if(fDoPhotonQA == 3 && fIsMC < 2){
1358  if(fIsHeavyIon == 1){
1359  fHistoCombinatorialMothersPt[iCut] = new TH3F("ESD_TrueCombinatorialMothers_Pt","ESD_TrueCombinatorialMothers_Pt",6,0,6,13,0,13,250,0,25);
1360  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 1,"Elec");
1361  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 2,"Pion");
1362  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 3,"Kaon");
1363  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 4,"Proton");
1364  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 5,"Rest");
1365  fHistoCombinatorialMothersPt[iCut]->GetXaxis()->SetBinLabel( 6,"Ancestor NP");
1366  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 1,"Elec");
1367  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 2,"Pion");
1368  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 3,"Kaon");
1369  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 4,"Proton");
1370  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 5,"Pi0");
1371  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 6,"#eta");
1372  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 7,"#omega");
1373  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 8,"#phi");
1374  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel( 9,"#eta'");
1375  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel(10,"K0s");
1376  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel(11,"#Lambda");
1377  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel(12,"#rho^{0}, #rho^{#pm}");
1378  fHistoCombinatorialMothersPt[iCut]->GetYaxis()->SetBinLabel(13,"Other");
1379  fTrueList[iCut]->Add(fHistoCombinatorialMothersPt[iCut]);
1380  }
1381 
1382  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());
1383  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_ek[iCut]);
1384  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());
1385  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_ep[iCut]);
1386  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());
1387  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_epi[iCut]);
1388  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());
1389  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_pik[iCut]);
1390  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());
1391  fTrueList[iCut]->Add(fHistoCombinatorialPtDeltaPhi_pip[iCut]);
1392  }
1393 
1394  fHistoTrueDalitzPsiPairDeltaPhi[iCut] = new TH2F("ESD_TrueDalitzPsiPairDeltaPhi_Pt", "ESD_TrueDalitzPsiPairDeltaPhi_Pt",100,-0.5,2,100,-0.5,0.5);
1395  fTrueList[iCut]->Add(fHistoTrueDalitzPsiPairDeltaPhi[iCut]);
1396  fHistoTrueGammaPsiPairDeltaPhi[iCut] = new TH2F("ESD_TrueGammaPsiPairDeltaPhi_Pt", "ESD_TrueGammaPsiPairDeltaPhi_Pt",100,-0.5,2,100,-0.5,0.5);
1397  fTrueList[iCut]->Add(fHistoTrueGammaPsiPairDeltaPhi[iCut]);
1398 
1399  fHistoTruePrimaryConvGammaESDPtMCPt[iCut] = new TH2F("ESD_TruePrimaryConvGammaESD_PtMCPt", "ESD_TruePrimaryConvGammaESD_PtMCPt",250,0,25,250,0,25);
1401 
1402 
1403  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromK0sESD_MCPtPt","ESD_TrueSecondaryConvGammaFromXFromK0sESD_MCPtPt",250,0,25,250,0,25);
1405  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromK0lESD_MCPtPt","ESD_TrueSecondaryConvGammaFromXFromK0lESD_MCPtPt",250,0,25,250,0,25);
1407  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[iCut] = new TH2F("ESD_TrueSecondaryConvGammaFromXFromLambdaESD_MCPtPt","ESD_TrueSecondaryConvGammaFromXFromLambdaESD_MCPtPt",250,0,25,250,0,25);
1409 
1410 
1412  fHistoTrueConvGammaPt[iCut]->Sumw2();
1413  fHistoDoubleCountTrueConvGammaRPt[iCut]->Sumw2();
1414  fHistoMultipleCountTrueConvGamma[iCut]->Sumw2();
1415  fHistoCombinatorialPt[iCut]->Sumw2();
1416  fHistoTruePrimaryConvGammaPt[iCut]->Sumw2();
1417  fHistoTrueSecondaryConvGammaPt[iCut]->Sumw2();
1418  fHistoTrueSecondaryConvGammaMCPt[iCut]->Sumw2();
1419  fHistoTruePrimaryConvGammaESDPtMCPt[iCut]->Sumw2();
1423  fHistoTrueDalitzPsiPairDeltaPhi[iCut]->Sumw2();
1424  fHistoTrueGammaPsiPairDeltaPhi[iCut]->Sumw2();
1425  }
1426 
1427  if (fDoPhotonQA > 0 ){
1428  if (fIsMC < 2){
1429  fHistoTrueConvGammaPsiPairPt[iCut] = new TH2F("ESD_TrueonvGamma_PsiPair_Pt","ESD_TrueConvGamma_PsiPair_Pt",500,0,5,250,0,25);
1430  fTrueList[iCut]->Add(fHistoTrueConvGammaPsiPairPt[iCut]);
1431  fHistoTrueConvGammaEta[iCut] = new TH1F("ESD_TrueConvGamma_Eta","ESD_TrueConvGamma_Eta",2000,-2,2);
1432  fTrueList[iCut]->Add(fHistoTrueConvGammaEta[iCut]);
1433  fHistoTrueConvGammaR[iCut] = new TH1F("ESD_TrueConvGamma_R","ESD_TrueConvGamma_R",800,0,200);
1434  fTrueList[iCut]->Add(fHistoTrueConvGammaR[iCut]);
1435  fHistoTrueConvGammaRMC[iCut] = new TH1F("ESD_TrueConvGamma_RMC","ESD_TrueConvGamma_RMC",800,0,200);
1436  fTrueList[iCut]->Add(fHistoTrueConvGammaRMC[iCut]);
1437  }
1438  fHistoTrueConvGammaPtMC[iCut] = new TH1F("ESD_TrueConvGamma_PtMC","ESD_TrueConvGamma_PtMC",250,0,25);
1439  fTrueList[iCut]->Add(fHistoTrueConvGammaPtMC[iCut]);
1441  fHistoTrueConvGammaPtMC[iCut]->Sumw2();
1442 
1443  }
1444 
1445  if(fDoMesonAnalysis){
1446  fHistoTrueMotherInvMassPt[iCut] = new TH2F("ESD_TrueMother_InvMass_Pt","ESD_TrueMother_InvMass_Pt",800,0,0.8,250,0,25);
1447  fTrueList[iCut]->Add(fHistoTrueMotherInvMassPt[iCut]);
1448  fHistoDoubleCountTruePi0InvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountPi0_InvMass_Pt","ESD_TrueDoubleCountPi0_InvMass_Pt",800,0,0.8,300,0,30);
1449  fTrueList[iCut]->Add(fHistoDoubleCountTruePi0InvMassPt[iCut]);
1450  fHistoMultipleCountTruePi0[iCut] = new TH1F("ESD_TrueMultipleCountPi0","ESD_TrueMultipleCountPi0",10,1,11);
1451  fTrueList[iCut]->Add(fHistoMultipleCountTruePi0[iCut]);
1452  fHistoDoubleCountTrueEtaInvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountEta_InvMass_Pt","ESD_TrueDoubleCountEta_InvMass_Pt",800,0,0.8,300,0,30);
1453  fTrueList[iCut]->Add(fHistoDoubleCountTrueEtaInvMassPt[iCut]);
1454  fHistoMultipleCountTrueEta[iCut] = new TH1F("ESD_TrueMultipleCountEta","ESD_TrueMultipleCountEta",10,1,11);
1455  fTrueList[iCut]->Add(fHistoMultipleCountTrueEta[iCut]);
1456  fHistoTruePrimaryMotherInvMassPt[iCut] = new TH2F("ESD_TruePrimaryMother_InvMass_Pt", "ESD_TruePrimaryMother_InvMass_Pt", 800,0,0.8,250,0,25);
1457  fHistoTruePrimaryMotherInvMassPt[iCut]->Sumw2();
1458  fTrueList[iCut]->Add(fHistoTruePrimaryMotherInvMassPt[iCut]);
1459  fHistoTruePrimaryMotherW0WeightingInvMassPt[iCut] = new TH2F("ESD_TruePrimaryMotherW0Weights_InvMass_Pt", "ESD_TruePrimaryMotherW0Weights_InvMass_Pt", 800,0,0.8,250,0,25);
1462  pESDTruePrimaryMotherWeightsInvMassPt[iCut] = new TProfile2D("ESD_TruePrimaryMotherWeights_InvMass_Pt", "ESD_TruePrimaryMotherWeights_InvMass_Pt", 800,0,0.8,250,0,25);
1465  fHistoTrueSecondaryMotherInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMother_InvMass_Pt", "ESD_TrueSecondaryMother_InvMass_Pt", 800,0,0.8,250,0,25);
1466  fHistoTrueSecondaryMotherInvMassPt[iCut]->Sumw2();
1468  fHistoTrueSecondaryMotherFromK0sInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromK0s_InvMass_Pt","ESD_TrueSecondaryMotherFromK0s_InvMass_Pt",800,0,0.8,250,0,25);
1471  fHistoTrueSecondaryMotherFromK0lInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromK0l_InvMass_Pt","ESD_TrueSecondaryMotherFromK0l_InvMass_Pt",800,0,0.8,250,0,25);
1474  fHistoTrueSecondaryMotherFromEtaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromEta_InvMass_Pt","ESD_TrueSecondaryMotherFromEta_InvMass_Pt",800,0,0.8,250,0,25);
1477  fHistoTrueSecondaryMotherFromLambdaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromLambda_InvMass_Pt","ESD_TrueSecondaryMotherFromLambda_InvMass_Pt",800,0,0.8,250,0,25);
1480 
1481  if(fIsMC < 2){
1482  fHistoTrueMotherDalitzInvMassPt[iCut] = new TH2F("ESD_TrueDalitz_InvMass_Pt","ESD_TrueDalitz_InvMass_Pt",800,0,0.8,250,0,25);
1483  fTrueList[iCut]->Add(fHistoTrueMotherDalitzInvMassPt[iCut]);
1484  }
1485 
1486  if (fIsMC > 1){
1487  fHistoTrueMotherInvMassPt[iCut]->Sumw2();
1488  fHistoDoubleCountTruePi0InvMassPt[iCut]->Sumw2();
1489  fHistoMultipleCountTruePi0[iCut]->Sumw2();
1490 
1491  fHistoDoubleCountTrueEtaInvMassPt[iCut]->Sumw2();
1492  fHistoMultipleCountTrueEta[iCut]->Sumw2();
1493  }
1494 
1495  if (fDoMesonQA > 0){
1496  if (fIsMC < 2){
1497  fHistoTruePrimaryPi0MCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryPi0_MCPt_ResolPt","ESD_TruePrimaryPi0_ResolPt_MCPt",500,0.03,25,1000,-1.,1.);
1498  fHistoTruePrimaryPi0MCPtResolPt[iCut]->Sumw2();
1500  fTrueList[iCut]->Add(fHistoTruePrimaryPi0MCPtResolPt[iCut]);
1501  fHistoTruePrimaryEtaMCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryEta_MCPt_ResolPt","ESD_TruePrimaryEta_ResolPt_MCPt",500,0.03,25,1000,-1.,1.);
1502  fHistoTruePrimaryEtaMCPtResolPt[iCut]->Sumw2();
1504  fTrueList[iCut]->Add(fHistoTruePrimaryEtaMCPtResolPt[iCut]);
1505  fHistoTrueBckGGInvMassPt[iCut] = new TH2F("ESD_TrueBckGG_InvMass_Pt","ESD_TrueBckGG_InvMass_Pt",800,0,0.8,250,0,25);
1506  fTrueList[iCut]->Add(fHistoTrueBckGGInvMassPt[iCut]);
1507  fHistoTrueBckContInvMassPt[iCut] = new TH2F("ESD_TrueBckCont_InvMass_Pt","ESD_TrueBckCont_InvMass_Pt",800,0,0.8,250,0,25);
1508  fTrueList[iCut]->Add(fHistoTrueBckContInvMassPt[iCut]);
1509  fHistoTrueK0sWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueK0sWithPi0Daughter_MCPt","ESD_TrueK0sWithPi0Daughter_MCPt",250,0,25);
1510  fTrueList[iCut]->Add(fHistoTrueK0sWithPi0DaughterMCPt[iCut]);
1511  fHistoTrueK0lWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueK0lWithPi0Daughter_MCPt","ESD_TrueK0lWithPi0Daughter_MCPt",250,0,25);
1512  fTrueList[iCut]->Add(fHistoTrueK0lWithPi0DaughterMCPt[iCut]);
1513  fHistoTrueEtaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueEtaWithPi0Daughter_MCPt","ESD_TrueEtaWithPi0Daughter_MCPt",250,0,25);
1514  fTrueList[iCut]->Add(fHistoTrueEtaWithPi0DaughterMCPt[iCut]);
1515  fHistoTrueLambdaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueLambdaWithPi0Daughter_MCPt","ESD_TrueLambdaWithPi0Daughter_MCPt",250,0,25);
1517 
1518  fHistoTruePi0PtY[iCut] = new TH2F("ESD_TruePi0_Pt_Y","ESD_TruePi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1520  fTrueList[iCut]->Add(fHistoTruePi0PtY[iCut]);
1521  fHistoTrueEtaPtY[iCut] = new TH2F("ESD_TrueEta_Pt_Y","ESD_TrueEta_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1523  fTrueList[iCut]->Add(fHistoTrueEtaPtY[iCut]);
1524  fHistoTruePi0PtOpenAngle[iCut] = new TH2F("ESD_TruePi0_Pt_OpenAngle","ESD_TruePi0_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());
1526  fTrueList[iCut]->Add(fHistoTruePi0PtOpenAngle[iCut]);
1527  fHistoTrueEtaPtOpenAngle[iCut] = new TH2F("ESD_TrueEta_Pt_OpenAngle","ESD_TrueEta_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());
1529  fTrueList[iCut]->Add(fHistoTrueEtaPtOpenAngle[iCut]);
1530  }
1531 
1532  fHistoTruePi0PtAlpha[iCut] = new TH2F("ESD_TruePi0_Pt_Alpha","ESD_TruePi0_Pt_Alpha",150,0.03,15.,100,0,1);
1534  fTrueList[iCut]->Add(fHistoTruePi0PtAlpha[iCut]);
1535  fHistoTrueEtaPtAlpha[iCut] = new TH2F("ESD_TrueEta_Pt_Alpha","ESD_TrueEta_Pt_Alpha",150,0.03,15.,100,0,1);
1537  fTrueList[iCut]->Add(fHistoTrueEtaPtAlpha[iCut]);
1538 
1539  }
1540  }
1541  }
1542  }
1543 
1544  vecDoubleCountTruePi0s.clear();
1545  vecDoubleCountTrueEtas.clear();
1547 
1548  mapMultipleCountTruePi0s.clear();
1549  mapMultipleCountTrueEtas.clear();
1551 
1552  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
1553  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
1554 
1555  if(fV0Reader)
1557  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms())
1558  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
1559 
1560  if(fV0Reader)
1562  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
1563  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
1564 
1568 
1570 
1571  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1572  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))) continue;
1573  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms()){
1574  fCutFolder[iCut]->Add(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
1575  }
1576  if(!((AliConversionPhotonCuts*)fCutArray->At(iCut))) continue;
1577  if(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms()){
1578  fCutFolder[iCut]->Add(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms());
1579  }
1580  if(fDoMesonAnalysis){
1581  if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
1582  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
1583  fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
1584  }
1585  }
1587  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
1588  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms()){
1589  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms());
1590  }
1591  }
1592 
1593  }
1594  if (fIsMC > 0){
1595  tBrokenFiles = new TTree("BrokenFiles","BrokenFiles");
1596  tBrokenFiles->Branch("fileName",&fFileNameBroken);
1598  }
1599 
1600  PostData(1, fOutputContainer);
1601 }
1602 //_____________________________________________________________________________
1604 {
1605  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1606  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
1607  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
1608  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
1609  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
1610  }
1611 
1612  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift()){
1613  fHistoEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1614  continue; // No Eta Shift requested, continue
1615  }
1616  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
1617  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
1618  fHistoEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1619  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1620  continue;
1621  }
1622  else{
1623  printf(" Gamma Conversion Task %s :: Eta Shift Manually Set to %f \n\n",
1624  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
1625  fHistoEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1626  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1627  }
1628  }
1629  return kTRUE;
1630 }
1631 //_____________________________________________________________________________
1633 {
1634  //
1635  // Called for each event
1636  //
1637  fInputEvent = InputEvent();
1638 
1639  // Set MC events
1640  if(fIsMC>0) fMCEvent = MCEvent();
1641 
1642  //calculating the weight for the centrality flattening
1643  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1644  if(fDoCentralityFlat > 0){
1645  fWeightCentrality[iCut] = 1.;
1646  fWeightCentrality[iCut] = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetWeightForCentralityFlattening(fInputEvent);
1647  }
1648  }
1649 
1650  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
1651  if(fInputEvent->IsIncompleteDAQ()==kTRUE) eventQuality = 2; // incomplete event
1652  // Event Not Accepted due to MC event missing or because it is incomplere or wrong trigger for V0ReaderV1 => skip broken events/files
1653  if(eventQuality == 2 || eventQuality == 3){
1654  // write out name of broken file for first event
1655  if (fIsMC > 0){
1656  if (fInputEvent->IsA()==AliESDEvent::Class()){
1657  if (((AliESDEvent*)fInputEvent)->GetEventNumberInFile() == 0){
1658  fFileNameBroken = new TObjString(Form("%s",((TString)fV0Reader->GetCurrentFileName()).Data()));
1659  if (tBrokenFiles) tBrokenFiles->Fill();
1660  delete fFileNameBroken;
1661  }
1662  }
1663  }
1664 
1665  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1666  fHistoNEvents[iCut]->Fill(eventQuality);
1667  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
1668  if( fDoCentralityFlat > 0) fHistoNEventsWeighted[iCut]->Fill(eventQuality, fWeightCentrality[iCut]);
1669  }
1670  return;
1671  }
1672 
1673  fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
1674 
1675  // ------------------- BeginEvent ----------------------------
1676 
1677  AliEventplane *EventPlane = fInputEvent->GetEventplane();
1678  if(fIsHeavyIon ==1)fEventPlaneAngle = EventPlane->GetEventplane("V0",fInputEvent,2);
1679  else fEventPlaneAngle=0.0;
1680 
1681  if(fIsMC > 0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
1682  RelabelAODPhotonCandidates(kTRUE); // In case of AODMC relabeling MC
1683  fV0Reader->RelabelAODs(kTRUE);
1684  }
1685  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1686  fiCut = iCut;
1687 
1688  Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon,kFALSE);
1689 
1690  if( fIsMC == 2 ){
1691  Float_t xsection = -1.;
1692  Float_t ntrials = -1.;
1693  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetXSectionAndNTrials(fMCEvent,xsection,ntrials);
1694  if((xsection==-1.) || (ntrials==-1.)) AliFatal(Form("ERROR: GetXSectionAndNTrials returned invalid xsection/ntrials, periodName from V0Reader: '%s'",fV0Reader->GetPeriodName().Data()));
1695  fProfileJetJetXSection[iCut]->Fill(0.,xsection);
1696  fhJetJetNTrials[iCut]->Fill("#sum{NTrials}",ntrials);
1697  }
1698 
1699  if( fIsMC > 0 ){
1700  fWeightJetJetMC = 1;
1701  Bool_t isMCJet = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsJetJetMCEventAccepted( fMCEvent, fWeightJetJetMC );
1702  if (fIsMC == 3){
1703  Double_t weightMult = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetWeightForMultiplicity(fV0Reader->GetNumberOfPrimaryTracks());
1704  fWeightJetJetMC = fWeightJetJetMC*weightMult;
1705  }
1706 
1707  if( fIsMC == 1 ) fWeightJetJetMC = 1;
1708  if(!isMCJet){
1709  fHistoNEvents[iCut]->Fill(10,fWeightJetJetMC);
1710  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(10);
1711  continue;
1712  }
1713  }
1714 
1715  if(eventNotAccepted){
1716  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
1717  fHistoNEvents[iCut]->Fill(eventNotAccepted,fWeightJetJetMC); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
1718  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(eventNotAccepted);
1719  if(fDoCentralityFlat > 0) fHistoNEventsWeighted[iCut]->Fill(eventNotAccepted, fWeightCentrality[iCut]*fWeightJetJetMC);
1720  continue;
1721  }
1722 
1723  if(eventQuality != 0){// Event Not Accepted
1724  // cout << "event rejected due to: " <<eventQuality << endl;
1725  fHistoNEvents[iCut]->Fill(eventQuality,fWeightJetJetMC);
1726  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
1727  if(fDoCentralityFlat > 0) fHistoNEventsWeighted[iCut]->Fill(eventQuality, fWeightCentrality[iCut]*fWeightJetJetMC);
1728  continue;
1729  }
1730 
1731  fHistoNEvents[iCut]->Fill(eventQuality,fWeightJetJetMC); // Should be 0 here
1732  if( fIsMC > 1 ) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
1733  if(fDoCentralityFlat > 0) fHistoNEventsWeighted[iCut]->Fill(eventQuality, fWeightCentrality[iCut]*fWeightJetJetMC); // Should be 0 here
1734 
1737 
1738  fHistoVertexZ[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetZ(),fWeightJetJetMC);
1739  if(fDoCentralityFlat > 0) fHistoVertexZWeighted[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetZ(), fWeightCentrality[iCut]*fWeightJetJetMC);
1740 
1741  if( fIsMC < 2 ){
1742  if(fDoCentralityFlat > 0) fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)), fWeightCentrality[iCut]);
1743  else fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)));
1744  }
1745 
1746  if(fDoPlotVsCentrality) fHistoCentrality[iCut]->Fill(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCentrality(fInputEvent),fWeightJetJetMC);
1748 
1751 
1752  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2){
1753  fHistoV0MultVsNumberTPCoutTracks[iCut]->Fill(fV0Reader->GetNumberOfTPCoutTracks(), fInputEvent->GetVZEROData()->GetMTotV0A());
1754  } else {
1755  fHistoV0MultVsNumberTPCoutTracks[iCut]->Fill(fV0Reader->GetNumberOfTPCoutTracks(), fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C());
1756  }
1757 
1758  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2) fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A(),fWeightJetJetMC);
1759  else if(fDoCentralityFlat > 0){
1760  fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C(), fWeightCentrality[iCut]*fWeightJetJetMC);
1761  } else {
1762  fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C(),fWeightJetJetMC);
1763  }
1764 
1766  ProcessClusters();
1767  }
1768 
1769  if(fIsMC > 0){
1770  // Process MC Particle
1771  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
1772  if(fInputEvent->IsA()==AliESDEvent::Class()){
1773  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1774  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1775  fMCEvent);
1776  }
1777  else if(fInputEvent->IsA()==AliAODEvent::Class()){
1778  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1779  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1780  fInputEvent);
1781  }
1782 
1783  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader()){
1784  for(Int_t i = 0;i<(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader())->GetEntries();i++){
1785  if(fIsMC < 2){
1786  TString nameBin= fHistoMCHeaders[iCut]->GetXaxis()->GetBinLabel(i+1);
1787  if (nameBin.CompareTo("")== 0){
1788  TString nameHeader = ((TObjString*)((TList*)((AliConvEventCuts*)fEventCutArray->At(iCut))
1789  ->GetAcceptedHeader())->At(i))->GetString();
1790  // cout << nameHeader << endl;
1791  fHistoMCHeaders[iCut]->GetXaxis()->SetBinLabel(i+1,nameHeader.Data());
1792  }
1793  }
1794  }
1795  }
1796  }
1797  }
1798 
1799  if( fIsMC > 0 ){
1800  if(fInputEvent->IsA()==AliESDEvent::Class()) ProcessMCParticles();
1801  if(fInputEvent->IsA()==AliAODEvent::Class()) ProcessAODMCParticles();
1802  }
1803 
1804  ProcessPhotonCandidates(); // Process this cuts gammas
1805 
1806  if(fDoCentralityFlat > 0){
1809  } else {
1810  fHistoNGammaCandidates[iCut]->Fill(fGammaCandidates->GetEntries(),fWeightJetJetMC);
1812  }
1813 
1814  if(fDoMesonAnalysis){ // Meson Analysis
1815  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseMCPSmearing() && fIsMC > 0 ){
1816  fUnsmearedPx = new Double_t[fGammaCandidates->GetEntries()]; // Store unsmeared Momenta
1817  fUnsmearedPy = new Double_t[fGammaCandidates->GetEntries()];
1818  fUnsmearedPz = new Double_t[fGammaCandidates->GetEntries()];
1819  fUnsmearedE = new Double_t[fGammaCandidates->GetEntries()];
1820 
1821  for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
1822  fUnsmearedPx[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Px();
1823  fUnsmearedPy[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Py();
1824  fUnsmearedPz[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Pz();
1825  fUnsmearedE[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->E();
1826  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->SmearParticle(dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(gamma)));
1827  }
1828  }
1829 
1830  CalculatePi0Candidates(); // Combine Gammas
1831  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
1832  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
1833  CalculateBackground(); // Combinatorial Background
1834  UpdateEventByEventData(); // Store Event for mixed Events
1835  } else {
1836  CalculateBackgroundRP(); // Combinatorial Background
1837  fBGHandlerRP[iCut]->AddEvent(fGammaCandidates,fInputEvent); // Store Event for mixed Events
1838  }
1839  }
1840  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseMCPSmearing() && fIsMC > 0 ){
1841  for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
1842  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPx(fUnsmearedPx[gamma]); // Reset Unsmeared Momenta
1843  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPy(fUnsmearedPy[gamma]);
1844  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPz(fUnsmearedPz[gamma]);
1845  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetE(fUnsmearedE[gamma]);
1846  }
1847  delete[] fUnsmearedPx; fUnsmearedPx = 0x0;
1848  delete[] fUnsmearedPy; fUnsmearedPy = 0x0;
1849  delete[] fUnsmearedPz; fUnsmearedPz = 0x0;
1850  delete[] fUnsmearedE; fUnsmearedE = 0x0;
1851  }
1852 
1853  if( fIsMC > 0 ){
1854  vecDoubleCountTruePi0s.clear();
1855  vecDoubleCountTrueEtas.clear();
1858  }
1859  }
1860 
1861  if( fIsMC > 0 ){
1864  }
1865 
1866  fGammaCandidates->Clear(); // delete this cuts good gammas
1867  }
1868 
1869  if( fIsMC > 0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
1870  RelabelAODPhotonCandidates(kFALSE); // Back to ESDMC Label
1871  fV0Reader->RelabelAODs(kFALSE);
1872  }
1873 
1874  PostData(1, fOutputContainer);
1875 }
1876 //________________________________________________________________________
1878 {
1879  Int_t nV0 = 0;
1880  TList *GammaCandidatesStepOne = new TList();
1881  TList *GammaCandidatesStepTwo = new TList();
1882  // Loop over Photon Candidates allocated by ReaderV1
1883  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
1884  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
1885  if(!PhotonCandidate) continue;
1886  fIsFromSelectedHeader = kTRUE;
1887 
1888  Float_t weightMatBudgetGamma = 1.;
1889  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
1890  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(PhotonCandidate);
1891  }
1892 
1893 
1894  if( fIsMC > 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
1895  Int_t isPosFromMBHeader
1896  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
1897  if(isPosFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
1898  Int_t isNegFromMBHeader
1899  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
1900  if(isNegFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
1901 
1902  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromSelectedHeader = kFALSE;
1903  }
1904 
1905 
1906  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fInputEvent)) continue;
1907  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(PhotonCandidate->GetPhotonPhi(),fEventPlaneAngle)) continue;
1908  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
1909  !((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
1910  fGammaCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
1911 
1913  if(fDoCentralityFlat > 0) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
1914  else fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightJetJetMC*weightMatBudgetGamma);
1915  if (fDoPhotonQA > 0 && fIsMC < 2){
1916  if(fDoCentralityFlat > 0){
1917  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
1918  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
1919  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
1920  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
1921  } else {
1922  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
1923  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
1924  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
1925  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(),fWeightJetJetMC*weightMatBudgetGamma);
1926  }
1927  }
1928  if( fIsMC > 0 ){
1929  if(fInputEvent->IsA()==AliESDEvent::Class())
1930  ProcessTruePhotonCandidates(PhotonCandidate);
1931  if(fInputEvent->IsA()==AliAODEvent::Class())
1932  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
1933  }
1934  if (fDoPhotonQA == 2){
1935  if (fIsHeavyIon == 1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
1936  fPtGamma = PhotonCandidate->Pt();
1937  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
1938  fRConvPhoton = PhotonCandidate->GetConversionRadius();
1939  fEtaPhoton = PhotonCandidate->GetPhotonEta();
1940  iCatPhoton = PhotonCandidate->GetPhotonQuality();
1941  tESDConvGammaPtDcazCat[fiCut]->Fill();
1942  } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
1943  fPtGamma = PhotonCandidate->Pt();
1944  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
1945  fRConvPhoton = PhotonCandidate->GetConversionRadius();
1946  fEtaPhoton = PhotonCandidate->GetPhotonEta();
1947  iCatPhoton = PhotonCandidate->GetPhotonQuality();
1948  tESDConvGammaPtDcazCat[fiCut]->Fill();
1949  }
1950  }
1951  }
1952  } else if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
1953  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
1954  nV0++;
1955  GammaCandidatesStepOne->Add(PhotonCandidate);
1956  } else if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
1957  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
1958  GammaCandidatesStepTwo->Add(PhotonCandidate);
1959  }
1960  }
1961  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){
1962  for(Int_t i = 0;i<GammaCandidatesStepOne->GetEntries();i++){
1963  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GammaCandidatesStepOne->At(i);
1964  if(!PhotonCandidate) continue;
1965  fIsFromSelectedHeader = kTRUE;
1966 
1967  Float_t weightMatBudgetGamma = 1.;
1968  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
1969  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(PhotonCandidate);
1970  }
1971 
1972 
1973  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
1974  Int_t isPosFromMBHeader
1975  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
1976  Int_t isNegFromMBHeader
1977  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
1978  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromSelectedHeader = kFALSE;
1979  }
1980  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GammaCandidatesStepOne->GetEntries())) continue;
1981  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
1982  fGammaCandidates->Add(PhotonCandidate);
1983 
1985  if(fDoCentralityFlat > 0) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
1986  else fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
1987  if (fDoPhotonQA > 0 && fIsMC < 2){
1988  if(fDoCentralityFlat > 0){
1989  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
1990  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
1991  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
1992  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
1993  } else {
1994  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
1995  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
1996  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
1997  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(),fWeightJetJetMC*weightMatBudgetGamma);
1998  }
1999  }
2000  if( fIsMC > 0 ){
2001  if(fInputEvent->IsA()==AliESDEvent::Class())
2002  ProcessTruePhotonCandidates(PhotonCandidate);
2003  if(fInputEvent->IsA()==AliAODEvent::Class())
2004  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
2005  }
2006  if (fDoPhotonQA == 2){
2007  if (fIsHeavyIon ==1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
2008  fPtGamma = PhotonCandidate->Pt();
2009  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2010  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2011  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2012  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2013  tESDConvGammaPtDcazCat[fiCut]->Fill();
2014  } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
2015  fPtGamma = PhotonCandidate->Pt();
2016  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2017  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2018  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2019  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2020  tESDConvGammaPtDcazCat[fiCut]->Fill();
2021  }
2022  }
2023  }
2024  } else GammaCandidatesStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
2025  }
2026  }
2027  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
2028  for(Int_t i = 0;i<GammaCandidatesStepTwo->GetEntries();i++){
2029  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GammaCandidatesStepTwo->At(i);
2030  if(!PhotonCandidate) continue;
2031  fIsFromSelectedHeader = kTRUE;
2032 
2033  Float_t weightMatBudgetGamma = 1.;
2034  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2035  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(PhotonCandidate);
2036  }
2037 
2038  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2039  Int_t isPosFromMBHeader
2040  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
2041  Int_t isNegFromMBHeader
2042  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
2043  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromSelectedHeader = kFALSE;
2044  }
2045  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GammaCandidatesStepTwo,i)) continue;
2046  fGammaCandidates->Add(PhotonCandidate); // Add gamma to current cut TList
2047 
2049  if(fDoCentralityFlat > 0) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2050  else fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2051  if (fDoPhotonQA > 0 && fIsMC < 2 ){
2052  if(fDoCentralityFlat > 0){
2053  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2054  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2055  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2056  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(), fWeightCentrality[fiCut]*fWeightJetJetMC*weightMatBudgetGamma);
2057  } else {
2058  fHistoConvGammaPsiPairPt[fiCut]->Fill(PhotonCandidate->GetPsiPair(),PhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2059  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
2060  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
2061  fHistoConvGammaPhi[fiCut]->Fill(PhotonCandidate->Phi(),fWeightJetJetMC*weightMatBudgetGamma);
2062  }
2063  }
2064  if( fIsMC > 0 ){
2065  if(fInputEvent->IsA()==AliESDEvent::Class())
2066  ProcessTruePhotonCandidates(PhotonCandidate);
2067  if(fInputEvent->IsA()==AliAODEvent::Class())
2068  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
2069  }
2070  if (fDoPhotonQA == 2){
2071  if (fIsHeavyIon == 1 && PhotonCandidate->Pt() > 0.399 && PhotonCandidate->Pt() < 12.){
2072  fPtGamma = PhotonCandidate->Pt();
2073  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2074  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2075  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2076  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2077  tESDConvGammaPtDcazCat[fiCut]->Fill();
2078  } else if ( PhotonCandidate->Pt() > 0.299 && PhotonCandidate->Pt() < 16.){
2079  fPtGamma = PhotonCandidate->Pt();
2080  fDCAzPhoton = PhotonCandidate->GetDCAzToPrimVtx();
2081  fRConvPhoton = PhotonCandidate->GetConversionRadius();
2082  fEtaPhoton = PhotonCandidate->GetPhotonEta();
2083  iCatPhoton = PhotonCandidate->GetPhotonQuality();
2084  tESDConvGammaPtDcazCat[fiCut]->Fill();
2085  }
2086  }
2087  }
2088  }
2089  }
2090 
2091  delete GammaCandidatesStepOne;
2092  GammaCandidatesStepOne = 0x0;
2093  delete GammaCandidatesStepTwo;
2094  GammaCandidatesStepTwo = 0x0;
2095 
2096 }
2097 //________________________________________________________________________
2099 {
2100  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2101  Double_t mcProdVtxX = primVtxMC->GetX();
2102  Double_t mcProdVtxY = primVtxMC->GetY();
2103  Double_t mcProdVtxZ = primVtxMC->GetZ();
2104 
2105  Double_t magField = fInputEvent->GetMagneticField();
2106  if( magField < 0.0 ){
2107  magField = 1.0;
2108  }
2109  else {
2110  magField = -1.0;
2111  }
2112 
2113  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2114  if (AODMCTrackArray != NULL && TruePhotonCandidate != NULL){
2115 
2116  AliAODMCParticle *posDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelPositive());
2117  AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelNegative());
2118  iPhotonMCInfo = 0;
2119 
2120  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
2121  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
2122 
2123  Double_t PhiParticle[2] = {posDaughter->Phi(),negDaughter->Phi()};
2124 
2125  if(posDaughter->GetMother() != negDaughter->GetMother()){
2126  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
2127  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
2128  if(posDaughter->GetMother() > -1){ //contamination is not a primary
2129  AliAODMCParticle *Mom = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
2130  if(Mom->GetMother() == -1){
2131  FillPhotonCombinatorialMothersHistAOD(posDaughter,Mom);
2132  } else {
2133  AliAODMCParticle *GranMom = (AliAODMCParticle*) AODMCTrackArray->At(Mom->GetMother());
2134  if(GranMom->GetMother() == -1){
2135  FillPhotonCombinatorialMothersHistAOD(posDaughter,GranMom);
2136  } else {
2137  AliAODMCParticle *GranGranMom = (AliAODMCParticle*) AODMCTrackArray->At(GranMom->GetMother());
2138  if(GranGranMom->GetMother() == -1){
2139  FillPhotonCombinatorialMothersHistAOD(posDaughter,GranGranMom);
2140  } else FillPhotonCombinatorialMothersHistAOD(posDaughter,GranGranMom);
2141  }
2142  }
2143  }
2144  if(negDaughter->GetMother() > -1){ //contamination is not a primary
2145  AliAODMCParticle *Mom = (AliAODMCParticle*) AODMCTrackArray->At(negDaughter->GetMother());
2146  if(Mom->GetMother() == -1){
2147  FillPhotonCombinatorialMothersHistAOD(negDaughter,Mom);
2148  } else {
2149  AliAODMCParticle *GranMom = (AliAODMCParticle*) AODMCTrackArray->At(Mom->GetMother());
2150  if(GranMom->GetMother() == -1){
2151  FillPhotonCombinatorialMothersHistAOD(negDaughter,GranMom);
2152  } else {
2153  AliAODMCParticle *GranGranMom = (AliAODMCParticle*) AODMCTrackArray->At(GranMom->GetMother());
2154  if(GranGranMom->GetMother() == -1){
2155  FillPhotonCombinatorialMothersHistAOD(negDaughter,GranGranMom);
2156  } else FillPhotonCombinatorialMothersHistAOD(posDaughter,GranGranMom);
2157  }
2158  }
2159  }
2160  }
2161  iPhotonMCInfo = 1;
2162  return;
2163  }
2164  else if(posDaughter->GetMother() == -1){
2165  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
2166  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
2167  FillPhotonCombinatorialMothersHistAOD(posDaughter,posDaughter);
2168  FillPhotonCombinatorialMothersHistAOD(negDaughter,negDaughter);
2169  }
2170  iPhotonMCInfo = 1;
2171  return;
2172  }
2173 
2174  if(pdgCode[0]!=11 || pdgCode[1]!=11){
2175  iPhotonMCInfo = 1;
2176  return; //One Particle is not a electron
2177  }
2178  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()){
2179  iPhotonMCInfo = 1;
2180  return; // Same Charge
2181  }
2182 
2183  AliAODMCParticle *Photon = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
2184  AliVTrack * electronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelNegative() );
2185  AliVTrack * positronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelPositive() );
2186  Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->Phi()-positronCandidate->Phi());
2187 
2188  if(Photon->GetPdgCode() != 22){
2189  fHistoTrueDalitzPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC);
2190  iPhotonMCInfo = 1;
2191  return; // Mother is no Photon
2192  }
2193 
2194  if(((posDaughter->GetMCProcessCode())) != 5 || ((negDaughter->GetMCProcessCode())) != 5){
2195  iPhotonMCInfo = 1;
2196  return;// check if the daughters come from a conversion
2197  }
2198  // STILL A BUG IN ALIROOT >>8 HAS TPO BE REMOVED AFTER FIX
2199 
2200  Double_t rConv=0.;
2201  rConv = sqrt( (posDaughter->Xv()*posDaughter->Xv()) + (posDaughter->Yv()*posDaughter->Yv()) );
2202 
2203  // True Photon
2204 
2205  Float_t weightMatBudgetGamma = 1.;
2206  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2207  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TruePhotonCandidate);
2208  }
2209 
2210  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2211  if (CheckVectorForDoubleCount(vecDoubleCountTrueConvGammas,posDaughter->GetMother())){
2212  fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2213  FillMultipleCountMap(mapMultipleCountTrueConvGammas,posDaughter->GetMother());
2214  }
2215  if (fDoPhotonQA > 0 ){
2216  if (fIsMC < 2){
2217  fHistoTrueConvGammaPsiPairPt[fiCut]->Fill(TruePhotonCandidate->GetPsiPair(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2218  fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta(),fWeightJetJetMC*weightMatBudgetGamma);
2219  fHistoTrueConvGammaR[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),fWeightJetJetMC*weightMatBudgetGamma);
2220  fHistoTrueConvGammaRMC[fiCut]->Fill(rConv,fWeightJetJetMC*weightMatBudgetGamma);
2221  }
2222  fHistoTrueConvGammaPtMC[fiCut]->Fill(Photon->Pt(), fWeightJetJetMC*weightMatBudgetGamma);
2223  }
2224  fHistoTrueGammaPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC*weightMatBudgetGamma);
2225 
2226  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2227  if(isPrimary){
2228  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
2229  iPhotonMCInfo = 6;
2230  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2231  fHistoTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(),fWeightJetJetMC*weightMatBudgetGamma); // Allways Filled
2232  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
2233  } else {
2234  iPhotonMCInfo = 2;
2235  if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 && ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetMother() > -1 ){
2236  if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 310){
2237  iPhotonMCInfo = 4;
2238  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
2239  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
2240  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2241  } else if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 130) {
2242  iPhotonMCInfo = 7;
2243  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
2244  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
2245  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2246  } else if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 3122) {
2247  iPhotonMCInfo = 5;
2248  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
2249  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
2250  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2251  } else if (((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 221) {
2252  iPhotonMCInfo = 3;
2253  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2254  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2255  } else {
2256  // if ( !(TMath::Abs(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetPdgCode()) == 11 && ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 22) ) {
2257  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2258  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2259  // }
2260  }
2261  }
2262  }
2263  }
2264  return;
2265 }
2266 //________________________________________________________________________
2268 {
2269 
2270  Double_t magField = fInputEvent->GetMagneticField();
2271  if( magField < 0.0 ){
2272  magField = 1.0;
2273  }
2274  else {
2275  magField = -1.0;
2276  }
2277 
2278  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2279  Double_t mcProdVtxX = primVtxMC->GetX();
2280  Double_t mcProdVtxY = primVtxMC->GetY();
2281  Double_t mcProdVtxZ = primVtxMC->GetZ();
2282 
2283  // Process True Photons
2284  TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCEvent);
2285  TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCEvent);
2286 
2287  iPhotonMCInfo = 0;
2288 
2289  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
2290  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
2291 
2292  Double_t PhiParticle[2] = {posDaughter->Phi(),negDaughter->Phi()};
2293 
2294  iPhotonMCInfo = 1;
2295  if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){
2296  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
2297  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
2298  if(posDaughter->GetMother(0) > -1){ //contamination is not a primary
2299  TParticle *Mom = fMCEvent->Particle(posDaughter->GetMother(0));
2300  if(Mom->GetMother(0) == -1){
2301  FillPhotonCombinatorialMothersHistESD(posDaughter,Mom);
2302  } else {
2303  TParticle *GranMom = fMCEvent->Particle(Mom->GetMother(0));
2304  if(GranMom->GetMother(0) == -1){
2305  FillPhotonCombinatorialMothersHistESD(posDaughter,GranMom);
2306  } else {
2307  TParticle *GranGranMom = fMCEvent->Particle(GranMom->GetMother(0));
2308  if(GranGranMom->GetMother(0) == -1){
2309  FillPhotonCombinatorialMothersHistESD(posDaughter,GranGranMom);
2310  } else FillPhotonCombinatorialMothersHistESD(posDaughter,GranGranMom);
2311  }
2312  }
2313  }
2314  if(negDaughter->GetMother(0) > -1){ //contamination is not a primary
2315  TParticle *Mom = fMCEvent->Particle(negDaughter->GetMother(0));
2316  if(Mom->GetMother(0) == -1){
2317  FillPhotonCombinatorialMothersHistESD(negDaughter,Mom);
2318  } else {
2319  TParticle *GranMom = fMCEvent->Particle(Mom->GetMother(0));
2320  if(GranMom->GetMother(0) == -1){
2321  FillPhotonCombinatorialMothersHistESD(negDaughter,GranMom);
2322  } else {
2323  TParticle *GranGranMom = fMCEvent->Particle(GranMom->GetMother(0));
2324  if(GranGranMom->GetMother(0) == -1){
2325  FillPhotonCombinatorialMothersHistESD(negDaughter,GranGranMom);
2326  } else FillPhotonCombinatorialMothersHistESD(posDaughter,GranGranMom);
2327  }
2328  }
2329  }
2330  }
2331  return;
2332  } else if(posDaughter->GetMother(0) == -1){ //gamma contamination is a primary
2333  FillPhotonCombinatorialBackgroundHist(TruePhotonCandidate, pdgCode, PhiParticle);
2334  if(fDoPhotonQA == 3 && fIsHeavyIon == 1){
2335  FillPhotonCombinatorialMothersHistESD(posDaughter,posDaughter);
2336  FillPhotonCombinatorialMothersHistESD(negDaughter,negDaughter);
2337  }
2338  return;
2339  }
2340 
2341  if(pdgCode[0]!=11 || pdgCode[1]!=11) return; //One Particle is not a electron
2342 
2343  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
2344 
2345  TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCEvent);
2346  AliVTrack * electronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelNegative() );
2347  AliVTrack * positronCandidate = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetTrack(fInputEvent,TruePhotonCandidate->GetTrackLabelPositive() );
2348  Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->Phi()-positronCandidate->Phi());
2349 
2350  if(Photon->GetPdgCode() != 22){
2351  fHistoTrueDalitzPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC);
2352  return; // Mother is no Photon
2353  }
2354 
2355  if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
2356 
2357  // True Photon
2358  Float_t weightMatBudgetGamma = 1.;
2359  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
2360  weightMatBudgetGamma = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TruePhotonCandidate);
2361  }
2362 
2363  // cout<< " AM- Material Budget weight Gamma::"<< weightMatBudgetGamma << " "<< TruePhotonCandidate->GetConversionRadius() << endl;
2364 
2365  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2366  if (CheckVectorForDoubleCount(vecDoubleCountTrueConvGammas,posDaughter->GetMother(0))){
2367  fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2368  FillMultipleCountMap(mapMultipleCountTrueConvGammas,posDaughter->GetMother(0));
2369  }
2370  if (fDoPhotonQA > 0){
2371  if (fIsMC < 2){
2372  fHistoTrueConvGammaPsiPairPt[fiCut]->Fill(TruePhotonCandidate->GetPsiPair(),TruePhotonCandidate->Pt(),weightMatBudgetGamma);
2373  fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta(),weightMatBudgetGamma);
2374  fHistoTrueConvGammaR[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),weightMatBudgetGamma);
2375  fHistoTrueConvGammaRMC[fiCut]->Fill(posDaughter->R(),weightMatBudgetGamma);
2376  }
2377  fHistoTrueConvGammaPtMC[fiCut]->Fill(Photon->Pt(), fWeightJetJetMC*weightMatBudgetGamma);
2378  }
2379 
2380  fHistoTrueGammaPsiPairDeltaPhi[fiCut]->Fill(deltaPhi,TruePhotonCandidate->GetPsiPair(),fWeightJetJetMC*weightMatBudgetGamma);
2381  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, posDaughter->GetMother(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
2382  // filling primary histograms
2383  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
2384  iPhotonMCInfo = 6;
2385  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2386  fHistoTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt(),fWeightJetJetMC*weightMatBudgetGamma); // Allways Filled
2387  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
2388  } else {
2389  // filling secondary photon histograms
2390  iPhotonMCInfo = 2;
2391  if( Photon->GetMother(0) > -1 && fMCEvent->Particle(Photon->GetMother(0))->GetMother(0) > -1){
2392  if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
2393  iPhotonMCInfo = 4;
2394  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
2395  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),0.,fWeightJetJetMC*weightMatBudgetGamma);
2396  fHistoTrueSecondaryConvGammaFromXFromK0sMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2397  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
2398  iPhotonMCInfo = 7;
2399  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
2400  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),1.,fWeightJetJetMC*weightMatBudgetGamma);
2401  fHistoTrueSecondaryConvGammaFromXFromK0lMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2402  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
2403  iPhotonMCInfo = 5;
2404  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
2405  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),2.,fWeightJetJetMC*weightMatBudgetGamma);
2406  fHistoTrueSecondaryConvGammaFromXFromLambdaMCPtESDPt[fiCut]->Fill(Photon->Pt(),TruePhotonCandidate->Pt(),fWeightJetJetMC*weightMatBudgetGamma);
2407  } else if (fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 221) {
2408  iPhotonMCInfo = 3;
2409  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2410  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2411  } else {
2412 // if ( !(TMath::Abs(fMCEvent->Particle(Photon->GetMother(0))->GetPdgCode()) == 11 && fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 22) ) {
2413  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2414  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2415 // }
2416  }
2417  } else {
2418  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2419  fHistoTrueSecondaryConvGammaMCPt[fiCut]->Fill(Photon->Pt(),3.,fWeightJetJetMC*weightMatBudgetGamma);
2420  }
2421  }
2422 }
2423 //________________________________________________________________________
2425 {
2426  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2427  Double_t mcProdVtxX = primVtxMC->GetX();
2428  Double_t mcProdVtxY = primVtxMC->GetY();
2429  Double_t mcProdVtxZ = primVtxMC->GetZ();
2430 
2431  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2432 
2433  if (AODMCTrackArray){
2434  // Loop over all primary MC particle
2435  for(Int_t i = 0; i < AODMCTrackArray->GetEntriesFast(); i++) {
2436 
2437  AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
2438  if (!particle) continue;
2439 
2440  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, particle, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2441  if (isPrimary){
2442 
2443  Int_t isMCFromMBHeader = -1;
2444  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2445  isMCFromMBHeader
2446  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2447  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2448  }
2449 
2450  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
2451  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kFALSE)){
2452  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // All MC Gamma
2453  if(particle->GetMother() >-1){ // Meson Decay Gamma
2454  switch((static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother())))->GetPdgCode()){
2455  case 111: // Pi0
2456  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2457  break;
2458  case 113: // Rho0
2459  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2460  break;
2461  case 221: // Eta
2462  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2463  break;
2464  case 223: // Omega
2465  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2466  break;
2467  case 331: // Eta'
2468  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2469  break;
2470  case 333: // Phi
2471  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2472  break;
2473  case 3212: // Sigma
2474  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2475  break;
2476  }
2477  }
2478  }
2479  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kTRUE)){
2480  Double_t rConv = 0;
2481  for(Int_t daughterIndex=particle->GetDaughter(0);daughterIndex<=particle->GetDaughter(1);daughterIndex++){
2482  AliAODMCParticle *tmpDaughter = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(daughterIndex));
2483  if(!tmpDaughter) continue;
2484  if(TMath::Abs(tmpDaughter->GetPdgCode()) == 11){
2485  rConv = sqrt( (tmpDaughter->Xv()*tmpDaughter->Xv()) + (tmpDaughter->Yv()*tmpDaughter->Yv()) );
2486  }
2487  }
2488  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2489  if ( fDoPhotonQA > 0 && fIsMC < 2){
2491  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta(),fWeightJetJetMC);
2492  }
2493  }
2494  // Converted MC Gamma
2495  if(fDoMesonAnalysis){
2496 
2497  Double_t mesonY = 1.e30;
2498  Double_t ratio = 0;
2499  if (particle->E() != TMath::Abs(particle->Pz())){
2500  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2501  }
2502  if( !(ratio <= 0) ){
2503  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2504  }
2505 
2506  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
2507  if ( particle->GetPdgCode() == 211 ){ // positve pions
2508  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2509  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2510  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2511  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2512  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
2513  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
2514  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2515  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
2516  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),4.,fWeightJetJetMC);
2517  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
2518  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),5.,fWeightJetJetMC);
2519  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
2520  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),6.,fWeightJetJetMC);
2521  } else if ( TMath::Abs(particle->GetPdgCode()) == 223 ){ // Omega
2522  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),7.,fWeightJetJetMC);
2523  } else if ( TMath::Abs(particle->GetPdgCode()) == 333 ){ // Phi
2524  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),8.,fWeightJetJetMC);
2525  } else if ( TMath::Abs(particle->GetPdgCode()) == 113 ){ // Rho0
2526  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),9.,fWeightJetJetMC);
2527  }
2528  }
2529 
2530  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2531  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
2532  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
2533  Float_t weighted= 1;
2534  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2535  if (particle->Pt()>0.005){
2536  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, 0x0, fInputEvent);
2537  // if(particle->GetPdgCode() == 221){
2538  // cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
2539  // }
2540  }
2541  }
2542 
2543  Double_t mesonY = 1.e30;
2544  Double_t ratio = 0;
2545  if (particle->E() != TMath::Abs(particle->Pz())){
2546  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2547  }
2548  if( !(ratio <= 0) ){
2549  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2550  }
2551 
2552  Double_t alpha = -1;
2553  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
2554  alpha = TMath::Abs((daughter0->E() - daughter1->E()))/(daughter0->E() + daughter1->E());
2555  }
2556 
2557  if(particle->GetPdgCode() == 111){
2558  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Pi0
2559  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2560  if ( fIsMC > 1 ) fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
2561  if (fDoMesonQA > 0){
2562  if ( fIsMC < 2 )fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
2563  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
2564  if ( fIsMC == 2 ) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2565  }
2566  } else if(particle->GetPdgCode() == 221){
2567  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Eta
2568  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2569  if ( fIsMC > 1 ) fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2570  if (fDoMesonQA > 0){
2571  if ( fIsMC < 2 )fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
2572  fHistoMCEtaPtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
2573  if ( fIsMC == 2 ) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2574  }
2575  }
2576 
2577  // Check the acceptance for both gammas
2578  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
2579  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
2580  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2581  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2582 
2583  if(particle->GetPdgCode() == 111){
2584  if(fIsMC > 1) fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 with gamma in acc NOT weighted at all
2585  fHistoMCPi0WOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Pi0 with gamma in acc NOT weighted
2586  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc
2587  } else if(particle->GetPdgCode() == 221){
2588  if(fIsMC > 1) fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta with gamma in acc NOT weighted at all
2589  fHistoMCEtaWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Eta with gamma in acc NOT weighted
2590  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Eta with gamma in acc
2591  }
2592  }
2593  }
2594  }
2595  // fill secondary histograms
2596  } else {
2597  Int_t isMCFromMBHeader = -1;
2598  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2599  isMCFromMBHeader
2600  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2601  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2602  }
2603 
2604  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) {
2605  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kFALSE)){
2606  if (particle->GetMother() > -1) {
2607  AliAODMCParticle *tmpMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2608  if (tmpMother->GetMother() > -1) {
2609  AliAODMCParticle *tmpGrandMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(tmpMother->GetMother()));
2610  if(tmpGrandMother->GetPdgCode() == 310) {
2611  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2612  } else if (tmpGrandMother->GetPdgCode() == 130) {
2613  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2614  } else if (tmpGrandMother->GetPdgCode() == 3122) {
2615  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
2616  } else {
2617  if ( !(TMath::Abs(tmpMother->GetPdgCode()) == 11 && tmpGrandMother->GetPdgCode() == 22) )
2618  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2619  }
2620  } else {
2621  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2622  }
2623  } else {
2624  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2625  }
2626  }
2627 
2628  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kTRUE)){
2629  if (particle->GetMother() > -1) {
2630  AliAODMCParticle *tmpMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2631  if (tmpMother->GetMother() > -1) {
2632  AliAODMCParticle *tmpGrandMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(tmpMother->GetMother()));
2633  if(tmpGrandMother->GetPdgCode() == 310) {
2634  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2635  } else if (tmpGrandMother->GetPdgCode() == 130) {
2636  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2637  } else if (tmpGrandMother->GetPdgCode() == 3122) {
2638  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
2639  } else {
2640  if ( !(TMath::Abs(tmpMother->GetPdgCode()) == 11 && tmpGrandMother->GetPdgCode() == 22) )
2641  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2642  }
2643  } else {
2644  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2645  }
2646  } else {
2647  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2648  }
2649  }
2650  }
2651 
2652  if(fDoMesonAnalysis){
2653  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2654  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
2655  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
2656  AliAODMCParticle* mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2657  Int_t pdgCode = mother->GetPdgCode();
2658  if(particle->GetPdgCode() == 111){
2659  Int_t source = GetSourceClassification(111,pdgCode);
2660  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
2661  fHistoMCSecPi0Source[fiCut]->Fill(pdgCode);
2662  } else if(particle->GetPdgCode() == 221){
2663  fHistoMCSecEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2664  fHistoMCSecEtaSource[fiCut]->Fill(pdgCode);
2665  }
2666 
2667  // pi0 really in acceptance/
2668  if( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
2669  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
2670  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2671  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2672  if(particle->GetPdgCode() == 111){
2673  Int_t source = GetSourceClassification(111,pdgCode);
2674  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
2675  }
2676  }
2677  }
2678  }
2679  }
2680  }
2681  }
2682  return;
2683 }
2684 //________________________________________________________________________
2686 {
2687  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2688  Double_t mcProdVtxX = primVtxMC->GetX();
2689  Double_t mcProdVtxY = primVtxMC->GetY();
2690  Double_t mcProdVtxZ = primVtxMC->GetZ();
2691 // cout << mcProdVtxX <<"\t" << mcProdVtxY << "\t" << mcProdVtxZ << endl;
2692 
2693  // Loop over all primary MC particle
2694  for(Long_t i = 0; i < fMCEvent->GetNumberOfTracks(); i++) {
2695 
2696  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
2697  // fill primary histogram
2698  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
2699  if (!particle) continue;
2700 
2701  Int_t isMCFromMBHeader = -1;
2702  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2703  isMCFromMBHeader
2704  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2705  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2706  }
2707 
2708  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
2709  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
2710  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // All MC Gamma
2711  if(particle->GetMother(0) >-1){ // Meson Decay Gamma
2712  switch(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()){
2713  case 111: // Pi0
2714  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2715  break;
2716  case 113: // Rho0
2717  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2718  break;
2719  case 221: // Eta
2720  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2721  break;
2722  case 223: // Omega
2723  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2724  break;
2725  case 331: // Eta'
2726  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2727  break;
2728  case 333: // Phi
2729  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2730  break;
2731  case 3212: // Sigma
2732  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2733  break;
2734  }
2735  }
2736  }
2737  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kTRUE)){
2738  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2739  if (fDoPhotonQA > 0 && fIsMC < 2){
2740  fHistoMCConvGammaR[fiCut]->Fill(((TParticle*)fMCEvent->Particle(particle->GetFirstDaughter()))->R(),fWeightJetJetMC);
2741  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta(),fWeightJetJetMC);
2742  }
2743  } // Converted MC Gamma
2744  if(fDoMesonAnalysis){
2745 
2746  Double_t mesonY = 1.e30;
2747  Double_t ratio = 0;
2748  if (particle->Energy() != TMath::Abs(particle->Pz())){
2749  ratio = (particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz());
2750  }
2751  if( !(ratio <= 0) ){
2752  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2753  }
2754 
2755  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
2756  if ( particle->GetPdgCode() == 211 ){ // positve pions
2757  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2758  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2759  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2760  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2761  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
2762  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
2763  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2764  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
2765  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),4.,fWeightJetJetMC);
2766  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
2767  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),5.,fWeightJetJetMC);
2768  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
2769  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),6.,fWeightJetJetMC);
2770  } else if ( TMath::Abs(particle->GetPdgCode()) == 223 ){ // Omega
2771  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),7.,fWeightJetJetMC);
2772  } else if ( TMath::Abs(particle->GetPdgCode()) == 333 ){ // Phi
2773  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),8.,fWeightJetJetMC);
2774  } else if ( TMath::Abs(particle->GetPdgCode()) == 113 ){ // Rho0
2775  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(),9.,fWeightJetJetMC);
2776  }
2777  }
2778 
2780  ->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2781  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
2782  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
2783 
2784  Float_t weighted= 1;
2785  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2786  if (particle->Pt()>0.005){
2787  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
2788  // if(particle->GetPdgCode() == 221){
2789  // cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
2790  // }
2791  }
2792  }
2793  Double_t mesonY = 1.e30;
2794  Double_t ratio = 0;
2795  if (particle->Energy() != TMath::Abs(particle->Pz())){
2796  ratio = (particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz());
2797  }
2798  if( !(ratio <= 0) ){
2799  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2800  }
2801 
2802  Double_t alpha = -1;
2803  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
2804  alpha = TMath::Abs((daughter0->Energy() - daughter1->Energy()))/(daughter0->Energy() + daughter1->Energy());
2805  }
2806 
2807  if(particle->GetPdgCode() == 111){
2808  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Pi0
2809  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2810  if (fIsMC > 1) fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
2811  if (fDoMesonQA > 0){
2812  if (fIsMC < 2)fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
2813  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
2814  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2815  }
2816  } else if(particle->GetPdgCode() == 221){
2817  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Eta
2818  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2819  if (fIsMC > 1) fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2820  if (fDoMesonQA > 0){
2821  if (fIsMC < 2)fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
2822  fHistoMCEtaPtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
2823  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2824  }
2825  }
2826 
2827  // Check the acceptance for both gammas & whether they are counted as primaries as well
2828  Bool_t kDaughter0IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetFirstDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2829  Bool_t kDaughter1IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetLastDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2830 
2831  if( kDaughter0IsPrim && kDaughter1IsPrim &&
2832  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter0,fMCEvent,kFALSE) &&
2833  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter1,fMCEvent,kFALSE) &&
2834  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2835  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2836 
2837  if(particle->GetPdgCode() == 111){
2838  if(fIsMC > 1) fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 with gamma in acc NOT weighted at all
2839  fHistoMCPi0WOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Pi0 with gamma in acc NOT weighted
2840  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc
2841  } else if(particle->GetPdgCode() == 221){
2842  if(fIsMC > 1) fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta with gamma in acc NOT weighted at all
2843  fHistoMCEtaWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Eta with gamma in acc NOT weighted
2844  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Eta with gamma in acc
2845  }
2846  }
2847  }
2848  }
2849  } else {
2850  // fill secondary histograms
2851  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
2852  if (!particle) continue;
2853 
2854  Int_t isMCFromMBHeader = -1;
2855  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2856  isMCFromMBHeader
2857  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2858  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2859  }
2860 
2861  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)){
2862  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
2863  if (particle->GetMother(0) > -1 && fMCEvent->Particle(particle->GetMother(0))->GetMother(0) > -1) {
2864  if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
2865  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2866  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
2867  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2868  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
2869  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
2870  } else {
2871  if ( !(TMath::Abs(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()) == 11 && fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 22) )
2872  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2873  }
2874  } else {
2875  fHistoMCAllSecondaryGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2876  }
2877  }
2878 
2879  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kTRUE)){
2880  if (particle->GetMother(0) > -1 && fMCEvent->Particle(particle->GetMother(0))->GetMother(0) > -1) {
2881  if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
2882  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),0.,fWeightJetJetMC);
2883  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 130) {
2884  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),1.,fWeightJetJetMC);
2885  } else if (fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 3122) {
2886  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),2.,fWeightJetJetMC);
2887  } else {
2888  if ( !(TMath::Abs(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()) == 11 && fMCEvent->Particle(fMCEvent->Particle(particle->GetMother(0))->GetMother(0))->GetPdgCode() == 22) )
2889  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2890  }
2891  } else {
2892  fHistoMCSecondaryConvGammaPt[fiCut]->Fill(particle->Pt(),3.,fWeightJetJetMC);
2893  }
2894  }
2895  }
2896 
2897  if(fDoMesonAnalysis){
2898  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2899  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
2900  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
2901  Int_t pdgCode = -1;
2902  if(particle->GetFirstMother()>-1) pdgCode = ((TParticle*)fMCEvent->Particle( particle->GetFirstMother() ))->GetPdgCode();
2903  if(particle->GetPdgCode() == 111){
2904  Int_t source = GetSourceClassification(111,pdgCode);
2905  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
2906 
2907  Double_t deltaX = particle->Vx() - mcProdVtxX;
2908  Double_t deltaY = particle->Vy() - mcProdVtxY;
2909  Double_t deltaZ = particle->Vz() - mcProdVtxZ;
2910  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
2911  if(fDoMesonQA > 0 && fIsMC < 2) fHistoMCSecPi0RvsSource[fiCut]->Fill(realRadius3D,source);
2912  fHistoMCSecPi0Source[fiCut]->Fill(pdgCode);
2913  } else if(particle->GetPdgCode() == 221){
2914  fHistoMCSecEtaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2915  fHistoMCSecEtaSource[fiCut]->Fill(pdgCode);
2916  }
2917 
2918  // pi0 really in acceptance/
2919  if( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter0,fMCEvent,kFALSE) &&
2920  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter1,fMCEvent,kFALSE) &&
2921  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2922  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2923  if(particle->GetPdgCode() == 111){
2924  Int_t source = GetSourceClassification(111,pdgCode);
2925  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source,fWeightJetJetMC);
2926  }
2927  }
2928  }
2929  }
2930  }
2931  }
2932 }
2933 
2934 //________________________________________________________________________
2936 
2937  // Conversion Gammas
2938  if(fGammaCandidates->GetEntries()>1){
2939  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries()-1;firstGammaIndex++){
2940  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
2941  if (gamma0==NULL) continue;
2942  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGammaCandidates->GetEntries();secondGammaIndex++){
2943  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(secondGammaIndex));
2944  //Check for same Electron ID
2945  if (gamma1==NULL) continue;
2946  if(gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelPositive() ||
2947  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelNegative() ||
2948  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelPositive() ||
2949  gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelNegative() ) continue;
2950 
2951  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0,gamma1);
2952  pi0cand->SetLabels(firstGammaIndex,secondGammaIndex);
2953  pi0cand->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
2954 
2955  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
2956  if(fDoCentralityFlat > 0){
2957  fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
2958  if(TMath::Abs(pi0cand->GetAlpha())<0.1) fHistoMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E(), fWeightCentrality[fiCut]*fWeightJetJetMC);
2959  } else {
2960  fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(),fWeightJetJetMC);
2961  if(TMath::Abs(pi0cand->GetAlpha())<0.1) fHistoMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E(),fWeightJetJetMC);
2962  }
2963 
2964  if (fDoMesonQA > 0){
2965 
2966  if(fDoMesonQA == 3 && TMath::Abs(gamma0->GetConversionRadius()-gamma1->GetConversionRadius())<10 && pi0cand->GetOpeningAngle()<0.1){
2967  Double_t sparesFill[4] = {gamma0->GetPhotonPt(),gamma0->GetConversionRadius(),TMath::Abs(gamma0->GetConversionRadius()-gamma1->GetConversionRadius()),pi0cand->GetOpeningAngle()};
2968  sPtRDeltaROpenAngle[fiCut]->Fill(sparesFill, 1);
2969  }
2970 
2971  if ( pi0cand->M() > 0.05 && pi0cand->M() < 0.17){
2972  if (fIsMC < 2){
2973  fHistoMotherPi0PtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
2974  fHistoMotherPi0PtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());
2975  }
2976  fHistoMotherPi0PtAlpha[fiCut]->Fill(pi0cand->Pt(),TMath::Abs(pi0cand->GetAlpha()),fWeightJetJetMC);
2977 
2978  }
2979  if ( pi0cand->M() > 0.45 && pi0cand->M() < 0.65){
2980  if (fIsMC < 2){
2981  fHistoMotherEtaPtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
2982  fHistoMotherEtaPtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());
2983  }
2984  fHistoMotherEtaPtAlpha[fiCut]->Fill(pi0cand->Pt(),TMath::Abs(pi0cand->GetAlpha()),fWeightJetJetMC);
2985  }
2986  }
2987  if(fDoTHnSparse && ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
2988  Int_t psibin = 0;
2989  Int_t zbin = 0;
2990  Int_t mbin = 0;
2991 
2992  Double_t sparesFill[4];
2993  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
2994  zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
2995  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
2997  } else {
2998  mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
2999  }
3000  sparesFill[0] = pi0cand->M();
3001  sparesFill[1] = pi0cand->Pt();
3002  sparesFill[2] = (Double_t)zbin;
3003  sparesFill[3] = (Double_t)mbin;
3004  } else {
3005  psibin = fBGHandlerRP[fiCut]->GetRPBinIndex(TMath::Abs(fEventPlaneAngle));
3006  zbin = fBGHandlerRP[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3007 // if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3008 // mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
3009 // } else {
3010 // mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
3011 // }
3012  sparesFill[0] = pi0cand->M();
3013  sparesFill[1] = pi0cand->Pt();
3014  sparesFill[2] = (Double_t)zbin;
3015  sparesFill[3] = (Double_t)psibin;
3016  }
3017 // Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
3018  if(fDoCentralityFlat > 0) sESDMotherInvMassPtZM[fiCut]->Fill(sparesFill, fWeightCentrality[fiCut]*fWeightJetJetMC); //instead of weight 1
3019  else sESDMotherInvMassPtZM[fiCut]->Fill(sparesFill, fWeightJetJetMC);
3020  }
3021 
3022 
3023  if( fIsMC > 0 ){
3024  if(fInputEvent->IsA()==AliESDEvent::Class())
3025  ProcessTrueMesonCandidates(pi0cand,gamma0,gamma1);
3026  if(fInputEvent->IsA()==AliAODEvent::Class())
3027  ProcessTrueMesonCandidatesAOD(pi0cand,gamma0,gamma1);
3028  }
3029  if (fDoMesonQA == 2){
3030  fInvMass = pi0cand->M();
3031  fPt = pi0cand->Pt();
3032  if (TMath::Abs(gamma0->GetDCAzToPrimVtx()) < TMath::Abs(gamma1->GetDCAzToPrimVtx())){
3033  fDCAzGammaMin = gamma0->GetDCAzToPrimVtx();
3034  fDCAzGammaMax = gamma1->GetDCAzToPrimVtx();
3035  } else {
3036  fDCAzGammaMin = gamma1->GetDCAzToPrimVtx();
3037  fDCAzGammaMax = gamma0->GetDCAzToPrimVtx();
3038  }
3039  iFlag = pi0cand->GetMesonQuality();
3040  // cout << "gamma 0: " << gamma0->GetV0Index()<< "\t" << gamma0->GetPx() << "\t" << gamma0->GetPy() << "\t" << gamma0->GetPz() << "\t" << endl;
3041  // cout << "gamma 1: " << gamma1->GetV0Index()<< "\t"<< gamma1->GetPx() << "\t" << gamma1->GetPy() << "\t" << gamma1->GetPz() << "\t" << endl;
3042  // cout << "pi0: "<<fInvMass << "\t" << fPt <<"\t" << fDCAzGammaMin << "\t" << fDCAzGammaMax << "\t" << (Int_t)iFlag << "\t" << (Int_t)iMesonMCInfo <<endl;
3043  if (fIsHeavyIon == 1 && fPt > 0.399 && fPt < 20. ) {
3044  if (fInvMass > 0.08 && fInvMass < 0.2) tESDMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
3045  if ((fInvMass > 0.45 && fInvMass < 0.6) && (fPt > 0.999 && fPt < 20.) )tESDMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
3046  } else if (fPt > 0.299 && fPt < 20. ) {
3047  if ( (fInvMass > 0.08 && fInvMass < 0.6) ) tESDMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
3048  }
3049  }
3050  }
3051  delete pi0cand;
3052  pi0cand=0x0;
3053  }
3054  }
3055  }
3056 }
3057 
3058 //______________________________________________________________________
3060 {
3061  // Process True Mesons
3062  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3063  Double_t mcProdVtxX = primVtxMC->GetX();
3064  Double_t mcProdVtxY = primVtxMC->GetY();
3065  Double_t mcProdVtxZ = primVtxMC->GetZ();
3066 
3067  iMesonMCInfo = 0;
3068  if(TrueGammaCandidate0->GetV0Index()<fInputEvent->GetNumberOfV0s()){
3069  Bool_t isTruePi0 = kFALSE;
3070  Bool_t isTrueEta = kFALSE;
3071  Bool_t isTruePi0Dalitz = kFALSE;
3072  Bool_t isTrueEtaDalitz = kFALSE;
3073  Bool_t gamma0DalitzCand = kFALSE;
3074  Bool_t gamma1DalitzCand = kFALSE;
3075  Int_t gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCEvent);
3076  Int_t gamma0MotherLabel = -1;
3077  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3078  // Daughters Gamma 0
3079  TParticle * negativeMC = (TParticle*)TrueGammaCandidate0->GetNegativeMCDaughter(fMCEvent);
3080  TParticle * positiveMC = (TParticle*)TrueGammaCandidate0->GetPositiveMCDaughter(fMCEvent);
3081  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
3082  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3083  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
3084  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
3085  gamma0MotherLabel=gammaMC0->GetFirstMother();
3086  }
3087  }
3088  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
3089  gamma0DalitzCand = kTRUE;
3090  gamma0MotherLabel=-111;
3091  }
3092  if(gammaMC0->GetPdgCode() ==221){ // Dalitz candidate
3093  gamma0DalitzCand = kTRUE;
3094  gamma0MotherLabel=-221;
3095  }
3096  }
3097  }
3098  if(TrueGammaCandidate1->GetV0Index()<fInputEvent->GetNumberOfV0s()){
3099  Int_t gamma1MCLabel = TrueGammaCandidate1->GetMCParticleLabel(fMCEvent);
3100  Int_t gamma1MotherLabel = -1;
3101  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3102  // Daughters Gamma 1
3103  TParticle * negativeMC = (TParticle*)TrueGammaCandidate1->GetNegativeMCDaughter(fMCEvent);
3104  TParticle * positiveMC = (TParticle*)TrueGammaCandidate1->GetPositiveMCDaughter(fMCEvent);
3105  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
3106  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3107  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
3108  if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
3109  gamma1MotherLabel=gammaMC1->GetFirstMother();
3110  }
3111  }
3112  if(gammaMC1->GetPdgCode() ==111 ){ // Dalitz candidate
3113  gamma1DalitzCand = kTRUE;
3114  gamma1MotherLabel=-111;
3115  }
3116  if(gammaMC1->GetPdgCode() ==221){ // Dalitz candidate
3117  gamma1DalitzCand = kTRUE;
3118  gamma1MotherLabel=-221;
3119  }
3120  }
3121  }
3122  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3123  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
3124  isTruePi0=kTRUE;
3125  if (CheckVectorForDoubleCount(vecDoubleCountTruePi0s,gamma0MotherLabel)){
3126  fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3128  }
3129  }
3130  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 221){
3131  isTrueEta=kTRUE;
3132  if (CheckVectorForDoubleCount(vecDoubleCountTrueEtas,gamma0MotherLabel)){
3133  fHistoDoubleCountTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3135  }
3136  }
3137  }
3138 
3139  //Identify Dalitz candidate
3140  if (gamma1DalitzCand || gamma0DalitzCand){
3141  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
3142  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
3143  if (gamma0MotherLabel == -221) isTrueEtaDalitz = kTRUE;
3144  }
3145  if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
3146  if (gamma1MotherLabel == -111) isTruePi0Dalitz = kTRUE;
3147  if (gamma1MotherLabel == -221) isTrueEtaDalitz = kTRUE;
3148  }
3149  }
3150 
3151 
3152  if(isTruePi0 || isTrueEta){// True Pion or Eta
3153 
3154  Float_t weightMatBudget = 1.;
3155  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
3156  weightMatBudget = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueGammaCandidate0) * ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueGammaCandidate1);
3157  }
3158 
3159  fHistoTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightMatBudget*fWeightJetJetMC);
3160  if (fDoMesonQA > 0){
3161  if (isTruePi0){
3162  if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
3163  if(fIsMC < 2){
3164  fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3165  fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3166  }
3167  fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()),fWeightJetJetMC);
3168 
3169  }
3170  } else if (isTrueEta){
3171  if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
3172  if(fIsMC < 2){
3173  fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3174  fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3175  }
3176  fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()),fWeightJetJetMC);
3177  }
3178  }
3179  }
3180 
3181  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, gamma0MotherLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3182 
3183  if(!isPrimary && gamma1MotherLabel>-1){ // Secondary Meson
3184  Long_t secMotherLabel = ((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetMother(0);
3185  Float_t weightedSec= 1;
3186  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, fMCEvent, fInputEvent) && fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310){
3187  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
3188  //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3189  }
3190  fHistoTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3191  iMesonMCInfo = 2;
3192  if (secMotherLabel >-1){
3193  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310){
3194  iMesonMCInfo = 4;
3195  fHistoTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3196  if (fDoMesonQA > 0 && fIsMC < 2 )fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3197  }
3198  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==130){
3199  iMesonMCInfo = 8;
3200  fHistoTrueSecondaryMotherFromK0lInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3201  if (fDoMesonQA > 0 && fIsMC < 2 )fHistoTrueK0lWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3202  }
3203  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==221){
3204  iMesonMCInfo = 3;
3205  fHistoTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3206  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3207  }
3208  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==3122){
3209  iMesonMCInfo = 7;
3210  fHistoTrueSecondaryMotherFromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3211  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3212  }
3213  }
3214  } else { // Only primary pi0 for efficiency calculation
3215  iMesonMCInfo = 6;
3216  Float_t weighted= 1;
3217  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCEvent, fInputEvent)){
3218  if (((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt()>0.005){
3219  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, fMCEvent, fInputEvent);
3220  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3221  }
3222  }
3223 
3224  fHistoTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget*fWeightJetJetMC);
3225  fHistoTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3226  pESDTruePrimaryMotherWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget*fWeightJetJetMC);
3227 
3228 
3229  if (fDoMesonQA > 0 && fIsMC < 2){
3230  if(isTruePi0){ // Only primary pi0 for resolution
3231  fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted*weightMatBudget);
3232  }
3233  if (isTrueEta){ // Only primary eta for resolution
3234  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted*weightMatBudget);
3235  }
3236  }
3237  }
3238  } else if(!isTruePi0 && !isTrueEta){ // Background
3239  if (fDoMesonQA > 0 && fIsMC < 2){
3240  if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
3241  fHistoTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3242  iMesonMCInfo = 1;
3243  } else { // No photon or without mother
3244  fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3245  }
3246  }
3247  if( isTruePi0Dalitz || isTrueEtaDalitz ){
3248  // Dalitz
3249  iMesonMCInfo = 5;
3250  if (fIsMC < 2) fHistoTrueMotherDalitzInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3251  } else if (gamma0DalitzCand || gamma1DalitzCand){
3252  if (fDoMesonQA > 0 && fIsMC < 2) fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3253  }
3254  }
3255  }
3256  }
3257 }
3258 
3259 //______________________________________________________________________
3261 {
3262  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3263  Double_t mcProdVtxX = primVtxMC->GetX();
3264  Double_t mcProdVtxY = primVtxMC->GetY();
3265  Double_t mcProdVtxZ = primVtxMC->GetZ();
3266 
3267  // Process True Mesons
3268  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3269  Bool_t isTruePi0 = kFALSE;
3270  Bool_t isTrueEta = kFALSE;
3271  Bool_t isTruePi0Dalitz = kFALSE;
3272  Bool_t isTrueEtaDalitz = kFALSE;
3273  Bool_t gamma0DalitzCand = kFALSE;
3274  Bool_t gamma1DalitzCand = kFALSE;
3275 
3276  if (AODMCTrackArray!=NULL && TrueGammaCandidate0 != NULL){
3277  AliAODMCParticle *positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
3278  AliAODMCParticle *negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
3279 
3280  iMesonMCInfo = 0;
3281  Int_t gamma0MCLabel = -1;
3282  Int_t gamma0MotherLabel = -1;
3283  if(!positiveMC||!negativeMC)
3284  return;
3285 
3286  if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
3287  gamma0MCLabel = positiveMC->GetMother();
3288  }
3289 
3290  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3291  // Daughters Gamma 0
3292  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3293  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3294  if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
3295  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
3296  gamma0MotherLabel=gammaMC0->GetMother();
3297  }
3298  }
3299  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
3300  gamma0DalitzCand = kTRUE;
3301  gamma0MotherLabel=-111;
3302  }
3303  if(gammaMC0->GetPdgCode() ==221){ // Dalitz candidate
3304  gamma0DalitzCand = kTRUE;
3305  gamma0MotherLabel=-221;
3306  }
3307  }
3308  }
3309  positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelPositive()));
3310  negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelNegative()));
3311 
3312  Int_t gamma1MCLabel = -1;
3313  Int_t gamma1MotherLabel = -1;
3314  if(!positiveMC||!negativeMC)
3315  return;
3316 
3317  if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
3318  gamma1MCLabel = positiveMC->GetMother();
3319  }
3320  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3321  // Daughters Gamma 1
3322  AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3323  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3324  if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
3325  if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
3326  gamma1MotherLabel=gammaMC1->GetMother();
3327  }
3328  }
3329  if(gammaMC1->GetPdgCode() ==111 ){ // Dalitz candidate
3330  gamma1DalitzCand = kTRUE;
3331  gamma1MotherLabel=-111;
3332  }
3333  if(gammaMC1->GetPdgCode() ==221){ // Dalitz candidate
3334  gamma1DalitzCand = kTRUE;
3335  gamma1MotherLabel=-221;
3336  }
3337  }
3338  }
3339  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3340  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
3341  isTruePi0=kTRUE;
3342  if (CheckVectorForDoubleCount(vecDoubleCountTruePi0s,gamma0MotherLabel)){
3343  fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3345  }
3346  }
3347  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 221){
3348  isTrueEta=kTRUE;
3349  if (CheckVectorForDoubleCount(vecDoubleCountTrueEtas,gamma0MotherLabel)){
3350  fHistoDoubleCountTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3352  }
3353  }
3354  }
3355 
3356  //Identify Dalitz candidate
3357  if (gamma1DalitzCand || gamma0DalitzCand){
3358  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
3359  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
3360  if (gamma0MotherLabel == -221) isTrueEtaDalitz = kTRUE;
3361  }
3362  if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
3363  if (gamma1MotherLabel == -111) isTruePi0Dalitz = kTRUE;
3364  if (gamma1MotherLabel == -221) isTrueEtaDalitz = kTRUE;
3365  }
3366  }
3367 
3368  if(isTruePi0 || isTrueEta){// True Pion or Eta
3369 
3370  Float_t weightMatBudget = 1.;
3371  if (fDoMaterialBudgetWeightingOfGammasForTrueMesons && ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetWeightsInitialized()) {
3372  weightMatBudget = ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueGammaCandidate0) * ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetMaterialBudgetCorrectingWeightForTrueGamma(TrueGammaCandidate1);
3373  }
3374 
3375  fHistoTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightMatBudget*fWeightJetJetMC);
3376  if (fDoMesonQA > 0){
3377  if (isTruePi0){
3378  if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
3379  if(fIsMC < 2){
3380  fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3381  fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3382  }
3383  fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()),fWeightJetJetMC);
3384  }
3385  } else if (isTrueEta){
3386  if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
3387  if(fIsMC < 2){
3388  fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3389  fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3390  }
3391  fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()),fWeightJetJetMC);
3392  }
3393  }
3394  }
3395  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel)), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3396 
3397  if(!isPrimary){ // Secondary Meson
3398  Long_t secMotherLabel = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetMother();
3399  Float_t weightedSec= 1;
3400  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, 0x0, fInputEvent) && static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
3401  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
3402  //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3403  }
3404  fHistoTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3405  iMesonMCInfo = 2;
3406  if (secMotherLabel >-1){
3407  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
3408  iMesonMCInfo = 4;
3409  fHistoTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3410  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3411  }
3412  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==130){
3413  iMesonMCInfo = 8;
3414  fHistoTrueSecondaryMotherFromK0lInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3415  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueK0lWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3416  }
3417  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==221){
3418  iMesonMCInfo = 3;
3419  fHistoTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3420  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3421  }
3422  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==3122){
3423  iMesonMCInfo = 7;
3424  fHistoTrueSecondaryMotherFromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec*weightMatBudget*fWeightJetJetMC);
3425  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3426  }
3427  }
3428  } else { // Only primary pi0 for efficiency calculation
3429  Float_t weighted= 1;
3430  iMesonMCInfo = 6;
3431  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, 0x0, fInputEvent)){
3432  if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt()>0.005){
3433  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, 0x0, fInputEvent);
3434  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3435  }
3436  }
3437  fHistoTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget*fWeightJetJetMC);
3438  fHistoTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),fWeightJetJetMC);
3439  pESDTruePrimaryMotherWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted*weightMatBudget*fWeightJetJetMC);
3440 
3441  if (fDoMesonQA > 0 && fIsMC < 2){
3442  if(isTruePi0){ // Only primary pi0 for resolution
3443  fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
3444  (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted*weightMatBudget);
3445 
3446  }
3447  if (isTrueEta){ // Only primary eta for resolution
3448  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
3449  (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted*weightMatBudget);
3450  }
3451  }
3452  }
3453  } else if(!isTruePi0 && !isTrueEta) { // Background
3454  if (fDoMesonQA > 0 && fIsMC < 2){
3455  if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
3456  fHistoTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3457  iMesonMCInfo = 1;
3458  } else { // No photon or without mother
3459  fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3460  }
3461  }
3462  if( isTruePi0Dalitz || isTrueEtaDalitz ){
3463  // Dalitz
3464  iMesonMCInfo = 5;
3465  if (fIsMC < 2)fHistoTrueMotherDalitzInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3466  } else if (gamma0DalitzCand || gamma1DalitzCand){
3467  if (fDoMesonQA > 0 && fIsMC < 2)fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3468  }
3469  }
3470  }
3471  return;
3472 }
3473 //________________________________________________________________________
3475 
3476  Int_t zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3477  Int_t mbin = 0;
3478 
3479  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3481  } else {
3482  mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
3483  }
3484 
3485  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseRotationMethod()){
3486 
3487  for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
3488  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
3489  for(Int_t iCurrent2=iCurrent+1;iCurrent2<fGammaCandidates->GetEntries();iCurrent2++){
3490  for(Int_t nRandom=0;nRandom<((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents();nRandom++){
3491  AliAODConversionPhoton currentEventGoodV02 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent2));
3492 
3493  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGProbability()){
3494  AliAODConversionMother *backgroundCandidateProb = new AliAODConversionMother(&currentEventGoodV0,&currentEventGoodV02);
3495  Double_t massBGprob = backgroundCandidateProb->M();
3496  if(massBGprob>0.1 && massBGprob<0.14){
3497  if(fRandom.Rndm()>fBGHandler[fiCut]->GetBGProb(zbin,mbin)){
3498  delete backgroundCandidateProb;
3499  continue;
3500  }
3501  }
3502  delete backgroundCandidateProb;
3503  backgroundCandidateProb = 0x0;
3504  }
3505 
3506  RotateParticle(&currentEventGoodV02);
3507  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&currentEventGoodV02);
3508  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3510  ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3511  if(fDoCentralityFlat > 0) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3512  else fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(),fWeightJetJetMC);
3513  if(fDoTHnSparse){
3514  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3515  if(fDoCentralityFlat > 0) sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightCentrality[fiCut]*fWeightJetJetMC); //instead of weight 1
3516  else sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightJetJetMC);
3517  }
3518  }
3519  delete backgroundCandidate;
3520  backgroundCandidate = 0x0;
3521  }
3522  }
3523  }
3524  } else {
3526 
3527  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3528  for(Int_t nEventsInBG=0;nEventsInBG<fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
3529  AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
3530  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3531  bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
3532  }
3533 
3534  for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
3535  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
3536  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3537  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
3538  if(fMoveParticleAccordingToVertex == kTRUE){
3539  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3540  }
3541  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3542  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
3543  }
3544 
3545  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
3546  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3548  ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3549  if(fDoCentralityFlat > 0) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3550  else fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(),fWeightJetJetMC);
3551  if(fDoTHnSparse){
3552  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3553  if(fDoCentralityFlat > 0) sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightCentrality[fiCut]*fWeightJetJetMC); //instead of weight 1
3554  else sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightJetJetMC);
3555  }
3556  }
3557  delete backgroundCandidate;
3558  backgroundCandidate = 0x0;
3559  }
3560  }
3561  }
3562  } else {
3563  for(Int_t nEventsInBG=0;nEventsInBG <fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
3564  AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
3565  if(previousEventV0s){
3566  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3567  bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
3568  }
3569  for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
3570  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGammaCandidates->At(iCurrent));
3571  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3572 
3573  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
3574 
3575  if(fMoveParticleAccordingToVertex == kTRUE){
3576  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3577  }
3578  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3579  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
3580  }
3581 
3582 
3583  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
3584  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3586  ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3587  if(fDoCentralityFlat > 0) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3588  else fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(),fWeightJetJetMC);
3589  if(fDoTHnSparse){
3590  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3591  if(fDoCentralityFlat > 0) sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightCentrality[fiCut]*fWeightJetJetMC); //instead of weight 1
3592  else sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill, fWeightJetJetMC);
3593  }
3594  }
3595  delete backgroundCandidate;
3596  backgroundCandidate = 0x0;
3597  }
3598  }
3599  }
3600  }
3601  }
3602  }
3603 }
3604 //________________________________________________________________________
3606 
3607  Int_t psibin = 0;
3608  Int_t zbin = 0;
3609 
3610  if(fDoTHnSparse){
3611  psibin = fBGHandlerRP[fiCut]->GetRPBinIndex(TMath::Abs(fEventPlaneAngle));
3612  zbin = fBGHandlerRP[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3613 // if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3614 // mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
3615 // } else {
3616 // mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
3617 // }
3618  }
3619 
3620  //Rotation Method
3621  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseRotationMethod()){
3622  // Correct for the number of rotations
3623  // BG is for rotation the same, except for factor NRotations
3624  Double_t weight=1./Double_t(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents());
3625 
3626  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
3627 
3628  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
3629  if (gamma0==NULL) continue;
3630  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGammaCandidates->GetEntries();secondGammaIndex++){
3631  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(secondGammaIndex));
3632  if (gamma1 == NULL) continue;
3633  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelected(gamma1,fInputEvent))continue;
3634  for(Int_t nRandom=0;nRandom<((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents();nRandom++){
3635  RotateParticle(gamma1);
3636  AliAODConversionMother backgroundCandidate(gamma0,gamma1);
3637  backgroundCandidate.CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3638  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(&backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3639  if(fDoCentralityFlat > 0) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3640  else fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt(),fWeightJetJetMC);
3641  if(fDoTHnSparse){
3642 // Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)mbin};
3643  Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)psibin};
3645  else sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,weight*fWeightJetJetMC);
3646  }
3647  }
3648  }
3649  }
3650  }
3651 
3652  } else {
3653  // Do Event Mixing
3654  for(Int_t nEventsInBG=0;nEventsInBG <fBGHandlerRP[fiCut]->GetNBGEvents(fGammaCandidates,fInputEvent);nEventsInBG++){
3655 
3657 
3658  if(previousEventGammas){
3659  // test weighted background
3660  Double_t weight=1.0;
3661  // Correct for the number of eventmixing:
3662  // N gammas -> (N-1) + (N-2) +(N-3) ...+ (N-(N-1)) using sum formula sum(i)=N*(N-1)/2 -> N*(N-1)/2
3663  // real combinations (since you cannot combine a photon with its own)
3664  // but BG leads to N_{a}*N_{b} combinations
3665  weight*=0.5*(Double_t(fGammaCandidates->GetEntries()-1))/Double_t(previousEventGammas->size());
3666 
3667  for(Int_t iCurrent=0;iCurrent<fGammaCandidates->GetEntries();iCurrent++){
3668 
3670 
3671  for(UInt_t iPrevious=0;iPrevious<previousEventGammas->size();iPrevious++){
3672 
3673  AliAODConversionPhoton *gamma1 = (AliAODConversionPhoton*)(previousEventGammas->at(iPrevious));
3674 
3675  AliAODConversionMother backgroundCandidate(gamma0,gamma1);
3676  backgroundCandidate.CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3678  ->MesonIsSelected(&backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3679  if(fDoCentralityFlat > 0) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt(), fWeightCentrality[fiCut]*fWeightJetJetMC);
3680  else fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt(),fWeightJetJetMC);
3681  if(fDoTHnSparse){
3682 // Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)mbin};
3683  Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)psibin};
3685  else sESDMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,weight*fWeightJetJetMC);
3686  }
3687  }
3688  }
3689  }
3690  }
3691  }
3692  }
3693 }
3694 
3695 //________________________________________________________________________
3697  Int_t fNDegreesPMBackground= ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->NDegreesRotation();
3698  Double_t nRadiansPM = fNDegreesPMBackground*TMath::Pi()/180;
3699  Double_t rotationValue = fRandom.Rndm()*2*nRadiansPM + TMath::Pi()-nRadiansPM;
3700  gamma->RotateZ(rotationValue);
3701 }
3702 
3703 //________________________________________________________________________
3705 
3706  previousEventEP=previousEventEP+TMath::Pi();
3707  thisEventEP=thisEventEP+TMath::Pi();
3708  Double_t rotationValue= thisEventEP-previousEventEP;
3709  gamma->RotateZ(rotationValue);
3710 }
3711 
3712 //________________________________________________________________________
3714  //see header file for documentation
3715 
3716  Double_t dx = vertex->fX - fInputEvent->GetPrimaryVertex()->GetX();
3717  Double_t dy = vertex->fY - fInputEvent->GetPrimaryVertex()->GetY();
3718  Double_t dz = vertex->fZ - fInputEvent->GetPrimaryVertex()->GetZ();
3719 
3720  Double_t movedPlace[3] = {particle->GetConversionX() - dx,particle->GetConversionY() - dy,particle->GetConversionZ() - dz};
3721  particle->SetConversionPoint(movedPlace);
3722 }
3723 
3724 //________________________________________________________________________
3726  //see header file for documentation
3727  if(fGammaCandidates->GetEntries() >0 ){
3728  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3729  fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),fEventPlaneAngle);
3730  }
3731  else{ // means we use #V0s for multiplicity
3732  fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGammaCandidates->GetEntries(),fEventPlaneAngle);
3733  }
3734  }
3735 }
3736 
3737 //________________________________________________________________________
3739 {
3740  // 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
3741  if(pdgCode[0]==11 && pdgCode[1]==11){
3742  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0.,fWeightJetJetMC);
3743  } else if( (pdgCode[0]==11 && pdgCode[1]==211) || (pdgCode[0]==211 && pdgCode[1]==11) ){
3744  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1.,fWeightJetJetMC);
3745  } else if( (pdgCode[0]==11 && pdgCode[1]==321) || (pdgCode[0]==321 && pdgCode[1]==11) ){
3746  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2.,fWeightJetJetMC);
3747  } else if( (pdgCode[0]==11 && pdgCode[1]==2212) || (pdgCode[0]==2212 && pdgCode[1]==11) ){
3748  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3.,fWeightJetJetMC);
3749  } else if( (pdgCode[0]==11 && pdgCode[1]==13) || (pdgCode[0]==13 && pdgCode[1]==11) ){
3750  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),4.,fWeightJetJetMC);
3751  } else if( pdgCode[0]==211 && pdgCode[1]==211 ){
3752  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),5.,fWeightJetJetMC);
3753  } else if( (pdgCode[0]==211 && pdgCode[1]==321) || (pdgCode[0]==321 && pdgCode[1]==211) ){
3754  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),6.,fWeightJetJetMC);
3755  } else if( (pdgCode[0]==211 && pdgCode[1]==2212) || (pdgCode[0]==2212 && pdgCode[1]==211) ){
3756  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),7.,fWeightJetJetMC);
3757  } else if( (pdgCode[0]==211 && pdgCode[1]==13) || (pdgCode[0]==13 && pdgCode[1]==211) ){
3758  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),8.,fWeightJetJetMC);
3759  } else if( pdgCode[0]==321 && pdgCode[1]==321 ){
3760  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),9.,fWeightJetJetMC);
3761  } else if( (pdgCode[0]==321 && pdgCode[1]==2212) || (pdgCode[0]==2212 && pdgCode[1]==321) ){
3762  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),10.,fWeightJetJetMC);
3763  } else if( (pdgCode[0]==321 && pdgCode[1]==13) || (pdgCode[0]==13 && pdgCode[1]==321) ){
3764  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),11.,fWeightJetJetMC);
3765  } else if( pdgCode[0]==2212 && pdgCode[1]==2212 ){
3766  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),12.,fWeightJetJetMC);
3767  } else if( (pdgCode[0]==2212 && pdgCode[1]==13) || (pdgCode[0]==13 && pdgCode[1]==2212) ){
3768  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),13.,fWeightJetJetMC);
3769  } else if( pdgCode[0]==13 && pdgCode[1]==13 ){
3770  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),14.,fWeightJetJetMC);
3771  } else {
3772  fHistoCombinatorialPt[fiCut]->Fill(TruePhotonCandidate->Pt(),15.,fWeightJetJetMC);
3773  }
3774 
3775  if(fDoPhotonQA == 3 && fIsMC < 2){
3776  if( (pdgCode[0]==11 && pdgCode[1]==211) || (pdgCode[0]==211 && pdgCode[1]==11) ){
3777  if(pdgCode[0]==11){fHistoCombinatorialPtDeltaPhi_epi[fiCut]->Fill(TruePhotonCandidate->Pt(),TMath::Abs((TruePhotonCandidate->Phi() - PhiParticle[1])));}
3778  else if(pdgCode[0]==211){fHistoCombinatorialPtDeltaPhi_epi[fiCut]->Fill(TruePhotonCandidate->Pt(),TMath::Abs((TruePhotonCandidate->Phi() - PhiParticle[0])));}
3779  }
3780  else if( (pdgCode[0]==11 && pdgCode[1]==321) || (pdgCode[0]==321 && pdgCode[1]==11) ){
3781  if(pdgCode[0]==11){fHistoCombinatorialPtDeltaPhi_ek[fiCut]->Fill(TruePhotonCandidate->Pt(),TMath::Abs((TruePhotonCandidate->Phi() - PhiParticle[1])));}
3782  else if(pdgCode[0]==321){fHistoCombinatorialPtDeltaPhi_ek[fiCut]->Fill(TruePhotonCandidate->Pt(),TMath::Abs((TruePhotonCandidate->Phi() - PhiParticle[0])));}
3783  }
3784  else if( (pdgCode[0]==11 && pdgCode[1]==2212) || (pdgCode[0]==2212 && pdgCode[1]==11) ){
3785  if(pdgCode[0]==11){fHistoCombinatorialPtDeltaPhi_ep[fiCut]->Fill(TruePhotonCandidate->Pt(),TMath::Abs((TruePhotonCandidate->Phi() - PhiParticle[1])));}
3786  else if(pdgCode[0]==2212){fHistoCombinatorialPtDeltaPhi_ep[fiCut]->Fill(TruePhotonCandidate->Pt(),TMath::Abs((TruePhotonCandidate->Phi() - PhiParticle[0])));}
3787  }
3788  else if( (pdgCode[0]==211 && pdgCode[1]==321) || (pdgCode[0]==321 && pdgCode[1]==211) ){
3789  if(pdgCode[0]==211){fHistoCombinatorialPtDeltaPhi_pik[fiCut]->Fill(TruePhotonCandidate->Pt(),TMath::Abs((TruePhotonCandidate->Phi() - PhiParticle[1])));}
3790  else if(pdgCode[0]==321){fHistoCombinatorialPtDeltaPhi_pik[fiCut]->Fill(TruePhotonCandidate->Pt(),TMath::Abs((TruePhotonCandidate->Phi() - PhiParticle[0])));}
3791  }
3792  else if( (pdgCode[0]==211 && pdgCode[1]==2212) || (pdgCode[0]==2212 && pdgCode[1]==211) ){
3793  if(pdgCode[0]==211){fHistoCombinatorialPtDeltaPhi_pip[fiCut]->Fill(TruePhotonCandidate->Pt(),TMath::Abs((TruePhotonCandidate->Phi() - PhiParticle[1])));}
3794  else if(pdgCode[0]==2212){fHistoCombinatorialPtDeltaPhi_pip[fiCut]->Fill(TruePhotonCandidate->Pt(),TMath::Abs((TruePhotonCandidate->Phi() - PhiParticle[0])));}
3795  }
3796 
3797  }
3798 }
3799 
3800 //________________________________________________________________________
3801 void AliAnalysisTaskGammaConvV1::FillPhotonCombinatorialMothersHistESD(TParticle *daughter, TParticle *motherCombPart)
3802 {
3803  Int_t pdgCombPart = TMath::Abs(daughter->GetPdgCode());
3804  Int_t pdgMotherCombPart = TMath::Abs(motherCombPart->GetPdgCode());
3805 
3806  // Combinatorial Bck mothers: e, pi, k, p, pi0, eta, omega, phi, eta', K0s, Lambda, rhos, other, not prim
3807  if(pdgCombPart==11){ //comb particle is an electron
3808  if(pdgMotherCombPart==11) fHistoCombinatorialMothersPt[fiCut]->Fill(0.,0.,motherCombPart->Pt());
3809  else if(pdgMotherCombPart==211) fHistoCombinatorialMothersPt[fiCut]->Fill(0.,1.,motherCombPart->Pt());
3810  else if(pdgMotherCombPart==321) fHistoCombinatorialMothersPt[fiCut]->Fill(0.,2.,motherCombPart->Pt());
3811  else if(pdgMotherCombPart==2212) fHistoCombinatorialMothersPt[fiCut]->Fill(0.,3.,motherCombPart->Pt());
3812  else if(pdgMotherCombPart==111) fHistoCombinatorialMothersPt[fiCut]->Fill(0.,4.,motherCombPart->Pt());