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