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