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