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