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