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