AliPhysics  a6017e1 (a6017e1)
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  fESDEvent(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  fESDEvent(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 
1427  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
1428  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
1429 
1430  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
1431  if(InputEvent()->IsIncompleteDAQ()==kTRUE) eventQuality = 2; // incomplete event
1432  if(eventQuality == 2 || eventQuality == 3){// Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1 or because it is incomplete
1433  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1434  fHistoNEvents[iCut]->Fill(eventQuality);
1435  }
1436  return;
1437  }
1438 
1439  fPionSelector=(AliPrimaryPionSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("PionSelector");
1440  if(!fPionSelector){printf("Error: No PionSelector");return;} // GetV0Reader
1441 
1442  if(fIsMC) fMCEvent = MCEvent();
1443  fESDEvent = (AliESDEvent*)InputEvent();
1444  fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
1445  fSelectorNegPionIndex = fPionSelector->GetReconstructedNegPionIndex(); // Electrons from default Cut
1446  fSelectorPosPionIndex = fPionSelector->GetReconstructedPosPionIndex(); // Positrons from default Cut
1447 
1449  //AddTaskContainers(); //Add conatiner
1450 
1451  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1452  fiCut = iCut;
1453 
1454  Bool_t isRunningEMCALrelAna = kFALSE;
1455  if (fNDMRecoMode > 0){
1456  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetClusterType() == 1) isRunningEMCALrelAna = kTRUE;
1457  }
1458 
1459  Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon, isRunningEMCALrelAna);
1460 
1461  if(eventNotAccepted){
1462  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
1463  fHistoNEvents[iCut]->Fill(eventNotAccepted); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
1464  continue;
1465  }
1466 
1467  if(eventQuality != 0){// Event Not Accepted
1468  // cout << "event rejected due to: " <<eventQuality << endl;
1469  fHistoNEvents[iCut]->Fill(eventQuality);
1470  continue;
1471  }
1472 
1473  fHistoNEvents[iCut]->Fill(eventQuality);
1475  if(!fDoLightOutput){
1476  fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)));
1477  }
1478  if(fMCEvent){ // Process MC Particle
1479  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
1480  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1481  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1482  fMCEvent);
1483  }
1485  }
1486 
1487  if (fNDMRecoMode < 2){
1488  ProcessConversionPhotonCandidates(); // Process this cuts conversion gammas
1489  }
1490  if (fNDMRecoMode > 0){
1491  ProcessCaloPhotonCandidates(); // Process this cuts calo gammas
1492  }
1493 
1494  if (fNDMRecoMode == 0 ){
1495  ProcessNeutralDecayMesonCandidatesPureConversions(); // Process neutral pion candidates purely from conversions
1496  }
1497  if (fNDMRecoMode == 1){
1498  ProcessNeutralPionCandidatesMixedConvCalo(); // Process neutral pion candidates mixed conv and calo
1499  }
1500  if (fNDMRecoMode == 2){
1501  ProcessNeutralPionCandidatesPureCalo(); // Process neutral pion candidates purely from calo
1502  }
1503 
1504  ProcessPionCandidates(); // Process this cuts gammas
1505 
1509 
1513 
1514  fGoodConvGammas->Clear();
1515  fClusterCandidates->Clear();
1518  fPosPionCandidates->Clear();
1519  fNegPionCandidates->Clear();
1520  fGoodVirtualParticles->Clear(); // delete this cuts good gammas
1521  }
1522 
1523  fSelectorNegPionIndex.clear();
1524  fSelectorPosPionIndex.clear();
1525 
1526  PostData( 1, fOutputContainer );
1527 }
1528 //________________________________________________________________________
1530  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1531  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
1532  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
1533  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
1534  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
1535  }
1536 
1537  if( !((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift() ){
1538  if(!fDoLightOutput){
1539  fProfileEtaShift[iCut]->Fill(0.,0.);
1540  }
1541  continue; // No Eta Shift requested, continue
1542  }
1543  if( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
1544  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
1545  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1546  ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->SetEtaShift( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() );
1547  if(!fDoLightOutput){
1548  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1549  }
1550  continue;
1551  } else {
1552  printf(" Eta t PiPlusPiMinus Gamma Task %s :: Eta Shift Manually Set to %f \n\n",
1553  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
1554  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1555  ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->SetEtaShift( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() );
1556  if(!fDoLightOutput){
1557  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1558  }
1559  }
1560  }
1561  return kTRUE;
1562 }
1563 
1564 
1567 }
1568 
1569 
1570 //________________________________________________________________________
1572 {
1573 
1574  Int_t nclus = 0;
1575  nclus = fInputEvent->GetNumberOfCaloClusters();
1576 
1577  // cout << nclus << endl;
1578 
1579  if(nclus == 0) return;
1580 
1581  // vertex
1582  Double_t vertex[3] = {0};
1583  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1584 
1585  // Loop over EMCal clusters
1586  for(Long_t i = 0; i < nclus; i++){
1587 
1588  AliVCluster* clus = NULL;
1589  if(fInputEvent->IsA()==AliESDEvent::Class()) clus = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(i));
1590  else if(fInputEvent->IsA()==AliAODEvent::Class()) clus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i));
1591 
1592  if (!clus) continue;
1593  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC,1.,i)){ delete clus; continue;}
1594  // TLorentzvector with cluster
1595  TLorentzVector clusterVector;
1596  clus->GetMomentum(clusterVector,vertex);
1597 
1598  TLorentzVector* tmpvec = new TLorentzVector();
1599  tmpvec->SetPxPyPzE(clusterVector.Px(),clusterVector.Py(),clusterVector.Pz(),clusterVector.E());
1600 
1601  // convert to AODConversionPhoton
1602  AliAODConversionPhoton *PhotonCandidate=new AliAODConversionPhoton(tmpvec);
1603  if(!PhotonCandidate){ delete clus; delete tmpvec; continue;}
1604 
1605  // Flag Photon as CaloPhoton
1606  PhotonCandidate->SetIsCaloPhoton();
1607  PhotonCandidate->SetCaloClusterRef(i);
1608  // get MC label
1609  if(fIsMC){
1610  Int_t* mclabelsCluster = clus->GetLabels();
1611  PhotonCandidate->SetNCaloPhotonMCLabels(clus->GetNLabels());
1612  // cout << clus->GetNLabels() << endl;
1613  if (clus->GetNLabels()>0){
1614  for (Int_t k =0; k< (Int_t)clus->GetNLabels(); k++){
1615  if (k< 50)PhotonCandidate->SetCaloPhotonMCLabel(k,mclabelsCluster[k]);
1616  // Int_t pdgCode = fMCEvent->Particle(mclabelsCluster[k])->GetPdgCode();
1617  // cout << "label " << k << "\t" << mclabelsCluster[k] << " pdg code: " << pdgCode << endl;
1618  }
1619  }
1620  }
1621 
1622  fIsFromMBHeader = kTRUE;
1623  // test whether largest contribution to cluster orginates in added signals
1624  if (fIsMC && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetCaloPhotonMCLabel(0), fMCEvent, fInputEvent) == 0) fIsFromMBHeader = kFALSE;
1625 
1626  if (fIsFromMBHeader && (!fDoLightOutput)){
1627  fHistoClusterGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
1628  fHistoClusterGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1629  }
1630  fClusterCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
1631 
1632  if(fIsMC){
1633  // if(fInputEvent->IsA()==AliESDEvent::Class()){
1634  ProcessTrueCaloPhotonCandidates(PhotonCandidate);
1635  // } else {
1636  // ProcessTrueClusterCandidatesAOD(PhotonCandidate);
1637  // }
1638  }
1639 
1640  delete clus;
1641  delete tmpvec;
1642  }
1643 
1644 }
1645 
1646 //________________________________________________________________________
1648 {
1649  TParticle *Photon = NULL;
1650  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
1651  if (TruePhotonCandidate->GetCaloPhotonMCLabel(0)<0) return;
1652  // fHistoTrueNLabelsInClus[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels());
1653 
1654  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
1655  Double_t mcProdVtxX = primVtxMC->GetX();
1656  Double_t mcProdVtxY = primVtxMC->GetY();
1657  Double_t mcProdVtxZ = primVtxMC->GetZ();
1658 
1659  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0)Photon = fMCEvent->Particle(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
1660  else return;
1661 
1662  if(Photon == NULL){
1663  // cout << "no photon" << endl;
1664  return;
1665  }
1666 
1667  // Int_t pdgCodeParticle = Photon->GetPdgCode();
1668  TruePhotonCandidate->SetCaloPhotonMCFlags(fMCEvent, kFALSE);
1669 
1670  // True Photon
1671  if(fIsFromMBHeader && (!fDoLightOutput)){
1672  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, TruePhotonCandidate->GetCaloPhotonMCLabel(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
1673  if(isPrimary){
1674  if (TruePhotonCandidate->IsLargestComponentPhoton()){
1675  fHistoTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1676  if (GammaIsNeutralMesonPiPlPiMiNDMDaughter(TruePhotonCandidate->GetCaloPhotonMCLabel(0))){
1677  fHistoTrueClusterGammaFromNeutralMesonPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1678  }
1679  }
1680  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
1681  fHistoTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1682  if (GammaIsNeutralMesonPiPlPiMiNDMDaughter(TruePhotonCandidate->GetCaloPhotonMCLabel(0))){
1683  fHistoTrueClusterGammaFromNeutralMesonPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1684  }
1685  }
1686  }
1687  }
1688  return;
1689 }
1690 
1691 
1692 
1693 //________________________________________________________________________
1695  Int_t nV0 = 0;
1696  TList GoodGammasStepOne;
1697  TList GoodGammasStepTwo;
1698  // Loop over Photon Candidates allocated by ReaderV1
1699 
1700  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
1701  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
1702  if(!PhotonCandidate) continue;
1703 
1704  fIsFromMBHeader = kTRUE;
1705 
1706  if( fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0 ){
1707  Int_t isPosFromMBHeader
1708  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
1709  if(isPosFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
1710  Int_t isNegFromMBHeader
1711  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent,fInputEvent);
1712  if(isNegFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
1713  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
1714  }
1715 
1716  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fESDEvent)) continue;
1717 
1718  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut() &&
1719  !((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // if no post reader loop is required add to events good gammas
1720 
1721  fGoodConvGammas->Add(PhotonCandidate);
1722 
1723  if(fIsFromMBHeader && (!fDoLightOutput)){
1724  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
1725  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1726  }
1727 
1728  if(fMCEvent){
1729  ProcessTrueConversionPhotonCandidates(PhotonCandidate);
1730  }
1731  } else if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
1732  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
1733  nV0++;
1734  GoodGammasStepOne.Add(PhotonCandidate);
1735  } else if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut() &&
1736  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
1737  GoodGammasStepTwo.Add(PhotonCandidate);
1738  }
1739  }
1740 
1741 
1742  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut()){
1743  for(Int_t i = 0;i<GoodGammasStepOne.GetEntries();i++){
1744  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GoodGammasStepOne.At(i);
1745  if(!PhotonCandidate) continue;
1746  fIsFromMBHeader = kTRUE;
1747  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
1748  Int_t isPosFromMBHeader
1749  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent,fInputEvent);
1750  Int_t isNegFromMBHeader
1751  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent,fInputEvent);
1752  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
1753  }
1754  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GoodGammasStepOne.GetEntries())) continue;
1755  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
1756  fGoodConvGammas->Add(PhotonCandidate);
1757  if(fIsFromMBHeader && (!fDoLightOutput)){
1758  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
1759  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1760  }
1761  if(fMCEvent){
1762  ProcessTrueConversionPhotonCandidates(PhotonCandidate);
1763  }
1764  }
1765  else GoodGammasStepTwo.Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
1766  }
1767  }
1768  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){
1769  for(Int_t i = 0;i<GoodGammasStepTwo.GetEntries();i++){
1770  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GoodGammasStepTwo.At(i);
1771  if(!PhotonCandidate) continue;
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  Int_t isNegFromMBHeader
1777  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent,fInputEvent);
1778  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
1779  }
1780 
1781  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,&GoodGammasStepTwo,i)) continue;
1782  fGoodConvGammas->Add(PhotonCandidate); // Add gamma to current cut TList
1783 
1784  if(fIsFromMBHeader && (!fDoLightOutput)){
1785  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt()); // Differences to old V0Reader in p_t due to conversion KF->TLorentzVector
1786  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1787  }
1788 
1789  if(fMCEvent){
1790  ProcessTrueConversionPhotonCandidates(PhotonCandidate);
1791  }
1792  }
1793  }
1794 }
1795 
1796 //________________________________________________________________________
1798 {
1799  // Process True Photons
1800  TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCEvent);
1801  TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCEvent);
1802 
1803  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
1804  Double_t mcProdVtxX = primVtxMC->GetX();
1805  Double_t mcProdVtxY = primVtxMC->GetY();
1806  Double_t mcProdVtxZ = primVtxMC->GetZ();
1807 
1808 
1809  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
1810  if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){ // Not Same Mother == Combinatorial Bck
1811  return;
1812  }
1813 
1814  else if (posDaughter->GetMother(0) == -1){
1815  return;
1816  }
1817 
1818  if(TMath::Abs(posDaughter->GetPdgCode())!=11 || TMath::Abs(negDaughter->GetPdgCode())!=11) return; //One Particle is not electron
1819  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
1820  if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
1821 
1822  TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCEvent);
1823  if(Photon->GetPdgCode() != 22) return; // Mother is no Photon
1824 
1825  // True Photon
1826 
1827  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueConvGammas,posDaughter->GetMother(0)) && (!fDoLightOutput)) fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt());
1828 
1829  Int_t labelGamma = TruePhotonCandidate->GetMCParticleLabel(fMCEvent);
1830  Bool_t gammaIsPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelGamma, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
1831  if( gammaIsPrimary ){
1832  if( fIsFromMBHeader && (!fDoLightOutput) ){
1833  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1834  if (GammaIsNeutralMesonPiPlPiMiNDMDaughter(labelGamma)){
1835  fHistoTrueConvGammaFromNeutralMesonPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1836  }
1837  }
1838  }
1839 }
1840 
1841 //________________________________________________________________________
1843  // Conversion Gammas
1844  if(fGoodConvGammas->GetEntries()>1){
1845  for(Int_t firstGammaIndex=0;firstGammaIndex<fGoodConvGammas->GetEntries()-1;firstGammaIndex++){
1846  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGoodConvGammas->At(firstGammaIndex));
1847  if (gamma0==NULL) continue;
1848  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGoodConvGammas->GetEntries();secondGammaIndex++){
1849  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGoodConvGammas->At(secondGammaIndex));
1850  //Check for same Electron ID
1851  if (gamma1==NULL) continue;
1852  if(gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelPositive() ||
1853  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelNegative() ||
1854  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelPositive() ||
1855  gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelNegative() ) continue;
1856 
1857  AliAODConversionMother *NDMcand = new AliAODConversionMother(gamma0,gamma1);
1858  NDMcand->SetLabels(firstGammaIndex,secondGammaIndex);
1859 
1860  NDMcand->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
1861 
1862  if(!fDoLightOutput){
1863  fHistoGammaGammaInvMassPtBeforeCuts[fiCut]->Fill(NDMcand->M(),NDMcand->Pt());
1864  }
1865  if((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelected(NDMcand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
1866  if(fIsMC){
1867  if(fInputEvent->IsA()==AliESDEvent::Class())
1868  ProcessTrueNeutralPionCandidatesPureConversions(NDMcand,gamma0,gamma1);
1869  if(fInputEvent->IsA()==AliAODEvent::Class())
1871  }
1872  if (((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 0)){
1873  fNeutralDecayParticleCandidates->Add(NDMcand);
1874 
1875  if(!fDoLightOutput){
1876  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt());
1877  }
1878  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixing()) &&
1879  (((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 1))){
1881 
1882  if(!fDoLightOutput){
1883  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt());
1884  }
1885  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixingBothSides()) &&
1886  ((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 2)) ||
1887  ((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 3))))){
1889 
1890  if(!fDoLightOutput){
1891  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt());
1892  }
1893  } else{
1894  delete NDMcand;
1895  NDMcand=0x0;
1896  }
1897  }else{
1898  delete NDMcand;
1899  NDMcand=0x0;
1900  }
1901  }
1902  }
1903  }
1904 }
1905 
1906 
1907 //________________________________________________________________________
1909 
1910  // Conversion Gammas
1911  if(fClusterCandidates->GetEntries()>0){
1912 
1913  // vertex
1914  Double_t vertex[3] = {0};
1915  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1916 
1917  for(Int_t firstGammaIndex=0;firstGammaIndex<fClusterCandidates->GetEntries();firstGammaIndex++){
1918  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(firstGammaIndex));
1919  if (gamma0==NULL) continue;
1920 
1921  for(Int_t secondGammaIndex=0;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
1922  if (firstGammaIndex == secondGammaIndex) continue;
1923  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
1924  if (gamma1==NULL) continue;
1925 
1926  AliAODConversionMother *NDMcand = new AliAODConversionMother(gamma0,gamma1);
1927  NDMcand->SetLabels(firstGammaIndex,secondGammaIndex);
1928 
1929  if(!fDoLightOutput){
1930  fHistoGammaGammaInvMassPtBeforeCuts[fiCut]->Fill(NDMcand->M(),NDMcand->Pt());
1931  }
1932 
1933  if((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelected(NDMcand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
1934  if(fIsMC){
1935  ProcessTrueNeutralPionCandidatesPureCalo(NDMcand,gamma0,gamma1);
1936  }
1937 
1938  if (((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 0)){
1939  fNeutralDecayParticleCandidates->Add(NDMcand);
1940 
1941  if(!fDoLightOutput){
1942  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt());
1943  }
1944  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixing()) &&
1945  (((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 1))){
1947 
1948  if(!fDoLightOutput){
1949  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt());
1950  }
1951  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixingBothSides()) &&
1952  ((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 2)) ||
1953  ((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 3))))){
1955 
1956  if(!fDoLightOutput){
1957  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt());
1958  }
1959  }else {
1960  delete NDMcand;
1961  NDMcand=0x0;
1962  }
1963  } else{
1964  delete NDMcand;
1965  NDMcand=0x0;
1966  }
1967  }
1968  }
1969  }
1970 }
1971 
1972 //______________________________________________________________________
1974 {
1975  // Process True Mesons
1976 
1977  Bool_t isTrueNDM = kFALSE;
1978  Int_t gamma0MCLabel = TrueGammaCandidate0->GetCaloPhotonMCLabel(0); // get most probable MC label
1979  Int_t gamma0MotherLabel = -1;
1980  Int_t motherRealLabel = -1;
1981 
1982  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
1983  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
1984  if (TrueGammaCandidate0->IsLargestComponentPhoton() || TrueGammaCandidate0->IsLargestComponentElectron()){ // largest component is electro magnetic
1985  // get mother of interest (pi0 or eta)
1986  if (TrueGammaCandidate0->IsLargestComponentPhoton()){ // for photons its the direct mother
1987  gamma0MotherLabel=gammaMC0->GetMother(0);
1988  motherRealLabel=gammaMC0->GetFirstMother();
1989  } else if (TrueGammaCandidate0->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
1990  if (TrueGammaCandidate0->IsConversion() && gammaMC0->GetMother(0)>-1){
1991  gamma0MotherLabel=fMCEvent->Particle(gammaMC0->GetMother(0))->GetMother(0);
1992  motherRealLabel=fMCEvent->Particle(gammaMC0->GetMother(0))->GetMother(0);
1993  } else {
1994  gamma0MotherLabel=gammaMC0->GetMother(0);
1995  motherRealLabel=gammaMC0->GetMother(0);
1996  }
1997  }
1998  }
1999  }
2000 
2001  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2002 
2003  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
2004  Int_t gamma1MotherLabel = -1;
2005  // check if
2006  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2007  // Daughters Gamma 1
2008  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
2009  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
2010  // get mother of interest (pi0 or eta)
2011  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
2012  gamma1MotherLabel=gammaMC1->GetMother(0);
2013  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
2014  if (TrueGammaCandidate1->IsConversion() && gammaMC1->GetMother(0)>-1) gamma1MotherLabel=fMCEvent->Particle(gammaMC1->GetMother(0))->GetMother(0);
2015  else gamma1MotherLabel=gammaMC1->GetMother(0);
2016  }
2017  }
2018  }
2019 
2020  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
2021  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == fPDGCodeNDM){
2022  isTrueNDM=kTRUE;
2023  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel) && (!fDoLightOutput)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2024  }
2025  }
2026 
2027  if(isTrueNDM){// True Pion
2028  Pi0Candidate->SetTrueMesonValue(1);
2029  Pi0Candidate->SetMCLabel(motherRealLabel);
2030  if(!fDoLightOutput){
2031  fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2032  switch( fSelectedHeavyNeutralMeson ) {
2033  case 0: // ETA MESON
2034  if( IsEtaPiPlPiMiPiZeroDaughter(motherRealLabel) )
2035  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2036  break;
2037  case 1: // OMEGA MESON
2038  if( IsOmegaPiPlPiMiPiZeroDaughter(motherRealLabel) )
2039  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2040  break;
2041  case 2: // ETA PRIME MESON
2042  if( IsEtaPrimePiPlPiMiEtaDaughter(motherRealLabel) )
2043  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2044  break;
2045  case 3: // D0 MESON
2046  if( IsD0PiPlPiMiPiZeroDaughter(motherRealLabel) )
2047  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2048  break;
2049  default:
2050  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
2051  }
2052  }
2053  }
2054 }
2055 
2056 
2057 
2058 //______________________________________________________________________
2060 {
2061  // Process True Mesons
2062  if(TrueGammaCandidate0->GetV0Index()<fInputEvent->GetNumberOfV0s()){
2063  Bool_t isTrueNDM = kFALSE;
2064  Bool_t isTruePi0Dalitz = kFALSE;
2065  Bool_t gamma0DalitzCand = kFALSE;
2066  Bool_t gamma1DalitzCand = kFALSE;
2067  Int_t gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCEvent);
2068  Int_t gamma0MotherLabel = -1;
2069  Int_t motherRealLabel = -1;
2070  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2071  // Daughters Gamma 0
2072  TParticle * negativeMC = (TParticle*)TrueGammaCandidate0->GetNegativeMCDaughter(fMCEvent);
2073  TParticle * positiveMC = (TParticle*)TrueGammaCandidate0->GetPositiveMCDaughter(fMCEvent);
2074  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
2075  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2076  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
2077  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
2078  gamma0MotherLabel=gammaMC0->GetFirstMother();
2079  motherRealLabel=gammaMC0->GetFirstMother();
2080  }
2081  }
2082  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
2083  gamma0DalitzCand = kTRUE;
2084  gamma0MotherLabel=-111;
2085  motherRealLabel=gamma0MCLabel;
2086  }
2087  }
2088  }
2089  if(TrueGammaCandidate1->GetV0Index()<fInputEvent->GetNumberOfV0s()){
2090  Int_t gamma1MCLabel = TrueGammaCandidate1->GetMCParticleLabel(fMCEvent);
2091  Int_t gamma1MotherLabel = -1;
2092  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2093  // Daughters Gamma 1
2094  TParticle * negativeMC = (TParticle*)TrueGammaCandidate1->GetNegativeMCDaughter(fMCEvent);
2095  TParticle * positiveMC = (TParticle*)TrueGammaCandidate1->GetPositiveMCDaughter(fMCEvent);
2096  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
2097  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2098  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
2099  if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
2100  gamma1MotherLabel=gammaMC1->GetFirstMother();
2101  }
2102  }
2103  if(gammaMC1->GetPdgCode() ==111 ){ // Dalitz candidate
2104  gamma1DalitzCand = kTRUE;
2105  gamma1MotherLabel=-111;
2106  }
2107  }
2108  }
2109  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
2110  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == fPDGCodeNDM){
2111  isTrueNDM=kTRUE;
2112  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel) && (!fDoLightOutput)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2113  }
2114  }
2115 
2116  //Identify Dalitz candidate
2117  if (gamma1DalitzCand || gamma0DalitzCand){
2118  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
2119  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
2120  }
2121  if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
2122  if (gamma1MotherLabel == -111) isTruePi0Dalitz = kTRUE;
2123  }
2124  }
2125 
2126 
2127  if(isTrueNDM || isTruePi0Dalitz){// True Pion
2128  Pi0Candidate->SetTrueMesonValue(1);
2129  Pi0Candidate->SetMCLabel(motherRealLabel);
2130  if(!fDoLightOutput){
2131  fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2132  switch( fSelectedHeavyNeutralMeson ) {
2133  case 0: // ETA MESON
2134  if( IsEtaPiPlPiMiPiZeroDaughter(motherRealLabel) )
2135  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2136  break;
2137  case 1: // OMEGA MESON
2138  if( IsOmegaPiPlPiMiPiZeroDaughter(motherRealLabel) )
2139  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2140  break;
2141  case 2: // ETA PRIME MESON
2142  if( IsEtaPrimePiPlPiMiEtaDaughter(motherRealLabel) )
2143  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2144  break;
2145  case 3: // D0 MESON
2146  if( IsD0PiPlPiMiPiZeroDaughter(motherRealLabel) )
2147  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2148  break;
2149  default:
2150  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
2151  }
2152  }
2153  }
2154  }
2155  }
2156 }
2157 
2158 //______________________________________________________________________
2160 {
2161 
2162  // Process True Mesons
2163  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2164  Bool_t isTruePi0 = kFALSE;
2165  Bool_t isTruePi0Dalitz = kFALSE;
2166  Bool_t gamma0DalitzCand = kFALSE;
2167  Bool_t gamma1DalitzCand = kFALSE;
2168  Int_t motherRealLabel = -1;
2169 
2170  if (AODMCTrackArray!=NULL && TrueGammaCandidate0 != NULL){
2171  AliAODMCParticle *positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
2172  AliAODMCParticle *negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
2173 
2174  Int_t gamma0MCLabel = -1;
2175  Int_t gamma0MotherLabel = -1;
2176  if(!positiveMC||!negativeMC)
2177  return;
2178 
2179  if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
2180  gamma0MCLabel = positiveMC->GetMother();
2181  }
2182 
2183  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2184  // Daughters Gamma 0
2185  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
2186  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2187  if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
2188  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
2189  gamma0MotherLabel=gammaMC0->GetMother();
2190  motherRealLabel=gammaMC0->GetMother();
2191  }
2192  }
2193  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
2194  gamma0DalitzCand = kTRUE;
2195  gamma0MotherLabel=-111;
2196  motherRealLabel=gamma0MCLabel;
2197  }
2198  }
2199  }
2200  positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelPositive()));
2201  negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelNegative()));
2202 
2203  Int_t gamma1MCLabel = -1;
2204  Int_t gamma1MotherLabel = -1;
2205  if(!positiveMC||!negativeMC)
2206  return;
2207 
2208  if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
2209  gamma1MCLabel = positiveMC->GetMother();
2210  }
2211  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2212  // Daughters Gamma 1
2213  AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
2214  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2215  if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
2216  if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
2217  gamma1MotherLabel=gammaMC1->GetMother();
2218  }
2219  }
2220  if(gammaMC1->GetPdgCode() ==111 ){ // Dalitz candidate
2221  gamma1DalitzCand = kTRUE;
2222  gamma1MotherLabel=-111;
2223  }
2224  }
2225  }
2226  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
2227  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == fPDGCodeNDM){
2228  isTruePi0=kTRUE;
2229  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel) &&(!fDoLightOutput)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2230  }
2231  }
2232 
2233  //Identify Dalitz candidate
2234  if (gamma1DalitzCand || gamma0DalitzCand){
2235  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
2236  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
2237  }
2238  if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
2239  if (gamma1MotherLabel == -111) isTruePi0Dalitz = kTRUE;
2240  }
2241  }
2242 
2243  if(isTruePi0 || isTruePi0Dalitz){// True Pion
2244  Pi0Candidate->SetTrueMesonValue(1);
2245  Pi0Candidate->SetMCLabel(motherRealLabel);
2246  if(!fDoLightOutput){
2247  fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2248  switch( fSelectedHeavyNeutralMeson ) {
2249  case 0: // ETA MESON
2250  if( IsEtaPiPlPiMiPiZeroDaughter(motherRealLabel) )
2251  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2252  break;
2253  case 1: // OMEGA MESON
2254  if( IsOmegaPiPlPiMiPiZeroDaughter(motherRealLabel) )
2255  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2256  break;
2257  case 2: // ETA PRIME MESON
2258  if( IsEtaPrimePiPlPiMiEtaDaughter(motherRealLabel) )
2259  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2260  break;
2261  case 3: // D0 MESON
2262  if( IsD0PiPlPiMiPiZeroDaughter(motherRealLabel) )
2263  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2264  break;
2265  default:
2266  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
2267  }
2268  }
2269  }
2270  }
2271  return;
2272 }
2273 
2274 
2275 //________________________________________________________________________
2277 
2278  // Conversion Gammas
2279  if(fGoodConvGammas->GetEntries()>0){
2280  // vertex
2281  Double_t vertex[3] = {0};
2282  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
2283 
2284  for(Int_t firstGammaIndex=0;firstGammaIndex<fGoodConvGammas->GetEntries();firstGammaIndex++){
2285  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGoodConvGammas->At(firstGammaIndex));
2286  if (gamma0==NULL) continue;
2287 
2288  for(Int_t secondGammaIndex=0;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
2289  Bool_t matched = kFALSE;
2290  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
2291  if (gamma1==NULL) continue;
2292 
2293  if (gamma1->GetIsCaloPhoton()){
2294  AliVCluster* cluster = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
2295  matched = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma0,cluster, fInputEvent );
2296  }
2297 
2298  AliAODConversionMother *NDMcand = new AliAODConversionMother(gamma0,gamma1);
2299  NDMcand->SetLabels(firstGammaIndex,secondGammaIndex);
2300 
2301  if(!fDoLightOutput){
2302  fHistoGammaGammaInvMassPtBeforeCuts[fiCut]->Fill(NDMcand->M(),NDMcand->Pt());
2303  }
2304 
2305  if((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelected(NDMcand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
2306  if (!matched){
2307  if(fIsMC){
2308  ProcessTrueNeutralPionCandidatesMixedConvCalo(NDMcand,gamma0,gamma1);
2309  }
2310  if (((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 0)){
2311  fNeutralDecayParticleCandidates->Add(NDMcand);
2312 
2313  if(!fDoLightOutput){
2314  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt());
2315  }
2316  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixing()) &&
2317  (((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 1))){
2319 
2320  if(!fDoLightOutput){
2321  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt());
2322  }
2323  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixingBothSides()) &&
2324  ((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 2)) ||
2325  ((((AliConversionMesonCuts*)fNeutralDecayMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(NDMcand, 3))))){
2327 
2328  if(!fDoLightOutput){
2329  fHistoGammaGammaInvMassPt[fiCut]->Fill(NDMcand->M(),NDMcand->Pt());
2330  }
2331  } else{
2332  delete NDMcand;
2333  NDMcand=0x0;
2334  }
2335  }else{
2336  delete NDMcand;
2337  NDMcand=0x0;
2338  }
2339  }else{
2340  delete NDMcand;
2341  NDMcand=0x0;
2342  }
2343  }
2344  }
2345  }
2346 }
2347 
2348 //______________________________________________________________________
2350 {
2351  // Process True Mesons
2352  if(TrueGammaCandidate0->GetV0Index()<fInputEvent->GetNumberOfV0s()){
2353  Bool_t isTruePi0 = kFALSE;
2354  Bool_t isTruePi0Dalitz = kFALSE;
2355  Bool_t gamma0DalitzCand = kFALSE;
2356 
2357  Int_t gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCEvent);
2358  Int_t gamma0MotherLabel = -1;
2359  Int_t motherRealLabel = -1;
2360  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2361  // Daughters Gamma 0
2362  TParticle * negativeMC = (TParticle*)TrueGammaCandidate0->GetNegativeMCDaughter(fMCEvent);
2363  TParticle * positiveMC = (TParticle*)TrueGammaCandidate0->GetPositiveMCDaughter(fMCEvent);
2364  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
2365  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2366  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
2367  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
2368  gamma0MotherLabel=gammaMC0->GetFirstMother();
2369  motherRealLabel=gammaMC0->GetFirstMother();
2370  }
2371  }
2372  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
2373  gamma0DalitzCand = kTRUE;
2374  gamma0MotherLabel=-111;
2375  motherRealLabel=gamma0MCLabel;
2376  }
2377 
2378  }
2379  }
2380 
2381  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2382 
2383  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
2384  Int_t gamma1MotherLabel = -1;
2385  // check if
2386 
2387  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2388  // Daughters Gamma 1
2389  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
2390  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
2391  // get mother of interest (pi0 or eta)
2392  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
2393  gamma1MotherLabel=gammaMC1->GetMother(0);
2394  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
2395  if (TrueGammaCandidate1->IsConversion() && gammaMC1->GetMother(0)>-1) gamma1MotherLabel=fMCEvent->Particle(gammaMC1->GetMother(0))->GetMother(0);
2396  else gamma1MotherLabel=gammaMC1->GetMother(0);
2397  }
2398  }
2399  }
2400 
2401  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
2402  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == fPDGCodeNDM){
2403  isTruePi0=kTRUE;
2404  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel) && (!fDoLightOutput)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2405  }
2406  }
2407 
2408  if (gamma0DalitzCand ){
2409  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
2410  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
2411  }
2412  }
2413 
2414  if(isTruePi0 || isTruePi0Dalitz ){
2415  Pi0Candidate->SetTrueMesonValue(1);
2416  Pi0Candidate->SetMCLabel(motherRealLabel);
2417  if(!fDoLightOutput){
2418  fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2419  switch( fSelectedHeavyNeutralMeson ) {
2420  case 0: // ETA MESON
2421  if( IsEtaPiPlPiMiPiZeroDaughter(motherRealLabel) )
2422  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2423  break;
2424  case 1: // OMEGA MESON
2425  if( IsOmegaPiPlPiMiPiZeroDaughter(motherRealLabel) )
2426  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2427  break;
2428  case 2: // ETA PRIME MESON
2429  if( IsEtaPrimePiPlPiMiEtaDaughter(motherRealLabel) )
2430  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2431  break;
2432  case 3: // D0 MESON
2433  if( IsD0PiPlPiMiPiZeroDaughter(motherRealLabel) )
2434  fHistoTrueMotherGammaGammaFromHNMInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2435  break;
2436  default:
2437  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
2438  }
2439  }
2440  }
2441  }
2442 }
2443 
2444 
2445 
2446 //________________________________________________________________________
2448 
2449  Double_t magField = fInputEvent->GetMagneticField();
2450  if( magField < 0.0 ){
2451  magField = 1.0;
2452  } else {
2453  magField = -1.0;
2454  }
2455 
2456  vector<Int_t> lGoodNegPionIndexPrev(0);
2457  vector<Int_t> lGoodPosPionIndexPrev(0);
2458 
2459  for(UInt_t i = 0; i < fSelectorNegPionIndex.size(); i++){
2460  AliESDtrack* negPionCandidate = fESDEvent->GetTrack(fSelectorNegPionIndex[i]);
2461  if(! ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelected(negPionCandidate) ) continue;
2462  lGoodNegPionIndexPrev.push_back( fSelectorNegPionIndex[i] );
2463 
2464  TLorentzVector negPionforHandler;
2465  negPionforHandler.SetPxPyPzE(negPionCandidate->Px(), negPionCandidate->Py(), negPionCandidate->Pz(), negPionCandidate->E());
2466 
2467  AliAODConversionPhoton *negPionHandler = new AliAODConversionPhoton(&negPionforHandler);
2468 
2469  fNegPionCandidates->Add(negPionHandler);
2470  if(!fDoLightOutput){
2471  fHistoNegPionPt[fiCut]->Fill(negPionCandidate->Pt());
2472  fHistoNegPionPhi[fiCut]->Fill(negPionCandidate->Phi());
2473  }
2474 
2475  if( fMCEvent ) {
2476  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2477  Double_t mcProdVtxX = primVtxMC->GetX();
2478  Double_t mcProdVtxY = primVtxMC->GetY();
2479  Double_t mcProdVtxZ = primVtxMC->GetZ();
2480 
2481  Int_t labelNegPion = TMath::Abs( negPionCandidate->GetLabel() );
2482  Bool_t negPionIsPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelNegPion, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2483  if( labelNegPion>-1 && labelNegPion < fMCEvent->GetNumberOfTracks() ){
2484  TParticle* negPion = fMCEvent->Particle(labelNegPion);
2485  if( negPion->GetPdgCode() == -211 ){
2486  if(!fDoLightOutput){
2487  if( negPionIsPrimary ){
2488  fHistoTrueNegPionPt[fiCut]->Fill(negPionCandidate->Pt()); //primary negPion
2489  }
2490  switch( fSelectedHeavyNeutralMeson ) {
2491  case 0: // ETA MESON
2492  if( IsEtaPiPlPiMiPiZeroDaughter(labelNegPion) && negPionIsPrimary )
2493  fHistoTrueNegPionFromNeutralMesonPt[fiCut]->Fill(negPionCandidate->Pt());
2494  break;
2495  case 1: // OMEGA MESON
2496  if( IsOmegaPiPlPiMiPiZeroDaughter(labelNegPion) && negPionIsPrimary)
2497  fHistoTrueNegPionFromNeutralMesonPt[fiCut]->Fill(negPionCandidate->Pt());
2498  break;
2499  case 2: // ETA PRIME MESON
2500  if( IsEtaPrimePiPlPiMiEtaDaughter(labelNegPion) && negPionIsPrimary)
2501  fHistoTrueNegPionFromNeutralMesonPt[fiCut]->Fill(negPionCandidate->Pt());
2502  break;
2503  case 3: // D0 MESON
2504  if( IsD0PiPlPiMiPiZeroDaughter(labelNegPion)& negPionIsPrimary)
2505  fHistoTrueNegPionFromNeutralMesonPt[fiCut]->Fill(negPionCandidate->Pt());
2506  break;
2507  default:
2508  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
2509  }
2510  }
2511  }
2512  }
2513  }
2514  }
2515 
2516  for(UInt_t i = 0; i < fSelectorPosPionIndex.size(); i++){
2517  AliESDtrack* posPionCandidate = fESDEvent->GetTrack( fSelectorPosPionIndex[i] );
2518  if(! ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelected(posPionCandidate) ) continue;
2519  lGoodPosPionIndexPrev.push_back( fSelectorPosPionIndex[i] );
2520 
2521  TLorentzVector posPionforHandler;
2522  posPionforHandler.SetPxPyPzE(posPionCandidate->Px(), posPionCandidate->Py(), posPionCandidate->Pz(), posPionCandidate->E());
2523 
2524  AliAODConversionPhoton *posPionHandler = new AliAODConversionPhoton(&posPionforHandler);
2525 
2526  fPosPionCandidates->Add(posPionHandler);
2527  if(!fDoLightOutput){
2528  fHistoPosPionPt[fiCut]->Fill( posPionCandidate->Pt() );
2529  fHistoPosPionPhi[fiCut]->Fill( posPionCandidate->Phi() );
2530  }
2531  if( fMCEvent ) {
2532  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2533  Double_t mcProdVtxX = primVtxMC->GetX();
2534  Double_t mcProdVtxY = primVtxMC->GetY();
2535  Double_t mcProdVtxZ = primVtxMC->GetZ();
2536 
2537  Int_t labelPosPion = TMath::Abs( posPionCandidate->GetLabel() );
2538  Bool_t posPionIsPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelPosPion, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2539  if( labelPosPion>-1 && labelPosPion < fMCEvent->GetNumberOfTracks() ) {
2540  TParticle* posPion = fMCEvent->Particle(labelPosPion);
2541  if( posPion->GetPdgCode() == 211 ){
2542  if(!fDoLightOutput){
2543  if( posPionIsPrimary ){
2544  fHistoTruePosPionPt[fiCut]->Fill(posPionCandidate->Pt());
2545  }
2546  switch( fSelectedHeavyNeutralMeson ) {
2547  case 0: // ETA MESON
2548  if( IsEtaPiPlPiMiPiZeroDaughter(labelPosPion) && posPionIsPrimary )
2549  fHistoTruePosPionFromNeutralMesonPt[fiCut]->Fill(posPionCandidate->Pt());
2550  break;
2551  case 1: // OMEGA MESON
2552  if( IsOmegaPiPlPiMiPiZeroDaughter(labelPosPion) && posPionIsPrimary)
2553  fHistoTruePosPionFromNeutralMesonPt[fiCut]->Fill(posPionCandidate->Pt());
2554  break;
2555  case 2: // ETA PRIME MESON
2556  if( IsEtaPrimePiPlPiMiEtaDaughter(labelPosPion) && posPionIsPrimary)
2557  fHistoTruePosPionFromNeutralMesonPt[fiCut]->Fill(posPionCandidate->Pt());
2558  break;
2559  case 3: // D0 MESON
2560  if( IsD0PiPlPiMiPiZeroDaughter(labelPosPion) && posPionIsPrimary )
2561  fHistoTruePosPionFromNeutralMesonPt[fiCut]->Fill(posPionCandidate->Pt());
2562  break;
2563  default:
2564  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
2565  }
2566  }
2567  }
2568  }
2569  }
2570  }
2571 
2572 
2573  for(UInt_t i = 0; i < lGoodNegPionIndexPrev.size(); i++){
2574  AliESDtrack *negPionCandidate = fESDEvent->GetTrack(lGoodNegPionIndexPrev[i]);
2575  AliKFParticle negPionCandidateKF( *negPionCandidate->GetConstrainedParam(), 211 );
2576 
2577  for(UInt_t j = 0; j < lGoodPosPionIndexPrev.size(); j++){
2578  AliESDtrack *posPionCandidate = fESDEvent->GetTrack(lGoodPosPionIndexPrev[j]);
2579  AliKFParticle posPionCandidateKF( *posPionCandidate->GetConstrainedParam(), 211 );
2580 
2581  AliKFConversionPhoton* virtualPhoton = NULL;
2582  virtualPhoton = new AliKFConversionPhoton(negPionCandidateKF,posPionCandidateKF);
2583  AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex());
2584  // primaryVertexImproved+=*virtualPhoton;
2585  virtualPhoton->SetProductionVertex(primaryVertexImproved);
2586  virtualPhoton->SetTrackLabels( lGoodPosPionIndexPrev[j], lGoodNegPionIndexPrev[i]);
2587 
2588  Int_t labeln=0;
2589  Int_t labelp=0;
2590  Int_t motherlabelp = 0;
2591  Int_t motherlabeln = 0;
2592  TParticle *fNegativeMCParticle =NULL;
2593  TParticle *fPositiveMCParticle =NULL;
2594  if( fMCEvent ) {
2595  labeln=TMath::Abs(negPionCandidate->GetLabel());
2596  labelp=TMath::Abs(posPionCandidate->GetLabel());
2597  if(labeln>-1) fNegativeMCParticle = fMCEvent->Particle(labeln);
2598  if(labelp>-1) fPositiveMCParticle = fMCEvent->Particle(labelp);
2599  // check whether MC particles exist, else abort
2600  if (fNegativeMCParticle == NULL || fPositiveMCParticle == NULL) return;
2601 
2602  motherlabeln = fNegativeMCParticle->GetMother(0);
2603  motherlabelp = fPositiveMCParticle->GetMother(0);
2604  virtualPhoton->SetMCLabelPositive(labelp);
2605  virtualPhoton->SetMCLabelNegative(labeln);
2606 
2607  }
2608 
2609  AliAODConversionPhoton *vParticle = new AliAODConversionPhoton(virtualPhoton); //To apply mass 2 pion mass cut
2610  if(!fDoLightOutput){
2611  if (fMCEvent &&(fDoMesonQA>0)){
2612  if (fPositiveMCParticle && fNegativeMCParticle ) {
2613  if (((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->DoMassCut()){
2614  if (vParticle->GetMass() < ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetMassCut()){
2615  if(TMath::Abs(fNegativeMCParticle->GetPdgCode())==211 && TMath::Abs(fPositiveMCParticle->GetPdgCode())==211){ // Pions ...
2616  fHistoTruePionPionInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2617  if (motherlabeln == motherlabelp){
2618  fHistoTruePionPionFromSameMotherInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2619  switch( fSelectedHeavyNeutralMeson ) {
2620  case 0: // ETA MESON
2621  if( IsEtaPiPlPiMiPiZeroDaughter(labeln) )
2622  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2623  break;
2624  case 1: // OMEGA MESON
2625  if( IsOmegaPiPlPiMiPiZeroDaughter(labeln) )
2626  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2627  break;
2628  case 2: // ETA PRIME MESON
2629  if( IsEtaPrimePiPlPiMiEtaDaughter(labeln) )
2630  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2631  break;
2632  case 3: // D0 MESON
2633  if( IsD0PiPlPiMiPiZeroDaughter(labeln) )
2634  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2635  break;
2636  default:
2637  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
2638  }
2639  }
2640  }
2641  }
2642  } else {
2643  if(TMath::Abs(fNegativeMCParticle->GetPdgCode())==211 && TMath::Abs(fPositiveMCParticle->GetPdgCode())==211){ // Pions ...
2644  fHistoTruePionPionInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2645  if (motherlabeln == motherlabelp){
2646  fHistoTruePionPionFromSameMotherInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2647  switch( fSelectedHeavyNeutralMeson ) {
2648  case 0: // ETA MESON
2649  if( IsEtaPiPlPiMiPiZeroDaughter(labeln) )
2650  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2651  break;
2652  case 1: // OMEGA MESON
2653  if( IsOmegaPiPlPiMiPiZeroDaughter(labeln) )
2654  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2655  break;
2656  case 2: // ETA PRIME MESON
2657  if( IsEtaPrimePiPlPiMiEtaDaughter(labeln) )
2658  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2659  break;
2660  case 3: // D0 MESON
2661  if( IsD0PiPlPiMiPiZeroDaughter(labeln) )
2662  fHistoTruePionPionFromHNMInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2663  break;
2664  default:
2665  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
2666  }
2667  }
2668  }
2669  }
2670  }
2671  }
2672  }
2673 
2674  if (((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->DoMassCut()){
2675  if (vParticle->GetMass() < ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetMassCut()){
2676  fGoodVirtualParticles->Add( vParticle );
2677  if(!fDoLightOutput){
2678  fHistoPionPionInvMassPt[fiCut]->Fill( vParticle->GetMass(),vParticle->Pt());
2679  }
2680  }else{
2681  delete vParticle;
2682  vParticle=0x0;
2683  }
2684  } else {
2685  fGoodVirtualParticles->Add( vParticle );
2686  if(!fDoLightOutput){
2687  fHistoPionPionInvMassPt[fiCut]->Fill( vParticle->GetMass(),vParticle->Pt());
2688  }
2689  }
2690 
2691  Double_t clsToFPos = -1.0;
2692  Double_t clsToFNeg = -1.0;
2693 
2694  Float_t dcaToVertexXYPos = -1.0;
2695  Float_t dcaToVertexZPos = -1.0;
2696  Float_t dcaToVertexXYNeg = -1.0;
2697  Float_t dcaToVertexZNeg = -1.0;
2698 
2699  if ( fDoMesonQA>0 ) {
2700  clsToFPos = ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetNFindableClustersTPC(posPionCandidate);
2701  clsToFNeg = ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetNFindableClustersTPC(negPionCandidate);
2702 
2703  Float_t bPos[2];
2704  Float_t bCovPos[3];
2705  posPionCandidate->GetImpactParameters(bPos,bCovPos);
2706  if (bCovPos[0]<=0 || bCovPos[2]<=0) {
2707  AliDebug(1, "Estimated b resolution lower or equal zero!");
2708  bCovPos[0]=0; bCovPos[2]=0;
2709  }
2710 
2711  Float_t bNeg[2];
2712  Float_t bCovNeg[3];
2713  posPionCandidate->GetImpactParameters(bNeg,bCovNeg);
2714  if (bCovNeg[0]<=0 || bCovNeg[2]<=0) {
2715  AliDebug(1, "Estimated b resolution lower or equal zero!");
2716  bCovNeg[0]=0; bCovNeg[2]=0;
2717  }
2718 
2719  dcaToVertexXYPos = bPos[0];
2720  dcaToVertexZPos = bPos[1];
2721  dcaToVertexXYNeg = bNeg[0];
2722  dcaToVertexZNeg = bNeg[1];
2723 
2724  if(!fDoLightOutput){
2725  fHistoNegPionEta[fiCut]->Fill( negPionCandidate->Eta() );
2726  fHistoPosPionEta[fiCut]->Fill( posPionCandidate->Eta() );
2727 
2728  fHistoNegPionClsTPC[fiCut]->Fill(clsToFNeg,negPionCandidate->Pt());
2729  fHistoPosPionClsTPC[fiCut]->Fill(clsToFPos,posPionCandidate->Pt());
2730 
2731  fHistoPionDCAxy[fiCut]->Fill( dcaToVertexXYNeg, negPionCandidate->Pt() );
2732  fHistoPionDCAz[fiCut]->Fill( dcaToVertexZNeg, negPionCandidate->Pt() );
2733  fHistoPionDCAxy[fiCut]->Fill( dcaToVertexXYPos, posPionCandidate->Pt() );
2734  fHistoPionDCAz[fiCut]->Fill( dcaToVertexZPos, posPionCandidate->Pt() );
2735 
2736  fHistoPionTPCdEdxNSigma[fiCut]->Fill( posPionCandidate->P(),((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetPIDResponse()->NumberOfSigmasTPC(posPionCandidate, AliPID::kPion) );
2737  fHistoPionTPCdEdxNSigma[fiCut]->Fill( negPionCandidate->P(),((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetPIDResponse()->NumberOfSigmasTPC(negPionCandidate, AliPID::kPion) );
2738 
2739  fHistoPionTPCdEdx[fiCut]->Fill( posPionCandidate->P(), TMath::Abs(posPionCandidate->GetTPCsignal()));
2740  fHistoPionTPCdEdx[fiCut]->Fill( negPionCandidate->P(), TMath::Abs(negPionCandidate->GetTPCsignal()));
2741  }
2742  }
2743 
2744  delete virtualPhoton;
2745  virtualPhoton=NULL;
2746  }
2747  }
2748 }
2749 
2750 //_____________________________________________________________________________
2752 
2753  // Loop over all primary MC particle
2754  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2755  Double_t mcProdVtxX = primVtxMC->GetX();
2756  Double_t mcProdVtxY = primVtxMC->GetY();
2757  Double_t mcProdVtxZ = primVtxMC->GetZ();
2758 
2759  for(Int_t i = 0; i < fMCEvent->GetNumberOfTracks(); i++) {
2760  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
2761 
2762  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
2763  if (!particle) continue;
2764 
2765  Int_t isMCFromMBHeader = -1;
2766  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2767  isMCFromMBHeader
2768  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2769  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2770  }
2771 
2772  if(!fDoLightOutput){
2773  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent,fInputEvent)){
2774  // find MC photons
2775  if (fNDMRecoMode < 2 ){
2776  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
2777  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma
2778  if(particle->GetMother(0) >-1){
2779  if (fMCEvent->Particle(particle->GetMother(0))->GetPdgCode() ==fPDGCodeNDM){
2780  if (fMCEvent->Particle(particle->GetMother(0))->GetMother(0) > -1){
2781  if ( fMCEvent->Particle((fMCEvent->Particle(particle->GetMother(0)))->GetMother(0))->GetPdgCode() == fPDGCodeAnalyzedMeson ){
2782  if ( fMCEvent->Particle(particle->GetMother(0))->GetNDaughters()==3 )
2783  fHistoMCGammaFromNeutralMesonPt[fiCut]->Fill(particle->Pt()); // All photons from eta or omega via pi0
2784  }
2785  }
2786  }
2787  }
2788  }
2789  } else if (fNDMRecoMode == 2){
2790  if(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(particle,fMCEvent)){
2791  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma
2792  if(particle->GetMother(0) >-1){
2793  if (fMCEvent->Particle(particle->GetMother(0))->GetPdgCode() ==fPDGCodeNDM){
2794  if (fMCEvent->Particle(particle->GetMother(0))->GetMother(0) > -1){
2795  if ( fMCEvent->Particle((fMCEvent->Particle(particle->GetMother(0)))->GetMother(0))->GetPdgCode() == fPDGCodeAnalyzedMeson ){
2796  if ( fMCEvent->Particle(particle->GetMother(0))->GetNDaughters()==3 )
2797  fHistoMCGammaFromNeutralMesonPt[fiCut]->Fill(particle->Pt()); // All photons from analyzed meson via pi0 or eta from decay
2798  }
2799  }
2800  }
2801  }
2802  }
2803  }
2804  if (fNDMRecoMode < 2){
2805  if (((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kTRUE)){
2806  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt());
2807  } // Converted MC Gamma
2808  }
2809  if(((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(i,fMCEvent)){
2810  if( particle->GetPdgCode() == 211){
2811  fHistoMCAllPosPionsPt[fiCut]->Fill(particle->Pt()); // All pos pions
2812  if(particle->GetMother(0) >-1){
2813  if (fMCEvent->Particle(particle->GetMother(0))->GetPdgCode() ==fPDGCodeAnalyzedMeson)
2814  fHistoMCPosPionsFromNeutralMesonPt[fiCut]->Fill(particle->Pt()); // All pos from neutral heavy meson (omega, eta OR eta prime)
2815  }
2816  }
2817  if( particle->GetPdgCode() == -211){
2818  fHistoMCAllNegPionsPt[fiCut]->Fill(particle->Pt()); // All neg pions
2819  if(particle->GetMother(0) >-1){
2820  if (fMCEvent->Particle(particle->GetMother(0))->GetPdgCode() ==fPDGCodeAnalyzedMeson)
2821  fHistoMCNegPionsFromNeutralMesonPt[fiCut]->Fill(particle->Pt()); // All pos from neutral heavy meson (omega, eta OR eta prime)
2822  }
2823  }
2824  }
2825  }
2826  }
2827 
2828  // \eta -> pi+ pi- \gamma
2829  Int_t labelNDM = -1;
2830  Int_t labelNegPion = -1;
2831  Int_t labelPosPion = -1;
2832 
2833  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())){
2834  Float_t weighted= 1;
2835  if( ((AliPrimaryPionCuts*) fPionCutArray->At(fiCut))->DoWeights() ) {
2836  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent,fInputEvent)){
2837  if (particle->Pt()>0.005){
2838  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent,fInputEvent);
2839  }
2840  }
2841  }
2842  if(particle->GetPdgCode() == fPDGCodeAnalyzedMeson)fHistoMCHNMPiPlPiMiNDMPt[fiCut]->Fill(particle->Pt(), weighted); // All MC eta, omega OR eta prime in respective decay channel
2843 
2844  if(labelNDM>-1){
2845  TParticle *particleNDM = fMCEvent->Particle(labelNDM);
2846  if(particleNDM->GetDaughter(0)>-1 && particleNDM->GetDaughter(1)>-1){
2847  TParticle *gamma1 = fMCEvent->Particle(particleNDM->GetDaughter(0));
2848  TParticle *gamma2 = fMCEvent->Particle(particleNDM->GetDaughter(1));
2849  Bool_t kDaughter0IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particleNDM->GetDaughter(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2850  Bool_t kDaughter1IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particleNDM->GetDaughter(1), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2851  Bool_t kNegPionIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelNegPion, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2852  Bool_t kPosPionIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelPosPion, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2853 
2854  if (fNDMRecoMode == 0){
2855  if( kDaughter0IsPrim && kDaughter1IsPrim && kNegPionIsPrim && kPosPionIsPrim &&
2856  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(gamma1,fMCEvent,kFALSE) && // test first daugther of pi0
2857  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(gamma2,fMCEvent,kFALSE) && // test second daughter of pi0
2858  ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(labelNegPion,fMCEvent) && // test negative pion
2859  ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(labelPosPion,fMCEvent) // test positive pion
2860  ) {
2861  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
2862  }
2863  } else if (fNDMRecoMode == 1){ // mixed mode
2864  // check if within PCM acceptance first
2865  if( kDaughter0IsPrim && kDaughter1IsPrim && kNegPionIsPrim && kPosPionIsPrim &&
2866  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(gamma1,fMCEvent,kFALSE) && // test first daugther of pi0
2867  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(gamma2,fMCEvent,kFALSE) && // test second daughter of pi0
2868  ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(labelNegPion,fMCEvent) && // test negative pion
2869  ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(labelPosPion,fMCEvent) // test positive pion
2870  ) {
2871  // check acceptance of clusters as well, true if one of them points into the Calo acceptance
2872  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma1,fMCEvent) ||
2873  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma2,fMCEvent) ){
2874  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
2875  }
2876  }
2877  } else if (fNDMRecoMode == 2){
2878  if( kDaughter0IsPrim && kDaughter1IsPrim && kNegPionIsPrim && kPosPionIsPrim &&
2879  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma1,fMCEvent) && // test first daugther of pi0
2880  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma2,fMCEvent) && // test second daughter of pi0
2881  ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(labelNegPion,fMCEvent) && // test negative pion
2882  ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(labelPosPion,fMCEvent) // test positive pion
2883  ) {
2884  if(particle->GetPdgCode() == fPDGCodeAnalyzedMeson) fHistoMCHNMPiPlPiMiNDMInAccPt[fiCut]->Fill(particle->Pt(), weighted ); // MC Eta pi+ pi- pi0 with gamma's and e+e- in acc
2885  }
2886  }
2887  }
2888  }
2889  }
2890  }
2891  }
2892 }
2893 
2894 
2895 //________________________________________________________________________
2897 
2898  // Conversion Gammas
2899  if( fNeutralDecayParticleCandidates->GetEntries() > 0 && fGoodVirtualParticles->GetEntries() > 0 ){
2900  for(Int_t mesonIndex=0; mesonIndex<fNeutralDecayParticleCandidates->GetEntries(); mesonIndex++){
2901  AliAODConversionMother *neutralDecayMeson=dynamic_cast<AliAODConversionMother*>(fNeutralDecayParticleCandidates->At(mesonIndex));
2902  if (neutralDecayMeson==NULL) continue;
2903 
2904  for(Int_t virtualParticleIndex=0;virtualParticleIndex<fGoodVirtualParticles->GetEntries();virtualParticleIndex++){
2905  AliAODConversionPhoton *vParticle=dynamic_cast<AliAODConversionPhoton*>(fGoodVirtualParticles->At(virtualParticleIndex));
2906  if (vParticle==NULL) continue;
2907  //Check for same Electron ID
2908 
2909  AliAODConversionMother mesoncand(neutralDecayMeson,vParticle);
2910  mesoncand.SetLabels(mesonIndex,virtualParticleIndex);
2911  if( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(&mesoncand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2912 
2913  AliVTrack *negPionCandidatetmp = fESDEvent->GetTrack(vParticle->GetTrackLabel(1)),
2914  *posPionCandidatetmp = fESDEvent->GetTrack(vParticle->GetTrackLabel(0));
2915  if(!(negPionCandidatetmp || posPionCandidatetmp)) continue;
2916  AliAODConversionMother NegPiontmp, PosPiontmp;
2917  NegPiontmp.SetPxPyPzE(negPionCandidatetmp->Px(), negPionCandidatetmp->Py(), negPionCandidatetmp->Pz(), negPionCandidatetmp->E());
2918  PosPiontmp.SetPxPyPzE(posPionCandidatetmp->Px(), posPionCandidatetmp->Py(), posPionCandidatetmp->Pz(), posPionCandidatetmp->E());
2919 
2920  if(KinematicCut(&NegPiontmp, &PosPiontmp, neutralDecayMeson, &mesoncand)){
2921  if(!fDoLightOutput){
2922  fHistoAngleHNMesonNDM[fiCut]->Fill(mesoncand.Pt(),neutralDecayMeson->Angle(mesoncand.Vect()));
2923  fHistoAngleHNMesonPiPl[fiCut]->Fill(mesoncand.Pt(),PosPiontmp.Angle(mesoncand.Vect()));
2924  fHistoAngleHNMesonPiMi[fiCut]->Fill(mesoncand.Pt(),NegPiontmp.Angle(mesoncand.Vect()));
2925  fHistoAngleNDMPiMi[fiCut]->Fill(mesoncand.Pt(),NegPiontmp.Angle(neutralDecayMeson->Vect()));
2926  fHistoAnglePiPlPiMi[fiCut]->Fill(mesoncand.Pt(),NegPiontmp.Angle(PosPiontmp.Vect()));
2927  fHistoAnglePiPlNDM[fiCut]->Fill(mesoncand.Pt(),PosPiontmp.Angle(neutralDecayMeson->Vect()));
2928  fHistoAngleHNMesonPiPlPiMi[fiCut]->Fill(mesoncand.Pt(),vParticle->Angle(mesoncand.Vect()));
2929  fHistoAngleSum[fiCut]->Fill(mesoncand.Pt(),((PosPiontmp.Angle(mesoncand.Vect()))+(NegPiontmp.Angle(PosPiontmp.Vect()))+(PosPiontmp.Angle(neutralDecayMeson->Vect()))));
2930  }
2931 
2932  // Subtract mass of used pi0 candidate and then add PDG mass to get to right range again
2933  fHistoMotherInvMassSubNDM[fiCut]->Fill(mesoncand.M()-(neutralDecayMeson->M()-fPDGMassNDM),mesoncand.Pt());
2934 
2935  // Fix Pz of pi0 candidate to match pi0 PDG mass
2936  AliAODConversionMother NDMtmp;
2937  NDMtmp.SetPxPyPzE(neutralDecayMeson->Px(), neutralDecayMeson->Py(), neutralDecayMeson->Pz(), neutralDecayMeson->Energy());
2938  FixPzToMatchPDGInvMassNDM(&NDMtmp);
2939  AliAODConversionMother mesontmp(&NDMtmp,vParticle);
2940  fHistoMotherInvMassFixedPzNDM[fiCut]->Fill(mesontmp.M(),mesontmp.Pt());
2941  fHistoMotherInvMassPt[fiCut]->Fill(mesoncand.M(),mesoncand.Pt());
2942  if(fMCEvent){
2943  ProcessTrueMesonCandidates(&mesoncand,neutralDecayMeson,vParticle);
2944  }
2945  }else{
2946  if(!fDoLightOutput){
2947  fHistoMotherInvMassPtRejectedKinematic[fiCut]->Fill(mesoncand.M(),mesoncand.Pt());
2948  }
2949  }
2950  }
2951  }
2952  }
2953  }
2954 }
2955 //________________________________________________________________________
2957 
2958  /* Event mixing histo explanation
2959  *
2960  * fHistoBackInvMassPtGroup1 => pi+ and pi- from same event
2961  * fHistoBackInvMassPtGroup2 => pi+ and pi0 from same event
2962  * fHistoBackInvMassPtGroup3 => pi- and pi0 from same event
2963  * fHistoBackInvMassPtGroup4 => no pions from same event
2964  */
2965 
2966  // Get multiplicity and zbin from fBGHandler
2967  Int_t zbin = fBGHandlerPiMi[fiCut]->GetZBinIndex(fESDEvent->GetPrimaryVertex()->GetZ());
2968  Int_t mbin = 0;
2969 
2970  // Multiplicity can be determined either by number of cluster candidates or track mulitiplicity
2971  if (((AliConversionMesonCuts *)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()) {
2973  } else {
2974  if (fNDMRecoMode < 2)
2976  else
2978  }
2979 
2982 
2983  // Get N of Pi0 according to chosen mix mode
2984  Int_t NNDMCandidates = 0;
2985  if ((((AliConversionMesonCuts *)fMesonCutArray->At(fiCut))->UseSidebandMixing()) || (((AliConversionMesonCuts *)fMesonCutArray->At(fiCut))->UseSidebandMixingBothSides())) {
2986  NNDMCandidates = fNeutralDecayParticleSidebandCandidates->GetEntries();
2987  } else {
2988  NNDMCandidates = fNeutralDecayParticleCandidates->GetEntries();
2989  }
2990  // Begin loop over all Pi0 candidates
2991  for (Int_t iCurrentNDM = 0; iCurrentNDM < NNDMCandidates; iCurrentNDM++) {
2992  AliAODConversionMother *EventNDMGoodMeson;
2993  if ((((AliConversionMesonCuts *)fMesonCutArray->At(fiCut))->UseSidebandMixing()) || (((AliConversionMesonCuts *)fMesonCutArray->At(fiCut))->UseSidebandMixingBothSides())) {
2994  EventNDMGoodMeson = (AliAODConversionMother *)(fNeutralDecayParticleSidebandCandidates->At(iCurrentNDM));
2995  } else {
2996  EventNDMGoodMeson = (AliAODConversionMother *)(fNeutralDecayParticleCandidates->At(iCurrentNDM));
2997  }
2998 
2999  if (!(((AliConversionMesonCuts *)fMesonCutArray->At(fiCut))->UseLikeSignMixing())) {
3000  // Begin loop over BG events for Pi+
3001  for (Int_t nEventsInBGPl = 0; nEventsInBGPl < fBGHandlerPiPl[fiCut]->GetNBGEvents(); nEventsInBGPl++) {
3002 
3003  // Store all Pi+ of current event in right binning in vector
3004  AliGammaConversionMotherAODVector *EventPiPlMeson = fBGHandlerPiPl[fiCut]->GetBGGoodMesons(zbin, mbin, nEventsInBGPl);
3005 
3006  // Begin loop over BG events for Pi-
3007  for (Int_t nEventsInBGMi = 0; nEventsInBGMi < fBGHandlerPiMi[fiCut]->GetNBGEvents(); nEventsInBGMi++) {
3008  AliGammaConversionMotherAODVector *EventPiMiMeson = fBGHandlerPiMi[fiCut]->GetBGGoodMesons(zbin, mbin, nEventsInBGMi);
3009 
3010  // If one of the events isn't found skip to next one
3011  if ((EventPiMiMeson && EventPiPlMeson) == kFALSE)
3012  continue;
3013 
3014  // Determine Background event vertex
3015  if (fMoveParticleAccordingToVertex == kTRUE) {
3016  bgEventVertexPl = fBGHandlerPiPl[fiCut]->GetBGEventVertex(zbin, mbin, nEventsInBGPl);
3017  bgEventVertexMi = fBGHandlerPiMi[fiCut]->GetBGEventVertex(zbin, mbin, nEventsInBGMi);
3018  }
3019  // Loop over all Pi+
3020  for (UInt_t iCurrentPiPl = 0; iCurrentPiPl < EventPiPlMeson->size(); iCurrentPiPl++) {
3021  AliAODConversionMother EventPiPlGoodMeson = (AliAODConversionMother)(*(EventPiPlMeson->at(iCurrentPiPl)));
3022 
3023  // Move Vertex
3024  if (fMoveParticleAccordingToVertex == kTRUE) {
3025  MoveParticleAccordingToVertex(&EventPiPlGoodMeson, bgEventVertexPl);
3026  }
3027 
3028  // Combine Pi+ and Pi0
3029  AliAODConversionMother PiPlNDMBackgroundCandidate(EventNDMGoodMeson, &EventPiPlGoodMeson);
3030 
3031  for (UInt_t iCurrentPiMi = 0; iCurrentPiMi < EventPiMiMeson->size(); iCurrentPiMi++) {
3032  AliAODConversionMother EventPiMiGoodMeson = (AliAODConversionMother)(*(EventPiMiMeson->at(iCurrentPiMi)));
3033 
3034  // Move Vertex
3035  if (fMoveParticleAccordingToVertex == kTRUE) {
3036  MoveParticleAccordingToVertex(&EventPiMiGoodMeson, bgEventVertexMi);
3037  }
3038 
3039  // Mass cut (pi+pi-)
3040  if (((AliPrimaryPionCuts *)fPionCutArray->At(fiCut))->DoMassCut()) {
3041  AliAODConversionMother backPiPlPiMiCandidate(&EventPiPlGoodMeson, &EventPiMiGoodMeson);
3042  if (backPiPlPiMiCandidate.M() >= ((AliPrimaryPionCuts *)fPionCutArray->At(fiCut))->GetMassCut()) {
3043  continue;
3044  }
3045  }
3046 
3047  // Create (final) Candidate
3048  AliAODConversionMother PiPlPiMiNDMBackgroundCandidate(&PiPlNDMBackgroundCandidate, &EventPiMiGoodMeson);
3049 
3050  // Check if candidate survives meson cut
3051  if (((AliConversionMesonCuts *)fMesonCutArray->At(fiCut))->MesonIsSelected(&PiPlPiMiNDMBackgroundCandidate, kFALSE, ((AliConvEventCuts *)fEventCutArray->At(fiCut))->GetEtaShift())) {
3052 
3053  // Check if candidate survives kinematic cut
3054  if (KinematicCut(&EventPiMiGoodMeson, &EventPiPlGoodMeson, EventNDMGoodMeson, &PiPlPiMiNDMBackgroundCandidate)) {
3055  // Create temporary mesons to be able to fix pz
3056  AliAODConversionMother NDMtmp;
3057  NDMtmp.SetPxPyPzE(EventNDMGoodMeson->Px(), EventNDMGoodMeson->Py(), EventNDMGoodMeson->Pz(), EventNDMGoodMeson->Energy());
3058  FixPzToMatchPDGInvMassNDM(&NDMtmp);
3059  AliAODConversionMother PiMiNDMtmp(&EventPiMiGoodMeson, &NDMtmp);
3060  AliAODConversionMother PiPlPiMiNDMtmp(&EventPiPlGoodMeson, &PiMiNDMtmp); // Must be two separate lines since second instance depends on first and execution order is not guaranteed
3061 
3062  if (nEventsInBGMi != nEventsInBGPl) {
3063  // Pi+ and Pi- don't come from the same event (but different than pi0 event)
3064  // Fill histograms
3065  fHistoBackInvMassPtGroup4[fiCut]->Fill(PiPlPiMiNDMBackgroundCandidate.M(), PiPlPiMiNDMBackgroundCandidate.Pt());
3066  fHistoBackInvMassPtGroup4SubNDM[fiCut]->Fill(PiPlPiMiNDMBackgroundCandidate.M() - (EventNDMGoodMeson->M() - fPDGMassNDM), PiPlPiMiNDMBackgroundCandidate.Pt());
3067  fHistoBackInvMassPtGroup4FixedPzNDM[fiCut]->Fill(PiPlPiMiNDMtmp.M(), PiPlPiMiNDMtmp.Pt());
3068  }
3069  else if (nEventsInBGMi == nEventsInBGPl) {
3070  // Pi+ and Pi- come from the same event (but different than pi0 event)
3071  fHistoBackInvMassPtGroup1[fiCut]->Fill(PiPlPiMiNDMBackgroundCandidate.M(), PiPlPiMiNDMBackgroundCandidate.Pt());
3072  fHistoBackInvMassPtGroup1SubNDM[fiCut]->Fill(PiPlPiMiNDMBackgroundCandidate.M() - (EventNDMGoodMeson->M() - fPDGMassNDM), PiPlPiMiNDMBackgroundCandidate.Pt());
3073  fHistoBackInvMassPtGroup1FixedPzNDM[fiCut]->Fill(PiPlPiMiNDMtmp.M(), PiPlPiMiNDMtmp.Pt());
3074  }
3075  }
3076  }
3077  } // end pi- loop
3078  } // end pi+ loop
3079  } // end loop over all pi- event
3080  } // end loop over pi+ events
3081 
3082  // Loop over all pi+ events(from Handler)
3083  for (Int_t nEventsInBGPl = 0; nEventsInBGPl < fBGHandlerPiPl[fiCut]->GetNBGEvents(); nEventsInBGPl++) {
3084  // Store all Pi+ of current event in right binning in vector
3085  AliGammaConversionMotherAODVector *EventPiPlMeson = fBGHandlerPiPl[fiCut]->GetBGGoodMesons(zbin, mbin, nEventsInBGPl);
3086 
3087  // Determine Vertex
3088  if (fMoveParticleAccordingToVertex == kTRUE) {
3089  bgEventVertexPl = fBGHandlerPiPl[fiCut]->GetBGEventVertex(zbin, mbin, nEventsInBGPl);
3090  }
3091  // Begin loop over all pi+ in ecent
3092  for (UInt_t iCurrentPiPl = 0; iCurrentPiPl < EventPiPlMeson->size(); iCurrentPiPl++) {
3093  AliAODConversionMother EventPiPlGoodMeson = (AliAODConversionMother)(*(EventPiPlMeson->at(iCurrentPiPl)));
3094 
3095  // Move vertex
3096  if (fMoveParticleAccordingToVertex == kTRUE) {
3097  MoveParticleAccordingToVertex(&EventPiPlGoodMeson, bgEventVertexPl);
3098  }
3099  // Combine Pi+ and Pi0
3100  AliAODConversionMother PiPlNDMBackgroundCandidate(EventNDMGoodMeson, &EventPiPlGoodMeson);
3101  // Loop over all pi- (from current event)
3102  for (Int_t iCurrentPiMi = 0; iCurrentPiMi < fNegPionCandidates->GetEntries(); iCurrentPiMi++) {
3103  AliAODConversionMother EventPiNegGoodMeson = *(AliAODConversionMother *)(fNegPionCandidates->At(iCurrentPiMi));
3104 
3105  // Mass cut on pi+pi-
3106  if (((AliPrimaryPionCuts *)fPionCutArray->At(fiCut))->DoMassCut()) {
3107  AliAODConversionMother backPiPlPiMiCandidate(&EventPiPlGoodMeson, &EventPiNegGoodMeson);
3108  if (backPiPlPiMiCandidate.M() >= ((AliPrimaryPionCuts *)fPionCutArray->At(fiCut))->GetMassCut()) {
3109  continue;
3110  }
3111  }
3112 
3113  // Create (final) Candidate
3114  AliAODConversionMother PiPlPiMiNDMBackgroundCandidate(&PiPlNDMBackgroundCandidate, &EventPiNegGoodMeson);
3115 
3116  // Check if candidate survives meson cut
3117  if (((AliConversionMesonCuts *)fMesonCutArray->At(fiCut))->MesonIsSelected(&PiPlPiMiNDMBackgroundCandidate, kFALSE, ((AliConvEventCuts *)fEventCutArray->At(fiCut))->GetEtaShift())) {
3118 
3119  // Check if candidate survives kinematic cut
3120  if (KinematicCut(&EventPiNegGoodMeson, &EventPiPlGoodMeson, EventNDMGoodMeson, &PiPlPiMiNDMBackgroundCandidate)) {
3121 
3122  // Create temporary mesons to be able to fix pz
3123  AliAODConversionMother NDMtmp;
3124  NDMtmp.SetPxPyPzE(EventNDMGoodMeson->Px(), EventNDMGoodMeson->Py(), EventNDMGoodMeson->Pz(), EventNDMGoodMeson->Energy());
3125  FixPzToMatchPDGInvMassNDM(&NDMtmp);
3126  AliAODConversionMother PiMiNDMtmp(&EventPiNegGoodMeson, &NDMtmp);
3127  AliAODConversionMother PiPlPiMiNDMtmp(&EventPiPlGoodMeson, &PiMiNDMtmp); // Must be two separate lines since second instance depends on first and execution order is not guaranteed
3128 
3129  // Fill histograms (pi- and pi0 from same event)
3130  fHistoBackInvMassPtGroup3[fiCut]->Fill(PiPlPiMiNDMBackgroundCandidate.M(), PiPlPiMiNDMBackgroundCandidate.Pt());
3131  fHistoBackInvMassPtGroup3SubNDM[fiCut]->Fill(PiPlPiMiNDMBackgroundCandidate.M() - (EventNDMGoodMeson->M() - fPDGMassNDM), PiPlPiMiNDMBackgroundCandidate.Pt());
3132  fHistoBackInvMassPtGroup3FixedPzNDM[fiCut]->Fill(PiPlPiMiNDMtmp.M(), PiPlPiMiNDMtmp.Pt());
3133  }
3134  }
3135  } // End loop pi- (from current event)
3136  } // End loop pi+
3137  } // end loop over pi+ events
3138 
3139  // Loop over all pi- events(from Handler)
3140  for (Int_t nEventsInBGMi = 0; nEventsInBGMi < fBGHandlerPiPl[fiCut]->GetNBGEvents(); nEventsInBGMi++) {
3141  // Store all Pi- of current event in right binning in vector
3142  AliGammaConversionMotherAODVector *EventPiMiMeson = fBGHandlerPiMi[fiCut]->GetBGGoodMesons(zbin, mbin, nEventsInBGMi);
3143 
3144  // Determine vertex
3145  if (fMoveParticleAccordingToVertex == kTRUE) {
3146  bgEventVertexMi = fBGHandlerPiMi[fiCut]->GetBGEventVertex(zbin, mbin, nEventsInBGMi);
3147  }
3148 
3149  // Begin loop over all pi- in event
3150  for (UInt_t iCurrentPiMi = 0; iCurrentPiMi < EventPiMiMeson->size(); iCurrentPiMi++) {
3151  AliAODConversionMother EventPiMiGoodMeson = (AliAODConversionMother)(*(EventPiMiMeson->at(iCurrentPiMi)));
3152 
3153  // move vertex
3154  if (fMoveParticleAccordingToVertex == kTRUE) {
3155  MoveParticleAccordingToVertex(&EventPiMiGoodMeson, bgEventVertexMi);
3156  }
3157 
3158  // Combine Pi- and Pi0
3159  AliAODConversionMother PiMiNDMBackgroundCandidate(EventNDMGoodMeson, &EventPiMiGoodMeson);
3160 
3161  // Loop over all pi+ (from current event)
3162  for (Int_t iCurrentPiPl = 0; iCurrentPiPl < fPosPionCandidates->GetEntries(); iCurrentPiPl++)
3163  {
3164  AliAODConversionMother EventPiPlGoodMeson = *(AliAODConversionMother *)(fPosPionCandidates->At(iCurrentPiPl));
3165 
3166  // Mass cut on pi+pi-
3167  if (((AliPrimaryPionCuts *)fPionCutArray->At(fiCut))->DoMassCut()) {
3168  AliAODConversionMother backPiPlPiMiCandidate(&EventPiPlGoodMeson, &EventPiMiGoodMeson);
3169  if (backPiPlPiMiCandidate.M() >= ((AliPrimaryPionCuts *)fPionCutArray->At(fiCut))->GetMassCut()) {
3170  continue;
3171  }
3172  }
3173 
3174  // Create (final) Candidate
3175  AliAODConversionMother PiPlPiMiNDMBackgroundCandidate(&PiMiNDMBackgroundCandidate, &EventPiPlGoodMeson);
3176 
3177  // Check if candidate survives meson cut
3178  if (((AliConversionMesonCuts *)fMesonCutArray->At(fiCut))->MesonIsSelected(&PiMiNDMBackgroundCandidate, kFALSE, ((AliConvEventCuts *)fEventCutArray->At(fiCut))->GetEtaShift())) {
3179 
3180  // Check if candidate survives kinematic cut
3181  if (KinematicCut(&EventPiMiGoodMeson, &EventPiPlGoodMeson, EventNDMGoodMeson, &PiPlPiMiNDMBackgroundCandidate)) {
3182 
3183  // Create temporary mesons to be able to fix pz
3184  AliAODConversionMother NDMtmp;
3185  NDMtmp.SetPxPyPzE(EventNDMGoodMeson->Px(), EventNDMGoodMeson->Py(), EventNDMGoodMeson->Pz(), EventNDMGoodMeson->Energy());
3186  FixPzToMatchPDGInvMassNDM(&NDMtmp);
3187  AliAODConversionMother PiMiNDMtmp(&EventPiMiGoodMeson, &NDMtmp);
3188  AliAODConversionMother PiPlPiMiNDMtmp(&EventPiPlGoodMeson, &PiMiNDMtmp); // Must be two separate lines since second instance depends on first and execution order is not guaranteed
3189 
3190  // Fill histograms (pi+ and pi0 from same event)
3191  fHistoBackInvMassPtGroup2[fiCut]->Fill(PiPlPiMiNDMBackgroundCandidate.M(), PiPlPiMiNDMBackgroundCandidate.Pt());
3192  fHistoBackInvMassPtGroup2SubNDM[fiCut]->Fill(PiPlPiMiNDMBackgroundCandidate.M() - (EventNDMGoodMeson->M() - fPDGMassNDM), PiPlPiMiNDMBackgroundCandidate.Pt());
3193  fHistoBackInvMassPtGroup2FixedPzNDM[fiCut]->Fill(PiPlPiMiNDMtmp.M(), PiPlPiMiNDMtmp.Pt());
3194  }
3195  }
3196  } // End loop pi+ (from current event)
3197  } // End loop pi-
3198  } // end loop over pi+ events
3199  /*
3200  * LikeSign Mixing
3201  */
3202  } else if (((AliConversionMesonCuts *)fMesonCutArray->At(fiCut))->UseLikeSignMixing()) {
3203  // Loops for Pi0Pi+Pi+ LikeSign mixing
3204  for (Int_t iCurrentPiPl = 0; iCurrentPiPl < fPosPionCandidates->GetEntries(); iCurrentPiPl++) {
3205 
3206  AliAODConversionMother EventPiPlGoodMeson = *(AliAODConversionMother *)(fPosPionCandidates->At(iCurrentPiPl));
3207 
3208  for (Int_t iCurrentPiPl2 = 0; iCurrentPiPl2 < fPosPionCandidates->GetEntries(); iCurrentPiPl2++) {
3209 
3210  if (iCurrentPiPl != iCurrentPiPl2) { // dont mix same particle
3211  AliAODConversionMother EventPiPlGoodMeson2 = *(AliAODConversionMother *)(fPosPionCandidates->At(iCurrentPiPl2));
3212 
3213  // Combine Pi+ and Pi0
3214  AliAODConversionMother PiPlNDMBackgroundCandidate(&EventPiPlGoodMeson, EventNDMGoodMeson);
3215 
3216  // Mass cut on pi+pi+
3217  if (((AliPrimaryPionCuts *)fPionCutArray->At(fiCut))->DoMassCut()) {
3218  AliAODConversionMother backPiPlPiPlCandidate(&EventPiPlGoodMeson, &EventPiPlGoodMeson2);
3219  if (backPiPlPiPlCandidate.M() >= ((AliPrimaryPionCuts *)fPionCutArray->At(fiCut))->GetMassCut()) {
3220  continue;
3221  }
3222  }
3223 
3224  // Create (final) Candidate
3225  AliAODConversionMother PiPlPiPlNDMBackgroundCandidate(&PiPlNDMBackgroundCandidate, &EventPiPlGoodMeson2);
3226 
3227  // Check if candidate survives meson cut
3228  if (((AliConversionMesonCuts *)fMesonCutArray->At(fiCut))->MesonIsSelected(&PiPlNDMBackgroundCandidate, kFALSE, ((AliConvEventCuts *)fEventCutArray->At(fiCut))->GetEtaShift())) {
3229 
3230  // Check if candidate survives kinematic cut
3231  if (KinematicCut(&EventPiPlGoodMeson, &EventPiPlGoodMeson2, EventNDMGoodMeson, &PiPlPiPlNDMBackgroundCandidate)) {
3232 
3233  // Create temporary mesons to be able to fix pz
3234  AliAODConversionMother NDMtmp;
3235  NDMtmp.SetPxPyPzE(EventNDMGoodMeson->Px(), EventNDMGoodMeson->Py(), EventNDMGoodMeson->Pz(), EventNDMGoodMeson->Energy());
3236  FixPzToMatchPDGInvMassNDM(&NDMtmp);
3237  AliAODConversionMother PiPlNDMtmp(&EventPiPlGoodMeson, &NDMtmp);
3238  AliAODConversionMother PiPlPiPlNDMtmp(&EventPiPlGoodMeson2, &PiPlNDMtmp); // Must be two separate lines since second instance depends on first and execution order is not guaranteed
3239 
3240  // Fill histograms (likesign)
3241  fHistoMotherLikeSignBackInvMassPt[fiCut]->Fill(PiPlPiPlNDMBackgroundCandidate.M(), PiPlPiPlNDMBackgroundCandidate.Pt());
3242  fHistoMotherLikeSignBackInvMassSubNDMPt[fiCut]->Fill(PiPlPiPlNDMBackgroundCandidate.M() - (EventNDMGoodMeson->M() - fPDGMassNDM), PiPlPiPlNDMBackgroundCandidate.Pt());
3243  fHistoMotherLikeSignBackInvMassFixedPzNDMPt[fiCut]->Fill(PiPlPiPlNDMtmp.M(), PiPlPiPlNDMtmp.Pt());
3244  }
3245  }
3246  }
3247  } // end of iCurrentPiPl2
3248  } // end of iCurrenPiPl
3249 
3250  // Loops for Pi0Pi-Pi- LikeSign mixing
3251  for (Int_t iCurrentPiMi = 0; iCurrentPiMi < fNegPionCandidates->GetEntries(); iCurrentPiMi++) {
3252 
3253  AliAODConversionMother EventPiMiGoodMeson = *(AliAODConversionMother *)(fNegPionCandidates->At(iCurrentPiMi));
3254 
3255  for (Int_t iCurrentPiMi2 = 0; iCurrentPiMi2 < fNegPionCandidates->GetEntries(); iCurrentPiMi2++){
3256 
3257  if (iCurrentPiMi != iCurrentPiMi2) { // dont mix same particle
3258  AliAODConversionMother EventPiMiGoodMeson2 = *(AliAODConversionMother *)(fNegPionCandidates->At(iCurrentPiMi2));
3259 
3260  // Combine Pi- and Pi0
3261  AliAODConversionMother PiMiNDMBackgroundCandidate(&EventPiMiGoodMeson, EventNDMGoodMeson);
3262 
3263  // Mass cut on pi-pi-
3264  if (((AliPrimaryPionCuts *)fPionCutArray->At(fiCut))->DoMassCut()) {
3265  AliAODConversionMother backPiMiPiMiCandidate(&EventPiMiGoodMeson, &EventPiMiGoodMeson2);
3266  if (backPiMiPiMiCandidate.M() >= ((AliPrimaryPionCuts *)fPionCutArray->At(fiCut))->GetMassCut()) {
3267  continue;
3268  }
3269  }
3270 
3271  // Create (final) Candidate
3272  AliAODConversionMother PiMiPiMiNDMBackgroundCandidate(&PiMiNDMBackgroundCandidate, &EventPiMiGoodMeson2);
3273 
3274  // Check if candidate survives meson cut
3275  if (((AliConversionMesonCuts *)fMesonCutArray->At(fiCut))->MesonIsSelected(&PiMiNDMBackgroundCandidate, kFALSE, ((AliConvEventCuts *)fEventCutArray->At(fiCut))->GetEtaShift())) {
3276 
3277  // Check if candidate survives kinematic cut
3278  if (KinematicCut(&EventPiMiGoodMeson, &EventPiMiGoodMeson2, EventNDMGoodMeson, &PiMiPiMiNDMBackgroundCandidate)) {
3279 
3280  // Create temporary mesons to be able to fix pz
3281  AliAODConversionMother NDMtmp;
3282  NDMtmp.SetPxPyPzE(EventNDMGoodMeson->Px(), EventNDMGoodMeson->Py(), EventNDMGoodMeson->Pz(), EventNDMGoodMeson->Energy());
3283  FixPzToMatchPDGInvMassNDM(&NDMtmp);
3284  AliAODConversionMother PiMiNDMtmp(&EventPiMiGoodMeson, &NDMtmp);
3285  AliAODConversionMother PiMiPiMiNDMtmp(&EventPiMiGoodMeson2, &PiMiNDMtmp); // Must be two separate lines since second instance depends on first and execution order is not guaranteed
3286 
3287  // Fill histograms (likesign)
3288  fHistoMotherLikeSignBackInvMassPt[fiCut]->Fill(PiMiPiMiNDMBackgroundCandidate.M(), PiMiPiMiNDMBackgroundCandidate.Pt());
3289  fHistoMotherLikeSignBackInvMassSubNDMPt[fiCut]->Fill(PiMiPiMiNDMBackgroundCandidate.M() - (EventNDMGoodMeson->M() - fPDGMassNDM), PiMiPiMiNDMBackgroundCandidate.Pt());
3290  fHistoMotherLikeSignBackInvMassFixedPzNDMPt[fiCut]->Fill(PiMiPiMiNDMtmp.M(), PiMiPiMiNDMtmp.Pt());
3291  }
3292  }
3293  }
3294  } // end of iCurrentPiMi2
3295  } // end of iCurrenPiMi
3296  } // end of LikeSign if
3297  } //end loop pi0 candidates
3298 }
3299 
3300 //______________________________________________________________________
3302 
3303  if(fTolerance == -1) return kTRUE;
3304  if((omega->Pt())<=5.){
3305  if( (omega->Angle(pospion->Vect())) < ((2.78715*(TMath::Exp(-0.589934*(omega->Pt()))+0.0519574))*fTolerance) &&
3306  (omega->Angle(negpion->Vect())) < ((5.94216*(TMath::Exp(-0.444428*(omega->Pt()))-0.0574076))*fTolerance) &&
3307  (omega->Angle(neutpion->Vect())) < ((2.79529*(TMath::Exp(-0.565999*(omega->Pt()))+0.0413576))*fTolerance) &&
3308  (pospion->Angle(negpion->Vect())) < ((3.14446*(TMath::Exp(-0.666433*(omega->Pt()))+0.0964309))*fTolerance) &&
3309  (pospion->Angle(neutpion->Vect())) < ((3.08241*(TMath::Exp(-0.650657*(omega->Pt()))+0.0997539))*fTolerance) &&
3310  (negpion->Angle(neutpion->Vect())) < ((3.18536*(TMath::Exp(-0.752847*(omega->Pt()))+0.1262780))*fTolerance)
3311  ){
3312  return kTRUE;
3313  }
3314  }else{
3315  if( (omega->Angle(pospion->Vect())) < ((0.459270*(TMath::Exp(-0.126007*(omega->Pt()))+0.100475))*fTolerance) &&
3316  (omega->Angle(negpion->Vect())) < ((0.521250*(TMath::Exp(-0.152532*(omega->Pt()))+0.114617))*fTolerance) &&
3317  (omega->Angle(neutpion->Vect())) < ((0.409766*(TMath::Exp(-0.108566*(omega->Pt()))+0.103594))*fTolerance) &&
3318  (pospion->Angle(negpion->Vect())) < ((0.709206*(TMath::Exp(-0.149072*(omega->Pt()))+0.111345))*fTolerance) &&
3319  (pospion->Angle(neutpion->Vect())) < ((0.662184*(TMath::Exp(-0.123397*(omega->Pt()))+0.104675))*fTolerance) &&
3320  (negpion->Angle(neutpion->Vect())) < ((0.730228*(TMath::Exp(-0.120859*(omega->Pt()))+0.105522))*fTolerance)
3321  ){
3322  return kTRUE;
3323  }
3324  }
3325  return kFALSE;
3326 }
3327 
3328 
3329 //______________________________________________________________________
3331 {
3332 
3333  // Process True Mesons
3334 
3335  Bool_t isSameMotherPiPlPiMiNDM = kFALSE; // pi+ pi- and pi0 have the same mother
3336  Bool_t isSameMotherPiPlPiMi = kFALSE; // pi+ and pi- have the same mother
3337  Bool_t isSameMotherPiPlNDM = kFALSE; // pi+ and pi0 have the same mother
3338  Bool_t isSameMotherPiMiNDM = kFALSE; // pi- and pi0 have the same mother
3339  Bool_t isNoSameMother = kFALSE; // none of the pions have the same mother
3340  Bool_t isNoPiPiPi = kFALSE; // the decay is not a 3 pion decay
3341 
3342 
3343  Int_t virtualParticleMCLabel = TrueVirtualParticleCandidate->GetMCParticleLabel(fMCEvent);
3344  Int_t virtualParticleMotherLabel = -1;
3345  Int_t trueMesonFlag = TrueNeutralDecayMesonCandidate->GetTrueMesonValue();
3346  Int_t NDMMCLabel = TrueNeutralDecayMesonCandidate->GetMCLabel();
3347 
3348  Float_t weighted= 1;
3349 
3350  if ( !(trueMesonFlag == 1 && NDMMCLabel != -1)){
3351  if((fDoMesonQA>0 ) && (!fDoLightOutput)){
3352  fHistoTruePiPlPiMiNDMContaminationInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3353  }
3354  return;
3355  }
3356  Int_t NDMMotherLabel = fMCEvent->Particle(NDMMCLabel)->GetMother(0);
3357 
3358  TParticle * negativeMC = (TParticle*)TrueVirtualParticleCandidate->GetNegativeMCDaughter(fMCEvent);
3359  TParticle * positiveMC = (TParticle*)TrueVirtualParticleCandidate->GetPositiveMCDaughter(fMCEvent);
3360 
3361  Int_t posMotherLabelMC = positiveMC->GetMother(0);
3362  Int_t negMotherLabelMC = negativeMC->GetMother(0);
3363 
3364  // Check case present
3365  if((TMath::Abs(negativeMC->GetPdgCode())==211) && (TMath::Abs(positiveMC->GetPdgCode())==211) && (fMCEvent->Particle(NDMMCLabel)->GetPdgCode()==fPDGCodeNDM)){
3366  // three pion decay
3367  if(virtualParticleMCLabel!=-1){
3368  // pi+ pi- have same mother
3369  virtualParticleMotherLabel = virtualParticleMCLabel;
3370  if(virtualParticleMotherLabel==NDMMotherLabel){
3371  // all pions from same mother
3372  if(fMCEvent->Particle(NDMMotherLabel)->GetStatusCode()!=21) isSameMotherPiPlPiMiNDM = kTRUE;
3373  } else{
3374  // only pi+ pi- from same mother
3375  if(fMCEvent->Particle(virtualParticleMotherLabel)->GetStatusCode()!=21) isSameMotherPiPlPiMi = kTRUE;
3376  }
3377  } else{
3378  if(NDMMotherLabel==negMotherLabelMC && negMotherLabelMC != -1){
3379  // pi0 and pi- same mother
3380  if(fMCEvent->Particle(negMotherLabelMC)->GetStatusCode()!=21) isSameMotherPiMiNDM = kTRUE;
3381  } else if(NDMMotherLabel==posMotherLabelMC && posMotherLabelMC != -1){
3382  // pi0 and pi+ same mother
3383  if(fMCEvent->Particle(posMotherLabelMC)->GetStatusCode()!=21) isSameMotherPiPlNDM = kTRUE;
3384  } else{
3385  // all pions different mother
3386  isNoSameMother = kTRUE;
3387  }
3388  }
3389  } else{
3390  // not a three pion decay
3391  isNoPiPiPi = kTRUE;
3392  }
3393 
3394  // Do things for each case
3395  if(isSameMotherPiPlPiMiNDM){
3396  if(fMCEvent->Particle(NDMMotherLabel)->GetPdgCode() == fPDGCodeAnalyzedMeson){
3397  // eta was found
3398  fHistoTrueMotherPiPlPiMiNDMInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3399  fHistoTrueMotherHNMPiPlPiMiNDMInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3400  AliAODConversionMother PosPiontmp, NegPiontmp;
3401  PosPiontmp.SetPxPyPzE(positiveMC->Px(), positiveMC->Py(), positiveMC->Pz(), positiveMC->Energy());
3402  NegPiontmp.SetPxPyPzE(negativeMC->Px(), negativeMC->Py(), negativeMC->Pz(), negativeMC->Energy());
3403  if(!fDoLightOutput) fHistoTrueAngleSum[fiCut]->Fill(mesoncand->Pt(),((PosPiontmp.Angle(mesoncand->Vect()))+(NegPiontmp.Angle(PosPiontmp.Vect()))+(PosPiontmp.Angle(TrueNeutralDecayMesonCandidate->Vect()))));
3404 
3405  // Fill tree to get info about event that the eta was found in
3406  if(fDoMesonQA>1 && (!fDoLightOutput)){
3407  fV0MultiplicityHNMEvent = fMCEvent->GetNumberOfV0s();
3408  fTrackMultiplicityHNMEvent = fMCEvent->GetNumberOfTracks();
3409  fZVertexHNMEvent = fMCEvent->GetPrimaryVertex()->GetZ();
3410  fPtHNM = mesoncand->Pt();
3411 
3412  fTreeEventInfoHNM[fiCut]->Fill();
3413  }
3414  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueHNMs,NDMMotherLabel) && (!fDoLightOutput)) fHistoDoubleCountTrueHNMInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt());
3415  } else{
3416  if(fDoMesonQA>1 && (!fDoLightOutput)){
3417  // Write "unknown" mother to TTree
3418  fSamePiPiPiMotherID = fMCEvent->Particle(posMotherLabelMC)->GetPdgCode();
3419  fSamePiPiPiMotherInvMass = mesoncand->M();
3420  fSamePiPiPiMotherPt = mesoncand->Pt();
3421 
3422  fTreePiPiPiSameMother[fiCut]->Fill();
3423  }
3424  }
3425  } else if(isSameMotherPiPlPiMi && (fDoMesonQA>0 ) && (!fDoLightOutput)){
3426  if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 221){
3427  // pi+pi- come from eta
3428  fHistoTruePiPlPiMiSameMotherFromEtaInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3429  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 223){
3430  // pi+pi- come from omega
3431  fHistoTruePiPlPiMiSameMotherFromOmegaInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3432  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 113){
3433  // pi+pi- come from rho0
3434  fHistoTruePiPlPiMiSameMotherFromRhoInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3435  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 331){
3436  // pi+pi- come from eta prime
3437  fHistoTruePiPlPiMiSameMotherFromEtaPrimeInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3438  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 310){
3439  // pi+pi- come from K0 short
3440  fHistoTruePiPlPiMiSameMotherFromK0sInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3441  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 130){
3442  // pi+pi- come from K0 short
3443  fHistoTruePiPlPiMiSameMotherFromK0lInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3444  } else{
3445  // pi+pi- come from something else
3446  if(fDoMesonQA>1 && (!fDoLightOutput)){
3447  fCasePiPi = 0;
3448  // Write "unknown" mother to TTree
3449  fSamePiPiMotherID = fMCEvent->Particle(posMotherLabelMC)->GetPdgCode();
3450  fSamePiPiMotherInvMass = mesoncand->M();
3451  fSamePiPiMotherPt = mesoncand->Pt();
3452 
3453  fTreePiPiSameMother[fiCut]->Fill();
3454  }
3455  }
3456  } else if(isSameMotherPiMiNDM && (fDoMesonQA>0 ) && (!fDoLightOutput)){
3457  if(fMCEvent->Particle(NDMMotherLabel)->GetPdgCode() == 221){
3458  // pi0pi- come from eta
3459  fHistoTruePiMiPiZeroSameMotherFromEtaInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3460  } else if(fMCEvent->Particle(NDMMotherLabel)->GetPdgCode() == 223){
3461  // pi0pi- come from omega
3462  fHistoTruePiMiPiZeroSameMotherFromOmegaInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3463  } else if(fMCEvent->Particle(NDMMotherLabel)->GetPdgCode() ==-213){
3464  // pi0pi- come from rho-
3465  fHistoTruePiMiPiZeroSameMotherFromRhoInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3466  } else if(fMCEvent->Particle(NDMMotherLabel)->GetPdgCode() == 130){
3467  // pi0pi- come from rho-
3468  fHistoTruePiMiPiZeroSameMotherFromK0lInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3469  } else{
3470  // pi0pi- come from something else
3471  if(fDoMesonQA>1){
3472  fCasePiPi = 1;
3473  // Write "unknown" mother to TTree
3474  fSamePiPiMotherID = fMCEvent->Particle(NDMMotherLabel)->GetPdgCode();
3475  fSamePiPiMotherInvMass = mesoncand->M();
3476  fSamePiPiMotherPt = mesoncand->Pt();
3477 
3478  fTreePiPiSameMother[fiCut]->Fill();
3479  }
3480  }
3481  } else if(isSameMotherPiPlNDM && (fDoMesonQA>0 ) && (!fDoLightOutput)){
3482  if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 221){
3483  // pi+pi0 come from eta
3484  fHistoTruePiPlPiZeroSameMotherFromEtaInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3485  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 223){
3486  // pi+pi0 come from omega
3487  fHistoTruePiPlPiZeroSameMotherFromOmegaInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3488  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 213) {
3489  // pi+pi0 come from rho+
3490  fHistoTruePiPlPiZeroSameMotherFromRhoInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3491  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 130) {
3492  // pi+pi0 come from rho+
3493  fHistoTruePiPlPiZeroSameMotherFromK0lInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3494  } else{
3495  // pi+pi0 come from something else
3496  if(fDoMesonQA>1){
3497  fCasePiPi = 2;
3498  // Write "unknown" mother to TTree
3499  fSamePiPiMotherID = fMCEvent->Particle(NDMMotherLabel)->GetPdgCode();
3500  fSamePiPiMotherInvMass = mesoncand->M();
3501  fSamePiPiMotherPt = mesoncand->Pt();
3502 
3503  fTreePiPiSameMother[fiCut]->Fill();
3504  }
3505  }
3506  } else if(isNoSameMother && (fDoMesonQA>0 ) && (!fDoLightOutput)){
3507  // no same mother purecombinatorical
3508  fHistoTruePiPlPiMiNDMPureCombinatoricalInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3509  } else if(isNoPiPiPi && (fDoMesonQA>0 ) && (!fDoLightOutput)){
3510  // no pi pi pi decay contamination
3511  fHistoTruePiPlPiMiNDMContaminationInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3512  // investigate here what was missmatched (?)
3513 
3514  }
3515 }
3516 
3517 
3518 //________________________________________________________________________
3520  //see header file for documentation
3521 
3522  Int_t method = 1;
3523  if( method == 1 ) {
3524  if(fPosPionCandidates->GetEntries() >0 && fNegPionCandidates->GetEntries() >0){
3525  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3526  fBGHandlerPiPl[fiCut]->AddMesonEvent(fPosPionCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),0);
3527  fBGHandlerPiMi[fiCut]->AddMesonEvent(fNegPionCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),0);
3528  } else { // means we use #V0s for multiplicity
3529  if (fNDMRecoMode < 2){
3530  fBGHandlerPiPl[fiCut]->AddMesonEvent(fPosPionCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGoodConvGammas->GetEntries(),0);
3531  fBGHandlerPiMi[fiCut]->AddMesonEvent(fNegPionCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGoodConvGammas->GetEntries(),0);
3532  }else {
3533  fBGHandlerPiPl[fiCut]->AddMesonEvent(fPosPionCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fClusterCandidates->GetEntries(),0);
3534  fBGHandlerPiMi[fiCut]->AddMesonEvent(fNegPionCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fClusterCandidates->GetEntries(),0);
3535  }
3536  }
3537  }
3538  }
3539 }
3540 
3541 //________________________________________________________________________
3543  //see header file for documentation
3544 
3545  Double_t dx = vertex->fX - fInputEvent->GetPrimaryVertex()->GetX();
3546  Double_t dy = vertex->fY - fInputEvent->GetPrimaryVertex()->GetY();
3547  Double_t dz = vertex->fZ - fInputEvent->GetPrimaryVertex()->GetZ();
3548 
3549  Double_t movedPlace[3] = {particle->GetProductionX() - dx,particle->GetProductionY() - dy,particle->GetProductionZ() - dz};
3550  particle->SetProductionPoint(movedPlace);
3551 }
3552 
3553 //________________________________________________________________________
3555 
3556  Double_t px = particle->Px();
3557  Double_t py = particle->Py();
3558  Int_t signPz = particle->Pz()<0?-1:1;
3559  Double_t energy = particle->Energy();
3560  Double_t pz = signPz*TMath::Sqrt(TMath::Abs(pow(fPDGMassNDM,2)-pow(energy,2)+pow(px,2)+pow(py,2)));
3561  particle->SetPxPyPzE(px,py,pz,energy);
3562 
3563  return;
3564 }
3565 
3566 //_____________________________________________________________________________________
3568  //
3569  // Returns true if the particle comes from eta -> pi+ pi- gamma
3570  //
3571  if(label<0) return kFALSE;
3572  Int_t motherLabel = fMCEvent->Particle( label )->GetMother(0);
3573  if( motherLabel < 0 || motherLabel >= fMCEvent->GetNumberOfTracks() ) return kFALSE;
3574 
3575  TParticle* mother = fMCEvent->Particle( motherLabel );
3576  if( mother->GetPdgCode() != 331 ) return kFALSE;
3577  if( IsPiPlPiMiEtaDecay( mother ) ) return kTRUE;
3578  return kFALSE;
3579 }
3580 //_____________________________________________________________________________________
3582  //
3583  // Returns true if the particle comes from eta -> pi+ pi- gamma
3584  //
3585  if(label<0) return kFALSE;
3586  Int_t motherLabel = fMCEvent->Particle( label )->GetMother(0);
3587  if( motherLabel < 0 || motherLabel >= fMCEvent->GetNumberOfTracks() ) return kFALSE;
3588 
3589  TParticle* mother = fMCEvent->Particle( motherLabel );
3590  if( mother->GetPdgCode() != 221 ) return kFALSE;
3591  if( IsPiPlPiMiPiZeroDecay( mother ) ) return kTRUE;
3592  return kFALSE;
3593 }
3594 
3595 //_____________________________________________________________________________________
3597  //
3598  // Returns true if the particle comes from eta -> pi+ pi- gamma
3599  //
3600  if(label<0) return kFALSE;
3601  Int_t motherLabel = fMCEvent->Particle( label )->GetMother(0);
3602  if( motherLabel < 0 || motherLabel >= fMCEvent->GetNumberOfTracks() ) return kFALSE;
3603 
3604  TParticle* mother = fMCEvent->Particle( motherLabel );
3605  if( mother->GetPdgCode() != 223 ) return kFALSE;
3606  if( IsPiPlPiMiPiZeroDecay( mother ) ) return kTRUE;
3607  return kFALSE;
3608 }
3609 
3610 //_____________________________________________________________________________________
3612  //
3613  // Returns true if the particle comes from eta -> pi+ pi- gamma
3614  //
3615  if(label<0) return kFALSE;
3616  Int_t motherLabel = fMCEvent->Particle( label )->GetMother(0);
3617  if( motherLabel < 0 || motherLabel >= fMCEvent->GetNumberOfTracks() ) return kFALSE;
3618 
3619  TParticle* mother = fMCEvent->Particle( motherLabel );
3620  if( mother->GetPdgCode() != 421 ) return kFALSE;
3621  if( IsPiPlPiMiPiZeroDecay( mother ) ) return kTRUE;
3622  return kFALSE;
3623 }
3624 
3625 
3626 //_____________________________________________________________________________
3628 {
3629  if( fMCMother->GetNDaughters() != 3 ) return kFALSE;
3630  if( !(fMCMother->GetPdgCode() == 221 || fMCMother->GetPdgCode() == 223 || fMCMother->GetPdgCode() == 421) ) return kFALSE;
3631 
3632  TParticle *posPion = 0x0;
3633  TParticle *negPion = 0x0;
3634  TParticle *neutPion = 0x0;
3635 
3636  for(Int_t index= fMCMother->GetFirstDaughter();index<= fMCMother->GetLastDaughter();index++){
3637  if(index<0) continue;
3638  TParticle* temp = (TParticle*)fMCEvent->Particle( index );
3639 
3640  switch( temp->GetPdgCode() ) {
3641  case 211:
3642  posPion = temp;
3643  break;
3644  case -211:
3645  negPion = temp;
3646  break;
3647  case 111:
3648  neutPion = temp;
3649  break;
3650  }
3651  }
3652  if( posPion && negPion && neutPion) return kTRUE;
3653 
3654  return kFALSE;
3655 }
3656 
3657 //_____________________________________________________________________________
3659 {
3660  if( fMCMother->GetNDaughters() != 3 ) return kFALSE;
3661  if( !(fMCMother->GetPdgCode() == 331) ) return kFALSE;
3662 
3663  TParticle *posPion = 0x0;
3664  TParticle *negPion = 0x0;
3665  TParticle *etaMeson = 0x0;
3666 
3667  for(Int_t index= fMCMother->GetFirstDaughter();index<= fMCMother->GetLastDaughter();index++){
3668  if(index<0) continue;
3669  TParticle* temp = (TParticle*)fMCEvent->Particle( index );
3670 
3671  switch( temp->GetPdgCode() ) {
3672  case 211:
3673  posPion = temp;
3674  break;
3675  case -211:
3676  negPion = temp;
3677  break;
3678  case 221:
3679  etaMeson = temp;
3680  break;
3681  }
3682  }
3683  if( posPion && negPion && etaMeson) return kTRUE;
3684 
3685  return kFALSE;
3686 }
3687 
3688 //_____________________________________________________________________________________
3690  //
3691  // Returns true if the particle comes from eta -> pi+ pi- gamma
3692  //
3693  if(label<0) return kFALSE;
3694  Int_t motherLabel = fMCEvent->Particle( label )->GetMother(0);
3695  if( motherLabel < 0 || motherLabel >= fMCEvent->GetNumberOfTracks() ) return kFALSE;
3696 
3697  TParticle* mother = fMCEvent->Particle( motherLabel );
3698  if( mother->GetPdgCode() != fPDGCodeNDM ) return kFALSE;
3699  Int_t grandMotherLabel = mother->GetMother(0);
3700  if( grandMotherLabel < 0 || grandMotherLabel >= fMCEvent->GetNumberOfTracks() ) return kFALSE;
3701  TParticle* grandmother = fMCEvent->Particle( grandMotherLabel );
3702 
3703  switch( fSelectedHeavyNeutralMeson ) {
3704  case 0: // ETA MESON
3705  case 1: // OMEGA MESON
3706  if( IsPiPlPiMiPiZeroDecay( grandmother ) ) return kTRUE;
3707  break;
3708  case 2: // ETA PRIME MESON
3709  if( IsPiPlPiMiEtaDecay( grandmother ) ) return kTRUE;
3710  break;
3711  case 3: // D0 MESON
3712  if( IsPiPlPiMiPiZeroDecay(grandmother) ) return kTRUE;
3713  break;
3714  default:
3715  AliError(Form("Heavy neutral meson not correctly selected (only 0,1,2,3 valid)... selected: %d",fSelectedHeavyNeutralMeson));
3716  }
3717 
3718  return kFALSE;
3719 }
3720 
3721 //_________________________________________________________________________________
3723 {
3724  if(tobechecked > -1)
3725  {
3726  vector<Int_t>::iterator it;
3727  it = find (vec.begin(), vec.end(), tobechecked);
3728  if (it != vec.end()) return true;
3729  else{
3730  vec.push_back(tobechecked);
3731  return false;
3732  }
3733  }
3734  return false;
3735 }
3736 
3737 
TParticle * GetMCParticle(AliMCEvent *mcEvent)
Bool_t KinematicCut(AliAODConversionMother *negpion, AliAODConversionMother *pospion, AliAODConversionMother *neutpion, AliAODConversionMother *omega)
vector< Int_t > GetReconstructedPosPionIndex()
void ProcessTrueMesonCandidates(AliAODConversionMother *Pi0Candidate, AliAODConversionMother *TrueNeutralPionCandidate, AliAODConversionPhoton *TrueVirtualGammaCandidate)
void SetCaloClusterRef(Long_t ref)
void SetLabels(Int_t label1, Int_t label2, Int_t label3=0)
double Double_t
Definition: External.C:58
GammaConversionVertex * GetBGEventVertex(Int_t zbin, Int_t mbin, Int_t event)
Definition: External.C:236
void MoveParticleAccordingToVertex(AliAODConversionMother *particle, const AliGammaConversionAODBGHandler::GammaConversionVertex *vertex)
void SetCaloPhotonMCFlags(AliMCEvent *mcEvent, Bool_t enableSort)
Int_t GetNumberOfPrimaryTracks()
energy
Definition: HFPtSpectrum.C:44
void AddMesonEvent(TList *const eventMothers, Double_t xvalue, Double_t yvalue, Double_t zvalue, Int_t multiplicity, Double_t epvalue=-100)
void SetProductionPoint(Double_t *point)
void SetTrueMesonValue(Int_t trueMeson)
TString GetPeriodName()
TParticle * GetPositiveMCDaughter(AliMCEvent *mcEvent)
void SetCaloPhotonMCLabel(Int_t i, Int_t labelCaloPhoton)
void ProcessTrueNeutralPionCandidatesPureCalo(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1)
TParticle * GetNegativeMCDaughter(AliMCEvent *mcEvent)
TH2F ** fHistoDoubleCountTrueHNMInvMassPt
array of histos with double counted pi0s, invMass, pT
int Int_t
Definition: External.C:63
Class handling all kinds of selection cuts for Gamma Calo analysis.
Definition: External.C:204
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
std::vector< AliAODConversionMother * > AliGammaConversionMotherAODVector
Int_t method
void ProcessTrueNeutralPionCandidatesPureConversionsAOD(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1)
Definition: