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