AliPhysics  59e0e03 (59e0e03)
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){
1371  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
1372  fHistoNEvents[iCut]->Fill(eventNotAccepted, fWeightJetJetMC); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
1373  if (fIsMC==2) fHistoNEventsWOWeight[iCut]->Fill(eventNotAccepted);
1374  if (eventNotAccepted==3 && fIsMC>0){
1375  triggered = kFALSE;
1376  } else {
1377  continue;
1378  }
1379  }
1380 
1381  if(eventQuality != 0){// 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){
1516  delete clus;
1517  continue;
1518  }
1519 
1520  // Set the jetjet weight to 1 in case the cluster orignated from the minimum bias header
1521  if (fIsMC>0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() == 4){
1522  if( ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(clus->GetLabelAt(0), fMCEvent, fInputEvent) == 2)
1523  tempClusterWeight = 1;
1524  }
1525 
1526  // if open cluster cuts are not fullfilled I can abort
1527  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC,tempClusterWeight, i)){
1528  delete clus;
1529  continue;
1530  }
1531 
1532  // TLorentzvector with cluster
1533  TLorentzVector clusterVector;
1534  clus->GetMomentum(clusterVector,vertex);
1535 
1536  TLorentzVector* tmpvec = new TLorentzVector();
1537  tmpvec->SetPxPyPzE(clusterVector.Px(),clusterVector.Py(),clusterVector.Pz(),clusterVector.E());
1538 
1539  // convert to AODConversionPhoton
1540  AliAODConversionPhoton *PhotonCandidate=new AliAODConversionPhoton(tmpvec);
1541  if(!PhotonCandidate){
1542  delete clus;
1543  delete tmpvec;
1544  if (PhotonCandidate) delete PhotonCandidate;
1545  continue;
1546  }
1547 
1548  // Flag Photon as CaloPhoton
1549  PhotonCandidate->SetIsCaloPhoton();
1550  PhotonCandidate->SetCaloClusterRef(i);
1551 
1552  // get MC label
1553  if(fIsMC> 0){
1554  Int_t* mclabelsCluster = clus->GetLabels();
1555 // cout << "cluster: " << i << endl;
1556  Int_t nValidClusters = 0;
1557 
1558  if (clus->GetNLabels()>0){
1559  for (Int_t k =0; k< (Int_t)clus->GetNLabels(); k++){
1560 // TParticle *dummy = NULL;
1561  if (mclabelsCluster[k]>0){
1562 // dummy = fMCEvent->Particle(mclabelsCluster[k]);
1563 // if (dummy->R() < 407.0){
1564  if (nValidClusters< 50)PhotonCandidate->SetCaloPhotonMCLabel(nValidClusters,mclabelsCluster[k]);
1565  nValidClusters++;
1566 // }
1567  }
1568  }
1569  }
1570  PhotonCandidate->SetNCaloPhotonMCLabels(nValidClusters);
1571 
1572  }
1573 
1574  fIsFromMBHeader = kTRUE;
1576 
1577  // test whether largest contribution to cluster orginates in added signals
1578  if (fIsMC>0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() > 0){
1579  // Set the jetjet weight to 1 in case the photon candidate orignated from the minimum bias header
1580  if ( ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetCaloPhotonMCLabel(0), fMCEvent, fInputEvent) == 2 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() == 4) tempPhotonWeight = 1;
1581  if ( ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetCaloPhotonMCLabel(0), fMCEvent, fInputEvent) == 0) fIsFromMBHeader = kFALSE;
1582  if (clus->GetNLabels()>1){
1583  Int_t* mclabelsCluster = clus->GetLabels();
1584  for (Int_t l = 1; l < (Int_t)clus->GetNLabels(); l++ ){
1585  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(mclabelsCluster[l], fMCEvent, fInputEvent) == 0) fIsOverlappingWithOtherHeader = kTRUE;
1586  }
1587  }
1588  }
1589 
1590  // check whether photon is from correct header
1592  fHistoClusOverlapHeadersGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), tempPhotonWeight);
1593  }
1594  // only cluster candidates from correct header will be processed fully
1596  fHistoClusGammaPt[fiCut]->Fill(PhotonCandidate->Pt(), tempPhotonWeight);
1597  fHistoClusGammaE[fiCut]->Fill(PhotonCandidate->E(), tempPhotonWeight);
1598  if (fDoClusterQA > 0){
1599  fHistoClusNCellsPt[fiCut]->Fill(clus->GetNCells(), PhotonCandidate->Pt(), tempPhotonWeight);
1600  }
1602  } else {
1603  delete clus;
1604  delete tmpvec;
1605  delete PhotonCandidate;
1606  continue;
1607  }
1608 
1609  if(!((AliCaloPhotonCuts*)fClusterMergedCutArray->At(fiCut))->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC,tempPhotonWeight,i)){
1610  delete clus;
1611  delete tmpvec;
1612  delete PhotonCandidate;
1613  continue;
1614  }else {
1616  }
1617 
1618  AliAODCaloCluster* clusSub1 = new AliAODCaloCluster();
1619  AliAODCaloCluster* clusSub2 = new AliAODCaloCluster();
1620 
1621 
1622  // split clusters according to their shares in the cluster (NLM == 1) needs to be treated differently
1623  if (((AliCaloPhotonCuts*)fClusterMergedCutArray->At(fiCut))->GetMinNLMCut() == 1 &&
1624  ((AliCaloPhotonCuts*)fClusterMergedCutArray->At(fiCut))->GetMaxNLMCut() == 1 ){
1625 
1626  Int_t absCellIdFirst = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->FindLargestCellInCluster(clus, fInputEvent);
1627  Int_t absCellIdSecond = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->FindSecondLargestCellInCluster(clus, fInputEvent);
1628 
1629  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->SplitEnergy(absCellIdFirst, absCellIdSecond,
1630  clus, fInputEvent, fIsMC, clusSub1, clusSub2);
1631 
1632 
1633  } else if (((AliCaloPhotonCuts*)fClusterMergedCutArray->At(fiCut))->GetMinNLMCut() > 1 ){
1634  const Int_t nc = clus->GetNCells();
1635  Int_t absCellIdList[nc];
1636  //Float_t maxEList[nc];
1637  //Int_t nlm = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetNumberOfLocalMaxima(clus, fInputEvent, absCellIdList, maxEList);
1638  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->SplitEnergy(absCellIdList[0], absCellIdList[1],
1639  clus, fInputEvent, fIsMC, clusSub1, clusSub2);
1640  }
1641  fHistoClusMergedPtvsM02[fiCut]->Fill( PhotonCandidate->Pt(),
1642  clus->GetM02(),
1643  tempPhotonWeight);
1644 
1645  // TLorentzvector with sub cluster 1
1646  TLorentzVector clusterVector1;
1647  clusSub1->GetMomentum(clusterVector1,vertex);
1648  TLorentzVector* tmpvec1 = new TLorentzVector();
1649  tmpvec1->SetPxPyPzE(clusterVector1.Px(),clusterVector1.Py(),clusterVector1.Pz(),clusterVector1.E());
1650  // convert to AODConversionPhoton
1651  AliAODConversionPhoton *PhotonCandidate1=new AliAODConversionPhoton(tmpvec1);
1652  if(!PhotonCandidate1){
1653  delete clusSub1;
1654  delete tmpvec1;
1655  continue;
1656  }
1657  // Flag Photon as CaloPhoton
1658  PhotonCandidate1->SetIsCaloPhoton();
1659 
1660  // TLorentzvector with sub cluster 2
1661  TLorentzVector clusterVector2;
1662  clusSub2->GetMomentum(clusterVector2,vertex);
1663  TLorentzVector* tmpvec2 = new TLorentzVector();
1664  tmpvec2->SetPxPyPzE(clusterVector2.Px(),clusterVector2.Py(),clusterVector2.Pz(),clusterVector2.E());
1665  // convert to AODConversionPhoton
1666  AliAODConversionPhoton *PhotonCandidate2=new AliAODConversionPhoton(tmpvec2);
1667  if(!PhotonCandidate2){
1668  delete clusSub2;
1669  delete tmpvec2;
1670  continue;
1671  }
1672  // Flag Photon as CaloPhoton
1673  PhotonCandidate2->SetIsCaloPhoton();
1674 
1675  // create pi0 candidate
1676  AliAODConversionMother *pi0cand = new AliAODConversionMother(PhotonCandidate1,PhotonCandidate2);
1677 
1678  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
1679  fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),PhotonCandidate->Pt(), tempPhotonWeight);
1680  fHistoClusMergedPtvsM02Accepted[fiCut]->Fill( PhotonCandidate->Pt(), clus->GetM02(), tempPhotonWeight);
1681  fHistoClusMergedEvsM02Accepted[fiCut]->Fill( PhotonCandidate->E(), clus->GetM02(), tempPhotonWeight);
1682  Int_t nlm = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetNumberOfLocalMaxima(clus, fInputEvent);
1683  if ( nlm < 11 ){
1684  fHistoClusNLMPt[fiCut]->Fill( nlm, PhotonCandidate->Pt());
1685  } else {
1686  fHistoClusNLMPt[fiCut]->Fill( 11., PhotonCandidate->Pt());
1687  }
1688 
1689  if (fDoClusterQA > 0){
1690  fHistoClusMergedNCellsPt[fiCut]->Fill(clus->GetNCells(), PhotonCandidate->Pt(), tempPhotonWeight);
1691  Double_t energyAround = 0;
1692  Double_t nCellsAround = 0;
1693  for (Int_t j = 0; j < nclus; j++){
1694  if (j == i) continue;
1695  AliVCluster* clusTemp = NULL;
1696  if(fInputEvent->IsA()==AliESDEvent::Class()){
1697  if(arrClustersProcess)
1698  clusTemp = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersProcess->At(j));
1699  else
1700  clusTemp = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(j));
1701  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
1702  if(arrClustersProcess)
1703  clusTemp = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersProcess->At(j));
1704  else
1705  clusTemp = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(j));
1706  }
1707 
1708  if (!clusTemp){
1709  delete clusTemp;
1710  continue;
1711  }
1712 
1713  Double_t R = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetDistanceBetweenClusters(clus, clusTemp);
1714 
1715  if (R < 0.15){
1716  nCellsAround = nCellsAround+clusTemp->GetNCells();
1717  energyAround = energyAround+clusTemp->E();
1718  }
1719  delete clusTemp;
1720  }
1721  fHistoClusMergedNCellsAroundPt[fiCut]->Fill(nCellsAround, PhotonCandidate->Pt(), tempPhotonWeight);
1722  fHistoClusMergedNCellsAroundAndInPt[fiCut]->Fill(nCellsAround+clus->GetNCells(), PhotonCandidate->Pt(), tempPhotonWeight);
1723  fHistoClusMergedEAroundE[fiCut]->Fill(energyAround, clus->E(), tempPhotonWeight);
1724  if (fIsMC > 0){
1725  fHistoClusMergedNParticlePt[fiCut]->Fill(clus->GetNLabels(), PhotonCandidate->Pt(), tempPhotonWeight);
1726  }
1727  }
1728  if (fDoMesonQA > 0 ){
1729  fHistoMotherPtY[fiCut]->Fill(PhotonCandidate->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), tempPhotonWeight);
1730  fHistoMotherPtAlpha[fiCut]->Fill(PhotonCandidate->Pt(),TMath::Abs(pi0cand->GetAlpha()), tempPhotonWeight);
1731  }
1732  if(fIsMC> 0 && PhotonCandidate && PhotonCandidate1 && PhotonCandidate2){
1733  if(fInputEvent->IsA()==AliESDEvent::Class())
1734  ProcessTrueClusterCandidates(PhotonCandidate, clus->GetM02(), PhotonCandidate1, PhotonCandidate2);
1735  if(fInputEvent->IsA()==AliAODEvent::Class())
1736  ProcessTrueClusterCandidatesAOD(PhotonCandidate, clus->GetM02(), PhotonCandidate1, PhotonCandidate2);
1737  }
1738  }
1739 
1740 
1741 
1742  delete pi0cand;
1743  delete clusSub1;
1744  delete tmpvec1;
1745  delete PhotonCandidate1;
1746  delete clusSub2;
1747  delete tmpvec2;
1748  delete PhotonCandidate2;
1749 
1750  delete clus;
1751  delete tmpvec;
1752  delete PhotonCandidate;
1753  }
1754 
1755 }
1756 
1757 //________________________________________________________________________
1759  AliAODConversionPhoton *TrueSubClusterCandidate1,
1760  AliAODConversionPhoton *TrueSubClusterCandidate2)
1761 {
1762 
1763  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
1764  Double_t mcProdVtxX = primVtxMC->GetX();
1765  Double_t mcProdVtxY = primVtxMC->GetY();
1766  Double_t mcProdVtxZ = primVtxMC->GetZ();
1767 
1768  Double_t tempClusterWeight = fWeightJetJetMC;
1769  TParticle *Photon = NULL;
1770  if (!TrueClusterCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
1771  if (TrueClusterCandidate->GetCaloPhotonMCLabel(0) < 0) return;
1772 
1773  if (TrueClusterCandidate->GetNCaloPhotonMCLabels()>0) Photon = fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMCLabel(0));
1774  else return;
1775 
1776  if(Photon == NULL){
1777  // cout << "no photon" << endl;
1778  return;
1779  }
1780 
1781  AliAODConversionMother *mesoncand = new AliAODConversionMother(TrueSubClusterCandidate1,TrueSubClusterCandidate2);
1782  Bool_t mesonIsSelected = (((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(mesoncand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()));
1783  if (!mesonIsSelected){
1784  delete mesoncand;
1785  return;
1786  }
1787  Int_t pdgCodeParticle = Photon->GetPdgCode();
1788  TrueClusterCandidate->SetCaloPhotonMCFlags(fMCEvent, fEnableSortForClusMC);
1789  if (TrueClusterCandidate->GetNCaloPhotonMCLabels()>0 && fEnableDetailedPrintOut){
1790  cout << endl << endl << "Cluster energy: " << TrueClusterCandidate->E() << endl;;
1791  TrueClusterCandidate->PrintCaloMCLabelsAndInfo(fMCEvent);
1792  TrueClusterCandidate->PrintCaloMCFlags();
1793  }
1794 
1796  Int_t clusterClass = 0;
1797  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, TrueClusterCandidate->GetCaloPhotonMCLabel(0), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
1798 
1799  // cluster classification:
1800  // 1 - nice merged cluster (2 gamma | contributions from 2 gamma) from pi0/eta
1801  // 2 - contribution from only 1 partner (1 gamma, 1 fully coverted gamma) from pi0/eta
1802  // 3 - contribution from part of 1 partner (1 electron) from pi0/eta
1803  Long_t motherLab = -1;
1804  if (TrueClusterCandidate->IsMerged() || TrueClusterCandidate->IsMergedPartConv()){
1805  clusterClass = 1;
1806  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
1807  } else if (TrueClusterCandidate->GetNCaloPhotonMotherMCLabels()> 0){
1808 // cout << TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0) << endl;
1809  if (TrueClusterCandidate->IsLargestComponentElectron() || TrueClusterCandidate->IsLargestComponentPhoton()){
1810  if (TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0) > -1 && (fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0))->GetPdgCode() == 111 || fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0))->GetPdgCode() == 221) ){
1811  if ( TrueClusterCandidate->IsConversion() && !TrueClusterCandidate->IsConversionFullyContained() ){
1812  clusterClass = 3;
1813  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
1814  } else {
1815  clusterClass = 2;
1816  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
1817  }
1818  }
1819  } else if (TrueClusterCandidate->IsSubLeadingEM()){
1820  if (TrueClusterCandidate->GetNCaloPhotonMotherMCLabels()> 1){
1821  if (fEnableDetailedPrintOut) cout << "Is Subleading EM: "<< TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1) << endl;
1822  if ( TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1) > -1){
1823  if (fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1))->GetPdgCode() == 111 || fMCEvent->Particle(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1))->GetPdgCode() == 221 ){
1824  clusterClass = 2;
1825  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1);
1826  }
1827  }
1828  }
1829  } else {
1830  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
1831  }
1832  }
1833 
1834  // Get Mother particle
1835  TParticle *mother = NULL;
1836  Int_t motherPDG = -1;
1837  if (motherLab > -1){
1838  mother = fMCEvent->Particle(motherLab);
1839  }
1840  if (fEnableDetailedPrintOut) cout << "cluster class: " << clusterClass << "\t mother lab: "<< motherLab ;
1841  if (mother){
1842  motherPDG = TMath::Abs(mother->GetPdgCode());
1843  if (fEnableDetailedPrintOut) cout << "\t mother pdg: " << motherPDG << endl;
1844  } else {
1845  if (fEnableDetailedPrintOut) cout << endl;
1846  }
1847  // Set the jetjet weight to 1 in case the photon orignated from the minimum bias header
1848  if (fIsMC>0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() == 4){
1849  if ( ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(motherLab, fMCEvent, fInputEvent) == 2) tempClusterWeight = 1;
1850  }
1851 
1852  //
1853  if (clusterClass == 1 || clusterClass == 2 || clusterClass == 3 ){
1854  fHistoTrueClusMergedPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1855  if (fDoMesonQA > 1)fHistoTrueClusMergedInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), tempClusterWeight);
1856 
1857  // separate different components
1858  if (clusterClass == 1 && TrueClusterCandidate->IsMerged()){
1859  if (motherPDG == 111){
1860  fHistoTrueClusMergedPureFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1861  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
1862  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 0., tempClusterWeight);
1863  }
1864  }
1865  if (motherPDG == 221)
1866  fHistoTrueClusMergedPureFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1867  } else if (clusterClass == 1 && TrueClusterCandidate->IsMergedPartConv()){
1868  if (motherPDG == 111){
1869  fHistoTrueClusMergedPartConvFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1870  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
1871  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 1., tempClusterWeight);
1872  }
1873  }
1874  if (motherPDG == 221)
1875  fHistoTrueClusMergedPartConvFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1876  } else if (clusterClass == 2){
1877  if (motherPDG == 111){
1878  fHistoTrueClusGammaFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1879  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
1880  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 2., tempClusterWeight);
1881  }
1882  }if (motherPDG == 221)
1883  fHistoTrueClusGammaFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1884  } else if (clusterClass == 3){
1885  if (motherPDG == 111) {
1886  fHistoTrueClusElectronFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1887  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
1888  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 3., tempClusterWeight);
1889  }
1890  }
1891  if (motherPDG == 221)
1892  fHistoTrueClusElectronFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1893  }
1894 
1895  // deal with pi0 only
1896  if (motherPDG == 111){
1897  fHistoTrueClusPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1899  fHistoDoubleCountTruePi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1900  if (!isPrimary)
1901  fHistoDoubleCountTrueSecPi0Pt[fiCut]->Fill(TrueClusterCandidate->Pt(), tempClusterWeight);
1902  }
1903 
1904 
1905  if (TrueClusterCandidate->IsDalitz()){
1906  fHistoTrueClusPi0DalitzPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1907  }
1908  if (fDoMesonQA > 1)fHistoTrueClusPi0InvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), tempClusterWeight);
1909  if (fDoMesonQA > 0){
1910  fHistoTrueClusPi0EM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, tempClusterWeight);
1911  }
1912  if (fDoMesonQA > 0 && GetSelectedMesonID() != 2){
1913  fHistoTruePi0PtY[fiCut]->Fill(TrueClusterCandidate->Pt(),mesoncand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), tempClusterWeight);
1914  fHistoTruePi0PtAlpha[fiCut]->Fill(TrueClusterCandidate->Pt(),TMath::Abs(mesoncand->GetAlpha()), tempClusterWeight);
1915  }
1916 
1917  if (GetSelectedMesonID() < 2) {
1918  if (isPrimary) {
1919  fHistoTrueClusPrimPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1920  if (fDoMesonQA > 1) fHistoTrueClusPrimPi0InvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), tempClusterWeight);
1921  if (fDoMesonQA > 0){
1922  if (clusterClass == 1 && TrueClusterCandidate->IsMerged())
1923  fHistoTruePrimaryPi0PureMergedMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),tempClusterWeight);
1924  else if (clusterClass == 1 && TrueClusterCandidate->IsMergedPartConv())
1925  fHistoTruePrimaryPi0MergedPartConvMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),tempClusterWeight);
1926  else if (clusterClass == 2)
1927  fHistoTruePrimaryPi01GammaMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),tempClusterWeight);
1928  else if (clusterClass == 3)
1929  fHistoTruePrimaryPi01ElectronMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),tempClusterWeight);
1930  }
1931  } else {
1932  fHistoTrueClusSecPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1933  if (fDoMesonQA > 0){
1934  fHistoTrueSecondaryPi0MCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),tempClusterWeight);
1935  }
1936  Int_t grandMaLab = mother->GetMother(0);
1937  if (grandMaLab > -1){
1938  if (TMath::Abs(fMCEvent->Particle(grandMaLab)->GetPdgCode()) == 310){
1939  fHistoTrueClusSecPi0FromK0sPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1940  } else if (TMath::Abs(fMCEvent->Particle(grandMaLab)->GetPdgCode()) == 130){
1941  fHistoTrueClusSecPi0FromK0lPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1942  } else if (TMath::Abs(fMCEvent->Particle(grandMaLab)->GetPdgCode()) == 3122){
1943  fHistoTrueClusSecPi0FromLambdaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1944  }
1945  }
1946  }
1947  }
1948  // deal with eta only
1949  } else if (motherPDG == 221){
1950  fHistoTrueClusEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1951  if (TrueClusterCandidate->IsDalitz()){
1952  fHistoTrueClusEtaDalitzPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1953  }
1954  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueEtas,motherLab)) fHistoDoubleCountTrueEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1955  if (fDoMesonQA > 1)fHistoTrueClusEtaInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), tempClusterWeight);
1956  if (fDoMesonQA > 0){
1957  fHistoTrueClusEtaEM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, tempClusterWeight);
1958  }
1959  if ( fDoMesonQA > 0 && GetSelectedMesonID() != 1 ){
1960  fHistoTrueEtaPtY[fiCut]->Fill(TrueClusterCandidate->Pt(),mesoncand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), tempClusterWeight);
1961  fHistoTrueEtaPtAlpha[fiCut]->Fill(TrueClusterCandidate->Pt(),TMath::Abs(mesoncand->GetAlpha()), tempClusterWeight);
1962  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),tempClusterWeight);
1963  }
1964  } else {
1965  fHistoTrueMergedMissedPDG[fiCut]->Fill(motherPDG, tempClusterWeight);
1966  }
1967 
1968  // leading particle is a photon or the conversion is fully contained and its not from pi0 || eta
1969  } else if (TrueClusterCandidate->IsLargestComponentPhoton() || TrueClusterCandidate->IsConversionFullyContained()
1970  || TrueClusterCandidate->IsElectronFromFragPhoton()){
1971  if (fEnableDetailedPrintOut) cout << "photon" << endl;
1972  fHistoTrueClusGammaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
1973  if (fDoMesonQA > 0){
1974  fHistoTrueClusGammaEM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, tempClusterWeight);
1975  }
1976 
1977  if (fDoMesonQA > 1) fHistoTrueClusGammaInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), tempClusterWeight);
1978  if (motherLab == -1){
1979  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 0.5, tempClusterWeight); // direct photon
1980  } else {
1981  if (motherPDG == 111)
1982  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 1.5, tempClusterWeight); // pi0
1983  else if (motherPDG == 221)
1984  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 2.5, tempClusterWeight); // eta
1985  else if (motherPDG == 331)
1986  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 3.5, tempClusterWeight); // eta'
1987  else if (motherPDG == 223)
1988  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 4.5, tempClusterWeight); // omega
1989  else if (motherPDG == 333)
1990  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 5.5, tempClusterWeight); // phi
1991  else if (motherPDG == 3122)
1992  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 6.5, tempClusterWeight); // Lambda
1993  else
1994  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 7.5, tempClusterWeight); // rest
1995  }
1996 
1997  // leading particle is an electron and its not from pi0 || eta and no electron from fragmentation photon conversion
1998  } else if (TrueClusterCandidate->IsLargestComponentElectron() &&
1999  !TrueClusterCandidate->IsElectronFromFragPhoton()){
2000  if (fEnableDetailedPrintOut) cout << "electron" << endl;
2001  fHistoTrueClusElectronPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2002  if (fDoMesonQA > 0){
2003  fHistoTrueClusElectronEM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, tempClusterWeight);
2004  }
2005 
2006  if (fDoMesonQA > 1) fHistoTrueClusElectronInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), tempClusterWeight);
2007  Int_t motherLab = Photon->GetMother(0);
2008  mother = fMCEvent->Particle(motherLab);
2009  if (mother){
2010  TrueClusterCandidate->GetLabel(0);
2011  motherPDG = TMath::Abs(mother->GetPdgCode());
2012  }
2013 
2014  if (motherLab == -1){
2015  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 0.5, tempClusterWeight); // direct electron
2016  } else {
2017  if (motherPDG == 22){
2018  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 1.5, tempClusterWeight); // gamma
2019  fHistoTrueClusElectronFromGammaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2020  } else if (motherPDG == 111){
2021  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 2.5, tempClusterWeight); // pi0
2022  } else if (motherPDG == 221){
2023  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 3.5, tempClusterWeight); // eta
2024  } else if ( int(motherPDG/100.)==5 || int(motherPDG/1000.)==5 ){
2025  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 5.5, tempClusterWeight); // b
2026  } else if ( int(motherPDG/100.)==4 || int(motherPDG/1000.)==4 ){
2027  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 4.5, tempClusterWeight); // c
2028  } else if (motherPDG == 23 || motherPDG == 24){
2029  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 6.5, tempClusterWeight); // W/Z
2030  } else if (motherPDG == 15) {
2031  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 7.5, tempClusterWeight); // tau
2032  } else {
2033  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 8.5, tempClusterWeight); // rest
2034  }
2035  }
2036 
2037  // leading particle is a hadron
2038  } else {
2039  if (fEnableDetailedPrintOut) cout << "BG" << endl;
2040  fHistoTrueClusBGPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2041  if (fDoMesonQA > 1) fHistoTrueClusBGInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), tempClusterWeight);
2042 
2043  Double_t maxM02 = 4.8;
2044  if (m02 >= 0 && m02 < maxM02){
2045  if (TMath::Abs(pdgCodeParticle) == 211) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 0.5, tempClusterWeight); // pi+/-
2046  else if (TMath::Abs(pdgCodeParticle) == 2212) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 1.5, tempClusterWeight); // p
2047  else if (TMath::Abs(pdgCodeParticle) == 321) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 2.5, tempClusterWeight); // K+-
2048  else if (TMath::Abs(pdgCodeParticle) == 2112) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 3.5, tempClusterWeight); // n
2049  else if (TMath::Abs(pdgCodeParticle) == 310) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 4.5, tempClusterWeight); // K0s
2050  else if (TMath::Abs(pdgCodeParticle) == 3122) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 5.5, tempClusterWeight); // Lambda
2051  else if (TMath::Abs(pdgCodeParticle) == 13) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 6.5, tempClusterWeight); // mu+/-
2052  else if (TMath::Abs(pdgCodeParticle) == 130) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 7.5, tempClusterWeight); // K0l
2053  else fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 8.5, tempClusterWeight); // Rest
2054  }
2055  }
2056  }
2057  delete mesoncand;
2058  return;
2059 }
2060 
2061 //________________________________________________________________________
2063  AliAODConversionPhoton *TrueSubClusterCandidate1,
2064  AliAODConversionPhoton *TrueSubClusterCandidate2)
2065 {
2066 
2067  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2068  Double_t mcProdVtxX = primVtxMC->GetX();
2069  Double_t mcProdVtxY = primVtxMC->GetY();
2070  Double_t mcProdVtxZ = primVtxMC->GetZ();
2071 
2072  Double_t tempClusterWeight = fWeightJetJetMC;
2073  AliAODMCParticle *Photon = NULL;
2074  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2075  if (AODMCTrackArray){
2076  if (!TrueClusterCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
2077  if (TrueClusterCandidate->GetCaloPhotonMCLabel(0) < 0) return;
2078 
2079  if (TrueClusterCandidate->GetNCaloPhotonMCLabels()>0) Photon = (AliAODMCParticle*) AODMCTrackArray->At(TrueClusterCandidate->GetCaloPhotonMCLabel(0));
2080  else return;
2081  } else {
2082  AliInfo("AODMCTrackArray could not be loaded");
2083  return;
2084  }
2085 
2086  if(Photon == NULL){
2087  // cout << "no photon" << endl;
2088  return;
2089  }
2090 
2091  AliAODConversionMother *mesoncand = new AliAODConversionMother(TrueSubClusterCandidate1,TrueSubClusterCandidate2);
2092  Bool_t mesonIsSelected = (((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(mesoncand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()));
2093  if (!mesonIsSelected){
2094  delete mesoncand;
2095  return;
2096  }
2097  Int_t pdgCodeParticle = Photon->GetPdgCode();
2099  if (TrueClusterCandidate->GetNCaloPhotonMCLabels()>0 && fEnableDetailedPrintOut){
2100  cout << endl << endl << "Cluster energy: " << TrueClusterCandidate->E() << endl;;
2101  //TrueClusterCandidate->PrintCaloMCLabelsAndInfo(fMCEvent);
2102  TrueClusterCandidate->PrintCaloMCFlags();
2103  }
2104 
2106  Int_t clusterClass = 0;
2107  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, Photon, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2108 
2109  // cluster classification:
2110  // 1 - nice merged cluster (2 gamma | contributions from 2 gamma) from pi0/eta
2111  // 2 - contribution from only 1 partner (1 gamma, 1 fully coverted gamma) from pi0/eta
2112  // 3 - contribution from part of 1 partner (1 electron) from pi0/eta
2113  Long_t motherLab = -1;
2114  if (TrueClusterCandidate->IsMerged() || TrueClusterCandidate->IsMergedPartConv()){
2115  clusterClass = 1;
2116  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
2117  } else if (TrueClusterCandidate->GetNCaloPhotonMotherMCLabels()> 0){
2118 // cout << TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0) << endl;
2119  if (TrueClusterCandidate->IsLargestComponentElectron() || TrueClusterCandidate->IsLargestComponentPhoton()){
2120  if (TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0) > -1 && (((AliAODMCParticle*) AODMCTrackArray->At(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0)))->GetPdgCode() == 111 || ((AliAODMCParticle*) AODMCTrackArray->At(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0)))->GetPdgCode() == 221) ){
2121  if ( TrueClusterCandidate->IsConversion() && !TrueClusterCandidate->IsConversionFullyContained() ){
2122  clusterClass = 3;
2123  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
2124  } else {
2125  clusterClass = 2;
2126  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
2127  }
2128  }
2129  } else if (TrueClusterCandidate->IsSubLeadingEM()){
2130  if (TrueClusterCandidate->GetNCaloPhotonMotherMCLabels()> 1){
2131  if (fEnableDetailedPrintOut) cout << "Is Subleading EM: "<< TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1) << endl;
2132  if ( TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1) > -1){
2133  if (TMath::Abs(((AliAODMCParticle*) AODMCTrackArray->At(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1)))->GetPdgCode()) == 111 || TMath::Abs(((AliAODMCParticle*) AODMCTrackArray->At(TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1)))->GetPdgCode()) == 221 ){
2134  clusterClass = 2;
2135  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(1);
2136  }
2137  }
2138  }
2139  } else {
2140  motherLab = TrueClusterCandidate->GetCaloPhotonMotherMCLabel(0);
2141  }
2142  }
2143 
2144  // Get Mother particle
2145  AliAODMCParticle *mother = NULL;
2146  Int_t motherPDG = -1;
2147  if (motherLab > -1){
2148  mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(motherLab));
2149  }
2150  if (fEnableDetailedPrintOut) cout << "cluster class: " << clusterClass << "\t mother lab: "<< motherLab ;
2151  if (mother){
2152  motherPDG = TMath::Abs(mother->GetPdgCode());
2153  if (fEnableDetailedPrintOut) cout << "\t mother pdg: " << motherPDG << endl;
2154  } else {
2155  if (fEnableDetailedPrintOut) cout << endl;
2156  }
2157 
2158  // Set the jetjet weight to 1 in case the cluster orignated from the minimum bias header
2159  if (fIsMC>0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() == 4){
2160  if ( ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(motherLab, fMCEvent, fInputEvent) == 2) tempClusterWeight = 1;
2161  }
2162 
2163  //
2164  if (clusterClass == 1 || clusterClass == 2 || clusterClass == 3 ){
2165  fHistoTrueClusMergedPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2166  if (fDoMesonQA > 1)fHistoTrueClusMergedInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), tempClusterWeight);
2167 
2168  // separate different components
2169  if (clusterClass == 1 && TrueClusterCandidate->IsMerged()){
2170  if (motherPDG == 111){
2171  fHistoTrueClusMergedPureFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2172  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
2173  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 0., tempClusterWeight);
2174  }
2175  }
2176  if (motherPDG == 221)
2177  fHistoTrueClusMergedPureFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2178  } else if (clusterClass == 1 && TrueClusterCandidate->IsMergedPartConv()){
2179  if (motherPDG == 111){
2180  fHistoTrueClusMergedPartConvFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2181  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
2182  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 1., tempClusterWeight);
2183  }
2184  }
2185  if (motherPDG == 221)
2186  fHistoTrueClusMergedPartConvFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2187  } else if (clusterClass == 2){
2188  if (motherPDG == 111){
2189  fHistoTrueClusGammaFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2190  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
2191  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 2., tempClusterWeight);
2192  }
2193  }if (motherPDG == 221)
2194  fHistoTrueClusGammaFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2195  } else if (clusterClass == 3){
2196  if (motherPDG == 111) {
2197  fHistoTrueClusElectronFromPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2198  if (GetSelectedMesonID() < 2 && !isPrimary && m02 >= 0 && m02 <= 4.8 ){
2199  fHistoTrueSecPi0PtvsDiffReco[fiCut]->Fill(TrueClusterCandidate->Pt(), 3., tempClusterWeight);
2200  }
2201  }
2202  if (motherPDG == 221)
2203  fHistoTrueClusElectronFromEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2204  }
2205 
2206  // deal with pi0 only
2207  if (motherPDG == 111){
2208  fHistoTrueClusPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2210  fHistoDoubleCountTruePi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2211  if (!isPrimary)
2212  fHistoDoubleCountTrueSecPi0Pt[fiCut]->Fill(TrueClusterCandidate->Pt(), tempClusterWeight);
2213  }
2214 
2215 
2216  if (TrueClusterCandidate->IsDalitz()){
2217  fHistoTrueClusPi0DalitzPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2218  }
2219  if (fDoMesonQA > 1)fHistoTrueClusPi0InvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), tempClusterWeight);
2220  if (fDoMesonQA > 0){
2221  fHistoTrueClusPi0EM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, tempClusterWeight);
2222  }
2223  if (fDoMesonQA > 0 && GetSelectedMesonID() != 2){
2224  fHistoTruePi0PtY[fiCut]->Fill(TrueClusterCandidate->Pt(),mesoncand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), tempClusterWeight);
2225  fHistoTruePi0PtAlpha[fiCut]->Fill(TrueClusterCandidate->Pt(),TMath::Abs(mesoncand->GetAlpha()), tempClusterWeight);
2226  }
2227 
2228  if (GetSelectedMesonID() < 2) {
2229  if (isPrimary) {
2230  fHistoTrueClusPrimPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2231  if (fDoMesonQA > 1) fHistoTrueClusPrimPi0InvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), tempClusterWeight);
2232  if (fDoMesonQA > 0){
2233  if (clusterClass == 1 && TrueClusterCandidate->IsMerged())
2234  fHistoTruePrimaryPi0PureMergedMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),tempClusterWeight);
2235  else if (clusterClass == 1 && TrueClusterCandidate->IsMergedPartConv())
2236  fHistoTruePrimaryPi0MergedPartConvMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),tempClusterWeight);
2237  else if (clusterClass == 2)
2238  fHistoTruePrimaryPi01GammaMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),tempClusterWeight);
2239  else if (clusterClass == 3)
2240  fHistoTruePrimaryPi01ElectronMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),tempClusterWeight);
2241  }
2242  } else {
2243  fHistoTrueClusSecPi0PtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2244  if (fDoMesonQA > 0){
2245  fHistoTrueSecondaryPi0MCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),tempClusterWeight);
2246  }
2247  Int_t grandMaLab = mother->GetMother();
2248  if (grandMaLab > -1){
2249  if (TMath::Abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(grandMaLab))->GetPdgCode()) == 310){
2250  fHistoTrueClusSecPi0FromK0sPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2251  } else if (TMath::Abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(grandMaLab))->GetPdgCode()) == 130){
2252  fHistoTrueClusSecPi0FromK0lPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2253  } else if (TMath::Abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(grandMaLab))->GetPdgCode()) == 3122){
2254  fHistoTrueClusSecPi0FromLambdaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2255  }
2256  }
2257  }
2258  }
2259  // deal with eta only
2260  } else if (motherPDG == 221){
2261  fHistoTrueClusEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2262  if (TrueClusterCandidate->IsDalitz()){
2263  fHistoTrueClusEtaDalitzPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2264  }
2265  if (CheckVectorForDoubleCount(fVectorDoubleCountTrueEtas,motherLab)) fHistoDoubleCountTrueEtaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2266  if (fDoMesonQA > 1)fHistoTrueClusEtaInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), tempClusterWeight);
2267  if (fDoMesonQA > 0){
2268  fHistoTrueClusEtaEM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, tempClusterWeight);
2269  }
2270  if ( fDoMesonQA > 0 && GetSelectedMesonID() != 1 ){
2271  fHistoTrueEtaPtY[fiCut]->Fill(TrueClusterCandidate->Pt(),mesoncand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), tempClusterWeight);
2272  fHistoTrueEtaPtAlpha[fiCut]->Fill(TrueClusterCandidate->Pt(),TMath::Abs(mesoncand->GetAlpha()), tempClusterWeight);
2273  fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(mother->Pt(),(TrueClusterCandidate->Pt()-mother->Pt())/mother->Pt(),tempClusterWeight);
2274  }
2275  } else {
2276  fHistoTrueMergedMissedPDG[fiCut]->Fill(motherPDG, tempClusterWeight);
2277  }
2278 
2279  // leading particle is a photon or the conversion is fully contained and its not from pi0 || eta
2280  } else if (TrueClusterCandidate->IsLargestComponentPhoton() || TrueClusterCandidate->IsConversionFullyContained()){
2281  if (fEnableDetailedPrintOut) cout << "photon" << endl;
2282  fHistoTrueClusGammaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2283  if (fDoMesonQA > 0){
2284  fHistoTrueClusGammaEM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, tempClusterWeight);
2285  }
2286 
2287  if (fDoMesonQA > 1) fHistoTrueClusGammaInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), tempClusterWeight);
2288  if (motherLab == -1){
2289  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 0.5, tempClusterWeight); // direct photon
2290  } else {
2291  if (motherPDG == 111)
2292  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 1.5, tempClusterWeight); // pi0
2293  else if (motherPDG == 221)
2294  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 2.5, tempClusterWeight); // eta
2295  else if (motherPDG == 331)
2296  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 3.5, tempClusterWeight); // eta'
2297  else if (motherPDG == 223)
2298  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 4.5, tempClusterWeight); // omega
2299  else if (motherPDG == 333)
2300  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 5.5, tempClusterWeight); // phi
2301  else if (motherPDG == 3122)
2302  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 6.5, tempClusterWeight); // Lambda
2303  else
2304  fHistoTrueClusGammaPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 7.5, tempClusterWeight); // rest
2305  }
2306 
2307  // leading particle is an electron and its not from pi0 || eta
2308  } else if (TrueClusterCandidate->IsLargestComponentElectron()){
2309  if (fEnableDetailedPrintOut) cout << "electron" << endl;
2310  fHistoTrueClusElectronPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2311  if (fDoMesonQA > 0){
2312  fHistoTrueClusElectronEM02[fiCut]->Fill(TrueClusterCandidate->E(), m02, tempClusterWeight);
2313  }
2314 
2315  if (fDoMesonQA > 1) fHistoTrueClusElectronInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), tempClusterWeight);
2316  Int_t motherLab = Photon->GetMother();
2317  if (motherLab == -1){
2318  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 0.5, tempClusterWeight); // direct electron
2319  } else {
2320  if (motherPDG == 22){
2321  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 1.5, tempClusterWeight); // gamma
2322  fHistoTrueClusElectronFromGammaPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2323  } else if (motherPDG == 111){
2324  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 2.5, tempClusterWeight); // pi0
2325  } else if (motherPDG == 221){
2326  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 3.5, tempClusterWeight); // eta
2327  } else if ( int(motherPDG/100.)==5 || int(motherPDG/1000.)==5 ){
2328  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 5.5, tempClusterWeight); // b
2329  } else if ( int(motherPDG/100.)==4 || int(motherPDG/1000.)==4 ){
2330  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 4.5, tempClusterWeight); // c
2331  } else if (motherPDG == 23 || motherPDG == 24){
2332  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 6.5, tempClusterWeight); // W/Z
2333  } else if (motherPDG == 15) {
2334  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 7.5, tempClusterWeight); // tau
2335  } else {
2336  fHistoTrueClusElectronPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 8.5, tempClusterWeight); // rest
2337  }
2338  }
2339  // leading particle is a hadron
2340  } else {
2341  if (fEnableDetailedPrintOut) cout << "BG" << endl;
2342  fHistoTrueClusBGPtvsM02[fiCut]->Fill(TrueClusterCandidate->Pt(), m02, tempClusterWeight);
2343  if (fDoMesonQA > 1) fHistoTrueClusBGInvMassvsPt[fiCut]->Fill(mesoncand->M(),TrueClusterCandidate->Pt(), tempClusterWeight);
2344 
2345  Double_t maxM02 = 4.8;
2346  if (m02 >= 0 && m02 < maxM02){
2347  if (TMath::Abs(pdgCodeParticle) == 211) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 0.5, tempClusterWeight); // pi+/-
2348  else if (TMath::Abs(pdgCodeParticle) == 2212) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 1.5, tempClusterWeight); // p
2349  else if (TMath::Abs(pdgCodeParticle) == 321) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 2.5, tempClusterWeight); // K+-
2350  else if (TMath::Abs(pdgCodeParticle) == 2112) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 3.5, tempClusterWeight); // n
2351  else if (TMath::Abs(pdgCodeParticle) == 310) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 4.5, tempClusterWeight); // K0s
2352  else if (TMath::Abs(pdgCodeParticle) == 3122) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 5.5, tempClusterWeight); // Lambda
2353  else if (TMath::Abs(pdgCodeParticle) == 13) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 6.5, tempClusterWeight); // mu+/-
2354  else if (TMath::Abs(pdgCodeParticle) == 130) fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 7.5, tempClusterWeight); // K0l
2355  else fHistoTrueClusBGPtvsSource[fiCut]->Fill(TrueClusterCandidate->Pt(), 8.5, tempClusterWeight); // Rest
2356  }
2357  }
2358  }
2359  delete mesoncand;
2360  return;
2361 }
2362 
2363 
2364 //________________________________________________________________________
2366 {
2367  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2368  Double_t mcProdVtxX = primVtxMC->GetX();
2369  Double_t mcProdVtxY = primVtxMC->GetY();
2370  Double_t mcProdVtxZ = primVtxMC->GetZ();
2371 
2372  // Loop over all primary MC particle
2373  for(Long_t i = 0; i < fMCEvent->GetNumberOfTracks(); i++) {
2374  Double_t tempParticleWeight = fWeightJetJetMC;
2375  if (((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, i, mcProdVtxX, mcProdVtxY, mcProdVtxZ)){
2376 
2377  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
2378  if (!particle) continue;
2379 
2380  Int_t isMCFromMBHeader = -1;
2381  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2382  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2383  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2384  // Set the jetjet weight to 1 in case the particle orignated from the minimum bias header
2385  if(isMCFromMBHeader == 2 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() == 4) tempParticleWeight = 1;
2386  }
2387 
2388  Double_t mesonY = 1.e30;
2389  Double_t ratio = 0;
2390  if (particle->Energy() != TMath::Abs(particle->Pz())){
2391  ratio = (particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz());
2392  }
2393  if( !(ratio <= 0) ){
2394  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2395  }
2396 
2397  // fill Primary Y hist
2398  if ( particle->GetPdgCode() == 211 ){ // positve pions
2399  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 0., tempParticleWeight);
2400  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2401  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 1., tempParticleWeight);
2402  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2403  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 2., tempParticleWeight);
2404  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
2405  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 3., tempParticleWeight);
2406  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
2407  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 4., tempParticleWeight);
2408  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
2409  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 5., tempParticleWeight);
2410  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
2411  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 6., tempParticleWeight);
2412  }
2413 
2414  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
2415  if ( particle->GetPdgCode() == 211 ){ // positve pions
2416  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 0., tempParticleWeight);
2417  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2418  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 1., tempParticleWeight);
2419  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2420  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 2., tempParticleWeight);
2421  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
2422  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 3., tempParticleWeight);
2423  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
2424  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 4., tempParticleWeight);
2425  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
2426  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 5., tempParticleWeight);
2427  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
2428  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 6., tempParticleWeight);
2429  } else if ( particle->GetPdgCode() == 22 ){ // photons
2430  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(), tempParticleWeight); // direct photons
2431  if(particle->GetMother(0) > -1){
2432  TParticle* mother = (TParticle*)fMCEvent->Particle(particle->GetMother(0));
2433  if ( TMath::Abs(mother->GetPdgCode()) == 111 ||
2434  TMath::Abs(mother->GetPdgCode()) == 113 ||
2435  TMath::Abs(mother->GetPdgCode()) == 221 ||
2436  TMath::Abs(mother->GetPdgCode()) == 223 ||
2437  TMath::Abs(mother->GetPdgCode()) == 331 ||
2438  TMath::Abs(mother->GetPdgCode()) == 333 ||
2439  TMath::Abs(mother->GetPdgCode()) == 3212 ||
2440  TMath::Abs(mother->GetPdgCode()) == 213
2441  ){
2442  fHistoMCDecayGammaPt[fiCut]->Fill(particle->Pt(), tempParticleWeight); // decay photons
2443  }
2444  }
2445  }
2446  }
2447 
2448  // check if particle is pi0/eta from di-photon decay
2450  ->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2451  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
2452  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
2453 
2454  Float_t weighted= 1;
2455  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2456  if (particle->Pt()>0.005){
2457  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
2458  }
2459  }
2460 
2461  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2462  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // All MC Pi0
2463  if (GetSelectedMesonID() != 2){
2464  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(), tempParticleWeight);
2465  if (fIsMC==2)fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
2466  if (fDoMesonQA > 0 ){
2467  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),tempParticleWeight);
2468  }
2469  }
2470  } else if( TMath::Abs(particle->GetPdgCode()) == 221 ){ // eta mesons
2471  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // All MC Eta
2472  if (GetSelectedMesonID() != 1){
2473  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(), tempParticleWeight);
2474  if (fIsMC==2)fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2475  if (fDoMesonQA > 0 ){
2476  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),tempParticleWeight);
2477  }
2478  }
2479  }
2480  // Check the acceptance for both gammas & whether they are counted as primaries as well
2481  Bool_t kDaughter0IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetFirstDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2482  Bool_t kDaughter1IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, particle->GetLastDaughter(), mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2483 
2484  if( kDaughter0IsPrim && kDaughter1IsPrim &&
2485  (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter0,fMCEvent) ||
2486  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter1,fMCEvent) ) ){
2487  if(particle->GetPdgCode() == 111 && GetSelectedMesonID() != 2){
2488  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // MC Pi0 with gamma in acc
2489  if (fIsMC == 2)fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 w/o event weights with gamma in acc
2490  } else if(particle->GetPdgCode() == 221 && GetSelectedMesonID() != 1){
2491  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // MC Eta with gamma in acc
2492  if (fIsMC == 2)fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta w/o event weights with gamma in acc
2493  }
2494  }
2495  }
2496  Int_t gammaLabel = -1;
2497  Int_t electronLabel = -1;
2498  Int_t positronLabel = -1;
2499  // check if particle is pi0/eta from Dalitz decay
2501  ->MesonIsSelectedMCDalitz(particle,fMCEvent, electronLabel, positronLabel, gammaLabel, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2502  if( (gammaLabel > -1) && (electronLabel > -1) && (positronLabel > -1) ){
2503  TParticle* gamma = (TParticle*)fMCEvent->Particle(gammaLabel);
2504  TParticle* electron = (TParticle*)fMCEvent->Particle(electronLabel);
2505  TParticle* positron = (TParticle*)fMCEvent->Particle(positronLabel);
2506 
2507  Float_t weighted= 1;
2508  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2509  if (particle->Pt()>0.005){
2510  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
2511  }
2512  }
2513 
2514  if(particle->GetPdgCode() == 111 && GetSelectedMesonID() != 2){
2515  fHistoMCPi0DalitzPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // All MC Pi0
2516  fHistoMCPi0DalitzWOWeightPt[fiCut]->Fill(particle->Pt(), tempParticleWeight);
2517  if (fIsMC==2)fHistoMCPi0DalitzWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2518  if (fDoMesonQA > 0 ){
2519  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),tempParticleWeight);
2520  }
2521  } else if(particle->GetPdgCode() == 221 && GetSelectedMesonID() != 1){
2522  fHistoMCEtaDalitzPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // All MC Eta
2523  fHistoMCEtaDalitzWOWeightPt[fiCut]->Fill(particle->Pt(), tempParticleWeight);
2524  if (fIsMC==2)fHistoMCEtaDalitzWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2525  if (fDoMesonQA > 0 ){
2526  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),tempParticleWeight);
2527  }
2528  }
2529 
2530  // Check the acceptance for both gammas & whether they are counted as primaries as well
2531  Bool_t kGammaIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, gammaLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2532  Bool_t kElectronIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, electronLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2533  Bool_t kPositronIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryESD( fMCEvent, positronLabel, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2534  if( kGammaIsPrim && kElectronIsPrim && kPositronIsPrim &&
2535  (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma,fMCEvent) ||
2536  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecMC(electron,fMCEvent) ||
2537  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecMC(positron,fMCEvent) )
2538  ){
2539  if(particle->GetPdgCode() == 111 && GetSelectedMesonID() != 2){
2540  fHistoMCPi0DalitzInAccPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // MC Pi0 with gamma in acc
2541  if (fIsMC == 2) fHistoMCPi0DalitzWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // MC Pi0 with gamma in acc
2542  } else if(particle->GetPdgCode() == 221 && GetSelectedMesonID() != 1){
2543  fHistoMCEtaDalitzInAccPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // MC Eta with gamma in acc
2544  if (fIsMC == 2) fHistoMCEtaDalitzWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // MC Pi0 with gamma in acc
2545  }
2546  }
2547  }
2548  }
2549  // End of primary threatment, now secondary treatment
2550  } else {
2551 
2552  TParticle* particle = (TParticle *)fMCEvent->Particle(i);
2553  if (!particle) continue;
2554 
2555  Int_t isMCFromMBHeader = -1;
2556  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2557  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2558  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2559  // Set the jetjet weight to 1 in case the particle orignated from the minimum bias header
2560  if(isMCFromMBHeader == 2 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() == 4) tempParticleWeight = 1;
2561  }
2562 
2563  // check if particle is pi0 from di-photon decay
2565  ->MesonIsSelectedMC(particle,fMCEvent,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2566  TParticle* daughter0 = (TParticle*)fMCEvent->Particle(particle->GetFirstDaughter());
2567  TParticle* daughter1 = (TParticle*)fMCEvent->Particle(particle->GetLastDaughter());
2568  TParticle* mother = NULL;
2569  Int_t motherPDG = -1000000;
2570  if (particle->GetMother(0) > -1){
2571  mother = (TParticle*)fMCEvent->Particle(particle->GetMother(0));
2572  if (mother)
2573  motherPDG = TMath::Abs(mother->GetPdgCode());
2574  }
2575 
2576  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2577  Int_t source = GetSourceClassification(111,motherPDG);
2578  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source, tempParticleWeight); // All secondary MC Pi0
2579  }
2580 
2581  // check whether pi0 landet in acceptance
2582  if( (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter0,fMCEvent) ||
2583  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter1,fMCEvent) ) ){
2584  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2585  Int_t source = GetSourceClassification(111,motherPDG);
2586  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source, tempParticleWeight); // All secondary MC Pi0
2587  }
2588  }
2589  }
2590 
2591  Int_t gammaLabel = -1;
2592  Int_t electronLabel = -1;
2593  Int_t positronLabel = -1;
2594  // check if particle is pi0/eta from Dalitz decay
2596  ->MesonIsSelectedMCDalitz(particle,fMCEvent, electronLabel, positronLabel, gammaLabel, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2597  if( (gammaLabel > -1) && (electronLabel > -1) && (positronLabel > -1) ){
2598  TParticle* gamma = (TParticle*)fMCEvent->Particle(gammaLabel);
2599  TParticle* electron = (TParticle*)fMCEvent->Particle(electronLabel);
2600  TParticle* positron = (TParticle*)fMCEvent->Particle(positronLabel);
2601 
2602  TParticle* mother = NULL;
2603  Int_t motherPDG = -1000000;
2604  if (particle->GetMother(0) > -1){
2605  mother = (TParticle*)fMCEvent->Particle(particle->GetMother(0));
2606  if (mother)
2607  motherPDG = TMath::Abs(mother->GetPdgCode());
2608  }
2609 
2610  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2611  Int_t source = GetSourceClassification(111,motherPDG);
2612  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source, tempParticleWeight); // All secondary MC Pi0
2613  }
2614 
2615  // check whether pi0 landet in acceptance
2616  if( (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(gamma,fMCEvent) ||
2617  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecMC(electron,fMCEvent) ||
2618  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecMC(positron,fMCEvent) ) ){
2619  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2620  Int_t source = GetSourceClassification(111,motherPDG);
2621  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source, tempParticleWeight); // All secondary MC Pi0
2622  }
2623  }
2624  }
2625  }
2626  }
2627  } // end of particle loop
2628 }
2629 
2630 //________________________________________________________________________
2632 {
2633  const AliVVertex* primVtxMC = fMCEvent->GetPrimaryVertex();
2634  Double_t mcProdVtxX = primVtxMC->GetX();
2635  Double_t mcProdVtxY = primVtxMC->GetY();
2636  Double_t mcProdVtxZ = primVtxMC->GetZ();
2637 
2638  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
2639  if (AODMCTrackArray == NULL) return;
2640 
2641  // Loop over all primary MC particle
2642  for(Long_t i = 0; i < AODMCTrackArray->GetEntriesFast(); i++) {
2643  Double_t tempParticleWeight = fWeightJetJetMC;
2644  AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
2645  if (!particle) continue;
2646 
2647  Bool_t isPrimary = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD(fInputEvent, particle, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2648  if (isPrimary) {
2649 
2650  Int_t isMCFromMBHeader = -1;
2651  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2652  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2653  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2654  // Set the jetjet weight to 1 in case the particle orignated from the minimum bias header
2655  if(isMCFromMBHeader == 2 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() == 4) tempParticleWeight = 1;
2656  }
2657 
2658  Double_t mesonY = 1.e30;
2659  Double_t ratio = 0;
2660  if (particle->E() != TMath::Abs(particle->Pz())){
2661  ratio = (particle->E()+particle->Pz()) / (particle->E()-particle->Pz());
2662  }
2663  if( !(ratio <= 0) ){
2664  mesonY = particle->Y()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
2665  }
2666 
2667  // fill Primary Y hist
2668  if ( particle->GetPdgCode() == 211 ){ // positve pions
2669  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 0., tempParticleWeight);
2670  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2671  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 1., tempParticleWeight);
2672  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2673  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 2., tempParticleWeight);
2674  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
2675  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 3., tempParticleWeight);
2676  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
2677  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 4., tempParticleWeight);
2678  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
2679  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 5., tempParticleWeight);
2680  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
2681  fHistoMCPrimaryYvsSource[fiCut]->Fill(mesonY, 6., tempParticleWeight);
2682  }
2683 
2684  if (TMath::Abs(mesonY) < ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetRapidityCutValue()){
2685  if ( particle->GetPdgCode() == 211 ){ // positve pions
2686  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 0., tempParticleWeight);
2687  } else if ( particle->GetPdgCode() == -211 ){ // negative pions
2688  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 1., tempParticleWeight);
2689  } else if ( particle->GetPdgCode() == 321 ){ // positve kaons
2690  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 2., tempParticleWeight);
2691  } else if ( particle->GetPdgCode() == -321 ){ // negative kaons
2692  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 3., tempParticleWeight);
2693  } else if ( TMath::Abs(particle->GetPdgCode()) == 310 ){ // K0s
2694  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 4., tempParticleWeight);
2695  } else if ( TMath::Abs(particle->GetPdgCode()) == 130 ){ // K0l
2696  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 5., tempParticleWeight);
2697  } else if ( TMath::Abs(particle->GetPdgCode()) == 3122 ){ // Lambda/ AntiLambda
2698  fHistoMCPrimaryPtvsSource[fiCut]->Fill(particle->Pt(), 6., tempParticleWeight);
2699  } else if ( particle->GetPdgCode() == 22 ){ // photons
2700  fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt(), tempParticleWeight); // direct photons
2701  if(particle->GetMother() > -1){
2702  AliAODMCParticle *mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2703  if ( TMath::Abs(mother->GetPdgCode()) == 111 ||
2704  TMath::Abs(mother->GetPdgCode()) == 113 ||
2705  TMath::Abs(mother->GetPdgCode()) == 221 ||
2706  TMath::Abs(mother->GetPdgCode()) == 223 ||
2707  TMath::Abs(mother->GetPdgCode()) == 331 ||
2708  TMath::Abs(mother->GetPdgCode()) == 333 ||
2709  TMath::Abs(mother->GetPdgCode()) == 3212 ||
2710  TMath::Abs(mother->GetPdgCode()) == 213
2711  ){
2712  fHistoMCDecayGammaPt[fiCut]->Fill(particle->Pt(), tempParticleWeight); // decay photons
2713  }
2714  }
2715  }
2716  }
2717 
2718  // check if particle is pi0/eta from di-photon decay
2720  ->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2721  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
2722  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
2723 
2724  Float_t weighted= 1;
2725  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2726  if (particle->Pt()>0.005){
2727  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, 0x0, fInputEvent);
2728  }
2729  }
2730 
2731  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2732  fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // All MC Pi0
2733  if (GetSelectedMesonID() != 2){
2734  fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt(), tempParticleWeight);
2735  if (fIsMC==2)fHistoMCPi0WOEvtWeightPt[fiCut]->Fill(particle->Pt());
2736  if (fDoMesonQA > 0 ){
2737  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),tempParticleWeight);
2738  }
2739  }
2740  } else if( TMath::Abs(particle->GetPdgCode()) == 221 ){ // eta mesons
2741  fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // All MC Eta
2742  if (GetSelectedMesonID() != 1){
2743  fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt(), tempParticleWeight);
2744  if (fIsMC==2)fHistoMCEtaWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2745  if (fDoMesonQA > 0 ){
2746  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),tempParticleWeight);
2747  }
2748  }
2749  }
2750  // Check the acceptance for both gammas & whether they are counted as primaries as well
2751  Bool_t kDaughter0IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, daughter0, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2752  Bool_t kDaughter1IsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, daughter1, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2753 
2754  if( kDaughter0IsPrim && kDaughter1IsPrim &&
2755  (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter0,AODMCTrackArray) ||
2756  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter1,AODMCTrackArray) ) ){
2757  if(particle->GetPdgCode() == 111 && GetSelectedMesonID() != 2){
2758  fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // MC Pi0 with gamma in acc
2759  if (fIsMC == 2)fHistoMCPi0WOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Pi0 w/o event weights with gamma in acc
2760  } else if(particle->GetPdgCode() == 221 && GetSelectedMesonID() != 1){
2761  fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // MC Eta with gamma in acc
2762  if (fIsMC == 2)fHistoMCEtaWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt()); // MC Eta w/o event weights with gamma in acc
2763  }
2764  }
2765  }
2766  Int_t gammaLabel = -1;
2767  Int_t electronLabel = -1;
2768  Int_t positronLabel = -1;
2769  // check if particle is pi0/eta from Dalitz decay
2771  ->MesonIsSelectedAODMCDalitz(particle,AODMCTrackArray, electronLabel, positronLabel, gammaLabel, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2772  if( (gammaLabel > -1) && (electronLabel > -1) && (positronLabel > -1) ){
2773  AliAODMCParticle* gamma = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaLabel));
2774  AliAODMCParticle* electron = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(electronLabel));
2775  AliAODMCParticle* positron = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(positronLabel));
2776 
2777  Float_t weighted= 1;
2778  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent)){
2779  if (particle->Pt()>0.005){
2780  weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(i, fMCEvent, fInputEvent);
2781  }
2782  }
2783 
2784  if(particle->GetPdgCode() == 111 && GetSelectedMesonID() != 2){
2785  fHistoMCPi0DalitzPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // All MC Pi0
2786  fHistoMCPi0DalitzWOWeightPt[fiCut]->Fill(particle->Pt(), tempParticleWeight);
2787  if (fIsMC==2)fHistoMCPi0DalitzWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2788  if (fDoMesonQA > 0 ){
2789  if (fIsMC == 2) fHistoMCPi0PtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),tempParticleWeight);
2790  }
2791  } else if(particle->GetPdgCode() == 221 && GetSelectedMesonID() != 1){
2792  fHistoMCEtaDalitzPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // All MC Eta
2793  fHistoMCEtaDalitzWOWeightPt[fiCut]->Fill(particle->Pt(), tempParticleWeight);
2794  if (fIsMC==2)fHistoMCEtaDalitzWOEvtWeightPt[fiCut]->Fill(particle->Pt());
2795  if (fDoMesonQA > 0 ){
2796  if (fIsMC == 2) fHistoMCEtaPtJetPt[fiCut]->Fill(particle->Pt(),((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetMaxPtJet(),tempParticleWeight);
2797  }
2798  }
2799 
2800  // Check the acceptance for both gammas & whether they are counted as primaries as well
2801  Bool_t kGammaIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, gamma, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2802  Bool_t kElectronIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, electron, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2803  Bool_t kPositronIsPrim = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsConversionPrimaryAOD( fInputEvent, positron, mcProdVtxX, mcProdVtxY, mcProdVtxZ);
2804  if( kGammaIsPrim && kElectronIsPrim && kPositronIsPrim &&
2805  (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(gamma,AODMCTrackArray) ||
2806  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecAODMC(electron,AODMCTrackArray) ||
2807  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecAODMC(positron,AODMCTrackArray) )
2808  ){
2809  if(particle->GetPdgCode() == 111 && GetSelectedMesonID() != 2){
2810  fHistoMCPi0DalitzInAccPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // MC Pi0 with gamma in acc
2811  if (fIsMC == 2) fHistoMCPi0DalitzWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // MC Pi0 with gamma in acc
2812  } else if(particle->GetPdgCode() == 221 && GetSelectedMesonID() != 1){
2813  fHistoMCEtaDalitzInAccPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // MC Eta with gamma in acc
2814  if (fIsMC == 2) fHistoMCEtaDalitzWOEvtWeightInAccPt[fiCut]->Fill(particle->Pt(),weighted* tempParticleWeight); // MC Pi0 with gamma in acc
2815  }
2816  }
2817  }
2818  }
2819  // End of primary threatment, now secondary treatment
2820  } else {
2821 
2822  AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
2823  if (!particle) continue;
2824 
2825  Int_t isMCFromMBHeader = -1;
2826  if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
2827  isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCEvent, fInputEvent);
2828  if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
2829  if(isMCFromMBHeader == 2 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() == 4) tempParticleWeight = 1;
2830  }
2831 
2832  // check if particle is pi0 from di-photon decay
2834  ->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2835  AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
2836  AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
2837  AliAODMCParticle* mother = NULL;
2838  Int_t motherPDG = -1000000;
2839  if (particle->GetMother() > -1){
2840  mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2841  if (mother)
2842  motherPDG = TMath::Abs(mother->GetPdgCode());
2843  }
2844 
2845  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2846  Int_t source = GetSourceClassification(111,motherPDG);
2847  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source, tempParticleWeight); // All secondary MC Pi0
2848  }
2849 
2850  // check whether pi0 landet in acceptance
2851  if( (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter0,AODMCTrackArray) ||
2852  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter1,AODMCTrackArray) ) ){
2853  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2854  Int_t source = GetSourceClassification(111,motherPDG);
2855  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source, tempParticleWeight); // All secondary MC Pi0
2856  }
2857  }
2858  }
2859 
2860  Int_t gammaLabel = -1;
2861  Int_t electronLabel = -1;
2862  Int_t positronLabel = -1;
2863  // check if particle is pi0/eta from Dalitz decay
2865  ->MesonIsSelectedAODMCDalitz(particle,AODMCTrackArray, electronLabel, positronLabel, gammaLabel, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
2866  if( (gammaLabel > -1) && (electronLabel > -1) && (positronLabel > -1) ){
2867  AliAODMCParticle* gamma = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaLabel));
2868  AliAODMCParticle* electron = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(electronLabel));
2869  AliAODMCParticle* positron = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(positronLabel));
2870 
2871  AliAODMCParticle* mother = NULL;
2872  Int_t motherPDG = -1000000;
2873  if (particle->GetMother() > -1){
2874  mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother()));
2875  if (mother)
2876  motherPDG = TMath::Abs(mother->GetPdgCode());
2877  }
2878 
2879  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2880  Int_t source = GetSourceClassification(111,motherPDG);
2881  fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source, tempParticleWeight); // All secondary MC Pi0
2882  }
2883 
2884  // check whether pi0 landet in acceptance
2885  if( (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(gamma,AODMCTrackArray) ||
2886  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecAODMC(electron,AODMCTrackArray) ||
2887  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedElecAODMC(positron,AODMCTrackArray) ) ){
2888  if( TMath::Abs(particle->GetPdgCode()) == 111 ){ // neutral pions
2889  Int_t source = GetSourceClassification(111,motherPDG);
2890  fHistoMCSecPi0InAccPtvsSource[fiCut]->Fill(particle->Pt(),source, tempParticleWeight); // All secondary MC Pi0
2891  }
2892  }
2893  }
2894  }
2895  }
2896  } // end of particle loop
2897  return;
2898 }
2899 
2900 //_________________________________________________________________________________
2902  TAxis *axisafter = histoRebin->GetXaxis();
2903  Int_t bins = axisafter->GetNbins();
2904  Double_t from = axisafter->GetXmin();
2905  Double_t to = axisafter->GetXmax();
2906  Double_t *newbins = new Double_t[bins+1];
2907  newbins[0] = from;
2908  Double_t factor = TMath::Power(to/from, 1./bins);
2909  for(Int_t i=1; i<=bins; ++i) newbins[i] = factor * newbins[i-1];
2910  axisafter->Set(bins, newbins);
2911  delete [] newbins;
2912 }
2913 
2914 //_________________________________________________________________________________
2916 {
2917  if(tobechecked > -1)
2918  {
2919  vector<Int_t>::iterator it;
2920  it = find (vec.begin(), vec.end(), tobechecked);
2921  if (it != vec.end()) return true;
2922  else{
2923  vec.push_back(tobechecked);
2924  return false;
2925  }
2926  }
2927  return false;
2928 }
2929 
2930 //________________________________________________________________________
2932 {
2933 
2934  //fOutputContainer->Print(); // Will crash on GRID
2935 }
2936 
2937 
2938 //_________________________________________________________________________________
2939 void AliAnalysisTaskGammaCaloMerged::FillMultipleCountMap(map<Int_t,Int_t> &ma, Int_t tobechecked){
2940  if( ma.find(tobechecked) != ma.end() ) ma[tobechecked] += 1;
2941  else ma[tobechecked] = 2;
2942  return;
2943 }
2944 
2945 //_________________________________________________________________________________
2947  map<Int_t, Int_t>::iterator it;
2948  for (it = ma.begin(); it != ma.end(); it++){
2949  hist->Fill(it->second, fWeightJetJetMC);
2950  }
2951  ma.clear();
2952  return;
2953 }
2954 
2955 
2956 //________________________________________________________________________
2958 
2959  if (daughter == 111) {
2960  if (TMath::Abs(pdgCode) == 310) return 1; // k0s
2961  else if (TMath::Abs(pdgCode) == 3122) return 2; // Lambda
2962  else if (TMath::Abs(pdgCode) == 130) return 3; // K0L
2963  else if (TMath::Abs(pdgCode) == 2212) return 4; // proton
2964  else if (TMath::Abs(pdgCode) == 2112) return 5; // neutron
2965  else if (TMath::Abs(pdgCode) == 211) return 6; // pion
2966  else if (TMath::Abs(pdgCode) == 321) return 7; // kaon
2967  else if (TMath::Abs(pdgCode) == 113 || TMath::Abs(pdgCode) == 213 ) return 8; // rho 0,+,-
2968  else if (TMath::Abs(pdgCode) == 3222 || TMath::Abs(pdgCode) == 3212 || TMath::Abs(pdgCode) == 3112 ) return 9; // Sigma
2969  else if (TMath::Abs(pdgCode) == 2224 || TMath::Abs(pdgCode) == 2214 || TMath::Abs(pdgCode) == 2114 || TMath::Abs(pdgCode) == 1114 ) return 10; // Delta
2970  else if (TMath::Abs(pdgCode) == 313 || TMath::Abs(pdgCode) == 323 ) return 11; // K*
2971  else return 15;
2972  }
2973  return 15;
2974 
2975 }
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