AliPhysics  b555aef (b555aef)
AliAnalysisTaskGammaCaloDalitzV1.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: Pedro Gonzalez, Baldo Sahlmueller, Friederike Bock *
5  * Version 1.0 *
6  * *
7  * *
8  * Permission to use, copy, modify and distribute this software and its *
9  * documentation strictly for non-commercial purposes is hereby granted *
10  * without fee, provided that the above copyright notice appears in all *
11  * copies and that both the copyright notice and this permission notice *
12  * appear in the supporting documentation. The authors make no claims *
13  * about the suitability of this software for any purpose. It is *
14  * provided "as is" without express or implied warranty. *
15  **************************************************************************/
16 
18 //----------------------------------------------------------------
19 // Class used to do analysis on conversion photons + calo photons
20 //----------------------------------------------------------------
22 #include "TChain.h"
23 #include "TTree.h"
24 #include "TBranch.h"
25 #include "TFile.h"
26 #include "TH1F.h"
27 #include "TH2F.h"
28 #include "TH3F.h"
29 #include "THnSparse.h"
30 #include "TCanvas.h"
31 #include "TNtuple.h"
32 #include "TDatabasePDG.h"
33 #include "AliAnalysisTask.h"
34 #include "AliAnalysisManager.h"
35 #include "AliESDEvent.h"
36 #include "AliESDInputHandler.h"
37 #include "AliMCEventHandler.h"
38 #include "AliMCEvent.h"
39 #include "AliMCParticle.h"
40 #include "AliCentrality.h"
41 #include "AliESDVZERO.h"
42 #include "AliESDpid.h"
44 #include "AliVParticle.h"
45 #include "AliESDtrack.h"
46 #include "AliESDtrackCuts.h"
47 #include "AliKFVertex.h"
48 #include "AliV0ReaderV1.h"
49 #include "AliGenCocktailEventHeader.h"
51 #include "AliAODMCParticle.h"
52 #include "AliAODMCHeader.h"
53 #include "AliEventplane.h"
55 #include "AliAODEvent.h"
56 #include "AliAODInputHandler.h"
57 #include "AliESDEvent.h"
58 #include "AliESDInputHandler.h"
59 #include "AliInputEventHandler.h"
60 #include "AliCaloTrackMatcher.h"
61 #include <vector>
62 
64 
65 //________________________________________________________________________
67  fV0Reader(NULL),
68  fV0ReaderName("V0ReaderV1"),
69  fElecSelector(NULL),
70  fBGClusHandler(NULL),
71  fInputEvent(NULL),
72  fMCEvent(NULL),
73  fCutFolder(NULL),
74  fESDList(NULL),
75  fBackList(NULL),
76  fMotherList(NULL),
77  fPhotonDCAList(NULL),
78  fTrueList(NULL),
79  fMCList(NULL),
80  fHeaderNameList(NULL),
81  fClusterOutputList(NULL),
82  fOutputContainer(NULL),
83  fReaderGammas(NULL),
84  fSelectorElectronIndex(0),
85  fSelectorPositronIndex(0),
86  fGammaCandidates(NULL),
87  fClusterCandidates(NULL),
88  fVirtualGammaCandidates(NULL),
89  fEventCutArray(NULL),
90  fEventCuts(NULL),
91  fGammaCutArray(NULL),
92  fElectronCutArray(NULL),
93  fConversionCuts(NULL),
94  fClusterCutArray(NULL),
95  fCaloPhotonCuts(NULL),
96  fMesonCutArray(NULL),
97  fMesonCuts(NULL),
98  fHistoConvGammaPt(NULL),
99  fHistoConvGammaR(NULL),
100  fHistoConvGammaEta(NULL),
101  fHistoDalitzElectronPt(NULL),
102  fHistoDalitzPositronPt(NULL),
103  fHistoDalitzElectronPhi(NULL),
104  fHistoDalitzPositronPhi(NULL),
105  fPtGamma(0),
106  fDCAzPhoton(0),
107  fRConvPhoton(0),
108  fEtaPhoton(0),
109  fCharCatPhoton(0),
110  fCharPhotonMCInfo(0),
111  fHistoMotherInvMassPt(NULL),
112  fHistoMotherInvMassOpeningAngleGammaElectron(NULL),
113  fHistoMotherMatchedInvMassPt(NULL),
114  fSparseMotherInvMassPtZM(NULL),
115  fHistoMotherBackInvMassPt(NULL),
116  fSparseMotherBackInvMassPtZM(NULL),
117  fHistoMotherInvMassEalpha(NULL),
118  fHistoMotherPi0PtY(NULL),
119  fHistoMotherEtaPtY(NULL),
120  fHistoMotherPi0PtAlpha(NULL),
121  fHistoMotherEtaPtAlpha(NULL),
122  fHistoMotherPi0PtOpenAngle(NULL),
123  fHistoMotherEtaPtOpenAngle(NULL),
124  fHistoMotherPi0ConvPhotonEtaPhi(NULL),
125  fHistoMotherEtaConvPhotonEtaPhi(NULL),
126  fHistoMotherInvMassECalib(NULL),
127  fHistoMotherInvMassECalibalpha(NULL),
128  fHistoClusGammaPt(NULL),
129  fHistoClusOverlapHeadersGammaPt(NULL),
130  fHistoMCHeaders(NULL),
131  fHistoMCAllGammaPt(NULL),
132  fHistoMCAllGammaPi0Pt(NULL),
133  fHistoMCAllGammaEMCALAccPt(NULL),
134  fHistoMCDecayGammaPi0Pt(NULL),
135  fHistoMCDecayGammaRhoPt(NULL),
136  fHistoMCDecayGammaEtaPt(NULL),
137  fHistoMCDecayGammaOmegaPt(NULL),
138  fHistoMCDecayGammaEtapPt(NULL),
139  fHistoMCDecayGammaPhiPt(NULL),
140  fHistoMCDecayGammaSigmaPt(NULL),
141  fHistoMCConvGammaPt(NULL),
142  fHistoMCConvGammaR(NULL),
143  fHistoMCConvGammaEta(NULL),
144  fHistoMCAllPositronsPt(NULL),
145  fHistoMCDecayPositronPi0Pt(NULL),
146  fHistoMCAllElectronsPt(NULL),
147  fHistoMCDecayElectronPi0Pt(NULL),
148  fHistoMCDecayNoPrimElectronPi0DalitzR(NULL),
149  fHistoMCDecayNoPrimPositronPi0DalitzR(NULL),
150  fHistoMCDecayNoPrimElectronPi0DalitzID(NULL),
151  fHistoMCDecayNoPrimPositronPi0DalitzID(NULL),
152  fHistoMCPi0GGPt(NULL),
153  fHistoMCPi0GGWOWeightPt(NULL),
154  fHistoMCPi0Pt(NULL),
155  fHistoMCPi0WOWeightPt(NULL),
156  fHistoMCEtaGGPt(NULL),
157  fHistoMCEtaGGWOWeightPt(NULL),
158  fHistoMCEtaPt(NULL),
159  fHistoMCEtaWOWeightPt(NULL),
160  fHistoMCPi0InAccPt(NULL),
161  fHistoMCPi0InAccOpeningAngleGammaElectron(NULL),
162  fHistoMCEtaInAccPt(NULL),
163  fHistoMCPi0PtY(NULL),
164  fHistoMCEtaPtY(NULL),
165  fHistoMCPi0PtAlpha(NULL),
166  fHistoMCEtaPtAlpha(NULL),
167  fHistoMCK0sPt(NULL),
168  fHistoMCK0sWOWeightPt(NULL),
169  fHistoMCK0sPtY(NULL),
170  fHistoTruePi0InvMassPt(NULL),
171  fHistoTrueEtaInvMassPt(NULL),
172  fHistoTruePi0ShowerInvMassPt(NULL),
173  fHistoTrueEtaShowerInvMassPt(NULL),
174  fHistoTruePi0NoShowerInvMassPt(NULL),
175  fHistoTrueEtaNoShowerInvMassPt(NULL),
176  fHistoTruePi0OpeningAngleGammaElectron(NULL),
177  fHistoTruePi0GGInvMassPt(NULL),
178  fHistoTrueEtaGGInvMassPt(NULL),
179  fHistoTruePi0CaloPhotonInvMassPt(NULL),
180  fHistoTrueEtaCaloPhotonInvMassPt(NULL),
181  fHistoTruePi0CaloConvertedPhotonInvMassPt(NULL),
182  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt(NULL),
183  fHistoTrueEtaCaloConvertedPhotonInvMassPt(NULL),
184  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt(NULL),
185  fHistoTruePi0CaloElectronInvMassPt(NULL),
186  fHistoTrueEtaCaloElectronInvMassPt(NULL),
187  fHistoTruePi0CaloMergedClusterInvMassPt(NULL),
188  fHistoTrueEtaCaloMergedClusterInvMassPt(NULL),
189  fHistoTrueMotherCaloEMNonLeadingInvMassPt(NULL),
190  fHistoTruePi0CaloMergedClusterPartConvInvMassPt(NULL),
191  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt(NULL),
192  fHistoTruePrimaryPi0InvMassPt(NULL),
193  fHistoTruePrimaryPi0GGInvMassPt(NULL),
194  fHistoTruePrimaryEtaInvMassPt(NULL),
195  fHistoTruePrimaryEtaGGInvMassPt(NULL),
196  fHistoTruePrimaryPi0W0WeightingInvMassPt(NULL),
197  fHistoTruePrimaryEtaW0WeightingInvMassPt(NULL),
198  fProfileTruePrimaryPi0WeightsInvMassPt(NULL),
199  fProfileTruePrimaryEtaWeightsInvMassPt(NULL),
200  fHistoTruePrimaryPi0MCPtResolPt(NULL),
201  fHistoTruePrimaryEtaMCPtResolPt(NULL),
202  fHistoTrueMotherPi0ConvPhotonEtaPhi(NULL),
203  fHistoTrueMotherEtaConvPhotonEtaPhi(NULL),
204  fHistoTrueSecondaryPi0InvMassPt(NULL),
205  fHistoTrueSecondaryPi0GGInvMassPt(NULL),
206  fHistoTrueSecondaryPi0FromK0sInvMassPt(NULL),
207  fHistoTrueK0sWithPi0DaughterMCPt(NULL),
208  fHistoTrueSecondaryPi0FromEtaInvMassPt(NULL),
209  fHistoTrueEtaWithPi0DaughterMCPt(NULL),
210  fHistoTrueSecondaryPi0FromLambdaInvMassPt(NULL),
211  fHistoTrueLambdaWithPi0DaughterMCPt(NULL),
212  fHistoTrueBckGGInvMassPt(NULL),
213  fHistoTrueBckContInvMassPt(NULL),
214  fHistoTruePi0PtY(NULL),
215  fHistoTrueEtaPtY(NULL),
216  fHistoTruePi0PtAlpha(NULL),
217  fHistoTrueEtaPtAlpha(NULL),
218  fHistoTruePi0PtOpenAngle(NULL),
219  fHistoTrueEtaPtOpenAngle(NULL),
220  fHistoTrueConvGammaPt(NULL),
221  fHistoTrueConvPi0GammaPt(NULL),
222  fHistoTrueConvGammaEta(NULL),
223  fHistoTruePositronPt(NULL),
224  fHistoTrueElectronPt(NULL),
225  fHistoTrueSecPositronPt(NULL),
226  fHistoTrueSecElectronPt(NULL),
227  fHistoTruePi0DalitzPositronPt(NULL),
228  fHistoTruePi0DalitzElectronPt(NULL),
229  fHistoTruePi0DalitzSecPositronPt(NULL),
230  fHistoTruePi0DalitzSecElectronPt(NULL),
231  fHistoTruePrimaryConvGammaPt(NULL),
232  fHistoTruePrimaryConvGammaESDPtMCPt(NULL),
233  fHistoTrueSecondaryConvGammaPt(NULL),
234  fHistoTrueSecondaryConvGammaFromXFromK0sPt(NULL),
235  fHistoTrueSecondaryConvGammaFromXFromLambdaPt(NULL),
236  fHistoTrueClusGammaPt(NULL),
237  fHistoTrueClusUnConvGammaPt(NULL),
238  fHistoTrueClusUnConvGammaMCPt(NULL),
239  fHistoTrueClusElectronPt(NULL),
240  fHistoTrueClusConvGammaPt(NULL),
241  fHistoTrueClusConvGammaMCPt(NULL),
242  fHistoTrueClusConvGammaFullyPt(NULL),
243  fHistoTrueClusMergedGammaPt(NULL),
244  fHistoTrueClusMergedPartConvGammaPt(NULL),
245  fHistoTrueClusDalitzPt(NULL),
246  fHistoTrueClusDalitzMergedPt(NULL),
247  fHistoTrueClusPhotonFromElecMotherPt(NULL),
248  fHistoTrueClusShowerPt(NULL),
249  fHistoTrueClusSubLeadingPt(NULL),
250  fHistoTrueClusNParticles(NULL),
251  fHistoTrueClusEMNonLeadingPt(NULL),
252  fHistoTrueNLabelsInClus(NULL),
253  fHistoTruePrimaryClusGammaPt(NULL),
254  fHistoTruePrimaryClusGammaESDPtMCPt(NULL),
255  fHistoTruePi0DalitzClusGammaPt(NULL),
256  fHistoTruePi0DalitzAllClusGammaPt(NULL),
257  fHistoTruePi0DalitzClusGammaMCPt(NULL),
258  fHistoTruePrimaryPi0PhotonPairPtconv(NULL),
259  fHistoTruePrimaryPi0DCPtconv(NULL),
260  fHistoTruePrimaryPi0MissingPtconv(NULL),
261  fHistoTruePrimaryEtaPhotonPairPtconv(NULL),
262  fHistoTruePrimaryEtaDCPtconv(NULL),
263  fHistoTruePrimaryEtaMissingPtconv(NULL),
264  fHistoTrueSecondaryPi0PhotonPairPtconv(NULL),
265  fHistoTrueSecondaryPi0DCPtconv(NULL),
266  fHistoTrueSecondaryPi0MissingPtconv(NULL),
267  fStringRecTruePi0s(NULL),
268  fStringRecTrueEtas(NULL),
269  fHistoDoubleCountTruePi0InvMassPt(NULL),
270  fHistoDoubleCountTrueEtaInvMassPt(NULL),
271  fHistoDoubleCountTrueConvGammaRPt(NULL),
272  fVectorDoubleCountTruePi0s(0),
273  fVectorDoubleCountTrueEtas(0),
274  fVectorDoubleCountTrueConvGammas(0),
275  fHistoNEvents(NULL),
276  fHistoNGoodESDTracks(NULL),
277  fHistoNGammaCandidates(NULL),
278  fHistoNGoodESDTracksVsNGammaCanditates(NULL),
279  fHistoSPDClusterTrackletBackground(NULL),
280  fHistoNV0Tracks(NULL),
281  fProfileEtaShift(NULL),
282  fEventPlaneAngle(-100),
283  fRandom(0),
284  fNGammaCandidates(0),
285  fUnsmearedPx(NULL),
286  fUnsmearedPy(NULL),
287  fUnsmearedPz(NULL),
288  fUnsmearedE(NULL),
289  fMCEventPos(NULL),
290  fMCEventNeg(NULL),
291  fESDArrayPos(NULL),
292  fESDArrayNeg(NULL),
293  fnCuts(0),
294  fiCut(0),
295  fMoveParticleAccordingToVertex(kTRUE),
296  fIsHeavyIon(0),
297  fDoMesonAnalysis(kTRUE),
298  fDoMesonQA(0),
299  fDoPhotonQA(0),
300  fDoClusterQA(0),
301  fIsFromMBHeader(kTRUE),
302  fIsOverlappingWithOtherHeader(kFALSE),
303  fIsMC(kFALSE),
304  fDoTHnSparse(kTRUE)
305 {
306 
307 }
308 
309 //________________________________________________________________________
311  AliAnalysisTaskSE(name),
312  fV0Reader(NULL),
313  fV0ReaderName("V0ReaderV1"),
314  fElecSelector(NULL),
315  fBGClusHandler(NULL),
316  fInputEvent(NULL),
317  fMCEvent(NULL),
318  fCutFolder(NULL),
319  fESDList(NULL),
320  fBackList(NULL),
321  fMotherList(NULL),
322  fPhotonDCAList(NULL),
323  fTrueList(NULL),
324  fMCList(NULL),
325  fHeaderNameList(NULL),
326  fClusterOutputList(NULL),
327  fOutputContainer(0),
328  fReaderGammas(NULL),
329  fSelectorElectronIndex(0),
330  fSelectorPositronIndex(0),
331  fGammaCandidates(NULL),
332  fClusterCandidates(NULL),
333  fVirtualGammaCandidates(NULL),
334  fEventCutArray(NULL),
335  fEventCuts(NULL),
336  fGammaCutArray(NULL),
337  fElectronCutArray(NULL),
338  fConversionCuts(NULL),
339  fClusterCutArray(NULL),
340  fCaloPhotonCuts(NULL),
341  fMesonCutArray(NULL),
342  fMesonCuts(NULL),
343  fHistoConvGammaPt(NULL),
344  fHistoConvGammaR(NULL),
345  fHistoConvGammaEta(NULL),
346  fHistoDalitzElectronPt(NULL),
347  fHistoDalitzPositronPt(NULL),
348  fHistoDalitzElectronPhi(NULL),
349  fHistoDalitzPositronPhi(NULL),
350  fPtGamma(0),
351  fDCAzPhoton(0),
352  fRConvPhoton(0),
353  fEtaPhoton(0),
354  fCharCatPhoton(0),
355  fCharPhotonMCInfo(0),
356  fHistoMotherInvMassPt(NULL),
357  fHistoMotherInvMassOpeningAngleGammaElectron(NULL),
358  fHistoMotherMatchedInvMassPt(NULL),
359  fSparseMotherInvMassPtZM(NULL),
360  fHistoMotherBackInvMassPt(NULL),
361  fSparseMotherBackInvMassPtZM(NULL),
362  fHistoMotherInvMassEalpha(NULL),
363  fHistoMotherPi0PtY(NULL),
364  fHistoMotherEtaPtY(NULL),
365  fHistoMotherPi0PtAlpha(NULL),
366  fHistoMotherEtaPtAlpha(NULL),
367  fHistoMotherPi0PtOpenAngle(NULL),
368  fHistoMotherEtaPtOpenAngle(NULL),
369  fHistoMotherPi0ConvPhotonEtaPhi(NULL),
370  fHistoMotherEtaConvPhotonEtaPhi(NULL),
371  fHistoMotherInvMassECalib(NULL),
372  fHistoMotherInvMassECalibalpha(NULL),
373  fHistoClusGammaPt(NULL),
374  fHistoClusOverlapHeadersGammaPt(NULL),
375  fHistoMCHeaders(NULL),
376  fHistoMCAllGammaPt(NULL),
377  fHistoMCAllGammaPi0Pt(NULL),
378  fHistoMCAllGammaEMCALAccPt(NULL),
379  fHistoMCDecayGammaPi0Pt(NULL),
380  fHistoMCDecayGammaRhoPt(NULL),
381  fHistoMCDecayGammaEtaPt(NULL),
382  fHistoMCDecayGammaOmegaPt(NULL),
383  fHistoMCDecayGammaEtapPt(NULL),
384  fHistoMCDecayGammaPhiPt(NULL),
385  fHistoMCDecayGammaSigmaPt(NULL),
386  fHistoMCConvGammaPt(NULL),
387  fHistoMCConvGammaR(NULL),
388  fHistoMCConvGammaEta(NULL),
389  fHistoMCAllPositronsPt(NULL),
390  fHistoMCDecayPositronPi0Pt(NULL),
391  fHistoMCAllElectronsPt(NULL),
392  fHistoMCDecayElectronPi0Pt(NULL),
393  fHistoMCDecayNoPrimElectronPi0DalitzR(NULL),
394  fHistoMCDecayNoPrimPositronPi0DalitzR(NULL),
395  fHistoMCDecayNoPrimElectronPi0DalitzID(NULL),
396  fHistoMCDecayNoPrimPositronPi0DalitzID(NULL),
397  fHistoMCPi0GGPt(NULL),
398  fHistoMCPi0GGWOWeightPt(NULL),
399  fHistoMCPi0Pt(NULL),
400  fHistoMCPi0WOWeightPt(NULL),
401  fHistoMCEtaGGPt(NULL),
402  fHistoMCEtaGGWOWeightPt(NULL),
403  fHistoMCEtaPt(NULL),
404  fHistoMCEtaWOWeightPt(NULL),
405  fHistoMCPi0InAccPt(NULL),
406  fHistoMCPi0InAccOpeningAngleGammaElectron(NULL),
407  fHistoMCEtaInAccPt(NULL),
408  fHistoMCPi0PtY(NULL),
409  fHistoMCEtaPtY(NULL),
410  fHistoMCPi0PtAlpha(NULL),
411  fHistoMCEtaPtAlpha(NULL),
412  fHistoMCK0sPt(NULL),
413  fHistoMCK0sWOWeightPt(NULL),
414  fHistoMCK0sPtY(NULL),
415  fHistoTruePi0InvMassPt(NULL),
416  fHistoTrueEtaInvMassPt(NULL),
417  fHistoTruePi0ShowerInvMassPt(NULL),
418  fHistoTrueEtaShowerInvMassPt(NULL),
419  fHistoTruePi0NoShowerInvMassPt(NULL),
420  fHistoTrueEtaNoShowerInvMassPt(NULL),
421  fHistoTruePi0OpeningAngleGammaElectron(NULL),
422  fHistoTruePi0GGInvMassPt(NULL),
423  fHistoTrueEtaGGInvMassPt(NULL),
424  fHistoTruePi0CaloPhotonInvMassPt(NULL),
425  fHistoTrueEtaCaloPhotonInvMassPt(NULL),
426  fHistoTruePi0CaloConvertedPhotonInvMassPt(NULL),
427  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt(NULL),
428  fHistoTrueEtaCaloConvertedPhotonInvMassPt(NULL),
429  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt(NULL),
430  fHistoTruePi0CaloElectronInvMassPt(NULL),
431  fHistoTrueEtaCaloElectronInvMassPt(NULL),
432  fHistoTruePi0CaloMergedClusterInvMassPt(NULL),
433  fHistoTrueEtaCaloMergedClusterInvMassPt(NULL),
434  fHistoTrueMotherCaloEMNonLeadingInvMassPt(NULL),
435  fHistoTruePi0CaloMergedClusterPartConvInvMassPt(NULL),
436  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt(NULL),
437  fHistoTruePrimaryPi0InvMassPt(NULL),
438  fHistoTruePrimaryPi0GGInvMassPt(NULL),
439  fHistoTruePrimaryEtaInvMassPt(NULL),
440  fHistoTruePrimaryEtaGGInvMassPt(NULL),
441  fHistoTruePrimaryPi0W0WeightingInvMassPt(NULL),
442  fHistoTruePrimaryEtaW0WeightingInvMassPt(NULL),
443  fProfileTruePrimaryPi0WeightsInvMassPt(NULL),
444  fProfileTruePrimaryEtaWeightsInvMassPt(NULL),
445  fHistoTruePrimaryPi0MCPtResolPt(NULL),
446  fHistoTruePrimaryEtaMCPtResolPt(NULL),
447  fHistoTrueMotherPi0ConvPhotonEtaPhi(NULL),
448  fHistoTrueMotherEtaConvPhotonEtaPhi(NULL),
449  fHistoTrueSecondaryPi0InvMassPt(NULL),
450  fHistoTrueSecondaryPi0GGInvMassPt(NULL),
451  fHistoTrueSecondaryPi0FromK0sInvMassPt(NULL),
452  fHistoTrueK0sWithPi0DaughterMCPt(NULL),
453  fHistoTrueSecondaryPi0FromEtaInvMassPt(NULL),
454  fHistoTrueEtaWithPi0DaughterMCPt(NULL),
455  fHistoTrueSecondaryPi0FromLambdaInvMassPt(NULL),
456  fHistoTrueLambdaWithPi0DaughterMCPt(NULL),
457  fHistoTrueBckGGInvMassPt(NULL),
458  fHistoTrueBckContInvMassPt(NULL),
459  fHistoTruePi0PtY(NULL),
460  fHistoTrueEtaPtY(NULL),
461  fHistoTruePi0PtAlpha(NULL),
462  fHistoTrueEtaPtAlpha(NULL),
463  fHistoTruePi0PtOpenAngle(NULL),
464  fHistoTrueEtaPtOpenAngle(NULL),
465  fHistoTrueConvGammaPt(NULL),
466  fHistoTrueConvPi0GammaPt(NULL),
467  fHistoTrueConvGammaEta(NULL),
468  fHistoTruePositronPt(NULL),
469  fHistoTrueElectronPt(NULL),
470  fHistoTrueSecPositronPt(NULL),
471  fHistoTrueSecElectronPt(NULL),
472  fHistoTruePi0DalitzPositronPt(NULL),
473  fHistoTruePi0DalitzElectronPt(NULL),
474  fHistoTruePi0DalitzSecPositronPt(NULL),
475  fHistoTruePi0DalitzSecElectronPt(NULL),
476  fHistoTruePrimaryConvGammaPt(NULL),
477  fHistoTruePrimaryConvGammaESDPtMCPt(NULL),
478  fHistoTrueSecondaryConvGammaPt(NULL),
479  fHistoTrueSecondaryConvGammaFromXFromK0sPt(NULL),
480  fHistoTrueSecondaryConvGammaFromXFromLambdaPt(NULL),
481  fHistoTrueClusGammaPt(NULL),
482  fHistoTrueClusUnConvGammaPt(NULL),
483  fHistoTrueClusUnConvGammaMCPt(NULL),
484  fHistoTrueClusElectronPt(NULL),
485  fHistoTrueClusConvGammaPt(NULL),
486  fHistoTrueClusConvGammaMCPt(NULL),
487  fHistoTrueClusConvGammaFullyPt(NULL),
488  fHistoTrueClusMergedGammaPt(NULL),
489  fHistoTrueClusMergedPartConvGammaPt(NULL),
490  fHistoTrueClusDalitzPt(NULL),
491  fHistoTrueClusDalitzMergedPt(NULL),
492  fHistoTrueClusPhotonFromElecMotherPt(NULL),
493  fHistoTrueClusShowerPt(NULL),
494  fHistoTrueClusSubLeadingPt(NULL),
495  fHistoTrueClusNParticles(NULL),
496  fHistoTrueClusEMNonLeadingPt(NULL),
497  fHistoTrueNLabelsInClus(NULL),
498  fHistoTruePrimaryClusGammaPt(NULL),
499  fHistoTruePrimaryClusGammaESDPtMCPt(NULL),
500  fHistoTruePi0DalitzClusGammaPt(NULL),
501  fHistoTruePi0DalitzAllClusGammaPt(NULL),
502  fHistoTruePi0DalitzClusGammaMCPt(NULL),
503  fHistoTruePrimaryPi0PhotonPairPtconv(NULL),
504  fHistoTruePrimaryPi0DCPtconv(NULL),
505  fHistoTruePrimaryPi0MissingPtconv(NULL),
506  fHistoTruePrimaryEtaPhotonPairPtconv(NULL),
507  fHistoTruePrimaryEtaDCPtconv(NULL),
508  fHistoTruePrimaryEtaMissingPtconv(NULL),
509  fHistoTrueSecondaryPi0PhotonPairPtconv(NULL),
510  fHistoTrueSecondaryPi0DCPtconv(NULL),
511  fHistoTrueSecondaryPi0MissingPtconv(NULL),
512  fStringRecTruePi0s(NULL),
513  fStringRecTrueEtas(NULL),
514  fHistoDoubleCountTruePi0InvMassPt(NULL),
515  fHistoDoubleCountTrueEtaInvMassPt(NULL),
516  fHistoDoubleCountTrueConvGammaRPt(NULL),
517  fVectorDoubleCountTruePi0s(0),
518  fVectorDoubleCountTrueEtas(0),
519  fVectorDoubleCountTrueConvGammas(0),
520  fHistoNEvents(NULL),
521  fHistoNGoodESDTracks(NULL),
522  fHistoNGammaCandidates(NULL),
523  fHistoNGoodESDTracksVsNGammaCanditates(NULL),
524  fHistoSPDClusterTrackletBackground(NULL),
525  fHistoNV0Tracks(NULL),
526  fProfileEtaShift(NULL),
527  fEventPlaneAngle(-100),
528  fRandom(0),
529  fNGammaCandidates(0),
530  fUnsmearedPx(NULL),
531  fUnsmearedPy(NULL),
532  fUnsmearedPz(NULL),
533  fUnsmearedE(NULL),
534  fMCEventPos(NULL),
535  fMCEventNeg(NULL),
536  fESDArrayPos(NULL),
537  fESDArrayNeg(NULL),
538  fnCuts(0),
539  fiCut(0),
540  fMoveParticleAccordingToVertex(kTRUE),
541  fIsHeavyIon(0),
542  fDoMesonAnalysis(kTRUE),
543  fDoMesonQA(0),
544  fDoPhotonQA(0),
545  fDoClusterQA(0),
546  fIsFromMBHeader(kTRUE),
547  fIsOverlappingWithOtherHeader(kFALSE),
548  fIsMC(kFALSE),
549  fDoTHnSparse(kTRUE)
550 {
551  // Define output slots here
552  DefineOutput(1, TList::Class());
553 }
554 
556 {
557  if(fGammaCandidates){
558  delete fGammaCandidates;
559  fGammaCandidates = 0x0;
560  }
561  if(fClusterCandidates){
562  delete fClusterCandidates;
563  fClusterCandidates = 0x0;
564  }
568  }
569 
570  if(fBGClusHandler){
571  delete[] fBGClusHandler;
572  fBGClusHandler = 0x0;
573  }
574 
575 }
576 //___________________________________________________________
578 
579  const Int_t nDim = 4;
580  Int_t nBins[nDim] = {800,250,7,4};
581  Double_t xMin[nDim] = {0,0, 0,0};
582  Double_t xMax[nDim] = {0.8,25,7,4};
583 
584  if( fDoTHnSparse ) {
585 
586  fSparseMotherInvMassPtZM = new THnSparseF*[fnCuts];
587  fSparseMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
588 
589  }
590 
591 
593 
594  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
595 
596  if (((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
597  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
598  TString cutstringPhoton = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
599  TString cutstringElectron = ((AliDalitzElectronCuts*)fElectronCutArray->At(iCut))->GetCutNumber();
600  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
601  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
602 
603  Int_t collisionSystem = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(0,1));
604  Int_t centMin = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(1,1));
605  Int_t centMax = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(2,1));
606 
607  if(collisionSystem == 1 || collisionSystem == 2 ||
608  collisionSystem == 5 || collisionSystem == 8 ||
609  collisionSystem == 9){
610  centMin = centMin*10;
611  centMax = centMax*10;
612  if(centMax ==0 && centMax!=centMin) centMax=100;
613  } else if(collisionSystem == 3 || collisionSystem == 6){
614  centMin = centMin*5;
615  centMax = centMax*5;
616  } else if(collisionSystem == 4 || collisionSystem == 7){
617  centMin = ((centMin*5)+45);
618  centMax = ((centMax*5)+45);
619  }
620 
621  if( fDoTHnSparse ) {
622 
623  fBackList[iCut] = new TList();
624  fBackList[iCut]->SetName(Form("%s_%s_%s_%s_%s Back histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringElectron.Data(),cutstringCalo.Data(), cutstringMeson.Data()));
625  fBackList[iCut]->SetOwner(kTRUE);
626  fCutFolder[iCut]->Add(fBackList[iCut]);
627 
628  fSparseMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_m","Back_Back_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
629  fBackList[iCut]->Add(fSparseMotherBackInvMassPtZM[iCut]);
630 
631  fMotherList[iCut] = new TList();
632  fMotherList[iCut]->SetName(Form("%s_%s_%s_%s_%s Mother histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringElectron.Data(),cutstringCalo.Data(), cutstringMeson.Data()));
633  fMotherList[iCut]->SetOwner(kTRUE);
634  fCutFolder[iCut]->Add(fMotherList[iCut]);
635 
636  fSparseMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_m","Back_Mother_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
637  fMotherList[iCut]->Add(fSparseMotherInvMassPtZM[iCut]);
638 
639  }
640 
641  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
642 
643 
645  collisionSystem,centMin,centMax,
646  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents(),
647  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseTrackMultiplicity(),
648  2,8,7);
649 
650  }
651  }
652  }
653 }
654 //________________________________________________________________________
656 
657  // Create histograms
658  if(fOutputContainer != NULL){
659  delete fOutputContainer;
660  fOutputContainer = NULL;
661  }
662  if(fOutputContainer == NULL){
663  fOutputContainer = new TList();
664  fOutputContainer->SetOwner(kTRUE);
665  }
666 
667  // Array of current cut's gammas
668  fGammaCandidates = new TList();
669  fClusterCandidates = new TList();
670  fClusterCandidates->SetOwner(kTRUE);
672  fVirtualGammaCandidates->SetOwner(kTRUE);
673 
674  fCutFolder = new TList*[fnCuts];
675  fESDList = new TList*[fnCuts];
676  fBackList = new TList*[fnCuts];
677  fMotherList = new TList*[fnCuts];
678  fHistoNEvents = new TH1I*[fnCuts];
683  fHistoNV0Tracks = new TH1I*[fnCuts];
684  fProfileEtaShift = new TProfile*[fnCuts];
685  fHistoConvGammaPt = new TH1F*[fnCuts];
686 
687  if (fDoPhotonQA == 2){
688  fPhotonDCAList = new TList*[fnCuts];
689 
690  }
691  if (fDoPhotonQA > 0){
692  fHistoConvGammaR = new TH1F*[fnCuts];
693  fHistoConvGammaEta = new TH1F*[fnCuts];
694  }
695 
696  fHistoDalitzElectronPt = new TH1F*[fnCuts];
697  fHistoDalitzPositronPt = new TH1F*[fnCuts];
698  fHistoDalitzElectronPhi = new TH1F*[fnCuts];
699  fHistoDalitzPositronPhi = new TH1F*[fnCuts];
700 
701 
702  if(fDoMesonAnalysis){
707  if (fDoMesonQA > 0){
717  }
718  if(fDoMesonQA == 1){
721  }
722  }
723 
725  fHistoClusGammaPt = new TH1F*[fnCuts];
727 
728  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
729  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
730  TString cutstringPhoton = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
731  TString cutstringElectron = ((AliDalitzElectronCuts*)fElectronCutArray->At(iCut))->GetCutNumber();
732  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
733  TString cutstringMeson = "NoMesonCut";
734  if(fDoMesonAnalysis)cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
735 
736  fCutFolder[iCut] = new TList();
737  fCutFolder[iCut]->SetName(Form("Cut Number %s_%s_%s_%s_%s",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringElectron.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
738  fCutFolder[iCut]->SetOwner(kTRUE);
739  fOutputContainer->Add(fCutFolder[iCut]);
740  fESDList[iCut] = new TList();
741  fESDList[iCut]->SetName(Form("%s_%s_%s_%s_%s ESD histograms", cutstringEvent.Data(),cutstringPhoton.Data(),cutstringElectron.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
742  fESDList[iCut]->SetOwner(kTRUE);
743  fCutFolder[iCut]->Add(fESDList[iCut]);
744 
745  fHistoNEvents[iCut] = new TH1I("NEvents","NEvents",14,-0.5,13.5);
746  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
747  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
748  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Missing MC");
749  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
750  TString TriggerNames = "Not Trigger: ";
751  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
752  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
753  } else {
754  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
755  }
756  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
757  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
758  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
759  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
760  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
761  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
762  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
763  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
764  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
765  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
766  fESDList[iCut]->Add(fHistoNEvents[iCut]);
767 
768  if(fIsHeavyIon == 1) fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",4000,0,4000);
769  else if(fIsHeavyIon == 2) fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",400,0,400);
770  else fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
771  fHistoNGoodESDTracks[iCut]->SetXTitle("# TPC tracks");
772  fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
773 
774  if(fIsHeavyIon == 1) fHistoNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",100,0,100);
775  else if(fIsHeavyIon == 2) fHistoNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",50,0,50);
776  else fHistoNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",50,0,50);
777  fHistoNGammaCandidates[iCut]->SetXTitle("# accepted $#gamma_{conv}");
778  fESDList[iCut]->Add(fHistoNGammaCandidates[iCut]);
779 
780  if(fIsHeavyIon == 1) fHistoNGoodESDTracksVsNGammaCanditates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",4000,0,4000,100,0,100);
781  else if(fIsHeavyIon == 2) fHistoNGoodESDTracksVsNGammaCanditates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",400,0,400,50,0,50);
782  else fHistoNGoodESDTracksVsNGammaCanditates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",200,0,200,50,0,50);
783  fHistoNGoodESDTracksVsNGammaCanditates[iCut]->SetXTitle("# TPC tracks");
784  fHistoNGoodESDTracksVsNGammaCanditates[iCut]->SetYTitle("# accepted $#gamma_{calo}");
786 
787  fHistoSPDClusterTrackletBackground[iCut] = new TH2F("SPD tracklets vs SPD clusters","SPD tracklets vs SPD clusters",100,0,200,250,0,1000);
789 
790  if(fIsHeavyIon == 1) fHistoNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",30000,0,30000);
791  else if(fIsHeavyIon == 2) fHistoNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",2500,0,2500);
792  else fHistoNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",1500,0,1500);
793  fHistoNV0Tracks[iCut]->SetXTitle("VZERO amp [arb. units]");
794  fESDList[iCut]->Add(fHistoNV0Tracks[iCut]);
795  fProfileEtaShift[iCut] = new TProfile("Eta Shift","Eta Shift",1, -0.5,0.5);
796  fESDList[iCut]->Add(fProfileEtaShift[iCut]);
797  fHistoConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt","ESD_ConvGamma_Pt",250,0,25);
798  fHistoConvGammaPt[iCut]->SetXTitle("p_{T,conv} (GeV/c)");
799  fESDList[iCut]->Add(fHistoConvGammaPt[iCut]);
800 
801  if (fDoPhotonQA == 2){
802  fPhotonDCAList[iCut] = new TList();
803  fPhotonDCAList[iCut]->SetName(Form("%s_%s_%s_%s Photon DCA tree",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
804  fPhotonDCAList[iCut]->SetOwner(kTRUE);
805  fCutFolder[iCut]->Add(fPhotonDCAList[iCut]);
806 
807 
808  }
809 
810  if (fDoPhotonQA > 0){
811  fHistoConvGammaR[iCut] = new TH1F("ESD_ConvGamma_R","ESD_ConvGamma_R",800,0,200);
812  fHistoConvGammaR[iCut]->SetXTitle("R_{conv} (cm)");
813  fESDList[iCut]->Add(fHistoConvGammaR[iCut]);
814  fHistoConvGammaEta[iCut] = new TH1F("ESD_ConvGamma_Eta","ESD_ConvGamma_Eta",2000,-2,2);
815  fHistoConvGammaEta[iCut]->SetXTitle("#eta_{conv}");
816  fESDList[iCut]->Add(fHistoConvGammaEta[iCut]);
817  }
818 
819 
820 
821 
822 
823  fHistoDalitzElectronPt[iCut] = new TH1F("ESD_DalitzElectron_Pt","ESD_DalitzElectron_Pt",1000,0,25);
824  fESDList[iCut]->Add(fHistoDalitzElectronPt[iCut]);
825 
826  fHistoDalitzPositronPt[iCut] = new TH1F("ESD_DalitzPositron_Pt","ESD_DalitzPositron_Pt",1000,0,25);
827  fESDList[iCut]->Add(fHistoDalitzPositronPt[iCut]);
828 
829  fHistoDalitzElectronPhi[iCut] = new TH1F("ESD_DalitzElectron_Phi","ESD_DalitzElectron_Phi",360,0,2*TMath::Pi());
830  fESDList[iCut]->Add(fHistoDalitzElectronPhi[iCut]);
831 
832  fHistoDalitzPositronPhi[iCut] = new TH1F("ESD_DalitzPositron_Phi","ESD_DalitzPositron_Phi",360,0,2*TMath::Pi());
833  fESDList[iCut]->Add(fHistoDalitzPositronPhi[iCut]);
834 
835 
836 
837 
838 
839 
840 
841  fClusterOutputList[iCut] = new TList();
842  fClusterOutputList[iCut]->SetName(Form("%s_%s_%s_%s_%s Cluster Output",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringElectron.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
843  fClusterOutputList[iCut]->SetOwner(1);
844  fCutFolder[iCut]->Add(fClusterOutputList[iCut]);
845 
846  fHistoClusGammaPt[iCut] = new TH1F("ClusGamma_Pt","ClusGamma_Pt",250,0,25);
847  fHistoClusGammaPt[iCut]->SetXTitle("p_{T,clus} (GeV/c)");
848  fClusterOutputList[iCut]->Add(fHistoClusGammaPt[iCut]);
849  fHistoClusOverlapHeadersGammaPt[iCut] = new TH1F("ClusGammaOverlapHeaders_Pt","ClusGammaOverlapHeaders_Pt",250,0,25);
850  fHistoClusOverlapHeadersGammaPt[iCut]->SetXTitle("p_{T,clus} (GeV/c), selected header w/ overlap");
852 
853  if(fDoMesonAnalysis){
854 
855  fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",800,0,0.8,250,0,25);
856  fHistoMotherInvMassPt[iCut]->SetXTitle("M_{inv} (GeV/c^{2})");
857  fHistoMotherInvMassPt[iCut]->SetYTitle("p_{T,pair} (GeV/c)");
858  fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
859 
860  fHistoMotherMatchedInvMassPt[iCut] = new TH2F("ESD_MotherMatched_InvMass_Pt","ESD_MotherMatched_InvMass_Pt",800,0,0.8,250,0,25);
861  fHistoMotherMatchedInvMassPt[iCut]->SetXTitle("M_{inv} (GeV/c^{2}) matched conv e^{+/-} to cluster");
862  fHistoMotherMatchedInvMassPt[iCut]->SetYTitle("p_{T,pair} (GeV/c)");
863  fESDList[iCut]->Add(fHistoMotherMatchedInvMassPt[iCut]);
864 
865  fHistoMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt","ESD_Background_InvMass_Pt",800,0,0.8,250,0,25);
866  fHistoMotherBackInvMassPt[iCut]->SetXTitle("M_{inv, mxed} (GeV/c^{2})");
867  fHistoMotherBackInvMassPt[iCut]->SetYTitle("p_{T,BG pair} (GeV/c)");
868  fESDList[iCut]->Add(fHistoMotherBackInvMassPt[iCut]);
869 
870  fHistoMotherInvMassEalpha[iCut] = new TH2F("ESD_Mother_InvMass_vs_E_alpha","ESD_Mother_InvMass_vs_E_alpha",800,0,0.8,250,0,25);
871  fHistoMotherInvMassEalpha[iCut]->SetXTitle("M_{inv} (GeV/c^{2})");
872  fHistoMotherInvMassEalpha[iCut]->SetYTitle("p_{T,pair} (GeV/c)");
873  fESDList[iCut]->Add(fHistoMotherInvMassEalpha[iCut]);
874 
875  if( fDoMesonQA > 0 ) {
876  fHistoMotherInvMassOpeningAngleGammaElectron[iCut] = new TH1F("ESD_MotherInvMass_OpeningAngle_GammaElectron", "ESD_MotherInvMass_OpeningAngle_GammaElectron",100,0.,TMath::Pi());
878  }
879 
880  }
881  }
882 
883  if(fDoMesonAnalysis){
884  InitBack(); // Init Background Handler
885  }
886 
887  if(fIsMC){
888  // MC Histogramms
889  fMCList = new TList*[fnCuts];
890  // True Histogramms
891  fTrueList = new TList*[fnCuts];
892  // Selected Header List
893  fHeaderNameList = new TList*[fnCuts];
894  fHistoMCHeaders = new TH1I*[fnCuts];
895  fHistoMCAllGammaPt = new TH1F*[fnCuts];
896  fHistoMCAllGammaPi0Pt = new TH1F*[fnCuts];
897  fHistoMCAllGammaEMCALAccPt = new TH1F*[fnCuts];
898  fHistoMCDecayGammaPi0Pt = new TH1F*[fnCuts];
899  fHistoMCDecayGammaRhoPt = new TH1F*[fnCuts];
900  fHistoMCDecayGammaEtaPt = new TH1F*[fnCuts];
901  fHistoMCDecayGammaOmegaPt = new TH1F*[fnCuts];
902  fHistoMCDecayGammaEtapPt = new TH1F*[fnCuts];
903  fHistoMCDecayGammaPhiPt = new TH1F*[fnCuts];
904  fHistoMCDecayGammaSigmaPt = new TH1F*[fnCuts];
905  fHistoMCConvGammaPt = new TH1F*[fnCuts];
906  fHistoMCAllPositronsPt = new TH1F*[fnCuts];
907  fHistoMCDecayPositronPi0Pt = new TH1F*[fnCuts];
908  fHistoMCAllElectronsPt = new TH1F*[fnCuts];
909  fHistoMCDecayElectronPi0Pt = new TH1F*[fnCuts];
914 
915 
916  fHistoTrueConvGammaPt = new TH1F*[fnCuts];
918  fHistoTrueConvPi0GammaPt = new TH1F*[fnCuts];
919  fHistoTruePositronPt = new TH1F*[fnCuts];
920  fHistoTrueElectronPt = new TH1F*[fnCuts];
921  fHistoTrueSecPositronPt = new TH1F*[fnCuts];
922  fHistoTrueSecElectronPt = new TH1F*[fnCuts];
927 
928 
929 
930 
936 
937  fHistoTrueClusGammaPt = new TH1F*[fnCuts];
940 
944 
945  if (fDoPhotonQA > 0){
946 
947  fHistoMCConvGammaR = new TH1F*[fnCuts];
948  fHistoMCConvGammaEta = new TH1F*[fnCuts];
949  fHistoTrueConvGammaEta = new TH1F*[fnCuts];
950 
951  }
952 
953 
954  if (fDoClusterQA > 0){
955 
956  fHistoTrueClusUnConvGammaPt = new TH1F*[fnCuts];
958  fHistoTrueClusElectronPt = new TH1F*[fnCuts];
959  fHistoTrueClusConvGammaPt = new TH1F*[fnCuts];
960  fHistoTrueClusConvGammaMCPt = new TH1F*[fnCuts];
962  fHistoTrueClusMergedGammaPt = new TH1F*[fnCuts];
964  fHistoTrueClusDalitzPt = new TH1F*[fnCuts];
967  fHistoTrueClusShowerPt = new TH1F*[fnCuts];
968  fHistoTrueClusSubLeadingPt = new TH1F*[fnCuts];
971  fHistoTrueNLabelsInClus = new TH1F*[fnCuts];
972  }
973 
974 
975  if(fDoMesonAnalysis){
976 
977  fHistoMCPi0GGPt = new TH1F*[fnCuts];
978  fHistoMCPi0GGWOWeightPt = new TH1F*[fnCuts];
979  fHistoMCPi0Pt = new TH1F*[fnCuts];
980  fHistoMCPi0WOWeightPt = new TH1F*[fnCuts];
981 
982  fHistoMCEtaGGPt = new TH1F*[fnCuts];
983  fHistoMCEtaGGWOWeightPt = new TH1F*[fnCuts];
984  fHistoMCEtaPt = new TH1F*[fnCuts];
985  fHistoMCEtaWOWeightPt = new TH1F*[fnCuts];
986 
987  fHistoMCPi0InAccPt = new TH1F*[fnCuts];
988 
989  fHistoMCEtaInAccPt = new TH1F*[fnCuts];
990 
1013  fHistoTruePrimaryPi0DCPtconv = new TH1F*[fnCuts];
1015  fHistoTruePrimaryEtaDCPtconv = new TH1F*[fnCuts];
1021 
1022 
1023  if (fDoMesonQA > 0){
1024 
1025  fHistoMCPi0PtY = new TH2F*[fnCuts];
1026  fHistoMCEtaPtY = new TH2F*[fnCuts];
1027  fHistoMCPi0PtAlpha = new TH2F*[fnCuts];
1028  fHistoMCEtaPtAlpha = new TH2F*[fnCuts];
1029  fHistoMCK0sPt = new TH1F*[fnCuts];
1030  fHistoMCK0sWOWeightPt = new TH1F*[fnCuts];
1031  fHistoMCK0sPtY = new TH2F*[fnCuts];
1052  fHistoTruePi0PtY = new TH2F*[fnCuts];
1053  fHistoTrueEtaPtY = new TH2F*[fnCuts];
1066 
1067  }
1068  }
1069 
1070  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1071 
1072  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
1073  TString cutstringPhoton = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
1074  TString cutstringElectron = ((AliDalitzElectronCuts*)fElectronCutArray->At(iCut))->GetCutNumber();
1075  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
1076  TString cutstringMeson = "NoMesonCut";
1077  if(fDoMesonAnalysis)cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
1078 
1079  fMCList[iCut] = new TList();
1080  fMCList[iCut]->SetName(Form("%s_%s_%s_%s_%s MC histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringElectron.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
1081  fMCList[iCut]->SetOwner(kTRUE);
1082  fCutFolder[iCut]->Add(fMCList[iCut]);
1083  fHistoMCHeaders[iCut] = new TH1I("MC_Headers","MC_Headers",20,0,20);
1084  fMCList[iCut]->Add(fHistoMCHeaders[iCut]);
1085  fHistoMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt","MC_AllGamma_Pt",250,0,25);
1086  fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);
1087 
1088  fHistoMCAllGammaPi0Pt[iCut] = new TH1F("MC_AllGammaPi0_Pt","MC_AllGammaPi0_Pt",250,0,25);
1089  fMCList[iCut]->Add(fHistoMCAllGammaPi0Pt[iCut]);
1090 
1091  fHistoMCAllGammaEMCALAccPt[iCut] = new TH1F("MC_AllGammaEMCALAcc_Pt","MC_AllGammaEMCALAcc_Pt",250,0,25);
1092  fMCList[iCut]->Add(fHistoMCAllGammaEMCALAccPt[iCut]);
1093  fHistoMCDecayGammaPi0Pt[iCut] = new TH1F("MC_DecayGammaPi0_Pt","MC_DecayGammaPi0_Pt",250,0,25);
1094  fMCList[iCut]->Add(fHistoMCDecayGammaPi0Pt[iCut]);
1095  fHistoMCDecayGammaRhoPt[iCut] = new TH1F("MC_DecayGammaRho_Pt","MC_DecayGammaRho_Pt",250,0,25);
1096  fMCList[iCut]->Add(fHistoMCDecayGammaRhoPt[iCut]);
1097  fHistoMCDecayGammaEtaPt[iCut] = new TH1F("MC_DecayGammaEta_Pt","MC_DecayGammaEta_Pt",250,0,25);
1098  fMCList[iCut]->Add(fHistoMCDecayGammaEtaPt[iCut]);
1099  fHistoMCDecayGammaOmegaPt[iCut] = new TH1F("MC_DecayGammaOmega_Pt","MC_DecayGammaOmmega_Pt",250,0,25);
1100  fMCList[iCut]->Add(fHistoMCDecayGammaOmegaPt[iCut]);
1101  fHistoMCDecayGammaEtapPt[iCut] = new TH1F("MC_DecayGammaEtap_Pt","MC_DecayGammaEtap_Pt",250,0,25);
1102  fMCList[iCut]->Add(fHistoMCDecayGammaEtapPt[iCut]);
1103  fHistoMCDecayGammaPhiPt[iCut] = new TH1F("MC_DecayGammaPhi_Pt","MC_DecayGammaPhi_Pt",250,0,25);
1104  fMCList[iCut]->Add(fHistoMCDecayGammaPhiPt[iCut]);
1105  fHistoMCDecayGammaSigmaPt[iCut] = new TH1F("MC_DecayGammaSigma_Pt","MC_DecayGammaSigma_Pt",250,0,25);
1106  fMCList[iCut]->Add(fHistoMCDecayGammaSigmaPt[iCut]);
1107  fHistoMCConvGammaPt[iCut] = new TH1F("MC_ConvGamma_Pt","MC_ConvGamma_Pt",250,0,25);
1108  fMCList[iCut]->Add(fHistoMCConvGammaPt[iCut]);
1109 
1110  fHistoMCAllPositronsPt[iCut] = new TH1F("MC_AllPositrons_Pt","MC_AllPositrons_Pt",1000,0,25);
1111  fMCList[iCut]->Add(fHistoMCAllPositronsPt[iCut]);
1112 
1113 
1114  fHistoMCDecayPositronPi0Pt[iCut] = new TH1F("MC_DecayPositronPi0_Pt","MC_DecayPositronPi0_Pt",1000,0,25);
1115  fMCList[iCut]->Add(fHistoMCDecayPositronPi0Pt[iCut]);
1116 
1117  fHistoMCAllElectronsPt[iCut] = new TH1F("MC_AllElectrons_Pt","MC_AllElectrons_Pt",1000,0,25);
1118  fMCList[iCut]->Add(fHistoMCAllElectronsPt[iCut]);
1119 
1120  fHistoMCDecayElectronPi0Pt[iCut] = new TH1F("MC_DecayElectronPi0_Pt","MC_DecayElectronPi0_Pt",1000,0,25);
1121  fMCList[iCut]->Add(fHistoMCDecayElectronPi0Pt[iCut]);
1122 
1123  fHistoMCDecayNoPrimElectronPi0DalitzR[iCut] = new TH1F("MC_DecayNoPrimElectronPi0Dalitz_R","MC_DecayNoPrimElectronPi0Dalitz_R",200,0,200);
1125 
1126  fHistoMCDecayNoPrimPositronPi0DalitzR[iCut] = new TH1F("MC_DecayNoPrimPositronPi0Dalitz_R","MC_DecayNoPrimPositronPi0Dalitz_R",200,0,200);
1128 
1129  fHistoMCDecayNoPrimElectronPi0DalitzID[iCut] = new TH1F("MC_DecayNoPrimElectronPi0Dalitz_ID","MC_DecayNoPrimElectronPi0Dalitz_ID",51,-1,50);
1131 
1132  fHistoMCDecayNoPrimPositronPi0DalitzID[iCut] = new TH1F("MC_DecayNoPrimPositronPi0Dalitz_ID","MC_DecayNoPrimPositronPi0Dalitz_ID",51,-1,50);
1134 
1135 
1136 
1137  if (fDoPhotonQA > 0){
1138 
1139  fHistoMCConvGammaR[iCut] = new TH1F("MC_ConvGamma_R","MC_ConvGamma_R",800,0,200);
1140  fMCList[iCut]->Add(fHistoMCConvGammaR[iCut]);
1141  fHistoMCConvGammaEta[iCut] = new TH1F("MC_ConvGamma_Eta","MC_ConvGamma_Eta",2000,-2,2);
1142  fMCList[iCut]->Add(fHistoMCConvGammaEta[iCut]);
1143 
1144  }
1145 
1146  if(fDoMesonAnalysis){
1147 
1148  fHistoMCPi0GGPt[iCut] = new TH1F("MC_Pi0_GG_Pt","MC_Pi0_GG_Pt",250,0,25);
1149  fHistoMCPi0GGPt[iCut]->Sumw2();
1150  fMCList[iCut]->Add(fHistoMCPi0GGPt[iCut]);
1151  fHistoMCPi0GGWOWeightPt[iCut] = new TH1F("MC_Pi0_GG_WOWeights_Pt","MC_Pi0_GG_WOWeights_Pt",250,0,25);
1152  fHistoMCPi0GGWOWeightPt[iCut]->Sumw2();
1153  fMCList[iCut]->Add(fHistoMCPi0GGWOWeightPt[iCut]);
1154 
1155  fHistoMCPi0Pt[iCut] = new TH1F("MC_Pi0_Pt","MC_Pi0_Pt",250,0,25);
1156  fHistoMCPi0Pt[iCut]->Sumw2();
1157 
1158  fMCList[iCut]->Add(fHistoMCPi0Pt[iCut]);
1159  fHistoMCPi0WOWeightPt[iCut] = new TH1F("MC_Pi0_WOWeights_Pt","MC_Pi0_WOWeights_Pt",250,0,25);
1160  fHistoMCPi0WOWeightPt[iCut]->Sumw2();
1161  fMCList[iCut]->Add(fHistoMCPi0WOWeightPt[iCut]);
1162 
1163 
1164  fHistoMCEtaGGPt[iCut] = new TH1F("MC_Eta_GG_Pt","MC_Eta_GG_Pt",250,0,25);
1165  fHistoMCEtaGGPt[iCut]->Sumw2();
1166  fMCList[iCut]->Add(fHistoMCEtaGGPt[iCut]);
1167  fHistoMCEtaGGWOWeightPt[iCut] = new TH1F("MC_Eta_GG_WOWeights_Pt","MC_Eta_GG_WOWeights_Pt",250,0,25);
1168  fHistoMCEtaGGWOWeightPt[iCut]->Sumw2();
1169  fMCList[iCut]->Add(fHistoMCEtaGGWOWeightPt[iCut]);
1170 
1171  fHistoMCEtaPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",250,0,25);
1172  fHistoMCEtaPt[iCut]->Sumw2();
1173  fMCList[iCut]->Add(fHistoMCEtaPt[iCut]);
1174  fHistoMCEtaWOWeightPt[iCut] = new TH1F("MC_Eta_WOWeights_Pt","MC_Eta_WOWeights_Pt",250,0,25);
1175  fHistoMCEtaWOWeightPt[iCut]->Sumw2();
1176  fMCList[iCut]->Add(fHistoMCEtaWOWeightPt[iCut]);
1177 
1178 
1179 
1180  fHistoMCPi0InAccPt[iCut] = new TH1F("MC_Pi0InAcc_Pt","MC_Pi0InAcc_Pt",250,0,25);
1181  fHistoMCPi0InAccPt[iCut]->Sumw2();
1182  fMCList[iCut]->Add(fHistoMCPi0InAccPt[iCut]);
1183  fHistoMCEtaInAccPt[iCut] = new TH1F("MC_EtaInAcc_Pt","MC_EtaInAcc_Pt",250,0,25);
1184  fHistoMCEtaInAccPt[iCut]->Sumw2();
1185  fMCList[iCut]->Add(fHistoMCEtaInAccPt[iCut]);
1186 
1187 
1188 
1189  if (fDoMesonQA > 0){
1190 
1191  fHistoMCPi0PtY[iCut] = new TH2F("MC_Pi0_Pt_Y","MC_Pi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1192  fHistoMCPi0PtY[iCut]->Sumw2();
1194  fMCList[iCut]->Add(fHistoMCPi0PtY[iCut]);
1195  fHistoMCEtaPtY[iCut] = new TH2F("MC_Eta_Pt_Y","MC_Eta_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1196  fHistoMCEtaPtY[iCut]->Sumw2();
1198  fMCList[iCut]->Add(fHistoMCEtaPtY[iCut]);
1199  fHistoMCPi0PtAlpha[iCut] = new TH2F("MC_Pi0_Pt_Alpha","MC_Pi0_Pt_Alpha",150,0.03,15.,100,0,1);
1201  fMCList[iCut]->Add(fHistoMCPi0PtAlpha[iCut]);
1202  fHistoMCEtaPtAlpha[iCut] = new TH2F("MC_Eta_Pt_Alpha","MC_Eta_Pt_Alpha",150,0.03,15.,100,0,1);
1204  fMCList[iCut]->Add(fHistoMCEtaPtAlpha[iCut]);
1205 
1206  fHistoMCK0sPt[iCut] = new TH1F("MC_K0s_Pt","MC_K0s_Pt",150,0,15);
1207  fHistoMCK0sPt[iCut]->Sumw2();
1208  fMCList[iCut]->Add(fHistoMCK0sPt[iCut]);
1209  fHistoMCK0sWOWeightPt[iCut] = new TH1F("MC_K0s_WOWeights_Pt","MC_K0s_WOWeights_Pt",150,0,15);
1210  fHistoMCK0sWOWeightPt[iCut]->Sumw2();
1211  fMCList[iCut]->Add(fHistoMCK0sWOWeightPt[iCut]);
1212  fHistoMCK0sPtY[iCut] = new TH2F("MC_K0s_Pt_Y","MC_K0s_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1213  fHistoMCK0sPtY[iCut]->Sumw2();
1215  fMCList[iCut]->Add(fHistoMCK0sPtY[iCut]);
1216 
1217  fHistoMCPi0InAccOpeningAngleGammaElectron[iCut] = new TH1F("MC_Pi0InAcc_OpeningAngle_GammaElectron","MC_Pi0InAcc_OpeningAngle_GammaElectron",100,0,TMath::Pi());
1219 
1220 
1221  }
1222 
1223  }
1224  fTrueList[iCut] = new TList();
1225  fTrueList[iCut]->SetName(Form("%s_%s_%s_%s_%s True histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringElectron.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
1226  fTrueList[iCut]->SetOwner(kTRUE);
1227  fCutFolder[iCut]->Add(fTrueList[iCut]);
1228 
1229  fHistoTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt","ESD_TrueConvGamma_Pt",250,0,25);
1230  fTrueList[iCut]->Add(fHistoTrueConvGammaPt[iCut]);
1231 
1232  fHistoDoubleCountTrueConvGammaRPt[iCut] = new TH2F("ESD_TrueDoubleCountConvGamma_R_Pt","ESD_TrueDoubleCountConvGamma_R_Pt",800,0,200,300,0,30);
1233  fTrueList[iCut]->Add(fHistoDoubleCountTrueConvGammaRPt[iCut]);
1234 
1235  fHistoTrueConvPi0GammaPt[iCut] = new TH1F("ESD_TrueConvPi0Gamma_Pt","ESD_TrueConvPi0Gamma_Pt",250,0,25);
1236  fTrueList[iCut]->Add(fHistoTrueConvPi0GammaPt[iCut]);
1237 
1238 
1239  fHistoTruePositronPt[iCut] = new TH1F("ESD_TruePositron_Pt","ESD_TruePositron_Pt",1000,0,25);
1240  fTrueList[iCut]->Add(fHistoTruePositronPt[iCut]);
1241 
1242  fHistoTrueElectronPt[iCut] = new TH1F("ESD_TrueElectron_Pt","ESD_TrueElectron_Pt",1000,0,25);
1243  fTrueList[iCut]->Add(fHistoTrueElectronPt[iCut]);
1244 
1245  fHistoTrueSecPositronPt[iCut] = new TH1F("ESD_TrueSecPositron_Pt","ESD_TrueSecPositron_Pt",1000,0,25);
1246  fTrueList[iCut]->Add(fHistoTrueSecPositronPt[iCut]);
1247 
1248  fHistoTrueSecElectronPt[iCut] = new TH1F("ESD_TrueSecElectron_Pt","ESD_TrueSecElectron_Pt",1000,0,25);
1249  fTrueList[iCut]->Add(fHistoTrueSecElectronPt[iCut]);
1250 
1251  fHistoTruePi0DalitzElectronPt[iCut] = new TH1F("ESD_TruePi0DalitzElectron_Pt","ESD_TruePi0DalitzElectron_Pt",1000,0,25);
1252  fTrueList[iCut]->Add(fHistoTruePi0DalitzElectronPt[iCut]);
1253 
1254  fHistoTruePi0DalitzPositronPt[iCut] = new TH1F("ESD_TruePi0DalitzPositron_Pt","ESD_TruePi0DalitzPositron_Pt",1000,0,25);
1255  fTrueList[iCut]->Add(fHistoTruePi0DalitzPositronPt[iCut]);
1256 
1257  fHistoTruePi0DalitzSecElectronPt[iCut] = new TH1F("ESD_TruePi0DalitzSecElectron_Pt","ESD_TruePi0DalitzSecElectron_Pt",1000,0,25);
1258  fTrueList[iCut]->Add(fHistoTruePi0DalitzSecElectronPt[iCut]);
1259 
1260  fHistoTruePi0DalitzSecPositronPt[iCut] = new TH1F("ESD_TruePi0DalitzSecPositron_Pt","ESD_TruePi0DalitzSecPositron_Pt",1000,0,25);
1261  fTrueList[iCut]->Add(fHistoTruePi0DalitzSecPositronPt[iCut]);
1262 
1263 
1264 
1265  fHistoTruePrimaryConvGammaPt[iCut] = new TH1F("ESD_TruePrimaryConvGamma_Pt","ESD_TruePrimaryConvGamma_Pt",250,0,25);
1266  fTrueList[iCut]->Add(fHistoTruePrimaryConvGammaPt[iCut]);
1267  fHistoTrueSecondaryConvGammaPt[iCut] = new TH1F("ESD_TrueSecondaryConvGamma_Pt","ESD_TrueSecondaryConvGamma_Pt",250,0,25);
1268  fTrueList[iCut]->Add(fHistoTrueSecondaryConvGammaPt[iCut]);
1269 
1270  fHistoTrueSecondaryConvGammaFromXFromK0sPt[iCut] = new TH1F("ESD_TrueSecondaryConvGammaFromXFromK0s_Pt", "ESD_TrueSecondaryConvGammaFromXFromK0s_Pt",250,0,25);
1272  fHistoTrueSecondaryConvGammaFromXFromLambdaPt[iCut] = new TH1F("ESD_TrueSecondaryConvGammaFromXFromLambda_Pt", "ESD_TrueSecondaryConvGammaFromXFromLambda_Pt",250,0,25);
1274 
1275  fHistoTruePrimaryConvGammaESDPtMCPt[iCut] = new TH2F("ESD_TruePrimaryConvGammaESD_PtMCPt", "ESD_TruePrimaryConvGammaESD_PtMCPt",250,0,25,250,0,25);
1277 
1278  fHistoTrueClusGammaPt[iCut] = new TH1F("TrueClusGamma_Pt","ESD_TrueClusGamma_Pt",250,0,25);
1279  fClusterOutputList[iCut]->Add(fHistoTrueClusGammaPt[iCut]);
1280  fHistoTruePrimaryClusGammaPt[iCut] = new TH1F("TruePrimaryClusGamma_Pt","ESD_TruePrimaryClusGamma_Pt",250,0,25);
1282  fHistoTruePrimaryClusGammaESDPtMCPt[iCut] = new TH2F("TruePrimaryClusGamma_Pt_MCPt","ESD_TruePrimaryClusGamma_MCPt",250,0,25,250,0,25);
1284 
1285  fHistoTruePi0DalitzClusGammaPt[iCut] = new TH1F("TruePi0DalitzClusGamma_Pt","fHistoTruePi0DalitzClusGamma_Pt",250,0,25);
1287 
1288  fHistoTruePi0DalitzClusGammaMCPt[iCut]= new TH1F("TruePi0DalitzClusGamma_MCPt","fHistoTruePi0DalitzClusGamma_MCPt",250,0,25);
1290 
1291 
1292  fHistoTruePi0DalitzAllClusGammaPt[iCut] = new TH1F("TruePi0DalitzAllClusGamma_Pt","TruePi0DalitzAllClusGamma_Pt",250,0,25);
1294 
1295 
1296 
1297 
1298  if (fDoPhotonQA > 0){
1299  fHistoTrueConvGammaEta[iCut] = new TH1F("ESD_TrueConvGamma_Eta","ESD_TrueConvGamma_Eta",2000,-2,2);
1300  fTrueList[iCut]->Add(fHistoTrueConvGammaEta[iCut]);
1301  }
1302  if (fDoClusterQA > 0){
1303  fHistoTrueClusUnConvGammaPt[iCut] = new TH1F("TrueClusUnConvGamma_Pt","TrueClusUnConvGamma_Pt",250,0,25);
1305  fHistoTrueClusUnConvGammaMCPt[iCut] = new TH1F("TrueClusUnConvGamma_MCPt","TrueClusUnConvGamma_MCPt",250,0,25);
1307  fHistoTrueClusElectronPt[iCut] = new TH1F("TrueClusElectron_Pt","TrueElectronGamma_Pt",250,0,25);
1308  fClusterOutputList[iCut]->Add(fHistoTrueClusElectronPt[iCut]);
1309  fHistoTrueClusConvGammaPt[iCut] = new TH1F("TrueClusConvGamma_Pt","TrueClusConvGamma_Pt",250,0,25);
1311  fHistoTrueClusConvGammaMCPt[iCut] = new TH1F("TrueClusConvGamma_MCPt","TrueClusConvGamma_MCPt",250,0,25);
1313  fHistoTrueClusConvGammaFullyPt[iCut] = new TH1F("TrueClusConvGammaFullyContained_Pt","TrueClusConvGammaFullyContained_Pt",250,0,25);
1315  fHistoTrueClusMergedGammaPt[iCut] = new TH1F("TrueClusMergedGamma_Pt","TrueClusMergedGamma_Pt",250,0,25);
1317  fHistoTrueClusMergedPartConvGammaPt[iCut] = new TH1F("TrueClusMergedPartConvGamma_Pt","TrueClusMergedPartConvGamma_Pt",250,0,25);
1319  fHistoTrueClusDalitzPt[iCut] = new TH1F("TrueClusDalitz_Pt","TrueClusDalitz_Pt",250,0,25);
1320  fClusterOutputList[iCut]->Add(fHistoTrueClusDalitzPt[iCut]);
1321  fHistoTrueClusDalitzMergedPt[iCut] = new TH1F("TrueClusDalitzMerged_Pt","TrueClusDalitzMerged_Pt",250,0,25);
1323  fHistoTrueClusPhotonFromElecMotherPt[iCut] = new TH1F("TrueClusPhotonFromElecMother_Pt","TrueClusPhotonFromElecMother_Pt",250,0,25);
1325  fHistoTrueClusShowerPt[iCut] = new TH1F("TrueClusShower_Pt","TrueClusShower_Pt",250,0,25);
1326  fClusterOutputList[iCut]->Add(fHistoTrueClusShowerPt[iCut]);
1327  fHistoTrueClusSubLeadingPt[iCut] = new TH1F("TrueClusSubleading_Pt","TrueClusSubleading_Pt",250,0,25);
1329  fHistoTrueClusNParticles[iCut] = new TH1I("TrueClusNParticles","TrueClusNParticles",20,0,20);
1330  fClusterOutputList[iCut]->Add(fHistoTrueClusNParticles[iCut]);
1331  fHistoTrueClusEMNonLeadingPt[iCut] = new TH1F("TrueClusEMNonLeading_Pt","TrueClusEMNonLeading_Pt",250,0,25);
1333  fHistoTrueNLabelsInClus[iCut] = new TH1F("TrueNLabelsInClus","TrueNLabelsInClus",100,-0.5,99.5);
1334  fClusterOutputList[iCut]->Add(fHistoTrueNLabelsInClus[iCut]);
1335  }
1336 
1337  if(fDoMesonAnalysis){
1338  fHistoTruePi0InvMassPt[iCut] = new TH2F("ESD_TruePi0_InvMass_Pt","ESD_TruePi0_InvMass_Pt",800,0,0.8,250,0,25);
1339  fHistoTruePi0InvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2})");
1340  fHistoTruePi0InvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1341  fTrueList[iCut]->Add(fHistoTruePi0InvMassPt[iCut]);
1342 
1343  fHistoTrueEtaInvMassPt[iCut] = new TH2F("ESD_TrueEta_InvMass_Pt","ESD_TrueEta_InvMass_Pt",800,0,0.8,250,0,25);
1344  fHistoTrueEtaInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2})");
1345  fHistoTrueEtaInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1346  fTrueList[iCut]->Add(fHistoTrueEtaInvMassPt[iCut]);
1347 
1348  fHistoDoubleCountTruePi0InvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountPi0_InvMass_Pt","ESD_TrueDoubleCountPi0_InvMass_Pt",800,0,0.8,300,0,30);
1349  fTrueList[iCut]->Add(fHistoDoubleCountTruePi0InvMassPt[iCut]);
1350  fHistoDoubleCountTrueEtaInvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountEta_InvMass_Pt","ESD_TrueDoubleCountEta_InvMass_Pt",800,0,0.8,300,0,30);
1351  fTrueList[iCut]->Add(fHistoDoubleCountTrueEtaInvMassPt[iCut]);
1352 
1353  fHistoTruePi0GGInvMassPt[iCut] = new TH2F("ESD_TruePi0GG_InvMass_Pt","ESD_TruePi0GG_InvMass_Pt",800,0,0.8,250,0,25);
1354  fHistoTruePi0GGInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2})");
1355  fHistoTruePi0GGInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1356  fTrueList[iCut]->Add(fHistoTruePi0GGInvMassPt[iCut]);
1357 
1358  fHistoTrueEtaGGInvMassPt[iCut] = new TH2F("ESD_TrueEtaGG_InvMass_Pt","ESD_TrueEtaGG_InvMass_Pt",800,0,0.8,250,0,25);
1359  fHistoTrueEtaGGInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2})");
1360  fHistoTrueEtaGGInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1361  fTrueList[iCut]->Add(fHistoTrueEtaGGInvMassPt[iCut]);
1362 
1363 
1364 
1365  fHistoTruePrimaryPi0InvMassPt[iCut] = new TH2F("ESD_TruePrimaryPi0_InvMass_Pt", "ESD_TruePrimaryPi0_InvMass_Pt", 800,0,0.8,250,0,25);
1366  fHistoTruePrimaryPi0InvMassPt[iCut]->SetXTitle("M_{inv,prim #pi^{0}} (GeV/c^{2})");
1367  fHistoTruePrimaryPi0InvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1368  fHistoTruePrimaryPi0InvMassPt[iCut]->Sumw2();
1369  fTrueList[iCut]->Add(fHistoTruePrimaryPi0InvMassPt[iCut]);
1370 
1371 
1372  fHistoTruePrimaryPi0GGInvMassPt[iCut] = new TH2F("ESD_TruePrimaryPi0GG_InvMass_Pt", "ESD_TruePrimaryPi0GG_InvMass_Pt", 800,0,0.8,250,0,25);
1373  fHistoTruePrimaryPi0GGInvMassPt[iCut]->SetXTitle("M_{inv,prim #pi^{0}} (GeV/c^{2})");
1374  fHistoTruePrimaryPi0GGInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1375  fHistoTruePrimaryPi0GGInvMassPt[iCut]->Sumw2();
1376  fTrueList[iCut]->Add(fHistoTruePrimaryPi0GGInvMassPt[iCut]);
1377 
1378 
1379  fHistoTruePrimaryEtaInvMassPt[iCut] = new TH2F("ESD_TruePrimaryEta_InvMass_Pt", "ESD_TruePrimaryEta_InvMass_Pt", 800,0,0.8,250,0,25);
1380  fHistoTruePrimaryEtaInvMassPt[iCut]->SetXTitle("M_{inv,prim #eta} (GeV/c^{2})");
1381  fHistoTruePrimaryEtaInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1382  fHistoTruePrimaryEtaInvMassPt[iCut]->Sumw2();
1383  fTrueList[iCut]->Add(fHistoTruePrimaryEtaInvMassPt[iCut]);
1384 
1385  fHistoTruePrimaryEtaGGInvMassPt[iCut] = new TH2F("ESD_TruePrimaryEtaGG_InvMass_Pt", "ESD_TruePrimaryEtaGG_InvMass_Pt", 800,0,0.8,250,0,25);
1386  fHistoTruePrimaryEtaGGInvMassPt[iCut]->SetXTitle("M_{inv,prim #eta} (GeV/c^{2})");
1387  fHistoTruePrimaryEtaGGInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1388  fHistoTruePrimaryEtaGGInvMassPt[iCut]->Sumw2();
1389  fTrueList[iCut]->Add(fHistoTruePrimaryEtaGGInvMassPt[iCut]);
1390 
1391 
1392  fHistoTruePrimaryPi0W0WeightingInvMassPt[iCut] = new TH2F("ESD_TruePrimaryPi0W0Weights_InvMass_Pt", "ESD_TruePrimaryPi0W0Weights_InvMass_Pt", 800,0,0.8,250,0,25);
1393  fHistoTruePrimaryPi0W0WeightingInvMassPt[iCut]->SetXTitle("M_{inv,prim #pi^{0}} (GeV/c^{2})");
1394  fHistoTruePrimaryPi0W0WeightingInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1396 
1397  fHistoTruePrimaryEtaW0WeightingInvMassPt[iCut] = new TH2F("ESD_TruePrimaryEtaW0Weights_InvMass_Pt", "ESD_TruePrimaryEtaW0Weights_InvMass_Pt", 800,0,0.8,250,0,25);
1398  fHistoTruePrimaryEtaW0WeightingInvMassPt[iCut]->SetXTitle("M_{inv,prim #eta} (GeV/c^{2})");
1399  fHistoTruePrimaryEtaW0WeightingInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1401 
1402  fProfileTruePrimaryPi0WeightsInvMassPt[iCut] = new TProfile2D("ESD_TruePrimaryPi0Weights_InvMass_Pt", "ESD_TruePrimaryPi0Weights_InvMass_Pt", 800,0,0.8,250,0,25);
1403  fProfileTruePrimaryPi0WeightsInvMassPt[iCut]->SetXTitle("M_{inv,prim #pi^{0}} (GeV/c^{2})");
1404  fProfileTruePrimaryPi0WeightsInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1407  fProfileTruePrimaryEtaWeightsInvMassPt[iCut] = new TProfile2D("ESD_TruePrimaryEtaWeights_InvMass_Pt", "ESD_TruePrimaryEtaWeights_InvMass_Pt", 800,0,0.8,250,0,25);
1408  fProfileTruePrimaryEtaWeightsInvMassPt[iCut]->SetXTitle("M_{inv,prim #eta} (GeV/c^{2})");
1409  fProfileTruePrimaryEtaWeightsInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1412 
1413  fHistoTrueSecondaryPi0InvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0_InvMass_Pt", "ESD_TrueSecondaryPi0_InvMass_Pt", 800,0,0.8,250,0,25);
1414  fHistoTrueSecondaryPi0InvMassPt[iCut]->SetXTitle("M_{inv,sec #pi^{0}} (GeV/c^{2})");
1415  fHistoTrueSecondaryPi0InvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1416  fHistoTrueSecondaryPi0InvMassPt[iCut]->Sumw2();
1417  fTrueList[iCut]->Add(fHistoTrueSecondaryPi0InvMassPt[iCut]);
1418 
1419 
1420  fHistoTrueSecondaryPi0GGInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0GG_InvMass_Pt", "ESD_TrueSecondaryPi0GG_InvMass_Pt", 800,0,0.8,250,0,25);
1421  fHistoTrueSecondaryPi0GGInvMassPt[iCut]->SetXTitle("M_{inv,sec #pi^{0}} (GeV/c^{2})");
1422  fHistoTrueSecondaryPi0GGInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1423  fHistoTrueSecondaryPi0GGInvMassPt[iCut]->Sumw2();
1424  fTrueList[iCut]->Add(fHistoTrueSecondaryPi0GGInvMassPt[iCut]);
1425 
1426 
1427 
1428 
1429  fHistoTrueSecondaryPi0FromK0sInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0FromK0s_InvMass_Pt","ESD_TrueSecondaryPi0FromK0s_InvMass_Pt",800,0,0.8,250,0,25);
1430  fHistoTrueSecondaryPi0FromK0sInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0} from K^{0}_{S}} (GeV/c^{2})");
1431  fHistoTrueSecondaryPi0FromK0sInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1434  fHistoTrueSecondaryPi0FromEtaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0FromEta_InvMass_Pt","ESD_TrueSecondaryPi0FromEta_InvMass_Pt",800,0,0.8,250,0,25);
1435  fHistoTrueSecondaryPi0FromEtaInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0} from #eta} (GeV/c^{2})");
1436  fHistoTrueSecondaryPi0FromEtaInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1438  fHistoTrueSecondaryPi0FromLambdaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryPi0FromLambda_InvMass_Pt","ESD_TrueSecondaryPi0FromLambda_InvMass_Pt",800,0,0.8,250,0,25);
1439  fHistoTrueSecondaryPi0FromLambdaInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0} from #Lambda} (GeV/c^{2})");
1440  fHistoTrueSecondaryPi0FromLambdaInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1442 
1443  fHistoTruePrimaryPi0PhotonPairPtconv[iCut] = new TH2F("ESD_TruePrimaryPi0_InvMass_PtConv","",800,0,0.8,250,0,25);
1444  fHistoTruePrimaryPi0PhotonPairPtconv[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2})");
1445  fHistoTruePrimaryPi0PhotonPairPtconv[iCut]->SetYTitle("#gamma^{conv} p_{T} (GeV/c)");
1446  fHistoTruePrimaryPi0PhotonPairPtconv[iCut]->Sumw2();
1448 
1449  fHistoTrueSecondaryPi0PhotonPairPtconv[iCut] = new TH2F("ESD_TrueSecondaryPi0_InvMass_PtConv","",800,0,0.8,250,0,25);
1450  fHistoTrueSecondaryPi0PhotonPairPtconv[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2})");
1451  fHistoTrueSecondaryPi0PhotonPairPtconv[iCut]->SetYTitle("#gamma^{conv} p_{T} (GeV/c)");
1454 
1455  fHistoTruePrimaryEtaPhotonPairPtconv[iCut] = new TH2F("ESD_TruePrimaryEta_InvMass_PtConv","",800,0,0.8,250,0,25);
1456  fHistoTruePrimaryEtaPhotonPairPtconv[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2})");
1457  fHistoTruePrimaryEtaPhotonPairPtconv[iCut]->SetYTitle("#gamma^{conv} p_{T} (GeV/c)");
1458  fHistoTruePrimaryEtaPhotonPairPtconv[iCut]->Sumw2();
1460 
1461  fHistoTruePrimaryPi0DCPtconv[iCut] = new TH1F("ESD_TruePrimaryPi0DC_PtConv","",250,0,25);
1462  fHistoTruePrimaryPi0DCPtconv[iCut]->SetXTitle("#gamma^{conv} p_{T} (GeV/c)");
1463  fHistoTruePrimaryPi0DCPtconv[iCut]->Sumw2();
1464  fTrueList[iCut]->Add(fHistoTruePrimaryPi0DCPtconv[iCut]);
1465 
1466  fHistoTrueSecondaryPi0DCPtconv[iCut] = new TH1F("ESD_TrueSecondaryPi0DC_PtConv","",250,0,25);
1467  fHistoTrueSecondaryPi0DCPtconv[iCut]->SetXTitle("#gamma^{conv} p_{T} (GeV/c)");
1468  fHistoTrueSecondaryPi0DCPtconv[iCut]->Sumw2();
1469  fTrueList[iCut]->Add(fHistoTrueSecondaryPi0DCPtconv[iCut]);
1470 
1471  fHistoTruePrimaryEtaDCPtconv[iCut] = new TH1F("ESD_TruePrimaryEtaDC_PtConv","",250,0,25);
1472  fHistoTruePrimaryEtaDCPtconv[iCut]->SetXTitle("#gamma^{conv} p_{T} (GeV/c)");
1473  fHistoTruePrimaryEtaDCPtconv[iCut]->Sumw2();
1474  fTrueList[iCut]->Add(fHistoTruePrimaryEtaDCPtconv[iCut]);
1475 
1476  fHistoTruePrimaryPi0MissingPtconv[iCut] = new TH1F("ESD_TruePrimaryPi0Missing_PtConv","",250,0,25);
1477  fHistoTruePrimaryPi0MissingPtconv[iCut]->SetXTitle("#gamma^{conv} p_{T} (GeV/c)");
1478  fHistoTruePrimaryPi0MissingPtconv[iCut]->Sumw2();
1479  fTrueList[iCut]->Add(fHistoTruePrimaryPi0MissingPtconv[iCut]);
1480 
1481  fHistoTrueSecondaryPi0MissingPtconv[iCut] = new TH1F("ESD_TrueSecondaryPi0Missing_PtConv","",250,0,25);
1482  fHistoTrueSecondaryPi0MissingPtconv[iCut]->SetXTitle("#gamma^{conv} p_{T} (GeV/c)");
1483  fHistoTrueSecondaryPi0MissingPtconv[iCut]->Sumw2();
1485 
1486  fHistoTruePrimaryEtaMissingPtconv[iCut] = new TH1F("ESD_TruePrimaryEtaMissing_PtConv","",250,0,25);
1487  fHistoTruePrimaryEtaMissingPtconv[iCut]->SetXTitle("#gamma^{conv} p_{T} (GeV/c)");
1488  fHistoTruePrimaryEtaMissingPtconv[iCut]->Sumw2();
1489  fTrueList[iCut]->Add(fHistoTruePrimaryEtaMissingPtconv[iCut]);
1490 
1491 
1492  if (fDoMesonQA > 0){
1493  fHistoTruePi0CaloPhotonInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloPhoton_InvMass_Pt","ESD_TruePi0CaloPhoton_InvMass_Pt",800,0,0.8,250,0,25);
1494  fHistoTruePi0CaloPhotonInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2}) #gamma #gamma");
1495  fHistoTruePi0CaloPhotonInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1496  fTrueList[iCut]->Add(fHistoTruePi0CaloPhotonInvMassPt[iCut]);
1497 
1498  fHistoTrueEtaCaloPhotonInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloPhoton_InvMass_Pt","ESD_TrueEtaCaloPhoton_InvMass_Pt",800,0,0.8,250,0,25);
1499  fHistoTrueEtaCaloPhotonInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2}) #gamma #gamma");
1500  fHistoTrueEtaCaloPhotonInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1501  fTrueList[iCut]->Add(fHistoTrueEtaCaloPhotonInvMassPt[iCut]);
1502 
1503  fHistoTruePi0CaloConvertedPhotonInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloConvertedPhoton_InvMass_Pt","ESD_TruePi0CaloConvertedPhoton_InvMass_Pt",800,0,0.8,250,0,25);
1504  fHistoTruePi0CaloConvertedPhotonInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2}) #gamma #gamma_{conv}");
1505  fHistoTruePi0CaloConvertedPhotonInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1507 
1508  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloConvertedPhotonMatched_InvMass_Pt","ESD_TruePi0CaloConvertedPhotonMatched_InvMass_Pt",800,0,0.8,250,0,25);
1509  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2}) #gamma #gamma_{conv,matched}");
1510  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1512 
1513  fHistoTrueEtaCaloConvertedPhotonInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloConvertedPhoton_InvMass_Pt","ESD_TrueEtaCaloConvertedPhoton_InvMass_Pt",800,0,0.8,250,0,25);
1514  fHistoTrueEtaCaloConvertedPhotonInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2}) #gamma #gamma_{conv}");
1515  fHistoTrueEtaCaloConvertedPhotonInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1517 
1518  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloConvertedPhotonMatched_InvMass_Pt","ESD_TrueEtaCaloConvertedPhotonMatched_InvMass_Pt",800,0,0.8,250,0,25);
1519  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2}) #gamma #gamma_{conv,matched}");
1520  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1522 
1523  fHistoTruePi0CaloElectronInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloElectron_InvMass_Pt","ESD_TruePi0CaloElectron_InvMass_Pt",800,0,0.8,250,0,25);
1524  fHistoTruePi0CaloElectronInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2}) #gamma e^{#pm}");
1525  fHistoTruePi0CaloElectronInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1527  fHistoTrueEtaCaloElectronInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloElectron_InvMass_Pt","ESD_TrueEtaCaloElectron_InvMass_Pt",800,0,0.8,250,0,25);
1528  fHistoTrueEtaCaloElectronInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2}) #gamma e^{#pm}");
1529  fHistoTrueEtaCaloElectronInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1531 
1532  fHistoTruePi0CaloMergedClusterInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloMergedCluster_InvMass_Pt","ESD_TruePi0CaloMergedCluster_InvMass_Pt",800,0,0.8,250,0,25);
1533  fHistoTruePi0CaloMergedClusterInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2}) #gamma merged cluster");
1534  fHistoTruePi0CaloMergedClusterInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1536  fHistoTrueEtaCaloMergedClusterInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloMergedCluster_InvMass_Pt","ESD_TrueEtaCaloMergedCluster_InvMass_Pt",800,0,0.8,250,0,25);
1537  fHistoTrueEtaCaloMergedClusterInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2}) #gamma merged cluster");
1538  fHistoTrueEtaCaloMergedClusterInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1540 
1541  fHistoTrueMotherCaloEMNonLeadingInvMassPt[iCut] = new TH2F("ESD_TrueMotherCaloEMNonLeading_InvMass_Pt","ESD_TrueMotherCaloEMNonLeading_InvMass_Pt",800,0,0.8,250,0,25);
1542  fHistoTrueMotherCaloEMNonLeadingInvMassPt[iCut]->SetXTitle("M_{inv} (GeV/c^{2}) #gamma cluster no leading EM");
1543  fHistoTrueMotherCaloEMNonLeadingInvMassPt[iCut]->SetYTitle("#pair p_{T} (GeV/c)");
1545  fHistoTruePi0CaloMergedClusterPartConvInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloMergedClusterPartConv_InvMass_Pt","ESD_TruePi0CaloMergedClusterPartConv_InvMass_Pt",800,0,0.8,250,0,25);
1546  fHistoTruePi0CaloMergedClusterPartConvInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2}) #gamma merged cluster, part conv");
1547  fHistoTruePi0CaloMergedClusterPartConvInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1549  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloMergedClusterPartConv_InvMass_Pt","ESD_TrueEtaCaloMergedClusterPartConv_InvMass_Pt",800,0,0.8,250,0,25);
1550  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2}) #gamma merged cluster, part conv");
1551  fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1553 
1554  fHistoTruePrimaryPi0MCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryPi0_MCPt_ResolPt","ESD_TruePrimaryPi0_ResolPt_MCPt",500,0.03,25,1000,-1.,1.);
1555  fHistoTruePrimaryPi0MCPtResolPt[iCut]->SetXTitle("#pi^{0} p_{T,MC} (GeV/c)");
1556  fHistoTruePrimaryPi0MCPtResolPt[iCut]->SetYTitle("#pi^{0} (p_{T,rec}-p_{T,MC})/p_{T,MC} ()");
1557  fHistoTruePrimaryPi0MCPtResolPt[iCut]->Sumw2();
1559  fTrueList[iCut]->Add(fHistoTruePrimaryPi0MCPtResolPt[iCut]);
1560 
1561  fHistoTruePrimaryEtaMCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryEta_MCPt_ResolPt","ESD_TruePrimaryEta_ResolPt_MCPt",500,0.03,25,1000,-1.,1.);
1562  fHistoTruePrimaryEtaMCPtResolPt[iCut]->SetXTitle("#eta p_{T,MC} (GeV/c)");
1563  fHistoTruePrimaryEtaMCPtResolPt[iCut]->SetYTitle("#eta (p_{T,rec}-p_{T,MC})/p_{T,MC} ()");
1564  fHistoTruePrimaryEtaMCPtResolPt[iCut]->Sumw2();
1566  fTrueList[iCut]->Add(fHistoTruePrimaryEtaMCPtResolPt[iCut]);
1567 
1568  fHistoTrueBckGGInvMassPt[iCut] = new TH2F("ESD_TrueBckGG_InvMass_Pt","ESD_TrueBckGG_InvMass_Pt",800,0,0.8,250,0,25);
1569  fHistoTrueBckGGInvMassPt[iCut]->SetXTitle("M_{inv} (GeV/c^{2}) #gamma #gamma no signal");
1570  fHistoTrueBckGGInvMassPt[iCut]->SetYTitle("#pair p_{T} (GeV/c)");
1571  fTrueList[iCut]->Add(fHistoTrueBckGGInvMassPt[iCut]);
1572  fHistoTrueBckContInvMassPt[iCut] = new TH2F("ESD_TrueBckCont_InvMass_Pt","ESD_TrueBckCont_InvMass_Pt",800,0,0.8,250,0,25);
1573  fHistoTrueBckContInvMassPt[iCut]->SetXTitle("M_{inv} (GeV/c^{2}) contamination");
1574  fHistoTrueBckContInvMassPt[iCut]->SetYTitle("#pair p_{T} (GeV/c)");
1575  fTrueList[iCut]->Add(fHistoTrueBckContInvMassPt[iCut]);
1576  fHistoTrueK0sWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueK0sWithPi0Daughter_MCPt","ESD_TrueK0sWithPi0Daughter_MCPt",250,0,25);
1577  fHistoTrueK0sWithPi0DaughterMCPt[iCut]->SetXTitle("K^{0}_{s} p_{MC,T} (GeV/c) for K^{0}_{s} where #pi^{0} rec ");
1578  fTrueList[iCut]->Add(fHistoTrueK0sWithPi0DaughterMCPt[iCut]);
1579  fHistoTrueEtaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueEtaWithPi0Daughter_MCPt","ESD_TrueEtaWithPi0Daughter_MCPt",250,0,25);
1580  fHistoTrueEtaWithPi0DaughterMCPt[iCut]->SetXTitle("#eta p_{MC,T} (GeV/c) for #eta where #pi^{0} rec ");
1581  fTrueList[iCut]->Add(fHistoTrueEtaWithPi0DaughterMCPt[iCut]);
1582  fHistoTrueLambdaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueLambdaWithPi0Daughter_MCPt","ESD_TrueLambdaWithPi0Daughter_MCPt",250,0,25);
1583  fHistoTrueLambdaWithPi0DaughterMCPt[iCut]->SetXTitle("#Lambda p_{MC,T} (GeV/c) for #Lambda where #pi^{0} rec ");
1585 
1586  fHistoTruePi0PtY[iCut] = new TH2F("ESD_TruePi0_Pt_Y","ESD_TruePi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1587  fHistoTruePi0PtY[iCut]->SetYTitle("Y_{#pi^{0}}");
1588  fHistoTruePi0PtY[iCut]->SetXTitle("#pi^{0} p_{T} (GeV/c)");
1590  fTrueList[iCut]->Add(fHistoTruePi0PtY[iCut]);
1591  fHistoTrueEtaPtY[iCut] = new TH2F("ESD_TrueEta_Pt_Y","ESD_TrueEta_Pt_Y",150,0.03,15.,150,-1.5,1.5);
1592  fHistoTrueEtaPtY[iCut]->SetYTitle("Y_{#eta}");
1593  fHistoTrueEtaPtY[iCut]->SetXTitle("#eta p_{T} (GeV/c)");
1595  fTrueList[iCut]->Add(fHistoTrueEtaPtY[iCut]);
1596  fHistoTruePi0PtAlpha[iCut] = new TH2F("ESD_TruePi0_Pt_Alpha","ESD_TruePi0_Pt_Alpha",150,0.03,15.,100,0,1);
1597  fHistoTruePi0PtAlpha[iCut]->SetYTitle("#alpha_{#pi^{0}}");
1598  fHistoTruePi0PtAlpha[iCut]->SetXTitle("#pi^{0} p_{T} (GeV/c)");
1600  fTrueList[iCut]->Add(fHistoTruePi0PtAlpha[iCut]);
1601  fHistoTrueEtaPtAlpha[iCut] = new TH2F("ESD_TrueEta_Pt_Alpha","ESD_TrueEta_Pt_Alpha",150,0.03,15.,100,0,1);
1602  fHistoTrueEtaPtAlpha[iCut]->SetYTitle("#alpha_{#eta}");
1603  fHistoTrueEtaPtAlpha[iCut]->SetXTitle("#eta p_{T} (GeV/c)");
1605  fTrueList[iCut]->Add(fHistoTrueEtaPtAlpha[iCut]);
1606 
1607  fHistoTruePi0PtOpenAngle[iCut] = new TH2F("ESD_TruePi0_Pt_OpenAngle","ESD_TruePi0_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());
1608  fHistoTruePi0PtOpenAngle[iCut]->SetYTitle("#theta_{#pi^{0}}");
1609  fHistoTruePi0PtOpenAngle[iCut]->SetXTitle("#pi^{0} p_{T} (GeV/c)");
1611  fTrueList[iCut]->Add(fHistoTruePi0PtOpenAngle[iCut]);
1612  fHistoTrueEtaPtOpenAngle[iCut] = new TH2F("ESD_TrueEta_Pt_OpenAngle","ESD_TrueEta_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());
1613  fHistoTrueEtaPtOpenAngle[iCut]->SetYTitle("#theta_{#eta}");
1614  fHistoTrueEtaPtOpenAngle[iCut]->SetXTitle("#eta p_{T} (GeV/c)");
1616  fTrueList[iCut]->Add(fHistoTrueEtaPtOpenAngle[iCut]);
1617 
1618  fHistoTrueMotherPi0ConvPhotonEtaPhi[iCut] = new TH2F("ESD_TrueMotherPi0ConvPhoton_Eta_Phi","conv photons for true #pi^{0}",600,0,2*TMath::Pi(),200,-1,1);
1619  fHistoTrueMotherPi0ConvPhotonEtaPhi[iCut]->SetXTitle("#phi_{#gamma_{conv}} (rad)");
1620  fHistoTrueMotherPi0ConvPhotonEtaPhi[iCut]->SetYTitle("#eta_{#gamma_{conv}}");
1622  fHistoTrueMotherEtaConvPhotonEtaPhi[iCut] = new TH2F("ESD_TrueMotherEtaConvPhoton_Eta_Phi","conv photons for true #eta",600,0,2*TMath::Pi(),200,-1,1);
1623  fHistoTrueMotherEtaConvPhotonEtaPhi[iCut]->SetXTitle("#phi_{#gamma_{conv}} (rad)");
1624  fHistoTrueMotherEtaConvPhotonEtaPhi[iCut]->SetYTitle("#eta_{#gamma_{conv}}");
1626 
1627 
1628  fHistoTruePi0ShowerInvMassPt[iCut] = new TH2F("ESD_TruePi0Shower_InvMass_Pt","ESD_TruePi0Shower_InvMass_Pt",800,0,0.8,250,0,25);
1629  fHistoTruePi0ShowerInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2})");
1630  fHistoTruePi0ShowerInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1631  fTrueList[iCut]->Add(fHistoTruePi0ShowerInvMassPt[iCut]);
1632 
1633  fHistoTrueEtaShowerInvMassPt[iCut] = new TH2F("ESD_TrueEtaShower_InvMass_Pt","ESD_TrueEtaShower_InvMass_Pt",800,0,0.8,250,0,25);
1634  fHistoTrueEtaShowerInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2})");
1635  fHistoTrueEtaShowerInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1636  fTrueList[iCut]->Add(fHistoTrueEtaShowerInvMassPt[iCut]);
1637 
1638  fHistoTruePi0NoShowerInvMassPt[iCut] = new TH2F("ESD_TruePi0NoShower_InvMass_Pt","ESD_TruePi0NoShower_InvMass_Pt",800,0,0.8,250,0,25);
1639  fHistoTruePi0NoShowerInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}} (GeV/c^{2})");
1640  fHistoTruePi0NoShowerInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T} (GeV/c)");
1641  fTrueList[iCut]->Add(fHistoTruePi0NoShowerInvMassPt[iCut]);
1642 
1643  fHistoTrueEtaNoShowerInvMassPt[iCut] = new TH2F("ESD_TrueEtaNoShower_InvMass_Pt","ESD_TrueEtaNoShower_InvMass_Pt",800,0,0.8,250,0,25);
1644  fHistoTrueEtaNoShowerInvMassPt[iCut]->SetXTitle("M_{inv,#eta} (GeV/c^{2})");
1645  fHistoTrueEtaNoShowerInvMassPt[iCut]->SetYTitle("#eta p_{T} (GeV/c)");
1646  fTrueList[iCut]->Add(fHistoTrueEtaNoShowerInvMassPt[iCut]);
1647 
1648  fHistoTruePi0OpeningAngleGammaElectron[iCut] = new TH1F("ESD_TruePi0_OpeningAngle_GammaElectron", "ESD_TruePi0_OpeningAngle_GammaElectron",100,0.,TMath::Pi());
1650 
1651 
1652 
1653  }
1654  }
1655  }
1656  }
1657 
1661 
1662  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
1663  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
1664 
1665  if(fV0Reader)
1667  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
1668  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
1669  if(fV0Reader)
1671  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms())
1672  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
1673 
1674  for(Int_t iMatcherTask = 0; iMatcherTask < 3; iMatcherTask++){
1675  AliCaloTrackMatcher* temp = (AliCaloTrackMatcher*) (AliAnalysisManager::GetAnalysisManager()->GetTask(Form("CaloTrackMatcher_%i",iMatcherTask)));
1676  if(temp) fOutputContainer->Add(temp->GetCaloTrackMatcherHistograms());
1677  }
1678 
1679  fElecSelector=(AliDalitzElectronSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("ElectronSelector");
1680  if(!fElecSelector){printf("Error: No ElectronSelector");return;} // GetV0Reader
1681 
1682  if( fElecSelector ){
1683  if ( ((AliDalitzElectronCuts*)fElecSelector->GetDalitzElectronCuts())->GetCutHistograms() ){
1685  }
1686  }
1687 
1688 
1689  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1690 
1691  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))) continue;
1692  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms()){
1693  fCutFolder[iCut]->Add(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
1694  }
1695  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))) continue;
1696  if(((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutHistograms()){
1697  fCutFolder[iCut]->Add(((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutHistograms());
1698  }
1699  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
1700  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms()){
1701  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms());
1702  }
1703  if(!((AliDalitzElectronCuts*)fElectronCutArray->At(iCut))) continue;
1704  if( ((AliDalitzElectronCuts*)fElectronCutArray->At(iCut))->GetCutHistograms() ) {
1705  fCutFolder[iCut]->Add( ((AliDalitzElectronCuts*)fElectronCutArray->At(iCut))->GetCutHistograms() );
1706  }
1707 
1708  if(fDoMesonAnalysis){
1709  if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
1710  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
1711  fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
1712  }
1713  }
1714 
1715  }
1716  PostData(1, fOutputContainer);
1717 }
1718 //_____________________________________________________________________________
1720 {
1721  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1722  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
1723  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
1724  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
1725  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
1726  }
1727 
1728  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift()){
1729  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1730  continue; // No Eta Shift requested, continue
1731  }
1732  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
1733  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
1734  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1735  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1736  continue;
1737  }
1738  else{
1739  printf(" Gamma Conversion Task %s :: Eta Shift Manually Set to %f \n\n",
1740  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
1741  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1742  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1743  }
1744  }
1745 
1746  return kTRUE;
1747 }
1748 //_____________________________________________________________________________
1750 {
1751  //
1752  // Called for each event
1753  //
1754 
1755  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
1756  if(eventQuality == 2 || eventQuality == 3){// Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1
1757 
1758  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1759  fHistoNEvents[iCut]->Fill(eventQuality);
1760  }
1761  return;
1762  }
1763 
1764  if(fIsMC) fMCEvent = MCEvent();
1765 
1766  fInputEvent = InputEvent();
1767 
1768  if(fInputEvent->IsA()==AliAODEvent::Class()){
1769  fInputEvent->InitMagneticField();
1770  }
1771 
1772  fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
1773  fSelectorElectronIndex = fElecSelector->GetReconstructedElectronsIndex(); // Electrons from default Cut
1774  fSelectorPositronIndex = fElecSelector->GetReconstructedPositronsIndex(); // Positrons from default Cut
1775 
1776 
1777 
1778  // ------------------- BeginEvent ----------------------------
1779 
1780  AliEventplane *EventPlane = fInputEvent->GetEventplane();
1781  if(fIsHeavyIon ==1)fEventPlaneAngle = EventPlane->GetEventplane("V0",fInputEvent,2);
1782  else fEventPlaneAngle=0.0;
1783 
1784  if(fIsMC && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
1785  RelabelAODPhotonCandidates(kTRUE); // In case of AODMC relabeling MC
1786  fV0Reader->RelabelAODs(kTRUE);
1787  }
1788 
1789 
1790  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1791 
1792  fiCut = iCut;
1793 
1794  Bool_t isRunningEMCALrelAna = kFALSE;
1795 
1796  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetClusterType() == 1) isRunningEMCALrelAna = kTRUE;
1797 
1798  Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon,isRunningEMCALrelAna);
1799 
1800  if(eventNotAccepted){
1801  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
1802  fHistoNEvents[iCut]->Fill(eventNotAccepted); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
1803  continue;
1804  }
1805 
1806  if(eventQuality != 0){// Event Not Accepted
1807  //cout << "event rejected due to: " <<eventQuality << endl;
1808  fHistoNEvents[iCut]->Fill(eventQuality);
1809  continue;
1810  }
1811 
1812  fHistoNEvents[iCut]->Fill(eventQuality); // Should be 0 here
1814  fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)));
1815 
1816  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2) fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A());
1817  else fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C());
1818 
1819  if(fIsMC){
1820 
1821 
1822  // Process MC Particle
1823  fStringRecTruePi0s[iCut] = "";
1824  fStringRecTrueEtas[iCut] = "";
1825 
1826  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
1827  if(fInputEvent->IsA()==AliESDEvent::Class()){
1828 
1829  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1830  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1831  fMCEvent);
1832  }
1833  else if(fInputEvent->IsA()==AliAODEvent::Class()){
1834  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1835  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1836  fInputEvent);
1837  }
1838 
1839  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader()){
1840  for(Int_t i = 0;i<(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader())->GetEntries();i++){
1841  TString nameBin= fHistoMCHeaders[iCut]->GetXaxis()->GetBinLabel(i+1);
1842  if (nameBin.CompareTo("")== 0){
1843  TString nameHeader = ((TObjString*)((TList*)((AliConvEventCuts*)fEventCutArray->At(iCut))
1844  ->GetAcceptedHeader())->At(i))->GetString();
1845  fHistoMCHeaders[iCut]->GetXaxis()->SetBinLabel(i+1,nameHeader.Data());
1846  }
1847  }
1848  }
1849  }
1850 
1851  if(fInputEvent->IsA()==AliESDEvent::Class())
1853  if(fInputEvent->IsA()==AliAODEvent::Class())
1855 
1856  }
1857 
1858 
1859  // it is in the loop to have the same conversion cut string (used also for MC stuff that should be same for V0 and Cluster)
1860  ProcessClusters(); // process calo clusters
1861  ProcessPhotonCandidates(); // Process this cuts gammas
1863 
1864  fHistoNGammaCandidates[iCut]->Fill(fClusterCandidates->GetEntries());
1866 
1867  if(fDoMesonAnalysis){ // Meson Analysis
1868  CalculatePi0DalitzCandidates(); //Combine gamma candidates
1869 
1870  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
1871 
1872  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
1873  CalculateBackground(); // Combinatorial Background
1874  UpdateEventByEventData(); // Store Event for mixed Events
1875  }
1876 
1877  }
1878 
1879  if(fIsMC && fInputEvent->IsA()==AliAODEvent::Class()){
1880  ProcessConversionPhotonsForMissingTagsAOD(); //Count missing tags
1881  } else if (fIsMC && fInputEvent->IsA()==AliESDEvent::Class()){
1882  ProcessConversionPhotonsForMissingTags(); //Count missing tags
1883  }
1886  }
1887 
1889 
1890  fGammaCandidates->Clear(); // delete this cuts good gammas
1891  fClusterCandidates->Clear(); // delete cluster candidates
1892  fVirtualGammaCandidates->Clear(); // delete this cuts good virtual gammas
1893  }
1894 
1895  if(fIsMC && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
1896  RelabelAODPhotonCandidates(kFALSE); // Back to ESDMC Label
1897  fV0Reader->RelabelAODs(kFALSE);
1898  }
1899 
1900  fSelectorElectronIndex.clear();
1901  fSelectorPositronIndex.clear();
1902 
1903  PostData(1, fOutputContainer);
1904 }
1905 
1906 //________________________________________________________________________
1908 {
1909 
1910  Int_t nclus = 0;
1911  nclus = fInputEvent->GetNumberOfCaloClusters();
1912 
1913 
1914  if(nclus == 0) return;
1915 
1916 
1917  // vertex
1918  Double_t vertex[3] = {0};
1919  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1920 
1921 
1922  // Loop over EMCal clusters
1923  for(Long_t i = 0; i < nclus; i++){
1924 
1925  AliVCluster* clus = NULL;
1926  if(fInputEvent->IsA()==AliESDEvent::Class()) clus = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(i));
1927  else if(fInputEvent->IsA()==AliAODEvent::Class()) clus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i));
1928 
1929  if ( !clus ) continue;
1930  if ( !((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC,1.,i) ){ delete clus; continue;}
1931 
1932  // TLorentzvector with cluster
1933  TLorentzVector clusterVector;
1934  clus->GetMomentum(clusterVector,vertex);
1935 
1936  TLorentzVector* tmpvec = new TLorentzVector();
1937  tmpvec->SetPxPyPzE(clusterVector.Px(),clusterVector.Py(),clusterVector.Pz(),clusterVector.E());
1938 
1939  // convert to AODConversionPhoton
1940  AliAODConversionPhoton *PhotonCandidate=new AliAODConversionPhoton(tmpvec);
1941  if(!PhotonCandidate){ delete clus; delete tmpvec; continue;}
1942 
1943  // Flag Photon as CaloPhoton
1944  PhotonCandidate->SetIsCaloPhoton();
1945  PhotonCandidate->SetCaloClusterRef(i);
1946  // get MC label
1947  if(fIsMC){
1948  Int_t* mclabelsCluster = clus->GetLabels();
1949  PhotonCandidate->SetNCaloPhotonMCLabels(clus->GetNLabels());
1950 // cout << clus->GetNLabels() << endl;
1951  if (clus->GetNLabels()>0){
1952  for (Int_t k =0; k< (Int_t)clus->GetNLabels(); k++){
1953  if (k< 50)PhotonCandidate->SetCaloPhotonMCLabel(k,mclabelsCluster[k]);
1954 // Int_t pdgCode = fMCEvent->Particle(mclabelsCluster[k])->GetPdgCode();
1955 // cout << "label " << k << "\t" << mclabelsCluster[k] << " pdg code: " << pdgCode << endl;
1956  }
1957  }
1958  }
1959 
1960  fIsFromMBHeader = kTRUE;
1962  // test whether largest contribution to cluster orginates in added signals
1963 
1964  if ( fIsMC && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() > 0 ){
1965 
1966  if ( ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetCaloPhotonMCLabel(0), fMCEvent, fInputEvent) == 0 ) fIsFromMBHeader = kFALSE;
1967 
1968 
1969  if (clus->GetNLabels()>1){
1970  Int_t* mclabelsCluster = clus->GetLabels();
1971  for (Int_t l = 1; l < (Int_t)clus->GetNLabels(); l++ ){
1972  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(mclabelsCluster[l], fMCEvent, fInputEvent) == 0) fIsOverlappingWithOtherHeader = kTRUE;
1973  }
1974  }
1975  }
1976 
1977  if(fIsMC){
1978  if(fInputEvent->IsA()==AliESDEvent::Class()){
1979  ProcessTrueClusterCandidates(PhotonCandidate);
1980  } else {
1981  ProcessTrueClusterCandidatesAOD(PhotonCandidate);
1982  }
1983  }
1984 
1987  fHistoClusGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
1988  fClusterCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
1989  } else{
1990  delete PhotonCandidate;
1991  }
1992 
1993  delete clus;
1994  delete tmpvec;
1995  }
1996 
1997 }
1998 
1999 //________________________________________________________________________
2001 {
2002 
2003  TParticle *Photon = NULL;
2004  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
2005  fHistoTrueNLabelsInClus[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels());
2006 
2007  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0)Photon = fMCEvent->Particle(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
2008  else return;
2009 
2010  if(Photon == NULL){
2011  // cout << "no photon" << endl;
2012  return;
2013  }
2014 
2015  TruePhotonCandidate->SetCaloPhotonMCFlags(fMCEvent,kFALSE);
2016 
2017  // True Photon
2019 
2020  if (TruePhotonCandidate->IsLargestComponentPhoton() || TruePhotonCandidate->IsLargestComponentElectron() ) {
2021 
2022  fHistoTrueClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2023 
2024 
2025 
2026  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2027  Double_t mcProdVtxX = primVtxMC->GetX();
2028  Double_t mcProdVtxY = primVtxMC->GetY();
2029  Double_t mcProdVtxZ = primVtxMC->GetZ();
2030  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, TruePhotonCandidate->GetCaloPhotonMCLabel(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2031 
2032 
2033 
2034  if(isPrimary){
2035 
2036  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
2037 
2038  fHistoTruePrimaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2039  fHistoTruePrimaryClusGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
2040 
2041 
2042  Int_t gammaMotherLabel = -1;
2043 
2044  if (TruePhotonCandidate->IsLargestComponentPhoton()){ // for photons its the direct mother
2045 
2046  gammaMotherLabel=Photon->GetMother(0);
2047 
2048 
2049  } else if ( TruePhotonCandidate->IsLargestComponentElectron() ){ // for electrons its either the direct mother or for conversions the grandmother
2050 
2051  if (TruePhotonCandidate->IsConversion()) gammaMotherLabel=fMCEvent->Particle(Photon->GetMother(0))->GetMother(0);
2052  else gammaMotherLabel=Photon->GetMother(0);
2053 
2054  }
2055 
2056  if( gammaMotherLabel > -1 ){
2057 
2058  Int_t motherFromShower = -1;
2059 
2060 
2061  TParticle* motherGamma = fMCEvent->Particle( gammaMotherLabel );
2062 
2063  //if( IsDalitz ( motherGamma ) == kTRUE ){
2064  if( motherGamma->GetPdgCode() == 111 ) {
2065 
2066  if( IsDalitz( motherGamma ) == kTRUE ){
2067 
2068  fHistoTruePi0DalitzClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2069  fHistoTruePi0DalitzClusGammaMCPt[fiCut]->Fill(Photon->Pt());
2070  }
2071 
2072 
2073  } else if ( ( motherFromShower = FindMotherOfPhoton( gammaMotherLabel ) ) > -1 ){
2074 
2075 
2076 
2077 
2078  TParticle* motherGammaShower = fMCEvent->Particle( motherFromShower );
2079 
2080 
2081 
2082 
2083  if( motherGammaShower->GetPdgCode() == 111 ) {
2084  if( IsDalitz ( motherGammaShower ) ) {
2085 
2086  fHistoTruePi0DalitzClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2087  fHistoTruePi0DalitzAllClusGammaPt[fiCut]->Fill( TruePhotonCandidate->Pt() );
2088  fHistoTruePi0DalitzClusGammaMCPt[fiCut]->Fill(Photon->Pt());
2089 
2090 
2091  }
2092 
2093  }
2094  }
2095  }
2096 
2097  }
2098 
2099  }
2100  else fHistoTrueClusEMNonLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2101 
2102 
2103  if (fDoClusterQA > 0){
2104  if (TruePhotonCandidate->IsLargestComponentPhoton()){
2105  fHistoTrueClusUnConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2106  fHistoTrueClusUnConvGammaMCPt[fiCut]->Fill(Photon->Pt());
2107  }
2108  if (TruePhotonCandidate->IsLargestComponentElectron())
2109  fHistoTrueClusElectronPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2110  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2111  fHistoTrueClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2112  fHistoTrueClusConvGammaMCPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(Photon->GetMother(0)))->Pt());
2113  }
2114  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion() && TruePhotonCandidate->IsConversionFullyContained())
2115  fHistoTrueClusConvGammaFullyPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2116  if (TruePhotonCandidate->IsMerged() || TruePhotonCandidate->IsMergedPartConv() || TruePhotonCandidate->IsDalitzMerged())
2117  fHistoTrueClusMergedGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2118  if (TruePhotonCandidate->IsMergedPartConv())
2119  fHistoTrueClusMergedPartConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2120  if (TruePhotonCandidate->IsDalitz())
2121  fHistoTrueClusDalitzPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2122  if (TruePhotonCandidate->IsDalitzMerged())
2123  fHistoTrueClusDalitzMergedPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2124  if (TruePhotonCandidate->IsPhotonWithElecMother())
2125  fHistoTrueClusPhotonFromElecMotherPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2126  if (TruePhotonCandidate->IsShower())
2127  fHistoTrueClusShowerPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2128  if (TruePhotonCandidate->IsSubLeadingEM())
2129  fHistoTrueClusSubLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2130  fHistoTrueClusNParticles[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels());
2131  }
2132  }
2133 
2134 
2135  return;
2136 }
2137 
2138 
2139 //________________________________________________________________________
2141 {
2142  AliAODMCParticle *Photon = NULL;
2143  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2144  if (AODMCTrackArray){
2145  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
2146  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0) Photon = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
2147  else return;
2148  } else {
2149  AliInfo("AODMCTrackArray could not be loaded");
2150  return;
2151  }
2152 
2153  if(Photon == NULL){
2154  // cout << "no photon" << endl;
2155  return;
2156  }
2157  TruePhotonCandidate->SetCaloPhotonMCFlagsAOD(fInputEvent, kFALSE);
2158  fHistoTrueNLabelsInClus[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels());
2159  // True Photon
2161  if (TruePhotonCandidate->IsLargestComponentPhoton() || TruePhotonCandidate->IsLargestComponentElectron() )fHistoTrueClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2162  else fHistoTrueClusEMNonLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2163  if (fDoClusterQA > 0){
2164  if (TruePhotonCandidate->IsLargestComponentPhoton()) {
2165  fHistoTrueClusUnConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2166  fHistoTrueClusUnConvGammaMCPt[fiCut]->Fill(Photon->Pt());
2167  }
2168  if (TruePhotonCandidate->IsLargestComponentElectron())
2169  fHistoTrueClusElectronPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2170  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()) {
2171  fHistoTrueClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2172  AliAODMCParticle *Mother = (AliAODMCParticle*) AODMCTrackArray->At(Photon->GetMother());
2173  fHistoTrueClusConvGammaMCPt[fiCut]->Fill(Mother->Pt());
2174  }
2175  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion() && TruePhotonCandidate->IsConversionFullyContained())
2176  fHistoTrueClusConvGammaFullyPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2177  if (TruePhotonCandidate->IsMerged() || TruePhotonCandidate->IsMergedPartConv() || TruePhotonCandidate->IsDalitzMerged())
2178  fHistoTrueClusMergedGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2179  if (TruePhotonCandidate->IsMergedPartConv())
2180  fHistoTrueClusMergedPartConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2181  if (TruePhotonCandidate->IsDalitz())
2182  fHistoTrueClusDalitzPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2183  if (TruePhotonCandidate->IsDalitzMerged())
2184  fHistoTrueClusDalitzMergedPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2185  if (TruePhotonCandidate->IsPhotonWithElecMother())
2186  fHistoTrueClusPhotonFromElecMotherPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2187  if (TruePhotonCandidate->IsShower())
2188  fHistoTrueClusShowerPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2189  if (TruePhotonCandidate->IsSubLeadingEM())
2190  fHistoTrueClusSubLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2191  fHistoTrueClusNParticles[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels());
2192  }
2193  }
2194 
2195  // True Photon
2196  if(fIsFromMBHeader){
2197  fHistoTrueClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2198  if (fDoPhotonQA > 0) fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta());
2199  }
2200 
2201  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2202  Double_t mcProdVtxX = primVtxMC->GetX();
2203  Double_t mcProdVtxY = primVtxMC->GetY();
2204  Double_t mcProdVtxZ = primVtxMC->GetZ();
2205  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2206 
2207  if(isPrimary){
2208  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
2209  if(fIsFromMBHeader){
2210  fHistoTruePrimaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2211  fHistoTruePrimaryClusGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
2212  }
2213  }
2214 }
2215 
2216 //________________________________________________________________________
2218 {
2219  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2220  Double_t mcProdVtxX = primVtxMC->GetX();
2221  Double_t mcProdVtxY = primVtxMC->GetY();
2222  Double_t mcProdVtxZ = primVtxMC->GetZ();
2223 
2224  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2225 
2226  // Loop over all primary MC particle
2227  for(Int_t i = 0; i < AODMCTrackArray->GetEntriesFast(); i++) {
2228 
2229  AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
2230  if (!particle) continue;
2231 
2232  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, particle, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2233  if (!isPrimary) continue;
2234 
2235  Int_t isMCFromMBHeader = -1;
2236  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2237  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2238  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2239  }
2240 
2241  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
2242  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kFALSE)){
2243  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma
2244  if (TMath::Abs(particle->Eta()) < 0.66 ){
2245  if (particle->Phi() > 1.39626 && particle->Phi() < 3.125) fHistoMCAllGammaEMCALAccPt[fiCut]->Fill(particle->Pt());
2246  }
2247  if(particle->GetMother() >-1){ // Meson Decay Gamma
2248  switch((static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother())))->GetPdgCode()){
2249  case 111: // Pi0
2250  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt());
2251  break;
2252  case 113: // Rho0
2253  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt());
2254  break;
2255  case 221: // Eta
2256  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt());
2257  break;
2258  case 223: // Omega
2259  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt());
2260  break;
2261  case 331: // Eta'
2262  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt());
2263  break;
2264  case 333: // Phi
2265  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt());
2266  break;
2267  case 3212: // Sigma
2268  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt());
2269  break;
2270  }
2271  }
2272  }
2273  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kTRUE)){
2274  Double_t rConv = 0;
2275  for(Int_t daughterIndex=particle->GetDaughter(0);daughterIndex<=particle->GetDaughter(1);daughterIndex++){
2276  AliAODMCParticle *tmpDaughter = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(daughterIndex));
2277  if(!tmpDaughter) continue;
2278  if(TMath::Abs(tmpDaughter->GetPdgCode()) == 11){
2279  rConv = sqrt( (tmpDaughter->Xv()*tmpDaughter->Xv()) + (tmpDaughter->Yv()*tmpDaughter->Yv()) );
2280  }
2281  }
2282  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt());
2283  if (fDoPhotonQA > 0){
2284  fHistoMCConvGammaR[fiCut]->Fill(rConv);
2285  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta());
2286  }
2287  }
2288  // Converted MC Gamma
2289  if(fDoMesonAnalysis){
2290  if(particle->GetPdgCode() == 310 && fDoMesonQA > 0){
2291  Double_t mesonY = 1.e30;
2292  Double_t ratio = 0;
2293  if (particle->E() != TMath::Abs(particle->Pz())){
2294  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2295  }
2296  if( !(ratio <= 0) ){
2297  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2298  }
2299  Float_t weightedK0s= 1;
2300  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2301  if (particle->Pt()>0.005){
2302  weightedK0s= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, 0x0, fInputEvent);
2303  //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
2304  }
2305  }
2306  fHistoMCK0sPt[fiCut]->Fill(particle->Pt(),weightedK0s);
2307  fHistoMCK0sWOWeightPt[fiCut]->Fill(particle->Pt());
2308  fHistoMCK0sPtY[fiCut]->Fill(particle->Pt(),mesonY,weightedK0s);
2309  }
2311  ->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2312  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
2313  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
2314  Float_t weighted= 1;
2315  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2316  if (particle->Pt()>0.005){
2317  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, 0x0, fInputEvent);
2318  // if(particle->GetPdgCode() == 221){
2319  // cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
2320  // }
2321  }
2322  }
2323  Double_t mesonY = 1.e30;
2324  Double_t ratio = 0;
2325  if (particle->E() != TMath::Abs(particle->Pz())){
2326  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2327  }
2328  if( !(ratio <= 0) ){
2329  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2330  }
2331 
2332  Double_t alpha = -1;
2333  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
2334  alpha = TMath::Abs((daughter0->E() - daughter1->E()))/(daughter0->E() + daughter1->E());
2335  }
2336 
2337 
2338  if(particle->GetPdgCode() == 111){
2339  fHistoMCPi0GGPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Pi0
2340  fHistoMCPi0GGWOWeightPt[fiCut]->Fill(particle->Pt());
2341  if (fDoMesonQA > 0){
2342  fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
2343  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha); // All MC Pi0
2344  }
2345  } else if(particle->GetPdgCode() == 221){
2346  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Eta
2347  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt());
2348  if (fDoMesonQA > 0){
2349  fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
2350  fHistoMCEtaPtAlpha[fiCut]->Fill(particle->Pt(),alpha); // All MC Pi0
2351  }
2352  }
2353 
2354  // Check the acceptance for both gammas
2355  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
2356  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
2357  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2358  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2359 
2360  if(particle->GetPdgCode() == 111){
2361  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted); // MC Pi0 with gamma in acc
2362  } else if(particle->GetPdgCode() == 221){
2363  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted); // MC Eta with gamma in acc
2364  }
2365  }
2366  }
2367  }
2368  }
2369 
2370 }
2371 //________________________________________________________________________
2373 {
2374 
2375  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2376  Double_t mcProdVtxX = primVtxMC->GetX();
2377  Double_t mcProdVtxY = primVtxMC->GetY();
2378  Double_t mcProdVtxZ = primVtxMC->GetZ();
2379 
2380 
2381 
2382  // Loop over all primary MC particle
2383  for(Int_t i = 0; i < fMCEvent->GetNumberOfTracks(); i++) {
2384 
2385 
2386 
2387  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
2388 
2389  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
2390  if (!particle) continue;
2391 
2392 
2393 
2394  Int_t isMCFromMBHeader = -1;
2395  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2396 
2397  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2398  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2399 
2400  }
2401 
2402 
2403 
2404 
2405  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
2406 
2407 
2408  if ( ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(particle,fMCEvent) == kTRUE ){
2409 
2410  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma
2411 
2412 
2413  if( IsPi0DalitzDaughter ( i ) == kTRUE ) {
2414 
2415  fHistoMCAllGammaPi0Pt[fiCut]->Fill(particle->Pt());
2416  }
2417 
2418  }
2419 
2420 
2421  if(((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->ElectronIsSelectedMC(i,fMCEvent) == kTRUE){
2422 
2423  Double_t deltaX = particle->Vx() - mcProdVtxX;
2424  Double_t deltaY = particle->Vy() - mcProdVtxY;
2425  Double_t deltaZ = particle->Vz() - mcProdVtxZ;
2426 
2427  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
2428 
2429 
2430  if( particle->GetPdgCode() == -11) {
2431  fHistoMCAllPositronsPt[fiCut]->Fill(particle->Pt()); // All positrons
2432 
2433 
2434 
2435  if ( particle->GetMother(0) > -1 ) {
2436 
2437  if( IsPi0DalitzDaughter( i ) == kTRUE ){
2438  fHistoMCDecayPositronPi0Pt[fiCut]->Fill(particle->Pt()); //Positrons from Pi0->Dalitz
2439 
2440  if( i >= fMCEvent->GetNumberOfPrimaries() ){
2441 
2442  fHistoMCDecayNoPrimPositronPi0DalitzR[fiCut]->Fill(realRadius3D);
2443  fHistoMCDecayNoPrimPositronPi0DalitzID[fiCut]->Fill( particle->GetUniqueID());
2444 
2445  }
2446 
2447  }
2448 
2449  }
2450  }
2451  if( particle->GetPdgCode() == 11){
2452 
2453  fHistoMCAllElectronsPt[fiCut]->Fill(particle->Pt()); // All electrons
2454 
2455  if ( particle->GetMother(0) > -1 ) {
2456 
2457  if( IsPi0DalitzDaughter( i ) == kTRUE ){
2458  fHistoMCDecayElectronPi0Pt[fiCut]->Fill(particle->Pt()); //Electrons from Pi0->Dalitz
2459  }
2460 
2461  if( i >= fMCEvent->GetNumberOfPrimaries() ){
2462 
2463  fHistoMCDecayNoPrimElectronPi0DalitzR[fiCut]->Fill(realRadius3D);
2464  fHistoMCDecayNoPrimElectronPi0DalitzID[fiCut]->Fill( particle->GetUniqueID());
2465 
2466  }
2467 
2468  }
2469 
2470  }
2471  }
2472 
2473 
2474  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
2475 
2476 
2477 
2478  if ( TMath::Abs(particle->Eta()) < 0.66 ){
2479  if (particle->Phi() > 1.39626 && particle->Phi() < 3.125) fHistoMCAllGammaEMCALAccPt[fiCut]->Fill(particle->Pt());
2480  }
2481 
2482  if(particle->GetMother(0) >-1){ // Meson Decay Gamma
2483  switch(fMCEvent->Particle(particle->GetMother(0))->GetPdgCode()){
2484  case 111: // Pi0
2485  fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt());
2486  break;
2487  case 113: // Rho0
2488  fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt());
2489  break;
2490  case 221: // Eta
2491  fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt());
2492  break;
2493  case 223: // Omega
2494  fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt());
2495  break;
2496  case 331: // Eta'
2497  fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt());
2498  break;
2499  case 333: // Phi
2500  fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt());
2501  break;
2502  case 3212: // Sigma
2503  fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt());
2504  break;
2505  }
2506  }
2507  }
2508  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kTRUE)){
2509  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt());
2510  if (fDoPhotonQA > 0){
2511  fHistoMCConvGammaR[fiCut]->Fill(((TParticle*)fMCEvent->Particle(particle->GetFirstDaughter()))->R());
2512  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta());
2513  }
2514  } // Converted MC Gamma
2515 
2516  if(fDoMesonAnalysis){
2517 
2518 
2520  ->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2521 
2522  Float_t weighted= 1;
2523 
2524  if( ((AliDalitzElectronCuts*) fElectronCutArray->At(fiCut))->DoWeights() ) {
2525 
2526  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2527 
2528  if (particle->Pt()>0.005){
2529  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
2530 
2531  }
2532  }
2533  }
2534 
2535  if(particle->GetPdgCode() == 111){
2536 
2537  fHistoMCPi0GGPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Pi0
2538  fHistoMCPi0GGWOWeightPt[fiCut]->Fill(particle->Pt());
2539 
2540 
2541  } else if(particle->GetPdgCode() == 221){
2542 
2543  fHistoMCEtaGGPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Eta
2544  fHistoMCEtaGGWOWeightPt[fiCut]->Fill(particle->Pt());
2545 
2546  }
2547 
2548 
2549  }
2550 
2551 
2552  Int_t labelgamma = -1;
2553  Int_t labelelectron = -1;
2554  Int_t labelpositron = -1;
2555 
2556 
2557  if( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMCDalitz(particle,fMCEvent,labelelectron,labelpositron,labelgamma,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2558 
2559  Float_t weighted= 1;
2560 
2561  if( ((AliDalitzElectronCuts*) fElectronCutArray->At(fiCut))->DoWeights() ) {
2562  if( ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent,fInputEvent) ) {
2563  if (particle->Pt()>0.005){
2564  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent,fInputEvent);
2565  }
2566  }
2567  }
2568 
2569  if(particle->GetPdgCode() == 111){
2570  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(), weighted); // All MC Pi0 Dalitz
2571  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt() ); //All MC Pi0 Dalitz without weights
2572  }
2573  if(particle->GetPdgCode() == 221){
2574  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(), weighted); // All MC Eta
2575  fHistoMCEtaWOWeightPt[fiCut]->Fill( particle->Pt() ); //All MC Eta Dalitz without weights
2576  }
2577 
2578  // Check the acceptance for gamma and electrons
2579 
2580  TParticle *gamma = fMCEvent->Particle(labelgamma);
2581  TParticle *electron = fMCEvent->Particle(labelelectron);
2582  TParticle *positron = fMCEvent->Particle(labelpositron);
2583 
2584 
2585 
2586 
2587 
2588  Bool_t kDaughGammaIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelgamma, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2589  Bool_t kDaughElectIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelelectron, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2590  Bool_t kDaughPositIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelpositron, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2591 
2592 
2593 
2594  if( kDaughElectIsPrim && kDaughPositIsPrim && kDaughGammaIsPrim &&
2595  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma,fMCEvent) &&
2596  ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->ElectronIsSelectedMC(labelelectron,fMCEvent) &&
2597  ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->ElectronIsSelectedMC(labelpositron,fMCEvent) ) {
2598 
2599 
2600  TLorentzVector TLVEpos,TLVEneg,TLVDalitz;
2601 
2602  Double_t electronMass = TDatabasePDG::Instance()->GetParticle( ::kElectron )->Mass();
2603 
2604  TLVEpos.SetXYZM(positron->Px(),positron->Py(),positron->Pz(),electronMass);
2605  TLVEneg.SetXYZM(electron->Px(),electron->Py(),electron->Pz(),electronMass);
2606  TVector3 V3gamma(gamma->Px(),gamma->Py(),gamma->Pz());
2607  Double_t angleGammaEpos = V3gamma.Angle(TLVEpos.Vect());
2608  Double_t angleGammaEneg = V3gamma.Angle(TLVEneg.Vect());
2609 
2610 
2611 
2612 
2613 
2614 
2615  if( particle->GetPdgCode() == 111 ){
2616 
2617 
2618  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt() , weighted); // MC Pi0Dalitz with gamma and e+e- in acc
2619 
2620  if( fDoMesonQA > 0 ) {
2621 
2622  fHistoMCPi0InAccOpeningAngleGammaElectron[fiCut]->Fill(angleGammaEpos);
2623  fHistoMCPi0InAccOpeningAngleGammaElectron[fiCut]->Fill(angleGammaEneg);
2624 
2625  }
2626 
2627 
2628  }
2629  if( particle->GetPdgCode() == 221 ){
2630 
2631  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(), weighted); // MC EtaDalitz with gamma and e+e- in acc
2632 
2633  }
2634  }
2635  }
2636  }
2637  }
2638  }
2639 }
2640 
2641 
2642 //________________________________________________________________________
2644 
2645  // Conversion Gammas
2646 
2647  if( fClusterCandidates->GetEntries() > 0 && fVirtualGammaCandidates->GetEntries() > 0 ){
2648 
2649  vector<Bool_t> lGoodVirtualGamma(fVirtualGammaCandidates->GetEntries(), kFALSE);
2650 
2651  for(Int_t GammaIndex=0; GammaIndex<fClusterCandidates->GetEntries(); GammaIndex++){
2652 
2653  AliAODConversionPhoton *gamma=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(GammaIndex));
2654 
2655  if (gamma==NULL) continue;
2656 
2657 
2658  for(Int_t virtualGammaIndex=0;virtualGammaIndex<fVirtualGammaCandidates->GetEntries();virtualGammaIndex++){
2659 
2660  Bool_t matched = kFALSE;
2661 
2662  AliAODConversionPhoton *Vgamma=dynamic_cast<AliAODConversionPhoton*>(fVirtualGammaCandidates->At(virtualGammaIndex));
2663  if (Vgamma==NULL) continue;
2664 
2665  //Check for same Electron ID
2666  if ( gamma->GetIsCaloPhoton() ){
2667 
2668  AliVCluster* cluster = fInputEvent->GetCaloCluster(gamma->GetCaloClusterRef());
2669  matched = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(Vgamma,cluster,fInputEvent );
2670 
2671  }
2672 
2673 
2674  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma,Vgamma);
2675  pi0cand->SetLabels(GammaIndex,virtualGammaIndex);
2676 
2677 
2678 
2679 
2680  if( (((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())) ){
2681 
2682  Int_t zbin = 0;
2683  Int_t mbin = 0;
2684 
2685  Double_t angleGammaPositron = -999;
2686  Double_t angleGammaElectron = -999;
2687 
2688 
2689  if ( fDoMesonQA > 0 ) {
2690 
2691  AliESDtrack* positronVgamma = (AliESDtrack*)fInputEvent->GetTrack( Vgamma->GetTrackLabelPositive() );
2692  Double_t momPositron[3];
2693  positronVgamma->GetConstrainedPxPyPz(momPositron);
2694 
2695 
2696  AliESDtrack* electronVgamma = (AliESDtrack*)fInputEvent->GetTrack( Vgamma->GetTrackLabelNegative() );
2697  Double_t momElectron[3];
2698  electronVgamma->GetConstrainedPxPyPz(momElectron);
2699 
2700 
2701  TVector3 vGamma(gamma->GetPx(),gamma->GetPy(),gamma->GetPz());;
2702  TVector3 vPositron(momPositron[0],momPositron[1],momPositron[2]);
2703  TVector3 vElectron(momElectron[0],momElectron[1],momElectron[2]);
2704 
2705  angleGammaPositron = vGamma.Angle(vPositron);
2706  angleGammaElectron = vGamma.Angle(vElectron);
2707 
2708  }
2709 
2710 
2711 
2712  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
2713 
2714  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
2715 
2716  zbin = fBGClusHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
2717 
2718  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
2720  } else {
2722  }
2723  }
2724  }
2725 
2726  if( ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->DoMassCut() == kTRUE ) {
2727  if( ((AliDalitzElectronCuts*) fElectronCutArray->At(fiCut))->MassCut( pi0cand->Pt() , Vgamma->M() ) == kTRUE ){
2728 
2729  if (matched){
2730 
2731  fHistoMotherMatchedInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
2732 
2733  } else {
2734 
2735  fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
2736 
2737  if(TMath::Abs(pi0cand->GetAlpha())<0.1)
2738  fHistoMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E());
2739 
2740 
2741  if( fDoMesonQA > 0 ) {
2742 
2743  fHistoMotherInvMassOpeningAngleGammaElectron[fiCut]->Fill( angleGammaPositron );
2744  fHistoMotherInvMassOpeningAngleGammaElectron[fiCut]->Fill( angleGammaElectron );
2745 
2746 
2747  }
2748 
2749 
2750  if( fDoTHnSparse ) {
2751  Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
2752  fSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
2753  }
2754 
2755  if(fMCEvent){
2756  ProcessTrueMesonCandidates(pi0cand,Vgamma,gamma,matched);
2757  }
2758 
2759  }
2760  }
2761  } else {
2762 
2763  if (matched){
2764  fHistoMotherMatchedInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
2765  } else {
2766 
2767  fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
2768 
2769  if(TMath::Abs( pi0cand->GetAlpha()) < 0.1 )
2770  fHistoMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E());
2771 
2772  if ( fDoTHnSparse ) {
2773  Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
2774  fSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
2775  }
2776 
2777  if( fDoMesonQA > 0 ) {
2778 
2779  fHistoMotherInvMassOpeningAngleGammaElectron[fiCut]->Fill( angleGammaPositron );
2780  fHistoMotherInvMassOpeningAngleGammaElectron[fiCut]->Fill( angleGammaElectron );
2781 
2782  }
2783 
2784 
2785  if(fMCEvent){
2786  ProcessTrueMesonCandidates(pi0cand,Vgamma,gamma,matched);
2787  }
2788  }
2789 
2790  }
2791  }
2792  delete pi0cand;
2793  pi0cand=0x0;
2794  }
2795  }
2796  }
2797 }
2798 
2799 //______________________________________________________________________
2801 {
2802  // Process True Mesons
2803 
2804  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2805  Double_t mcProdVtxX = primVtxMC->GetX();
2806  Double_t mcProdVtxY = primVtxMC->GetY();
2807  Double_t mcProdVtxZ = primVtxMC->GetZ();
2808 
2809 
2810  Bool_t isTruePi0 = kFALSE;
2811  Bool_t isTrueEta = kFALSE;
2812 
2813 
2814  Int_t virtualGammaMCLabel = TrueVirtualGammaCandidate->GetMCParticleLabel(fMCEvent);
2815  Int_t virtualGammaMotherLabel = -1;
2816  Int_t virtualGamma = -1;
2817 
2818  Bool_t motherFromShower = kFALSE;
2819 
2820  Double_t angleGammaPositron = -999;
2821  Double_t angleGammaElectron = -999;
2822 
2823 
2824  if( fDoMesonQA > 0 ) {
2825 
2826  AliESDtrack* positronVgamma = (AliESDtrack*)fInputEvent->GetTrack( TrueVirtualGammaCandidate->GetTrackLabelPositive() );
2827  Double_t momPositron[3];
2828  positronVgamma->GetConstrainedPxPyPz(momPositron);
2829 
2830 
2831  AliESDtrack* electronVgamma = (AliESDtrack*)fInputEvent->GetTrack( TrueVirtualGammaCandidate->GetTrackLabelNegative() );
2832  Double_t momElectron[3];
2833  electronVgamma->GetConstrainedPxPyPz(momElectron);
2834 
2835 
2836  TVector3 vGamma(TrueGammaCandidate1->GetPx(),TrueGammaCandidate1->GetPy(),TrueGammaCandidate1->GetPz());;
2837  TVector3 vPositron(momPositron[0],momPositron[1],momPositron[2]);
2838  TVector3 vElectron(momElectron[0],momElectron[1],momElectron[2]);
2839 
2840  angleGammaPositron = vGamma.Angle(vPositron);
2841  angleGammaElectron = vGamma.Angle(vElectron);
2842 
2843  }
2844 
2845 
2846 
2847  if( virtualGammaMCLabel != -1 ){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2848  // Daughters Gamma 1
2849  TParticle * negativeMC = (TParticle*)TrueVirtualGammaCandidate->GetNegativeMCDaughter(fMCEvent);
2850  TParticle * positiveMC = (TParticle*)TrueVirtualGammaCandidate->GetPositiveMCDaughter(fMCEvent);
2851  TParticle * virtualGammaMotherMC = (TParticle*)fMCEvent->Particle(virtualGammaMCLabel);
2852 
2853  if( TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11) { // Electrons ...
2854 
2855  if( virtualGammaMotherMC->GetPdgCode() != 22 ){
2856  virtualGammaMotherLabel=virtualGammaMCLabel;
2857  virtualGamma = 1;
2858 
2859  } else if (negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
2860  virtualGammaMotherLabel=virtualGammaMotherMC->GetMother(0);
2861  virtualGamma = 0; //no virtual gamma
2862  }
2863  }
2864  }
2865 
2866  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2867 
2868  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
2869  Int_t gamma1MotherLabel = -1;
2870  // check if
2871 
2872  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2873 
2874  // Daughters Gamma 1
2875  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
2876 
2877  if ( TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron() ){ // largest component is electro magnetic
2878  // get mother of interest (pi0 or eta)
2879  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
2880  gamma1MotherLabel=gammaMC1->GetMother(0);
2881  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
2882  if (TrueGammaCandidate1->IsConversion()) gamma1MotherLabel=fMCEvent->Particle(gammaMC1->GetMother(0))->GetMother(0);
2883  else gamma1MotherLabel=gammaMC1->GetMother(0);
2884  }
2885 
2886 
2887  if( gamma1MotherLabel > -1 ){
2888 
2889  Int_t pdgCodeMother = ((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode();
2890 
2891  if( pdgCodeMother != 111 && pdgCodeMother != 221 ){ //The mother is not and eta and MC
2892 
2893  gamma1MotherLabel = FindMotherOfPhoton( gamma1MotherLabel );
2894  motherFromShower = kTRUE;
2895 
2896  }
2897  }
2898 
2899 
2900 
2901  } else {
2902  if (fDoMesonQA > 0) fHistoTrueMotherCaloEMNonLeadingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2903  }
2904  }
2905 
2906  if(virtualGammaMotherLabel >= 0 && virtualGammaMotherLabel==gamma1MotherLabel){
2907 
2908  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
2909  isTruePi0=kTRUE;
2910  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma1MotherLabel)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2911  }
2912 
2913  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 221){
2914  isTrueEta=kTRUE;
2915  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueEtas,gamma1MotherLabel)) fHistoDoubleCountTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2916  }
2917 
2918  }
2919 
2920  if(isTruePi0 || isTrueEta){// True Pion or Eta
2921 
2922 
2923  if( virtualGamma == 1 ){
2924 
2925  if( !matched ) {
2926 
2927  if( isTruePi0 ) {
2928 
2929  fHistoTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2930  if( fDoMesonQA > 0 ) {
2931  fHistoTruePi0OpeningAngleGammaElectron[fiCut]->Fill(angleGammaPositron);
2932  fHistoTruePi0OpeningAngleGammaElectron[fiCut]->Fill(angleGammaElectron);
2933  }
2934  }
2935  if (isTrueEta)fHistoTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2936 
2937  }
2938 
2939 
2940  if (fDoMesonQA > 0){
2941 
2942 
2943  if( motherFromShower == kTRUE && !matched ){
2944 
2945  if (isTruePi0)fHistoTruePi0ShowerInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2946  if (isTrueEta)fHistoTrueEtaShowerInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2947 
2948  } else if ( motherFromShower == kFALSE && !matched ){
2949 
2950  if (isTruePi0)fHistoTruePi0NoShowerInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2951  if (isTrueEta)fHistoTrueEtaNoShowerInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2952 
2953  }
2954 
2955  if (TrueGammaCandidate1->IsLargestComponentPhoton() && !matched){
2956  if(isTruePi0) fHistoTruePi0CaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2957  if(isTrueEta) fHistoTrueEtaCaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2958  }
2959  if (TrueGammaCandidate1->IsLargestComponentElectron() && !matched){
2960  if(isTruePi0) fHistoTruePi0CaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2961  if(isTrueEta) fHistoTrueEtaCaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2962  }
2963  if (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion() ){
2964  if (isTruePi0 && !matched)fHistoTruePi0CaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2965  if (isTrueEta && !matched)fHistoTrueEtaCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2966  if ((TrueVirtualGammaCandidate->GetMCLabelPositive() == gamma1MCLabel || TrueVirtualGammaCandidate->GetMCLabelNegative() == gamma1MCLabel) && isTruePi0){
2967  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2968  }
2969  if ((TrueVirtualGammaCandidate->GetMCLabelPositive() == gamma1MCLabel || TrueVirtualGammaCandidate->GetMCLabelNegative() == gamma1MCLabel) && isTrueEta){
2970  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2971  }
2972  }
2973  if ((TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged()) && !matched ){
2974  if (isTruePi0 )fHistoTruePi0CaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2975  if (isTrueEta )fHistoTrueEtaCaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2976  }
2977  if (TrueGammaCandidate1->IsMergedPartConv() && !matched){
2978  if (isTruePi0) fHistoTruePi0CaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2979  if (isTrueEta) fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2980  }
2981  }
2982 
2983  if ( !matched ) {
2984 
2985  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, gamma1MotherLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2986 
2987 
2988  if(!isPrimary){ // Secondary Meson
2989 
2990  Int_t secMotherLabel = ((TParticle*)fMCEvent->Particle(virtualGammaMotherLabel))->GetMother(0);
2991  Float_t weightedSec = 1;
2992 
2993  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, fMCEvent, fInputEvent) && fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310){
2994  weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(secMotherLabel, fMCEvent, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
2995 
2996  }
2997 
2998  if (isTruePi0){
2999  fHistoTrueSecondaryPi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3000  fHistoTrueSecondaryPi0PhotonPairPtconv[fiCut]->Fill(Pi0Candidate->M(),TrueGammaCandidate1->Pt(),weightedSec);
3001  if(CheckIfContainedInString(fStringRecTruePi0s[fiCut],virtualGammaMotherLabel)){
3002  fHistoTrueSecondaryPi0DCPtconv[fiCut]->Fill(TrueGammaCandidate1->Pt(),weightedSec);
3003  }
3004  }
3005 
3006  if (secMotherLabel >-1){
3007  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310 && isTruePi0 ){
3008  fHistoTrueSecondaryPi0FromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3009  if (fDoMesonQA > 0)fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3010  }
3011  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==221 && isTruePi0){
3012  fHistoTrueSecondaryPi0FromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3013  if (fDoMesonQA > 0)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3014  }
3015  if(fMCEvent->Particle(secMotherLabel)->GetPdgCode()==3122 && isTruePi0){
3016  fHistoTrueSecondaryPi0FromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3017  if (fDoMesonQA > 0)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(fMCEvent->Particle(secMotherLabel)->Pt());
3018  }
3019  }
3020  } else { // Only primary pi0 for efficiency calculation
3021  Float_t weighted= 1;
3022  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCEvent, fInputEvent)){
3023  if (((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt()>0.005){
3024  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, fMCEvent, fInputEvent);
3025  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3026  }
3027  }
3028  if (isTruePi0){
3029  fHistoTruePrimaryPi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3030  fHistoTruePrimaryPi0PhotonPairPtconv[fiCut]->Fill(Pi0Candidate->M(),TrueGammaCandidate1->Pt(),weighted);
3031  fHistoTruePrimaryPi0W0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3032  fProfileTruePrimaryPi0WeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3033  if(CheckIfContainedInString(fStringRecTruePi0s[fiCut],virtualGammaMotherLabel)){
3034  fHistoTruePrimaryPi0DCPtconv[fiCut]->Fill(TrueGammaCandidate1->Pt(),weighted);
3035  }
3036 
3037  } else if (isTrueEta) {
3038  fHistoTruePrimaryEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3039  fHistoTruePrimaryEtaPhotonPairPtconv[fiCut]->Fill(Pi0Candidate->M(),TrueGammaCandidate1->Pt(),weighted);
3040  fHistoTruePrimaryEtaW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3041  fProfileTruePrimaryEtaWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3042  if(CheckIfContainedInString(fStringRecTrueEtas[fiCut],virtualGammaMotherLabel)){
3043  fHistoTruePrimaryEtaDCPtconv[fiCut]->Fill(TrueGammaCandidate1->Pt(),weighted);
3044  }
3045  }
3046 
3047  if (fDoMesonQA > 0){
3048  if(isTruePi0){ // Only primary pi0 for resolution
3049  fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted);
3050  }
3051  if (isTrueEta){ // Only primary eta for resolution
3052  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted);
3053  }
3054  }
3055  }
3056  }
3057  } else if ( virtualGamma == 0 ) {
3058 
3059  if( !matched ) {
3060 
3061  if (isTruePi0)fHistoTruePi0GGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3062  if (isTrueEta)fHistoTrueEtaGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3063 
3064  if(virtualGammaMotherLabel >= fMCEvent->GetNumberOfPrimaries()){ // Secondary Meson
3065 
3066  Int_t secMotherLabel = ((TParticle*)fMCEvent->Particle(virtualGammaMotherLabel))->GetMother(0);
3067  Float_t weightedSec= 1;
3068 
3069  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, fMCEvent, fInputEvent) && fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310){
3070  weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(secMotherLabel, fMCEvent, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
3071  //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3072  }
3073  if (isTruePi0){
3074  fHistoTrueSecondaryPi0GGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3075  }
3076 
3077  } else { // Only primary pi0 for efficiency calculation
3078  Float_t weighted= 1;
3079  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCEvent, fInputEvent)){
3080  if (((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt()>0.005){
3081  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, fMCEvent, fInputEvent);
3082  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3083  }
3084  }
3085  if (isTruePi0){
3086  fHistoTruePrimaryPi0GGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3087 
3088  } else if (isTrueEta) {
3089  fHistoTruePrimaryEtaGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3090  }
3091 
3092  }
3093  }
3094 
3095  }
3096 
3097  } else if( !isTruePi0 && !isTrueEta ){ // Background
3098 
3099  if (fDoMesonQA > 0){
3100  if(virtualGammaMotherLabel>-1 && gamma1MotherLabel>-1 && virtualGamma == 0){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
3101  fHistoTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3102  } else { // No photon or without mother
3103  fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3104  }
3105  }
3106  }
3107 
3108 
3109  if (isTrueEta && !matched){
3110  fStringRecTrueEtas[fiCut].Append(Form("%i,",virtualGammaMotherLabel));
3111  }
3112  if (isTruePi0 && !matched){
3113  fStringRecTruePi0s[fiCut].Append(Form("%i,",virtualGammaMotherLabel));
3114  }
3115 
3116 }
3117 //______________________________________________________________________
3119 {
3120  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3121  Double_t mcProdVtxX = primVtxMC->GetX();
3122  Double_t mcProdVtxY = primVtxMC->GetY();
3123  Double_t mcProdVtxZ = primVtxMC->GetZ();
3124 
3125  // Process True Mesons
3126  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3127  Bool_t isTruePi0 = kFALSE;
3128  Bool_t isTrueEta = kFALSE;
3129 
3130  AliAODMCParticle *positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
3131  AliAODMCParticle *negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
3132 
3133  Int_t gamma0MCLabel = -1;
3134  Int_t gamma0MotherLabel = -1;
3135  if(!positiveMC||!negativeMC)
3136  return;
3137 
3138  if (TrueGammaCandidate0->IsTrueConvertedPhoton()){
3139  gamma0MCLabel = positiveMC->GetMother();
3140  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3141  gamma0MotherLabel=gammaMC0->GetMother();
3142  }
3143 
3144  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3145  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
3146  Int_t gamma1MotherLabel = -1;
3147  // check if
3148 
3149  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3150  // Daughters Gamma 1
3151  AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3152  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
3153  // get mother of interest (pi0 or eta)
3154  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
3155  gamma1MotherLabel=gammaMC1->GetMother();
3156  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
3157  if (TrueGammaCandidate1->IsConversion()){
3158  AliAODMCParticle * gammaGrandMotherMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC1->GetMother()));
3159  gamma1MotherLabel=gammaGrandMotherMC1->GetMother();
3160  } else gamma1MotherLabel=gammaMC1->GetMother();
3161  }
3162  } else {
3163  if (fDoMesonQA > 0) fHistoTrueMotherCaloEMNonLeadingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3164  }
3165  }
3166 
3167  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3168  if(((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
3169  isTruePi0=kTRUE;
3170  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma1MotherLabel)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3171  }
3172  if(((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 221){
3173  isTrueEta=kTRUE;
3174  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueEtas,gamma1MotherLabel)) fHistoDoubleCountTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3175  }
3176  }
3177 
3178  if(isTruePi0 || isTrueEta){// True Pion or Eta
3179  if (!matched){
3180  if (isTruePi0)fHistoTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3181  if (isTrueEta)fHistoTrueEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3182  }
3183  if (fDoMesonQA > 0){
3184  if (TrueGammaCandidate1->IsLargestComponentPhoton() && !matched){
3185  if (isTruePi0) fHistoTruePi0CaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3186  if (isTrueEta) fHistoTrueEtaCaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3187  }
3188  if (TrueGammaCandidate1->IsLargestComponentElectron() && !matched) {
3189  if (isTruePi0) fHistoTruePi0CaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3190  if (isTrueEta) fHistoTrueEtaCaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3191  }
3192  if (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()){
3193 
3194  if (isTruePi0 && !matched)fHistoTruePi0CaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3195  if (isTrueEta && !matched)fHistoTrueEtaCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3196  if ((TrueGammaCandidate0->GetMCLabelPositive() == gamma1MCLabel || TrueGammaCandidate0->GetMCLabelNegative() == gamma1MCLabel) && isTruePi0)
3197  fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3198  if ((TrueGammaCandidate0->GetMCLabelPositive() == gamma1MCLabel || TrueGammaCandidate0->GetMCLabelNegative() == gamma1MCLabel) && isTrueEta)
3199  fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3200  }
3201  if ((TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged()) && !matched ){
3202  if (isTruePi0) fHistoTruePi0CaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3203  if (isTrueEta) fHistoTrueEtaCaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3204  }
3205  if (TrueGammaCandidate1->IsMergedPartConv() && !matched) {
3206  if (isTruePi0) fHistoTruePi0CaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3207  if (isTrueEta) fHistoTrueEtaCaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3208  }
3209  }
3210 
3211  if ( !matched){
3212  if (fDoMesonQA > 0){
3213  if (isTruePi0){
3214  if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
3215  fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3216  fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()));
3217  fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3218  fHistoTrueMotherPi0ConvPhotonEtaPhi[fiCut]->Fill(TrueGammaCandidate0->GetPhotonPhi(), TrueGammaCandidate0->GetPhotonEta());
3219  }
3220  } else if (isTrueEta){
3221  if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
3222  fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3223  fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),TMath::Abs(Pi0Candidate->GetAlpha()));
3224  fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
3225  fHistoTrueMotherEtaConvPhotonEtaPhi[fiCut]->Fill(TrueGammaCandidate0->GetPhotonPhi(), TrueGammaCandidate0->GetPhotonEta());
3226  }
3227  }
3228  }
3229  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel)), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3230  if(isPrimary){ // Secondary Meson
3231  Int_t secMotherLabel = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetMother();
3232  Float_t weightedSec= 1;
3233  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, 0x0, fInputEvent) && static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
3234  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
3235  //cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
3236  }
3237  if (isTruePi0){
3238  fHistoTrueSecondaryPi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3239  fHistoTrueSecondaryPi0PhotonPairPtconv[fiCut]->Fill(Pi0Candidate->M(),TrueGammaCandidate0->Pt(),weightedSec);
3240  if(CheckIfContainedInString(fStringRecTruePi0s[fiCut],gamma0MotherLabel)){
3241  fHistoTrueSecondaryPi0DCPtconv[fiCut]->Fill(TrueGammaCandidate0->Pt(),weightedSec);
3242  }
3243  }
3244  if (secMotherLabel >-1){
3245  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310 && isTruePi0){
3246  fHistoTrueSecondaryPi0FromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3247  if (fDoMesonQA > 0)fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3248  }
3249  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==221 && isTruePi0){
3250  fHistoTrueSecondaryPi0FromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3251  if (fDoMesonQA > 0)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3252  }
3253  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==3122 && isTruePi0){
3254  fHistoTrueSecondaryPi0FromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
3255  if (fDoMesonQA > 0)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
3256  }
3257  }
3258  } else{ // Only primary pi0 for efficiency calculation
3259  Float_t weighted= 1;
3260  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, 0x0, fInputEvent)){
3261  if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt()>0.005){
3262  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, 0x0, fInputEvent);
3263  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3264  }
3265  }
3266  if (isTruePi0){
3267  fHistoTruePrimaryPi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3268  fHistoTruePrimaryPi0W0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3269  fHistoTruePrimaryPi0PhotonPairPtconv[fiCut]->Fill(Pi0Candidate->M(),TrueGammaCandidate0->Pt(),weighted);
3270  fProfileTruePrimaryPi0WeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3271  if(CheckIfContainedInString(fStringRecTruePi0s[fiCut],gamma0MotherLabel)){
3272  fHistoTruePrimaryPi0DCPtconv[fiCut]->Fill(TrueGammaCandidate0->Pt(),weighted);
3273  }
3274  } else if (isTrueEta){
3275  fHistoTruePrimaryEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3276  fHistoTruePrimaryEtaW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3277  fHistoTruePrimaryEtaPhotonPairPtconv[fiCut]->Fill(Pi0Candidate->M(),TrueGammaCandidate0->Pt(),weighted);
3278  fProfileTruePrimaryEtaWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
3279  if(CheckIfContainedInString(fStringRecTrueEtas[fiCut],gamma0MotherLabel)){
3280  fHistoTruePrimaryEtaDCPtconv[fiCut]->Fill(TrueGammaCandidate0->Pt(),weighted);
3281  }
3282  }
3283  if (fDoMesonQA > 0){
3284  if(isTruePi0){ // Only primary pi0 for resolution
3285  fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
3286  (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
3287 
3288  }
3289  if (isTrueEta){ // Only primary eta for resolution
3290  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
3291  (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
3292  }
3293  }
3294  }
3295  }
3296  } else if(!isTruePi0 && !isTrueEta) { // Background
3297  if (fDoMesonQA > 0){
3298  if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
3299  fHistoTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3300  } else { // No photon or without mother
3301  fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
3302  }
3303  }
3304  }
3305 
3306  if (isTrueEta && !matched){
3307  fStringRecTrueEtas[fiCut].Append(Form("%i,",gamma0MotherLabel));
3308  }
3309  if (isTruePi0 && !matched){
3310  fStringRecTruePi0s[fiCut].Append(Form("%i,",gamma0MotherLabel));
3311  }
3312 
3313 
3314 
3315 }
3316 
3317 //________________________________________________________________________
3319 {
3320  Int_t nV0 = 0;
3321  TList *GammaCandidatesStepOne = new TList();
3322  TList *GammaCandidatesStepTwo = new TList();
3323  // Loop over Photon Candidates allocated by ReaderV1
3324  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
3325  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
3326  if(!PhotonCandidate) continue;
3327  fIsFromMBHeader = kTRUE;
3328 
3329  if(fIsMC && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3330 
3331  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
3332  if(isPosFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3333  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
3334  if(isNegFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3335  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
3336  }
3337 
3338  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fInputEvent)) continue;
3339  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->InPlaneOutOfPlaneCut(PhotonCandidate->GetPhotonPhi(),fEventPlaneAngle)) continue;
3340  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut() &&
3341  !((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){
3342  fGammaCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
3343 
3344  if(fIsFromMBHeader){
3345  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
3346  if (fDoPhotonQA > 0){
3347  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
3348  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
3349  }
3350  }
3351  if(fIsMC){
3352  if(fInputEvent->IsA()==AliESDEvent::Class())
3353  ProcessTruePhotonCandidates(PhotonCandidate);
3354  if(fInputEvent->IsA()==AliAODEvent::Class())
3355  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
3356  }
3357 
3358  } else if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
3359  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
3360  nV0++;
3361  GammaCandidatesStepOne->Add(PhotonCandidate);
3362  } else if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut() &&
3363  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
3364  GammaCandidatesStepTwo->Add(PhotonCandidate);
3365  }
3366  }
3367 
3368  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut()){
3369  for(Int_t i = 0;i<GammaCandidatesStepOne->GetEntries();i++){
3370  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GammaCandidatesStepOne->At(i);
3371  if(!PhotonCandidate) continue;
3372  fIsFromMBHeader = kTRUE;
3373  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3374  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
3375  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
3376  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
3377  }
3378  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GammaCandidatesStepOne->GetEntries())) continue;
3379  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
3380  fGammaCandidates->Add(PhotonCandidate);
3381  if(fIsFromMBHeader){
3382  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
3383  if (fDoPhotonQA > 0){
3384  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
3385  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
3386  }
3387  }
3388 
3389  if(fIsMC){
3390  if(fInputEvent->IsA()==AliESDEvent::Class())
3391  ProcessTruePhotonCandidates(PhotonCandidate);
3392  if(fInputEvent->IsA()==AliAODEvent::Class())
3393  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
3394  }
3395 
3396  }
3397  else GammaCandidatesStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
3398 
3399 
3400  }
3401  }
3402  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){
3403  for(Int_t i = 0;i<GammaCandidatesStepTwo->GetEntries();i++){
3404  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GammaCandidatesStepTwo->At(i);
3405  if(!PhotonCandidate) continue;
3406  fIsFromMBHeader = kTRUE;
3407  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3408  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
3409  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
3410  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
3411  }
3412  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GammaCandidatesStepTwo,i)) continue;
3413  fGammaCandidates->Add(PhotonCandidate); // Add gamma to current cut TList
3414  if(fIsFromMBHeader){
3415  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
3416  if (fDoPhotonQA > 0){
3417  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
3418  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
3419  }
3420  }
3421  if(fIsMC){
3422  if(fInputEvent->IsA()==AliESDEvent::Class())
3423  ProcessTruePhotonCandidates(PhotonCandidate);
3424  if(fInputEvent->IsA()==AliAODEvent::Class())
3425  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
3426  }
3427 
3428  }
3429  }
3430 
3431  delete GammaCandidatesStepOne;
3432  GammaCandidatesStepOne = 0x0;
3433  delete GammaCandidatesStepTwo;
3434  GammaCandidatesStepTwo = 0x0;
3435 
3436 }
3437 //________________________________________________________________________
3439 {
3440 
3441  Double_t magField = fInputEvent->GetMagneticField();
3442  if( magField < 0.0 ){
3443  magField = 1.0;
3444  }
3445  else {
3446  magField = -1.0;
3447  }
3448 
3449  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3450  if (AODMCTrackArray == NULL) return;
3451  AliAODMCParticle *posDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelPositive());
3452  AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelNegative());
3453  fCharPhotonMCInfo = 0;
3454 
3455  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
3456  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
3457 
3458  if(posDaughter->GetMother() != negDaughter->GetMother()){
3459 
3460  fCharPhotonMCInfo = 1;
3461  return;
3462  }
3463  else if(posDaughter->GetMother() == -1){
3464 
3465  fCharPhotonMCInfo = 1;
3466  return;
3467  }
3468 
3469  if(pdgCode[0]!=11 || pdgCode[1]!=11){
3470  fCharPhotonMCInfo = 1;
3471  return; //One Particle is not a electron
3472  }
3473 
3474  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()){
3475  fCharPhotonMCInfo = 1;
3476  return; // Same Charge
3477  }
3478 
3479  AliAODMCParticle *Photon = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
3480  if(Photon->GetPdgCode() != 22){
3481  fCharPhotonMCInfo = 1;
3482  return; // Mother is no Photon
3483  }
3484 
3485  if(((posDaughter->GetMCProcessCode())) != 5 || ((negDaughter->GetMCProcessCode())) != 5){
3486  fCharPhotonMCInfo = 1;
3487  return;// check if the daughters come from a conversion
3488  }
3489  // STILL A BUG IN ALIROOT >>8 HAS TPO BE REMOVED AFTER FIX
3490 
3491 
3492 
3493  // True Photon
3494  if(fIsFromMBHeader){
3495  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3496  if (fDoPhotonQA > 0) fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta());
3497  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueConvGammas,posDaughter->GetMother())) fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt());
3498  }
3499 
3500  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3501  Double_t mcProdVtxX = primVtxMC->GetX();
3502  Double_t mcProdVtxY = primVtxMC->GetY();
3503  Double_t mcProdVtxZ = primVtxMC->GetZ();
3504  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3505 
3506  if(isPrimary){
3507  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
3508  if(fIsFromMBHeader){
3509  fCharPhotonMCInfo = 6;
3510  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3511  fHistoTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
3512  }
3513  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
3514  } else {
3515  if(fIsFromMBHeader){
3516  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3517  fCharPhotonMCInfo = 2;
3518  if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 &&
3519  ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 3122){
3520  fCharPhotonMCInfo = 5;
3521  fHistoTrueSecondaryConvGammaFromXFromLambdaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3522  }
3523  if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 &&
3524  ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 310){
3525  fCharPhotonMCInfo = 4;
3526  fHistoTrueSecondaryConvGammaFromXFromK0sPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3527  }
3528  if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1 &&
3529  ((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 221){
3530  fCharPhotonMCInfo = 3;
3531  }
3532  }
3533  }
3534  TruePhotonCandidate->SetIsTrueConvertedPhoton();
3535 }
3536 
3537 //________________________________________________________________________
3539 {
3540  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3541  Double_t mcProdVtxX = primVtxMC->GetX();
3542  Double_t mcProdVtxY = primVtxMC->GetY();
3543  Double_t mcProdVtxZ = primVtxMC->GetZ();
3544 
3545  Double_t magField = fInputEvent->GetMagneticField();
3546  if( magField < 0.0 ){
3547  magField = 1.0;
3548  }
3549  else {
3550  magField = -1.0;
3551  }
3552 
3553  // Process True Photons
3554  TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCEvent);
3555  TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCEvent);
3556  fCharPhotonMCInfo = 0;
3557 
3558  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
3559  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
3560  fCharPhotonMCInfo = 1;
3561  if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){
3562 
3563  return;
3564  }
3565  else if(posDaughter->GetMother(0) == -1){
3566 
3567  return;
3568  }
3569 
3570  if(pdgCode[0]!=11 || pdgCode[1]!=11) return; //One Particle is not a electron
3571 
3572  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
3573 
3574  TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCEvent);
3575 
3576  if(Photon->GetPdgCode() != 22){
3577  return; // Mother is no Photon
3578  }
3579 
3580  if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
3581 
3582  // True Photon
3583  if(fIsFromMBHeader){
3584  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3585  if (fDoPhotonQA > 0) fHistoTrueConvGammaEta[fiCut]->Fill(TruePhotonCandidate->Eta());
3586  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueConvGammas,posDaughter->GetMother(0))) fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt());
3587  }
3588  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, posDaughter->GetMother(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3589  if(isPrimary){
3590  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
3591  if(fIsFromMBHeader){
3592  fCharPhotonMCInfo = 6;
3593  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3594  fHistoTruePrimaryConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
3595  }
3596  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
3597  } else {
3598  // fill secondary histograms
3599  if(fIsFromMBHeader){
3600  fCharPhotonMCInfo = 2;
3601  fHistoTrueSecondaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3602  if(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0) > -1 &&
3603  fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 3122){
3604  fHistoTrueSecondaryConvGammaFromXFromLambdaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3605  fCharPhotonMCInfo = 5;
3606  }
3607  if(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0) > -1 &&
3608  fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
3609  fHistoTrueSecondaryConvGammaFromXFromK0sPt[fiCut]->Fill(TruePhotonCandidate->Pt());
3610  fCharPhotonMCInfo = 4;
3611  }
3612  if(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0) > -1 &&
3613  fMCEvent->Particle(fMCEvent->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 221){
3614  fCharPhotonMCInfo = 3;
3615  }
3616  }
3617  }
3618  TruePhotonCandidate->SetIsTrueConvertedPhoton();
3619  return;
3620 }
3621 //________________________________________________________________________
3623 
3624  Int_t zbin= fBGClusHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3625  Int_t mbin = 0;
3626 
3627 
3628  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3630  } else {
3632  }
3633 
3634 
3636 
3637  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3638 
3639  for(Int_t nEventsInBG=0;nEventsInBG<fBGClusHandler[fiCut]->GetNBGEvents();nEventsInBG++){
3640 
3641  AliGammaConversionAODVector *previousEventV0s = fBGClusHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
3642  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3643  bgEventVertex = fBGClusHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
3644  }
3645 
3646  for(Int_t iCurrent=0;iCurrent<fVirtualGammaCandidates->GetEntries();iCurrent++){
3647 
3648  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fVirtualGammaCandidates->At(iCurrent));
3649 
3650  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3651  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
3652 
3653  if(fMoveParticleAccordingToVertex == kTRUE){
3654  if (bgEventVertex){
3655  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3656  }
3657  }
3658  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3659  if (bgEventVertex){
3660  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
3661  }
3662  }
3663 
3664  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
3665  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3667  ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3668 
3669 
3670  if( ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->DoMassCut() == kTRUE ) {
3671 
3672  if( ((AliDalitzElectronCuts*) fElectronCutArray->At(fiCut))->MassCut( backgroundCandidate->Pt() , currentEventGoodV0.M() ) == kTRUE ){
3673 
3674 
3675  fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
3676 
3677  if(fDoTHnSparse){
3678  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3679  fSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
3680  }
3681  }
3682  }
3683  }
3684  delete backgroundCandidate;
3685  backgroundCandidate = 0x0;
3686  }
3687  }
3688  }
3689  } else {
3690  for(Int_t nEventsInBG=0;nEventsInBG <fBGClusHandler[fiCut]->GetNBGEvents();nEventsInBG++){
3691  AliGammaConversionAODVector *previousEventV0s = fBGClusHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
3692  if(previousEventV0s){
3693  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0 ){
3694  bgEventVertex = fBGClusHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
3695  }
3696  for(Int_t iCurrent=0;iCurrent<fVirtualGammaCandidates->GetEntries();iCurrent++){
3697  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fVirtualGammaCandidates->At(iCurrent));
3698  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3699 
3700  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
3701 
3702  if(fMoveParticleAccordingToVertex == kTRUE){
3703  if (bgEventVertex){
3704  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3705  }
3706  }
3707  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3708  if (bgEventVertex){
3709  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
3710  }
3711  }
3712 
3713  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
3714  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3715  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3716 
3717  if( ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->DoMassCut() == kTRUE ) {
3718 
3719  if( ((AliDalitzElectronCuts*) fElectronCutArray->At(fiCut))->MassCut( backgroundCandidate->Pt() , currentEventGoodV0.M() ) == kTRUE ){
3720 
3721 
3722  fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
3723 
3724  if(fDoTHnSparse){
3725  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3726  fSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
3727  }
3728  }
3729  }
3730  }
3731  delete backgroundCandidate;
3732  backgroundCandidate = 0x0;
3733  }
3734  }
3735  }
3736  }
3737  }
3738 }
3739 
3740 //________________________________________________________________________
3742  Int_t fNDegreesPMBackground= ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->NDegreesRotation();
3743  Double_t nRadiansPM = fNDegreesPMBackground*TMath::Pi()/180;
3744  Double_t rotationValue = fRandom.Rndm()*2*nRadiansPM + TMath::Pi()-nRadiansPM;
3745  gamma->RotateZ(rotationValue);
3746 }
3747 
3748 //________________________________________________________________________
3750 
3751  previousEventEP=previousEventEP+TMath::Pi();
3752  thisEventEP=thisEventEP+TMath::Pi();
3753  Double_t rotationValue= thisEventEP-previousEventEP;
3754  gamma->RotateZ(rotationValue);
3755 }
3756 
3757 //________________________________________________________________________
3759  //see header file for documentation
3760 
3761  Double_t dx = vertex->fX - fInputEvent->GetPrimaryVertex()->GetX();
3762  Double_t dy = vertex->fY - fInputEvent->GetPrimaryVertex()->GetY();
3763  Double_t dz = vertex->fZ - fInputEvent->GetPrimaryVertex()->GetZ();
3764 
3765  Double_t movedPlace[3] = {particle->GetConversionX() - dx,particle->GetConversionY() - dy,particle->GetConversionZ() - dz};
3766  particle->SetConversionPoint(movedPlace);
3767 }
3768 //________________________________________________________________________
3770  //see header file for documentation
3771  if( fClusterCandidates->GetEntries() > 0 ){
3772  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3773  fBGClusHandler[fiCut]->AddEvent(fClusterCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),fEventPlaneAngle);
3774  } else { // means we use #V0s for multiplicity
3775  fBGClusHandler[fiCut]->AddEvent(fClusterCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fClusterCandidates->GetEntries(),fEventPlaneAngle);
3776  }
3777  }
3778 }
3779 
3780 //________________________________________________________________________
3782 
3783  // Relabeling For AOD Event
3784  // ESDiD -> AODiD
3785  // MCLabel -> AODMCLabel
3786 
3787  if(mode){
3788  fMCEventPos = new Int_t[fReaderGammas->GetEntries()];
3789  fMCEventNeg = new Int_t[fReaderGammas->GetEntries()];
3790  fESDArrayPos = new Int_t[fReaderGammas->GetEntries()];
3791  fESDArrayNeg = new Int_t[fReaderGammas->GetEntries()];
3792  }
3793 
3794  for(Int_t iGamma = 0;iGamma<fReaderGammas->GetEntries();iGamma++){
3795  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(iGamma);
3796  if(!PhotonCandidate) continue;
3797  if(!mode){// Back to ESD Labels
3798  PhotonCandidate->SetMCLabelPositive(fMCEventPos[iGamma]);
3799  PhotonCandidate->SetMCLabelNegative(fMCEventNeg[iGamma]);
3800  PhotonCandidate->SetLabelPositive(fESDArrayPos[iGamma]);
3801  PhotonCandidate->SetLabelNegative(fESDArrayNeg[iGamma]);
3802  continue;
3803  }
3804  fMCEventPos[iGamma] = PhotonCandidate->GetMCLabelPositive();
3805  fMCEventNeg[iGamma] = PhotonCandidate->GetMCLabelNegative();
3806  fESDArrayPos[iGamma] = PhotonCandidate->GetTrackLabelPositive();
3807  fESDArrayNeg[iGamma] = PhotonCandidate->GetTrackLabelNegative();
3808 
3809  Bool_t AODLabelPos = kFALSE;
3810  Bool_t AODLabelNeg = kFALSE;
3811 
3812  for(Int_t i = 0; i<fInputEvent->GetNumberOfTracks();i++){
3813  AliAODTrack *tempDaughter = static_cast<AliAODTrack*>(fInputEvent->GetTrack(i));
3814  if(!AODLabelPos){
3815  if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelPositive() ){
3816  PhotonCandidate->SetMCLabelPositive(TMath::Abs(tempDaughter->GetLabel()));
3817  PhotonCandidate->SetLabelPositive(i);
3818  AODLabelPos = kTRUE;
3819  }
3820  }
3821  if(!AODLabelNeg){
3822  if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelNegative()){
3823  PhotonCandidate->SetMCLabelNegative(TMath::Abs(tempDaughter->GetLabel()));
3824  PhotonCandidate->SetLabelNegative(i);
3825  AODLabelNeg = kTRUE;
3826  }
3827  }
3828  if(AODLabelNeg && AODLabelPos){
3829  break;
3830  }
3831  }
3832  if(!AODLabelPos || !AODLabelNeg){
3833  cout<<"WARNING!!! AOD TRACKS NOT FOUND FOR"<<endl;
3834  }
3835  }
3836 
3837 
3838  if(!mode){
3839  delete[] fMCEventPos;
3840  delete[] fMCEventNeg;
3841  delete[] fESDArrayPos;
3842  delete[] fESDArrayNeg;
3843  }
3844 }
3845 
3847  TAxis *axisafter = histoRebin->GetXaxis();
3848  Int_t bins = axisafter->GetNbins();
3849  Double_t from = axisafter->GetXmin();
3850  Double_t to = axisafter->GetXmax();
3851  Double_t *newbins = new Double_t[bins+1];
3852  newbins[0] = from;
3853  Double_t factor = TMath::Power(to/from, 1./bins);
3854  for(Int_t i=1; i<=bins; ++i) newbins[i] = factor * newbins[i-1];
3855  axisafter->Set(bins, newbins);
3856  delete [] newbins;
3857 }
3858 
3859 //________________________________________________________________________
3861 {
3862 
3863  //fOutputContainer->Print(); // Will crash on GRID
3864 }
3865 
3866 //________________________________________________________________________
3868 
3869  if (daughter == 111) {
3870  if (TMath::Abs(pdgCode) == 310) return 1; // k0s
3871  else if (TMath::Abs(pdgCode) == 3122) return 2; // Lambda
3872  else if (TMath::Abs(pdgCode) == 130) return 3; // K0L
3873  else if (TMath::Abs(pdgCode) == 2212) return 4; // proton
3874  else if (TMath::Abs(pdgCode) == 2112) return 5; // neutron
3875  else if (TMath::Abs(pdgCode) == 211) return 6; // pion
3876  else if (TMath::Abs(pdgCode) == 321) return 7; // kaon
3877  else if (TMath::Abs(pdgCode) == 113 || TMath::Abs(pdgCode) == 213 ) return 8; // rho 0,+,-
3878  else if (TMath::Abs(pdgCode) == 3222 || TMath::Abs(pdgCode) == 3212 || TMath::Abs(pdgCode) == 3112 ) return 9; // Sigma
3879  else if (TMath::Abs(pdgCode) == 2224 || TMath::Abs(pdgCode) == 2214 || TMath::Abs(pdgCode) == 2114 || TMath::Abs(pdgCode) == 1114 ) return 10; // Delta
3880  else if (TMath::Abs(pdgCode) == 313 || TMath::Abs(pdgCode) == 323 ) return 11; // K*
3881  else return 15;
3882  }
3883  return 15;
3884 
3885 }
3886 
3887 //_________________________________________________________________________________
3889  TObjArray *arr = input.Tokenize(",");
3890  for (Int_t i = 0; i < arr->GetEntriesFast();i++){
3891  TString tempStr = ((TObjString*)arr->At(i))->GetString();
3892  if (tempStr.Atoi() == tobechecked) return kTRUE;
3893  }
3894  return kFALSE;
3895 }
3896 
3897 //_________________________________________________________________________________
3899  TObjArray *arr = input.Tokenize(",");
3900  Bool_t isContained = kFALSE;
3901  for (Int_t i = 0; i < arr->GetEntriesFast();i++){
3902  TString tempStr = ((TObjString*)arr->At(i))->GetString();
3903  if (tempStr.Atoi() == tobechecked) isContained= kTRUE;
3904  }
3905  if (!isContained)input.Append(Form("%i,",tobechecked));
3906  return isContained;
3907 }
3908 
3909 //_________________________________________________________________________________
3911 
3912  if (!fMCEvent) return;
3913 
3914  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3915  Double_t mcProdVtxX = primVtxMC->GetX();
3916  Double_t mcProdVtxY = primVtxMC->GetY();
3917  Double_t mcProdVtxZ = primVtxMC->GetZ();
3918 
3919  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
3920 
3921  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
3922 
3923  if (gamma0->IsTrueConvertedPhoton()){
3924  Int_t gamma0MotherLabel = -1;
3925  Int_t gamma0MCLabel = gamma0->GetMCParticleLabel(fMCEvent);
3926  if(gamma0MCLabel != -1){
3927  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
3928  gamma0MotherLabel=gammaMC0->GetFirstMother();
3929  if (gamma0MotherLabel>-1){
3930  if(((TParticle*)fMCEvent->Particle(gamma0MotherLabel))->GetPdgCode() == 111){
3932 
3933  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, gamma0MotherLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3934 
3935  if (!isPrimary){
3936  Int_t secMotherLabel = ((TParticle*)fMCEvent->Particle(gamma0MotherLabel))->GetMother(0);
3937  Float_t weightedSec= 1;
3938  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, fMCEvent, fInputEvent) && fMCEvent->Particle(secMotherLabel)->GetPdgCode()==310){
3939  weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(secMotherLabel, fMCEvent, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
3940  }
3941  fHistoTrueSecondaryPi0MissingPtconv[fiCut]->Fill(gamma0->Pt(),weightedSec);
3942  } else {
3943  Float_t weighted= 1;
3944  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma0MotherLabel, fMCEvent, fInputEvent)){
3945  if (((TParticle*)fMCEvent->Particle(gamma0MotherLabel))->Pt()>0.005){
3946  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma0MotherLabel, fMCEvent, fInputEvent);
3947  }
3948  }
3949  fHistoTruePrimaryPi0MissingPtconv[fiCut]->Fill(gamma0->Pt(),weighted);
3950  }
3951  }
3952  } else if(((TParticle*)fMCEvent->Particle(gamma0MotherLabel))->GetPdgCode() == 221){
3954  Float_t weighted= 1;
3955  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma0MotherLabel, fMCEvent, fInputEvent)){
3956  if (((TParticle*)fMCEvent->Particle(gamma0MotherLabel))->Pt()>0.005){
3957  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma0MotherLabel, fMCEvent, fInputEvent);
3958  }
3959  }
3960  fHistoTruePrimaryEtaMissingPtconv[fiCut]->Fill(gamma0->Pt(),weighted);
3961  }
3962  }
3963  }
3964  }
3965  }
3966  }
3967 
3968 }
3969 
3970 //_________________________________________________________________________________
3972 
3973  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3974  Double_t mcProdVtxX = primVtxMC->GetX();
3975  Double_t mcProdVtxY = primVtxMC->GetY();
3976  Double_t mcProdVtxZ = primVtxMC->GetZ();
3977 
3978  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3979 
3980  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
3981  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
3982 
3983  if (gamma0->IsTrueConvertedPhoton()){
3984  AliAODMCParticle *positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0->GetMCLabelPositive()));
3985  AliAODMCParticle *negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0->GetMCLabelNegative()));
3986 
3987  Int_t gamma0MCLabel = -1;
3988  Int_t gamma0MotherLabel = -1;
3989  if(!positiveMC||!negativeMC)
3990  return;
3991 
3992  if (gamma0->IsTrueConvertedPhoton()){
3993  gamma0MCLabel = positiveMC->GetMother();
3994  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3995  gamma0MotherLabel=gammaMC0->GetMother();
3996 
3997  if (gamma0MotherLabel>-1){
3998  if(((AliAODMCParticle*)AODMCTrackArray->At(gamma0MotherLabel))->GetPdgCode() == 111){
4000  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel)), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
4001  if (isPrimary){
4002  Int_t secMotherLabel = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel))->GetMother();
4003  Float_t weightedSec= 1;
4004  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, 0x0, fInputEvent) && static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
4005  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
4006  }
4007  fHistoTrueSecondaryPi0MissingPtconv[fiCut]->Fill(gamma0->Pt(),weightedSec);
4008  } else {
4009  Float_t weighted= 1;
4010  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma0MotherLabel, 0x0, fInputEvent)){
4011  if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel))->Pt()>0.005){
4012  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma0MotherLabel, 0x0, fInputEvent);
4013  }
4014  }
4015  fHistoTruePrimaryPi0MissingPtconv[fiCut]->Fill(gamma0->Pt(),weighted);
4016  }
4017  }
4018  } else if(((AliAODMCParticle*)AODMCTrackArray->At(gamma0MotherLabel))->GetPdgCode() == 221){
4020  Float_t weighted= 1;
4021  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma0MotherLabel, 0x0, fInputEvent)){
4022  if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel))->Pt()>0.005){
4023  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma0MotherLabel, 0x0, fInputEvent);
4024  }
4025  }
4026  fHistoTruePrimaryEtaMissingPtconv[fiCut]->Fill(gamma0->Pt(),weighted);
4027  }
4028  }
4029  }
4030  }
4031  }
4032  }
4033 
4034  return;
4035 }
4036 
4037 //________________________________________________________________________
4039 
4040  const AliVVertex* primVtxMC = 0;
4041  Double_t mcProdVtxX = 0;
4042  Double_t mcProdVtxY = 0;
4043  Double_t mcProdVtxZ = 0;
4044 
4045 
4046 
4047 
4048  if ( fMCEvent ) {
4049 
4050  primVtxMC = fMCEvent->GetPrimaryVertex();
4051  mcProdVtxX = primVtxMC->GetX();
4052  mcProdVtxY = primVtxMC->GetY();
4053  mcProdVtxZ = primVtxMC->GetZ();
4054 
4055  }
4056 
4057 
4058 
4059  Double_t magField = fInputEvent->GetMagneticField();
4060 
4061 
4062  if( magField < 0.0 ){
4063 
4064  magField = 1.0;
4065 
4066  } else {
4067 
4068  magField = -1.0;
4069  }
4070 
4071 
4072  vector<Int_t> lGoodElectronIndexPrev(0);
4073  vector<Int_t> lGoodPositronIndexPrev(0);
4074 
4075 
4076 
4077  for(UInt_t i = 0; i < fSelectorElectronIndex.size(); i++){
4078 
4079  AliESDtrack* electronCandidate = (AliESDtrack*)fInputEvent->GetTrack(fSelectorElectronIndex[i]);
4080 
4081  if( fMCEvent ) {
4082 
4083  Int_t labelelectron = TMath::Abs( electronCandidate->GetLabel() );
4084  Int_t isMCFromMBHeader = -1;
4085 
4086  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0) {
4087  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(labelelectron,fMCEvent,fInputEvent);
4088  if( isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut) )->GetSignalRejection() != 3) continue;
4089  }
4090 
4091  }
4092 
4093 
4094  if(! ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->ElectronIsSelected(electronCandidate) ) continue;
4095 
4096  lGoodElectronIndexPrev.push_back( fSelectorElectronIndex[i] );
4097  fHistoDalitzElectronPt[fiCut]->Fill(electronCandidate->Pt());
4098  fHistoDalitzElectronPhi[fiCut]->Fill(electronCandidate->Phi());
4099 
4100 
4101  if( fMCEvent ) {
4102 
4103  Int_t labelelectron = TMath::Abs( electronCandidate->GetLabel() );
4104 
4105  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelelectron, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
4106 
4107 
4108  if( labelelectron >=0 && labelelectron < fMCEvent->GetNumberOfTracks() ){
4109  TParticle* electron = fMCEvent->Particle(labelelectron);
4110  if( electron->GetPdgCode() == 11 ){
4111  if( isPrimary ){
4112  fHistoTrueElectronPt[fiCut]->Fill(electronCandidate->Pt()); //primary electron
4113  } else {
4114  fHistoTrueSecElectronPt[fiCut]->Fill(electronCandidate->Pt()); //secondary electron
4115  }
4116  if( IsPi0DalitzDaughter(labelelectron) == kTRUE ) {
4117  if( isPrimary ) {
4118  fHistoTruePi0DalitzElectronPt[fiCut]->Fill(electronCandidate->Pt());
4119  } else {
4120  fHistoTruePi0DalitzSecElectronPt[fiCut]->Fill(electronCandidate->Pt());
4121  }
4122  }
4123  }
4124  }
4125  }
4126 
4127  }
4128 
4129 
4130 
4131  for(UInt_t i = 0; i < fSelectorPositronIndex.size(); i++){
4132 
4133 
4134  AliESDtrack* positronCandidate = (AliESDtrack*)fInputEvent->GetTrack( fSelectorPositronIndex[i] );
4135 
4136  if( fMCEvent ) {
4137 
4138  Int_t labelpositron = TMath::Abs( positronCandidate->GetLabel() );
4139  Int_t isMCFromMBHeader = -1;
4140 
4141  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0) {
4142  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(labelpositron,fMCEvent,fInputEvent);
4143  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
4144  }
4145  }
4146 
4147 
4148  if(! ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->ElectronIsSelected(positronCandidate) ) continue;
4149 
4150  lGoodPositronIndexPrev.push_back( fSelectorPositronIndex[i] );
4151  fHistoDalitzPositronPt[fiCut]->Fill( positronCandidate->Pt() );
4152  fHistoDalitzPositronPhi[fiCut]->Fill( positronCandidate->Phi() );
4153 
4154  if( fMCEvent ) {
4155  Int_t labelpositron = TMath::Abs( positronCandidate->GetLabel() );
4156  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelpositron, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
4157 
4158 
4159  if( labelpositron >=0 && labelpositron < fMCEvent->GetNumberOfTracks() ) {
4160  TParticle* positron = fMCEvent->Particle(labelpositron);
4161  if( positron->GetPdgCode() == -11 ){
4162  if( isPrimary ){
4163  fHistoTruePositronPt[fiCut]->Fill(positronCandidate->Pt());
4164  } else {
4165  fHistoTrueSecPositronPt[fiCut]->Fill(positronCandidate->Pt());
4166  }
4167  if( IsPi0DalitzDaughter(labelpositron) == kTRUE ) {
4168  if( isPrimary ){
4169  fHistoTruePi0DalitzPositronPt[fiCut]->Fill(positronCandidate->Pt());
4170  } else {
4171  fHistoTruePi0DalitzSecPositronPt[fiCut]->Fill(positronCandidate->Pt());
4172  }
4173  }
4174  }
4175  }
4176  }
4177  }
4178 
4179  vector<Bool_t> lElectronPsiIndex(lGoodElectronIndexPrev.size(), kTRUE);
4180  vector<Bool_t> lPositronPsiIndex(lGoodPositronIndexPrev.size(), kTRUE);
4181 
4182  if( ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->DoPsiPairCut() == kTRUE ){
4183  for( UInt_t i = 0; i < lGoodElectronIndexPrev.size(); i++ ) {
4184  AliESDtrack *electronCandidate = (AliESDtrack*) fInputEvent->GetTrack(lGoodElectronIndexPrev[i]);
4185  for(UInt_t j = 0; j < lGoodPositronIndexPrev.size(); j++){
4186 
4187  AliESDtrack *positronCandidate = (AliESDtrack*) fInputEvent->GetTrack(lGoodPositronIndexPrev[j]);
4188  Double_t psiPair = GetPsiPair(positronCandidate,electronCandidate);
4189  Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->GetConstrainedParam()->Phi()-positronCandidate->GetConstrainedParam()->Phi());
4190 
4191  if( ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->IsFromGammaConversion(psiPair,deltaPhi ) ){
4192  lElectronPsiIndex[i] = kFALSE;
4193  lPositronPsiIndex[j] = kFALSE;
4194  }
4195  }
4196  }
4197  }
4198 
4199  vector<Int_t> lGoodElectronIndex(0);
4200  vector<Int_t> lGoodPositronIndex(0);
4201 
4202  for( UInt_t i = 0; i < lGoodElectronIndexPrev.size(); i++ ) {
4203  if( lElectronPsiIndex[i] == kTRUE )
4204  lGoodElectronIndex.push_back( lGoodElectronIndexPrev[i] );
4205  }
4206 
4207  for( UInt_t i = 0; i < lGoodPositronIndexPrev.size(); i++ ) {
4208  if( lPositronPsiIndex[i] == kTRUE )
4209  lGoodPositronIndex.push_back( lGoodPositronIndexPrev[i] );
4210  }
4211 
4212 
4213  for(UInt_t i = 0; i < lGoodElectronIndex.size(); i++){
4214 
4215  AliESDtrack *electronCandidate = (AliESDtrack*)fInputEvent->GetTrack(lGoodElectronIndex[i]);
4216  AliKFParticle electronCandidateKF( *electronCandidate->GetConstrainedParam(), ::kElectron );
4217 
4218  TLorentzVector electronCandidateTLV;
4219 
4220  electronCandidateTLV.SetXYZM(electronCandidate->GetConstrainedParam()->Px(),electronCandidate->GetConstrainedParam()->Py(),electronCandidate->GetConstrainedParam()->Pz(),TDatabasePDG::Instance()->GetParticle( ::kElectron )->Mass());
4221 
4222 
4223  for(UInt_t j = 0; j < lGoodPositronIndex.size(); j++){
4224 
4225  AliESDtrack *positronCandidate = (AliESDtrack*) fInputEvent->GetTrack(lGoodPositronIndex[j]);
4226  AliKFParticle positronCandidateKF( *positronCandidate->GetConstrainedParam(), ::kPositron );
4227  TLorentzVector positronCandidateTLV;
4228 
4229  positronCandidateTLV.SetXYZM(positronCandidate->GetConstrainedParam()->Px(),positronCandidate->GetConstrainedParam()->Py(),positronCandidate->GetConstrainedParam()->Pz(),TDatabasePDG::Instance()->GetParticle( ::kPositron )->Mass());
4230 
4231  TLorentzVector *virtualPhotonTLV = 0;
4232  AliKFConversionPhoton* virtualPhoton = NULL;
4233  AliAODConversionPhoton *vphoton;
4234 
4235  if( ((AliDalitzElectronCuts*)fElectronCutArray->At(fiCut))->GetUseElectronMCSmearing() && ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseMCPSmearing() && fMCEvent){
4236  TLorentzVector smearelectronCandidateTLV = ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->SmearElectron(electronCandidateTLV);
4237  TLorentzVector smearpositronCandidateTLV = ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->SmearElectron(positronCandidateTLV);
4238  virtualPhotonTLV = new TLorentzVector( smearelectronCandidateTLV + smearpositronCandidateTLV );
4239  vphoton= new AliAODConversionPhoton(virtualPhotonTLV);
4240  vphoton->SetMass(virtualPhotonTLV->M());
4241  } else {
4242  virtualPhoton = new AliKFConversionPhoton(electronCandidateKF,positronCandidateKF);
4243 
4244  AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex());
4245  primaryVertexImproved+=*virtualPhoton;
4246  virtualPhoton->SetProductionVertex(primaryVertexImproved);
4247 
4248  vphoton= new AliAODConversionPhoton(virtualPhoton);
4249  }
4250  vphoton->SetTrackLabels( lGoodPositronIndex[j], lGoodElectronIndex[i]);
4251 
4252  if( fMCEvent ) {
4253  Int_t labeln=TMath::Abs(electronCandidate->GetLabel());
4254  Int_t labelp=TMath::Abs(positronCandidate->GetLabel());
4255  TParticle *fNegativeMCParticle = fMCEvent->Particle(labeln);
4256  TParticle *fPositiveMCParticle = fMCEvent->Particle(labelp);
4257 
4258  if( fPositiveMCParticle && fNegativeMCParticle) {
4259  vphoton->SetMCLabelPositive(labelp);
4260  vphoton->SetMCLabelNegative(labeln);
4261 
4262  }
4263  }
4264 
4265 
4266  fVirtualGammaCandidates->Add( vphoton );
4267 
4268  if( virtualPhoton ){
4269  delete virtualPhoton;
4270  virtualPhoton=NULL;
4271  }
4272  if ( virtualPhotonTLV ){
4273  delete virtualPhotonTLV;
4274  virtualPhotonTLV=NULL;
4275  }
4276 
4277  }
4278  }
4279 
4280 }
4281 
4282 //_____________________________________________________________________________________
4284 {
4285 //
4286 // Returns true if the particle comes from Pi0 -> e+ e- gamma
4287 //
4288  Int_t motherLabel = fMCEvent->Particle( label )->GetMother(0);
4289 
4290  if( motherLabel < 0 || motherLabel >= fMCEvent->GetNumberOfTracks() ) return kFALSE;
4291 
4292  TParticle* mother = fMCEvent->Particle( motherLabel );
4293 
4294  if( mother->GetPdgCode() != 111 ) return kFALSE;
4295 
4296  if( IsDalitz( mother ) ) return kTRUE;
4297 
4298  return kFALSE;
4299 
4300 }
4301 //_____________________________________________________________________________
4302 Double_t AliAnalysisTaskGammaCaloDalitzV1::GetPsiPair( const AliESDtrack *trackPos, const AliESDtrack *trackNeg ) const
4303 {
4304  //
4305  // This angle is a measure for the contribution of the opening in polar
4306  // direction ?0 to the opening angle ? Pair
4307  //
4308  // Ref. Measurement of photons via conversion pairs with the PHENIX experiment at RHIC
4309  // Master Thesis. Thorsten Dahms. 2005
4310  // https://twiki.cern.ch/twiki/pub/ALICE/GammaPhysicsPublications/tdahms_thesis.pdf
4311  //
4312  Double_t momPos[3];
4313  Double_t momNeg[3];
4314  if( trackPos->GetConstrainedPxPyPz(momPos) == 0 ) trackPos->GetPxPyPz( momPos );
4315  if( trackNeg->GetConstrainedPxPyPz(momNeg) == 0 ) trackNeg->GetPxPyPz( momNeg );
4316 
4317  TVector3 posDaughter;
4318  TVector3 negDaughter;
4319 
4320  posDaughter.SetXYZ( momPos[0], momPos[1], momPos[2] );
4321  negDaughter.SetXYZ( momNeg[0], momNeg[1], momNeg[2] );
4322 
4323  Double_t deltaTheta = negDaughter.Theta() - posDaughter.Theta();
4324  Double_t openingAngle = posDaughter.Angle( negDaughter ); //TMath::ACos( posDaughter.Dot(negDaughter)/(negDaughter.Mag()*posDaughter.Mag()) );
4325 
4326  if( openingAngle < 1e-20 ) return 0.;
4327 
4328  Double_t psiAngle = TMath::ASin( deltaTheta/openingAngle );
4329 
4330  return psiAngle;
4331 }
4332 //_____________________________________________________________________________
4334 {
4335 
4336  if( fMCMother->GetNDaughters() != 3 ) return kFALSE;
4337  if( fMCMother->GetPdgCode() != 111 && fMCMother->GetPdgCode() != 221 ) return kFALSE;
4338 
4339 
4340  TParticle *positron = 0x0;
4341  TParticle *electron = 0x0;
4342  TParticle *gamma = 0x0;
4343 
4344  for(Int_t index= fMCMother->GetFirstDaughter();index<= fMCMother->GetLastDaughter();index++){
4345  TParticle* temp = (TParticle*)fMCEvent->Particle( index );
4346  switch( temp->GetPdgCode() ) {
4347  case ::kPositron:
4348  positron = temp;
4349  break;
4350  case ::kElectron:
4351  electron = temp;
4352  break;
4353  case ::kGamma:
4354  gamma = temp;
4355  break;
4356  }
4357  }
4358 
4359  if( positron && electron && gamma) return kTRUE;
4360 
4361  return kFALSE;
4362 }
4363 
4364 //_________________________________________________________________
4366 
4367 
4368 
4369  if( particleLabel < 0 ) return -1;
4370 
4371  TParticle* particle = (TParticle*)fMCEvent->Particle( particleLabel );
4372 
4373  if( particle->GetMother(0) < 0 ) return -1;
4374 
4375  else if ( ((TParticle*)fMCEvent->Particle( particle->GetMother(0) ) )->GetPdgCode() == 111 ||
4376  ((TParticle*)fMCEvent->Particle( particle->GetMother(0) ) )->GetPdgCode() == 221 ) {
4377 
4378  return particle->GetMother(0);
4379  }
4380 
4381  else return FindMotherOfPhoton( particle->GetMother(0) );
4382 
4383 
4384 }
4385 
4386 //_________________________________________________________________________________
4388 {
4389  if(tobechecked > -1)
4390  {
4391  vector<Int_t>::iterator it;
4392  it = find (vec.begin(), vec.end(), tobechecked);
4393  if (it != vec.end()) return true;
4394  else{
4395  vec.push_back(tobechecked);