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