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