AliPhysics  608b256 (608b256)
AliAnalysisTaskNeutralMesonToPiPlPiMiNeutralMeson.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: Friederike Bock *
5  * Version 1 *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 //
17 
18 #include <memory>
19 #include <vector>
20 #include "TParticle.h"
21 #include "TPDGCode.h"
22 #include "TMCProcess.h"
23 #include "TDatabasePDG.h"
24 #include "TList.h"
25 #include "TChain.h"
26 #include "TDirectory.h"
27 #include "TTree.h"
28 #include "TH1.h"
29 #include "TH1F.h"
30 #include "THnSparse.h"
31 #include "TH2F.h"
32 #include "AliAnalysisManager.h"
33 #include "AliESDInputHandler.h"
34 #include "AliESDtrack.h"
35 #include "AliMCEvent.h"
36 #include "AliMCEventHandler.h"
37 #include "AliPID.h"
38 #include "AliLog.h"
39 #include "AliESDtrackCuts.h"
40 #include "AliESDpidCuts.h"
41 #include "AliMCEvent.h"
42 #include "AliESDv0.h"
43 #include "AliESDEvent.h"
44 #include "AliESDpid.h"
45 #include "AliKFParticle.h"
46 #include "AliMCEventHandler.h"
47 #include "AliKFVertex.h"
48 #include "AliTriggerAnalysis.h"
49 #include "AliCentrality.h"
50 #include "AliMultiplicity.h"
51 #include "AliAODEvent.h"
53 #include "AliCaloTrackMatcher.h"
54 #include <vector>
55 
57 
58 //-----------------------------------------------------------------------------------------------
60  fV0Reader(nullptr),
61  fV0ReaderName("V0ReaderV1"),
62  fPionSelector(NULL),
63  fBGHandlerPiPl(NULL),
64  fBGHandlerPiMi(NULL),
65  fInputEvent(NULL),
66  fMCEvent(NULL),
67  fCutFolder(NULL),
68  fESDList(NULL),
69  fTrueList(NULL),
70  fTrueTreeList(NULL),
71  fMCList(NULL),
72  fOutputContainer(0),
73  fReaderGammas(nullptr),
74  fSelectorNegPionIndex(0),
75  fSelectorPosPionIndex(0),
76  fGoodConvGammas(nullptr),
77  fClusterCandidates(nullptr),
78  fNeutralDecayParticleCandidates(nullptr),
79  fNeutralDecayParticleSidebandCandidates(nullptr),
80  fPosPionCandidates(nullptr),
81  fNegPionCandidates(nullptr),
82  fGoodVirtualParticles(nullptr),
83  fEventCutArray(nullptr),
84  fGammaCutArray(nullptr),
85  fClusterCutArray(nullptr),
86  fPionCutArray(nullptr),
87  fNeutralDecayMesonCutArray(nullptr),
88  fMesonCutArray(nullptr),
89  fEventCuts(nullptr),
90  fConversionCuts(nullptr),
91  fClusterCuts(nullptr),
92  fTreePiPiSameMother(nullptr),
93  fTreePiPiPiSameMother(nullptr),
94  fTreeEventInfoHNM(nullptr),
95  fCasePiPi(-1),
96  fSamePiPiMotherID(-1),
97  fSamePiPiMotherInvMass(-1),
98  fSamePiPiMotherPt(-1),
99  fSamePiPiPiMotherID(-1),
100  fSamePiPiPiMotherInvMass(-1),
101  fSamePiPiPiMotherPt(-1),
102  fV0MultiplicityHNMEvent(-1),
103  fTrackMultiplicityHNMEvent(-1),
104  fZVertexHNMEvent(-1),
105  fPtHNM(-1),
106  fPDGMassNDM(-1),
107  fPDGCodeNDM(-1),
108  fPDGCodeAnalyzedMeson(-1),
109  fHistoConvGammaPt(nullptr),
110  fHistoConvGammaEta(nullptr),
111  fHistoClusterGammaPt(nullptr),
112  fHistoClusterGammaEta(nullptr),
113  fHistoNegPionPt(nullptr),
114  fHistoPosPionPt(nullptr),
115  fHistoNegPionPhi(nullptr),
116  fHistoPosPionPhi(nullptr),
117  fHistoNegPionEta(nullptr),
118  fHistoPosPionEta(nullptr),
119  fHistoNegPionClsTPC(nullptr),
120  fHistoPosPionClsTPC(nullptr),
121  fHistoPionDCAxy(nullptr),
122  fHistoPionDCAz(nullptr),
123  fHistoPionTPCdEdxNSigma(nullptr),
124  fHistoPionTPCdEdx(nullptr),
125  fHistoPionPionInvMassPt(nullptr),
126  fHistoGammaGammaInvMassPt(nullptr),
127  fHistoGammaGammaInvMassPtBeforeCuts(nullptr),
128  fHistoMotherInvMassPt(nullptr),
129  fHistoMotherInvMassPtRejectedKinematic(nullptr),
130  fHistoBackInvMassPtGroup1(nullptr),
131  fHistoBackInvMassPtGroup2(nullptr),
132  fHistoBackInvMassPtGroup3(nullptr),
133  fHistoBackInvMassPtGroup4(nullptr),
134  fHistoMotherLikeSignBackInvMassPt(nullptr),
135  fHistoAngleHNMesonPiPlPiMi(nullptr),
136  fHistoAngleHNMesonNDM(nullptr),
137  fHistoAngleHNMesonPiPl(nullptr),
138  fHistoAngleHNMesonPiMi(nullptr),
139  fHistoAnglePiPlPiMi(nullptr),
140  fHistoAngleNDMPiMi(nullptr),
141  fHistoAnglePiPlNDM(nullptr),
142  fHistoAngleSum(nullptr),
143  fHistoTrueAngleSum(nullptr),
144  fHistoMotherInvMassSubNDM(nullptr),
145  fHistoBackInvMassPtGroup1SubNDM(nullptr),
146  fHistoBackInvMassPtGroup2SubNDM(nullptr),
147  fHistoBackInvMassPtGroup3SubNDM(nullptr),
148  fHistoBackInvMassPtGroup4SubNDM(nullptr),
149  fHistoMotherLikeSignBackInvMassSubNDMPt(nullptr),
150  fHistoMotherInvMassFixedPzNDM(nullptr),
151  fHistoBackInvMassPtGroup1FixedPzNDM(nullptr),
152  fHistoBackInvMassPtGroup2FixedPzNDM(nullptr),
153  fHistoBackInvMassPtGroup3FixedPzNDM(nullptr),
154  fHistoBackInvMassPtGroup4FixedPzNDM(nullptr),
155  fHistoMotherLikeSignBackInvMassFixedPzNDMPt(nullptr),
156  fHistoMCAllGammaPt(nullptr),
157  fHistoMCConvGammaPt(nullptr),
158  fHistoMCAllMesonPt(nullptr),
159  fHistoMCAllMesonEta(nullptr),
160  fHistoMCAllMesonPhi(nullptr),
161  fHistoMCMesonFromNeutralMesonPt(nullptr),
162  fHistoMCMesonFromNeutralMesonEta(nullptr),
163  fHistoMCMesonFromNeutralMesonPhi(nullptr),
164  fHistoMCAllPosPionsPt(nullptr),
165  fHistoMCAllPosPionsEta(nullptr),
166  fHistoMCAllPosPionsPhi(nullptr),
167  fHistoMCAllNegPionsPt(nullptr),
168  fHistoMCAllNegPionsEta(nullptr),
169  fHistoMCAllNegPionsPhi(nullptr),
170  fHistoMCGammaFromNeutralMesonPt(nullptr),
171  fHistoMCPosPionsFromNeutralMesonPt(nullptr),
172  fHistoMCPosPionsFromNeutralMesonEta(nullptr),
173  fHistoMCPosPionsFromNeutralMesonPhi(nullptr),
174  fHistoMCNegPionsFromNeutralMesonPt(nullptr),
175  fHistoMCNegPionsFromNeutralMesonEta(nullptr),
176  fHistoMCNegPionsFromNeutralMesonPhi(nullptr),
177  fHistoMCHNMPiPlPiMiNDMPt(nullptr),
178  fHistoMCHNMPiPlPiMiNDMInAccPt(nullptr),
179  fHistoMCHeavyAllPt(nullptr),
180  fHistoMCHeavyAllEta(nullptr),
181  fHistoMCHeavyAllPhi(nullptr),
182  fHistoMCHeavyChannelPt(nullptr),
183  fHistoMCHeavyChannelEta(nullptr),
184  fHistoMCHeavyChannelPhi(nullptr),
185  fHistMCChannelNDMFromHeavyPt(nullptr),
186  fHistMCChannelNDMFromHeavyEta(nullptr),
187  fHistMCChannelNDMFromHeavyPhi(nullptr),
188  fHistMCChannelPiPlusFromHeavyPt(nullptr),
189  fHistMCChannelPiPlusFromHeavyEta(nullptr),
190  fHistMCChannelPiPlusFromHeavyPhi(nullptr),
191  fHistMCChannelPiMinusFromHeavyPt(nullptr),
192  fHistMCChannelPiMinusFromHeavyEta(nullptr),
193  fHistMCChannelPiPMinusFromHeavyPhi(nullptr),
194  fHistMCChannelNDMPtHeavyPt(nullptr),
195  fHistMCChannelPiPlusPtHeavyPt(nullptr),
196  fHistMCChannelPiMinusPtHeavyPt(nullptr),
197  fHistoMCHeavyReconstructiblePt(nullptr),
198  fHistoMCHeavyReconstructibleEta(nullptr),
199  fHistoMCHeavyReconstructiblePhi(nullptr),
200  fHistMCReconstructibleNDMFromHeavyPt(nullptr),
201  fHistMCReconstructibleNDMFromHeavyEta(nullptr),
202  fHistMCReconstructibleNDMFromHeavyPhi(nullptr),
203  fHistMCReconstructiblePiPlusFromHeavyPt(nullptr),
204  fHistMCReconstructiblePiPlusFromHeavyEta(nullptr),
205  fHistMCReconstructiblePiPlusFromHeavyPhi(nullptr),
206  fHistMCReconstructiblePiMinusFromHeavyPt(nullptr),
207  fHistMCReconstructiblePiMinusFromHeavyEta(nullptr),
208  fHistMCReconstructiblePiPMinusFromHeavyPhi(nullptr),
209  fHistMCReconstructibleNDMPtHeavyPt(nullptr),
210  fHistMCReconstructiblePiPlusPtHeavyPt(nullptr),
211  fHistMCReconstructiblePiMinusPtHeavyPt(nullptr),
212  fHistoTrueMotherPiPlPiMiNDMInvMassPt(nullptr),
213  fHistoTrueMotherHNMPiPlPiMiNDMInvMassPt(nullptr),
214  fHistoTrueMotherGammaGammaInvMassPt(nullptr),
215  fHistoTrueMotherGammaGammaFromHNMInvMassPt(nullptr),
216  fHistoTrueConvGammaPt(nullptr),
217  fHistoTrueConvGammaFromNeutralMesonPt(nullptr),
218  fHistoTrueClusterGammaPt(nullptr),
219  fHistoTrueClusterGammaFromNeutralMesonPt(nullptr),
220  fHistoTruePosPionPt(nullptr),
221  fHistoTruePosPionFromNeutralMesonPt(nullptr),
222  fHistoTrueNegPionPt(nullptr),
223  fHistoTrueNegPionFromNeutralMesonPt(nullptr),
224  fHistoTruePionPionInvMassPt(nullptr),
225  fHistoTruePionPionFromSameMotherInvMassPt(nullptr),
226  fHistoTruePionPionFromHNMInvMassPt(nullptr),
227  fHistoTruePiPlPiMiSameMotherFromEtaInvMassPt(nullptr),
228  fHistoTruePiPlPiMiSameMotherFromOmegaInvMassPt(nullptr),
229  fHistoTruePiPlPiMiSameMotherFromRhoInvMassPt(nullptr),
230  fHistoTruePiPlPiMiSameMotherFromEtaPrimeInvMassPt(nullptr),
231  fHistoTruePiPlPiMiSameMotherFromK0sInvMassPt(nullptr),
232  fHistoTruePiPlPiMiSameMotherFromK0lInvMassPt(nullptr),
233  fHistoTruePiMiPiZeroSameMotherFromEtaInvMassPt(nullptr),
234  fHistoTruePiMiPiZeroSameMotherFromOmegaInvMassPt(nullptr),
235  fHistoTruePiMiPiZeroSameMotherFromRhoInvMassPt(nullptr),
236  fHistoTruePiMiPiZeroSameMotherFromK0lInvMassPt(nullptr),
237  fHistoTruePiPlPiZeroSameMotherFromEtaInvMassPt(nullptr),
238  fHistoTruePiPlPiZeroSameMotherFromOmegaInvMassPt(nullptr),
239  fHistoTruePiPlPiZeroSameMotherFromRhoInvMassPt(nullptr),
240  fHistoTruePiPlPiZeroSameMotherFromK0lInvMassPt(nullptr),
241  fHistoTruePiPlPiMiNDMPureCombinatoricalInvMassPt(nullptr),
242  fHistoTruePiPlPiMiNDMContaminationInvMassPt(nullptr),
243  fHistoDoubleCountTruePi0InvMassPt(nullptr),
244  fHistoDoubleCountTrueHNMInvMassPt(nullptr),
245  fHistoDoubleCountTrueConvGammaRPt(nullptr),
246  fVectorDoubleCountTruePi0s(0),
247  fVectorDoubleCountTrueHNMs(0),
248  fVectorDoubleCountTrueConvGammas(0),
249  fHistoNEvents(nullptr),
250  fProfileJetJetXSection(nullptr),
251  fHistoJetJetNTrials(nullptr),
252  fHistoNGoodESDTracks(nullptr),
253  fProfileEtaShift(nullptr),
254  fHistoSPDClusterTrackletBackground(nullptr),
255  fRandom(0),
256  fnCuts(0),
257  fiCut(0),
258  fNumberOfESDTracks(0),
259  fMoveParticleAccordingToVertex(kFALSE),
260  fIsHeavyIon(0),
261  fDoMesonAnalysis(kTRUE),
262  fDoMesonQA(0),
263  fIsFromMBHeader(kTRUE),
264  fIsMC(kFALSE),
265  fSelectedHeavyNeutralMeson(kFALSE),
266  fDoLightOutput(kFALSE),
267  fNDMRecoMode(0),
268  fTolerance(-1),
269  fWeightJetJetMC(1.),
270  fTrackMatcherRunningMode(0),
271  fMCEventPos(),
272  fMCEventNeg(),
273  fESDArrayPos(),
274  fESDArrayNeg()
275 {
276 
277 }
278 
279 //-----------------------------------------------------------------------------------------------
281  AliAnalysisTaskSE(name),
282  fV0Reader(nullptr),
283  fV0ReaderName("V0ReaderV1"),
284  fPionSelector(NULL),
285  fBGHandlerPiPl(NULL),
286  fBGHandlerPiMi(NULL),
287  fInputEvent(NULL),
288  fMCEvent(NULL),
289  fCutFolder(NULL),
290  fESDList(NULL),
291  fTrueList(NULL),
292  fTrueTreeList(NULL),
293  fMCList(NULL),
294  fOutputContainer(0),
295  fReaderGammas(nullptr),
296  fSelectorNegPionIndex(0),
297  fSelectorPosPionIndex(0),
298  fGoodConvGammas(nullptr),
299  fClusterCandidates(nullptr),
300  fNeutralDecayParticleCandidates(nullptr),
301  fNeutralDecayParticleSidebandCandidates(nullptr),
302  fPosPionCandidates(nullptr),
303  fNegPionCandidates(nullptr),
304  fGoodVirtualParticles(nullptr),
305  fEventCutArray(nullptr),
306  fGammaCutArray(nullptr),
307  fClusterCutArray(nullptr),
308  fPionCutArray(nullptr),
309  fNeutralDecayMesonCutArray(nullptr),
310  fMesonCutArray(nullptr),
311  fEventCuts(nullptr),
312  fConversionCuts(nullptr),
313  fClusterCuts(nullptr),
314  fTreePiPiSameMother(nullptr),
315  fTreePiPiPiSameMother(nullptr),
316  fTreeEventInfoHNM(nullptr),
317  fCasePiPi(-1),
318  fSamePiPiMotherID(-1),
319  fSamePiPiMotherInvMass(-1),
320  fSamePiPiMotherPt(-1),
321  fSamePiPiPiMotherID(-1),
322  fSamePiPiPiMotherInvMass(-1),
323  fSamePiPiPiMotherPt(-1),
324  fV0MultiplicityHNMEvent(-1),
325  fTrackMultiplicityHNMEvent(-1),
326  fZVertexHNMEvent(-1),
327  fPtHNM(-1),
328  fPDGMassNDM(-1),
329  fPDGCodeNDM(-1),
330  fPDGCodeAnalyzedMeson(-1),
331  fHistoConvGammaPt(nullptr),
332  fHistoConvGammaEta(nullptr),
333  fHistoClusterGammaPt(nullptr),
334  fHistoClusterGammaEta(nullptr),
335  fHistoNegPionPt(nullptr),
336  fHistoPosPionPt(nullptr),
337  fHistoNegPionPhi(nullptr),
338  fHistoPosPionPhi(nullptr),
339  fHistoNegPionEta(nullptr),
340  fHistoPosPionEta(nullptr),
341  fHistoNegPionClsTPC(nullptr),
342  fHistoPosPionClsTPC(nullptr),
343  fHistoPionDCAxy(nullptr),
344  fHistoPionDCAz(nullptr),
345  fHistoPionTPCdEdxNSigma(nullptr),
346  fHistoPionTPCdEdx(nullptr),
347  fHistoPionPionInvMassPt(nullptr),
348  fHistoGammaGammaInvMassPt(nullptr),
349  fHistoGammaGammaInvMassPtBeforeCuts(nullptr),
350  fHistoMotherInvMassPt(nullptr),
351  fHistoMotherInvMassPtRejectedKinematic(nullptr),
352  fHistoBackInvMassPtGroup1(nullptr),
353  fHistoBackInvMassPtGroup2(nullptr),
354  fHistoBackInvMassPtGroup3(nullptr),
355  fHistoBackInvMassPtGroup4(nullptr),
356  fHistoMotherLikeSignBackInvMassPt(nullptr),
357  fHistoAngleHNMesonPiPlPiMi(nullptr),
358  fHistoAngleHNMesonNDM(nullptr),
359  fHistoAngleHNMesonPiPl(nullptr),
360  fHistoAngleHNMesonPiMi(nullptr),
361  fHistoAnglePiPlPiMi(nullptr),
362  fHistoAngleNDMPiMi(nullptr),
363  fHistoAnglePiPlNDM(nullptr),
364  fHistoAngleSum(nullptr),
365  fHistoTrueAngleSum(nullptr),
366  fHistoMotherInvMassSubNDM(nullptr),
367  fHistoBackInvMassPtGroup1SubNDM(nullptr),
368  fHistoBackInvMassPtGroup2SubNDM(nullptr),
369  fHistoBackInvMassPtGroup3SubNDM(nullptr),
370  fHistoBackInvMassPtGroup4SubNDM(nullptr),
371  fHistoMotherLikeSignBackInvMassSubNDMPt(nullptr),
372  fHistoMotherInvMassFixedPzNDM(nullptr),
373  fHistoBackInvMassPtGroup1FixedPzNDM(nullptr),
374  fHistoBackInvMassPtGroup2FixedPzNDM(nullptr),
375  fHistoBackInvMassPtGroup3FixedPzNDM(nullptr),
376  fHistoBackInvMassPtGroup4FixedPzNDM(nullptr),
377  fHistoMotherLikeSignBackInvMassFixedPzNDMPt(nullptr),
378  fHistoMCAllGammaPt(nullptr),
379  fHistoMCConvGammaPt(nullptr),
380  fHistoMCAllMesonPt(nullptr),
381  fHistoMCAllMesonEta(nullptr),
382  fHistoMCAllMesonPhi(nullptr),
383  fHistoMCMesonFromNeutralMesonPt(nullptr),
384  fHistoMCMesonFromNeutralMesonEta(nullptr),
385  fHistoMCMesonFromNeutralMesonPhi(nullptr),
386  fHistoMCAllPosPionsPt(nullptr),
387  fHistoMCAllPosPionsEta(nullptr),
388  fHistoMCAllPosPionsPhi(nullptr),
389  fHistoMCAllNegPionsPt(nullptr),
390  fHistoMCAllNegPionsEta(nullptr),
391  fHistoMCAllNegPionsPhi(nullptr),
392  fHistoMCGammaFromNeutralMesonPt(nullptr),
393  fHistoMCPosPionsFromNeutralMesonPt(nullptr),
394  fHistoMCPosPionsFromNeutralMesonEta(nullptr),
395  fHistoMCPosPionsFromNeutralMesonPhi(nullptr),
396  fHistoMCNegPionsFromNeutralMesonPt(nullptr),
397  fHistoMCNegPionsFromNeutralMesonEta(nullptr),
398  fHistoMCNegPionsFromNeutralMesonPhi(nullptr),
399  fHistoMCHNMPiPlPiMiNDMPt(nullptr),
400  fHistoMCHNMPiPlPiMiNDMInAccPt(nullptr),
401  fHistoMCHeavyAllPt(nullptr),
402  fHistoMCHeavyAllEta(nullptr),
403  fHistoMCHeavyAllPhi(nullptr),
404  fHistoMCHeavyChannelPt(nullptr),
405  fHistoMCHeavyChannelEta(nullptr),
406  fHistoMCHeavyChannelPhi(nullptr),
407  fHistMCChannelNDMFromHeavyPt(nullptr),
408  fHistMCChannelNDMFromHeavyEta(nullptr),
409  fHistMCChannelNDMFromHeavyPhi(nullptr),
410  fHistMCChannelPiPlusFromHeavyPt(nullptr),
411  fHistMCChannelPiPlusFromHeavyEta(nullptr),
412  fHistMCChannelPiPlusFromHeavyPhi(nullptr),
413  fHistMCChannelPiMinusFromHeavyPt(nullptr),
414  fHistMCChannelPiMinusFromHeavyEta(nullptr),
415  fHistMCChannelPiPMinusFromHeavyPhi(nullptr),
416  fHistMCChannelNDMPtHeavyPt(nullptr),
417  fHistMCChannelPiPlusPtHeavyPt(nullptr),
418  fHistMCChannelPiMinusPtHeavyPt(nullptr),
419  fHistoMCHeavyReconstructiblePt(nullptr),
420  fHistoMCHeavyReconstructibleEta(nullptr),
421  fHistoMCHeavyReconstructiblePhi(nullptr),
422  fHistMCReconstructibleNDMFromHeavyPt(nullptr),
423  fHistMCReconstructibleNDMFromHeavyEta(nullptr),
424  fHistMCReconstructibleNDMFromHeavyPhi(nullptr),
425  fHistMCReconstructiblePiPlusFromHeavyPt(nullptr),
426  fHistMCReconstructiblePiPlusFromHeavyEta(nullptr),
427  fHistMCReconstructiblePiPlusFromHeavyPhi(nullptr),
428  fHistMCReconstructiblePiMinusFromHeavyPt(nullptr),
429  fHistMCReconstructiblePiMinusFromHeavyEta(nullptr),
430  fHistMCReconstructiblePiPMinusFromHeavyPhi(nullptr),
431  fHistMCReconstructibleNDMPtHeavyPt(nullptr),
432  fHistMCReconstructiblePiPlusPtHeavyPt(nullptr),
433  fHistMCReconstructiblePiMinusPtHeavyPt(nullptr),
434  fHistoTrueMotherPiPlPiMiNDMInvMassPt(nullptr),
435  fHistoTrueMotherHNMPiPlPiMiNDMInvMassPt(nullptr),
436  fHistoTrueMotherGammaGammaInvMassPt(nullptr),
437  fHistoTrueMotherGammaGammaFromHNMInvMassPt(nullptr),
438  fHistoTrueConvGammaPt(nullptr),
439  fHistoTrueConvGammaFromNeutralMesonPt(nullptr),
440  fHistoTrueClusterGammaPt(nullptr),
441  fHistoTrueClusterGammaFromNeutralMesonPt(nullptr),
442  fHistoTruePosPionPt(nullptr),
443  fHistoTruePosPionFromNeutralMesonPt(nullptr),
444  fHistoTrueNegPionPt(nullptr),
445  fHistoTrueNegPionFromNeutralMesonPt(nullptr),
446  fHistoTruePionPionInvMassPt(nullptr),
447  fHistoTruePionPionFromSameMotherInvMassPt(nullptr),
448  fHistoTruePionPionFromHNMInvMassPt(nullptr),
449  fHistoTruePiPlPiMiSameMotherFromEtaInvMassPt(nullptr),
450  fHistoTruePiPlPiMiSameMotherFromOmegaInvMassPt(nullptr),
451  fHistoTruePiPlPiMiSameMotherFromRhoInvMassPt(nullptr),
452  fHistoTruePiPlPiMiSameMotherFromEtaPrimeInvMassPt(nullptr),
453  fHistoTruePiPlPiMiSameMotherFromK0sInvMassPt(nullptr),
454  fHistoTruePiPlPiMiSameMotherFromK0lInvMassPt(nullptr),
455  fHistoTruePiMiPiZeroSameMotherFromEtaInvMassPt(nullptr),
456  fHistoTruePiMiPiZeroSameMotherFromOmegaInvMassPt(nullptr),
457  fHistoTruePiMiPiZeroSameMotherFromRhoInvMassPt(nullptr),
458  fHistoTruePiMiPiZeroSameMotherFromK0lInvMassPt(nullptr),
459  fHistoTruePiPlPiZeroSameMotherFromEtaInvMassPt(nullptr),
460  fHistoTruePiPlPiZeroSameMotherFromOmegaInvMassPt(nullptr),
461  fHistoTruePiPlPiZeroSameMotherFromRhoInvMassPt(nullptr),
462  fHistoTruePiPlPiZeroSameMotherFromK0lInvMassPt(nullptr),
463  fHistoTruePiPlPiMiNDMPureCombinatoricalInvMassPt(nullptr),
464  fHistoTruePiPlPiMiNDMContaminationInvMassPt(nullptr),
465  fHistoDoubleCountTruePi0InvMassPt(nullptr),
466  fHistoDoubleCountTrueHNMInvMassPt(nullptr),
467  fHistoDoubleCountTrueConvGammaRPt(nullptr),
468  fVectorDoubleCountTruePi0s(0),
469  fVectorDoubleCountTrueHNMs(0),
470  fVectorDoubleCountTrueConvGammas(0),
471  fHistoNEvents(nullptr),
472  fProfileJetJetXSection(nullptr),
473  fHistoJetJetNTrials(nullptr),
474  fHistoNGoodESDTracks(nullptr),
475  fProfileEtaShift(nullptr),
476  fHistoSPDClusterTrackletBackground(nullptr),
477  fRandom(0),
478  fnCuts(0),
479  fiCut(0),
480  fNumberOfESDTracks(0),
481  fMoveParticleAccordingToVertex(kFALSE),
482  fIsHeavyIon(0),
483  fDoMesonAnalysis(kTRUE),
484  fDoMesonQA(0),
485  fIsFromMBHeader(kTRUE),
486  fIsMC(kFALSE),
487  fSelectedHeavyNeutralMeson(kFALSE),
488  fDoLightOutput(kFALSE),
489  fNDMRecoMode(0),
490  fTolerance(-1),
491  fWeightJetJetMC(1.),
492  fTrackMatcherRunningMode(0),
493  fMCEventPos(),
494  fMCEventNeg(),
495  fESDArrayPos(),
496  fESDArrayNeg()
497 {
498  DefineOutput(1, TList::Class());
499 }
500 
501 //-----------------------------------------------------------------------------------------------
503 {
504  //
505  // virtual destructor
506  //
507  cout<<"Destructor"<<endl;
508  if(fGoodConvGammas){
509  delete fGoodConvGammas;
510  }
511  if(fClusterCandidates){
512  delete fClusterCandidates;
513  }
514 
517  }
518 
521  }
522 
523  if(fPosPionCandidates){
524  delete fPosPionCandidates;
525  }
526 
527  if(fNegPionCandidates){
528  delete fNegPionCandidates;
529  }
530 
532  delete fGoodVirtualParticles;
533  }
534 
535  if(fBGHandlerPiPl){
536  for(int icut = 0; icut < fnCuts; icut++)
537  delete fBGHandlerPiPl[icut];
538  delete[] fBGHandlerPiPl;
539  }
540 
541  if(fBGHandlerPiMi){
542  for(int icut = 0; icut < fnCuts; icut++)
543  delete fBGHandlerPiMi[icut];
544  delete[] fBGHandlerPiMi;
545  }
546 }
547 //___________________________________________________________
549 
552 
553  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
554 
555  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
556  TString cutstringPion = ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutNumber();
557  TString cutstringConvGamma = "";
558  if (fNDMRecoMode < 2) cutstringConvGamma = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
559  TString cutstringCaloGamma = "";
560  if (fNDMRecoMode > 0) cutstringCaloGamma = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
561  TString cutstringNeutralPion= ((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(iCut))->GetCutNumber();
562  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
563 
564  TString fullCutString = "";
565  if (fNDMRecoMode == 0) fullCutString = Form("%i_%s_%s_%s_%s_%s",fNDMRecoMode,cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringNeutralPion.Data(), cutstringPion.Data(),cutstringMeson.Data());
566  else if (fNDMRecoMode == 1) fullCutString = Form("%i_%s_%s_%s_%s_%s_%s",fNDMRecoMode,cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringCaloGamma.Data(),cutstringNeutralPion.Data(), cutstringPion.Data(),cutstringMeson.Data());
567  else if (fNDMRecoMode == 2) fullCutString = Form("%i_%s_%s_%s_%s_%s",fNDMRecoMode,cutstringEvent.Data(),cutstringCaloGamma.Data(),cutstringNeutralPion.Data(), cutstringPion.Data(),cutstringMeson.Data());
568 
569  Int_t collisionSystem = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(0,1));
570  Int_t centMin = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(1,1));
571  Int_t centMax = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(2,1));
572 
573  if(collisionSystem == 1 || collisionSystem == 2 ||
574  collisionSystem == 5 || collisionSystem == 8 ||
575  collisionSystem == 9){
576  centMin = centMin*10;
577  centMax = centMax*10;
578  }
579  else if(collisionSystem == 3 || collisionSystem == 6){
580  centMin = centMin*5;
581  centMax = centMax*5;
582  }
583  else if(collisionSystem == 4 || collisionSystem == 7){
584  centMin = ((centMin*5)+45);
585  centMax = ((centMax*5)+45);
586  }
587 
588  fBGHandlerPiPl[iCut] = new AliGammaConversionAODBGHandler( collisionSystem,centMin,centMax,
589  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents(),
590  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity(),
591  4,8,5);
592 
593  fBGHandlerPiMi[iCut] = new AliGammaConversionAODBGHandler( collisionSystem,centMin,centMax,
594  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents(),
595  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity(),
596  4,8,5);
597  }
598 }
599 
600 //______________________________________________________________________
602 {
603  //
604  // Create ouput objects
605  //
606 
607  // Set pT and mass ranges
608  Double_t HistoNMassBins = 600;
609  Double_t HistoMassRange[2] = {0.4,1.0};
610  Double_t HistoNMassBinsSub = 600;
611  Double_t HistoMassRangeSub[2] = {0.4,1.0};
612  Double_t HistoNPtBins = 250;
613  Double_t HistoPtRange[2] = {0.,25.};
614  Double_t HistoNMassBinsDecayMeson = 450;
615  Double_t HistoMassRangeNDM[2] = {0.0,0.45};
616  Double_t HistoNMassBinsPiPlusPiMinus = 2000;
617  Double_t HistoMassRangePiPlusPiMinus[2] = {0.0,2.0};
618  TString NameNeutralMesonAnalyzed = "not set";
619  TString NameNeutralMesonAnalyzedLatex = "not set";
620  TString NameNDM = "not set";
621  TString NameNDMLatex = "not set";
622 
623  switch( fSelectedHeavyNeutralMeson ) {
624  case 0: // ETA MESON
625  HistoNMassBins = 400;
626  HistoMassRange[0] = 0.3;
627  HistoMassRange[1] = 0.7;
628  HistoNMassBinsSub = 400;
629  HistoMassRangeSub[0] = 0.3;
630  HistoMassRangeSub[1] = 0.7;
631  HistoNMassBinsDecayMeson = 450;
632  HistoMassRangeNDM[0] = 0.0;
633  HistoMassRangeNDM[1] = 0.45;
634  NameNeutralMesonAnalyzed = "Eta";
635  NameNeutralMesonAnalyzedLatex = "#eta";
636  NameNDM = "NeutralPion";
637  NameNDMLatex = "#pi^{0}";
638  fPDGMassNDM = 0.1349766; // hard coded PDG value to keep results reproducable later
639  fPDGCodeNDM = 111; // PDG pi0
640  fPDGCodeAnalyzedMeson = 221; // PDG omega
641  break;
642  case 1: // OMEGA MESON
643  HistoNMassBins = 500;
644  HistoMassRange[0] = 0.5;
645  HistoMassRange[1] = 1.0;
646  HistoNMassBinsSub = 500;
647  HistoMassRangeSub[0] = 0.5;
648  HistoMassRangeSub[1] = 1.0;
649  HistoNMassBinsDecayMeson = 450;
650  HistoMassRangeNDM[0] = 0.0;
651  HistoMassRangeNDM[1] = 0.45;
652  NameNeutralMesonAnalyzed = "Omega";
653  NameNeutralMesonAnalyzedLatex = "#omega";
654  NameNDM = "NeutralPion";
655  NameNDMLatex = "#pi^{0}";
656  fPDGMassNDM = 0.1349766; // hard coded PDG value to keep results reproducable later
657  fPDGCodeNDM = 111; // PDG pi0
658  fPDGCodeAnalyzedMeson = 223; // PDG omega
659  break;
660  case 2: // ETA PRIME MESON
661  HistoNMassBins = 600;
662  HistoMassRange[0] = 0.6;
663  HistoMassRange[1] = 1.2;
664  HistoNMassBinsSub = 600;
665  HistoMassRangeSub[0] = 0.6;
666  HistoMassRangeSub[1] = 1.2;
667  HistoNMassBinsDecayMeson = 450;
668  HistoMassRangeNDM[0] = 0.4;
669  HistoMassRangeNDM[1] = 0.85;
670  NameNeutralMesonAnalyzed = "EtaPrime";
671  NameNeutralMesonAnalyzedLatex = "#eta'";
672  NameNDM = "EtaMeson";
673  NameNDMLatex = "#eta";
674  fPDGMassNDM = 0.547862; // hard coded PDG value to keep results reproducable later
675  fPDGCodeNDM = 221; // PDG value eta
676  fPDGCodeAnalyzedMeson = 331; // PDG value eta prime
677  break;
678  case 3: // D0 MESON
679  HistoNMassBins = 600;
680  HistoMassRange[0] = 1.4;
681  HistoMassRange[1] = 2.0;
682  HistoNMassBinsSub = 400; // MF: Background subtraction?
683  HistoMassRangeSub[0] = 1.6;
684  HistoMassRangeSub[1] = 2.0;
685  HistoNMassBinsDecayMeson = 450;
686  HistoMassRangeNDM[0] = 0.0;
687  HistoMassRangeNDM[1] = 0.45;
688  HistoNPtBins = 500;
689  HistoPtRange[1] = 50.;
690  NameNeutralMesonAnalyzed = "D0";
691  NameNeutralMesonAnalyzedLatex = "D^{0}";
692  NameNDM = "NeutralPion";
693  NameNDMLatex = "#pi^{0}";
694  fPDGMassNDM = 0.1349766; // hard coded PDG value to keep results reproducable later
695  fPDGCodeNDM = 111; // PDG value pi0
696  fPDGCodeAnalyzedMeson = 421; // PDG value D0
697  break;
698  default:
699  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
700  }
701 
702  // Create the output container
703  if(fOutputContainer != nullptr){
704  delete fOutputContainer;
705  fOutputContainer = nullptr;
706  }
707  if(fOutputContainer == nullptr){
708  fOutputContainer = new TList();
709  fOutputContainer->SetOwner(kTRUE);
710  }
711 
712  fGoodConvGammas = new TList();
713  fClusterCandidates = new TList();
714  fClusterCandidates->SetOwner(kTRUE);
715 
717  fNeutralDecayParticleCandidates->SetOwner(kTRUE);
718 
721 
722 
723  fPosPionCandidates = new TList();
724  fPosPionCandidates->SetOwner(kTRUE);
725  fNegPionCandidates = new TList();
726  fNegPionCandidates->SetOwner(kTRUE);
728  fGoodVirtualParticles->SetOwner(kTRUE);
729 
730  fCutFolder = new TList*[fnCuts];
731  fESDList = new TList*[fnCuts];
732  fHistoNEvents = new TH1I*[fnCuts];
734  if(fIsMC == 2) {
735  fProfileJetJetXSection = new TProfile*[fnCuts];
736  fHistoJetJetNTrials = new TH1F*[fnCuts];
737  }
738  if(!fDoLightOutput){
739  fProfileEtaShift = new TProfile*[fnCuts];
741 
742  if (fNDMRecoMode < 2){
743  fHistoConvGammaPt = new TH1F*[fnCuts];
744  fHistoConvGammaEta = new TH1F*[fnCuts];
745  }
746  if (fNDMRecoMode > 0){
747  fHistoClusterGammaPt = new TH1F*[fnCuts];
748  fHistoClusterGammaEta = new TH1F*[fnCuts];
749  }
750  fHistoNegPionPt = new TH1F*[fnCuts];
751  fHistoPosPionPt = new TH1F*[fnCuts];
752  fHistoNegPionPhi = new TH1F*[fnCuts];
753  fHistoPosPionPhi = new TH1F*[fnCuts];
755 
756  if( fDoMesonQA>0 ) {
757  fHistoNegPionEta = new TH1F*[fnCuts];
758  fHistoPosPionEta = new TH1F*[fnCuts];
761  fHistoPionDCAxy = new TH2F*[fnCuts];
762  fHistoPionDCAz = new TH2F*[fnCuts];
764  fHistoPionTPCdEdx = new TH2F*[fnCuts];
765  }
766 
767 
775  fHistoAngleSum = new TH2F*[fnCuts];
776  }
777 
786 
788 
794 
796 
802 
804 
805  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
806  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
807  TString cutstringPion = ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutNumber();
808  TString cutstringConvGamma = "";
809  if (fNDMRecoMode < 2)
810  cutstringConvGamma = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
811  TString cutstringCaloGamma = "";
812  if (fNDMRecoMode > 0)
813  cutstringCaloGamma = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
814  TString cutstringNeutralPion = ((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(iCut))->GetCutNumber();
815  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
816 
817  TString fullCutString = "";
818  if (fNDMRecoMode == 0)
819  fullCutString = Form("%i_%s_%s_%s_%s_%s",fNDMRecoMode,cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringNeutralPion.Data(), cutstringPion.Data(),cutstringMeson.Data());
820  else if (fNDMRecoMode == 1)
821  fullCutString = Form("%i_%s_%s_%s_%s_%s_%s",fNDMRecoMode,cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringCaloGamma.Data(),cutstringNeutralPion.Data(), cutstringPion.Data(),cutstringMeson.Data());
822  else if (fNDMRecoMode == 2)
823  fullCutString = Form("%i_%s_%s_%s_%s_%s",fNDMRecoMode,cutstringEvent.Data(),cutstringCaloGamma.Data(),cutstringNeutralPion.Data(), cutstringPion.Data(),cutstringMeson.Data());
824  TString nameCutFolder = Form("Cut Number %s", fullCutString.Data());
825  TString nameESDList = Form("%s ESD histograms", fullCutString.Data());
826 
827  fCutFolder[iCut] = new TList();
828  fCutFolder[iCut]->SetName(nameCutFolder.Data());
829  fCutFolder[iCut]->SetOwner(kTRUE);
830  fOutputContainer->Add(fCutFolder[iCut]);
831 
832  fESDList[iCut] = new TList();
833  fESDList[iCut]->SetName(nameESDList.Data());
834  fESDList[iCut]->SetOwner(kTRUE);
835 
836  fHistoNEvents[iCut] = new TH1I("NEvents","NEvents",14,-0.5,13.5);
837  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
838  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
839  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
840  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
841  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
842  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
843  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
844  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
845  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
846  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
847  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
848  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
849  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
850  fHistoNEvents[iCut]->GetYaxis()->SetTitle("N_{events}");
851  fESDList[iCut]->Add(fHistoNEvents[iCut]);
852 
853  if (fIsMC == 2){
854  fProfileJetJetXSection[iCut] = new TProfile("XSection", "XSection", 1, -0.5, 0.5);
855  fESDList[iCut]->Add(fProfileJetJetXSection[iCut]);
856  fHistoJetJetNTrials[iCut] = new TH1F("NTrials", "#sum{NTrials}", 1, 0, 1);
857  fHistoJetJetNTrials[iCut]->GetXaxis()->SetBinLabel(1,"#sum{NTrials}");
858  fESDList[iCut]->Add(fHistoJetJetNTrials[iCut]);
859  }
860 
861  if(fIsHeavyIon>0)
862  fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",3000,0,3000);
863  else
864  fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
865  fHistoNGoodESDTracks[iCut]->GetXaxis()->SetTitle("N_{good ESD tracks}");
866  fHistoNGoodESDTracks[iCut]->GetYaxis()->SetTitle("N_{events}");
867  fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
868  if(!fDoLightOutput){
869  fProfileEtaShift[iCut] = new TProfile("Eta Shift","Eta Shift",1, -0.5,0.5);
870  fESDList[iCut]->Add(fProfileEtaShift[iCut]);
871  fHistoSPDClusterTrackletBackground[iCut] = new TH2F("SPD tracklets vs SPD clusters","SPD tracklets vs SPD clusters",100,0,200,250,0,1000);
872  fHistoSPDClusterTrackletBackground[iCut]->GetXaxis()->SetTitle("N_{SPD tracklets}");
873  fHistoSPDClusterTrackletBackground[iCut]->GetYaxis()->SetTitle("N_{SPD clusters}");
875  if (fNDMRecoMode < 2){
876  fHistoConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt","ESD_ConvGamma_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
877  fHistoConvGammaPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
878  fHistoConvGammaPt[iCut]->GetYaxis()->SetTitle("N_{#gamma,conv}");
879  fESDList[iCut]->Add(fHistoConvGammaPt[iCut]);
880  fHistoConvGammaEta[iCut] = new TH1F("ESD_ConvGamma_Eta","ESD_ConvGamma_Eta",600,-1.5,1.5);
881  fHistoConvGammaEta[iCut]->GetXaxis()->SetTitle("#eta");
882  fHistoConvGammaEta[iCut]->GetYaxis()->SetTitle("N_{#gamma,conv}");
883  fESDList[iCut]->Add(fHistoConvGammaEta[iCut]);
884  }
885  if (fNDMRecoMode > 0){
886  fHistoClusterGammaPt[iCut] = new TH1F("ESD_ClusterGamma_Pt","ESD_ClusterGamma_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
887  fHistoClusterGammaPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
888  fHistoClusterGammaPt[iCut]->GetYaxis()->SetTitle("N_{#gamma,cluster}");
889  fESDList[iCut]->Add(fHistoClusterGammaPt[iCut]);
890  fHistoClusterGammaEta[iCut] = new TH1F("ESD_ClusterGamma_Eta","ESD_ClusterGamma_Eta",600,-1.5,1.5);
891  fHistoClusterGammaEta[iCut]->GetXaxis()->SetTitle("#eta");
892  fHistoClusterGammaEta[iCut]->GetYaxis()->SetTitle("N_{#gamma,cluster}");
893  fESDList[iCut]->Add(fHistoClusterGammaEta[iCut]);
894  }
895  fHistoNegPionPt[iCut] = new TH1F("ESD_PrimaryNegPions_Pt","ESD_PrimaryNegPions_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
896  fHistoNegPionPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
897  fHistoNegPionPt[iCut]->GetYaxis()->SetTitle("N_{#pi^{-}}");
898  fESDList[iCut]->Add(fHistoNegPionPt[iCut]);
899  fHistoPosPionPt[iCut] = new TH1F("ESD_PrimaryPosPions_Pt","ESD_PrimaryPosPions_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
900  fHistoPosPionPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
901  fHistoPosPionPt[iCut]->GetYaxis()->SetTitle("N_{#pi^{+}}");
902  fESDList[iCut]->Add(fHistoPosPionPt[iCut]);
903  fHistoNegPionPhi[iCut] = new TH1F("ESD_PrimaryNegPions_Phi","ESD_PrimaryNegPions_Phi",360,0,2*TMath::Pi());
904  fHistoNegPionPhi[iCut]->GetXaxis()->SetTitle("#phi");
905  fHistoNegPionPhi[iCut]->GetYaxis()->SetTitle("N_{#pi^{-}}");
906  fESDList[iCut]->Add(fHistoNegPionPhi[iCut]);
907  fHistoPosPionPhi[iCut] = new TH1F("ESD_PrimaryPosPions_Phi","ESD_PrimaryPosPions_Phi",360,0,2*TMath::Pi());
908  fHistoPosPionPhi[iCut]->GetXaxis()->SetTitle("#phi");
909  fHistoPosPionPhi[iCut]->GetYaxis()->SetTitle("N_{#pi^{+}}");
910  fESDList[iCut]->Add(fHistoPosPionPhi[iCut]);
911  fHistoPionPionInvMassPt[iCut] = new TH2F("ESD_PiPlusPiNeg_InvMassPt","ESD_PiPlusPiNeg_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
912  fHistoPionPionInvMassPt[iCut]->GetXaxis()->SetTitle("M_{#pi^{+}#pi^{-}} (GeV/c^{2})");
913  fHistoPionPionInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
914  fESDList[iCut]->Add(fHistoPionPionInvMassPt[iCut]);
915 
916  if ( fDoMesonQA>0 ) {
917  fHistoNegPionEta[iCut] = new TH1F("ESD_PrimaryNegPions_Eta","ESD_PrimaryNegPions_Eta",600,-1.5,1.5);
918  fHistoNegPionEta[iCut]->GetXaxis()->SetTitle("#eta");
919  fHistoNegPionEta[iCut]->GetYaxis()->SetTitle("N_{#pi^{-}}");
920  fESDList[iCut]->Add(fHistoNegPionEta[iCut]);
921  fHistoPosPionEta[iCut] = new TH1F("ESD_PrimaryPosPions_Eta","ESD_PrimaryPosPions_Eta",600,-1.5,1.5);
922  fHistoPosPionEta[iCut]->GetXaxis()->SetTitle("#eta");
923  fHistoPosPionEta[iCut]->GetYaxis()->SetTitle("N_{#pi^{+}}");
924  fESDList[iCut]->Add(fHistoPosPionEta[iCut]);
925  fHistoNegPionClsTPC[iCut] = new TH2F("ESD_PrimaryNegPions_ClsTPC","ESD_PrimaryNegPions_ClsTPC",100,0,1,400,0.,10.);
926  fHistoNegPionClsTPC[iCut]->GetXaxis()->SetTitle("N_{findable cls. TPC #pi^{-}}");
927  fHistoNegPionClsTPC[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
928  fESDList[iCut]->Add(fHistoNegPionClsTPC[iCut]);
929  fHistoPosPionClsTPC[iCut] = new TH2F("ESD_PrimaryPosPions_ClsTPC","ESD_PrimaryPosPions_ClsTPC",100,0,1,400,0.,10.);
930  fHistoPosPionClsTPC[iCut]->GetXaxis()->SetTitle("N_{findable cls. TPC #pi^{+}}");
931  fHistoPosPionClsTPC[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
932  fESDList[iCut]->Add(fHistoPosPionClsTPC[iCut]);
933  fHistoPionDCAxy[iCut] = new TH2F("ESD_PrimaryPions_DCAxy","ESD_PrimaryPions_DCAxy",800,-4.0,4.0,400,0.,10.);
934  fHistoPionDCAxy[iCut]->GetXaxis()->SetTitle("DCA_{xy}");
935  fHistoPionDCAxy[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
936  fESDList[iCut]->Add(fHistoPionDCAxy[iCut]);
937  fHistoPionDCAz[iCut] = new TH2F("ESD_PrimaryPions_DCAz","ESD_PrimaryPions_DCAz",800,-4.0,4.0,400,0.,10.);
938  fHistoPionDCAz[iCut]->GetXaxis()->SetTitle("DCA_{z}");
939  fHistoPionDCAz[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
940  fESDList[iCut]->Add(fHistoPionDCAz[iCut]);
941  fHistoPionTPCdEdxNSigma[iCut] = new TH2F("ESD_PrimaryPions_TPCdEdx","ESD_PrimaryPions_TPCdEdx",150,0.05,20,400,-10,10);
942  fHistoPionTPCdEdxNSigma[iCut]->GetXaxis()->SetTitle("p (GeV/c)");
943  fHistoPionTPCdEdxNSigma[iCut]->GetYaxis()->SetTitle("#sigma_{PID,TPC}");
944  fESDList[iCut]->Add(fHistoPionTPCdEdxNSigma[iCut]);
945  fHistoPionTPCdEdx[iCut] = new TH2F("ESD_PrimaryPions_TPCdEdxSignal","ESD_PrimaryPions_TPCdEdxSignal" ,150,0.05,20.0,800,0.0,200);
946  fHistoPionTPCdEdx[iCut]->GetXaxis()->SetTitle("p (GeV/c)");
947  fHistoPionTPCdEdx[iCut]->GetYaxis()->SetTitle("dE/dx signal (au)");
948  fESDList[iCut]->Add(fHistoPionTPCdEdx[iCut]);
949  }
950  fHistoGammaGammaInvMassPt[iCut] = new TH2F("ESD_GammaGamma_InvMass_Pt","ESD_GammaGamma_InvMass_Pt",HistoNMassBinsDecayMeson,HistoMassRangeNDM[0],HistoMassRangeNDM[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
951  fHistoGammaGammaInvMassPt[iCut]->GetXaxis()->SetTitle("M_{#gamma #gamma} (GeV/c^{2})");
952  fHistoGammaGammaInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
953  fESDList[iCut]->Add(fHistoGammaGammaInvMassPt[iCut]);
954 
955  fHistoGammaGammaInvMassPtBeforeCuts[iCut] = new TH2F("ESD_GammaGamma_InvMass_Pt_Before_Cuts","ESD_GammaGamma_InvMass_Pt_Before_Cuts",HistoNMassBinsDecayMeson,HistoMassRangeNDM[0],HistoMassRangeNDM[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
956  fHistoGammaGammaInvMassPtBeforeCuts[iCut]->GetXaxis()->SetTitle("M_{#gamma #gamma} (GeV/c^{2})");
957  fHistoGammaGammaInvMassPtBeforeCuts[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
959  }
960  fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
961  fHistoMotherInvMassPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} (GeV/c^{2})",NameNDMLatex.Data()));
962  fHistoMotherInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
963  fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
964  fHistoMotherInvMassPtRejectedKinematic[iCut] = new TH2F("ESD_Mother_InvMass_Pt_KinematicRejected","ESD_Mother_InvMass_Pt_KinematicRejected",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
965  fHistoMotherInvMassPtRejectedKinematic[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} (GeV/c^{2})",NameNDMLatex.Data()));
966  fHistoMotherInvMassPtRejectedKinematic[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
968 
969  fHistoBackInvMassPtGroup1[iCut] = new TH2F("ESD_Background_1_InvMass_Pt","ESD_Background_1_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
970  fHistoBackInvMassPtGroup2[iCut] = new TH2F("ESD_Background_2_InvMass_Pt","ESD_Background_2_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
971  fHistoBackInvMassPtGroup3[iCut] = new TH2F("ESD_Background_3_InvMass_Pt","ESD_Background_3_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
972  fHistoBackInvMassPtGroup4[iCut] = new TH2F("ESD_Background_4_InvMass_Pt","ESD_Background_4_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
973  fHistoBackInvMassPtGroup1[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} (GeV/c^{2})",NameNDMLatex.Data()));
974  fHistoBackInvMassPtGroup1[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
975  fHistoBackInvMassPtGroup2[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} (GeV/c^{2})",NameNDMLatex.Data()));
976  fHistoBackInvMassPtGroup2[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
977  fHistoBackInvMassPtGroup3[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} (GeV/c^{2})",NameNDMLatex.Data()));
978  fHistoBackInvMassPtGroup3[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
979  fHistoBackInvMassPtGroup4[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} (GeV/c^{2})",NameNDMLatex.Data()));
980  fHistoBackInvMassPtGroup4[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
981  if(!(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseLikeSignMixing())){
982  fESDList[iCut]->Add(fHistoBackInvMassPtGroup1[iCut]);
983  fESDList[iCut]->Add(fHistoBackInvMassPtGroup2[iCut]);
984  fESDList[iCut]->Add(fHistoBackInvMassPtGroup3[iCut]);
985  fESDList[iCut]->Add(fHistoBackInvMassPtGroup4[iCut]);
986  }
987 
988  fHistoMotherLikeSignBackInvMassPt[iCut] = new TH2F("ESD_Background_LikeSign_InvMass_Pt","ESD_Background_LikeSign_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
989  fHistoMotherLikeSignBackInvMassPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{#pm} #pi^{#pm} %s} (GeV/c^{2})",NameNDMLatex.Data()));
990  fHistoMotherLikeSignBackInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
991  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseLikeSignMixing()){
993  }
994  fHistoMotherInvMassSubNDM[iCut] = new TH2F("ESD_InvMass_Mother_Sub_InvMass_Neutral_Pt","ESD_InvMass_Mother_Sub_InvMass_Neutral_Pt",HistoNMassBinsSub,HistoMassRangeSub[0],HistoMassRangeSub[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
995  fHistoMotherInvMassSubNDM[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} - (M_{%s}-M_{%s},PDG}) (GeV/c^{2})",NameNDMLatex.Data(),NameNDMLatex.Data(),NameNDMLatex.Data()));
996  fHistoMotherInvMassSubNDM[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
997  fESDList[iCut]->Add(fHistoMotherInvMassSubNDM[iCut]);
998 
999  fHistoBackInvMassPtGroup1SubNDM[iCut] = new TH2F("ESD_Background_1_InvMass_Sub_InvMass_Neutral_Pt","ESD_Background_1_InvMass_Sub_InvMass_Neutral_Pt",
1000  HistoNMassBinsSub,HistoMassRangeSub[0],HistoMassRangeSub[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1001  fHistoBackInvMassPtGroup2SubNDM[iCut] = new TH2F("ESD_Background_2_InvMass_Sub_InvMass_Neutral_Pt","ESD_Background_2_InvMass_Sub_InvMass_Neutral_Pt",
1002  HistoNMassBinsSub,HistoMassRangeSub[0],HistoMassRangeSub[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1003  fHistoBackInvMassPtGroup3SubNDM[iCut] = new TH2F("ESD_Background_3_InvMass_Sub_InvMass_Neutral_Pt","ESD_Background_3_InvMass_Sub_InvMass_Neutral_Pt",
1004  HistoNMassBinsSub,HistoMassRangeSub[0],HistoMassRangeSub[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1005  fHistoBackInvMassPtGroup4SubNDM[iCut] = new TH2F("ESD_Background_4_InvMass_Sub_InvMass_Neutral_Pt","ESD_Background_4_InvMass_Sub_InvMass_Neutral_Pt",
1006  HistoNMassBinsSub,HistoMassRangeSub[0],HistoMassRangeSub[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1007 
1008  fHistoBackInvMassPtGroup1SubNDM[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} - (M_{%s}-M_{%s},PDG}) (GeV/c^{2})",NameNDMLatex.Data(),NameNDMLatex.Data(),NameNDMLatex.Data()));
1009  fHistoBackInvMassPtGroup1SubNDM[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1010  fHistoBackInvMassPtGroup2SubNDM[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} - (M_{%s}-M_{%s},PDG}) (GeV/c^{2})",NameNDMLatex.Data(),NameNDMLatex.Data(),NameNDMLatex.Data()));
1011  fHistoBackInvMassPtGroup2SubNDM[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1012  fHistoBackInvMassPtGroup3SubNDM[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} - (M_{%s}-M_{%s},PDG}) (GeV/c^{2})",NameNDMLatex.Data(),NameNDMLatex.Data(),NameNDMLatex.Data()));
1013  fHistoBackInvMassPtGroup3SubNDM[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1014  fHistoBackInvMassPtGroup4SubNDM[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} - (M_{%s}-M_{%s},PDG}) (GeV/c^{2})",NameNDMLatex.Data(),NameNDMLatex.Data(),NameNDMLatex.Data()));
1015  fHistoBackInvMassPtGroup4SubNDM[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1016  if(!(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseLikeSignMixing())){
1017  fESDList[iCut]->Add(fHistoBackInvMassPtGroup4SubNDM[iCut]);
1018  fESDList[iCut]->Add(fHistoBackInvMassPtGroup1SubNDM[iCut]);
1019  fESDList[iCut]->Add(fHistoBackInvMassPtGroup2SubNDM[iCut]);
1020  fESDList[iCut]->Add(fHistoBackInvMassPtGroup3SubNDM[iCut]);
1021  }
1022  fHistoMotherLikeSignBackInvMassSubNDMPt[iCut] = new TH2F("ESD_Background_LikeSign_InvMass_Sub_InvMass_Neutral_Pt","ESD_Background_LikeSign_InvMass_Sub_InvMass_Neutral_Pt",
1023  HistoNMassBinsSub,HistoMassRangeSub[0],HistoMassRangeSub[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1024  fHistoMotherLikeSignBackInvMassSubNDMPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{#pm} #pi^{#pm} %s} - M_{%s} (GeV/c^{2})",NameNDMLatex.Data(),NameNDMLatex.Data()));
1025  fHistoMotherLikeSignBackInvMassSubNDMPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1026  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseLikeSignMixing()){
1028  }
1029  fHistoMotherInvMassFixedPzNDM[iCut] = new TH2F("ESD_InvMass_Mother_FixedPz_Neutral_Pt","ESD_Mother_InvMass_FixedPz_Neutral_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1030  fHistoMotherInvMassFixedPzNDM[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} (GeV/c^{2})",NameNDMLatex.Data()));
1031  fHistoMotherInvMassFixedPzNDM[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1032  fESDList[iCut]->Add(fHistoMotherInvMassFixedPzNDM[iCut]);
1033 
1034  fHistoBackInvMassPtGroup1FixedPzNDM[iCut] = new TH2F("ESD_Background_1_InvMass_FixedPz_Neutral_Pt","ESD_Background_1_InvMass_FixedPz_Neutral_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1035  fHistoBackInvMassPtGroup2FixedPzNDM[iCut] = new TH2F("ESD_Background_2_InvMass_FixedPz_Neutral_Pt","ESD_Background_2_InvMass_FixedPz_Neutral_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1036  fHistoBackInvMassPtGroup3FixedPzNDM[iCut] = new TH2F("ESD_Background_3_InvMass_FixedPz_Neutral_Pt","ESD_Background_3_InvMass_FixedPz_Neutral_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1037  fHistoBackInvMassPtGroup4FixedPzNDM[iCut] = new TH2F("ESD_Background_4_InvMass_FixedPz_Neutral_Pt","ESD_Background_4_InvMass_FixedPz_Neutral_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1038  fHistoBackInvMassPtGroup1FixedPzNDM[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} (GeV/c^{2})",NameNDMLatex.Data()));
1039  fHistoBackInvMassPtGroup1FixedPzNDM[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1040  fHistoBackInvMassPtGroup2FixedPzNDM[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} (GeV/c^{2})",NameNDMLatex.Data()));
1041  fHistoBackInvMassPtGroup2FixedPzNDM[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1042  fHistoBackInvMassPtGroup3FixedPzNDM[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} (GeV/c^{2})",NameNDMLatex.Data()));
1043  fHistoBackInvMassPtGroup3FixedPzNDM[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1044  fHistoBackInvMassPtGroup4FixedPzNDM[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} (GeV/c^{2})",NameNDMLatex.Data()));
1045  fHistoBackInvMassPtGroup4FixedPzNDM[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1046  if(!(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseLikeSignMixing())){
1051  }
1052  fHistoMotherLikeSignBackInvMassFixedPzNDMPt[iCut] = new TH2F("ESD_Background_LikeSign_InvMass_FixedPz_Neutral_Pt","ESD_Background_LikeSign_InvMass_FixedPz_Neutral_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1053  fHistoMotherLikeSignBackInvMassFixedPzNDMPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{#pm} #pi^{#pm} %s} (GeV/c^{2})",NameNDMLatex.Data()));
1054  fHistoMotherLikeSignBackInvMassFixedPzNDMPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1055  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseLikeSignMixing()){
1057  }
1058  if(!fDoLightOutput){
1059  fHistoAngleHNMesonPiPlPiMi[iCut] = new TH2F(Form("ESD_Mother_Angle%sNegPionsPosPions_Pt",NameNeutralMesonAnalyzed.Data()),Form("ESD_Mother_Angle%sNegPionsPosPions_Pt",NameNeutralMesonAnalyzed.Data()),HistoNPtBins,HistoPtRange[0],HistoPtRange[1],360,0,TMath::Pi());
1060  fHistoAngleHNMesonPiPlPiMi[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1061  fHistoAngleHNMesonPiPlPiMi[iCut]->GetYaxis()->SetTitle("#angle (meson,#pi^{+}#pi^{-})");
1062  fESDList[iCut]->Add(fHistoAngleHNMesonPiPlPiMi[iCut]);
1063  fHistoAngleHNMesonPiMi[iCut] = new TH2F(Form("ESD_Mother_Angle%sNegPions_Pt",NameNeutralMesonAnalyzed.Data()),Form("ESD_Mother_Angle%sNegPions_Pt",NameNeutralMesonAnalyzed.Data()),HistoNPtBins,HistoPtRange[0],HistoPtRange[1],360,0,TMath::Pi());
1064  fHistoAngleHNMesonPiMi[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1065  fHistoAngleHNMesonPiMi[iCut]->GetYaxis()->SetTitle("#angle (meson,#pi^{-})");
1066  fESDList[iCut]->Add(fHistoAngleHNMesonPiMi[iCut]);
1067  fHistoAngleHNMesonPiPl[iCut] = new TH2F(Form("ESD_Mother_Angle%sPosPions_Pt",NameNeutralMesonAnalyzed.Data()),Form("ESD_Mother_Angle%sPosPions_Pt",NameNeutralMesonAnalyzed.Data()),HistoNPtBins,HistoPtRange[0],HistoPtRange[1],360,0,TMath::Pi());
1068  fHistoAngleHNMesonPiPl[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1069  fHistoAngleHNMesonPiPl[iCut]->GetYaxis()->SetTitle("#angle (meson,#pi^{+})");
1070  fESDList[iCut]->Add(fHistoAngleHNMesonPiPl[iCut]);
1071  fHistoAngleHNMesonNDM[iCut] = new TH2F(Form("ESD_Mother_Angle%s%s_Pt",NameNeutralMesonAnalyzed.Data(),NameNDM.Data()),Form("ESD_Mother_Angle%s%s_Pt",NameNeutralMesonAnalyzed.Data(),NameNDM.Data()),HistoNPtBins,HistoPtRange[0],HistoPtRange[1],360,0,TMath::Pi());
1072  fHistoAngleHNMesonNDM[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1073  fHistoAngleHNMesonNDM[iCut]->GetYaxis()->SetTitle(Form("#angle (meson,%s)",NameNDMLatex.Data()));
1074  fESDList[iCut]->Add(fHistoAngleHNMesonNDM[iCut]);
1075  fHistoAnglePiPlNDM[iCut] = new TH2F(Form("ESD_Mother_AnglePosPions%s_Pt",NameNDM.Data()),Form("ESD_Mother_AnglePosPions%s_Pt",NameNDM.Data()),HistoNPtBins,HistoPtRange[0],HistoPtRange[1],360,0,TMath::Pi());
1076  fHistoAnglePiPlNDM[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1077  fHistoAnglePiPlNDM[iCut]->GetYaxis()->SetTitle(Form("#angle (#pi^{+},%s)",NameNDMLatex.Data()));
1078  fESDList[iCut]->Add(fHistoAnglePiPlNDM[iCut]);
1079  fHistoAnglePiPlPiMi[iCut] = new TH2F("ESD_Mother_AnglePosPionsNegPions_Pt","ESD_Mother_AnglePosPionsNegPions_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1],360,0,TMath::Pi());
1080  fHistoAnglePiPlPiMi[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1081  fHistoAnglePiPlPiMi[iCut]->GetYaxis()->SetTitle("#angle (#pi^{+},#pi^{-})");
1082  fESDList[iCut]->Add(fHistoAnglePiPlPiMi[iCut]);
1083  fHistoAngleNDMPiMi[iCut] = new TH2F(Form("ESD_Mother_Angle%sNegPions_Pt",NameNDM.Data()),Form("ESD_Mother_Angle%sNegPions_Pt",NameNDM.Data()),HistoNPtBins,HistoPtRange[0],HistoPtRange[1],360,0,TMath::Pi());
1084  fHistoAngleNDMPiMi[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1085  fHistoAngleNDMPiMi[iCut]->GetYaxis()->SetTitle(Form("#angle (%s,#pi^{-})",NameNDMLatex.Data()));
1086  fESDList[iCut]->Add(fHistoAngleNDMPiMi[iCut]);
1087  fHistoAngleSum[iCut] = new TH2F("ESD_Mother_AngleSum_Pt","ESD_Mother_AngleSum_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1],720,0,2*TMath::Pi());
1088  fHistoAngleSum[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1089  fHistoAngleSum[iCut]->GetYaxis()->SetTitle("#sum #angle");
1090  fESDList[iCut]->Add(fHistoAngleSum[iCut]);
1091  }
1092  if ( fDoMesonQA>0 && (!fDoLightOutput) ) {
1093  TAxis *AxisAfter = fHistoPionTPCdEdxNSigma[iCut]->GetXaxis();
1094  Int_t bins = AxisAfter->GetNbins();
1095  Double_t from = AxisAfter->GetXmin();
1096  Double_t to = AxisAfter->GetXmax();
1097  Double_t *newBins = new Double_t[bins+1];
1098  newBins[0] = from;
1099  Double_t factor = TMath::Power(to/from, 1./bins);
1100  for(Int_t i=1; i<=bins; ++i) newBins[i] = factor * newBins[i-1];
1101 
1102  AxisAfter->Set(bins, newBins);
1103  AxisAfter = fHistoPionTPCdEdx[iCut]->GetXaxis();
1104  AxisAfter->Set(bins, newBins);
1105  delete [] newBins;
1106  }
1107 
1108  fCutFolder[iCut]->Add(fESDList[iCut]);
1109 
1110  }
1111 
1112  if( fIsMC ){
1113  // MC Histogramms
1114  fMCList = new TList*[fnCuts];
1115  // True Histogramms
1116  fTrueList = new TList*[fnCuts];
1117  if(!fDoLightOutput){
1118  if (fNDMRecoMode < 2){
1119  fHistoTrueConvGammaPt = new TH1F*[fnCuts];
1122  }
1123  if (fNDMRecoMode > 0){
1124  fHistoTrueClusterGammaPt = new TH1F*[fnCuts];
1126  }
1127  fHistoTruePosPionPt = new TH1F*[fnCuts];
1128  fHistoTrueNegPionPt = new TH1F*[fnCuts];
1131 
1132 
1133  fHistoMCAllGammaPt = new TH1F*[fnCuts];
1134  if (fNDMRecoMode < 2){
1135  fHistoMCConvGammaPt = new TH1F*[fnCuts];
1136  }
1137  fHistoMCAllPosPionsPt = new TH1F*[fnCuts];
1138  fHistoMCAllNegPionsPt = new TH1F*[fnCuts];
1142 
1143  if(fDoMesonQA > 0){
1144  fHistoMCAllMesonPt = new TH1F*[fnCuts];
1145  fHistoMCAllMesonEta = new TH1F*[fnCuts];
1146  fHistoMCAllMesonPhi = new TH1F*[fnCuts];
1150  fHistoMCAllPosPionsEta = new TH1F*[fnCuts];
1151  fHistoMCAllPosPionsPhi = new TH1F*[fnCuts];
1152  fHistoMCAllNegPionsEta = new TH1F*[fnCuts];
1153  fHistoMCAllNegPionsPhi = new TH1F*[fnCuts];
1158  fHistoMCHeavyAllPt = new TH1F*[fnCuts];
1159  fHistoMCHeavyAllEta = new TH1F*[fnCuts];
1160  fHistoMCHeavyAllPhi = new TH1F*[fnCuts];
1161  fHistoMCHeavyChannelPt = new TH1F*[fnCuts];
1162  fHistoMCHeavyChannelEta = new TH1F*[fnCuts];
1163  fHistoMCHeavyChannelPhi = new TH1F*[fnCuts];
1164  fHistMCChannelNDMFromHeavyPt = new TH1F*[fnCuts];
1191  }
1192  }
1193  fHistoMCHNMPiPlPiMiNDMPt = new TH1F*[fnCuts];
1195  if(!fDoLightOutput){
1198  }
1201  if(!fDoLightOutput){
1204  fHistoTrueAngleSum = new TH2F*[fnCuts];
1205  }
1206  if(!fDoLightOutput){
1207  if (fDoMesonQA>0){
1211 
1228  if (fDoMesonQA>1){
1229  fTrueTreeList = new TList*[fnCuts];
1232  fTreeEventInfoHNM = new TTree*[fnCuts];
1233  }
1234  }
1235  }
1236 
1237  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1238  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
1239  TString cutstringPion = ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutNumber();
1240  TString cutstringConvGamma = "";
1241  if (fNDMRecoMode < 2)
1242  cutstringConvGamma = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
1243  TString cutstringCaloGamma = "";
1244  if (fNDMRecoMode > 0)
1245  cutstringCaloGamma = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
1246  TString cutstringNeutralPion = ((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(iCut))->GetCutNumber();
1247  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
1248 
1249  TString fullCutString = "";
1250  if (fNDMRecoMode == 0)
1251  fullCutString = Form("%i_%s_%s_%s_%s_%s",fNDMRecoMode,cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringNeutralPion.Data(), cutstringPion.Data(),
1252  cutstringMeson.Data());
1253  else if (fNDMRecoMode == 1)
1254  fullCutString = Form("%i_%s_%s_%s_%s_%s_%s",fNDMRecoMode,cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringCaloGamma.Data(), cutstringNeutralPion.Data(),
1255  cutstringPion.Data(), cutstringMeson.Data());
1256  else if (fNDMRecoMode == 2)
1257  fullCutString = Form("%i_%s_%s_%s_%s_%s",fNDMRecoMode,cutstringEvent.Data(), cutstringCaloGamma.Data(), cutstringNeutralPion.Data(), cutstringPion.Data(),
1258  cutstringMeson.Data());
1259  TString nameMCList = Form("%s MC histograms", fullCutString.Data());
1260  TString nameTrueRecList = Form("%s True histograms", fullCutString.Data());
1261  TString nameTrueRecTTreeList = Form("%s True TTrees", fullCutString.Data());
1262 
1263  fMCList[iCut] = new TList();
1264  fMCList[iCut]->SetName(nameMCList.Data());
1265  fMCList[iCut]->SetOwner(kTRUE);
1266  fCutFolder[iCut]->Add(fMCList[iCut]);
1267 
1268  if(!fDoLightOutput){
1269  fHistoMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt","MC_AllGamma_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1270  fHistoMCAllGammaPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1271  fHistoMCAllGammaPt[iCut]->GetYaxis()->SetTitle("N_{#gamma}");
1272  fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);
1273  if (fNDMRecoMode < 2){
1274  fHistoMCConvGammaPt[iCut] = new TH1F("MC_ConvGamma_Pt","MC_ConvGamma_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1275  fHistoMCConvGammaPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1276  fHistoMCConvGammaPt[iCut]->GetYaxis()->SetTitle("N_{#gamma,conv}");
1277  fMCList[iCut]->Add(fHistoMCConvGammaPt[iCut]);
1278  }
1279  fHistoMCGammaFromNeutralMesonPt[iCut] = new TH1F("MC_GammaFromNeutralMeson_Pt","MC_GammaFromNeutralMeson_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1280  fHistoMCGammaFromNeutralMesonPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1281  fHistoMCGammaFromNeutralMesonPt[iCut]->GetYaxis()->SetTitle("N_{#gamma}");
1282  fMCList[iCut]->Add(fHistoMCGammaFromNeutralMesonPt[iCut]);
1283  fHistoMCAllPosPionsPt[iCut] = new TH1F("MC_AllPosPions_Pt","MC_AllPosPions_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1284  fHistoMCAllPosPionsPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1285  fHistoMCAllPosPionsPt[iCut]->GetYaxis()->SetTitle("N_{#pi^{+}}");
1286  fMCList[iCut]->Add(fHistoMCAllPosPionsPt[iCut]);
1287  fHistoMCAllNegPionsPt[iCut] = new TH1F("MC_AllNegPions_Pt","MC_AllNegPions_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1288  fHistoMCAllNegPionsPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1289  fHistoMCAllNegPionsPt[iCut]->GetYaxis()->SetTitle("N_{#pi^{-}}");
1290  fMCList[iCut]->Add(fHistoMCAllNegPionsPt[iCut]);
1291  fHistoMCNegPionsFromNeutralMesonPt[iCut] = new TH1F("MC_NegPionsFromNeutralMeson_Pt","MC_NegPionsFromNeutralMeson_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1292  fHistoMCNegPionsFromNeutralMesonPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1293  fHistoMCNegPionsFromNeutralMesonPt[iCut]->GetYaxis()->SetTitle("N_{#pi^{-}}");
1294  fMCList[iCut]->Add(fHistoMCNegPionsFromNeutralMesonPt[iCut]);
1295  fHistoMCPosPionsFromNeutralMesonPt[iCut] = new TH1F("MC_PosPionsFromNeutralMeson_Pt","MC_PosPionsFromNeutralMeson_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1296  fHistoMCPosPionsFromNeutralMesonPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1297  fHistoMCPosPionsFromNeutralMesonPt[iCut]->GetYaxis()->SetTitle("N_{#pi^{+}}");
1298  fMCList[iCut]->Add(fHistoMCPosPionsFromNeutralMesonPt[iCut]);
1299  if (fDoMesonQA>0){
1300  fHistoMCAllMesonPt[iCut] = new TH1F("MC_AllNDM_Pt", "MC_AllNDM_Pt", HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1301  fHistoMCAllMesonPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1302  fHistoMCAllMesonPt[iCut]->GetYaxis()->SetTitle(Form("N_{%s}}", NameNDMLatex.Data()));
1303  fMCList[iCut]->Add(fHistoMCAllMesonPt[iCut]);
1304  fHistoMCAllMesonEta[iCut] = new TH1F("MC_AllNDM_Eta", "MC_AllNDM_Eta", 200, -2, 2);
1305  fHistoMCAllMesonEta[iCut]->GetXaxis()->SetTitle("#eta");
1306  fHistoMCAllMesonEta[iCut]->GetYaxis()->SetTitle(Form("N_{%s}}", NameNDMLatex.Data()));
1307  fMCList[iCut]->Add(fHistoMCAllMesonEta[iCut]);
1308  fHistoMCAllMesonPhi[iCut] = new TH1F("MC_AllNDM_Phi", "MC_AllNDM_Phi", 200, 0, TMath::TwoPi());
1309  fHistoMCAllMesonPhi[iCut]->GetXaxis()->SetTitle("#varphi");
1310  fHistoMCAllMesonPhi[iCut]->GetYaxis()->SetTitle(Form("N_{%s}}", NameNDMLatex.Data()));
1311  fMCList[iCut]->Add(fHistoMCAllMesonPhi[iCut]);
1312  fHistoMCMesonFromNeutralMesonPt[iCut] = new TH1F("MC_NDMFromNeutralMeson_Pt", "MC_NDMFormNeutralMeson_Pt", HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1313  fHistoMCMesonFromNeutralMesonPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1314  fHistoMCMesonFromNeutralMesonPt[iCut]->GetYaxis()->SetTitle(Form("N_{%s}}", NameNDMLatex.Data()));
1315  fMCList[iCut]->Add(fHistoMCMesonFromNeutralMesonPt[iCut]);
1316  fHistoMCMesonFromNeutralMesonEta[iCut] = new TH1F("MC_NDMFromNeutralMeson_Eta", "MC_NDMFromNeutralMeson_Eta", 200, -2, 2);
1317  fHistoMCMesonFromNeutralMesonEta[iCut]->GetXaxis()->SetTitle("#eta");
1318  fHistoMCMesonFromNeutralMesonEta[iCut]->GetYaxis()->SetTitle(Form("N_{%s}}", NameNDMLatex.Data()));
1319  fMCList[iCut]->Add(fHistoMCMesonFromNeutralMesonEta[iCut]);
1320  fHistoMCMesonFromNeutralMesonPhi[iCut] = new TH1F("MC_NDMFromNeutralMeson_Phi", "MC_NDMFromNeutralMeson_Phi", 200, 0, TMath::TwoPi());
1321  fHistoMCMesonFromNeutralMesonPhi[iCut]->GetXaxis()->SetTitle("#varphi");
1322  fHistoMCMesonFromNeutralMesonPhi[iCut]->GetYaxis()->SetTitle(Form("N_{%s}}", NameNDMLatex.Data()));
1323  fMCList[iCut]->Add(fHistoMCMesonFromNeutralMesonPhi[iCut]);
1324  fHistoMCAllPosPionsEta[iCut] = new TH1F("MC_AllPosPions_Eta","MC_AllPosPions_Eta", 200, -2., 2.);
1325  fHistoMCAllPosPionsEta[iCut]->GetXaxis()->SetTitle("#eta");
1326  fHistoMCAllPosPionsEta[iCut]->GetYaxis()->SetTitle("N_{#pi^{+}}");
1327  fMCList[iCut]->Add(fHistoMCAllPosPionsEta[iCut]);
1328  fHistoMCAllPosPionsPhi[iCut] = new TH1F("MC_AllPosPions_Phi","MC_AllPosPions_Phi", 200, 0., TMath::TwoPi());
1329  fHistoMCAllPosPionsPhi[iCut]->GetXaxis()->SetTitle("#phi");
1330  fHistoMCAllPosPionsPhi[iCut]->GetYaxis()->SetTitle("N_{#pi^{+}}");
1331  fMCList[iCut]->Add(fHistoMCAllPosPionsPhi[iCut]);
1332  fHistoMCAllNegPionsEta[iCut] = new TH1F("MC_AllNegPions_Eta","MC_AllNegPions_Eta", 200, -2., 2.);
1333  fHistoMCAllNegPionsEta[iCut]->GetXaxis()->SetTitle("#eta");
1334  fHistoMCAllNegPionsEta[iCut]->GetYaxis()->SetTitle("N_{#pi^{-}}");
1335  fMCList[iCut]->Add(fHistoMCAllNegPionsEta[iCut]);
1336  fHistoMCAllNegPionsPhi[iCut] = new TH1F("MC_AllNegPions_Phi","MC_AllNegPions_Phi", 200, 0., TMath::TwoPi());
1337  fHistoMCAllNegPionsPhi[iCut]->GetXaxis()->SetTitle("#phi");
1338  fHistoMCAllNegPionsPhi[iCut]->GetYaxis()->SetTitle("N_{#pi^{-}}");
1339  fMCList[iCut]->Add(fHistoMCAllNegPionsPhi[iCut]);
1340  fHistoMCPosPionsFromNeutralMesonEta[iCut] = new TH1F("MC_PosPionsFromNeutralMeson_Eta","MC_PosPionsFromNeutralMeson_Eta", 200, -2., 2.);
1341  fHistoMCPosPionsFromNeutralMesonEta[iCut]->GetXaxis()->SetTitle("#eta");
1342  fHistoMCPosPionsFromNeutralMesonEta[iCut]->GetYaxis()->SetTitle("N_{#pi^{+}}");
1343  fMCList[iCut]->Add(fHistoMCPosPionsFromNeutralMesonEta[iCut]);
1344  fHistoMCPosPionsFromNeutralMesonPhi[iCut] = new TH1F("MC_PosPionsFromNeutralMeson_Phi","MC_PosPionsFromNeutralMeson_Phi", 200, 0., TMath::TwoPi());
1345  fHistoMCPosPionsFromNeutralMesonPhi[iCut]->GetXaxis()->SetTitle("#phi");
1346  fHistoMCPosPionsFromNeutralMesonPhi[iCut]->GetYaxis()->SetTitle("N_{#pi^{+}}");
1347  fMCList[iCut]->Add(fHistoMCPosPionsFromNeutralMesonPhi[iCut]);
1348  fHistoMCNegPionsFromNeutralMesonEta[iCut] = new TH1F("MC_NegPionsFromNeutralMeson_Eta","MC_NegPionsFromNeutralMeson_Eta", 200, -2., 2.);
1349  fHistoMCNegPionsFromNeutralMesonEta[iCut]->GetXaxis()->SetTitle("#eta");
1350  fHistoMCNegPionsFromNeutralMesonEta[iCut]->GetYaxis()->SetTitle("N_{#pi^{-}}");
1351  fMCList[iCut]->Add(fHistoMCNegPionsFromNeutralMesonEta[iCut]);
1352  fHistoMCNegPionsFromNeutralMesonPhi[iCut] = new TH1F("MC_NegPionsFromNeutralMeson_Phi","MC_NegPionsFromNeutralMeson_Phi", 200, 0., TMath::TwoPi());
1353  fHistoMCNegPionsFromNeutralMesonPhi[iCut]->GetXaxis()->SetTitle("#phi");
1354  fHistoMCNegPionsFromNeutralMesonPhi[iCut]->GetYaxis()->SetTitle("N_{#pi^{-}}");
1355 
1356  fMCList[iCut]->Add(fHistoMCNegPionsFromNeutralMesonPhi[iCut]);
1357  fHistoMCHeavyAllPt[iCut] = new TH1F("MC_HeavyAll_Pt", "MC_HeavyAll_Pt", HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1358  fHistoMCHeavyAllPt[iCut]->SetXTitle("p_{t} (GeV/c)");
1359  fHistoMCHeavyAllPt[iCut]->SetYTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1360  fMCList[iCut]->Add(fHistoMCHeavyAllPt[iCut]);
1361  fHistoMCHeavyAllEta[iCut] = new TH1F("MC_HeavyAll_Eta", "MC_HeavyAll_Eta", 200, -2., 2.);
1362  fHistoMCHeavyAllEta[iCut]->SetXTitle("#eta");
1363  fHistoMCHeavyAllEta[iCut]->SetYTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1364  fMCList[iCut]->Add(fHistoMCHeavyAllEta[iCut]);
1365  fHistoMCHeavyAllPhi[iCut] = new TH1F("MC_HeavyAll_Phi", "MC_HeavyAll_Phi", 200, 0., TMath::TwoPi());
1366  fHistoMCHeavyAllPhi[iCut]->SetXTitle("#phi{t} (GeV/c");
1367  fHistoMCHeavyAllPhi[iCut]->SetYTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1368  fMCList[iCut]->Add(fHistoMCHeavyAllPhi[iCut]);
1369  fHistoMCHeavyChannelPt[iCut] = new TH1F("MC_HeavyChannel_Pt", "MC_HeavyChannel_Pt", HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1370  fHistoMCHeavyChannelPt[iCut]->SetXTitle("p_{t} (GeV/c)");
1371  fHistoMCHeavyChannelPt[iCut]->SetYTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1372  fMCList[iCut]->Add(fHistoMCHeavyChannelPt[iCut]);
1373  fHistoMCHeavyChannelEta[iCut] = new TH1F("MC_HeavyChannel_Eta", "MC_HeavyChannel_Eta", 200, -2., 2.);
1374  fHistoMCHeavyAllEta[iCut]->SetXTitle("#eta");
1375  fHistoMCHeavyAllEta[iCut]->SetYTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1376  fMCList[iCut]->Add(fHistoMCHeavyChannelEta[iCut]);
1377  fHistoMCHeavyChannelPhi[iCut] = new TH1F("MC_HeavyChannel_Phi", "MC_HeavyChannel_Phi", 200, 0., TMath::TwoPi());
1378  fHistoMCHeavyChannelPhi[iCut]->SetXTitle("#phi{t} (GeV/c");
1379  fHistoMCHeavyChannelPhi[iCut]->SetYTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1380  fMCList[iCut]->Add(fHistoMCHeavyChannelPhi[iCut]);
1381  fHistMCChannelNDMFromHeavyPt[iCut] = new TH1F("MC_NDMFromHeavyChannel_Pt", "MC_NDMFromHeavyChannel_Pt", HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1382  fHistMCChannelNDMFromHeavyPt[iCut]->SetXTitle("p_{t} (GeV/c)");
1383  fHistMCChannelNDMFromHeavyPt[iCut]->SetYTitle(Form("N_{%s}", NameNDMLatex.Data()));
1384  fMCList[iCut]->Add(fHistMCChannelNDMFromHeavyPt[iCut]);
1385  fHistMCChannelNDMFromHeavyEta[iCut] = new TH1F("MC_NDMFromHeavyChannel_Eta", "MC_NDMFromHeavyChannel_Eta", 200, -2., 2.);
1386  fHistMCChannelNDMFromHeavyEta[iCut]->SetXTitle("#eta");
1387  fHistMCChannelNDMFromHeavyEta[iCut]->SetYTitle(Form("N_{%s}", NameNDMLatex.Data()));
1388  fMCList[iCut]->Add(fHistMCChannelNDMFromHeavyEta[iCut]);
1389  fHistMCChannelNDMFromHeavyPhi[iCut] = new TH1F("MC_NDMFromHeavyChannel_Phi", "MC_NDMFromHeavyChannel_Phi", 200, 0., TMath::TwoPi());
1390  fHistMCChannelNDMFromHeavyPhi[iCut]->SetXTitle("#phi");
1391  fHistMCChannelNDMFromHeavyPhi[iCut]->SetYTitle(Form("N_{%s}", NameNDMLatex.Data()));
1392  fMCList[iCut]->Add(fHistMCChannelNDMFromHeavyPhi[iCut]);
1393  fHistMCChannelPiPlusFromHeavyPt[iCut] = new TH1F("MC_PiPlusFromHeavyChannel_Pt", "MC_PiPlusFromHeavyChannel_Pt", HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1394  fHistMCChannelPiPlusFromHeavyPt[iCut]->SetXTitle("p_{t} (GeV/c)");
1395  fHistMCChannelPiPlusFromHeavyPt[iCut]->SetYTitle("N_{#pi^{+}}");
1396  fMCList[iCut]->Add(fHistMCChannelPiPlusFromHeavyPt[iCut]);
1397  fHistMCChannelPiPlusFromHeavyEta[iCut] = new TH1F("MC_PiPlusFromHeavyChannel_Eta", "MC_PiPlusFromHeavyChannel_Eta", 200, -2., 2.);
1398  fHistMCChannelPiPlusFromHeavyEta[iCut]->SetXTitle("#eta");
1399  fHistMCChannelPiPlusFromHeavyEta[iCut]->SetYTitle("N_{#pi^{+}}");
1400  fMCList[iCut]->Add(fHistMCChannelPiPlusFromHeavyEta[iCut]);
1401  fHistMCChannelPiPlusFromHeavyPhi[iCut] = new TH1F("MC_PiPlusFromHeavyChannel_Phi", "MC_PiPlusFromHeavyChannel_Phi", 200, 0., TMath::TwoPi());
1402  fHistMCChannelPiPlusFromHeavyPhi[iCut]->SetXTitle("#phi");
1403  fHistMCChannelPiPlusFromHeavyPhi[iCut]->SetYTitle("N_{#pi^{+}}");
1404  fMCList[iCut]->Add(fHistMCChannelPiPlusFromHeavyPhi[iCut]);
1405  fHistMCChannelPiMinusFromHeavyPt[iCut] = new TH1F("MC_PiMinusFromHeavyChannel_Pt", "MC_PiMinusFromHeavyChannel_Pt", HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1406  fHistMCChannelPiMinusFromHeavyPt[iCut]->SetXTitle("p_{t} (GeV/c)");
1407  fHistMCChannelPiMinusFromHeavyPt[iCut]->SetYTitle("N_{#pi^{-}}");
1408  fMCList[iCut]->Add(fHistMCChannelPiMinusFromHeavyPt[iCut]);
1409  fHistMCChannelPiMinusFromHeavyEta[iCut] = new TH1F("MC_PiMinusFromHeavyChannel_Eta", "MC_PiMinusFromHeavyChannel_Eta", 200, -2., 2.);
1410  fHistMCChannelPiMinusFromHeavyEta[iCut]->SetXTitle("#eta");
1411  fHistMCChannelPiMinusFromHeavyEta[iCut]->SetYTitle("N_{#pi^{-}}");
1412  fMCList[iCut]->Add(fHistMCChannelPiMinusFromHeavyEta[iCut]);
1413  fHistMCChannelPiPMinusFromHeavyPhi[iCut] = new TH1F("MC_PiMinusFromHeavyChannel_Phi", "MC_PiMinusFromHeavyChannel_Phi", 200, 0., TMath::TwoPi());
1414  fHistMCChannelPiPMinusFromHeavyPhi[iCut]->SetXTitle("#phi");
1415  fHistMCChannelPiPMinusFromHeavyPhi[iCut]->SetYTitle("N_{#pi^{-}}");
1416  fMCList[iCut]->Add(fHistMCChannelPiPMinusFromHeavyPhi[iCut]);
1417 
1418  fHistMCChannelNDMPtHeavyPt[iCut] = new TH2F("MC_CorrPtNDMHeavyChannel", "MC_CorrPtNDMHeavyChannel", HistoNPtBins, HistoPtRange[0], HistoPtRange[1], HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1419  fHistMCChannelNDMPtHeavyPt[iCut]->SetXTitle(Form("p_{t, %s} (GeV/c)", NameNeutralMesonAnalyzedLatex.Data()));
1420  fHistMCChannelNDMPtHeavyPt[iCut]->SetYTitle(Form("p_{t, %s} (GeV/c)", NameNDMLatex.Data()));
1421  fHistMCChannelNDMPtHeavyPt[iCut]->SetZTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1422  fMCList[iCut]->Add(fHistMCChannelNDMPtHeavyPt[iCut]);
1423  fHistMCChannelPiPlusPtHeavyPt[iCut] = new TH2F("MC_CorrPtPiPlusHeavyChannel", "MC_CorrPtPiPlusHeavyChannel", HistoNPtBins, HistoPtRange[0], HistoPtRange[1], HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1424  fHistMCChannelPiPlusPtHeavyPt[iCut]->SetXTitle(Form("p_{t, %s} (GeV/c)", NameNeutralMesonAnalyzedLatex.Data()));
1425  fHistMCChannelPiPlusPtHeavyPt[iCut]->SetYTitle("p_{t, #pi^{-}%s} (GeV/c)");
1426  fHistMCChannelPiPlusPtHeavyPt[iCut]->SetZTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1427  fMCList[iCut]->Add(fHistMCChannelPiPlusPtHeavyPt[iCut]);
1428  fHistMCChannelPiMinusPtHeavyPt[iCut] = new TH2F("MC_CorrPtPiMinusHeavyChannel", "MC_CorrPtPiMinusHeavyChannel", HistoNPtBins, HistoPtRange[0], HistoPtRange[1], HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1429  fHistMCChannelPiMinusPtHeavyPt[iCut]->SetXTitle(Form("p_{t, %s} (GeV/c)", NameNeutralMesonAnalyzedLatex.Data()));
1430  fHistMCChannelPiMinusPtHeavyPt[iCut]->SetYTitle("p_{t, #pi^{-}%s} (GeV/c)");
1431  fHistMCChannelPiMinusPtHeavyPt[iCut]->SetZTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1432  fMCList[iCut]->Add(fHistMCChannelPiMinusPtHeavyPt[iCut]);
1433 
1434  fHistoMCHeavyReconstructiblePt[iCut] = new TH1F("MC_HeavyReconstructible_Pt", "MC_HeavyReconstructible_Pt", HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1435  fHistoMCHeavyReconstructiblePt[iCut]->SetXTitle("p_{t} (GeV/c)");
1436  fHistoMCHeavyReconstructiblePt[iCut]->SetYTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1437  fMCList[iCut]->Add(fHistoMCHeavyReconstructiblePt[iCut]);
1438  fHistoMCHeavyReconstructibleEta[iCut] = new TH1F("MC_HeavyReconstructible_Eta", "MC_HeavyReconstructible_Eta", 200, -2., 2.);
1439  fHistoMCHeavyAllEta[iCut]->SetXTitle("#eta");
1440  fHistoMCHeavyAllEta[iCut]->SetYTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1441  fMCList[iCut]->Add(fHistoMCHeavyReconstructibleEta[iCut]);
1442  fHistoMCHeavyReconstructiblePhi[iCut] = new TH1F("MC_HeavyReconstructible_Phi", "MC_HeavyReconstructible_Phi", 200, 0., TMath::TwoPi());
1443  fHistoMCHeavyReconstructiblePhi[iCut]->SetXTitle("#phi{t} (GeV/c");
1444  fHistoMCHeavyReconstructiblePhi[iCut]->SetYTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1445  fMCList[iCut]->Add(fHistoMCHeavyReconstructiblePhi[iCut]);
1446  fHistMCReconstructibleNDMFromHeavyPt[iCut] = new TH1F("MC_NDMFromHeavyReconstructible_Pt", "MC_NDMFromHeavyReconstructible_Pt", HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1447  fHistMCReconstructibleNDMFromHeavyPt[iCut]->SetXTitle("p_{t} (GeV/c)");
1448  fHistMCReconstructibleNDMFromHeavyPt[iCut]->SetYTitle(Form("N_{%s}", NameNDMLatex.Data()));
1449  fMCList[iCut]->Add(fHistMCReconstructibleNDMFromHeavyPt[iCut]);
1450  fHistMCReconstructibleNDMFromHeavyEta[iCut] = new TH1F("MC_NDMFromHeavyReconstructible_Eta", "MC_NDMFromHeavyReconstructible_Eta", 200, -2., 2.);
1451  fHistMCReconstructibleNDMFromHeavyEta[iCut]->SetXTitle("#eta");
1452  fHistMCReconstructibleNDMFromHeavyEta[iCut]->SetYTitle(Form("N_{%s}", NameNDMLatex.Data()));
1453  fMCList[iCut]->Add(fHistMCReconstructibleNDMFromHeavyEta[iCut]);
1454  fHistMCReconstructibleNDMFromHeavyPhi[iCut] = new TH1F("MC_NDMFromHeavyReconstructible_Phi", "MC_NDMFromHeavyReconstructible_Phi", 200, 0., TMath::TwoPi());
1455  fHistMCReconstructibleNDMFromHeavyPhi[iCut]->SetXTitle("#phi");
1456  fHistMCReconstructibleNDMFromHeavyPhi[iCut]->SetYTitle(Form("N_{%s}", NameNDMLatex.Data()));
1457  fMCList[iCut]->Add(fHistMCReconstructibleNDMFromHeavyPhi[iCut]);
1458  fHistMCReconstructiblePiPlusFromHeavyPt[iCut] = new TH1F("MC_PiPlusFromHeavyReconstructible_Pt", "MC_PiPlusFromHeavyReconstructible_Pt", HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1459  fHistMCReconstructiblePiPlusFromHeavyPt[iCut]->SetXTitle("p_{t} (GeV/c)");
1460  fHistMCReconstructiblePiPlusFromHeavyPt[iCut]->SetYTitle("N_{#pi^{+}}");
1461  fMCList[iCut]->Add(fHistMCReconstructiblePiPlusFromHeavyPt[iCut]);
1462  fHistMCReconstructiblePiPlusFromHeavyEta[iCut] = new TH1F("MC_PiPlusFromHeavyReconstructible_Eta", "MC_PiPlusFromHeavyReconstructible_Eta", 200, -2., 2.);
1463  fHistMCReconstructiblePiPlusFromHeavyEta[iCut]->SetXTitle("#eta");
1464  fHistMCReconstructiblePiPlusFromHeavyEta[iCut]->SetYTitle("N_{#pi^{+}}");
1465  fMCList[iCut]->Add(fHistMCReconstructiblePiPlusFromHeavyEta[iCut]);
1466  fHistMCReconstructiblePiPlusFromHeavyPhi[iCut] = new TH1F("MC_PiPlusFromHeavyReconstructible_Phi", "MC_PiPlusFromHeavyReconstructible_Phi", 200, 0., TMath::TwoPi());
1467  fHistMCReconstructiblePiPlusFromHeavyPhi[iCut]->SetXTitle("#phi");
1468  fHistMCReconstructiblePiPlusFromHeavyPhi[iCut]->SetYTitle("N_{#pi^{+}}");
1469  fMCList[iCut]->Add(fHistMCReconstructiblePiPlusFromHeavyPhi[iCut]);
1470  fHistMCReconstructiblePiMinusFromHeavyPt[iCut] = new TH1F("MC_PiMinusFromHeavyReconstructible_Pt", "MC_PiMinusFromHeavyReconstructible_Pt", HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1471  fHistMCReconstructiblePiMinusFromHeavyPt[iCut]->SetXTitle("p_{t} (GeV/c)");
1472  fHistMCReconstructiblePiMinusFromHeavyPt[iCut]->SetYTitle("N_{#pi^{-}}");
1473  fMCList[iCut]->Add(fHistMCReconstructiblePiMinusFromHeavyPt[iCut]);
1474  fHistMCReconstructiblePiMinusFromHeavyEta[iCut] = new TH1F("MC_PiMinusFromHeavyReconstructible_Eta", "MC_PiMinusFromHeavyReconstructible_Eta", 200, -2., 2.);
1475  fHistMCReconstructiblePiMinusFromHeavyEta[iCut]->SetXTitle("#eta");
1476  fHistMCReconstructiblePiMinusFromHeavyEta[iCut]->SetYTitle("N_{#pi^{-}}");
1477  fMCList[iCut]->Add(fHistMCReconstructiblePiMinusFromHeavyEta[iCut]);
1478  fHistMCReconstructiblePiPMinusFromHeavyPhi[iCut] = new TH1F("MC_PiMinusFromHeavyReconstructible_Phi", "MC_PiMinusFromHeavyReconstructible_Phi", 200, 0., TMath::TwoPi());
1479  fHistMCReconstructiblePiPMinusFromHeavyPhi[iCut]->SetXTitle("#phi");
1480  fHistMCReconstructiblePiPMinusFromHeavyPhi[iCut]->SetYTitle("N_{#pi^{-}}");
1481  fMCList[iCut]->Add(fHistMCReconstructiblePiPMinusFromHeavyPhi[iCut]);
1482 
1483  fHistMCReconstructibleNDMPtHeavyPt[iCut] = new TH2F("MC_CorrPtNDMHeavyReconstructible", "MC_CorrPtNDMHeavyReconstructible", HistoNPtBins, HistoPtRange[0], HistoPtRange[1], HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1484  fHistMCReconstructibleNDMPtHeavyPt[iCut]->SetXTitle(Form("p_{t, %s} (GeV/c)", NameNeutralMesonAnalyzedLatex.Data()));
1485  fHistMCReconstructibleNDMPtHeavyPt[iCut]->SetYTitle(Form("p_{t, %s} (GeV/c)", NameNDMLatex.Data()));
1486  fHistMCReconstructibleNDMPtHeavyPt[iCut]->SetZTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1487  fMCList[iCut]->Add(fHistMCReconstructibleNDMPtHeavyPt[iCut]);
1488  fHistMCReconstructiblePiPlusPtHeavyPt[iCut] = new TH2F("MC_CorrPtPiPlusHeavyReconstructible", "MC_CorrPtPiPlusHeavyReconstructible", HistoNPtBins, HistoPtRange[0], HistoPtRange[1], HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1489  fHistMCReconstructiblePiPlusPtHeavyPt[iCut]->SetXTitle(Form("p_{t, %s} (GeV/c)", NameNeutralMesonAnalyzedLatex.Data()));
1490  fHistMCReconstructiblePiPlusPtHeavyPt[iCut]->SetYTitle("p_{t, #pi^{-}%s} (GeV/c)");
1491  fHistMCReconstructiblePiPlusPtHeavyPt[iCut]->SetZTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1492  fMCList[iCut]->Add(fHistMCReconstructiblePiPlusPtHeavyPt[iCut]);
1493  fHistMCReconstructiblePiMinusPtHeavyPt[iCut] = new TH2F("MC_CorrPtPiMinusHeavyReconstructible", "MC_CorrPtPiMinusHeavyReconstructible", HistoNPtBins, HistoPtRange[0], HistoPtRange[1], HistoNPtBins, HistoPtRange[0], HistoPtRange[1]);
1494  fHistMCReconstructiblePiMinusPtHeavyPt[iCut]->SetXTitle(Form("p_{t, %s} (GeV/c)", NameNeutralMesonAnalyzedLatex.Data()));
1495  fHistMCReconstructiblePiMinusPtHeavyPt[iCut]->SetYTitle("p_{t, #pi^{-}%s} (GeV/c)");
1496  fHistMCReconstructiblePiMinusPtHeavyPt[iCut]->SetZTitle(Form("N_{%s}", NameNeutralMesonAnalyzedLatex.Data()));
1497  fMCList[iCut]->Add(fHistMCReconstructiblePiMinusPtHeavyPt[iCut]);
1498  }
1499  }
1500  fHistoMCHNMPiPlPiMiNDMPt[iCut] = new TH1F("MC_HNM_Pt","MC_HNM_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1501  fHistoMCHNMPiPlPiMiNDMPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1502  fHistoMCHNMPiPlPiMiNDMPt[iCut]->GetYaxis()->SetTitle("N_{HNM}");
1503  fHistoMCHNMPiPlPiMiNDMPt[iCut]->Sumw2();
1504  fMCList[iCut]->Add(fHistoMCHNMPiPlPiMiNDMPt[iCut]);
1505 
1506  fHistoMCHNMPiPlPiMiNDMInAccPt[iCut] = new TH1F("MC_HNMInAcc_Pt","MC_HNMInAcc_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1507  fHistoMCHNMPiPlPiMiNDMInAccPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1508  fHistoMCHNMPiPlPiMiNDMInAccPt[iCut]->GetYaxis()->SetTitle("A #times N_{HNM}");
1509  fHistoMCHNMPiPlPiMiNDMInAccPt[iCut]->Sumw2();
1510  fMCList[iCut]->Add(fHistoMCHNMPiPlPiMiNDMInAccPt[iCut]);
1511 
1512  fTrueList[iCut] = new TList();
1513  fTrueList[iCut]->SetName(nameTrueRecList.Data());
1514  fTrueList[iCut]->SetOwner(kTRUE);
1515  fCutFolder[iCut]->Add(fTrueList[iCut]);
1516 
1517  if(!fDoLightOutput){
1518  if (fNDMRecoMode < 2){
1519  fHistoTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt","ESD_TrueConvGamma_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1520  fHistoTrueConvGammaPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1521  fHistoTrueConvGammaPt[iCut]->GetYaxis()->SetTitle("N_{#gamma,conv}");
1522  fTrueList[iCut]->Add(fHistoTrueConvGammaPt[iCut]);
1523  fHistoDoubleCountTrueConvGammaRPt[iCut] = new TH2F("ESD_TrueDoubleCountConvGamma_R_Pt","ESD_TrueDoubleCountConvGamma_R_Pt",800,0,200,HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1524  fHistoDoubleCountTrueConvGammaRPt[iCut]->GetXaxis()->SetTitle("R_{conv} (cm)");
1525  fHistoDoubleCountTrueConvGammaRPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1526  fTrueList[iCut]->Add(fHistoDoubleCountTrueConvGammaRPt[iCut]);
1527  fHistoTrueConvGammaFromNeutralMesonPt[iCut] = new TH1F("ESD_TrueConvGammaFromNeutralMeson_Pt","ESD_TrueConvGammaFromNeutralMeson_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1528  fHistoTrueConvGammaFromNeutralMesonPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1529  fHistoTrueConvGammaFromNeutralMesonPt[iCut]->GetYaxis()->SetTitle("N_{#gamma,conv}");
1531  }
1532  if (fNDMRecoMode > 0){
1533  fHistoTrueClusterGammaPt[iCut] = new TH1F("ESD_TrueClusterGamma_Pt","ESD_TrueClusterGamma_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1534  fHistoTrueClusterGammaPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1535  fHistoTrueClusterGammaPt[iCut]->GetYaxis()->SetTitle("N_{#gamma,cluster}");
1536  fTrueList[iCut]->Add(fHistoTrueClusterGammaPt[iCut]);
1537  fHistoTrueClusterGammaFromNeutralMesonPt[iCut] = new TH1F("ESD_TrueClusterGammaFromNeutralMeson_Pt","ESD_TrueClusterGammaFromNeutralMeson_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1538  fHistoTrueClusterGammaFromNeutralMesonPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1539  fHistoTrueClusterGammaFromNeutralMesonPt[iCut]->GetYaxis()->SetTitle("N_{#gamma,cluster}");
1541  }
1542  fHistoTruePosPionPt[iCut] = new TH1F("ESD_TruePosPion_Pt","ESD_TruePosPion_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1543  fHistoTruePosPionPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1544  fHistoTruePosPionPt[iCut]->GetYaxis()->SetTitle("N_{#pi^{+}}");
1545  fTrueList[iCut]->Add(fHistoTruePosPionPt[iCut]);
1546  fHistoTrueNegPionPt[iCut] = new TH1F("ESD_TrueNegPion_Pt","ESD_TrueNegPion_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1547  fHistoTrueNegPionPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1548  fHistoTrueNegPionPt[iCut]->GetYaxis()->SetTitle("N_{#pi^{-}}");
1549  fTrueList[iCut]->Add(fHistoTrueNegPionPt[iCut]);
1550 
1551  fHistoTrueNegPionFromNeutralMesonPt[iCut] = new TH1F("ESD_TrueNegPionFromNeutralMeson_Pt","ESD_TrueNegPionFromNeutralMeson_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1552  fHistoTrueNegPionFromNeutralMesonPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1553  fHistoTrueNegPionFromNeutralMesonPt[iCut]->GetYaxis()->SetTitle("N_{#pi^{-}}");
1555  fHistoTruePosPionFromNeutralMesonPt[iCut] = new TH1F("ESD_TruePosPionFromNeutralMeson_Pt","ESD_TruePosPionFromNeutralMeson_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1556  fHistoTruePosPionFromNeutralMesonPt[iCut]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
1557  fHistoTruePosPionFromNeutralMesonPt[iCut]->GetYaxis()->SetTitle("N_{#pi^{+}}");
1559 
1560  fHistoDoubleCountTruePi0InvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountPi0_InvMass_Pt","ESD_TrueDoubleCountPi0_InvMass_Pt",800,0,0.8,HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1561  fHistoDoubleCountTruePi0InvMassPt[iCut]->GetXaxis()->SetTitle("M_{#gamma #gamma} (GeV/c^{2})");
1562  fHistoDoubleCountTruePi0InvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1563  fTrueList[iCut]->Add(fHistoDoubleCountTruePi0InvMassPt[iCut]);
1564  fHistoDoubleCountTrueHNMInvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountHNM_InvMass_Pt","ESD_TrueDoubleCountHNM_InvMass_Pt",800,0,0.8,HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1565  fHistoDoubleCountTrueHNMInvMassPt[iCut]->GetXaxis()->SetTitle("M_{#eta} (GeV/c^{2})");
1566  fHistoDoubleCountTrueHNMInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1567  fTrueList[iCut]->Add(fHistoDoubleCountTrueHNMInvMassPt[iCut]);
1568  }
1569  fHistoTrueMotherPiPlPiMiNDMInvMassPt[iCut] = new TH2F("ESD_TrueMotherPiPlPiMiNDM_InvMass_Pt","ESD_TrueMotherPiPlPiMiNDM_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1570  fHistoTrueMotherPiPlPiMiNDMInvMassPt[iCut]->Sumw2();
1571  fHistoTrueMotherPiPlPiMiNDMInvMassPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} (GeV/c^{2})",NameNDMLatex.Data()));
1572  fHistoTrueMotherPiPlPiMiNDMInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1574 
1575  fHistoTrueMotherHNMPiPlPiMiNDMInvMassPt[iCut] = new TH2F("ESD_TrueMotherHNMPiPlPiMiNDM_InvMass_Pt","ESD_TrueMotherHNMPiPlPiMiNDM_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1577  fHistoTrueMotherHNMPiPlPiMiNDMInvMassPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+} #pi^{-} %s} (GeV/c^{2})",NameNDMLatex.Data()));
1578  fHistoTrueMotherHNMPiPlPiMiNDMInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1580 
1581  if(!fDoLightOutput){
1582  fHistoTrueMotherGammaGammaInvMassPt[iCut] = new TH2F("ESD_TrueMotherGG_InvMass_Pt","ESD_TrueMotherGG_InvMass_Pt",HistoNMassBinsDecayMeson,HistoMassRangeNDM[0],HistoMassRangeNDM[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1583  fHistoTrueMotherGammaGammaInvMassPt[iCut]->GetXaxis()->SetTitle("M_{#gamma #gamma} (GeV/c^{2})");
1584  fHistoTrueMotherGammaGammaInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1586  fHistoTrueMotherGammaGammaFromHNMInvMassPt[iCut] = new TH2F("ESD_TrueMotherGGFromHNM_InvMass_Pt","ESD_TrueMotherGGFromHNM_InvMass_Pt",HistoNMassBinsDecayMeson,HistoMassRangeNDM[0],HistoMassRangeNDM[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1587  fHistoTrueMotherGammaGammaFromHNMInvMassPt[iCut]->GetXaxis()->SetTitle("M_{#gamma #gamma} (GeV/c^{2})");
1588  fHistoTrueMotherGammaGammaFromHNMInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1590  fHistoTrueAngleSum[iCut] = new TH2F("ESD_TrueMother_AngleSum_Pt","ESD_TrueMother_AngleSum_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1],720,0,2*TMath::Pi());
1591  fHistoTrueAngleSum[iCut]->GetXaxis()->SetTitle("#sum #angle");
1592  fHistoTrueAngleSum[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1593  fTrueList[iCut]->Add(fHistoTrueAngleSum[iCut]);
1594 
1595  if (fDoMesonQA>0){
1596  fHistoTruePionPionInvMassPt[iCut] = new TH2F("ESD_TruePiPlusPiNeg_InvMassPt","ESD_TruePiPlusPiNeg_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1597  fHistoTruePionPionInvMassPt[iCut]->GetXaxis()->SetTitle("M_{#pi^{+}#pi^{-}} (GeV/c^{2})");
1598  fHistoTruePionPionInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1599  fTrueList[iCut]->Add(fHistoTruePionPionInvMassPt[iCut]);
1600  fHistoTruePionPionFromSameMotherInvMassPt[iCut] = new TH2F("ESD_TruePiPlusPiNegFromSameMother_InvMassPt","ESD_TruePiPlusPiNegFromSameMother_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1601  fHistoTruePionPionFromSameMotherInvMassPt[iCut]->GetXaxis()->SetTitle("M_{#pi^{+}#pi^{-}} (GeV/c^{2})");
1602  fHistoTruePionPionFromSameMotherInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1604  fHistoTruePionPionFromHNMInvMassPt[iCut] = new TH2F("ESD_TruePiPlusPiNegFromHNM_InvMassPt","ESD_TruePiPlusPiNegFromHNM_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1605  fHistoTruePionPionFromHNMInvMassPt[iCut]->GetXaxis()->SetTitle("M_{#pi^{+}#pi^{-}} (GeV/c^{2})");
1606  fHistoTruePionPionFromHNMInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1608 
1609  fHistoTruePiPlPiMiSameMotherFromEtaInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiSameMotherFromEta_InvMassPt","ESD_TruePiPlPiMiSameMotherFromEta_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1610  fHistoTruePiPlPiMiSameMotherFromEtaInvMassPt[iCut]->GetXaxis()->SetTitle("M_{#pi^{+}#pi^{-}} (GeV/c^{2})");
1611  fHistoTruePiPlPiMiSameMotherFromEtaInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1613  fHistoTruePiPlPiMiSameMotherFromOmegaInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiSameMotherFromOmega_InvMassPt","ESD_TruePiPlPiMiSameMotherFromOmega_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1614  fHistoTruePiPlPiMiSameMotherFromOmegaInvMassPt[iCut]->GetXaxis()->SetTitle("M_{#pi^{+}#pi^{-}} (GeV/c^{2})");
1615  fHistoTruePiPlPiMiSameMotherFromOmegaInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1617  fHistoTruePiPlPiMiSameMotherFromRhoInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiSameMotherFromRho_InvMassPt","ESD_TruePiPlPiMiSameMotherFromRho_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1618  fHistoTruePiPlPiMiSameMotherFromRhoInvMassPt[iCut]->GetXaxis()->SetTitle("M_{#pi^{+}#pi^{-}} (GeV/c^{2})");
1619  fHistoTruePiPlPiMiSameMotherFromRhoInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1621  fHistoTruePiPlPiMiSameMotherFromEtaPrimeInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiSameMotherFromEtaPrime_InvMassPt","ESD_TruePiPlPiMiSameMotherFromEtaPrime_InvMassPt",
1622  HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1623  fHistoTruePiPlPiMiSameMotherFromEtaPrimeInvMassPt[iCut]->GetXaxis()->SetTitle("M_{#pi^{+}#pi^{-}} (GeV/c^{2})");
1624  fHistoTruePiPlPiMiSameMotherFromEtaPrimeInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1626  fHistoTruePiPlPiMiSameMotherFromK0sInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiSameMotherFromK0s_InvMassPt","ESD_TruePiPlPiMiSameMotherFromK0s_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1627  fHistoTruePiPlPiMiSameMotherFromK0sInvMassPt[iCut]->GetXaxis()->SetTitle("M_{#pi^{+}#pi^{-}} (GeV/c^{2})");
1628  fHistoTruePiPlPiMiSameMotherFromK0sInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1630  fHistoTruePiPlPiMiSameMotherFromK0lInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiSameMotherFromK0l_InvMassPt","ESD_TruePiPlPiMiSameMotherFromK0l_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1631  fHistoTruePiPlPiMiSameMotherFromK0lInvMassPt[iCut]->GetXaxis()->SetTitle("M_{#pi^{+}#pi^{-}} (GeV/c^{2})");
1632  fHistoTruePiPlPiMiSameMotherFromK0lInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1634 
1635  fHistoTruePiMiPiZeroSameMotherFromEtaInvMassPt[iCut] = new TH2F("ESD_TruePiMiPiZeroSameMotherFromEta_InvMassPt","ESD_TruePiMiPiZeroSameMotherFromEta_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1636  fHistoTruePiMiPiZeroSameMotherFromEtaInvMassPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{-}%s} (GeV/c^{2})",NameNDMLatex.Data()));
1637  fHistoTruePiMiPiZeroSameMotherFromEtaInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1639  fHistoTruePiMiPiZeroSameMotherFromOmegaInvMassPt[iCut] = new TH2F("ESD_TruePiMiPiZeroSameMotherFromOmega_InvMassPt","ESD_TruePiMiPiZeroSameMotherFromOmega_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1640  fHistoTruePiMiPiZeroSameMotherFromOmegaInvMassPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{-}%s} (GeV/c^{2})",NameNDMLatex.Data()));
1641  fHistoTruePiMiPiZeroSameMotherFromOmegaInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1643  fHistoTruePiMiPiZeroSameMotherFromRhoInvMassPt[iCut] = new TH2F("ESD_TruePiMiPiZeroSameMotherFromRho_InvMassPt","ESD_TruePiMiPiZeroSameMotherFromRho_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1644  fHistoTruePiMiPiZeroSameMotherFromRhoInvMassPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{-}%s} (GeV/c^{2})",NameNDMLatex.Data()));
1645  fHistoTruePiMiPiZeroSameMotherFromRhoInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1647  fHistoTruePiMiPiZeroSameMotherFromK0lInvMassPt[iCut] = new TH2F("ESD_TruePiMiPiZeroSameMotherFromK0l_InvMassPt","ESD_TruePiMiPiZeroSameMotherFromK0l_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1648  fHistoTruePiMiPiZeroSameMotherFromK0lInvMassPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{-}%s} (GeV/c^{2})",NameNDMLatex.Data()));
1649  fHistoTruePiMiPiZeroSameMotherFromK0lInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1651 
1652  fHistoTruePiPlPiZeroSameMotherFromEtaInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiZeroSameMotherFromEta_InvMassPt","ESD_TruePiPlPiZeroSameMotherFromEta_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1653  fHistoTruePiPlPiZeroSameMotherFromEtaInvMassPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+}%s} (GeV/c^{2})",NameNDMLatex.Data()));
1654  fHistoTruePiPlPiZeroSameMotherFromEtaInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1656  fHistoTruePiPlPiZeroSameMotherFromOmegaInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiZeroSameMotherFromOmega_InvMassPt","ESD_TruePiPlPiZeroSameMotherFromOmega_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1657  fHistoTruePiPlPiZeroSameMotherFromOmegaInvMassPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+}%s} (GeV/c^{2})",NameNDMLatex.Data()));
1658  fHistoTruePiPlPiZeroSameMotherFromOmegaInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1660  fHistoTruePiPlPiZeroSameMotherFromRhoInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiZeroSameMotherFromRho_InvMassPt","ESD_TruePiPlPiZeroSameMotherFromRho_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1661  fHistoTruePiPlPiZeroSameMotherFromRhoInvMassPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+}%s} (GeV/c^{2})",NameNDMLatex.Data()));
1662  fHistoTruePiMiPiZeroSameMotherFromRhoInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1664  fHistoTruePiPlPiZeroSameMotherFromK0lInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiZeroSameMotherFromK0l_InvMassPt","ESD_TruePiPlPiZeroSameMotherFromK0l_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1665  fHistoTruePiPlPiZeroSameMotherFromK0lInvMassPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+}%s} (GeV/c^{2})",NameNDMLatex.Data()));
1666  fHistoTruePiPlPiZeroSameMotherFromK0lInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1668  fHistoTruePiPlPiMiNDMPureCombinatoricalInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiNDMPureCombinatorical_InvMassPt","ESD_TruePiPlPiMiNDMPureCombinatorical_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1669  fHistoTruePiPlPiMiNDMPureCombinatoricalInvMassPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+}#pi^{-}%s} (GeV/c^{2})",NameNDMLatex.Data()));
1670  fHistoTruePiPlPiMiNDMPureCombinatoricalInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1672  fHistoTruePiPlPiMiNDMContaminationInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiNDMContamination_InvMassPt","ESD_TruePiPlPiMiNDMContamination_InvMassPt",HistoNMassBinsPiPlusPiMinus,HistoMassRangePiPlusPiMinus[0],HistoMassRangePiPlusPiMinus[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1673  fHistoTruePiPlPiMiNDMContaminationInvMassPt[iCut]->GetXaxis()->SetTitle(Form("M_{#pi^{+}#pi^{-}%s} (GeV/c^{2})",NameNDMLatex.Data()));
1674  fHistoTruePiPlPiMiNDMContaminationInvMassPt[iCut]->GetYaxis()->SetTitle("p_{T} (GeV/c)");
1676  if(fDoMesonQA>1){
1677  fTrueTreeList[iCut] = new TList();
1678  fTrueTreeList[iCut]->SetName(nameTrueRecTTreeList.Data());
1679  fTrueTreeList[iCut]->SetOwner(kTRUE);
1680  fCutFolder[iCut]->Add(fTrueTreeList[iCut]);
1681 
1682  fTreePiPiSameMother[iCut] = new TTree("TreePiPiSameMother","TreePiPiSameMother");
1683  fTreePiPiSameMother[iCut]->Branch("fCasePiPi", &fCasePiPi, "fCasePiPi/S");
1684  fTreePiPiSameMother[iCut]->Branch("fSamePiPiMotherID", &fSamePiPiMotherID, "fSamePiPiMotherID/F");
1685  fTreePiPiSameMother[iCut]->Branch("fSamePiPiMotherInvMass", &fSamePiPiMotherInvMass, "fSamePiPiMotherInvMass/F");
1686  fTreePiPiSameMother[iCut]->Branch("fSamePiPiMotherPt", &fSamePiPiMotherPt, "fSamePiPiMotherPt/F");
1687  fTrueTreeList[iCut]->Add(fTreePiPiSameMother[iCut]);
1688 
1689  fTreePiPiPiSameMother[iCut] = new TTree("TreePiPiPiSameMother","TreePiPiPiSameMother");
1690  fTreePiPiPiSameMother[iCut]->Branch("fSamePiPiPiMotherID", &fSamePiPiPiMotherID, "fSamePiPiPiMotherID/F");
1691  fTreePiPiPiSameMother[iCut]->Branch("fSamePiPiPiMotherInvMass", &fSamePiPiPiMotherInvMass, "fSamePiPiPiMotherInvMass/F");
1692  fTreePiPiPiSameMother[iCut]->Branch("fSamePiPiPiMotherPt", &fSamePiPiPiMotherPt, "fSamePiPiPiMotherPt/F");
1693  fTrueTreeList[iCut]->Add(fTreePiPiPiSameMother[iCut]);
1694 
1695  fTreeEventInfoHNM[iCut] = new TTree("TreeEventInfoHNM","TreeEventInfoHNM");
1696  fTreeEventInfoHNM[iCut]->Branch("fV0MultiplicityHNMEvent", &fV0MultiplicityHNMEvent, "fV0MultiplicityHNMEvent/F");
1697  fTreeEventInfoHNM[iCut]->Branch("fTrackMultiplicityHNMEvent", &fTrackMultiplicityHNMEvent, "fTrackMultiplicityHNMEvent/F");
1698  fTreeEventInfoHNM[iCut]->Branch("fZVertexHNMEvent", &fZVertexHNMEvent, "fZVertexHNMEvent/F");
1699  fTreeEventInfoHNM[iCut]->Branch("fPtHNM", &fPtHNM, "fPtHNM/F");
1700  fTrueTreeList[iCut]->Add(fTreeEventInfoHNM[iCut]);
1701  }
1702  }
1703  }
1704  }
1705  }
1706 
1710 
1711  InitBack(); // Init Background Handler
1712 
1713  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
1714  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
1715 
1716  if(fV0Reader){
1718  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms()){
1719  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
1720  }
1721  }
1722 
1724  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms()){
1725  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
1726  }
1727  }
1728 
1729  }
1730 
1731  for(Int_t iMatcherTask = 0; iMatcherTask < 3; iMatcherTask++){
1732  AliCaloTrackMatcher* temp = (AliCaloTrackMatcher*) (AliAnalysisManager::GetAnalysisManager()->GetTask(Form("CaloTrackMatcher_%i_%i",iMatcherTask,fTrackMatcherRunningMode)));
1733  if(temp && (!fDoLightOutput)) fOutputContainer->Add(temp->GetCaloTrackMatcherHistograms());
1734  }
1735 
1736  fPionSelector=(AliPrimaryPionSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("PionSelector");
1737  if(!fPionSelector){printf("Error: No PionSelector");return;} // GetV0Reader
1738 
1739  if( fPionSelector && (!fDoLightOutput)){
1740  if ( ((AliPrimaryPionCuts*)fPionSelector->GetPrimaryPionCuts())->GetCutHistograms() ){
1741  fOutputContainer->Add( ((AliPrimaryPionCuts*)fPionSelector->GetPrimaryPionCuts())->GetCutHistograms() );
1742  }
1743  }
1744 
1745  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1746  if( fEventCutArray) {
1747  if( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms() ) {
1748  fCutFolder[iCut]->Add( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
1749  }
1750  }
1751 
1752  if( fPionCutArray){
1753  if( ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutHistograms() ) {
1754  fCutFolder[iCut]->Add( ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutHistograms() );
1755  }
1756  }
1757  if (fNDMRecoMode < 2){
1758  if( fGammaCutArray ) {
1759  if( ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutHistograms() ) {
1760  fCutFolder[iCut]->Add( ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutHistograms() );
1761  }
1762  }
1763  }
1764  if (fNDMRecoMode > 0){
1765  if( fClusterCutArray ) {
1766  if( ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms() ) {
1767  fCutFolder[iCut]->Add( ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms() );
1768  }
1769  }
1770  }
1772  if( ((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(iCut))->GetCutHistograms() ) {
1773  fCutFolder[iCut]->Add( ((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(iCut))->GetCutHistograms());
1774  }
1775  }
1776  if( fMesonCutArray ) {
1777  if( ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms() ) {
1778  fCutFolder[iCut]->Add( ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
1779  }
1780  }
1781  }
1782 
1783  PostData(1, fOutputContainer);
1784 
1785 }
1786 
1787 //______________________________________________________________________
1789 
1790  //
1791  // Execute analysis for current event
1792  //
1793  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
1794  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
1795 
1796  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
1797  if(InputEvent()->IsIncompleteDAQ()==kTRUE) eventQuality = 2; // incomplete event
1798  if(eventQuality == 2 || eventQuality == 3){// Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1 or because it is incomplete
1799  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1800  fHistoNEvents[iCut]->Fill(eventQuality);
1801  }
1802  return;
1803  }
1804 
1805  fPionSelector=(AliPrimaryPionSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("PionSelector");
1806  if(!fPionSelector){printf("Error: No PionSelector");return;} // GetV0Reader
1807 
1808  if(fIsMC) fMCEvent = MCEvent();
1809  fInputEvent = InputEvent();
1810  fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
1811  fSelectorNegPionIndex = fPionSelector->GetReconstructedNegPionIndex(); // Electrons from default Cut
1812  fSelectorPosPionIndex = fPionSelector->GetReconstructedPosPionIndex(); // Positrons from default Cut
1813 
1815  //AddTaskContainers(); //Add conatiner
1816 
1817  if(fIsMC && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
1818  RelabelAODPhotonCandidates(kTRUE); // In case of AODMC relabeling MC
1819  fV0Reader->RelabelAODs(kTRUE);
1820  }
1821  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1822  fiCut = iCut;
1823 
1824  Bool_t isRunningEMCALrelAna = kFALSE;
1825  if (fNDMRecoMode > 0){
1826  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetClusterType() == 1) isRunningEMCALrelAna = kTRUE;
1827  }
1828 
1829  Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon, isRunningEMCALrelAna);
1830 
1831  if(fIsMC==2){
1832  Float_t xsection = -1.;
1833  Float_t ntrials = -1.;
1834  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetXSectionAndNTrials(fMCEvent,xsection,ntrials, fInputEvent );
1835  if((xsection==-1.) || (ntrials==-1.)) AliFatal(Form("ERROR: GetXSectionAndNTrials returned invalid xsection/ntrials, periodName from V0Reader: '%s'",fV0Reader->GetPeriodName().Data()));
1836  fProfileJetJetXSection[iCut]->Fill(0.,xsection);
1837  fHistoJetJetNTrials[iCut]->Fill("#sum{NTrials}", ntrials);
1838  }
1839 
1840  fWeightJetJetMC = 1;
1841  if (fIsMC > 1){
1842  Bool_t isMCJet = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsJetJetMCEventAccepted( fMCEvent, fWeightJetJetMC , fInputEvent);
1843  if (fIsMC == 3){
1844  Double_t weightMult = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetWeightForMultiplicity(fV0Reader->GetNumberOfPrimaryTracks());
1845  fWeightJetJetMC = fWeightJetJetMC*weightMult;
1846  }
1847 
1848  if (!isMCJet){
1849  fHistoNEvents[iCut]->Fill(10,fWeightJetJetMC);
1850  //if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(10);
1851  continue;
1852  }
1853  }
1854 
1855  if(eventNotAccepted){
1856  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
1857  fHistoNEvents[iCut]->Fill(eventNotAccepted); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
1858  continue;
1859  }
1860 
1861  if(eventQuality != 0){// Event Not Accepted
1862  // cout << "event rejected due to: " <<eventQuality << endl;
1863  fHistoNEvents[iCut]->Fill(eventQuality);
1864  continue;
1865  }
1866 
1867  fHistoNEvents[iCut]->Fill(eventQuality);
1869  if(!fDoLightOutput){
1870  fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)));
1871  }
1872  if(fMCEvent){ // Process MC Particle
1873  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
1874 
1875  if(fInputEvent->IsA()==AliESDEvent::Class()){
1876  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1877  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1878  fMCEvent);
1879  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
1880  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1881  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1882  fInputEvent);
1883  }
1884 
1885  }
1886  if(fInputEvent->IsA()==AliESDEvent::Class()) ProcessMCParticles();
1887  if(fInputEvent->IsA()==AliAODEvent::Class()) ProcessAODMCParticles();
1888  }
1889 
1890  if (fNDMRecoMode < 2){
1891  ProcessConversionPhotonCandidates(); // Process this cuts conversion gammas
1892  }
1893  if (fNDMRecoMode > 0){
1894  ProcessCaloPhotonCandidates(); // Process this cuts calo gammas
1895  }
1896 
1897  if (fNDMRecoMode == 0 ){
1898  ProcessNeutralDecayMesonCandidatesPureConversions(); // Process neutral pion candidates purely from conversions
1899  }
1900  if (fNDMRecoMode == 1){
1901  ProcessNeutralPionCandidatesMixedConvCalo(); // Process neutral pion candidates mixed conv and calo
1902  }
1903  if (fNDMRecoMode == 2){
1904  ProcessNeutralPionCandidatesPureCalo(); // Process neutral pion candidates purely from calo
1905  }
1906 
1907  if(fInputEvent->IsA()==AliESDEvent::Class()) ProcessPionCandidates(); // Process this cuts gammas
1908  if(fInputEvent->IsA()==AliAODEvent::Class()) ProcessPionCandidatesAOD();
1909 
1913 
1917 
1918  fGoodConvGammas->Clear();
1919  fClusterCandidates->Clear();
1922  fPosPionCandidates->Clear();
1923  fNegPionCandidates->Clear();
1924  fGoodVirtualParticles->Clear(); // delete this cuts good gammas
1925  }
1926 
1927  fSelectorNegPionIndex.clear();
1928  fSelectorPosPionIndex.clear();
1929 
1930  if( fIsMC && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
1931  RelabelAODPhotonCandidates(kFALSE); // Back to ESDMC Label
1932  fV0Reader->RelabelAODs(kFALSE);
1933  }
1934 
1935  PostData( 1, fOutputContainer );
1936 }
1937 //________________________________________________________________________
1939  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1940  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
1941  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
1942  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
1943  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
1944  }
1945 
1946  if( !((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift() ){
1947  if(!fDoLightOutput){
1948  fProfileEtaShift[iCut]->Fill(0.,0.);
1949  }
1950  continue; // No Eta Shift requested, continue
1951  }
1952  if( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
1953  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
1954  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1955  ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->SetEtaShift( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() );
1956  if(!fDoLightOutput){
1957  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1958  }
1959  continue;
1960  } else {
1961  printf(" Eta t PiPlusPiMinus Gamma Task %s :: Eta Shift Manually Set to %f \n\n",
1962  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
1963  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1964  ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->SetEtaShift( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() );
1965  if(!fDoLightOutput){
1966  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1967  }
1968  }
1969  }
1970  return kTRUE;
1971 }
1972 
1973 
1976 }
1977 
1978 
1979 //________________________________________________________________________
1981 {
1982 
1983  Int_t nclus = 0;
1984  nclus = fInputEvent->GetNumberOfCaloClusters();
1985 
1986  // cout << nclus << endl;
1987 
1988  if(nclus == 0) return;
1989 
1990  // vertex
1991  Double_t vertex[3] = {0};
1992  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1993 
1994  // Loop over EMCal clusters
1995  for(Long_t i = 0; i < nclus; i++){
1996 
1997  std::unique_ptr<AliVCluster> clus;
1998  if(fInputEvent->IsA()==AliESDEvent::Class()) clus = std::unique_ptr<AliVCluster>(new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(i)));
1999  else if(fInputEvent->IsA()==AliAODEvent::Class()) clus = std::unique_ptr<AliVCluster>(new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i)));
2000 
2001  if (!clus) continue;
2002  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelected(clus.get(),fInputEvent,fMCEvent,fIsMC,1.,i)) continue;
2003  // TLorentzvector with cluster
2004  TLorentzVector clusterVector;
2005  clus->GetMomentum(clusterVector,vertex);
2006 
2007  TLorentzVector tmpvec;
2008  tmpvec.SetPxPyPzE(clusterVector.Px(),clusterVector.Py(),clusterVector.Pz(),clusterVector.E());
2009 
2010  // convert to AODConversionPhoton
2011  AliAODConversionPhoton *PhotonCandidate=new AliAODConversionPhoton(&tmpvec);
2012  if(!PhotonCandidate) continue;
2013 
2014  // Flag Photon as CaloPhoton
2015  PhotonCandidate->SetIsCaloPhoton();
2016  PhotonCandidate->SetCaloClusterRef(i);
2017  // get MC label
2018  if(fIsMC){
2019  Int_t* mclabelsCluster = clus->GetLabels();
2020  PhotonCandidate->SetNCaloPhotonMCLabels(clus->GetNLabels());
2021  // cout << clus->GetNLabels() << endl;
2022  if (clus->GetNLabels()>0){
2023  for (Int_t k =0; k< (Int_t)clus->GetNLabels(); k++){
2024  if (k< 50)PhotonCandidate->SetCaloPhotonMCLabel(k,mclabelsCluster[k]);
2025  // Int_t pdgCode = fMCEvent->Particle(mclabelsCluster[k])->GetPdgCode();
2026  // cout << "label " << k << "\t" << mclabelsCluster[k] << " pdg code: " << pdgCode << endl;
2027  }
2028  }
2029  }
2030 
2031  fIsFromMBHeader = kTRUE;
2032  // test whether largest contribution to cluster orginates in added signals
2033  if ((((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() > 0) && fIsMC && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetCaloPhotonMCLabel(0), fMCEvent, fInputEvent) == 0) fIsFromMBHeader = kFALSE;
2034  if (fIsFromMBHeader && (!fDoLightOutput)){
2035  fHistoClusterGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightJetJetMC);
2036  fHistoClusterGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightJetJetMC);
2037  }
2038  fClusterCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
2039 
2040  if(fIsMC){
2041  if(fInputEvent->IsA()==AliESDEvent::Class()){
2042  ProcessTrueCaloPhotonCandidates(PhotonCandidate);
2043  } else {
2044  ProcessTrueCaloPhotonCandidatesAOD(PhotonCandidate);
2045  }
2046  }
2047  }
2048 }
2049 
2050 //________________________________________________________________________
2052 {
2053  TParticle *Photon = nullptr;
2054  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
2055  if (TruePhotonCandidate->GetCaloPhotonMCLabel(0)<0) return;
2056  // fHistoTrueNLabelsInClus[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels());
2057 
2058  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2059  Double_t mcProdVtxX = primVtxMC->GetX();
2060  Double_t mcProdVtxY = primVtxMC->GetY();
2061  Double_t mcProdVtxZ = primVtxMC->GetZ();
2062 
2063  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0)Photon = fMCEvent->Particle(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
2064  else return;
2065 
2066  if(Photon == nullptr){
2067  // cout << "no photon" << endl;
2068  return;
2069  }
2070 
2071  // Int_t pdgCodeParticle = Photon->GetPdgCode();
2072  TruePhotonCandidate->SetCaloPhotonMCFlags(fMCEvent, kFALSE);
2073 
2074  // True Photon
2075  if(fIsFromMBHeader && (!fDoLightOutput)){
2076  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, TruePhotonCandidate->GetCaloPhotonMCLabel(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2077  if(isPrimary){
2078  if (TruePhotonCandidate->IsLargestComponentPhoton()){
2079  fHistoTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2080  if (GammaIsNeutralMesonPiPlPiMiNDMDaughter(TruePhotonCandidate->GetCaloPhotonMCLabel(0))){
2081  fHistoTrueClusterGammaFromNeutralMesonPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2082  }
2083  }
2084  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2085  fHistoTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2086  if (GammaIsNeutralMesonPiPlPiMiNDMDaughter(TruePhotonCandidate->GetCaloPhotonMCLabel(0))){
2087  fHistoTrueClusterGammaFromNeutralMesonPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2088  }
2089  }
2090  }
2091  }
2092  return;
2093 }
2094 
2095 //________________________________________________________________________
2097 {
2098  AliAODMCParticle *Photon = NULL;
2099  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2100 
2101  if (AODMCTrackArray){
2102  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
2103  if (TruePhotonCandidate->GetCaloPhotonMCLabel(0)<0) return;
2104  }else{
2105  AliInfo("AODMCTrackArray could not be loaded");
2106  return;
2107  }
2108  // fHistoTrueNLabelsInClus[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels());
2109 
2110  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2111  Double_t mcProdVtxX = primVtxMC->GetX();
2112  Double_t mcProdVtxY = primVtxMC->GetY();
2113  Double_t mcProdVtxZ = primVtxMC->GetZ();
2114 
2115  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0)Photon = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
2116  else return;
2117 
2118  if(Photon == NULL){
2119  return;
2120  }
2121 
2122  // Int_t pdgCodeParticle = Photon->GetPdgCode();
2123  TruePhotonCandidate->SetCaloPhotonMCFlagsAOD(fInputEvent, kFALSE);
2124 
2125  // True Photon
2126  if(fIsFromMBHeader && (!fDoLightOutput)){
2127  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2128  if(isPrimary){
2129  if (TruePhotonCandidate->IsLargestComponentPhoton()){
2130  fHistoTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2131  if (GammaIsNeutralMesonPiPlPiMiNDMDaughterAOD(AODMCTrackArray,TruePhotonCandidate->GetCaloPhotonMCLabel(0))){
2132  fHistoTrueClusterGammaFromNeutralMesonPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2133  }
2134  }
2135  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
2136  fHistoTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2137  if (GammaIsNeutralMesonPiPlPiMiNDMDaughterAOD(AODMCTrackArray,TruePhotonCandidate->GetCaloPhotonMCLabel(0))){
2138  fHistoTrueClusterGammaFromNeutralMesonPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2139  }
2140  }
2141  }
2142  }
2143  return;
2144 }
2145 
2146 
2147 //________________________________________________________________________
2149  Int_t nV0 = 0;
2150  TList GoodGammasStepOne;
2151  TList GoodGammasStepTwo;
2152  // Loop over Photon Candidates allocated by ReaderV1
2153 
2154  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
2155  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
2156  if(!PhotonCandidate) continue;
2157 
2158  fIsFromMBHeader = kTRUE;
2159 
2160  if( fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0 ){
2161  Int_t isPosFromMBHeader
2162  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
2163  if(isPosFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2164  Int_t isNegFromMBHeader
2165  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent,fInputEvent);
2166  if(isNegFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2167  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
2168  }
2169 
2170  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fInputEvent)) continue;
2171 
2172  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut() &&
2173  !((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // if no post reader loop is required add to events good gammas
2174 
2175  fGoodConvGammas->Add(PhotonCandidate);
2176 
2177  if(fIsFromMBHeader && (!fDoLightOutput)){
2178  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightJetJetMC);
2179  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightJetJetMC);
2180  }
2181 
2182  if(fMCEvent){
2183  if(fInputEvent->IsA()==AliESDEvent::Class())
2184  ProcessTrueConversionPhotonCandidates(PhotonCandidate);
2185  if(fInputEvent->IsA()==AliAODEvent::Class())
2187  }
2188  } else if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
2189  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
2190  nV0++;
2191  GoodGammasStepOne.Add(PhotonCandidate);
2192  } else if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut() &&
2193  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
2194  GoodGammasStepTwo.Add(PhotonCandidate);
2195  }
2196  }
2197 
2198 
2199  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut()){
2200  for(Int_t i = 0;i<GoodGammasStepOne.GetEntries();i++){
2201  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GoodGammasStepOne.At(i);
2202  if(!PhotonCandidate) continue;
2203  fIsFromMBHeader = kTRUE;
2204  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2205  Int_t isPosFromMBHeader
2206  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent,fInputEvent);
2207  Int_t isNegFromMBHeader
2208  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent,fInputEvent);
2209  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
2210  }
2211  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GoodGammasStepOne.GetEntries())) continue;
2212  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
2213  fGoodConvGammas->Add(PhotonCandidate);
2214  if(fIsFromMBHeader && (!fDoLightOutput)){
2215  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightJetJetMC);
2216  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightJetJetMC);
2217  }
2218  if(fMCEvent){
2219  if(fInputEvent->IsA()==AliESDEvent::Class())
2220  ProcessTrueConversionPhotonCandidates(PhotonCandidate);
2221  if(fInputEvent->IsA()==AliAODEvent::Class())
2223  }
2224  }
2225  else GoodGammasStepTwo.Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
2226  }
2227  }
2228  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){
2229  for(Int_t i = 0;i<GoodGammasStepTwo.GetEntries();i++){
2230  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GoodGammasStepTwo.At(i);
2231  if(!PhotonCandidate) continue;
2232 
2233  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2234  Int_t isPosFromMBHeader
2235  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent,fInputEvent);
2236  Int_t isNegFromMBHeader
2237  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent,fInputEvent);
2238  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
2239  }
2240 
2241  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,&GoodGammasStepTwo,i)) continue;
2242  fGoodConvGammas->Add(PhotonCandidate); // Add gamma to current cut TList
2243 
2244  if(fIsFromMBHeader && (!fDoLightOutput)){
2245  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightJetJetMC); // Differences to old V0Reader in p_t due to conversion KF->TLorentzVector
2246  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta(), fWeightJetJetMC);
2247  }
2248 
2249  if(fMCEvent){
2250  if(fInputEvent->IsA()==AliESDEvent::Class())
2251  ProcessTrueConversionPhotonCandidates(PhotonCandidate);
2252  if(fInputEvent->IsA()==AliAODEvent::Class())
2254  }
2255  }
2256  }
2257 }
2258 
2259 //________________________________________________________________________
2261 {
2262  // Process True Photons
2263  TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCEvent);
2264  TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCEvent);
2265 
2266  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2267  Double_t mcProdVtxX = primVtxMC->GetX();
2268  Double_t mcProdVtxY = primVtxMC->GetY();
2269  Double_t mcProdVtxZ = primVtxMC->GetZ();
2270 
2271 
2272  if(posDaughter == NULL || negDaughter == NULL){
2273  return; // One particle does not exist
2274  }
2275  if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){ // Not Same Mother == Combinatorial Bck
2276  return;
2277  }
2278 
2279  else if (posDaughter->GetMother(0) == -1){
2280  return;
2281  }
2282 
2283  if(TMath::Abs(posDaughter->GetPdgCode())!=11 || TMath::Abs(negDaughter->GetPdgCode())!=11){
2284  return; //One Particle is not electron
2285  }
2286  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()){
2287  return; // Same Charge
2288  }
2289  if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5){
2290  return;// check if the daughters come from a conversion
2291  }
2292  TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCEvent);
2293  if(Photon->GetPdgCode() != 22){
2294  return; // Mother is no Photon
2295  }
2296  // True Photon
2297 
2298  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueConvGammas,posDaughter->GetMother(0)) && (!fDoLightOutput)) fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt());
2299 
2300  Int_t labelGamma = TruePhotonCandidate->GetMCParticleLabel(fMCEvent);
2301  Bool_t gammaIsPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelGamma, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2302  if( gammaIsPrimary ){
2303  if( fIsFromMBHeader && (!fDoLightOutput) ){
2304  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
2305  if (GammaIsNeutralMesonPiPlPiMiNDMDaughter(labelGamma)){
2306  fHistoTrueConvGammaFromNeutralMesonPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2307  }
2308  }
2309  }
2310 }
2311 
2312 //________________________________________________________________________
2314 {
2315  // Process True Photons
2316  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2317  if (AODMCTrackArray == NULL || TruePhotonCandidate == NULL){
2318  return;
2319  }
2320  AliAODMCParticle *posDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelPositive());
2321  AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelNegative());
2322 
2323  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2324  Double_t mcProdVtxX = primVtxMC->GetX();
2325  Double_t mcProdVtxY = primVtxMC->GetY();
2326  Double_t mcProdVtxZ = primVtxMC->GetZ();
2327 
2328 
2329  if(posDaughter == NULL || negDaughter == NULL) {
2330  return; // One particle does not exist
2331  }
2332  if(posDaughter->GetMother() != negDaughter->GetMother()){ // Not Same Mother == Combinatorial Bck
2333  return;
2334  }
2335  else if (posDaughter->GetMother() == -1){
2336  return;
2337  }
2338 
2339  if(TMath::Abs(posDaughter->GetPdgCode())!=11 || TMath::Abs(negDaughter->GetPdgCode())!=11){
2340  return; //One Particle is not electron
2341  }
2342  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()){
2343  return; // Same Charge
2344  }
2345  if(posDaughter->GetMCProcessCode() != 5 || negDaughter->GetMCProcessCode() !=5){
2346  return;// check if the daughters come from a conversion
2347  }
2348  AliAODMCParticle *Photon = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
2349  if(Photon->GetPdgCode() != 22){
2350  return; // Mother is no Photon
2351 }
2352  // True Photon
2353 
2354  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueConvGammas,posDaughter->GetMother()) && (!fDoLightOutput)) fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt());
2355 
2356  // for AOD you have to ask electron for mother to get label
2357  Int_t labelGamma = posDaughter->GetMother();
2358  Bool_t gammaIsPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2359  if( gammaIsPrimary ){
2360  if( fIsFromMBHeader && (!fDoLightOutput) ){
2361  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2362  if (GammaIsNeutralMesonPiPlPiMiNDMDaughterAOD(AODMCTrackArray, labelGamma)){
2363  fHistoTrueConvGammaFromNeutralMesonPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
2364  }
2365  }
2366  }
2367 }
2368 
2369 //________________________________________________________________________
2371  // Conversion Gammas
2372  if(fGoodConvGammas->GetEntries()>1){
2373  for(Int_t firstGammaIndex=0;firstGammaIndex<fGoodConvGammas->GetEntries()-1;firstGammaIndex++){
2374  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGoodConvGammas->At(firstGammaIndex));
2375  if (gamma0==nullptr) continue;
2376  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGoodConvGammas->GetEntries();secondGammaIndex++){
2377  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGoodConvGammas->At(secondGammaIndex));
2378  //Check for same Electron ID
2379  if (gamma1==nullptr) continue;
2380  if(gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelPositive() ||
2381  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelNegative() ||
2382  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelPositive() ||
2383  gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelNegative() ) continue;
2384 
2385  AliAODConversionMother *NDMcand = new AliAODConversionMother(gamma0,gamma1);
2386  NDMcand->SetLabels(firstGammaIndex,secondGammaIndex);
2387 
2388  NDMcand->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
2389 
2390  if(!fDoLightOutput){
2391  fHistoGammaGammaInvMassPtBeforeCuts[fiCut]->Fill(NDMcand->M(),NDMcand->Pt(), fWeightJetJetMC);
2392  }
2393  if((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelected(NDMcand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
2394  if(fIsMC){
2395  if(fInputEvent->IsA()==AliESDEvent::Class())
2396  ProcessTrueNeutralPionCandidatesPureConversions(NDMcand,gamma0,gamma1);
2397  if(fInputEvent->IsA()==AliAODEvent::Class())
2399  }
2400  if (((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 0)){
2401  fNeutralDecayParticleCandidates->Add(NDMcand);
2402 
2403  if(!fDoLightOutput){
2404  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt(), fWeightJetJetMC);
2405  }
2406  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixing()) &&
2407  (((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 1))){
2409 
2410  if(!fDoLightOutput){
2411  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt(), fWeightJetJetMC);
2412  }
2413  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixingBothSides()) &&
2414  ((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 2)) ||
2415  ((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 3))))){
2417 
2418  if(!fDoLightOutput){
2419  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt(), fWeightJetJetMC);
2420  }
2421  } else{
2422  delete NDMcand;
2423  }
2424  } else{
2425  delete NDMcand;
2426  }
2427  }
2428  }
2429  }
2430 }
2431 
2432 
2433 //________________________________________________________________________
2435 
2436  // Conversion Gammas
2437  if(fClusterCandidates->GetEntries()>0){
2438 
2439  // vertex
2440  Double_t vertex[3] = {0};
2441  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
2442 
2443  for(Int_t firstGammaIndex=0;firstGammaIndex<fClusterCandidates->GetEntries();firstGammaIndex++){
2444  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(firstGammaIndex));
2445  if (gamma0==nullptr) continue;
2446 
2447  for(Int_t secondGammaIndex=0;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
2448  if (firstGammaIndex == secondGammaIndex) continue;
2449  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
2450  if (gamma1==nullptr) continue;
2451 
2452  AliAODConversionMother *NDMcand = new AliAODConversionMother(gamma0,gamma1);
2453  NDMcand->SetLabels(firstGammaIndex,secondGammaIndex);
2454 
2455  if(!fDoLightOutput){
2456  fHistoGammaGammaInvMassPtBeforeCuts[fiCut]->Fill(NDMcand->M(),NDMcand->Pt(), fWeightJetJetMC);
2457  }
2458 
2459  if((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelected(NDMcand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
2460  if(fIsMC){
2461  if(fInputEvent->IsA()==AliESDEvent::Class())
2462  ProcessTrueNeutralPionCandidatesPureCalo(NDMcand,gamma0,gamma1);
2463  if(fInputEvent->IsA()==AliAODEvent::Class())
2464  ProcessTrueNeutralPionCandidatesPureCaloAOD(NDMcand,gamma0,gamma1);
2465  }
2466 
2467  if (((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 0)){
2468  fNeutralDecayParticleCandidates->Add(NDMcand);
2469 
2470  if(!fDoLightOutput){
2471  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt(), fWeightJetJetMC);
2472  }
2473  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixing()) &&
2474  (((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 1))){
2476 
2477  if(!fDoLightOutput){
2478  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt(), fWeightJetJetMC);
2479  }
2480  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixingBothSides()) &&
2481  ((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 2)) ||
2482  ((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 3))))){
2484 
2485  if(!fDoLightOutput){
2486  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt(), fWeightJetJetMC);
2487  }
2488  }else {
2489  delete NDMcand;
2490  }
2491  } else{
2492  delete NDMcand;
2493  }
2494  }
2495  }
2496  }
2497 }
2498 
2499 //______________________________________________________________________
2501 {
2502  // Process True Mesons
2503 
2504  Bool_t isTrueNDM = kFALSE;
2505  Int_t gamma0MCLabel = TrueGammaCandidate0->GetCaloPhotonMCLabel(0); // get most probable MC label
2506  Int_t gamma0MotherLabel = -1;
2507 
2508  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2509  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
2510  if (TrueGammaCandidate0->IsLargestComponentPhoton() || TrueGammaCandidate0->IsLargestComponentElectron()){ // largest component is electro magnetic
2511  // get mother of interest (pi0 or eta)
2512  if (TrueGammaCandidate0->IsLargestComponentPhoton()){ // for photons its the direct mother
2513  gamma0MotherLabel=gammaMC0->GetMother(0);
2514  } else if (TrueGammaCandidate0->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
2515  if (TrueGammaCandidate0->IsConversion() && gammaMC0->GetMother(0)>-1){
2516  gamma0MotherLabel=fMCEvent->Particle(gammaMC0->GetMother(0))->GetMother(0);
2517  } else {
2518  gamma0MotherLabel=gammaMC0->GetMother(0);
2519  }
2520  }
2521  }
2522  }
2523 
2524  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2525 
2526  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
2527  Int_t gamma1MotherLabel = -1;
2528  // check if
2529  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2530  // Daughters Gamma 1
2531  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
2532  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
2533  // get mother of interest (pi0 or eta)
2534  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
2535  gamma1MotherLabel=gammaMC1->GetMother(0);
2536  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
2537  if (TrueGammaCandidate1->IsConversion() && gammaMC1->GetMother(0)>-1) gamma1MotherLabel=fMCEvent->Particle(gammaMC1->GetMother(0))->GetMother(0);
2538  else gamma1MotherLabel=gammaMC1->GetMother(0);
2539  }
2540  }
2541  }
2542 
2543  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
2544  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == fPDGCodeNDM){
2545  isTrueNDM=kTRUE;
2546  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel) && (!fDoLightOutput)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2547  }
2548  }
2549 
2550  if(isTrueNDM){// True Pion
2551  Pi0Candidate->SetTrueMesonValue(1);
2552  Pi0Candidate->SetMCLabel(gamma0MotherLabel);
2553  if(!fDoLightOutput){
2554  fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2555  switch( fSelectedHeavyNeutralMeson ) {
2556  case 0: // ETA MESON
2557  if( IsEtaPiPlPiMiPiZeroDaughter(gamma0MotherLabel) )
2558  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2559  break;
2560  case 1: // OMEGA MESON
2561  if( IsOmegaPiPlPiMiPiZeroDaughter(gamma0MotherLabel) )
2562  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2563  break;
2564  case 2: // ETA PRIME MESON
2565  if( IsEtaPrimePiPlPiMiEtaDaughter(gamma0MotherLabel) )
2566  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2567  break;
2568  case 3: // D0 MESON
2569  if( IsD0PiPlPiMiPiZeroDaughter(gamma0MotherLabel) )
2570  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2571  break;
2572  default:
2573  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
2574  }
2575  }
2576  }
2577 }
2578 
2579 //______________________________________________________________________
2581 {
2582  // Process True Mesons
2583  // Process True Mesons
2584  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2585  if (AODMCTrackArray == NULL) return;
2586 
2587  Bool_t isTrueNDM = kFALSE;
2588  Int_t gamma0MCLabel = TrueGammaCandidate0->GetCaloPhotonMCLabel(0); // get most probable MC label
2589  Int_t gamma0MotherLabel = -1;
2590 
2591  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2592  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
2593  if (TrueGammaCandidate0->IsLargestComponentPhoton() || TrueGammaCandidate0->IsLargestComponentElectron()){ // largest component is electro magnetic
2594  // get mother of interest (pi0 or eta)
2595  if (TrueGammaCandidate0->IsLargestComponentPhoton()){ // for photons its the direct mother
2596  gamma0MotherLabel=gammaMC0->GetMother();
2597  } else if (TrueGammaCandidate0->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
2598  if (TrueGammaCandidate0->IsConversion() && gammaMC0->GetMother()>-1){
2599  AliAODMCParticle * gammaGrandMotherMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC0->GetMother()));
2600  gamma0MotherLabel=gammaGrandMotherMC0->GetMother();
2601  } else {
2602  gamma0MotherLabel=gammaMC0->GetMother();
2603  }
2604  }
2605  }
2606  }
2607 
2608  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2609 
2610  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
2611  Int_t gamma1MotherLabel = -1;
2612  // check if
2613  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2614  // Daughters Gamma 1
2615  AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
2616  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
2617  // get mother of interest (pi0 or eta)
2618  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
2619  gamma1MotherLabel=gammaMC1->GetMother();
2620  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
2621  if (TrueGammaCandidate1->IsConversion() && gammaMC1->GetMother()>-1){
2622  AliAODMCParticle * gammaGrandMotherMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC1->GetMother()));
2623  gamma1MotherLabel=gammaGrandMotherMC1->GetMother();
2624  }else gamma1MotherLabel=gammaMC1->GetMother();
2625  }
2626  }
2627  }
2628 
2629  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
2630  if(((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == fPDGCodeNDM){
2631  isTrueNDM=kTRUE;
2632  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel) && (!fDoLightOutput)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2633  }
2634  }
2635 
2636  if(isTrueNDM){// True Pion
2637  Pi0Candidate->SetTrueMesonValue(1);
2638  Pi0Candidate->SetMCLabel(gamma0MotherLabel);
2639  if(!fDoLightOutput){
2640  fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2641  switch( fSelectedHeavyNeutralMeson ) {
2642  case 0: // ETA MESON
2643  if( IsEtaPiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,gamma0MotherLabel) )
2644  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2645  break;
2646  case 1: // OMEGA MESON
2647  if( IsOmegaPiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,gamma0MotherLabel) )
2648  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2649  break;
2650  case 2: // ETA PRIME MESON
2651  if( IsEtaPrimePiPlPiMiEtaDaughterAOD(AODMCTrackArray,gamma0MotherLabel) )
2652  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2653  break;
2654  case 3: // D0 MESON
2655  if( IsD0PiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,gamma0MotherLabel) )
2656  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2657  break;
2658  default:
2659  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
2660  }
2661  }
2662  }
2663 }
2664 
2665 
2666 
2667 //______________________________________________________________________
2669 {
2670  // Process True Mesons
2671  if(TrueGammaCandidate0->GetV0Index()<fInputEvent->GetNumberOfV0s()){
2672  Bool_t isTrueNDM = kFALSE;
2673  Bool_t isTruePi0Dalitz = kFALSE;
2674  Bool_t gamma0DalitzCand = kFALSE;
2675  Bool_t gamma1DalitzCand = kFALSE;
2676  Int_t gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCEvent);
2677  Int_t gamma0MotherLabel = -1;
2678  Int_t motherRealLabel = -1;
2679  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2680  // Daughters Gamma 0
2681  TParticle * negativeMC = (TParticle*)TrueGammaCandidate0->GetNegativeMCDaughter(fMCEvent);
2682  TParticle * positiveMC = (TParticle*)TrueGammaCandidate0->GetPositiveMCDaughter(fMCEvent);
2683  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
2684  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2685  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
2686  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
2687  gamma0MotherLabel=gammaMC0->GetFirstMother();
2688  motherRealLabel=gammaMC0->GetFirstMother();
2689  }
2690  }
2691  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
2692  gamma0DalitzCand = kTRUE;
2693  gamma0MotherLabel=-111;
2694  motherRealLabel=gamma0MCLabel;
2695  }
2696  }
2697  }
2698  if(TrueGammaCandidate1->GetV0Index()<fInputEvent->GetNumberOfV0s()){
2699  Int_t gamma1MCLabel = TrueGammaCandidate1->GetMCParticleLabel(fMCEvent);
2700  Int_t gamma1MotherLabel = -1;
2701  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2702  // Daughters Gamma 1
2703  TParticle * negativeMC = (TParticle*)TrueGammaCandidate1->GetNegativeMCDaughter(fMCEvent);
2704  TParticle * positiveMC = (TParticle*)TrueGammaCandidate1->GetPositiveMCDaughter(fMCEvent);
2705  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
2706  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2707  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
2708  if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
2709  gamma1MotherLabel=gammaMC1->GetFirstMother();
2710  }
2711  }
2712  if(gammaMC1->GetPdgCode() ==111 ){ // Dalitz candidate
2713  gamma1DalitzCand = kTRUE;
2714  gamma1MotherLabel=-111;
2715  }
2716  }
2717  }
2718  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
2719  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == fPDGCodeNDM){
2720  isTrueNDM=kTRUE;
2721  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel) && (!fDoLightOutput)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2722  }
2723  }
2724 
2725  //Identify Dalitz candidate
2726  if (gamma1DalitzCand || gamma0DalitzCand){
2727  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
2728  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
2729  }
2730  if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
2731  if (gamma1MotherLabel == -111) isTruePi0Dalitz = kTRUE;
2732  }
2733  }
2734 
2735 
2736  if(isTrueNDM || isTruePi0Dalitz){// True Pion
2737  Pi0Candidate->SetTrueMesonValue(1);
2738  Pi0Candidate->SetMCLabel(motherRealLabel);
2739  if(!fDoLightOutput){
2740  fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2741  switch( fSelectedHeavyNeutralMeson ) {
2742  case 0: // ETA MESON
2743  if( IsEtaPiPlPiMiPiZeroDaughter(motherRealLabel) )
2744  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2745  break;
2746  case 1: // OMEGA MESON
2747  if( IsOmegaPiPlPiMiPiZeroDaughter(motherRealLabel) )
2748  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2749  break;
2750  case 2: // ETA PRIME MESON
2751  if( IsEtaPrimePiPlPiMiEtaDaughter(motherRealLabel) )
2752  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2753  break;
2754  case 3: // D0 MESON
2755  if( IsD0PiPlPiMiPiZeroDaughter(motherRealLabel) )
2756  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2757  break;
2758  default:
2759  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
2760  }
2761  }
2762  }
2763  }
2764  }
2765 }
2766 
2767 //______________________________________________________________________
2769 {
2770 
2771  // Process True Mesons
2772  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2773  Bool_t isTruePi0 = kFALSE;
2774  Bool_t isTruePi0Dalitz = kFALSE;
2775  Bool_t gamma0DalitzCand = kFALSE;
2776  Bool_t gamma1DalitzCand = kFALSE;
2777  Int_t motherRealLabel = -1;
2778 
2779  if (AODMCTrackArray!=nullptr && TrueGammaCandidate0 != nullptr){
2780  AliAODMCParticle *positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
2781  AliAODMCParticle *negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
2782 
2783  Int_t gamma0MCLabel = -1;
2784  Int_t gamma0MotherLabel = -1;
2785  if(!positiveMC||!negativeMC)
2786  return;
2787 
2788  if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
2789  gamma0MCLabel = positiveMC->GetMother();
2790  }
2791 
2792  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2793  // Daughters Gamma 0
2794  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
2795  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2796  if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
2797  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
2798  gamma0MotherLabel=gammaMC0->GetMother();
2799  motherRealLabel=gammaMC0->GetMother();
2800  }
2801  }
2802  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
2803  gamma0DalitzCand = kTRUE;
2804  gamma0MotherLabel=-111;
2805  motherRealLabel=gamma0MCLabel;
2806  }
2807  }
2808  }
2809  positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelPositive()));
2810  negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelNegative()));
2811 
2812  Int_t gamma1MCLabel = -1;
2813  Int_t gamma1MotherLabel = -1;
2814  if(!positiveMC||!negativeMC)
2815  return;
2816 
2817  if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
2818  gamma1MCLabel = positiveMC->GetMother();
2819  }
2820  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2821  // Daughters Gamma 1
2822  AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
2823  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2824  if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
2825  if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
2826  gamma1MotherLabel=gammaMC1->GetMother();
2827  }
2828  }
2829  if(gammaMC1->GetPdgCode() ==111 ){ // Dalitz candidate
2830  gamma1DalitzCand = kTRUE;
2831  gamma1MotherLabel=-111;
2832  }
2833  }
2834  }
2835  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
2836  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == fPDGCodeNDM){
2837  isTruePi0=kTRUE;
2838  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel) &&(!fDoLightOutput)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2839  }
2840  }
2841 
2842  //Identify Dalitz candidate
2843  if (gamma1DalitzCand || gamma0DalitzCand){
2844  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
2845  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
2846  }
2847  if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
2848  if (gamma1MotherLabel == -111) isTruePi0Dalitz = kTRUE;
2849  }
2850  }
2851 
2852  if(isTruePi0 || isTruePi0Dalitz){// True Pion
2853  Pi0Candidate->SetTrueMesonValue(1);
2854  Pi0Candidate->SetMCLabel(motherRealLabel);
2855  if(!fDoLightOutput){
2856  fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2857  switch( fSelectedHeavyNeutralMeson ) {
2858  case 0: // ETA MESON
2859  if( IsEtaPiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,motherRealLabel) )
2860  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2861  break;
2862  case 1: // OMEGA MESON
2863  if( IsOmegaPiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,motherRealLabel) )
2864  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2865  break;
2866  case 2: // ETA PRIME MESON
2867  if( IsEtaPrimePiPlPiMiEtaDaughterAOD(AODMCTrackArray, motherRealLabel) )
2868  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2869  break;
2870  case 3: // D0 MESON
2871  if( IsD0PiPlPiMiPiZeroDaughterAOD(AODMCTrackArray, motherRealLabel) )
2872  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
2873  break;
2874  default:
2875  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
2876  }
2877  }
2878  }
2879  }
2880  return;
2881 }
2882 
2883 
2884 //________________________________________________________________________
2886 
2887  // Conversion Gammas
2888  if(fGoodConvGammas->GetEntries()>0){
2889  // vertex
2890  Double_t vertex[3] = {0};
2891  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
2892 
2893  for(Int_t firstGammaIndex=0;firstGammaIndex<fGoodConvGammas->GetEntries();firstGammaIndex++){
2894  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGoodConvGammas->At(firstGammaIndex));
2895  if (gamma0==nullptr) continue;
2896 
2897  for(Int_t secondGammaIndex=0;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
2898  Bool_t matched = kFALSE;
2899  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
2900  if (gamma1==nullptr) continue;
2901 
2902  if (gamma1->GetIsCaloPhoton()){
2903  AliVCluster* cluster = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
2904  matched = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma0,cluster, fInputEvent );
2905  }
2906 
2907  AliAODConversionMother *NDMcand = new AliAODConversionMother(gamma0,gamma1);
2908  NDMcand->SetLabels(firstGammaIndex,secondGammaIndex);
2909 
2910  if(!fDoLightOutput){
2911  fHistoGammaGammaInvMassPtBeforeCuts[fiCut]->Fill(NDMcand->M(),NDMcand->Pt(), fWeightJetJetMC);
2912  }
2913 
2914  if((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelected(NDMcand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
2915  if (!matched){
2916  if(fIsMC){
2917  if(fInputEvent->IsA()==AliESDEvent::Class())
2918  ProcessTrueNeutralPionCandidatesMixedConvCalo(NDMcand,gamma0,gamma1);
2919  if(fInputEvent->IsA()==AliAODEvent::Class())
2920  ProcessTrueNeutralPionCandidatesMixedConvCaloAOD(NDMcand,gamma0,gamma1);
2921  }
2922  if (((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 0)){
2923  fNeutralDecayParticleCandidates->Add(NDMcand);
2924 
2925  if(!fDoLightOutput){
2926  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt(), fWeightJetJetMC);
2927  }
2928  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixing()) &&
2929  (((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 1))){
2931 
2932  if(!fDoLightOutput){
2933  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt(), fWeightJetJetMC);
2934  }
2935  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixingBothSides()) &&
2936  ((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 2)) ||
2937  ((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 3))))){
2939 
2940  if(!fDoLightOutput){
2941  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt(), fWeightJetJetMC);
2942  }
2943  } else{
2944  delete NDMcand;
2945  NDMcand=0x0;
2946  }
2947  }else{
2948  delete NDMcand;
2949  NDMcand=0x0;
2950  }
2951  }else{
2952  delete NDMcand;
2953  NDMcand=0x0;
2954  }
2955  }
2956  }
2957  }
2958 }
2959 
2960 //______________________________________________________________________
2962 {
2963  // Process True Mesons
2964  if(TrueGammaCandidate0->GetV0Index()<fInputEvent->GetNumberOfV0s()){
2965  Bool_t isTruePi0 = kFALSE;
2966  Bool_t isTruePi0Dalitz = kFALSE;
2967  Bool_t gamma0DalitzCand = kFALSE;
2968 
2969  Int_t gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCEvent);
2970  Int_t gamma0MotherLabel = -1;
2971  Int_t motherRealLabel = -1;
2972  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2973  // Daughters Gamma 0
2974  TParticle * negativeMC = (TParticle*)TrueGammaCandidate0->GetNegativeMCDaughter(fMCEvent);
2975  TParticle * positiveMC = (TParticle*)TrueGammaCandidate0->GetPositiveMCDaughter(fMCEvent);
2976  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
2977  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2978  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
2979  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
2980  gamma0MotherLabel=gammaMC0->GetFirstMother();
2981  motherRealLabel=gammaMC0->GetFirstMother();
2982  }
2983  }
2984  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
2985  gamma0DalitzCand = kTRUE;
2986  gamma0MotherLabel=-111;
2987  motherRealLabel=gamma0MCLabel;
2988  }
2989 
2990  }
2991  }
2992 
2993  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2994 
2995  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
2996  Int_t gamma1MotherLabel = -1;
2997  // check if
2998 
2999  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3000  // Daughters Gamma 1
3001  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
3002  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
3003  // get mother of interest (pi0 or eta)
3004  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
3005  gamma1MotherLabel=gammaMC1->GetMother(0);
3006  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
3007  if (TrueGammaCandidate1->IsConversion() && gammaMC1->GetMother(0)>-1) gamma1MotherLabel=fMCEvent->Particle(gammaMC1->GetMother(0))->GetMother(0);
3008  else gamma1MotherLabel=gammaMC1->GetMother(0);
3009  }
3010  }
3011  }
3012 
3013  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3014  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == fPDGCodeNDM){
3015  isTruePi0=kTRUE;
3016  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel) && (!fDoLightOutput)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3017  }
3018  }
3019 
3020  if (gamma0DalitzCand ){
3021  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
3022  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
3023  }
3024  }
3025 
3026  if(isTruePi0 || isTruePi0Dalitz ){
3027  Pi0Candidate->SetTrueMesonValue(1);
3028  Pi0Candidate->SetMCLabel(motherRealLabel);
3029  if(!fDoLightOutput){
3030  fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3031  switch( fSelectedHeavyNeutralMeson ) {
3032  case 0: // ETA MESON
3033  if( IsEtaPiPlPiMiPiZeroDaughter(motherRealLabel) )
3034  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3035  break;
3036  case 1: // OMEGA MESON
3037  if( IsOmegaPiPlPiMiPiZeroDaughter(motherRealLabel) )
3038  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3039  break;
3040  case 2: // ETA PRIME MESON
3041  if( IsEtaPrimePiPlPiMiEtaDaughter(motherRealLabel) )
3042  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3043  break;
3044  case 3: // D0 MESON
3045  if( IsD0PiPlPiMiPiZeroDaughter(motherRealLabel) )
3046  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3047  break;
3048  default:
3049  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
3050  }
3051  }
3052  }
3053  }
3054 }
3055 
3056 //______________________________________________________________________
3058 {
3059  // Process True Mesons
3060  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3061  if (AODMCTrackArray == NULL) return;
3062 
3063  AliAODMCParticle * negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
3064  AliAODMCParticle * positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
3065  if(TrueGammaCandidate0->GetV0Index()<fInputEvent->GetNumberOfV0s()){
3066  Bool_t isTruePi0 = kFALSE;
3067  Bool_t isTruePi0Dalitz = kFALSE;
3068  Bool_t gamma0DalitzCand = kFALSE;
3069 
3070  Int_t gamma0MCLabel = positiveMC->GetMother();// check that this always works
3071  Int_t gamma0MotherLabel = -1;
3072 
3073  Int_t motherRealLabel = -1;
3074  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3075  // Daughters Gamma 0
3076  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3077  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3078  if(negativeMC->GetMCProcessCode() == 5 && positiveMC->GetMCProcessCode() ==5){ // ... From Conversion ...
3079  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
3080  gamma0MotherLabel=gammaMC0->GetMother();
3081  motherRealLabel=gammaMC0->GetMother();
3082  }
3083  }
3084  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
3085  gamma0DalitzCand = kTRUE;
3086  gamma0MotherLabel=-111;
3087  motherRealLabel=gamma0MCLabel;
3088  }
3089 
3090  }
3091  }
3092 
3093  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3094 
3095  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
3096  Int_t gamma1MotherLabel = -1;
3097  // check if
3098 
3099  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3100  // Daughters Gamma 1
3101  AliAODMCParticle *gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3102  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
3103  // get mother of interest (pi0 or eta)
3104  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
3105  gamma1MotherLabel=gammaMC1->GetMother();
3106  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
3107  if (TrueGammaCandidate1->IsConversion() && gammaMC1->GetMother()>-1) gamma1MotherLabel= (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC1->GetMother())))->GetMother();
3108  else gamma1MotherLabel=gammaMC1->GetMother();
3109  }
3110  }
3111  }
3112 
3113  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3114  if((static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel)))->GetPdgCode() == fPDGCodeNDM){
3115  isTruePi0=kTRUE;
3116  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel) && (!fDoLightOutput)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3117  }
3118  }
3119 
3120  if (gamma0DalitzCand ){
3121  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
3122  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
3123  }
3124  }
3125 
3126  if(isTruePi0 || isTruePi0Dalitz ){
3127  Pi0Candidate->SetTrueMesonValue(1);
3128  Pi0Candidate->SetMCLabel(motherRealLabel);
3129  if(!fDoLightOutput){
3130  fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3131  switch( fSelectedHeavyNeutralMeson ) {
3132  case 0: // ETA MESON
3133  if( IsEtaPiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,motherRealLabel) )
3134  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3135  break;
3136  case 1: // OMEGA MESON
3137  if( IsOmegaPiPlPiMiPiZeroDaughterAOD(AODMCTrackArray, motherRealLabel) )
3138  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3139  break;
3140  case 2: // ETA PRIME MESON
3141  if( IsEtaPrimePiPlPiMiEtaDaughterAOD(AODMCTrackArray, motherRealLabel) )
3142  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3143  break;
3144  case 3: // D0 MESON
3145  if( IsD0PiPlPiMiPiZeroDaughterAOD(AODMCTrackArray, motherRealLabel) )
3146  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(), fWeightJetJetMC);
3147  break;
3148  default:
3149  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
3150  }
3151  }
3152  }
3153  }
3154 }
3155 
3156 
3157 //________________________________________________________________________
3159 
3160  Double_t magField = fInputEvent->GetMagneticField();
3161  if( magField < 0.0 ){
3162  magField = 1.0;
3163  } else {
3164  magField = -1.0;
3165  }
3166 
3167  vector<Int_t> lGoodNegPionIndexPrev(0);
3168  vector<Int_t> lGoodPosPionIndexPrev(0);
3169 
3170  for(UInt_t i = 0; i < fSelectorNegPionIndex.size(); i++){
3171 
3172  AliESDtrack* negPionCandidate =dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(fSelectorNegPionIndex[i]));
3173  if(! ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelected(negPionCandidate) ) continue;
3174  lGoodNegPionIndexPrev.push_back( fSelectorNegPionIndex[i] );
3175 
3176  TLorentzVector negPionforHandler;
3177  negPionforHandler.SetPxPyPzE(negPionCandidate->Px(), negPionCandidate->Py(), negPionCandidate->Pz(), negPionCandidate->E());
3178 
3179  AliAODConversionPhoton *negPionHandler = new AliAODConversionPhoton(&negPionforHandler);
3180 
3181  fNegPionCandidates->Add(negPionHandler);
3182  if(!fDoLightOutput){
3183  fHistoNegPionPt[fiCut]->Fill(negPionCandidate->Pt(), fWeightJetJetMC);
3184  fHistoNegPionPhi[fiCut]->Fill(negPionCandidate->Phi(), fWeightJetJetMC);
3185  }
3186 
3187  if( fMCEvent ) {
3188  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3189  Double_t mcProdVtxX = primVtxMC->GetX();
3190  Double_t mcProdVtxY = primVtxMC->GetY();
3191  Double_t mcProdVtxZ = primVtxMC->GetZ();
3192 
3193  Int_t labelNegPion = TMath::Abs( negPionCandidate->GetLabel() );
3194  Bool_t negPionIsPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelNegPion, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3195  if( labelNegPion>-1 && labelNegPion < fMCEvent->GetNumberOfTracks() ){
3196  TParticle* negPion = fMCEvent->Particle(labelNegPion);
3197  if( negPion->GetPdgCode() == -211 ){
3198  if(!fDoLightOutput){
3199  if( negPionIsPrimary ){
3200  fHistoTrueNegPionPt[fiCut]->Fill(negPionCandidate->Pt(), fWeightJetJetMC); //primary negPion
3201  }
3202  switch( fSelectedHeavyNeutralMeson ) {
3203  case 0: // ETA MESON
3204  if( IsEtaPiPlPiMiPiZeroDaughter(labelNegPion) && negPionIsPrimary )
3205  fHistoTrueNegPionFromNeutralMesonPt[fiCut]->Fill(negPionCandidate->Pt(), fWeightJetJetMC);
3206  break;
3207  case 1: // OMEGA MESON
3208  if( IsOmegaPiPlPiMiPiZeroDaughter(labelNegPion) && negPionIsPrimary)
3209  fHistoTrueNegPionFromNeutralMesonPt[fiCut]->Fill(negPionCandidate->Pt(), fWeightJetJetMC);
3210  break;
3211  case 2: // ETA PRIME MESON
3212  if( IsEtaPrimePiPlPiMiEtaDaughter(labelNegPion) && negPionIsPrimary)
3213  fHistoTrueNegPionFromNeutralMesonPt[fiCut]->Fill(negPionCandidate->Pt(), fWeightJetJetMC);
3214  break;
3215  case 3: // D0 MESON
3216  if( IsD0PiPlPiMiPiZeroDaughter(labelNegPion)& negPionIsPrimary)
3217  fHistoTrueNegPionFromNeutralMesonPt[fiCut]->Fill(negPionCandidate->Pt(), fWeightJetJetMC);
3218  break;
3219  default:
3220  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
3221  }
3222  }
3223  }
3224  }
3225  }
3226  }
3227 
3228  for(UInt_t i = 0; i < fSelectorPosPionIndex.size(); i++){
3229  AliESDtrack* posPionCandidate = dynamic_cast<AliESDtrack*>(fInputEvent->GetTrack(fSelectorPosPionIndex[i]));
3230  if(! ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelected(posPionCandidate) ) continue;
3231  lGoodPosPionIndexPrev.push_back( fSelectorPosPionIndex[i] );
3232 
3233  TLorentzVector posPionforHandler;
3234  posPionforHandler.SetPxPyPzE(posPionCandidate->Px(), posPionCandidate->Py(), posPionCandidate->Pz(), posPionCandidate->E());
3235 
3236  AliAODConversionPhoton *posPionHandler = new AliAODConversionPhoton(&posPionforHandler);
3237 
3238  fPosPionCandidates->Add(posPionHandler);
3239  if(!fDoLightOutput){
3240  fHistoPosPionPt[fiCut]->Fill(posPionCandidate->Pt(), fWeightJetJetMC);
3241  fHistoPosPionPhi[fiCut]->Fill(posPionCandidate->Phi(), fWeightJetJetMC);
3242  }
3243  if( fMCEvent ) {
3244  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3245  Double_t mcProdVtxX = primVtxMC->GetX();
3246  Double_t mcProdVtxY = primVtxMC->GetY();
3247  Double_t mcProdVtxZ = primVtxMC->GetZ();
3248 
3249  Int_t labelPosPion = TMath::Abs( posPionCandidate->GetLabel() );
3250  Bool_t posPionIsPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelPosPion, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3251  if( labelPosPion>-1 && labelPosPion < fMCEvent->GetNumberOfTracks() ) {
3252  TParticle* posPion = fMCEvent->Particle(labelPosPion);
3253  if( posPion->GetPdgCode() == 211 ){
3254  if(!fDoLightOutput){
3255  if( posPionIsPrimary ){
3256  fHistoTruePosPionPt[fiCut]->Fill(posPionCandidate->Pt(), fWeightJetJetMC);
3257  }
3258  switch( fSelectedHeavyNeutralMeson ) {
3259  case 0: // ETA MESON
3260  if( IsEtaPiPlPiMiPiZeroDaughter(labelPosPion) && posPionIsPrimary )
3261  fHistoTruePosPionFromNeutralMesonPt[fiCut]->Fill(posPionCandidate->Pt(), fWeightJetJetMC);
3262  break;
3263  case 1: // OMEGA MESON
3264  if( IsOmegaPiPlPiMiPiZeroDaughter(labelPosPion) && posPionIsPrimary)
3265  fHistoTruePosPionFromNeutralMesonPt[fiCut]->Fill(posPionCandidate->Pt(), fWeightJetJetMC);
3266  break;
3267  case 2: // ETA PRIME MESON
3268  if( IsEtaPrimePiPlPiMiEtaDaughter(labelPosPion) && posPionIsPrimary)
3269  fHistoTruePosPionFromNeutralMesonPt[fiCut]->Fill(posPionCandidate->Pt(), fWeightJetJetMC);
3270  break;
3271  case 3: // D0 MESON
3272  if( IsD0PiPlPiMiPiZeroDaughter(labelPosPion) && posPionIsPrimary )
3273  fHistoTruePosPionFromNeutralMesonPt[fiCut]->Fill(posPionCandidate->Pt(), fWeightJetJetMC);
3274  break;
3275  default:
3276  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
3277  }
3278  }
3279  }
3280  }
3281  }
3282  }
3283 
3284 
3285  for(UInt_t i = 0; i < lGoodNegPionIndexPrev.size(); i++){
3286  AliVTrack* negPionCandidate = dynamic_cast<AliVTrack*>(fInputEvent->GetTrack(lGoodNegPionIndexPrev[i]));
3287 // AliESDtrack *negPionCandidate = fInputEvent->GetTrack(lGoodNegPionIndexPrev[i]);
3288  AliKFParticle negPionCandidateKF( *negPionCandidate->GetConstrainedParam(), 211 );
3289 
3290  for(UInt_t j = 0; j < lGoodPosPionIndexPrev.size(); j++){
3291  AliVTrack *posPionCandidate = dynamic_cast<AliVTrack*>(fInputEvent->GetTrack(lGoodPosPionIndexPrev[j]));
3292  AliKFParticle posPionCandidateKF( *posPionCandidate->GetConstrainedParam(), 211 );
3293 
3294  AliKFConversionPhoton virtualPhoton(negPionCandidateKF,posPionCandidateKF);
3295  AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex());
3296  // primaryVertexImproved+=*virtualPhoton;
3297  virtualPhoton.SetProductionVertex(primaryVertexImproved);
3298  virtualPhoton.SetTrackLabels( lGoodPosPionIndexPrev[j], lGoodNegPionIndexPrev[i]);
3299 
3300  Int_t labeln=0;
3301  Int_t labelp=0;
3302  Int_t motherlabelp = 0;
3303  Int_t motherlabeln = 0;
3304  TParticle *fNegativeMCParticle =nullptr;
3305  TParticle *fPositiveMCParticle =nullptr;
3306  if( fMCEvent ) {
3307  labeln=TMath::Abs(negPionCandidate->GetLabel());
3308  labelp=TMath::Abs(posPionCandidate->GetLabel());
3309  if(labeln>-1) fNegativeMCParticle = fMCEvent->Particle(labeln);
3310  if(labelp>-1) fPositiveMCParticle = fMCEvent->Particle(labelp);
3311  // check whether MC particles exist, else abort
3312  if (fNegativeMCParticle == nullptr || fPositiveMCParticle == nullptr) return;
3313 
3314  motherlabeln = fNegativeMCParticle->GetMother(0);
3315  motherlabelp = fPositiveMCParticle->GetMother(0);
3316  virtualPhoton.SetMCLabelPositive(labelp);
3317  virtualPhoton.SetMCLabelNegative(labeln);
3318 
3319  }
3320 
3321  AliAODConversionPhoton *vParticle = new AliAODConversionPhoton(&virtualPhoton); //To apply mass 2 pion mass cut
3322  if(!fDoLightOutput){
3323  if (fMCEvent &&(fDoMesonQA>0)){
3324  if (fPositiveMCParticle && fNegativeMCParticle ) {
3325  if (((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->DoMassCut()){
3326  if (vParticle->GetMass() < ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetMassCut()){
3327  if(TMath::Abs(fNegativeMCParticle->GetPdgCode())==211 && TMath::Abs(fPositiveMCParticle->GetPdgCode())==211){ // Pions ...
3328  fHistoTruePionPionInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3329  if (motherlabeln == motherlabelp){
3330  fHistoTruePionPionFromSameMotherInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3331  switch( fSelectedHeavyNeutralMeson ) {
3332  case 0: // ETA MESON
3333  if( IsEtaPiPlPiMiPiZeroDaughter(labeln) )
3334  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3335  break;
3336  case 1: // OMEGA MESON
3337  if( IsOmegaPiPlPiMiPiZeroDaughter(labeln) )
3338  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3339  break;
3340  case 2: // ETA PRIME MESON
3341  if( IsEtaPrimePiPlPiMiEtaDaughter(labeln) )
3342  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3343  break;
3344  case 3: // D0 MESON
3345  if( IsD0PiPlPiMiPiZeroDaughter(labeln) )
3346  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3347  break;
3348  default:
3349  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
3350  }
3351  }
3352  }
3353  }
3354  } else {
3355  if(TMath::Abs(fNegativeMCParticle->GetPdgCode())==211 && TMath::Abs(fPositiveMCParticle->GetPdgCode())==211){ // Pions ...
3356  fHistoTruePionPionInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3357  if (motherlabeln == motherlabelp){
3358  fHistoTruePionPionFromSameMotherInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3359  switch( fSelectedHeavyNeutralMeson ) {
3360  case 0: // ETA MESON
3361  if( IsEtaPiPlPiMiPiZeroDaughter(labeln) )
3362  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3363  break;
3364  case 1: // OMEGA MESON
3365  if( IsOmegaPiPlPiMiPiZeroDaughter(labeln) )
3366  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3367  break;
3368  case 2: // ETA PRIME MESON
3369  if( IsEtaPrimePiPlPiMiEtaDaughter(labeln) )
3370  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3371  break;
3372  case 3: // D0 MESON
3373  if( IsD0PiPlPiMiPiZeroDaughter(labeln) )
3374  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3375  break;
3376  default:
3377  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
3378  }
3379  }
3380  }
3381  }
3382  }
3383  }
3384  }
3385 
3386  if (((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->DoMassCut()){
3387  if (vParticle->GetMass() < ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetMassCut()){
3388  fGoodVirtualParticles->Add( vParticle );
3389  if(!fDoLightOutput){
3390  fHistoPionPionInvMassPt[fiCut]->Fill( vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3391  }
3392  }else{
3393  delete vParticle;
3394  }
3395  } else {
3396  fGoodVirtualParticles->Add( vParticle );
3397  if(!fDoLightOutput){
3398  fHistoPionPionInvMassPt[fiCut]->Fill( vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3399  }
3400  }
3401 
3402  Double_t clsToFPos = -1.0;
3403  Double_t clsToFNeg = -1.0;
3404 
3405  Float_t dcaToVertexXYPos = -1.0;
3406  Float_t dcaToVertexZPos = -1.0;
3407  Float_t dcaToVertexXYNeg = -1.0;
3408  Float_t dcaToVertexZNeg = -1.0;
3409 
3410  if ( fDoMesonQA>0 ) {
3411  clsToFPos = ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetNFindableClustersTPC(posPionCandidate);
3412  clsToFNeg = ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetNFindableClustersTPC(negPionCandidate);
3413 
3414  Float_t bPos[2];
3415  Float_t bCovPos[3];
3416  posPionCandidate->GetImpactParameters(bPos,bCovPos);
3417  if (bCovPos[0]<=0 || bCovPos[2]<=0) {
3418  AliDebug(1, "Estimated b resolution lower or equal zero!");
3419  bCovPos[0]=0; bCovPos[2]=0;
3420  }
3421 
3422  Float_t bNeg[2];
3423  Float_t bCovNeg[3];
3424  posPionCandidate->GetImpactParameters(bNeg,bCovNeg);
3425  if (bCovNeg[0]<=0 || bCovNeg[2]<=0) {
3426  AliDebug(1, "Estimated b resolution lower or equal zero!");
3427  bCovNeg[0]=0; bCovNeg[2]=0;
3428  }
3429 
3430  dcaToVertexXYPos = bPos[0];
3431  dcaToVertexZPos = bPos[1];
3432  dcaToVertexXYNeg = bNeg[0];
3433  dcaToVertexZNeg = bNeg[1];
3434 
3435  if(!fDoLightOutput){
3436  fHistoNegPionEta[fiCut]->Fill(negPionCandidate->Eta(), fWeightJetJetMC);
3437  fHistoPosPionEta[fiCut]->Fill(posPionCandidate->Eta(), fWeightJetJetMC);
3438 
3439  fHistoNegPionClsTPC[fiCut]->Fill(clsToFNeg,negPionCandidate->Pt(), fWeightJetJetMC);
3440  fHistoPosPionClsTPC[fiCut]->Fill(clsToFPos,posPionCandidate->Pt(), fWeightJetJetMC);
3441 
3442  fHistoPionDCAxy[fiCut]->Fill( dcaToVertexXYNeg, negPionCandidate->Pt(), fWeightJetJetMC );
3443  fHistoPionDCAz[fiCut]->Fill( dcaToVertexZNeg, negPionCandidate->Pt(), fWeightJetJetMC );
3444  fHistoPionDCAxy[fiCut]->Fill( dcaToVertexXYPos, posPionCandidate->Pt(), fWeightJetJetMC );
3445  fHistoPionDCAz[fiCut]->Fill( dcaToVertexZPos, posPionCandidate->Pt(), fWeightJetJetMC );
3446 
3447  fHistoPionTPCdEdxNSigma[fiCut]->Fill( posPionCandidate->P(),((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetPIDResponse()->NumberOfSigmasTPC(posPionCandidate, AliPID::kPion), fWeightJetJetMC );
3448  fHistoPionTPCdEdxNSigma[fiCut]->Fill( negPionCandidate->P(),((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetPIDResponse()->NumberOfSigmasTPC(negPionCandidate, AliPID::kPion), fWeightJetJetMC );
3449 
3450  fHistoPionTPCdEdx[fiCut]->Fill(posPionCandidate->P(), TMath::Abs(posPionCandidate->GetTPCsignal()), fWeightJetJetMC);
3451  fHistoPionTPCdEdx[fiCut]->Fill(negPionCandidate->P(), TMath::Abs(negPionCandidate->GetTPCsignal()), fWeightJetJetMC);
3452  }
3453  }
3454  }
3455  }
3456 }
3457 
3458 //________________________________________________________________________
3460 
3461  Double_t magField = fInputEvent->GetMagneticField();
3462  if( magField < 0.0 ){
3463  magField = 1.0;
3464  } else {
3465  magField = -1.0;
3466  }
3467 
3468  vector<Int_t> lGoodNegPionIndexPrev(0);
3469  vector<Int_t> lGoodPosPionIndexPrev(0);
3470 
3471  TClonesArray *AODMCTrackArray = NULL;
3472  if(fMCEvent){
3473  AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3474  }
3475 
3476  for(UInt_t i = 0; i < fSelectorNegPionIndex.size(); i++){
3477 
3478  AliAODTrack* negPionCandidate =dynamic_cast<AliAODTrack*>(fInputEvent->GetTrack(fSelectorNegPionIndex[i]));
3479  if(! ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedAOD(negPionCandidate) ) continue;
3480  lGoodNegPionIndexPrev.push_back( fSelectorNegPionIndex[i] );
3481 
3482  TLorentzVector negPionforHandler;
3483  negPionforHandler.SetPxPyPzE(negPionCandidate->Px(), negPionCandidate->Py(), negPionCandidate->Pz(), negPionCandidate->E());
3484 
3485  AliAODConversionPhoton *negPionHandler = new AliAODConversionPhoton(&negPionforHandler);
3486 
3487  fNegPionCandidates->Add(negPionHandler);
3488  if(!fDoLightOutput){
3489  fHistoNegPionPt[fiCut]->Fill(negPionCandidate->Pt(), fWeightJetJetMC);
3490  fHistoNegPionPhi[fiCut]->Fill(negPionCandidate->Phi(), fWeightJetJetMC);
3491  }
3492 
3493  if( fMCEvent ) {
3494  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3495  Double_t mcProdVtxX = primVtxMC->GetX();
3496  Double_t mcProdVtxY = primVtxMC->GetY();
3497  Double_t mcProdVtxZ = primVtxMC->GetZ();
3498 
3499  Int_t labelNegPion = TMath::Abs( negPionCandidate->GetLabel() );
3500  if( labelNegPion>-1 && labelNegPion < AODMCTrackArray->GetEntriesFast() ){
3501  AliAODMCParticle* negPion = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(labelNegPion));
3502  Bool_t negPionIsPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, negPion, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3503  if( negPion->GetPdgCode() == -211 ){
3504  if(!fDoLightOutput){
3505  if( negPionIsPrimary ){
3506  fHistoTrueNegPionPt[fiCut]->Fill(negPionCandidate->Pt(), fWeightJetJetMC); //primary negPion
3507  }
3508  switch( fSelectedHeavyNeutralMeson ) {
3509  case 0: // ETA MESON
3510  if( IsEtaPiPlPiMiPiZeroDaughterAOD(AODMCTrackArray, labelNegPion) && negPionIsPrimary )
3511  fHistoTrueNegPionFromNeutralMesonPt[fiCut]->Fill(negPionCandidate->Pt(), fWeightJetJetMC);
3512  break;
3513  case 1: // OMEGA MESON
3514  if( IsOmegaPiPlPiMiPiZeroDaughterAOD(AODMCTrackArray, labelNegPion) && negPionIsPrimary)
3515  fHistoTrueNegPionFromNeutralMesonPt[fiCut]->Fill(negPionCandidate->Pt(), fWeightJetJetMC);
3516  break;
3517  case 2: // ETA PRIME MESON
3518  if( IsEtaPrimePiPlPiMiEtaDaughterAOD(AODMCTrackArray,labelNegPion) && negPionIsPrimary)
3519  fHistoTrueNegPionFromNeutralMesonPt[fiCut]->Fill(negPionCandidate->Pt(), fWeightJetJetMC);
3520  break;
3521  case 3: // D0 MESON
3522  if( IsD0PiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,labelNegPion)& negPionIsPrimary)
3523  fHistoTrueNegPionFromNeutralMesonPt[fiCut]->Fill(negPionCandidate->Pt(), fWeightJetJetMC);
3524  break;
3525  default:
3526  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
3527  }
3528  }
3529  }
3530  }
3531  }
3532  }
3533 
3534  for(UInt_t i = 0; i < fSelectorPosPionIndex.size(); i++){
3535  AliAODTrack* posPionCandidate = dynamic_cast<AliAODTrack*>(fInputEvent->GetTrack(fSelectorPosPionIndex[i]));
3536  if(! ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedAOD(posPionCandidate) ) continue;
3537  lGoodPosPionIndexPrev.push_back( fSelectorPosPionIndex[i] );
3538 
3539  TLorentzVector posPionforHandler;
3540  posPionforHandler.SetPxPyPzE(posPionCandidate->Px(), posPionCandidate->Py(), posPionCandidate->Pz(), posPionCandidate->E());
3541 
3542  AliAODConversionPhoton *posPionHandler = new AliAODConversionPhoton(&posPionforHandler);
3543 
3544  fPosPionCandidates->Add(posPionHandler);
3545  if(!fDoLightOutput){
3546  fHistoPosPionPt[fiCut]->Fill( posPionCandidate->Pt(), fWeightJetJetMC );
3547  fHistoPosPionPhi[fiCut]->Fill( posPionCandidate->Phi(), fWeightJetJetMC );
3548  }
3549  if( fMCEvent ) {
3550  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3551  Double_t mcProdVtxX = primVtxMC->GetX();
3552  Double_t mcProdVtxY = primVtxMC->GetY();
3553  Double_t mcProdVtxZ = primVtxMC->GetZ();
3554 
3555  Int_t labelPosPion = TMath::Abs( posPionCandidate->GetLabel() );
3556  if( labelPosPion>-1 && labelPosPion < fMCEvent->GetNumberOfTracks() ) {
3557  AliAODMCParticle* posPion = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(labelPosPion));
3558  Bool_t posPionIsPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, posPion, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3559  if( posPion->GetPdgCode() == 211 ){
3560  if(!fDoLightOutput){
3561  if( posPionIsPrimary ){
3562  fHistoTruePosPionPt[fiCut]->Fill(posPionCandidate->Pt(), fWeightJetJetMC);
3563  }
3564  switch( fSelectedHeavyNeutralMeson ) {
3565  case 0: // ETA MESON
3566  if( IsEtaPiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,labelPosPion) && posPionIsPrimary )
3567  fHistoTruePosPionFromNeutralMesonPt[fiCut]->Fill(posPionCandidate->Pt(), fWeightJetJetMC);
3568  break;
3569  case 1: // OMEGA MESON
3570  if( IsOmegaPiPlPiMiPiZeroDaughterAOD(AODMCTrackArray, labelPosPion) && posPionIsPrimary)
3571  fHistoTruePosPionFromNeutralMesonPt[fiCut]->Fill(posPionCandidate->Pt(), fWeightJetJetMC);
3572  break;
3573  case 2: // ETA PRIME MESON
3574  if( IsEtaPrimePiPlPiMiEtaDaughterAOD(AODMCTrackArray, labelPosPion) && posPionIsPrimary)
3575  fHistoTruePosPionFromNeutralMesonPt[fiCut]->Fill(posPionCandidate->Pt(), fWeightJetJetMC);
3576  break;
3577  case 3: // D0 MESON
3578  if( IsD0PiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,labelPosPion) && posPionIsPrimary )
3579  fHistoTruePosPionFromNeutralMesonPt[fiCut]->Fill(posPionCandidate->Pt(), fWeightJetJetMC);
3580  break;
3581  default:
3582  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
3583  }
3584  }
3585  }
3586  }
3587  }
3588  }
3589 
3590 
3591  for(UInt_t i = 0; i < lGoodNegPionIndexPrev.size(); i++){
3592  AliVTrack* negPionCandidate = dynamic_cast<AliVTrack*>(fInputEvent->GetTrack(lGoodNegPionIndexPrev[i]));
3593 
3594  AliKFParticle negPionCandidateKF( *negPionCandidate, 211 );
3595 
3596  for(UInt_t j = 0; j < lGoodPosPionIndexPrev.size(); j++){
3597  AliVTrack *posPionCandidate = dynamic_cast<AliVTrack*>(fInputEvent->GetTrack(lGoodPosPionIndexPrev[j]));
3598  AliKFParticle posPionCandidateKF( *posPionCandidate, 211 );
3599 
3600  AliKFConversionPhoton* virtualPhoton = NULL;
3601  virtualPhoton = new AliKFConversionPhoton(negPionCandidateKF,posPionCandidateKF);
3602  AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex());
3603  // primaryVertexImproved+=*virtualPhoton;
3604  virtualPhoton->SetProductionVertex(primaryVertexImproved);
3605  virtualPhoton->SetTrackLabels( lGoodPosPionIndexPrev[j], lGoodNegPionIndexPrev[i]);
3606 
3607  Int_t labeln=0;
3608  Int_t labelp=0;
3609  Int_t motherlabelp = 0;
3610  Int_t motherlabeln = 0;
3611  AliAODMCParticle *fNegativeMCParticle =NULL;
3612  AliAODMCParticle *fPositiveMCParticle =NULL;
3613  if( fMCEvent ) {
3614  labeln=TMath::Abs(negPionCandidate->GetLabel());
3615  labelp=TMath::Abs(posPionCandidate->GetLabel());
3616  if(labeln>-1) fNegativeMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(labeln));
3617  if(labelp>-1) fPositiveMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(labelp));
3618  // check whether MC particles exist, else abort
3619  if (fNegativeMCParticle == NULL || fPositiveMCParticle == NULL) return;
3620 
3621  motherlabeln = fNegativeMCParticle->GetMother();
3622  motherlabelp = fPositiveMCParticle->GetMother();
3623  virtualPhoton->SetMCLabelPositive(labelp);
3624  virtualPhoton->SetMCLabelNegative(labeln);
3625 
3626  }
3627 
3628  AliAODConversionPhoton *vParticle = new AliAODConversionPhoton(virtualPhoton); //To apply mass 2 pion mass cut
3629  if(!fDoLightOutput){
3630  if (fMCEvent &&(fDoMesonQA>0)){
3631  if (fPositiveMCParticle && fNegativeMCParticle ) {
3632  if (((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->DoMassCut()){
3633  if (vParticle->GetMass() < ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetMassCut()){
3634  if(TMath::Abs(fNegativeMCParticle->GetPdgCode())==211 && TMath::Abs(fPositiveMCParticle->GetPdgCode())==211){ // Pions ...
3635  fHistoTruePionPionInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3636  if (motherlabeln == motherlabelp){
3637  fHistoTruePionPionFromSameMotherInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3638  switch( fSelectedHeavyNeutralMeson ) {
3639  case 0: // ETA MESON
3640  if( IsEtaPiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,labeln) )
3641  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3642  break;
3643  case 1: // OMEGA MESON
3644  if( IsOmegaPiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,labeln) )
3645  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3646  break;
3647  case 2: // ETA PRIME MESON
3648  if( IsEtaPrimePiPlPiMiEtaDaughterAOD(AODMCTrackArray,labeln) )
3649  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3650  break;
3651  case 3: // D0 MESON
3652  if( IsD0PiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,labeln) )
3653  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3654  break;
3655  default:
3656  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
3657  }
3658  }
3659  }
3660  }
3661  } else {
3662  if(TMath::Abs(fNegativeMCParticle->GetPdgCode())==211 && TMath::Abs(fPositiveMCParticle->GetPdgCode())==211){ // Pions ...
3663  fHistoTruePionPionInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3664  if (motherlabeln == motherlabelp){
3665  fHistoTruePionPionFromSameMotherInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3666  switch( fSelectedHeavyNeutralMeson ) {
3667  case 0: // ETA MESON
3668  if( IsEtaPiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,labeln) )
3669  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3670  break;
3671  case 1: // OMEGA MESON
3672  if( IsOmegaPiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,labeln) )
3673  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3674  break;
3675  case 2: // ETA PRIME MESON
3676  if( IsEtaPrimePiPlPiMiEtaDaughterAOD(AODMCTrackArray,labeln) )
3677  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3678  break;
3679  case 3: // D0 MESON
3680  if( IsD0PiPlPiMiPiZeroDaughterAOD(AODMCTrackArray,labeln) )
3681  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3682  break;
3683  default:
3684  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
3685  }
3686  }
3687  }
3688  }
3689  }
3690  }
3691  }
3692 
3693  if (((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->DoMassCut()){
3694  if (vParticle->GetMass() < ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetMassCut()){
3695  fGoodVirtualParticles->Add( vParticle );
3696  if(!fDoLightOutput){
3697  fHistoPionPionInvMassPt[fiCut]->Fill( vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3698  }
3699  }else{
3700  delete vParticle;
3701  vParticle=0x0;
3702  }
3703  } else {
3704  fGoodVirtualParticles->Add( vParticle );
3705  if(!fDoLightOutput){
3706  fHistoPionPionInvMassPt[fiCut]->Fill( vParticle->GetMass(),vParticle->Pt(), fWeightJetJetMC);
3707  }
3708  }
3709 
3710  Double_t clsToFPos = -1.0;
3711  Double_t clsToFNeg = -1.0;
3712 
3713  Float_t dcaToVertexXYPos = -1.0;
3714  Float_t dcaToVertexZPos = -1.0;
3715  Float_t dcaToVertexXYNeg = -1.0;
3716  Float_t dcaToVertexZNeg = -1.0;
3717 
3718  if ( fDoMesonQA>0 ) {
3719  clsToFPos = ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetNFindableClustersTPC(posPionCandidate);
3720  clsToFNeg = ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetNFindableClustersTPC(negPionCandidate);
3721 
3722  Float_t bPos[2];
3723  Float_t bCovPos[3];
3724  posPionCandidate->GetImpactParameters(bPos,bCovPos);
3725  if (bCovPos[0]<=0 || bCovPos[2]<=0) {
3726  AliDebug(1, "Estimated b resolution lower or equal zero!");
3727  bCovPos[0]=0; bCovPos[2]=0;
3728  }
3729 
3730  Float_t bNeg[2];
3731  Float_t bCovNeg[3];
3732  posPionCandidate->GetImpactParameters(bNeg,bCovNeg);
3733  if (bCovNeg[0]<=0 || bCovNeg[2]<=0) {
3734  AliDebug(1, "Estimated b resolution lower or equal zero!");
3735  bCovNeg[0]=0; bCovNeg[2]=0;
3736  }
3737 
3738  dcaToVertexXYPos = bPos[0];
3739  dcaToVertexZPos = bPos[1];
3740  dcaToVertexXYNeg = bNeg[0];
3741  dcaToVertexZNeg = bNeg[1];
3742 
3743  if(!fDoLightOutput){
3744  fHistoNegPionEta[fiCut]->Fill( negPionCandidate->Eta(), fWeightJetJetMC );
3745  fHistoPosPionEta[fiCut]->Fill( posPionCandidate->Eta(), fWeightJetJetMC );
3746 
3747  fHistoNegPionClsTPC[fiCut]->Fill(clsToFNeg,negPionCandidate->Pt(), fWeightJetJetMC);
3748  fHistoPosPionClsTPC[fiCut]->Fill(clsToFPos,posPionCandidate->Pt(), fWeightJetJetMC);
3749 
3750  fHistoPionDCAxy[fiCut]->Fill( dcaToVertexXYNeg, negPionCandidate->Pt(), fWeightJetJetMC );
3751  fHistoPionDCAz[fiCut]->Fill( dcaToVertexZNeg, negPionCandidate->Pt(), fWeightJetJetMC );
3752  fHistoPionDCAxy[fiCut]->Fill( dcaToVertexXYPos, posPionCandidate->Pt(), fWeightJetJetMC );
3753  fHistoPionDCAz[fiCut]->Fill( dcaToVertexZPos, posPionCandidate->Pt(), fWeightJetJetMC );
3754 
3755  fHistoPionTPCdEdxNSigma[fiCut]->Fill( posPionCandidate->P(),((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetPIDResponse()->NumberOfSigmasTPC(posPionCandidate, AliPID::kPion), fWeightJetJetMC );
3756  fHistoPionTPCdEdxNSigma[fiCut]->Fill( negPionCandidate->P(),((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetPIDResponse()->NumberOfSigmasTPC(negPionCandidate, AliPID::kPion), fWeightJetJetMC );
3757 
3758  fHistoPionTPCdEdx[fiCut]->Fill( posPionCandidate->P(), TMath::Abs(posPionCandidate->GetTPCsignal()), fWeightJetJetMC );
3759  fHistoPionTPCdEdx[fiCut]->Fill( negPionCandidate->P(), TMath::Abs(negPionCandidate->GetTPCsignal()), fWeightJetJetMC );
3760  }
3761  }
3762 
3763  delete virtualPhoton;
3764  }
3765  }
3766 }
3767 
3768 //_____________________________________________________________________________
3770 
3771  // Loop over all primary MC particle
3772  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3773  Double_t mcProdVtxX = primVtxMC->GetX();
3774  Double_t mcProdVtxY = primVtxMC->GetY();
3775  Double_t mcProdVtxZ = primVtxMC->GetZ();
3776 
3777  for(Int_t i = 0; i < fMCEvent->GetNumberOfTracks(); i++) {
3778  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
3779 
3780  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
3781  if (!particle) continue;
3782 
3783  Int_t isMCFromMBHeader = -1;
3784  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
3785  isMCFromMBHeader
3786  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
3787  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
3788  }
3789 
3790  if(!fDoLightOutput){
3791  if(fDoMesonQA > 0){
3792  // Fill kinematics for heavy particle
3793  // This also contains not-reconstructed particles
3794  if(TMath::Abs(particle->GetPdgCode()) == fPDGCodeAnalyzedMeson){
3795  fHistoMCHeavyAllPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
3796  fHistoMCHeavyAllEta[fiCut]->Fill(particle->Eta(), fWeightJetJetMC);
3797  fHistoMCHeavyAllPhi[fiCut]->Fill(TVector2::Phi_0_2pi(particle->Phi()), fWeightJetJetMC);
3798  // check for Decay kinematics
3799  if(particle->GetNDaughters() == 3){
3800  AliVParticle *neutralMeson(nullptr), *piplus(nullptr), *piminus(nullptr);
3801  Int_t indexpiplus(-1), indexpiminus(-1);
3802  for(int idaug = particle->GetFirstDaughter(); idaug <= particle->GetLastDaughter(); idaug++) {
3803  AliVParticle *daughter = fMCEvent->GetTrack(idaug);
3804  if(daughter->PdgCode() == kPiPlus){
3805  piplus = daughter;
3806  indexpiplus = idaug;
3807  } else if(daughter->PdgCode() == kPiMinus) {
3808  piminus = daughter;
3809  indexpiminus = idaug;
3810  } else if(TMath::Abs(daughter->PdgCode()) == fPDGCodeNDM){
3811  neutralMeson = daughter;
3812  }
3813  }
3814  if(neutralMeson && piplus && piminus) {
3815  fHistoMCHeavyChannelPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
3816  fHistoMCHeavyChannelEta[fiCut]->Fill(particle->Eta(), fWeightJetJetMC);
3817  fHistoMCHeavyChannelPhi[fiCut]->Fill(TVector2::Phi_0_2pi(particle->Phi()), fWeightJetJetMC);
3818  // Fill kinematics for daughter particles
3819  fHistMCChannelNDMFromHeavyPt[fiCut]->Fill(neutralMeson->Pt(), fWeightJetJetMC);
3820  fHistMCChannelNDMFromHeavyEta[fiCut]->Fill(neutralMeson->Eta(), fWeightJetJetMC);
3821  fHistMCChannelNDMFromHeavyPhi[fiCut]->Fill(TVector2::Phi_0_2pi(neutralMeson->Phi()), fWeightJetJetMC);