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