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