AliPhysics  e6c8d43 (e6c8d43)
AliAnalysisTaskGammaCaloMerged.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: Friederike Bock *
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 "AliV0ReaderV1.h"
48 #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  fDoLightOutput(kFALSE),
70  fInputEvent(NULL),
71  fMCEvent(NULL),
72  fCutFolder(NULL),
73  fESDList(NULL),
74  fTrueList(NULL),
75  fMCList(NULL),
76  fHeaderNameList(NULL),
77  fOutputContainer(NULL),
78  fNClusterCandidates(0),
79  fNClusterMergedCandidates(0),
80  fEventCutArray(NULL),
81  fEventCuts(NULL),
82  fClusterCutArray(NULL),
83  fClusterMergedCutArray(NULL),
84  fMesonCutArray(NULL),
85  fMesonCuts(NULL),
86  fHistoMotherInvMassPt(NULL),
87  fHistoMotherPtY(NULL),
88  fHistoMotherPtAlpha(NULL),
89  fHistoClusGammaPt(NULL),
90  fHistoClusGammaE(NULL),
91  fHistoClusOverlapHeadersGammaPt(NULL),
92  fHistoClusNLMPt(NULL),
93  fHistoClusMergedPtvsM02(NULL),
94  fHistoClusMergedPtvsM02Accepted(NULL),
95  fHistoClusMergedEvsM02Accepted(NULL),
96  fHistoClusNCellsPt(NULL),
97  fHistoClusMergedNCellsPt(NULL),
98  fHistoClusMergedNParticlePt(NULL),
99  fHistoClusMergedNCellsAroundPt(NULL),
100  fHistoClusMergedNCellsAroundAndInPt(NULL),
101  fHistoClusMergedEAroundE(NULL),
102  fHistoMCHeaders(NULL),
103  fHistoMCPi0Pt(NULL),
104  fHistoMCPi0WOWeightPt(NULL),
105  fHistoMCPi0WOEvtWeightPt(NULL),
106  fHistoMCEtaPt(NULL),
107  fHistoMCEtaWOWeightPt(NULL),
108  fHistoMCEtaWOEvtWeightPt(NULL),
109  fHistoMCPi0DalitzPt(NULL),
110  fHistoMCPi0DalitzWOWeightPt(NULL),
111  fHistoMCPi0DalitzWOEvtWeightPt(NULL),
112  fHistoMCEtaDalitzPt(NULL),
113  fHistoMCEtaDalitzWOWeightPt(NULL),
114  fHistoMCEtaDalitzWOEvtWeightPt(NULL),
115  fHistoMCPi0InAccPt(NULL),
116  fHistoMCEtaInAccPt(NULL),
117  fHistoMCPi0WOEvtWeightInAccPt(NULL),
118  fHistoMCEtaWOEvtWeightInAccPt(NULL),
119  fHistoMCPi0DalitzInAccPt(NULL),
120  fHistoMCEtaDalitzInAccPt(NULL),
121  fHistoMCPi0DalitzWOEvtWeightInAccPt(NULL),
122  fHistoMCEtaDalitzWOEvtWeightInAccPt(NULL),
123  fHistoMCSecPi0PtvsSource(NULL),
124  fHistoMCSecPi0InAccPtvsSource(NULL),
125  fHistoMCPi0PtJetPt(NULL),
126  fHistoMCEtaPtJetPt(NULL),
127  fHistoMCPrimaryPtvsSource(NULL),
128  fHistoMCPrimaryYvsSource(NULL),
129  fHistoMCDecayGammaPt(NULL),
130  fHistoMCAllGammaPt(NULL),
131  fHistoTrueClusMergedPtvsM02(NULL),
132  fHistoTrueClusPi0PtvsM02(NULL),
133  fHistoTrueClusPi0DalitzPtvsM02(NULL),
134  fHistoTrueClusPrimPi0PtvsM02(NULL),
135  fHistoTrueClusSecPi0PtvsM02(NULL),
136  fHistoTrueClusSecPi0FromK0sPtvsM02(NULL),
137  fHistoTrueClusSecPi0FromK0lPtvsM02(NULL),
138  fHistoTrueClusSecPi0FromLambdaPtvsM02(NULL),
139  fHistoTrueClusEtaPtvsM02(NULL),
140  fHistoTrueClusEtaDalitzPtvsM02(NULL),
141  fHistoTrueClusMergedPureFromPi0PtvsM02(NULL),
142  fHistoTrueClusMergedPureFromEtaPtvsM02(NULL),
143  fHistoTrueClusMergedPartConvFromPi0PtvsM02(NULL),
144  fHistoTrueClusMergedPartConvFromEtaPtvsM02(NULL),
145  fHistoTrueClusGammaFromPi0PtvsM02(NULL),
146  fHistoTrueClusGammaFromEtaPtvsM02(NULL),
147  fHistoTrueClusElectronFromPi0PtvsM02(NULL),
148  fHistoTrueClusElectronFromEtaPtvsM02(NULL),
149  fHistoTrueSecPi0PtvsDiffReco(NULL),
150  fHistoTrueClusBGPtvsM02(NULL),
151  fHistoTrueClusGammaPtvsM02(NULL),
152  fHistoTrueClusGammaPartConvPtvsM02(NULL),
153  fHistoTrueClusElectronPtvsM02(NULL),
154  fHistoTrueClusElectronFromGammaPtvsM02(NULL),
155  fHistoTrueClusMergedInvMassvsPt(NULL),
156  fHistoTrueClusPi0InvMassvsPt(NULL),
157  fHistoTrueClusPrimPi0InvMassvsPt(NULL),
158  fHistoTrueClusEtaInvMassvsPt(NULL),
159  fHistoTrueClusBGInvMassvsPt(NULL),
160  fHistoTrueClusGammaInvMassvsPt(NULL),
161  fHistoTrueClusElectronInvMassvsPt(NULL),
162  fHistoTrueClusBGPtvsSource(NULL),
163  fHistoTrueClusGammaPtvsSource(NULL),
164  fHistoTrueClusElectronPtvsSource(NULL),
165 // fHistoTrueClusElectronPtvsMotherID(NULL),
166 // fHistoTrueClusElectronPtvsTopMotherID(NULL),
167 // fHistoTrueClusElectronPtvsConvPhotonTopMotherID(NULL),
168  fHistoTrueMergedMissedPDG(NULL),
169  fHistoTruePi0PtY(NULL),
170  fHistoTrueEtaPtY(NULL),
171  fHistoTruePi0PtAlpha(NULL),
172  fHistoTrueEtaPtAlpha(NULL),
173  fHistoTrueClusGammaEM02(NULL),
174  fHistoTrueClusElectronEM02(NULL),
175  fHistoTrueClusPi0EM02(NULL),
176  fHistoTrueClusEtaEM02(NULL),
177  fHistoTruePrimaryPi0PureMergedMCPtResolPt(NULL),
178  fHistoTruePrimaryPi0MergedPartConvMCPtResolPt(NULL),
179  fHistoTruePrimaryPi01GammaMCPtResolPt(NULL),
180  fHistoTruePrimaryPi01ElectronMCPtResolPt(NULL),
181  fHistoTruePrimaryEtaMCPtResolPt(NULL),
182  fHistoTrueSecondaryPi0MCPtResolPt(NULL),
183  fHistoDoubleCountTruePi0PtvsM02(NULL),
184  fHistoDoubleCountTrueSecPi0Pt(NULL),
185  fHistoDoubleCountTrueEtaPtvsM02(NULL),
186  fVectorDoubleCountTruePi0s(0),
187  fVectorDoubleCountTrueEtas(0),
188  fHistoNEvents(NULL),
189  fHistoNEventsWOWeight(NULL),
190  fHistoNGoodESDTracks(NULL),
191  fHistoVertexZ(NULL),
192  fHistoNClusterCandidates(NULL),
193  fHistoNClusterMergedCandidates(NULL),
194  fHistoNGoodESDTracksVsNClusterCandidates(NULL),
195  fHistoSPDClusterTrackletBackground(NULL),
196  fHistoNV0Tracks(NULL),
197  fProfileEtaShift(NULL),
198  fProfileJetJetXSection(NULL),
199  fHistoJetJetNTrials(NULL),
200  fRandom(0),
201  fnCuts(0),
202  fiCut(0),
203  fIsHeavyIon(0),
204  fDoMesonQA(0),
205  fDoClusterQA(0),
206  fIsFromMBHeader(kTRUE),
207  fIsOverlappingWithOtherHeader(kFALSE),
208  fIsMC(0),
209  fSetPlotHistsExtQA(kFALSE),
210  fWeightJetJetMC(1),
211  fSelectedMesonID(0),
212  fEnableDetailedPrintOut(kFALSE),
213  fEnableSortForClusMC(kFALSE),
214  tBrokenFiles(NULL),
215  fFileNameBroken(NULL),
216  fDoDetailedM02(NULL)
217 {
218 
219 }
220 
221 //________________________________________________________________________
223  AliAnalysisTaskSE(name),
224  fV0Reader(NULL),
225  fV0ReaderName("V0ReaderV1"),
226  fCorrTaskSetting(""),
227  fDoLightOutput(kFALSE),
228  fInputEvent(NULL),
229  fMCEvent(NULL),
230  fCutFolder(NULL),
231  fESDList(NULL),
232  fTrueList(NULL),
233  fMCList(NULL),
234  fHeaderNameList(NULL),
235  fOutputContainer(NULL),
236  fNClusterCandidates(0),
237  fNClusterMergedCandidates(0),
238  fEventCutArray(NULL),
239  fEventCuts(NULL),
240  fClusterCutArray(NULL),
241  fClusterMergedCutArray(NULL),
242  fMesonCutArray(NULL),
243  fMesonCuts(NULL),
244  fHistoMotherInvMassPt(NULL),
245  fHistoMotherPtY(NULL),
246  fHistoMotherPtAlpha(NULL),
247  fHistoClusGammaPt(NULL),
248  fHistoClusGammaE(NULL),
249  fHistoClusOverlapHeadersGammaPt(NULL),
250  fHistoClusNLMPt(NULL),
251  fHistoClusMergedPtvsM02(NULL),
252  fHistoClusMergedPtvsM02Accepted(NULL),
253  fHistoClusMergedEvsM02Accepted(NULL),
254  fHistoClusNCellsPt(NULL),
255  fHistoClusMergedNCellsPt(NULL),
256  fHistoClusMergedNParticlePt(NULL),
257  fHistoClusMergedNCellsAroundPt(NULL),
258  fHistoClusMergedNCellsAroundAndInPt(NULL),
259  fHistoClusMergedEAroundE(NULL),
260  fHistoMCHeaders(NULL),
261  fHistoMCPi0Pt(NULL),
262  fHistoMCPi0WOWeightPt(NULL),
263  fHistoMCPi0WOEvtWeightPt(NULL),
264  fHistoMCEtaPt(NULL),
265  fHistoMCEtaWOWeightPt(NULL),
266  fHistoMCEtaWOEvtWeightPt(NULL),
267  fHistoMCPi0DalitzPt(NULL),
268  fHistoMCPi0DalitzWOWeightPt(NULL),
269  fHistoMCPi0DalitzWOEvtWeightPt(NULL),
270  fHistoMCEtaDalitzPt(NULL),
271  fHistoMCEtaDalitzWOWeightPt(NULL),
272  fHistoMCEtaDalitzWOEvtWeightPt(NULL),
273  fHistoMCPi0InAccPt(NULL),
274  fHistoMCEtaInAccPt(NULL),
275  fHistoMCPi0WOEvtWeightInAccPt(NULL),
276  fHistoMCEtaWOEvtWeightInAccPt(NULL),
277  fHistoMCPi0DalitzInAccPt(NULL),
278  fHistoMCEtaDalitzInAccPt(NULL),
279  fHistoMCPi0DalitzWOEvtWeightInAccPt(NULL),
280  fHistoMCEtaDalitzWOEvtWeightInAccPt(NULL),
281  fHistoMCSecPi0PtvsSource(NULL),
282  fHistoMCSecPi0InAccPtvsSource(NULL),
283  fHistoMCPi0PtJetPt(NULL),
284  fHistoMCEtaPtJetPt(NULL),
285  fHistoMCPrimaryPtvsSource(NULL),
286  fHistoMCPrimaryYvsSource(NULL),
287  fHistoMCDecayGammaPt(NULL),
288  fHistoMCAllGammaPt(NULL),
289  fHistoTrueClusMergedPtvsM02(NULL),
290  fHistoTrueClusPi0PtvsM02(NULL),
291  fHistoTrueClusPi0DalitzPtvsM02(NULL),
292  fHistoTrueClusPrimPi0PtvsM02(NULL),
293  fHistoTrueClusSecPi0PtvsM02(NULL),
294  fHistoTrueClusSecPi0FromK0sPtvsM02(NULL),
295  fHistoTrueClusSecPi0FromK0lPtvsM02(NULL),
296  fHistoTrueClusSecPi0FromLambdaPtvsM02(NULL),
297  fHistoTrueClusEtaPtvsM02(NULL),
298  fHistoTrueClusEtaDalitzPtvsM02(NULL),
299  fHistoTrueClusMergedPureFromPi0PtvsM02(NULL),
300  fHistoTrueClusMergedPureFromEtaPtvsM02(NULL),
301  fHistoTrueClusMergedPartConvFromPi0PtvsM02(NULL),
302  fHistoTrueClusMergedPartConvFromEtaPtvsM02(NULL),
303  fHistoTrueClusGammaFromPi0PtvsM02(NULL),
304  fHistoTrueClusGammaFromEtaPtvsM02(NULL),
305  fHistoTrueClusElectronFromPi0PtvsM02(NULL),
306  fHistoTrueClusElectronFromEtaPtvsM02(NULL),
307  fHistoTrueSecPi0PtvsDiffReco(NULL),
308  fHistoTrueClusBGPtvsM02(NULL),
309  fHistoTrueClusGammaPtvsM02(NULL),
310  fHistoTrueClusGammaPartConvPtvsM02(NULL),
311  fHistoTrueClusElectronPtvsM02(NULL),
312  fHistoTrueClusElectronFromGammaPtvsM02(NULL),
313  fHistoTrueClusMergedInvMassvsPt(NULL),
314  fHistoTrueClusPi0InvMassvsPt(NULL),
315  fHistoTrueClusPrimPi0InvMassvsPt(NULL),
316  fHistoTrueClusEtaInvMassvsPt(NULL),
317  fHistoTrueClusBGInvMassvsPt(NULL),
318  fHistoTrueClusGammaInvMassvsPt(NULL),
319  fHistoTrueClusElectronInvMassvsPt(NULL),
320  fHistoTrueClusBGPtvsSource(NULL),
321  fHistoTrueClusGammaPtvsSource(NULL),
322  fHistoTrueClusElectronPtvsSource(NULL),
323 // fHistoTrueClusElectronPtvsMotherID(NULL),
324 // fHistoTrueClusElectronPtvsTopMotherID(NULL),
325 // fHistoTrueClusElectronPtvsConvPhotonTopMotherID(NULL),
326  fHistoTrueMergedMissedPDG(NULL),
327  fHistoTruePi0PtY(NULL),
328  fHistoTrueEtaPtY(NULL),
329  fHistoTruePi0PtAlpha(NULL),
330  fHistoTrueEtaPtAlpha(NULL),
331  fHistoTrueClusGammaEM02(NULL),
332  fHistoTrueClusElectronEM02(NULL),
333  fHistoTrueClusPi0EM02(NULL),
334  fHistoTrueClusEtaEM02(NULL),
335  fHistoTruePrimaryPi0PureMergedMCPtResolPt(NULL),
336  fHistoTruePrimaryPi0MergedPartConvMCPtResolPt(NULL),
337  fHistoTruePrimaryPi01GammaMCPtResolPt(NULL),
338  fHistoTruePrimaryPi01ElectronMCPtResolPt(NULL),
339  fHistoTruePrimaryEtaMCPtResolPt(NULL),
340  fHistoTrueSecondaryPi0MCPtResolPt(NULL),
341  fHistoDoubleCountTruePi0PtvsM02(NULL),
342  fHistoDoubleCountTrueSecPi0Pt(NULL),
343  fHistoDoubleCountTrueEtaPtvsM02(NULL),
344  fVectorDoubleCountTruePi0s(0),
345  fVectorDoubleCountTrueEtas(0),
346  fHistoNEvents(NULL),
347  fHistoNEventsWOWeight(NULL),
348  fHistoNGoodESDTracks(NULL),
349  fHistoVertexZ(NULL),
350  fHistoNClusterCandidates(NULL),
351  fHistoNClusterMergedCandidates(NULL),
352  fHistoNGoodESDTracksVsNClusterCandidates(NULL),
353  fHistoSPDClusterTrackletBackground(NULL),
354  fHistoNV0Tracks(NULL),
355  fProfileEtaShift(NULL),
356  fProfileJetJetXSection(NULL),
357  fHistoJetJetNTrials(NULL),
358  fRandom(0),
359  fnCuts(0),
360  fiCut(0),
361  fIsHeavyIon(0),
362  fDoMesonQA(0),
363  fDoClusterQA(0),
364  fIsFromMBHeader(kTRUE),
365  fIsOverlappingWithOtherHeader(kFALSE),
366  fIsMC(0),
367  fSetPlotHistsExtQA(kFALSE),
368  fWeightJetJetMC(1),
369  fSelectedMesonID(0),
370  fEnableDetailedPrintOut(kFALSE),
371  fEnableSortForClusMC(kFALSE),
372  tBrokenFiles(NULL),
373  fFileNameBroken(NULL),
374  fDoDetailedM02(NULL)
375 {
376  // Define output slots here
377  DefineOutput(1, TList::Class());
378 }
379 
381 {
382 
383 }
384 
385 //________________________________________________________________________
387 
388  fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
389  if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
390 
391 
392  Int_t invMassBins = 800;
393  Float_t startMass = 0;
394  Float_t endMass = 0.8;
395  Double_t *arrPtBinning = new Double_t[1000];
396 
397  if (GetSelectedMesonID() == 1) {
398  invMassBins = 400;
399  startMass = 0;
400  endMass = 0.4;
401  } else if (GetSelectedMesonID() == 2) {
402  invMassBins = 800;
403  startMass = 0.;
404  endMass = 0.8;
405  }
406 
407  Int_t ptBinsDefClus = 500;
408  Float_t startPtDefClus = 0;
409  Float_t endPtDefClus = 50;
410 
411  Int_t ptBins = 400;
412  Float_t startPt = 10;
413  Float_t endPt = 50;
414 
415  Int_t ptBinsLog = 200;
416  Float_t startPtLog = 10;
417  Float_t endPtLog = 50;
418  if (GetSelectedMesonID() == 2 ) {
419  ptBins = 500;
420  startPt = 20;
421  endPt = 70;
422  for(Int_t i=0; i<ptBins+1;i++){
423  arrPtBinning[i] = 10.+((endPt-startPt)/ptBins)*i;
424  }
425  ptBinsLog = 250;
426  startPtLog = 20;
427  endPtLog = 70;
428  } else if (((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k5TeV ||
429  ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k8TeV ||
433  ptBins = 610;
434  startPt = 10;
435  endPt = 200;
436  // pT dependet binning for very high pT analyses
437  for(Int_t i=0; i<ptBins+2;i++){
438  if(i<400)
439  arrPtBinning[i] = 10.+0.1*i;
440  else if(i<500)
441  arrPtBinning[i] = 50.+0.2*(i-400);
442  else if(i<540)
443  arrPtBinning[i] = 70.+0.5*(i-500);
444  else if(i<570)
445  arrPtBinning[i] = 90.+1.0*(i-540);
446  else
447  arrPtBinning[i] = 120+2.0*(i-570);
448  }
449  ptBinsLog = 475;
450  startPtLog = 10;
451  endPtLog = 200;
452  ptBinsDefClus = 1000;
453  startPtDefClus = 0;
454  endPtDefClus = 200;
455  } else if (((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k13TeVLowB ||
457  ptBins = 900;
458  startPt = 10;
459  endPt = 100;
460  for(Int_t i=0; i<ptBins+1;i++){
461  arrPtBinning[i] = 10.+((endPt-startPt)/ptBins)*i;
462  }
463  ptBinsLog = 450;
464  startPtLog = 10;
465  endPtLog = 100;
466  ptBinsDefClus = 1000;
467  startPtDefClus = 0;
468  endPtDefClus = 100;
469  } else {
470  for(Int_t i=0; i<ptBins+1;i++){
471  arrPtBinning[i] = 10.+((endPt-startPt)/ptBins)*i;
472  }
473  }
474 
475  Int_t showerShapeBins = 500;
476  Float_t startShowerShape = 0;
477  Float_t endShowerShape = 5;
478 
479  if (fDoDetailedM02) showerShapeBins = 5000;
480 
481  // Create histograms
482  if(fOutputContainer != NULL){
483  delete fOutputContainer;
484  fOutputContainer = NULL;
485  }
486  if(fOutputContainer == NULL){
487  fOutputContainer = new TList();
488  fOutputContainer->SetOwner(kTRUE);
489  }
490 
491  fCutFolder = new TList*[fnCuts];
492  fESDList = new TList*[fnCuts];
493 
494  fHistoNEvents = new TH1F*[fnCuts];
495  if(fIsMC == 2){
496  fHistoNEventsWOWeight = new TH1F*[fnCuts];
497  fProfileJetJetXSection = new TProfile*[fnCuts];
498  fHistoJetJetNTrials = new TH1F*[fnCuts];
499  }
500 
501  fHistoNGoodESDTracks = new TH1F*[fnCuts];
502  fHistoVertexZ = new TH1F*[fnCuts];
503  fHistoNClusterCandidates = new TH1F*[fnCuts];
507  fHistoNV0Tracks = new TH1F*[fnCuts];
508  fProfileEtaShift = new TProfile*[fnCuts];
509 
511  if (fDoMesonQA > 0 ){
512  fHistoMotherPtY = new TH2F*[fnCuts];
514  }
515 
516  fHistoClusGammaPt = new TH1F*[fnCuts];
517  fHistoClusGammaE = new TH1F*[fnCuts];
522  fHistoClusNLMPt = new TH2F*[fnCuts];
523  if (fDoClusterQA > 0){
529 
530  if (fIsMC > 0){
532  }
533 
534  }
535 
536  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
537  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
538  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
539  TString cutstringCaloMerged = ((AliCaloPhotonCuts*)fClusterMergedCutArray->At(iCut))->GetCutNumber();
540  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
541 
542  //Int_t nLMCut = ((AliCaloPhotonCuts*)fClusterMergedCutArray->At(iCut))->GetMinNLMCut();
543 
544  fCutFolder[iCut] = new TList();
545  fCutFolder[iCut]->SetName(Form("Cut Number %s_%s_%s_%s",cutstringEvent.Data(), cutstringCalo.Data(), cutstringCaloMerged.Data(), cutstringMeson.Data()));
546  fCutFolder[iCut]->SetOwner(kTRUE);
547  fOutputContainer->Add(fCutFolder[iCut]);
548  fESDList[iCut] = new TList();
549  fESDList[iCut]->SetName(Form("%s_%s_%s_%s ESD histograms",cutstringEvent.Data(), cutstringCalo.Data(), cutstringCaloMerged.Data(), cutstringMeson.Data()));
550  fESDList[iCut]->SetOwner(kTRUE);
551  fCutFolder[iCut]->Add(fESDList[iCut]);
552 
553  fHistoNEvents[iCut] = new TH1F("NEvents","NEvents",14,-0.5,13.5);
554  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
555  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
556  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
557  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
558  TString TriggerNames = "Not Trigger: ";
559  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
560  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
561  } else {
562  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
563  }
564  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
565  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
566  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
567  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
568  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
569  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problems");
570  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
571  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
572  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
573  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
574  fESDList[iCut]->Add(fHistoNEvents[iCut]);
575 
576  if (fIsMC == 2){
577  fHistoNEventsWOWeight[iCut] = new TH1F("NEventsWOWeight","NEventsWOWeight",14,-0.5,13.5);
578  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
579  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
580  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
581  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
582  TString TriggerNames = "Not Trigger: ";
583  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
584  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
585  } else {
586  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
587  }
588  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
589  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
590  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
591  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
592  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
593  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
594  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
595  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
596  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
597  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
598  fESDList[iCut]->Add(fHistoNEventsWOWeight[iCut]);
599 
600  fProfileJetJetXSection[iCut] = new TProfile("XSection","XSection",1,-0.5,0.5);
601  fESDList[iCut]->Add(fProfileJetJetXSection[iCut]);
602  fHistoJetJetNTrials[iCut] = new TH1F("NTrials","#sum{NTrials}",1,0,1);
603  fHistoJetJetNTrials[iCut]->GetXaxis()->SetBinLabel(1,"#sum{NTrials}");
604  fESDList[iCut]->Add(fHistoJetJetNTrials[iCut]);
605  }
606 
607  if(fIsHeavyIon == 1)
608  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks","GoodESDTracks",4000,-0.5,3999.5);
609  else if(fIsHeavyIon == 2)
610  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks","GoodESDTracks",400,-0.5,399.5);
611  else
612  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks","GoodESDTracks",200,-0.5,199.5);
613  fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
614 
615  fHistoVertexZ[iCut] = new TH1F("VertexZ","VertexZ",1000,-50,50);
616  fESDList[iCut]->Add(fHistoVertexZ[iCut]);
617 
618  if(fIsHeavyIon == 1)
619  fHistoNClusterCandidates[iCut] = new TH1F("GammaCandidates","GammaCandidates",600,-0.5,599.5);
620  else if(fIsHeavyIon == 2)
621  fHistoNClusterCandidates[iCut] = new TH1F("GammaCandidates","GammaCandidates",400,-0.5,399.5);
622  else
623  fHistoNClusterCandidates[iCut] = new TH1F("GammaCandidates","GammaCandidates",100,-0.5,99.5);
624  fESDList[iCut]->Add(fHistoNClusterCandidates[iCut]);
625 
626  if(fIsHeavyIon == 1)
627  fHistoNClusterMergedCandidates[iCut] = new TH1F("MergedCandidates","MergedCandidates",300,-0.5,299.5);
628  else if(fIsHeavyIon == 2)
629  fHistoNClusterMergedCandidates[iCut] = new TH1F("MergedCandidates","MergedCandidates",200,-0.5,199.5);
630  else
631  fHistoNClusterMergedCandidates[iCut] = new TH1F("MergedCandidates","MergedCandidates",50,-0.5,49.5);
632  fESDList[iCut]->Add(fHistoNClusterMergedCandidates[iCut]);
633 
634 
635  if(fIsHeavyIon == 1)
636  fHistoNGoodESDTracksVsNClusterCandidates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",4000,-0.5,3999.5,600,-0.5,599.5);
637  else if(fIsHeavyIon == 2)
638  fHistoNGoodESDTracksVsNClusterCandidates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",400,-0.5,399.5,400,-0.5,399.5);
639  else
640  fHistoNGoodESDTracksVsNClusterCandidates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",200,-0.5,199.5,100,-0.5,99.5);
642 
643  fHistoSPDClusterTrackletBackground[iCut] = new TH2F("SPD tracklets vs SPD clusters","SPD tracklets vs SPD clusters",100,0,200,250,0,1000);
645 
646  if(fIsHeavyIon == 1)
647  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity","V0 Multiplicity",30000,-0.5,29999.5);
648  else if(fIsHeavyIon == 2)
649  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity","V0 Multiplicity",2500,-0.5,2499.5);
650  else
651  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity","V0 Multiplicity",1500,-0.5,1499.5);
652  fESDList[iCut]->Add(fHistoNV0Tracks[iCut]);
653  fProfileEtaShift[iCut] = new TProfile("Eta Shift","Eta Shift",1, -0.5,0.5);
654  fESDList[iCut]->Add(fProfileEtaShift[iCut]);
655 
656  if (fIsMC == 2){
657  fHistoNEvents[iCut]->Sumw2();
658  fHistoNGoodESDTracks[iCut]->Sumw2();
659  fHistoVertexZ[iCut]->Sumw2();
660  fHistoNClusterCandidates[iCut]->Sumw2();
662  fHistoSPDClusterTrackletBackground[iCut]->Sumw2();
663  fHistoNV0Tracks[iCut]->Sumw2();
664  fProfileEtaShift[iCut]->Sumw2();
665  }
666 
667  fHistoClusGammaPt[iCut] = new TH1F("ClusGamma_Pt","ClusGamma_Pt",ptBinsDefClus, startPtDefClus, endPtDefClus);
668  fESDList[iCut]->Add(fHistoClusGammaPt[iCut]);
669  fHistoClusGammaE[iCut] = new TH1F("ClusGamma_E","ClusGamma_E",ptBinsDefClus, startPtDefClus, endPtDefClus);
670  fESDList[iCut]->Add(fHistoClusGammaE[iCut]);
671  fHistoClusOverlapHeadersGammaPt[iCut] = new TH1F("ClusGammaOverlapHeaders_Pt","ClusGammaOverlapHeaders_Pt",ptBins, arrPtBinning);
672  fESDList[iCut]->Add(fHistoClusOverlapHeadersGammaPt[iCut]);
673  fHistoClusMergedPtvsM02[iCut] = new TH2F("ClusMerged_Pt_M02","ClusMerged_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
674  fESDList[iCut]->Add(fHistoClusMergedPtvsM02[iCut]);
675  fHistoClusMergedPtvsM02Accepted[iCut] = new TH2F("ClusMerged_Pt_M02_AcceptedMeson","ClusMerged_Pt_M02_AcceptedMeson",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
676  fESDList[iCut]->Add(fHistoClusMergedPtvsM02Accepted[iCut]);
677  fHistoClusMergedEvsM02Accepted[iCut] = new TH2F("ClusMerged_E_M02_AcceptedMeson","ClusMerged_E_M02_AcceptedMeson",ptBins, arrPtBinning, showerShapeBins, startShowerShape, endShowerShape);
678  fESDList[iCut]->Add(fHistoClusMergedEvsM02Accepted[iCut]);
679  fHistoClusNLMPt[iCut] = new TH2F("ClusMerged_NLM_Pt_AcceptedMeson","ClusMerged_NLM_Pt_AcceptedMeson",12, -0.5, 11.5, ptBins, arrPtBinning);
680  fESDList[iCut]->Add(fHistoClusNLMPt[iCut]);
681 
682 
683  if (fIsMC == 2){
684  fHistoClusGammaPt[iCut]->Sumw2();
685  fHistoClusGammaE[iCut]->Sumw2();
686  fHistoClusOverlapHeadersGammaPt[iCut]->Sumw2();
687  fHistoClusMergedPtvsM02[iCut]->Sumw2();
688  fHistoClusMergedPtvsM02Accepted[iCut]->Sumw2();
689  fHistoClusMergedEvsM02Accepted[iCut]->Sumw2();
690  fHistoClusNLMPt[iCut]->Sumw2();
691  }
692 
693  if (fDoClusterQA > 0){
694  fHistoClusNCellsPt[iCut] = new TH2F("Clus_NCells_Pt","Clus_NCells_Pt",100,-0.5,99.5,ptBins, arrPtBinning);
695  fESDList[iCut]->Add(fHistoClusNCellsPt[iCut]);
696  fHistoClusMergedNCellsPt[iCut] = new TH2F("ClusMerged_NCells_Pt","ClusMerged_NCells_Pt",100,-0.5,99.5,ptBins, arrPtBinning);
697  fESDList[iCut]->Add(fHistoClusMergedNCellsPt[iCut]);
698  fHistoClusMergedNCellsAroundPt[iCut] = new TH2F("ClusMerged_NCellsAroundClus_Pt","ClusMerged_NCellsAroundClus_Pt",100,-0.5,99.5,ptBins, arrPtBinning);
699  fESDList[iCut]->Add(fHistoClusMergedNCellsAroundPt[iCut]);
700  fHistoClusMergedNCellsAroundAndInPt[iCut] = new TH2F("ClusMerged_NCellsAroundAndInClus_Pt","ClusMerged_NCellsAroundAndInClus_Pt",100,-0.5,99.5,ptBins, arrPtBinning);
702  fHistoClusMergedEAroundE[iCut] = new TH2F("ClusMerged_EAroundClus_E","ClusMerged_EAroundClus_E",ptBinsDefClus, startPtDefClus, endPtDefClus, ptBins, arrPtBinning);
703  fESDList[iCut]->Add(fHistoClusMergedEAroundE[iCut]);
704 
705  if (fIsMC > 0){
706  fHistoClusMergedNParticlePt[iCut] = new TH2F("ClusMerged_NPart_Pt","ClusMerged_NPart_Pt",100,-0.5,99.5,ptBins, arrPtBinning);
707  fESDList[iCut]->Add(fHistoClusMergedNParticlePt[iCut]);
708  if (fIsMC == 2){
709  fHistoClusNCellsPt[iCut]->Sumw2();
710  fHistoClusMergedNCellsPt[iCut]->Sumw2();
711  fHistoClusMergedNCellsAroundPt[iCut]->Sumw2();
713  fHistoClusMergedEAroundE[iCut]->Sumw2();
714  fHistoClusMergedNParticlePt[iCut]->Sumw2();
715  fHistoClusMergedEAroundE[iCut]->Sumw2();
716  }
717  }
718  }
719 
720  fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",invMassBins, startMass, endMass,ptBins, arrPtBinning);
721  fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
722 
723  if (fIsMC == 2){
724  fHistoMotherInvMassPt[iCut]->Sumw2();
725  }
726 
727  if (fDoMesonQA > 0 ){
728  fHistoMotherPtY[iCut] = new TH2F("ESD_Mother_Pt_Y","ESD_Mother_Pt_Y", ptBinsLog, startPtLog, endPtLog, 150, -1.5, 1.5);
730  fESDList[iCut]->Add(fHistoMotherPtY[iCut]);
731  fHistoMotherPtAlpha[iCut] = new TH2F("ESD_Mother_Pt_Alpha","ESD_Mother_Pt_Alpha", ptBinsLog, startPtLog, endPtLog, 100, 0, 1);
733  fESDList[iCut]->Add(fHistoMotherPtAlpha[iCut]);
734  if (fIsMC == 2){
735  fHistoMotherPtY[iCut]->Sumw2();
736  fHistoMotherPtAlpha[iCut]->Sumw2();
737  }
738  }
739  }
740 
741  if (fIsMC > 0){
742  fMCList = new TList*[fnCuts];
743  fTrueList = new TList*[fnCuts];
744 
745  fHistoMCPi0Pt = new TH1F*[fnCuts];
746  fHistoMCEtaPt = new TH1F*[fnCuts];
749  fHistoMCDecayGammaPt = new TH1F*[fnCuts];
750  fHistoMCAllGammaPt = new TH1F*[fnCuts];
751  if (GetSelectedMesonID() != 2){
752  fHistoMCPi0WOWeightPt = new TH1F*[fnCuts];
753  fHistoMCPi0InAccPt = new TH1F*[fnCuts];
757  fHistoMCPi0DalitzPt = new TH1F*[fnCuts];
758  fHistoMCPi0DalitzWOWeightPt = new TH1F*[fnCuts];
759  fHistoMCPi0DalitzInAccPt = new TH1F*[fnCuts];
761  }
762  if (GetSelectedMesonID() != 1){
763  fHistoMCEtaWOWeightPt = new TH1F*[fnCuts];
764  fHistoMCEtaInAccPt = new TH1F*[fnCuts];
766  fHistoMCEtaDalitzPt = new TH1F*[fnCuts];
767  fHistoMCEtaDalitzWOWeightPt = new TH1F*[fnCuts];
768  fHistoMCEtaDalitzInAccPt = new TH1F*[fnCuts];
770  }
771  if (fIsMC == 2){
772  if (GetSelectedMesonID() != 2)
773  fHistoMCPi0WOEvtWeightPt = new TH1F*[fnCuts];
775  if (GetSelectedMesonID() != 1)
776  fHistoMCEtaWOEvtWeightPt = new TH1F*[fnCuts];
778  if (fDoMesonQA > 0){
779  if (GetSelectedMesonID() != 2)
781  if (GetSelectedMesonID() != 1)
783  }
784  }
785 
789  if (GetSelectedMesonID() < 2){
796  }
811 
815 // fHistoTrueClusElectronPtvsMotherID = new TH2F*[fnCuts];
816 // fHistoTrueClusElectronPtvsTopMotherID = new TH2F*[fnCuts];
817 // fHistoTrueClusElectronPtvsConvPhotonTopMotherID = new TH2F*[fnCuts];
818  fHistoTrueMergedMissedPDG = new TH1F*[fnCuts];
819 
823 
824  if (fDoMesonQA > 1){
831  if (GetSelectedMesonID() < 2){
833  }
834  }
835 
836  if (fDoMesonQA > 0){
841 
842  if (GetSelectedMesonID() != 2){
843  fHistoTruePi0PtY = new TH2F*[fnCuts];
850  }
851  if (GetSelectedMesonID() != 1){
852  fHistoTrueEtaPtY = new TH2F*[fnCuts];
855  }
856  }
857 
858  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
859  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
860  TString cutstringCalo = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
861  TString cutstringCaloMerged = ((AliCaloPhotonCuts*)fClusterMergedCutArray->At(iCut))->GetCutNumber();
862  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
863 
864 
865  fMCList[iCut] = new TList();
866  fMCList[iCut]->SetName(Form("%s_%s_%s_%s MC histograms",cutstringEvent.Data(),cutstringCalo.Data(),cutstringCaloMerged.Data(), cutstringMeson.Data()));
867  fMCList[iCut]->SetOwner(kTRUE);
868  fCutFolder[iCut]->Add(fMCList[iCut]);
869 
870  fHistoMCPi0Pt[iCut] = new TH1F("MC_Pi0_Pt","MC_Pi0_Pt",ptBins, arrPtBinning);
871  fHistoMCPi0Pt[iCut]->Sumw2();
872  fMCList[iCut]->Add(fHistoMCPi0Pt[iCut]);
873  fHistoMCEtaPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",ptBins, arrPtBinning);
874  fHistoMCEtaPt[iCut]->Sumw2();
875  fMCList[iCut]->Add(fHistoMCEtaPt[iCut]);
876 
877  fHistoMCPrimaryPtvsSource[iCut] = new TH2F("MC_Primary_Pt_Source","MC_Primary_Pt_Source",ptBins, arrPtBinning, 7, -0.5, 6.5);
878  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(1,"Pi+");
879  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(2,"Pi-");
880  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(3,"K+");
881  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(4,"K-");
882  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(5,"K0s");
883  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(6,"K0l");
884  fHistoMCPrimaryPtvsSource[iCut]->GetYaxis()->SetBinLabel(7,"Lambda");
885  fHistoMCPrimaryPtvsSource[iCut]->Sumw2();
886  fMCList[iCut]->Add(fHistoMCPrimaryPtvsSource[iCut]);
887 
888  fHistoMCPrimaryYvsSource[iCut] = new TH2F("MC_Primary_Y_Source","MC_Primary_Y_Source",400, -20, 20, 7, -0.5, 6.5);
889  fHistoMCPrimaryYvsSource[iCut]->GetYaxis()->SetBinLabel(1,"Pi+");
890  fHistoMCPrimaryYvsSource[iCut]->GetYaxis()->SetBinLabel(2,"Pi-");
891  fHistoMCPrimaryYvsSource[iCut]->GetYaxis()->SetBinLabel(3,"K+");
892  fHistoMCPrimaryYvsSource[iCut]->GetYaxis()->SetBinLabel(4,"K-");
893  fHistoMCPrimaryYvsSource[iCut]->GetYaxis()->SetBinLabel(5,"K0s");
894  fHistoMCPrimaryYvsSource[iCut]->GetYaxis()->SetBinLabel(6,"K0l");
895  fHistoMCPrimaryYvsSource[iCut]->GetYaxis()->SetBinLabel(7,"Lambda");
896  fHistoMCPrimaryYvsSource[iCut]->Sumw2();
897  fMCList[iCut]->Add(fHistoMCPrimaryYvsSource[iCut]);
898 
899  fHistoMCDecayGammaPt[iCut] = new TH1F("MC_DecayGamma_Pt","MC_DecayGamma_Pt",ptBins, arrPtBinning);
900  fHistoMCDecayGammaPt[iCut]->Sumw2();
901  fMCList[iCut]->Add(fHistoMCDecayGammaPt[iCut]);
902  fHistoMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt","MC_AllGamma_Pt",ptBins, arrPtBinning);
903  fHistoMCAllGammaPt[iCut]->Sumw2();
904  fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);
905 
906  if (GetSelectedMesonID() != 2){
907  fHistoMCPi0WOWeightPt[iCut] = new TH1F("MC_Pi0_WOWeights_Pt","MC_Pi0_WOWeights_Pt",ptBins, arrPtBinning);
908  fMCList[iCut]->Add(fHistoMCPi0WOWeightPt[iCut]);
909  fHistoMCPi0InAccPt[iCut] = new TH1F("MC_Pi0InAcc_Pt","MC_Pi0InAcc_Pt",ptBins, arrPtBinning);
910  fHistoMCPi0InAccPt[iCut]->Sumw2();
911  fMCList[iCut]->Add(fHistoMCPi0InAccPt[iCut]);
912  fHistoMCPi0DalitzPt[iCut] = new TH1F("MC_Pi0Dalitz_Pt","MC_Pi0Dalitz_Pt",ptBins, arrPtBinning);
913  fHistoMCPi0DalitzPt[iCut]->Sumw2();
914  fMCList[iCut]->Add(fHistoMCPi0DalitzPt[iCut]);
915  fHistoMCPi0DalitzWOWeightPt[iCut] = new TH1F("MC_Pi0Dalitz_WOWeights_Pt","MC_Pi0Dalitz_WOWeights_Pt",ptBins, arrPtBinning);
916  fMCList[iCut]->Add(fHistoMCPi0DalitzWOWeightPt[iCut]);
917  fHistoMCPi0DalitzInAccPt[iCut] = new TH1F("MC_Pi0DalitzInAcc_Pt","MC_Pi0DalitzInAcc_Pt",ptBins, arrPtBinning);
918  fHistoMCPi0DalitzInAccPt[iCut]->Sumw2();
919  fMCList[iCut]->Add(fHistoMCPi0DalitzInAccPt[iCut]);
920 
921  // initialization for secondary histograms
922  fHistoMCSecPi0PtvsSource[iCut] = new TH2F("MC_SecPi0_Pt_Source","MC_SecPi0_Pt_Source", ptBins, arrPtBinning, 16, -0.5, 15.5);
923  fHistoMCSecPi0PtvsSource[iCut]->Sumw2();
924  fMCList[iCut]->Add(fHistoMCSecPi0PtvsSource[iCut]);
925  fHistoMCSecPi0InAccPtvsSource[iCut] = new TH2F("MC_SecPi0InAcc_Pt_Source","MC_SecPi0InAcc_Pt_Source", ptBins, arrPtBinning, 16, -0.5, 15.5);
926  fHistoMCSecPi0InAccPtvsSource[iCut]->Sumw2();
927  fMCList[iCut]->Add(fHistoMCSecPi0InAccPtvsSource[iCut]);
928  }
929 
930  if (GetSelectedMesonID() != 1){
931  fHistoMCEtaWOWeightPt[iCut] = new TH1F("MC_Eta_WOWeights_Pt","MC_Eta_WOWeights_Pt",ptBins, arrPtBinning);
932  fMCList[iCut]->Add(fHistoMCEtaWOWeightPt[iCut]);
933  fHistoMCEtaInAccPt[iCut] = new TH1F("MC_EtaInAcc_Pt","MC_EtaInAcc_Pt",ptBins, arrPtBinning);
934  fHistoMCEtaInAccPt[iCut]->Sumw2();
935  fMCList[iCut]->Add(fHistoMCEtaInAccPt[iCut]);
936  fHistoMCEtaDalitzPt[iCut] = new TH1F("MC_EtaDalitz_Pt","MC_EtaDalitz_Pt",ptBins, arrPtBinning);
937  fHistoMCEtaDalitzPt[iCut]->Sumw2();
938  fMCList[iCut]->Add(fHistoMCEtaDalitzPt[iCut]);
939  fHistoMCEtaDalitzWOWeightPt[iCut] = new TH1F("MC_EtaDalitz_WOWeights_Pt","MC_EtaDalitz_WOWeights_Pt",ptBins, arrPtBinning);
940  fMCList[iCut]->Add(fHistoMCEtaDalitzWOWeightPt[iCut]);
941  fHistoMCEtaDalitzInAccPt[iCut] = new TH1F("MC_EtaDalitzInAcc_Pt","MC_EtaDalitzInAcc_Pt",ptBins, arrPtBinning);
942  fHistoMCEtaDalitzInAccPt[iCut]->Sumw2();
943  fMCList[iCut]->Add(fHistoMCEtaDalitzInAccPt[iCut]);
944  }
945 
946  if (fIsMC == 2){
947  if (GetSelectedMesonID() != 2){
948  fHistoMCPi0WOWeightPt[iCut]->Sumw2();
949  fHistoMCPi0DalitzWOWeightPt[iCut]->Sumw2();
950  fHistoMCPi0WOEvtWeightPt[iCut] = new TH1F("MC_Pi0_WOEventWeights_Pt","MC_Pi0_WOEventWeights_Pt",ptBins, arrPtBinning);
951  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightPt[iCut]);
952  fHistoMCPi0DalitzWOEvtWeightPt[iCut] = new TH1F("MC_Pi0Dalitz_WOEventWeights_Pt","MC_Pi0Dalitz_WOEventWeights_Pt",ptBins, arrPtBinning);
953  fMCList[iCut]->Add(fHistoMCPi0DalitzWOEvtWeightPt[iCut]);
954  fHistoMCPi0DalitzWOEvtWeightInAccPt[iCut] = new TH1F("MC_Pi0DalitzWOEvtWeightInAcc_Pt","MC_Pi0DalitzWOEvtWeightInAcc_Pt",ptBins, arrPtBinning);
956  fHistoMCPi0WOEvtWeightInAccPt[iCut] = new TH1F("MC_Pi0WOEvtWeightInAcc_Pt","MC_Pi0WOEvtWeightInAcc_Pt",ptBins, arrPtBinning);
957  fMCList[iCut]->Add(fHistoMCPi0WOEvtWeightInAccPt[iCut]);
958 
959 
960  }
961  if (GetSelectedMesonID() != 1){
962  fHistoMCEtaWOWeightPt[iCut]->Sumw2();
963  fHistoMCEtaDalitzWOWeightPt[iCut]->Sumw2();
964  fHistoMCEtaWOEvtWeightPt[iCut] = new TH1F("MC_Eta_WOEventWeights_Pt","MC_Eta_WOEventWeights_Pt",ptBins, arrPtBinning);
965  fMCList[iCut]->Add(fHistoMCEtaWOEvtWeightPt[iCut]);
966  fHistoMCEtaDalitzWOEvtWeightPt[iCut] = new TH1F("MC_EtaDalitz_WOEventWeights_Pt","MC_EtaDalitz_WOEventWeights_Pt",ptBins, arrPtBinning);
967  fMCList[iCut]->Add(fHistoMCEtaDalitzWOEvtWeightPt[iCut]);
968  fHistoMCEtaWOEvtWeightInAccPt[iCut] = new TH1F("MC_EtaWOEvtWeightInAcc_Pt","MC_EtaWOEvtWeightInAcc_Pt",ptBins, arrPtBinning);
969  fMCList[iCut]->Add(fHistoMCEtaWOEvtWeightInAccPt[iCut]);
970  fHistoMCEtaDalitzWOEvtWeightInAccPt[iCut] = new TH1F("MC_EtaDalitzWOEvtWeightInAcc_Pt","MC_EtaDalitzWOEvtWeightInAcc_Pt",ptBins, arrPtBinning);
972  }
973  if (fDoMesonQA > 0){
974  if (GetSelectedMesonID() != 2){
975  fHistoMCPi0PtJetPt[iCut] = new TH2F("MC_Pi0_Pt_JetPt","MC_Pi0_Pt_JetPt", ptBinsLog, startPtLog, endPtLog, 200, -0.5, 199.5);
976  fHistoMCPi0PtJetPt[iCut]->Sumw2();
978  fMCList[iCut]->Add(fHistoMCPi0PtJetPt[iCut]);
979  }
980  if (GetSelectedMesonID() != 1){
981  fHistoMCEtaPtJetPt[iCut] = new TH2F("MC_Eta_Pt_JetPt","MC_Eta_Pt_JetPt", ptBinsLog, startPtLog, endPtLog, 200, -0.5, 199.5);
982  fHistoMCEtaPtJetPt[iCut]->Sumw2();
984  fMCList[iCut]->Add(fHistoMCEtaPtJetPt[iCut]);
985  }
986  }
987  }
988 
989  fTrueList[iCut] = new TList();
990  fTrueList[iCut]->SetName(Form("%s_%s_%s_%s True histograms",cutstringEvent.Data(),cutstringCalo.Data(),cutstringCaloMerged.Data(), cutstringMeson.Data()));
991  fTrueList[iCut]->SetOwner(kTRUE);
992  fCutFolder[iCut]->Add(fTrueList[iCut]);
993 
994  fHistoTrueClusMergedPtvsM02[iCut] = new TH2F("ESD_TrueClusMerged_Pt_M02","ESD_TrueClusMerged_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
995  fTrueList[iCut]->Add(fHistoTrueClusMergedPtvsM02[iCut]);
996  fHistoTrueClusPi0PtvsM02 [iCut] = new TH2F("ESD_TrueClusFromPi0_Pt_M02","ESD_TrueClusFromPi0_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
997  fTrueList[iCut]->Add(fHistoTrueClusPi0PtvsM02[iCut]);
998  fHistoTrueClusPi0DalitzPtvsM02 [iCut] = new TH2F("ESD_TrueClusFromPi0Dalitz_Pt_M02","ESD_TrueClusFromPi0Dalitz_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
999  fTrueList[iCut]->Add(fHistoTrueClusPi0DalitzPtvsM02[iCut]);
1000  fHistoTrueClusEtaPtvsM02[iCut] = new TH2F("ESD_TrueClusFromEta_Pt_M02","ESD_TrueClusFromEta_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1001  fTrueList[iCut]->Add(fHistoTrueClusEtaPtvsM02[iCut]);
1002  fHistoTrueClusEtaDalitzPtvsM02[iCut] = new TH2F("ESD_TrueClusFromEtaDalitz_Pt_M02","ESD_TrueClusFromEtaDalitz_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1003  fTrueList[iCut]->Add(fHistoTrueClusEtaDalitzPtvsM02[iCut]);
1004  fHistoTrueClusMergedPureFromPi0PtvsM02[iCut] = new TH2F("ESD_TrueClusMergedPureFromPi0_Pt_M02","ESD_TrueClusMergedPureFromPi0_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1006  fHistoTrueClusMergedPureFromEtaPtvsM02[iCut] = new TH2F("ESD_TrueClusMergedPureFromEta_Pt_M02","ESD_TrueClusMergedPureFromEta_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1008  fHistoTrueClusMergedPartConvFromPi0PtvsM02[iCut] = new TH2F("ESD_TrueClusMergedPartConvFromPi0_Pt_M02","ESD_TrueClusMergedPartConvFromPi0_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1010  fHistoTrueClusMergedPartConvFromEtaPtvsM02[iCut] = new TH2F("ESD_TrueClusMergedPartConvFromEta_Pt_M02","ESD_TrueClusMergedPartConvFromEta_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1012 
1013  fHistoTrueClusBGPtvsM02[iCut] = new TH2F("ESD_TrueClusBG_Pt_M02","ESD_TrueClusBG_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1014  fTrueList[iCut]->Add(fHistoTrueClusBGPtvsM02[iCut]);
1015  fHistoTrueClusGammaPtvsM02[iCut] = new TH2F("ESD_TrueClusGamma_Pt_M02","ESD_TrueClusGamma_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1016  fTrueList[iCut]->Add(fHistoTrueClusGammaPtvsM02[iCut]);
1017  fHistoTrueClusGammaFromPi0PtvsM02[iCut] = new TH2F("ESD_TrueClusGamma_FromPi0_Pt_M02","ESD_TrueClusGamma_FromPi0_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1018  fTrueList[iCut]->Add(fHistoTrueClusGammaFromPi0PtvsM02[iCut]);
1019  fHistoTrueClusGammaFromEtaPtvsM02[iCut] = new TH2F("ESD_TrueClusGamma_FromEta_Pt_M02","ESD_TrueClusGamma_FromEta_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1020  fTrueList[iCut]->Add(fHistoTrueClusGammaFromEtaPtvsM02[iCut]);
1021  fHistoTrueClusElectronPtvsM02[iCut] = new TH2F("ESD_TrueClusElectron_Pt_M02","ESD_TrueClusElectron_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1022  fTrueList[iCut]->Add(fHistoTrueClusElectronPtvsM02[iCut]);
1023  fHistoTrueClusElectronFromPi0PtvsM02[iCut] = new TH2F("ESD_TrueClusElectron_FromPi0_Pt_M02","ESD_TrueClusElectron_FromPi0_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1025  fHistoTrueClusElectronFromEtaPtvsM02[iCut] = new TH2F("ESD_TrueClusElectron_FromEta_Pt_M02","ESD_TrueClusElectron_FromEta_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1027  fHistoTrueClusElectronFromGammaPtvsM02[iCut] = new TH2F("ESD_TrueClusElectron_FromGamma_Pt_M02","ESD_TrueClusElectron_FromGamma_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1029 
1030  if (GetSelectedMesonID() < 2){
1031  fHistoTrueClusPrimPi0PtvsM02[iCut] = new TH2F("ESD_TrueClusFromPrimPi0_Pt_M02","ESD_TrueClusFromPrimPi0_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1032  fTrueList[iCut]->Add(fHistoTrueClusPrimPi0PtvsM02[iCut]);
1033  fHistoTrueClusSecPi0PtvsM02[iCut] = new TH2F("ESD_TrueClusFromSecPi0_Pt_M02","ESD_TrueClusFromSecPi0_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1034  fTrueList[iCut]->Add(fHistoTrueClusSecPi0PtvsM02[iCut]);
1035  fHistoTrueClusSecPi0FromK0sPtvsM02[iCut] = new TH2F("ESD_TrueClusFromSecPi0FromK0s_Pt_M02","ESD_TrueClusFromSecPi0FromK0s_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1037  fHistoTrueClusSecPi0FromK0lPtvsM02[iCut] = new TH2F("ESD_TrueClusFromSecPi0FromK0l_Pt_M02","ESD_TrueClusFromSecPi0FromK0l_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1039  fHistoTrueClusSecPi0FromLambdaPtvsM02[iCut] = new TH2F("ESD_TrueClusFromSecPi0FromLambda_Pt_M02","ESD_TrueClusFromSecPi0FromLambda_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1041  fHistoTrueSecPi0PtvsDiffReco[iCut] = new TH2F("ESD_TrueClusFromSecPi0_Pt_RecoMethod","ESD_TrueClusFromSecPi0_Pt_RecoMethod",ptBins, arrPtBinning, 4, -0.5, 3.5);
1042  fTrueList[iCut]->Add(fHistoTrueSecPi0PtvsDiffReco[iCut]);
1043  }
1044 
1045 
1046  fHistoTrueClusBGPtvsSource[iCut] = new TH2F("ESD_TrueClusBG_Pt_Source","ESD_TrueClusBG_Pt_Source",ptBins, arrPtBinning, 10, 0, 10);
1047  fTrueList[iCut]->Add(fHistoTrueClusBGPtvsSource[iCut]);
1048  fHistoTrueClusGammaPtvsSource[iCut] = new TH2F("ESD_TrueClusGamma_Pt_Source","ESD_TrueClusGamma_Pt_Source",ptBins, arrPtBinning, 8, 0, 8);
1049  fTrueList[iCut]->Add(fHistoTrueClusGammaPtvsSource[iCut]);
1050  fHistoTrueClusElectronPtvsSource[iCut] = new TH2F("ESD_TrueClusElectron_Pt_Source","ESD_TrueClusElectron_Pt_Source",ptBins, arrPtBinning, 9, 0, 9);
1051  fTrueList[iCut]->Add(fHistoTrueClusElectronPtvsSource[iCut]);
1052 // fHistoTrueClusElectronPtvsMotherID[iCut] = new TH2F("ESD_TrueClusElectron_Pt_MotherID","ESD_TrueClusElectron_Pt_MotherID",ptBins, arrPtBinning, 570, -1.5, 568.5);
1053 // fTrueList[iCut]->Add(fHistoTrueClusElectronPtvsMotherID[iCut]);
1054 // fHistoTrueClusElectronPtvsTopMotherID[iCut] = new TH2F("ESD_TrueClusElectron_Pt_TopMotherID","ESD_TrueClusElectron_Pt_TopMotherID",ptBins, arrPtBinning, 570, -1.5, 568.5);
1055 // fTrueList[iCut]->Add(fHistoTrueClusElectronPtvsTopMotherID[iCut]);
1056 // fHistoTrueClusElectronPtvsConvPhotonTopMotherID[iCut] = new TH2F("ESD_TrueClusElectron_Pt_ConvPhotonTopMotherID","ESD_TrueClusElectron_Pt_ConvPhotonTopMotherID",ptBins, arrPtBinning, 570, -1.5, 568.5);
1057 // fTrueList[iCut]->Add(fHistoTrueClusElectronPtvsConvPhotonTopMotherID[iCut]);
1058  fHistoTrueMergedMissedPDG[iCut] = new TH1F("ESD_TrueMergedMissed_PDG","ESD_TrueMergedMissed_PDG",10000, -1.5, 9998.5);
1059  fTrueList[iCut]->Add(fHistoTrueMergedMissedPDG[iCut]);
1060 
1061  fHistoDoubleCountTruePi0PtvsM02[iCut] = new TH2F("ESD_TrueDoubleCountPi0_Pt_M02","ESD_TrueDoubleCountPi0_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1062  fTrueList[iCut]->Add(fHistoDoubleCountTruePi0PtvsM02[iCut]);
1063  fHistoDoubleCountTrueSecPi0Pt[iCut] = new TH1F("ESD_TrueDoubleCountSecPi0_Pt","ESD_TrueDoubleCountSecPi0_Pt",ptBins, arrPtBinning);
1064  fTrueList[iCut]->Add(fHistoDoubleCountTrueSecPi0Pt[iCut]);
1065  fHistoDoubleCountTrueEtaPtvsM02[iCut] = new TH2F("ESD_TrueDoubleCountEta_Pt_M02","ESD_TrueDoubleCountEta_Pt_M02",ptBins, arrPtBinning,showerShapeBins, startShowerShape, endShowerShape);
1066  fTrueList[iCut]->Add(fHistoDoubleCountTrueEtaPtvsM02[iCut]);
1067 
1068 
1069  if (fDoMesonQA > 1){
1070  fHistoTrueClusMergedInvMassvsPt[iCut] = new TH2F("ESD_TrueClusMerged_InvMass_Pt","ESD_TrueClusMerged_InvMass_Pt",invMassBins, startMass, endMass,ptBins, arrPtBinning);
1071  fTrueList[iCut]->Add(fHistoTrueClusMergedInvMassvsPt[iCut]);
1072  fHistoTrueClusPi0InvMassvsPt [iCut] = new TH2F("ESD_TrueClusFromPi0_InvMass_Pt","ESD_TrueClusFromPi0_InvMass_Pt",invMassBins, startMass, endMass,ptBins, arrPtBinning);
1073  fTrueList[iCut]->Add(fHistoTrueClusPi0InvMassvsPt[iCut]);
1074  fHistoTrueClusEtaInvMassvsPt[iCut] = new TH2F("ESD_TrueClusFromEta_InvMass_Pt","ESD_TrueClusFromEta_InvMass_Pt",invMassBins, startMass, endMass,ptBins, arrPtBinning);
1075  fTrueList[iCut]->Add(fHistoTrueClusEtaInvMassvsPt[iCut]);
1076  fHistoTrueClusBGInvMassvsPt[iCut] = new TH2F("ESD_TrueClusBG_InvMass_Pt","ESD_TrueClusBG_InvMass_Pt",invMassBins, startMass, endMass,ptBins, arrPtBinning);
1077  fTrueList[iCut]->Add(fHistoTrueClusBGInvMassvsPt[iCut]);
1078  fHistoTrueClusGammaInvMassvsPt[iCut] = new TH2F("ESD_TrueClusGamma_InvMass_Pt","ESD_TrueClusGamma_InvMass_Pt",invMassBins, startMass, endMass,ptBins, arrPtBinning);
1079  fTrueList[iCut]->Add(fHistoTrueClusGammaInvMassvsPt[iCut]);
1080  fHistoTrueClusElectronInvMassvsPt[iCut] = new TH2F("ESD_TrueClusElectron_InvMass_Pt","ESD_TrueClusElectron_InvMass_Pt",invMassBins, startMass, endMass,ptBins, arrPtBinning);
1081  fTrueList[iCut]->Add(fHistoTrueClusElectronInvMassvsPt[iCut]);
1082  if (GetSelectedMesonID() < 2){
1083  fHistoTrueClusPrimPi0InvMassvsPt[iCut] = new TH2F("ESD_TrueClusFromPrimPi0_InvMass_Pt","ESD_TrueClusFromPrimPi0_InvMass_Pt",invMassBins, startMass, endMass,ptBins, arrPtBinning);
1084  fTrueList[iCut]->Add(fHistoTrueClusPrimPi0InvMassvsPt[iCut]);
1085  }
1086  }
1087 
1088  if (fDoMesonQA > 0){
1089  fHistoTrueClusGammaEM02[iCut] = new TH2F("TrueClusGammaEM02","TrueClusGammaEM02",ptBins, arrPtBinning, showerShapeBins, startShowerShape, endShowerShape);
1090  fTrueList[iCut]->Add(fHistoTrueClusGammaEM02[iCut]);
1091  fHistoTrueClusElectronEM02[iCut] = new TH2F("TrueClusElectronEM02","TrueClusElectronEM02",ptBins, arrPtBinning, showerShapeBins, startShowerShape, endShowerShape);
1092  fTrueList[iCut]->Add(fHistoTrueClusElectronEM02[iCut]);
1093  fHistoTrueClusPi0EM02[iCut] = new TH2F("TrueClusPi0EM02","TrueClusPi0EM02",ptBins, arrPtBinning, showerShapeBins, startShowerShape, endShowerShape);
1094  fTrueList[iCut]->Add(fHistoTrueClusPi0EM02[iCut]);
1095  fHistoTrueClusEtaEM02[iCut] = new TH2F("TrueClusEtaEM02","TrueClusEtaEM02",ptBins, arrPtBinning, showerShapeBins, startShowerShape, endShowerShape);
1096  fTrueList[iCut]->Add(fHistoTrueClusEtaEM02[iCut]);
1097  if (GetSelectedMesonID() != 2){
1098  fHistoTruePi0PtY[iCut] = new TH2F("ESD_TruePi0_Pt_Y","ESD_TruePi0_Pt_Y",ptBinsLog, startPtLog, endPtLog,150,-1.5,1.5);
1100  fTrueList[iCut]->Add(fHistoTruePi0PtY[iCut]);
1101  fHistoTruePi0PtAlpha[iCut] = new TH2F("ESD_TruePi0_Pt_Alpha","ESD_TruePi0_Pt_Alpha",ptBinsLog, startPtLog, endPtLog,100,0,1);
1103  fTrueList[iCut]->Add(fHistoTruePi0PtAlpha[iCut]);
1104  fHistoTruePrimaryPi0PureMergedMCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryPi0PureMerged_MCPt_ResolPt","ESD_TruePrimaryPi0PureMerged_ResolPt_MCPt",ptBinsLog, startPtLog, endPtLog,1000,-1.,1.);
1107  fHistoTruePrimaryPi0MergedPartConvMCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryPi0MergedPartConv_MCPt_ResolPt","ESD_TruePrimaryPi0MergedPartConv_ResolPt_MCPt",ptBinsLog, startPtLog, endPtLog,1000,-1.,1.);
1110  fHistoTruePrimaryPi01GammaMCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryPi01Gamma_MCPt_ResolPt","ESD_TruePrimaryPi01Gamma_ResolPt_MCPt",ptBinsLog, startPtLog, endPtLog,1000,-1.,1.);
1113  fHistoTruePrimaryPi01ElectronMCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryPi01Electron_MCPt_ResolPt","ESD_TruePrimaryPi01Electron_ResolPt_MCPt",ptBinsLog, startPtLog, endPtLog,1000,-1.,1.);
1116  fHistoTrueSecondaryPi0MCPtResolPt[iCut] = new TH2F("ESD_TrueSecondaryPi0_MCPt_ResolPt","ESD_TrueSecondaryPi0_MCPt_ResolPt",ptBinsLog, startPtLog, endPtLog,2000,-10.,10.);
1118  fTrueList[iCut]->Add(fHistoTrueSecondaryPi0MCPtResolPt[iCut]);
1119  }
1120  if (GetSelectedMesonID() != 1){
1121  fHistoTrueEtaPtY[iCut] = new TH2F("ESD_TrueEta_Pt_Y","ESD_TrueEta_Pt_Y",ptBinsLog, startPtLog, endPtLog,150,-1.5,1.5);
1123  fTrueList[iCut]->Add(fHistoTrueEtaPtY[iCut]);
1124  fHistoTrueEtaPtAlpha[iCut] = new TH2F("ESD_TrueEta_Pt_Alpha","ESD_TrueEta_Pt_Alpha",ptBinsLog, startPtLog, endPtLog,100,0,0.5);
1126  fTrueList[iCut]->Add(fHistoTrueEtaPtAlpha[iCut]);
1127  fHistoTruePrimaryEtaMCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryEta_MCPt_ResolPt","ESD_TruePrimaryEta_ResolPt_MCPt",ptBinsLog, startPtLog, endPtLog,1000,-1.,1.);
1129  fTrueList[iCut]->Add(fHistoTruePrimaryEtaMCPtResolPt[iCut]);
1130  }
1131  }
1132 
1133  if (fIsMC == 2){
1134  fHistoTrueClusMergedPtvsM02[iCut]->Sumw2();
1135  fHistoTrueClusPi0PtvsM02[iCut]->Sumw2();
1136  fHistoTrueClusPi0DalitzPtvsM02[iCut]->Sumw2();
1137  fHistoTrueClusEtaPtvsM02[iCut]->Sumw2();
1138  fHistoTrueClusEtaDalitzPtvsM02[iCut]->Sumw2();
1143  fHistoTrueMergedMissedPDG[iCut]->Sumw2();
1144  fHistoTrueClusBGPtvsM02[iCut]->Sumw2();
1145  fHistoTrueClusGammaPtvsM02[iCut]->Sumw2();
1146  fHistoTrueClusGammaFromPi0PtvsM02[iCut]->Sumw2();
1147  fHistoTrueClusGammaFromEtaPtvsM02[iCut]->Sumw2();
1148  fHistoTrueClusElectronPtvsM02[iCut]->Sumw2();
1149  fHistoTrueClusElectronFromPi0PtvsM02[iCut]->Sumw2();
1150  fHistoTrueClusElectronFromEtaPtvsM02[iCut]->Sumw2();
1152  fHistoTrueClusBGPtvsSource[iCut]->Sumw2();
1153  fHistoTrueClusGammaPtvsSource[iCut]->Sumw2();
1154  fHistoTrueClusElectronPtvsSource[iCut]->Sumw2();
1155 // fHistoTrueClusElectronPtvsMotherID[iCut]->Sumw2();
1156 // fHistoTrueClusElectronPtvsTopMotherID[iCut]->Sumw2();
1157 // fHistoTrueClusElectronPtvsConvPhotonTopMotherID[iCut]->Sumw2();
1158  fHistoDoubleCountTruePi0PtvsM02[iCut]->Sumw2();
1159  fHistoDoubleCountTrueSecPi0Pt[iCut]->Sumw2();
1160  fHistoDoubleCountTrueEtaPtvsM02[iCut]->Sumw2();
1161 
1162  if (GetSelectedMesonID() < 2){
1163  fHistoTrueClusPrimPi0PtvsM02[iCut]->Sumw2();
1164  fHistoTrueClusSecPi0PtvsM02[iCut]->Sumw2();
1165  fHistoTrueClusSecPi0FromK0sPtvsM02[iCut]->Sumw2();
1166  fHistoTrueClusSecPi0FromK0lPtvsM02[iCut]->Sumw2();
1168  fHistoTrueSecPi0PtvsDiffReco[iCut]->Sumw2();
1169  }
1170 
1171  if (fDoMesonQA > 1){
1172  fHistoTrueClusMergedInvMassvsPt[iCut]->Sumw2();
1173  fHistoTrueClusPi0InvMassvsPt[iCut]->Sumw2();
1174  fHistoTrueClusEtaInvMassvsPt[iCut]->Sumw2();
1175  fHistoTrueClusBGInvMassvsPt[iCut]->Sumw2();
1176  fHistoTrueClusGammaInvMassvsPt[iCut]->Sumw2();
1177  fHistoTrueClusElectronInvMassvsPt[iCut]->Sumw2();
1178  if (GetSelectedMesonID() < 2){
1179  fHistoTrueClusPrimPi0InvMassvsPt[iCut]->Sumw2();
1180  }
1181  }
1182 
1183  if (fDoMesonQA > 0 ){
1184  if (GetSelectedMesonID() != 2){
1185  fHistoTruePi0PtY[iCut]->Sumw2();
1186  fHistoTruePi0PtAlpha[iCut]->Sumw2();
1191  fHistoTrueSecondaryPi0MCPtResolPt[iCut]->Sumw2();
1192  fHistoTrueClusPi0EM02[iCut]->Sumw2();
1193  fHistoTrueClusEtaEM02[iCut]->Sumw2();
1194  fHistoTrueClusGammaEM02[iCut]->Sumw2();
1195  fHistoTrueClusElectronEM02[iCut]->Sumw2();
1196  }
1197  if (GetSelectedMesonID() != 1){
1198  fHistoTrueEtaPtY[iCut]->Sumw2();
1199  fHistoTrueEtaPtAlpha[iCut]->Sumw2();
1200  fHistoTruePrimaryEtaMCPtResolPt[iCut]->Sumw2();
1201  }
1202  }
1203  }
1204  }
1205 
1206  }
1207 
1208  if(fV0Reader)
1210  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
1211  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
1212  if(fV0Reader)
1214  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms())
1215  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
1216 
1217  for(Int_t iMatcherTask = 0; iMatcherTask < 3; iMatcherTask++){
1218  AliCaloTrackMatcher* temp = (AliCaloTrackMatcher*) (AliAnalysisManager::GetAnalysisManager()->GetTask(Form("CaloTrackMatcher_%i",iMatcherTask)));
1219  if(temp) fOutputContainer->Add(temp->GetCaloTrackMatcherHistograms());
1220  }
1221 
1222 
1223  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1224  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))) continue;
1225  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms()){
1226  fCutFolder[iCut]->Add(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
1227  }
1228  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
1229  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms()){
1230  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms());
1231  }
1232  if(!((AliCaloPhotonCuts*)fClusterMergedCutArray->At(iCut))) continue;
1233  if(((AliCaloPhotonCuts*)fClusterMergedCutArray->At(iCut))->GetCutHistograms()){
1234  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterMergedCutArray->At(iCut))->GetCutHistograms());
1235  }
1236 
1237  if(fSetPlotHistsExtQA){
1238  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
1239  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetExtQAHistograms()){
1240  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetExtQAHistograms());
1241  }
1242  }
1243  if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
1244  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
1245  fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
1246  }
1247  }
1248 
1249  if (fIsMC > 0){
1250  tBrokenFiles = new TTree("BrokenFiles","BrokenFiles");
1251  tBrokenFiles->Branch("fileName",&fFileNameBroken);
1253  }
1254 
1255 
1256  PostData(1, fOutputContainer);
1257 }
1258 //_____________________________________________________________________________
1260 {
1261  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
1262  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
1263  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
1264  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
1265  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
1266  }
1267 
1268  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift()){
1269  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1270  continue; // No Eta Shift requested, continue
1271  }
1272  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
1273  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
1274  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1275  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1276  continue;
1277  } else {
1278  printf(" Gamma Conversion Task %s :: Eta Shift Manually Set to %f \n\n",
1279  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
1280  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
1281  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
1282  }
1283 
1284  // Check whether non linearity correction has been applied already
1285  Bool_t doNonLinCorr = kTRUE;
1286  if (((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetNonLinearity() == ((AliCaloPhotonCuts*)fClusterMergedCutArray->At(iCut))->GetNonLinearity()){
1287  doNonLinCorr = kFALSE;
1288  } else if (((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetNonLinearity() == 0 && ((AliCaloPhotonCuts*)fClusterMergedCutArray->At(iCut))->GetNonLinearity() > 0){
1289  doNonLinCorr = kTRUE;
1290  } else if (((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetNonLinearity() > 0 && ((AliCaloPhotonCuts*)fClusterMergedCutArray->At(iCut))->GetNonLinearity() == 0){
1291  doNonLinCorr = kTRUE;
1292  } else {
1293  doNonLinCorr = kFALSE;
1294  cout << "ERROR: something went wrong in the configuration, different non linearity corrections have been chosen in the standard and merged cluster, which are incompatible" << endl;
1295  cout << "INFO: switching off the non lin corr for merged cluster" << endl;
1296  }
1297  // check whether photon fullfill merged cluster cuts as well
1298  if (doNonLinCorr) ((AliCaloPhotonCuts*)fClusterMergedCutArray->At(fiCut))->SetUseNonLinearitySwitch(doNonLinCorr);
1299 
1300 
1301  }
1302  return kTRUE;
1303 }
1304 //_____________________________________________________________________________
1306 {
1307  //
1308  // Called for each event
1309  //
1310  fInputEvent = InputEvent();
1311 
1312  if(fIsMC> 0) fMCEvent = MCEvent();
1313 
1314  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
1315  if(fInputEvent->IsIncompleteDAQ()==kTRUE) eventQuality = 2; // incomplete event
1316 
1317  // Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1 or because it is incomplete => abort processing of this file/event
1318  if(eventQuality == 2 || eventQuality == 3){
1319  // write out name of broken file for first event
1320  if (fIsMC > 0){
1321  if (fInputEvent->IsA()==AliESDEvent::Class()){
1322  if (((AliESDEvent*)fInputEvent)->GetEventNumberInFile() == 0){
1323  fFileNameBroken = new TObjString(Form("%s",((TString)fV0Reader->GetCurrentFileName()).Data()));
1324  if (tBrokenFiles) tBrokenFiles->Fill();
1325  delete fFileNameBroken;
1326  }
1327  }
1328  }
1329 
1330  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1331  fHistoNEvents[iCut]->Fill(eventQuality);
1332  if (fIsMC==2)
1333  fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
1334  }
1335  return;
1336  }
1337 
1338  // ------------------- BeginEvent ----------------------------
1339 
1340  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1341  fiCut = iCut;
1342 
1343  Bool_t isRunningEMCALrelAna = kFALSE;
1344  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetClusterType() == 1) isRunningEMCALrelAna = kTRUE;
1345 
1346  Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon, isRunningEMCALrelAna);
1347 
1348  if(fIsMC==2){
1349  Float_t xsection = -1.; Float_t ntrials = -1.;
1350  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetXSectionAndNTrials(fMCEvent,xsection,ntrials,fInputEvent);
1351  if((xsection==-1.) || (ntrials==-1.)) AliFatal(Form("ERROR: GetXSectionAndNTrials returned invalid xsection/ntrials, periodName from V0Reader: '%s'",fV0Reader->GetPeriodName().Data()));
1352  fProfileJetJetXSection[iCut]->Fill(0.,xsection);
1353  fHistoJetJetNTrials[iCut]->Fill("#sum{NTrials}",ntrials);
1354  }
1355 
1356  fWeightJetJetMC = 1;
1357  // cout << fMCEvent << endl;
1358  Bool_t isMCJet = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsJetJetMCEventAccepted( fMCEvent, fWeightJetJetMC, fInputEvent );
1359  if (!isMCJet){
1360  fHistoNEvents[iCut]->Fill(10,fWeightJetJetMC);
1361  if (fIsMC==2) fHistoNEventsWOWeight[iCut]->Fill(10);
1362  continue;
1363  }
1364 
1365  Bool_t triggered = kTRUE;
1366  if(eventNotAccepted){
1367  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
1368  fHistoNEvents[iCut]->Fill(eventNotAccepted, fWeightJetJetMC); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
1369  if (fIsMC==2) fHistoNEventsWOWeight[iCut]->Fill(eventNotAccepted);
1370  if (eventNotAccepted==3 && fIsMC>0){
1371  triggered = kFALSE;
1372  } else {
1373  continue;
1374  }
1375  }
1376 
1377  if(eventQuality != 0){// Event Not Accepted
1378  //cout << "event rejected due to: " <<eventQuality << endl;
1379  fHistoNEvents[iCut]->Fill(eventQuality, fWeightJetJetMC);
1380  if (fIsMC==2) fHistoNEventsWOWeight[iCut]->Fill(eventQuality);
1381 
1382  continue;
1383  }
1384  if (triggered == kTRUE) {
1385  fHistoNEvents[iCut]->Fill(eventQuality, fWeightJetJetMC); // Should be 0 here
1386  if (fIsMC==2) fHistoNEventsWOWeight[iCut]->Fill(eventQuality); // Should be 0 here
1387 
1389  fWeightJetJetMC);
1390  fHistoVertexZ[iCut]->Fill( fInputEvent->GetPrimaryVertex()->GetZ(),
1391  fWeightJetJetMC);
1392  fHistoSPDClusterTrackletBackground[iCut]->Fill( fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),
1393  (fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)),
1394  fWeightJetJetMC);
1395  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2)
1396  fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A(),
1397  fWeightJetJetMC);
1398  else
1399  fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C(),
1400  fWeightJetJetMC);
1401  }
1402  if(fIsMC> 0){
1403  // Process MC Particle
1404  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
1405  if(fInputEvent->IsA()==AliESDEvent::Class()){
1406  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1407  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1408  fMCEvent);
1409  }
1410  else if(fInputEvent->IsA()==AliAODEvent::Class()){
1411  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
1412  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
1413  fInputEvent);
1414  }
1415 
1416  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader()){
1417  for(Int_t i = 0;i<(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader())->GetEntries();i++){
1418  TString nameBin= fHistoMCHeaders[iCut]->GetXaxis()->GetBinLabel(i+1);
1419  if (nameBin.CompareTo("")== 0){
1420  TString nameHeader = ((TObjString*)((TList*)((AliConvEventCuts*)fEventCutArray->At(iCut))
1421  ->GetAcceptedHeader())->At(i))->GetString();
1422  fHistoMCHeaders[iCut]->GetXaxis()->SetBinLabel(i+1,nameHeader.Data());
1423  }
1424  }
1425  }
1426  }
1427  }
1428  if(fIsMC>0){
1429  if(fInputEvent->IsA()==AliESDEvent::Class())
1431  if(fInputEvent->IsA()==AliAODEvent::Class())
1433  }
1434 
1435  if (triggered==kFALSE) continue;
1436 
1437  // 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)
1438  ProcessClusters(); // process calo clusters
1439 
1441  fWeightJetJetMC);
1443  fWeightJetJetMC);
1444 
1447  fWeightJetJetMC);
1448 
1451 
1452  }
1453 
1454  PostData(1, fOutputContainer);
1455 }
1456 
1457 //________________________________________________________________________
1459 
1460  Int_t nclus = 0;
1461  TClonesArray * arrClustersProcess = NULL;
1462  if(!fCorrTaskSetting.CompareTo("")){
1463  nclus = fInputEvent->GetNumberOfCaloClusters();
1464  } else {
1465  arrClustersProcess = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
1466  if(!arrClustersProcess)
1467  AliFatal(Form("%sClustersBranch was not found in AliAnalysisTaskGammaCaloMerged! Check the correction framework settings!",fCorrTaskSetting.Data()));
1468  nclus = arrClustersProcess->GetEntries();
1469  }
1470 
1471 // cout << nclus << endl;
1472 
1473  if(nclus == 0) return;
1474 
1475 // cout << "new event with accepted clusters: \t trigger \t" << (((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSpecialTriggerName()).Data() <<endl;
1476 
1477  fNClusterCandidates = 0;
1479 
1480  // plotting histograms on cell/tower level, only if extendedMatchAndQA > 1
1481  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->FillHistogramsExtendedQA(fInputEvent,fIsMC);
1482 
1483  // match tracks to clusters
1484  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchTracksToClusters(fInputEvent, fWeightJetJetMC, kTRUE, fMCEvent);
1485  // match tracks to clusters also for mergedCutArray
1486  ((AliCaloPhotonCuts*)fClusterMergedCutArray->At(fiCut))->MatchTracksToClusters(fInputEvent, fWeightJetJetMC, kTRUE, fMCEvent);
1487 
1488  // vertex
1489  Double_t vertex[3] = {0};
1490  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1491 
1492  // Loop over EMCal clusters
1493  for(Long_t i = 0; i < nclus; i++){
1494 
1495  // select clusters with open cuts for normalizations histos
1496  AliVCluster* clus = NULL;
1497  if(fInputEvent->IsA()==AliESDEvent::Class()){
1498  if(arrClustersProcess)
1499  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersProcess->At(i));
1500  else
1501  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(i));
1502  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
1503  if(arrClustersProcess)
1504  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersProcess->At(i));
1505  else
1506  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i));
1507  }
1508 
1509  if (!clus){
1510  delete clus;
1511  continue;
1512  }
1513 
1514  // if open cluster cuts are not fullfilled I can abort
1515  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC,fWeightJetJetMC, i)){
1516  delete clus;
1517  continue;
1518  }
1519 
1520  // TLorentzvector with cluster
1521  TLorentzVector clusterVector;
1522  clus->GetMomentum(clusterVector,vertex);
1523 
1524  TLorentzVector* tmpvec = new TLorentzVector();
1525  tmpvec->SetPxPyPzE(clusterVector.Px(),clusterVector.Py(),clusterVector.Pz(),clusterVector.E());
1526 
1527  // convert to AODConversionPhoton
1528  AliAODConversionPhoton *PhotonCandidate=new AliAODConversionPhoton(tmpvec);
1529  if(!PhotonCandidate){
1530  delete clus;
1531  delete tmpvec;
1532  if (PhotonCandidate) delete PhotonCandidate;
1533  continue;
1534  }
1535 
1536  // Flag Photon as CaloPhoton
1537  PhotonCandidate->SetIsCaloPhoton();
1538  PhotonCandidate->SetCaloClusterRef(i);
1539 
1540  // get MC label
1541  if(fIsMC> 0){
1542  Int_t* mclabelsCluster = clus->GetLabels();
1543 // cout << "cluster: " << i << endl;
1544  Int_t nValidClusters = 0;
1545 
1546  if (clus->GetNLabels()>0){
1547  for (Int_t k =0; k< (Int_t)clus->GetNLabels(); k++){
1548 // TParticle *dummy = NULL;
1549  if (mclabelsCluster[k]>0){
1550 // dummy = fMCEvent->Particle(mclabelsCluster[k]);
1551 // if (dummy->R() < 407.0){
1552  if (nValidClusters< 50)PhotonCandidate->SetCaloPhotonMCLabel(nValidClusters,mclabelsCluster[k]);
1553  nValidClusters++;
1554 // }
1555  }
1556  }
1557  }
1558  PhotonCandidate->SetNCaloPhotonMCLabels(nValidClusters);
1559 
1560  }
1561 
1562  fIsFromMBHeader = kTRUE;
1564 
1565  // test whether largest contribution to cluster orginates in added signals
1566  if (fIsMC>0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() > 0){
1567  if ( ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetCaloPhotonMCLabel(0), fMCEvent, fInputEvent) == 0) fIsFromMBHeader = kFALSE;
1568  if (clus->GetNLabels()>1){
1569  Int_t* mclabelsCluster = clus->GetLabels();
1570  for (Int_t l = 1; l < (Int_t)clus->GetNLabels(); l++ ){
1571  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(mclabelsCluster[l], fMCEvent, fInputEvent) == 0) fIsOverlappingWithOtherHeader = kTRUE;
1572  }
1573  }
1574  }
1575 
1576  // check whether photon is from correct header
1578  fHistoClusOverlapHeadersGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightJetJetMC);
1579  }
1580  // only cluster candidates from correct header will be processed fully
1582  fHistoClusGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), fWeightJetJetMC);
1583  fHistoClusGammaE[fiCut]->Fill(PhotonCandidate->E(), fWeightJetJetMC);
1584  if (fDoClusterQA > 0){
1585  fHistoClusNCellsPt[fiCut]->Fill(clus->GetNCells(), PhotonCandidate->Pt(), fWeightJetJetMC);
1586  }
1588  } else {
1589  delete clus;
1590  delete tmpvec;
1591  delete PhotonCandidate;
1592  continue;
1593  }
1594 
1595  if(!((AliCaloPhotonCuts*)fClusterMergedCutArray->At(fiCut))->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC,fWeightJetJetMC,i)){
1596  delete clus;
1597  delete tmpvec;
1598  delete PhotonCandidate;
1599  continue;
1600  }else {
1602  }
1603 
1604  AliAODCaloCluster* clusSub1 = new AliAODCaloCluster();
1605  AliAODCaloCluster* clusSub2 = new AliAODCaloCluster();
1606 
1607 
1608  // split clusters according to their shares in the cluster (NLM == 1) needs to be treated differently
1609  if (((AliCaloPhotonCuts*)fClusterMergedCutArray->At(fiCut))->GetMinNLMCut() == 1 &&
1610  ((AliCaloPhotonCuts*)fClusterMergedCutArray->At(fiCut))->GetMaxNLMCut() == 1 ){
1611 
1612  Int_t absCellIdFirst = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->FindLargestCellInCluster(clus, fInputEvent);
1613  Int_t absCellIdSecond = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->FindSecondLargestCellInCluster(clus, fInputEvent);
1614 
1615  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->SplitEnergy(absCellIdFirst, absCellIdSecond,
1616  clus, fInputEvent, fIsMC, clusSub1, clusSub2);
1617 
1618 
1619  } else if (((AliCaloPhotonCuts*)fClusterMergedCutArray->At(fiCut))->GetMinNLMCut() > 1 ){
1620  const Int_t nc = clus->GetNCells();
1621  Int_t absCellIdList[nc];
1622  //Float_t maxEList[nc];
1623  //Int_t nlm = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetNumberOfLocalMaxima(clus, fInputEvent, absCellIdList, maxEList);
1624  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->SplitEnergy(absCellIdList[0], absCellIdList[1],
1625  clus, fInputEvent, fIsMC, clusSub1, clusSub2);
1626  }
1627  fHistoClusMergedPtvsM02[fiCut]->Fill( PhotonCandidate->Pt(),
1628  clus->GetM02(),
1629  fWeightJetJetMC);
1630 
1631  // TLorentzvector with sub cluster 1
1632  TLorentzVector clusterVector1;
1633  clusSub1->GetMomentum(clusterVector1,vertex);
1634  TLorentzVector* tmpvec1 = new TLorentzVector();
1635  tmpvec1->SetPxPyPzE(clusterVector1.Px(),clusterVector1.Py(),clusterVector1.Pz(),clusterVector1.E());
1636  // convert to AODConversionPhoton
1637  AliAODConversionPhoton *PhotonCandidate1=new AliAODConversionPhoton(tmpvec1);
1638  if(!PhotonCandidate1){
1639  delete clusSub1;
1640  delete tmpvec1;
1641  continue;
1642  }
1643  // Flag Photon as CaloPhoton
1644  PhotonCandidate1->SetIsCaloPhoton();
1645 
1646  // TLorentzvector with sub cluster 2
1647  TLorentzVector clusterVector2;
1648  clusSub2->GetMomentum(clusterVector2,vertex);
1649  TLorentzVector* tmpvec2 = new TLorentzVector();
1650  tmpvec2->SetPxPyPzE(clusterVector2.Px(),clusterVector2.Py(),clusterVector2.Pz(),clusterVector2.E());
1651  // convert to AODConversionPhoton
1652  AliAODConversionPhoton *PhotonCandidate2=new AliAODConversionPhoton(tmpvec2);
1653  if(!PhotonCandidate2){
1654  delete clusSub2;
1655  delete tmpvec2;
1656  continue;
1657  }
1658  // Flag Photon as CaloPhoton
1659  PhotonCandidate2->SetIsCaloPhoton();
1660 
1661  // create pi0 candidate
1662  AliAODConversionMother *pi0cand = new AliAODConversionMother(PhotonCandidate1,PhotonCandidate2);
1663 
1664  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
1665  fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),PhotonCandidate->Pt(), fWeightJetJetMC);
1666  fHistoClusMergedPtvsM02Accepted[fiCut]->Fill( PhotonCandidate->Pt(), clus->GetM02(), fWeightJetJetMC);
1667  fHistoClusMergedEvsM02Accepted[fiCut]->Fill( PhotonCandidate->E(), clus->GetM02(), fWeightJetJetMC);
1668  Int_t nlm = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetNumberOfLocalMaxima(clus, fInputEvent);
1669  if ( nlm < 11 ){
1670  fHistoClusNLMPt[fiCut]->Fill( nlm, PhotonCandidate->Pt());
1671  } else {
1672  fHistoClusNLMPt[fiCut]->Fill( 11., PhotonCandidate->Pt());
1673  }
1674 
1675  if (fDoClusterQA > 0){
1676  fHistoClusMergedNCellsPt[fiCut]->Fill(clus->GetNCells(), PhotonCandidate->Pt(), fWeightJetJetMC);
1677  Double_t energyAround = 0;
1678  Double_t nCellsAround = 0;
1679  for (Int_t j = 0; j < nclus; j++){
1680  if (j == i) continue;
1681  AliVCluster* clusTemp = NULL;
1682  if(fInputEvent->IsA()==AliESDEvent::Class()){
1683  if(arrClustersProcess)
1684  clusTemp = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersProcess->At(j));
1685  else
1686  clusTemp = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(j));
1687  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
1688  if(arrClustersProcess)
1689  clusTemp = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersProcess->At(j));
1690  else
1691  clusTemp = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(j));
1692  }
1693 
1694  if (!clusTemp){
1695  delete clusTemp;
1696  continue;
1697  }
1698 
1699  Double_t R = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetDistanceBetweenClusters(clus, clusTemp);
1700 
1701  if (R < 0.15){
1702  nCellsAround = nCellsAround+clusTemp->GetNCells();
1703  energyAround = energyAround+clusTemp->E();
1704  }
1705  delete clusTemp;
1706  }
1707  fHistoClusMergedNCellsAroundPt[fiCut]->Fill(nCellsAround, PhotonCandidate->Pt(), fWeightJetJetMC);
1708  fHistoClusMergedNCellsAroundAndInPt[fiCut]->Fill(nCellsAround+clus->GetNCells(), PhotonCandidate->Pt(), fWeightJetJetMC);
1709  fHistoClusMergedEAroundE[fiCut]->Fill(energyAround, clus->E(), fWeightJetJetMC);
1710  if (fIsMC > 0){
1711  fHistoClusMergedNParticlePt[fiCut]->Fill(clus->GetNLabels(), PhotonCandidate->Pt(), fWeightJetJetMC);
1712  }
1713  }
1714  if (fDoMesonQA > 0 ){
1715  fHistoMotherPtY[fiCut]->Fill(PhotonCandidate->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), fWeightJetJetMC);
1716  fHistoMotherPtAlpha[fiCut]->Fill(PhotonCandidate->Pt(),TMath::Abs(pi0cand->GetAlpha()), fWeightJetJetMC);
1717  }
1718  if(fIsMC> 0 && PhotonCandidate && PhotonCandidate1 && PhotonCandidate2){
1719  if(fInputEvent->IsA()==AliESDEvent::Class())
1720  ProcessTrueClusterCandidates(PhotonCandidate, clus->GetM02(), PhotonCandidate1, PhotonCandidate2);
1721  if(fInputEvent->IsA()==AliAODEvent::Class())
1722  ProcessTrueClusterCandidatesAOD(PhotonCandidate, clus->GetM02(), PhotonCandidate1, PhotonCandidate2);
1723  }
1724  }
1725 
1726 
1727 
1728  delete pi0cand;
1729  delete clusSub1;
1730  delete tmpvec1;
1731  delete PhotonCandidate1;
1732  delete clusSub2;
1733  delete tmpvec2;
1734  delete PhotonCandidate2;
1735 
1736  delete clus;
1737  delete tmpvec;
1738  delete PhotonCandidate;
1739  }
1740 
1741 }
1742 
1743 //________________________________________________________________________
1745  AliAODConversionPhoton *TrueSubClusterCandidate1,
1746  AliAODConversionPhoton *TrueSubClusterCandidate2)
1747 {
1748 
1749  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
1750  Double_t mcProdVtxX = primVtxMC->GetX();
1751  Double_t mcProdVtxY = primVtxMC->GetY();
1752  Double_t mcProdVtxZ = primVtxMC->GetZ();
1753 
1754  TParticle *Photon = NULL;
1755  if (!TrueClusterCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
1756  if (TrueClusterCandidate->GetCaloPhotonMCLabel(0) < 0) return;
1757 
1758  if (TrueClusterCandidate->GetNCaloPhotonMCLabels()>0) Photon = fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMCLabel(0));
1759  else return;
1760 
1761  if(Photon == NULL){
1762  // cout << "no photon" << endl;
1763  return;
1764  }
1765 
1766  AliAODConversionMother *mesoncand = new AliAODConversionMother(TrueSubClusterCandidate1,TrueSubClusterCandidate2);
1767  Bool_t mesonIsSelected = (((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(mesoncand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()));
1768  if (!mesonIsSelected){
1769  delete mesoncand;
1770  return;
1771  }
1772  Int_t pdgCodeParticle = Photon->GetPdgCode();
1773  TrueClusterCandidate->SetCaloPhotonMCFlags(fMCEvent, fEnableSortForClusMC);
1774  if (TrueClusterCandidate->GetNCaloPhotonMCLabels()>0 && fEnableDetailedPrintOut){
1775  cout << endl << endl << "Cluster energy: " << TrueClusterCandidate->E() << endl;;
1776  TrueClusterCandidate->PrintCaloMCLabelsAndInfo(fMCEvent);
1777  TrueClusterCandidate->PrintCaloMCFlags();
1778  }
1779 
1781  Int_t clusterClass = 0;
1782  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, TrueClusterCandidate->GetCaloPhotonMCLabel(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
1783 
1784  // cluster classification:
1785  // 1 - nice merged cluster (2 gamma | contributions from 2 gamma) from pi0/eta
1786  // 2 - contribution from only 1 partner (1 gamma, 1 fully coverted gamma) from pi0/eta
1787  // 3 - contribution from part of 1 partner (1 electron) from pi0/eta
1788  Long_t motherLab = -1;
1789  if (TrueClusterCandidate->IsMerged() || TrueClusterCandidate->IsMergedPartConv()){
1790  clusterClass = 1;
1791  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
1792  } else if (TrueClusterCandidate->GetNCaloPhotonMotherMCLabels()> 0){
1793 // cout << TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0) << endl;
1794  if (TrueClusterCandidate->IsLargestComponentElectron() || TrueClusterCandidate->IsLargestComponentPhoton()){
1795  if (TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0) > -1 && (fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0))->GetPdgCode() == 111 || fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0))->GetPdgCode() == 221) ){
1796  if ( TrueClusterCandidate->IsConversion() && !TrueClusterCandidate->IsConversionFullyContained() ){
1797  clusterClass = 3;
1798  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
1799  } else {
1800  clusterClass = 2;
1801  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
1802  }
1803  }
1804  } else if (TrueClusterCandidate->IsSubLeadingEM()){
1805  if (TrueClusterCandidate->GetNCaloPhotonMotherMCLabels()> 1){
1806  if (fEnableDetailedPrintOut) cout << "Is Subleading EM: "<< TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1) << endl;
1807  if ( TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1) > -1){
1808  if (fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1))->GetPdgCode() == 111 || fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1))->GetPdgCode() == 221 ){
1809  clusterClass = 2;
1810  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1);
1811  }
1812  }
1813  }
1814  } else {
1815  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
1816  }
1817  }
1818 
1819  // Get Mother particle
1820  TParticle *mother = NULL;
1821  Int_t motherPDG = -1;
1822  if (motherLab > -1){
1823  mother = fMCEvent->Particle(motherLab);
1824  }
1825  if (fEnableDetailedPrintOut) cout << "cluster class: " << clusterClass << "\t mother lab: "<< motherLab ;
1826  if (mother){
1827  motherPDG = TMath::Abs(mother->GetPdgCode());
1828  if (fEnableDetailedPrintOut) cout << "\t mother pdg: " << motherPDG << endl;
1829  } else {
1830  if (fEnableDetailedPrintOut) cout << endl;
1831  }
1832 
1833  //
1834  if (clusterClass == 1 || clusterClass == 2 || clusterClass == 3 ){
1835  fHistoTrueClusMergedPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1836  if (fDoMesonQA > 1)fHistoTrueClusMergedInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), fWeightJetJetMC);
1837 
1838  // separate different components
1839  if (clusterClass == 1 && TrueClusterCandidate->IsMerged()){
1840  if (motherPDG == 111){
1841  fHistoTrueClusMergedPureFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1842  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
1843  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 0., fWeightJetJetMC);
1844  }
1845  }
1846  if (motherPDG == 221)
1847  fHistoTrueClusMergedPureFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1848  } else if (clusterClass == 1 && TrueClusterCandidate->IsMergedPartConv()){
1849  if (motherPDG == 111){
1850  fHistoTrueClusMergedPartConvFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1851  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
1852  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 1., fWeightJetJetMC);
1853  }
1854  }
1855  if (motherPDG == 221)
1856  fHistoTrueClusMergedPartConvFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1857  } else if (clusterClass == 2){
1858  if (motherPDG == 111){
1859  fHistoTrueClusGammaFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1860  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
1861  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 2., fWeightJetJetMC);
1862  }
1863  }if (motherPDG == 221)
1864  fHistoTrueClusGammaFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1865  } else if (clusterClass == 3){
1866  if (motherPDG == 111) {
1867  fHistoTrueClusElectronFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1868  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
1869  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 3., fWeightJetJetMC);
1870  }
1871  }
1872  if (motherPDG == 221)
1873  fHistoTrueClusElectronFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1874  }
1875 
1876  // deal with pi0 only
1877  if (motherPDG == 111){
1878  fHistoTrueClusPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1880  fHistoDoubleCountTruePi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1881  if (!isPrimary)
1882  fHistoDoubleCountTrueSecPi0Pt[fiCut]->Fill(TrueClusterCandidate->Pt(), fWeightJetJetMC);
1883  }
1884 
1885 
1886  if (TrueClusterCandidate->IsDalitz()){
1887  fHistoTrueClusPi0DalitzPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1888  }
1889  if (fDoMesonQA > 1)fHistoTrueClusPi0InvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), fWeightJetJetMC);
1890  if (fDoMesonQA > 0){
1891  fHistoTrueClusPi0EM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, fWeightJetJetMC);
1892  }
1893  if (fDoMesonQA > 0 && GetSelectedMesonID() != 2){
1894  fHistoTruePi0PtY[fiCut]->Fill(TrueClusterCandidate->Pt(),mesoncand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), fWeightJetJetMC);
1895  fHistoTruePi0PtAlpha[fiCut]->Fill(TrueClusterCandidate->Pt(),TMath::Abs(mesoncand->GetAlpha()), fWeightJetJetMC);
1896  }
1897 
1898  if (GetSelectedMesonID() < 2) {
1899  if (isPrimary) {
1900  fHistoTrueClusPrimPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1901  if (fDoMesonQA > 1) fHistoTrueClusPrimPi0InvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), fWeightJetJetMC);
1902  if (fDoMesonQA > 0){
1903  if (clusterClass == 1 && TrueClusterCandidate->IsMerged())
1904  fHistoTruePrimaryPi0PureMergedMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),fWeightJetJetMC);
1905  else if (clusterClass == 1 && TrueClusterCandidate->IsMergedPartConv())
1906  fHistoTruePrimaryPi0MergedPartConvMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),fWeightJetJetMC);
1907  else if (clusterClass == 2)
1908  fHistoTruePrimaryPi01GammaMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),fWeightJetJetMC);
1909  else if (clusterClass == 3)
1910  fHistoTruePrimaryPi01ElectronMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),fWeightJetJetMC);
1911  }
1912  } else {
1913  fHistoTrueClusSecPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1914  if (fDoMesonQA > 0){
1915  fHistoTrueSecondaryPi0MCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),fWeightJetJetMC);
1916  }
1917  Int_t grandMaLab = mother->GetMother(0);
1918  if (grandMaLab > -1){
1919  if (TMath::Abs(fMCEvent->Particle(grandMaLab)->GetPdgCode()) == 310){
1920  fHistoTrueClusSecPi0FromK0sPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1921  } else if (TMath::Abs(fMCEvent->Particle(grandMaLab)->GetPdgCode()) == 130){
1922  fHistoTrueClusSecPi0FromK0lPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1923  } else if (TMath::Abs(fMCEvent->Particle(grandMaLab)->GetPdgCode()) == 3122){
1924  fHistoTrueClusSecPi0FromLambdaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1925  }
1926  }
1927  }
1928  }
1929  // deal with eta only
1930  } else if (motherPDG == 221){
1931  fHistoTrueClusEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1932  if (TrueClusterCandidate->IsDalitz()){
1933  fHistoTrueClusEtaDalitzPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1934  }
1935  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueEtas,motherLab)) fHistoDoubleCountTrueEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1936  if (fDoMesonQA > 1)fHistoTrueClusEtaInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), fWeightJetJetMC);
1937  if (fDoMesonQA > 0){
1938  fHistoTrueClusEtaEM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, fWeightJetJetMC);
1939  }
1940  if ( fDoMesonQA > 0 && GetSelectedMesonID() != 1 ){
1941  fHistoTrueEtaPtY[fiCut]->Fill(TrueClusterCandidate->Pt(),mesoncand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), fWeightJetJetMC);
1942  fHistoTrueEtaPtAlpha[fiCut]->Fill(TrueClusterCandidate->Pt(),TMath::Abs(mesoncand->GetAlpha()), fWeightJetJetMC);
1943  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),fWeightJetJetMC);
1944  }
1945  } else {
1946  fHistoTrueMergedMissedPDG[fiCut]->Fill(motherPDG, fWeightJetJetMC);
1947  }
1948 
1949  // leading particle is a photon or the conversion is fully contained and its not from pi0 || eta
1950  } else if (TrueClusterCandidate->IsLargestComponentPhoton() || TrueClusterCandidate->IsConversionFullyContained()
1951  || TrueClusterCandidate->IsElectronFromFragPhoton()){
1952  if (fEnableDetailedPrintOut) cout << "photon" << endl;
1953  fHistoTrueClusGammaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1954  if (fDoMesonQA > 0){
1955  fHistoTrueClusGammaEM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, fWeightJetJetMC);
1956  }
1957 
1958  if (fDoMesonQA > 1) fHistoTrueClusGammaInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), fWeightJetJetMC);
1959  if (motherLab == -1){
1960  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 0.5, fWeightJetJetMC); // direct photon
1961  } else {
1962  if (motherPDG == 111)
1963  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 1.5, fWeightJetJetMC); // pi0
1964  else if (motherPDG == 221)
1965  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 2.5, fWeightJetJetMC); // eta
1966  else if (motherPDG == 331)
1967  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 3.5, fWeightJetJetMC); // eta'
1968  else if (motherPDG == 223)
1969  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 4.5, fWeightJetJetMC); // omega
1970  else if (motherPDG == 333)
1971  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 5.5, fWeightJetJetMC); // phi
1972  else if (motherPDG == 3122)
1973  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 6.5, fWeightJetJetMC); // Lambda
1974  else
1975  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 7.5, fWeightJetJetMC); // rest
1976  }
1977 
1978  // leading particle is an electron and its not from pi0 || eta and no electron from fragmentation photon conversion
1979  } else if (TrueClusterCandidate->IsLargestComponentElectron() &&
1980  !TrueClusterCandidate->IsElectronFromFragPhoton()){
1981  if (fEnableDetailedPrintOut) cout << "electron" << endl;
1982  fHistoTrueClusElectronPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
1983  if (fDoMesonQA > 0){
1984  fHistoTrueClusElectronEM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, fWeightJetJetMC);
1985  }
1986 
1987  if (fDoMesonQA > 1) fHistoTrueClusElectronInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), fWeightJetJetMC);
1988  Int_t motherLab = Photon->GetMother(0);
1989  mother = fMCEvent->Particle(motherLab);
1990  if (mother){
1991  TrueClusterCandidate->GetLabel(0);
1992  motherPDG = TMath::Abs(mother->GetPdgCode());
1993  }
1994 
1995  if (motherLab == -1){
1996  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 0.5, fWeightJetJetMC); // direct electron
1997  } else {
1998  if (motherPDG == 22){
1999  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 1.5, fWeightJetJetMC); // gamma
2000  fHistoTrueClusElectronFromGammaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2001  } else if (motherPDG == 111){
2002  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 2.5, fWeightJetJetMC); // pi0
2003  } else if (motherPDG == 221){
2004  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 3.5, fWeightJetJetMC); // eta
2005  } else if ( int(motherPDG/100.)==5 || int(motherPDG/1000.)==5 ){
2006  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 5.5, fWeightJetJetMC); // b
2007  } else if ( int(motherPDG/100.)==4 || int(motherPDG/1000.)==4 ){
2008  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 4.5, fWeightJetJetMC); // c
2009  } else if (motherPDG == 23 || motherPDG == 24){
2010  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 6.5, fWeightJetJetMC); // W/Z
2011  } else if (motherPDG == 15) {
2012  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 7.5, fWeightJetJetMC); // tau
2013  } else {
2014  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 8.5, fWeightJetJetMC); // rest
2015  }
2016  }
2017 
2018  // leading particle is a hadron
2019  } else {
2020  if (fEnableDetailedPrintOut) cout << "BG" << endl;
2021  fHistoTrueClusBGPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2022  if (fDoMesonQA > 1) fHistoTrueClusBGInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), fWeightJetJetMC);
2023 
2024  Double_t maxM02 = 4.8;
2025  if (m02 >= 0 && m02 < maxM02){
2026  if (TMath::Abs(pdgCodeParticle) == 211) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 0.5, fWeightJetJetMC); // pi+/-
2027  else if (TMath::Abs(pdgCodeParticle) == 2212) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 1.5, fWeightJetJetMC); // p
2028  else if (TMath::Abs(pdgCodeParticle) == 321) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 2.5, fWeightJetJetMC); // K+-
2029  else if (TMath::Abs(pdgCodeParticle) == 2112) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 3.5, fWeightJetJetMC); // n
2030  else if (TMath::Abs(pdgCodeParticle) == 310) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 4.5, fWeightJetJetMC); // K0s
2031  else if (TMath::Abs(pdgCodeParticle) == 3122) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 5.5, fWeightJetJetMC); // Lambda
2032  else if (TMath::Abs(pdgCodeParticle) == 13) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 6.5, fWeightJetJetMC); // mu+/-
2033  else if (TMath::Abs(pdgCodeParticle) == 130) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 7.5, fWeightJetJetMC); // K0l
2034  else fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 8.5, fWeightJetJetMC); // Rest
2035  }
2036  }
2037  }
2038  delete mesoncand;
2039  return;
2040 }
2041 
2042 //________________________________________________________________________
2044  AliAODConversionPhoton *TrueSubClusterCandidate1,
2045  AliAODConversionPhoton *TrueSubClusterCandidate2)
2046 {
2047 
2048  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2049  Double_t mcProdVtxX = primVtxMC->GetX();
2050  Double_t mcProdVtxY = primVtxMC->GetY();
2051  Double_t mcProdVtxZ = primVtxMC->GetZ();
2052 
2053  AliAODMCParticle *Photon = NULL;
2054  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2055  if (AODMCTrackArray){
2056  if (!TrueClusterCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
2057  if (TrueClusterCandidate->GetCaloPhotonMCLabel(0) < 0) return;
2058 
2059  if (TrueClusterCandidate->GetNCaloPhotonMCLabels()>0) Photon = (AliAODMCParticle*) AODMCTrackArray->At(TrueClusterCandidate->GetCaloPhotonMCLabel(0));
2060  else return;
2061  } else {
2062  AliInfo("AODMCTrackArray could not be loaded");
2063  return;
2064  }
2065 
2066  if(Photon == NULL){
2067  // cout << "no photon" << endl;
2068  return;
2069  }
2070 
2071  AliAODConversionMother *mesoncand = new AliAODConversionMother(TrueSubClusterCandidate1,TrueSubClusterCandidate2);
2072  Bool_t mesonIsSelected = (((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(mesoncand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()));
2073  if (!mesonIsSelected){
2074  delete mesoncand;
2075  return;
2076  }
2077  Int_t pdgCodeParticle = Photon->GetPdgCode();
2079  if (TrueClusterCandidate->GetNCaloPhotonMCLabels()>0 && fEnableDetailedPrintOut){
2080  cout << endl << endl << "Cluster energy: " << TrueClusterCandidate->E() << endl;;
2081  //TrueClusterCandidate->PrintCaloMCLabelsAndInfo(fMCEvent);
2082  TrueClusterCandidate->PrintCaloMCFlags();
2083  }
2084 
2086  Int_t clusterClass = 0;
2087  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2088 
2089  // cluster classification:
2090  // 1 - nice merged cluster (2 gamma | contributions from 2 gamma) from pi0/eta
2091  // 2 - contribution from only 1 partner (1 gamma, 1 fully coverted gamma) from pi0/eta
2092  // 3 - contribution from part of 1 partner (1 electron) from pi0/eta
2093  Long_t motherLab = -1;
2094  if (TrueClusterCandidate->IsMerged() || TrueClusterCandidate->IsMergedPartConv()){
2095  clusterClass = 1;
2096  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
2097  } else if (TrueClusterCandidate->GetNCaloPhotonMotherMCLabels()> 0){
2098 // cout << TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0) << endl;
2099  if (TrueClusterCandidate->IsLargestComponentElectron() || TrueClusterCandidate->IsLargestComponentPhoton()){
2100  if (TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0) > -1 && (((AliAODMCParticle*) AODMCTrackArray->At(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0)))->GetPdgCode() == 111 || ((AliAODMCParticle*) AODMCTrackArray->At(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0)))->GetPdgCode() == 221) ){
2101  if ( TrueClusterCandidate->IsConversion() && !TrueClusterCandidate->IsConversionFullyContained() ){
2102  clusterClass = 3;
2103  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
2104  } else {
2105  clusterClass = 2;
2106  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
2107  }
2108  }
2109  } else if (TrueClusterCandidate->IsSubLeadingEM()){
2110  if (TrueClusterCandidate->GetNCaloPhotonMotherMCLabels()> 1){
2111  if (fEnableDetailedPrintOut) cout << "Is Subleading EM: "<< TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1) << endl;
2112  if ( TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1) > -1){
2113  if (TMath::Abs(((AliAODMCParticle*) AODMCTrackArray->At(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1)))->GetPdgCode()) == 111 || TMath::Abs(((AliAODMCParticle*) AODMCTrackArray->At(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1)))->GetPdgCode()) == 221 ){
2114  clusterClass = 2;
2115  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1);
2116  }
2117  }
2118  }
2119  } else {
2120  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
2121  }
2122  }
2123 
2124  // Get Mother particle
2125  AliAODMCParticle *mother = NULL;
2126  Int_t motherPDG = -1;
2127  if (motherLab > -1){
2128  mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(motherLab));
2129  }
2130  if (fEnableDetailedPrintOut) cout << "cluster class: " << clusterClass << "\t mother lab: "<< motherLab ;
2131  if (mother){
2132  motherPDG = TMath::Abs(mother->GetPdgCode());
2133  if (fEnableDetailedPrintOut) cout << "\t mother pdg: " << motherPDG << endl;
2134  } else {
2135  if (fEnableDetailedPrintOut) cout << endl;
2136  }
2137 
2138  //
2139  if (clusterClass == 1 || clusterClass == 2 || clusterClass == 3 ){
2140  fHistoTrueClusMergedPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2141  if (fDoMesonQA > 1)fHistoTrueClusMergedInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), fWeightJetJetMC);
2142 
2143  // separate different components
2144  if (clusterClass == 1 && TrueClusterCandidate->IsMerged()){
2145  if (motherPDG == 111){
2146  fHistoTrueClusMergedPureFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2147  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
2148  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 0., fWeightJetJetMC);
2149  }
2150  }
2151  if (motherPDG == 221)
2152  fHistoTrueClusMergedPureFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2153  } else if (clusterClass == 1 && TrueClusterCandidate->IsMergedPartConv()){
2154  if (motherPDG == 111){
2155  fHistoTrueClusMergedPartConvFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2156  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
2157  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 1., fWeightJetJetMC);
2158  }
2159  }
2160  if (motherPDG == 221)
2161  fHistoTrueClusMergedPartConvFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2162  } else if (clusterClass == 2){
2163  if (motherPDG == 111){
2164  fHistoTrueClusGammaFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2165  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
2166  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 2., fWeightJetJetMC);
2167  }
2168  }if (motherPDG == 221)
2169  fHistoTrueClusGammaFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2170  } else if (clusterClass == 3){
2171  if (motherPDG == 111) {
2172  fHistoTrueClusElectronFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2173  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
2174  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 3., fWeightJetJetMC);
2175  }
2176  }
2177  if (motherPDG == 221)
2178  fHistoTrueClusElectronFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2179  }
2180 
2181  // deal with pi0 only
2182  if (motherPDG == 111){
2183  fHistoTrueClusPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2185  fHistoDoubleCountTruePi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2186  if (!isPrimary)
2187  fHistoDoubleCountTrueSecPi0Pt[fiCut]->Fill(TrueClusterCandidate->Pt(), fWeightJetJetMC);
2188  }
2189 
2190 
2191  if (TrueClusterCandidate->IsDalitz()){
2192  fHistoTrueClusPi0DalitzPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2193  }
2194  if (fDoMesonQA > 1)fHistoTrueClusPi0InvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), fWeightJetJetMC);
2195  if (fDoMesonQA > 0){
2196  fHistoTrueClusPi0EM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, fWeightJetJetMC);
2197  }
2198  if (fDoMesonQA > 0 && GetSelectedMesonID() != 2){
2199  fHistoTruePi0PtY[fiCut]->Fill(TrueClusterCandidate->Pt(),mesoncand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), fWeightJetJetMC);
2200  fHistoTruePi0PtAlpha[fiCut]->Fill(TrueClusterCandidate->Pt(),TMath::Abs(mesoncand->GetAlpha()), fWeightJetJetMC);
2201  }
2202 
2203  if (GetSelectedMesonID() < 2) {
2204  if (isPrimary) {
2205  fHistoTrueClusPrimPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2206  if (fDoMesonQA > 1) fHistoTrueClusPrimPi0InvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), fWeightJetJetMC);
2207  if (fDoMesonQA > 0){
2208  if (clusterClass == 1 && TrueClusterCandidate->IsMerged())
2209  fHistoTruePrimaryPi0PureMergedMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),fWeightJetJetMC);
2210  else if (clusterClass == 1 && TrueClusterCandidate->IsMergedPartConv())
2211  fHistoTruePrimaryPi0MergedPartConvMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),fWeightJetJetMC);
2212  else if (clusterClass == 2)
2213  fHistoTruePrimaryPi01GammaMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),fWeightJetJetMC);
2214  else if (clusterClass == 3)
2215  fHistoTruePrimaryPi01ElectronMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),fWeightJetJetMC);
2216  }
2217  } else {
2218  fHistoTrueClusSecPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2219  if (fDoMesonQA > 0){
2220  fHistoTrueSecondaryPi0MCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),fWeightJetJetMC);
2221  }
2222  Int_t grandMaLab = mother->GetMother();
2223  if (grandMaLab > -1){
2224  if (TMath::Abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(grandMaLab))->GetPdgCode()) == 310){
2225  fHistoTrueClusSecPi0FromK0sPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2226  } else if (TMath::Abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(grandMaLab))->GetPdgCode()) == 130){
2227  fHistoTrueClusSecPi0FromK0lPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2228  } else if (TMath::Abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(grandMaLab))->GetPdgCode()) == 3122){
2229  fHistoTrueClusSecPi0FromLambdaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2230  }
2231  }
2232  }
2233  }
2234  // deal with eta only
2235  } else if (motherPDG == 221){
2236  fHistoTrueClusEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2237  if (TrueClusterCandidate->IsDalitz()){
2238  fHistoTrueClusEtaDalitzPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2239  }
2240  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueEtas,motherLab)) fHistoDoubleCountTrueEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2241  if (fDoMesonQA > 1)fHistoTrueClusEtaInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), fWeightJetJetMC);
2242  if (fDoMesonQA > 0){
2243  fHistoTrueClusEtaEM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, fWeightJetJetMC);
2244  }
2245  if ( fDoMesonQA > 0 && GetSelectedMesonID() != 1 ){
2246  fHistoTrueEtaPtY[fiCut]->Fill(TrueClusterCandidate->Pt(),mesoncand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), fWeightJetJetMC);
2247  fHistoTrueEtaPtAlpha[fiCut]->Fill(TrueClusterCandidate->Pt(),TMath::Abs(mesoncand->GetAlpha()), fWeightJetJetMC);
2248  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),fWeightJetJetMC);
2249  }
2250  } else {
2251  fHistoTrueMergedMissedPDG[fiCut]->Fill(motherPDG, fWeightJetJetMC);
2252  }
2253 
2254  // leading particle is a photon or the conversion is fully contained and its not from pi0 || eta
2255  } else if (TrueClusterCandidate->IsLargestComponentPhoton() || TrueClusterCandidate->IsConversionFullyContained()){
2256  if (fEnableDetailedPrintOut) cout << "photon" << endl;
2257  fHistoTrueClusGammaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2258  if (fDoMesonQA > 0){
2259  fHistoTrueClusGammaEM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, fWeightJetJetMC);
2260  }
2261 
2262  if (fDoMesonQA > 1) fHistoTrueClusGammaInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), fWeightJetJetMC);
2263  if (motherLab == -1){
2264  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 0.5, fWeightJetJetMC); // direct photon
2265  } else {
2266  if (motherPDG == 111)
2267  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 1.5, fWeightJetJetMC); // pi0
2268  else if (motherPDG == 221)
2269  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 2.5, fWeightJetJetMC); // eta
2270  else if (motherPDG == 331)
2271  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 3.5, fWeightJetJetMC); // eta'
2272  else if (motherPDG == 223)
2273  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 4.5, fWeightJetJetMC); // omega
2274  else if (motherPDG == 333)
2275  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 5.5, fWeightJetJetMC); // phi
2276  else if (motherPDG == 3122)
2277  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 6.5, fWeightJetJetMC); // Lambda
2278  else
2279  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 7.5, fWeightJetJetMC); // rest
2280  }
2281 
2282  // leading particle is an electron and its not from pi0 || eta
2283  } else if (TrueClusterCandidate->IsLargestComponentElectron()){
2284  if (fEnableDetailedPrintOut) cout << "electron" << endl;
2285  fHistoTrueClusElectronPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2286  if (fDoMesonQA > 0){
2287  fHistoTrueClusElectronEM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, fWeightJetJetMC);
2288  }
2289 
2290  if (fDoMesonQA > 1) fHistoTrueClusElectronInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), fWeightJetJetMC);
2291  Int_t motherLab = Photon->GetMother();
2292  if (motherLab == -1){
2293  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 0.5, fWeightJetJetMC); // direct electron
2294  } else {
2295  if (motherPDG == 22){
2296  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 1.5, fWeightJetJetMC); // gamma
2297  fHistoTrueClusElectronFromGammaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2298  } else if (motherPDG == 111){
2299  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 2.5, fWeightJetJetMC); // pi0
2300  } else if (motherPDG == 221){
2301  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 3.5, fWeightJetJetMC); // eta
2302  } else if ( int(motherPDG/100.)==5 || int(motherPDG/1000.)==5 ){
2303  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 5.5, fWeightJetJetMC); // b
2304  } else if ( int(motherPDG/100.)==4 || int(motherPDG/1000.)==4 ){
2305  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 4.5, fWeightJetJetMC); // c
2306  } else if (motherPDG == 23 || motherPDG == 24){
2307  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 6.5, fWeightJetJetMC); // W/Z
2308  } else if (motherPDG == 15) {
2309  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 7.5, fWeightJetJetMC); // tau
2310  } else {
2311  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 8.5, fWeightJetJetMC); // rest
2312  }
2313  }
2314  // leading particle is a hadron
2315  } else {
2316  if (fEnableDetailedPrintOut) cout << "BG" << endl;
2317  fHistoTrueClusBGPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, fWeightJetJetMC);
2318  if (fDoMesonQA > 1) fHistoTrueClusBGInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), fWeightJetJetMC);
2319 
2320  Double_t maxM02 = 4.8;
2321  if (m02 >= 0 && m02 < maxM02){
2322  if (TMath::Abs(pdgCodeParticle) == 211) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 0.5, fWeightJetJetMC); // pi+/-
2323  else if (TMath::Abs(pdgCodeParticle) == 2212) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 1.5, fWeightJetJetMC); // p
2324  else if (TMath::Abs(pdgCodeParticle) == 321) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 2.5, fWeightJetJetMC); // K+-
2325  else if (TMath::Abs(pdgCodeParticle) == 2112) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 3.5, fWeightJetJetMC); // n
2326  else if (TMath::Abs(pdgCodeParticle) == 310) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 4.5, fWeightJetJetMC); // K0s
2327  else if (TMath::Abs(pdgCodeParticle) == 3122) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 5.5, fWeightJetJetMC); // Lambda
2328  else if (TMath::Abs(pdgCodeParticle) == 13) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 6.5, fWeightJetJetMC); // mu+/-
2329  else if (TMath::Abs(pdgCodeParticle) == 130) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 7.5, fWeightJetJetMC); // K0l
2330  else fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 8.5, fWeightJetJetMC); // Rest
2331  }
2332  }
2333  }
2334  delete mesoncand;
2335  return;
2336 }
2337 
2338 
2339 //________________________________________________________________________
2341 {
2342  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2343  Double_t mcProdVtxX = primVtxMC->GetX();
2344  Double_t mcProdVtxY = primVtxMC->GetY();
2345  Double_t mcProdVtxZ = primVtxMC->GetZ();
2346 
2347  // Loop over all primary MC particle
2348  for(Long_t i = 0; i < fMCEvent->GetNumberOfTracks(); i++) {
2349  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
2350 
2351  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
2352  if (!particle) continue;
2353 
2354  Int_t isMCFromMBHeader = -1;
2355  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2356  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2357  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2358  }
2359 
2360  Double_t mesonY = 1.e30;
2361  Double_t ratio = 0;
2362  if (particle->Energy() != TMath::Abs(particle->Pz())){
2363  ratio = (particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz());
2364  }
2365  if( !(ratio <= 0) ){
2366  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2367  }
2368 
2369  // fill Primary Y hist
2370  if ( particle->GetPdgCode() == 211 ){ // positve pions
2371  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 0., fWeightJetJetMC);
2372  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2373  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 1., fWeightJetJetMC);
2374  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2375  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 2., fWeightJetJetMC);
2376  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
2377  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 3., fWeightJetJetMC);
2378  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
2379  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 4., fWeightJetJetMC);
2380  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
2381  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 5., fWeightJetJetMC);
2382  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
2383  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 6., fWeightJetJetMC);
2384  }
2385 
2386  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
2387  if ( particle->GetPdgCode() == 211 ){ // positve pions
2388  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 0., fWeightJetJetMC);
2389  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2390  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 1., fWeightJetJetMC);
2391  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2392  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 2., fWeightJetJetMC);
2393  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
2394  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 3., fWeightJetJetMC);
2395  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
2396  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 4., fWeightJetJetMC);
2397  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
2398  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 5., fWeightJetJetMC);
2399  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
2400  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 6., fWeightJetJetMC);
2401  } else if ( particle->GetPdgCode() == 22 ){ // photons
2402  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC); // direct photons
2403  if(particle->GetMother(0) > -1){
2404  TParticle* mother = (TParticle*)fMCEvent->Particle(particle->GetMother(0));
2405  if ( TMath::Abs(mother->GetPdgCode()) == 111 ||
2406  TMath::Abs(mother->GetPdgCode()) == 113 ||
2407  TMath::Abs(mother->GetPdgCode()) == 221 ||
2408  TMath::Abs(mother->GetPdgCode()) == 223 ||
2409  TMath::Abs(mother->GetPdgCode()) == 331 ||
2410  TMath::Abs(mother->GetPdgCode()) == 333 ||
2411  TMath::Abs(mother->GetPdgCode()) == 3212 ||
2412  TMath::Abs(mother->GetPdgCode()) == 213
2413  ){
2414  fHistoMCDecayGammaPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC); // decay photons
2415  }
2416  }
2417  }
2418  }
2419 
2420  // check if particle is pi0/eta from di-photon decay
2422  ->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2423  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
2424  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
2425 
2426  Float_t weighted= 1;
2427  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2428  if (particle->Pt()>0.005){
2429  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
2430  }
2431  }
2432 
2433  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2434  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // All MC Pi0
2435  if (GetSelectedMesonID() != 2){
2436  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2437  if (fIsMC==2)fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
2438  if (fDoMesonQA > 0 ){
2439  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2440  }
2441  }
2442  } else if( TMath::Abs(particle->GetPdgCode()) == 221 ){ // eta mesons
2443  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // All MC Eta
2444  if (GetSelectedMesonID() != 1){
2445  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2446  if (fIsMC==2)fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2447  if (fDoMesonQA > 0 ){
2448  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2449  }
2450  }
2451  }
2452  // Check the acceptance for both gammas & whether they are counted as primaries as well
2453  Bool_t kDaughter0IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetFirstDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2454  Bool_t kDaughter1IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetLastDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2455 
2456  if( kDaughter0IsPrim && kDaughter1IsPrim &&
2457  (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter0,fMCEvent) ||
2458  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter1,fMCEvent) ) ){
2459  if(particle->GetPdgCode() == 111 && GetSelectedMesonID() != 2){
2460  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Pi0 with gamma in acc
2461  if (fIsMC == 2)fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 w/o event weights with gamma in acc
2462  } else if(particle->GetPdgCode() == 221 && GetSelectedMesonID() != 1){
2463  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Eta with gamma in acc
2464  if (fIsMC == 2)fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta w/o event weights with gamma in acc
2465  }
2466  }
2467  }
2468  Int_t gammaLabel = -1;
2469  Int_t electronLabel = -1;
2470  Int_t positronLabel = -1;
2471  // check if particle is pi0/eta from Dalitz decay
2473  ->MesonIsSelectedMCDalitz(particle,fMCEvent, electronLabel, positronLabel, gammaLabel, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2474  if( (gammaLabel > -1) && (electronLabel > -1) && (positronLabel > -1) ){
2475  TParticle* gamma = (TParticle*)fMCEvent->Particle(gammaLabel);
2476  TParticle* electron = (TParticle*)fMCEvent->Particle(electronLabel);
2477  TParticle* positron = (TParticle*)fMCEvent->Particle(positronLabel);
2478 
2479  Float_t weighted= 1;
2480  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2481  if (particle->Pt()>0.005){
2482  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
2483  }
2484  }
2485 
2486  if(particle->GetPdgCode() == 111 && GetSelectedMesonID() != 2){
2487  fHistoMCPi0DalitzPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // All MC Pi0
2488  fHistoMCPi0DalitzWOWeightPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2489  if (fIsMC==2)fHistoMCPi0DalitzWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2490  if (fDoMesonQA > 0 ){
2491  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2492  }
2493  } else if(particle->GetPdgCode() == 221 && GetSelectedMesonID() != 1){
2494  fHistoMCEtaDalitzPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // All MC Eta
2495  fHistoMCEtaDalitzWOWeightPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2496  if (fIsMC==2)fHistoMCEtaDalitzWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2497  if (fDoMesonQA > 0 ){
2498  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2499  }
2500  }
2501 
2502  // Check the acceptance for both gammas & whether they are counted as primaries as well
2503  Bool_t kGammaIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, gammaLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2504  Bool_t kElectronIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, electronLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2505  Bool_t kPositronIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, positronLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2506  if( kGammaIsPrim && kElectronIsPrim && kPositronIsPrim &&
2507  (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma,fMCEvent) ||
2508  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecMC(electron,fMCEvent) ||
2509  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecMC(positron,fMCEvent) )
2510  ){
2511  if(particle->GetPdgCode() == 111 && GetSelectedMesonID() != 2){
2512  fHistoMCPi0DalitzInAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Pi0 with gamma in acc
2513  if (fIsMC == 2) fHistoMCPi0DalitzWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Pi0 with gamma in acc
2514  } else if(particle->GetPdgCode() == 221 && GetSelectedMesonID() != 1){
2515  fHistoMCEtaDalitzInAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Eta with gamma in acc
2516  if (fIsMC == 2) fHistoMCEtaDalitzWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Pi0 with gamma in acc
2517  }
2518  }
2519  }
2520  }
2521  // End of primary threatment, now secondary treatment
2522  } else {
2523 
2524  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
2525  if (!particle) continue;
2526 
2527  Int_t isMCFromMBHeader = -1;
2528  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2529  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2530  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2531  }
2532 
2533  // check if particle is pi0 from di-photon decay
2535  ->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2536  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
2537  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
2538  TParticle* mother = NULL;
2539  Int_t motherPDG = -1000000;
2540  if (particle->GetMother(0) > -1){
2541  mother = (TParticle*)fMCEvent->Particle(particle->GetMother(0));
2542  if (mother)
2543  motherPDG = TMath::Abs(mother->GetPdgCode());
2544  }
2545 
2546  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2547  Int_t source = GetSourceClassification(111,motherPDG);
2548  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source, fWeightJetJetMC); // All secondary MC Pi0
2549  }
2550 
2551  // check whether pi0 landet in acceptance
2552  if( (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter0,fMCEvent) ||
2553  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter1,fMCEvent) ) ){
2554  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2555  Int_t source = GetSourceClassification(111,motherPDG);
2556  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source, fWeightJetJetMC); // All secondary MC Pi0
2557  }
2558  }
2559  }
2560 
2561  Int_t gammaLabel = -1;
2562  Int_t electronLabel = -1;
2563  Int_t positronLabel = -1;
2564  // check if particle is pi0/eta from Dalitz decay
2566  ->MesonIsSelectedMCDalitz(particle,fMCEvent, electronLabel, positronLabel, gammaLabel, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2567  if( (gammaLabel > -1) && (electronLabel > -1) && (positronLabel > -1) ){
2568  TParticle* gamma = (TParticle*)fMCEvent->Particle(gammaLabel);
2569  TParticle* electron = (TParticle*)fMCEvent->Particle(electronLabel);
2570  TParticle* positron = (TParticle*)fMCEvent->Particle(positronLabel);
2571 
2572  TParticle* mother = NULL;
2573  Int_t motherPDG = -1000000;
2574  if (particle->GetMother(0) > -1){
2575  mother = (TParticle*)fMCEvent->Particle(particle->GetMother(0));
2576  if (mother)
2577  motherPDG = TMath::Abs(mother->GetPdgCode());
2578  }
2579 
2580  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2581  Int_t source = GetSourceClassification(111,motherPDG);
2582  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source, fWeightJetJetMC); // All secondary MC Pi0
2583  }
2584 
2585  // check whether pi0 landet in acceptance
2586  if( (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma,fMCEvent) ||
2587  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecMC(electron,fMCEvent) ||
2588  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecMC(positron,fMCEvent) ) ){
2589  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2590  Int_t source = GetSourceClassification(111,motherPDG);
2591  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source, fWeightJetJetMC); // All secondary MC Pi0
2592  }
2593  }
2594  }
2595  }
2596  }
2597  } // end of particle loop
2598 }
2599 
2600 //________________________________________________________________________
2602 {
2603  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2604  Double_t mcProdVtxX = primVtxMC->GetX();
2605  Double_t mcProdVtxY = primVtxMC->GetY();
2606  Double_t mcProdVtxZ = primVtxMC->GetZ();
2607 
2608  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2609  if (AODMCTrackArray == NULL) return;
2610 
2611  // Loop over all primary MC particle
2612  for(Long_t i = 0; i < AODMCTrackArray->GetEntriesFast(); i++) {
2613 
2614  AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
2615  if (!particle) continue;
2616 
2617  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, particle, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2618  if (isPrimary) {
2619 
2620  Int_t isMCFromMBHeader = -1;
2621  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2622  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2623  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2624  }
2625 
2626  Double_t mesonY = 1.e30;
2627  Double_t ratio = 0;
2628  if (particle->E() != TMath::Abs(particle->Pz())){
2629  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2630  }
2631  if( !(ratio <= 0) ){
2632  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2633  }
2634 
2635  // fill Primary Y hist
2636  if ( particle->GetPdgCode() == 211 ){ // positve pions
2637  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 0., fWeightJetJetMC);
2638  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2639  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 1., fWeightJetJetMC);
2640  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2641  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 2., fWeightJetJetMC);
2642  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
2643  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 3., fWeightJetJetMC);
2644  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
2645  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 4., fWeightJetJetMC);
2646  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
2647  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 5., fWeightJetJetMC);
2648  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
2649  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 6., fWeightJetJetMC);
2650  }
2651 
2652  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
2653  if ( particle->GetPdgCode() == 211 ){ // positve pions
2654  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 0., fWeightJetJetMC);
2655  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2656  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 1., fWeightJetJetMC);
2657  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2658  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 2., fWeightJetJetMC);
2659  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
2660  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 3., fWeightJetJetMC);
2661  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
2662  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 4., fWeightJetJetMC);
2663  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
2664  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 5., fWeightJetJetMC);
2665  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
2666  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 6., fWeightJetJetMC);
2667  } else if ( particle->GetPdgCode() == 22 ){ // photons
2668  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC); // direct photons
2669  if(particle->GetMother() > -1){
2670  AliAODMCParticle *mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2671  if ( TMath::Abs(mother->GetPdgCode()) == 111 ||
2672  TMath::Abs(mother->GetPdgCode()) == 113 ||
2673  TMath::Abs(mother->GetPdgCode()) == 221 ||
2674  TMath::Abs(mother->GetPdgCode()) == 223 ||
2675  TMath::Abs(mother->GetPdgCode()) == 331 ||
2676  TMath::Abs(mother->GetPdgCode()) == 333 ||
2677  TMath::Abs(mother->GetPdgCode()) == 3212 ||
2678  TMath::Abs(mother->GetPdgCode()) == 213
2679  ){
2680  fHistoMCDecayGammaPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC); // decay photons
2681  }
2682  }
2683  }
2684  }
2685 
2686  // check if particle is pi0/eta from di-photon decay
2688  ->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2689  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
2690  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
2691 
2692  Float_t weighted= 1;
2693  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2694  if (particle->Pt()>0.005){
2695  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, 0x0, fInputEvent);
2696  }
2697  }
2698 
2699  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2700  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // All MC Pi0
2701  if (GetSelectedMesonID() != 2){
2702  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2703  if (fIsMC==2)fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
2704  if (fDoMesonQA > 0 ){
2705  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2706  }
2707  }
2708  } else if( TMath::Abs(particle->GetPdgCode()) == 221 ){ // eta mesons
2709  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // All MC Eta
2710  if (GetSelectedMesonID() != 1){
2711  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2712  if (fIsMC==2)fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2713  if (fDoMesonQA > 0 ){
2714  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2715  }
2716  }
2717  }
2718  // Check the acceptance for both gammas & whether they are counted as primaries as well
2719  Bool_t kDaughter0IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, daughter0, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2720  Bool_t kDaughter1IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, daughter1, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2721 
2722  if( kDaughter0IsPrim && kDaughter1IsPrim &&
2723  (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter0,AODMCTrackArray) ||
2724  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter1,AODMCTrackArray) ) ){
2725  if(particle->GetPdgCode() == 111 && GetSelectedMesonID() != 2){
2726  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Pi0 with gamma in acc
2727  if (fIsMC == 2)fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 w/o event weights with gamma in acc
2728  } else if(particle->GetPdgCode() == 221 && GetSelectedMesonID() != 1){
2729  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Eta with gamma in acc
2730  if (fIsMC == 2)fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta w/o event weights with gamma in acc
2731  }
2732  }
2733  }
2734  Int_t gammaLabel = -1;
2735  Int_t electronLabel = -1;
2736  Int_t positronLabel = -1;
2737  // check if particle is pi0/eta from Dalitz decay
2739  ->MesonIsSelectedAODMCDalitz(particle,AODMCTrackArray, electronLabel, positronLabel, gammaLabel, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2740  if( (gammaLabel > -1) && (electronLabel > -1) && (positronLabel > -1) ){
2741  AliAODMCParticle* gamma = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaLabel));
2742  AliAODMCParticle* electron = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(electronLabel));
2743  AliAODMCParticle* positron = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(positronLabel));
2744 
2745  Float_t weighted= 1;
2746  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2747  if (particle->Pt()>0.005){
2748  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
2749  }
2750  }
2751 
2752  if(particle->GetPdgCode() == 111 && GetSelectedMesonID() != 2){
2753  fHistoMCPi0DalitzPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // All MC Pi0
2754  fHistoMCPi0DalitzWOWeightPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2755  if (fIsMC==2)fHistoMCPi0DalitzWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2756  if (fDoMesonQA > 0 ){
2757  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2758  }
2759  } else if(particle->GetPdgCode() == 221 && GetSelectedMesonID() != 1){
2760  fHistoMCEtaDalitzPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // All MC Eta
2761  fHistoMCEtaDalitzWOWeightPt[fiCut]->Fill(particle->Pt(), fWeightJetJetMC);
2762  if (fIsMC==2)fHistoMCEtaDalitzWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2763  if (fDoMesonQA > 0 ){
2764  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),fWeightJetJetMC);
2765  }
2766  }
2767 
2768  // Check the acceptance for both gammas & whether they are counted as primaries as well
2769  Bool_t kGammaIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, gamma, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2770  Bool_t kElectronIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, electron, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2771  Bool_t kPositronIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, positron, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2772  if( kGammaIsPrim && kElectronIsPrim && kPositronIsPrim &&
2773  (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(gamma,AODMCTrackArray) ||
2774  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecAODMC(electron,AODMCTrackArray) ||
2775  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecAODMC(positron,AODMCTrackArray) )
2776  ){
2777  if(particle->GetPdgCode() == 111 && GetSelectedMesonID() != 2){
2778  fHistoMCPi0DalitzInAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Pi0 with gamma in acc
2779  if (fIsMC == 2) fHistoMCPi0DalitzWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Pi0 with gamma in acc
2780  } else if(particle->GetPdgCode() == 221 && GetSelectedMesonID() != 1){
2781  fHistoMCEtaDalitzInAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Eta with gamma in acc
2782  if (fIsMC == 2) fHistoMCEtaDalitzWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt(),weighted* fWeightJetJetMC); // MC Pi0 with gamma in acc
2783  }
2784  }
2785  }
2786  }
2787  // End of primary threatment, now secondary treatment
2788  } else {
2789 
2790  AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
2791  if (!particle) continue;
2792 
2793  Int_t isMCFromMBHeader = -1;
2794  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2795  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2796  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2797  }
2798 
2799  // check if particle is pi0 from di-photon decay
2801  ->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2802  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
2803  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
2804  AliAODMCParticle* mother = NULL;
2805  Int_t motherPDG = -1000000;
2806  if (particle->GetMother() > -1){
2807  mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2808  if (mother)
2809  motherPDG = TMath::Abs(mother->GetPdgCode());
2810  }
2811 
2812  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2813  Int_t source = GetSourceClassification(111,motherPDG);
2814  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source, fWeightJetJetMC); // All secondary MC Pi0
2815  }
2816 
2817  // check whether pi0 landet in acceptance
2818  if( (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter0,AODMCTrackArray) ||
2819  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter1,AODMCTrackArray) ) ){
2820  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2821  Int_t source = GetSourceClassification(111,motherPDG);
2822  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source, fWeightJetJetMC); // All secondary MC Pi0
2823  }
2824  }
2825  }
2826 
2827  Int_t gammaLabel = -1;
2828  Int_t electronLabel = -1;
2829  Int_t positronLabel = -1;
2830  // check if particle is pi0/eta from Dalitz decay
2832  ->MesonIsSelectedAODMCDalitz(particle,AODMCTrackArray, electronLabel, positronLabel, gammaLabel, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2833  if( (gammaLabel > -1) && (electronLabel > -1) && (positronLabel > -1) ){
2834  AliAODMCParticle* gamma = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaLabel));
2835  AliAODMCParticle* electron = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(electronLabel));
2836  AliAODMCParticle* positron = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(positronLabel));
2837 
2838  AliAODMCParticle* mother = NULL;
2839  Int_t motherPDG = -1000000;
2840  if (particle->GetMother() > -1){
2841  mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2842  if (mother)
2843  motherPDG = TMath::Abs(mother->GetPdgCode());
2844  }
2845 
2846  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2847  Int_t source = GetSourceClassification(111,motherPDG);
2848  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source, fWeightJetJetMC); // All secondary MC Pi0
2849  }
2850 
2851  // check whether pi0 landet in acceptance
2852  if( (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(gamma,AODMCTrackArray) ||
2853  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecAODMC(electron,AODMCTrackArray) ||
2854  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecAODMC(positron,AODMCTrackArray) ) ){
2855  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2856  Int_t source = GetSourceClassification(111,motherPDG);
2857  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source, fWeightJetJetMC); // All secondary MC Pi0
2858  }
2859  }
2860  }
2861  }
2862  }
2863  } // end of particle loop
2864  return;
2865 }
2866 
2867 //_________________________________________________________________________________
2869  TAxis *axisafter = histoRebin->GetXaxis();
2870  Int_t bins = axisafter->GetNbins();
2871  Double_t from = axisafter->GetXmin();
2872  Double_t to = axisafter->GetXmax();
2873  Double_t *newbins = new Double_t[bins+1];
2874  newbins[0] = from;
2875  Double_t factor = TMath::Power(to/from, 1./bins);
2876  for(Int_t i=1; i<=bins; ++i) newbins[i] = factor * newbins[i-1];
2877  axisafter->Set(bins, newbins);
2878  delete [] newbins;
2879 }
2880 
2881 //_________________________________________________________________________________
2883 {
2884  if(tobechecked > -1)
2885  {
2886  vector<Int_t>::iterator it;
2887  it = find (vec.begin(), vec.end(), tobechecked);
2888  if (it != vec.end()) return true;
2889  else{
2890  vec.push_back(tobechecked);
2891  return false;
2892  }
2893  }
2894  return false;
2895 }
2896 
2897 //________________________________________________________________________
2899 {
2900 
2901  //fOutputContainer->Print(); // Will crash on GRID
2902 }
2903 
2904 
2905 //_________________________________________________________________________________
2906 void AliAnalysisTaskGammaCaloMerged::FillMultipleCountMap(map<Int_t,Int_t> &ma, Int_t tobechecked){
2907  if( ma.find(tobechecked) != ma.end() ) ma[tobechecked] += 1;
2908  else ma[tobechecked] = 2;
2909  return;
2910 }
2911 
2912 //_________________________________________________________________________________
2914  map<Int_t, Int_t>::iterator it;
2915  for (it = ma.begin(); it != ma.end(); it++){
2916  hist->Fill(it->second, fWeightJetJetMC);
2917  }
2918  ma.clear();
2919  return;
2920 }
2921 
2922 
2923 //________________________________________________________________________
2925 
2926  if (daughter == 111) {
2927  if (TMath::Abs(pdgCode) == 310) return 1; // k0s
2928  else if (TMath::Abs(pdgCode) == 3122) return 2; // Lambda
2929  else if (TMath::Abs(pdgCode) == 130) return 3; // K0L
2930  else if (TMath::Abs(pdgCode) == 2212) return 4; // proton
2931  else if (TMath::Abs(pdgCode) == 2112) return 5; // neutron
2932  else if (TMath::Abs(pdgCode) == 211) return 6; // pion
2933  else if (TMath::Abs(pdgCode) == 321) return 7; // kaon
2934  else if (TMath::Abs(pdgCode) == 113 || TMath::Abs(pdgCode) == 213 ) return 8; // rho 0,+,-
2935  else if (TMath::Abs(pdgCode) == 3222 || TMath::Abs(pdgCode) == 3212 || TMath::Abs(pdgCode) == 3112 ) return 9; // Sigma
2936  else if (TMath::Abs(pdgCode) == 2224 || TMath::Abs(pdgCode) == 2214 || TMath::Abs(pdgCode) == 2114 || TMath::Abs(pdgCode) == 1114 ) return 10; // Delta
2937  else if (TMath::Abs(pdgCode) == 313 || TMath::Abs(pdgCode) == 323 ) return 11; // K*
2938  else return 15;
2939  }
2940  return 15;
2941 
2942 }
TH2F ** fHistoClusMergedNCellsPt
array of histos with cluster NCells vs Pt
TH1F ** fHistoNGoodESDTracks
array of histos with event information without event weights
TH1F ** fHistoMCPi0DalitzInAccPt
array of histos without evt weight eta in acceptance, pT
TH2F ** fHistoTruePrimaryEtaMCPtResolPt
array of histos with validated weighted primary pi0, MCpt, resol pt
TH2F ** fHistoClusMergedNCellsAroundPt
array of histos with merged cluster N MC paricles in cluster vs Pt
TH2F ** fHistoTruePi0PtAlpha
array of histos with validated eta, pt, Y
void SetCaloClusterRef(Long_t ref)
TH1F ** fHistoClusOverlapHeadersGammaPt
array of histos with cluster, E
double Double_t
Definition: External.C:58
void FillMultipleCountHistoAndClear(map< Int_t, Int_t > &ma, TH1F *hist)
Definition: External.C:236
TH2F ** fHistoMotherPtAlpha
array of histograms with signal +BG pt, Y
void SetCaloPhotonMCFlags(AliMCEvent *mcEvent, Bool_t enableSort)
TH1F ** fHistoMCPi0InAccPt
array of histos without event weights eta Dalitz, pT
TH2F ** fHistoTruePrimaryPi0MergedPartConvMCPtResolPt
array of histos with validated weighted primary pi0, MCpt, resol pt
TH1F ** fHistoMCEtaDalitzWOWeightPt
array of histos with weighted eta Dalitz, pT
TH2F ** fHistoTrueEtaPtAlpha
array of histos with validated pi0, pt, alpha
TH1F ** fHistoMCPi0DalitzPt
array of histos without event weights eta, pT
TH1F ** fHistoMCAllGammaPt
array of histos with weighted decay gamma
Int_t GetNumberOfPrimaryTracks()
TH1F ** fHistoClusGammaE
array of histos with cluster, pt
TH2F ** fHistoMCPrimaryPtvsSource
array of histos with weighted eta, pT, hardest jet pt
TH2F ** fHistoSPDClusterTrackletBackground
array of histos with number of good tracks vs gamma candidates
TH2F ** fHistoMCSecPi0InAccPtvsSource
array of histos with weighted pi0 from sec, pT for different sources
TString GetCurrentFileName()
Definition: AliV0ReaderV1.h:95
TString GetPeriodName()
TH1F ** fHistoNEvents
vector containing labels of validated eta
virtual Int_t GetLabel(Int_t i) const
TH2F ** fHistoTrueClusEtaEM02
array of histos with validated pi0, E, m02
TH1F ** fHistoNEventsWOWeight
array of histos with event information
void SetCaloPhotonMCLabel(Int_t i, Int_t labelCaloPhoton)
TH2F ** fHistoClusMergedNCellsAroundAndInPt
array of histos with number of cells surrounding merged cluster vs merged cluster Pt ...
TH1F ** fHistoClusGammaPt
array of histograms with signal +BG pt, alpha
Int_t GetCaloPhotonMotherMCLabel(Int_t i)
TH1F ** fHistoMCEtaWOEvtWeightPt
array of histos with unweighted eta, pT
TH1I ** fHistoMCHeaders
array of histos with E surrounding merged cluster vs merged cluster E
TH1F ** fHistoMCDecayGammaPt
array of histos with weighted primary particles, Y vs source
void PrintCaloMCLabelsAndInfo(AliMCEvent *mcEvent)
TH2F ** fHistoClusNCellsPt
array of histos with cluster merged accepted mesons, E vs M02
TH1F ** fHistoMCPi0DalitzWOWeightPt
array of histos with weighted pi0 Dalitz, pT
TH2F ** fHistoClusMergedEvsM02Accepted
array of histos with cluster merged accepted mesons, pt vs M02
int Int_t
Definition: External.C:63
TH2F ** fHistoClusMergedPtvsM02Accepted
array of histos with cluster merged, pt vs M02
TH1F ** fHistoMCEtaDalitzPt
array of histos without event weights pi0 Dalitz, pT
Class handling all kinds of selection cuts for Gamma Calo analysis.
TH2F ** fHistoClusMergedEAroundE
array of histos with number of cells surrounding merged cluster + Ncells in clus vs merged cluster Pt...
TH1F ** fHistoNClusterMergedCandidates
array of histos with number of cluster candidates per event
TH2F ** fHistoMCPrimaryYvsSource
array of histos with weighted primary particles, pT vs source
TH1F ** fHistoMCEtaDalitzWOEvtWeightPt
array of histos with unweighted eta Dalitz, pT
float Float_t
Definition: External.C:68
TH1F ** fHistoMCPi0WOWeightPt
array of histos with weighted pi0, pT
Bool_t CheckVectorForDoubleCount(vector< Int_t > &vec, Int_t tobechecked)
TH1F ** fHistoMCPi0WOEvtWeightPt
array of histos with unweighted pi0, pT
TH1F ** fHistoNClusterCandidates
array of histos with vertex z distribution for selected events
Int_t fNClusterMergedCandidates
current number of cluster candidates
AliConversionPhotonCuts * GetConversionCuts()
Definition: AliV0ReaderV1.h:89
TH1F ** fHistoMCPi0WOEvtWeightInAccPt
array of histos with weighted eta in acceptance, pT
TH2F ** fHistoMotherPtY
array of histogram with signal + BG for same event photon pairs, inv Mass, pt
void ProcessTrueClusterCandidatesAOD(AliAODConversionPhoton *TruePhotonCandidate, Float_t m02, AliAODConversionPhoton *TrueSubClusterCandidate1, AliAODConversionPhoton *TrueSubClusterCandidate2)
TH2F ** fHistoMCPi0PtJetPt
array of histos with weighted pi0 from sec in acceptance, pT for different sources ...
TH1F ** fHistoNV0Tracks
array of histos with SPD tracklets vs SPD clusters for background rejection
Class handling all kinds of selection cuts for Gamma Conversion analysis.
TH2F ** fHistoTrueSecondaryPi0MCPtResolPt
array of histos with validated weighted primary eta, MCpt, resol pt
TH1F ** fHistoJetJetNTrials
array of profiles with xsection for jetjet
TH2F ** fHistoTruePrimaryPi01GammaMCPtResolPt
array of histos with validated weighted primary pi0, MCpt, resol pt
TH1F ** fHistoMCEtaDalitzInAccPt
array of histos with weighted pi0 dalitz in acceptance, pT
TH1F ** fHistoMCPi0Pt
array of histos for header names
TH1F ** fHistoMCEtaDalitzWOEvtWeightInAccPt
array of histos without evt weight pi0 in acceptance, pT
TH2F ** fHistoTrueClusPi0EM02
array of histos with validated electrons, E, m02
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
TH2F ** fHistoClusMergedNParticlePt
array of histos with merged cluster NCells vs Pt
TH1F ** fHistoMCEtaWOEvtWeightInAccPt
array of histos without evt weight pi0 in acceptance, pT
Int_t GetSourceClassification(Int_t daughter, Int_t pdgCode)
TH2F ** fHistoTrueClusGammaEM02
array of histos with validated eta, pt, alpha
TList * GetCaloTrackMatcherHistograms()
TH2F ** fHistoDoubleCountTrueEtaPtvsM02
array of histos with double counted secondary pi0s, pT, M02
TH2F ** fHistoClusMergedPtvsM02
array of histos with cluster NLM vs Pt
TProfile ** fProfileEtaShift
array of histos with V0 counts
Definition: External.C:220
Class handling all kinds of selection cuts for Gamma Conversion analysis.
TH2F ** fHistoMCEtaPtJetPt
array of histos with weighted pi0, pT, hardest jet pt
TH2F ** fHistoDoubleCountTruePi0PtvsM02
array of histos with validated weighted secondary pi0, MCpt, resol pt
TH2F ** fHistoTrueClusMergedPtvsM02
array of histos with weighted all gamma
void SetNCaloPhotonMCLabels(Int_t nLabels)
TH1F ** fHistoDoubleCountTrueSecPi0Pt
array of histos with double counted pi0s, pT, M02
TH1F ** fHistoMCEtaPt
array of histos without event weights pi0, pT
TH1F ** fHistoMCEtaWOWeightPt
array of histos with weighted eta, pT
void ProcessTrueClusterCandidates(AliAODConversionPhoton *TruePhotonCandidate, Float_t m02, AliAODConversionPhoton *TrueSubClusterCandidate1, AliAODConversionPhoton *TrueSubClusterCandidate2)
Class handling all kinds of selection cuts for Gamma Conversion analysis.
TH1F ** fHistoMCPi0DalitzWOEvtWeightInAccPt
array of histos with weighted eta dalitz in acceptance, pT
TH2F ** fHistoNGoodESDTracksVsNClusterCandidates
array of histos with number of merged cluster candidates per event
TH2F ** fHistoMCSecPi0PtvsSource
array of histos without evt weight eta in acceptance, pT
TH1F ** fHistoMCPi0DalitzWOEvtWeightPt
array of histos with unweighted pi0 Dalitz, pT
AliConvEventCuts * GetEventCuts()
Definition: AliV0ReaderV1.h:90
const char Option_t
Definition: External.C:48
TList * fEventCutArray
current number of merged cluster candidates
TH1F ** fHistoMCEtaInAccPt
array of histos with weighted pi0 in acceptance, pT
bool Bool_t
Definition: External.C:53
TH2F ** fHistoTruePrimaryPi01ElectronMCPtResolPt
array of histos with validated weighted primary pi0, MCpt, resol pt
TProfile ** fProfileJetJetXSection
array of profiles with eta shift
vector< Int_t > fVectorDoubleCountTrueEtas
vector containing labels of validated pi0
TH1F ** fHistoVertexZ
array of histos with number of good tracks (2010 Standard track cuts)
vector< Int_t > fVectorDoubleCountTruePi0s
array of histos with double counted etas, pT, M02
void SetCaloPhotonMCFlagsAOD(AliVEvent *event, Bool_t enableSort)
TH2F ** fHistoTruePrimaryPi0PureMergedMCPtResolPt
array of histos with validated eta, E, m02
TH2F ** fHistoClusNLMPt
array of histos with cluster, pt overlapping with other headers
TH2F ** fHistoTrueEtaPtY
array of histos with validated pi0, pt, Y
void FillMultipleCountMap(map< Int_t, Int_t > &ma, Int_t tobechecked)
TH2F ** fHistoTrueClusElectronEM02
array of histos with validated gamma, E, m02