AliPhysics  b752f14 (b752f14)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskOmegaToPiZeroGamma.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: Daniel Mühlheim, Ziruo Zhang *
5  * Version 1.0 *
6  * *
7  * *
8  * Permission to use, copy, modify and distribute this software and its *
9  * documentation strictly for non-commercial purposes is hereby granted *
10  * without fee, provided that the above copyright notice appears in all *
11  * copies and that both the copyright notice and this permission notice *
12  * appear in the supporting documentation. The authors make no claims *
13  * about the suitability of this software for any purpose. It is *
14  * provided "as is" without express or implied warranty. *
15  **************************************************************************/
16 
18 //----------------------------------------------------------------
19 // Class used to do analysis on conversion photons + calo photons
20 //----------------------------------------------------------------
22 #include "TChain.h"
23 #include "TTree.h"
24 #include "TBranch.h"
25 #include "TFile.h"
26 #include "TH1F.h"
27 #include "TH2F.h"
28 #include "TH3F.h"
29 #include "THnSparse.h"
30 #include "TCanvas.h"
31 #include "TNtuple.h"
32 #include "AliAnalysisTask.h"
33 #include "AliAnalysisManager.h"
34 #include "AliESDEvent.h"
35 #include "AliESDInputHandler.h"
36 #include "AliMCEventHandler.h"
37 #include "AliMCEvent.h"
38 #include "AliMCParticle.h"
39 #include "AliCentrality.h"
40 #include "AliESDVZERO.h"
41 #include "AliESDpid.h"
43 #include "AliVParticle.h"
44 #include "AliESDtrack.h"
45 #include "AliESDtrackCuts.h"
46 #include "AliKFVertex.h"
47 #include "AliGenCocktailEventHeader.h"
49 #include "AliAODMCParticle.h"
50 #include "AliAODMCHeader.h"
51 #include "AliEventplane.h"
53 #include "AliAODEvent.h"
54 #include "AliAODInputHandler.h"
55 #include "AliESDEvent.h"
56 #include "AliESDInputHandler.h"
57 #include "AliInputEventHandler.h"
58 #include "AliCaloTrackMatcher.h"
59 #include <vector>
60 #include <map>
61 
63 
64 //________________________________________________________________________
66  fV0Reader(NULL),
67  fV0ReaderName("V0ReaderV1"),
68  fBGHandler(NULL),
69  fBGClusHandler(NULL),
70  fBGPi0Handler(NULL),
71  fInputEvent(NULL),
72  fMCEvent(NULL),
73  fMCStack(NULL),
74  fCutFolder(NULL),
75  fESDList(NULL),
76  fTrueList(NULL),
77  fMCList(NULL),
78  fClusterOutputList(NULL),
79  fOutputContainer(NULL),
80  fReaderGammas(NULL),
81  fGammaCandidates(NULL),
82  fClusterCandidates(NULL),
83  fPi0Candidates(NULL),
84  fEventCutArray(NULL),
85  fEventCuts(NULL),
86  fCutArray(NULL),
87  fConversionCuts(NULL),
88  fClusterCutArray(NULL),
89  fCaloPhotonCuts(NULL),
90  fNeutralPionCutArray(NULL),
91  fMesonCutArray(NULL),
92  fHistoConvGammaPt(NULL),
93  fHistoConvGammaR(NULL),
94  fHistoConvGammaEta(NULL),
95  fHistoPhotonPairInvMassPt(NULL),
96  fHistoPhotonPairMatchedInvMassPt(NULL),
97  fHistoPhotonPairYPt(NULL),
98  fHistoPhotonPairAlphaPt(NULL),
99  fHistoPhotonPairOpenAnglePt(NULL),
100  fHistoPhotonPairEtaPhi(NULL),
101  fHistoMotherConvPhotonEtaPhi(NULL),
102  fHistoMotherInvMassPt(NULL),
103  fHistoMotherMatchedInvMassPt(NULL),
104  fHistoMotherAngleCutRejectedInvMassPt(NULL),
105  fHistoMotherYPt(NULL),
106  fHistoMotherAlphaPt(NULL),
107  fHistoMotherEtaPhi(NULL),
108  fHistoMotherPi0AnglePt(NULL),
109  fHistoMotherGammaAnglePt(NULL),
110  fHistoPi0GammaAnglePt(NULL),
111  fHistoGammaFromMotherPt(NULL),
112  fHistoDiffPi0SameGammaBackInvMassPt(NULL),
113  fHistoSamePi0DiffGammaBackInvMassPt(NULL),
114  fHistoClusGammaPt(NULL),
115  fHistoClusOverlapHeadersGammaPt(NULL),
116  fHistoMCAllGammaPt(NULL),
117  fHistoMCAllGammaEMCALAccPt(NULL),
118  fHistoMCConvGammaPt(NULL),
119  fHistoMCConvGammaR(NULL),
120  fHistoMCConvGammaEta(NULL),
121  fHistoMCPi0Pt(NULL),
122  fHistoMCPi0WOWeightPt(NULL),
123  fHistoMCPi0WOEvtWeightPt(NULL),
124  fHistoMCPi0InAccPt(NULL),
125  fHistoMCPi0WOWeightInAccPt(NULL),
126  fHistoMCPi0PtY(NULL),
127  fHistoMCPi0PtAlpha(NULL),
128  fHistoMCPi0PtJetPt(NULL),
129  fHistoMCGammaFromAllOmegaPt(NULL),
130  fHistoMCGammaFromOmegaInAccPt(NULL),
131  fHistoMCOmegaInAccInvMassPt(NULL),
132  fHistoMCOmegaInvMassPt(NULL),
133  fHistoMCAllOmegaYPt(NULL),
134  fHistoMCOmegaInAccYPt(NULL),
135  fHistoMCAllOmegaInvMassPt(NULL),
136  fHistoMCAllOmegaAlphaPt(NULL),
137  fHistoMCOmegaInAccAlphaPt(NULL),
138  fHistoMCPi0FromAllOmegaAlphaPt(NULL),
139  fHistoMCPi0FromOmegaInAccAlphaPt(NULL),
140  fHistoMCPi0FromAllOmegaYPt(NULL),
141  fHistoMCPi0FromOmegaInAccYPt(NULL),
142  fHistoMCPi0FromAllOmegaEtaPhi(NULL),
143  fHistoMCPi0FromOmegaInAccEtaPhi(NULL),
144  fHistoMCPi0FromAllOmegaInvMassPt(NULL),
145  fHistoMCPi0FromOmegaInAccInvMassPt(NULL),
146  fHistoMCAllOmegaEtaPhi(NULL),
147  fHistoMCOmegaInAccEtaPhi(NULL),
148  fHistoMCAllOmegaPiZeroAnglePt(NULL),
149  fHistoMCAllPiZeroGammaAnglePt(NULL),
150  fHistoMCAllOmegaGammaAnglePt(NULL),
151  fHistoMCInAccOmegaPiZeroAnglePt(NULL),
152  fHistoMCInAccPiZeroGammaAnglePt(NULL),
153  fHistoMCInAccOmegaGammaAnglePt(NULL),
154  fHistoMCAllOmegaPtPi0Pt(NULL),
155  fHistoMCInAccOmegaPtPi0Pt(NULL),
156  fHistoMCAllOmegaPtGammaPt(NULL),
157  fHistoMCInAccOmegaPtGammaPt(NULL),
158  fHistoTrueOmegaInvMassPt(NULL),
159  fHistoTruePi0FromOmegaInvMassPt(NULL),
160  fHistoTruePi0FromOmegaAlphaPt(NULL),
161  fHistoTruePi0FromOmegaYPt(NULL),
162  fHistoTruePi0FromOmegaEtaPhi(NULL),
163  fHistoTruePi0FromOmegaOpenAnglePt(NULL),
164  fHistoTrueOmegaPi0AnglePt(NULL),
165  fHistoTrueOmegaGammaAnglePt(NULL),
166  fHistoTruePi0GammaAnglePt(NULL),
167  fHistoTrueOmegaYPt(NULL),
168  fHistoTrueOmegaAlphaPt(NULL),
169  fHistoTrueOmegaEtaPhi(NULL),
170  fHistoTrueOmegaPtPi0Pt(NULL),
171  fHistoTrueOmegaPtGammaPt(NULL),
172  fHistoTrueGammaFromOmegaPt(NULL),
173  fVectorRecTruePi0s(0),
174  fVectorDoubleCountTruePi0s(0),
175  fHistoMultipleCountTruePi0(NULL),
176  fMapMultipleCountTruePi0s(),
177  fHistoNEvents(NULL),
178  fHistoNEventsMinGamma(NULL),
179  fHistoMCOmegaDecayChannels(NULL),
180  fHistoNEventsWOWeight(NULL),
181  fHistoNGoodESDTracks(NULL),
182  fHistoVertexZ(NULL),
183  fHistoNGammaCandidates(NULL),
184  fHistoNClusterCandidates(NULL),
185  fHistoNGoodESDTracksVsNGammaCandidates(NULL),
186  fHistoSPDClusterTrackletBackground(NULL),
187  fHistoNV0Tracks(NULL),
188  fProfileEtaShift(NULL),
189  fProfileJetJetXSection(NULL),
190  fHistoJetJetNTrials(NULL),
191  fEventPlaneAngle(-100),
192  fNGammaCandidates(0),
193  fUnsmearedPx(NULL),
194  fUnsmearedPy(NULL),
195  fUnsmearedPz(NULL),
196  fUnsmearedE(NULL),
197  fMCStackPos(NULL),
198  fMCStackNeg(NULL),
199  fESDArrayPos(NULL),
200  fESDArrayNeg(NULL),
201  fnCuts(0),
202  fiCut(0),
203  fMoveParticleAccordingToVertex(kTRUE),
204  fIsHeavyIon(0),
205  fDoMesonQA(0),
206  fDoPhotonQA(0),
207  fIsFromMBHeader(kTRUE),
208  fIsOverlappingWithOtherHeader(kFALSE),
209  fIsMC(0),
210  fSetPlotHistsExtQA(kFALSE),
211  fWeightJetJetMC(1),
212  fEnableSortForClusMC(kFALSE),
213  fReconMethod(0),
214  flowerFactor(0),
215  fupperFactor(0),
216  fMinPi0Pt(0),
217  fmaxfit(NULL),
218  fDoPiZeroGammaAngleCut(kFALSE)
219 {
220 
221 }
222 
223 //________________________________________________________________________
225  AliAnalysisTaskSE(name),
226  fV0Reader(NULL),
227  fV0ReaderName("V0ReaderV1"),
228  fBGHandler(NULL),
229  fBGClusHandler(NULL),
230  fBGPi0Handler(NULL),
231  fInputEvent(NULL),
232  fMCEvent(NULL),
233  fMCStack(NULL),
234  fCutFolder(NULL),
235  fESDList(NULL),
236  fTrueList(NULL),
237  fMCList(NULL),
238  fClusterOutputList(NULL),
239  fOutputContainer(0),
240  fReaderGammas(NULL),
241  fGammaCandidates(NULL),
242  fClusterCandidates(NULL),
243  fPi0Candidates(NULL),
244  fEventCutArray(NULL),
245  fEventCuts(NULL),
246  fCutArray(NULL),
247  fConversionCuts(NULL),
248  fClusterCutArray(NULL),
249  fCaloPhotonCuts(NULL),
250  fNeutralPionCutArray(NULL),
251  fMesonCutArray(NULL),
252  fHistoConvGammaPt(NULL),
253  fHistoConvGammaR(NULL),
254  fHistoConvGammaEta(NULL),
255  fHistoPhotonPairInvMassPt(NULL),
256  fHistoPhotonPairMatchedInvMassPt(NULL),
257  fHistoPhotonPairYPt(NULL),
258  fHistoPhotonPairAlphaPt(NULL),
259  fHistoPhotonPairOpenAnglePt(NULL),
260  fHistoPhotonPairEtaPhi(NULL),
261  fHistoMotherConvPhotonEtaPhi(NULL),
262  fHistoMotherInvMassPt(NULL),
263  fHistoMotherMatchedInvMassPt(NULL),
264  fHistoMotherAngleCutRejectedInvMassPt(NULL),
265  fHistoMotherYPt(NULL),
266  fHistoMotherAlphaPt(NULL),
267  fHistoMotherEtaPhi(NULL),
268  fHistoMotherPi0AnglePt(NULL),
269  fHistoMotherGammaAnglePt(NULL),
270  fHistoPi0GammaAnglePt(NULL),
271  fHistoGammaFromMotherPt(NULL),
272  fHistoDiffPi0SameGammaBackInvMassPt(NULL),
273  fHistoSamePi0DiffGammaBackInvMassPt(NULL),
274  fHistoClusGammaPt(NULL),
275  fHistoClusOverlapHeadersGammaPt(NULL),
276  fHistoMCAllGammaPt(NULL),
277  fHistoMCAllGammaEMCALAccPt(NULL),
278  fHistoMCConvGammaPt(NULL),
279  fHistoMCConvGammaR(NULL),
280  fHistoMCConvGammaEta(NULL),
281  fHistoMCPi0Pt(NULL),
282  fHistoMCPi0WOWeightPt(NULL),
283  fHistoMCPi0WOEvtWeightPt(NULL),
284  fHistoMCPi0InAccPt(NULL),
285  fHistoMCPi0WOWeightInAccPt(NULL),
286  fHistoMCPi0PtY(NULL),
287  fHistoMCPi0PtAlpha(NULL),
288  fHistoMCPi0PtJetPt(NULL),
289  fHistoMCGammaFromAllOmegaPt(NULL),
290  fHistoMCGammaFromOmegaInAccPt(NULL),
291  fHistoMCPi0FromAllOmegaInvMassPt(NULL),
292  fHistoMCAllOmegaYPt(NULL),
293  fHistoMCOmegaInAccYPt(NULL),
294  fHistoMCAllOmegaInvMassPt(NULL),
295  fHistoMCOmegaInvMassPt(NULL),
296  fHistoMCOmegaInAccInvMassPt(NULL),
297  fHistoMCAllOmegaAlphaPt(NULL),
298  fHistoMCOmegaInAccAlphaPt(NULL),
299  fHistoMCPi0FromAllOmegaAlphaPt(NULL),
300  fHistoMCPi0FromOmegaInAccAlphaPt(NULL),
301  fHistoMCPi0FromOmegaInAccInvMassPt(NULL),
302  fHistoMCPi0FromAllOmegaYPt(NULL),
303  fHistoMCPi0FromOmegaInAccYPt(NULL),
304  fHistoMCPi0FromAllOmegaEtaPhi(NULL),
305  fHistoMCPi0FromOmegaInAccEtaPhi(NULL),
306  fHistoMCOmegaInAccEtaPhi(NULL),
307  fHistoMCAllOmegaEtaPhi(NULL),
308  fHistoMCAllOmegaPiZeroAnglePt(NULL),
309  fHistoMCAllPiZeroGammaAnglePt(NULL),
310  fHistoMCAllOmegaGammaAnglePt(NULL),
311  fHistoMCInAccOmegaPiZeroAnglePt(NULL),
312  fHistoMCInAccPiZeroGammaAnglePt(NULL),
313  fHistoMCInAccOmegaGammaAnglePt(NULL),
314  fHistoMCAllOmegaPtPi0Pt(NULL),
315  fHistoMCInAccOmegaPtPi0Pt(NULL),
316  fHistoMCAllOmegaPtGammaPt(NULL),
317  fHistoMCInAccOmegaPtGammaPt(NULL),
318  fHistoTrueOmegaInvMassPt(NULL),
319  fHistoTrueOmegaYPt(NULL),
320  fHistoTrueOmegaAlphaPt(NULL),
321  fHistoTruePi0FromOmegaInvMassPt(NULL),
322  fHistoTruePi0FromOmegaAlphaPt(NULL),
323  fHistoTruePi0FromOmegaYPt(NULL),
324  fHistoTruePi0FromOmegaEtaPhi(NULL),
325  fHistoTruePi0FromOmegaOpenAnglePt(NULL),
326  fHistoTrueOmegaPi0AnglePt(NULL),
327  fHistoTrueOmegaGammaAnglePt(NULL),
328  fHistoTruePi0GammaAnglePt(NULL),
329  fHistoTrueOmegaEtaPhi(NULL),
330  fHistoTrueOmegaPtPi0Pt(NULL),
331  fHistoTrueOmegaPtGammaPt(NULL),
332  fHistoTrueGammaFromOmegaPt(NULL),
333  fVectorRecTruePi0s(0),
334  fVectorDoubleCountTruePi0s(0),
335  fHistoMultipleCountTruePi0(NULL),
336  fMapMultipleCountTruePi0s(),
337  fHistoNEvents(NULL),
338  fHistoNEventsMinGamma(NULL),
339  fHistoMCOmegaDecayChannels(NULL),
340  fHistoNEventsWOWeight(NULL),
341  fHistoNGoodESDTracks(NULL),
342  fHistoVertexZ(NULL),
343  fHistoNGammaCandidates(NULL),
344  fHistoNClusterCandidates(NULL),
345  fHistoNGoodESDTracksVsNGammaCandidates(NULL),
346  fHistoSPDClusterTrackletBackground(NULL),
347  fHistoNV0Tracks(NULL),
348  fProfileEtaShift(NULL),
349  fProfileJetJetXSection(NULL),
350  fHistoJetJetNTrials(NULL),
351  fEventPlaneAngle(-100),
352  fNGammaCandidates(0),
353  fUnsmearedPx(NULL),
354  fUnsmearedPy(NULL),
355  fUnsmearedPz(NULL),
356  fUnsmearedE(NULL),
357  fMCStackPos(NULL),
358  fMCStackNeg(NULL),
359  fESDArrayPos(NULL),
360  fESDArrayNeg(NULL),
361  fnCuts(0),
362  fiCut(0),
363  fMoveParticleAccordingToVertex(kTRUE),
364  fIsHeavyIon(0),
365  fDoMesonQA(0),
366  fDoPhotonQA(0),
367  fIsFromMBHeader(kTRUE),
368  fIsOverlappingWithOtherHeader(kFALSE),
369  fIsMC(0),
370  fSetPlotHistsExtQA(kFALSE),
371  fWeightJetJetMC(1),
372  fEnableSortForClusMC(kFALSE),
373  fReconMethod(0),
374  flowerFactor(0),
375  fupperFactor(0),
376  fMinPi0Pt(0),
377  fmaxfit(NULL),
378  fDoPiZeroGammaAngleCut(kFALSE)
379 {
380  // Define output slots here
381  DefineOutput(1, TList::Class());
382 }
383 
385 {
386  if(fGammaCandidates){
387  delete fGammaCandidates;
388  fGammaCandidates = 0x0;
389  }
390  if(fClusterCandidates){
391  delete fClusterCandidates;
392  fClusterCandidates = 0x0;
393  }
394  if(fPi0Candidates){
395  delete fPi0Candidates;
396  fPi0Candidates = 0x0;
397  }
398  if(fBGHandler){
399  delete[] fBGHandler;
400  fBGHandler = 0x0;
401  }
402  if(fBGClusHandler){
403  delete[] fBGClusHandler;
404  fBGClusHandler = 0x0;
405  }
406  if(fBGPi0Handler){
407  delete[] fBGPi0Handler;
408  fBGPi0Handler = 0x0;
409  }
411  delete fmaxfit;
412  fmaxfit = 0x0;
413  }
414 }
415 //___________________________________________________________
417 
421 
422  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
423  if (((AliConversionMesonCuts*)fNeutralPionCutArray->At(iCut))->DoBGCalculation()){
424 
425  Int_t collisionSystem = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(0,1));
426  Int_t centMin = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(1,1));
427  Int_t centMax = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(2,1));
428 
429  if(collisionSystem == 1 || collisionSystem == 2 ||
430  collisionSystem == 5 || collisionSystem == 8 ||
431  collisionSystem == 9){
432  centMin = centMin*10;
433  centMax = centMax*10;
434  if(centMax ==0 && centMax!=centMin) centMax=100;
435  }else if(collisionSystem == 3 || collisionSystem == 6){
436  centMin = centMin*5;
437  centMax = centMax*5;
438  }else if(collisionSystem == 4 || collisionSystem == 7){
439  centMin = ((centMin*5)+45);
440  centMax = ((centMax*5)+45);
441  }
442 
444  collisionSystem,centMin,centMax,
445  ((AliConversionMesonCuts*)fNeutralPionCutArray->At(iCut))->GetNumberOfBGEvents(),
446  ((AliConversionMesonCuts*)fNeutralPionCutArray->At(iCut))->UseTrackMultiplicity(),
447  2,8,5);
449  collisionSystem,centMin,centMax,
450  ((AliConversionMesonCuts*)fNeutralPionCutArray->At(iCut))->GetNumberOfBGEvents(),
451  ((AliConversionMesonCuts*)fNeutralPionCutArray->At(iCut))->UseTrackMultiplicity(),
452  2,8,5);
454  collisionSystem,centMin,centMax,
455  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents(),
456  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseTrackMultiplicity(),
457  2,8,5);
458  }
459  }
460 }
461 //________________________________________________________________________
463 
464  if (fIsMC > 1){
465  fDoPhotonQA = 0;
466  }
467 
468  // create function for pi0-gamma angle cut
470  fmaxfit = new TF1("maxfit", "4.99209 / pow(x + 1.34075, 1.65) + 0.0568024");
471  }
472 
473  if(fReconMethod > 3) fMinPi0Pt = 0.5; //PCM-PCM
474  else if(fReconMethod > 1) fMinPi0Pt = 1.5; //EMCAL-EMCAL
475  else fMinPi0Pt = 1.0; //PCM-EMCAL
476 
477  // Create histograms
478  if(fOutputContainer != NULL){
479  delete fOutputContainer;
480  fOutputContainer = NULL;
481  }
482  if(fOutputContainer == NULL){
483  fOutputContainer = new TList();
484  fOutputContainer->SetOwner(kTRUE);
485  }
486 
487  // Array of current cut's gammas
488  fGammaCandidates = new TList();
489  fClusterCandidates = new TList();
490  fClusterCandidates->SetOwner(kTRUE);
491  fPi0Candidates = new TList();
492  fPi0Candidates->SetOwner(kTRUE);
493 
494  fCutFolder = new TList*[fnCuts];
495  fESDList = new TList*[fnCuts];
496 
497  fHistoNEvents = new TH1F*[fnCuts];
498  fHistoNEventsMinGamma = new TH1F*[fnCuts];
499  if (fIsMC > 1){
500  fHistoNEventsWOWeight = new TH1F*[fnCuts];
501  }
502  if (fIsMC == 2){
503  fProfileJetJetXSection = new TProfile*[fnCuts];
504  fHistoJetJetNTrials = new TH1F*[fnCuts];
505  }
506  fHistoNGoodESDTracks = new TH1F*[fnCuts];
507  fHistoVertexZ = new TH1F*[fnCuts];
508  fHistoNClusterCandidates = new TH1F*[fnCuts];
509  fHistoNGammaCandidates = new TH1F*[fnCuts];
510  if(fIsHeavyIon==2)
511  fProfileEtaShift = new TProfile*[fnCuts];
514  fHistoNV0Tracks = new TH1F*[fnCuts];
515  fHistoConvGammaPt = new TH1F*[fnCuts];
516 
517  if (fDoPhotonQA > 0){
518  fHistoConvGammaR = new TH1F*[fnCuts];
519  fHistoConvGammaEta = new TH1F*[fnCuts];
520  }
521 
524  fHistoGammaFromMotherPt = new TH1F*[fnCuts];
525  if(fReconMethod<2)
527  if(fReconMethod!=2 && fReconMethod!=5)
531 
532  // BG histograms
535 
536  // QA histograms
537  if(fDoMesonQA>0){
542  if(fReconMethod!=2 && fReconMethod!=5)
544  fHistoMotherYPt = new TH2F*[fnCuts];
550  }
551 
552  if(fReconMethod!=5){
554  fHistoClusGammaPt = new TH1F*[fnCuts];
556  }
557 
558  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
559  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
560  TString cutstringPhoton = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
561  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
562  TString cutstringNeutralPion = ((AliConversionMesonCuts*)fNeutralPionCutArray->At(iCut))->GetCutNumber();
563  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
564 
565  fCutFolder[iCut] = new TList();
566  fCutFolder[iCut]->SetName(Form("Cut Number %s_%s_%s_%s_%s",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringNeutralPion.Data(),cutstringMeson.Data()));
567  fCutFolder[iCut]->SetOwner(kTRUE);
568  fOutputContainer->Add(fCutFolder[iCut]);
569  fESDList[iCut] = new TList();
570  fESDList[iCut]->SetName(Form("%s_%s_%s_%s_%s ESD histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringNeutralPion.Data(),cutstringMeson.Data()));
571  fESDList[iCut]->SetOwner(kTRUE);
572  fCutFolder[iCut]->Add(fESDList[iCut]);
573 
574  fHistoNEvents[iCut] = new TH1F("NEvents","NEvents",14,-0.5,13.5);
575  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
576  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
577  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
578  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
579  TString TriggerNames = "Not Trigger: ";
580  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
581  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
582  }else {
583  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
584  }
585  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
586  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
587  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
588  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
589  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
590  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
591  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
592  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
593  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
594  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
595  fESDList[iCut]->Add(fHistoNEvents[iCut]);
596 
597  fHistoNEventsMinGamma[iCut] = new TH1F("NEventsMinGamma","NEventsMinGamma",4,-0.5,3.5);
598  fHistoNEventsMinGamma[iCut]->GetXaxis()->SetBinLabel(1,"2 EMCal 1 PCM");
599  fHistoNEventsMinGamma[iCut]->GetXaxis()->SetBinLabel(2,"2 PCM 1 EMCal");
600  fHistoNEventsMinGamma[iCut]->GetXaxis()->SetBinLabel(3,"3 EMCal");
601  fHistoNEventsMinGamma[iCut]->GetXaxis()->SetBinLabel(4,"3 PCM");
602  fESDList[iCut]->Add(fHistoNEventsMinGamma[iCut]);
603 
604  if (fIsMC > 1){
605  fHistoNEventsWOWeight[iCut] = new TH1F("NEventsWOWeight","NEventsWOWeight",14,-0.5,13.5);
606  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
607  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
608  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
609  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
610  TString TriggerNames = "Not Trigger: ";
611  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
612  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
613  }else {
614  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
615  }
616  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
617  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
618  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
619  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
620  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
621  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
622  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
623  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
624  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
625  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
626  fESDList[iCut]->Add(fHistoNEventsWOWeight[iCut]);
627  }
628 
629  if (fIsMC == 2){
630  fProfileJetJetXSection[iCut] = new TProfile("XSection","XSection",1,-0.5,0.5);
631  fESDList[iCut]->Add(fProfileJetJetXSection[iCut]);
632  fHistoJetJetNTrials[iCut] = new TH1F("NTrials","#sum{NTrials}",1,0,1);
633  fHistoJetJetNTrials[iCut]->GetXaxis()->SetBinLabel(1,"#sum{NTrials}");
634  fESDList[iCut]->Add(fHistoJetJetNTrials[iCut]);
635  }
636 
637  if(fIsHeavyIon == 1)
638  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks","GoodESDTracks",4000,0,4000);
639  else if(fIsHeavyIon == 2)
640  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks","GoodESDTracks",400,0,400);
641  else
642  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks","GoodESDTracks",200,0,200);
643  fHistoNGoodESDTracks[iCut]->SetXTitle("# TPC tracks");
644  fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
645 
646  fHistoVertexZ[iCut] = new TH1F("VertexZ","VertexZ",1000,-50,50);
647  fESDList[iCut]->Add(fHistoVertexZ[iCut]);
648 
649  if(fIsHeavyIon == 1)
650  fHistoNGammaCandidates[iCut] = new TH1F("GammaCandidates","GammaCandidates",100,0,100);
651  else if(fIsHeavyIon == 2)
652  fHistoNGammaCandidates[iCut] = new TH1F("GammaCandidates","GammaCandidates",50,0,50);
653  else
654  fHistoNGammaCandidates[iCut] = new TH1F("GammaCandidates","GammaCandidates",50,0,50);
655  fHistoNGammaCandidates[iCut]->SetXTitle("# accepted #gamma_{conv}");
656  fESDList[iCut]->Add(fHistoNGammaCandidates[iCut]);
657 
658  fHistoNClusterCandidates[iCut] = new TH1F("ClusterCandidates","ClusterCandidates",50,0,50);
659  fHistoNClusterCandidates[iCut]->SetXTitle("# accepted #gamma_{cluster}");
660  fESDList[iCut]->Add(fHistoNClusterCandidates[iCut]);
661 
662  if(fIsHeavyIon == 1)
663  fHistoNGoodESDTracksVsNGammaCandidates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",4000,0,4000,100,0,100);
664  else if(fIsHeavyIon == 2)
665  fHistoNGoodESDTracksVsNGammaCandidates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",400,0,400,50,0,50);
666  else
667  fHistoNGoodESDTracksVsNGammaCandidates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",200,0,200,50,0,50);
668  fHistoNGoodESDTracksVsNGammaCandidates[iCut]->SetXTitle("# TPC tracks");
669  fHistoNGoodESDTracksVsNGammaCandidates[iCut]->SetYTitle("# accepted #gamma_{conv}");
671 
672  fHistoSPDClusterTrackletBackground[iCut] = new TH2F("SPD tracklets vs SPD clusters","SPD tracklets vs SPD clusters",100,0,200,250,0,1000);
674 
675  if(fIsHeavyIon == 1)
676  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity","V0 Multiplicity",30000,0,30000);
677  else if(fIsHeavyIon == 2)
678  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity","V0 Multiplicity",2500,0,2500);
679  else
680  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity","V0 Multiplicity",1500,0,1500);
681  fHistoNV0Tracks[iCut]->SetXTitle("VZERO amp [arb. units]");
682  fESDList[iCut]->Add(fHistoNV0Tracks[iCut]);
683 
684  fHistoConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt","ESD_ConvGamma_Pt",500,0,50);
685  fHistoConvGammaPt[iCut]->SetXTitle("p_{T,conv}(GeV/c)");
686  fESDList[iCut]->Add(fHistoConvGammaPt[iCut]);
687 
688  if(fIsHeavyIon == 2){
689  fProfileEtaShift[iCut] = new TProfile("Eta Shift","Eta Shift",1, -0.5,0.5);
690  fESDList[iCut]->Add(fProfileEtaShift[iCut]);
691  }
692 
693  if (fIsMC > 1){
694  fHistoNEvents[iCut]->Sumw2();
695  fHistoNEventsMinGamma[iCut]->Sumw2();
696  fHistoNGoodESDTracks[iCut]->Sumw2();
697  fHistoVertexZ[iCut]->Sumw2();
698  fHistoNClusterCandidates[iCut]->Sumw2();
699  fHistoNGammaCandidates[iCut]->Sumw2();
701  fHistoSPDClusterTrackletBackground[iCut]->Sumw2();
702  fHistoNV0Tracks[iCut]->Sumw2();
703  fHistoConvGammaPt[iCut]->Sumw2();
704  }
705 
706  if (fDoPhotonQA > 0){
707  fHistoConvGammaR[iCut] = new TH1F("ESD_ConvGamma_R","ESD_ConvGamma_R",800,0,200);
708  fHistoConvGammaR[iCut]->SetXTitle("R_{conv}(cm)");
709  fESDList[iCut]->Add(fHistoConvGammaR[iCut]);
710  fHistoConvGammaEta[iCut] = new TH1F("ESD_ConvGamma_Eta","ESD_ConvGamma_Eta",2000,-2,2);
711  fHistoConvGammaEta[iCut]->SetXTitle("#eta_{conv}");
712  fESDList[iCut]->Add(fHistoConvGammaEta[iCut]);
713  }
714 
715  if(fReconMethod!=5){
716  fClusterOutputList[iCut] = new TList();
717  fClusterOutputList[iCut]->SetName(Form("%s_%s_%s_%s_%s Cluster Output",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringNeutralPion.Data(),cutstringMeson.Data()));
718  fClusterOutputList[iCut]->SetOwner(1);
719  fCutFolder[iCut]->Add(fClusterOutputList[iCut]);
720 
721  fHistoClusGammaPt[iCut] = new TH1F("ClusGamma_Pt","ClusGamma_Pt",200,0,20);
722  fHistoClusGammaPt[iCut]->SetXTitle("p_{T,clus}(GeV/c)");
723  fClusterOutputList[iCut]->Add(fHistoClusGammaPt[iCut]);
724  fHistoClusOverlapHeadersGammaPt[iCut] = new TH1F("ClusGammaOverlapHeaders_Pt","ClusGammaOverlapHeaders_Pt",200,0,20);
725  fHistoClusOverlapHeadersGammaPt[iCut]->SetXTitle("p_{T,clus}(GeV/c), selected header w/ overlap");
727 
728  if (fIsMC > 1){
729  fHistoClusGammaPt[iCut]->Sumw2();
730  fHistoClusOverlapHeadersGammaPt[iCut]->Sumw2();
731  }
732  }
733 
734  fHistoPhotonPairInvMassPt[iCut] = new TH2F("ESD_PhotonPair_InvMass_Pt","ESD_PhotonPair_InvMass_Pt",800,0,0.8,200,0,20);
735  fHistoPhotonPairInvMassPt[iCut]->SetXTitle("M_{inv, #pi^{0} cand}(GeV/c^{2})");
736  fHistoPhotonPairInvMassPt[iCut]->SetYTitle("p_{T, #pi^{0} cand}(GeV/c)");
737  fESDList[iCut]->Add(fHistoPhotonPairInvMassPt[iCut]);
738 
739  fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",800,0.4,1.2,200,0,20);
740  fHistoMotherInvMassPt[iCut]->SetXTitle("M_{inv, #omega cand}(GeV/c^{2})");
741  fHistoMotherInvMassPt[iCut]->SetYTitle("p_{T, #omega cand}(GeV/c)");
742  fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
743 
744  fHistoGammaFromMotherPt[iCut] = new TH1F("ESD_GammaFromMother_Pt","ESD_GammaFromMother_Pt",200,0,20);
745  fHistoGammaFromMotherPt[iCut]->SetXTitle("p_{T, #gamma from #omega cand}(GeV/c)");
746  fESDList[iCut]->Add(fHistoGammaFromMotherPt[iCut]);
747 
748  if(fReconMethod!=2 && fReconMethod!=5){
749  fHistoMotherMatchedInvMassPt[iCut] = new TH2F("ESD_Mother_Matched_InvMass_Pt","ESD_Mother_Matched_InvMass_Pt",800,0.4,1.2,200,0,20);
750  fHistoMotherMatchedInvMassPt[iCut]->SetXTitle("M_{inv, #omega matched}(GeV/c^{2})");
751  fHistoMotherMatchedInvMassPt[iCut]->SetYTitle("p_{T, #omega matched}(GeV/c)");
752  fESDList[iCut]->Add(fHistoMotherMatchedInvMassPt[iCut]);
753  }
754 
756  fHistoMotherAngleCutRejectedInvMassPt[iCut] = new TH2F("ESD_Mother_AngleCutRejected_InvMass_Pt","ESD_Mother_AngleCutRejected_InvMass_Pt",800,0.4,1.2,200,0,20);
757  fHistoMotherAngleCutRejectedInvMassPt[iCut]->SetXTitle("M_{inv, #omega rejected}(GeV/c^{2})");
758  fHistoMotherAngleCutRejectedInvMassPt[iCut]->SetYTitle("p_{T, #omega rejected}(GeV/c)");
760  }
761 
762  if(fReconMethod<2){
763  fHistoPhotonPairMatchedInvMassPt[iCut] = new TH2F("ESD_PhotonPair_Matched_InvMass_Pt","ESD_PhotonPair_Matched_InvMass_Pt",800,0,0.8,200,0,20);
764  fHistoPhotonPairMatchedInvMassPt[iCut]->SetXTitle("M_{inv}(GeV/c^{2}) matched conv e^{+/-}to cluster");
765  fHistoPhotonPairMatchedInvMassPt[iCut]->SetYTitle("p_{T}(GeV/c)");
766  fESDList[iCut]->Add(fHistoPhotonPairMatchedInvMassPt[iCut]);
767  }
768 
769  fHistoDiffPi0SameGammaBackInvMassPt[iCut] = new TH2F("ESD_Mother_DiffPi0SameGamma_InvMass_Pt","ESD_Mother_DiffPi0SameGamma_InvMass_Pt",800,0.4,1.2,200,0,20);
770  fHistoDiffPi0SameGammaBackInvMassPt[iCut]->SetXTitle("M_{inv}(GeV/c^{2})");
771  fHistoDiffPi0SameGammaBackInvMassPt[iCut]->SetYTitle("p_{T}(GeV/c)");
773 
774  fHistoSamePi0DiffGammaBackInvMassPt[iCut] = new TH2F("ESD_Mother_SamePi0DiffGamma_InvMass_Pt","ESD_Mother_SamePi0DiffGamma_InvMass_Pt",800,0.4,1.2,200,0,20);
775  fHistoSamePi0DiffGammaBackInvMassPt[iCut]->SetXTitle("M_{inv}(GeV/c^{2})");
776  fHistoSamePi0DiffGammaBackInvMassPt[iCut]->SetYTitle("p_{T}(GeV/c)");
778 
779  if (fIsMC > 1){
780  fHistoPhotonPairInvMassPt[iCut]->Sumw2();
781  fHistoMotherInvMassPt[iCut]->Sumw2();
782  fHistoGammaFromMotherPt[iCut]->Sumw2();
783  if(fReconMethod!=2 && fReconMethod!=5) fHistoMotherMatchedInvMassPt[iCut]->Sumw2();
785  if(fReconMethod<2) fHistoPhotonPairMatchedInvMassPt[iCut]->Sumw2();
788  }
789 
790  if(fDoMesonQA>0){
791  fHistoPhotonPairYPt[iCut] = new TH2F("ESD_PhotonPair_Y_Pt","ESD_PhotonPair_Y_Pt",300,0.03,30.,150,-1.5,1.5);
792  fHistoPhotonPairYPt[iCut]->SetXTitle("p_{T, #pi^{0}cand}(GeV/c)");
793  fHistoPhotonPairYPt[iCut]->SetYTitle("y_{#pi^{0}cand}");
795  fESDList[iCut]->Add(fHistoPhotonPairYPt[iCut]);
796 
797  fHistoPhotonPairAlphaPt[iCut] = new TH2F("ESD_PhotonPair_Alpha_Pt","ESD_PhotonPair_Alpha_Pt",300,0.03,30.,200,-1,1);
798  fHistoPhotonPairAlphaPt[iCut]->SetXTitle("p_{T, #pi^{0}cand}(GeV/c)");
799  fHistoPhotonPairAlphaPt[iCut]->SetYTitle("#alpha_{#pi^{0}cand}");
801  fESDList[iCut]->Add(fHistoPhotonPairAlphaPt[iCut]);
802 
803  fHistoPhotonPairOpenAnglePt[iCut] = new TH2F("ESD_PhotonPair_OpenAngle_Pt","ESD_PhotonPair_OpenAngle_Pt",300,0.03,30.,100,0,1);
804  fHistoPhotonPairOpenAnglePt[iCut]->SetXTitle("p_{T, #pi^{0}cand}(GeV/c)");
805  fHistoPhotonPairOpenAnglePt[iCut]->SetYTitle("#theta_{#pi^{0}cand}");
807  fESDList[iCut]->Add(fHistoPhotonPairOpenAnglePt[iCut]);
808 
809  fHistoPhotonPairEtaPhi[iCut] = new TH2F("ESD_PhotonPair_Eta_Phi","ESD_PhotonPair_Eta_Phi",600,0,2*TMath::Pi(),200,-1,1);
810  fHistoPhotonPairEtaPhi[iCut]->SetXTitle("#phi_{#pi^{0}cand}(rad)");
811  fHistoPhotonPairEtaPhi[iCut]->SetYTitle("#eta_{#pi^{0}cand}");
812  fESDList[iCut]->Add(fHistoPhotonPairEtaPhi[iCut]);
813 
814  if(fReconMethod!=2 && fReconMethod!=5){
815  fHistoMotherConvPhotonEtaPhi[iCut] = new TH2F("ESD_MotherConvPhoton_Eta_Phi","ConvPhoton under #omega peak",600,0,2*TMath::Pi(),200,-1,1);
816  fHistoMotherConvPhotonEtaPhi[iCut]->SetXTitle("#phi_{#gamma_{conv}}(rad)");
817  fHistoMotherConvPhotonEtaPhi[iCut]->SetYTitle("#eta_{#gamma_{conv}}");
818  fESDList[iCut]->Add(fHistoMotherConvPhotonEtaPhi[iCut]);
819  }
820 
821  fHistoMotherYPt[iCut] = new TH2F("ESD_Mother_Y_Pt","ESD_Mother_Y_Pt",200,0,20,150,-1.5,1.5);
822  fHistoMotherYPt[iCut]->SetYTitle("y_{#omega cand}");
823  fHistoMotherYPt[iCut]->SetXTitle("p_{T, #omega cand}(GeV/c)");
824  fESDList[iCut]->Add(fHistoMotherYPt[iCut]);
825 
826  fHistoMotherAlphaPt[iCut] = new TH2F("ESD_Mother_Alpha_Pt","ESD_Mother_Alpha_Pt",200,0,20,200,-1,1);
827  fHistoMotherAlphaPt[iCut]->SetXTitle("p_{T, #omega cand}(GeV/c)");
828  fHistoMotherAlphaPt[iCut]->SetYTitle("#alpha_{#omega cand}");
829  fESDList[iCut]->Add(fHistoMotherAlphaPt[iCut]);
830 
831  fHistoMotherEtaPhi[iCut] = new TH2F("ESD_Mother_Eta_Phi","ESD_Mother_Eta_Phi",600,0,2*TMath::Pi(),200,-1,1);
832  fHistoMotherEtaPhi[iCut]->SetXTitle("#phi_{#omega cand}(rad)");
833  fHistoMotherEtaPhi[iCut]->SetYTitle("#eta_{#omega cand}");
834  fESDList[iCut]->Add(fHistoMotherEtaPhi[iCut]);
835 
836  fHistoMotherPi0AnglePt[iCut] = new TH2F("ESD_MotherPi0_Angle_Pt","ESD_MotherPi0_Angle_Pt",200,0,20,360,0,TMath::Pi());
837  fHistoMotherPi0AnglePt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
838  fHistoMotherPi0AnglePt[iCut]->SetYTitle("#theta_{#omega cand, pi^{0}cand}");
839  fESDList[iCut]->Add(fHistoMotherPi0AnglePt[iCut]);
840 
841  fHistoMotherGammaAnglePt[iCut] = new TH2F("ESD_MotherGamma_Angle_Pt","ESD_MotherGamma_Angle_Pt",200,0,20,360,0,TMath::Pi());
842  fHistoMotherGammaAnglePt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
843  fHistoMotherGammaAnglePt[iCut]->SetYTitle("#theta_{#omega cand, #gamma}");
844  fESDList[iCut]->Add(fHistoMotherGammaAnglePt[iCut]);
845 
846  fHistoPi0GammaAnglePt[iCut] = new TH2F("ESD_Pi0Gamma_Angle_Pt","ESD_Pi0Gamma_Angle_Pt",200,0,20,360,0,TMath::Pi());
847  fHistoPi0GammaAnglePt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
848  fHistoPi0GammaAnglePt[iCut]->SetYTitle("#theta_{#pi^{0}cand,#gamma}");
849  fESDList[iCut]->Add(fHistoPi0GammaAnglePt[iCut]);
850 
851  if (fIsMC > 1){
852  fHistoPhotonPairYPt[iCut]->Sumw2();
853  fHistoPhotonPairAlphaPt[iCut]->Sumw2();
854  fHistoPhotonPairOpenAnglePt[iCut]->Sumw2();
855  fHistoPhotonPairEtaPhi[iCut]->Sumw2();
856  if(fReconMethod!=2 && fReconMethod!=5) fHistoMotherConvPhotonEtaPhi[iCut]->Sumw2();
857  fHistoMotherYPt[iCut]->Sumw2();
858  fHistoMotherPi0AnglePt[iCut]->Sumw2();
859  fHistoMotherGammaAnglePt[iCut]->Sumw2();
860  fHistoMotherAlphaPt[iCut]->Sumw2();
861  fHistoMotherEtaPhi[iCut]->Sumw2();
862  fHistoPi0GammaAnglePt[iCut]->Sumw2();
863  }
864  }
865  }
866 
867  InitBack(); // Init Background Handler
868 
869  if(fIsMC>0){
870  // MC Histogramms
871  fMCList = new TList*[fnCuts];
872  // True Histogramms
873  fTrueList = new TList*[fnCuts];
874 
875  fHistoMCAllGammaPt = new TH1F*[fnCuts];
876  fHistoMCAllGammaEMCALAccPt = new TH1F*[fnCuts];
877  fHistoMCConvGammaPt = new TH1F*[fnCuts];
883  fHistoMCPi0Pt = new TH1F*[fnCuts];
884  fHistoMCPi0WOWeightPt = new TH1F*[fnCuts];
885  fHistoMCPi0InAccPt = new TH1F*[fnCuts];
886  fHistoMCPi0WOWeightInAccPt = new TH1F*[fnCuts];
887  if (fIsMC > 1){
888  fHistoMCPi0WOEvtWeightPt = new TH1F*[fnCuts];
889  }
890  fHistoMCGammaFromAllOmegaPt = new TH1F*[fnCuts];
892  fHistoMCOmegaDecayChannels = new TH1F*[fnCuts];
893 
894  if(fDoMesonQA>0){
917  fHistoMCPi0PtY = new TH2F*[fnCuts];
919  if (fIsMC == 2){
921  }
922  }
923 
924  if (fDoPhotonQA > 0){
925  fHistoMCConvGammaR = new TH1F*[fnCuts];
926  fHistoMCConvGammaEta = new TH1F*[fnCuts];
927  }
928 
931  fHistoTrueGammaFromOmegaPt = new TH1F*[fnCuts];
932 
933  if(fDoMesonQA>0){
946  }
947 
948  fHistoMultipleCountTruePi0 = new TH1F*[fnCuts];
949 
950  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
951  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
952  TString cutstringPhoton = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
953  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
954  TString cutstringNeutralPion = ((AliConversionMesonCuts*)fNeutralPionCutArray->At(iCut))->GetCutNumber();
955  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
956 
957  fMCList[iCut] = new TList();
958  fMCList[iCut]->SetName(Form("%s_%s_%s_%s_%s MC histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringNeutralPion.Data(),cutstringMeson.Data()));
959  fMCList[iCut]->SetOwner(kTRUE);
960  fCutFolder[iCut]->Add(fMCList[iCut]);
961 
962  fHistoMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt","MC_AllGamma_Pt",200,0,20);
963  fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);
964  fHistoMCAllGammaEMCALAccPt[iCut] = new TH1F("MC_AllGammaEMCALAcc_Pt","MC_AllGammaEMCALAcc_Pt",200,0,20);
965  fMCList[iCut]->Add(fHistoMCAllGammaEMCALAccPt[iCut]);
966  fHistoMCConvGammaPt[iCut] = new TH1F("MC_ConvGamma_Pt","MC_ConvGamma_Pt",500,0,50);
967  fMCList[iCut]->Add(fHistoMCConvGammaPt[iCut]);
968 
969  if (fIsMC > 1){
970  fHistoMCAllGammaPt[iCut]->Sumw2();
971  fHistoMCAllGammaEMCALAccPt[iCut]->Sumw2();
972  fHistoMCConvGammaPt[iCut]->Sumw2();
973  }
974 
975  if (fDoPhotonQA > 0){
976  fHistoMCConvGammaR[iCut] = new TH1F("MC_ConvGamma_R","MC_ConvGamma_R",800,0,200);
977  fMCList[iCut]->Add(fHistoMCConvGammaR[iCut]);
978  fHistoMCConvGammaEta[iCut] = new TH1F("MC_ConvGamma_Eta","MC_ConvGamma_Eta",2000,-2,2);
979  fMCList[iCut]->Add(fHistoMCConvGammaEta[iCut]);
980  }
981 
982  fHistoMCPi0Pt[iCut] = new TH1F("MC_Pi0_Pt","MC_Pi0_Pt",200,0,20);
983  fHistoMCPi0Pt[iCut]->Sumw2();
984  fMCList[iCut]->Add(fHistoMCPi0Pt[iCut]);
985  fHistoMCPi0WOWeightPt[iCut] = new TH1F("MC_Pi0_WOWeights_Pt","MC_Pi0_WOWeights_Pt",200,0,20);
986  fMCList[iCut]->Add(fHistoMCPi0WOWeightPt[iCut]);
987 
988  fHistoMCPi0InAccPt[iCut] = new TH1F("MC_Pi0InAcc_Pt","MC_Pi0InAcc_Pt",200,0,20);
989  fHistoMCPi0InAccPt[iCut]->Sumw2();
990  fMCList[iCut]->Add(fHistoMCPi0InAccPt[iCut]);
991  fHistoMCPi0WOWeightInAccPt[iCut] = new TH1F("MC_Pi0WOWeightInAcc_Pt","MC_Pi0WOWeightInAcc_Pt",200,0,20);
992  fMCList[iCut]->Add(fHistoMCPi0WOWeightInAccPt[iCut]);
993 
994  fHistoMCGammaFromAllOmegaPt[iCut] = new TH1F("MC_GammaFromAllOmega_Pt","MC_GammaFromAllOmega_Pt",200,0,20);
995  fHistoMCGammaFromAllOmegaPt[iCut]->SetXTitle("p_{T, #gamma}(GeV/c)");
996  fMCList[iCut]->Add(fHistoMCGammaFromAllOmegaPt[iCut]);
997 
998  fHistoMCGammaFromOmegaInAccPt[iCut] = new TH1F("MC_GammaFromOmegaInAcc_Pt","MC_GammaFromOmegaInAcc_Pt",200,0,20);
999  fHistoMCGammaFromOmegaInAccPt[iCut]->SetXTitle("p_{T, #gamma}(GeV/c)");
1000  fMCList[iCut]->Add(fHistoMCGammaFromOmegaInAccPt[iCut]);
1001 
1002  fHistoMCOmegaDecayChannels[iCut] = new TH1F("MC_OmegaDecayChannels","MC_OmegaDecayChannels",3,-0.5,2.5);
1003  fHistoMCOmegaDecayChannels[iCut]->GetXaxis()->SetBinLabel(1,"PiPlPiMiPiZero");
1004  fHistoMCOmegaDecayChannels[iCut]->GetXaxis()->SetBinLabel(2,"PiZeroGamma");
1005  fHistoMCOmegaDecayChannels[iCut]->GetXaxis()->SetBinLabel(3,"Others");
1006  fMCList[iCut]->Add(fHistoMCOmegaDecayChannels[iCut]);
1007 
1008  fHistoMCAllOmegaInvMassPt[iCut] = new TH2F("MC_AllOmega_InvMass_Pt","MC_AllOmega_InvMass_Pt",800,0.4,1.2,200,0,20);
1009  fHistoMCAllOmegaInvMassPt[iCut]->SetXTitle("M_{inv,#omega}(GeV/c^{2})");
1010  fHistoMCAllOmegaInvMassPt[iCut]->SetYTitle("#omega p_{T}(GeV/c)");
1011  fMCList[iCut]->Add(fHistoMCAllOmegaInvMassPt[iCut]);
1012 
1013  fHistoMCPi0FromAllOmegaInvMassPt[iCut] = new TH2F("MC_Pi0FromAllOmega_InvMass_Pt","MC_Pi0FromAllOmega_InvMass_Pt",800,0,0.8,200,0,20);
1014  fHistoMCPi0FromAllOmegaInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2})");
1015  fHistoMCPi0FromAllOmegaInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T}(GeV/c)");
1016  fMCList[iCut]->Add(fHistoMCPi0FromAllOmegaInvMassPt[iCut]);
1017 
1018  fHistoMCPi0FromOmegaInAccInvMassPt[iCut] = new TH2F("MC_Pi0FromOmegaInAcc_InvMass_Pt","MC_Pi0FromOmegaInAcc_InvMass_Pt",800,0,0.8,200,0,20);
1019  fHistoMCPi0FromOmegaInAccInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2})");
1020  fHistoMCPi0FromOmegaInAccInvMassPt[iCut]->SetYTitle("#pi^{0} p_{T}(GeV/c)");
1021  fMCList[iCut]->Add(fHistoMCPi0FromOmegaInAccInvMassPt[iCut]);
1022 
1023  fHistoMCOmegaInvMassPt[iCut] = new TH2F("MC_OmegaInvMass_Pt","MC_OmegaInvMass_Pt",800,0.4,1.2,200,0,20);
1024  fHistoMCOmegaInvMassPt[iCut]->SetXTitle("M_{inv,#omega}(GeV/c^{2})");
1025  fHistoMCOmegaInvMassPt[iCut]->SetYTitle("#omega p_{T}(GeV/c)");
1026  fMCList[iCut]->Add(fHistoMCOmegaInvMassPt[iCut]);
1027 
1028  fHistoMCOmegaInAccInvMassPt[iCut] = new TH2F("MC_OmegaInAcc_InvMass_Pt","MC_OmegaInAcc_InvMass_Pt",800,0.4,1.2,200,0,20);
1029  fHistoMCOmegaInAccInvMassPt[iCut]->SetXTitle("M_{inv,#omega}(GeV/c^{2})");
1030  fHistoMCOmegaInAccInvMassPt[iCut]->SetYTitle("#omega p_{T}(GeV/c)");
1031  fMCList[iCut]->Add(fHistoMCOmegaInAccInvMassPt[iCut]);
1032 
1033  if(fDoMesonQA>0){
1034  fHistoMCAllOmegaYPt[iCut] = new TH2F("MC_AllOmega_Y_Pt","MC_AllOmega_Y_Pt",200,0,20,150,-1.5,1.5);
1035  fHistoMCAllOmegaYPt[iCut]->SetXTitle("p_{T,#omega}(GeV/c)");
1036  fHistoMCAllOmegaYPt[iCut]->SetYTitle("Y_{#omega}");
1037  fMCList[iCut]->Add(fHistoMCAllOmegaYPt[iCut]);
1038 
1039  fHistoMCOmegaInAccYPt[iCut] = new TH2F("MC_OmegaInAcc_Y_Pt","MC_OmegaInAcc_Y_Pt",200,0,20,150,-1.5,1.5);
1040  fHistoMCOmegaInAccYPt[iCut]->SetXTitle("p_{T,#omega}(GeV/c)");
1041  fHistoMCOmegaInAccYPt[iCut]->SetYTitle("Y_{#omega}");
1042  fMCList[iCut]->Add(fHistoMCOmegaInAccYPt[iCut]);
1043 
1044  fHistoMCAllOmegaAlphaPt[iCut] = new TH2F("MC_AllOmega_Alpha_Pt","MC_AllOmega_Alpha_Pt",200,0,20,200,-1,1);
1045  fHistoMCAllOmegaAlphaPt[iCut]->SetXTitle("p_{T,#omega}(GeV/c)");
1046  fHistoMCAllOmegaAlphaPt[iCut]->SetYTitle("#alpha_{#omega}");
1047  fMCList[iCut]->Add(fHistoMCAllOmegaAlphaPt[iCut]);
1048 
1049  fHistoMCOmegaInAccAlphaPt[iCut] = new TH2F("MC_OmegaInAcc_Alpha_Pt","MC_OmegaInAcc_Alpha_Pt",200,0,20,200,-1,1);
1050  fHistoMCOmegaInAccAlphaPt[iCut]->SetXTitle("p_{T,#omega}(GeV/c)");
1051  fHistoMCOmegaInAccAlphaPt[iCut]->SetYTitle("#alpha_{#omega}");
1052  fMCList[iCut]->Add(fHistoMCOmegaInAccAlphaPt[iCut]);
1053 
1054  fHistoMCPi0FromAllOmegaAlphaPt[iCut] = new TH2F("MC_Pi0FromAllOmega_Alpha_Pt","MC_Pi0FromAllOmega_Alpha_Pt",200,0,20,200,-1,1);
1055  fHistoMCPi0FromAllOmegaAlphaPt[iCut]->SetXTitle("p_{T,#pi^{0}}(GeV/c)");
1056  fHistoMCPi0FromAllOmegaAlphaPt[iCut]->SetYTitle("#alpha_{#pi^{0}}");
1057  fMCList[iCut]->Add(fHistoMCPi0FromAllOmegaAlphaPt[iCut]);
1058 
1059  fHistoMCPi0FromOmegaInAccAlphaPt[iCut] = new TH2F("MC_Pi0FromOmegaInAcc_Alpha_Pt","MC_Pi0FromOmegaInAcc_Alpha_Pt",200,0,20,200,-1,1);
1060  fHistoMCPi0FromOmegaInAccAlphaPt[iCut]->SetXTitle("p_{T,#pi^{0}}(GeV/c)");
1061  fHistoMCPi0FromOmegaInAccAlphaPt[iCut]->SetYTitle("#alpha_{#pi^{0}}");
1062  fMCList[iCut]->Add(fHistoMCPi0FromOmegaInAccAlphaPt[iCut]);
1063 
1064  fHistoMCPi0FromAllOmegaYPt[iCut] = new TH2F("MC_Pi0FromAllOmega_Y_Pt","MC_Pi0FromAllOmega_Y_Pt",200,0,20,150,-1.5,1.5);
1065  fHistoMCPi0FromAllOmegaYPt[iCut]->SetXTitle("p_{T,#pi^{0}}(GeV/c)");
1066  fHistoMCPi0FromAllOmegaYPt[iCut]->SetYTitle("Y_{#pi^{0}}");
1067  fMCList[iCut]->Add(fHistoMCPi0FromAllOmegaYPt[iCut]);
1068 
1069  fHistoMCPi0FromOmegaInAccYPt[iCut] = new TH2F("MC_Pi0FromOmegaInAcc_Y_Pt","MC_Pi0FromOmegaInAcc_Y_Pt",200,0,20,150,-1.5,1.5);
1070  fHistoMCPi0FromOmegaInAccYPt[iCut]->SetXTitle("p_{T,#pi^{0}}(GeV/c)");
1071  fHistoMCPi0FromOmegaInAccYPt[iCut]->SetYTitle("Y_{#pi^{0}}");
1072  fMCList[iCut]->Add(fHistoMCPi0FromOmegaInAccYPt[iCut]);
1073 
1074  fHistoMCPi0FromAllOmegaEtaPhi[iCut] = new TH2F("MC_Pi0FromAllOmega_Eta_Phi","MC_Pi0FromAllOmega_Eta_Phi",600,0,2*TMath::Pi(),200,-1,1);
1075  fHistoMCPi0FromAllOmegaEtaPhi[iCut]->SetXTitle("#phi_{#pi^{0}}(rad)");
1076  fHistoMCPi0FromAllOmegaEtaPhi[iCut]->SetYTitle("#eta_{#pi^{0}}");
1077  fMCList[iCut]->Add(fHistoMCPi0FromAllOmegaEtaPhi[iCut]);
1078 
1079  fHistoMCPi0FromOmegaInAccEtaPhi[iCut] = new TH2F("MC_Pi0FromOmegaInAcc_Eta_Phi","MC_Pi0FromOmegaInAcc_Eta_Phi",600,0,2*TMath::Pi(),200,-1,1);
1080  fHistoMCPi0FromOmegaInAccEtaPhi[iCut]->SetXTitle("#phi_{#pi^{0}}(rad)");
1081  fHistoMCPi0FromOmegaInAccEtaPhi[iCut]->SetYTitle("#eta_{#pi^{0}}");
1082  fMCList[iCut]->Add(fHistoMCPi0FromOmegaInAccEtaPhi[iCut]);
1083 
1084  fHistoMCAllOmegaEtaPhi[iCut] = new TH2F("MC_AllOmega_Eta_Phi","MC_AllOmega_Eta_Phi",600,0,2*TMath::Pi(),200,-1,1);
1085  fHistoMCAllOmegaEtaPhi[iCut]->SetXTitle("#phi_{#omega}(rad)");
1086  fHistoMCAllOmegaEtaPhi[iCut]->SetYTitle("#eta_{#omega}");
1087  fMCList[iCut]->Add(fHistoMCAllOmegaEtaPhi[iCut]);
1088 
1089  fHistoMCOmegaInAccEtaPhi[iCut] = new TH2F("MC_OmegaInAcc_Eta_Phi","MC_OmegaInAcc_Eta_Phi",600,0,2*TMath::Pi(),200,-1,1);
1090  fHistoMCOmegaInAccEtaPhi[iCut]->SetXTitle("#phi_{#omega}(rad)");
1091  fHistoMCOmegaInAccEtaPhi[iCut]->SetYTitle("#eta_{#omega}");
1092  fMCList[iCut]->Add(fHistoMCOmegaInAccEtaPhi[iCut]);
1093 
1094  fHistoMCAllOmegaPiZeroAnglePt[iCut] = new TH2F("MC_AllOmegaPiZero_Angle_Pt","MC_AllOmegaPiZero_Angle_Pt",200,0,20,360,0,TMath::Pi());
1095  fHistoMCAllOmegaPiZeroAnglePt[iCut]->SetYTitle("#theta_{#omega,#pi^{0}}");
1096  fHistoMCAllOmegaPiZeroAnglePt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
1097  fMCList[iCut]->Add(fHistoMCAllOmegaPiZeroAnglePt[iCut]);
1098 
1099  fHistoMCAllPiZeroGammaAnglePt[iCut] = new TH2F("MC_AllPiZeroGamma_Angle_Pt","MC_AllPiZeroGamma_Angle_Pt",200,0,20,360,0,TMath::Pi());
1100  fHistoMCAllPiZeroGammaAnglePt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
1101  fHistoMCAllPiZeroGammaAnglePt[iCut]->SetYTitle("#theta_{#pi^{0},#gamma}");
1102  fMCList[iCut]->Add(fHistoMCAllPiZeroGammaAnglePt[iCut]);
1103 
1104  fHistoMCAllOmegaGammaAnglePt[iCut] = new TH2F("MC_AllOmegaGamma_Angle_Pt","MC_AllOmegaGamma_Angle_Pt",200,0,20,360,0,TMath::Pi());
1105  fHistoMCAllOmegaGammaAnglePt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
1106  fHistoMCAllOmegaGammaAnglePt[iCut]->SetYTitle("#theta_{#omega,#gamma}");
1107  fMCList[iCut]->Add(fHistoMCAllOmegaGammaAnglePt[iCut]);
1108 
1109  fHistoMCInAccOmegaPiZeroAnglePt[iCut] = new TH2F("MC_InAccOmegaPiZero_Angle_Pt","MC_InAccOmegaPiZero_Angle_Pt",200,0,20,360,0,TMath::Pi());
1110  fHistoMCInAccOmegaPiZeroAnglePt[iCut]->SetXTitle("p_{T,#omega}(GeV/c)");
1111  fHistoMCInAccOmegaPiZeroAnglePt[iCut]->SetYTitle("#theta_{#omega,#pi^{0}}");
1112  fMCList[iCut]->Add(fHistoMCInAccOmegaPiZeroAnglePt[iCut]);
1113 
1114  fHistoMCInAccPiZeroGammaAnglePt[iCut] = new TH2F("MC_InAccPiZeroGamma_Angle_Pt","MC_InAccPiZeroGamma_Angle_Pt",200,0,20,360,0,TMath::Pi());
1115  fHistoMCInAccPiZeroGammaAnglePt[iCut]->SetXTitle("p_{T,#omega}(GeV/c)");
1116  fHistoMCInAccPiZeroGammaAnglePt[iCut]->SetYTitle("#theta_{#pi^{0},#gamma}");
1117  fMCList[iCut]->Add(fHistoMCInAccPiZeroGammaAnglePt[iCut]);
1118 
1119  fHistoMCInAccOmegaGammaAnglePt[iCut] = new TH2F("MC_InAccOmegaGamma_Angle_Pt","MC_InAccOmegaGamma_Angle_Pt",200,0,20,360,0,TMath::Pi());
1120  fHistoMCInAccOmegaGammaAnglePt[iCut]->SetXTitle("p_{T,#omega}(GeV/c)");
1121  fHistoMCInAccOmegaGammaAnglePt[iCut]->SetYTitle("#theta_{#omega,#gamma}");
1122  fMCList[iCut]->Add(fHistoMCInAccOmegaGammaAnglePt[iCut]);
1123 
1124  fHistoMCAllOmegaPtPi0Pt[iCut] = new TH2F("MC_All_OmegaPt_Pi0Pt","MC_All_OmegaPt_Pi0Pt",200,0,20,200,0,20);
1125  fHistoMCAllOmegaPtPi0Pt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
1126  fHistoMCAllOmegaPtPi0Pt[iCut]->SetYTitle("#pi^{0} p_{T}(GeV/c)");
1127  fMCList[iCut]->Add(fHistoMCAllOmegaPtPi0Pt[iCut]);
1128 
1129  fHistoMCInAccOmegaPtPi0Pt[iCut] = new TH2F("MC_InAcc_OmegaPt_Pi0Pt","MC_InAcc_OmegaPt_Pi0Pt",200,0,20,200,0,20);
1130  fHistoMCInAccOmegaPtPi0Pt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
1131  fHistoMCInAccOmegaPtPi0Pt[iCut]->SetYTitle("#pi^{0} p_{T}(GeV/c)");
1132  fMCList[iCut]->Add(fHistoMCInAccOmegaPtPi0Pt[iCut]);
1133 
1134  fHistoMCAllOmegaPtGammaPt[iCut] = new TH2F("MC_All_OmegaPt_GammaPt","MC_All_OmegaPt_GammaPt",200,0,20,200,0,20);
1135  fHistoMCAllOmegaPtGammaPt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
1136  fHistoMCAllOmegaPtGammaPt[iCut]->SetYTitle("#gamma p_{T}(GeV/c)");
1137  fMCList[iCut]->Add(fHistoMCAllOmegaPtGammaPt[iCut]);
1138 
1139  fHistoMCInAccOmegaPtGammaPt[iCut] = new TH2F("MC_InAcc_OmegaPt_GammaPt","MC_InAcc_OmegaPt_GammaPt",200,0,20,200,0,20);
1140  fHistoMCInAccOmegaPtGammaPt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
1141  fHistoMCInAccOmegaPtGammaPt[iCut]->SetYTitle("#gamma p_{T}(GeV/c)");
1142  fMCList[iCut]->Add(fHistoMCInAccOmegaPtGammaPt[iCut]);
1143 
1144  fHistoMCPi0PtY[iCut] = new TH2F("MC_Pi0_Pt_Y","MC_Pi0_Pt_Y",300,0.03,30.,150,-1.5,1.5);
1145  fHistoMCPi0PtY[iCut]->Sumw2();
1147  fMCList[iCut]->Add(fHistoMCPi0PtY[iCut]);
1148 
1149  fHistoMCPi0PtAlpha[iCut] = new TH2F("MC_Pi0_Pt_Alpha","MC_Pi0_Pt_Alpha",300,0.03,30.,200,-1,1);
1151  fMCList[iCut]->Add(fHistoMCPi0PtAlpha[iCut]);
1152 
1153  if (fIsMC > 1){
1154  fHistoMCPi0PtAlpha[iCut]->Sumw2();
1155  fHistoMCAllOmegaYPt[iCut]->Sumw2();
1156  fHistoMCOmegaInAccYPt[iCut]->Sumw2();
1157  fHistoMCAllOmegaAlphaPt[iCut]->Sumw2();
1158  fHistoMCOmegaInAccAlphaPt[iCut]->Sumw2();
1159  fHistoMCPi0FromAllOmegaAlphaPt[iCut]->Sumw2();
1160  fHistoMCPi0FromOmegaInAccAlphaPt[iCut]->Sumw2();
1161  fHistoMCPi0FromAllOmegaYPt[iCut]->Sumw2();
1162  fHistoMCPi0FromOmegaInAccYPt[iCut]->Sumw2();
1163  fHistoMCPi0FromAllOmegaEtaPhi[iCut]->Sumw2();
1164  fHistoMCPi0FromOmegaInAccEtaPhi[iCut]->Sumw2();
1165  fHistoMCAllOmegaEtaPhi[iCut]->Sumw2();
1166  fHistoMCOmegaInAccEtaPhi[iCut]->Sumw2();
1167  fHistoMCAllOmegaPiZeroAnglePt[iCut]->Sumw2();
1168  fHistoMCAllPiZeroGammaAnglePt[iCut]->Sumw2();
1169  fHistoMCAllOmegaGammaAnglePt[iCut]->Sumw2();
1170  fHistoMCInAccOmegaPiZeroAnglePt[iCut]->Sumw2();
1171  fHistoMCInAccPiZeroGammaAnglePt[iCut]->Sumw2();
1172  fHistoMCInAccOmegaGammaAnglePt[iCut]->Sumw2();
1173  fHistoMCAllOmegaPtPi0Pt[iCut]->Sumw2();
1174  fHistoMCInAccOmegaPtPi0Pt[iCut]->Sumw2();
1175  fHistoMCAllOmegaPtGammaPt[iCut]->Sumw2();
1176  fHistoMCInAccOmegaPtGammaPt[iCut]->Sumw2();
1177  }
1178  }
1179 
1180  if (fIsMC > 1){
1181  fHistoMCPi0WOWeightPt[iCut]->Sumw2();
1182  fHistoMCPi0WOWeightInAccPt[iCut]->Sumw2();
1183  fHistoMCPi0WOEvtWeightPt[iCut] = new TH1F("MC_Pi0_WOEventWeights_Pt","MC_Pi0_WOEventWeights_Pt",400,0,40);
1184  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightPt[iCut]);
1185  fHistoMCGammaFromAllOmegaPt[iCut]->Sumw2();
1186  fHistoMCGammaFromOmegaInAccPt[iCut]->Sumw2();
1187  fHistoMCOmegaInAccInvMassPt[iCut]->Sumw2();
1188  fHistoMCOmegaInvMassPt[iCut]->Sumw2();
1189  fHistoMCAllOmegaInvMassPt[iCut]->Sumw2();
1190  fHistoMCPi0FromAllOmegaInvMassPt[iCut]->Sumw2();
1191  fHistoMCPi0FromOmegaInAccInvMassPt[iCut]->Sumw2();
1192  fHistoMCOmegaDecayChannels[iCut]->Sumw2();
1193 
1194  if (fDoMesonQA > 0 && fIsMC == 2){
1195  fHistoMCPi0PtJetPt[iCut] = new TH2F("MC_Pi0_Pt_JetPt","MC_Pi0_Pt_JetPt",300,0.03,30.,200,0,200);
1196  fHistoMCPi0PtJetPt[iCut]->Sumw2();
1198  fMCList[iCut]->Add(fHistoMCPi0PtJetPt[iCut]);
1199  }
1200  }
1201 
1202  fTrueList[iCut] = new TList();
1203  fTrueList[iCut]->SetName(Form("%s_%s_%s_%s_%s True histograms",cutstringEvent.Data(),cutstringPhoton.Data(),cutstringCalo.Data(),cutstringNeutralPion.Data(),cutstringMeson.Data()));
1204  fTrueList[iCut]->SetOwner(kTRUE);
1205  fCutFolder[iCut]->Add(fTrueList[iCut]);
1206 
1207  fHistoTrueOmegaInvMassPt[iCut] = new TH2F("True_Omega_InvMass_Pt","True_Omega_InvMass_Pt",800,0.4,1.2,200,0,20);
1208  fHistoTrueOmegaInvMassPt[iCut]->SetXTitle("M_{inv,#omega}(GeV/c^{2})");
1209  fHistoTrueOmegaInvMassPt[iCut]->SetYTitle("#omega p_{T}(GeV/c)");
1210  fTrueList[iCut]->Add(fHistoTrueOmegaInvMassPt[iCut]);
1211 
1212  fHistoTruePi0FromOmegaInvMassPt[iCut] = new TH2F("True_Pi0FromOmega_InvMass_Pt","True_Pi0FromOmega_InvMass_Pt",800,0,0.8,200,0,20);
1213  fHistoTruePi0FromOmegaInvMassPt[iCut]->SetXTitle("M_{inv,#pi^{0}}(GeV/c^{2})");
1214  fHistoTruePi0FromOmegaInvMassPt[iCut]->SetYTitle("#omega p_{T}(GeV/c)");
1215  fTrueList[iCut]->Add(fHistoTruePi0FromOmegaInvMassPt[iCut]);
1216 
1217  fHistoTrueGammaFromOmegaPt[iCut] = new TH1F("True_GammaFromOmega_Pt","True_GammaFromOmega_Pt",200,0,20);
1218  fHistoTrueGammaFromOmegaPt[iCut]->SetXTitle("p_{T,#gamma}(GeV/c)");
1219  fTrueList[iCut]->Add(fHistoTrueGammaFromOmegaPt[iCut]);
1220 
1221  if(fDoMesonQA>0){
1222  fHistoTrueOmegaYPt[iCut] = new TH2F("True_Omega_Y_Pt","True_Omega_Y_Pt",200,0,20,150,-1.5,1.5);
1223  fHistoTrueOmegaYPt[iCut]->SetXTitle("p_{T,#omega}(GeV/c)");
1224  fHistoTrueOmegaYPt[iCut]->SetYTitle("Y_{#omega}");
1225  fTrueList[iCut]->Add(fHistoTrueOmegaYPt[iCut]);
1226 
1227  fHistoTrueOmegaAlphaPt[iCut] = new TH2F("True_Omega_Alpha_Pt","True_Omega_Alpha_Pt",200,0,20,200,-1,1);
1228  fHistoTrueOmegaAlphaPt[iCut]->SetXTitle("p_{T,#omega}(GeV/c)");
1229  fHistoTrueOmegaAlphaPt[iCut]->SetYTitle("#alpha_{#omega}");
1230  fTrueList[iCut]->Add(fHistoTrueOmegaAlphaPt[iCut]);
1231 
1232  fHistoTruePi0FromOmegaYPt[iCut] = new TH2F("True_Pi0FromOmega_Y_Pt","True_Pi0FromOmega_Y_Pt",200,0,20,150,-1.5,1.5);
1233  fHistoTruePi0FromOmegaYPt[iCut]->SetXTitle("p_{T,pi^{0}}(GeV/c)");
1234  fHistoTruePi0FromOmegaYPt[iCut]->SetYTitle("Y_{#pi^{0}}");
1235  fTrueList[iCut]->Add(fHistoTruePi0FromOmegaYPt[iCut]);
1236 
1237  fHistoTruePi0FromOmegaAlphaPt[iCut] = new TH2F("True_Pi0FromOmega_Alpha_Pt","MC_Pi0FromOmega_Alpha_Pt",200,0,20,200,-1,1);
1238  fHistoTruePi0FromOmegaAlphaPt[iCut]->SetXTitle("p_{T,pi^{0}}(GeV/c)");
1239  fHistoTruePi0FromOmegaAlphaPt[iCut]->SetYTitle("#alpha_{#pi^{0}}");
1240  fTrueList[iCut]->Add(fHistoTruePi0FromOmegaAlphaPt[iCut]);
1241 
1242  fHistoTrueOmegaPi0AnglePt[iCut] = new TH2F("True_OmegaPiZero_Angle_Pt","True_OmegaPiZero_Angle_Pt",200,0,20,360,0,TMath::Pi());
1243  fHistoTrueOmegaPi0AnglePt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
1244  fHistoTrueOmegaPi0AnglePt[iCut]->SetYTitle("#theta_{#omega,#pi^{0}}");
1245  fTrueList[iCut]->Add(fHistoTrueOmegaPi0AnglePt[iCut]);
1246 
1247  fHistoTruePi0GammaAnglePt[iCut] = new TH2F("True_PiZeroGamma_Angle_Pt","True_PiZeroGamma_Angle_Pt",200,0,20,360,0,TMath::Pi());
1248  fHistoTruePi0GammaAnglePt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
1249  fHistoTruePi0GammaAnglePt[iCut]->SetYTitle("#theta_{#pi_{0},#gamma}");
1250  fTrueList[iCut]->Add(fHistoTruePi0GammaAnglePt[iCut]);
1251 
1252  fHistoTrueOmegaGammaAnglePt[iCut] = new TH2F("True_OmegaGamma_Angle_Pt","True_OmegaGamma_Angle_Pt",200,0,20,360,0,TMath::Pi());
1253  fHistoTrueOmegaGammaAnglePt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
1254  fHistoTrueOmegaGammaAnglePt[iCut]->SetYTitle("#theta_{#omega,#gamma}");
1255  fTrueList[iCut]->Add(fHistoTrueOmegaGammaAnglePt[iCut]);
1256 
1257  fHistoTrueOmegaEtaPhi[iCut] = new TH2F("True_Omega_Eta_Phi","True_Omega_Eta_Phi",600,0,2*TMath::Pi(),200,-1,1);
1258  fHistoTrueOmegaEtaPhi[iCut]->SetXTitle("#phi_{#omega}(rad)");
1259  fHistoTrueOmegaEtaPhi[iCut]->SetYTitle("#eta_{#omega}");
1260  fTrueList[iCut]->Add(fHistoTrueOmegaEtaPhi[iCut]);
1261 
1262  fHistoTruePi0FromOmegaEtaPhi[iCut] = new TH2F("True_Pi0FromOmega_Eta_Phi","True_Pi0FromOmega_Eta_Phi",600,0,2*TMath::Pi(),200,-1,1);
1263  fHistoTruePi0FromOmegaEtaPhi[iCut]->SetXTitle("#phi_{#pi^{0}}(rad)");
1264  fHistoTruePi0FromOmegaEtaPhi[iCut]->SetYTitle("#eta_{#pi^{0}}");
1265  fTrueList[iCut]->Add(fHistoTruePi0FromOmegaEtaPhi[iCut]);
1266 
1267  fHistoTruePi0FromOmegaOpenAnglePt[iCut] = new TH2F("True_Pi0FromOmega_OpenAngle_Pt","True_Pi0FromOmega_OpenAngle_Pt",200,0,20,100,0,1);
1268  fHistoTruePi0FromOmegaOpenAnglePt[iCut]->SetXTitle("p_{T, #pi^{0}}(GeV/c)");
1269  fHistoTruePi0FromOmegaOpenAnglePt[iCut]->SetYTitle("#theta_{#pi^{0}}");
1270  fTrueList[iCut]->Add(fHistoTruePi0FromOmegaOpenAnglePt[iCut]);
1271 
1272  fHistoTrueOmegaPtPi0Pt[iCut] = new TH2F("True_OmegaPt_Pi0Pt","True_OmegaPt_Pi0Pt",200,0,20,200,0,20);
1273  fHistoTrueOmegaPtPi0Pt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
1274  fHistoTrueOmegaPtPi0Pt[iCut]->SetYTitle("#pi^{0} p_{T}(GeV/c)");
1275  fTrueList[iCut]->Add(fHistoTrueOmegaPtPi0Pt[iCut]);
1276 
1277  fHistoTrueOmegaPtGammaPt[iCut] = new TH2F("True_OmegaPt_GammaPt","True_OmegaPt_GammaPt",200,0,20,200,0,20);
1278  fHistoTrueOmegaPtGammaPt[iCut]->SetXTitle("#omega p_{T}(GeV/c)");
1279  fHistoTrueOmegaPtGammaPt[iCut]->SetYTitle("#gamma p_{T}(GeV/c)");
1280  fTrueList[iCut]->Add(fHistoTrueOmegaPtGammaPt[iCut]);
1281 
1282  if (fIsMC > 1){
1283  fHistoTruePi0FromOmegaAlphaPt[iCut]->Sumw2();
1284  fHistoTruePi0FromOmegaYPt[iCut]->Sumw2();
1285  fHistoTruePi0FromOmegaEtaPhi[iCut]->Sumw2();
1286  fHistoTruePi0FromOmegaOpenAnglePt[iCut]->Sumw2();
1287  fHistoTrueOmegaPi0AnglePt[iCut]->Sumw2();
1288  fHistoTrueOmegaGammaAnglePt[iCut]->Sumw2();
1289  fHistoTruePi0GammaAnglePt[iCut]->Sumw2();
1290  fHistoTrueOmegaYPt[iCut]->Sumw2();
1291  fHistoTrueOmegaAlphaPt[iCut]->Sumw2();
1292  fHistoTrueOmegaEtaPhi[iCut]->Sumw2();
1293  fHistoTrueOmegaPtPi0Pt[iCut]->Sumw2();
1294  fHistoTrueOmegaPtGammaPt[iCut]->Sumw2();
1295  fHistoTrueOmegaYPt[iCut]->Sumw2();
1296  }
1297  }
1298 
1299  fHistoMultipleCountTruePi0[iCut] = new TH1F("ESD_TrueMultipleCountPi0","ESD_TrueMultipleCountPi0",10,1,11);
1300  fTrueList[iCut]->Add(fHistoMultipleCountTruePi0[iCut]);
1301 
1302  if (fIsMC > 1){
1303  fHistoMultipleCountTruePi0[iCut]->Sumw2();
1304  fHistoTrueOmegaInvMassPt[iCut]->Sumw2();
1305  fHistoTruePi0FromOmegaInvMassPt[iCut]->Sumw2();
1306  fHistoTrueGammaFromOmegaPt[iCut]->Sumw2();
1307  }
1308  }
1309  }
1310 
1312 
1313  fMapMultipleCountTruePi0s.clear();
1314 
1315  fVectorRecTruePi0s.clear();
1316 
1317  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
1318  if(!fV0Reader){printf("Error: No V0 Reader");return;}// GetV0Reader
1319 
1320  if(fV0Reader)
1322  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
1323  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
1324  if(fV0Reader)
1326  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms())
1327  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
1328 
1332 
1333  for(Int_t iMatcherTask = 0; iMatcherTask < 3; iMatcherTask++){
1334  AliCaloTrackMatcher* temp = (AliCaloTrackMatcher*) (AliAnalysisManager::GetAnalysisManager()->GetTask(Form("CaloTrackMatcher_%i",iMatcherTask)));
1335  if(temp) fOutputContainer->Add(temp->GetCaloTrackMatcherHistograms());
1336  }
1337 
1338 
1339  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1340  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))) continue;
1341  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms()){
1342  fCutFolder[iCut]->Add(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
1343  }
1344  if(!((AliConversionPhotonCuts*)fCutArray->At(iCut))) continue;
1345  if(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms()){
1346  fCutFolder[iCut]->Add(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms());
1347  }
1348  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
1349  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms()){
1350  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms());
1351  }
1352  if(fSetPlotHistsExtQA){
1353  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
1354  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetExtQAHistograms()){
1355  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetExtQAHistograms());
1356  }
1357  }
1358  if(!((AliConversionMesonCuts*)fNeutralPionCutArray->At(iCut))) continue;
1359  if(((AliConversionMesonCuts*)fNeutralPionCutArray->At(iCut))->GetCutHistograms()){
1360  fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fNeutralPionCutArray->At(iCut))->GetCutHistograms());
1361  }
1362  if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
1363  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
1364  fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
1365  }
1366  }
1367  PostData(1, fOutputContainer);
1368 }
1369 //_____________________________________________________________________________
1371 {
1372  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1373  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
1374  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
1375  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
1376  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
1377  }
1378 
1379  if(fIsHeavyIon == 2){
1380  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift()){
1381  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1382  continue; // No Eta Shift requested, continue
1383  }
1384  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
1385  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
1386  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1387  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1388  continue;
1389  } else{
1390  printf(" Gamma Conversion Task %s :: Eta Shift Manually Set to %f \n\n",
1391  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
1392  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1393  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1394  }
1395  }
1396  }
1397 
1398  return kTRUE;
1399 }
1400 //_____________________________________________________________________________
1402 {
1403  //
1404  // Called for each event
1405  //
1406  fInputEvent = InputEvent();
1407 
1408  if(fIsMC > 0) fMCEvent = MCEvent();
1409  if(fIsMC>0 && fInputEvent->IsA()==AliESDEvent::Class() && fMCEvent){
1410  fMCStack = fMCEvent->Stack();
1411  }
1412 
1413  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
1414  if(fInputEvent->IsIncompleteDAQ()==kTRUE) eventQuality = 2;// incomplete event
1415  // Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1 or because it is incomplete => skip broken event/files
1416  if(eventQuality == 2 || eventQuality == 3){
1417  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1418  fHistoNEvents[iCut]->Fill(eventQuality);
1419  if (fIsMC > 1) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
1420  }
1421  return;
1422  }
1423 
1424  if(fInputEvent->IsA()==AliAODEvent::Class()){
1425  fInputEvent->InitMagneticField();
1426  }
1427 
1428  fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
1429 
1430  // ------------------- BeginEvent ----------------------------
1431  AliEventplane *EventPlane = fInputEvent->GetEventplane();
1432  if(fIsHeavyIon ==1)fEventPlaneAngle = EventPlane->GetEventplane("V0",fInputEvent,2);
1433  else fEventPlaneAngle=0.0;
1434 
1435  if(fIsMC>0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
1436  RelabelAODPhotonCandidates(kTRUE);// In case of AODMC relabeling MC
1437  fV0Reader->RelabelAODs(kTRUE);
1438  }
1439 
1440  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1441 
1442  fiCut = iCut;
1443 // cout << ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber() << "_" << ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber() <<
1444 // "_" << ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber() <<endl;
1445 
1446  Bool_t isRunningEMCALrelAna = kFALSE;
1447  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetClusterType() == 1) isRunningEMCALrelAna = kTRUE;
1448 
1449  Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon,isRunningEMCALrelAna);
1450 
1451  if(fIsMC==2){
1452  Float_t xsection = -1.;
1453  Float_t ntrials = -1.;
1454  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetXSectionAndNTrials(fMCEvent,xsection,ntrials);
1455  if((xsection==-1.) || (ntrials==-1.)) AliFatal(Form("ERROR: GetXSectionAndNTrials returned invalid xsection/ntrials, periodName from V0Reader: '%s'",fV0Reader->GetPeriodName().Data()));
1456  fProfileJetJetXSection[iCut]->Fill(0.,xsection);
1457  fHistoJetJetNTrials[iCut]->Fill("#sum{NTrials}",ntrials);
1458  }
1459 
1460  if(fIsMC>0){
1461  fWeightJetJetMC = 1;
1462  // cout << fMCEvent << endl;
1463  Bool_t isMCJet = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsJetJetMCEventAccepted( fMCEvent, fWeightJetJetMC );
1464  if (fIsMC == 3){
1465  Double_t weightMult = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetWeightForMultiplicity(fV0Reader->GetNumberOfPrimaryTracks());
1466  fWeightJetJetMC = fWeightJetJetMC*weightMult;
1467  }
1468  if(fIsMC==1) fWeightJetJetMC = 1;
1469  if (!isMCJet){
1470  fHistoNEvents[iCut]->Fill(10,fWeightJetJetMC);
1471  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(10);
1472  continue;
1473  }
1474  }
1475 
1476  Bool_t triggered = kTRUE;
1477 
1478  if(eventNotAccepted!= 0){
1479  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
1480  fHistoNEvents[iCut]->Fill(eventNotAccepted, fWeightJetJetMC); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
1481  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventNotAccepted);
1482  if (eventNotAccepted==3 && fIsMC > 0){
1483  triggered = kFALSE;
1484  }else {
1485  continue;
1486  }
1487  }
1488 
1489  if(eventQuality != 0){// Event Not Accepted
1490  //cout << "event rejected due to: " <<eventQuality << endl;
1491  fHistoNEvents[iCut]->Fill(eventQuality, fWeightJetJetMC);
1492  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
1493  continue;
1494  }
1495 
1496  if (triggered==kTRUE){
1497  fHistoNEvents[iCut]->Fill(eventQuality, fWeightJetJetMC); // Should be 0 here
1498  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventQuality); // Should be 0 here
1499 
1501  fHistoVertexZ[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetZ(), fWeightJetJetMC);
1502  fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)),fWeightJetJetMC);
1503  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2) fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A(), fWeightJetJetMC);
1504  else fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C(), fWeightJetJetMC);
1505  }
1506 
1507  if(fIsMC>0){
1508  // Process MC Particle
1509  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
1510  if(fInputEvent->IsA()==AliESDEvent::Class()){
1511  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1512  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1513  fMCEvent);
1514  }
1515  else if(fInputEvent->IsA()==AliAODEvent::Class()){
1516  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1517  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1518  fInputEvent);
1519  }
1520  }
1521  }
1522  if(fIsMC>0){
1523  if(fInputEvent->IsA()==AliESDEvent::Class())
1525  if(fInputEvent->IsA()==AliAODEvent::Class())
1527  }
1528 
1529  if (triggered==kFALSE) continue;
1530 
1531  // it is in the loop to have the same conversion cut string (used also for MC stuff that should be same for V0 and Cluster)
1532  if(fReconMethod!=5) ProcessClusters();// process calo clusters
1533  if(fReconMethod!=2) ProcessPhotonCandidates(); // Process this cuts gammas
1534 
1535  fHistoNGammaCandidates[iCut]->Fill(fGammaCandidates->GetEntries(),fWeightJetJetMC);
1536  fHistoNClusterCandidates[iCut]->Fill(fClusterCandidates->GetEntries(),fWeightJetJetMC);
1538  if(fClusterCandidates->GetEntries()>1 && fGammaCandidates->GetEntries()>0){
1539  fHistoNEventsMinGamma[iCut]->Fill(0.,fWeightJetJetMC);
1540  }
1541  if(fClusterCandidates->GetEntries()>0 && fGammaCandidates->GetEntries()>1){
1542  fHistoNEventsMinGamma[iCut]->Fill(1,fWeightJetJetMC);
1543  }
1544  if(fClusterCandidates->GetEntries()>2){
1545  fHistoNEventsMinGamma[iCut]->Fill(2,fWeightJetJetMC);
1546  }
1547  if(fGammaCandidates->GetEntries()>2){
1548  fHistoNEventsMinGamma[iCut]->Fill(3,fWeightJetJetMC);
1549  }
1550 
1551  // Meson Analysis
1552  if(((AliConversionMesonCuts*)fNeutralPionCutArray->At(iCut))->UseMCPSmearing() && fIsMC>0){
1553  fUnsmearedPx = new Double_t[fGammaCandidates->GetEntries()]; // Store unsmeared Momenta
1554  fUnsmearedPy = new Double_t[fGammaCandidates->GetEntries()];
1555  fUnsmearedPz = new Double_t[fGammaCandidates->GetEntries()];
1556  fUnsmearedE = new Double_t[fGammaCandidates->GetEntries()];
1557 
1558  for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
1559  fUnsmearedPx[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Px();
1560  fUnsmearedPy[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Py();
1561  fUnsmearedPz[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Pz();
1562  fUnsmearedE[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->E();
1563  ((AliConversionMesonCuts*)fNeutralPionCutArray->At(iCut))->SmearParticle(dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(gamma)));
1564  }
1565  }
1566 
1567  CalculateOmegaCandidates(); // Combine Gammas from conversion and from calo
1568  CalculateBackground(); // Combinatorial Background
1569  UpdateEventByEventData(); // Store Event for mixed Events
1570 
1571  if(((AliConversionMesonCuts*)fNeutralPionCutArray->At(iCut))->UseMCPSmearing() && fIsMC>0){
1572  for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
1573  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPx(fUnsmearedPx[gamma]); // Reset Unsmeared Momenta
1574  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPy(fUnsmearedPy[gamma]);
1575  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPz(fUnsmearedPz[gamma]);
1576  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetE(fUnsmearedE[gamma]);
1577  }
1578  delete[] fUnsmearedPx; fUnsmearedPx = 0x0;
1579  delete[] fUnsmearedPy; fUnsmearedPy = 0x0;
1580  delete[] fUnsmearedPz; fUnsmearedPz = 0x0;
1581  delete[] fUnsmearedE;fUnsmearedE = 0x0;
1582  }
1583 
1584  if(fIsMC>0){
1585  fVectorRecTruePi0s.clear();
1588  }
1589 
1590  fGammaCandidates->Clear(); // delete this cuts good gammas
1591  fClusterCandidates->Clear(); // delete cluster candidates
1592  fPi0Candidates->Clear(); // delete pi0 candidates
1593  }
1594 
1595  if(fIsMC>0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled())){
1596  RelabelAODPhotonCandidates(kFALSE); // Back to ESDMC Label
1597  fV0Reader->RelabelAODs(kFALSE);
1598  }
1599 
1600  PostData(1, fOutputContainer);
1601 }
1602 
1603 //________________________________________________________________________
1605 
1606  Int_t nclus = 0;
1607  nclus = fInputEvent->GetNumberOfCaloClusters();
1608 
1609 // cout << nclus << endl;
1610 
1611  if(nclus == 0) return;
1612 
1613  // plotting histograms on cell/tower level, only if extendedMatchAndQA > 1
1614  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->FillHistogramsExtendedQA(fInputEvent,fIsMC);
1615 
1616  if(fReconMethod==2){
1617  // match tracks to clusters
1618  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchTracksToClusters(fInputEvent,fWeightJetJetMC);
1619  }
1620 
1621  // vertex
1622  Double_t vertex[3] = {0,0,0};
1623  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1624 
1625  // Loop over EMCal clusters
1626  for(Int_t i = 0; i < nclus; i++){
1627  AliVCluster* clus = NULL;
1628  if(fInputEvent->IsA()==AliESDEvent::Class()) clus = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(i));
1629  else if(fInputEvent->IsA()==AliAODEvent::Class()) clus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i));
1630 
1631  if (!clus) continue;
1632  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC,fWeightJetJetMC,i)){ delete clus; continue;}
1633 
1634  // TLorentzvector with cluster
1635  TLorentzVector clusterVector;
1636  clus->GetMomentum(clusterVector,vertex);
1637 
1638  TLorentzVector* tmpvec = new TLorentzVector();
1639  tmpvec->SetPxPyPzE(clusterVector.Px(),clusterVector.Py(),clusterVector.Pz(),clusterVector.E());
1640 
1641  // convert to AODConversionPhoton
1642  AliAODConversionPhoton *PhotonCandidate = new AliAODConversionPhoton(tmpvec);
1643  if(!PhotonCandidate){ delete clus; delete tmpvec; continue;}
1644 
1645  // Flag Photon as CaloPhoton
1646  PhotonCandidate->SetIsCaloPhoton();
1647  PhotonCandidate->SetCaloClusterRef((Long_t)i);
1648  // get MC label
1649  if(fIsMC>0){
1650  Int_t* mclabelsCluster = clus->GetLabels();
1651  PhotonCandidate->SetNCaloPhotonMCLabels(clus->GetNLabels());
1652 // cout << clus->GetNLabels() << endl;
1653  if (clus->GetNLabels()>0){
1654  for (Int_t k =0; k<(Int_t)clus->GetNLabels(); k++){
1655  if (k<50)PhotonCandidate->SetCaloPhotonMCLabel(k,mclabelsCluster[k]);
1656 // Int_t pdgCode = fMCStack->Particle(mclabelsCluster[k])->GetPdgCode();
1657 // cout << "label " << k << "\t" << mclabelsCluster[k] << " pdg code: " << pdgCode << endl;
1658  }
1659  }
1660  }
1661 
1662  fIsFromMBHeader = kTRUE;
1664  //TString periodName = fV0Reader->GetPeriodName();
1665  // test whether largest contribution to cluster orginates in added signals
1666  if (fIsMC>0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() > 0){
1667  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetCaloPhotonMCLabel(0), fMCStack, fInputEvent) == 0){
1668  fIsFromMBHeader = kFALSE;
1669  }
1670  if (clus->GetNLabels()>1){
1671  Int_t* mclabelsCluster = clus->GetLabels();
1672  for (Int_t l = 1; l < (Int_t)clus->GetNLabels(); l++ ){
1673  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(mclabelsCluster[l], fMCStack, fInputEvent) == 0){
1675  }
1676  }
1677  }
1678  }
1679 
1681  fHistoClusOverlapHeadersGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
1682 
1684  if(fIsMC>0){
1685  if(fInputEvent->IsA()==AliESDEvent::Class()){
1686  ProcessTrueClusterCandidates(PhotonCandidate);
1687  }else {
1688  ProcessTrueClusterCandidatesAOD(PhotonCandidate);
1689  }
1690  }
1691  fHistoClusGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
1692  fClusterCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
1693  }else{
1694  delete PhotonCandidate;
1695  }
1696 
1697  delete clus;
1698  delete tmpvec;
1699  }
1700 }
1701 
1702 //________________________________________________________________________
1704 {
1705 
1706  TParticle *Photon = NULL;
1707  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
1708  if (TruePhotonCandidate->GetCaloPhotonMCLabel(0) < 0) return;
1709 
1710  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0) Photon = fMCStack->Particle(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
1711  else return;
1712 
1713  if(Photon == NULL){
1714  // cout << "no photon" << endl;
1715  return;
1716  }
1717 
1718  TruePhotonCandidate->SetCaloPhotonMCFlags(fMCStack, fEnableSortForClusMC);
1719 
1720  return;
1721 }
1722 
1723 //________________________________________________________________________
1725 {
1726  AliAODMCParticle *Photon = NULL;
1727  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
1728  if (AODMCTrackArray){
1729  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
1730  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0) Photon = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
1731  else return;
1732  }else {
1733  AliInfo("AODMCTrackArray could not be loaded");
1734  return;
1735  }
1736 
1737  if(Photon == NULL){
1738  // cout << "no photon" << endl;
1739  return;
1740  }
1741 
1743 
1744  return;
1745 }
1746 
1747 //________________________________________________________________________
1749 {
1750  Int_t nV0 = 0;
1751  TList *GammaCandidatesStepOne = new TList();
1752  TList *GammaCandidatesStepTwo = new TList();
1753  // Loop over Photon Candidates allocated by ReaderV1
1754  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
1755  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
1756  if(!PhotonCandidate) continue;
1757  fIsFromMBHeader = kTRUE;
1758  if(fIsMC>0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
1759  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack, fInputEvent);
1760  if(isPosFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
1761  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack, fInputEvent);
1762  if(isNegFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
1763  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
1764  }
1765 
1766  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fInputEvent)) continue;
1767  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(PhotonCandidate->GetPhotonPhi(),fEventPlaneAngle)) continue;
1768  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
1769  !((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
1770  fGammaCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
1771 
1772  if(fIsFromMBHeader){
1773  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
1774  if (fDoPhotonQA > 0){
1775  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
1776  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1777  }
1778  }
1779  if(fIsMC>0){
1780  if(fInputEvent->IsA()==AliESDEvent::Class())
1781  ProcessTruePhotonCandidates(PhotonCandidate);
1782  if(fInputEvent->IsA()==AliAODEvent::Class())
1783  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
1784  }
1785 
1786  }else if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
1787  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
1788  nV0++;
1789  GammaCandidatesStepOne->Add(PhotonCandidate);
1790  }else if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
1791  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
1792  GammaCandidatesStepTwo->Add(PhotonCandidate);
1793  }
1794  }
1795  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){
1796  for(Int_t i = 0;i<GammaCandidatesStepOne->GetEntries();i++){
1797  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GammaCandidatesStepOne->At(i);
1798  if(!PhotonCandidate) continue;
1799  fIsFromMBHeader = kTRUE;
1800  if(fMCStack && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
1801  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack, fInputEvent);
1802  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack, fInputEvent);
1803  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
1804  }
1805  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GammaCandidatesStepOne->GetEntries())) continue;
1806  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
1807  fGammaCandidates->Add(PhotonCandidate);
1808  if(fIsFromMBHeader){
1809  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
1810  if (fDoPhotonQA > 0){
1811  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
1812  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1813  }
1814  }
1815  if(fIsMC>0){
1816  if(fInputEvent->IsA()==AliESDEvent::Class())
1817  ProcessTruePhotonCandidates(PhotonCandidate);
1818  if(fInputEvent->IsA()==AliAODEvent::Class())
1819  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
1820  }
1821  } else GammaCandidatesStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
1822  }
1823  }
1824  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
1825  for(Int_t i = 0;i<GammaCandidatesStepTwo->GetEntries();i++){
1826  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GammaCandidatesStepTwo->At(i);
1827  if(!PhotonCandidate) continue;
1828  fIsFromMBHeader = kTRUE;
1829  if(fMCStack && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
1830  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack, fInputEvent);
1831  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack, fInputEvent);
1832  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
1833  }
1834  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GammaCandidatesStepTwo,i)) continue;
1835  fGammaCandidates->Add(PhotonCandidate); // Add gamma to current cut TList
1836  if(fIsFromMBHeader){
1837  fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
1838  if (fDoPhotonQA > 0){
1839  fHistoConvGammaR[fiCut]->Fill(PhotonCandidate->GetConversionRadius());
1840  fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
1841  }
1842  }
1843  if(fIsMC>0){
1844  if(fInputEvent->IsA()==AliESDEvent::Class())
1845  ProcessTruePhotonCandidates(PhotonCandidate);
1846  if(fInputEvent->IsA()==AliAODEvent::Class())
1847  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
1848  }
1849  }
1850  }
1851 
1852  delete GammaCandidatesStepOne;
1853  GammaCandidatesStepOne = 0x0;
1854  delete GammaCandidatesStepTwo;
1855  GammaCandidatesStepTwo = 0x0;
1856 
1857 }
1858 
1859 //________________________________________________________________________
1861 {
1862  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
1863  if (AODMCTrackArray == NULL) return;
1864  AliAODMCParticle *posDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelPositive());
1865  AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelNegative());
1866 
1867  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
1868  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
1869 
1870  if(posDaughter->GetMother() != negDaughter->GetMother()) return;
1871 
1872  else if(posDaughter->GetMother() == -1) return;
1873 
1874  if(pdgCode[0]!=11 || pdgCode[1]!=11) return; //One Particle is not a electron
1875 
1876  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
1877 
1878  AliAODMCParticle *Photon = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
1879  if(Photon->GetPdgCode() != 22) return; // Mother is no Photon
1880 
1881  if(((posDaughter->GetMCProcessCode())) != 5 || ((negDaughter->GetMCProcessCode())) != 5) return; // check if the daughters come from a conversion
1882 
1883  TruePhotonCandidate->SetIsTrueConvertedPhoton();
1884 }
1885 
1886 //________________________________________________________________________
1888 {
1889  // Process True Photons
1890  TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCStack);
1891  TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCStack);
1892 
1893  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
1894  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
1895  if(posDaughter->GetMother(0) != negDaughter->GetMother(0)) return;
1896  else if(posDaughter->GetMother(0) == -1) return;
1897 
1898  if(pdgCode[0]!=11 || pdgCode[1]!=11) return; //One Particle is not a electron
1899 
1900  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
1901 
1902  TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCStack);
1903 
1904  if(Photon->GetPdgCode() != 22){
1905  return; // Mother is no Photon
1906  }
1907 
1908  if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
1909 
1910  // True Photon
1911  TruePhotonCandidate->SetIsTrueConvertedPhoton();
1912  return;
1913 }
1914 //________________________________________________________________________
1916 {
1917  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
1918  Double_t mcProdVtxX = primVtxMC->GetX();
1919  Double_t mcProdVtxY = primVtxMC->GetY();
1920  Double_t mcProdVtxZ = primVtxMC->GetZ();
1921 
1922  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
1923  if (AODMCTrackArray == NULL) return;
1924 
1925  // Loop over all primary MC particle
1926  for(Long_t i = 0; i < AODMCTrackArray->GetEntriesFast(); i++) {
1927 
1928  AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
1929  if (!particle) continue;
1930 
1931  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, particle, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
1932  if (!isPrimary) continue;
1933 
1934  Int_t isMCFromMBHeader = -1;
1935  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
1936  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent);
1937  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
1938  }
1939 
1940  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
1941  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kFALSE)){
1942  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // All MC Gamma
1943  if (TMath::Abs(particle->Eta()) < 0.66 ){
1944  if (particle->Phi() > 1.39626 && particle->Phi() < 3.125) fHistoMCAllGammaEMCALAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
1945  }
1946  }
1947  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(particle,AODMCTrackArray,kTRUE)){
1948  Double_t rConv = 0;
1949  for(Int_t daughterIndex=particle->GetDaughter(0);daughterIndex<=particle->GetDaughter(1);daughterIndex++){
1950  AliAODMCParticle *tmpDaughter = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(daughterIndex));
1951  if(!tmpDaughter) continue;
1952  if(TMath::Abs(tmpDaughter->GetPdgCode()) == 11){
1953  rConv = sqrt( (tmpDaughter->Xv()*tmpDaughter->Xv()) + (tmpDaughter->Yv()*tmpDaughter->Yv()) );
1954  }
1955  }
1956  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
1957  if (fDoPhotonQA > 0){
1958  fHistoMCConvGammaR[fiCut]->Fill(rConv);
1959  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta());
1960  }
1961  }
1962  // Converted MC Gamma
1964  ->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
1965  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
1966  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
1967  Float_t weighted= 1;
1968  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
1969  if (particle->Pt()>0.005){
1970  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, 0x0, fInputEvent);
1971  // if(particle->GetPdgCode() == 221){
1972  // cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
1973  // }
1974  }
1975  }
1976  Double_t mesonY = 10.;
1977  if(particle->E() - particle->Pz() == 0 || particle->E() + particle->Pz() == 0){
1978  mesonY=10.-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
1979  }else{
1980  mesonY = 0.5*(TMath::Log((particle->E()+particle->Pz()) / (particle->E()-particle->Pz())))-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
1981  }
1982 
1983  Double_t alpha = -10;
1984  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
1985  alpha = (daughter0->E() - daughter1->E())/(daughter0->E() + daughter1->E());
1986  }
1987 
1988 
1989  if(particle->GetPdgCode() == 111){
1990  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Pi0
1991  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
1992  if (fIsMC > 1) fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
1993  if (fDoMesonQA > 0){
1994  fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted*fWeightJetJetMC);
1995  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC);
1996  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
1997  }
1998  }
1999 
2000  // Check the acceptance for both gammas
2001  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
2002  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
2003  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2004  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2005  // check acceptance of clusters as well, true if one of them points into the Calo acceptance
2006  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter0,AODMCTrackArray) ||
2007  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter1,AODMCTrackArray) ){
2008  if(particle->GetPdgCode() == 111){
2009  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc
2010  fHistoMCPi0WOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Pi0 with gamma in acc wo weight
2011  }
2012  }
2013  }
2014  }
2015  }
2016 }
2017 
2018 //________________________________________________________________________
2020 {
2021  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2022  Double_t mcProdVtxX = primVtxMC->GetX();
2023  Double_t mcProdVtxY = primVtxMC->GetY();
2024  Double_t mcProdVtxZ = primVtxMC->GetZ();
2025 // cout << mcProdVtxX <<"\t" << mcProdVtxY << "\t" << mcProdVtxZ << endl;
2026 
2027  // Loop over all primary MC particles
2028  for(Int_t i = 0; i < fMCStack->GetNtrack(); i++) {
2029  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCStack, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
2030  // fill primary histograms
2031  TParticle* particle = (TParticle *)fMCStack->Particle(i);
2032  if (!particle) continue;
2033 
2034  // fill histograms for all true omegas
2035  if(particle->GetPdgCode() == 223){
2036 
2037  Bool_t DecaysToPiPlPiMiPiZero = kFALSE;
2038 
2039  TParticle *posPion = 0x0;
2040  TParticle *negPion = 0x0;
2041  TParticle *neutPion = 0x0;
2042 
2043  for(Int_t index= particle->GetFirstDaughter();index <= particle->GetLastDaughter();index++){
2044  if(index < 0) continue;
2045 
2046  TParticle *temp = (TParticle*)fMCStack->Particle(index);
2047 
2048  switch(temp->GetPdgCode()) {
2049  case 211:
2050  posPion = temp;
2051  break;
2052  case -211:
2053  negPion = temp;
2054  break;
2055  case 111:
2056  neutPion = temp;
2057  break;
2058  }
2059  }
2060 
2061  if(posPion && negPion && neutPion) DecaysToPiPlPiMiPiZero = kTRUE;
2062 
2063  if(DecaysToPiPlPiMiPiZero){
2065  } else if (particle->GetNDaughters()==2){
2066  TParticle *gamma2 = 0x0;
2067  TParticle *pi0 = 0x0;
2068 
2069  for(Int_t index = particle->GetFirstDaughter();index <= particle->GetLastDaughter();index++){
2070  if(index < 0) continue;
2071 
2072  TParticle *temp = (TParticle*)fMCStack->Particle(index);
2073  switch(temp->GetPdgCode()){
2074  case 22:
2075  gamma2 = temp;
2076  break;
2077  case 111:
2078  pi0 = temp;
2079  break;
2080  }
2081  }
2082 
2083  if(gamma2 && pi0){
2085  fHistoMCAllOmegaInvMassPt[fiCut]->Fill(TMath::Sqrt((particle->Energy())*(particle->Energy())-(particle->P())*(particle->P())),particle->Pt(),fWeightJetJetMC);
2086  fHistoMCGammaFromAllOmegaPt[fiCut]->Fill(gamma2->Pt(),fWeightJetJetMC);
2087  fHistoMCPi0FromAllOmegaInvMassPt[fiCut]->Fill(TMath::Sqrt((pi0->Energy())*(pi0->Energy())-(pi0->P())*(pi0->P())),pi0->Pt(),fWeightJetJetMC);
2088  if(fDoMesonQA>0){
2089 
2090  fHistoMCPi0FromAllOmegaEtaPhi[fiCut]->Fill(pi0->Phi(),pi0->Eta(),fWeightJetJetMC);
2091  fHistoMCAllOmegaPtPi0Pt[fiCut]->Fill(particle->Pt(),pi0->Pt(),fWeightJetJetMC);
2092  fHistoMCAllOmegaPtGammaPt[fiCut]->Fill(particle->Pt(),gamma2->Pt(),fWeightJetJetMC);
2093 
2094  Double_t alpha = (pi0->Energy() - gamma2->Energy())/(pi0->Energy() + gamma2->Energy());
2095  fHistoMCAllOmegaAlphaPt[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC);
2096 
2097  Double_t Pi0Y = 10.;
2098  if(pi0->Energy() - pi0->Pz() == 0 || pi0->Energy() + pi0->Pz() == 0){
2099  Pi0Y=10.-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2100  }else{
2101  Pi0Y = 0.5*(TMath::Log((pi0->Energy()+pi0->Pz()) / (pi0->Energy()-pi0->Pz())))-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2102  }
2103  fHistoMCPi0FromAllOmegaYPt[fiCut]->Fill(pi0->Pt(),Pi0Y,fWeightJetJetMC);
2104 
2105  Double_t OmegaY = 10.;
2106  if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
2107  OmegaY=10.-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2108  }else{
2109  OmegaY = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())))-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2110  }
2111  fHistoMCAllOmegaYPt[fiCut]->Fill(particle->Pt(),OmegaY,fWeightJetJetMC);
2112 
2113  fHistoMCAllOmegaEtaPhi[fiCut]->Fill(particle->Phi(),particle->Eta(),fWeightJetJetMC);
2114 
2115  //get angles and plot
2116  TVector3 omegavector = TVector3(particle->Px(),particle->Py(),particle->Pz());
2117  TVector3 pi0vector = TVector3(pi0->Px(),pi0->Py(),pi0->Pz());
2118  TVector3 gamma2vector = TVector3(gamma2->Px(),gamma2->Py(),gamma2->Pz());
2119  fHistoMCAllOmegaPiZeroAnglePt[fiCut]->Fill(particle->Pt(),TMath::Pi() - pi0vector.Angle(omegavector),fWeightJetJetMC);
2120  fHistoMCAllPiZeroGammaAnglePt[fiCut]->Fill(particle->Pt(),pi0vector.Angle(gamma2vector),fWeightJetJetMC);
2121  fHistoMCAllOmegaGammaAnglePt[fiCut]->Fill(particle->Pt(),TMath::Pi() - omegavector.Angle(gamma2vector),fWeightJetJetMC);
2122 
2123  //check whether pi0 decayed into two gammas
2124  if (pi0->GetNDaughters()==2 && pi0->GetFirstDaughter()>-1 && pi0->GetLastDaughter()>-1){
2125  TParticle *gamma0 = (TParticle*)fMCStack->Particle(pi0->GetFirstDaughter());
2126  TParticle *gamma1 = (TParticle*)fMCStack->Particle(pi0->GetLastDaughter());
2127  if (gamma0->GetPdgCode()==22 && gamma1->GetPdgCode()==22){
2128 
2129  //plot pi0 alpha
2130  Double_t pi0alpha = (gamma0->Energy() - gamma1->Energy())/(gamma0->Energy() + gamma1->Energy());
2131  fHistoMCPi0FromAllOmegaAlphaPt[fiCut]->Fill(pi0->Pt(),pi0alpha,fWeightJetJetMC);
2132  }
2133  }
2134  }
2135  } else{
2137  }
2138  } else{
2140  }
2141  }
2142 
2143  //fill histograms for omegas in acceptance
2144  Int_t labelNeutPion = -1;
2145  Int_t labelGamma = -1;
2146 
2148  ->MesonIsSelectedMCPiZeroGamma(particle,fMCStack,labelNeutPion,labelGamma,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2149  if (labelNeutPion > -1 && labelGamma > -1){
2150  TParticle *neutPion = fMCStack->Particle(labelNeutPion);
2151 
2152  //fill histograms for acceptance correction
2153  fHistoMCOmegaInvMassPt[fiCut]->Fill(TMath::Sqrt((particle->Energy())*(particle->Energy())-(particle->P())*(particle->P())),particle->Pt(),fWeightJetJetMC);
2154 
2155  if (neutPion->GetNDaughters()==2 && neutPion->GetFirstDaughter()>-1 && neutPion->GetLastDaughter()>-1){
2156 
2157  TParticle *gamma0 = (TParticle*)fMCStack->Particle(neutPion->GetFirstDaughter());
2158  TParticle *gamma1 = (TParticle*)fMCStack->Particle(neutPion->GetLastDaughter());
2159  TParticle *gamma2 = (TParticle*)fMCStack->Particle(labelGamma);
2160 
2161  Bool_t InAcceptance = kFALSE;
2162 
2163  if (fReconMethod%2==1){ //cases 1,3,5 where reconstruction requires gamma2 to be a pcm photon
2164  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(gamma2,fMCStack,kFALSE)){ //check that gamma2 is in acceptance
2165  if(fReconMethod==5){
2166  //check that both gamma0 and gamma1 are in acceptance
2167  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(gamma0,fMCStack,kFALSE) &&
2168  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(gamma1,fMCStack,kFALSE)){
2169  InAcceptance = kTRUE;
2170  }
2171  } else if(fReconMethod==3){
2172  if(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma0,fMCStack) &&
2173  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma1,fMCStack)){
2174  InAcceptance = kTRUE;
2175  }
2176  } else if(fReconMethod==1){ // both gammas must be in tpc acceptance
2177  if((((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(gamma0,fMCStack,kFALSE) &&
2178  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(gamma1,fMCStack,kFALSE)) &&
2179  // check acceptance of clusters as well, true if one of them points into the Calo acceptance
2180  (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma0,fMCStack) ||
2181  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma1,fMCStack))){
2182  InAcceptance = kTRUE;
2183  }
2184  }
2185  }
2186  } else{ //cases 0,2,4 where reconstruction requires gamma2 to be a calo photon
2187  if(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma2,fMCStack)){
2188  if(fReconMethod==4){
2189  //check that both gamma0 and gamma1 are in acceptance
2190  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(gamma0,fMCStack,kFALSE) &&
2191  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(gamma1,fMCStack,kFALSE)){
2192  InAcceptance = kTRUE;
2193  }
2194  } else if(fReconMethod==2){
2195  if(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma0,fMCStack) &&
2196  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma1,fMCStack)){
2197  InAcceptance = kTRUE;
2198  }
2199  } else if(fReconMethod==0){ //either gamma0 is in tpc acc & gamma1 is in emcal acc or vice versa
2200  if((((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(gamma0,fMCStack,kFALSE) &&
2201  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(gamma1,fMCStack,kFALSE)) &&
2202  // check acceptance of clusters as well, true if one of them points into the Calo acceptance
2203  (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma0,fMCStack) ||
2204  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma1,fMCStack))){
2205  InAcceptance = kTRUE;
2206  }
2207  }
2208  }
2209  }
2210  if(InAcceptance){
2211  // fill in acceptance histograms
2212  fHistoMCOmegaInAccInvMassPt[fiCut]->Fill(TMath::Sqrt((particle->Energy())*(particle->Energy())-(particle->P())*(particle->P())),particle->Pt(),fWeightJetJetMC);
2213  fHistoMCPi0FromOmegaInAccInvMassPt[fiCut]->Fill(TMath::Sqrt((neutPion->Energy())*(neutPion->Energy())-(neutPion->P())*(neutPion->P())),neutPion->Pt(),fWeightJetJetMC);
2215 
2216  if(fDoMesonQA>0){
2217 
2218  TVector3 omegavector = TVector3(particle->Px(),particle->Py(),particle->Pz());
2219  TVector3 pi0vector = TVector3(neutPion->Px(),neutPion->Py(),neutPion->Pz());
2220  TVector3 gamma2vector = TVector3(gamma2->Px(),gamma2->Py(),gamma2->Pz());
2221 
2222  Double_t OmegaPiZeroAngle = TMath::Pi() - pi0vector.Angle(omegavector);
2223  Double_t PiZeroGammaAngle = pi0vector.Angle(gamma2vector);
2224  Double_t OmegaGammaAngle = TMath::Pi() - omegavector.Angle(gamma2vector);
2225 
2226  Double_t OmegaY = 10.;
2227  if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
2228  OmegaY=10.-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2229  }else{
2230  OmegaY = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())))-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2231  }
2232  Double_t Pi0Y = 10.;
2233  if(neutPion->Energy() - neutPion->Pz() == 0 || neutPion->Energy() + neutPion->Pz() == 0){
2234  Pi0Y=10.-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2235  }else{
2236  Pi0Y = 0.5*(TMath::Log((neutPion->Energy()+neutPion->Pz()) / (neutPion->Energy()-neutPion->Pz())))-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2237  }
2238 
2239  Double_t OmegaAlpha = (neutPion->Energy() - gamma2->Energy())/(neutPion->Energy() + gamma2->Energy());
2240  Double_t Pi0Alpha = (gamma0->Energy() - gamma1->Energy())/(gamma0->Energy() + gamma1->Energy());
2241 
2242  fHistoMCOmegaInAccEtaPhi[fiCut]->Fill(particle->Phi(),particle->Eta(),fWeightJetJetMC);
2243  fHistoMCOmegaInAccYPt[fiCut]->Fill(particle->Pt(),OmegaY,fWeightJetJetMC);
2244  fHistoMCOmegaInAccAlphaPt[fiCut]->Fill(particle->Pt(),OmegaAlpha,fWeightJetJetMC);
2245  fHistoMCInAccOmegaPiZeroAnglePt[fiCut]->Fill(particle->Pt(),OmegaPiZeroAngle,fWeightJetJetMC);
2246  fHistoMCInAccPiZeroGammaAnglePt[fiCut]->Fill(particle->Pt(),PiZeroGammaAngle,fWeightJetJetMC);
2247  fHistoMCInAccOmegaGammaAnglePt[fiCut]->Fill(particle->Pt(),OmegaGammaAngle,fWeightJetJetMC);
2248  fHistoMCPi0FromOmegaInAccAlphaPt[fiCut]->Fill(neutPion->Pt(),Pi0Alpha,fWeightJetJetMC);
2249  fHistoMCPi0FromOmegaInAccYPt[fiCut]->Fill(neutPion->Pt(),Pi0Y,fWeightJetJetMC);
2250  fHistoMCPi0FromOmegaInAccEtaPhi[fiCut]->Fill(particle->Phi(),particle->Eta(),fWeightJetJetMC);
2251  fHistoMCInAccOmegaPtPi0Pt[fiCut]->Fill(particle->Pt(),neutPion->Pt(),fWeightJetJetMC);
2252  fHistoMCInAccOmegaPtGammaPt[fiCut]->Fill(particle->Pt(),gamma2->Pt(),fWeightJetJetMC);
2253  }
2254  }
2255  }
2256  }
2257  }
2258 
2259 
2260  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCStack,kFALSE)){
2261  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // All MC Gamma
2262  if (TMath::Abs(particle->Eta()) < 0.66 ){
2263  if (particle->Phi() > 1.39626 && particle->Phi() < 3.125) fHistoMCAllGammaEMCALAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2264  }
2265  }
2266  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCStack,kTRUE)){
2267  fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2268  if (fDoPhotonQA > 0 && particle->GetFirstDaughter()>-1){
2269  fHistoMCConvGammaR[fiCut]->Fill(((TParticle*)fMCStack->Particle(particle->GetFirstDaughter()))->R());
2270  fHistoMCConvGammaEta[fiCut]->Fill(particle->Eta());
2271  }
2272  }// Converted MC Gamma
2274  ->MesonIsSelectedMC(particle,fMCStack,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2275  if(particle->GetFirstDaughter()>-1 && particle->GetLastDaughter()>-1){
2276  TParticle* daughter0 = (TParticle*)fMCStack->Particle(particle->GetFirstDaughter());
2277  TParticle* daughter1 = (TParticle*)fMCStack->Particle(particle->GetLastDaughter());
2278 
2279  Float_t weighted= 1;
2280  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
2281  if (particle->Pt()>0.005){
2282  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCStack, fInputEvent);
2283  // if(particle->GetPdgCode() == 221){
2284  // cout << "MC input \t"<<i << "\t" << particle->Pt()<<"\t"<<weighted << endl;
2285  // }
2286  }
2287  }
2288  Double_t mesonY = 10.;
2289  if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
2290  mesonY=10.-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2291  }else{
2292  mesonY = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())))-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2293  }
2294 
2295  Double_t alpha = -10;
2296  if (particle->GetPdgCode() == 111 || particle->GetPdgCode() == 221){
2297  alpha = (daughter0->Energy() - daughter1->Energy())/(daughter0->Energy() + daughter1->Energy());
2298  }
2299 
2300  if(particle->GetPdgCode() == 111){
2301  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Pi0
2302  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2303  if (fIsMC > 1) fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
2304  if (fDoMesonQA > 0){
2305  fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted*fWeightJetJetMC); // All MC Pi0
2306  fHistoMCPi0PtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Pi0
2307  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2308  }
2309  }
2310  // Check the acceptance for both gammas & whether they are counted as primaries as well
2311  Bool_t kDaughter0IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCStack, particle->GetFirstDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2312  Bool_t kDaughter1IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCStack, particle->GetLastDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2313  Bool_t InAcceptance = kFALSE;
2314 
2315  if(fReconMethod/2 == 0){
2316  if( kDaughter0IsPrim && kDaughter1IsPrim &&
2317  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter0,fMCStack,kFALSE) &&
2318  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter1,fMCStack,kFALSE)){
2319  // check acceptance of clusters as well, true if one of them points into the Calo acceptance
2320  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter0,fMCStack) ||
2321  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter1,fMCStack)){
2322  InAcceptance = kTRUE;
2323  }
2324  }
2325  } else if(fReconMethod/2 == 1){
2326  if(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter0,fMCStack) &&
2327  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter1,fMCStack)){
2328  InAcceptance = kTRUE;
2329  }
2330  } else if(fReconMethod/2 == 2){
2331  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter0,fMCStack,kFALSE) &&
2332  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter1,fMCStack,kFALSE)){
2333  InAcceptance = kTRUE;
2334  }
2335  }
2336  if(InAcceptance){
2337  // fill in acceptance histograms
2338  if(particle->GetPdgCode() == 111){
2339  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Pi0 with gamma in acc
2340  fHistoMCPi0WOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Pi0 with gamma in acc wo weighting
2341  }
2342  }
2343  }
2344  }
2345  }
2346  }
2347 }
2348 
2349 //________________________________________________________________________
2351 {
2352  switch(fReconMethod){
2353  //PCM-cal,cal
2354  case 0:
2355  if(fClusterCandidates->GetEntries()>1 && fGammaCandidates->GetEntries()>0){
2356  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
2357  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
2358  if (gamma0==NULL) continue;
2359 
2360  for(Int_t secondGammaIndex=0;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
2361  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
2362  if (gamma1==NULL || !(gamma1->GetIsCaloPhoton())) continue;
2363  Bool_t matched = kFALSE;
2364  AliVCluster* cluster = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
2365  matched = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma0,cluster,fInputEvent,fWeightJetJetMC);
2366 
2367  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0,gamma1);
2368 
2369  if((((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))
2370  && pi0cand->Pt() > fMinPi0Pt){
2371  if (matched){
2372  fHistoPhotonPairMatchedInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(),fWeightJetJetMC);
2373  } else{
2374  fHistoPhotonPairInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(),fWeightJetJetMC);
2375  if (pi0cand->M() > ((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->GetSelectionLow() &&
2376  pi0cand->M() < ((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->GetSelectionHigh()){
2377  //change energy of pi0 candidate s.t. its mass is the pdg mass
2378  pi0cand->SetPxPyPzE(pi0cand->Px(),pi0cand->Py(),pi0cand->Pz(),TMath::Sqrt(0.1349766*0.1349766+pi0cand->P()*pi0cand->P()));
2379  fPi0Candidates->Add(pi0cand);
2380  if(fDoMesonQA>0){
2381  fHistoPhotonPairYPt[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2382  fHistoPhotonPairAlphaPt[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetAlpha(),fWeightJetJetMC);
2383  fHistoPhotonPairOpenAnglePt[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle(),fWeightJetJetMC);
2384  fHistoPhotonPairEtaPhi[fiCut]->Fill(pi0cand->Phi(),pi0cand->Eta(),fWeightJetJetMC);
2385  }
2386  // get third photon from clusters and calculate inv mass of omega
2387  for(Int_t thirdGammaIndex=0;thirdGammaIndex<fClusterCandidates->GetEntries();thirdGammaIndex++){
2388  if (thirdGammaIndex==secondGammaIndex) continue;
2389  Bool_t matchedgamma2wconvgamma = kFALSE;
2390  AliAODConversionPhoton *gamma2=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(thirdGammaIndex));
2391  if (gamma2==NULL || !(gamma2->GetIsCaloPhoton())) continue;
2392  AliVCluster* cluster2 = fInputEvent->GetCaloCluster(gamma2->GetCaloClusterRef());
2393  matchedgamma2wconvgamma = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma0,cluster2, fInputEvent, fWeightJetJetMC);
2394  AliAODConversionMother *omegacand = new AliAODConversionMother(pi0cand,gamma2);
2395  if (matchedgamma2wconvgamma){
2396  fHistoMotherMatchedInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2397  delete omegacand;
2398  omegacand=0x0;
2399  continue;
2400  }
2401  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedPiZeroGammaAngle(omegacand, pi0cand, gamma2, fDoPiZeroGammaAngleCut, fmaxfit, flowerFactor, fupperFactor)){
2402  fHistoMotherInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2403  if(fIsMC>0){
2404  if(fInputEvent->IsA()==AliESDEvent::Class())
2405  ProcessTrueMesonCandidates(omegacand,gamma0,gamma1,gamma2);
2406  if(fInputEvent->IsA()==AliAODEvent::Class())
2407  ProcessTrueMesonCandidatesAOD(omegacand,gamma0,gamma1,gamma2);
2408  }
2409  if(omegacand->M()>0.7 && omegacand->M()<0.85){
2410  fHistoGammaFromMotherPt[fiCut]->Fill(gamma2->Pt(),fWeightJetJetMC);
2411  if(fDoMesonQA>0){
2413  fHistoMotherYPt[fiCut]->Fill(omegacand->Pt(),omegacand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2414  fHistoMotherAlphaPt[fiCut]->Fill(omegacand->Pt(),omegacand->GetAlpha(),fWeightJetJetMC);
2415  fHistoMotherEtaPhi[fiCut]->Fill(omegacand->Phi(),omegacand->Eta(),fWeightJetJetMC);
2416  fHistoMotherPi0AnglePt[fiCut]->Fill(omegacand->Pt(),TMath::Pi() - omegacand->Angle(pi0cand->Vect()),fWeightJetJetMC);
2417  fHistoMotherGammaAnglePt[fiCut]->Fill(omegacand->Pt(),TMath::Pi() - omegacand->Angle(gamma2->Vect()),fWeightJetJetMC);
2418  fHistoPi0GammaAnglePt[fiCut]->Fill(omegacand->Pt(),pi0cand->Angle(gamma2->Vect()),fWeightJetJetMC);
2419  }
2420  }
2421  } else if(fDoPiZeroGammaAngleCut){
2422  fHistoMotherAngleCutRejectedInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2423  }
2424  delete omegacand;
2425  omegacand=0x0;
2426  }
2427  } else{
2428  delete pi0cand;
2429  pi0cand=0x0;
2430  }
2431  }
2432  }
2433  }
2434  }
2435  }
2436  break;
2437  //PCM-cal,PCM
2438  case 1:
2439  if(fGammaCandidates->GetEntries()>1 && fClusterCandidates->GetEntries()>0){
2440  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
2441  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
2442  if (gamma0==NULL) continue;
2443 
2444  for(Int_t secondGammaIndex=0;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
2445  Bool_t matched = kFALSE;
2446  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
2447  if (gamma1==NULL || !(gamma1->GetIsCaloPhoton())) continue;
2448 
2449  AliVCluster* cluster = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
2450  matched = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma0,cluster, fInputEvent, fWeightJetJetMC);
2451 
2452  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0,gamma1);
2453 
2454  if((((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))
2455  && pi0cand->Pt() > fMinPi0Pt){
2456  if (matched){
2457  fHistoPhotonPairMatchedInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(),fWeightJetJetMC);
2458  } else{
2459  // fill photon pair histograms
2460  fHistoPhotonPairInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(),fWeightJetJetMC);
2461  if (pi0cand->M() > ((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->GetSelectionLow() &&
2462  pi0cand->M() < ((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->GetSelectionHigh()){
2463  //change energy of pi0 candidate s.t. its mass is the pdg mass
2464  pi0cand->SetPxPyPzE(pi0cand->Px(),pi0cand->Py(),pi0cand->Pz(),TMath::Sqrt(0.1349766*0.1349766+pi0cand->P()*pi0cand->P()));
2465  fPi0Candidates->Add(pi0cand);
2466  if(fDoMesonQA>0){
2467  fHistoPhotonPairYPt[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2468  fHistoPhotonPairAlphaPt[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetAlpha(),fWeightJetJetMC);
2469  fHistoPhotonPairOpenAnglePt[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle(),fWeightJetJetMC);
2470  fHistoPhotonPairEtaPhi[fiCut]->Fill(pi0cand->Phi(),pi0cand->Eta(),fWeightJetJetMC);
2471  }
2472  // get third photon from conversion photon candidates and calculate inv mass of omega
2473  for(Int_t thirdGammaIndex=0;thirdGammaIndex<fGammaCandidates->GetEntries();thirdGammaIndex++){
2474  if (thirdGammaIndex==firstGammaIndex) continue;
2475  Bool_t matchedgamma1wconvgamma2 = kFALSE;
2476  AliAODConversionPhoton *gamma2=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(thirdGammaIndex));
2477  if (gamma2==NULL) continue;
2478  matchedgamma1wconvgamma2 = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma2, cluster, fInputEvent, fWeightJetJetMC);
2479  AliAODConversionMother *omegacand = new AliAODConversionMother(pi0cand,gamma2);
2480  if (matchedgamma1wconvgamma2){
2481  fHistoMotherMatchedInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2482  delete omegacand;
2483  omegacand=0x0;
2484  continue;
2485  }
2486  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedPiZeroGammaAngle(omegacand, pi0cand, gamma2, fDoPiZeroGammaAngleCut, fmaxfit, flowerFactor, fupperFactor)){
2487  fHistoMotherInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2488  if(fIsMC>0){
2489  if(fInputEvent->IsA()==AliESDEvent::Class())
2490  ProcessTrueMesonCandidates(omegacand,gamma0,gamma1,gamma2);
2491  if(fInputEvent->IsA()==AliAODEvent::Class())
2492  ProcessTrueMesonCandidatesAOD(omegacand,gamma0,gamma1,gamma2);
2493  }
2494  if(omegacand->M()>0.7 && omegacand->M()<0.85){
2495  fHistoGammaFromMotherPt[fiCut]->Fill(gamma2->Pt(),fWeightJetJetMC);
2496  if(fDoMesonQA>0){
2499  fHistoMotherYPt[fiCut]->Fill(omegacand->Pt(),omegacand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2500  fHistoMotherAlphaPt[fiCut]->Fill(omegacand->Pt(),omegacand->GetAlpha(),fWeightJetJetMC);
2501  fHistoMotherEtaPhi[fiCut]->Fill(omegacand->Phi(),omegacand->Eta(),fWeightJetJetMC);
2502  fHistoMotherPi0AnglePt[fiCut]->Fill(omegacand->Pt(),TMath::Pi() - omegacand->Angle(pi0cand->Vect()),fWeightJetJetMC);
2503  fHistoMotherGammaAnglePt[fiCut]->Fill(omegacand->Pt(),TMath::Pi() - omegacand->Angle(gamma2->Vect()),fWeightJetJetMC);
2504  fHistoPi0GammaAnglePt[fiCut]->Fill(omegacand->Pt(),pi0cand->Angle(gamma2->Vect()),fWeightJetJetMC);
2505  }
2506  }
2507  } else if(fDoPiZeroGammaAngleCut){
2508  fHistoMotherAngleCutRejectedInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2509  }
2510  delete omegacand;
2511  omegacand=0x0;
2512  }
2513  } else{
2514  delete pi0cand;
2515  pi0cand=0x0;
2516  }
2517  }
2518  }
2519  }
2520  }
2521  }
2522  break;
2523  //cal-cal,cal
2524  case 2:
2525  if(fClusterCandidates->GetEntries()>2){
2526  for(Int_t firstGammaIndex=0;firstGammaIndex<fClusterCandidates->GetEntries();firstGammaIndex++){
2527  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(firstGammaIndex));
2528  if (gamma0==NULL || !(gamma0->GetIsCaloPhoton())) continue;
2529  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
2530  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
2531  if (gamma1==NULL || !(gamma1->GetIsCaloPhoton())) continue;
2532  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0, gamma1);
2534  ->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())
2535  && pi0cand->Pt() > fMinPi0Pt){
2536  fHistoPhotonPairInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(),fWeightJetJetMC);
2537  if(pi0cand->M() > ((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->GetSelectionLow() &&
2538  pi0cand->M() < ((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->GetSelectionHigh()){
2539  //change energy of pi0 candidate s.t. its mass is the pdg mass
2540  pi0cand->SetPxPyPzE(pi0cand->Px(),pi0cand->Py(),pi0cand->Pz(),TMath::Sqrt(0.1349766*0.1349766+pi0cand->P()*pi0cand->P()));
2541  fPi0Candidates->Add(pi0cand);
2542  if(fDoMesonQA>0){
2543  fHistoPhotonPairYPt[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2544  fHistoPhotonPairAlphaPt[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetAlpha(),fWeightJetJetMC);
2545  fHistoPhotonPairOpenAnglePt[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle(),fWeightJetJetMC);
2546  fHistoPhotonPairEtaPhi[fiCut]->Fill(pi0cand->Phi(),pi0cand->Eta(),fWeightJetJetMC);
2547  }
2548  for(Int_t thirdGammaIndex=0;thirdGammaIndex<fClusterCandidates->GetEntries();thirdGammaIndex++){
2549  if (thirdGammaIndex==secondGammaIndex || thirdGammaIndex==firstGammaIndex) continue;
2550  AliAODConversionPhoton *gamma2=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(thirdGammaIndex));
2551  if (gamma2==NULL || !(gamma2->GetIsCaloPhoton())) continue;
2552  AliAODConversionMother *omegacand = new AliAODConversionMother(pi0cand,gamma2);
2553  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedPiZeroGammaAngle(omegacand, pi0cand, gamma2, fDoPiZeroGammaAngleCut, fmaxfit, flowerFactor, fupperFactor)){
2554  fHistoMotherInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2555  if(fIsMC>0){
2556  if(fInputEvent->IsA()==AliESDEvent::Class())
2557  ProcessTrueMesonCandidates(omegacand,gamma0,gamma1,gamma2);
2558  if(fInputEvent->IsA()==AliAODEvent::Class())
2559  ProcessTrueMesonCandidatesAOD(omegacand,gamma0,gamma1,gamma2);
2560  }
2561  if(omegacand->M()>0.7 && omegacand->M()<0.85){
2562  fHistoGammaFromMotherPt[fiCut]->Fill(gamma2->Pt(),fWeightJetJetMC);
2563  if(fDoMesonQA>0){
2564  fHistoMotherYPt[fiCut]->Fill(omegacand->Pt(),omegacand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2565  fHistoMotherAlphaPt[fiCut]->Fill(omegacand->Pt(),omegacand->GetAlpha(),fWeightJetJetMC);
2566  fHistoMotherEtaPhi[fiCut]->Fill(omegacand->Phi(),omegacand->Eta(),fWeightJetJetMC);
2567  fHistoMotherPi0AnglePt[fiCut]->Fill(omegacand->Pt(),TMath::Pi() - omegacand->Angle(pi0cand->Vect()),fWeightJetJetMC);
2568  fHistoMotherGammaAnglePt[fiCut]->Fill(omegacand->Pt(),TMath::Pi() - omegacand->Angle(gamma2->Vect()),fWeightJetJetMC);
2569  fHistoPi0GammaAnglePt[fiCut]->Fill(omegacand->Pt(),pi0cand->Angle(gamma2->Vect()),fWeightJetJetMC);
2570  }
2571  }
2572  } else if(fDoPiZeroGammaAngleCut){
2573  fHistoMotherAngleCutRejectedInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2574  }
2575  delete omegacand;
2576  omegacand=0x0;
2577  }
2578  } else{
2579  delete pi0cand;
2580  pi0cand=0x0;
2581  }
2582  }
2583  }
2584  }
2585  }
2586  break;
2587  //cal-cal,PCM
2588  case 3:
2589  if(fClusterCandidates->GetEntries()>1 && fGammaCandidates->GetEntries()>0){
2590  for(Int_t firstGammaIndex=0;firstGammaIndex<fClusterCandidates->GetEntries();firstGammaIndex++){
2591  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(firstGammaIndex));
2592  if (gamma0==NULL || !(gamma0->GetIsCaloPhoton())) continue;
2593  AliVCluster* cluster0 = fInputEvent->GetCaloCluster(gamma0->GetCaloClusterRef());
2594  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
2595  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
2596  if (gamma1==NULL || !(gamma1->GetIsCaloPhoton())) continue;
2597  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0, gamma1);
2599  ->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())
2600  && pi0cand->Pt() > fMinPi0Pt){
2601  fHistoPhotonPairInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(),fWeightJetJetMC);
2602  if(pi0cand->M() > ((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->GetSelectionLow() &&
2603  pi0cand->M() < ((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->GetSelectionHigh()){
2604  //change energy of pi0 candidate s.t. its mass is the pdg mass
2605  pi0cand->SetPxPyPzE(pi0cand->Px(),pi0cand->Py(),pi0cand->Pz(),TMath::Sqrt(0.1349766*0.1349766+pi0cand->P()*pi0cand->P()));
2606  fPi0Candidates->Add(pi0cand);
2607  if(fDoMesonQA>0){
2608  fHistoPhotonPairYPt[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2609  fHistoPhotonPairAlphaPt[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetAlpha(),fWeightJetJetMC);
2610  fHistoPhotonPairOpenAnglePt[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle(),fWeightJetJetMC);
2611  fHistoPhotonPairEtaPhi[fiCut]->Fill(pi0cand->Phi(),pi0cand->Eta(),fWeightJetJetMC);
2612  }
2613  AliVCluster* cluster1 = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
2614  for(Int_t thirdGammaIndex=0;thirdGammaIndex<fGammaCandidates->GetEntries();thirdGammaIndex++){
2615  AliAODConversionPhoton *gamma2=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(thirdGammaIndex));
2616  Bool_t matched = (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma2,cluster0, fInputEvent, fWeightJetJetMC))
2617  || (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma2,cluster1, fInputEvent, fWeightJetJetMC));
2618  AliAODConversionMother *omegacand = new AliAODConversionMother(pi0cand,gamma2);
2619  if (matched){
2620  fHistoMotherMatchedInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2621  delete omegacand;
2622  omegacand=0x0;
2623  continue;
2624  }
2625  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedPiZeroGammaAngle(omegacand, pi0cand, gamma2, fDoPiZeroGammaAngleCut, fmaxfit, flowerFactor, fupperFactor)){
2626  fHistoMotherInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2627  if(fIsMC>0){
2628  if(fInputEvent->IsA()==AliESDEvent::Class())
2629  ProcessTrueMesonCandidates(omegacand,gamma0,gamma1,gamma2);
2630  if(fInputEvent->IsA()==AliAODEvent::Class())
2631  ProcessTrueMesonCandidatesAOD(omegacand,gamma0,gamma1,gamma2);
2632  }
2633  if(omegacand->M()>0.7 && omegacand->M()<0.85){
2634  fHistoGammaFromMotherPt[fiCut]->Fill(gamma2->Pt(),fWeightJetJetMC);
2635  if(fDoMesonQA>0){
2637  fHistoMotherYPt[fiCut]->Fill(omegacand->Pt(),omegacand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2638  fHistoMotherAlphaPt[fiCut]->Fill(omegacand->Pt(),omegacand->GetAlpha(),fWeightJetJetMC);
2639  fHistoMotherEtaPhi[fiCut]->Fill(omegacand->Phi(),omegacand->Eta(),fWeightJetJetMC);
2640  fHistoMotherPi0AnglePt[fiCut]->Fill(omegacand->Pt(),TMath::Pi() - omegacand->Angle(pi0cand->Vect()),fWeightJetJetMC);
2641  fHistoMotherGammaAnglePt[fiCut]->Fill(omegacand->Pt(),TMath::Pi() - omegacand->Angle(gamma2->Vect()),fWeightJetJetMC);
2642  fHistoPi0GammaAnglePt[fiCut]->Fill(omegacand->Pt(),pi0cand->Angle(gamma2->Vect()),fWeightJetJetMC);
2643  }
2644  }
2645  } else if(fDoPiZeroGammaAngleCut){
2646  fHistoMotherAngleCutRejectedInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2647  }
2648  delete omegacand;
2649  omegacand=0x0;
2650  }
2651  } else{
2652  delete pi0cand;
2653  pi0cand=0x0;
2654  }
2655  }
2656  }
2657  }
2658  }
2659  break;
2660  //PCM-PCM,cal
2661  case 4:
2662  if(fGammaCandidates->GetEntries()>1 && fClusterCandidates->GetEntries()>0){
2663  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
2664  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
2665  if(gamma0==NULL) continue;
2666  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGammaCandidates->GetEntries();secondGammaIndex++){
2667  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(secondGammaIndex));
2668  if(gamma1==NULL) continue;
2669  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0,gamma1);
2671  ->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())
2672  && pi0cand->Pt() > fMinPi0Pt){
2673  fHistoPhotonPairInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(),fWeightJetJetMC);
2674  if(pi0cand->M() > ((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->GetSelectionLow() &&
2675  pi0cand->M() < ((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->GetSelectionHigh()){
2676  //change energy of pi0 candidate s.t. its mass is the pdg mass
2677  pi0cand->SetPxPyPzE(pi0cand->Px(),pi0cand->Py(),pi0cand->Pz(),TMath::Sqrt(0.1349766*0.1349766+pi0cand->P()*pi0cand->P()));
2678  fPi0Candidates->Add(pi0cand);
2679  if(fDoMesonQA>0){
2680  fHistoPhotonPairYPt[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2681  fHistoPhotonPairAlphaPt[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetAlpha(),fWeightJetJetMC);
2682  fHistoPhotonPairOpenAnglePt[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle(),fWeightJetJetMC);
2683  fHistoPhotonPairEtaPhi[fiCut]->Fill(pi0cand->Phi(),pi0cand->Eta(),fWeightJetJetMC);
2684  }
2685  for(Int_t thirdGammaIndex=0;thirdGammaIndex<fClusterCandidates->GetEntries();thirdGammaIndex++){
2686  AliAODConversionPhoton *gamma2=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(thirdGammaIndex));
2687  if(gamma2==NULL || !(gamma2->GetIsCaloPhoton())) continue;
2688  AliVCluster* cluster = fInputEvent->GetCaloCluster(gamma2->GetCaloClusterRef());
2689  Bool_t matched = (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma0,cluster, fInputEvent, fWeightJetJetMC))
2690  || (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma1,cluster, fInputEvent, fWeightJetJetMC));
2691  AliAODConversionMother *omegacand = new AliAODConversionMother(pi0cand,gamma2);
2692  if (matched){
2693  fHistoMotherMatchedInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2694  delete omegacand;
2695  omegacand=0x0;
2696  continue;
2697  }
2698  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedPiZeroGammaAngle(omegacand, pi0cand, gamma2, fDoPiZeroGammaAngleCut, fmaxfit, flowerFactor, fupperFactor)){
2699  fHistoMotherInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2700  if(fIsMC>0){
2701  if(fInputEvent->IsA()==AliESDEvent::Class())
2702  ProcessTrueMesonCandidates(omegacand,gamma0,gamma1,gamma2);
2703  if(fInputEvent->IsA()==AliAODEvent::Class())
2704  ProcessTrueMesonCandidatesAOD(omegacand,gamma0,gamma1,gamma2);
2705  }
2706  if(omegacand->M()>0.7 && omegacand->M()<0.85){
2707  fHistoGammaFromMotherPt[fiCut]->Fill(gamma2->Pt(),fWeightJetJetMC);
2708  if(fDoMesonQA){
2709  fHistoMotherYPt[fiCut]->Fill(omegacand->Pt(),omegacand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2710  fHistoMotherAlphaPt[fiCut]->Fill(omegacand->Pt(),omegacand->GetAlpha(),fWeightJetJetMC);
2711  fHistoMotherEtaPhi[fiCut]->Fill(omegacand->Phi(),omegacand->Eta(),fWeightJetJetMC);
2712  fHistoMotherPi0AnglePt[fiCut]->Fill(omegacand->Pt(),TMath::Pi() - omegacand->Angle(pi0cand->Vect()),fWeightJetJetMC);
2713  fHistoMotherGammaAnglePt[fiCut]->Fill(omegacand->Pt(),TMath::Pi() - omegacand->Angle(gamma2->Vect()),fWeightJetJetMC);
2714  fHistoPi0GammaAnglePt[fiCut]->Fill(omegacand->Pt(),pi0cand->Angle(gamma2->Vect()),fWeightJetJetMC);
2717  }
2718  }
2719  } else if(fDoPiZeroGammaAngleCut){
2720  fHistoMotherAngleCutRejectedInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2721  }
2722  delete omegacand;
2723  omegacand=0x0;
2724  }
2725  } else{
2726  delete pi0cand;
2727  pi0cand=0x0;
2728  }
2729  }
2730  }
2731  }
2732  }
2733  break;
2734  //PCM-PCM,PCM
2735  case 5:
2736  if(fGammaCandidates->GetEntries()>2){
2737  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
2738  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
2739  if (gamma0==NULL) continue;
2740  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGammaCandidates->GetEntries();secondGammaIndex++){
2741  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(secondGammaIndex));
2742  if (gamma1==NULL || (secondGammaIndex+1)>=(fGammaCandidates->GetEntries())) continue;
2743  AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0, gamma1);
2745  ->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())
2746  && pi0cand->Pt() > fMinPi0Pt){
2747  fHistoPhotonPairInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt(),fWeightJetJetMC);
2748  if(pi0cand->M() > ((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->GetSelectionLow() &&
2749  pi0cand->M() < ((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->GetSelectionHigh()){
2750  //change energy of pi0 candidate s.t. its mass is the pdg mass
2751  pi0cand->SetPxPyPzE(pi0cand->Px(),pi0cand->Py(),pi0cand->Pz(),TMath::Sqrt(0.1349766*0.1349766+pi0cand->P()*pi0cand->P()));
2752  fPi0Candidates->Add(pi0cand);
2753  if(fDoMesonQA>0){
2754  fHistoPhotonPairYPt[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2755  fHistoPhotonPairAlphaPt[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetAlpha(),fWeightJetJetMC);
2756  fHistoPhotonPairOpenAnglePt[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle(),fWeightJetJetMC);
2757  fHistoPhotonPairEtaPhi[fiCut]->Fill(pi0cand->Phi(),pi0cand->Eta(),fWeightJetJetMC);
2758  }
2759  for(Int_t thirdGammaIndex=0;thirdGammaIndex<fGammaCandidates->GetEntries();thirdGammaIndex++){
2760  if (thirdGammaIndex==firstGammaIndex || thirdGammaIndex==secondGammaIndex) continue;
2761  AliAODConversionPhoton *gamma2=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(thirdGammaIndex));
2762  if (gamma2==NULL) continue;
2763  AliAODConversionMother *omegacand = new AliAODConversionMother(pi0cand,gamma2);
2764  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedPiZeroGammaAngle(omegacand, pi0cand, gamma2, fDoPiZeroGammaAngleCut, fmaxfit, flowerFactor, fupperFactor)){
2765  if(fIsMC>0){
2766  if(fInputEvent->IsA()==AliESDEvent::Class())
2767  ProcessTrueMesonCandidates(omegacand,gamma0,gamma1,gamma2);
2768  if(fInputEvent->IsA()==AliAODEvent::Class())
2769  ProcessTrueMesonCandidatesAOD(omegacand,gamma0,gamma1,gamma2);
2770  }
2771  fHistoMotherInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2772  if(omegacand->M()>0.7 && omegacand->M()<0.85){
2773  fHistoGammaFromMotherPt[fiCut]->Fill(gamma2->Pt(),fWeightJetJetMC);
2774  if(fDoMesonQA>0){
2775  fHistoMotherYPt[fiCut]->Fill(omegacand->Pt(),omegacand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2776  fHistoMotherAlphaPt[fiCut]->Fill(omegacand->Pt(),omegacand->GetAlpha(),fWeightJetJetMC);
2777  fHistoMotherEtaPhi[fiCut]->Fill(omegacand->Phi(),omegacand->Eta(),fWeightJetJetMC);
2778  fHistoMotherPi0AnglePt[fiCut]->Fill(omegacand->Pt(),TMath::Pi() - omegacand->Angle(pi0cand->Vect()),fWeightJetJetMC);
2779  fHistoMotherGammaAnglePt[fiCut]->Fill(omegacand->Pt(),TMath::Pi() - omegacand->Angle(gamma2->Vect()),fWeightJetJetMC);
2780  fHistoPi0GammaAnglePt[fiCut]->Fill(omegacand->Pt(),pi0cand->Angle(gamma2->Vect()),fWeightJetJetMC);
2781  }
2782  }
2783  } else if(fDoPiZeroGammaAngleCut){
2784  fHistoMotherAngleCutRejectedInvMassPt[fiCut]->Fill(omegacand->M(),omegacand->Pt(),fWeightJetJetMC);
2785  }
2786  delete omegacand;
2787  omegacand=0x0;
2788  }
2789  } else{
2790  delete pi0cand;
2791  pi0cand=0x0;
2792  }
2793  }
2794  }
2795  }
2796  }
2797  break;
2798  }
2799 }
2800 //______________________________________________________________________
2802 {
2803  switch (fReconMethod){
2804  // pcm-cal,cal
2805  case 0:
2806  {
2807  // get gamma0MotherLabel
2808  Int_t gamma0MCLabel = -1;
2809  Int_t gamma0MotherLabel = -1;
2810  if (TrueGammaCandidate0->IsTrueConvertedPhoton()){
2811  gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCStack);
2812  if(gamma0MCLabel>-1){
2813  TParticle * gammaMC0 = (TParticle*)fMCStack->Particle(gamma0MCLabel);
2814  gamma0MotherLabel=gammaMC0->GetFirstMother();
2815  }
2816  }
2817 
2818  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2819  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
2820  Int_t gamma1MotherLabel = -1;
2821  TParticle * gammaMC1 = 0x0;
2822  if(gamma1MCLabel != -1){
2823  // get mother or grandmother of gamma1 depending on whether it is an electron-leading/photon-leading cluster
2824  gammaMC1 = (TParticle*)fMCStack->Particle(gamma1MCLabel);
2825  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons it's the direct mother
2826  gamma1MotherLabel=gammaMC1->GetMother(0);
2827  }else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
2828  if (TrueGammaCandidate1->IsConversion() && gammaMC1->GetMother(0)>-1) gamma1MotherLabel=(fMCStack->Particle(gammaMC1->GetMother(0)))->GetMother(0);
2829  else gamma1MotherLabel=gammaMC1->GetMother(0);
2830  }
2831  }
2832 
2833  // check if mother of gamma0 and gamma1 is really a pi0
2834  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel && ((TParticle*)fMCStack->Particle(gamma0MotherLabel))->GetPdgCode() == 111){
2835 
2836  // fill pi0 histograms here if necessary
2837 
2838  if (!TrueGammaCandidate2->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2839  Int_t gamma2MCLabel = TrueGammaCandidate2->GetCaloPhotonMCLabel(0); // get most probable MC label
2840  Int_t gamma2MotherLabel = -1;
2841  TParticle * gammaMC2 = 0x0;
2842  if(gamma2MCLabel != -1){
2843  // get mother or grandmother of gamma1 (potentially true omega) depending on whether it is an electron-leading/photon-leading cluster
2844  gammaMC2 = (TParticle*)fMCStack->Particle(gamma2MCLabel);
2845  if (TrueGammaCandidate2->IsLargestComponentPhoton()){ // for photons it's the direct mother
2846  gamma2MotherLabel=gammaMC2->GetMother(0);
2847  }else if (TrueGammaCandidate2->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
2848  if (TrueGammaCandidate2->IsConversion() && gammaMC2->GetMother(0)>-1) gamma2MotherLabel=fMCStack->Particle(gammaMC2->GetMother(0))->GetMother(0);
2849  else gamma2MotherLabel=gammaMC2->GetMother(0);
2850  }
2851  }
2852 
2853  //get pi0MotherLabel
2854  Int_t pi0MotherLabel = fMCStack->Particle(gamma0MotherLabel)->GetMother(0);
2855  // check if mother of pi0 and mother of gamma2 are the same particle and that it is an omega
2856  if(pi0MotherLabel>=0 && gamma2MotherLabel==pi0MotherLabel && ((TParticle*)fMCStack->Particle(pi0MotherLabel))->GetPdgCode() == 223){
2857  fHistoTrueOmegaInvMassPt[fiCut]->Fill(OmegaCandidate->M(),OmegaCandidate->Pt(),fWeightJetJetMC);
2858  // create pi0 candidate and fill histograms
2859  AliAODConversionMother *TruePi0 = new AliAODConversionMother(TrueGammaCandidate0, TrueGammaCandidate1);
2860  fHistoTruePi0FromOmegaInvMassPt[fiCut]->Fill(TruePi0->M(),TruePi0->Pt(),fWeightJetJetMC);
2861  fHistoTrueGammaFromOmegaPt[fiCut]->Fill(TrueGammaCandidate2->Pt(),fWeightJetJetMC);
2862  if(fDoMesonQA>0){
2863  fHistoTrueOmegaYPt[fiCut]->Fill(OmegaCandidate->Pt(),OmegaCandidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2864  fHistoTrueOmegaAlphaPt[fiCut]->Fill(OmegaCandidate->Pt(),OmegaCandidate->GetAlpha(),fWeightJetJetMC);
2865  fHistoTrueOmegaEtaPhi[fiCut]->Fill(OmegaCandidate->Phi(),OmegaCandidate->Eta(),fWeightJetJetMC);
2866  fHistoTrueOmegaGammaAnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TMath::Pi() - OmegaCandidate->Angle(TrueGammaCandidate2->Vect()),fWeightJetJetMC);
2867  fHistoTrueOmegaPtGammaPt[fiCut]->Fill(OmegaCandidate->Pt(),TrueGammaCandidate2->Pt(),fWeightJetJetMC);
2868  fHistoTruePi0FromOmegaAlphaPt[fiCut]->Fill(TruePi0->Pt(),TruePi0->GetAlpha(),fWeightJetJetMC);
2869  fHistoTruePi0FromOmegaYPt[fiCut]->Fill(TruePi0->Pt(),TruePi0->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2870  fHistoTruePi0FromOmegaEtaPhi[fiCut]->Fill(TruePi0->Phi(),TruePi0->Eta(),fWeightJetJetMC);
2872  fHistoTrueOmegaPi0AnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TMath::Pi() - OmegaCandidate->Angle(TruePi0->Vect()),fWeightJetJetMC);
2873  fHistoTruePi0GammaAnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TruePi0->Angle(TrueGammaCandidate2->Vect()),fWeightJetJetMC);
2874  fHistoTrueOmegaPtPi0Pt[fiCut]->Fill(OmegaCandidate->Pt(),TruePi0->Pt(),fWeightJetJetMC);
2875  }
2876  delete TruePi0;
2877  TruePi0=0x0;
2878  }
2879  }
2880  }
2881  break;
2882  // pcm-cal,pcm
2883  case 1:
2884  {
2885  // get gamma0MotherLabel
2886  Int_t gamma0MCLabel = -1;
2887  Int_t gamma0MotherLabel = -1;
2888  if (TrueGammaCandidate0->IsTrueConvertedPhoton()){
2889  gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCStack);
2890  if(gamma0MCLabel>-1){
2891  TParticle * gammaMC0 = (TParticle*)fMCStack->Particle(gamma0MCLabel);
2892  gamma0MotherLabel=gammaMC0->GetFirstMother();
2893  }
2894  }
2895 
2896  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2897  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
2898  Int_t gamma1MotherLabel = -1;
2899  TParticle * gammaMC1 = 0x0;
2900  if(gamma1MCLabel != -1){
2901  // get mother or grandmother of gamma1 depending on whether it is an electron-leading/photon-leading cluster
2902  gammaMC1 = (TParticle*)fMCStack->Particle(gamma1MCLabel);
2903  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons it's the direct mother
2904  gamma1MotherLabel=gammaMC1->GetMother(0);
2905  }else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
2906  if (TrueGammaCandidate1->IsConversion() && gammaMC1->GetMother(0)>-1) gamma1MotherLabel=fMCStack->Particle(gammaMC1->GetMother(0))->GetMother(0);
2907  else gamma1MotherLabel=gammaMC1->GetMother(0);
2908  }
2909  }
2910 
2911  // check if mother of gamma0 and gamma1 is really a pi0
2912  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel && ((TParticle*)fMCStack->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
2913 
2914  // fill pi0 histograms here if necessary
2915 
2916  // get mother of gamma2
2917  Int_t gamma2MCLabel = -1;
2918  Int_t gamma2MotherLabel = -1;
2919  if (TrueGammaCandidate2->IsTrueConvertedPhoton()){
2920  gamma2MCLabel = TrueGammaCandidate2->GetMCParticleLabel(fMCStack);
2921  if(gamma2MCLabel>-1){
2922  TParticle * gammaMC2 = (TParticle*)fMCStack->Particle(gamma2MCLabel);
2923  gamma2MotherLabel = gammaMC2->GetFirstMother();
2924  }
2925  }
2926 
2927  // get pi0MotherLabel
2928  Int_t pi0MotherLabel = fMCStack->Particle(gamma0MotherLabel)->GetMother(0);
2929  // check if mother of pi0 and mother of gamma2 are the same particle and that it is an omega
2930  if(pi0MotherLabel>=0 && gamma2MotherLabel==pi0MotherLabel && ((TParticle*)fMCStack->Particle(pi0MotherLabel))->GetPdgCode() == 223){
2931  fHistoTrueOmegaInvMassPt[fiCut]->Fill(OmegaCandidate->M(),OmegaCandidate->Pt(),fWeightJetJetMC);
2932  // create pi0 candidate and fill histograms
2933  AliAODConversionMother *TruePi0 = new AliAODConversionMother(TrueGammaCandidate0, TrueGammaCandidate1);
2934  fHistoTruePi0FromOmegaInvMassPt[fiCut]->Fill(TruePi0->M(),TruePi0->Pt(),fWeightJetJetMC);
2935  fHistoTrueGammaFromOmegaPt[fiCut]->Fill(TrueGammaCandidate2->Pt(),fWeightJetJetMC);
2936  if(fDoMesonQA>0){
2937  fHistoTrueOmegaYPt[fiCut]->Fill(OmegaCandidate->Pt(),OmegaCandidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2938  fHistoTrueOmegaAlphaPt[fiCut]->Fill(OmegaCandidate->Pt(),OmegaCandidate->GetAlpha(),fWeightJetJetMC);
2939  fHistoTrueOmegaEtaPhi[fiCut]->Fill(OmegaCandidate->Phi(),OmegaCandidate->Eta(),fWeightJetJetMC);
2940  fHistoTrueOmegaGammaAnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TMath::Pi() - OmegaCandidate->Angle(TrueGammaCandidate2->Vect()),fWeightJetJetMC);
2941  fHistoTrueOmegaPtGammaPt[fiCut]->Fill(OmegaCandidate->Pt(),TrueGammaCandidate2->Pt(),fWeightJetJetMC);
2942  fHistoTruePi0FromOmegaAlphaPt[fiCut]->Fill(TruePi0->Pt(),TruePi0->GetAlpha(),fWeightJetJetMC);
2943  fHistoTruePi0FromOmegaYPt[fiCut]->Fill(TruePi0->Pt(),TruePi0->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2944  fHistoTruePi0FromOmegaEtaPhi[fiCut]->Fill(TruePi0->Phi(),TruePi0->Eta(),fWeightJetJetMC);
2946  fHistoTrueOmegaPi0AnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TMath::Pi() - OmegaCandidate->Angle(TruePi0->Vect()),fWeightJetJetMC);
2947  fHistoTruePi0GammaAnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TruePi0->Angle(TrueGammaCandidate2->Vect()),fWeightJetJetMC);
2948  fHistoTrueOmegaPtPi0Pt[fiCut]->Fill(OmegaCandidate->Pt(),TruePi0->Pt(),fWeightJetJetMC);
2949  }
2950  delete TruePi0;
2951  TruePi0=0x0;
2952  }
2953  }
2954  }
2955  break;
2956  // cal-cal,cal
2957  case 2:
2958  {
2959  // get gamma0MotherLabel
2960  if (!TrueGammaCandidate0->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2961  Int_t gamma0MCLabel = TrueGammaCandidate0->GetCaloPhotonMCLabel(0); // get most probable MC label
2962  Int_t gamma0MotherLabel = -1;
2963  TParticle * gammaMC0 = 0x0;
2964  if(gamma0MCLabel != -1){
2965  // get mother or grandmother of gamma0 depending on whether it is an electron-leading/photon-leading cluster
2966  gammaMC0 = (TParticle*)fMCStack->Particle(gamma0MCLabel);
2967  if (TrueGammaCandidate0->IsLargestComponentPhoton()){ // for photons it's the direct mother
2968  gamma0MotherLabel=gammaMC0->GetMother(0);
2969  }else if (TrueGammaCandidate0->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
2970  if (TrueGammaCandidate0->IsConversion() && gammaMC0->GetMother(0)>-1) gamma0MotherLabel=fMCStack->Particle(gammaMC0->GetMother(0))->GetMother(0);
2971  else gamma0MotherLabel=gammaMC0->GetMother(0);
2972  }
2973  }
2974 
2975  // get gamma1MotherLabel
2976  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2977  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
2978  Int_t gamma1MotherLabel = -1;
2979  TParticle * gammaMC1 = 0x0;
2980  if(gamma1MCLabel != -1){
2981  // get mother or grandmother of gamma1 depending on whether it is an electron-leading/photon-leading cluster
2982  gammaMC1 = (TParticle*)fMCStack->Particle(gamma1MCLabel);
2983  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons it's the direct mother
2984  gamma1MotherLabel=gammaMC1->GetMother(0);
2985  }else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
2986  if (TrueGammaCandidate1->IsConversion() && gammaMC1->GetMother(0)>-1) gamma1MotherLabel=fMCStack->Particle(gammaMC1->GetMother(0))->GetMother(0);
2987  else gamma1MotherLabel=gammaMC1->GetMother(0);
2988  }
2989  }
2990 
2991  // check if mother of gamma0 and gamma1 is really a pi0
2992  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel && ((TParticle*)fMCStack->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
2993 
2994  // fill pi0 histograms here if necessary
2995 
2996  if (!TrueGammaCandidate2->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2997  Int_t gamma2MCLabel = TrueGammaCandidate2->GetCaloPhotonMCLabel(0); // get most probable MC label
2998  Int_t gamma2MotherLabel = -1;
2999  TParticle * gammaMC2 = 0x0;
3000  if(gamma2MCLabel != -1){
3001  // get mother or grandmother of gamma2 (potentially true omega) depending on whether it is an electron-leading/photon-leading cluster
3002  gammaMC2 = (TParticle*)fMCStack->Particle(gamma2MCLabel);
3003  if (TrueGammaCandidate2->IsLargestComponentPhoton()){ // for photons it's the direct mother
3004  gamma2MotherLabel=gammaMC2->GetMother(0);
3005  }else if (TrueGammaCandidate2->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
3006  if (TrueGammaCandidate2->IsConversion() && gammaMC2->GetMother(0)>-1) gamma2MotherLabel=fMCStack->Particle(gammaMC2->GetMother(0))->GetMother(0);
3007  else gamma2MotherLabel=gammaMC2->GetMother(0);
3008  }
3009  }
3010 
3011  //get pi0MotherLabel
3012  Int_t pi0MotherLabel = fMCStack->Particle(gamma0MotherLabel)->GetMother(0);
3013  // check if mother of pi0 and mother of gamma2 are the same particle and that it is an omega
3014  if(pi0MotherLabel>=0 && gamma2MotherLabel==pi0MotherLabel && ((TParticle*)fMCStack->Particle(pi0MotherLabel))->GetPdgCode() == 223){
3015  fHistoTrueOmegaInvMassPt[fiCut]->Fill(OmegaCandidate->M(),OmegaCandidate->Pt(),fWeightJetJetMC);
3016  // create pi0 candidate and fill histograms
3017  AliAODConversionMother *TruePi0 = new AliAODConversionMother(TrueGammaCandidate0, TrueGammaCandidate1);
3018  fHistoTruePi0FromOmegaInvMassPt[fiCut]->Fill(TruePi0->M(),TruePi0->Pt(),fWeightJetJetMC);
3019  fHistoTrueGammaFromOmegaPt[fiCut]->Fill(TrueGammaCandidate2->Pt(),fWeightJetJetMC);
3020  if(fDoMesonQA>0){
3021  fHistoTrueOmegaYPt[fiCut]->Fill(OmegaCandidate->Pt(),OmegaCandidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
3022  fHistoTrueOmegaAlphaPt[fiCut]->Fill(OmegaCandidate->Pt(),OmegaCandidate->GetAlpha(),fWeightJetJetMC);
3023  fHistoTrueOmegaEtaPhi[fiCut]->Fill(OmegaCandidate->Phi(),OmegaCandidate->Eta(),fWeightJetJetMC);
3024  fHistoTrueOmegaGammaAnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TMath::Pi() - OmegaCandidate->Angle(TrueGammaCandidate2->Vect()),fWeightJetJetMC);
3025  fHistoTrueOmegaPtGammaPt[fiCut]->Fill(OmegaCandidate->Pt(),TrueGammaCandidate2->Pt(),fWeightJetJetMC);
3026  fHistoTruePi0FromOmegaAlphaPt[fiCut]->Fill(TruePi0->Pt(),TruePi0->GetAlpha(),fWeightJetJetMC);
3027  fHistoTruePi0FromOmegaYPt[fiCut]->Fill(TruePi0->Pt(),TruePi0->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
3028  fHistoTruePi0FromOmegaEtaPhi[fiCut]->Fill(TruePi0->Phi(),TruePi0->Eta(),fWeightJetJetMC);
3030  fHistoTrueOmegaPi0AnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TMath::Pi() - OmegaCandidate->Angle(TruePi0->Vect()),fWeightJetJetMC);
3031  fHistoTruePi0GammaAnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TruePi0->Angle(TrueGammaCandidate2->Vect()),fWeightJetJetMC);
3032  fHistoTrueOmegaPtPi0Pt[fiCut]->Fill(OmegaCandidate->Pt(),TruePi0->Pt(),fWeightJetJetMC);
3033  }
3034  delete TruePi0;
3035  TruePi0=0x0;
3036  }
3037  }
3038  }
3039  break;
3040  // cal-cal,pcm
3041  case 3:
3042  {
3043  // get gamma0MotherLabel
3044  if (!TrueGammaCandidate0->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3045  Int_t gamma0MCLabel = TrueGammaCandidate0->GetCaloPhotonMCLabel(0); // get most probable MC label
3046  Int_t gamma0MotherLabel = -1;
3047  TParticle * gammaMC0 = 0x0;
3048  if(gamma0MCLabel != -1){
3049  // get mother or grandmother of gamma0 depending on whether it is an electron-leading/photon-leading cluster
3050  gammaMC0 = (TParticle*)fMCStack->Particle(gamma0MCLabel);
3051  if (TrueGammaCandidate0->IsLargestComponentPhoton()){ // for photons it's the direct mother
3052  gamma0MotherLabel=gammaMC0->GetMother(0);
3053  }else if (TrueGammaCandidate0->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
3054  if (TrueGammaCandidate0->IsConversion() && gammaMC0->GetMother(0)>-1) gamma0MotherLabel=fMCStack->Particle(gammaMC0->GetMother(0))->GetMother(0);
3055  else gamma0MotherLabel=gammaMC0->GetMother(0);
3056  }
3057  }
3058 
3059  // get gamma1MotherLabel
3060  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3061  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
3062  Int_t gamma1MotherLabel = -1;
3063  TParticle * gammaMC1 = 0x0;
3064  if(gamma1MCLabel != -1){
3065  // get mother or grandmother of gamma1 depending on whether it is an electron-leading/photon-leading cluster
3066  gammaMC1 = (TParticle*)fMCStack->Particle(gamma1MCLabel);
3067  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons it's the direct mother
3068  gamma1MotherLabel=gammaMC1->GetMother(0);
3069  }else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
3070  if (TrueGammaCandidate1->IsConversion() && gammaMC1->GetMother(0)>-1) gamma1MotherLabel=fMCStack->Particle(gammaMC1->GetMother(0))->GetMother(0);
3071  else gamma1MotherLabel=gammaMC1->GetMother(0);
3072  }
3073  }
3074 
3075  // check if mother of gamma0 and gamma1 is really a pi0
3076  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel && ((TParticle*)fMCStack->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
3077 
3078  // fill pi0 histograms here if necessary
3079 
3080  // get mother of gamma2
3081  Int_t gamma2MCLabel = -1;
3082  Int_t gamma2MotherLabel = -1;
3083  if (TrueGammaCandidate2->IsTrueConvertedPhoton()){
3084  gamma2MCLabel = TrueGammaCandidate2->GetMCParticleLabel(fMCStack);
3085  if(gamma2MCLabel>-1){
3086  TParticle * gammaMC2 = (TParticle*)fMCStack->Particle(gamma2MCLabel);
3087  gamma2MotherLabel = gammaMC2->GetFirstMother();
3088  }
3089  }
3090 
3091  // get pi0MotherLabel
3092  Int_t pi0MotherLabel = fMCStack->Particle(gamma0MotherLabel)->GetMother(0);
3093  // check if mother of pi0 and mother of gamma2 are the same particle and that it is an omega
3094  if(pi0MotherLabel>=0 && gamma2MotherLabel==pi0MotherLabel && ((TParticle*)fMCStack->Particle(pi0MotherLabel))->GetPdgCode() == 223){
3095  fHistoTrueOmegaInvMassPt[fiCut]->Fill(OmegaCandidate->M(),OmegaCandidate->Pt(),fWeightJetJetMC);
3096  // create pi0 candidate and fill histograms
3097  AliAODConversionMother *TruePi0 = new AliAODConversionMother(TrueGammaCandidate0, TrueGammaCandidate1);
3098  fHistoTruePi0FromOmegaInvMassPt[fiCut]->Fill(TruePi0->M(),TruePi0->Pt(),fWeightJetJetMC);
3099  fHistoTrueGammaFromOmegaPt[fiCut]->Fill(TrueGammaCandidate2->Pt(),fWeightJetJetMC);
3100  if(fDoMesonQA>0){
3101  fHistoTrueOmegaYPt[fiCut]->Fill(OmegaCandidate->Pt(),OmegaCandidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
3102  fHistoTrueOmegaAlphaPt[fiCut]->Fill(OmegaCandidate->Pt(),OmegaCandidate->GetAlpha(),fWeightJetJetMC);
3103  fHistoTrueOmegaEtaPhi[fiCut]->Fill(OmegaCandidate->Phi(),OmegaCandidate->Eta(),fWeightJetJetMC);
3104  fHistoTrueOmegaGammaAnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TMath::Pi() - OmegaCandidate->Angle(TrueGammaCandidate2->Vect()),fWeightJetJetMC);
3105  fHistoTrueOmegaPtGammaPt[fiCut]->Fill(OmegaCandidate->Pt(),TrueGammaCandidate2->Pt(),fWeightJetJetMC);
3106  fHistoTruePi0FromOmegaAlphaPt[fiCut]->Fill(TruePi0->Pt(),TruePi0->GetAlpha(),fWeightJetJetMC);
3107  fHistoTruePi0FromOmegaYPt[fiCut]->Fill(TruePi0->Pt(),TruePi0->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
3108  fHistoTruePi0FromOmegaEtaPhi[fiCut]->Fill(TruePi0->Phi(),TruePi0->Eta(),fWeightJetJetMC);
3110  fHistoTrueOmegaPi0AnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TMath::Pi() - OmegaCandidate->Angle(TruePi0->Vect()),fWeightJetJetMC);
3111  fHistoTruePi0GammaAnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TruePi0->Angle(TrueGammaCandidate2->Vect()),fWeightJetJetMC);
3112  fHistoTrueOmegaPtPi0Pt[fiCut]->Fill(OmegaCandidate->Pt(),TruePi0->Pt(),fWeightJetJetMC);
3113  }
3114  delete TruePi0;
3115  TruePi0=0x0;
3116  }
3117  }
3118  }
3119  break;
3120  // pcm-pcm,cal
3121  case 4:
3122  {
3123  // get gamma0MotherLabel
3124  Int_t gamma0MCLabel = -1;
3125  Int_t gamma0MotherLabel = -1;
3126  if (TrueGammaCandidate0->IsTrueConvertedPhoton()){
3127  gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCStack);
3128  if(gamma0MCLabel>-1){
3129  TParticle * gammaMC0 = (TParticle*)fMCStack->Particle(gamma0MCLabel);
3130  gamma0MotherLabel=gammaMC0->GetFirstMother();
3131  }
3132  }
3133 
3134  // get gamma1MotherLabel
3135  Int_t gamma1MCLabel = -1;
3136  Int_t gamma1MotherLabel = -1;
3137  if (TrueGammaCandidate1->IsTrueConvertedPhoton()){
3138  gamma1MCLabel = TrueGammaCandidate1->GetMCParticleLabel(fMCStack);
3139  if(gamma1MCLabel>-1){
3140  TParticle * gammaMC1 = (TParticle*)fMCStack->Particle(gamma1MCLabel);
3141  gamma1MotherLabel=gammaMC1->GetFirstMother();
3142  }
3143  }
3144 
3145  // check if mother of gamma0 and gamma1 is really a pi0
3146  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel &&
3147  ((TParticle*)fMCStack->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
3148 
3149  // fill pi0 histograms here if necessary
3150 
3151  if (!TrueGammaCandidate2->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3152  Int_t gamma2MCLabel = TrueGammaCandidate2->GetCaloPhotonMCLabel(0); // get most probable MC label
3153  Int_t gamma2MotherLabel = -1;
3154  TParticle * gammaMC2 = 0x0;
3155  if(gamma2MCLabel != -1){
3156  // get mother or grandmother of gamma1 (potentially true omega) depending on whether it is an electron-leading/photon-leading cluster
3157  gammaMC2 = (TParticle*)fMCStack->Particle(gamma2MCLabel);
3158  if (TrueGammaCandidate2->IsLargestComponentPhoton()){ // for photons it's the direct mother
3159  gamma2MotherLabel=gammaMC2->GetMother(0);
3160  }else if (TrueGammaCandidate2->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
3161  if (TrueGammaCandidate2->IsConversion() && gammaMC2->GetMother(0)>-1) gamma2MotherLabel=fMCStack->Particle(gammaMC2->GetMother(0))->GetMother(0);
3162  else gamma2MotherLabel=gammaMC2->GetMother(0);
3163  }
3164  }
3165 
3166  //get pi0MotherLabel
3167  Int_t pi0MotherLabel = fMCStack->Particle(gamma0MotherLabel)->GetMother(0);
3168  // check if mother of pi0 and mother of gamma2 are the same particle and that it is an omega
3169  if(pi0MotherLabel>=0 && gamma2MotherLabel==pi0MotherLabel && ((TParticle*)fMCStack->Particle(pi0MotherLabel))->GetPdgCode() == 223){
3170  fHistoTrueOmegaInvMassPt[fiCut]->Fill(OmegaCandidate->M(),OmegaCandidate->Pt(),fWeightJetJetMC);
3171  // create pi0 candidate and fill histograms
3172  AliAODConversionMother *TruePi0 = new AliAODConversionMother(TrueGammaCandidate0, TrueGammaCandidate1);
3173  fHistoTruePi0FromOmegaInvMassPt[fiCut]->Fill(TruePi0->M(),TruePi0->Pt(),fWeightJetJetMC);
3174  fHistoTrueGammaFromOmegaPt[fiCut]->Fill(TrueGammaCandidate2->Pt(),fWeightJetJetMC);
3175  if(fDoMesonQA>0){
3176  fHistoTrueOmegaYPt[fiCut]->Fill(OmegaCandidate->Pt(),OmegaCandidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
3177  fHistoTrueOmegaAlphaPt[fiCut]->Fill(OmegaCandidate->Pt(),OmegaCandidate->GetAlpha(),fWeightJetJetMC);
3178  fHistoTrueOmegaEtaPhi[fiCut]->Fill(OmegaCandidate->Phi(),OmegaCandidate->Eta(),fWeightJetJetMC);
3179  fHistoTrueOmegaGammaAnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TMath::Pi() - OmegaCandidate->Angle(TrueGammaCandidate2->Vect()),fWeightJetJetMC);
3180  fHistoTrueOmegaPtGammaPt[fiCut]->Fill(OmegaCandidate->Pt(),TrueGammaCandidate2->Pt(),fWeightJetJetMC);
3181  fHistoTruePi0FromOmegaAlphaPt[fiCut]->Fill(TruePi0->Pt(),TruePi0->GetAlpha(),fWeightJetJetMC);
3182  fHistoTruePi0FromOmegaYPt[fiCut]->Fill(TruePi0->Pt(),TruePi0->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
3183  fHistoTruePi0FromOmegaEtaPhi[fiCut]->Fill(TruePi0->Phi(),TruePi0->Eta(),fWeightJetJetMC);
3185  fHistoTrueOmegaPi0AnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TMath::Pi() - OmegaCandidate->Angle(TruePi0->Vect()),fWeightJetJetMC);
3186  fHistoTruePi0GammaAnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TruePi0->Angle(TrueGammaCandidate2->Vect()),fWeightJetJetMC);
3187  fHistoTrueOmegaPtPi0Pt[fiCut]->Fill(OmegaCandidate->Pt(),TruePi0->Pt(),fWeightJetJetMC);
3188  }
3189  delete TruePi0;
3190  TruePi0=0x0;
3191  }
3192  }
3193  }
3194  break;
3195  // pcm-pcm,pcm
3196  case 5:
3197  {
3198  // get gamma0MotherLabel
3199  Int_t gamma0MCLabel = -1;
3200  Int_t gamma0MotherLabel = -1;
3201  if (TrueGammaCandidate0->IsTrueConvertedPhoton()){
3202  gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCStack);
3203  if(gamma0MCLabel>-1){
3204  TParticle * gammaMC0 = (TParticle*)fMCStack->Particle(gamma0MCLabel);
3205  gamma0MotherLabel=gammaMC0->GetFirstMother();
3206  }
3207  }
3208 
3209  // get gamma1MotherLabel
3210  Int_t gamma1MCLabel = -1;
3211  Int_t gamma1MotherLabel = -1;
3212  if (TrueGammaCandidate1->IsTrueConvertedPhoton()){
3213  gamma1MCLabel = TrueGammaCandidate1->GetMCParticleLabel(fMCStack);
3214  if(gamma1MCLabel>-1){
3215  TParticle * gammaMC1 = (TParticle*)fMCStack->Particle(gamma1MCLabel);
3216  gamma1MotherLabel=gammaMC1->GetFirstMother();
3217  }
3218  }
3219 
3220  // check if mother of gamma0 and gamma1 is really a pi0
3221  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel &&
3222  ((TParticle*)fMCStack->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
3223 
3224  // fill pi0 histograms here if necessary
3225 
3226  Int_t gamma2MCLabel = -1;
3227  Int_t gamma2MotherLabel = -1;
3228  if (TrueGammaCandidate2->IsTrueConvertedPhoton()){
3229  gamma2MCLabel = TrueGammaCandidate2->GetMCParticleLabel(fMCStack);
3230  if(gamma2MCLabel>-1){
3231  TParticle * gammaMC2 = (TParticle*)fMCStack->Particle(gamma2MCLabel);
3232  gamma2MotherLabel=gammaMC2->GetFirstMother();
3233  }
3234  }
3235 
3236  //get pi0MotherLabel
3237  Int_t pi0MotherLabel = fMCStack->Particle(gamma0MotherLabel)->GetMother(0);
3238  // check if mother of pi0 and mother of gamma2 are the same particle and that it is an omega
3239  if(pi0MotherLabel>=0 && gamma2MotherLabel==pi0MotherLabel && ((TParticle*)fMCStack->Particle(pi0MotherLabel))->GetPdgCode() == 223){
3240  fHistoTrueOmegaInvMassPt[fiCut]->Fill(OmegaCandidate->M(),OmegaCandidate->Pt(),fWeightJetJetMC);
3241  // create pi0 candidate and fill histograms
3242  AliAODConversionMother *TruePi0 = new AliAODConversionMother(TrueGammaCandidate0, TrueGammaCandidate1);
3243  fHistoTruePi0FromOmegaInvMassPt[fiCut]->Fill(TruePi0->M(),TruePi0->Pt(),fWeightJetJetMC);
3244  fHistoTrueGammaFromOmegaPt[fiCut]->Fill(TrueGammaCandidate2->Pt(),fWeightJetJetMC);
3245  if(fDoMesonQA>0){
3246  fHistoTrueOmegaYPt[fiCut]->Fill(OmegaCandidate->Pt(),OmegaCandidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
3247  fHistoTrueOmegaAlphaPt[fiCut]->Fill(OmegaCandidate->Pt(),OmegaCandidate->GetAlpha(),fWeightJetJetMC);
3248  fHistoTrueOmegaEtaPhi[fiCut]->Fill(OmegaCandidate->Phi(),OmegaCandidate->Eta(),fWeightJetJetMC);
3249  fHistoTrueOmegaGammaAnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TMath::Pi() - OmegaCandidate->Angle(TrueGammaCandidate2->Vect()),fWeightJetJetMC);
3250  fHistoTrueOmegaPtGammaPt[fiCut]->Fill(OmegaCandidate->Pt(),TrueGammaCandidate2->Pt(),fWeightJetJetMC);
3251  fHistoTruePi0FromOmegaAlphaPt[fiCut]->Fill(TruePi0->Pt(),TruePi0->GetAlpha(),fWeightJetJetMC);
3252  fHistoTruePi0FromOmegaYPt[fiCut]->Fill(TruePi0->Pt(),TruePi0->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
3253  fHistoTruePi0FromOmegaEtaPhi[fiCut]->Fill(TruePi0->Phi(),TruePi0->Eta(),fWeightJetJetMC);
3255  fHistoTrueOmegaPi0AnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TMath::Pi() - OmegaCandidate->Angle(TruePi0->Vect()),fWeightJetJetMC);
3256  fHistoTruePi0GammaAnglePt[fiCut]->Fill(OmegaCandidate->Pt(),TruePi0->Angle(TrueGammaCandidate2->Vect()),fWeightJetJetMC);
3257  fHistoTrueOmegaPtPi0Pt[fiCut]->Fill(OmegaCandidate->Pt(),TruePi0->Pt(),fWeightJetJetMC);
3258  }
3259  delete TruePi0;
3260  TruePi0=0x0;
3261  }
3262  }
3263  }
3264  break;
3265  }
3266 }
3267 
3268 //______________________________________________________________________
3270 {
3271  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3272  if (AODMCTrackArray == NULL) return;
3273  Bool_t isTruePi0 = kFALSE;
3274  Bool_t isTrueOmega = kFALSE;
3275 
3276  switch(fReconMethod){
3277  // pcm-cal,cal
3278  case 0:
3279  {
3280  AliAODMCParticle *positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
3281  AliAODMCParticle *negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
3282 
3283  Int_t gamma0MCLabel = -1;
3284  Int_t gamma0MotherLabel = -1;
3285  if(!positiveMC||!negativeMC)
3286  return;
3287 
3288  if (TrueGammaCandidate0->IsTrueConvertedPhoton()){
3289  gamma0MCLabel = positiveMC->GetMother();
3290  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3291  gamma0MotherLabel=gammaMC0->GetMother();
3292  }
3293 
3294  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3295  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
3296  Int_t gamma1MotherLabel = -1;
3297 
3298  AliAODMCParticle * gammaMC1 = 0x0;
3299  if(gamma1MCLabel != -1){
3300  gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3301  // get gamma1MotherLabel
3302  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons it's the direct mother
3303  gamma1MotherLabel=gammaMC1->GetMother();
3304  }else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
3305  if (TrueGammaCandidate1->IsConversion()){
3306  AliAODMCParticle * gammaGrandMotherMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC1->GetMother()));
3307  gamma1MotherLabel=gammaGrandMotherMC1->GetMother();
3308  }else gamma1MotherLabel=gammaMC1->GetMother();
3309  }
3310  }
3311 
3312  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel &&
3313  ((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
3314  isTruePi0=kTRUE;
3315 
3316  // create pi0 and get pi0MotherLabel
3317  AliAODMCParticle * TruePi0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel));
3318  Int_t pi0MotherLabel = TruePi0->GetMother();
3319 
3320  if (!TrueGammaCandidate2->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3321  Int_t gamma2MCLabel = TrueGammaCandidate2->GetCaloPhotonMCLabel(0); // get most probable MC label
3322  Int_t gamma2MotherLabel = -1;
3323 
3324  AliAODMCParticle * gammaMC2 = 0x0;
3325  if(gamma2MCLabel != -1){
3326  gammaMC2 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma2MCLabel));
3327  // get mother label
3328  if (TrueGammaCandidate2->IsLargestComponentPhoton()){ // for photons it's the direct mother
3329  gamma2MotherLabel=gammaMC2->GetMother();
3330  }else if (TrueGammaCandidate2->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
3331  if (TrueGammaCandidate2->IsConversion()){
3332  AliAODMCParticle * gammaGrandMotherMC2 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC2->GetMother()));
3333  gamma2MotherLabel=gammaGrandMotherMC2->GetMother();
3334  }else gamma2MotherLabel=gammaMC2->GetMother();
3335  }
3336  }
3337 
3338  if(pi0MotherLabel==gamma2MotherLabel && ((AliAODMCParticle*)AODMCTrackArray->At(gamma2MotherLabel))->GetPdgCode() == 223){
3339  isTrueOmega = kTRUE;
3340  }
3341  if(isTrueOmega){
3342  fHistoTrueOmegaInvMassPt[fiCut]->Fill(OmegaCandidate->M(),OmegaCandidate->Pt(),fWeightJetJetMC);
3343  fHistoTruePi0FromOmegaInvMassPt[fiCut]->Fill(TruePi0->M(),TruePi0->Pt(),fWeightJetJetMC);
3344  }
3345  }
3346  }
3347  break;
3348  // pcm-cal,pcm
3349  case 1:
3350  {
3351  AliAODMCParticle *positive0MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
3352  AliAODMCParticle *negative0MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
3353 
3354  Int_t gamma0MCLabel = -1;
3355  Int_t gamma0MotherLabel = -1;
3356  if(!positive0MC||!negative0MC)
3357  return;
3358 
3359  if (TrueGammaCandidate0->IsTrueConvertedPhoton()){
3360  gamma0MCLabel = positive0MC->GetMother();
3361  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3362  gamma0MotherLabel=gammaMC0->GetMother();
3363  }
3364 
3365  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3366  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
3367  Int_t gamma1MotherLabel = -1;
3368 
3369  AliAODMCParticle * gammaMC1 = 0x0;
3370  if(gamma1MCLabel != -1){
3371  gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3372  // get gamma1MotherLabel
3373  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons it's the direct mother
3374  gamma1MotherLabel=gammaMC1->GetMother();
3375  }else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
3376  if (TrueGammaCandidate1->IsConversion()){
3377  AliAODMCParticle * gammaGrandMotherMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC1->GetMother()));
3378  gamma1MotherLabel=gammaGrandMotherMC1->GetMother();
3379  }else gamma1MotherLabel=gammaMC1->GetMother();
3380  }
3381  }
3382 
3383  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel &&
3384  ((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
3385  isTruePi0=kTRUE;
3386 
3387  // create pi0 and get pi0MotherLabel
3388  AliAODMCParticle * TruePi0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel));
3389  Int_t pi0MotherLabel = TruePi0->GetMother();
3390 
3391  // get gamma2MotherLabel
3392  AliAODMCParticle *positive2MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate2->GetMCLabelPositive()));
3393  AliAODMCParticle *negative2MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate2->GetMCLabelNegative()));
3394 
3395  Int_t gamma2MCLabel = -1;
3396  Int_t gamma2MotherLabel = -1;
3397  if(!positive2MC||!negative2MC)
3398  return;
3399 
3400  if (TrueGammaCandidate2->IsTrueConvertedPhoton()){
3401  gamma2MCLabel = positive2MC->GetMother();
3402  AliAODMCParticle * gammaMC2 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma2MCLabel));
3403  gamma2MotherLabel=gammaMC2->GetMother();
3404  }
3405 
3406  if(pi0MotherLabel==gamma2MotherLabel && ((AliAODMCParticle*)AODMCTrackArray->At(gamma2MotherLabel))->GetPdgCode() == 223){
3407  isTrueOmega = kTRUE;
3408  }
3409  if(isTrueOmega){
3410  fHistoTrueOmegaInvMassPt[fiCut]->Fill(OmegaCandidate->M(),OmegaCandidate->Pt(),fWeightJetJetMC);
3411  fHistoTruePi0FromOmegaInvMassPt[fiCut]->Fill(TruePi0->M(),TruePi0->Pt(),fWeightJetJetMC);
3412  }
3413  }
3414  }
3415  break;
3416  // cal-cal,cal
3417  case 2:
3418  {
3419  if (!TrueGammaCandidate0->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3420  Int_t gamma0MCLabel = TrueGammaCandidate0->GetCaloPhotonMCLabel(0); // get most probable MC label
3421  Int_t gamma0MotherLabel = -1;
3422 
3423  AliAODMCParticle * gammaMC0 = 0x0;
3424  if(gamma0MCLabel != -1){
3425  gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3426  // get gamma0MotherLabel
3427  if (TrueGammaCandidate0->IsLargestComponentPhoton()){ // for photons it's the direct mother
3428  gamma0MotherLabel=gammaMC0->GetMother();
3429  }else if (TrueGammaCandidate0->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
3430  if (TrueGammaCandidate0->IsConversion()){
3431  AliAODMCParticle * gammaGrandMotherMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC0->GetMother()));
3432  gamma0MotherLabel=gammaGrandMotherMC0->GetMother();
3433  }else gamma0MotherLabel=gammaMC0->GetMother();
3434  }
3435  }
3436 
3437  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3438  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
3439  Int_t gamma1MotherLabel = -1;
3440 
3441  AliAODMCParticle * gammaMC1 = 0x0;
3442  if(gamma1MCLabel != -1){
3443  gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3444  // get gamma1MotherLabel
3445  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons it's the direct mother
3446  gamma1MotherLabel=gammaMC1->GetMother();
3447  }else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
3448  if (TrueGammaCandidate1->IsConversion()){
3449  AliAODMCParticle * gammaGrandMotherMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC1->GetMother()));
3450  gamma1MotherLabel=gammaGrandMotherMC1->GetMother();
3451  }else gamma1MotherLabel=gammaMC1->GetMother();
3452  }
3453  }
3454 
3455  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel &&
3456  ((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
3457  isTruePi0=kTRUE;
3458 
3459  // create pi0 and get pi0MotherLabel
3460  AliAODMCParticle * TruePi0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel));
3461  Int_t pi0MotherLabel = TruePi0->GetMother();
3462 
3463  if (!TrueGammaCandidate2->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3464  Int_t gamma2MCLabel = TrueGammaCandidate2->GetCaloPhotonMCLabel(0); // get most probable MC label
3465  Int_t gamma2MotherLabel = -1;
3466 
3467  AliAODMCParticle * gammaMC2 = 0x0;
3468  if(gamma2MCLabel != -1){
3469  gammaMC2 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma2MCLabel));
3470  // get gamma2MotherLabel
3471  if (TrueGammaCandidate2->IsLargestComponentPhoton()){ // for photons it's the direct mother
3472  gamma2MotherLabel=gammaMC2->GetMother();
3473  }else if (TrueGammaCandidate2->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
3474  if (TrueGammaCandidate2->IsConversion()){
3475  AliAODMCParticle * gammaGrandMotherMC2 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC2->GetMother()));
3476  gamma2MotherLabel=gammaGrandMotherMC2->GetMother();
3477  }else gamma2MotherLabel=gammaMC2->GetMother();
3478  }
3479  }
3480 
3481  if(pi0MotherLabel==gamma2MotherLabel && ((AliAODMCParticle*)AODMCTrackArray->At(gamma2MotherLabel))->GetPdgCode() == 223){
3482  isTrueOmega = kTRUE;
3483  }
3484  if(isTrueOmega){
3485  fHistoTrueOmegaInvMassPt[fiCut]->Fill(OmegaCandidate->M(),OmegaCandidate->Pt(),fWeightJetJetMC);
3486  fHistoTruePi0FromOmegaInvMassPt[fiCut]->Fill(TruePi0->M(),TruePi0->Pt(),fWeightJetJetMC);
3487  }
3488  }
3489  }
3490  break;
3491  // cal-cal,pcm
3492  case 3:
3493  {
3494  if (!TrueGammaCandidate0->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3495  Int_t gamma0MCLabel = TrueGammaCandidate0->GetCaloPhotonMCLabel(0); // get most probable MC label
3496  Int_t gamma0MotherLabel = -1;
3497 
3498  AliAODMCParticle * gammaMC0 = 0x0;
3499  if(gamma0MCLabel != -1){
3500  gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3501  // get gamma0MotherLabel
3502  if (TrueGammaCandidate0->IsLargestComponentPhoton()){ // for photons it's the direct mother
3503  gamma0MotherLabel=gammaMC0->GetMother();
3504  }else if (TrueGammaCandidate0->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
3505  if (TrueGammaCandidate0->IsConversion()){
3506  AliAODMCParticle * gammaGrandMotherMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC0->GetMother()));
3507  gamma0MotherLabel=gammaGrandMotherMC0->GetMother();
3508  }else gamma0MotherLabel=gammaMC0->GetMother();
3509  }
3510  }
3511 
3512  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3513  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
3514  Int_t gamma1MotherLabel = -1;
3515 
3516  AliAODMCParticle * gammaMC1 = 0x0;
3517  if(gamma1MCLabel != -1){
3518  gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3519  // get gamma1MotherLabel
3520  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons it's the direct mother
3521  gamma1MotherLabel=gammaMC1->GetMother();
3522  }else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
3523  if (TrueGammaCandidate1->IsConversion()){
3524  AliAODMCParticle * gammaGrandMotherMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC1->GetMother()));
3525  gamma1MotherLabel=gammaGrandMotherMC1->GetMother();
3526  }else gamma1MotherLabel=gammaMC1->GetMother();
3527  }
3528  }
3529 
3530  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel &&
3531  ((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
3532  isTruePi0=kTRUE;
3533 
3534  // create pi0 and get pi0MotherLabel
3535  AliAODMCParticle * TruePi0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel));
3536  Int_t pi0MotherLabel = TruePi0->GetMother();
3537 
3538  // get gamma2MotherLabel
3539  AliAODMCParticle *positive2MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate2->GetMCLabelPositive()));
3540  AliAODMCParticle *negative2MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate2->GetMCLabelNegative()));
3541 
3542  Int_t gamma2MCLabel = -1;
3543  Int_t gamma2MotherLabel = -1;
3544  if(!positive2MC||!negative2MC)
3545  return;
3546 
3547  if (TrueGammaCandidate2->IsTrueConvertedPhoton()){
3548  gamma2MCLabel = positive2MC->GetMother();
3549  AliAODMCParticle * gammaMC2 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma2MCLabel));
3550  gamma2MotherLabel=gammaMC2->GetMother();
3551  }
3552 
3553  if(pi0MotherLabel==gamma2MotherLabel && ((AliAODMCParticle*)AODMCTrackArray->At(gamma2MotherLabel))->GetPdgCode() == 223){
3554  isTrueOmega = kTRUE;
3555  }
3556  if(isTrueOmega){
3557  fHistoTrueOmegaInvMassPt[fiCut]->Fill(OmegaCandidate->M(),OmegaCandidate->Pt(),fWeightJetJetMC);
3558  fHistoTruePi0FromOmegaInvMassPt[fiCut]->Fill(TruePi0->M(),TruePi0->Pt(),fWeightJetJetMC);
3559  }
3560  }
3561  }
3562  break;
3563  // pcm-pcm,cal
3564  case 4:
3565  {
3566  AliAODMCParticle *positive0MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
3567  AliAODMCParticle *negative0MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
3568 
3569  Int_t gamma0MCLabel = -1;
3570  Int_t gamma0MotherLabel = -1;
3571  if(!positive0MC||!negative0MC)
3572  return;
3573 
3574  if (TrueGammaCandidate0->IsTrueConvertedPhoton()){
3575  gamma0MCLabel = positive0MC->GetMother();
3576  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3577  gamma0MotherLabel=gammaMC0->GetMother();
3578  }
3579 
3580  AliAODMCParticle *positive1MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelPositive()));
3581  AliAODMCParticle *negative1MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelNegative()));
3582 
3583  Int_t gamma1MCLabel = -1;
3584  Int_t gamma1MotherLabel = -1;
3585  if(!positive1MC||!negative1MC)
3586  return;
3587 
3588  if (TrueGammaCandidate1->IsTrueConvertedPhoton()){
3589  gamma1MCLabel = positive1MC->GetMother();
3590  AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3591  gamma1MotherLabel=gammaMC1->GetMother();
3592  }
3593 
3594  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel &&
3595  ((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
3596  isTruePi0=kTRUE;
3597 
3598  // create pi0 and get pi0MotherLabel
3599  AliAODMCParticle * TruePi0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel));
3600  Int_t pi0MotherLabel = TruePi0->GetMother();
3601 
3602  if (!TrueGammaCandidate2->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
3603  Int_t gamma2MCLabel = TrueGammaCandidate2->GetCaloPhotonMCLabel(0); // get most probable MC label
3604  Int_t gamma2MotherLabel = -1;
3605 
3606  AliAODMCParticle * gammaMC2 = 0x0;
3607  if(gamma2MCLabel != -1){
3608  gammaMC2 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma2MCLabel));
3609  // get mother label
3610  if (TrueGammaCandidate2->IsLargestComponentPhoton()){ // for photons it's the direct mother
3611  gamma2MotherLabel=gammaMC2->GetMother();
3612  }else if (TrueGammaCandidate2->IsLargestComponentElectron()){ // for electrons it's either the direct mother or for conversions the grandmother
3613  if (TrueGammaCandidate2->IsConversion()){
3614  AliAODMCParticle * gammaGrandMotherMC2 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC2->GetMother()));
3615  gamma2MotherLabel=gammaGrandMotherMC2->GetMother();
3616  }else gamma2MotherLabel=gammaMC2->GetMother();
3617  }
3618  }
3619 
3620  if(pi0MotherLabel==gamma2MotherLabel && ((AliAODMCParticle*)AODMCTrackArray->At(gamma2MotherLabel))->GetPdgCode() == 223){
3621  isTrueOmega = kTRUE;
3622  }
3623  if(isTrueOmega){
3624  fHistoTrueOmegaInvMassPt[fiCut]->Fill(OmegaCandidate->M(),OmegaCandidate->Pt(),fWeightJetJetMC);
3625  fHistoTruePi0FromOmegaInvMassPt[fiCut]->Fill(TruePi0->M(),TruePi0->Pt(),fWeightJetJetMC);
3626  }
3627  }
3628  }
3629  break;
3630  // pcm-pcm,pcm
3631  case 5:
3632  {
3633  AliAODMCParticle *positive0MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
3634  AliAODMCParticle *negative0MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
3635 
3636  Int_t gamma0MCLabel = -1;
3637  Int_t gamma0MotherLabel = -1;
3638  if(!positive0MC||!negative0MC)
3639  return;
3640 
3641  if (TrueGammaCandidate0->IsTrueConvertedPhoton()){
3642  gamma0MCLabel = positive0MC->GetMother();
3643  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3644  gamma0MotherLabel=gammaMC0->GetMother();
3645  }
3646 
3647  AliAODMCParticle *positive1MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelPositive()));
3648  AliAODMCParticle *negative1MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelNegative()));
3649 
3650  Int_t gamma1MCLabel = -1;
3651  Int_t gamma1MotherLabel = -1;
3652  if(!positive1MC||!negative1MC)
3653  return;
3654 
3655  if (TrueGammaCandidate1->IsTrueConvertedPhoton()){
3656  gamma1MCLabel = positive1MC->GetMother();
3657  AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3658  gamma1MotherLabel=gammaMC1->GetMother();
3659  }
3660 
3661  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel &&
3662  ((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
3663  isTruePi0=kTRUE;
3664 
3665  // create pi0 and get pi0MotherLabel
3666  AliAODMCParticle * TruePi0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel));
3667  Int_t pi0MotherLabel = TruePi0->GetMother();
3668 
3669  AliAODMCParticle *positive2MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate2->GetMCLabelPositive()));
3670  AliAODMCParticle *negative2MC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate2->GetMCLabelNegative()));
3671 
3672  Int_t gamma2MCLabel = -1;
3673  Int_t gamma2MotherLabel = -1;
3674  if(!positive2MC||!negative2MC)
3675  return;
3676 
3677  if (TrueGammaCandidate2->IsTrueConvertedPhoton()){
3678  gamma2MCLabel = positive2MC->GetMother();
3679  AliAODMCParticle * gammaMC2 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma2MCLabel));
3680  gamma2MotherLabel=gammaMC2->GetMother();
3681  }
3682 
3683  if(pi0MotherLabel==gamma2MotherLabel && ((AliAODMCParticle*)AODMCTrackArray->At(gamma2MotherLabel))->GetPdgCode() == 223){
3684  isTrueOmega = kTRUE;
3685  }
3686  if(isTrueOmega){
3687  fHistoTrueOmegaInvMassPt[fiCut]->Fill(OmegaCandidate->M(),OmegaCandidate->Pt(),fWeightJetJetMC);
3688  fHistoTruePi0FromOmegaInvMassPt[fiCut]->Fill(TruePi0->M(),TruePi0->Pt(),fWeightJetJetMC);
3689  }
3690  }
3691  }
3692  break;
3693  }
3694 }
3695 
3696 //________________________________________________________________________
3698 
3699  //zbin and mbin from pi0handler
3700  Int_t Pi0zbin = fBGPi0Handler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3701  Int_t Pi0mbin = 0;
3702 
3703  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3705  }else {
3706  Pi0mbin = fBGPi0Handler[fiCut]->GetMultiplicityBinIndex(fPi0Candidates->GetEntries());
3707  }
3708 
3710 
3711  // background generation using pi0s and gammas
3712  // pi0 from handler, gamma from current event
3713  for(Int_t previous=0;previous<fBGPi0Handler[fiCut]->GetNBGEvents();previous++){
3714  AliGammaConversionMotherAODVector* previousPi0s = fBGPi0Handler[fiCut]->GetBGGoodMesons(Pi0zbin,Pi0mbin,previous);
3715  if(fMoveParticleAccordingToVertex == kTRUE){
3716  bgEvent1Vertex = fBGPi0Handler[fiCut]->GetBGEventVertex(Pi0zbin,Pi0mbin,previous);
3717  }
3718  for(Int_t iPi0=0;iPi0<previousPi0s->size();iPi0++){
3719  AliAODConversionMother BGpi0cand = (AliAODConversionMother)(*(previousPi0s->at(iPi0)));
3720  if(fMoveParticleAccordingToVertex == kTRUE && bgEvent1Vertex){
3721  MoveParticleAccordingToVertex(&BGpi0cand, bgEvent1Vertex);
3722  }
3723  if(fReconMethod % 2 == 0){ //EMCAL gamma
3724  for(Int_t iCurrent3=0;iCurrent3<fClusterCandidates->GetEntries();iCurrent3++){
3725  AliAODConversionPhoton *gamma2 = dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(iCurrent3));
3726  if(gamma2 == NULL || !(gamma2->GetIsCaloPhoton())) continue;
3727  AliAODConversionMother *BGOmegacand = new AliAODConversionMother(&BGpi0cand,gamma2);
3728  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedPiZeroGammaAngle(BGOmegacand, &BGpi0cand, gamma2, fDoPiZeroGammaAngleCut, fmaxfit, flowerFactor, fupperFactor)){
3729  fHistoDiffPi0SameGammaBackInvMassPt[fiCut]->Fill(BGOmegacand->M(),BGOmegacand->Pt(),fWeightJetJetMC);
3730  }
3731  delete BGOmegacand;
3732  BGOmegacand = 0x0;
3733  }
3734  } else{ //PCM gamma
3735  for(Int_t iCurrent3=0;iCurrent3<fGammaCandidates->GetEntries();iCurrent3++){
3736  AliAODConversionPhoton *gamma2 = dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(iCurrent3));
3737  if(gamma2 == NULL) continue;
3738  AliAODConversionMother *BGOmegacand = new AliAODConversionMother(&BGpi0cand,gamma2);
3739  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedPiZeroGammaAngle(BGOmegacand, &BGpi0cand, gamma2, fDoPiZeroGammaAngleCut, fmaxfit, flowerFactor, fupperFactor)){
3740  fHistoDiffPi0SameGammaBackInvMassPt[fiCut]->Fill(BGOmegacand->M(),BGOmegacand->Pt(),fWeightJetJetMC);
3741  }
3742  delete BGOmegacand;
3743  BGOmegacand = 0x0;
3744  }
3745  }
3746  }
3747  }
3748 
3749  //pi0 from current event, gamma from handler
3750  //zbin and mbin from clushandler
3751  Int_t Cluszbin = fBGClusHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3752  Int_t Clusmbin = 0;
3753 
3754  if(((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->UseTrackMultiplicity()){
3756  }else {
3757  Clusmbin = fBGClusHandler[fiCut]->GetMultiplicityBinIndex(fClusterCandidates->GetEntries());
3758  }
3759 
3760  //zbin and mbin from gammahandler
3761  Int_t Gammazbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3762  Int_t Gammambin = 0;
3763 
3764  if(((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->UseTrackMultiplicity()){
3766  }else {
3767  Gammambin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
3768  }
3769 
3770  for(Int_t iCurrent=0;iCurrent<fPi0Candidates->GetEntries();iCurrent++){
3771  AliAODConversionMother* BGpi0cand = dynamic_cast<AliAODConversionMother*>(fPi0Candidates->At(iCurrent));
3772  if(BGpi0cand == NULL) continue;
3773  if(fReconMethod % 2 == 0){ //EMCAL gamma
3774  for(Int_t previous=0;previous<fBGClusHandler[fiCut]->GetNBGEvents();previous++){
3775  AliGammaConversionAODVector *previousclusters = fBGClusHandler[fiCut]->GetBGGoodV0s(Cluszbin,Clusmbin,previous);
3776  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3777  bgEvent1Vertex = fBGClusHandler[fiCut]->GetBGEventVertex(Cluszbin,Clusmbin,previous);
3778  }
3779  for(Int_t igamma2=0;igamma2<previousclusters->size();igamma2++){
3780  AliAODConversionPhoton gamma2 = (AliAODConversionPhoton)(*(previousclusters->at(igamma2)));
3781  if(fMoveParticleAccordingToVertex == kTRUE && bgEvent1Vertex){
3782  MoveParticleAccordingToVertex(&gamma2,bgEvent1Vertex);
3783  }
3784  AliAODConversionMother *BGOmegacand = new AliAODConversionMother(BGpi0cand,&gamma2);
3785  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedPiZeroGammaAngle(BGOmegacand, BGpi0cand, &gamma2, fDoPiZeroGammaAngleCut, fmaxfit, flowerFactor, fupperFactor)){
3786  fHistoSamePi0DiffGammaBackInvMassPt[fiCut]->Fill(BGOmegacand->M(),BGOmegacand->Pt(),fWeightJetJetMC);
3787  }
3788  delete BGOmegacand;
3789  BGOmegacand = 0x0;
3790  }
3791  }
3792  } else{ //PCM gamma
3793  for(Int_t previous=0;previous<fBGHandler[fiCut]->GetNBGEvents();previous++){
3794  AliGammaConversionAODVector *previousV0s = fBGHandler[fiCut]->GetBGGoodV0s(Gammazbin,Gammambin,previous);
3795  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3796  bgEvent1Vertex = fBGHandler[fiCut]->GetBGEventVertex(Gammazbin,Gammambin,previous);
3797  }
3798  for(Int_t igamma2=0;igamma2<previousV0s->size();igamma2++){
3799  AliAODConversionPhoton gamma2 = (AliAODConversionPhoton)(*(previousV0s->at(igamma2)));
3800  if(fMoveParticleAccordingToVertex == kTRUE && bgEvent1Vertex){
3801  MoveParticleAccordingToVertex(&gamma2,bgEvent1Vertex);
3802  }
3803  AliAODConversionMother *BGOmegacand = new AliAODConversionMother(BGpi0cand,&gamma2);
3804  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedPiZeroGammaAngle(BGOmegacand, BGpi0cand, &gamma2, fDoPiZeroGammaAngleCut, fmaxfit, flowerFactor, fupperFactor)){
3805  fHistoSamePi0DiffGammaBackInvMassPt[fiCut]->Fill(BGOmegacand->M(),BGOmegacand->Pt(),fWeightJetJetMC);
3806  }
3807  delete BGOmegacand;
3808  BGOmegacand = 0x0;
3809  }
3810  }
3811  }
3812  }
3813 }
3814 
3815 //________________________________________________________________________
3817  //see header file for documentation
3818 
3819  Double_t dx = vertex->fX - fInputEvent->GetPrimaryVertex()->GetX();
3820  Double_t dy = vertex->fY - fInputEvent->GetPrimaryVertex()->GetY();
3821  Double_t dz = vertex->fZ - fInputEvent->GetPrimaryVertex()->GetZ();
3822 
3823  Double_t movedPlace[3] = {particle->GetConversionX() - dx,particle->GetConversionY() - dy,particle->GetConversionZ() - dz};
3824  particle->SetConversionPoint(movedPlace);
3825 }
3826 //________________________________________________________________________
3828  //see header file for documentation
3829 
3830  Double_t dx = vertex->fX - fInputEvent->GetPrimaryVertex()->GetX();
3831  Double_t dy = vertex->fY - fInputEvent->GetPrimaryVertex()->GetY();
3832  Double_t dz = vertex->fZ - fInputEvent->GetPrimaryVertex()->GetZ();
3833 
3834  Double_t movedPlace[3] = {particle->GetProductionX() - dx,particle->GetProductionY() - dy,particle->GetProductionZ() - dz};
3835  particle->SetProductionPoint(movedPlace);
3836 }
3837 //________________________________________________________________________
3839  //see header file for documentation
3840  if(fPi0Candidates->GetEntries()>0){
3841  if(fReconMethod % 2 == 1){ //single gamma is PCM
3842  if(((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->UseTrackMultiplicity()){
3843  fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),fEventPlaneAngle);
3844  }else { // means we use #V0s for multiplicity
3845  fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGammaCandidates->GetEntries(),fEventPlaneAngle);
3846  }
3847  } else{ //single gamma is EMCAL
3848  if(((AliConversionMesonCuts*)fNeutralPionCutArray->At(fiCut))->UseTrackMultiplicity()){
3849  fBGClusHandler[fiCut]->AddEvent(fClusterCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),fEventPlaneAngle);
3850  }else {
3851  fBGClusHandler[fiCut]->AddEvent(fClusterCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fClusterCandidates->GetEntries(),fEventPlaneAngle);
3852  }
3853  }
3854  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3855  fBGPi0Handler[fiCut]->AddMesonEvent(fPi0Candidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),0);
3856  }else {
3857  fBGPi0Handler[fiCut]->AddMesonEvent(fPi0Candidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fPi0Candidates->GetEntries(),0);
3858  }
3859  }
3860 }
3861 
3862 //________________________________________________________________________
3864 
3865  // Relabeling For AOD Event
3866  // ESDiD -> AODiD
3867  // MCLabel -> AODMCLabel
3868 
3869  if(mode){
3870  fMCStackPos = new Int_t[fReaderGammas->GetEntries()];
3871  fMCStackNeg = new Int_t[fReaderGammas->GetEntries()];
3872  fESDArrayPos = new Int_t[fReaderGammas->GetEntries()];
3873  fESDArrayNeg = new Int_t[fReaderGammas->GetEntries()];
3874  }
3875 
3876  for(Int_t iGamma = 0;iGamma<fReaderGammas->GetEntries();iGamma++){
3877  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*)