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