AliPhysics  764b6ea (764b6ea)
AliAnalysisTaskNeutralMesonToPiPlPiMiPiZero.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  fNeutralPionCandidates(NULL),
78  fNeutralPionSidebandCandidates(NULL),
79  fPosPionCandidates(NULL),
80  fNegPionCandidates(NULL),
81  fGoodVirtualParticles(NULL),
82  fEventCutArray(NULL),
83  fGammaCutArray(NULL),
84  fClusterCutArray(NULL),
85  fPionCutArray(NULL),
86  fNeutralPionMesonCutArray(NULL),
87  fMesonCutArray(NULL),
88  fEventCuts(NULL),
89  fConversionCuts(NULL),
90  fClusterCuts(NULL),
91  fTreePiPiSameMother(NULL),
92  fTreePiPiPiSameMother(NULL),
93  fCasePiPi(-1),
94  fSamePiPiMotherID(-1),
95  fSamePiPiMotherInvMass(-1),
96  fSamePiPiMotherPt(-1),
97  fSamePiPiPiMotherID(-1),
98  fSamePiPiPiMotherInvMass(-1),
99  fSamePiPiPiMotherPt(-1),
100  fHistoConvGammaPt(NULL),
101  fHistoConvGammaEta(NULL),
102  fHistoClusterGammaPt(NULL),
103  fHistoClusterGammaEta(NULL),
104  fHistoNegPionPt(NULL),
105  fHistoPosPionPt(NULL),
106  fHistoNegPionPhi(NULL),
107  fHistoPosPionPhi(NULL),
108  fHistoNegPionEta(NULL),
109  fHistoPosPionEta(NULL),
110  fHistoNegPionClsTPC(NULL),
111  fHistoPosPionClsTPC(NULL),
112  fHistoPionDCAxy(NULL),
113  fHistoPionDCAz(NULL),
114  fHistoPionTPCdEdxNSigma(NULL),
115  fHistoPionTPCdEdx(NULL),
116  fHistoPionPionInvMassPt(NULL),
117  fHistoGammaGammaInvMassPt(NULL),
118  fHistoMotherInvMassPt(NULL),
119  fHistoMotherInvMassPtRejectedKinematic(NULL),
120  fHistoBackInvMassPtGroup1(NULL),
121  fHistoBackInvMassPtGroup2(NULL),
122  fHistoBackInvMassPtGroup3(NULL),
123  fHistoBackInvMassPtGroup4(NULL),
124  fHistoMotherLikeSignBackInvMassPt(NULL),
125  fHistoAngleOmegaPiPlPiMi(NULL),
126  fHistoAngleOmegaPiZero(NULL),
127  fHistoAngleOmegaPiPl(NULL),
128  fHistoAngleOmegaPiMi(NULL),
129  fHistoAnglePiPlPiMi(NULL),
130  fHistoAnglePiZeroPiMi(NULL),
131  fHistoAnglePiPlPiZero(NULL),
132  fHistoAngleSum(NULL),
133  fHistoTrueAngleSum(NULL),
134  fHistoMotherInvMassSubPi0(NULL),
135  fHistoBackInvMassPtGroup1SubPi0(NULL),
136  fHistoBackInvMassPtGroup2SubPi0(NULL),
137  fHistoBackInvMassPtGroup3SubPi0(NULL),
138  fHistoBackInvMassPtGroup4SubPi0(NULL),
139  fHistoMotherLikeSignBackInvMassSubPi0Pt(NULL),
140  fHistoMotherInvMassFixedPzPi0(NULL),
141  fHistoBackInvMassPtGroup1FixedPzPi0(NULL),
142  fHistoBackInvMassPtGroup2FixedPzPi0(NULL),
143  fHistoBackInvMassPtGroup3FixedPzPi0(NULL),
144  fHistoBackInvMassPtGroup4FixedPzPi0(NULL),
145  fHistoMotherLikeSignBackInvMassFixedPzPi0Pt(NULL),
146  fHistoMCAllGammaPt(NULL),
147  fHistoMCConvGammaPt(NULL),
148  fHistoMCAllPosPionsPt(NULL),
149  fHistoMCAllNegPionsPt(NULL),
150  fHistoMCGammaFromNeutralMesonPt(NULL),
151  fHistoMCPosPionsFromNeutralMesonPt(NULL),
152  fHistoMCNegPionsFromNeutralMesonPt(NULL),
153  fHistoMCEtaPiPlPiMiPiZeroPt(NULL),
154  fHistoMCEtaPiPlPiMiPiZeroInAccPt(NULL),
155  fHistoMCOmegaPiPlPiMiPiZeroPt(NULL),
156  fHistoMCOmegaPiPlPiMiPiZeroInAccPt(NULL),
157  fHistoTrueMotherPiPlPiMiPiZeroInvMassPt(NULL),
158  fHistoTrueMotherOmegaPiPlPiMiPiZeroInvMassPt(NULL),
159  fHistoTrueMotherEtaPiPlPiMiPiZeroInvMassPt(NULL),
160  fHistoTrueMotherGammaGammaInvMassPt(NULL),
161  fHistoTrueMotherGammaGammaFromEtaInvMassPt(NULL),
162  fHistoTrueMotherGammaGammaFromOmegaInvMassPt(NULL),
163  fHistoTrueConvGammaPt(NULL),
164  fHistoTrueConvGammaFromNeutralMesonPt(NULL),
165  fHistoTrueClusterGammaPt(NULL),
166  fHistoTrueClusterGammaFromNeutralMesonPt(NULL),
167  fHistoTruePosPionPt(NULL),
168  fHistoTruePosPionFromNeutralMesonPt(NULL),
169  fHistoTrueNegPionPt(NULL),
170  fHistoTrueNegPionFromNeutralMesonPt(NULL),
171  fHistoTruePionPionInvMassPt(NULL),
172  fHistoTruePionPionFromSameMotherInvMassPt(NULL),
173  fHistoTruePionPionFromEtaInvMassPt(NULL),
174  fHistoTruePionPionFromOmegaInvMassPt(NULL),
175  fHistoTruePiPlPiMiSameMotherFromEtaInvMassPt(NULL),
176  fHistoTruePiPlPiMiSameMotherFromOmegaInvMassPt(NULL),
177  fHistoTruePiPlPiMiSameMotherFromRhoInvMassPt(NULL),
178  fHistoTruePiPlPiMiSameMotherFromEtaPrimeInvMassPt(NULL),
179  fHistoTruePiPlPiMiSameMotherFromK0sInvMassPt(NULL),
180  fHistoTruePiPlPiMiSameMotherFromK0lInvMassPt(NULL),
181  fHistoTruePiMiPiZeroSameMotherFromEtaInvMassPt(NULL),
182  fHistoTruePiMiPiZeroSameMotherFromOmegaInvMassPt(NULL),
183  fHistoTruePiMiPiZeroSameMotherFromRhoInvMassPt(NULL),
184  fHistoTruePiMiPiZeroSameMotherFromK0lInvMassPt(NULL),
185  fHistoTruePiPlPiZeroSameMotherFromEtaInvMassPt(NULL),
186  fHistoTruePiPlPiZeroSameMotherFromOmegaInvMassPt(NULL),
187  fHistoTruePiPlPiZeroSameMotherFromRhoInvMassPt(NULL),
188  fHistoTruePiPlPiZeroSameMotherFromK0lInvMassPt(NULL),
189  fHistoTruePiPlPiMiPiZeroPureCombinatoricalInvMassPt(NULL),
190  fHistoTruePiPlPiMiPiZeroContaminationInvMassPt(NULL),
191  fHistoDoubleCountTruePi0InvMassPt(NULL),
192  fHistoDoubleCountTrueEtaInvMassPt(NULL),
193  fHistoDoubleCountTrueOmegaInvMassPt(NULL),
194  fHistoDoubleCountTrueConvGammaRPt(NULL),
195  fVectorDoubleCountTruePi0s(0),
196  fVectorDoubleCountTrueEtas(0),
197  fVectorDoubleCountTrueOmegas(0),
198  fVectorDoubleCountTrueConvGammas(0),
199  fHistoNEvents(NULL),
200  fHistoNGoodESDTracks(NULL),
201  fProfileEtaShift(NULL),
202  fHistoSPDClusterTrackletBackground(NULL),
203  fRandom(0),
204  fnCuts(0),
205  fiCut(0),
206  fNumberOfESDTracks(0),
207  fMoveParticleAccordingToVertex(kFALSE),
208  fIsHeavyIon(0),
209  fDoMesonAnalysis(kTRUE),
210  fDoMesonQA(0),
211  fIsFromMBHeader(kTRUE),
212  fIsMC(kFALSE),
213  fDoLightOutput(kFALSE),
214  fNeutralPionMode(0),
215  fTolerance(-1),
216  fNeutralPionPtMin(0.)
217 {
218 
219 }
220 
221 //-----------------------------------------------------------------------------------------------
223  AliAnalysisTaskSE(name),
224  fV0Reader(NULL),
225  fV0ReaderName("V0ReaderV1"),
226  fPionSelector(NULL),
227  fBGHandlerPiPl(NULL),
228  fBGHandlerPiMi(NULL),
229  fESDEvent(NULL),
230  fMCEvent(NULL),
231  fCutFolder(NULL),
232  fESDList(NULL),
233  fTrueList(NULL),
234  fTrueTreeList(NULL),
235  fMCList(NULL),
236  fOutputContainer(0),
237  fReaderGammas(NULL),
238  fSelectorNegPionIndex(0),
239  fSelectorPosPionIndex(0),
240  fGoodConvGammas(NULL),
241  fClusterCandidates(NULL),
242  fNeutralPionCandidates(NULL),
243  fNeutralPionSidebandCandidates(NULL),
244  fPosPionCandidates(NULL),
245  fNegPionCandidates(NULL),
246  fGoodVirtualParticles(NULL),
247  fEventCutArray(NULL),
248  fGammaCutArray(NULL),
249  fClusterCutArray(NULL),
250  fPionCutArray(NULL),
251  fNeutralPionMesonCutArray(NULL),
252  fMesonCutArray(NULL),
253  fEventCuts(NULL),
254  fConversionCuts(NULL),
255  fClusterCuts(NULL),
256  fTreePiPiSameMother(NULL),
257  fTreePiPiPiSameMother(NULL),
258  fCasePiPi(-1),
259  fSamePiPiMotherID(-1),
260  fSamePiPiMotherInvMass(-1),
261  fSamePiPiMotherPt(-1),
262  fSamePiPiPiMotherID(-1),
263  fSamePiPiPiMotherInvMass(-1),
264  fSamePiPiPiMotherPt(-1),
265  fHistoConvGammaPt(NULL),
266  fHistoConvGammaEta(NULL),
267  fHistoClusterGammaPt(NULL),
268  fHistoClusterGammaEta(NULL),
269  fHistoNegPionPt(NULL),
270  fHistoPosPionPt(NULL),
271  fHistoNegPionPhi(NULL),
272  fHistoPosPionPhi(NULL),
273  fHistoNegPionEta(NULL),
274  fHistoPosPionEta(NULL),
275  fHistoNegPionClsTPC(NULL),
276  fHistoPosPionClsTPC(NULL),
277  fHistoPionDCAxy(NULL),
278  fHistoPionDCAz(NULL),
279  fHistoPionTPCdEdxNSigma(NULL),
280  fHistoPionTPCdEdx(NULL),
281  fHistoPionPionInvMassPt(NULL),
282  fHistoGammaGammaInvMassPt(NULL),
283  fHistoMotherInvMassPt(NULL),
284  fHistoMotherInvMassPtRejectedKinematic(NULL),
285  fHistoBackInvMassPtGroup1(NULL),
286  fHistoBackInvMassPtGroup2(NULL),
287  fHistoBackInvMassPtGroup3(NULL),
288  fHistoBackInvMassPtGroup4(NULL),
289  fHistoMotherLikeSignBackInvMassPt(NULL),
290  fHistoAngleOmegaPiPlPiMi(NULL),
291  fHistoAngleOmegaPiZero(NULL),
292  fHistoAngleOmegaPiPl(NULL),
293  fHistoAngleOmegaPiMi(NULL),
294  fHistoAnglePiPlPiMi(NULL),
295  fHistoAnglePiZeroPiMi(NULL),
296  fHistoAnglePiPlPiZero(NULL),
297  fHistoAngleSum(NULL),
298  fHistoTrueAngleSum(NULL),
299  fHistoMotherInvMassSubPi0(NULL),
300  fHistoBackInvMassPtGroup1SubPi0(NULL),
301  fHistoBackInvMassPtGroup2SubPi0(NULL),
302  fHistoBackInvMassPtGroup3SubPi0(NULL),
303  fHistoBackInvMassPtGroup4SubPi0(NULL),
304  fHistoMotherLikeSignBackInvMassSubPi0Pt(NULL),
305  fHistoMotherInvMassFixedPzPi0(NULL),
306  fHistoBackInvMassPtGroup1FixedPzPi0(NULL),
307  fHistoBackInvMassPtGroup2FixedPzPi0(NULL),
308  fHistoBackInvMassPtGroup3FixedPzPi0(NULL),
309  fHistoBackInvMassPtGroup4FixedPzPi0(NULL),
310  fHistoMotherLikeSignBackInvMassFixedPzPi0Pt(NULL),
311  fHistoMCAllGammaPt(NULL),
312  fHistoMCConvGammaPt(NULL),
313  fHistoMCAllPosPionsPt(NULL),
314  fHistoMCAllNegPionsPt(NULL),
315  fHistoMCGammaFromNeutralMesonPt(NULL),
316  fHistoMCPosPionsFromNeutralMesonPt(NULL),
317  fHistoMCNegPionsFromNeutralMesonPt(NULL),
318  fHistoMCEtaPiPlPiMiPiZeroPt(NULL),
319  fHistoMCEtaPiPlPiMiPiZeroInAccPt(NULL),
320  fHistoMCOmegaPiPlPiMiPiZeroPt(NULL),
321  fHistoMCOmegaPiPlPiMiPiZeroInAccPt(NULL),
322  fHistoTrueMotherPiPlPiMiPiZeroInvMassPt(NULL),
323  fHistoTrueMotherOmegaPiPlPiMiPiZeroInvMassPt(NULL),
324  fHistoTrueMotherEtaPiPlPiMiPiZeroInvMassPt(NULL),
325  fHistoTrueMotherGammaGammaInvMassPt(NULL),
326  fHistoTrueMotherGammaGammaFromEtaInvMassPt(NULL),
327  fHistoTrueMotherGammaGammaFromOmegaInvMassPt(NULL),
328  fHistoTrueConvGammaPt(NULL),
329  fHistoTrueConvGammaFromNeutralMesonPt(NULL),
330  fHistoTrueClusterGammaPt(NULL),
331  fHistoTrueClusterGammaFromNeutralMesonPt(NULL),
332  fHistoTruePosPionPt(NULL),
333  fHistoTruePosPionFromNeutralMesonPt(NULL),
334  fHistoTrueNegPionPt(NULL),
335  fHistoTrueNegPionFromNeutralMesonPt(NULL),
336  fHistoTruePionPionInvMassPt(NULL),
337  fHistoTruePionPionFromSameMotherInvMassPt(NULL),
338  fHistoTruePionPionFromEtaInvMassPt(NULL),
339  fHistoTruePionPionFromOmegaInvMassPt(NULL),
340  fHistoTruePiPlPiMiSameMotherFromEtaInvMassPt(NULL),
341  fHistoTruePiPlPiMiSameMotherFromOmegaInvMassPt(NULL),
342  fHistoTruePiPlPiMiSameMotherFromRhoInvMassPt(NULL),
343  fHistoTruePiPlPiMiSameMotherFromEtaPrimeInvMassPt(NULL),
344  fHistoTruePiPlPiMiSameMotherFromK0sInvMassPt(NULL),
345  fHistoTruePiPlPiMiSameMotherFromK0lInvMassPt(NULL),
346  fHistoTruePiMiPiZeroSameMotherFromEtaInvMassPt(NULL),
347  fHistoTruePiMiPiZeroSameMotherFromOmegaInvMassPt(NULL),
348  fHistoTruePiMiPiZeroSameMotherFromRhoInvMassPt(NULL),
349  fHistoTruePiMiPiZeroSameMotherFromK0lInvMassPt(NULL),
350  fHistoTruePiPlPiZeroSameMotherFromEtaInvMassPt(NULL),
351  fHistoTruePiPlPiZeroSameMotherFromOmegaInvMassPt(NULL),
352  fHistoTruePiPlPiZeroSameMotherFromRhoInvMassPt(NULL),
353  fHistoTruePiPlPiZeroSameMotherFromK0lInvMassPt(NULL),
354  fHistoTruePiPlPiMiPiZeroPureCombinatoricalInvMassPt(NULL),
355  fHistoTruePiPlPiMiPiZeroContaminationInvMassPt(NULL),
356  fHistoDoubleCountTruePi0InvMassPt(NULL),
357  fHistoDoubleCountTrueEtaInvMassPt(NULL),
358  fHistoDoubleCountTrueOmegaInvMassPt(NULL),
359  fHistoDoubleCountTrueConvGammaRPt(NULL),
360  fVectorDoubleCountTruePi0s(0),
361  fVectorDoubleCountTrueEtas(0),
362  fVectorDoubleCountTrueOmegas(0),
363  fVectorDoubleCountTrueConvGammas(0),
364  fHistoNEvents(NULL),
365  fHistoNGoodESDTracks(NULL),
366  fProfileEtaShift(NULL),
367  fHistoSPDClusterTrackletBackground(NULL),
368  fRandom(0),
369  fnCuts(0),
370  fiCut(0),
371  fNumberOfESDTracks(0),
372  fMoveParticleAccordingToVertex(kFALSE),
373  fIsHeavyIon(0),
374  fDoMesonAnalysis(kTRUE),
375  fDoMesonQA(0),
376  fIsFromMBHeader(kTRUE),
377  fIsMC(kFALSE),
378  fDoLightOutput(kFALSE),
379  fNeutralPionMode(0),
380  fTolerance(-1),
381  fNeutralPionPtMin(0.)
382 {
383  DefineOutput(1, TList::Class());
384 }
385 
386 //-----------------------------------------------------------------------------------------------
388 {
389  //
390  // virtual destructor
391  //
392  cout<<"Destructor"<<endl;
393  if(fGoodConvGammas){
394  delete fGoodConvGammas;
395  fGoodConvGammas = 0x0;
396  }
397  if(fClusterCandidates){
398  delete fClusterCandidates;
399  fClusterCandidates = 0x0;
400  }
401 
403  delete fNeutralPionCandidates;
405  }
406 
410  }
411 
412  if(fPosPionCandidates){
413  delete fPosPionCandidates;
414  fPosPionCandidates = 0x0;
415  }
416 
417  if(fNegPionCandidates){
418  delete fNegPionCandidates;
419  fNegPionCandidates = 0x0;
420  }
421 
423  delete fGoodVirtualParticles;
424  fGoodVirtualParticles = 0x0;
425  }
426 
427  if(fBGHandlerPiPl){
428  delete[] fBGHandlerPiPl;
429  fBGHandlerPiPl = 0x0;
430  }
431 
432  if(fBGHandlerPiMi){
433  delete[] fBGHandlerPiMi;
434  fBGHandlerPiMi = 0x0;
435  }
436 }
437 //___________________________________________________________
439 
442 
443  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
444 
445  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
446  TString cutstringPion = ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutNumber();
447  TString cutstringConvGamma = "";
448  if (fNeutralPionMode < 2) cutstringConvGamma = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
449  TString cutstringCaloGamma = "";
450  if (fNeutralPionMode > 0) cutstringCaloGamma = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
451  TString cutstringNeutralPion= ((AliConversionMesonCuts*)fNeutralPionMesonCutArray->At(iCut))->GetCutNumber();
452  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
453 
454  TString fullCutString = "";
455  if (fNeutralPionMode == 0) fullCutString = Form("%i_%s_%s_%s_%s_%s",fNeutralPionMode,cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringNeutralPion.Data(), cutstringPion.Data(),cutstringMeson.Data());
456  else if (fNeutralPionMode == 1) fullCutString = Form("%i_%s_%s_%s_%s_%s_%s",fNeutralPionMode,cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringCaloGamma.Data(),cutstringNeutralPion.Data(), cutstringPion.Data(),cutstringMeson.Data());
457  else if (fNeutralPionMode == 2) fullCutString = Form("%i_%s_%s_%s_%s_%s",fNeutralPionMode,cutstringEvent.Data(),cutstringCaloGamma.Data(),cutstringNeutralPion.Data(), cutstringPion.Data(),cutstringMeson.Data());
458 
459  Int_t collisionSystem = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(0,1));
460  Int_t centMin = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(1,1));
461  Int_t centMax = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(2,1));
462 
463  if(collisionSystem == 1 || collisionSystem == 2 ||
464  collisionSystem == 5 || collisionSystem == 8 ||
465  collisionSystem == 9){
466  centMin = centMin*10;
467  centMax = centMax*10;
468  }
469  else if(collisionSystem == 3 || collisionSystem == 6){
470  centMin = centMin*5;
471  centMax = centMax*5;
472  }
473  else if(collisionSystem == 4 || collisionSystem == 7){
474  centMin = ((centMin*5)+45);
475  centMax = ((centMax*5)+45);
476  }
477 
478  fBGHandlerPiPl[iCut] = new AliGammaConversionAODBGHandler( collisionSystem,centMin,centMax,
479  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents(),
480  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity(),
481  4,8,5);
482 
483  fBGHandlerPiMi[iCut] = new AliGammaConversionAODBGHandler( collisionSystem,centMin,centMax,
484  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents(),
485  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity(),
486  4,8,5);
487  }
488 }
489 
490 //______________________________________________________________________
492 {
493  //
494  // Create ouput objects
495  //
496 
497  // Set pT and mass ranges
498  Double_t HistoMassRange[2] = {0.4,1.0};
499  Double_t HistoMassRangeSub[2] = {0.1,1.0};
500  Double_t HistoPtRange[2] = {0.,25.};
501  Double_t HistoNMassBins = 600;
502  Double_t HistoNMassBinsSub = 900;
503  Double_t HistoNPtBins = 250;
504  // Create the output container
505  if(fOutputContainer != NULL){
506  delete fOutputContainer;
507  fOutputContainer = NULL;
508  }
509  if(fOutputContainer == NULL){
510  fOutputContainer = new TList();
511  fOutputContainer->SetOwner(kTRUE);
512  }
513 
514  fGoodConvGammas = new TList();
515  fClusterCandidates = new TList();
516  fClusterCandidates->SetOwner(kTRUE);
517 
519  fNeutralPionCandidates->SetOwner(kTRUE);
520 
522  fNeutralPionSidebandCandidates->SetOwner(kTRUE);
523 
524 
525  fPosPionCandidates = new TList();
526  fPosPionCandidates->SetOwner(kTRUE);
527  fNegPionCandidates = new TList();
528  fNegPionCandidates->SetOwner(kTRUE);
530  fGoodVirtualParticles->SetOwner(kTRUE);
531 
532  fCutFolder = new TList*[fnCuts];
533  fESDList = new TList*[fnCuts];
534  fHistoNEvents = new TH1I*[fnCuts];
536  if(!fDoLightOutput){
537  fProfileEtaShift = new TProfile*[fnCuts];
539 
540  if (fNeutralPionMode < 2){
541  fHistoConvGammaPt = new TH1F*[fnCuts];
542  fHistoConvGammaEta = new TH1F*[fnCuts];
543  }
544  if (fNeutralPionMode > 0){
545  fHistoClusterGammaPt = new TH1F*[fnCuts];
546  fHistoClusterGammaEta = new TH1F*[fnCuts];
547  }
548  fHistoNegPionPt = new TH1F*[fnCuts];
549  fHistoPosPionPt = new TH1F*[fnCuts];
550  fHistoNegPionPhi = new TH1F*[fnCuts];
551  fHistoPosPionPhi = new TH1F*[fnCuts];
553 
554  if( fDoMesonQA>0 ) {
555  fHistoNegPionEta = new TH1F*[fnCuts];
556  fHistoPosPionEta = new TH1F*[fnCuts];
559  fHistoPionDCAxy = new TH2F*[fnCuts];
560  fHistoPionDCAz = new TH2F*[fnCuts];
562  fHistoPionTPCdEdx = new TH2F*[fnCuts];
563  }
564 
565 
573  fHistoAngleSum = new TH2F*[fnCuts];
574  }
575 
583 
585 
591 
593 
599 
601 
602  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
603  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
604  TString cutstringPion = ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutNumber();
605  TString cutstringConvGamma = "";
606  if (fNeutralPionMode < 2)
607  cutstringConvGamma = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
608  TString cutstringCaloGamma = "";
609  if (fNeutralPionMode > 0)
610  cutstringCaloGamma = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
611  TString cutstringNeutralPion = ((AliConversionMesonCuts*)fNeutralPionMesonCutArray->At(iCut))->GetCutNumber();
612  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
613 
614  TString fullCutString = "";
615  if (fNeutralPionMode == 0)
616  fullCutString = Form("%i_%s_%s_%s_%s_%s",fNeutralPionMode,cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringNeutralPion.Data(), cutstringPion.Data(),cutstringMeson.Data());
617  else if (fNeutralPionMode == 1)
618  fullCutString = Form("%i_%s_%s_%s_%s_%s_%s",fNeutralPionMode,cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringCaloGamma.Data(),cutstringNeutralPion.Data(), cutstringPion.Data(),cutstringMeson.Data());
619  else if (fNeutralPionMode == 2)
620  fullCutString = Form("%i_%s_%s_%s_%s_%s",fNeutralPionMode,cutstringEvent.Data(),cutstringCaloGamma.Data(),cutstringNeutralPion.Data(), cutstringPion.Data(),cutstringMeson.Data());
621  TString nameCutFolder = Form("Cut Number %s", fullCutString.Data());
622  TString nameESDList = Form("%s ESD histograms", fullCutString.Data());
623 
624  fCutFolder[iCut] = new TList();
625  fCutFolder[iCut]->SetName(nameCutFolder.Data());
626  fCutFolder[iCut]->SetOwner(kTRUE);
627  fOutputContainer->Add(fCutFolder[iCut]);
628 
629  fESDList[iCut] = new TList();
630  fESDList[iCut]->SetName(nameESDList.Data());
631  fESDList[iCut]->SetOwner(kTRUE);
632 
633  fHistoNEvents[iCut] = new TH1I("NEvents","NEvents",14,-0.5,13.5);
634  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
635  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
636  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
637  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
638  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
639  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
640  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
641  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
642  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
643  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
644  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
645  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
646  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
647  fESDList[iCut]->Add(fHistoNEvents[iCut]);
648 
649  if(fIsHeavyIon>0)
650  fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",3000,0,3000);
651  else
652  fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
653  fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
654  if(!fDoLightOutput){
655  fProfileEtaShift[iCut] = new TProfile("Eta Shift","Eta Shift",1, -0.5,0.5);
656  fESDList[iCut]->Add(fProfileEtaShift[iCut]);
657  fHistoSPDClusterTrackletBackground[iCut] = new TH2F("SPD tracklets vs SPD clusters","SPD tracklets vs SPD clusters",100,0,200,250,0,1000);
659  if (fNeutralPionMode < 2){
660  fHistoConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt","ESD_ConvGamma_Pt",250,0,25);
661  fESDList[iCut]->Add(fHistoConvGammaPt[iCut]);
662  fHistoConvGammaEta[iCut] = new TH1F("ESD_ConvGamma_Eta","ESD_ConvGamma_Eta",600,-1.5,1.5);
663  fESDList[iCut]->Add(fHistoConvGammaEta[iCut]);
664  }
665  if (fNeutralPionMode > 0){
666  fHistoClusterGammaPt[iCut] = new TH1F("ESD_ClusterGamma_Pt","ESD_ClusterGamma_Pt",250,0,25);
667  fESDList[iCut]->Add(fHistoClusterGammaPt[iCut]);
668  fHistoClusterGammaEta[iCut] = new TH1F("ESD_ClusterGamma_Eta","ESD_ClusterGamma_Eta",600,-1.5,1.5);
669  fESDList[iCut]->Add(fHistoClusterGammaEta[iCut]);
670  }
671  fHistoNegPionPt[iCut] = new TH1F("ESD_PrimaryNegPions_Pt","ESD_PrimaryNegPions_Pt",1000,0,25);
672  fESDList[iCut]->Add(fHistoNegPionPt[iCut]);
673  fHistoPosPionPt[iCut] = new TH1F("ESD_PrimaryPosPions_Pt","ESD_PrimaryPosPions_Pt",1000,0,25);
674  fESDList[iCut]->Add(fHistoPosPionPt[iCut]);
675  fHistoNegPionPhi[iCut] = new TH1F("ESD_PrimaryNegPions_Phi","ESD_PrimaryNegPions_Phi",360,0,2*TMath::Pi());
676  fESDList[iCut]->Add(fHistoNegPionPhi[iCut]);
677  fHistoPosPionPhi[iCut] = new TH1F("ESD_PrimaryPosPions_Phi","ESD_PrimaryPosPions_Phi",360,0,2*TMath::Pi());
678  fESDList[iCut]->Add(fHistoPosPionPhi[iCut]);
679  fHistoPionPionInvMassPt[iCut] = new TH2F("ESD_PiPlusPiNeg_InvMassPt","ESD_PiPlusPiNeg_InvMassPt",2000,0.,2.,200,0.,20.);
680  fESDList[iCut]->Add(fHistoPionPionInvMassPt[iCut]);
681 
682  if ( fDoMesonQA>0 ) {
683  fHistoNegPionEta[iCut] = new TH1F("ESD_PrimaryNegPions_Eta","ESD_PrimaryNegPions_Eta",600,-1.5,1.5);
684  fESDList[iCut]->Add(fHistoNegPionEta[iCut]);
685  fHistoPosPionEta[iCut] = new TH1F("ESD_PrimaryPosPions_Eta","ESD_PrimaryPosPions_Eta",600,-1.5,1.5);
686  fESDList[iCut]->Add(fHistoPosPionEta[iCut]);
687  fHistoNegPionClsTPC[iCut] = new TH2F("ESD_PrimaryNegPions_ClsTPC","ESD_PrimaryNegPions_ClsTPC",100,0,1,400,0.,10.);
688  fESDList[iCut]->Add(fHistoNegPionClsTPC[iCut]);
689  fHistoPosPionClsTPC[iCut] = new TH2F("ESD_PrimaryPosPions_ClsTPC","ESD_PrimaryPosPions_ClsTPC",100,0,1,400,0.,10.);
690  fESDList[iCut]->Add(fHistoPosPionClsTPC[iCut]);
691  fHistoPionDCAxy[iCut] = new TH2F("ESD_PrimaryPions_DCAxy","ESD_PrimaryPions_DCAxy",800,-4.0,4.0,400,0.,10.);
692  fESDList[iCut]->Add(fHistoPionDCAxy[iCut]);
693  fHistoPionDCAz[iCut] = new TH2F("ESD_PrimaryPions_DCAz","ESD_PrimaryPions_DCAz",800,-4.0,4.0,400,0.,10.);
694  fESDList[iCut]->Add(fHistoPionDCAz[iCut]);
695  fHistoPionTPCdEdxNSigma[iCut] = new TH2F("ESD_PrimaryPions_TPCdEdx","ESD_PrimaryPions_TPCdEdx",150,0.05,20,400,-10,10);
696  fESDList[iCut]->Add(fHistoPionTPCdEdxNSigma[iCut]);
697  fHistoPionTPCdEdx[iCut] = new TH2F("ESD_PrimaryPions_TPCdEdxSignal","ESD_PrimaryPions_TPCdEdxSignal" ,150,0.05,20.0,800,0.0,200);
698  fESDList[iCut]->Add(fHistoPionTPCdEdx[iCut]);
699  }
700  fHistoGammaGammaInvMassPt[iCut] = new TH2F("ESD_GammaGamma_InvMass_Pt","ESD_GammaGamma_InvMass_Pt",450,0.,0.45,250,0,25);
701  fESDList[iCut]->Add(fHistoGammaGammaInvMassPt[iCut]);
702  }
703  fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
704  fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
705  fHistoMotherInvMassPtRejectedKinematic[iCut] = new TH2F("ESD_Mother_InvMass_Pt_KinematicRejected","ESD_Mother_InvMass_Pt_KinematicRejected",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
707 
708  fHistoBackInvMassPtGroup1[iCut] = new TH2F("ESD_Background_1_InvMass_Pt","ESD_Background_1_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
709  fHistoBackInvMassPtGroup2[iCut] = new TH2F("ESD_Background_2_InvMass_Pt","ESD_Background_2_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
710  fHistoBackInvMassPtGroup3[iCut] = new TH2F("ESD_Background_3_InvMass_Pt","ESD_Background_3_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
711  fHistoBackInvMassPtGroup4[iCut] = new TH2F("ESD_Background_4_InvMass_Pt","ESD_Background_4_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
712  if(!(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseLikeSignMixing())){
713  fESDList[iCut]->Add(fHistoBackInvMassPtGroup1[iCut]);
714  fESDList[iCut]->Add(fHistoBackInvMassPtGroup2[iCut]);
715  fESDList[iCut]->Add(fHistoBackInvMassPtGroup3[iCut]);
716  fESDList[iCut]->Add(fHistoBackInvMassPtGroup4[iCut]);
717  }
718 
719  fHistoMotherLikeSignBackInvMassPt[iCut] = new TH2F("ESD_Background_LikeSign_InvMass_Pt","ESD_Background_LikeSign_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
720  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseLikeSignMixing()){
722  }
723  fHistoMotherInvMassSubPi0[iCut] = new TH2F("ESD_InvMass_Mother_Sub_InvMass(NeutralPion)_Pt","ESD_Mother_InvMass_Sub_InvMass(NeutralPion)_Pt",HistoNMassBinsSub,HistoMassRangeSub[0],HistoMassRangeSub[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
724  fESDList[iCut]->Add(fHistoMotherInvMassSubPi0[iCut]);
725 
726  fHistoBackInvMassPtGroup1SubPi0[iCut] = new TH2F("ESD_Background_1_InvMass_Sub_InvMass(NeutralPion)_Pt","ESD_Background_1_InvMass_Sub_InvMass(NeutralPion)_Pt",
727  HistoNMassBinsSub,HistoMassRangeSub[0],HistoMassRangeSub[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
728  fHistoBackInvMassPtGroup2SubPi0[iCut] = new TH2F("ESD_Background_2_InvMass_Sub_InvMass(NeutralPion)_Pt","ESD_Background_2_InvMass_Sub_InvMass(NeutralPion)_Pt",
729  HistoNMassBinsSub,HistoMassRangeSub[0],HistoMassRangeSub[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
730  fHistoBackInvMassPtGroup3SubPi0[iCut] = new TH2F("ESD_Background_3_InvMass_Sub_InvMass(NeutralPion)_Pt","ESD_Background_3_InvMass_Sub_InvMass(NeutralPion)_Pt",
731  HistoNMassBinsSub,HistoMassRangeSub[0],HistoMassRangeSub[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
732  fHistoBackInvMassPtGroup4SubPi0[iCut] = new TH2F("ESD_Background_4_InvMass_Sub_InvMass(NeutralPion)_Pt","ESD_Background_4_InvMass_Sub_InvMass(NeutralPion)_Pt",
733  HistoNMassBinsSub,HistoMassRangeSub[0],HistoMassRangeSub[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
734  if(!(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseLikeSignMixing())){
735  fESDList[iCut]->Add(fHistoBackInvMassPtGroup4SubPi0[iCut]);
736 
737  fESDList[iCut]->Add(fHistoBackInvMassPtGroup1SubPi0[iCut]);
738  fESDList[iCut]->Add(fHistoBackInvMassPtGroup2SubPi0[iCut]);
739  fESDList[iCut]->Add(fHistoBackInvMassPtGroup3SubPi0[iCut]);
740  }
741  fHistoMotherLikeSignBackInvMassSubPi0Pt[iCut] = new TH2F("ESD_Background_LikeSign_InvMass_Sub_InvMass(NeutralPion)_Pt","ESD_Background_LikeSign_InvMass_Sub_InvMass(NeutralPion)_Pt",
742  HistoNMassBinsSub,HistoMassRangeSub[0],HistoMassRangeSub[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
743  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseLikeSignMixing()){
745  }
746  fHistoMotherInvMassFixedPzPi0[iCut] = new TH2F("ESD_InvMass_Mother_FixedPz(NeutralPion)_Pt","ESD_Mother_InvMass_FixedPz(NeutralPion)_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
747  fESDList[iCut]->Add(fHistoMotherInvMassFixedPzPi0[iCut]);
748 
749  fHistoBackInvMassPtGroup1FixedPzPi0[iCut] = new TH2F("ESD_Background_1_InvMass_FixedPz(NeutralPion)_Pt","ESD_Background_1_InvMass_FixedPz(NeutralPion)_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
750  fHistoBackInvMassPtGroup2FixedPzPi0[iCut] = new TH2F("ESD_Background_2_InvMass_FixedPz(NeutralPion)_Pt","ESD_Background_2_InvMass_FixedPz(NeutralPion)_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
751  fHistoBackInvMassPtGroup3FixedPzPi0[iCut] = new TH2F("ESD_Background_3_InvMass_FixedPz(NeutralPion)_Pt","ESD_Background_3_InvMass_FixedPz(NeutralPion)_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
752  fHistoBackInvMassPtGroup4FixedPzPi0[iCut] = new TH2F("ESD_Background_4_InvMass_FixedPz(NeutralPion)_Pt","ESD_Background_4_InvMass_FixedPz(NeutralPion)_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
753 
754  if(!(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseLikeSignMixing())){
759  }
760  fHistoMotherLikeSignBackInvMassFixedPzPi0Pt[iCut] = new TH2F("ESD_Background_LikeSign_InvMass_FixedPz(NeutralPion)_Pt","ESD_Background_LikeSign_InvMass_FixedPz(NeutralPion)_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
761  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseLikeSignMixing()){
763  }
764  if(!fDoLightOutput){
765  fHistoAngleOmegaPiPlPiMi[iCut] = new TH2F("ESD_Mother_AngleOmegaNegPionsPosPions_Pt","ESD_Mother_AngleOmegaNegPionsPosPions_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1],360,0,TMath::Pi());
766  fESDList[iCut]->Add(fHistoAngleOmegaPiPlPiMi[iCut]);
767  fHistoAngleOmegaPiMi[iCut] = new TH2F("ESD_Mother_AngleOmegaNegPions_Pt","ESD_Mother_AngleOmegaNegPions_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1],360,0,TMath::Pi());
768  fESDList[iCut]->Add(fHistoAngleOmegaPiMi[iCut]);
769  fHistoAngleOmegaPiPl[iCut] = new TH2F("ESD_Mother_AngleOmegaPosPions_Pt","ESD_Mother_AngleOmegaPosPions_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1],360,0,TMath::Pi());
770  fESDList[iCut]->Add(fHistoAngleOmegaPiPl[iCut]);
771  fHistoAngleOmegaPiZero[iCut] = new TH2F("ESD_Mother_AngleOmegaNeutralPion_Pt","ESD_Mother_AngleOmegaNeutralPion_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1],360,0,TMath::Pi());
772  fESDList[iCut]->Add(fHistoAngleOmegaPiZero[iCut]);
773  fHistoAnglePiPlPiZero[iCut] = new TH2F("ESD_Mother_AnglePosPionsNeutralPion_Pt","ESD_Mother_AnglePosPionsNeutralPion_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1],360,0,TMath::Pi());
774  fESDList[iCut]->Add(fHistoAnglePiPlPiZero[iCut]);
775  fHistoAnglePiPlPiMi[iCut] = new TH2F("ESD_Mother_AnglePosPionsNegPions_Pt","ESD_Mother_AnglePosPionsNegPions_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1],360,0,TMath::Pi());
776  fESDList[iCut]->Add(fHistoAnglePiPlPiMi[iCut]);
777  fHistoAnglePiZeroPiMi[iCut] = new TH2F("ESD_Mother_AngleNeutralPionNegPions_Pt","ESD_Mother_AngleNeutralPionNegPions_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1],360,0,TMath::Pi());
778  fESDList[iCut]->Add(fHistoAnglePiZeroPiMi[iCut]);
779  fHistoAngleSum[iCut] = new TH2F("ESD_Mother_AngleSum_Pt","ESD_Mother_AngleSum_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1],720,0,2*TMath::Pi());
780  fESDList[iCut]->Add(fHistoAngleSum[iCut]);
781  }
782  if ( fDoMesonQA>0 && (!fDoLightOutput) ) {
783  TAxis *AxisAfter = fHistoPionTPCdEdxNSigma[iCut]->GetXaxis();
784  Int_t bins = AxisAfter->GetNbins();
785  Double_t from = AxisAfter->GetXmin();
786  Double_t to = AxisAfter->GetXmax();
787  Double_t *newBins = new Double_t[bins+1];
788  newBins[0] = from;
789  Double_t factor = TMath::Power(to/from, 1./bins);
790  for(Int_t i=1; i<=bins; ++i) newBins[i] = factor * newBins[i-1];
791 
792  AxisAfter->Set(bins, newBins);
793  AxisAfter = fHistoPionTPCdEdx[iCut]->GetXaxis();
794  AxisAfter->Set(bins, newBins);
795  delete [] newBins;
796  }
797 
798  fCutFolder[iCut]->Add(fESDList[iCut]);
799 
800  }
801 
802  if( fIsMC ){
803  // MC Histogramms
804  fMCList = new TList*[fnCuts];
805  // True Histogramms
806  fTrueList = new TList*[fnCuts];
807  if(!fDoLightOutput){
808  if (fNeutralPionMode < 2){
809  fHistoTrueConvGammaPt = new TH1F*[fnCuts];
812  }
813  if (fNeutralPionMode > 0){
814  fHistoTrueClusterGammaPt = new TH1F*[fnCuts];
816  }
817  fHistoTruePosPionPt = new TH1F*[fnCuts];
818  fHistoTrueNegPionPt = new TH1F*[fnCuts];
821 
822 
823  fHistoMCAllGammaPt = new TH1F*[fnCuts];
824  if (fNeutralPionMode < 2){
825  fHistoMCConvGammaPt = new TH1F*[fnCuts];
826  }
827  fHistoMCAllPosPionsPt = new TH1F*[fnCuts];
828  fHistoMCAllNegPionsPt = new TH1F*[fnCuts];
832  }
833  fHistoMCEtaPiPlPiMiPiZeroPt = new TH1F*[fnCuts];
837  if(!fDoLightOutput){
841  }
843  if(!fDoLightOutput){
850  }
851  if(!fDoLightOutput){
852  if (fDoMesonQA>0){
857 
874  if (fDoMesonQA>1){
875  fTrueTreeList = new TList*[fnCuts];
878  }
879  }
880  }
881 
882  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
883  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
884  TString cutstringPion = ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutNumber();
885  TString cutstringConvGamma = "";
886  if (fNeutralPionMode < 2)
887  cutstringConvGamma = ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
888  TString cutstringCaloGamma = "";
889  if (fNeutralPionMode > 0)
890  cutstringCaloGamma = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
891  TString cutstringNeutralPion = ((AliConversionMesonCuts*)fNeutralPionMesonCutArray->At(iCut))->GetCutNumber();
892  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
893 
894  TString fullCutString = "";
895  if (fNeutralPionMode == 0)
896  fullCutString = Form("%i_%s_%s_%s_%s_%s",fNeutralPionMode,cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringNeutralPion.Data(), cutstringPion.Data(),
897  cutstringMeson.Data());
898  else if (fNeutralPionMode == 1)
899  fullCutString = Form("%i_%s_%s_%s_%s_%s_%s",fNeutralPionMode,cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringCaloGamma.Data(), cutstringNeutralPion.Data(),
900  cutstringPion.Data(), cutstringMeson.Data());
901  else if (fNeutralPionMode == 2)
902  fullCutString = Form("%i_%s_%s_%s_%s_%s",fNeutralPionMode,cutstringEvent.Data(), cutstringCaloGamma.Data(), cutstringNeutralPion.Data(), cutstringPion.Data(),
903  cutstringMeson.Data());
904  TString nameMCList = Form("%s MC histograms", fullCutString.Data());
905  TString nameTrueRecList = Form("%s True histograms", fullCutString.Data());
906  TString nameTrueRecTTreeList = Form("%s True TTrees", fullCutString.Data());
907 
908  fMCList[iCut] = new TList();
909  fMCList[iCut]->SetName(nameMCList.Data());
910  fMCList[iCut]->SetOwner(kTRUE);
911  fCutFolder[iCut]->Add(fMCList[iCut]);
912 
913  if(!fDoLightOutput){
914  fHistoMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt","MC_AllGamma_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
915  fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);
916  if (fNeutralPionMode < 2){
917  fHistoMCConvGammaPt[iCut] = new TH1F("MC_ConvGamma_Pt","MC_ConvGamma_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
918  fMCList[iCut]->Add(fHistoMCConvGammaPt[iCut]);
919  }
920 
921  fHistoMCAllPosPionsPt[iCut] = new TH1F("MC_AllPosPions_Pt","MC_AllPosPions_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
922  fMCList[iCut]->Add(fHistoMCAllPosPionsPt[iCut]);
923  fHistoMCAllNegPionsPt[iCut] = new TH1F("MC_AllNegPions_Pt","MC_AllNegPions_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
924  fMCList[iCut]->Add(fHistoMCAllNegPionsPt[iCut]);
925  fHistoMCGammaFromNeutralMesonPt[iCut] = new TH1F("MC_GammaFromNeutralMeson_Pt","MC_GammaFromNeutralMeson_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
926  fMCList[iCut]->Add(fHistoMCGammaFromNeutralMesonPt[iCut]);
927  fHistoMCPosPionsFromNeutralMesonPt[iCut] = new TH1F("MC_PosPionsFromNeutralMeson_Pt","MC_PosPionsFromNeutralMeson_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
928  fMCList[iCut]->Add(fHistoMCPosPionsFromNeutralMesonPt[iCut]);
929  fHistoMCNegPionsFromNeutralMesonPt[iCut] = new TH1F("MC_NegPionsFromNeutralMeson_Pt","MC_NegPionsFromNeutralMeson_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
930  fMCList[iCut]->Add(fHistoMCNegPionsFromNeutralMesonPt[iCut]);
931  }
932  fHistoMCEtaPiPlPiMiPiZeroPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
933  fHistoMCEtaPiPlPiMiPiZeroPt[iCut]->Sumw2();
934  fMCList[iCut]->Add(fHistoMCEtaPiPlPiMiPiZeroPt[iCut]);
935 
936  fHistoMCEtaPiPlPiMiPiZeroInAccPt[iCut] = new TH1F("MC_EtaInAcc_Pt","MC_EtaInAcc_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
937  fHistoMCEtaPiPlPiMiPiZeroInAccPt[iCut]->Sumw2();
938  fMCList[iCut]->Add(fHistoMCEtaPiPlPiMiPiZeroInAccPt[iCut]);
939 
940  fHistoMCOmegaPiPlPiMiPiZeroPt[iCut] = new TH1F("MC_Omega_Pt","MC_Omega_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
941  fHistoMCOmegaPiPlPiMiPiZeroPt[iCut]->Sumw2();
942  fMCList[iCut]->Add(fHistoMCOmegaPiPlPiMiPiZeroPt[iCut]);
943 
944  fHistoMCOmegaPiPlPiMiPiZeroInAccPt[iCut] = new TH1F("MC_OmegaInAcc_Pt","MC_OmegaInAcc_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
945  fHistoMCOmegaPiPlPiMiPiZeroInAccPt[iCut]->Sumw2();
946  fMCList[iCut]->Add(fHistoMCOmegaPiPlPiMiPiZeroInAccPt[iCut]);
947 
948  fTrueList[iCut] = new TList();
949  fTrueList[iCut]->SetName(nameTrueRecList.Data());
950  fTrueList[iCut]->SetOwner(kTRUE);
951  fCutFolder[iCut]->Add(fTrueList[iCut]);
952 
953  if(!fDoLightOutput){
954  if (fNeutralPionMode < 2){
955  fHistoTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt","ESD_TrueConvGamma_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
956  fTrueList[iCut]->Add(fHistoTrueConvGammaPt[iCut]);
957  fHistoDoubleCountTrueConvGammaRPt[iCut] = new TH2F("ESD_TrueDoubleCountConvGamma_R_Pt","ESD_TrueDoubleCountConvGamma_R_Pt",800,0,200,300,0,30);
959  fHistoTrueConvGammaFromNeutralMesonPt[iCut] = new TH1F("ESD_TrueConvGammaFromNeutralMeson_Pt","ESD_TrueConvGammaFromNeutralMeson_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
961  }
962  if (fNeutralPionMode > 0){
963  fHistoTrueClusterGammaPt[iCut] = new TH1F("ESD_TrueClusterGamma_Pt","ESD_TrueClusterGamma_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
964  fTrueList[iCut]->Add(fHistoTrueClusterGammaPt[iCut]);
965  fHistoTrueClusterGammaFromNeutralMesonPt[iCut] = new TH1F("ESD_TrueClusterGammaFromNeutralMeson_Pt","ESD_TrueClusterGammaFromNeutralMeson_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
967  }
968  fHistoTruePosPionPt[iCut] = new TH1F("ESD_TruePosPion_Pt","ESD_TruePosPion_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
969  fTrueList[iCut]->Add(fHistoTruePosPionPt[iCut]);
970  fHistoTrueNegPionPt[iCut] = new TH1F("ESD_TrueNegPion_Pt","ESD_TrueNegPion_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
971  fTrueList[iCut]->Add(fHistoTrueNegPionPt[iCut]);
972 
973  fHistoTrueNegPionFromNeutralMesonPt[iCut] = new TH1F("ESD_TrueNegPionFromNeutralMeson_Pt","ESD_TrueNegPionFromNeutralMeson_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
975  fHistoTruePosPionFromNeutralMesonPt[iCut] = new TH1F("ESD_TruePosPionFromNeutralMeson_Pt","ESD_TruePosPionFromNeutralMeson_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
977 
978  fHistoDoubleCountTruePi0InvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountPi0_InvMass_Pt","ESD_TrueDoubleCountPi0_InvMass_Pt",800,0,0.8,300,0,30);
980  fHistoDoubleCountTrueEtaInvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountEta_InvMass_Pt","ESD_TrueDoubleCountEta_InvMass_Pt",800,0,0.8,300,0,30);
982  fHistoDoubleCountTrueOmegaInvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountOmega_InvMass_Pt","ESD_TrueDoubleCountOmega_InvMass_Pt",800,0,0.8,300,0,30);
984  }
985  fHistoTrueMotherPiPlPiMiPiZeroInvMassPt[iCut] = new TH2F("ESD_TrueMotherPiPlPiMiPiZero_InvMass_Pt","ESD_TrueMotherPiPlPiMiPiZero_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
988  if(!fDoLightOutput){
989  fHistoTrueMotherOmegaPiPlPiMiPiZeroInvMassPt[iCut] = new TH2F("ESD_TrueMotherOmegaPiPlPiMiPiZero_InvMass_Pt","ESD_TrueMotherOmegaPiPlPiMiPiZero_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
990  fHistoTrueMotherEtaPiPlPiMiPiZeroInvMassPt[iCut] = new TH2F("ESD_TrueMotherEtaPiPlPiMiPiZero_InvMass_Pt","ESD_TrueMotherEtaPiPlPiMiPiZero_InvMass_Pt",HistoNMassBins,HistoMassRange[0],HistoMassRange[1],HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
995 
996 
997  fHistoTrueMotherGammaGammaInvMassPt[iCut] = new TH2F("ESD_TrueMotherGG_InvMass_Pt","ESD_TrueMotherGG_InvMass_Pt",450,0.,0.45,HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
999  fHistoTrueMotherGammaGammaFromEtaInvMassPt[iCut] = new TH2F("ESD_TrueMotherGGFromEta_InvMass_Pt","ESD_TrueMotherGGFromEta_InvMass_Pt",450,0.,0.45,HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1001  fHistoTrueMotherGammaGammaFromOmegaInvMassPt[iCut] = new TH2F("ESD_TrueMotherGGFromOmega_InvMass_Pt","ESD_TrueMotherGGFromOmega_InvMass_Pt",450,0.,0.45,HistoNPtBins,HistoPtRange[0],HistoPtRange[1]);
1003  fHistoTrueAngleSum[iCut] = new TH2F("ESD_TrueMother_AngleSum_Pt","ESD_TrueMother_AngleSum_Pt",HistoNPtBins,HistoPtRange[0],HistoPtRange[1],720,0,2*TMath::Pi());
1004  fTrueList[iCut]->Add(fHistoTrueAngleSum[iCut]);
1005 
1006  if (fDoMesonQA>0){
1007  fHistoTruePionPionInvMassPt[iCut] = new TH2F("ESD_TruePiPlusPiNeg_InvMassPt","ESD_TruePiPlusPiNeg_InvMassPt",2000,0.,2.,200,0.,20.);
1008  fTrueList[iCut]->Add(fHistoTruePionPionInvMassPt[iCut]);
1009  fHistoTruePionPionFromSameMotherInvMassPt[iCut] = new TH2F("ESD_TruePiPlusPiNegFromSameMother_InvMassPt","ESD_TruePiPlusPiNegFromSameMother_InvMassPt",2000,0.,2.,200,0.,20.);
1011  fHistoTruePionPionFromEtaInvMassPt[iCut] = new TH2F("ESD_TruePiPlusPiNegFromEta_InvMassPt","ESD_TruePiPlusPiNegFromEta_InvMassPt",2000,0.,2.,200,0.,20.);
1013  fHistoTruePionPionFromOmegaInvMassPt[iCut] = new TH2F("ESD_TruePiPlusPiNegFromOmega_InvMassPt","ESD_TruePiPlusPiNegFromOmega_InvMassPt",2000,0.,2.,200,0.,20.);
1015 
1016  fHistoTruePiPlPiMiSameMotherFromEtaInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiSameMotherFromEta_InvMassPt","ESD_TruePiPlPiMiSameMotherFromEta_InvMassPt",2000,0.,2.,200,0.,20.);
1018  fHistoTruePiPlPiMiSameMotherFromOmegaInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiSameMotherFromOmega_InvMassPt","ESD_TruePiPlPiMiSameMotherFromOmega_InvMassPt",2000,0.,2.,200,0.,20.);
1020  fHistoTruePiPlPiMiSameMotherFromRhoInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiSameMotherFromRho_InvMassPt","ESD_TruePiPlPiMiSameMotherFromRho_InvMassPt",2000,0.,2.,200,0.,20.);
1022  fHistoTruePiPlPiMiSameMotherFromEtaPrimeInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiSameMotherFromEtaPrime_InvMassPt","ESD_TruePiPlPiMiSameMotherFromEtaPrime_InvMassPt",
1023  2000,0.,2.,200,0.,20.);
1025  fHistoTruePiPlPiMiSameMotherFromK0sInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiSameMotherFromK0s_InvMassPt","ESD_TruePiPlPiMiSameMotherFromK0s_InvMassPt",2000,0.,2.,200,0.,20.);
1027  fHistoTruePiPlPiMiSameMotherFromK0lInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiSameMotherFromK0l_InvMassPt","ESD_TruePiPlPiMiSameMotherFromK0l_InvMassPt",2000,0.,2.,200,0.,20.);
1029 
1030  fHistoTruePiMiPiZeroSameMotherFromEtaInvMassPt[iCut] = new TH2F("ESD_TruePiMiPiZeroSameMotherFromEta_InvMassPt","ESD_TruePiMiPiZeroSameMotherFromEta_InvMassPt",2000,0.,2.,200,0.,20.);
1032  fHistoTruePiMiPiZeroSameMotherFromOmegaInvMassPt[iCut] = new TH2F("ESD_TruePiMiPiZeroSameMotherFromOmega_InvMassPt","ESD_TruePiMiPiZeroSameMotherFromOmega_InvMassPt",2000,0.,2.,200,0.,20.);
1034  fHistoTruePiMiPiZeroSameMotherFromRhoInvMassPt[iCut] = new TH2F("ESD_TruePiMiPiZeroSameMotherFromRho_InvMassPt","ESD_TruePiMiPiZeroSameMotherFromRho_InvMassPt",2000,0.,2.,200,0.,20.);
1036  fHistoTruePiMiPiZeroSameMotherFromK0lInvMassPt[iCut] = new TH2F("ESD_TruePiMiPiZeroSameMotherFromK0l_InvMassPt","ESD_TruePiMiPiZeroSameMotherFromK0l_InvMassPt",2000,0.,2.,200,0.,20.);
1038 
1039  fHistoTruePiPlPiZeroSameMotherFromEtaInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiZeroSameMotherFromEta_InvMassPt","ESD_TruePiPlPiZeroSameMotherFromEta_InvMassPt",2000,0.,2.,200,0.,20.);
1041  fHistoTruePiPlPiZeroSameMotherFromOmegaInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiZeroSameMotherFromOmega_InvMassPt","ESD_TruePiPlPiZeroSameMotherFromOmega_InvMassPt",2000,0.,2.,200,0.,20.);
1043  fHistoTruePiPlPiZeroSameMotherFromRhoInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiZeroSameMotherFromRho_InvMassPt","ESD_TruePiPlPiZeroSameMotherFromRho_InvMassPt",2000,0.,2.,200,0.,20.);
1045  fHistoTruePiPlPiZeroSameMotherFromK0lInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiZeroSameMotherFromK0l_InvMassPt","ESD_TruePiPlPiZeroSameMotherFromK0l_InvMassPt",2000,0.,2.,200,0.,20.);
1047  fHistoTruePiPlPiMiPiZeroPureCombinatoricalInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiPiZeroPureCombinatorical_InvMassPt","ESD_TruePiPlPiMiPiZeroPureCombinatorical_InvMassPt",2000,0.,2.,200,0.,20.);
1049  fHistoTruePiPlPiMiPiZeroContaminationInvMassPt[iCut] = new TH2F("ESD_TruePiPlPiMiPiZeroContamination_InvMassPt","ESD_TruePiPlPiMiPiZeroContamination_InvMassPt",2000,0.,2.,200,0.,20.);
1051  if(fDoMesonQA>1){
1052  fTrueTreeList[iCut] = new TList();
1053  fTrueTreeList[iCut]->SetName(nameTrueRecTTreeList.Data());
1054  fTrueTreeList[iCut]->SetOwner(kTRUE);
1055  fCutFolder[iCut]->Add(fTrueTreeList[iCut]);
1056 
1057  fTreePiPiSameMother[iCut] = new TTree("TreePiPiSameMother","TreePiPiSameMother");
1058  fTreePiPiSameMother[iCut]->Branch("fCasePiPi", &fCasePiPi, "fCasePiPi/S");
1059  fTreePiPiSameMother[iCut]->Branch("fSamePiPiMotherID", &fSamePiPiMotherID, "fSamePiPiMotherID/F");
1060  fTreePiPiSameMother[iCut]->Branch("fSamePiPiMotherInvMass", &fSamePiPiMotherInvMass, "fSamePiPiMotherInvMass/F");
1061  fTreePiPiSameMother[iCut]->Branch("fSamePiPiMotherPt", &fSamePiPiMotherPt, "fSamePiPiMotherPt/F");
1062  fTrueTreeList[iCut]->Add(fTreePiPiSameMother[iCut]);
1063 
1064  fTreePiPiPiSameMother[iCut] = new TTree("TreePiPiPiSameMother","TreePiPiPiSameMother");
1065  fTreePiPiPiSameMother[iCut]->Branch("fSamePiPiPiMotherID", &fSamePiPiPiMotherID, "fSamePiPiPiMotherID/F");
1066  fTreePiPiPiSameMother[iCut]->Branch("fSamePiPiPiMotherInvMass", &fSamePiPiPiMotherInvMass, "fSamePiPiPiMotherInvMass/F");
1067  fTreePiPiPiSameMother[iCut]->Branch("fSamePiPiPiMotherPt", &fSamePiPiPiMotherPt, "fSamePiPiPiMotherPt/F");
1068  fTrueTreeList[iCut]->Add(fTreePiPiPiSameMother[iCut]);
1069  }
1070  }
1071  }
1072  }
1073  }
1074 
1079 
1080  InitBack(); // Init Background Handler
1081 
1082  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
1083  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
1084 
1085  if(fV0Reader){
1087  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms()){
1088  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
1089  }
1090  }
1091 
1093  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms()){
1094  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
1095  }
1096  }
1097 
1098  }
1099 
1100  for(Int_t iMatcherTask = 0; iMatcherTask < 3; iMatcherTask++){
1101  AliCaloTrackMatcher* temp = (AliCaloTrackMatcher*) (AliAnalysisManager::GetAnalysisManager()->GetTask(Form("CaloTrackMatcher_%i",iMatcherTask)));
1102  if(temp) fOutputContainer->Add(temp->GetCaloTrackMatcherHistograms());
1103  }
1104 
1105  fPionSelector=(AliPrimaryPionSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("PionSelector");
1106  if(!fPionSelector){printf("Error: No PionSelector");return;} // GetV0Reader
1107 
1108  if( fPionSelector && (!fDoLightOutput)){
1109  if ( ((AliPrimaryPionCuts*)fPionSelector->GetPrimaryPionCuts())->GetCutHistograms() ){
1110  fOutputContainer->Add( ((AliPrimaryPionCuts*)fPionSelector->GetPrimaryPionCuts())->GetCutHistograms() );
1111  }
1112  }
1113 
1114  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1115  if( fEventCutArray) {
1116  if( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms() ) {
1117  fCutFolder[iCut]->Add( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
1118  }
1119  }
1120 
1121  if( fPionCutArray){
1122  if( ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutHistograms() ) {
1123  fCutFolder[iCut]->Add( ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutHistograms() );
1124  }
1125  }
1126  if (fNeutralPionMode < 2){
1127  if( fGammaCutArray ) {
1128  if( ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutHistograms() ) {
1129  fCutFolder[iCut]->Add( ((AliConversionPhotonCuts*)fGammaCutArray->At(iCut))->GetCutHistograms() );
1130  }
1131  }
1132  }
1133  if (fNeutralPionMode > 0){
1134  if( fClusterCutArray ) {
1135  if( ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms() ) {
1136  fCutFolder[iCut]->Add( ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms() );
1137  }
1138  }
1139  }
1141  if( ((AliConversionMesonCuts*)fNeutralPionMesonCutArray->At(iCut))->GetCutHistograms() ) {
1142  fCutFolder[iCut]->Add( ((AliConversionMesonCuts*)fNeutralPionMesonCutArray->At(iCut))->GetCutHistograms());
1143  }
1144  }
1145  if( fMesonCutArray ) {
1146  if( ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms() ) {
1147  fCutFolder[iCut]->Add( ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
1148  }
1149  }
1150  }
1151 
1152  PostData(1, fOutputContainer);
1153 
1154 }
1155 
1156 //______________________________________________________________________
1158 
1159  //
1160  // Execute analysis for current event
1161  //
1162 
1163  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
1164  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
1165 
1166  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
1167  if(InputEvent()->IsIncompleteDAQ()==kTRUE) eventQuality = 2; // incomplete event
1168  if(eventQuality == 2 || eventQuality == 3){// Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1 or because it is incomplete
1169  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1170  fHistoNEvents[iCut]->Fill(eventQuality);
1171  }
1172  return;
1173  }
1174 
1175  fPionSelector=(AliPrimaryPionSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("PionSelector");
1176  if(!fPionSelector){printf("Error: No PionSelector");return;} // GetV0Reader
1177 
1178  if(fIsMC) fMCEvent = MCEvent();
1179  fESDEvent = (AliESDEvent*)InputEvent();
1180  fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
1181  fSelectorNegPionIndex = fPionSelector->GetReconstructedNegPionIndex(); // Electrons from default Cut
1182  fSelectorPosPionIndex = fPionSelector->GetReconstructedPosPionIndex(); // Positrons from default Cut
1183 
1185  //AddTaskContainers(); //Add conatiner
1186 
1187  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1188  fiCut = iCut;
1189 
1190  Bool_t isRunningEMCALrelAna = kFALSE;
1191  if (fNeutralPionMode > 0){
1192  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetClusterType() == 1) isRunningEMCALrelAna = kTRUE;
1193  }
1194 
1195  Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon, isRunningEMCALrelAna);
1196 
1197  if(eventNotAccepted){
1198  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
1199  fHistoNEvents[iCut]->Fill(eventNotAccepted); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
1200  continue;
1201  }
1202 
1203  if(eventQuality != 0){// Event Not Accepted
1204  // cout << "event rejected due to: " <<eventQuality << endl;
1205  fHistoNEvents[iCut]->Fill(eventQuality);
1206  continue;
1207  }
1208 
1209  fHistoNEvents[iCut]->Fill(eventQuality);
1211  if(!fDoLightOutput){
1212  fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)));
1213  }
1214  if(fMCEvent){ // Process MC Particle
1215  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
1216  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1217  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1218  fMCEvent);
1219  }
1221  }
1222 
1223  if (fNeutralPionMode < 2){
1224  ProcessConversionPhotonCandidates(); // Process this cuts conversion gammas
1225  }
1226  if (fNeutralPionMode > 0){
1227  ProcessCaloPhotonCandidates(); // Process this cuts calo gammas
1228  }
1229 
1230  if (fNeutralPionMode == 0 ){
1231  ProcessNeutralPionCandidatesPureConversions(); // Process neutral pion candidates purely from conversions
1232  }
1233  if (fNeutralPionMode == 1){
1234  ProcessNeutralPionCandidatesMixedConvCalo(); // Process neutral pion candidates mixed conv and calo
1235  }
1236  if (fNeutralPionMode == 2){
1237  ProcessNeutralPionCandidatesPureCalo(); // Process neutral pion candidates purely from calo
1238  }
1239 
1240  ProcessPionCandidates(); // Process this cuts gammas
1241 
1245 
1250 
1251  fGoodConvGammas->Clear();
1252  fClusterCandidates->Clear();
1253  fNeutralPionCandidates->Clear();
1255  fPosPionCandidates->Clear();
1256  fNegPionCandidates->Clear();
1257  fGoodVirtualParticles->Clear(); // delete this cuts good gammas
1258  }
1259 
1260  fSelectorNegPionIndex.clear();
1261  fSelectorPosPionIndex.clear();
1262 
1263  PostData( 1, fOutputContainer );
1264 }
1265 //________________________________________________________________________
1267  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1268  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
1269  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
1270  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
1271  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
1272  }
1273 
1274  if( !((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift() ){
1275  if(!fDoLightOutput){
1276  fProfileEtaShift[iCut]->Fill(0.,0.);
1277  }
1278  continue; // No Eta Shift requested, continue
1279  }
1280  if( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
1281  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
1282  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1283  ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->SetEtaShift( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() );
1284  if(!fDoLightOutput){
1285  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1286  }
1287  continue;
1288  } else {
1289  printf(" Eta t PiPlusPiMinus Gamma Task %s :: Eta Shift Manually Set to %f \n\n",
1290  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
1291  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1292  ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->SetEtaShift( ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() );
1293  if(!fDoLightOutput){
1294  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1295  }
1296  }
1297  }
1298  return kTRUE;
1299 }
1300 
1301 
1304 }
1305 
1306 
1307 //________________________________________________________________________
1309 {
1310 
1311  Int_t nclus = 0;
1312  nclus = fInputEvent->GetNumberOfCaloClusters();
1313 
1314 // cout << nclus << endl;
1315 
1316  if(nclus == 0) return;
1317 
1318  // vertex
1319  Double_t vertex[3] = {0};
1320  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1321 
1322  // Loop over EMCal clusters
1323  for(Long_t i = 0; i < nclus; i++){
1324 
1325  AliVCluster* clus = NULL;
1326  if(fInputEvent->IsA()==AliESDEvent::Class()) clus = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(i));
1327  else if(fInputEvent->IsA()==AliAODEvent::Class()) clus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i));
1328 
1329  if (!clus) continue;
1330  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC,1.,i)){ delete clus; continue;}
1331  // TLorentzvector with cluster
1332  TLorentzVector clusterVector;
1333  clus->GetMomentum(clusterVector,vertex);
1334 
1335  TLorentzVector* tmpvec = new TLorentzVector();
1336  tmpvec->SetPxPyPzE(clusterVector.Px(),clusterVector.Py(),clusterVector.Pz(),clusterVector.E());
1337 
1338  // convert to AODConversionPhoton
1339  AliAODConversionPhoton *PhotonCandidate=new AliAODConversionPhoton(tmpvec);
1340  if(!PhotonCandidate){ delete clus; delete tmpvec; continue;}
1341 
1342  // Flag Photon as CaloPhoton
1343  PhotonCandidate->SetIsCaloPhoton();
1344  PhotonCandidate->SetCaloClusterRef(i);
1345  // get MC label
1346  if(fIsMC){
1347  Int_t* mclabelsCluster = clus->GetLabels();
1348  PhotonCandidate->SetNCaloPhotonMCLabels(clus->GetNLabels());
1349 // cout << clus->GetNLabels() << endl;
1350  if (clus->GetNLabels()>0){
1351  for (Int_t k =0; k< (Int_t)clus->GetNLabels(); k++){
1352  if (k< 50)PhotonCandidate->SetCaloPhotonMCLabel(k,mclabelsCluster[k]);
1353 // Int_t pdgCode = fMCEvent->Particle(mclabelsCluster[k])->GetPdgCode();
1354 // cout << "label " << k << "\t" << mclabelsCluster[k] << " pdg code: " << pdgCode << endl;
1355  }
1356  }
1357  }
1358 
1359  fIsFromMBHeader = kTRUE;
1360  // test whether largest contribution to cluster orginates in added signals
1361  if (fIsMC && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetCaloPhotonMCLabel(0), fMCEvent, fInputEvent) == 0) fIsFromMBHeader = kFALSE;
1362 
1363  if (fIsFromMBHeader && (!fDoLightOutput)){
1364  fHistoClusterGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
1365  fHistoClusterGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1366  }
1367  fClusterCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
1368 
1369  if(fIsMC){
1370 // if(fInputEvent->IsA()==AliESDEvent::Class()){
1371  ProcessTrueCaloPhotonCandidates(PhotonCandidate);
1372 // } else {
1373 // ProcessTrueClusterCandidatesAOD(PhotonCandidate);
1374 // }
1375  }
1376 
1377  delete clus;
1378  delete tmpvec;
1379  }
1380 
1381 }
1382 
1383 //________________________________________________________________________
1385 {
1386  TParticle *Photon = NULL;
1387  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
1388  if (TruePhotonCandidate->GetCaloPhotonMCLabel(0)<0) return;
1389 // fHistoTrueNLabelsInClus[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels());
1390 
1391  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
1392  Double_t mcProdVtxX = primVtxMC->GetX();
1393  Double_t mcProdVtxY = primVtxMC->GetY();
1394  Double_t mcProdVtxZ = primVtxMC->GetZ();
1395 
1396  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0)Photon = fMCEvent->Particle(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
1397  else return;
1398 
1399  if(Photon == NULL){
1400  // cout << "no photon" << endl;
1401  return;
1402  }
1403 
1404 // Int_t pdgCodeParticle = Photon->GetPdgCode();
1405  TruePhotonCandidate->SetCaloPhotonMCFlags(fMCEvent, kFALSE);
1406 
1407  // True Photon
1408  if(fIsFromMBHeader && (!fDoLightOutput)){
1409  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, TruePhotonCandidate->GetCaloPhotonMCLabel(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
1410  if(isPrimary){
1411  if (TruePhotonCandidate->IsLargestComponentPhoton()){
1412  fHistoTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1414  fHistoTrueClusterGammaFromNeutralMesonPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1415  }
1416  }
1417  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
1418  fHistoTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1420  fHistoTrueClusterGammaFromNeutralMesonPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1421  }
1422  }
1423  }
1424  }
1425  return;
1426 }
1427 
1428 
1429 
1430 //________________________________________________________________________
1432  Int_t nV0 = 0;
1433  TList *GoodGammasStepOne = new TList();
1434  TList *GoodGammasStepTwo = new TList();
1435  // Loop over Photon Candidates allocated by ReaderV1
1436 
1437  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
1438  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
1439  if(!PhotonCandidate) continue;
1440 
1441  fIsFromMBHeader = kTRUE;
1442 
1443  if( fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0 ){
1444  Int_t isPosFromMBHeader
1445  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
1446  if(isPosFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
1447  Int_t isNegFromMBHeader
1448  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent,fInputEvent);
1449  if(isNegFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
1450  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
1451  }
1452 
1453  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fESDEvent)) continue;
1454 
1455  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut() &&
1456  !((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // if no post reader loop is required add to events good gammas
1457 
1458  fGoodConvGammas->Add(PhotonCandidate);
1459 
1460  if(fIsFromMBHeader && (!fDoLightOutput)){
1461  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
1462  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1463  }
1464 
1465  if(fMCEvent){
1466  ProcessTrueConversionPhotonCandidates(PhotonCandidate);
1467  }
1468  } else if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
1469  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
1470  nV0++;
1471  GoodGammasStepOne->Add(PhotonCandidate);
1472  } else if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut() &&
1473  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
1474  GoodGammasStepTwo->Add(PhotonCandidate);
1475  }
1476  }
1477 
1478 
1479  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut()){
1480  for(Int_t i = 0;i<GoodGammasStepOne->GetEntries();i++){
1481  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GoodGammasStepOne->At(i);
1482  if(!PhotonCandidate) continue;
1483  fIsFromMBHeader = kTRUE;
1484  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
1485  Int_t isPosFromMBHeader
1486  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent,fInputEvent);
1487  Int_t isNegFromMBHeader
1488  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent,fInputEvent);
1489  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
1490  }
1491  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GoodGammasStepOne->GetEntries())) continue;
1492  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
1493  fGoodConvGammas->Add(PhotonCandidate);
1494  if(fIsFromMBHeader && (!fDoLightOutput)){
1495  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
1496  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1497  }
1498  if(fMCEvent){
1499  ProcessTrueConversionPhotonCandidates(PhotonCandidate);
1500  }
1501  }
1502  else GoodGammasStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
1503  }
1504  }
1505  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){
1506  for(Int_t i = 0;i<GoodGammasStepTwo->GetEntries();i++){
1507  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GoodGammasStepTwo->At(i);
1508  if(!PhotonCandidate) continue;
1509 
1510  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
1511  Int_t isPosFromMBHeader
1512  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent,fInputEvent);
1513  Int_t isNegFromMBHeader
1514  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent,fInputEvent);
1515  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
1516  }
1517 
1518  if(!((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GoodGammasStepTwo,i)) continue;
1519  fGoodConvGammas->Add(PhotonCandidate); // Add gamma to current cut TList
1520 
1521  if(fIsFromMBHeader && (!fDoLightOutput)){
1522  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt()); // Differences to old V0Reader in p_t due to conversion KF->TLorentzVector
1523  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1524  }
1525 
1526  if(fMCEvent){
1527  ProcessTrueConversionPhotonCandidates(PhotonCandidate);
1528  }
1529  }
1530  }
1531 
1532  delete GoodGammasStepOne;
1533  GoodGammasStepOne = 0x0;
1534  delete GoodGammasStepTwo;
1535  GoodGammasStepTwo = 0x0;
1536 }
1537 
1538 //________________________________________________________________________
1540 {
1541  // Process True Photons
1542  TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCEvent);
1543  TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCEvent);
1544 
1545  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
1546  Double_t mcProdVtxX = primVtxMC->GetX();
1547  Double_t mcProdVtxY = primVtxMC->GetY();
1548  Double_t mcProdVtxZ = primVtxMC->GetZ();
1549 
1550 
1551  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
1552  if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){ // Not Same Mother == Combinatorial Bck
1553  return;
1554  }
1555 
1556  else if (posDaughter->GetMother(0) == -1){
1557  return;
1558  }
1559 
1560  if(TMath::Abs(posDaughter->GetPdgCode())!=11 || TMath::Abs(negDaughter->GetPdgCode())!=11) return; //One Particle is not electron
1561  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
1562  if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
1563 
1564  TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCEvent);
1565  if(Photon->GetPdgCode() != 22) return; // Mother is no Photon
1566 
1567  // True Photon
1568 
1569  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueConvGammas,posDaughter->GetMother(0)) && (!fDoLightOutput)) fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt());
1570 
1571  Int_t labelGamma = TruePhotonCandidate->GetMCParticleLabel(fMCEvent);
1572  Bool_t gammaIsPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelGamma, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
1573  if( gammaIsPrimary ){
1574  if( fIsFromMBHeader && (!fDoLightOutput) ){
1575  fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1577  fHistoTrueConvGammaFromNeutralMesonPt[fiCut]->Fill(TruePhotonCandidate->Pt());
1578  }
1579  }
1580  }
1581 }
1582 
1583 //________________________________________________________________________
1585  // Conversion Gammas
1586  if(fGoodConvGammas->GetEntries()>1){
1587  for(Int_t firstGammaIndex=0;firstGammaIndex<fGoodConvGammas->GetEntries()-1;firstGammaIndex++){
1588  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGoodConvGammas->At(firstGammaIndex));
1589  if (gamma0==NULL) continue;
1590  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGoodConvGammas->GetEntries();secondGammaIndex++){
1591  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGoodConvGammas->At(secondGammaIndex));
1592  //Check for same Electron ID
1593  if (gamma1==NULL) continue;
1594  if(gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelPositive() ||
1595  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelNegative() ||
1596  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelPositive() ||
1597  gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelNegative() ) continue;
1598 
1599  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0,gamma1);
1600  pi0cand->SetLabels(firstGammaIndex,secondGammaIndex);
1601 
1602  pi0cand->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
1603  if((((AliConversionMesonCuts*)fNeutralPionMesonCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
1604  if(!fDoLightOutput){
1605  fHistoGammaGammaInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
1606  }
1607  if(fIsMC){
1608  if(fInputEvent->IsA()==AliESDEvent::Class())
1609  ProcessTrueNeutralPionCandidatesPureConversions(pi0cand,gamma0,gamma1);
1610  if(fInputEvent->IsA()==AliAODEvent::Class())
1612  }
1613  if (pi0cand->M() > ((AliConversionMesonCuts*)fNeutralPionMesonCutArray->At(fiCut))->GetSelectionLow() && pi0cand->M() < ((AliConversionMesonCuts*)fNeutralPionMesonCutArray->At(fiCut))->GetSelectionHigh()){
1614  fNeutralPionCandidates->Add(pi0cand);
1615  // cout << "Pi0 candidate " << pi0cand->M() << "\t" << pi0cand->Pt() << endl;
1616 
1617  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixing()) && (pi0cand->M() > ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingLow() && pi0cand->M() < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingHigh())){
1618  fNeutralPionSidebandCandidates->Add(pi0cand);
1619  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixingBothSides())
1620  && ((pi0cand->M() > ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingLeftLow() && pi0cand->M() < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingLeftHigh())
1621  || (pi0cand->M() > ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingRightLow() && pi0cand->M() < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingRightHigh())))
1622  {
1623  fNeutralPionSidebandCandidates->Add(pi0cand);
1624  } else{
1625  delete pi0cand;
1626  pi0cand=0x0;
1627  }
1628  }else{
1629  delete pi0cand;
1630  pi0cand=0x0;
1631  }
1632  }
1633  }
1634  }
1635 }
1636 
1637 
1638 //________________________________________________________________________
1640 
1641  // Conversion Gammas
1642  if(fClusterCandidates->GetEntries()>0){
1643 
1644  // vertex
1645  Double_t vertex[3] = {0};
1646  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1647 
1648  for(Int_t firstGammaIndex=0;firstGammaIndex<fClusterCandidates->GetEntries();firstGammaIndex++){
1649  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(firstGammaIndex));
1650  if (gamma0==NULL) continue;
1651 
1652  for(Int_t secondGammaIndex=0;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
1653  if (firstGammaIndex == secondGammaIndex) continue;
1654  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
1655  if (gamma1==NULL) continue;
1656 
1657  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0,gamma1);
1658  pi0cand->SetLabels(firstGammaIndex,secondGammaIndex);
1659 
1660  if((((AliConversionMesonCuts*)fNeutralPionMesonCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
1661  if(!fDoLightOutput){
1662  fHistoGammaGammaInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
1663  }
1664  if(fIsMC){
1665 // if(fInputEvent->IsA()==AliESDEvent::Class())
1666  ProcessTrueNeutralPionCandidatesPureCalo(pi0cand,gamma0,gamma1);
1667 // if(fInputEvent->IsA()==AliAODEvent::Class())
1668 // ProcessTrueNeutralPionCandidatesPureConversionsAOD(pi0cand,gamma0,gamma1);
1669  }
1670  if (pi0cand->M() > ((AliConversionMesonCuts*)fNeutralPionMesonCutArray->At(fiCut))->GetSelectionLow() && pi0cand->M() < ((AliConversionMesonCuts*)fNeutralPionMesonCutArray->At(fiCut))->GetSelectionHigh()){
1671  fNeutralPionCandidates->Add(pi0cand);
1672  // cout << "Pi0 candidate " << pi0cand->M() << "\t" << pi0cand->Pt() << endl;
1673  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixing()) && (pi0cand->M() > ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingLow() && pi0cand->M() < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingHigh())){
1674  fNeutralPionSidebandCandidates->Add(pi0cand);
1675  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixingBothSides())
1676  && ((pi0cand->M() > ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingLeftLow() && pi0cand->M() < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingLeftHigh())
1677  || (pi0cand->M() > ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingRightLow() && pi0cand->M() < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingRightHigh())))
1678  {
1679  fNeutralPionSidebandCandidates->Add(pi0cand);
1680  }else {
1681  delete pi0cand;
1682  pi0cand=0x0;
1683  }
1684 
1685  }else{
1686  delete pi0cand;
1687  pi0cand=0x0;
1688  }
1689  }
1690  }
1691  }
1692 }
1693 
1694 //______________________________________________________________________
1696 {
1697  // Process True Mesons
1698 
1699  Bool_t isTruePi0 = kFALSE;
1700  Int_t gamma0MCLabel = TrueGammaCandidate0->GetCaloPhotonMCLabel(0); // get most probable MC label
1701  Int_t gamma0MotherLabel = -1;
1702  Int_t motherRealLabel = -1;
1703 
1704  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
1705  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
1706  if (TrueGammaCandidate0->IsLargestComponentPhoton() || TrueGammaCandidate0->IsLargestComponentElectron()){ // largest component is electro magnetic
1707  // get mother of interest (pi0 or eta)
1708  if (TrueGammaCandidate0->IsLargestComponentPhoton()){ // for photons its the direct mother
1709  gamma0MotherLabel=gammaMC0->GetMother(0);
1710  motherRealLabel=gammaMC0->GetFirstMother();
1711  } else if (TrueGammaCandidate0->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
1712  if (TrueGammaCandidate0->IsConversion() && gammaMC0->GetMother(0)>-1){
1713  gamma0MotherLabel=fMCEvent->Particle(gammaMC0->GetMother(0))->GetMother(0);
1714  motherRealLabel=fMCEvent->Particle(gammaMC0->GetMother(0))->GetMother(0);
1715  } else {
1716  gamma0MotherLabel=gammaMC0->GetMother(0);
1717  motherRealLabel=gammaMC0->GetMother(0);
1718  }
1719  }
1720  }
1721  }
1722 
1723  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
1724 
1725  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
1726  Int_t gamma1MotherLabel = -1;
1727  // check if
1728  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
1729  // Daughters Gamma 1
1730  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
1731  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
1732  // get mother of interest (pi0 or eta)
1733  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
1734  gamma1MotherLabel=gammaMC1->GetMother(0);
1735  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
1736  if (TrueGammaCandidate1->IsConversion() && gammaMC1->GetMother(0)>-1) gamma1MotherLabel=fMCEvent->Particle(gammaMC1->GetMother(0))->GetMother(0);
1737  else gamma1MotherLabel=gammaMC1->GetMother(0);
1738  }
1739  }
1740  }
1741 
1742  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
1743  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
1744  isTruePi0=kTRUE;
1745  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel) && (!fDoLightOutput)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1746  }
1747  }
1748 
1749  if(isTruePi0){// True Pion
1750  Pi0Candidate->SetTrueMesonValue(1);
1751  Pi0Candidate->SetMCLabel(motherRealLabel);
1752  if(!fDoLightOutput){
1753  fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1754  if( IsEtaPiPlPiMiPiZeroDaughter(motherRealLabel) ) {
1755  fHistoTrueMotherGammaGammaFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1756  }
1757  if( IsOmegaPiPlPiMiPiZeroDaughter(motherRealLabel) ) {
1758  fHistoTrueMotherGammaGammaFromOmegaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1759  }
1760  }
1761  }
1762 }
1763 
1764 
1765 
1766 //______________________________________________________________________
1768 {
1769  // Process True Mesons
1770  if(TrueGammaCandidate0->GetV0Index()<fInputEvent->GetNumberOfV0s()){
1771  Bool_t isTruePi0 = kFALSE;
1772  Bool_t isTruePi0Dalitz = kFALSE;
1773  Bool_t gamma0DalitzCand = kFALSE;
1774  Bool_t gamma1DalitzCand = kFALSE;
1775  Int_t gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCEvent);
1776  Int_t gamma0MotherLabel = -1;
1777  Int_t motherRealLabel = -1;
1778  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
1779  // Daughters Gamma 0
1780  TParticle * negativeMC = (TParticle*)TrueGammaCandidate0->GetNegativeMCDaughter(fMCEvent);
1781  TParticle * positiveMC = (TParticle*)TrueGammaCandidate0->GetPositiveMCDaughter(fMCEvent);
1782  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
1783  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
1784  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
1785  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
1786  gamma0MotherLabel=gammaMC0->GetFirstMother();
1787  motherRealLabel=gammaMC0->GetFirstMother();
1788  }
1789  }
1790  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
1791  gamma0DalitzCand = kTRUE;
1792  gamma0MotherLabel=-111;
1793  motherRealLabel=gamma0MCLabel;
1794  }
1795  }
1796  }
1797  if(TrueGammaCandidate1->GetV0Index()<fInputEvent->GetNumberOfV0s()){
1798  Int_t gamma1MCLabel = TrueGammaCandidate1->GetMCParticleLabel(fMCEvent);
1799  Int_t gamma1MotherLabel = -1;
1800  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
1801  // Daughters Gamma 1
1802  TParticle * negativeMC = (TParticle*)TrueGammaCandidate1->GetNegativeMCDaughter(fMCEvent);
1803  TParticle * positiveMC = (TParticle*)TrueGammaCandidate1->GetPositiveMCDaughter(fMCEvent);
1804  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
1805  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
1806  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
1807  if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
1808  gamma1MotherLabel=gammaMC1->GetFirstMother();
1809  }
1810  }
1811  if(gammaMC1->GetPdgCode() ==111 ){ // Dalitz candidate
1812  gamma1DalitzCand = kTRUE;
1813  gamma1MotherLabel=-111;
1814  }
1815  }
1816  }
1817  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
1818  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
1819  isTruePi0=kTRUE;
1820  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel) && (!fDoLightOutput)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1821  }
1822  }
1823 
1824  //Identify Dalitz candidate
1825  if (gamma1DalitzCand || gamma0DalitzCand){
1826  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
1827  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
1828  }
1829  if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
1830  if (gamma1MotherLabel == -111) isTruePi0Dalitz = kTRUE;
1831  }
1832  }
1833 
1834 
1835  if(isTruePi0 || isTruePi0Dalitz){// True Pion
1836  Pi0Candidate->SetTrueMesonValue(1);
1837  Pi0Candidate->SetMCLabel(motherRealLabel);
1838  if(!fDoLightOutput){
1839  fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1840  if( IsEtaPiPlPiMiPiZeroDaughter(motherRealLabel) ) {
1841  fHistoTrueMotherGammaGammaFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1842  }
1843  if( IsOmegaPiPlPiMiPiZeroDaughter(motherRealLabel) ) {
1844  fHistoTrueMotherGammaGammaFromOmegaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1845  }
1846  }
1847  }
1848  }
1849  }
1850 }
1851 
1852 //______________________________________________________________________
1854 {
1855 
1856  // Process True Mesons
1857  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
1858  Bool_t isTruePi0 = kFALSE;
1859  Bool_t isTruePi0Dalitz = kFALSE;
1860  Bool_t gamma0DalitzCand = kFALSE;
1861  Bool_t gamma1DalitzCand = kFALSE;
1862  Int_t motherRealLabel = -1;
1863 
1864  if (AODMCTrackArray!=NULL && TrueGammaCandidate0 != NULL){
1865  AliAODMCParticle *positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
1866  AliAODMCParticle *negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
1867 
1868  Int_t gamma0MCLabel = -1;
1869  Int_t gamma0MotherLabel = -1;
1870  if(!positiveMC||!negativeMC)
1871  return;
1872 
1873  if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
1874  gamma0MCLabel = positiveMC->GetMother();
1875  }
1876 
1877  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
1878  // Daughters Gamma 0
1879  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
1880  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
1881  if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
1882  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
1883  gamma0MotherLabel=gammaMC0->GetMother();
1884  motherRealLabel=gammaMC0->GetMother();
1885  }
1886  }
1887  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
1888  gamma0DalitzCand = kTRUE;
1889  gamma0MotherLabel=-111;
1890  motherRealLabel=gamma0MCLabel;
1891  }
1892  }
1893  }
1894  positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelPositive()));
1895  negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelNegative()));
1896 
1897  Int_t gamma1MCLabel = -1;
1898  Int_t gamma1MotherLabel = -1;
1899  if(!positiveMC||!negativeMC)
1900  return;
1901 
1902  if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
1903  gamma1MCLabel = positiveMC->GetMother();
1904  }
1905  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
1906  // Daughters Gamma 1
1907  AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
1908  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
1909  if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
1910  if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
1911  gamma1MotherLabel=gammaMC1->GetMother();
1912  }
1913  }
1914  if(gammaMC1->GetPdgCode() ==111 ){ // Dalitz candidate
1915  gamma1DalitzCand = kTRUE;
1916  gamma1MotherLabel=-111;
1917  }
1918  }
1919  }
1920  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
1921  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
1922  isTruePi0=kTRUE;
1923  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel) &&(!fDoLightOutput)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1924  }
1925  }
1926 
1927  //Identify Dalitz candidate
1928  if (gamma1DalitzCand || gamma0DalitzCand){
1929  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
1930  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
1931  }
1932  if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
1933  if (gamma1MotherLabel == -111) isTruePi0Dalitz = kTRUE;
1934  }
1935  }
1936 
1937  if(isTruePi0 || isTruePi0Dalitz){// True Pion
1938  Pi0Candidate->SetTrueMesonValue(1);
1939  Pi0Candidate->SetMCLabel(motherRealLabel);
1940  if(!fDoLightOutput){
1941  fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1942  if( IsEtaPiPlPiMiPiZeroDaughter(motherRealLabel) ) {
1943  fHistoTrueMotherGammaGammaFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1944  }
1945  if( IsOmegaPiPlPiMiPiZeroDaughter(motherRealLabel) ) {
1946  fHistoTrueMotherGammaGammaFromOmegaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
1947  }
1948  }
1949  }
1950  }
1951  return;
1952 }
1953 
1954 
1955 //________________________________________________________________________
1957 
1958  // Conversion Gammas
1959  if(fGoodConvGammas->GetEntries()>0){
1960  // vertex
1961  Double_t vertex[3] = {0};
1962  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1963 
1964  for(Int_t firstGammaIndex=0;firstGammaIndex<fGoodConvGammas->GetEntries();firstGammaIndex++){
1965  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGoodConvGammas->At(firstGammaIndex));
1966  if (gamma0==NULL) continue;
1967 
1968  for(Int_t secondGammaIndex=0;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
1969  Bool_t matched = kFALSE;
1970  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
1971  if (gamma1==NULL) continue;
1972 
1973  if (gamma1->GetIsCaloPhoton()){
1974  AliVCluster* cluster = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
1975  matched = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma0,cluster, fInputEvent );
1976  }
1977 
1978  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0,gamma1);
1979  pi0cand->SetLabels(firstGammaIndex,secondGammaIndex);
1980 
1981  if((((AliConversionMesonCuts*)fNeutralPionMesonCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
1982  if (!matched){
1983  if(!fDoLightOutput){
1984  fHistoGammaGammaInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
1985  }
1986  if(fIsMC){
1987 // if(fInputEvent->IsA()==AliESDEvent::Class())
1988  ProcessTrueNeutralPionCandidatesMixedConvCalo(pi0cand,gamma0,gamma1);
1989 // if(fInputEvent->IsA()==AliAODEvent::Class())
1990 // ProcessTrueMesonCandidatesAOD(pi0cand,gamma0,gamma1, matched);
1991  }
1992  if (pi0cand->M() > ((AliConversionMesonCuts*)fNeutralPionMesonCutArray->At(fiCut))->GetSelectionLow() && pi0cand->M() < ((AliConversionMesonCuts*)fNeutralPionMesonCutArray->At(fiCut))->GetSelectionHigh()){
1993  fNeutralPionCandidates->Add(pi0cand);
1994  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixing()) && (pi0cand->M() > ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingLow() && pi0cand->M() < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingHigh())){
1995  fNeutralPionSidebandCandidates->Add(pi0cand);
1996  } else if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixingBothSides())
1997  && ((pi0cand->M() > ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingLeftLow() && pi0cand->M() < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingLeftHigh())
1998  || (pi0cand->M() > ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingRightLow() && pi0cand->M() < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetSidebandMixingRightHigh())))
1999  {
2000  fNeutralPionSidebandCandidates->Add(pi0cand);
2001  }else{
2002  delete pi0cand;
2003  pi0cand=0x0;
2004  }
2005 
2006  }else{
2007  delete pi0cand;
2008  pi0cand=0x0;
2009  }
2010  }else{
2011  delete pi0cand;
2012  pi0cand=0x0;
2013  }
2014  }
2015  }
2016  }
2017 }
2018 
2019 //______________________________________________________________________
2021 {
2022  // Process True Mesons
2023  if(TrueGammaCandidate0->GetV0Index()<fInputEvent->GetNumberOfV0s()){
2024  Bool_t isTruePi0 = kFALSE;
2025  Bool_t isTruePi0Dalitz = kFALSE;
2026  Bool_t gamma0DalitzCand = kFALSE;
2027 
2028  Int_t gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCEvent);
2029  Int_t gamma0MotherLabel = -1;
2030  Int_t motherRealLabel = -1;
2031  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2032  // Daughters Gamma 0
2033  TParticle * negativeMC = (TParticle*)TrueGammaCandidate0->GetNegativeMCDaughter(fMCEvent);
2034  TParticle * positiveMC = (TParticle*)TrueGammaCandidate0->GetPositiveMCDaughter(fMCEvent);
2035  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
2036  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
2037  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
2038  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
2039  gamma0MotherLabel=gammaMC0->GetFirstMother();
2040  motherRealLabel=gammaMC0->GetFirstMother();
2041  }
2042  }
2043  if(gammaMC0->GetPdgCode() ==111){ // Dalitz candidate
2044  gamma0DalitzCand = kTRUE;
2045  gamma0MotherLabel=-111;
2046  motherRealLabel=gamma0MCLabel;
2047  }
2048 
2049  }
2050  }
2051 
2052  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2053 
2054  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
2055  Int_t gamma1MotherLabel = -1;
2056  // check if
2057 
2058  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2059  // Daughters Gamma 1
2060  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
2061  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
2062  // get mother of interest (pi0 or eta)
2063  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
2064  gamma1MotherLabel=gammaMC1->GetMother(0);
2065  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
2066  if (TrueGammaCandidate1->IsConversion() && gammaMC1->GetMother(0)>-1) gamma1MotherLabel=fMCEvent->Particle(gammaMC1->GetMother(0))->GetMother(0);
2067  else gamma1MotherLabel=gammaMC1->GetMother(0);
2068  }
2069  }
2070  }
2071 
2072  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
2073  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
2074  isTruePi0=kTRUE;
2075  if (CheckVectorForDoubleCount(fVectorDoubleCountTruePi0s,gamma0MotherLabel) && (!fDoLightOutput)) fHistoDoubleCountTruePi0InvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2076  }
2077  }
2078 
2079  if (gamma0DalitzCand ){
2080  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
2081  if (gamma0MotherLabel == -111) isTruePi0Dalitz = kTRUE;
2082  }
2083  }
2084 
2085  if(isTruePi0 || isTruePi0Dalitz ){
2086  Pi0Candidate->SetTrueMesonValue(1);
2087  Pi0Candidate->SetMCLabel(motherRealLabel);
2088  if(!fDoLightOutput){
2089  fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2090  if( IsEtaPiPlPiMiPiZeroDaughter(motherRealLabel) ) {
2091  fHistoTrueMotherGammaGammaFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2092  }
2093  if( IsOmegaPiPlPiMiPiZeroDaughter(motherRealLabel) ) {
2094  fHistoTrueMotherGammaGammaFromOmegaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
2095  }
2096  }
2097  }
2098  }
2099 }
2100 
2101 
2102 
2103 //________________________________________________________________________
2105 
2106  Double_t magField = fInputEvent->GetMagneticField();
2107  if( magField < 0.0 ){
2108  magField = 1.0;
2109  } else {
2110  magField = -1.0;
2111  }
2112 
2113  vector<Int_t> lGoodNegPionIndexPrev(0);
2114  vector<Int_t> lGoodPosPionIndexPrev(0);
2115 
2116  for(UInt_t i = 0; i < fSelectorNegPionIndex.size(); i++){
2117  AliESDtrack* negPionCandidate = fESDEvent->GetTrack(fSelectorNegPionIndex[i]);
2118  if(! ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelected(negPionCandidate) ) continue;
2119  lGoodNegPionIndexPrev.push_back( fSelectorNegPionIndex[i] );
2120 
2121  TLorentzVector *negPionforHandler = new TLorentzVector();
2122  negPionforHandler->SetPxPyPzE(negPionCandidate->Px(), negPionCandidate->Py(), negPionCandidate->Pz(), negPionCandidate->E());
2123 
2124  AliAODConversionPhoton *negPionHandler = new AliAODConversionPhoton(negPionforHandler);
2125  delete negPionforHandler;
2126 
2127  fNegPionCandidates->Add(negPionHandler);
2128  if(!fDoLightOutput){
2129  fHistoNegPionPt[fiCut]->Fill(negPionCandidate->Pt());
2130  fHistoNegPionPhi[fiCut]->Fill(negPionCandidate->Phi());
2131  }
2132 
2133  if( fMCEvent ) {
2134  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2135  Double_t mcProdVtxX = primVtxMC->GetX();
2136  Double_t mcProdVtxY = primVtxMC->GetY();
2137  Double_t mcProdVtxZ = primVtxMC->GetZ();
2138 
2139  Int_t labelNegPion = TMath::Abs( negPionCandidate->GetLabel() );
2140  Bool_t negPionIsPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelNegPion, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2141  if( labelNegPion>-1 && labelNegPion < fMCEvent->GetNumberOfTracks() ){
2142  TParticle* negPion = fMCEvent->Particle(labelNegPion);
2143  if( negPion->GetPdgCode() == -211 ){
2144  if(!fDoLightOutput){
2145 
2146  if( negPionIsPrimary ){
2147  fHistoTrueNegPionPt[fiCut]->Fill(negPionCandidate->Pt()); //primary negPion
2148  }
2149  if( IsEtaPiPlPiMiPiZeroDaughter(labelNegPion) || IsOmegaPiPlPiMiPiZeroDaughter(labelNegPion) ) {
2150  if( negPionIsPrimary ) {
2151  fHistoTrueNegPionFromNeutralMesonPt[fiCut]->Fill(negPionCandidate->Pt());
2152  }
2153  }
2154  }
2155  }
2156  }
2157  }
2158  }
2159 
2160  for(UInt_t i = 0; i < fSelectorPosPionIndex.size(); i++){
2161  AliESDtrack* posPionCandidate = fESDEvent->GetTrack( fSelectorPosPionIndex[i] );
2162  if(! ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelected(posPionCandidate) ) continue;
2163  lGoodPosPionIndexPrev.push_back( fSelectorPosPionIndex[i] );
2164 
2165  TLorentzVector *posPionforHandler = new TLorentzVector();
2166  posPionforHandler->SetPxPyPzE(posPionCandidate->Px(), posPionCandidate->Py(), posPionCandidate->Pz(), posPionCandidate->E());
2167 
2168  AliAODConversionPhoton *posPionHandler = new AliAODConversionPhoton(posPionforHandler);
2169  delete posPionforHandler;
2170 
2171  fPosPionCandidates->Add(posPionHandler);
2172  if(!fDoLightOutput){
2173  fHistoPosPionPt[fiCut]->Fill( posPionCandidate->Pt() );
2174  fHistoPosPionPhi[fiCut]->Fill( posPionCandidate->Phi() );
2175  }
2176  if( fMCEvent ) {
2177  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2178  Double_t mcProdVtxX = primVtxMC->GetX();
2179  Double_t mcProdVtxY = primVtxMC->GetY();
2180  Double_t mcProdVtxZ = primVtxMC->GetZ();
2181 
2182  Int_t labelPosPion = TMath::Abs( posPionCandidate->GetLabel() );
2183  Bool_t posPionIsPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelPosPion, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2184  if( labelPosPion>-1 && labelPosPion < fMCEvent->GetNumberOfTracks() ) {
2185  TParticle* posPion = fMCEvent->Particle(labelPosPion);
2186  if( posPion->GetPdgCode() == 211 ){
2187  if(!fDoLightOutput){
2188  if( posPionIsPrimary ){
2189  fHistoTruePosPionPt[fiCut]->Fill(posPionCandidate->Pt());
2190  }
2191  if( IsEtaPiPlPiMiPiZeroDaughter(labelPosPion) || IsOmegaPiPlPiMiPiZeroDaughter(labelPosPion) ) {
2192  if(posPionIsPrimary){
2193  fHistoTruePosPionFromNeutralMesonPt[fiCut]->Fill(posPionCandidate->Pt());
2194  }
2195  }
2196  }
2197  }
2198  }
2199  }
2200  }
2201 
2202 
2203  for(UInt_t i = 0; i < lGoodNegPionIndexPrev.size(); i++){
2204  AliESDtrack *negPionCandidate = fESDEvent->GetTrack(lGoodNegPionIndexPrev[i]);
2205  AliKFParticle negPionCandidateKF( *negPionCandidate->GetConstrainedParam(), 211 );
2206 
2207  for(UInt_t j = 0; j < lGoodPosPionIndexPrev.size(); j++){
2208  AliESDtrack *posPionCandidate = fESDEvent->GetTrack(lGoodPosPionIndexPrev[j]);
2209  AliKFParticle posPionCandidateKF( *posPionCandidate->GetConstrainedParam(), 211 );
2210 
2211  AliKFConversionPhoton* virtualPhoton = NULL;
2212  virtualPhoton = new AliKFConversionPhoton(negPionCandidateKF,posPionCandidateKF);
2213  AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex());
2214 // primaryVertexImproved+=*virtualPhoton;
2215  virtualPhoton->SetProductionVertex(primaryVertexImproved);
2216  virtualPhoton->SetTrackLabels( lGoodPosPionIndexPrev[j], lGoodNegPionIndexPrev[i]);
2217 
2218  Int_t labeln=0;
2219  Int_t labelp=0;
2220  Int_t motherlabelp = 0;
2221  Int_t motherlabeln = 0;
2222  TParticle *fNegativeMCParticle =NULL;
2223  TParticle *fPositiveMCParticle =NULL;
2224  if( fMCEvent ) {
2225  labeln=TMath::Abs(negPionCandidate->GetLabel());
2226  labelp=TMath::Abs(posPionCandidate->GetLabel());
2227  if(labeln>-1) fNegativeMCParticle = fMCEvent->Particle(labeln);
2228  if(labelp>-1) fPositiveMCParticle = fMCEvent->Particle(labelp);
2229  // check whether MC particles exist, else abort
2230  if (fNegativeMCParticle == NULL || fPositiveMCParticle == NULL) return;
2231 
2232  motherlabeln = fNegativeMCParticle->GetMother(0);
2233  motherlabelp = fPositiveMCParticle->GetMother(0);
2234  virtualPhoton->SetMCLabelPositive(labelp);
2235  virtualPhoton->SetMCLabelNegative(labeln);
2236 
2237  }
2238 
2239  AliAODConversionPhoton *vParticle = new AliAODConversionPhoton(virtualPhoton); //To apply mass 2 pion mass cut
2240  if(!fDoLightOutput){
2241  if (fMCEvent &&(fDoMesonQA>0)){
2242  if (fPositiveMCParticle && fNegativeMCParticle ) {
2243  if (((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->DoMassCut()){
2244  if (vParticle->GetMass() < ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetMassCut()){
2245  if(TMath::Abs(fNegativeMCParticle->GetPdgCode())==211 && TMath::Abs(fPositiveMCParticle->GetPdgCode())==211){ // Pions ...
2246  fHistoTruePionPionInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2247  if (motherlabeln == motherlabelp){
2248  fHistoTruePionPionFromSameMotherInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2249  if( IsEtaPiPlPiMiPiZeroDaughter(labeln) ) { //|| IsOmegaPiPlPiMiPiZeroDaughter(labeln)
2250  fHistoTruePionPionFromEtaInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2251  }
2252  if( IsOmegaPiPlPiMiPiZeroDaughter(labeln) ) { //||
2253  fHistoTruePionPionFromOmegaInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2254  }
2255  }
2256  }
2257  }
2258  } else {
2259  if(TMath::Abs(fNegativeMCParticle->GetPdgCode())==211 && TMath::Abs(fPositiveMCParticle->GetPdgCode())==211){ // Pions ...
2260  fHistoTruePionPionInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2261  if (motherlabeln == motherlabelp){
2262  fHistoTruePionPionFromSameMotherInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2263  if( IsEtaPiPlPiMiPiZeroDaughter(labeln) ) { //|| IsOmegaPiPlPiMiPiZeroDaughter(labeln)
2264  fHistoTruePionPionFromEtaInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2265  }
2266  if( IsOmegaPiPlPiMiPiZeroDaughter(labeln) ) { //||
2267  fHistoTruePionPionFromOmegaInvMassPt[fiCut]->Fill(vParticle->GetMass(),vParticle->Pt());
2268  }
2269  }
2270  }
2271  }
2272  }
2273  }
2274  }
2275 
2276  if (((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->DoMassCut()){
2277  if (vParticle->GetMass() < ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetMassCut()){
2278  fGoodVirtualParticles->Add( vParticle );
2279  if(!fDoLightOutput){
2280  fHistoPionPionInvMassPt[fiCut]->Fill( vParticle->GetMass(),vParticle->Pt());
2281  }
2282  }else{
2283  delete vParticle;
2284  vParticle=0x0;
2285  }
2286  } else {
2287  fGoodVirtualParticles->Add( vParticle );
2288  if(!fDoLightOutput){
2289  fHistoPionPionInvMassPt[fiCut]->Fill( vParticle->GetMass(),vParticle->Pt());
2290  }
2291  }
2292 
2293  Double_t clsToFPos = -1.0;
2294  Double_t clsToFNeg = -1.0;
2295 
2296  Float_t dcaToVertexXYPos = -1.0;
2297  Float_t dcaToVertexZPos = -1.0;
2298  Float_t dcaToVertexXYNeg = -1.0;
2299  Float_t dcaToVertexZNeg = -1.0;
2300 
2301  if ( fDoMesonQA>0 ) {
2302  clsToFPos = ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetNFindableClustersTPC(posPionCandidate);
2303  clsToFNeg = ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetNFindableClustersTPC(negPionCandidate);
2304 
2305  Float_t bPos[2];
2306  Float_t bCovPos[3];
2307  posPionCandidate->GetImpactParameters(bPos,bCovPos);
2308  if (bCovPos[0]<=0 || bCovPos[2]<=0) {
2309  AliDebug(1, "Estimated b resolution lower or equal zero!");
2310  bCovPos[0]=0; bCovPos[2]=0;
2311  }
2312 
2313  Float_t bNeg[2];
2314  Float_t bCovNeg[3];
2315  posPionCandidate->GetImpactParameters(bNeg,bCovNeg);
2316  if (bCovNeg[0]<=0 || bCovNeg[2]<=0) {
2317  AliDebug(1, "Estimated b resolution lower or equal zero!");
2318  bCovNeg[0]=0; bCovNeg[2]=0;
2319  }
2320 
2321  dcaToVertexXYPos = bPos[0];
2322  dcaToVertexZPos = bPos[1];
2323  dcaToVertexXYNeg = bNeg[0];
2324  dcaToVertexZNeg = bNeg[1];
2325 
2326  if(!fDoLightOutput){
2327  fHistoNegPionEta[fiCut]->Fill( negPionCandidate->Eta() );
2328  fHistoPosPionEta[fiCut]->Fill( posPionCandidate->Eta() );
2329 
2330  fHistoNegPionClsTPC[fiCut]->Fill(clsToFNeg,negPionCandidate->Pt());
2331  fHistoPosPionClsTPC[fiCut]->Fill(clsToFPos,posPionCandidate->Pt());
2332 
2333  fHistoPionDCAxy[fiCut]->Fill( dcaToVertexXYNeg, negPionCandidate->Pt() );
2334  fHistoPionDCAz[fiCut]->Fill( dcaToVertexZNeg, negPionCandidate->Pt() );
2335  fHistoPionDCAxy[fiCut]->Fill( dcaToVertexXYPos, posPionCandidate->Pt() );
2336  fHistoPionDCAz[fiCut]->Fill( dcaToVertexZPos, posPionCandidate->Pt() );
2337 
2338  fHistoPionTPCdEdxNSigma[fiCut]->Fill( posPionCandidate->P(),((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetPIDResponse()->NumberOfSigmasTPC(posPionCandidate, AliPID::kPion) );
2339  fHistoPionTPCdEdxNSigma[fiCut]->Fill( negPionCandidate->P(),((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetPIDResponse()->NumberOfSigmasTPC(negPionCandidate, AliPID::kPion) );
2340 
2341  fHistoPionTPCdEdx[fiCut]->Fill( posPionCandidate->P(), TMath::Abs(posPionCandidate->GetTPCsignal()));
2342  fHistoPionTPCdEdx[fiCut]->Fill( negPionCandidate->P(), TMath::Abs(negPionCandidate->GetTPCsignal()));
2343  }
2344  }
2345 
2346  delete virtualPhoton;
2347  virtualPhoton=NULL;
2348  }
2349  }
2350 }
2351 
2352 //_____________________________________________________________________________
2354 
2355  // Loop over all primary MC particle
2356  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2357  Double_t mcProdVtxX = primVtxMC->GetX();
2358  Double_t mcProdVtxY = primVtxMC->GetY();
2359  Double_t mcProdVtxZ = primVtxMC->GetZ();
2360 
2361  for(Int_t i = 0; i < fMCEvent->GetNumberOfTracks(); i++) {
2362  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
2363 
2364  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
2365  if (!particle) continue;
2366 
2367  Int_t isMCFromMBHeader = -1;
2368  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2369  isMCFromMBHeader
2370  = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2371  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2372  }
2373 
2374  if(!fDoLightOutput){
2375  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent,fInputEvent)){
2376  // find MC photons
2377  if (fNeutralPionMode < 2){
2378  if(((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kFALSE)){
2379  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma
2380  if(particle->GetMother(0) >-1){
2381  if (fMCEvent->Particle(particle->GetMother(0))->GetPdgCode() ==111){
2382  if (fMCEvent->Particle(particle->GetMother(0))->GetMother(0) > -1){
2383  if ( fMCEvent->Particle((fMCEvent->Particle(particle->GetMother(0)))->GetMother(0))->GetPdgCode() == 221 ||
2384  fMCEvent->Particle((fMCEvent->Particle(particle->GetMother(0)))->GetMother(0))->GetPdgCode() == 223 ){
2385  if ( fMCEvent->Particle(particle->GetMother(0))->GetNDaughters()==3 )
2386  fHistoMCGammaFromNeutralMesonPt[fiCut]->Fill(particle->Pt()); // All photons from eta or omega via pi0
2387  }
2388  }
2389  }
2390  }
2391  }
2392  } else if (fNeutralPionMode == 2){
2393  if(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(particle,fMCEvent)){
2394  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma
2395  if(particle->GetMother(0) >-1){
2396  if (fMCEvent->Particle(particle->GetMother(0))->GetPdgCode() ==111){
2397  if (fMCEvent->Particle(particle->GetMother(0))->GetMother(0) > -1){
2398  if ( fMCEvent->Particle((fMCEvent->Particle(particle->GetMother(0)))->GetMother(0))->GetPdgCode() == 221 ||
2399  fMCEvent->Particle((fMCEvent->Particle(particle->GetMother(0)))->GetMother(0))->GetPdgCode() == 223 ){
2400  if ( fMCEvent->Particle(particle->GetMother(0))->GetNDaughters()==3 )
2401  fHistoMCGammaFromNeutralMesonPt[fiCut]->Fill(particle->Pt()); // All photons from eta or omega via pi0
2402  }
2403  }
2404  }
2405  }
2406  }
2407  }
2408  if (fNeutralPionMode < 2){
2409  if (((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCEvent,kTRUE)){
2410  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt());
2411  } // Converted MC Gamma
2412  }
2413  if(((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(i,fMCEvent)){
2414  if( particle->GetPdgCode() == 211){
2415  fHistoMCAllPosPionsPt[fiCut]->Fill(particle->Pt()); // All pos pions
2416  if(particle->GetMother(0) >-1){
2417  if (fMCEvent->Particle(particle->GetMother(0))->GetPdgCode() ==221 || fMCEvent->Particle(particle->GetMother(0))->GetPdgCode() ==223)
2418  fHistoMCPosPionsFromNeutralMesonPt[fiCut]->Fill(particle->Pt()); // All pos from eta or omega
2419  }
2420  }
2421  if( particle->GetPdgCode() == -211){
2422  fHistoMCAllNegPionsPt[fiCut]->Fill(particle->Pt()); // All neg pions
2423  if(particle->GetMother(0) >-1){
2424  if (fMCEvent->Particle(particle->GetMother(0))->GetPdgCode() ==221 || fMCEvent->Particle(particle->GetMother(0))->GetPdgCode() ==223 )
2425  fHistoMCNegPionsFromNeutralMesonPt[fiCut]->Fill(particle->Pt()); // All pos from eta or omega
2426  }
2427  }
2428  }
2429  }
2430 
2431  // \eta -> pi+ pi- \gamma
2432  Int_t labelNeutPion = -1;
2433  Int_t labelNegPion = -1;
2434  Int_t labelPosPion = -1;
2435 
2436  if( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMCPiPlPiMiPiZero(particle,fMCEvent,labelNegPion,labelPosPion,labelNeutPion,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2437  Float_t weighted= 1;
2438  if( ((AliPrimaryPionCuts*) fPionCutArray->At(fiCut))->DoWeights() ) {
2439  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent,fInputEvent)){
2440  if (particle->Pt()>0.005){
2441  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent,fInputEvent);
2442  }
2443  }
2444  }
2445  if(particle->GetPdgCode() == 221)fHistoMCEtaPiPlPiMiPiZeroPt[fiCut]->Fill(particle->Pt(), weighted); // All MC Eta in respective decay channel
2446  if(particle->GetPdgCode() == 223)fHistoMCOmegaPiPlPiMiPiZeroPt[fiCut]->Fill(particle->Pt(), weighted); // All MC Omega in respective decay channel
2447 
2448  if(labelNeutPion>-1){
2449  TParticle *neutPion = fMCEvent->Particle(labelNeutPion);
2450  if(neutPion->GetDaughter(0)>-1 && neutPion->GetDaughter(1)>-1){
2451  TParticle *gamma1 = fMCEvent->Particle(neutPion->GetDaughter(0));
2452  TParticle *gamma2 = fMCEvent->Particle(neutPion->GetDaughter(1));
2453  Bool_t kDaughter0IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, neutPion->GetDaughter(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2454  Bool_t kDaughter1IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, neutPion->GetDaughter(1), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2455  Bool_t kNegPionIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelNegPion, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2456  Bool_t kPosPionIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, labelPosPion, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2457 
2458  if (fNeutralPionMode < 2){
2459  if( kDaughter0IsPrim && kDaughter1IsPrim && kNegPionIsPrim && kPosPionIsPrim &&
2460  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(gamma1,fMCEvent,kFALSE) && // test first daugther of pi0
2461  ((AliConversionPhotonCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(gamma2,fMCEvent,kFALSE) && // test second daughter of pi0
2462  ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(labelNegPion,fMCEvent) && // test negative pion
2463  ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(labelPosPion,fMCEvent) // test positive pion
2464  ) {
2465  if(particle->GetPdgCode() == 221) fHistoMCEtaPiPlPiMiPiZeroInAccPt[fiCut]->Fill(particle->Pt(), weighted ); // MC Eta pi+ pi- pi0 with gamma's and e+e- in acc
2466  if(particle->GetPdgCode() == 223) fHistoMCOmegaPiPlPiMiPiZeroInAccPt[fiCut]->Fill(particle->Pt(), weighted ); // MC Omega pi+ pi- pi0 with gamma's and e+e- in acc
2467  }
2468  } else if (fNeutralPionMode == 2){
2469  if( kDaughter0IsPrim && kDaughter1IsPrim && kNegPionIsPrim && kPosPionIsPrim &&
2470  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma1,fMCEvent) && // test first daugther of pi0
2471  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma2,fMCEvent) && // test second daughter of pi0
2472  ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(labelNegPion,fMCEvent) && // test negative pion
2473  ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(labelPosPion,fMCEvent) // test positive pion
2474  ) {
2475  if(particle->GetPdgCode() == 221) fHistoMCEtaPiPlPiMiPiZeroInAccPt[fiCut]->Fill(particle->Pt(), weighted ); // MC Eta pi+ pi- pi0 with gamma's and e+e- in acc
2476  if(particle->GetPdgCode() == 223) fHistoMCOmegaPiPlPiMiPiZeroInAccPt[fiCut]->Fill(particle->Pt(), weighted ); // MC Omega pi+ pi- pi0 with gamma's and e+e- in acc
2477  }
2478  }
2479  }
2480  }
2481  }
2482  }
2483  }
2484  }
2485 }
2486 
2487 
2488 //________________________________________________________________________
2490 
2491  // Conversion Gammas
2492  if( fNeutralPionCandidates->GetEntries() > 0 && fGoodVirtualParticles->GetEntries() > 0 ){
2493  for(Int_t mesonIndex=0; mesonIndex<fNeutralPionCandidates->GetEntries(); mesonIndex++){
2494  AliAODConversionMother *neutralPion=dynamic_cast<AliAODConversionMother*>(fNeutralPionCandidates->At(mesonIndex));
2495  if (neutralPion==NULL) continue;
2496 
2497  // cut on pT of neutralPion
2498  if(neutralPion->Pt() < fNeutralPionPtMin) continue;
2499 
2500  for(Int_t virtualParticleIndex=0;virtualParticleIndex<fGoodVirtualParticles->GetEntries();virtualParticleIndex++){
2501 
2502  AliAODConversionPhoton *vParticle=dynamic_cast<AliAODConversionPhoton*>(fGoodVirtualParticles->At(virtualParticleIndex));
2503  if (vParticle==NULL) continue;
2504  //Check for same Electron ID
2505 
2506  AliAODConversionMother *mesoncand = new AliAODConversionMother(neutralPion,vParticle);
2507  mesoncand->SetLabels(mesonIndex,virtualParticleIndex);
2508  if( ( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(mesoncand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())) ){
2509 
2510  AliESDtrack *negPionCandidatetmp = (AliESDtrack*) fESDEvent->GetTrack(vParticle->GetTrackLabel(1));
2511  if(negPionCandidatetmp==NULL){ delete mesoncand; continue;}
2512  AliAODConversionMother *NegPiontmp = new AliAODConversionMother();
2513  NegPiontmp->SetPxPyPzE(negPionCandidatetmp->Px(), negPionCandidatetmp->Py(), negPionCandidatetmp->Pz(), negPionCandidatetmp->E());
2514 
2515  AliESDtrack *posPionCandidatetmp = (AliESDtrack*) fESDEvent->GetTrack(vParticle->GetTrackLabel(0));
2516  if(posPionCandidatetmp==NULL){ delete NegPiontmp; delete mesoncand; continue;}
2517  AliAODConversionMother *PosPiontmp = new AliAODConversionMother();
2518  PosPiontmp->SetPxPyPzE(posPionCandidatetmp->Px(), posPionCandidatetmp->Py(), posPionCandidatetmp->Pz(), posPionCandidatetmp->E());
2519 
2520  if(KinematicCut(NegPiontmp, PosPiontmp, neutralPion, mesoncand)){
2521  if(!fDoLightOutput){
2522  fHistoAngleOmegaPiZero[fiCut]->Fill(mesoncand->Pt(),neutralPion->Angle(mesoncand->Vect()));
2523  fHistoAngleOmegaPiPl[fiCut]->Fill(mesoncand->Pt(),PosPiontmp->Angle(mesoncand->Vect()));
2524  fHistoAngleOmegaPiMi[fiCut]->Fill(mesoncand->Pt(),NegPiontmp->Angle(mesoncand->Vect()));
2525  fHistoAnglePiZeroPiMi[fiCut]->Fill(mesoncand->Pt(),NegPiontmp->Angle(neutralPion->Vect()));
2526  fHistoAnglePiPlPiMi[fiCut]->Fill(mesoncand->Pt(),NegPiontmp->Angle(PosPiontmp->Vect()));
2527  fHistoAnglePiPlPiZero[fiCut]->Fill(mesoncand->Pt(),PosPiontmp->Angle(neutralPion->Vect()));
2528  fHistoAngleOmegaPiPlPiMi[fiCut]->Fill(mesoncand->Pt(),vParticle->Angle(mesoncand->Vect()));
2529  fHistoAngleSum[fiCut]->Fill(mesoncand->Pt(),((PosPiontmp->Angle(mesoncand->Vect()))+(NegPiontmp->Angle(PosPiontmp->Vect()))+(PosPiontmp->Angle(neutralPion->Vect()))));
2530 
2531  //Double_t sparesFill[4] = {mesoncand->M(),mesoncand->Pt(),(Double_t)zbin,(Double_t)mbin};
2532  //fTHnSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
2533  }
2534  fHistoMotherInvMassSubPi0[fiCut]->Fill(mesoncand->M()-neutralPion->M(),mesoncand->Pt());
2536  Pi0tmp->SetPxPyPzE(neutralPion->Px(), neutralPion->Py(), neutralPion->Pz(), neutralPion->Energy());
2537  FixPzToMatchPDGInvMassPi0(Pi0tmp);
2538  AliAODConversionMother *mesontmp = new AliAODConversionMother(Pi0tmp,vParticle);
2539  fHistoMotherInvMassFixedPzPi0[fiCut]->Fill(mesontmp->M(),mesontmp->Pt());
2540  delete Pi0tmp;
2541  delete mesontmp;
2542  fHistoMotherInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt());
2543  if(fMCEvent){
2544  ProcessTrueMesonCandidates(mesoncand,neutralPion,vParticle);
2545  }
2546  }else{
2547  if(!fDoLightOutput){
2548  fHistoMotherInvMassPtRejectedKinematic[fiCut]->Fill(mesoncand->M(),mesoncand->Pt());
2549  }
2550  }
2551  if(!fDoLightOutput){
2552  delete NegPiontmp;
2553  delete PosPiontmp;
2554  }
2555  }
2556  delete mesoncand;
2557  mesoncand=0x0;
2558  }
2559  }
2560  }
2561 }
2562 //________________________________________________________________________
2564 
2565  /* Event mixing histo explanation
2566  *
2567  * fHistoBackInvMassPtGroup1 => pi+ and pi- from same event
2568  * fHistoBackInvMassPtGroup2 => pi+ and pi0 from same event
2569  * fHistoBackInvMassPtGroup3 => pi- and pi0 from same event
2570  * fHistoBackInvMassPtGroup4 => no pions from same event
2571  */
2572 
2573  // Get multiplicity and zbin from fBGHandler
2574  Int_t zbin= fBGHandlerPiMi[fiCut]->GetZBinIndex(fESDEvent->GetPrimaryVertex()->GetZ());
2575  Int_t mbin = 0;
2576 
2577  // Multiplicity can be determined either by number of cluster candidates or track mulitiplicity
2578  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
2580  } else {
2582  else mbin = fBGHandlerPiMi[fiCut]->GetMultiplicityBinIndex(fClusterCandidates->GetEntries());
2583  }
2584 
2587 
2588  // Get N of Pi0 according to chosen mix mode
2589  Int_t NPi0Candidates = 0;
2590  if( (((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixing()) || (((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixingBothSides())){
2591  NPi0Candidates = fNeutralPionSidebandCandidates->GetEntries();
2592  }else{
2593  NPi0Candidates = fNeutralPionCandidates->GetEntries();
2594  }
2595  // Begin loop over all Pi0 candidates
2596  for(Int_t iCurrentPi0=0; iCurrentPi0<NPi0Candidates; iCurrentPi0++){
2597  AliAODConversionMother* EventPiZeroGoodMeson;
2598  if( (((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixing()) || (((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseSidebandMixingBothSides())){
2599  EventPiZeroGoodMeson = (AliAODConversionMother*)(fNeutralPionSidebandCandidates->At(iCurrentPi0));
2600  }else{
2601  EventPiZeroGoodMeson = (AliAODConversionMother*)(fNeutralPionCandidates->At(iCurrentPi0));
2602  }
2603 
2604  // Check if current pi0 fullfills Pt criteria dependend on NeutralPionMode
2605  if(EventPiZeroGoodMeson->Pt() < fNeutralPionPtMin) continue;
2606 
2607 if(!(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseLikeSignMixing())){
2608  // Begin loop over BG events for Pi+
2609  for(Int_t nEventsInBGPl=0;nEventsInBGPl<fBGHandlerPiPl[fiCut]->GetNBGEvents();nEventsInBGPl++){
2610 
2611  // Store all Pi+ of current event in right binning in vector
2612  AliGammaConversionMotherAODVector *EventPiPlMeson = fBGHandlerPiPl[fiCut]->GetBGGoodMesons(zbin,mbin,nEventsInBGPl);
2613 
2614  // Begin loop over BG events for Pi-
2615  for(Int_t nEventsInBGMi=0;nEventsInBGMi<fBGHandlerPiMi[fiCut]->GetNBGEvents();nEventsInBGMi++){
2616  AliGammaConversionMotherAODVector *EventPiMiMeson = fBGHandlerPiMi[fiCut]->GetBGGoodMesons(zbin,mbin,nEventsInBGMi);
2617 
2618  // If one of the events isn't found skip to next one
2619  if((EventPiMiMeson && EventPiPlMeson) == kFALSE) continue;
2620 
2621  // Determine Background event vertex
2622  if(fMoveParticleAccordingToVertex == kTRUE){
2623  bgEventVertexPl = fBGHandlerPiPl[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBGPl);
2624  bgEventVertexMi = fBGHandlerPiMi[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBGMi);
2625  }
2626  // Loop over all Pi+
2627  for(UInt_t iCurrentPiPl = 0; iCurrentPiPl<EventPiPlMeson->size();iCurrentPiPl++){
2628  AliAODConversionMother EventPiPlGoodMeson= (AliAODConversionMother)(*(EventPiPlMeson->at(iCurrentPiPl)));
2629 
2630  // Move Vertex
2631  if(fMoveParticleAccordingToVertex == kTRUE){
2632  MoveParticleAccordingToVertex(&EventPiPlGoodMeson, bgEventVertexPl);
2633  }
2634 
2635  // Combine Pi+ and Pi0
2636  AliAODConversionMother *PiPlPiZeroBackgroundCandidate = new AliAODConversionMother(EventPiZeroGoodMeson, &EventPiPlGoodMeson);
2637 
2638  for(UInt_t iCurrentPiMi = 0; iCurrentPiMi<EventPiMiMeson->size();iCurrentPiMi++){
2639  AliAODConversionMother EventPiMiGoodMeson = (AliAODConversionMother)(*(EventPiMiMeson->at(iCurrentPiMi)));
2640 
2641  // Move Vertex
2642  if(fMoveParticleAccordingToVertex == kTRUE){
2643  MoveParticleAccordingToVertex(&EventPiMiGoodMeson, bgEventVertexMi);
2644  }
2645 
2646  // Mass cut (pi+pi-)
2647  if (((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->DoMassCut()){
2648  AliAODConversionMother *backPiPlPiMiCandidate = new AliAODConversionMother(&EventPiPlGoodMeson,&EventPiMiGoodMeson);
2649  if (backPiPlPiMiCandidate->M() >= ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetMassCut()){
2650  delete backPiPlPiMiCandidate;
2651  backPiPlPiMiCandidate = 0x0;
2652  continue;
2653  }
2654  delete backPiPlPiMiCandidate;
2655  backPiPlPiMiCandidate = 0x0;
2656  }
2657 
2658  // Create (final) Candidate
2659  AliAODConversionMother *PiPlPiMiPiZeroBackgroundCandidate = new AliAODConversionMother(PiPlPiZeroBackgroundCandidate,&EventPiMiGoodMeson);
2660 
2661  // Check if candidate survives meson cut
2662  if( ( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(PiPlPiMiPiZeroBackgroundCandidate,kFALSE, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
2663  // Check if candidate survives kinematic cut
2664  if(KinematicCut(&EventPiMiGoodMeson, &EventPiPlGoodMeson,EventPiZeroGoodMeson,PiPlPiMiPiZeroBackgroundCandidate)){
2665  // Create temporary mesons to be able to fix pz
2667  Pi0tmp->SetPxPyPzE(EventPiZeroGoodMeson->Px(), EventPiZeroGoodMeson->Py(), EventPiZeroGoodMeson->Pz(), EventPiZeroGoodMeson->Energy());
2668  FixPzToMatchPDGInvMassPi0(Pi0tmp);
2669  AliAODConversionMother *PiMiPiZerotmp = new AliAODConversionMother(&EventPiMiGoodMeson,Pi0tmp);
2670  AliAODConversionMother *PiPlPiMiPiZerotmp = new AliAODConversionMother(&EventPiPlGoodMeson,PiMiPiZerotmp);
2671 
2672  if (nEventsInBGMi != nEventsInBGPl){
2673  // Pi+ and Pi- don't come from the same event (but different than pi0 event)
2674  // Fill histograms
2675  fHistoBackInvMassPtGroup4[fiCut]->Fill(PiPlPiMiPiZeroBackgroundCandidate->M(),PiPlPiMiPiZeroBackgroundCandidate->Pt());
2676  fHistoBackInvMassPtGroup4SubPi0[fiCut]->Fill(PiPlPiMiPiZeroBackgroundCandidate->M()-EventPiZeroGoodMeson->M(),PiPlPiMiPiZeroBackgroundCandidate->Pt());
2677  fHistoBackInvMassPtGroup4FixedPzPi0[fiCut]->Fill(PiPlPiMiPiZerotmp->M(),PiPlPiMiPiZerotmp->Pt());
2678 
2679  } else if(nEventsInBGMi==nEventsInBGPl){
2680  // Pi+ and Pi- come from the same event (but different than pi0 event)
2681  fHistoBackInvMassPtGroup1[fiCut]->Fill(PiPlPiMiPiZeroBackgroundCandidate->M(),PiPlPiMiPiZeroBackgroundCandidate->Pt());
2682  fHistoBackInvMassPtGroup1SubPi0[fiCut]->Fill(PiPlPiMiPiZeroBackgroundCandidate->M()-EventPiZeroGoodMeson->M(),PiPlPiMiPiZeroBackgroundCandidate->Pt());
2683  fHistoBackInvMassPtGroup1FixedPzPi0[fiCut]->Fill(PiPlPiMiPiZerotmp->M(),PiPlPiMiPiZerotmp->Pt());
2684  }
2685 
2686  delete Pi0tmp;
2687  delete PiMiPiZerotmp;
2688  delete PiPlPiMiPiZerotmp;
2689 
2690  delete PiPlPiMiPiZeroBackgroundCandidate;
2691  PiPlPiMiPiZeroBackgroundCandidate = 0x0;
2692  }
2693  }
2694  if(PiPlPiMiPiZeroBackgroundCandidate!=0x0){
2695  delete PiPlPiMiPiZeroBackgroundCandidate;
2696  PiPlPiMiPiZeroBackgroundCandidate = 0x0;
2697  }
2698  } // end pi- loop
2699  if(PiPlPiZeroBackgroundCandidate!=0x0){
2700  delete PiPlPiZeroBackgroundCandidate;
2701  PiPlPiZeroBackgroundCandidate = 0x0;
2702  }
2703  } // end pi+ loop
2704  } // end loop over all pi- event
2705  } // end loop over pi+ events
2706 
2707  // Loop over all pi+ events(from Handler)
2708  for(Int_t nEventsInBGPl=0;nEventsInBGPl<fBGHandlerPiPl[fiCut]->GetNBGEvents();nEventsInBGPl++){
2709  // Store all Pi+ of current event in right binning in vector
2710  AliGammaConversionMotherAODVector *EventPiPlMeson = fBGHandlerPiPl[fiCut]->GetBGGoodMesons(zbin,mbin,nEventsInBGPl);
2711 
2712  // Determine Vertex
2713  if(fMoveParticleAccordingToVertex == kTRUE){
2714  bgEventVertexPl = fBGHandlerPiPl[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBGPl);
2715  }
2716  // Begin loop over all pi+ in ecent
2717  for(UInt_t iCurrentPiPl = 0; iCurrentPiPl<EventPiPlMeson->size();iCurrentPiPl++){
2718  AliAODConversionMother EventPiPlGoodMeson= (AliAODConversionMother)(*(EventPiPlMeson->at(iCurrentPiPl)));
2719 
2720  // Move vertex
2721  if(fMoveParticleAccordingToVertex == kTRUE){
2722  MoveParticleAccordingToVertex(&EventPiPlGoodMeson, bgEventVertexPl);
2723  }
2724  // Combine Pi+ and Pi0
2725  AliAODConversionMother *PiPlPiZeroBackgroundCandidate = new AliAODConversionMother(EventPiZeroGoodMeson, &EventPiPlGoodMeson);
2726  // Loop over all pi- (from current event)
2727  for(Int_t iCurrentPiMi=0; iCurrentPiMi<fNegPionCandidates->GetEntries(); iCurrentPiMi++){
2728  AliAODConversionMother EventPiNegGoodMeson = *(AliAODConversionMother*)(fNegPionCandidates->At(iCurrentPiMi));
2729 
2730  // Mass cut on pi+pi-
2731  if (((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->DoMassCut()){
2732  AliAODConversionMother *backPiPlPiMiCandidate = new AliAODConversionMother(&EventPiPlGoodMeson,&EventPiNegGoodMeson);
2733  if (backPiPlPiMiCandidate->M() >= ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetMassCut()){
2734  delete backPiPlPiMiCandidate;
2735  backPiPlPiMiCandidate = 0x0;
2736  continue;
2737  }
2738  delete backPiPlPiMiCandidate;
2739  backPiPlPiMiCandidate = 0x0;
2740  }
2741 
2742  // Create (final) Candidate
2743  AliAODConversionMother *PiPlPiMiPiZeroBackgroundCandidate = new AliAODConversionMother(PiPlPiZeroBackgroundCandidate,&EventPiNegGoodMeson);
2744 
2745  // Check if candidate survives meson cut
2746  if( ( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(PiPlPiMiPiZeroBackgroundCandidate,kFALSE, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
2747 
2748  // Check if candidate survives kinematic cut
2749  if(KinematicCut(&EventPiNegGoodMeson, &EventPiPlGoodMeson, EventPiZeroGoodMeson,PiPlPiMiPiZeroBackgroundCandidate)){
2750 
2751  // Create temporary mesons to be able to fix pz
2753  Pi0tmp->SetPxPyPzE(EventPiZeroGoodMeson->Px(), EventPiZeroGoodMeson->Py(), EventPiZeroGoodMeson->Pz(), EventPiZeroGoodMeson->Energy());
2754  FixPzToMatchPDGInvMassPi0(Pi0tmp);
2755  AliAODConversionMother *PiMiPiZerotmp = new AliAODConversionMother(&EventPiNegGoodMeson,Pi0tmp);
2756  AliAODConversionMother *PiPlPiMiPiZerotmp = new AliAODConversionMother(&EventPiPlGoodMeson,PiMiPiZerotmp);
2757 
2758  // Fill histograms (pi- and pi0 from same event)
2759  fHistoBackInvMassPtGroup3[fiCut]->Fill(PiPlPiMiPiZeroBackgroundCandidate->M(),PiPlPiMiPiZeroBackgroundCandidate->Pt());
2760  fHistoBackInvMassPtGroup3SubPi0[fiCut]->Fill(PiPlPiMiPiZeroBackgroundCandidate->M()-EventPiZeroGoodMeson->M(),PiPlPiMiPiZeroBackgroundCandidate->Pt());
2761  fHistoBackInvMassPtGroup3FixedPzPi0[fiCut]->Fill(PiPlPiMiPiZerotmp->M(),PiPlPiMiPiZerotmp->Pt());
2762 
2763  delete Pi0tmp;
2764  delete PiMiPiZerotmp;
2765  delete PiPlPiMiPiZerotmp;
2766 
2767  delete PiPlPiMiPiZeroBackgroundCandidate;
2768  PiPlPiMiPiZeroBackgroundCandidate = 0x0;
2769  }
2770  }
2771  if(PiPlPiMiPiZeroBackgroundCandidate!=0x0){
2772  delete PiPlPiMiPiZeroBackgroundCandidate;
2773  PiPlPiMiPiZeroBackgroundCandidate = 0x0;
2774  }
2775  } // End loop pi- (from current event)
2776  if(PiPlPiZeroBackgroundCandidate!=0x0){
2777  delete PiPlPiZeroBackgroundCandidate;
2778  PiPlPiZeroBackgroundCandidate = 0x0;
2779  }
2780  } // End loop pi+
2781  } // end loop over pi+ events
2782 
2783  // Loop over all pi- events(from Handler)
2784  for(Int_t nEventsInBGMi=0;nEventsInBGMi<fBGHandlerPiPl[fiCut]->GetNBGEvents();nEventsInBGMi++){
2785  // Store all Pi- of current event in right binning in vector
2786  AliGammaConversionMotherAODVector *EventPiMiMeson = fBGHandlerPiMi[fiCut]->GetBGGoodMesons(zbin,mbin,nEventsInBGMi);
2787 
2788  // Determine vertex
2789  if(fMoveParticleAccordingToVertex == kTRUE){
2790  bgEventVertexMi = fBGHandlerPiMi[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBGMi);
2791  }
2792 
2793  // Begin loop over all pi- in event
2794  for(UInt_t iCurrentPiMi = 0; iCurrentPiMi<EventPiMiMeson->size();iCurrentPiMi++){
2795  AliAODConversionMother EventPiMiGoodMeson= (AliAODConversionMother)(*(EventPiMiMeson->at(iCurrentPiMi)));
2796 
2797  // move vertex
2798  if(fMoveParticleAccordingToVertex == kTRUE){
2799  MoveParticleAccordingToVertex(&EventPiMiGoodMeson, bgEventVertexMi);
2800  }
2801 
2802 
2803  // Combine Pi- and Pi0
2804  AliAODConversionMother *PiMiPiZeroBackgroundCandidate = new AliAODConversionMother(EventPiZeroGoodMeson, &EventPiMiGoodMeson);
2805 
2806  // Loop over all pi+ (from current event)
2807  for(Int_t iCurrentPiPl=0; iCurrentPiPl<fPosPionCandidates->GetEntries(); iCurrentPiPl++){
2808  AliAODConversionMother EventPiPlGoodMeson = *(AliAODConversionMother*)(fPosPionCandidates->At(iCurrentPiPl));
2809 
2810  // Mass cut on pi+pi-
2811  if (((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->DoMassCut()){
2812  AliAODConversionMother *backPiPlPiMiCandidate = new AliAODConversionMother(&EventPiPlGoodMeson,&EventPiMiGoodMeson);
2813  if (backPiPlPiMiCandidate->M() >= ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetMassCut()){
2814  delete backPiPlPiMiCandidate;
2815  backPiPlPiMiCandidate = 0x0;
2816  continue;
2817  }
2818  delete backPiPlPiMiCandidate;
2819  backPiPlPiMiCandidate = 0x0;
2820  }
2821 
2822  // Create (final) Candidate
2823  AliAODConversionMother *PiPlPiMiPiZeroBackgroundCandidate = new AliAODConversionMother(PiMiPiZeroBackgroundCandidate,&EventPiPlGoodMeson);
2824 
2825  // Check if candidate survives meson cut
2826  if( ( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(PiMiPiZeroBackgroundCandidate,kFALSE, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
2827 
2828  // Check if candidate survives kinematic cut
2829  if(KinematicCut(&EventPiMiGoodMeson, &EventPiPlGoodMeson, EventPiZeroGoodMeson,PiPlPiMiPiZeroBackgroundCandidate)){
2830 
2831  // Create temporary mesons to be able to fix pz
2833  Pi0tmp->SetPxPyPzE(EventPiZeroGoodMeson->Px(), EventPiZeroGoodMeson->Py(), EventPiZeroGoodMeson->Pz(), EventPiZeroGoodMeson->Energy());
2834  FixPzToMatchPDGInvMassPi0(Pi0tmp);
2835  AliAODConversionMother *PiMiPiZerotmp = new AliAODConversionMother(&EventPiMiGoodMeson,Pi0tmp);
2836  AliAODConversionMother *PiPlPiMiPiZerotmp = new AliAODConversionMother(&EventPiPlGoodMeson,PiMiPiZerotmp);
2837 
2838  // Fill histograms (pi+ and pi0 from same event)
2839  fHistoBackInvMassPtGroup2[fiCut]->Fill(PiPlPiMiPiZeroBackgroundCandidate->M(),PiPlPiMiPiZeroBackgroundCandidate->Pt());
2840  fHistoBackInvMassPtGroup2SubPi0[fiCut]->Fill(PiPlPiMiPiZeroBackgroundCandidate->M()-EventPiZeroGoodMeson->M(),PiPlPiMiPiZeroBackgroundCandidate->Pt());
2841  fHistoBackInvMassPtGroup2FixedPzPi0[fiCut]->Fill(PiPlPiMiPiZerotmp->M(),PiPlPiMiPiZerotmp->Pt());
2842 
2843  delete Pi0tmp;
2844  delete PiMiPiZerotmp;
2845  delete PiPlPiMiPiZerotmp;
2846 
2847  delete PiPlPiMiPiZeroBackgroundCandidate;
2848  PiPlPiMiPiZeroBackgroundCandidate = 0x0;
2849  }
2850  }
2851  if(PiPlPiMiPiZeroBackgroundCandidate!=0x0){
2852  delete PiPlPiMiPiZeroBackgroundCandidate;
2853  PiPlPiMiPiZeroBackgroundCandidate = 0x0;
2854  }
2855  } // End loop pi+ (from current event)
2856  if(PiMiPiZeroBackgroundCandidate!=0x0){
2857  delete PiMiPiZeroBackgroundCandidate;
2858  PiMiPiZeroBackgroundCandidate = 0x0;
2859  }
2860  } // End loop pi-
2861  } // end loop over pi+ events
2862  /*
2863  * LikeSign Mixing
2864  */
2865  } else if( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseLikeSignMixing()){
2866  // Loops for Pi0Pi+Pi+ LikeSign mixing
2867  for(Int_t iCurrentPiPl=0; iCurrentPiPl<fPosPionCandidates->GetEntries(); iCurrentPiPl++){
2868 
2869  AliAODConversionMother EventPiPlGoodMeson = *(AliAODConversionMother*)(fPosPionCandidates->At(iCurrentPiPl));
2870 
2871  for(Int_t iCurrentPiPl2=0; iCurrentPiPl2<fPosPionCandidates->GetEntries(); iCurrentPiPl2++){
2872 
2873  if(iCurrentPiPl!=iCurrentPiPl2){ // dont mix same particle
2874  AliAODConversionMother EventPiPlGoodMeson2 = *(AliAODConversionMother*)(fPosPionCandidates->At(iCurrentPiPl2));
2875 
2876  // Combine Pi+ and Pi0
2877  AliAODConversionMother *PiPlPiZeroBackgroundCandidate = new AliAODConversionMother(&EventPiPlGoodMeson, EventPiZeroGoodMeson);
2878 
2879  // Mass cut on pi+pi+
2880  if (((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->DoMassCut()){
2881  AliAODConversionMother *backPiPlPiPlCandidate = new AliAODConversionMother(&EventPiPlGoodMeson,&EventPiPlGoodMeson2);
2882  if (backPiPlPiPlCandidate->M() >= ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetMassCut()){
2883  delete backPiPlPiPlCandidate;
2884  backPiPlPiPlCandidate = 0x0;
2885  continue;
2886  }
2887  delete backPiPlPiPlCandidate;
2888  backPiPlPiPlCandidate = 0x0;
2889  }
2890 
2891  // Create (final) Candidate
2892  AliAODConversionMother *PiPlPiPlPiZeroBackgroundCandidate = new AliAODConversionMother(PiPlPiZeroBackgroundCandidate, &EventPiPlGoodMeson2);
2893 
2894  // Check if candidate survives meson cut
2895  if( ( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(PiPlPiZeroBackgroundCandidate,kFALSE, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
2896 
2897  // Check if candidate survives kinematic cut
2898  if(KinematicCut(&EventPiPlGoodMeson, &EventPiPlGoodMeson2, EventPiZeroGoodMeson,PiPlPiPlPiZeroBackgroundCandidate)){
2899 
2900  // Create temporary mesons to be able to fix pz
2902  Pi0tmp->SetPxPyPzE(EventPiZeroGoodMeson->Px(), EventPiZeroGoodMeson->Py(), EventPiZeroGoodMeson->Pz(), EventPiZeroGoodMeson->Energy());
2903  FixPzToMatchPDGInvMassPi0(Pi0tmp);
2904  AliAODConversionMother *PiPlPiZerotmp = new AliAODConversionMother(&EventPiPlGoodMeson,Pi0tmp);
2905  AliAODConversionMother *PiPlPiPlPiZerotmp = new AliAODConversionMother(&EventPiPlGoodMeson2,PiPlPiZerotmp);
2906 
2907  // Fill histograms (likesign)
2908  fHistoMotherLikeSignBackInvMassPt[fiCut]->Fill(PiPlPiPlPiZeroBackgroundCandidate->M(),PiPlPiPlPiZeroBackgroundCandidate->Pt());
2909  fHistoMotherLikeSignBackInvMassSubPi0Pt[fiCut]->Fill(PiPlPiPlPiZeroBackgroundCandidate->M()-EventPiZeroGoodMeson->M(),PiPlPiPlPiZeroBackgroundCandidate->Pt());
2910  fHistoMotherLikeSignBackInvMassFixedPzPi0Pt[fiCut]->Fill(PiPlPiPlPiZerotmp->M(),PiPlPiPlPiZerotmp->Pt());
2911 
2912  delete Pi0tmp;
2913  delete PiPlPiZerotmp;
2914  delete PiPlPiPlPiZerotmp;
2915 
2916  delete PiPlPiPlPiZeroBackgroundCandidate;
2917  PiPlPiPlPiZeroBackgroundCandidate = 0x0;
2918  }
2919  }
2920 
2921 
2922  }
2923  } // end of iCurrentPiPl2
2924  }// end of iCurrenPiPl
2925 
2926  // Loops for Pi0Pi-Pi- LikeSign mixing
2927  for(Int_t iCurrentPiMi=0; iCurrentPiMi<fNegPionCandidates->GetEntries(); iCurrentPiMi++){
2928 
2929  AliAODConversionMother EventPiMiGoodMeson = *(AliAODConversionMother*)(fNegPionCandidates->At(iCurrentPiMi));
2930 
2931  for(Int_t iCurrentPiMi2=0; iCurrentPiMi2<fNegPionCandidates->GetEntries(); iCurrentPiMi2++){
2932 
2933  if(iCurrentPiMi!=iCurrentPiMi2){ // dont mix same particle
2934  AliAODConversionMother EventPiMiGoodMeson2 = *(AliAODConversionMother*)(fNegPionCandidates->At(iCurrentPiMi2));
2935 
2936  // Combine Pi- and Pi0
2937  AliAODConversionMother *PiMiPiZeroBackgroundCandidate = new AliAODConversionMother(&EventPiMiGoodMeson, EventPiZeroGoodMeson);
2938 
2939  // Mass cut on pi-pi-
2940  if (((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->DoMassCut()){
2941  AliAODConversionMother *backPiMiPiMiCandidate = new AliAODConversionMother(&EventPiMiGoodMeson,&EventPiMiGoodMeson2);
2942  if (backPiMiPiMiCandidate->M() >= ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetMassCut()){
2943  delete backPiMiPiMiCandidate;
2944  backPiMiPiMiCandidate = 0x0;
2945  continue;
2946  }
2947  delete backPiMiPiMiCandidate;
2948  backPiMiPiMiCandidate = 0x0;
2949  }
2950 
2951  // Create (final) Candidate
2952  AliAODConversionMother *PiMiPiMiPiZeroBackgroundCandidate = new AliAODConversionMother(PiMiPiZeroBackgroundCandidate, &EventPiMiGoodMeson2);
2953 
2954  // Check if candidate survives meson cut
2955  if( ( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(PiMiPiZeroBackgroundCandidate,kFALSE, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
2956 
2957  // Check if candidate survives kinematic cut
2958  if(KinematicCut(&EventPiMiGoodMeson, &EventPiMiGoodMeson2, EventPiZeroGoodMeson,PiMiPiMiPiZeroBackgroundCandidate)){
2959 
2960  // Create temporary mesons to be able to fix pz
2962  Pi0tmp->SetPxPyPzE(EventPiZeroGoodMeson->Px(), EventPiZeroGoodMeson->Py(), EventPiZeroGoodMeson->Pz(), EventPiZeroGoodMeson->Energy());
2963  FixPzToMatchPDGInvMassPi0(Pi0tmp);
2964  AliAODConversionMother *PiMiPiZerotmp = new AliAODConversionMother(&EventPiMiGoodMeson,Pi0tmp);
2965  AliAODConversionMother *PiMiPiMiPiZerotmp = new AliAODConversionMother(&EventPiMiGoodMeson2,PiMiPiZerotmp);
2966 
2967  // Fill histograms (likesign)
2968  fHistoMotherLikeSignBackInvMassPt[fiCut]->Fill(PiMiPiMiPiZeroBackgroundCandidate->M(),PiMiPiMiPiZeroBackgroundCandidate->Pt());
2969  fHistoMotherLikeSignBackInvMassSubPi0Pt[fiCut]->Fill(PiMiPiMiPiZeroBackgroundCandidate->M()-EventPiZeroGoodMeson->M(),PiMiPiMiPiZeroBackgroundCandidate->Pt());
2970  fHistoMotherLikeSignBackInvMassFixedPzPi0Pt[fiCut]->Fill(PiMiPiMiPiZerotmp->M(),PiMiPiMiPiZerotmp->Pt());
2971 
2972  delete Pi0tmp;
2973  delete PiMiPiZerotmp;
2974  delete PiMiPiMiPiZerotmp;
2975 
2976  delete PiMiPiMiPiZeroBackgroundCandidate;
2977  PiMiPiMiPiZeroBackgroundCandidate = 0x0;
2978  }
2979  }
2980 
2981 
2982  }
2983  } // end of iCurrentPiMi2
2984  }// end of iCurrenPiMi
2985  } // end of LikeSign if
2986  } //end loop pi0 candidates
2987 }
2988 
2989 //______________________________________________________________________
2991 
2992  if(fTolerance == -1) return kTRUE;
2993  if((omega->Pt())<=5.){
2994  if( (omega->Angle(pospion->Vect())) < ((2.78715*(TMath::Exp(-0.589934*(omega->Pt()))+0.0519574))*fTolerance) &&
2995  (omega->Angle(negpion->Vect())) < ((5.94216*(TMath::Exp(-0.444428*(omega->Pt()))-0.0574076))*fTolerance) &&
2996  (omega->Angle(neutpion->Vect())) < ((2.79529*(TMath::Exp(-0.565999*(omega->Pt()))+0.0413576))*fTolerance) &&
2997  (pospion->Angle(negpion->Vect())) < ((3.14446*(TMath::Exp(-0.666433*(omega->Pt()))+0.0964309))*fTolerance) &&
2998  (pospion->Angle(neutpion->Vect())) < ((3.08241*(TMath::Exp(-0.650657*(omega->Pt()))+0.0997539))*fTolerance) &&
2999  (negpion->Angle(neutpion->Vect())) < ((3.18536*(TMath::Exp(-0.752847*(omega->Pt()))+0.1262780))*fTolerance)
3000  ){
3001  return kTRUE;
3002  }
3003  }else{
3004  if( (omega->Angle(pospion->Vect())) < ((0.459270*(TMath::Exp(-0.126007*(omega->Pt()))+0.100475))*fTolerance) &&
3005  (omega->Angle(negpion->Vect())) < ((0.521250*(TMath::Exp(-0.152532*(omega->Pt()))+0.114617))*fTolerance) &&
3006  (omega->Angle(neutpion->Vect())) < ((0.409766*(TMath::Exp(-0.108566*(omega->Pt()))+0.103594))*fTolerance) &&
3007  (pospion->Angle(negpion->Vect())) < ((0.709206*(TMath::Exp(-0.149072*(omega->Pt()))+0.111345))*fTolerance) &&
3008  (pospion->Angle(neutpion->Vect())) < ((0.662184*(TMath::Exp(-0.123397*(omega->Pt()))+0.104675))*fTolerance) &&
3009  (negpion->Angle(neutpion->Vect())) < ((0.730228*(TMath::Exp(-0.120859*(omega->Pt()))+0.105522))*fTolerance)
3010  ){
3011  return kTRUE;
3012  }
3013  }
3014  return kFALSE;
3015 }
3016 
3017 
3018 //______________________________________________________________________
3020 {
3021 
3022  // Process True Mesons
3023 
3024  Bool_t isSameMotherPiPlPiMiPiZero = kFALSE; // pi+ pi- and pi0 have the same mother
3025  Bool_t isSameMotherPiPlPiMi = kFALSE; // pi+ and pi- have the same mother
3026  Bool_t isSameMotherPiPlPiZero = kFALSE; // pi+ and pi0 have the same mother
3027  Bool_t isSameMotherPiMiPiZero = kFALSE; // pi- and pi0 have the same mother
3028  Bool_t isNoSameMother = kFALSE; // none of the pions have the same mother
3029  Bool_t isNoPiPiPi = kFALSE; // the decay is not a 3 pion decay
3030 
3031 
3032  Int_t virtualParticleMCLabel = TrueVirtualParticleCandidate->GetMCParticleLabel(fMCEvent);
3033  Int_t virtualParticleMotherLabel = -1;
3034  Int_t trueMesonFlag = TrueNeutralPionCandidate->GetTrueMesonValue();
3035  Int_t pi0MCLabel = TrueNeutralPionCandidate->GetMCLabel();
3036 
3037  Float_t weighted= 1;
3038 
3039  if ( !(trueMesonFlag == 1 && pi0MCLabel != -1)){
3040  if((fDoMesonQA>0 ) && (!fDoLightOutput)){
3041  fHistoTruePiPlPiMiPiZeroContaminationInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3042  }
3043  return;
3044  }
3045  Int_t pi0MotherLabel = fMCEvent->Particle(pi0MCLabel)->GetMother(0);
3046 
3047  TParticle * negativeMC = (TParticle*)TrueVirtualParticleCandidate->GetNegativeMCDaughter(fMCEvent);
3048  TParticle * positiveMC = (TParticle*)TrueVirtualParticleCandidate->GetPositiveMCDaughter(fMCEvent);
3049 
3050  Int_t posMotherLabelMC = positiveMC->GetMother(0);
3051  Int_t negMotherLabelMC = negativeMC->GetMother(0);
3052 
3053  // Check case present
3054  if((TMath::Abs(negativeMC->GetPdgCode())==211) && (TMath::Abs(positiveMC->GetPdgCode())==211) && (fMCEvent->Particle(pi0MCLabel)->GetPdgCode()==111)){
3055  // three pion decay
3056  if(virtualParticleMCLabel!=-1){
3057  // pi+ pi- have same mother
3058  virtualParticleMotherLabel = virtualParticleMCLabel;
3059  if(virtualParticleMotherLabel==pi0MotherLabel){
3060  // all pions from same mother
3061  if(fMCEvent->Particle(pi0MotherLabel)->GetStatusCode()!=21) isSameMotherPiPlPiMiPiZero = kTRUE;
3062  } else{
3063  // only pi+ pi- from same mother
3064  if(fMCEvent->Particle(virtualParticleMotherLabel)->GetStatusCode()!=21) isSameMotherPiPlPiMi = kTRUE;
3065  }
3066  } else{
3067  if(pi0MotherLabel==negMotherLabelMC && negMotherLabelMC != -1){
3068  // pi0 and pi- same mother
3069  if(fMCEvent->Particle(negMotherLabelMC)->GetStatusCode()!=21) isSameMotherPiMiPiZero = kTRUE;
3070  } else if(pi0MotherLabel==posMotherLabelMC && posMotherLabelMC != -1){
3071  // pi0 and pi+ same mother
3072  if(fMCEvent->Particle(posMotherLabelMC)->GetStatusCode()!=21) isSameMotherPiPlPiZero = kTRUE;
3073  } else{
3074  // all pions different mother
3075  isNoSameMother = kTRUE;
3076  }
3077  }
3078  } else{
3079  // not a three pion decay
3080  isNoPiPiPi = kTRUE;
3081  }
3082 
3083  // Do things for each case
3084  if(isSameMotherPiPlPiMiPiZero){
3085  if(fMCEvent->Particle(pi0MotherLabel)->GetPdgCode() == 221){
3086  // eta was found
3087  if(!fDoLightOutput) fHistoTrueMotherPiPlPiMiPiZeroInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3088  if(!fDoLightOutput) fHistoTrueMotherEtaPiPlPiMiPiZeroInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3089  AliAODConversionMother *PosPiontmp = new AliAODConversionMother();
3090  PosPiontmp->SetPxPyPzE(positiveMC->Px(), positiveMC->Py(), positiveMC->Pz(), positiveMC->Energy());
3091  AliAODConversionMother *NegPiontmp = new AliAODConversionMother();
3092  NegPiontmp->SetPxPyPzE(negativeMC->Px(), negativeMC->Py(), negativeMC->Pz(), negativeMC->Energy());
3093  if(!fDoLightOutput) fHistoTrueAngleSum[fiCut]->Fill(mesoncand->Pt(),((PosPiontmp->Angle(mesoncand->Vect()))+(NegPiontmp->Angle(PosPiontmp->Vect()))+(PosPiontmp->Angle(TrueNeutralPionCandidate->Vect()))));
3094 
3095  delete PosPiontmp; PosPiontmp = 0x0;
3096  delete NegPiontmp; NegPiontmp = 0x0;
3097 
3098  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueEtas,pi0MotherLabel) && (!fDoLightOutput)) fHistoDoubleCountTrueEtaInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt());
3099  } else if(fMCEvent->Particle(pi0MotherLabel)->GetPdgCode() == 223){
3100  // omega was found
3101  fHistoTrueMotherPiPlPiMiPiZeroInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3102  if(!fDoLightOutput) fHistoTrueMotherOmegaPiPlPiMiPiZeroInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3103 
3104  AliAODConversionMother *PosPiontmp = new AliAODConversionMother();
3105  PosPiontmp->SetPxPyPzE(positiveMC->Px(), positiveMC->Py(), positiveMC->Pz(), positiveMC->Energy());
3106  AliAODConversionMother *NegPiontmp = new AliAODConversionMother();
3107  NegPiontmp->SetPxPyPzE(negativeMC->Px(), negativeMC->Py(), negativeMC->Pz(), negativeMC->Energy());
3108  if(!fDoLightOutput) fHistoTrueAngleSum[fiCut]->Fill(mesoncand->Pt(),((PosPiontmp->Angle(mesoncand->Vect()))+(NegPiontmp->Angle(PosPiontmp->Vect()))+(PosPiontmp->Angle(TrueNeutralPionCandidate->Vect()))));
3109 
3110  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueOmegas,pi0MotherLabel) && (!fDoLightOutput)) fHistoDoubleCountTrueOmegaInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt());
3111  } else{
3112  if(fDoMesonQA>1 && (!fDoLightOutput)){
3113  // Write "unknown" mother to TTree
3114  fSamePiPiPiMotherID = fMCEvent->Particle(posMotherLabelMC)->GetPdgCode();
3115  fSamePiPiPiMotherInvMass = mesoncand->M();
3116  fSamePiPiPiMotherPt = mesoncand->Pt();
3117 
3118  fTreePiPiPiSameMother[fiCut]->Fill();
3119  }
3120  }
3121  } else if(isSameMotherPiPlPiMi && (fDoMesonQA>0 ) && (!fDoLightOutput)){
3122  if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 221){
3123  // pi+pi- come from eta
3124  fHistoTruePiPlPiMiSameMotherFromEtaInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3125  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 223){
3126  // pi+pi- come from omega
3127  fHistoTruePiPlPiMiSameMotherFromOmegaInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3128  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 113){
3129  // pi+pi- come from rho0
3130  fHistoTruePiPlPiMiSameMotherFromRhoInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3131  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 331){
3132  // pi+pi- come from eta prime
3133  fHistoTruePiPlPiMiSameMotherFromEtaPrimeInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3134  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 310){
3135  // pi+pi- come from K0 short
3136  fHistoTruePiPlPiMiSameMotherFromK0sInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3137  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 130){
3138  // pi+pi- come from K0 short
3139  fHistoTruePiPlPiMiSameMotherFromK0lInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3140  } else{
3141  // pi+pi- come from something else
3142  if(fDoMesonQA>1 && (!fDoLightOutput)){
3143  fCasePiPi = 0;
3144  // Write "unknown" mother to TTree
3145  fSamePiPiMotherID = fMCEvent->Particle(posMotherLabelMC)->GetPdgCode();
3146  fSamePiPiMotherInvMass = mesoncand->M();
3147  fSamePiPiMotherPt = mesoncand->Pt();
3148 
3149  fTreePiPiSameMother[fiCut]->Fill();
3150  }
3151  }
3152  } else if(isSameMotherPiMiPiZero && (fDoMesonQA>0 ) && (!fDoLightOutput)){
3153  if(fMCEvent->Particle(pi0MotherLabel)->GetPdgCode() == 221){
3154  // pi0pi- come from eta
3155  fHistoTruePiMiPiZeroSameMotherFromEtaInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3156  } else if(fMCEvent->Particle(pi0MotherLabel)->GetPdgCode() == 223){
3157  // pi0pi- come from omega
3158  fHistoTruePiMiPiZeroSameMotherFromOmegaInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3159  } else if(fMCEvent->Particle(pi0MotherLabel)->GetPdgCode() ==-213){
3160  // pi0pi- come from rho-
3161  fHistoTruePiMiPiZeroSameMotherFromRhoInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3162  } else if(fMCEvent->Particle(pi0MotherLabel)->GetPdgCode() == 130){
3163  // pi0pi- come from rho-
3164  fHistoTruePiMiPiZeroSameMotherFromK0lInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3165  } else{
3166  // pi0pi- come from something else
3167  if(fDoMesonQA>1){
3168  fCasePiPi = 1;
3169  // Write "unknown" mother to TTree
3170  fSamePiPiMotherID = fMCEvent->Particle(pi0MotherLabel)->GetPdgCode();
3171  fSamePiPiMotherInvMass = mesoncand->M();
3172  fSamePiPiMotherPt = mesoncand->Pt();
3173 
3174  fTreePiPiSameMother[fiCut]->Fill();
3175  }
3176  }
3177  } else if(isSameMotherPiPlPiZero && (fDoMesonQA>0 ) && (!fDoLightOutput)){
3178  if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 221){
3179  // pi+pi0 come from eta
3180  fHistoTruePiPlPiZeroSameMotherFromEtaInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3181  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 223){
3182  // pi+pi0 come from omega
3183  fHistoTruePiPlPiZeroSameMotherFromOmegaInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3184  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 213) {
3185  // pi+pi0 come from rho+
3186  fHistoTruePiPlPiZeroSameMotherFromRhoInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3187  } else if(fMCEvent->Particle(posMotherLabelMC)->GetPdgCode() == 130) {
3188  // pi+pi0 come from rho+
3189  fHistoTruePiPlPiZeroSameMotherFromK0lInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3190  } else{
3191  // pi+pi0 come from something else
3192  if(fDoMesonQA>1){
3193  fCasePiPi = 2;
3194  // Write "unknown" mother to TTree
3195  fSamePiPiMotherID = fMCEvent->Particle(pi0MotherLabel)->GetPdgCode();
3196  fSamePiPiMotherInvMass = mesoncand->M();
3197  fSamePiPiMotherPt = mesoncand->Pt();
3198 
3199  fTreePiPiSameMother[fiCut]->Fill();
3200  }
3201  }
3202  } else if(isNoSameMother && (fDoMesonQA>0 ) && (!fDoLightOutput)){
3203  // no same mother purecombinatorical
3204  fHistoTruePiPlPiMiPiZeroPureCombinatoricalInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3205  } else if(isNoPiPiPi && (fDoMesonQA>0 ) && (!fDoLightOutput)){
3206  // no pi pi pi decay contamination
3207  fHistoTruePiPlPiMiPiZeroContaminationInvMassPt[fiCut]->Fill(mesoncand->M(),mesoncand->Pt(),weighted);
3208  // investigate here what was missmatched (?)
3209 
3210  }
3211 }
3212 
3213 
3214 //________________________________________________________________________
3216  //see header file for documentation
3217 
3218  Int_t method = 1;
3219  if( method == 1 ) {
3220  if(fPosPionCandidates->GetEntries() >0 && fNegPionCandidates->GetEntries() >0){
3221  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3222  fBGHandlerPiPl[fiCut]->AddMesonEvent(fPosPionCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),0);
3223  fBGHandlerPiMi[fiCut]->AddMesonEvent(fNegPionCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),0);
3224  } else { // means we use #V0s for multiplicity
3225  if (fNeutralPionMode < 2){
3226  fBGHandlerPiPl[fiCut]->AddMesonEvent(fPosPionCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGoodConvGammas->GetEntries(),0);
3227  fBGHandlerPiMi[fiCut]->AddMesonEvent(fNegPionCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGoodConvGammas->GetEntries(),0);
3228  }else {
3229  fBGHandlerPiPl[fiCut]->AddMesonEvent(fPosPionCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fClusterCandidates->GetEntries(),0);
3230  fBGHandlerPiMi[fiCut]->AddMesonEvent(fNegPionCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fClusterCandidates->GetEntries(),0);
3231  }
3232  }
3233  }
3234  }
3235 // else if ( method == 2 ){
3236 // if(fGoodVirtualParticles->GetEntries() > 0 ){
3237 // if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3238 // fBGHandler[fiCut]->AddEvent(fGoodVirtualParticles,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),0);
3239 // } else{ // means we use #V0s for multiplicity
3240 // fBGHandler[fiCut]->AddEvent(fGoodVirtualParticles,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGoodVirtualParticles->GetEntries(),0);
3241 // }
3242 // }
3243 // }
3244 }
3245 
3246 //________________________________________________________________________
3248  //see header file for documentation
3249 
3250  Double_t dx = vertex->fX - fInputEvent->GetPrimaryVertex()->GetX();
3251  Double_t dy = vertex->fY - fInputEvent->GetPrimaryVertex()->GetY();
3252  Double_t dz = vertex->fZ - fInputEvent->GetPrimaryVertex()->GetZ();
3253 
3254  Double_t movedPlace[3] = {particle->GetProductionX() - dx,particle->GetProductionY() - dy,particle->GetProductionZ() - dz};
3255  particle->SetProductionPoint(movedPlace);
3256 }
3257 
3258 //________________________________________________________________________
3260 
3261 TParticle pi0;
3262 pi0.SetPdgCode(111);
3263 Double_t PdgMass = pi0.GetMass();
3264 
3265 Double_t px = particle->Px();
3266 Double_t py = particle->Py();
3267 Int_t signPz = particle->Pz()<0?-1:1;
3268 Double_t energy = particle->Energy();
3269 Double_t pz = signPz*TMath::Sqrt(TMath::Abs(pow(PdgMass,2)-pow(energy,2)+pow(px,2)+pow(py,2)));
3270 particle->SetPxPyPzE(px,py,pz,energy);
3271 
3272 return;
3273 }
3274 
3275 //_____________________________________________________________________________________
3277 //
3278 // Returns true if the particle comes from eta -> pi+ pi- gamma
3279 //
3280  if(label<0) return kFALSE;
3281  Int_t motherLabel = fMCEvent->Particle( label )->GetMother(0);
3282  if( motherLabel < 0 || motherLabel >= fMCEvent->GetNumberOfTracks() ) return kFALSE;
3283 
3284  TParticle* mother = fMCEvent->Particle( motherLabel );
3285 // cout << "found eta? " << endl;
3286  if( mother->GetPdgCode() != 221 ) return kFALSE;
3287 // else cout << "YES" << endl;
3288  if( IsPiPlPiMiPiZeroDecay( mother ) ) return kTRUE;
3289  return kFALSE;
3290 }
3291 
3292 //_____________________________________________________________________________________
3294 //
3295 // Returns true if the particle comes from eta -> pi+ pi- gamma
3296 //
3297  if(label<0) return kFALSE;
3298  Int_t motherLabel = fMCEvent->Particle( label )->GetMother(0);
3299  if( motherLabel < 0 || motherLabel >= fMCEvent->GetNumberOfTracks() ) return kFALSE;
3300 
3301  TParticle* mother = fMCEvent->Particle( motherLabel );
3302 // cout << "found omega? " << endl;
3303  if( mother->GetPdgCode() != 223 ) return kFALSE;
3304 // else cout << "YES" << endl;
3305  if( IsPiPlPiMiPiZeroDecay( mother ) ) return kTRUE;
3306  return kFALSE;
3307 }
3308 
3309 
3310 //_____________________________________________________________________________
3312 {
3313 // cout << fMCMother->GetNDaughters() << endl;
3314  if( fMCMother->GetNDaughters() != 3 ) return kFALSE;
3315 // cout << fMCMother->GetPdgCode() << endl;
3316  if( !(fMCMother->GetPdgCode() == 221 || fMCMother->GetPdgCode() == 223) ) return kFALSE;
3317 // cout << "made it til here" << endl;
3318 
3319  TParticle *posPion = 0x0;
3320  TParticle *negPion = 0x0;
3321  TParticle *neutPion = 0x0;
3322 
3323  for(Int_t index= fMCMother->GetFirstDaughter();index<= fMCMother->GetLastDaughter();index++){
3324  if(index<0) continue;
3325  TParticle* temp = (TParticle*)fMCEvent->Particle( index );
3326 
3327  switch( temp->GetPdgCode() ) {
3328  case 211:
3329  posPion = temp;
3330  break;
3331  case -211:
3332  negPion = temp;
3333  break;
3334  case 111:
3335  neutPion = temp;
3336  break;
3337  }
3338  }
3339  if( posPion && negPion && neutPion) return kTRUE;
3340 
3341  return kFALSE;
3342 }
3343 
3344 //_____________________________________________________________________________________
3346 //
3347 // Returns true if the particle comes from eta -> pi+ pi- gamma
3348 //
3349  if(label<0) return kFALSE;
3350  Int_t motherLabel = fMCEvent->Particle( label )->GetMother(0);
3351  if( motherLabel < 0 || motherLabel >= fMCEvent->GetNumberOfTracks() ) return kFALSE;
3352 
3353  TParticle* mother = fMCEvent->Particle( motherLabel );
3354 // cout << "found omega? " << endl;
3355  if( mother->GetPdgCode() != 111 ) return kFALSE;
3356 // else cout << "YES" << endl;
3357  Int_t grandMotherLabel = mother->GetMother(0);
3358  if( grandMotherLabel < 0 || grandMotherLabel >= fMCEvent->GetNumberOfTracks() ) return kFALSE;
3359  TParticle* grandmother = fMCEvent->Particle( grandMotherLabel );
3360 
3361  if( IsPiPlPiMiPiZeroDecay( grandmother ) ) return kTRUE;
3362  return kFALSE;
3363 }
3364 
3365 //_________________________________________________________________________________
3367 {
3368  if(tobechecked > -1)
3369  {
3370  vector<Int_t>::iterator it;
3371  it = find (vec.begin(), vec.end(), tobechecked);
3372  if (it != vec.end()) return true;
3373  else{
3374  vec.push_back(tobechecked);
3375  return false;
3376  }
3377  }
3378  return false;
3379 }
3380 
3381 
TParticle * GetMCParticle(AliMCEvent *mcEvent)
vector< Int_t > GetReconstructedPosPionIndex()
void ProcessTrueNeutralPionCandidatesPureCalo(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1)
void SetCaloClusterRef(Long_t ref)
void SetLabels(Int_t label1, Int_t label2, Int_t label3=0)
double Double_t
Definition: External.C:58
vector< Int_t > fVectorDoubleCountTruePi0s
array of histos with double counted photons, R, pT
GammaConversionVertex * GetBGEventVertex(Int_t zbin, Int_t mbin, Int_t event)
Definition: External.C:236
void SetCaloPhotonMCFlags(AliMCEvent *mcEvent, Bool_t enableSort)
vector< Int_t > fVectorDoubleCountTrueOmegas
vector containing labels of validated eta
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)
vector< Int_t > fVectorDoubleCountTrueEtas
vector containing labels of validated pi0
void SetProductionPoint(Double_t *point)
void SetTrueMesonValue(Int_t trueMeson)
TString GetPeriodName()
void ProcessTrueMesonCandidates(AliAODConversionMother *Pi0Candidate, AliAODConversionMother *TrueNeutralPionCandidate, AliAODConversionPhoton *TrueVirtualGammaCandidate)
TParticle * GetPositiveMCDaughter(AliMCEvent *mcEvent)
void SetCaloPhotonMCLabel(Int_t i, Int_t labelCaloPhoton)
TParticle * GetNegativeMCDaughter(AliMCEvent *mcEvent)
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
void ProcessTrueCaloPhotonCandidates(AliAODConversionPhoton *TruePhotonCandidate)
float Float_t
Definition: External.C:68
std::vector< AliAODConversionMother * > AliGammaConversionMotherAODVector
Int_t method
TH1I ** fHistoNEvents
vector containing labels of validated photons
AliConversionPhotonCuts * GetConversionCuts()
Definition: AliV0ReaderV1.h:89
Int_t GetTrackLabel(Int_t i) const
Class handling all kinds of selection cuts for Gamma Conversion analysis.
Int_t GetMCParticleLabel(AliMCEvent *mcEvent)
TH2F ** fHistoDoubleCountTrueConvGammaRPt
array of histos with double counted omegas, invMass, pT
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
Double_t centMax
void ProcessTrueNeutralPionCandidatesPureConversions(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1)
TList * GetCaloTrackMatcherHistograms()
Double_t GetProductionZ() const
Double_t GetProductionX() const
AliGammaConversionMotherAODVector * GetBGGoodMesons(Int_t zbin, Int_t mbin, Int_t event)
vector< Int_t > fVectorDoubleCountTrueConvGammas
vector containing labels of validated omega
Class handling all kinds of selection cuts for Gamma Conversion analysis.
TH2F ** fHistoDoubleCountTrueEtaInvMassPt
array of histos with double counted pi0s, invMass, pT
void SetNCaloPhotonMCLabels(Int_t nLabels)
TClonesArray * GetReconstructedGammas() const
Definition: AliV0ReaderV1.h:85
AliPrimaryPionCuts * GetPrimaryPionCuts()
TH2F ** fHistoDoubleCountTrueOmegaInvMassPt
array of histos with double counted etas, invMass, pT
Bool_t KinematicCut(AliAODConversionMother *negpion, AliAODConversionMother *pospion, AliAODConversionMother *neutpion, AliAODConversionMother *omega)
Class handling all kinds of selection cuts for Gamma Conversion analysis.
Double_t GetProductionY() const
AliConvEventCuts * GetEventCuts()
Definition: AliV0ReaderV1.h:90
const char Option_t
Definition: External.C:48
void MoveParticleAccordingToVertex(AliAODConversionMother *particle, const AliGammaConversionAODBGHandler::GammaConversionVertex *vertex)
bool Bool_t
Definition: External.C:53
void ProcessTrueNeutralPionCandidatesMixedConvCalo(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1)
vector< Int_t > GetReconstructedNegPionIndex()
void CalculateDistanceOfClossetApproachToPrimVtx(const AliVVertex *primVertex)
Bool_t CheckVectorForDoubleCount(vector< Int_t > &vec, Int_t tobechecked)
Double_t GetConversionRadius() const
void ProcessTrueNeutralPionCandidatesPureConversionsAOD(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1)
Double_t centMin