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