AliPhysics  9c7580a (9c7580a)
AliAnalysisTaskHeavyNeutralMesonToGG.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2020, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: Friederike Bock, Sandro Wenzel *
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  fCorrTaskSetting(""),
69  fBGHandler(NULL),
70  fBGHandlerRP(NULL),
71  fBGClusHandler(NULL),
72  fBGClusHandlerRP(NULL),
73  fInputEvent(NULL),
74  fMCEvent(NULL),
75  fCutFolder(NULL),
76  fESDList(NULL),
77  fBackList(NULL),
78  fMotherList(NULL),
79  fTrueList(NULL),
80  fMCList(NULL),
81  fOutputContainer(NULL),
82  fReaderGammas(NULL),
83  fGammaCandidates(NULL),
84  fClusterCandidates(NULL),
85  fEventCutArray(NULL),
86  fEventCuts(NULL),
87  fCutArray(NULL),
88  fConversionCuts(NULL),
89  fClusterCutArray(NULL),
90  fCaloPhotonCuts(NULL),
91  fMesonCutArray(NULL),
92  fMesonCuts(NULL),
93  fHistoConvGammaPt(NULL),
94  fHistoMotherInvMassPt(NULL),
95  fHistoMotherMatchedInvMassPt(NULL),
96  fSparseMotherInvMassPtZM(NULL),
97  fHistoMotherBackInvMassPt(NULL),
98  fSparseMotherBackInvMassPtZM(NULL),
99  fHistoMotherMesonPtY(NULL),
100  fHistoMotherMesonPtAlpha(NULL),
101  fHistoMotherMesonPtOpenAngle(NULL),
102  fHistoMotherMesonConvPhotonEtaPhi(NULL),
103  fHistoClusGammaPt(NULL),
104  fHistoClusGammaE(NULL),
105  fHistoClusOverlapHeadersGammaPt(NULL),
106  fHistoClusAllHeadersGammaPt(NULL),
107  fHistoClusRejectedHeadersGammaPt(NULL),
108  fHistoMCHeaders(NULL),
109  fHistoMCMesonPt(NULL),
110  fHistoMCMesonWOWeightPt(NULL),
111  fHistoMCMesonWOEvtWeightPt(NULL),
112  fHistoMCMesonInAccPt(NULL),
113  fHistoMCMesonWOWeightInAccPt(NULL),
114  fHistoMCMesonWOEvtWeightInAccPt(NULL),
115  fHistoMCMesonPtY(NULL),
116  fHistoMCMesonPtAlpha(NULL),
117  fHistoMCMesonPtJetPt(NULL),
118  fHistoTrueMesonInvMassPt(NULL),
119  fHistoTrueMesonMatchedInvMassPt(NULL),
120  fHistoTrueMesonCaloPhotonInvMassPt(NULL),
121  fHistoTrueMesonCaloConvertedPhotonInvMassPt(NULL),
122  fHistoTrueMesonCaloMixedPhotonConvPhotonInvMassPt(NULL),
123  fHistoTrueMesonCaloConvertedPhotonMatchedInvMassPt(NULL),
124  fHistoTrueMesonCaloElectronInvMassPt(NULL),
125  fHistoTrueMesonCaloMergedClusterInvMassPt(NULL),
126  fHistoTrueMesonCaloMergedClusterPartConvInvMassPt(NULL),
127  fHistoTruePrimaryMesonInvMassPt(NULL),
128  fHistoTruePrimaryMesonW0WeightingInvMassPt(NULL),
129  fProfileTruePrimaryMesonWeightsInvMassPt(NULL),
130  fHistoTruePrimaryMesonMCPtResolPt(NULL),
131  fHistoTrueMotherMesonConvPhotonEtaPhi(NULL),
132  fHistoTrueBckGGInvMassPt(NULL),
133  fHistoTrueBckFullMesonContainedInOneClusterInvMassPt(NULL),
134  fHistoTrueBckAsymEClustersInvMassPt(NULL),
135  fHistoTrueBckContInvMassPt(NULL),
136  fHistoTrueMesonPtY(NULL),
137  fHistoTrueMesonPtAlpha(NULL),
138  fHistoTrueMesonPtOpenAngle(NULL),
139  fHistoTrueConvGammaPt(NULL),
140  fHistoTruePrimaryConvGammaPt(NULL),
141  fHistoTrueClusGammaPt(NULL),
142  fHistoTrueClusConvGammaPt(NULL),
143  fHistoTrueClusConvGammaFullyPt(NULL),
144  fHistoTrueNLabelsInClusPt(NULL),
145  fHistoTruePrimaryClusGammaPt(NULL),
146  fHistoTruePrimaryClusConvGammaPt(NULL),
147  fVectorRecTrueMesons(0),
148  fHistoDoubleCountTrueMesonInvMassPt(NULL),
149  fHistoDoubleCountTrueConvGammaRPt(NULL),
150  fHistoDoubleCountTrueClusterGammaPt(NULL),
151  fVectorDoubleCountTrueMesons(0),
152  fVectorDoubleCountTrueConvGammas(0),
153  fVectorDoubleCountTrueClusterGammas(0),
154  fHistoMultipleCountTrueMeson(NULL),
155  fHistoMultipleCountTrueConvGamma(NULL),
156  fHistoMultipleCountTrueClusterGamma(NULL),
157  fMapMultipleCountTrueMesons(),
158  fMapMultipleCountTrueConvGammas(),
159  fMapMultipleCountTrueClusterGammas(),
160  fHistoNEvents(NULL),
161  fHistoNEventsWOWeight(NULL),
162  fHistoNGoodESDTracks(NULL),
163  fHistoVertexZ(NULL),
164  fHistoVertexX(NULL),
165  fHistoVertexY(NULL),
166  fHistoNGammaConvCandidates(NULL),
167  fHistoNGammaCaloCandidates(NULL),
168  fHistoSPDClusterTrackletBackground(NULL),
169  fHistoNV0Tracks(NULL),
170  fProfileEtaShift(NULL),
171  fProfileJetJetXSection(NULL),
172  fHistoJetJetNTrials(NULL),
173  fEventPlaneAngle(-100),
174  fRandom(0),
175  fNGammaCandidates(0),
176  fUnsmearedPx(NULL),
177  fUnsmearedPy(NULL),
178  fUnsmearedPz(NULL),
179  fUnsmearedE(NULL),
180  fMCEventPos(NULL),
181  fMCEventNeg(NULL),
182  fESDArrayPos(NULL),
183  fESDArrayNeg(NULL),
184  fnCuts(0),
185  fiCut(0),
186  fMoveParticleAccordingToVertex(kTRUE),
187  fIsHeavyIon(0),
188  fDoLightOutput(kFALSE),
189  fMesonRecoMode(-1),
190  fMesonType(-1),
191  fMesonPDG(0),
192  fMesonInvMassMin(0),
193  fMesonInvMassMax(0),
194  fMesonInvMassNBins(0),
195  fMesonInvMassWindow(NULL),
196  fDoMesonQA(0),
197  fDoPhotonQA(0),
198  fDoClusterQA(0),
199  fIsFromDesiredHeader(kTRUE),
200  fIsOverlappingWithOtherHeader(kFALSE),
201  fIsMC(0),
202  fDoTHnSparse(kTRUE),
203  fSetPlotHistsExtQA(kFALSE),
204  fWeightJetJetMC(1),
205  fDoConvGammaShowerShapeTree(kFALSE),
206  fEnableSortForClusMC(kFALSE),
207  fDoPrimaryTrackMatching(kFALSE),
208  fDoInvMassShowerShapeTree(kFALSE),
209  tBrokenFiles(NULL),
210  fFileNameBroken(NULL),
211  fAllowOverlapHeaders(kTRUE)
212 {
213 
214 }
215 
216 //________________________________________________________________________
218  AliAnalysisTaskSE(name),
219  fV0Reader(NULL),
220  fV0ReaderName("V0ReaderV1"),
221  fCorrTaskSetting(""),
222  fBGHandler(NULL),
223  fBGHandlerRP(NULL),
224  fBGClusHandler(NULL),
225  fBGClusHandlerRP(NULL),
226  fInputEvent(NULL),
227  fMCEvent(NULL),
228  fCutFolder(NULL),
229  fESDList(NULL),
230  fBackList(NULL),
231  fMotherList(NULL),
232  fTrueList(NULL),
233  fMCList(NULL),
234  fOutputContainer(0),
235  fReaderGammas(NULL),
236  fGammaCandidates(NULL),
237  fClusterCandidates(NULL),
238  fEventCutArray(NULL),
239  fEventCuts(NULL),
240  fCutArray(NULL),
241  fConversionCuts(NULL),
242  fClusterCutArray(NULL),
243  fCaloPhotonCuts(NULL),
244  fMesonCutArray(NULL),
245  fMesonCuts(NULL),
246  fHistoConvGammaPt(NULL),
247  fHistoMotherInvMassPt(NULL),
248  fHistoMotherMatchedInvMassPt(NULL),
249  fSparseMotherInvMassPtZM(NULL),
250  fHistoMotherBackInvMassPt(NULL),
251  fSparseMotherBackInvMassPtZM(NULL),
252  fHistoMotherMesonPtY(NULL),
253  fHistoMotherMesonPtAlpha(NULL),
254  fHistoMotherMesonPtOpenAngle(NULL),
255  fHistoMotherMesonConvPhotonEtaPhi(NULL),
256  fHistoClusGammaPt(NULL),
257  fHistoClusGammaE(NULL),
258  fHistoClusOverlapHeadersGammaPt(NULL),
259  fHistoClusAllHeadersGammaPt(NULL),
260  fHistoClusRejectedHeadersGammaPt(NULL),
261  fHistoMCHeaders(NULL),
262  fHistoMCMesonPt(NULL),
263  fHistoMCMesonWOWeightPt(NULL),
264  fHistoMCMesonWOEvtWeightPt(NULL),
265  fHistoMCMesonInAccPt(NULL),
266  fHistoMCMesonWOWeightInAccPt(NULL),
267  fHistoMCMesonWOEvtWeightInAccPt(NULL),
268  fHistoMCMesonPtY(NULL),
269  fHistoMCMesonPtAlpha(NULL),
270  fHistoMCMesonPtJetPt(NULL),
271  fHistoTrueMesonInvMassPt(NULL),
272  fHistoTrueMesonMatchedInvMassPt(NULL),
273  fHistoTrueMesonCaloPhotonInvMassPt(NULL),
274  fHistoTrueMesonCaloConvertedPhotonInvMassPt(NULL),
275  fHistoTrueMesonCaloMixedPhotonConvPhotonInvMassPt(NULL),
276  fHistoTrueMesonCaloConvertedPhotonMatchedInvMassPt(NULL),
277  fHistoTrueMesonCaloElectronInvMassPt(NULL),
278  fHistoTrueMesonCaloMergedClusterInvMassPt(NULL),
279  fHistoTrueMesonCaloMergedClusterPartConvInvMassPt(NULL),
280  fHistoTruePrimaryMesonInvMassPt(NULL),
281  fHistoTruePrimaryMesonW0WeightingInvMassPt(NULL),
282  fProfileTruePrimaryMesonWeightsInvMassPt(NULL),
283  fHistoTruePrimaryMesonMCPtResolPt(NULL),
284  fHistoTrueMotherMesonConvPhotonEtaPhi(NULL),
285  fHistoTrueBckGGInvMassPt(NULL),
286  fHistoTrueBckFullMesonContainedInOneClusterInvMassPt(NULL),
287  fHistoTrueBckAsymEClustersInvMassPt(NULL),
288  fHistoTrueBckContInvMassPt(NULL),
289  fHistoTrueMesonPtY(NULL),
290  fHistoTrueMesonPtAlpha(NULL),
291  fHistoTrueMesonPtOpenAngle(NULL),
292  fHistoTrueConvGammaPt(NULL),
293  fHistoTruePrimaryConvGammaPt(NULL),
294  fHistoTrueClusGammaPt(NULL),
295  fHistoTrueClusConvGammaPt(NULL),
296  fHistoTrueClusConvGammaFullyPt(NULL),
297  fHistoTrueNLabelsInClusPt(NULL),
298  fHistoTruePrimaryClusGammaPt(NULL),
299  fHistoTruePrimaryClusConvGammaPt(NULL),
300  fVectorRecTrueMesons(0),
301  fHistoDoubleCountTrueMesonInvMassPt(NULL),
302  fHistoDoubleCountTrueConvGammaRPt(NULL),
303  fHistoDoubleCountTrueClusterGammaPt(NULL),
304  fVectorDoubleCountTrueMesons(0),
305  fVectorDoubleCountTrueConvGammas(0),
306  fVectorDoubleCountTrueClusterGammas(0),
307  fHistoMultipleCountTrueMeson(NULL),
308  fHistoMultipleCountTrueConvGamma(NULL),
309  fHistoMultipleCountTrueClusterGamma(NULL),
310  fMapMultipleCountTrueMesons(),
311  fMapMultipleCountTrueConvGammas(),
312  fMapMultipleCountTrueClusterGammas(),
313  fHistoNEvents(NULL),
314  fHistoNEventsWOWeight(NULL),
315  fHistoNGoodESDTracks(NULL),
316  fHistoVertexZ(NULL),
317  fHistoVertexX(NULL),
318  fHistoVertexY(NULL),
319  fHistoNGammaConvCandidates(NULL),
320  fHistoNGammaCaloCandidates(NULL),
321  fHistoSPDClusterTrackletBackground(NULL),
322  fHistoNV0Tracks(NULL),
323  fProfileEtaShift(NULL),
324  fProfileJetJetXSection(NULL),
325  fHistoJetJetNTrials(NULL),
326  fEventPlaneAngle(-100),
327  fRandom(0),
328  fNGammaCandidates(0),
329  fUnsmearedPx(NULL),
330  fUnsmearedPy(NULL),
331  fUnsmearedPz(NULL),
332  fUnsmearedE(NULL),
333  fMCEventPos(NULL),
334  fMCEventNeg(NULL),
335  fESDArrayPos(NULL),
336  fESDArrayNeg(NULL),
337  fnCuts(0),
338  fiCut(0),
339  fMoveParticleAccordingToVertex(kTRUE),
340  fIsHeavyIon(0),
341  fDoLightOutput(kFALSE),
342  fMesonRecoMode(-1),
343  fMesonType(-1),
344  fMesonPDG(0),
345  fMesonInvMassMin(0),
346  fMesonInvMassMax(0),
347  fMesonInvMassNBins(0),
348  fMesonInvMassWindow(NULL),
349  fDoMesonQA(0),
350  fDoPhotonQA(0),
351  fDoClusterQA(0),
352  fIsFromDesiredHeader(kTRUE),
353  fIsOverlappingWithOtherHeader(kFALSE),
354  fIsMC(0),
355  fDoTHnSparse(kTRUE),
356  fSetPlotHistsExtQA(kFALSE),
357  fWeightJetJetMC(1),
358  fDoConvGammaShowerShapeTree(kFALSE),
359  fEnableSortForClusMC(kFALSE),
360  fDoPrimaryTrackMatching(kFALSE),
361  fDoInvMassShowerShapeTree(kFALSE),
362  tBrokenFiles(NULL),
363  fFileNameBroken(NULL),
364  fAllowOverlapHeaders(kTRUE)
365 {
366  // Define output slots here
367  DefineOutput(1, TList::Class());
368 }
369 
371 {
372  if(fGammaCandidates){
373  delete fGammaCandidates;
374  fGammaCandidates = 0x0;
375  }
376  if(fClusterCandidates){
377  delete fClusterCandidates;
378  fClusterCandidates = 0x0;
379  }
380  if(fBGHandler){
381  delete[] fBGHandler;
382  fBGHandler = 0x0;
383  }
384  if(fBGHandlerRP){
385  delete[] fBGHandlerRP;
386  fBGHandlerRP = 0x0;
387  }
388  if(fBGClusHandler){
389  delete[] fBGClusHandler;
390  fBGClusHandler = 0x0;
391  }
392  if(fBGClusHandlerRP){
393  delete[] fBGClusHandlerRP;
394  fBGClusHandlerRP = 0x0;
395  }
396 }
397 //___________________________________________________________
399 
400  const Int_t nDim = 4;
401  Int_t nBins[nDim] = {800,300,7,4};
402  Double_t xMin[nDim] = {0,0, 0,0};
403  Double_t xMax[nDim] = {0.8,30,7,4};
404 
405  if(fDoTHnSparse){
406  fSparseMotherInvMassPtZM = new THnSparseF*[fnCuts];
407  fSparseMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
408  }
409 
412 
415 
416  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
417  if (((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
418  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
419  TString cutstringConvGamma = "";
420  TString cutstringCaloGamma = "";
421  if (fMesonRecoMode < 2) cutstringConvGamma = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
422  if (fMesonRecoMode > 0) cutstringCaloGamma = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
423  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
424 
425  TString fullCutString = "";
426  if (fMesonRecoMode == 0) fullCutString = Form("%i_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(), cutstringConvGamma.Data(), cutstringMeson.Data());
427  else if (fMesonRecoMode == 1) fullCutString = Form("%i_%s_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringCaloGamma.Data(), cutstringMeson.Data());
428  else if (fMesonRecoMode == 2) fullCutString = Form("%i_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(), cutstringCaloGamma.Data(), cutstringMeson.Data());
429 
430  Int_t collisionSystem = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(0,1));
431  Int_t centMin = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(1,1));
432  Int_t centMax = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(2,1));
433 
434  if( collisionSystem == 1 || collisionSystem == 2 ||
435  collisionSystem == 5 || collisionSystem == 8 ||
436  collisionSystem == 9){
437  centMin = centMin*10;
438  centMax = centMax*10;
439  if(centMax ==0 && centMax!=centMin) centMax=100;
440  }else if(collisionSystem == 3 || collisionSystem == 6){
441  centMin = centMin*5;
442  centMax = centMax*5;
443  }else if(collisionSystem == 4 || collisionSystem == 7){
444  centMin = ((centMin*5)+45);
445  centMax = ((centMax*5)+45);
446  }
447 
448  if(fDoTHnSparse){
449  fBackList[iCut] = new TList();
450  fBackList[iCut]->SetName(Form("%s Back histograms",fullCutString.Data()));
451  fBackList[iCut]->SetOwner(kTRUE);
452  fCutFolder[iCut]->Add(fBackList[iCut]);
453 
454  fSparseMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_m", "Back_Back_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
455  fBackList[iCut]->Add(fSparseMotherBackInvMassPtZM[iCut]);
456 
457  fMotherList[iCut] = new TList();
458  fMotherList[iCut]->SetName(Form("%s Mother histograms",fullCutString.Data()));
459  fMotherList[iCut]->SetOwner(kTRUE);
460  fCutFolder[iCut]->Add(fMotherList[iCut]);
461 
462  fSparseMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_m", "Back_Mother_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
463  fMotherList[iCut]->Add(fSparseMotherInvMassPtZM[iCut]);
464  }
465 
466  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
467  fBGHandler[iCut] = new AliGammaConversionAODBGHandler( collisionSystem,centMin,centMax,
468  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents(),
469  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseTrackMultiplicity(),
470  2,8,5);
471  fBGClusHandler[iCut] = new AliGammaConversionAODBGHandler( collisionSystem,centMin,centMax,
472  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents(),
473  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseTrackMultiplicity(),
474  2,8,5);
475  fBGHandlerRP[iCut] = NULL;
476  }else{
478  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity(),
479  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents());
481  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity(),
482  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents());
483  fBGHandler[iCut] = NULL;
484  }
485  }
486  }
487 }
488 
489 //________________________________________________________________________
491 
492  fV0Reader = (AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
493  if(!fV0Reader){printf("Error: No V0 Reader");return;}// GetV0Reader
494  if (fIsMC == 2){
495  fDoClusterQA = 0;
496  fDoTHnSparse = kFALSE;
497  } else if (fIsMC == 3){
498  fDoTHnSparse = kFALSE;
499  }
500  // Create histograms
501  if(fOutputContainer != NULL){
502  delete fOutputContainer;
503  fOutputContainer = NULL;
504  }
505  if(fOutputContainer == NULL){
506  fOutputContainer = new TList();
507  fOutputContainer->SetOwner(kTRUE);
508  }
509 
510  // Array of current cut's gammas
511  fGammaCandidates = new TList();
512  fClusterCandidates = new TList();
513  fClusterCandidates->SetOwner(kTRUE);
514 
515  fCutFolder = new TList*[fnCuts];
516  fESDList = new TList*[fnCuts];
517 
518  if(fDoTHnSparse){
519  fBackList = new TList*[fnCuts];
520  fMotherList = new TList*[fnCuts];
521  }
522 
523  fHistoNEvents = new TH1F*[fnCuts];
524  if (fIsMC > 1){
525  fHistoNEventsWOWeight = new TH1F*[fnCuts];
526  }
527  if (fIsMC == 2){
528  fProfileJetJetXSection = new TProfile*[fnCuts];
529  fHistoJetJetNTrials = new TH1F*[fnCuts];
530  }
531  fHistoNGoodESDTracks = new TH1F*[fnCuts];
532  fHistoVertexZ = new TH1F*[fnCuts];
533  if(!fDoLightOutput){
534  fHistoVertexX = new TH1F*[fnCuts];
535  fHistoVertexY = new TH1F*[fnCuts];
536  }
537  if (fMesonRecoMode < 2) fHistoNGammaConvCandidates = new TH1F*[fnCuts];
538  if(fIsHeavyIon==2) fProfileEtaShift = new TProfile*[fnCuts];
539  if(!fDoLightOutput){
541  fHistoNV0Tracks = new TH1F*[fnCuts];
542  if (fMesonRecoMode < 2)
543  fHistoConvGammaPt = new TH1F*[fnCuts];
544  }
545 
546  if (fMesonRecoMode > 0) {
547  fHistoNGammaCaloCandidates = new TH1F*[fnCuts];
548  if (!fDoLightOutput ){
549  fHistoClusGammaPt = new TH1F*[fnCuts];
550  fHistoClusGammaE = new TH1F*[fnCuts];
551  if (fIsMC > 0){
553  fHistoClusAllHeadersGammaPt = new TH1F*[fnCuts];
555  }
556  }
557  }
558 
561  if(!fDoLightOutput && fMesonRecoMode == 1){
563  }
564  if (fDoMesonQA > 0){
569  }
570 
571  fMesonInvMassWindow = new Double_t[2];
572  if (fMesonType < 0 || fMesonType > 2){
573  if(!fV0Reader){printf("Error: No V0 Reader");return;}// GetV0Reader
574  } else if (fMesonType == 0){ // pi0 case 134.9770 ± 0.0005 MeV
575  fMesonPDG = 111;
576  fMesonInvMassMin = 0.;
577  fMesonInvMassMax = 0.400;
578  fMesonInvMassNBins = 400;
579  fMesonInvMassWindow[0] = 0.05;
580  fMesonInvMassWindow[1] = 0.17;
581  } else if (fMesonType == 1){ // eta case 547.862 ± 0.017 MeV
582  fMesonPDG = 221;
583  fMesonInvMassMin = 0.300;
584  fMesonInvMassMax = 0.800;
585  fMesonInvMassNBins = 500;
586  fMesonInvMassWindow[0] = 0.45;
587  fMesonInvMassWindow[1] = 0.65;
588  } else if (fMesonType == 2){ // eta' case 957.78 ± 0.06 MeV
589  fMesonPDG = 331;
590  fMesonInvMassMin = 0.700;
591  fMesonInvMassMax = 1.200;
592  fMesonInvMassNBins = 500;
593  fMesonInvMassWindow[0] = 0.85;
594  fMesonInvMassWindow[1] = 1.05;
595  }
596  // set common binning in pT for mesons and photons
597  Int_t nBinsPt = 200;
598  Float_t binWidthPt = 0.1;
599  Float_t minPt = 0;
600  Float_t maxPt = 20;
601  Int_t nBinsQAPt = 170;
602  Float_t maxQAPt = 20;
603  Int_t nBinsClusterPt = 500;
604  Float_t minClusterPt = 0;
605  Float_t maxClusterPt = 50;
606  Double_t *arrPtBinning = new Double_t[1200];
607  Double_t *arrQAPtBinning = new Double_t[1200];
608  Double_t *arrClusPtBinning = new Double_t[1200];
609  // Set special pt binning for pp 8TeV
610  if (((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k8TeV ){
611  nBinsQAPt = 190;
612  maxQAPt = 40;
613  for(Int_t i=0; i<nBinsQAPt+1;i++){
614  if(i<60) arrQAPtBinning[i] = 0.05*i;
615  else if(i<130) arrQAPtBinning[i] = 3.+0.1*(i-60);
616  else if(i<170) arrQAPtBinning[i] = 10.+0.25*(i-130);
617  else if(i<190) arrQAPtBinning[i] = 20.+1.0*(i-170);
618  else arrQAPtBinning[i] = maxQAPt;
619  }
620  nBinsPt = 400;
621  minPt = 0;
622  maxPt = 40;
623  for(Int_t i=0; i<nBinsPt+1;i++){
624  arrPtBinning[i] = ((maxPt-minPt)/nBinsPt)*i;
625  }
626  nBinsClusterPt = 800;
627  minClusterPt = 0;
628  maxClusterPt = 80;
629  for(Int_t i=0; i<nBinsPt+1;i++){
630  arrClusPtBinning[i] = ((maxClusterPt-minClusterPt)/nBinsClusterPt)*i;
631  }
632  // Set special pt binning for pPb 5TeV
633  } else if ( ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::kpPb5TeV ||
635  ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k5TeV ){
636  binWidthPt = 0.05;
637  nBinsPt = 205;
638  minPt = 0;
639  maxPt = 60;
640  for(Int_t i=0; i<nBinsPt+1;i++){
641  if (i < 1) arrPtBinning[i] = 0.3*i;
642  else if(i<55) arrPtBinning[i] = 0.3+0.05*(i-1);
643  else if(i<125) arrPtBinning[i] = 3.+0.1*(i-55);
644  else if(i<165) arrPtBinning[i] = 10.+0.25*(i-125);
645  else if(i<205) arrPtBinning[i] = 20.+1.0*(i-165);
646  else arrPtBinning[i] = maxPt;
647  }
648  nBinsQAPt = 210;
649  maxQAPt = 60;
650  for(Int_t i=0; i<nBinsQAPt+1;i++){
651  if(i<60) arrQAPtBinning[i] = 0.05*i;
652  else if(i<130) arrQAPtBinning[i] = 3.+0.1*(i-60);
653  else if(i<170) arrQAPtBinning[i] = 10.+0.25*(i-130);
654  else if(i<210) arrQAPtBinning[i] = 20.+1.0*(i-170);
655  else arrQAPtBinning[i] = maxQAPt;
656  }
657  nBinsClusterPt = 301;
658  minClusterPt = 0;
659  maxClusterPt = 100;
660  for(Int_t i=0; i<nBinsClusterPt+1;i++){
661  if (i < 1) arrClusPtBinning[i] = 0.3*i;
662  else if(i<55) arrClusPtBinning[i] = 0.3+0.05*(i-1);
663  else if(i<125) arrClusPtBinning[i] = 3.+0.1*(i-55);
664  else if(i<155) arrClusPtBinning[i] = 10.+0.2*(i-125);
665  else if(i<211) arrClusPtBinning[i] = 16.+0.25*(i-155);
666  else if(i<251) arrClusPtBinning[i] = 30.+0.5*(i-211);
667  else if(i<301) arrClusPtBinning[i] = 50.+1.0*(i-251);
668  else arrClusPtBinning[i] = maxClusterPt;
669  }
670  // Set special pt binning for pp 13TeV, pPb 8TeV
671  } else if ( ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k13TeV ||
674  nBinsPt = 285;
675  minPt = 0;
676  maxPt = 100;
677  binWidthPt = 0.05;
678  for(Int_t i=0; i<nBinsPt+1;i++){
679  if (i < 1) arrPtBinning[i] = 0.3*i;
680  else if(i<55) arrPtBinning[i] = 0.3+0.05*(i-1);
681  else if(i<125) arrPtBinning[i] = 3.+0.1*(i-55);
682  else if(i<185) arrPtBinning[i] = 10.+0.25*(i-125);
683  else if(i<235) arrPtBinning[i] = 25.+0.5*(i-185);
684  else if(i<285) arrPtBinning[i] = 50.+1.0*(i-235);
685  else arrPtBinning[i] = maxPt;
686  }
687  nBinsQAPt = 270;
688  maxQAPt = 100;
689  for(Int_t i=0; i<nBinsQAPt+1;i++){
690  if(i<60) arrQAPtBinning[i] = 0.05*i;
691  else if(i<130) arrQAPtBinning[i] = 3.+0.1*(i-60);
692  else if(i<170) arrQAPtBinning[i] = 10.+0.25*(i-130);
693  else if(i<210) arrQAPtBinning[i] = 20.+0.5*(i-170);
694  else if(i<270) arrQAPtBinning[i] = 40.+1.0*(i-210);
695  else arrQAPtBinning[i] = maxQAPt;
696  }
697  nBinsClusterPt = 301;
698  minClusterPt = 0;
699  maxClusterPt = 100;
700  for(Int_t i=0; i<nBinsClusterPt+1;i++){
701  if (i < 1) arrClusPtBinning[i] = 0.3*i;
702  else if(i<55) arrClusPtBinning[i] = 0.3+0.05*(i-1);
703  else if(i<125) arrClusPtBinning[i] = 3.+0.1*(i-55);
704  else if(i<155) arrClusPtBinning[i] = 10.+0.2*(i-125);
705  else if(i<211) arrClusPtBinning[i] = 16.+0.25*(i-155);
706  else if(i<251) arrClusPtBinning[i] = 30.+0.5*(i-211);
707  else if(i<301) arrClusPtBinning[i] = 50.+1.0*(i-251);
708  else arrClusPtBinning[i] = maxClusterPt;
709  }
710  } else if (((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::kXeXe5440GeV ){
711  nBinsPt = 90;
712  minPt = 0;
713  maxPt = 20;
714  for(Int_t i=0; i<nBinsPt+1;i++){
715  if (i < 1) arrPtBinning[i] = 0.3*i;
716  else if(i<58) arrPtBinning[i] = 0.3+0.1*(i-1);
717  else if(i<82) arrPtBinning[i] = 6.+0.25*(i-58);
718  else if(i<90) arrPtBinning[i] = 12.+1.0*(i-82);
719  else arrPtBinning[i] = maxPt;
720  }
721  nBinsQAPt = 92;
722  maxQAPt = 20;
723  for(Int_t i=0; i<nBinsQAPt+1;i++){
724  if(i<60) arrQAPtBinning[i] = 0.1*i;
725  else if(i<84) arrQAPtBinning[i] = 6.+0.25*(i-60);
726  else if(i<92) arrQAPtBinning[i] = 12.+1.0*(i-84);
727  else arrQAPtBinning[i] = maxQAPt;
728  }
729  nBinsClusterPt = 148;
730  minClusterPt = 0;
731  maxClusterPt = 40;
732  for(Int_t i=0; i<nBinsClusterPt+1;i++){
733  if (i < 1) arrClusPtBinning[i] = 0.3*i;
734  else if(i<98) arrClusPtBinning[i] = 0.3+0.1*(i-1);
735  else if(i<123) arrClusPtBinning[i] = 10.+0.2*(i-98);
736  else if(i<148) arrClusPtBinning[i] = 15.+1.0*(i-123);
737  else arrClusPtBinning[i] = maxClusterPt;
738  }
739  } else if (((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::kPbPb5TeV ){
740  nBinsPt = 90;
741  minPt = 0;
742  maxPt = 20;
743  for(Int_t i=0; i<nBinsPt+1;i++){
744  if (i < 1) arrPtBinning[i] = 0.3*i;
745  else if(i<58) arrPtBinning[i] = 0.3+0.1*(i-1);
746  else if(i<82) arrPtBinning[i] = 6.+0.25*(i-58);
747  else if(i<90) arrPtBinning[i] = 12.+1.0*(i-82);
748  else arrPtBinning[i] = maxPt;
749  }
750  nBinsQAPt = 92;
751  maxQAPt = 20;
752  for(Int_t i=0; i<nBinsQAPt+1;i++){
753  if(i<60) arrQAPtBinning[i] = 0.1*i;
754  else if(i<84) arrQAPtBinning[i] = 6.+0.25*(i-60);
755  else if(i<92) arrQAPtBinning[i] = 12.+1.0*(i-84);
756  else arrQAPtBinning[i] = maxQAPt;
757  }
758  nBinsClusterPt = 148;
759  minClusterPt = 0;
760  maxClusterPt = 40;
761  for(Int_t i=0; i<nBinsClusterPt+1;i++){
762  if (i < 1) arrClusPtBinning[i] = 0.3*i;
763  else if(i<98) arrClusPtBinning[i] = 0.3+0.1*(i-1);
764  else if(i<123) arrClusPtBinning[i] = 10.+0.2*(i-98);
765  else if(i<148) arrClusPtBinning[i] = 15.+1.0*(i-123);
766  else arrClusPtBinning[i] = maxClusterPt;
767  }
768  // default binning
769  } else {
770  for(Int_t i=0; i<nBinsPt+1;i++){
771  arrPtBinning[i] = ((maxPt-minPt)/nBinsPt)*i;
772  }
773  for(Int_t i=0; i<nBinsClusterPt+1;i++){
774  arrClusPtBinning[i] = ((maxClusterPt-minClusterPt)/nBinsClusterPt)*i;
775  }
776  for(Int_t i=0; i<nBinsQAPt+1;i++){
777  if(i<60) arrQAPtBinning[i] = 0.05*i;
778  else if(i<130) arrQAPtBinning[i] = 3.+0.1*(i-60);
779  else if(i<170) arrQAPtBinning[i] = 10.+0.25*(i-130);
780  else arrQAPtBinning[i] = maxQAPt;
781  }
782  }
783 
784  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
785  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
786  TString cutstringConvGamma = "";
787  TString cutstringCaloGamma = "";
788  if (fMesonRecoMode < 2) cutstringConvGamma = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
789  if (fMesonRecoMode > 0) cutstringCaloGamma = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
790  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
791 
792  TString fullCutString = "";
793  if (fMesonRecoMode == 0) fullCutString = Form("%i_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(), cutstringConvGamma.Data(), cutstringMeson.Data());
794  else if (fMesonRecoMode == 1) fullCutString = Form("%i_%s_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringCaloGamma.Data(), cutstringMeson.Data());
795  else if (fMesonRecoMode == 2) fullCutString = Form("%i_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(), cutstringCaloGamma.Data(), cutstringMeson.Data());
796 
797  fCutFolder[iCut] = new TList();
798  fCutFolder[iCut]->SetName(Form("Cut Number %s",fullCutString.Data()));
799  fCutFolder[iCut]->SetOwner(kTRUE);
800  fOutputContainer->Add(fCutFolder[iCut]);
801  fESDList[iCut] = new TList();
802  fESDList[iCut]->SetName(Form("%s ESD histograms",fullCutString.Data()));
803  fESDList[iCut]->SetOwner(kTRUE);
804  fCutFolder[iCut]->Add(fESDList[iCut]);
805 
806  fHistoNEvents[iCut] = new TH1F("NEvents", "NEvents", 14, -0.5, 13.5);
807  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
808  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
809  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
810  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
811  TString TriggerNames = "Not Trigger: ";
812  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
813  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
814  }else {
815  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
816  }
817  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
818  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
819  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
820  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
821  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
822  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
823  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
824  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
825  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
826  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
827  fESDList[iCut]->Add(fHistoNEvents[iCut]);
828 
829  if (fIsMC > 1){
830  fHistoNEventsWOWeight[iCut] = new TH1F("NEventsWOWeight", "NEventsWOWeight", 14, -0.5, 13.5);
831  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
832  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
833  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
834  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
835  TString TriggerNames = "Not Trigger: ";
836  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
837  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
838  }else {
839  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
840  }
841  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
842  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
843  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
844  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
845  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
846  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
847  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
848  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
849  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
850  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
851  fESDList[iCut]->Add(fHistoNEventsWOWeight[iCut]);
852  }
853 
854  if (fIsMC == 2){
855  fProfileJetJetXSection[iCut] = new TProfile("XSection", "XSection", 1, -0.5, 0.5);
856  fESDList[iCut]->Add(fProfileJetJetXSection[iCut]);
857  fHistoJetJetNTrials[iCut] = new TH1F("NTrials", "#sum{NTrials}", 1, 0, 1);
858  fHistoJetJetNTrials[iCut]->GetXaxis()->SetBinLabel(1,"#sum{NTrials}");
859  fESDList[iCut]->Add(fHistoJetJetNTrials[iCut]);
860  }
861 
862  if(fIsHeavyIon == 1)
863  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks", "GoodESDTracks; # TPC tracks", 4000, 0, 4000);
864  else if(fIsHeavyIon == 2)
865  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks", "GoodESDTracks; # TPC tracks", 400, 0, 400);
866  else
867  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks", "GoodESDTracks; # TPC tracks", 200, 0, 200);
868  fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
869 
870  fHistoVertexZ[iCut] = new TH1F("VertexZ", "VertexZ", 200, -10, 10);
871  fESDList[iCut]->Add(fHistoVertexZ[iCut]);
872  if(!fDoLightOutput){
873  fHistoVertexX[iCut] = new TH1F("VertexX", "VertexX", 100, -5, 5);
874  fESDList[iCut]->Add(fHistoVertexX[iCut]);
875  fHistoVertexY[iCut] = new TH1F("VertexY", "VertexY", 100, -5, 5);
876  fESDList[iCut]->Add(fHistoVertexY[iCut]);
877  }
878 
879  if (fMesonRecoMode < 2){
880  if(fIsHeavyIon == 1)
881  fHistoNGammaConvCandidates[iCut] = new TH1F("GammaConvCandidates", "GammaConvCandidates; # accepted #gamma_{conv}", 100, 0, 100);
882  else if(fIsHeavyIon == 2)
883  fHistoNGammaConvCandidates[iCut] = new TH1F("GammaConvCandidates", "GammaConvCandidates; # accepted #gamma_{conv}", 50, 0, 50);
884  else
885  fHistoNGammaConvCandidates[iCut] = new TH1F("GammaConvCandidates", "GammaConvCandidates; # accepted #gamma_{conv}", 50, 0, 50);
886  fESDList[iCut]->Add(fHistoNGammaConvCandidates[iCut]);
887  }
888  if (fMesonRecoMode > 0){
889  if(fIsHeavyIon == 1)
890  fHistoNGammaCaloCandidates[iCut] = new TH1F("GammaCaloCandidates", "GammaCaloCandidates; # accepted #gamma_{conv}", 100, 0, 100);
891  else if(fIsHeavyIon == 2)
892  fHistoNGammaCaloCandidates[iCut] = new TH1F("GammaCaloCandidates", "GammaCaloCandidates; # accepted #gamma_{conv}", 50, 0, 50);
893  else
894  fHistoNGammaCaloCandidates[iCut] = new TH1F("GammaCaloCandidates", "GammaCaloCandidates; # accepted #gamma_{conv}", 50, 0, 50);
895  fESDList[iCut]->Add(fHistoNGammaCaloCandidates[iCut]);
896  }
897 
898  if(!fDoLightOutput){
899  fHistoSPDClusterTrackletBackground[iCut] = new TH2F("SPD tracklets vs SPD clusters", "SPD tracklets vs SPD clusters", 100, 0, 200, 250, 0, 1000);
901 
902  if(fIsHeavyIon == 1)
903  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity", "V0 Multiplicity; VZERO amp [arb. units]", 30000, 0, 30000);
904  else if(fIsHeavyIon == 2)
905  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity", "V0 Multiplicity; VZERO amp [arb. units]", 2500, 0, 2500);
906  else
907  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity", "V0 Multiplicity; VZERO amp [arb. units]", 1500, 0, 1500);
908  fESDList[iCut]->Add(fHistoNV0Tracks[iCut]);
909 
910  if (fMesonRecoMode < 2){
911  fHistoConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt", "ESD_ConvGamma_Pt; p_{T,conv}(GeV/c)", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
912  fESDList[iCut]->Add(fHistoConvGammaPt[iCut]);
913  }
914  if (fMesonRecoMode > 0){
915  fHistoClusGammaPt[iCut] = new TH1F("ClusGamma_Pt", "ClusGamma_Pt; p_{T,clus} (GeV/c)", nBinsClusterPt, arrClusPtBinning);
916  fESDList[iCut]->Add(fHistoClusGammaPt[iCut]);
917  fHistoClusGammaE[iCut] = new TH1F("ClusGamma_E", "ClusGamma_E; E_{clus} (GeV)", nBinsClusterPt, arrClusPtBinning);
918  fESDList[iCut]->Add(fHistoClusGammaE[iCut]);
919  if (fIsMC > 0){
920  fHistoClusOverlapHeadersGammaPt[iCut] = new TH1F("ClusGammaOverlapHeaders_Pt", "ClusGammaOverlapHeaders_Pt; p_{T,clus} (GeV/c), selected header w/ overlap",
921  nBinsClusterPt, arrClusPtBinning);
922  fESDList[iCut]->Add(fHistoClusOverlapHeadersGammaPt[iCut]);
923  fHistoClusAllHeadersGammaPt[iCut] = new TH1F("ClusGammaAllHeaders_Pt", "ClusGammaAllHeaders_Pt; p_{T,clus} (GeV/c), all headers",
924  nBinsClusterPt, arrClusPtBinning);
925  fESDList[iCut]->Add(fHistoClusAllHeadersGammaPt[iCut]);
926  fHistoClusRejectedHeadersGammaPt[iCut] = new TH1F("ClusGammaRejectedHeaders_Pt", "ClusGammaRejectedHeaders_Pt; p_{T,clus} (GeV/c), rejected headers",
927  nBinsClusterPt, arrClusPtBinning);
928  fESDList[iCut]->Add(fHistoClusRejectedHeadersGammaPt[iCut]);
929  }
930  }
931  }
932 
933  if(fIsHeavyIon == 2){
934  fProfileEtaShift[iCut] = new TProfile("Eta Shift", "Eta Shift", 1, -0.5, 0.5);
935  fESDList[iCut]->Add(fProfileEtaShift[iCut]);
936  }
937 
938  if (fIsMC > 1){
939  fHistoNEvents[iCut]->Sumw2();
940  fHistoNGoodESDTracks[iCut]->Sumw2();
941  fHistoVertexZ[iCut]->Sumw2();
942  if (fHistoNGammaConvCandidates[iCut]) fHistoNGammaConvCandidates[iCut]->Sumw2();
943  if (fHistoNGammaCaloCandidates[iCut]) fHistoNGammaCaloCandidates[iCut]->Sumw2();
944  if(!fDoLightOutput){
945  fHistoVertexX[iCut]->Sumw2();
946  fHistoVertexY[iCut]->Sumw2();
947  fHistoSPDClusterTrackletBackground[iCut]->Sumw2();
948  fHistoNV0Tracks[iCut]->Sumw2();
949  if (fHistoConvGammaPt[iCut]) fHistoConvGammaPt[iCut]->Sumw2();
950  if (fHistoClusGammaPt[iCut]) fHistoClusGammaPt[iCut]->Sumw2();
951  if (fHistoClusGammaE[iCut]) fHistoClusGammaE[iCut]->Sumw2();
955  }
956  }
957 
958 
959  fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt", "ESD_Mother_InvMass_Pt; M_{inv} (GeV/c^{2}); p_{T,pair} (GeV/c)",
960  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
961  fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
962 
963  if(!fDoLightOutput){
964  if (fMesonRecoMode == 1){
965  fHistoMotherMatchedInvMassPt[iCut] = new TH2F("ESD_MotherMatched_InvMass_Pt", "ESD_MotherMatched_InvMass_Pt; M_{inv} (GeV/c^{2}) matched conv e^{+/-}to cluster; p_{T,pair} (GeV/c)",
966  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
967  fESDList[iCut]->Add(fHistoMotherMatchedInvMassPt[iCut]);
968  }
969  }
970 
971  fHistoMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt", "ESD_Background_InvMass_Pt; M_{inv, mxed}(GeV/c^{2}); p_{T,BG pair} (GeV/c)",
972  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
973  fESDList[iCut]->Add(fHistoMotherBackInvMassPt[iCut]);
974 
975  if (fIsMC > 1){
976  fHistoMotherInvMassPt[iCut]->Sumw2();
977  fHistoMotherBackInvMassPt[iCut]->Sumw2();
979  }
980 
981  if (fDoMesonQA > 0 ){
982  fHistoMotherMesonPtY[iCut] = new TH2F("ESD_MotherMeson_Pt_Y", "ESD_MotherMeson_Pt_Y; p_{T, meson cand} (GeV/c); y_{meson cand}",
983  nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
984  fESDList[iCut]->Add(fHistoMotherMesonPtY[iCut]);
985  fHistoMotherMesonPtAlpha[iCut] = new TH2F("ESD_MotherMeson_Pt_Alpha", "ESD_MotherMeson_Pt_Alpha; p_{T, meson cand} (GeV/c); #alpha_{meson cand}",
986  nBinsQAPt, arrQAPtBinning, 200, -1, 1);
987  fESDList[iCut]->Add(fHistoMotherMesonPtAlpha[iCut]);
988  fHistoMotherMesonPtOpenAngle[iCut] = new TH2F("ESD_MotherMeson_Pt_OpenAngle", "ESD_MotherMeson_Pt_OpenAngle; p_{T, meson cand} (GeV/c); #theta_{meson cand}",
989  nBinsQAPt, arrQAPtBinning, 100, 0, 1);
990  fESDList[iCut]->Add(fHistoMotherMesonPtOpenAngle[iCut]);
991  fHistoMotherMesonConvPhotonEtaPhi[iCut] = new TH2F("ESD_MotherMesonConvPhoton_Eta_Phi", "ConvPhoton under meson peak; #phi_{#gamma_{conv}}(rad); #eta_{#gamma_{conv}}",
992  600, 0, 2*TMath::Pi(), 200, -1, 1);
994  if (fIsMC > 1){
995  fHistoMotherMesonPtY[iCut]->Sumw2();
996  fHistoMotherMesonPtAlpha[iCut]->Sumw2();
997  fHistoMotherMesonPtOpenAngle[iCut]->Sumw2();
998  fHistoMotherMesonConvPhotonEtaPhi[iCut]->Sumw2();
999  }
1000  }
1001  }
1002 
1003  InitBack(); // Init Background Handler
1004 
1005  if(fIsMC>0){
1006  // MC Histogramms
1007  fMCList = new TList*[fnCuts];
1008  // True Histogramms
1009  fTrueList = new TList*[fnCuts];
1010 
1011  if(!fDoLightOutput){
1012  fHistoMCHeaders = new TH1I*[fnCuts];
1013  if (fMesonRecoMode < 2){
1014  fHistoTrueConvGammaPt = new TH1F*[fnCuts];
1017  fHistoTruePrimaryConvGammaPt = new TH1F*[fnCuts];
1018  }
1019 
1020  if (fMesonRecoMode > 0){
1021  fHistoTrueClusGammaPt = new TH1F*[fnCuts];
1022  fHistoTrueClusConvGammaPt = new TH1F*[fnCuts];
1023  fHistoTruePrimaryClusGammaPt = new TH1F*[fnCuts];
1029  }
1030  }
1031 
1032  fHistoMCMesonPt = new TH1F*[fnCuts];
1033  fHistoMCMesonWOWeightPt = new TH1F*[fnCuts];
1034  fHistoMCMesonInAccPt = new TH1F*[fnCuts];
1035  fHistoMCMesonWOWeightInAccPt = new TH1F*[fnCuts];
1036  if (fIsMC > 1){
1037  fHistoMCMesonWOEvtWeightPt = new TH1F*[fnCuts];
1039  }
1040 
1043  fHistoMultipleCountTrueMeson = new TH1F*[fnCuts];
1047  if (fMesonRecoMode == 1){
1049  }
1050 
1051  if (fDoMesonQA > 0){
1052  fHistoMCMesonPtY = new TH2F*[fnCuts];
1054  if (fIsMC == 2){
1056  }
1057 
1058  if (fIsMC < 2){
1059  if (fMesonRecoMode > 0){
1065  }
1066  if (fMesonRecoMode == 1){
1069  }
1070  if (fMesonRecoMode == 2){
1072  }
1074  }
1075  if(fDoMesonQA > 1){
1080  }
1081  fHistoTrueMesonPtY = new TH2F*[fnCuts];
1084  }
1085 
1086  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1087  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
1088  TString cutstringConvGamma = "";
1089  TString cutstringCaloGamma = "";
1090  if (fMesonRecoMode < 2) cutstringConvGamma = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
1091  if (fMesonRecoMode > 0) cutstringCaloGamma = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
1092  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
1093 
1094  TString fullCutString = "";
1095  if (fMesonRecoMode == 0) fullCutString = Form("%i_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(), cutstringConvGamma.Data(), cutstringMeson.Data());
1096  else if (fMesonRecoMode == 1) fullCutString = Form("%i_%s_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringCaloGamma.Data(), cutstringMeson.Data());
1097  else if (fMesonRecoMode == 2) fullCutString = Form("%i_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(), cutstringCaloGamma.Data(), cutstringMeson.Data());
1098 
1099  fMCList[iCut] = new TList();
1100  fMCList[iCut]->SetName(Form("%s MC histograms",fullCutString.Data()));
1101  fMCList[iCut]->SetOwner(kTRUE);
1102  fCutFolder[iCut]->Add(fMCList[iCut]);
1103  if(!fDoLightOutput){
1104  fHistoMCHeaders[iCut] = new TH1I("MC_Headers", "MC_Headers", 20, 0, 20);
1105  fMCList[iCut]->Add(fHistoMCHeaders[iCut]);
1106  }
1107 
1108  fHistoMCMesonPt[iCut] = new TH1F("MC_Meson_Pt", "MC_Meson_Pt; p_{T} (GeV/c)",
1109  (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1110  fHistoMCMesonPt[iCut]->Sumw2();
1111  fMCList[iCut]->Add(fHistoMCMesonPt[iCut]);
1112  fHistoMCMesonWOWeightPt[iCut] = new TH1F("MC_Meson_WOWeights_Pt", "MC_Meson_WOWeights_Pt; p_{T} (GeV/c)",
1113  (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1114  fMCList[iCut]->Add(fHistoMCMesonWOWeightPt[iCut]);
1115 
1116  fHistoMCMesonInAccPt[iCut] = new TH1F("MC_MesonInAcc_Pt", "MC_MesonInAcc_Pt; p_{T} (GeV/c)",
1117  (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1118  fHistoMCMesonInAccPt[iCut]->Sumw2();
1119  fMCList[iCut]->Add(fHistoMCMesonInAccPt[iCut]);
1120  fHistoMCMesonWOWeightInAccPt[iCut] = new TH1F("MC_MesonWOWeightInAcc_Pt", "MC_MesonWOWeightInAcc_Pt; p_{T} (GeV/c)",
1121  (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1122  fMCList[iCut]->Add(fHistoMCMesonWOWeightInAccPt[iCut]);
1123 
1124  if (fIsMC > 1){
1125  fHistoMCMesonWOWeightPt[iCut]->Sumw2();
1126  fHistoMCMesonWOWeightInAccPt[iCut]->Sumw2();
1127  fHistoMCMesonWOEvtWeightPt[iCut] = new TH1F("MC_Meson_WOEventWeights_Pt", "MC_Meson_WOEventWeights_Pt; p_{T} (GeV/c)",
1128  (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1129  fMCList[iCut]->Add(fHistoMCMesonWOEvtWeightPt[iCut]);
1130  fHistoMCMesonWOEvtWeightInAccPt[iCut] = new TH1F("MC_Meson_WOEventWeightsInAcc_Pt", "MC_Meson_WOEventWeightsInAcc_Pt; p_{T} (GeV/c)",
1131  (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1132  fMCList[iCut]->Add(fHistoMCMesonWOEvtWeightInAccPt[iCut]);
1133 
1134  if (fDoMesonQA > 0 && fIsMC == 2){
1135  fHistoMCMesonPtJetPt[iCut] = new TH2F("MC_Meson_Pt_JetPt", "MC_Meson_Pt_JetPt; p_{T} (GeV/c); p_{T,jet} (GeV/c)",
1136  nBinsQAPt, arrQAPtBinning, 200, 0, 200);
1137  fHistoMCMesonPtJetPt[iCut]->Sumw2();
1138  fMCList[iCut]->Add(fHistoMCMesonPtJetPt[iCut]);
1139  }
1140  }
1141 
1142  // book additional MC QA histograms
1143  if (fDoMesonQA > 0){
1144  fHistoMCMesonPtY[iCut] = new TH2F("MC_Meson_Pt_Y", "MC_Meson_Pt_Y; p_{T} (GeV/c); Y ",
1145  nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
1146  fHistoMCMesonPtY[iCut]->Sumw2();
1147  fMCList[iCut]->Add(fHistoMCMesonPtY[iCut]);
1148  fHistoMCMesonPtAlpha[iCut] = new TH2F("MC_Meson_Pt_Alpha", "MC_Meson_Pt_Alpha; p_{T} (GeV/c); #alpha",
1149  nBinsQAPt, arrQAPtBinning, 200, -1, 1);
1150  fMCList[iCut]->Add(fHistoMCMesonPtAlpha[iCut]);
1151 
1152  if (fIsMC == 2){
1153  fHistoMCMesonPtAlpha[iCut]->Sumw2();
1154  }
1155  }
1156 
1157  fTrueList[iCut] = new TList();
1158  fTrueList[iCut]->SetName(Form("%s True histograms",fullCutString.Data()));
1159  fTrueList[iCut]->SetOwner(kTRUE);
1160  fCutFolder[iCut]->Add(fTrueList[iCut]);
1161 
1162  if(!fDoLightOutput){
1163  if (fMesonRecoMode < 2){
1164  fHistoTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt", "ESD_TrueConvGamma_Pt; p_{T,clus} (GeV/c); counts",
1165  (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1166  fTrueList[iCut]->Add(fHistoTrueConvGammaPt[iCut]);
1167  fHistoDoubleCountTrueConvGammaRPt[iCut] = new TH2F("ESD_TrueDoubleCountConvGamma_R_Pt", "ESD_TrueDoubleCountConvGamma_R_Pt; R (cm); p_{T,clus} (GeV/c)",
1168  800, 0, 200, (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1169  fTrueList[iCut]->Add(fHistoDoubleCountTrueConvGammaRPt[iCut]);
1170  fHistoMultipleCountTrueConvGamma[iCut] = new TH1F("ESD_TrueMultipleCountConvGamma", "ESD_TrueMultipleCountConvGamma", 10, 1, 11);
1171  fTrueList[iCut]->Add(fHistoMultipleCountTrueConvGamma[iCut]);
1172  fHistoTruePrimaryConvGammaPt[iCut] = new TH1F("ESD_TruePrimaryConvGamma_Pt", "ESD_TruePrimaryConvGamma_Pt;p_{T,clus} (GeV/c); counts", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
1173  fTrueList[iCut]->Add(fHistoTruePrimaryConvGammaPt[iCut]);
1174  }
1175  if (fMesonRecoMode > 0){
1176  fHistoTrueClusGammaPt[iCut] = new TH1F("TrueClusGamma_Pt", "ESD_TrueClusGamma_Pt; p_{T,clus} (GeV/c); counts", nBinsClusterPt, arrClusPtBinning);
1177  fTrueList[iCut]->Add(fHistoTrueClusGammaPt[iCut]);
1178  fHistoTruePrimaryClusGammaPt[iCut] = new TH1F("TruePrimaryClusGamma_Pt", "ESD_TruePrimaryClusGamma_Pt; p_{T,clus} (GeV/c); counts", nBinsClusterPt, arrClusPtBinning);
1179  fTrueList[iCut]->Add(fHistoTruePrimaryClusGammaPt[iCut]);
1180  fHistoTrueClusConvGammaPt[iCut] = new TH1F("TrueClusConvGamma_Pt", "TrueClusConvGamma_Pt; p_{T,clus} (GeV/c); counts", nBinsClusterPt, arrClusPtBinning);
1181  fTrueList[iCut]->Add(fHistoTrueClusConvGammaPt[iCut]);
1182  fHistoTruePrimaryClusConvGammaPt[iCut] = new TH1F("TruePrimaryClusConvGamma_Pt", "ESD_TruePrimaryClusConvGamma_Pt; p_{T,clus} (GeV/c); counts", nBinsClusterPt, arrClusPtBinning);
1183  fTrueList[iCut]->Add(fHistoTruePrimaryClusConvGammaPt[iCut]);
1184  fHistoDoubleCountTrueClusterGammaPt[iCut] = new TH2F("TrueDoubleCountClusterGamma_Pt", "TrueDoubleCountClusterGamma_Pt; p_{T,clus} (GeV/c); counts",
1185  nBinsClusterPt, arrClusPtBinning, 2, 0, 2);
1187  fHistoMultipleCountTrueClusterGamma[iCut] = new TH1F("TrueMultipleCountClusterGamma", "TrueMultipleCountClusterGamma", 10, 1, 11);
1189  fHistoTrueClusConvGammaFullyPt[iCut] = new TH1F("TrueClusConvGammaFullyContained_Pt", "TrueClusConvGammaFullyContained_Pt; p_{T,clus} (GeV/c); counts",
1190  nBinsClusterPt, arrClusPtBinning);
1191  fTrueList[iCut]->Add(fHistoTrueClusConvGammaFullyPt[iCut]);
1192  fHistoTrueNLabelsInClusPt[iCut] = new TH2F("TrueNLabelsInClus_Pt", "TrueNLabelsInClus_Pt; p_{T,clus} (GeV/c); counts",
1193  100, -0.5, 99.5, nBinsClusterPt, arrClusPtBinning);
1194  fTrueList[iCut]->Add(fHistoTrueNLabelsInClusPt[iCut]);
1195  }
1196  }
1197 
1198  if (fIsMC > 1){
1199  if(!fDoLightOutput){
1200  if (fMesonRecoMode < 2){
1201  fHistoTrueConvGammaPt[iCut]->Sumw2();
1202  fHistoDoubleCountTrueConvGammaRPt[iCut]->Sumw2();
1203  fHistoMultipleCountTrueConvGamma[iCut]->Sumw2();
1204  }
1205  if (fMesonRecoMode > 0){
1206  fHistoTruePrimaryConvGammaPt[iCut]->Sumw2();
1207  fHistoTruePrimaryClusGammaPt[iCut]->Sumw2();
1208  fHistoTrueNLabelsInClusPt[iCut]->Sumw2();
1209  fHistoTrueClusConvGammaPt[iCut]->Sumw2();
1210  fHistoTruePrimaryClusConvGammaPt[iCut]->Sumw2();
1211  fHistoTrueClusGammaPt[iCut]->Sumw2();
1212  fHistoDoubleCountTrueClusterGammaPt[iCut]->Sumw2();
1213  fHistoMultipleCountTrueClusterGamma[iCut]->Sumw2();
1214  fHistoTrueClusConvGammaFullyPt[iCut]->Sumw2();
1215  }
1216  }
1217 
1218  }
1219 
1220  fHistoTrueMesonInvMassPt[iCut] = new TH2F("ESD_TrueMeson_InvMass_Pt", "ESD_TrueMeson_InvMass_Pt;M_{inv}(GeV/c^{2});p_{T}(GeV/c)",
1221  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1222  fHistoTrueMesonInvMassPt[iCut]->Sumw2();
1223  fTrueList[iCut]->Add(fHistoTrueMesonInvMassPt[iCut]);
1224 
1225  fHistoDoubleCountTrueMesonInvMassPt[iCut] = new TH2F("ESD_TrueDoubleCountMeson_InvMass_Pt", "ESD_TrueDoubleCountMeson_InvMass_Pt;M_{inv}(GeV/c^{2});p_{T}(GeV/c)",
1226  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1228  fHistoMultipleCountTrueMeson[iCut] = new TH1F("ESD_TrueMultipleCountMeson", "ESD_TrueMultipleCountMeson;# number of multiple counts;#", 10, 1, 11);
1229  fHistoMultipleCountTrueMeson[iCut]->Sumw2();
1230  fTrueList[iCut]->Add(fHistoMultipleCountTrueMeson[iCut]);
1231 
1232  fHistoTruePrimaryMesonInvMassPt[iCut] = new TH2F("ESD_TruePrimaryMeson_InvMass_Pt", "ESD_TruePrimaryMeson_InvMass_Pt;M_{inv}(GeV/c^{2});p_{T}(GeV/c)",
1233  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1234  fHistoTruePrimaryMesonInvMassPt[iCut]->Sumw2();
1235  fTrueList[iCut]->Add(fHistoTruePrimaryMesonInvMassPt[iCut]);
1236 
1237  fHistoTruePrimaryMesonW0WeightingInvMassPt[iCut] = new TH2F("ESD_TruePrimaryMesonW0Weights_InvMass_Pt",
1238  "ESD_TruePrimaryMesonW0Weights_InvMass_Pt;M_{inv}(GeV/c^{2});p_{T}(GeV/c)",
1239  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1241 
1242  fProfileTruePrimaryMesonWeightsInvMassPt[iCut] = new TProfile2D("ESD_TruePrimaryMesonWeights_InvMass_Pt",
1243  "ESD_TruePrimaryMesonWeights_InvMass_Pt;M_{inv}(GeV/c^{2});p_{T}(GeV/c)",
1244  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1247 
1248  if (fMesonRecoMode == 1){
1249  fHistoTrueMesonMatchedInvMassPt[iCut] = new TH2F("ESD_TrueMeson_Matched_InvMass_Pt", "ESD_TrueMeson_Matched_InvMass_Pt;M_{inv}(GeV/c^{2});p_{T}(GeV/c)",
1250  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1251  fHistoTrueMesonMatchedInvMassPt[iCut]->Sumw2();
1252  fTrueList[iCut]->Add(fHistoTrueMesonMatchedInvMassPt[iCut]);
1253  }
1254 
1255  if (fIsMC > 1){
1257  }
1258 
1259  if (fDoMesonQA > 0){
1260  if (fIsMC < 2){
1261  if (fMesonRecoMode > 0){
1262  fHistoTrueMesonCaloPhotonInvMassPt[iCut] = new TH2F( "ESD_TrueMesonCaloPhoton_InvMass_Pt",
1263  "ESD_TrueMesonCaloPhoton_InvMass_Pt; M_{inv}(GeV/c^{2}) #gamma #gamma;p_{T}(GeV/c) ",
1264  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1266  fHistoTrueMesonCaloConvertedPhotonInvMassPt[iCut] = new TH2F( "ESD_TrueMesonCaloConvertedPhoton_InvMass_Pt",
1267  "ESD_TrueMesonCaloConvertedPhoton_InvMass_Pt;M_{inv}(GeV/c^{2}) #gamma #gamma_{conv};p_{T}(GeV/c)",
1268  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1270  fHistoTrueMesonCaloElectronInvMassPt[iCut] = new TH2F("ESD_TrueMesonCaloElectron_InvMass_Pt",
1271  "ESD_TrueMesonCaloElectron_InvMass_Pt; M_{inv}(GeV/c^{2}) #gamma e^{#pm}; ; p_{T}(GeV/c)",
1272  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1274  fHistoTrueMesonCaloMergedClusterInvMassPt[iCut] = new TH2F("ESD_TrueMesonCaloMergedCluster_InvMass_Pt",
1275  "ESD_TrueMesonCaloMergedCluster_InvMass_Pt; M_{inv}(GeV/c^{2}) #gamma merged cluster; p_{T}(GeV/c)",
1276  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1278  fHistoTrueMesonCaloMergedClusterPartConvInvMassPt[iCut] = new TH2F( "ESD_TrueMesonCaloMergedClusterPartConv_InvMass_Pt",
1279  "ESD_TrueMesonCaloMergedClusterPartConv_InvMass_Pt; M_{inv}(GeV/c^{2}) #gamma merged cluster, part conv; p_{T}(GeV/c)",
1280  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1282  }
1283  if (fMesonRecoMode == 1){
1284  fHistoTrueMesonCaloConvertedPhotonMatchedInvMassPt[iCut] = new TH2F("ESD_TrueMesonCaloConvertedPhotonMatched_InvMass_Pt",
1285  "ESD_TrueMesonCaloConvertedPhotonMatched_InvMass_Pt;M_{inv}(GeV/c^{2}) #gamma #gamma_{conv,matched};p_{T}(GeV/c)",
1286  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1288  fHistoTrueMotherMesonConvPhotonEtaPhi[iCut] = new TH2F("ESD_TrueMotherMesonConvPhoton_Eta_Phi", "conv photons for true ; #phi_{#gamma_{conv}}(rad);#eta_{#gamma_{conv}}",
1289  600, 0, 2*TMath::Pi(), 200, -1, 1);
1291  }
1292  if (fMesonRecoMode == 2){
1293  fHistoTrueMesonCaloMixedPhotonConvPhotonInvMassPt[iCut] = new TH2F("ESD_TrueMesonCaloMixedPhotonConvertedPhoton_InvMass_Pt",
1294  "ESD_TrueMesonCaloMixedPhotonConvertedPhoton_InvMass_Pt;M_{inv}(GeV/c^{2}) #gamma #gamma_{conv,matched};p_{T}(GeV/c)",
1295  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1297  }
1298  fHistoTruePrimaryMesonMCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryMeson_MCPt_ResolPt",
1299  "ESD_TruePrimaryMeson_ResolPt_MCPt; p_{T,MC}(GeV/c); (p_{T,rec}-p_{T,MC})/p_{T,MC}()",
1300  500, 0.03, 25, 1000, -1., 1.);
1301  fHistoTruePrimaryMesonMCPtResolPt[iCut]->Sumw2();
1303  fTrueList[iCut]->Add(fHistoTruePrimaryMesonMCPtResolPt[iCut]);
1304  }
1305  if(fDoMesonQA>1){
1306  fHistoTrueBckGGInvMassPt[iCut] = new TH2F("ESD_TrueBckGG_InvMass_Pt",
1307  "ESD_TrueBckGG_InvMass_Pt; M_{inv} (GeV/c^{2}) #gamma #gamma no signal; #pair p_{T}(GeV/c)",
1308  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1309  fTrueList[iCut]->Add(fHistoTrueBckGGInvMassPt[iCut]);
1310  fHistoTrueBckFullMesonContainedInOneClusterInvMassPt[iCut] = new TH2F( "ESD_TrueBckFullMesonContained_InvMass_Pt",
1311  "ESD_TrueBckFullMesonContained_InvMass_Pt; M_{inv} (GeV/c^{2}) #gamma #gamma, calo gamma with full pi0; #pair p_{T}(GeV/c)",
1312  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1314  fHistoTrueBckAsymEClustersInvMassPt[iCut] = new TH2F("ESD_TrueBckAsymEClus_InvMass_Pt",
1315  "ESD_TrueBckAsymEClus_InvMass_Pt; M_{inv} (GeV/c^{2}) #gamma #gamma, calo gamma >70% of pi0 energy; #pair p_{T}(GeV/c)",
1316  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1318  fHistoTrueBckContInvMassPt[iCut] = new TH2F("ESD_TrueBckCont_InvMass_Pt",
1319  "ESD_TrueBckCont_InvMass_Pt; M_{inv} (GeV/c^{2}) contamination; #pair p_{T}(GeV/c)",
1320  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
1321  fTrueList[iCut]->Add(fHistoTrueBckContInvMassPt[iCut]);
1322  }
1323  fHistoTrueMesonPtY[iCut] = new TH2F("ESD_TrueMeson_Pt_Y", "ESD_TrueMeson_Pt_Y; p_{T}(GeV/c); Y",
1324  nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
1325  fTrueList[iCut]->Add(fHistoTrueMesonPtY[iCut]);
1326  fHistoTrueMesonPtAlpha[iCut] = new TH2F("ESD_TrueMeson_Pt_Alpha", "ESD_TrueMeson_Pt_Alpha; p_{T}(GeV/c); #alpha",
1327  nBinsQAPt, arrQAPtBinning, 200, -1, 1);
1328  fTrueList[iCut]->Add(fHistoTrueMesonPtAlpha[iCut]);
1329  fHistoTrueMesonPtOpenAngle[iCut] = new TH2F("ESD_TrueMeson_Pt_OpenAngle", "ESD_TrueMeson_Pt_OpenAngle; p_{T}(GeV/c); #theta",
1330  nBinsQAPt, arrQAPtBinning, 100, 0, 1);
1331  fTrueList[iCut]->Add(fHistoTrueMesonPtOpenAngle[iCut]);
1332 
1333  if (fIsMC > 1){
1334  if(fDoMesonQA>1){
1335  fHistoTrueBckGGInvMassPt[iCut]->Sumw2();
1337  fHistoTrueBckAsymEClustersInvMassPt[iCut]->Sumw2();
1338  fHistoTrueBckContInvMassPt[iCut]->Sumw2();
1339  }
1340  fHistoTrueMesonPtY[iCut]->Sumw2();
1341  fHistoTrueMesonPtAlpha[iCut]->Sumw2();
1342  fHistoTrueMesonPtOpenAngle[iCut]->Sumw2();
1344  }
1345  }
1346  }
1347  }
1348 
1352 
1356 
1357  fVectorRecTrueMesons.clear();
1358 
1359  if(fV0Reader)
1361  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
1362  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
1363  if(fV0Reader)
1365  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms())
1366  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
1367 
1371 
1372  for(Int_t iMatcherTask = 0; iMatcherTask < 3; iMatcherTask++){
1373  AliCaloTrackMatcher* temp = (AliCaloTrackMatcher*) (AliAnalysisManager::GetAnalysisManager()->GetTask(Form("CaloTrackMatcher_%i",iMatcherTask)));
1374  if(temp) fOutputContainer->Add(temp->GetCaloTrackMatcherHistograms());
1375  }
1376 
1377  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1378  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))) continue;
1379  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms()){
1380  fCutFolder[iCut]->Add(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
1381  }
1382  if (fMesonRecoMode < 2){
1383  if(!((AliConversionPhotonCuts*)fCutArray->At(iCut))) continue;
1384  if(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms()){
1385  fCutFolder[iCut]->Add(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms());
1386  }
1387  }
1388  if (fMesonRecoMode > 0){
1389  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
1390  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms()){
1391  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms());
1392  }
1393  if(fSetPlotHistsExtQA){
1394  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
1395  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetExtQAHistograms()){
1396  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetExtQAHistograms());
1397  }
1398  }
1399  }
1400  if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
1401  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
1402  fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
1403  }
1404  }
1405 
1406  if (fIsMC > 0){
1407  tBrokenFiles = new TTree("BrokenFiles", "BrokenFiles");
1408  tBrokenFiles->Branch("fileName",&fFileNameBroken);
1410  }
1411 
1412  PostData(1, fOutputContainer);
1413 }
1414 //_____________________________________________________________________________
1416 
1417  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1418  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
1419  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
1420  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
1421  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
1422  }
1423 
1424  if(fIsHeavyIon == 2){
1425  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift()){
1426  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1427  continue; // No Eta Shift requested, continue
1428  }
1429  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
1430  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
1431  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1432  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1433  continue;
1434  } else{
1435  printf(" Gamma Conversion Task %s :: Eta Shift Manually Set to %f \n\n",
1436  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
1437  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1438  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1439  }
1440  }
1441  }
1442 
1443  return kTRUE;
1444 }
1445 //_____________________________________________________________________________
1447  //
1448  // Called for each event
1449  //
1450  fInputEvent = InputEvent();
1451 
1452  if(fIsMC > 0) fMCEvent = MCEvent();
1453 
1454  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
1455  if(fInputEvent->IsIncompleteDAQ()==kTRUE) eventQuality = 2;// incomplete event
1456  // Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1 or because it is incomplete => abort processing of this event/file
1457  if(eventQuality == 2 || eventQuality == 3){
1458  // write out name of broken file for first event
1459  if (fIsMC > 0){
1460  if (fInputEvent->IsA()==AliESDEvent::Class()){
1461  if (((AliESDEvent*)fInputEvent)->GetEventNumberInFile() == 0){
1462  fFileNameBroken = new TObjString(Form("%s",((TString)fV0Reader->GetCurrentFileName()).Data()));
1463  if (tBrokenFiles) tBrokenFiles->Fill();
1464  delete fFileNameBroken;
1465  }
1466  }
1467  }
1468 
1469  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1470  fHistoNEvents[iCut]->Fill(eventQuality);
1471  if (fIsMC > 1) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
1472  }
1473  return;
1474  }
1475 
1476  if(fInputEvent->IsA()==AliAODEvent::Class()){
1477  fInputEvent->InitMagneticField();
1478  }
1479 
1480  fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
1481 
1482  // ------------------- BeginEvent ----------------------------
1483  AliEventplane *EventPlane = fInputEvent->GetEventplane();
1484  if(fIsHeavyIon ==1)fEventPlaneAngle = EventPlane->GetEventplane("V0",fInputEvent,2);
1485  else fEventPlaneAngle=0.0;
1486 
1487  if(fIsMC>0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled()) && fMesonRecoMode < 2){
1488  RelabelAODPhotonCandidates(kTRUE);// In case of AODMC relabeling MC
1489  fV0Reader->RelabelAODs(kTRUE);
1490  }
1491 
1492  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1493 
1494  fiCut = iCut;
1495  Bool_t isRunningEMCALrelAna = kFALSE;
1496  if (fMesonRecoMode > 0){
1497  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetClusterType() == 1) isRunningEMCALrelAna = kTRUE;
1498  }
1499 
1500  Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon,isRunningEMCALrelAna);
1501 
1502  if(fIsMC==2){
1503  Float_t xsection = -1.;
1504  Float_t ntrials = -1.;
1505  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetXSectionAndNTrials(fMCEvent,xsection,ntrials,fInputEvent);
1506  if((xsection==-1.) || (ntrials==-1.)) AliFatal(Form("ERROR: GetXSectionAndNTrials returned invalid xsection/ntrials, periodName from V0Reader: '%s'",fV0Reader->GetPeriodName().Data()));
1507  fProfileJetJetXSection[iCut]->Fill(0.,xsection);
1508  fHistoJetJetNTrials[iCut]->Fill("#sum{NTrials}",ntrials);
1509  }
1510 
1511  if(fIsMC>0){
1512  fWeightJetJetMC = 1;
1513  // cout << fMCEvent << endl;
1514  Bool_t isMCJet = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsJetJetMCEventAccepted( fMCEvent, fWeightJetJetMC, fInputEvent );
1515  if (fIsMC == 3){
1516  Double_t weightMult = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetWeightForMultiplicity(fV0Reader->GetNumberOfPrimaryTracks());
1517  fWeightJetJetMC = fWeightJetJetMC*weightMult;
1518  }
1519  if(fIsMC==1) fWeightJetJetMC = 1;
1520  if (!isMCJet){
1521  fHistoNEvents[iCut]->Fill(10,fWeightJetJetMC);
1522  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(10);
1523  continue;
1524  }
1525  }
1526 
1527  Bool_t triggered = kTRUE;
1528 
1529  if(eventNotAccepted!= 0){
1530  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
1531  fHistoNEvents[iCut]->Fill(eventNotAccepted, fWeightJetJetMC); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
1532  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventNotAccepted);
1533  if (eventNotAccepted==3 && fIsMC > 0){
1534  triggered = kFALSE;
1535  }else {
1536  continue;
1537  }
1538  }
1539 
1540  if(eventQuality != 0){// Event Not Accepted
1541  //cout << "event rejected due to: " <<eventQuality << endl;
1542  fHistoNEvents[iCut]->Fill(eventQuality, fWeightJetJetMC);
1543  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
1544  continue;
1545  }
1546 
1547  if (triggered==kTRUE){
1548  fHistoNEvents[iCut]->Fill(eventQuality, fWeightJetJetMC); // Should be 0 here
1549  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventQuality); // Should be 0 here
1550 
1552  fHistoVertexZ[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetZ(), fWeightJetJetMC);
1553  if(!fDoLightOutput){
1554  fHistoVertexX[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetX(), fWeightJetJetMC);
1555  fHistoVertexY[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetY(), fWeightJetJetMC);
1556  fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)),fWeightJetJetMC);
1557  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2) fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A(), fWeightJetJetMC);
1558  else fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C(), fWeightJetJetMC);
1559  }
1560  }
1561 
1562  if(fIsMC>0){
1563  // Process MC Particle
1564  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
1565  if(fInputEvent->IsA()==AliESDEvent::Class()){
1566  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1567  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1568  fMCEvent);
1569  }
1570  else if(fInputEvent->IsA()==AliAODEvent::Class()){
1571  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1572  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1573  fInputEvent);
1574  }
1575 
1576  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader()){
1577  for(Int_t i = 0;i<(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader())->GetEntries();i++){
1578  TString nameBin= fHistoMCHeaders[iCut]->GetXaxis()->GetBinLabel(i+1);
1579  if (nameBin.CompareTo("")== 0){
1580  TString nameHeader = ((TObjString*)((TList*)((AliConvEventCuts*)fEventCutArray->At(iCut))
1581  ->GetAcceptedHeader())->At(i))->GetString();
1582  fHistoMCHeaders[iCut]->GetXaxis()->SetBinLabel(i+1,nameHeader.Data());
1583  }
1584  }
1585  }
1586  }
1587  }
1588  if(fIsMC>0){
1589  if(fInputEvent->IsA()==AliESDEvent::Class())
1591  if(fInputEvent->IsA()==AliAODEvent::Class())
1593  }
1594 
1595  if (triggered==kFALSE) continue;
1596 
1597  // 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)
1598  if (fMesonRecoMode > 0) // process calo clusters
1599  ProcessClusters();
1600  if (fMesonRecoMode < 2) // Process this cuts gammas
1602 
1603  if (fMesonRecoMode < 2) fHistoNGammaConvCandidates[iCut]->Fill(fGammaCandidates->GetEntries(),fWeightJetJetMC);
1605 
1606  if (fMesonRecoMode < 2){
1607  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseMCPSmearing() && fIsMC>0){
1608  fUnsmearedPx = new Double_t[fGammaCandidates->GetEntries()]; // Store unsmeared Momenta
1609  fUnsmearedPy = new Double_t[fGammaCandidates->GetEntries()];
1610  fUnsmearedPz = new Double_t[fGammaCandidates->GetEntries()];
1611  fUnsmearedE = new Double_t[fGammaCandidates->GetEntries()];
1612 
1613  for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
1614  fUnsmearedPx[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Px();
1615  fUnsmearedPy[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Py();
1616  fUnsmearedPz[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->Pz();
1617  fUnsmearedE[gamma] = ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->E();
1618  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->SmearParticle(dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(gamma)));
1619  }
1620  }
1621  }
1622 
1623  CalculateMesonCandidates(); // Combine Gammas from conversion and from calo
1624 
1625  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
1626  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
1627  CalculateBackground(); // Combinatorial Background
1628  UpdateEventByEventData(); // Store Event for mixed Events
1629  } else{
1630  CalculateBackgroundRP(); // Combinatorial Background
1631  fBGHandlerRP[iCut]->AddEvent(fGammaCandidates,fInputEvent); // Store Event for mixed Events
1632  fBGClusHandlerRP[iCut]->AddEvent(fClusterCandidates,fInputEvent); // Store Event for mixed Events
1633  }
1634  }
1635 
1636  if (fMesonRecoMode < 2){
1637  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseMCPSmearing() && fIsMC>0){
1638  for(Int_t gamma=0;gamma<fGammaCandidates->GetEntries();gamma++){ // Smear the AODPhotons in MC
1639  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPx(fUnsmearedPx[gamma]); // Reset Unsmeared Momenta
1640  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPy(fUnsmearedPy[gamma]);
1641  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetPz(fUnsmearedPz[gamma]);
1642  ((AliAODConversionPhoton*)fGammaCandidates->At(gamma))->SetE(fUnsmearedE[gamma]);
1643  }
1644  delete[] fUnsmearedPx; fUnsmearedPx = 0x0;
1645  delete[] fUnsmearedPy; fUnsmearedPy = 0x0;
1646  delete[] fUnsmearedPz; fUnsmearedPz = 0x0;
1647  delete[] fUnsmearedE;fUnsmearedE = 0x0;
1648  }
1649  }
1650 
1651  if(fIsMC>0){
1652  fVectorRecTrueMesons.clear();
1659  }
1660 
1661  fGammaCandidates->Clear(); // delete this cuts good gammas
1662  fClusterCandidates->Clear(); // delete cluster candidates
1663  }
1664 
1665  if(fIsMC>0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled()) && fMesonRecoMode < 2){
1666  RelabelAODPhotonCandidates(kFALSE); // Back to ESDMC Label
1667  fV0Reader->RelabelAODs(kFALSE);
1668  }
1669 
1670  PostData(1, fOutputContainer);
1671 }
1672 
1673 //________________________________________________________________________
1675  Int_t nclus = 0;
1676  TClonesArray * arrClustersProcess = NULL;
1677  if(!fCorrTaskSetting.CompareTo("")){
1678  nclus = fInputEvent->GetNumberOfCaloClusters();
1679  } else {
1680  arrClustersProcess = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
1681  if(!arrClustersProcess)
1682  AliFatal(Form("%sClustersBranch was not found in AliAnalysisTaskHeavyNeutralMesonToGG! Check the correction framework settings!",fCorrTaskSetting.Data()));
1683  nclus = arrClustersProcess->GetEntries();
1684  }
1685 
1686  // cout << nclus << endl;
1687 
1688  if(nclus == 0) return;
1689 
1690  // plotting histograms on cell/tower level, only if extendedMatchAndQA > 1
1691  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->FillHistogramsExtendedQA(fInputEvent,fIsMC);
1692 
1693  // match tracks to clusters
1694  if(fDoPrimaryTrackMatching) ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchTracksToClusters(fInputEvent,fWeightJetJetMC,kFALSE);
1695 
1696  // vertex
1697  Double_t vertex[3] = {0,0,0};
1698  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1699 
1700  // Loop over EMCal clusters
1701  for(Int_t i = 0; i < nclus; i++){
1702  AliVCluster* clus = NULL;
1703  if(fInputEvent->IsA()==AliESDEvent::Class()){
1704  if(arrClustersProcess)
1705  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersProcess->At(i));
1706  else
1707  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(i));
1708  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
1709  if(arrClustersProcess)
1710  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersProcess->At(i));
1711  else
1712  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i));
1713  }
1714 
1715  if (!clus) continue;
1716  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC,fWeightJetJetMC,i)){
1717  delete clus;
1718  continue;
1719  }
1720 
1721  // TLorentzvector with cluster
1722  TLorentzVector clusterVector;
1723  clus->GetMomentum(clusterVector,vertex);
1724 
1725  TLorentzVector* tmpvec = new TLorentzVector();
1726  tmpvec->SetPxPyPzE(clusterVector.Px(),clusterVector.Py(),clusterVector.Pz(),clusterVector.E());
1727 
1728  // convert to AODConversionPhoton
1729  AliAODConversionPhoton *PhotonCandidate = new AliAODConversionPhoton(tmpvec);
1730  if(!PhotonCandidate){ delete clus; delete tmpvec; continue;}
1731 
1732  // Flag Photon as CaloPhoton
1733  PhotonCandidate->SetIsCaloPhoton();
1734  PhotonCandidate->SetCaloClusterRef((Long_t)i);
1735  // get MC label
1736  if(fIsMC>0){
1737  PhotonCandidate->SetNCaloPhotonMCLabels(clus->GetNLabels());
1738  Int_t* mclabelsCluster = clus->GetLabels();
1739  PhotonCandidate->SetNCaloPhotonMCLabels(clus->GetNLabels());
1740  // cout << clus->GetNLabels() << endl;
1741  if (clus->GetNLabels()>0){
1742  for (Int_t k =0; k<(Int_t)clus->GetNLabels(); k++){
1743  if (k<50)PhotonCandidate->SetCaloPhotonMCLabel(k,mclabelsCluster[k]);
1744  // Int_t pdgCode = fMCEvent->Particle(mclabelsCluster[k])->GetPdgCode();
1745  // cout << "label " << k << "\t" << mclabelsCluster[k] << " pdg code: " << pdgCode << endl;
1746  }
1747  }
1748  }
1749 
1750  fIsFromDesiredHeader = kTRUE;
1752  //TString periodName = fV0Reader->GetPeriodName();
1753  // test whether largest contribution to cluster orginates in added signals
1754  if (fIsMC>0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() > 0){
1755  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetCaloPhotonMCLabel(0), fMCEvent, fInputEvent) == 0){
1756  fIsFromDesiredHeader = kFALSE;
1757  }
1758  if (clus->GetNLabels()>1){
1759  Int_t* mclabelsCluster = clus->GetLabels();
1760  for (Int_t l = 1; l < (Int_t)clus->GetNLabels(); l++ ){
1761  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(mclabelsCluster[l], fMCEvent, fInputEvent) == 0){
1763  }
1764  }
1765  }
1766  }
1767  fHistoClusAllHeadersGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
1768  if (!fIsFromDesiredHeader)
1769  fHistoClusRejectedHeadersGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
1771  fHistoClusOverlapHeadersGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
1772 
1774  fHistoClusGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
1775  fHistoClusGammaE[fiCut]->Fill(PhotonCandidate->E(),fWeightJetJetMC);
1776  if(fIsMC>0){
1777  if(fInputEvent->IsA()==AliESDEvent::Class()){
1778  ProcessTrueClusterCandidates(PhotonCandidate,clus->GetM02());
1779  }else {
1780  ProcessTrueClusterCandidatesAOD(PhotonCandidate,clus->GetM02());
1781  }
1782  }
1783  fClusterCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
1784  }else{
1785  delete PhotonCandidate;
1786  }
1787 
1788  delete clus;
1789  delete tmpvec;
1790  }
1791 }
1792 
1793 //________________________________________________________________________
1795 
1796  TParticle *Photon = NULL;
1797  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
1798  if (TruePhotonCandidate->GetCaloPhotonMCLabel(0) < 0) return;
1799  if(!fDoLightOutput) fHistoTrueNLabelsInClusPt[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
1800 
1801  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0)Photon = fMCEvent->Particle(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
1802  else return;
1803 
1804  if(Photon == NULL){
1805  // cout << "no photon" << endl;
1806  return;
1807  }
1808 
1809  TruePhotonCandidate->SetCaloPhotonMCFlags(fMCEvent, fEnableSortForClusMC);
1810 
1811  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
1812  Double_t mcProdVtxX = primVtxMC->GetX();
1813  Double_t mcProdVtxY = primVtxMC->GetY();
1814  Double_t mcProdVtxZ = primVtxMC->GetZ();
1815  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, TruePhotonCandidate->GetCaloPhotonMCLabel(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
1816 
1817  // to get primary distrinction right put mother of conversion electron as particle to check
1818  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
1819  isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, Photon->GetMother(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
1820 
1821 
1822  // Fill histograms for inclusive gamma corrections
1823  // --> a) all clusters with leading real or converted photons
1824  if (TruePhotonCandidate->IsLargestComponentPhoton() || (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()) ){
1825  fHistoTrueClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
1826  if(!fDoLightOutput){
1827  // how many of those clusters are from converted photons
1828  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
1829  fHistoTrueClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
1830  }
1831  // --> b) which of these are primary
1832  if(isPrimary){
1833  fHistoTruePrimaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
1834  // --> c) which are from conversions? Just additonal information
1835  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion() && (Photon->GetMother(0)>-1)){
1836  fHistoTruePrimaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
1837  }
1838  // --> d) how do the secondaries look like
1839  }
1840  }
1841  }
1842 
1843  // Some additional QA
1844  if (fDoClusterQA > 0){
1845  // how many of the converted photons are fully contained in the cluster
1846  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion() && TruePhotonCandidate->IsConversionFullyContained())
1847  fHistoTrueClusConvGammaFullyPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
1848  }
1849 
1850  // Check if we are double counting photons
1851  Int_t motherLab = Photon->GetMother(0);
1852  if (motherLab > -1){
1853  if (TruePhotonCandidate->IsLargestComponentPhoton()){
1855  fHistoDoubleCountTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),(Double_t)0,fWeightJetJetMC);
1857  }
1858  }
1859  Int_t grandMotherLab = fMCEvent->Particle(motherLab)->GetMother(0);
1860  if (grandMotherLab > -1){
1861  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
1863  fHistoDoubleCountTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),(Double_t)1,fWeightJetJetMC);
1865  }
1866  }
1867  }
1868  }
1869  return;
1870 }
1871 
1872 
1873 //________________________________________________________________________
1875 
1876  AliAODMCParticle *Photon = NULL;
1877  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
1878  if (AODMCTrackArray){
1879  if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
1880  if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0) Photon = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
1881  else return;
1882  }else {
1883  AliInfo("AODMCTrackArray could not be loaded");
1884  return;
1885  }
1886 
1887  if(Photon == NULL){
1888  // cout << "no photon" << endl;
1889  return;
1890  }
1891 
1893  if(!fDoLightOutput) fHistoTrueNLabelsInClusPt[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
1894 
1895  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
1896  Double_t mcProdVtxX = primVtxMC->GetX();
1897  Double_t mcProdVtxY = primVtxMC->GetY();
1898  Double_t mcProdVtxZ = primVtxMC->GetZ();
1899  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
1900 
1901  // to get primary distrinction right put mother of conversion electron as particle to check
1902  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
1903  if (Photon->GetMother()> -1){
1904  AliAODMCParticle *Mother = (AliAODMCParticle*) AODMCTrackArray->At(Photon->GetMother());
1905  isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, Mother, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
1906  }
1907  }
1908 
1909  // True Photon
1910  if (TruePhotonCandidate->IsLargestComponentPhoton() || (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()) ){
1911  fHistoTrueClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
1912  if(!fDoLightOutput){
1913  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
1914  fHistoTrueClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
1915  }
1916  if(isPrimary){
1917  fHistoTruePrimaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
1918  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
1919  fHistoTruePrimaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
1920  }
1921  }
1922  }
1923  }
1924  if (fDoClusterQA > 0){
1925  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion() && TruePhotonCandidate->IsConversionFullyContained())
1926  fHistoTrueClusConvGammaFullyPt[fiCut]->Fill(TruePhotonCandidate->Pt(), fWeightJetJetMC);
1927  }
1928  Int_t motherLab = Photon->GetMother();
1929  if (motherLab > -1){
1930  if (TruePhotonCandidate->IsLargestComponentPhoton()){
1932  fHistoDoubleCountTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),(Double_t)0,fWeightJetJetMC);
1934  }
1935  }
1936  Int_t grandMotherLab = ((AliAODMCParticle*) AODMCTrackArray->At(motherLab))->GetMother();
1937  if (grandMotherLab > -1){
1938  if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
1940  fHistoDoubleCountTrueClusterGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),(Double_t)1,fWeightJetJetMC);
1942  }
1943  }
1944  }
1945  }
1946 
1947  return;
1948 }
1949 
1950 //________________________________________________________________________
1952 
1953  Int_t nV0 = 0;
1954  TList *GammaCandidatesStepOne = new TList();
1955  TList *GammaCandidatesStepTwo = new TList();
1956  // Loop over Photon Candidates allocated by ReaderV1
1957  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
1958  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
1959  if(!PhotonCandidate) continue;
1960  fIsFromDesiredHeader = kTRUE;
1961  if(fIsMC>0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
1962  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
1963  if(isPosFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
1964  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
1965  if(isNegFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
1966  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromDesiredHeader = kFALSE;
1967  }
1968 
1969  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fInputEvent)) continue;
1970  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(PhotonCandidate->GetPhotonPhi(),fEventPlaneAngle)) continue;
1971  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
1972  !((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
1973  fGammaCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
1974 
1976  if(!fDoLightOutput) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
1977  }
1978  if(fIsMC>0){
1979  if(fInputEvent->IsA()==AliESDEvent::Class())
1980  ProcessTruePhotonCandidates(PhotonCandidate);
1981  if(fInputEvent->IsA()==AliAODEvent::Class())
1982  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
1983  }
1984  }else if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
1985  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
1986  nV0++;
1987  GammaCandidatesStepOne->Add(PhotonCandidate);
1988  }else if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
1989  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
1990  GammaCandidatesStepTwo->Add(PhotonCandidate);
1991  }
1992  }
1993 
1994  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){
1995  for(Int_t i = 0;i<GammaCandidatesStepOne->GetEntries();i++){
1996  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GammaCandidatesStepOne->At(i);
1997  if(!PhotonCandidate) continue;
1998  fIsFromDesiredHeader = kTRUE;
1999  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2000  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
2001  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
2002  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromDesiredHeader = kFALSE;
2003  }
2004  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GammaCandidatesStepOne->GetEntries())) continue;
2005  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
2006  fGammaCandidates->Add(PhotonCandidate);
2008  if(!fDoLightOutput) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
2009  }
2010  if(fIsMC>0){
2011  if(fInputEvent->IsA()==AliESDEvent::Class())
2012  ProcessTruePhotonCandidates(PhotonCandidate);
2013  if(fInputEvent->IsA()==AliAODEvent::Class())
2014  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
2015  }
2016  } else GammaCandidatesStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
2017  }
2018  }
2019 
2020  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
2021  for(Int_t i = 0;i<GammaCandidatesStepTwo->GetEntries();i++){
2022  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GammaCandidatesStepTwo->At(i);
2023  if(!PhotonCandidate) continue;
2024  fIsFromDesiredHeader = kTRUE;
2025  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2026  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
2027  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
2028  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromDesiredHeader = kFALSE;
2029  }
2030  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GammaCandidatesStepTwo,i)) continue;
2031  fGammaCandidates->Add(PhotonCandidate); // Add gamma to current cut TList
2033  if(!fDoLightOutput) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
2034  }
2035  if(fIsMC>0){
2036  if(fInputEvent->IsA()==AliESDEvent::Class())
2037  ProcessTruePhotonCandidates(PhotonCandidate);
2038  if(fInputEvent->IsA()==AliAODEvent::Class())
2039  ProcessTruePhotonCandidatesAOD(PhotonCandidate);
2040  }
2041  }
2042  }
2043 
2044  delete GammaCandidatesStepOne;
2045  GammaCandidatesStepOne = 0x0;
2046  delete GammaCandidatesStepTwo;
2047  GammaCandidatesStepTwo = 0x0;
2048 
2049 }
2050 
2051 //________________________________________________________________________
2053 
2054  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2055  Double_t mcProdVtxX = primVtxMC->GetX();
2056  Double_t mcProdVtxY = primVtxMC->GetY();
2057  Double_t mcProdVtxZ = primVtxMC->GetZ();
2058 
2059  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2060  if (AODMCTrackArray == NULL) return;
2061  AliAODMCParticle *posDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelPositive());
2062  AliAODMCParticle *negDaughter = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetMCLabelNegative());
2063 
2064  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
2065  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
2066 
2067  if(posDaughter->GetMother() != negDaughter->GetMother()){
2068  return;
2069  } else if(posDaughter->GetMother() == -1){
2070  return;
2071  }
2072 
2073  if(pdgCode[0]!=11 || pdgCode[1]!=11){
2074  return; //One Particle is not a electron
2075  }
2076 
2077  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()){
2078  return; // Same Charge
2079  }
2080 
2081  AliAODMCParticle *Photon = (AliAODMCParticle*) AODMCTrackArray->At(posDaughter->GetMother());
2082  if(Photon->GetPdgCode() != 22){
2083  return; // Mother is no Photon
2084  }
2085 
2086  if(((posDaughter->GetMCProcessCode())) != 5 || ((negDaughter->GetMCProcessCode())) != 5){
2087  return;// check if the daughters come from a conversion
2088  }
2089  // STILL A BUG IN ALIROOT >>8 HAS TPO BE REMOVED AFTER FIX
2090 
2091  // True Photon
2093  if(!fDoLightOutput) fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2094  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueConvGammas,posDaughter->GetMother())){
2095  if(!fDoLightOutput) fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2096  FillMultipleCountMap(fMapMultipleCountTrueConvGammas,posDaughter->GetMother());
2097  }
2098  }
2099 
2100  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2101  if(isPrimary){
2102  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
2104  if(!fDoLightOutput){
2105  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2106  }
2107  }
2108  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
2109  }
2110  TruePhotonCandidate->SetIsTrueConvertedPhoton();
2111  return;
2112 }
2113 
2114 //________________________________________________________________________
2116 
2117  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2118  Double_t mcProdVtxX = primVtxMC->GetX();
2119  Double_t mcProdVtxY = primVtxMC->GetY();
2120  Double_t mcProdVtxZ = primVtxMC->GetZ();
2121 
2122  // Process True Photons
2123  TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(fMCEvent);
2124  TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(fMCEvent);
2125 
2126  if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
2127  Int_t pdgCode[2] = {TMath::Abs(posDaughter->GetPdgCode()),TMath::Abs(negDaughter->GetPdgCode())};
2128  if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){
2129  return;
2130  }
2131  else if(posDaughter->GetMother(0) == -1){
2132  return;
2133  }
2134 
2135  if(pdgCode[0]!=11 || pdgCode[1]!=11) return; //One Particle is not a electron
2136 
2137  if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
2138 
2139  TParticle *Photon = TruePhotonCandidate->GetMCParticle(fMCEvent);
2140 
2141  if(Photon->GetPdgCode() != 22){
2142  return; // Mother is no Photon
2143  }
2144 
2145  if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
2146 
2147  // True Photon
2149  if(!fDoLightOutput) fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2150  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueConvGammas,posDaughter->GetMother(0))){
2151  if(!fDoLightOutput) fHistoDoubleCountTrueConvGammaRPt[fiCut]->Fill(TruePhotonCandidate->GetConversionRadius(),TruePhotonCandidate->Pt(),fWeightJetJetMC);
2152  FillMultipleCountMap(fMapMultipleCountTrueConvGammas,posDaughter->GetMother(0));
2153  }
2154  }
2155  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, posDaughter->GetMother(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2156  if(isPrimary){
2157  // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
2159  if(!fDoLightOutput){
2160  fHistoTruePrimaryConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt(),fWeightJetJetMC);
2161  }
2162  }
2163  // (Not Filled for i6, Extra Signal Gamma (parambox) are secondary)
2164  }
2165  TruePhotonCandidate->SetIsTrueConvertedPhoton();
2166  return;
2167 }
2168 //________________________________________________________________________
2170 
2171  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2172  Double_t mcProdVtxX = primVtxMC->GetX();
2173  Double_t mcProdVtxY = primVtxMC->GetY();
2174  Double_t mcProdVtxZ = primVtxMC->GetZ();
2175 
2176  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2177  if (AODMCTrackArray == NULL) return;
2178 
2179  // Loop over all primary MC particle
2180  for(Long_t i = 0; i < AODMCTrackArray->GetEntriesFast(); i++) {
2181 
2182  AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
2183  if (!particle) continue;
2184 
2185  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, particle, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2186  if (isPrimary) {
2187 
2188  Int_t isMCFromMBHeader = -1;
2189  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2190  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2191  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2192  }
2193 
2194  if (fMesonRecoMode < 2){
2195  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
2196  }
2197 
2198  Double_t mesonY = 1.e30;
2199  Double_t ratio = 0;
2200  if (particle->E() != TMath::Abs(particle->Pz())){
2201  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2202  }
2203  if( !(ratio <= 0) ){
2204  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2205  }
2206 
2207  // check neutral mesons
2208  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2209  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
2210  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
2211  Float_t weighted= 1;
2212  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2213  if (particle->Pt()>0.005){
2214  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, 0x0, fInputEvent);
2215  }
2216  }
2217  Double_t alpha = -10;
2218 
2219  if(particle->GetPdgCode() == fMesonPDG){
2220  alpha = (daughter0->E() - daughter1->E())/(daughter0->E() + daughter1->E());
2221  if (fHistoMCMesonPt[fiCut])fHistoMCMesonPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Meson
2222  if (fHistoMCMesonWOWeightPt[fiCut]) fHistoMCMesonWOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2223  if (fIsMC > 1 && fHistoMCMesonWOEvtWeightPt[fiCut])fHistoMCMesonWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2224  if (fDoMesonQA > 0){
2225  if (fHistoMCMesonPtY[fiCut])fHistoMCMesonPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted*fWeightJetJetMC);
2226  if (fHistoMCMesonPtAlpha[fiCut])fHistoMCMesonPtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC);
2227  if (fIsMC == 2 && fHistoMCMesonPtJetPt[fiCut])fHistoMCMesonPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2228  }
2229 
2230  // Check the acceptance for both gammas
2231  if (fMesonRecoMode == 0){
2232  if( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
2233  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
2234  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2235  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2236  // check acceptance of clusters as well, true if one of them points into the Calo acceptance
2237  if (fHistoMCMesonInAccPt[fiCut])fHistoMCMesonInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Meson with gamma in acc
2238  if (fHistoMCMesonWOWeightInAccPt[fiCut])fHistoMCMesonWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Meson with gamma in acc wo weight
2239  if(fIsMC > 1 && fHistoMCMesonWOEvtWeightInAccPt[fiCut])fHistoMCMesonWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Meson with gamma in acc wo any weight
2240  }
2241  } else if (fMesonRecoMode == 1){
2242  if( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter0,AODMCTrackArray,kFALSE) &&
2243  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedAODMC(daughter1,AODMCTrackArray,kFALSE) &&
2244  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2245  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2246  // check acceptance of clusters as well, true if one of them points into the Calo acceptance
2247  if( ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter0,AODMCTrackArray) ||
2248  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter1,AODMCTrackArray) ){
2249  if (fHistoMCMesonInAccPt[fiCut])fHistoMCMesonInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Meson with gamma in acc
2250  if (fHistoMCMesonWOWeightInAccPt[fiCut])fHistoMCMesonWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Meson with gamma in acc wo weight
2251  if(fIsMC > 1 && fHistoMCMesonWOEvtWeightInAccPt[fiCut])fHistoMCMesonWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Meson with gamma in acc wo any weight
2252  }
2253  }
2254  } else if (fMesonRecoMode == 2){
2255  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter0,AODMCTrackArray) &&
2256  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter1,AODMCTrackArray) ){
2257  if (fHistoMCMesonInAccPt[fiCut])fHistoMCMesonInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Meson with gamma in acc
2258  if (fHistoMCMesonWOWeightInAccPt[fiCut])fHistoMCMesonWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Meson with gamma in acc wo weight
2259  if(fIsMC > 1 && fHistoMCMesonWOEvtWeightInAccPt[fiCut])fHistoMCMesonWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Meson with gamma in acc wo any weight
2260  }
2261  }
2262  }
2263  }
2264  }
2265  }
2266 }
2267 
2268 //________________________________________________________________________
2270 
2271  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2272  Double_t mcProdVtxX = primVtxMC->GetX();
2273  Double_t mcProdVtxY = primVtxMC->GetY();
2274  Double_t mcProdVtxZ = primVtxMC->GetZ();
2275  // cout << mcProdVtxX <<"\t" << mcProdVtxY << "\t" << mcProdVtxZ << endl;
2276 
2277  // Loop over all primary MC particle
2278  for(Long_t i = 0; i < fMCEvent->GetNumberOfTracks(); i++) {
2279  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
2280  // fill primary histograms
2281  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
2282  if (!particle) continue;
2283 
2284  Int_t isMCFromMBHeader = -1;
2285  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2286  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2287  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2288  }
2289 
2290  if (fMesonRecoMode < 2){
2291  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(particle->Phi(),fEventPlaneAngle,kFALSE)) continue;
2292  }
2293 
2294  // Fill histograms for other particles
2295  Double_t mesonY = 1.e30;
2296  Double_t ratio = 0;
2297  if (particle->Energy() != TMath::Abs(particle->Pz())){
2298  ratio = (particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz());
2299  }
2300  if( !(ratio <= 0) ){
2301  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2302  }
2303 
2304  // check neutral mesons
2305  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2306  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
2307  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
2308 
2309  Float_t weighted= 1;
2310  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2311  if (particle->Pt()>0.005){
2312  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
2313  }
2314  }
2315 
2316  Double_t alpha = -10;
2317  if(particle->GetPdgCode() == fMesonPDG){
2318  alpha = (daughter0->Energy() - daughter1->Energy())/(daughter0->Energy() + daughter1->Energy());
2319  if (fHistoMCMesonPt[fiCut])fHistoMCMesonPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // All MC Meson
2320  if (fHistoMCMesonWOWeightPt[fiCut]) fHistoMCMesonWOWeightPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC);
2321  if (fIsMC > 1 && fHistoMCMesonWOEvtWeightPt[fiCut])fHistoMCMesonWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2322  if (fDoMesonQA > 0){
2323  if (fHistoMCMesonPtY[fiCut])fHistoMCMesonPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted*fWeightJetJetMC); // All MC Meson
2324  if (fHistoMCMesonPtAlpha[fiCut])fHistoMCMesonPtAlpha[fiCut]->Fill(particle->Pt(),alpha,fWeightJetJetMC); // All MC Meson
2325  if (fIsMC == 2 && fHistoMCMesonPtJetPt[fiCut])fHistoMCMesonPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2326  }
2327 
2328  // Check the acceptance for both gammas & whether they are counted as primaries as well
2329  Bool_t kDaughter0IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetFirstDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2330  Bool_t kDaughter1IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetLastDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2331  if( kDaughter0IsPrim && kDaughter1IsPrim ){
2332  if (fMesonRecoMode == 0){
2333  if( ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter0,fMCEvent,kFALSE) &&
2334  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter1,fMCEvent,kFALSE) &&
2335  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2336  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2337  // check acceptance of clusters as well, true if one of them points into the Calo acceptance
2338  if (fHistoMCMesonInAccPt[fiCut])fHistoMCMesonInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Meson with gamma in acc
2339  if (fHistoMCMesonWOWeightInAccPt[fiCut])fHistoMCMesonWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Meson with gamma in acc wo weighting
2340  if(fIsMC > 1 && fHistoMCMesonWOEvtWeightInAccPt[fiCut])fHistoMCMesonWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Meson with gamma in acc wo any weight
2341  }
2342  } else if (fMesonRecoMode == 1){
2343  if (((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter0,fMCEvent,kFALSE) &&
2344  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelectedMC(daughter1,fMCEvent,kFALSE) &&
2345  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter0->Phi(),fEventPlaneAngle,kFALSE) &&
2346  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(daughter1->Phi(),fEventPlaneAngle,kFALSE)){
2347  // check acceptance of clusters as well, true if one of them points into the Calo acceptance
2348  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter0,fMCEvent) ||
2349  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter1,fMCEvent) ){
2350  if (fHistoMCMesonInAccPt[fiCut])fHistoMCMesonInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Meson with gamma in acc
2351  if (fHistoMCMesonWOWeightInAccPt[fiCut])fHistoMCMesonWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Meson with gamma in acc wo weighting
2352  if(fIsMC > 1 && fHistoMCMesonWOEvtWeightInAccPt[fiCut])fHistoMCMesonWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Meson with gamma in acc wo any weight
2353  }
2354  }
2355  } else if (fMesonRecoMode == 2){
2356  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter0,fMCEvent) &&
2357  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter1,fMCEvent) ){
2358  if (fHistoMCMesonInAccPt[fiCut])fHistoMCMesonInAccPt[fiCut]->Fill(particle->Pt(),weighted*fWeightJetJetMC); // MC Meson with gamma in acc
2359  if (fHistoMCMesonWOWeightInAccPt[fiCut])fHistoMCMesonWOWeightInAccPt[fiCut]->Fill(particle->Pt(),fWeightJetJetMC); // MC Meson with gamma in acc wo weighting
2360  if(fIsMC > 1 && fHistoMCMesonWOEvtWeightInAccPt[fiCut])fHistoMCMesonWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Meson with gamma in acc wo any weight
2361  }
2362  }
2363  }
2364  }
2365  }
2366  }
2367  }
2368 }
2369 
2370 //________________________________________________________________________
2372  TClonesArray * arrClustersMesonCand = NULL;
2373  if(fCorrTaskSetting.CompareTo("") && fMesonRecoMode > 0)
2374  arrClustersMesonCand = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
2375 
2376  if (fMesonRecoMode == 0){
2377  if(fGammaCandidates->GetEntries()>1){
2378  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries()-1;firstGammaIndex++){
2379  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
2380  if (gamma0==NULL) continue;
2381  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGammaCandidates->GetEntries();secondGammaIndex++){
2382  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(secondGammaIndex));
2383  //Check for same Electron ID
2384  if (gamma1==NULL) continue;
2385  if(gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelPositive() ||
2386  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelNegative() ||
2387  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelPositive() ||
2388  gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelNegative() ) continue;
2389 
2390  AliAODConversionMother *mesonCand = new AliAODConversionMother(gamma0,gamma1);
2391  mesonCand->SetLabels(firstGammaIndex,secondGammaIndex);
2392  mesonCand->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
2393 
2394  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(mesonCand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
2395  if (fHistoMotherInvMassPt[fiCut]) fHistoMotherInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
2396 
2397  if (fDoMesonQA > 0){
2398  if (mesonCand->M() > fMesonInvMassWindow[0] && mesonCand->M() < fMesonInvMassWindow[1]){
2399  if (fHistoMotherMesonPtY[fiCut]) fHistoMotherMesonPtY[fiCut]->Fill(mesonCand->Pt(),mesonCand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2400  if (fHistoMotherMesonPtAlpha[fiCut]) fHistoMotherMesonPtAlpha[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetAlpha(),fWeightJetJetMC);
2401  if (fHistoMotherMesonPtOpenAngle[fiCut]) fHistoMotherMesonPtOpenAngle[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetOpeningAngle(),fWeightJetJetMC);
2402  }
2403  }
2404  if(fDoTHnSparse && ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
2405  Int_t zbin = 0;
2406  Int_t mbin = 0;
2407  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
2408  zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
2409  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
2411  }else {
2412  mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
2413  }
2414  }else{
2415  zbin = fBGHandlerRP[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
2416  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
2418  }else {
2420  }
2421  }
2422 
2423  Double_t sparesFill[4] = {mesonCand->M(),mesonCand->Pt(),(Double_t)zbin,(Double_t)mbin};
2424  if (fSparseMotherInvMassPtZM[fiCut]) fSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
2425  }
2426 
2427 
2428  if( fIsMC > 0 ){
2429  if(fInputEvent->IsA()==AliESDEvent::Class())
2430  ProcessTrueMesonCandidatesConv(mesonCand, gamma0, gamma1);
2431  if(fInputEvent->IsA()==AliAODEvent::Class())
2432  ProcessTrueMesonCandidatesConvAOD(mesonCand, gamma0, gamma1);
2433  }
2434  }
2435  delete mesonCand;
2436  mesonCand=0x0;
2437  }
2438  }
2439  }
2440  } else if (fMesonRecoMode == 1){
2441  if(fGammaCandidates->GetEntries()>0){
2442  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
2443  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
2444  if (gamma0==NULL) continue;
2445 
2446  for(Int_t secondGammaIndex=0;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
2447  Bool_t matched = kFALSE;
2448  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
2449  if (gamma1==NULL) continue;
2450 
2451  if (gamma1->GetIsCaloPhoton()){
2452  AliVCluster* cluster = NULL;
2453  if(fInputEvent->IsA()==AliESDEvent::Class()){
2454  if(arrClustersMesonCand)
2455  cluster = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMesonCand->At(gamma1->GetCaloClusterRef()));
2456  else
2457  cluster = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
2458  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
2459  if(arrClustersMesonCand)
2460  cluster = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMesonCand->At(gamma1->GetCaloClusterRef()));
2461  else
2462  cluster = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
2463  }
2464 
2465  matched = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma0,cluster, fInputEvent, fWeightJetJetMC);
2466  if(arrClustersMesonCand) delete cluster;
2467  }
2468 
2469  AliAODConversionMother *mesonCand = new AliAODConversionMother(gamma0,gamma1);
2470  mesonCand->SetLabels(firstGammaIndex,secondGammaIndex);
2471 
2472  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(mesonCand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
2473  if (matched){
2474  if(fHistoMotherMatchedInvMassPt[fiCut]) fHistoMotherMatchedInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),fWeightJetJetMC);
2475  }else {
2476  if (fHistoMotherInvMassPt[fiCut]) fHistoMotherInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),fWeightJetJetMC);
2477  }
2478 
2479  // fill new histograms
2480  if (!matched){
2481  if (fDoMesonQA > 0){
2482  if (mesonCand->M() > fMesonInvMassWindow[0] && mesonCand->M() < fMesonInvMassWindow[1]){
2483  if (fHistoMotherMesonPtY[fiCut]) fHistoMotherMesonPtY[fiCut]->Fill(mesonCand->Pt(),mesonCand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2484  if (fHistoMotherMesonPtAlpha[fiCut]) fHistoMotherMesonPtAlpha[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetAlpha(),fWeightJetJetMC);
2485  if (fHistoMotherMesonPtOpenAngle[fiCut]) fHistoMotherMesonPtOpenAngle[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetOpeningAngle(),fWeightJetJetMC);
2487  }
2488  }
2489  if(fDoTHnSparse && ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
2490  Int_t zbin = 0;
2491  Int_t mbin = 0;
2492 
2493  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
2494  zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
2495  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
2497  }else {
2498  mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
2499  }
2500  }else{
2501  zbin = fBGHandlerRP[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
2502  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
2504  }else {
2506  }
2507  }
2508  Double_t sparesFill[4] = {mesonCand->M(),mesonCand->Pt(),(Double_t)zbin,(Double_t)mbin};
2509  if (fSparseMotherInvMassPtZM[fiCut]) fSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
2510  }
2511  }
2512 
2513  if(fIsMC>0){
2514  if(fInputEvent->IsA()==AliESDEvent::Class())
2515  ProcessTrueMesonCandidatesConvCalo(mesonCand, gamma0, gamma1, matched);
2516  if(fInputEvent->IsA()==AliAODEvent::Class())
2517  ProcessTrueMesonCandidatesConvCaloAOD(mesonCand, gamma0, gamma1, matched);
2518  }
2519  }
2520  delete mesonCand;
2521  mesonCand=0x0;
2522  }
2523  }
2524  }
2525  } else if (fMesonRecoMode == 2){
2526  if(fClusterCandidates->GetEntries()>0){
2527 
2528  for(Int_t firstGammaIndex=0;firstGammaIndex<fClusterCandidates->GetEntries();firstGammaIndex++){
2529  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(firstGammaIndex));
2530  if (gamma0==NULL) continue;
2531  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
2532  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
2533  if (gamma1==NULL) continue;
2534 
2535  AliAODConversionMother *mesonCand = new AliAODConversionMother(gamma0,gamma1);
2536  mesonCand->SetLabels(firstGammaIndex,secondGammaIndex);
2537 
2538  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(mesonCand, kTRUE, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), gamma0->GetLeadingCellID(), gamma1->GetLeadingCellID()))){
2539  if (fHistoMotherInvMassPt[fiCut]) fHistoMotherInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
2540  // fill new histograms
2541  if (fDoMesonQA > 0 && fDoMesonQA < 3){
2542  if ( mesonCand->M() > fMesonInvMassWindow[0] && mesonCand->M() < fMesonInvMassWindow[1]){
2543  fHistoMotherMesonPtY[fiCut]->Fill(mesonCand->Pt(),mesonCand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), fWeightJetJetMC);
2544  fHistoMotherMesonPtAlpha[fiCut]->Fill(mesonCand->Pt(),TMath::Abs(mesonCand->GetAlpha()), fWeightJetJetMC);
2545  fHistoMotherMesonPtOpenAngle[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetOpeningAngle(), fWeightJetJetMC);
2546  }
2547  }
2548  if(fDoTHnSparse && ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
2549  Int_t zbin = 0;
2550  Int_t mbin = 0;
2551 
2552  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
2553  zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
2554  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
2556  } else {
2558  }
2559  }
2560  Double_t sparesFill[4] = {mesonCand->M(),mesonCand->Pt(),(Double_t)zbin,(Double_t)mbin};
2561  if (fSparseMotherInvMassPtZM[fiCut]) fSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
2562  }
2563 
2564  if(fIsMC> 0){
2565  if(fInputEvent->IsA()==AliESDEvent::Class())
2566  ProcessTrueMesonCandidatesCalo(mesonCand,gamma0,gamma1);
2567  if(fInputEvent->IsA()==AliAODEvent::Class())
2568  ProcessTrueMesonCandidatesCaloAOD(mesonCand,gamma0,gamma1);
2569  }
2570  }
2571  delete mesonCand;
2572  mesonCand=0x0;
2573  }
2574  }
2575  }
2576  }
2577 }
2578 
2579 //______________________________________________________________________
2581  AliAODConversionPhoton *TrueGammaCandidate0,
2582  AliAODConversionPhoton *TrueGammaCandidate1,
2583  Bool_t matched )
2584 {
2585  // obtain MC vertex
2586  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2587  Double_t mcProdVtxX = primVtxMC->GetX();
2588  Double_t mcProdVtxY = primVtxMC->GetY();
2589  Double_t mcProdVtxZ = primVtxMC->GetZ();
2590 
2591  // Process True Mesons
2592  if(TrueGammaCandidate0->GetV0Index()<fInputEvent->GetNumberOfV0s()){
2593  Bool_t isTrueMeson = kFALSE;
2594  Int_t gamma0MCLabel = -1;
2595  Int_t gamma0MotherLabel = -1;
2596  if (TrueGammaCandidate0->IsTrueConvertedPhoton()){
2597  gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCEvent);
2598  if(gamma0MCLabel>-1){
2599  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
2600  gamma0MotherLabel=gammaMC0->GetFirstMother();
2601  }
2602  }
2603  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2604 
2605  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
2606  Int_t gamma1MotherLabel = -1;
2607  // check if
2608 
2609  TParticle * gammaMC1 = 0x0;
2610  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2611  // Daughters Gamma 1
2612  gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
2613  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
2614  // get mother of interest (pi0 or eta)
2615  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
2616  gamma1MotherLabel=gammaMC1->GetMother(0);
2617  }else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
2618  if (TrueGammaCandidate1->IsConversion() && gammaMC1->GetMother(0)>-1) gamma1MotherLabel=fMCEvent->Particle(gammaMC1->GetMother(0))->GetMother(0);
2619  else gamma1MotherLabel=gammaMC1->GetMother(0);
2620  }
2621  }
2622  }
2623 
2624  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
2625  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == fMesonPDG){
2626  isTrueMeson=kTRUE;
2627  }
2628  }
2629 
2630  if(isTrueMeson ){// True Pion or Eta
2631  if (!matched){
2632  if (fHistoTrueMesonInvMassPt[fiCut]) fHistoTrueMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),fWeightJetJetMC);
2633  }else{
2634  if (fHistoTrueMesonMatchedInvMassPt[fiCut]) fHistoTrueMesonMatchedInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),fWeightJetJetMC);
2635  }
2636  if (fDoMesonQA > 0 && fIsMC < 2){
2637  if (TrueGammaCandidate1->IsLargestComponentPhoton() && !matched){
2638  if (fHistoTrueMesonCaloPhotonInvMassPt[fiCut]) fHistoTrueMesonCaloPhotonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
2639  }
2640  if (TrueGammaCandidate1->IsLargestComponentElectron() && !matched){
2641  if (fHistoTrueMesonCaloElectronInvMassPt[fiCut]) fHistoTrueMesonCaloElectronInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
2642  }
2643  if (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion() ){
2644  if ( !matched){
2645  fHistoTrueMesonCaloConvertedPhotonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
2646  }
2647 
2648  if ((TrueGammaCandidate0->GetMCLabelPositive() == gamma1MCLabel || TrueGammaCandidate0->GetMCLabelNegative() == gamma1MCLabel) && isTrueMeson){
2650  }
2651  }
2652  if ((TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged()) && !matched ){
2654  }
2655  if (TrueGammaCandidate1->IsMergedPartConv() && !matched){
2657  }
2658  }
2659  if (!matched){
2660  if (fDoMesonQA > 0){
2661  if (isTrueMeson){
2662  if (mesonCand->M() > fMesonInvMassWindow[0] && mesonCand->M() < fMesonInvMassWindow[1] ){
2663  if (fHistoTrueMesonPtY[fiCut]) fHistoTrueMesonPtY[fiCut]->Fill(mesonCand->Pt(),mesonCand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2664  if (fHistoTrueMesonPtAlpha[fiCut]) fHistoTrueMesonPtAlpha[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetAlpha(),fWeightJetJetMC);
2665  if (fHistoTrueMesonPtOpenAngle[fiCut]) fHistoTrueMesonPtOpenAngle[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetOpeningAngle(),fWeightJetJetMC);
2666  if (fHistoTrueMotherMesonConvPhotonEtaPhi[fiCut])fHistoTrueMotherMesonConvPhotonEtaPhi[fiCut]->Fill(TrueGammaCandidate0->GetPhotonPhi(), TrueGammaCandidate0->GetPhotonEta(),fWeightJetJetMC);
2667  }
2668  }
2669  }
2670  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, gamma0MotherLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2671  if (isPrimary) {
2672  Float_t weighted= 1;
2673  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCEvent, fInputEvent)){
2674  if (((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt()>0.005){
2675  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, fMCEvent, fInputEvent);
2676  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
2677  }
2678  }
2679  if (isTrueMeson){
2680  if (fHistoTruePrimaryMesonInvMassPt[fiCut]) fHistoTruePrimaryMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),weighted*fWeightJetJetMC);
2682  if (fProfileTruePrimaryMesonWeightsInvMassPt[fiCut]) fProfileTruePrimaryMesonWeightsInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),weighted*fWeightJetJetMC);
2684  if (fHistoDoubleCountTrueMesonInvMassPt[fiCut]) fHistoDoubleCountTrueMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),weighted*fWeightJetJetMC);
2686  }
2687  }
2688 
2689  if (fDoMesonQA > 0 && fIsMC < 2){
2690  if(isTrueMeson){ // Only primary pi0 for resolution
2691  if (fHistoTruePrimaryMesonMCPtResolPt[fiCut]) fHistoTruePrimaryMesonMCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(mesonCand->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted*fWeightJetJetMC);
2692  }
2693  }
2694  }
2695  }
2696  }else if(!isTrueMeson ){ // Background
2697  if (fDoMesonQA > 1){
2698  if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Meson or Eta
2699  if (fHistoTrueBckGGInvMassPt[fiCut])fHistoTrueBckGGInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
2700  if(
2701  ( ((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == fMesonPDG
2702  && (TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv()))
2703  ){
2705  }else if( TrueGammaCandidate1->E()/mesonCand->E() > 0.7 ){
2706  if (fHistoTrueBckAsymEClustersInvMassPt[fiCut]) fHistoTrueBckAsymEClustersInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
2707  }
2708  }else { // No photon or without mother
2709  if (fHistoTrueBckContInvMassPt[fiCut]) fHistoTrueBckContInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
2710  }
2711  }
2712  }
2713  if (isTrueMeson && !matched){
2714  fVectorRecTrueMesons.push_back(gamma0MotherLabel);
2715  }
2716  }
2717 }
2718 
2719 //______________________________________________________________________
2721  AliAODConversionPhoton *TrueGammaCandidate0,
2722  AliAODConversionPhoton *TrueGammaCandidate1,
2723  Bool_t matched )
2724 {
2725  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2726  Double_t mcProdVtxX = primVtxMC->GetX();
2727  Double_t mcProdVtxY = primVtxMC->GetY();
2728  Double_t mcProdVtxZ = primVtxMC->GetZ();
2729 
2730  // Process True Mesons
2731  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2732  if (AODMCTrackArray == NULL) return;
2733  Bool_t isTrueMeson = kFALSE;
2734 
2735  AliAODMCParticle *positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
2736  AliAODMCParticle *negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
2737 
2738  Int_t gamma0MCLabel = -1;
2739  Int_t gamma0MotherLabel = -1;
2740  if(!positiveMC||!negativeMC)
2741  return;
2742 
2743  if (TrueGammaCandidate0->IsTrueConvertedPhoton()){
2744  gamma0MCLabel = positiveMC->GetMother();
2745  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
2746  gamma0MotherLabel=gammaMC0->GetMother();
2747  }
2748 
2749  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2750  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
2751  Int_t gamma1MotherLabel = -1;
2752  // check if
2753 
2754  AliAODMCParticle * gammaMC1 = 0x0;
2755  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2756  // Daughters Gamma 1
2757  gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
2758  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
2759  // get mother of interest (pi0 or eta)
2760  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
2761  gamma1MotherLabel=gammaMC1->GetMother();
2762  }else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
2763  if (TrueGammaCandidate1->IsConversion()){
2764  AliAODMCParticle * gammaGrandMotherMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC1->GetMother()));
2765  gamma1MotherLabel=gammaGrandMotherMC1->GetMother();
2766  }else gamma1MotherLabel=gammaMC1->GetMother();
2767  }
2768  }
2769  }
2770 
2771  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
2772  if(((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == fMesonPDG){
2773  isTrueMeson=kTRUE;
2774  }
2775  }
2776 
2777  if(isTrueMeson ){// True Pion or Eta
2778  if (!matched){
2779  if (fHistoTrueMesonInvMassPt[fiCut]) fHistoTrueMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),fWeightJetJetMC);
2780 
2781  }else{
2782  if (fHistoTrueMesonMatchedInvMassPt[fiCut]) fHistoTrueMesonMatchedInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),fWeightJetJetMC);
2783  }
2784  if (fDoMesonQA > 0 && fIsMC < 2){
2785  if (TrueGammaCandidate1->IsLargestComponentPhoton() && !matched){
2786  if (fHistoTrueMesonCaloPhotonInvMassPt[fiCut]) fHistoTrueMesonCaloPhotonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
2787  }
2788  if (TrueGammaCandidate1->IsLargestComponentElectron() && !matched) {
2789  if (fHistoTrueMesonCaloElectronInvMassPt[fiCut]) fHistoTrueMesonCaloElectronInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
2790  }
2791  if (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()){
2792  if (!matched)fHistoTrueMesonCaloConvertedPhotonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
2793  if ((TrueGammaCandidate0->GetMCLabelPositive() == gamma1MCLabel || TrueGammaCandidate0->GetMCLabelNegative() == gamma1MCLabel) && isTrueMeson)
2795  }
2796  if ((TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged()) && !matched ){
2798  }
2799  if (TrueGammaCandidate1->IsMergedPartConv() && !matched) {
2801  }
2802  }
2803 
2804  if ( !matched){
2805  if (fDoMesonQA > 0){
2806  if (mesonCand->M() > fMesonInvMassWindow[0] && mesonCand->M() < fMesonInvMassWindow[1] ){
2807  if (fHistoTrueMesonPtY[fiCut]) fHistoTrueMesonPtY[fiCut]->Fill(mesonCand->Pt(),mesonCand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
2808  if (fHistoTrueMesonPtAlpha[fiCut]) fHistoTrueMesonPtAlpha[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetAlpha(),fWeightJetJetMC);
2809  if (fHistoTrueMesonPtOpenAngle[fiCut]) fHistoTrueMesonPtOpenAngle[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetOpeningAngle(),fWeightJetJetMC);
2810  if (fHistoTrueMotherMesonConvPhotonEtaPhi[fiCut]) fHistoTrueMotherMesonConvPhotonEtaPhi[fiCut]->Fill(TrueGammaCandidate0->GetPhotonPhi(), TrueGammaCandidate0->GetPhotonEta(),fWeightJetJetMC);
2811  }
2812  }
2813 
2814  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel)), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2815  if(isPrimary){
2816  // Only primary pi0 for efficiency calculation
2817  Float_t weighted= 1;
2818  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, 0x0, fInputEvent)){
2819  if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt()>0.005){
2820  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, 0x0, fInputEvent);
2821  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
2822  }
2823  }
2824  if (isTrueMeson){
2825  if (fHistoTruePrimaryMesonInvMassPt[fiCut]) fHistoTruePrimaryMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),weighted*fWeightJetJetMC);
2827  if (fProfileTruePrimaryMesonWeightsInvMassPt[fiCut]) fProfileTruePrimaryMesonWeightsInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),weighted*fWeightJetJetMC);
2829  if (fHistoDoubleCountTrueMesonInvMassPt[fiCut]) fHistoDoubleCountTrueMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),weighted*fWeightJetJetMC);
2831  }
2832  }
2833  if (fDoMesonQA > 0 && fIsMC < 2){
2834  if(isTrueMeson){ // Only primary pi0 for resolution
2835  if (fHistoTruePrimaryMesonMCPtResolPt[fiCut]) fHistoTruePrimaryMesonMCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
2836  (mesonCand->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted*fWeightJetJetMC);
2837 
2838  }
2839  }
2840  }
2841  }
2842  }else if(!isTrueMeson ) { // Background
2843  if (fDoMesonQA > 1){
2844  if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Meson or Eta
2845  if (fHistoTrueBckGGInvMassPt[fiCut]) fHistoTrueBckGGInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
2846 
2847  if( (((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == fMesonPDG
2848  && ((TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv())))
2849  ){
2851  }else if( TrueGammaCandidate1->E()/mesonCand->E() > 0.7 ){
2852  if (fHistoTrueBckAsymEClustersInvMassPt[fiCut]) fHistoTrueBckAsymEClustersInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
2853  }
2854  }else { // No photon or without mother
2855  if (fHistoTrueBckContInvMassPt[fiCut]) fHistoTrueBckContInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
2856  }
2857  }
2858  }
2859  if (isTrueMeson && !matched){
2860  fVectorRecTrueMesons.push_back(gamma0MotherLabel);
2861  }
2862 }
2863 
2864 
2865 //______________________________________________________________________
2867  AliAODConversionPhoton *TrueGammaCandidate0,
2868  AliAODConversionPhoton *TrueGammaCandidate1)
2869 {
2870  // Process True Mesons
2871  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2872  Double_t mcProdVtxX = primVtxMC->GetX();
2873  Double_t mcProdVtxY = primVtxMC->GetY();
2874  Double_t mcProdVtxZ = primVtxMC->GetZ();
2875 
2876  Bool_t isTrueMeson = kFALSE;
2877  Int_t gamma0MCLabel = TrueGammaCandidate0->GetCaloPhotonMCLabel(0); // get most probable MC label
2878  Int_t gamma0MotherLabel = -1;
2879 
2880  TParticle * gammaMC0 = 0x0;
2881  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2882  gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
2883  if (TrueGammaCandidate0->IsLargestComponentPhoton() || TrueGammaCandidate0->IsLargestComponentElectron()){ // largest component is electro magnetic
2884  // get mother of interest (pi0 or eta)
2885  if (TrueGammaCandidate0->IsLargestComponentPhoton()){ // for photons its the direct mother
2886  gamma0MotherLabel=gammaMC0->GetMother(0);
2887  } else if (TrueGammaCandidate0->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
2888  if (TrueGammaCandidate0->IsConversion() && (gammaMC0->GetMother(0) > -1)){
2889  gamma0MotherLabel=fMCEvent->Particle(gammaMC0->GetMother(0))->GetMother(0);
2890  } else {
2891  gamma0MotherLabel=gammaMC0->GetMother(0);
2892  }
2893  }
2894  }
2895  }
2896  if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
2897 
2898  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
2899  Int_t gamma1MotherLabel = -1;
2900  // check if
2901 
2902  TParticle * gammaMC1 = 0x0;
2903  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
2904  // Daughters Gamma 1
2905  gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
2906  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
2907  // get mother of interest (pi0 or eta)
2908  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
2909  gamma1MotherLabel = gammaMC1->GetMother(0);
2910  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
2911  if (TrueGammaCandidate1->IsConversion()){
2912  if(gammaMC1->GetMother(0) > -1) gamma1MotherLabel = fMCEvent->Particle(gammaMC1->GetMother(0))->GetMother(0);
2913  } else {
2914  gamma1MotherLabel=gammaMC1->GetMother(0);
2915  }
2916  }
2917  }
2918  }
2919 
2920  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
2921  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == fMesonPDG){
2922  isTrueMeson=kTRUE;
2923  }
2924  }
2925 
2926  if(isTrueMeson ){// True Meson
2927  if (fHistoTrueMesonInvMassPt[fiCut]) fHistoTrueMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
2928  if (fDoMesonQA > 0 && fDoMesonQA < 3 && fIsMC < 2){
2929  // both gammas are real gammas
2930  if (TrueGammaCandidate0->IsLargestComponentPhoton() && TrueGammaCandidate1->IsLargestComponentPhoton()) {
2931  if (fHistoTrueMesonCaloPhotonInvMassPt[fiCut]) fHistoTrueMesonCaloPhotonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
2932  }
2933  // both particles are electrons
2934  if (TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate1->IsLargestComponentElectron() ) {
2935  if (fHistoTrueMesonCaloElectronInvMassPt[fiCut]) fHistoTrueMesonCaloElectronInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
2936  }
2937  // both particles are converted electrons
2938  if ((TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion()) && (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()) ){
2939  fHistoTrueMesonCaloConvertedPhotonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
2940  }
2941  // 1 gamma is converted the other one is normals
2942  if ( (TrueGammaCandidate0->IsLargestComponentPhoton() && TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()) ||
2943  (TrueGammaCandidate1->IsLargestComponentPhoton() && TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion())
2944  ) {
2945  fHistoTrueMesonCaloMixedPhotonConvPhotonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
2946  }
2947 
2948  // at least one of the photon is merged
2949  if (TrueGammaCandidate0->IsMerged() || TrueGammaCandidate0->IsMergedPartConv() || TrueGammaCandidate0->IsDalitzMerged() || TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged() ){
2950  if (fHistoTrueMesonCaloMergedClusterInvMassPt[fiCut]) fHistoTrueMesonCaloMergedClusterInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
2951  }
2952  // at least one of the photon is merged and part conv
2953  if (TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate0->IsMergedPartConv()) {
2955  }
2956  }
2957 
2958  if (fDoMesonQA > 0 && fDoMesonQA < 3){
2959  if ( mesonCand->M() > fMesonInvMassWindow[0] && mesonCand->M() < fMesonInvMassWindow[1] ){
2960  if (fHistoTrueMesonPtY[fiCut]) fHistoTrueMesonPtY[fiCut]->Fill(mesonCand->Pt(),mesonCand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), fWeightJetJetMC);
2961  if (fHistoTrueMesonPtAlpha[fiCut]) fHistoTrueMesonPtAlpha[fiCut]->Fill(mesonCand->Pt(),TMath::Abs(mesonCand->GetAlpha()), fWeightJetJetMC);
2962  if (fHistoTrueMesonPtOpenAngle[fiCut]) fHistoTrueMesonPtOpenAngle[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetOpeningAngle(), fWeightJetJetMC);
2963  }
2964 
2965  }
2966  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, gamma0MotherLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2967  if(isPrimary){ // Only primary pi0 for efficiency calculation
2968  // filling primary histograms
2969  Float_t weighted= 1;
2970  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCEvent, fInputEvent)){
2971  if (((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt()>0.005){
2972  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, fMCEvent, fInputEvent);
2973  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
2974  }
2975  }
2976  if (isTrueMeson){
2977  if (fHistoTruePrimaryMesonInvMassPt[fiCut]) fHistoTruePrimaryMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),weighted* fWeightJetJetMC);
2979  if (fProfileTruePrimaryMesonWeightsInvMassPt[fiCut]) fProfileTruePrimaryMesonWeightsInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),weighted* fWeightJetJetMC);
2980  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueMesons,gamma0MotherLabel) && fHistoDoubleCountTrueMesonInvMassPt[fiCut]) fHistoDoubleCountTrueMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), weighted*fWeightJetJetMC);
2981  }
2982  if (fDoMesonQA > 0 && fDoMesonQA < 3 && fIsMC<2){
2983  if(isTrueMeson){ // Only primary pi0 for resolution
2984  if (fHistoTruePrimaryMesonMCPtResolPt[fiCut]) fHistoTruePrimaryMesonMCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(mesonCand->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted* fWeightJetJetMC);
2985  }
2986  }
2987  }
2988  } else if(!isTrueMeson ){ // Background
2989  if (fDoMesonQA > 1 && fDoMesonQA < 3){
2990  if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
2991  if (fHistoTrueBckGGInvMassPt[fiCut]) fHistoTrueBckGGInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
2992 
2993  if( (((TParticle*)fMCEvent->Particle(gamma0MotherLabel))->GetPdgCode() == fMesonPDG
2994  && (TrueGammaCandidate0->IsMerged() || TrueGammaCandidate0->IsMergedPartConv()))
2995  ||
2996  (((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == fMesonPDG
2997  && (TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv()))
2998  ){
3000  }else if( (TrueGammaCandidate0->E()/mesonCand->E() > 0.7) || (TrueGammaCandidate1->E()/mesonCand->E() > 0.7) ){
3001  if (fHistoTrueBckAsymEClustersInvMassPt[fiCut]) fHistoTrueBckAsymEClustersInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
3002  }
3003  } else { // No photon or without mother
3004  if (fHistoTrueBckContInvMassPt[fiCut]) fHistoTrueBckContInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
3005  }
3006  }
3007  }
3008 }
3009 
3010 //______________________________________________________________________
3012  AliAODConversionPhoton *TrueGammaCandidate0,
3013  AliAODConversionPhoton *TrueGammaCandidate1)
3014 {
3015  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3016  Double_t mcProdVtxX = primVtxMC->GetX();
3017  Double_t mcProdVtxY = primVtxMC->GetY();
3018  Double_t mcProdVtxZ = primVtxMC->GetZ();
3019 
3020  // Process True Mesons
3021  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3022  if (AODMCTrackArray == NULL) return;
3023 
3024  Bool_t isTrueMeson = kFALSE;
3025  Int_t gamma0MCLabel = TrueGammaCandidate0->GetCaloPhotonMCLabel(0); // get most probable MC label
3026  Int_t gamma0MotherLabel = -1;
3027 
3028  // check if
3029  AliAODMCParticle * gammaMC0 = 0x0;
3030  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3031  // Daughters Gamma 0
3032  gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3033  if (TrueGammaCandidate0->IsLargestComponentPhoton() || TrueGammaCandidate0->IsLargestComponentElectron()){ // largest component is electro magnetic
3034  // get mother of interest (pi0 or eta)
3035  if (TrueGammaCandidate0->IsLargestComponentPhoton()){ // for photons its the direct mother
3036  gamma0MotherLabel=gammaMC0->GetMother();
3037  } else if (TrueGammaCandidate0->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
3038  if (TrueGammaCandidate0->IsConversion()){
3039  AliAODMCParticle * gammaGrandMotherMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC0->GetMother()));
3040  gamma0MotherLabel=gammaGrandMotherMC0->GetMother();
3041  } else gamma0MotherLabel=gammaMC0->GetMother();
3042  }
3043  }
3044  }
3045 
3046  Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0); // get most probable MC label
3047  Int_t gamma1MotherLabel = -1;
3048 
3049  // check if
3050  AliAODMCParticle *gammaMC1 = 0x0;
3051  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3052  // Daughters Gamma 1
3053  gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3054  if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){ // largest component is electro magnetic
3055  // get mother of interest (pi0 or eta)
3056  if (TrueGammaCandidate1->IsLargestComponentPhoton()){ // for photons its the direct mother
3057  gamma1MotherLabel=gammaMC1->GetMother();
3058  } else if (TrueGammaCandidate1->IsLargestComponentElectron()){ // for electrons its either the direct mother or for conversions the grandmother
3059  if (TrueGammaCandidate1->IsConversion()){
3060  AliAODMCParticle * gammaGrandMotherMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC1->GetMother()));
3061  gamma1MotherLabel=gammaGrandMotherMC1->GetMother();
3062  } else gamma1MotherLabel=gammaMC1->GetMother();
3063  }
3064  }
3065  }
3066 
3067  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3068  if(((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == fMesonPDG){
3069  isTrueMeson=kTRUE;
3070  }
3071  }
3072 
3073  if(isTrueMeson ){// True Meson
3074  if (fHistoTrueMesonInvMassPt[fiCut]) fHistoTrueMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
3075  if (fDoMesonQA > 0 && fDoMesonQA < 3 && fIsMC < 2){
3076  // both gammas are real gammas
3077  if (TrueGammaCandidate0->IsLargestComponentPhoton() && TrueGammaCandidate1->IsLargestComponentPhoton()) {
3078  if (fHistoTrueMesonCaloPhotonInvMassPt[fiCut]) fHistoTrueMesonCaloPhotonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
3079  }
3080  // both particles are electrons
3081  if (TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate1->IsLargestComponentElectron() ) {
3082  if (fHistoTrueMesonCaloElectronInvMassPt[fiCut]) fHistoTrueMesonCaloElectronInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
3083  }
3084  // both particles are converted electrons
3085  if ((TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion()) && (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()) ){
3086  fHistoTrueMesonCaloConvertedPhotonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
3087  }
3088  // 1 gamma is converted the other one is normals
3089  if ( (TrueGammaCandidate0->IsLargestComponentPhoton() && TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()) ||
3090  (TrueGammaCandidate1->IsLargestComponentPhoton() && TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion())
3091  ) {
3092  fHistoTrueMesonCaloMixedPhotonConvPhotonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
3093  }
3094 
3095  // at least one of the photon is merged
3096  if (TrueGammaCandidate0->IsMerged() || TrueGammaCandidate0->IsMergedPartConv() || TrueGammaCandidate0->IsDalitzMerged() || TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged() ){
3097  if (fHistoTrueMesonCaloMergedClusterInvMassPt[fiCut]) fHistoTrueMesonCaloMergedClusterInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
3098  }
3099  // at least one of the photon is merged and part conv
3100  if (TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate0->IsMergedPartConv()) {
3102  }
3103  }
3104 
3105  if (fDoMesonQA > 0 && fDoMesonQA < 3){
3106  if ( mesonCand->M() > fMesonInvMassWindow[0] && mesonCand->M() < fMesonInvMassWindow[1] ){
3107  if (fHistoTrueMesonPtY[fiCut]) fHistoTrueMesonPtY[fiCut]->Fill(mesonCand->Pt(),mesonCand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), fWeightJetJetMC);
3108  if (fHistoTrueMesonPtAlpha[fiCut]) fHistoTrueMesonPtAlpha[fiCut]->Fill(mesonCand->Pt(),TMath::Abs(mesonCand->GetAlpha()), fWeightJetJetMC);
3109  if (fHistoTrueMesonPtOpenAngle[fiCut]) fHistoTrueMesonPtOpenAngle[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetOpeningAngle(), fWeightJetJetMC);
3110  }
3111  }
3112 
3113  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel)), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3114  if(isPrimary){ // Only primary pi0 for efficiency calculation
3115  Float_t weighted= 1;
3116  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, 0x0, fInputEvent)){
3117  if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt()>0.005){
3118  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, 0x0, fInputEvent);
3119  }
3120  }
3121 
3122  if (fHistoTruePrimaryMesonInvMassPt[fiCut]) fHistoTruePrimaryMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),weighted* fWeightJetJetMC);
3124  if (fProfileTruePrimaryMesonWeightsInvMassPt[fiCut]) fProfileTruePrimaryMesonWeightsInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),weighted* fWeightJetJetMC);
3125  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueMesons,gamma0MotherLabel) && fHistoDoubleCountTrueMesonInvMassPt[fiCut]) fHistoDoubleCountTrueMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), weighted*fWeightJetJetMC);
3126  if (fDoMesonQA > 0 && fDoMesonQA < 3 && fIsMC<2){
3127  if (fHistoTruePrimaryMesonMCPtResolPt[fiCut]) fHistoTruePrimaryMesonMCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
3128  (mesonCand->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted* fWeightJetJetMC);
3129  }
3130  }
3131  } else if(!isTrueMeson ) { // Background
3132  if (fDoMesonQA > 1 && fDoMesonQA < 3){
3133  if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
3134  if (fHistoTrueBckGGInvMassPt[fiCut]) fHistoTrueBckGGInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
3135 
3136  if( (((AliAODMCParticle*)AODMCTrackArray->At(gamma0MotherLabel))->GetPdgCode() == fMesonPDG
3137  && (TrueGammaCandidate0->IsMerged() || TrueGammaCandidate0->IsMergedPartConv()))
3138  ||
3139  (((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == fMesonPDG
3140  && (TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv()))
3141  ){
3143  }else if( (TrueGammaCandidate0->E()/mesonCand->E() > 0.7) || (TrueGammaCandidate1->E()/mesonCand->E() > 0.7) ){
3144  if (fHistoTrueBckAsymEClustersInvMassPt[fiCut]) fHistoTrueBckAsymEClustersInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
3145  }
3146  } else { // No photon or without mother
3147  if (fHistoTrueBckContInvMassPt[fiCut]) fHistoTrueBckContInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
3148  }
3149  }
3150  }
3151 }
3152 
3153 
3154 //______________________________________________________________________
3156  AliAODConversionPhoton *TrueGammaCandidate0,
3157  AliAODConversionPhoton *TrueGammaCandidate1)
3158 {
3159  // Process True Mesons
3160  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3161  Double_t mcProdVtxX = primVtxMC->GetX();
3162  Double_t mcProdVtxY = primVtxMC->GetY();
3163  Double_t mcProdVtxZ = primVtxMC->GetZ();
3164 
3165  if(TrueGammaCandidate0->GetV0Index()<fInputEvent->GetNumberOfV0s()){
3166  Bool_t isTrueMeson = kFALSE;
3167  Bool_t isTrueMesonDalitz = kFALSE;
3168  Bool_t gamma0DalitzCand = kFALSE;
3169  Bool_t gamma1DalitzCand = kFALSE;
3170  Int_t gamma0MCLabel = TrueGammaCandidate0->GetMCParticleLabel(fMCEvent);
3171  Int_t gamma0MotherLabel = -1;
3172  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3173  // Daughters Gamma 0
3174  TParticle * negativeMC = (TParticle*)TrueGammaCandidate0->GetNegativeMCDaughter(fMCEvent);
3175  TParticle * positiveMC = (TParticle*)TrueGammaCandidate0->GetPositiveMCDaughter(fMCEvent);
3176  TParticle * gammaMC0 = (TParticle*)fMCEvent->Particle(gamma0MCLabel);
3177  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3178  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
3179  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
3180  gamma0MotherLabel=gammaMC0->GetFirstMother();
3181  }
3182  }
3183  if(gammaMC0->GetPdgCode() ==fMesonPDG){ // Dalitz candidate
3184  gamma0DalitzCand = kTRUE;
3185  gamma0MotherLabel=-fMesonPDG;
3186  }
3187  }
3188  }
3189  if(TrueGammaCandidate1->GetV0Index()<fInputEvent->GetNumberOfV0s()){
3190  Int_t gamma1MCLabel = TrueGammaCandidate1->GetMCParticleLabel(fMCEvent);
3191  Int_t gamma1MotherLabel = -1;
3192  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3193  // Daughters Gamma 1
3194  TParticle * negativeMC = (TParticle*)TrueGammaCandidate1->GetNegativeMCDaughter(fMCEvent);
3195  TParticle * positiveMC = (TParticle*)TrueGammaCandidate1->GetPositiveMCDaughter(fMCEvent);
3196  TParticle * gammaMC1 = (TParticle*)fMCEvent->Particle(gamma1MCLabel);
3197  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3198  if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
3199  if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
3200  gamma1MotherLabel=gammaMC1->GetFirstMother();
3201  }
3202  }
3203  if(gammaMC1->GetPdgCode() ==fMesonPDG ){ // Dalitz candidate
3204  gamma1DalitzCand = kTRUE;
3205  gamma1MotherLabel=-fMesonPDG;
3206  }
3207  }
3208  }
3209  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3210  if(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->GetPdgCode() == fMesonPDG){
3211  isTrueMeson=kTRUE;
3215  }
3216  }
3217  }
3218 
3219  //Identify Dalitz candidate
3220  if (gamma1DalitzCand || gamma0DalitzCand){
3221  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
3222  if (gamma0MotherLabel == -fMesonPDG) isTrueMesonDalitz = kTRUE;
3223  }
3224  if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
3225  if (gamma1MotherLabel == -fMesonPDG) isTrueMesonDalitz = kTRUE;
3226  }
3227  }
3228 
3229 
3230  if(isTrueMeson ){// True Meosn
3231  if (fHistoTrueMesonInvMassPt[fiCut])fHistoTrueMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),fWeightJetJetMC);
3232  if (fDoMesonQA > 0){
3233  if ( mesonCand->M() > fMesonInvMassWindow[0] && mesonCand->M() < fMesonInvMassWindow[1]){
3234  if(fIsMC < 2){
3235  if (fHistoTrueMesonPtY[fiCut]) fHistoTrueMesonPtY[fiCut]->Fill(mesonCand->Pt(),mesonCand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3236  if (fHistoTrueMesonPtOpenAngle[fiCut]) fHistoTrueMesonPtOpenAngle[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetOpeningAngle());
3237  if (fHistoTrueMesonPtAlpha[fiCut]) fHistoTrueMesonPtAlpha[fiCut]->Fill(mesonCand->Pt(),TMath::Abs(mesonCand->GetAlpha()),fWeightJetJetMC);
3238  }
3239  }
3240  }
3241  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, gamma0MotherLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3242  if(isPrimary){ // Only primary pi0 for efficiency calculation
3243  Float_t weighted= 1;
3244  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCEvent, fInputEvent)){
3245  if (((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt()>0.005){
3246  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, fMCEvent, fInputEvent);
3247  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3248  }
3249  }
3250  if (fHistoTruePrimaryMesonInvMassPt[fiCut]) fHistoTruePrimaryMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),weighted*fWeightJetJetMC);
3252  if (fProfileTruePrimaryMesonWeightsInvMassPt[fiCut]) fProfileTruePrimaryMesonWeightsInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),weighted*fWeightJetJetMC);
3253 
3254  if (fDoMesonQA > 0 && fIsMC < 2){
3255  if (fHistoTruePrimaryMesonMCPtResolPt[fiCut]) fHistoTruePrimaryMesonMCPtResolPt[fiCut]->Fill(((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),(mesonCand->Pt()-((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt())/((TParticle*)fMCEvent->Particle(gamma1MotherLabel))->Pt(),weighted);
3256  }
3257  }
3258  } else if(!isTrueMeson ){ // Background
3259  if (fDoMesonQA > 1 && fIsMC < 2){
3260  if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
3261  if (fHistoTrueBckGGInvMassPt[fiCut])fHistoTrueBckGGInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
3262  } else { // No photon or without mother
3263  if (fHistoTrueBckContInvMassPt[fiCut]) fHistoTrueBckContInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
3264  }
3265  }
3266  if (!isTrueMesonDalitz && (gamma0DalitzCand || gamma1DalitzCand)){
3267  if (fDoMesonQA > 1 && fIsMC < 2 && fHistoTrueBckContInvMassPt[fiCut]) fHistoTrueBckContInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
3268  }
3269  }
3270  }
3271  }
3272 }
3273 
3274 //______________________________________________________________________
3276  AliAODConversionPhoton *TrueGammaCandidate0,
3277  AliAODConversionPhoton *TrueGammaCandidate1)
3278 {
3279  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
3280  Double_t mcProdVtxX = primVtxMC->GetX();
3281  Double_t mcProdVtxY = primVtxMC->GetY();
3282  Double_t mcProdVtxZ = primVtxMC->GetZ();
3283 
3284  // Process True Mesons
3285  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3286  Bool_t isTrueMeson = kFALSE;
3287  Bool_t isTrueMesonDalitz = kFALSE;
3288  Bool_t gamma0DalitzCand = kFALSE;
3289  Bool_t gamma1DalitzCand = kFALSE;
3290 
3291  if (AODMCTrackArray!=NULL && TrueGammaCandidate0 != NULL){
3292  AliAODMCParticle *positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelPositive()));
3293  AliAODMCParticle *negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate0->GetMCLabelNegative()));
3294 
3295  Int_t gamma0MCLabel = -1;
3296  Int_t gamma0MotherLabel = -1;
3297  if(!positiveMC||!negativeMC)
3298  return;
3299 
3300  if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
3301  gamma0MCLabel = positiveMC->GetMother();
3302  }
3303 
3304  if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3305  // Daughters Gamma 0
3306  AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
3307  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3308  if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
3309  if(gammaMC0->GetPdgCode() == 22){ // ... with Gamma Mother
3310  gamma0MotherLabel=gammaMC0->GetMother();
3311  }
3312  }
3313  if(gammaMC0->GetPdgCode() ==fMesonPDG){ // Dalitz candidate
3314  gamma0DalitzCand = kTRUE;
3315  gamma0MotherLabel=-fMesonPDG;
3316  }
3317  }
3318  }
3319  positiveMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelPositive()));
3320  negativeMC = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(TrueGammaCandidate1->GetMCLabelNegative()));
3321 
3322  Int_t gamma1MCLabel = -1;
3323  Int_t gamma1MotherLabel = -1;
3324  if(!positiveMC||!negativeMC)
3325  return;
3326 
3327  if(positiveMC->GetMother()>-1&&(negativeMC->GetMother() == positiveMC->GetMother())){
3328  gamma1MCLabel = positiveMC->GetMother();
3329  }
3330  if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
3331  // Daughters Gamma 1
3332  AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
3333  if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){ // Electrons ...
3334  if(((positiveMC->GetMCProcessCode())) == 5 && ((negativeMC->GetMCProcessCode())) == 5){ // ... From Conversion ...
3335  if(gammaMC1->GetPdgCode() == 22){ // ... with Gamma Mother
3336  gamma1MotherLabel=gammaMC1->GetMother();
3337  }
3338  }
3339  if(gammaMC1->GetPdgCode() ==fMesonPDG ){ // Dalitz candidate
3340  gamma1DalitzCand = kTRUE;
3341  gamma1MotherLabel=-fMesonPDG;
3342  }
3343  }
3344  }
3345  if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
3346  if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == fMesonPDG){
3347  isTrueMeson=kTRUE;
3351  }
3352  }
3353  }
3354 
3355  //Identify Dalitz candidate
3356  if (gamma1DalitzCand || gamma0DalitzCand){
3357  if (gamma0DalitzCand && gamma0MCLabel >=0 && gamma0MCLabel==gamma1MotherLabel){
3358  if (gamma0MotherLabel == -fMesonPDG) isTrueMesonDalitz = kTRUE;
3359  }
3360  if (gamma1DalitzCand && gamma1MCLabel >=0 && gamma1MCLabel==gamma0MotherLabel){
3361  if (gamma1MotherLabel == -fMesonPDG) isTrueMesonDalitz = kTRUE;
3362  }
3363  }
3364 
3365  if(isTrueMeson ){// True Meson
3366  if (fHistoTrueMesonInvMassPt[fiCut])fHistoTrueMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),fWeightJetJetMC);
3367  if (fDoMesonQA > 0){
3368  if ( mesonCand->M() > fMesonInvMassWindow[0] && mesonCand->M() < fMesonInvMassWindow[1]){
3369  if(fIsMC < 2){
3370  if (fHistoTrueMesonPtY[fiCut]) fHistoTrueMesonPtY[fiCut]->Fill(mesonCand->Pt(),mesonCand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
3371  if (fHistoTrueMesonPtOpenAngle[fiCut]) fHistoTrueMesonPtOpenAngle[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetOpeningAngle());
3372  }
3373  if (fHistoTrueMesonPtAlpha[fiCut]) fHistoTrueMesonPtAlpha[fiCut]->Fill(mesonCand->Pt(),TMath::Abs(mesonCand->GetAlpha()),fWeightJetJetMC);
3374  }
3375 
3376  }
3377  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel)), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
3378 
3379  if(isPrimary){ // Only primary pi0 for efficiency calculation
3380  Float_t weighted= 1;
3381  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, 0x0, fInputEvent)){
3382  if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt()>0.005){
3383  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(gamma1MotherLabel, 0x0, fInputEvent);
3384  // cout << "rec \t " <<gamma1MotherLabel << "\t" << weighted << endl;
3385  }
3386  }
3387  if (fHistoTruePrimaryMesonInvMassPt[fiCut]) fHistoTruePrimaryMesonInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),weighted*fWeightJetJetMC);
3389  if (fProfileTruePrimaryMesonWeightsInvMassPt[fiCut]) fProfileTruePrimaryMesonWeightsInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),weighted*fWeightJetJetMC);
3390 
3391  if (fDoMesonQA > 0 && fIsMC < 2){
3392  if (fHistoTruePrimaryMesonMCPtResolPt[fiCut])fHistoTruePrimaryMesonMCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
3393  (mesonCand->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
3394  }
3395  }
3396  } else if(!isTrueMeson ) { // Background
3397  if (fDoMesonQA > 1 && fIsMC < 2){
3398  if(!(gamma0MotherLabel>-1 && gamma1MotherLabel>-1)){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
3399  if (fHistoTrueBckGGInvMassPt[fiCut])fHistoTrueBckGGInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
3400  } else { // No photon or without mother
3401  if (fHistoTrueBckContInvMassPt[fiCut]) fHistoTrueBckContInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
3402  }
3403  }
3404  if (!isTrueMesonDalitz && (gamma0DalitzCand || gamma1DalitzCand)){
3405  if (fDoMesonQA > 1 && fIsMC < 2)if (fHistoTrueBckContInvMassPt[fiCut]) fHistoTrueBckContInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt());
3406  }
3407  }
3408  }
3409  return;
3410 }
3411 
3412 
3413 //________________________________________________________________________
3415 
3416  // set current BG handler
3417  AliGammaConversionAODBGHandler* currBGHandler = NULL;
3418  TList* currPhotonList = NULL;
3419  if (fMesonRecoMode == 0){
3420  currBGHandler = fBGHandler[fiCut];
3421  currPhotonList = fGammaCandidates;
3422  } else if (fMesonRecoMode == 1){
3423  currBGHandler = fBGClusHandler[fiCut];
3424  currPhotonList = fGammaCandidates;
3425  } else if (fMesonRecoMode == 2){
3426  currBGHandler = fBGClusHandler[fiCut];
3427  currPhotonList = fClusterCandidates;
3428  }
3429 
3430  Int_t zbin = currBGHandler->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3431  Int_t mbin = 0;
3432  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3434  } else {
3435  mbin = currBGHandler->GetMultiplicityBinIndex(currPhotonList->GetEntries());
3436  }
3437 
3439  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3440  for(Int_t nEventsInBG=0;nEventsInBG<currBGHandler->GetNBGEvents();nEventsInBG++){
3441  AliGammaConversionAODVector *previousEventV0s = currBGHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);
3442  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3443  bgEventVertex = currBGHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
3444  }
3445  for(Int_t iCurrent=0;iCurrent<currPhotonList->GetEntries();iCurrent++){
3446  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(currPhotonList->At(iCurrent));
3447  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3448  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
3449  if(fMoveParticleAccordingToVertex == kTRUE){
3450  if (bgEventVertex){
3451  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3452  }
3453  }
3454  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3455  if (bgEventVertex){
3456  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
3457  }
3458  }
3459 
3460  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
3461  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3462  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3463  if (fHistoMotherBackInvMassPt[fiCut]) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(),fWeightJetJetMC);
3464  if(fDoTHnSparse){
3465  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3466  if (fSparseMotherBackInvMassPtZM[fiCut]) fSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
3467  }
3468  }
3469  delete backgroundCandidate;
3470  backgroundCandidate = 0x0;
3471  }
3472  }
3473  }
3474  }else {
3475  for(Int_t nEventsInBG=0;nEventsInBG <currBGHandler->GetNBGEvents();nEventsInBG++){
3476  AliGammaConversionAODVector *previousEventV0s = currBGHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);
3477  if(previousEventV0s){
3478  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0 ){
3479  bgEventVertex = currBGHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
3480  }
3481  for(Int_t iCurrent=0;iCurrent<currPhotonList->GetEntries();iCurrent++){
3482  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(currPhotonList->At(iCurrent));
3483  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
3484 
3485  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
3486 
3487  if(fMoveParticleAccordingToVertex == kTRUE){
3488  if (bgEventVertex){
3489  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
3490  }
3491  }
3492  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
3493  if (bgEventVertex){
3494  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
3495  }
3496  }
3497 
3498  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
3499  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3500  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
3501  if (fHistoMotherBackInvMassPt[fiCut]) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(),fWeightJetJetMC);
3502  if(fDoTHnSparse){
3503  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
3504  if (fSparseMotherBackInvMassPtZM[fiCut]) fSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
3505  }
3506  }
3507  delete backgroundCandidate;
3508  backgroundCandidate = 0x0;
3509  }
3510  }
3511  }
3512  }
3513  }
3514 }
3515 
3516 //________________________________________________________________________
3518 
3519  // set current BG handler
3520  AliConversionAODBGHandlerRP* currBGHandler = NULL;
3521  TList* currPhotonList = NULL;
3522  if (fMesonRecoMode == 0){
3523  currBGHandler = fBGHandlerRP[fiCut];
3524  currPhotonList = fGammaCandidates;
3525  } else if (fMesonRecoMode == 1){
3526  currBGHandler = fBGClusHandlerRP[fiCut];
3527  currPhotonList = fGammaCandidates;
3528  } else if (fMesonRecoMode == 2){
3529  currBGHandler = fBGClusHandlerRP[fiCut];
3530  currPhotonList = fClusterCandidates;
3531  }
3532 
3533  Int_t zbin = currBGHandler->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
3534  Int_t mbin = 0;
3535  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3537  } else {
3538  mbin = currBGHandler->GetMultiplicityBinIndex(currPhotonList->GetEntries());
3539  }
3540 
3541  //Rotation Method
3542  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseRotationMethod()){
3543  // Correct for the number of rotations
3544  // BG is for rotation the same, except for factor NRotations
3545  Double_t weight=1./Double_t(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents());
3546  for(Int_t firstGammaIndex=0;firstGammaIndex<currPhotonList->GetEntries();firstGammaIndex++){
3547  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(currPhotonList->At(firstGammaIndex));
3548  if (gamma0==NULL) continue;
3549  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<currPhotonList->GetEntries();secondGammaIndex++){
3550  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(currPhotonList->At(secondGammaIndex));
3551  if (gamma1 == NULL) continue;
3552  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelected(gamma1,fInputEvent))continue;
3553  for(Int_t nRandom=0;nRandom<((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents();nRandom++){
3554  RotateParticle(gamma1);
3555  AliAODConversionMother backgroundCandidate(gamma0,gamma1);
3556  backgroundCandidate.CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3557  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(&backgroundCandidate, kFALSE, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3558  if (fHistoMotherBackInvMassPt[fiCut]) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt(),fWeightJetJetMC);
3559  if(fDoTHnSparse){
3560  Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)mbin};
3561  if (fSparseMotherBackInvMassPtZM[fiCut]) fSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,weight);
3562  }
3563  }
3564  }
3565  }
3566  }
3567 
3568  }else {
3569  // Do Event Mixing
3570  for(Int_t nEventsInBG=0;nEventsInBG <currBGHandler->GetNBGEvents(currPhotonList,fInputEvent);nEventsInBG++){
3571  AliGammaConversionPhotonVector *previousEventGammas = currBGHandler->GetBGGoodGammas(currPhotonList,fInputEvent,nEventsInBG);
3572  if(previousEventGammas){
3573  // test weighted background
3574  Double_t weight=1.0;
3575  // Correct for the number of eventmixing:
3576  // N gammas -> (N-1) + (N-2) +(N-3) ...+ (N-(N-1)) using sum formula sum(i)=N*(N-1)/2 -> N*(N-1)/2
3577  // real combinations (since you cannot combine a photon with its own)
3578  // but BG leads to N_{a}*N_{b}combinations
3579  weight*=0.5*(Double_t(currPhotonList->GetEntries()-1))/Double_t(previousEventGammas->size());
3580 
3581  for(Int_t iCurrent=0;iCurrent<currPhotonList->GetEntries();iCurrent++){
3582  AliAODConversionPhoton *gamma0 = (AliAODConversionPhoton*)(currPhotonList->At(iCurrent));
3583  for(UInt_t iPrevious=0;iPrevious<previousEventGammas->size();iPrevious++){
3584  AliAODConversionPhoton *gamma1 = (AliAODConversionPhoton*)(previousEventGammas->at(iPrevious));
3585  AliAODConversionMother backgroundCandidate(gamma0,gamma1);
3586  backgroundCandidate.CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
3588  ->MesonIsSelected(&backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
3589  if (fHistoMotherBackInvMassPt[fiCut]) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt(),fWeightJetJetMC);
3590  if(fDoTHnSparse){
3591  Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)mbin};
3592  if (fSparseMotherBackInvMassPtZM[fiCut]) fSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,weight);
3593  }
3594  }
3595  }
3596  }
3597  }
3598  }
3599  }
3600 }
3601 
3602 //________________________________________________________________________
3604  Int_t fNDegreesPMBackground= ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->NDegreesRotation();
3605  Double_t nRadiansPM = fNDegreesPMBackground*TMath::Pi()/180;
3606  Double_t rotationValue = fRandom.Rndm()*2*nRadiansPM + TMath::Pi()-nRadiansPM;
3607  gamma->RotateZ(rotationValue);
3608 }
3609 
3610 //________________________________________________________________________
3612  previousEventEP=previousEventEP+TMath::Pi();
3613  thisEventEP=thisEventEP+TMath::Pi();
3614  Double_t rotationValue= thisEventEP-previousEventEP;
3615  gamma->RotateZ(rotationValue);
3616 }
3617 
3618 //________________________________________________________________________
3620  //see header file for documentation
3621 
3622  Double_t dx = vertex->fX - fInputEvent->GetPrimaryVertex()->GetX();
3623  Double_t dy = vertex->fY - fInputEvent->GetPrimaryVertex()->GetY();
3624  Double_t dz = vertex->fZ - fInputEvent->GetPrimaryVertex()->GetZ();
3625 
3626  Double_t movedPlace[3] = {particle->GetConversionX() - dx,particle->GetConversionY() - dy,particle->GetConversionZ() - dz};
3627  particle->SetConversionPoint(movedPlace);
3628 }
3629 //________________________________________________________________________
3631  //see header file for documentation
3632  if(fGammaCandidates->GetEntries() >0 && fMesonRecoMode == 0 ){
3633  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3634  fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
3636  }else { // means we use #V0s for multiplicity
3637  fBGHandler[fiCut]->AddEvent(fGammaCandidates, fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
3638  fGammaCandidates->GetEntries(), fEventPlaneAngle);
3639  }
3640  } else if((fGammaCandidates->GetEntries() >0 || fClusterCandidates->GetEntries() > 0 ) && fMesonRecoMode == 1 ){
3641  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3642  fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
3644  fBGClusHandler[fiCut]->AddEvent(fClusterCandidates,fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
3646  }else { // means we use #V0s for multiplicity
3647  fBGHandler[fiCut]->AddEvent(fGammaCandidates, fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
3648  fGammaCandidates->GetEntries(), fEventPlaneAngle);
3649  fBGClusHandler[fiCut]->AddEvent(fClusterCandidates, fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
3650  fGammaCandidates->GetEntries(), fEventPlaneAngle);
3651  }
3652  } else if(fClusterCandidates->GetEntries() >0 && fMesonRecoMode == 2 ){
3653  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
3654  fBGClusHandler[fiCut]->AddEvent(fClusterCandidates,fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
3656  }else { // means we use #V0s for multiplicity
3657  fBGClusHandler[fiCut]->AddEvent(fClusterCandidates, fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
3658  fGammaCandidates->GetEntries(), fEventPlaneAngle);
3659  }
3660  }
3661 }
3662 
3663 //________________________________________________________________________
3665 
3666  // Relabeling For AOD Event
3667  // ESDiD -> AODiD
3668  // MCLabel -> AODMCLabel
3669 
3670  if(mode){
3671  fMCEventPos = new Int_t[fReaderGammas->GetEntries()];
3672  fMCEventNeg = new Int_t[fReaderGammas->GetEntries()];
3673  fESDArrayPos = new Int_t[fReaderGammas->GetEntries()];
3674  fESDArrayNeg = new Int_t[fReaderGammas->GetEntries()];
3675  }
3676 
3677  for(Int_t iGamma = 0;iGamma<fReaderGammas->GetEntries();iGamma++){
3678  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(iGamma);
3679  if(!PhotonCandidate) continue;
3680  if(!mode){// Back to ESD Labels
3681  PhotonCandidate->SetMCLabelPositive(fMCEventPos[iGamma]);
3682  PhotonCandidate->SetMCLabelNegative(fMCEventNeg[iGamma]);
3683  PhotonCandidate->SetLabelPositive(fESDArrayPos[iGamma]);
3684  PhotonCandidate->SetLabelNegative(fESDArrayNeg[iGamma]);
3685  continue;
3686  }
3687  fMCEventPos[iGamma] = PhotonCandidate->GetMCLabelPositive();
3688  fMCEventNeg[iGamma] = PhotonCandidate->GetMCLabelNegative();
3689  fESDArrayPos[iGamma] = PhotonCandidate->GetTrackLabelPositive();
3690  fESDArrayNeg[iGamma] = PhotonCandidate->GetTrackLabelNegative();
3691 
3692  Bool_t AODLabelPos = kFALSE;
3693  Bool_t AODLabelNeg = kFALSE;
3694 
3695  for(Int_t i = 0; i<fInputEvent->GetNumberOfTracks();i++){
3696  AliAODTrack *tempDaughter = static_cast<AliAODTrack*>(fInputEvent->GetTrack(i));
3697  if(!AODLabelPos){
3698  if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelPositive() ){
3699  PhotonCandidate->SetMCLabelPositive(TMath::Abs(tempDaughter->GetLabel()));
3700  PhotonCandidate->SetLabelPositive(i);
3701  AODLabelPos = kTRUE;
3702  }
3703  }
3704  if(!AODLabelNeg){
3705  if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelNegative()){
3706  PhotonCandidate->SetMCLabelNegative(TMath::Abs(tempDaughter->GetLabel()));
3707  PhotonCandidate->SetLabelNegative(i);
3708  AODLabelNeg = kTRUE;
3709  }
3710  }
3711  if(AODLabelNeg && AODLabelPos){
3712  break;
3713  }
3714  }
3715  if(!AODLabelPos || !AODLabelNeg){
3716  cout<<"WARNING!!! AOD TRACKS NOT FOUND FOR"<<endl;
3717  if(!AODLabelNeg){
3718  PhotonCandidate->SetMCLabelNegative(-999999);
3719  PhotonCandidate->SetLabelNegative(-999999);
3720  }
3721  if(!AODLabelPos){
3722  PhotonCandidate->SetMCLabelPositive(-999999);
3723  PhotonCandidate->SetLabelPositive(-999999);
3724  }
3725  }
3726  }
3727 
3728  if(!mode){
3729  delete[] fMCEventPos;
3730  delete[] fMCEventNeg;
3731  delete[] fESDArrayPos;
3732  delete[] fESDArrayNeg;
3733  }
3734 }
3735 
3736 //________________________________________________________________________
3738  TAxis *axisafter = histoRebin->GetXaxis();
3739  Int_t bins = axisafter->GetNbins();
3740  Double_t from = axisafter->GetXmin();
3741  Double_t to = axisafter->GetXmax();
3742  Double_t *newbins = new Double_t[bins+1];
3743  newbins[0] = from;
3744  Double_t factor = TMath::Power(to/from, 1./bins);
3745  for(Int_t i=1; i<=bins; ++i) newbins[i] = factor * newbins[i-1];
3746  axisafter->Set(bins, newbins);
3747  delete [] newbins;
3748 }
3749 
3750 //________________________________________________________________________
3752 {
3753  //fOutputContainer->Print(); // Will crash on GRID
3754 }
3755 
3756 //_________________________________________________________________________________
3758  if(tobechecked > -1){
3759  vector<Int_t>::iterator it;
3760  it = find (vec.begin(), vec.end(), tobechecked);
3761  if (it != vec.end()) return true;
3762  else return false;
3763  }
3764  return false;
3765 }
3766 
3767 //_________________________________________________________________________________
3769  if(tobechecked > -1){
3770  vector<Int_t>::iterator it;
3771  it = find (vec.begin(), vec.end(), tobechecked);
3772  if (it != vec.end()) return true;
3773  else{
3774  vec.push_back(tobechecked);
3775  return false;
3776  }
3777  }
3778  return false;
3779 }
3780 
3781 //_________________________________________________________________________________
3783  if( ma.find(tobechecked) != ma.end() ) ma[tobechecked] += 1;
3784  else ma[tobechecked] = 2;
3785  return;
3786 }
3787 
3788 //_________________________________________________________________________________
3790  map<Int_t, Int_t>::iterator it;
3791  for (it = ma.begin(); it != ma.end(); it++){
3792  hist->Fill(it->second, fWeightJetJetMC);
3793  }
3794  ma.clear();
3795  return;
3796 }
TParticle * GetMCParticle(AliMCEvent *mcEvent)
TH1F ** fHistoClusOverlapHeadersGammaPt
array of histos with cluster, E
TH1F ** fHistoNGammaConvCandidates
array of histos with vertex y distribution for selected events
virtual Double_t GetPhotonPhi() const
TH2F ** fHistoSPDClusterTrackletBackground
array of histos with number of calo gamma candidates per event
TH1F ** fHistoVertexX
array of histos with vertex z distribution for selected events
TH2F ** fHistoTrueMesonCaloMergedClusterPartConvInvMassPt
array of histos with validated mothers, merged cluster invMass, pt
void SetCaloClusterRef(Long_t ref)
void SetLabels(Int_t label1, Int_t label2, Int_t label3=0)
double Double_t
Definition: External.C:58
Bool_t CheckVectorForDoubleCount(vector< Int_t > &vec, Int_t tobechecked)
GammaConversionVertex * GetBGEventVertex(Int_t zbin, Int_t mbin, Int_t event)
TH1F ** fHistoMCMesonWOWeightInAccPt
array of histos with weighted meson in acceptance, pT
Definition: External.C:236
void SetCaloPhotonMCFlags(AliMCEvent *mcEvent, Bool_t enableSort)
void SetConversionPoint(Double_t convpoint[3])