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