AliPhysics  master (3d17d9d)
AliAnalysisTaskConvCaloCalibration.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2020, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: Friederike Bock, Joshua König *
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 "AliGenCocktailEventHeader.h"
48 #include "AliConversionAODBGHandlerRP.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  fRandom(0),
67  fV0Reader(NULL),
68  fBGHandler(NULL),
69  fBGHandlerRP(NULL),
70  fBGClusHandler(NULL),
71  fBGClusHandlerRP(NULL),
72  fInputEvent(NULL),
73  fMCEvent(NULL),
74  fEventCuts(NULL),
75  fConversionCuts(NULL),
76  fCaloPhotonCuts(NULL),
77  fMesonCuts(NULL),
78  fGeomEMCAL(NULL),
79  fCutFolder(NULL),
80  fESDList(NULL),
81  fBackList(NULL),
82  fMotherList(NULL),
83  fOutputContainer(NULL),
84  fGammaCandidates(NULL),
85  fClusterCandidates(NULL),
86  fEventCutArray(NULL),
87  fCutArray(NULL),
88  fClusterCutArray(NULL),
89  fMesonCutArray(NULL),
90  fReaderGammas(NULL),
91  fV0ReaderName("V0ReaderV1"),
92  fCorrTaskSetting(""),
93  fFileNameBroken(NULL),
94  fSparseMotherInvMassPtZM(NULL),
95  fSparseMotherBackInvMassPtZM(NULL),
96  fTreeBrokenFiles(NULL),
97  fHistoMotherInvMassPt(NULL),
98  fHistoMotherMatchedInvMassPt(NULL),
99  fHistoMotherBackInvMassPt(NULL),
100  fHistoMotherMesonPtY(NULL),
101  fHistoMotherMesonPtAlpha(NULL),
102  fHistoMotherMesonPtOpenAngle(NULL),
103  fHistoMotherMesonConvPhotonEtaPhi(NULL),
104  fHistoSPDClusterTrackletBackground(NULL),
105  fHistoMotherInvMassECalibSM(NULL),
106  fHistoMotherBackInvMassECalibSM(NULL),
107  fHistoMotherInvMassECalib(NULL),
108  fHistoMotherBackInvMassECalib(NULL),
109  fProfileEtaShift(NULL),
110  fProfileJetJetXSection(NULL),
111  // fHistoMCHeaders(NULL),
112  fHistoConvGammaPt(NULL),
113  fHistoClusGammaPt(NULL),
114  fHistoClusGammaE(NULL),
115  fHistoClusGammaPtSM(NULL),
116  fHistoClusGammaESM(NULL),
117  fHistoMotherInvMassRejected(NULL),
118  fHistoNEvents(NULL),
119  fHistoNEventsWOWeight(NULL),
120  fHistoNGoodESDTracks(NULL),
121  fHistoVertexZ(NULL),
122  fHistoVertexX(NULL),
123  fHistoVertexY(NULL),
124  fHistoNGammaConvCandidates(NULL),
125  fHistoNGammaCaloCandidates(NULL),
126  fHistoNV0Tracks(NULL),
127  fHistoJetJetNTrials(NULL),
128  fUnsmearedPx(NULL),
129  fUnsmearedPy(NULL),
130  fUnsmearedPz(NULL),
131  fUnsmearedE(NULL),
132  fMesonInvMassWindow(NULL),
133  fMCEventPos(NULL),
134  fMCEventNeg(NULL),
135  fESDArrayPos(NULL),
136  fESDArrayNeg(NULL),
137  fEventPlaneAngle(-100),
138  fMesonInvMassMin(0),
139  fMesonInvMassMax(0),
140  fMesonInvMassNBins(0),
141  fWeightJetJetMC(1),
142  fNGammaCandidates(0),
143  fnCuts(0),
144  fiCut(0),
145  fIsHeavyIon(0),
146  fMesonRecoMode(-1),
147  fMesonType(-1),
148  fMesonPDG(0),
149  fDoMesonQA(0),
150  fDoPhotonQA(0),
151  fDoClusterQA(0),
152  fIsMC(0),
153  fnModules(20),
154  fMoveParticleAccordingToVertex(kTRUE),
155  fDoLightOutput(kFALSE),
156  fIsFromDesiredHeader(kTRUE),
157  fIsOverlappingWithOtherHeader(kFALSE),
158  fDoTHnSparse(kTRUE),
159  fSetPlotHistsExtQA(kFALSE),
160  fDoConvGammaShowerShapeTree(kFALSE),
161  fEnableSortForClusMC(kFALSE),
162  fDoPrimaryTrackMatching(kFALSE),
163  fDoInvMassShowerShapeTree(kFALSE),
164  fAllowOverlapHeaders(kTRUE),
165  fEnableClusterCutsForTrigger(kFALSE),
166  fTrackMatcherRunningMode(0),
167  fUseEletronMatchingCalibration(kFALSE),
168  fElecSelector(NULL)
169 {
170 
171 }
172 
173 //________________________________________________________________________
175  AliAnalysisTaskSE(name),
176  fRandom(0),
177  fV0Reader(NULL),
178  fBGHandler(NULL),
179  fBGHandlerRP(NULL),
180  fBGClusHandler(NULL),
181  fBGClusHandlerRP(NULL),
182  fInputEvent(NULL),
183  fMCEvent(NULL),
184  fEventCuts(NULL),
185  fConversionCuts(NULL),
186  fCaloPhotonCuts(NULL),
187  fMesonCuts(NULL),
188  fGeomEMCAL(NULL),
189  fCutFolder(NULL),
190  fESDList(NULL),
191  fBackList(NULL),
192  fMotherList(NULL),
193  fOutputContainer(NULL),
194  fGammaCandidates(NULL),
195  fClusterCandidates(NULL),
196  fEventCutArray(NULL),
197  fCutArray(NULL),
198  fClusterCutArray(NULL),
199  fMesonCutArray(NULL),
200  fReaderGammas(NULL),
201  fV0ReaderName("V0ReaderV1"),
202  fCorrTaskSetting(""),
203  fFileNameBroken(NULL),
204  fSparseMotherInvMassPtZM(NULL),
205  fSparseMotherBackInvMassPtZM(NULL),
206  fTreeBrokenFiles(NULL),
207  fHistoMotherInvMassPt(NULL),
208  fHistoMotherMatchedInvMassPt(NULL),
209  fHistoMotherBackInvMassPt(NULL),
210  fHistoMotherMesonPtY(NULL),
211  fHistoMotherMesonPtAlpha(NULL),
212  fHistoMotherMesonPtOpenAngle(NULL),
213  fHistoMotherMesonConvPhotonEtaPhi(NULL),
214  fHistoSPDClusterTrackletBackground(NULL),
215  fHistoMotherInvMassECalibSM(NULL),
216  fHistoMotherBackInvMassECalibSM(NULL),
217  fHistoMotherInvMassECalib(NULL),
218  fHistoMotherBackInvMassECalib(NULL),
219  fProfileEtaShift(NULL),
220  fProfileJetJetXSection(NULL),
221  // fHistoMCHeaders(NULL),
222  fHistoConvGammaPt(NULL),
223  fHistoClusGammaPt(NULL),
224  fHistoClusGammaE(NULL),
225  fHistoClusGammaPtSM(NULL),
226  fHistoClusGammaESM(NULL),
227  fHistoMotherInvMassRejected(NULL),
228  fHistoNEvents(NULL),
229  fHistoNEventsWOWeight(NULL),
230  fHistoNGoodESDTracks(NULL),
231  fHistoVertexZ(NULL),
232  fHistoVertexX(NULL),
233  fHistoVertexY(NULL),
234  fHistoNGammaConvCandidates(NULL),
235  fHistoNGammaCaloCandidates(NULL),
236  fHistoNV0Tracks(NULL),
237  fHistoJetJetNTrials(NULL),
238  fUnsmearedPx(NULL),
239  fUnsmearedPy(NULL),
240  fUnsmearedPz(NULL),
241  fUnsmearedE(NULL),
242  fMesonInvMassWindow(NULL),
243  fMCEventPos(NULL),
244  fMCEventNeg(NULL),
245  fESDArrayPos(NULL),
246  fESDArrayNeg(NULL),
247  fEventPlaneAngle(-100),
248  fMesonInvMassMin(0),
249  fMesonInvMassMax(0),
250  fMesonInvMassNBins(0),
251  fWeightJetJetMC(1),
252  fNGammaCandidates(0),
253  fnCuts(0),
254  fiCut(0),
255  fIsHeavyIon(0),
256  fMesonRecoMode(-1),
257  fMesonType(-1),
258  fMesonPDG(0),
259  fDoMesonQA(0),
260  fDoPhotonQA(0),
261  fDoClusterQA(0),
262  fIsMC(0),
263  fnModules(20),
264  fMoveParticleAccordingToVertex(kTRUE),
265  fDoLightOutput(kFALSE),
266  fIsFromDesiredHeader(kTRUE),
267  fIsOverlappingWithOtherHeader(kFALSE),
268  fDoTHnSparse(kTRUE),
269  fSetPlotHistsExtQA(kFALSE),
270  fDoConvGammaShowerShapeTree(kFALSE),
271  fEnableSortForClusMC(kFALSE),
272  fDoPrimaryTrackMatching(kFALSE),
273  fDoInvMassShowerShapeTree(kFALSE),
274  fAllowOverlapHeaders(kTRUE),
275  fEnableClusterCutsForTrigger(kFALSE),
276  fTrackMatcherRunningMode(0),
277  fUseEletronMatchingCalibration(kFALSE),
278  fElecSelector(NULL)
279 {
280  // Define output slots here
281  DefineOutput(1, TList::Class());
282 }
283 
285 {
286  if(fGammaCandidates){
287  delete fGammaCandidates;
288  fGammaCandidates = 0x0;
289  }
290  if(fClusterCandidates){
291  delete fClusterCandidates;
292  fClusterCandidates = 0x0;
293  }
294  if(fBGHandler){
295  delete[] fBGHandler;
296  fBGHandler = 0x0;
297  }
298  if(fBGHandlerRP){
299  delete[] fBGHandlerRP;
300  fBGHandlerRP = 0x0;
301  }
302  if(fBGClusHandler){
303  delete[] fBGClusHandler;
304  fBGClusHandler = 0x0;
305  }
306  if(fBGClusHandlerRP){
307  delete[] fBGClusHandlerRP;
308  fBGClusHandlerRP = 0x0;
309  }
310 }
311 //___________________________________________________________
313 
314  const Int_t nDim = 4;
315  Int_t nBins[nDim] = {800,300,7,4};
316  Double_t xMin[nDim] = {0,0, 0,0};
317  Double_t xMax[nDim] = {0.8,30,7,4};
318 
319  if(fDoTHnSparse){
320  fSparseMotherInvMassPtZM = new THnSparseF*[fnCuts];
321  fSparseMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
322  }
323 
325  fBGHandlerRP = new AliConversionAODBGHandlerRP*[fnCuts];
326 
328  fBGClusHandlerRP = new AliConversionAODBGHandlerRP*[fnCuts];
329 
330  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
331  if (((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
332  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
333  TString cutstringConvGamma = "";
334  TString cutstringCaloGamma = "";
335  if (fMesonRecoMode < 2) cutstringConvGamma = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
336  if (fMesonRecoMode > 0 || fEnableClusterCutsForTrigger ) cutstringCaloGamma = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
337  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
338 
339  TString fullCutString = "";
340  if (fMesonRecoMode == 0) fullCutString = Form("%i_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(), cutstringConvGamma.Data(), cutstringMeson.Data());
341  else if (fMesonRecoMode == 1) fullCutString = Form("%i_%s_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringCaloGamma.Data(), cutstringMeson.Data());
342  else if (fMesonRecoMode == 2) fullCutString = Form("%i_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(), cutstringCaloGamma.Data(), cutstringMeson.Data());
343 
344  Int_t collisionSystem = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(0,1));
345  Int_t centMin = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(1,1));
346  Int_t centMax = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(2,1));
347 
348  if( collisionSystem == 1 || collisionSystem == 2 ||
349  collisionSystem == 5 || collisionSystem == 8 ||
350  collisionSystem == 9){
351  centMin = centMin*10;
352  centMax = centMax*10;
353  if(centMax ==0 && centMax!=centMin) centMax=100;
354  }else if(collisionSystem == 3 || collisionSystem == 6){
355  centMin = centMin*5;
356  centMax = centMax*5;
357  }else if(collisionSystem == 4 || collisionSystem == 7){
358  centMin = ((centMin*5)+45);
359  centMax = ((centMax*5)+45);
360  }
361 
362  if(fDoTHnSparse){
363  fBackList[iCut] = new TList();
364  fBackList[iCut]->SetName(Form("%s Back histograms",fullCutString.Data()));
365  fBackList[iCut]->SetOwner(kTRUE);
366  fCutFolder[iCut]->Add(fBackList[iCut]);
367 
368  fSparseMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_m", "Back_Back_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
369  fBackList[iCut]->Add(fSparseMotherBackInvMassPtZM[iCut]);
370 
371  fMotherList[iCut] = new TList();
372  fMotherList[iCut]->SetName(Form("%s Mother histograms",fullCutString.Data()));
373  fMotherList[iCut]->SetOwner(kTRUE);
374  fCutFolder[iCut]->Add(fMotherList[iCut]);
375 
376  fSparseMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_m", "Back_Mother_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
377  fMotherList[iCut]->Add(fSparseMotherInvMassPtZM[iCut]);
378  }
379 
380  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
381  fBGHandler[iCut] = new AliGammaConversionAODBGHandler( collisionSystem,centMin,centMax,
382  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents(),
383  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseTrackMultiplicity(),
384  2,8,5);
385  fBGClusHandler[iCut] = new AliGammaConversionAODBGHandler( collisionSystem,centMin,centMax,
386  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents(),
387  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseTrackMultiplicity(),
388  2,8,5);
389  fBGHandlerRP[iCut] = NULL;
390  }else{
391  fBGHandlerRP[iCut] = new AliConversionAODBGHandlerRP(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsHeavyIon(),
392  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity(),
393  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents());
394  fBGClusHandlerRP[iCut] = new AliConversionAODBGHandlerRP( ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsHeavyIon(),
395  ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity(),
396  ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents());
397  fBGHandler[iCut] = NULL;
398  }
399  }
400  }
401 }
402 
403 //________________________________________________________________________
405 
406  fV0Reader = (AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data());
407  if(!fV0Reader){printf("Error: No V0 Reader");return;}// GetV0Reader
408  if (fIsMC == 2){
409  fDoClusterQA = 0;
410  fDoTHnSparse = kFALSE;
411  } else if (fIsMC == 3){
412  fDoTHnSparse = kFALSE;
413  }
414 
415  if (fMesonRecoMode == 2)
417 
418  // Create histograms
419  if(fOutputContainer != NULL){
420  delete fOutputContainer;
421  fOutputContainer = NULL;
422  }
423  if(fOutputContainer == NULL){
424  fOutputContainer = new TList();
425  fOutputContainer->SetOwner(kTRUE);
426  }
427 
428  // Array of current cut's gammas
429  fGammaCandidates = new TList();
430  fClusterCandidates = new TList();
431  fClusterCandidates->SetOwner(kTRUE);
432 
433  fCutFolder = new TList*[fnCuts];
434  fESDList = new TList*[fnCuts];
435 
436  if(fDoTHnSparse){
437  fBackList = new TList*[fnCuts];
438  fMotherList = new TList*[fnCuts];
439  }
440 
441  fHistoNEvents = new TH1F*[fnCuts];
442  if (fIsMC > 1){
443  fHistoNEventsWOWeight = new TH1F*[fnCuts];
444  }
445  if (fIsMC == 2){
446  fProfileJetJetXSection = new TProfile*[fnCuts];
447  fHistoJetJetNTrials = new TH1F*[fnCuts];
448  }
449  fHistoNGoodESDTracks = new TH1F*[fnCuts];
450  fHistoVertexZ = new TH1F*[fnCuts];
451  if(!fDoLightOutput){
452  fHistoVertexX = new TH1F*[fnCuts];
453  fHistoVertexY = new TH1F*[fnCuts];
454  }
455  if (fMesonRecoMode < 2) fHistoNGammaConvCandidates = new TH1F*[fnCuts];
456  if(fIsHeavyIon==2) fProfileEtaShift = new TProfile*[fnCuts];
457  if(!fDoLightOutput){
459  fHistoNV0Tracks = new TH1F*[fnCuts];
460  if (fMesonRecoMode < 2)
461  fHistoConvGammaPt = new TH1F*[fnCuts];
462  }
463 
465 
466  fHistoNGammaCaloCandidates = new TH1F*[fnCuts];
467  fHistoClusGammaPt = new TH1F*[fnCuts];
468  fHistoClusGammaE = new TH1F*[fnCuts];
469  fHistoClusGammaPtSM = new TH1F**[fnCuts];
470  fHistoClusGammaESM = new TH1F**[fnCuts];
471  for(Int_t icuts = 0; icuts < fnCuts; icuts++){
472  fHistoClusGammaPtSM[icuts] = new TH1F*[fnModules];
473  fHistoClusGammaESM[icuts] = new TH1F*[fnModules];
474  }
475  }
476 
478  fHistoMotherInvMassRejected = new TH1F*[fnCuts];
482  for(Int_t icuts = 0; icuts < fnCuts; icuts++){
485  }
488  if(!fDoLightOutput && fMesonRecoMode == 1){
490  }
491  if (fDoMesonQA > 0){
496  }
497 
498  fMesonInvMassWindow = new Double_t[2];
499  if (fMesonType < 0 || fMesonType > 2){
500  if(!fV0Reader){printf("Error: No V0 Reader");return;}// GetV0Reader
501  } else if (fMesonType == 0){ // pi0 case 134.9770 ± 0.0005 MeV
502  fMesonPDG = 111;
503  fMesonInvMassMin = 0.;
504  fMesonInvMassMax = 0.300;
505  fMesonInvMassNBins = 300;
506  fMesonInvMassWindow[0] = 0.05;
507  fMesonInvMassWindow[1] = 0.17;
508  } else if (fMesonType == 1){ // eta case 547.862 ± 0.017 MeV
509  fMesonPDG = 221;
510  fMesonInvMassMin = 0.300;
511  fMesonInvMassMax = 0.800;
512  fMesonInvMassNBins = 500;
513  fMesonInvMassWindow[0] = 0.45;
514  fMesonInvMassWindow[1] = 0.65;
515  } else if (fMesonType == 2){ // eta' case 957.78 ± 0.06 MeV
516  fMesonPDG = 331;
517  fMesonInvMassMin = 0.700;
518  fMesonInvMassMax = 1.200;
519  fMesonInvMassNBins = 500;
520  fMesonInvMassWindow[0] = 0.85;
521  fMesonInvMassWindow[1] = 1.05;
522  }
523  // set common binning in pT for mesons and photons
524  Int_t nBinsPt = 200;
525  Float_t binWidthPt = 0.1;
526  Float_t minPt = 0;
527  Float_t maxPt = 20;
528  Int_t nBinsQAPt = 170;
529  Float_t maxQAPt = 20;
530  Int_t nBinsClusterPt = 500;
531  Float_t maxClusterPt = 50;
532  Double_t *arrPtBinning = new Double_t[1200];
533  Double_t *arrQAPtBinning = new Double_t[1200];
534  Double_t *arrClusPtBinning = new Double_t[1200];
535  // Set special pt binning for pp 13TeV, pPb 8TeV
536  if ( ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k13TeV ||
537  ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::k13TeVLowB ||
538  ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEnergyEnum() == AliConvEventCuts::kpPb8TeV ){
539  if(fMesonRecoMode < 2){
540  nBinsPt = 235;
541  minPt = 0;
542  maxPt = 50;
543  binWidthPt = 0.05;
544  for(Int_t i=0; i<nBinsPt+1;i++){
545  if (i < 1) arrPtBinning[i] = 0.3*i;
546  else if(i<55) arrPtBinning[i] = 0.3+0.05*(i-1);
547  else if(i<125) arrPtBinning[i] = 3.+0.1*(i-55);
548  else if(i<185) arrPtBinning[i] = 10.+0.25*(i-125);
549  else if(i<235) arrPtBinning[i] = 25.+0.5*(i-185);
550  else arrPtBinning[i] = maxPt;
551  }
552  nBinsQAPt = 221;
553  maxQAPt = 50;
554  for(Int_t i=0; i<nBinsQAPt+1;i++){
555  if(i<60) arrQAPtBinning[i] = 0.05*i;
556  else if(i<130) arrQAPtBinning[i] = 3.+0.1*(i-60);
557  else if(i<170) arrQAPtBinning[i] = 10.+0.25*(i-130);
558  else if(i<210) arrQAPtBinning[i] = 20.+0.5*(i-170);
559  else if(i<221) arrQAPtBinning[i] = 40.+1.0*(i-210);
560  else arrQAPtBinning[i] = maxQAPt;
561  }
562  nBinsClusterPt = 351;
563  maxClusterPt = 50;
564  for(Int_t i=0; i<nBinsClusterPt+1;i++){
565  if (i < 1) arrClusPtBinning[i] = 0.3*i;
566  else if(i<55) arrClusPtBinning[i] = 0.3+0.05*(i-1);
567  else if(i<125) arrClusPtBinning[i] = 3.+0.1*(i-55);
568  else if(i<155) arrClusPtBinning[i] = 10.+0.2*(i-125);
569  else if(i<211) arrClusPtBinning[i] = 16.+0.25*(i-155);
570  else if(i<251) arrClusPtBinning[i] = 30.+0.5*(i-211);
571  else arrClusPtBinning[i] = maxClusterPt;
572  }
573 
574  } else if(fMesonRecoMode == 2){
575  nBinsPt = 165;
576  minPt = 0;
577  maxPt = 20;
578  binWidthPt = 0.05;
579  for(Int_t i=0; i<nBinsPt+1;i++){
580  if (i < 1) arrPtBinning[i] = 0.3*i;
581  else if(i<55) arrPtBinning[i] = 0.3+0.05*(i-1);
582  else if(i<125) arrPtBinning[i] = 3.+0.1*(i-55);
583  else if(i<165) arrPtBinning[i] = 10.+0.25*(i-125);
584  else arrPtBinning[i] = maxPt;
585  }
586  nBinsQAPt = 210;
587  maxQAPt = 20;
588  for(Int_t i=0; i<nBinsQAPt+1;i++){
589  if(i<60) arrQAPtBinning[i] = 0.05*i;
590  else if(i<130) arrQAPtBinning[i] = 3.+0.1*(i-60);
591  else if(i<170) arrQAPtBinning[i] = 10.+0.25*(i-130);
592  else arrQAPtBinning[i] = maxQAPt;
593  }
594  nBinsClusterPt = 171;
595  maxClusterPt = 20;
596  for(Int_t i=0; i<nBinsClusterPt+1;i++){
597  if (i < 1) arrClusPtBinning[i] = 0.3*i;
598  else if(i<55) arrClusPtBinning[i] = 0.3+0.05*(i-1);
599  else if(i<125) arrClusPtBinning[i] = 3.+0.1*(i-55);
600  else if(i<155) arrClusPtBinning[i] = 10.+0.2*(i-125);
601  else if(i<171) arrClusPtBinning[i] = 16.+0.25*(i-155);
602  else arrClusPtBinning[i] = maxClusterPt;
603  }
604  }
605 
606  // default binning
607  } else {
608  nBinsPt = 235;
609  minPt = 0;
610  maxPt = 50;
611  binWidthPt = 0.05;
612  for(Int_t i=0; i<nBinsPt+1;i++){
613  if (i < 1) arrPtBinning[i] = 0.3*i;
614  else if(i<55) arrPtBinning[i] = 0.3+0.05*(i-1);
615  else if(i<125) arrPtBinning[i] = 3.+0.1*(i-55);
616  else if(i<185) arrPtBinning[i] = 10.+0.25*(i-125);
617  else if(i<235) arrPtBinning[i] = 25.+0.5*(i-185);
618  else arrPtBinning[i] = maxPt;
619  }
620  nBinsQAPt = 221;
621  maxQAPt = 50;
622  for(Int_t i=0; i<nBinsQAPt+1;i++){
623  if(i<60) arrQAPtBinning[i] = 0.05*i;
624  else if(i<130) arrQAPtBinning[i] = 3.+0.1*(i-60);
625  else if(i<170) arrQAPtBinning[i] = 10.+0.25*(i-130);
626  else if(i<210) arrQAPtBinning[i] = 20.+0.5*(i-170);
627  else if(i<221) arrQAPtBinning[i] = 40.+1.0*(i-210);
628  else arrQAPtBinning[i] = maxQAPt;
629  }
630  nBinsClusterPt = 351;
631  maxClusterPt = 50;
632  for(Int_t i=0; i<nBinsClusterPt+1;i++){
633  if (i < 1) arrClusPtBinning[i] = 0.3*i;
634  else if(i<55) arrClusPtBinning[i] = 0.3+0.05*(i-1);
635  else if(i<125) arrClusPtBinning[i] = 3.+0.1*(i-55);
636  else if(i<155) arrClusPtBinning[i] = 10.+0.2*(i-125);
637  else if(i<211) arrClusPtBinning[i] = 16.+0.25*(i-155);
638  else if(i<251) arrClusPtBinning[i] = 30.+0.5*(i-211);
639  else arrClusPtBinning[i] = maxClusterPt;
640  }
641  }
642 
643  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
644  TString cutstringEvent = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
645  TString cutstringConvGamma = "";
646  TString cutstringCaloGamma = "";
647  if (fMesonRecoMode < 2) cutstringConvGamma = ((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutNumber();
648  if (fMesonRecoMode > 0 || fEnableClusterCutsForTrigger) cutstringCaloGamma = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
649  TString cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
650 
651  TString fullCutString = "";
652  if (fMesonRecoMode == 0) fullCutString = Form("%i_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(), cutstringConvGamma.Data(), cutstringMeson.Data());
653  else if (fMesonRecoMode == 1) fullCutString = Form("%i_%s_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(),cutstringConvGamma.Data(),cutstringCaloGamma.Data(), cutstringMeson.Data());
654  else if (fMesonRecoMode == 2) fullCutString = Form("%i_%s_%s_%s",fMesonRecoMode, cutstringEvent.Data(), cutstringCaloGamma.Data(), cutstringMeson.Data());
655 
656  fCutFolder[iCut] = new TList();
657  fCutFolder[iCut]->SetName(Form("Cut Number %s",fullCutString.Data()));
658  fCutFolder[iCut]->SetOwner(kTRUE);
659  fOutputContainer->Add(fCutFolder[iCut]);
660  fESDList[iCut] = new TList();
661  fESDList[iCut]->SetName(Form("%s ESD histograms",fullCutString.Data()));
662  fESDList[iCut]->SetOwner(kTRUE);
663  fCutFolder[iCut]->Add(fESDList[iCut]);
664 
665  fHistoNEvents[iCut] = new TH1F("NEvents", "NEvents", 14, -0.5, 13.5);
666  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
667  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
668  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
669  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
670  TString TriggerNames = "Not Trigger: ";
671  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
672  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
673  }else {
674  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
675  }
676  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
677  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
678  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
679  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
680  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
681  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
682  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
683  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
684  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
685  fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
686  fESDList[iCut]->Add(fHistoNEvents[iCut]);
687 
688  if (fIsMC > 1){
689  fHistoNEventsWOWeight[iCut] = new TH1F("NEventsWOWeight", "NEventsWOWeight", 14, -0.5, 13.5);
690  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
691  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
692  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(3,"Miss. MC or inc. ev.");
693  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() > 1 ){
694  TString TriggerNames = "Not Trigger: ";
695  TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
696  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
697  }else {
698  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
699  }
700  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
701  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
702  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
703  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
704  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
705  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(10,"EMCAL problem");
706  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(11,"rejectedForJetJetMC");
707  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(12,"SPD hits vs tracklet");
708  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(13,"Out-of-Bunch pileup Past-Future");
709  fHistoNEventsWOWeight[iCut]->GetXaxis()->SetBinLabel(14,"Pileup V0M-TPCout Tracks");
710  fESDList[iCut]->Add(fHistoNEventsWOWeight[iCut]);
711  }
712 
713  if (fIsMC == 2){
714  fProfileJetJetXSection[iCut] = new TProfile("XSection", "XSection", 1, -0.5, 0.5);
715  fESDList[iCut]->Add(fProfileJetJetXSection[iCut]);
716  fHistoJetJetNTrials[iCut] = new TH1F("NTrials", "#sum{NTrials}", 1, 0, 1);
717  fHistoJetJetNTrials[iCut]->GetXaxis()->SetBinLabel(1,"#sum{NTrials}");
718  fESDList[iCut]->Add(fHistoJetJetNTrials[iCut]);
719  }
720 
721  if(fIsHeavyIon == 1)
722  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks", "GoodESDTracks; # TPC tracks", 4000, 0, 4000);
723  else if(fIsHeavyIon == 2)
724  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks", "GoodESDTracks; # TPC tracks", 400, 0, 400);
725  else
726  fHistoNGoodESDTracks[iCut] = new TH1F("GoodESDTracks", "GoodESDTracks; # TPC tracks", 200, 0, 200);
727  fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
728 
729  fHistoVertexZ[iCut] = new TH1F("VertexZ", "VertexZ", 200, -10, 10);
730  fESDList[iCut]->Add(fHistoVertexZ[iCut]);
731  if(!fDoLightOutput){
732  fHistoVertexX[iCut] = new TH1F("VertexX", "VertexX", 100, -5, 5);
733  fESDList[iCut]->Add(fHistoVertexX[iCut]);
734  fHistoVertexY[iCut] = new TH1F("VertexY", "VertexY", 100, -5, 5);
735  fESDList[iCut]->Add(fHistoVertexY[iCut]);
736  }
737 
738  if (fMesonRecoMode < 2){
739  if(fIsHeavyIon == 1)
740  fHistoNGammaConvCandidates[iCut] = new TH1F("GammaConvCandidates", "GammaConvCandidates; # accepted #gamma_{conv}", 100, 0, 100);
741  else if(fIsHeavyIon == 2)
742  fHistoNGammaConvCandidates[iCut] = new TH1F("GammaConvCandidates", "GammaConvCandidates; # accepted #gamma_{conv}", 50, 0, 50);
743  else
744  fHistoNGammaConvCandidates[iCut] = new TH1F("GammaConvCandidates", "GammaConvCandidates; # accepted #gamma_{conv}", 50, 0, 50);
745  fESDList[iCut]->Add(fHistoNGammaConvCandidates[iCut]);
746  }
747  if (fMesonRecoMode > 0){ //if (fMesonRecoMode > 0 || fEnableClusterCutsForTrigger){
748  if(fIsHeavyIon == 1)
749  fHistoNGammaCaloCandidates[iCut] = new TH1F("GammaCaloCandidates", "GammaCaloCandidates; # accepted #gamma_{conv}", 100, 0, 100);
750  else if(fIsHeavyIon == 2)
751  fHistoNGammaCaloCandidates[iCut] = new TH1F("GammaCaloCandidates", "GammaCaloCandidates; # accepted #gamma_{conv}", 50, 0, 50);
752  else
753  fHistoNGammaCaloCandidates[iCut] = new TH1F("GammaCaloCandidates", "GammaCaloCandidates; # accepted #gamma_{conv}", 50, 0, 50);
754  fESDList[iCut]->Add(fHistoNGammaCaloCandidates[iCut]);
755 
756  }
757 
758  if(!fDoLightOutput){
759  fHistoSPDClusterTrackletBackground[iCut] = new TH2F("SPD tracklets vs SPD clusters", "SPD tracklets vs SPD clusters", 100, 0, 200, 250, 0, 1000);
761 
762  if(fIsHeavyIon == 1)
763  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity", "V0 Multiplicity; VZERO amp [arb. units]", 30000, 0, 30000);
764  else if(fIsHeavyIon == 2)
765  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity", "V0 Multiplicity; VZERO amp [arb. units]", 2500, 0, 2500);
766  else
767  fHistoNV0Tracks[iCut] = new TH1F("V0 Multiplicity", "V0 Multiplicity; VZERO amp [arb. units]", 1500, 0, 1500);
768  fESDList[iCut]->Add(fHistoNV0Tracks[iCut]);
769 
770  if (fMesonRecoMode < 2){
771  fHistoConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt", "ESD_ConvGamma_Pt; p_{T,conv}(GeV/c)", (Int_t)((maxPt-minPt)/binWidthPt), minPt, maxPt);
772  fESDList[iCut]->Add(fHistoConvGammaPt[iCut]);
773  }
775  fHistoClusGammaPt[iCut] = new TH1F("ClusGamma_Pt", "ClusGamma_Pt; p_{T,clus} (GeV/c)", nBinsClusterPt, arrClusPtBinning);
776  fESDList[iCut]->Add(fHistoClusGammaPt[iCut]);
777  fHistoClusGammaE[iCut] = new TH1F("ClusGamma_E", "ClusGamma_E; E_{clus} (GeV)", nBinsClusterPt, arrClusPtBinning);
778  fESDList[iCut]->Add(fHistoClusGammaE[iCut]);
779  }
780  }
781 
782  if(fIsHeavyIon == 2){
783  fProfileEtaShift[iCut] = new TProfile("Eta Shift", "Eta Shift", 1, -0.5, 0.5);
784  fESDList[iCut]->Add(fProfileEtaShift[iCut]);
785  }
786 
787  if (fIsMC > 1){
788  fHistoNEvents[iCut]->Sumw2();
789  fHistoNGoodESDTracks[iCut]->Sumw2();
790  fHistoVertexZ[iCut]->Sumw2();
791  if (fMesonRecoMode < 2) fHistoNGammaConvCandidates[iCut]->Sumw2();
793  if(!fDoLightOutput){
794  fHistoVertexX[iCut]->Sumw2();
795  fHistoVertexY[iCut]->Sumw2();
796  fHistoSPDClusterTrackletBackground[iCut]->Sumw2();
797  fHistoNV0Tracks[iCut]->Sumw2();
798  if (fMesonRecoMode < 2)
799  fHistoConvGammaPt[iCut]->Sumw2();
801  if (fHistoClusGammaPt[iCut]) fHistoClusGammaPt[iCut]->Sumw2();
802  if (fHistoClusGammaE[iCut]) fHistoClusGammaE[iCut]->Sumw2();
803  }
804  }
805  }
806 
807  for(Int_t iModules = 0; iModules < fnModules; iModules++ ){
808  fHistoMotherInvMassECalibSM[iCut][iModules] = new TH2F(Form("ESD_Mother_InvMass_E_Calib_SM%i",iModules), Form("ESD_Mother_InvMass_E_Calib_SM%i",iModules), fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
809  fHistoMotherInvMassECalibSM[iCut][iModules]->SetXTitle("M_{inv} (GeV/c^{2})");
810  fHistoMotherInvMassECalibSM[iCut][iModules]->SetYTitle("E_{cluster}(GeV)");
811  fESDList[iCut]->Add(fHistoMotherInvMassECalibSM[iCut][iModules]);
812  fHistoMotherBackInvMassECalibSM[iCut][iModules] = new TH2F(Form("ESD_Back_InvMass_E_Calib_SM%i",iModules), Form("ESD_Back_InvMass_E_Calib_SM%i",iModules), fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
813  fHistoMotherBackInvMassECalibSM[iCut][iModules]->SetXTitle("M_{inv} (GeV/c^{2})");
814  fHistoMotherBackInvMassECalibSM[iCut][iModules]->SetYTitle("E_{cluster}(GeV)");
815  fESDList[iCut]->Add(fHistoMotherBackInvMassECalibSM[iCut][iModules]);
816 
817  fHistoClusGammaPtSM[iCut][iModules] = new TH1F(Form("ClusGamma_Pt_SM%i",iModules), Form("ClusGamma_Pt_SM%i; p_{T,clus} (GeV/c)",iModules), nBinsClusterPt, arrClusPtBinning);
818  fESDList[iCut]->Add(fHistoClusGammaPtSM[iCut][iModules]);
819  fHistoClusGammaESM[iCut][iModules] = new TH1F(Form("ClusGamma_E_SM%i",iModules), Form("ClusGamma_E_SM%i; p_{T,clus} (GeV/c)",iModules), nBinsClusterPt, arrClusPtBinning);
820  fESDList[iCut]->Add(fHistoClusGammaESM[iCut][iModules]);
821  }
822 
823  fHistoMotherInvMassECalib[iCut] = new TH2F("ESD_Mother_InvMass_E_Calib", "ESD_Mother_InvMass_E_Calib", fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
824  fHistoMotherInvMassECalib[iCut]->SetXTitle("M_{inv} (GeV/c^{2})");
825  fHistoMotherInvMassECalib[iCut]->SetYTitle("E_{cluster}(GeV)");
826  fESDList[iCut]->Add(fHistoMotherInvMassECalib[iCut]);
827  fHistoMotherBackInvMassECalib[iCut] = new TH2F("ESD_Back_InvMass_E_Calib", "ESD_Back_InvMass_E_Calib", fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
828  fHistoMotherBackInvMassECalib[iCut]->SetXTitle("M_{inv} (GeV/c^{2})");
829  fHistoMotherBackInvMassECalib[iCut]->SetYTitle("E_{cluster}(GeV)");
830  fESDList[iCut]->Add(fHistoMotherBackInvMassECalib[iCut]);
831 
832 
833  fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt", "ESD_Mother_InvMass_Pt; M_{inv} (GeV/c^{2}); p_{T,pair} (GeV/c)",
834  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
835  fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
836  fHistoMotherInvMassRejected[iCut] = new TH1F("ESD_Mother_InvMassRejected", "ESD_Mother_InvMassRejected; M_{inv} (GeV/c^{2})",
837  1200, 0, 1.2);
838  fESDList[iCut]->Add(fHistoMotherInvMassRejected[iCut]);
839 
840 
841 
842  if(!fDoLightOutput){
843  if (fMesonRecoMode == 1){
844  fHistoMotherMatchedInvMassPt[iCut] = new TH2F("ESD_MotherMatched_InvMass_Pt", "ESD_MotherMatched_InvMass_Pt; M_{inv} (GeV/c^{2}) matched conv e^{+/-}to cluster; p_{T,pair} (GeV/c)",
845  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
846  fESDList[iCut]->Add(fHistoMotherMatchedInvMassPt[iCut]);
847  }
848  }
849 
850  fHistoMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt", "ESD_Background_InvMass_Pt; M_{inv, mxed}(GeV/c^{2}); p_{T,BG pair} (GeV/c)",
851  fMesonInvMassNBins, fMesonInvMassMin, fMesonInvMassMax, nBinsPt, arrPtBinning);
852  fESDList[iCut]->Add(fHistoMotherBackInvMassPt[iCut]);
853 
854  if (fIsMC > 1){
855  fHistoMotherInvMassPt[iCut]->Sumw2();
856  fHistoMotherBackInvMassPt[iCut]->Sumw2();
857  if (fMesonRecoMode == 1){
859  }
860  }
861 
862  if (fDoMesonQA > 0 ){
863  fHistoMotherMesonPtY[iCut] = new TH2F("ESD_MotherMeson_Pt_Y", "ESD_MotherMeson_Pt_Y; p_{T, meson cand} (GeV/c); y_{meson cand}",
864  nBinsQAPt, arrQAPtBinning, 150, -1.5, 1.5);
865  fESDList[iCut]->Add(fHistoMotherMesonPtY[iCut]);
866  fHistoMotherMesonPtAlpha[iCut] = new TH2F("ESD_MotherMeson_Pt_Alpha", "ESD_MotherMeson_Pt_Alpha; p_{T, meson cand} (GeV/c); #alpha_{meson cand}",
867  nBinsQAPt, arrQAPtBinning, 200, -1, 1);
868  fESDList[iCut]->Add(fHistoMotherMesonPtAlpha[iCut]);
869  fHistoMotherMesonPtOpenAngle[iCut] = new TH2F("ESD_MotherMeson_Pt_OpenAngle", "ESD_MotherMeson_Pt_OpenAngle; p_{T, meson cand} (GeV/c); #theta_{meson cand}",
870  nBinsQAPt, arrQAPtBinning, 100, 0, 1);
871  fESDList[iCut]->Add(fHistoMotherMesonPtOpenAngle[iCut]);
872  fHistoMotherMesonConvPhotonEtaPhi[iCut] = new TH2F("ESD_MotherMesonConvPhoton_Eta_Phi", "ConvPhoton under meson peak; #phi_{#gamma_{conv}}(rad); #eta_{#gamma_{conv}}",
873  600, 0, 2*TMath::Pi(), 200, -1, 1);
875  if (fIsMC > 1){
876  fHistoMotherMesonPtY[iCut]->Sumw2();
877  fHistoMotherMesonPtAlpha[iCut]->Sumw2();
878  fHistoMotherMesonPtOpenAngle[iCut]->Sumw2();
879  fHistoMotherMesonConvPhotonEtaPhi[iCut]->Sumw2();
880  }
881  }
882  }
883 
884  InitBack(); // Init Background Handler
885 
886 
887  if(fV0Reader)
888  if((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())
889  if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
890  fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
891  if(fV0Reader)
892  if((AliConvEventCuts*)fV0Reader->GetEventCuts())
893  if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms())
894  fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
895 
896  if( fV0Reader && fV0Reader->GetProduceV0FindingEfficiency())
897  if (fV0Reader->GetV0FindingEfficiencyHistograms())
898  fOutputContainer->Add(fV0Reader->GetV0FindingEfficiencyHistograms());
899 
900  for(Int_t iMatcherTask = 0; iMatcherTask < 5; iMatcherTask++){
901  AliCaloTrackMatcher* temp = 0x0;
902  if(!fCorrTaskSetting.CompareTo("")){
903  temp = (AliCaloTrackMatcher*) (AliAnalysisManager::GetAnalysisManager()->GetTask(Form("CaloTrackMatcher_%i_%i",iMatcherTask,fTrackMatcherRunningMode)));
904  } else {
905  temp = (AliCaloTrackMatcher*) (AliAnalysisManager::GetAnalysisManager()->GetTask(Form("CaloTrackMatcher_%i_%i_%s",iMatcherTask,fTrackMatcherRunningMode,fCorrTaskSetting.Data())));
906  }
907  if(temp) fOutputContainer->Add(temp->GetCaloTrackMatcherHistograms());
908  }
909 
910  // for electron selection
912  fElecSelector=(AliDalitzElectronSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("ElectronSelector");
913  if(!fElecSelector){AliFatal("Error: No ElectronSelector");}
914 
915  if( fElecSelector ){
916  if ( ((AliDalitzElectronCuts*)fElecSelector->GetDalitzElectronCuts())->GetCutHistograms() ){
917  fOutputContainer->Add( ((AliDalitzElectronCuts*)fElecSelector->GetDalitzElectronCuts())->GetCutHistograms() );
918  }
919  }
920  }
921 
922 
923  //********************************************************************************************************//
924  //***************************** NOT NEEDED FOR CALIBRATION??? ****************************************//
925  //********************************************************************************************************//
926  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
927  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))) continue;
928  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms()){
929  fCutFolder[iCut]->Add(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
930  }
931  if (fMesonRecoMode < 2){
932  if(!((AliConversionPhotonCuts*)fCutArray->At(iCut))) continue;
933  if(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms()){
934  fCutFolder[iCut]->Add(((AliConversionPhotonCuts*)fCutArray->At(iCut))->GetCutHistograms());
935  }
936  }
938  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
939  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms()){
940  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms());
941  }
942  if(fSetPlotHistsExtQA){
943  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
944  if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetExtQAHistograms()){
945  fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetExtQAHistograms());
946  }
947  }
948  }
949  if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
950  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
951  fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
952  }
953  }
954 
955 
956  PostData(1, fOutputContainer);
957 }
958 //_____________________________________________________________________________
960 
961  for(Int_t iCut = 0; iCut<fnCuts;iCut++){
962  if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod && ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum() != AliConvEventCuts::kNoPeriod){
963  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnumExplicit(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetPeriodEnum());
964  } else if (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetPeriodEnum() == AliConvEventCuts::kNoPeriod ){
965  ((AliConvEventCuts*)fEventCutArray->At(iCut))->SetPeriodEnum(fV0Reader->GetPeriodName());
966  }
967 
968  if(fIsHeavyIon == 2){
969  if(!((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift()){
970  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
971  continue; // No Eta Shift requested, continue
972  }
973  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
974  ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod();
975  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
976  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
977  continue;
978  } else{
979  printf(" Gamma Conversion Task %s :: Eta Shift Manually Set to %f \n\n",
980  (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
981  fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
982  ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
983  }
984  }
985  }
986 
987  return kTRUE;
988 }
989 //_____________________________________________________________________________
991  //
992  // Called for each event
993  //
994  fInputEvent = InputEvent();
995 
996  if(fIsMC > 0) fMCEvent = MCEvent();
997 
998  Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetEventQuality();
999  if(fInputEvent->IsIncompleteDAQ()==kTRUE) eventQuality = 2;// incomplete event
1000  // Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1 or because it is incomplete => abort processing of this event/file
1001  if(eventQuality == 2 || eventQuality == 3){
1002  // write out name of broken file for first event
1003 
1004  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1005  fHistoNEvents[iCut]->Fill(eventQuality);
1006  }
1007  return;
1008  }
1009 // if(fInputEvent->IsA()==AliAODEvent::Class()){
1010 // fInputEvent->InitMagneticField();
1011 // }
1012  fReaderGammas = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
1013 
1015  fSelectorElectronIndex = fElecSelector->GetReconstructedElectronsIndex(); // Electrons from default Cut
1016  fSelectorPositronIndex = fElecSelector->GetReconstructedPositronsIndex(); // Positrons from default Cut
1017  } else if(fUseEletronMatchingCalibration == 2){
1018  GetV0Electrons();
1019  }
1020 
1021  // ------------------- BeginEvent ----------------------------
1022  AliEventplane *EventPlane = fInputEvent->GetEventplane();
1023  if(fIsHeavyIon ==1)fEventPlaneAngle = EventPlane->GetEventplane("V0",fInputEvent,2);
1024  else fEventPlaneAngle=0.0;
1025 
1026  for(Int_t iCut = 0; iCut<fnCuts; iCut++){
1027 
1028  fiCut = iCut;
1029  Bool_t isRunningEMCALrelAna = kFALSE;
1031  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetClusterType() == 1) isRunningEMCALrelAna = kTRUE;
1032  }
1033 
1034  if (fIsMC > 0){
1035  fWeightJetJetMC = 1;
1036  Float_t pthard = -1;
1037  Bool_t isMCJet = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsJetJetMCEventAccepted( fMCEvent, fWeightJetJetMC , pthard, fInputEvent);
1038  if (fIsMC == 3){
1039  Double_t weightMult = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetWeightForMultiplicity(fV0Reader->GetNumberOfPrimaryTracks());
1040  fWeightJetJetMC = fWeightJetJetMC*weightMult;
1041  }
1042 
1043  if (!isMCJet){
1044  fHistoNEvents[iCut]->Fill(10,fWeightJetJetMC);
1045  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(10);
1046  continue;
1047  }
1048  }
1049 
1050  Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),fInputEvent,fMCEvent,fIsHeavyIon,isRunningEMCALrelAna);
1051 
1052  if(eventNotAccepted!= 0){
1053  fHistoNEvents[iCut]->Fill(eventNotAccepted, fWeightJetJetMC); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
1054  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventNotAccepted);
1055  // cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
1056  continue;
1057  }
1058  if(eventQuality != 0){// Event Not Accepted
1059  //cout << "event rejected due to: " <<eventQuality << endl;
1060  fHistoNEvents[iCut]->Fill(eventQuality, fWeightJetJetMC);
1061  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventQuality); // Should be 0 here
1062  continue;
1063  }
1064 
1065  fHistoNEvents[iCut]->Fill(eventQuality, fWeightJetJetMC); // Should be 0 here
1066  if (fIsMC>1) fHistoNEventsWOWeight[iCut]->Fill(eventQuality); // Should be 0 here
1067 
1068  fHistoNGoodESDTracks[iCut]->Fill(fV0Reader->GetNumberOfPrimaryTracks(), fWeightJetJetMC);
1069  fHistoVertexZ[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetZ(), fWeightJetJetMC);
1070  if(!fDoLightOutput){
1071  fHistoVertexX[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetX(), fWeightJetJetMC);
1072  fHistoVertexY[iCut]->Fill(fInputEvent->GetPrimaryVertex()->GetY(), fWeightJetJetMC);
1073  fHistoSPDClusterTrackletBackground[iCut]->Fill(fInputEvent->GetMultiplicity()->GetNumberOfTracklets(),(fInputEvent->GetNumberOfITSClusters(0)+fInputEvent->GetNumberOfITSClusters(1)),fWeightJetJetMC);
1074  if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2) fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A(), fWeightJetJetMC);
1075  else fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C(), fWeightJetJetMC);
1076  }
1077 
1078  if (fMesonRecoMode < 2){
1079  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetDoElecDeDxPostCalibration()){
1080  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->LoadElecDeDxPostCalibration(fInputEvent->GetRunNumber())){
1081  AliFatal(Form("ERROR: LoadElecDeDxPostCalibration returned kFALSE for %d despite being requested!",fInputEvent->GetRunNumber()));
1082  }
1083  }
1084  }
1085 
1086 
1087  // 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)
1088  if (fMesonRecoMode > 0 || fEnableClusterCutsForTrigger) // process calo clusters
1089  ProcessClusters();
1090  if (fMesonRecoMode < 2) // Process this cuts gammas
1092  if (fMesonRecoMode < 2) fHistoNGammaConvCandidates[iCut]->Fill(fGammaCandidates->GetEntries(),fWeightJetJetMC);
1094 
1095 
1096  // check gamma gamma pairs and veto if necessary
1097  if (!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetAcceptMassFlag())
1098  SetPhotonVeto();
1099 
1100  CalculateMesonCandidates(); // Combine Gammas from conversion and from calo
1101  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
1102  if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
1103  CalculateBackground(); // Combinatorial Background
1104  UpdateEventByEventData(); // Store Event for mixed Events
1105  } else{
1106  CalculateBackgroundRP(); // Combinatorial Background
1107  fBGHandlerRP[iCut]->AddEvent(fGammaCandidates,fInputEvent); // Store Event for mixed Events
1108  fBGClusHandlerRP[iCut]->AddEvent(fClusterCandidates,fInputEvent); // Store Event for mixed Events
1109  }
1110  }
1111  fGammaCandidates->Clear(); // delete this cuts good gammas
1112  fClusterCandidates->Clear(); // delete cluster candidates
1113  }
1114 
1115  // if(fIsMC>0 && fInputEvent->IsA()==AliAODEvent::Class() && !(fV0Reader->AreAODsRelabeled()) && fMesonRecoMode < 2){
1116  // RelabelAODPhotonCandidates(kFALSE); // Back to ESDMC Label
1117  // fV0Reader->RelabelAODs(kFALSE);
1118  // }
1119  fSelectorElectronIndex.clear();
1120  fSelectorPositronIndex.clear();
1121  fV0Electrons.clear();
1122  PostData(1, fOutputContainer);
1123 }
1124 
1125 //________________________________________________________________________
1127  Int_t nclus = 0;
1128  TClonesArray * arrClustersProcess = NULL;
1129  if(!fCorrTaskSetting.CompareTo("")){
1130  nclus = fInputEvent->GetNumberOfCaloClusters();
1131  } else {
1132  arrClustersProcess = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
1133  if(!arrClustersProcess)
1134  AliFatal(Form("%sClustersBranch was not found in AliAnalysisTaskConvCaloCalibration! Check the correction framework settings!",fCorrTaskSetting.Data()));
1135  nclus = arrClustersProcess->GetEntries();
1136  }
1137 
1138  // cout << nclus << endl;
1139  vector<AliAODConversionPhoton*> vectorCurrentClusters;
1140  vector<Int_t> vectorRejectCluster;
1141  vector<Int_t> vectorClusterSM;
1142  vector<Double_t> vectorPhotonWeight;
1143 
1144  if(nclus == 0) return;
1145 
1146  // plotting histograms on cell/tower level, only if extendedMatchAndQA > 1
1147  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->FillHistogramsExtendedQA(fInputEvent,fIsMC);
1148 
1149  // match tracks to clusters
1150  if(fDoPrimaryTrackMatching && fUseEletronMatchingCalibration == 0) ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchTracksToClusters(fInputEvent,fWeightJetJetMC,kFALSE);
1151  // vertex
1152  Double_t vertex[3] = {0,0,0};
1153  InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
1154 
1155  // Loop over EMCal clusters
1156  for(Int_t i = 0; i < nclus; i++){
1157  AliVCluster* clus = NULL;
1158  if(fInputEvent->IsA()==AliESDEvent::Class()){
1159  if(arrClustersProcess)
1160  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersProcess->At(i));
1161  else
1162  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)fInputEvent->GetCaloCluster(i));
1163  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
1164  if(arrClustersProcess)
1165  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersProcess->At(i));
1166  else
1167  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)fInputEvent->GetCaloCluster(i));
1168  }
1169 
1170  if (!clus) continue;
1171  if(!((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelected(clus,fInputEvent,fMCEvent,fIsMC,fWeightJetJetMC,i)){
1172  delete clus;
1173  continue;
1174  }
1176  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchElectronTracksToClusters(fInputEvent, fMCEvent, clus, fIsMC, fSelectorElectronIndex, fWeightJetJetMC);
1177  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchElectronTracksToClusters(fInputEvent, fMCEvent, clus, fIsMC, fSelectorPositronIndex, fWeightJetJetMC);
1178  } else if(fUseEletronMatchingCalibration == 2){
1179  ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchElectronTracksToClusters(fInputEvent, fMCEvent, clus, fIsMC, fV0Electrons, fWeightJetJetMC);
1180  }
1181 
1182 
1183  // TLorentzvector with cluster
1184  TLorentzVector clusterVector;
1185  clus->GetMomentum(clusterVector,vertex);
1186 
1187  TLorentzVector* tmpvec = new TLorentzVector();
1188  tmpvec->SetPxPyPzE(clusterVector.Px(),clusterVector.Py(),clusterVector.Pz(),clusterVector.E());
1189 
1190  // convert to AODConversionPhoton
1191  AliAODConversionPhoton *PhotonCandidate = new AliAODConversionPhoton(tmpvec);
1192  if(!PhotonCandidate){ delete clus; delete tmpvec; continue;}
1193 
1194  // Flag Photon as CaloPhoton
1195  PhotonCandidate->SetIsCaloPhoton(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetClusterType());
1196  PhotonCandidate->SetCaloClusterRef((Long_t)i);
1197  PhotonCandidate->SetLeadingCellID(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->FindLargestCellInCluster(clus,fInputEvent));
1198 
1199 
1200  fIsFromDesiredHeader = kTRUE;
1203 
1204  vectorCurrentClusters.push_back(PhotonCandidate);
1205  vectorPhotonWeight.push_back(fWeightJetJetMC);
1206 
1207  if(PhotonCandidate->GetIsCaloPhoton() == 1 || PhotonCandidate->GetIsCaloPhoton() == 3 ){
1208  fGeomEMCAL = AliEMCALGeometry::GetInstance();
1209  vectorClusterSM.push_back(fGeomEMCAL->GetSuperModuleNumber(PhotonCandidate->GetLeadingCellID()));
1210  }else {
1211  vectorClusterSM.push_back(0);
1212  }
1213  }else{
1214  delete PhotonCandidate;
1215  }
1216 
1217  delete clus;
1218  delete tmpvec;
1219  }
1220  Bool_t rejected = kFALSE;
1221  // run conversion recovery in addition
1222  if (((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->GetIsConversionRecovery()){
1223  rejected = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->CheckForReconstructedConversionPairs(vectorCurrentClusters,vectorRejectCluster);
1224  }
1225 
1226  for (Int_t iter = 0; iter < (Int_t)vectorCurrentClusters.size();iter++){
1227 
1228  if (!((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->CheckVectorForIndexAndAdd(vectorRejectCluster, iter,kFALSE)){
1229  fHistoClusGammaPt[fiCut]->Fill(vectorCurrentClusters.at(iter)->Pt(), vectorPhotonWeight.at(iter));
1230  fHistoClusGammaE[fiCut]->Fill(vectorCurrentClusters.at(iter)->E(), vectorPhotonWeight.at(iter));
1231 
1232  if(vectorClusterSM.at(iter) >= 0 && vectorClusterSM.at(iter) < 20){
1233  fHistoClusGammaPtSM[fiCut][vectorClusterSM.at(iter)]->Fill(vectorCurrentClusters.at(iter)->Pt(),vectorPhotonWeight.at(iter));
1234  fHistoClusGammaESM[fiCut][vectorClusterSM.at(iter)]->Fill(vectorCurrentClusters.at(iter)->Pt(),vectorPhotonWeight.at(iter));
1235  }
1236 
1237  fClusterCandidates->Add(vectorCurrentClusters.at(iter));
1238  }
1239  }
1240  vectorRejectCluster.clear();
1241  vectorClusterSM.clear();
1242  vectorPhotonWeight.clear();
1243 }
1244 
1245 //________________________________________________________________________
1247 
1248  Int_t nV0 = 0;
1249  TList *GammaCandidatesStepOne = new TList();
1250  TList *GammaCandidatesStepTwo = new TList();
1251  // Loop over Photon Candidates allocated by ReaderV1
1252  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
1253  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
1254  if(!PhotonCandidate) continue;
1255  fIsFromDesiredHeader = kTRUE;
1256  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fInputEvent)) continue;
1257  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->InPlaneOutOfPlaneCut(PhotonCandidate->GetPhotonPhi(),fEventPlaneAngle)) continue;
1258  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
1259  !((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
1260  fGammaCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
1261 
1263  if(!fDoLightOutput) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
1264  }
1265  }else if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
1266  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
1267  nV0++;
1268  GammaCandidatesStepOne->Add(PhotonCandidate);
1269  }else if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut() &&
1270  ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
1271  GammaCandidatesStepTwo->Add(PhotonCandidate);
1272  }
1273  }
1274 
1275  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseElecSharingCut()){
1276  for(Int_t i = 0;i<GammaCandidatesStepOne->GetEntries();i++){
1277  AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GammaCandidatesStepOne->At(i);
1278  if(!PhotonCandidate) continue;
1279  fIsFromDesiredHeader = kTRUE;
1280  // if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
1281  // Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
1282  // Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
1283  // if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromDesiredHeader = kFALSE;
1284  // }
1285  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GammaCandidatesStepOne->GetEntries())) continue;
1286  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
1287  fGammaCandidates->Add(PhotonCandidate);
1289  if(!fDoLightOutput) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
1290  }
1291  } else GammaCandidatesStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
1292  }
1293  }
1294 
1295  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->UseToCloseV0sCut()){
1296  for(Int_t i = 0;i<GammaCandidatesStepTwo->GetEntries();i++){
1297  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GammaCandidatesStepTwo->At(i);
1298  if(!PhotonCandidate) continue;
1299  fIsFromDesiredHeader = kTRUE;
1300  if(fMCEvent && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
1301  Int_t isPosFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCEvent, fInputEvent);
1302  Int_t isNegFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCEvent, fInputEvent);
1303  if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromDesiredHeader = kFALSE;
1304  }
1305  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GammaCandidatesStepTwo,i)) continue;
1306  fGammaCandidates->Add(PhotonCandidate); // Add gamma to current cut TList
1308  if(!fDoLightOutput) fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt(),fWeightJetJetMC);
1309  }
1310  }
1311  }
1312 
1313  delete GammaCandidatesStepOne;
1314  GammaCandidatesStepOne = 0x0;
1315  delete GammaCandidatesStepTwo;
1316  GammaCandidatesStepTwo = 0x0;
1317 
1318 }
1319 
1320 //________________________________________________________________________
1322 
1323  for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
1324  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
1325  if(!PhotonCandidate) continue;
1326 
1327  //apply cuts to maximize electron purity
1328  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fInputEvent))continue;
1329 
1330  for (Int_t iElec = 0;iElec < 2;iElec++){
1331  Int_t tracklabel = PhotonCandidate->GetLabel(iElec);
1332  AliVTrack *inTrack = 0x0;
1333  if( fInputEvent->IsA()==AliESDEvent::Class() ) {
1334  if( tracklabel > fInputEvent->GetNumberOfTracks() ) continue;
1335  inTrack = dynamic_cast<AliVTrack*>(fInputEvent->GetTrack(tracklabel));
1336  } else {
1337  if( ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->AreAODsRelabeled() ){
1338  inTrack = dynamic_cast<AliVTrack*>(fInputEvent->GetTrack(tracklabel));
1339  } else {
1340  for( Int_t ii=0;ii<fInputEvent->GetNumberOfTracks();ii++ ) {
1341  inTrack = dynamic_cast<AliVTrack*>(fInputEvent->GetTrack(ii));
1342  if(inTrack){
1343  if(inTrack->GetID() == tracklabel) {
1344  break;
1345  }
1346  }
1347  }
1348  }
1349  }
1350  fV0Electrons.push_back(tracklabel);
1351  }
1352 
1353  }
1354 
1355 }
1356 
1357 //________________________________________________________________________
1358 // function to reject photons in specific invariant mass window
1359 //________________________________________________________________________
1361  TClonesArray * arrClustersMesonCand = NULL;
1362  if(fCorrTaskSetting.CompareTo("") && fMesonRecoMode > 0)
1363  arrClustersMesonCand = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
1364 
1365  if (fMesonRecoMode == 0){
1366  if(fGammaCandidates->GetEntries()>1){
1367  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries()-1;firstGammaIndex++){
1368  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
1369  if (gamma0==NULL) continue;
1370  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fGammaCandidates->GetEntries();secondGammaIndex++){
1371  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(secondGammaIndex));
1372  //Check for same Electron ID
1373  if (gamma1==NULL) continue;
1374  if(gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelPositive() ||
1375  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelNegative() ||
1376  gamma0->GetTrackLabelNegative() == gamma1->GetTrackLabelPositive() ||
1377  gamma0->GetTrackLabelPositive() == gamma1->GetTrackLabelNegative() ) continue;
1378 
1379  AliAODConversionMother *mesonCand = new AliAODConversionMother(gamma0,gamma1);
1380  mesonCand->SetLabels(firstGammaIndex,secondGammaIndex);
1381  mesonCand->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
1382 
1383  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(mesonCand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
1384  if (!(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(mesonCand, 0))){
1385  gamma0->SetUseForMesonPair(kFALSE);
1386  gamma1->SetUseForMesonPair(kFALSE);
1387  fHistoMotherInvMassRejected[fiCut]->Fill(mesonCand->M());
1388  }
1389  }
1390  delete mesonCand;
1391  mesonCand=0x0;
1392  }
1393  }
1394  }
1395  } else if (fMesonRecoMode == 1){
1396  if(fGammaCandidates->GetEntries()>0){
1397  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
1398  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
1399  if (gamma0==NULL) continue;
1400 
1401  for(Int_t secondGammaIndex=0;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
1402  Bool_t matched = kFALSE;
1403  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
1404  if (gamma1==NULL) continue;
1405 
1406  if (gamma1->GetIsCaloPhoton() > 0){
1407  AliVCluster* cluster = NULL;
1408  if(fInputEvent->IsA()==AliESDEvent::Class()){
1409  if(arrClustersMesonCand)
1410  cluster = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMesonCand->At(gamma1->GetCaloClusterRef()));
1411  else
1412  cluster = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
1413  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
1414  if(arrClustersMesonCand)
1415  cluster = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMesonCand->At(gamma1->GetCaloClusterRef()));
1416  else
1417  cluster = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
1418  }
1419 
1420  matched = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma0,cluster, fInputEvent, fWeightJetJetMC);
1421  if(arrClustersMesonCand) delete cluster;
1422  }
1423 
1424  AliAODConversionMother *mesonCand = new AliAODConversionMother(gamma0,gamma1);
1425  mesonCand->SetLabels(firstGammaIndex,secondGammaIndex);
1426 
1427  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(mesonCand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
1428  if (!matched){
1429  if (!(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(mesonCand, 0))){
1430  gamma0->SetUseForMesonPair(kFALSE);
1431  gamma1->SetUseForMesonPair(kFALSE);
1432  fHistoMotherInvMassRejected[fiCut]->Fill(mesonCand->M());
1433  }
1434  }
1435  }
1436  delete mesonCand;
1437  mesonCand=0x0;
1438  }
1439  }
1440  }
1441  } else if (fMesonRecoMode == 2){
1442  if(fClusterCandidates->GetEntries()>0){
1443  for(Int_t firstGammaIndex=0;firstGammaIndex<fClusterCandidates->GetEntries();firstGammaIndex++){
1444  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(firstGammaIndex));
1445  if (gamma0==NULL) continue;
1446  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
1447  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
1448  if (gamma1==NULL) continue;
1449 
1450  AliAODConversionMother *mesonCand = new AliAODConversionMother(gamma0,gamma1);
1451  mesonCand->SetLabels(firstGammaIndex,secondGammaIndex);
1452 
1453  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(mesonCand, kTRUE, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), gamma0->GetLeadingCellID(), gamma1->GetLeadingCellID(), gamma0->GetIsCaloPhoton(), gamma1->GetIsCaloPhoton()))){
1454  if (!(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedByMassCut(mesonCand, 0))){
1455  gamma0->SetUseForMesonPair(kFALSE);
1456  gamma1->SetUseForMesonPair(kFALSE);
1457  fHistoMotherInvMassRejected[fiCut]->Fill(mesonCand->M());
1458  }
1459  }
1460  delete mesonCand;
1461  mesonCand=0x0;
1462  }
1463  }
1464  }
1465  }
1466 }
1467 
1468 //________________________________________________________________________
1470  TClonesArray * arrClustersMesonCand = NULL;
1471  if(fCorrTaskSetting.CompareTo("") && fMesonRecoMode > 0)
1472  arrClustersMesonCand = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
1473 
1474  // AliVCaloCells* cells = 0x0;
1475  // cells = fInputEvent->GetEMCALCells();
1476  Int_t nMod = -1;
1477  Short_t cellNumber = 0;
1478  AliVCluster* cluster = NULL;
1479  AliVCluster* Cluster0 = NULL;
1480  AliVCluster* Cluster1 = NULL;
1481  fGeomEMCAL = AliEMCALGeometry::GetInstance();
1482  if (fMesonRecoMode == 1){ //PCM-CALO
1483  if(fGammaCandidates->GetEntries()>0){
1484  for(Int_t firstGammaIndex=0;firstGammaIndex<fGammaCandidates->GetEntries();firstGammaIndex++){
1485  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fGammaCandidates->At(firstGammaIndex));
1486  if (gamma0==NULL) continue;
1487 
1488  for(Int_t secondGammaIndex=0;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
1489  Bool_t matched = kFALSE;
1490  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
1491  if (gamma1==NULL) continue;
1492 
1493  if (gamma1->GetIsCaloPhoton() > 0){
1494 
1495  if(fInputEvent->IsA()==AliESDEvent::Class()){
1496  if(arrClustersMesonCand)
1497  cluster = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMesonCand->At(gamma1->GetCaloClusterRef()));
1498  else
1499  cluster = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
1500  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
1501  if(arrClustersMesonCand)
1502  cluster = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMesonCand->At(gamma1->GetCaloClusterRef()));
1503  else
1504  cluster = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
1505  }
1506  }
1507  matched = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma0,cluster, fInputEvent, fWeightJetJetMC);
1508  // if(arrClustersMesonCand) delete cluster;
1509 
1510  AliAODConversionMother *mesonCand = new AliAODConversionMother(gamma0,gamma1);
1511  mesonCand->SetLabels(firstGammaIndex,secondGammaIndex);
1512 
1513  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(mesonCand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
1514  if (matched){
1515  if(fHistoMotherMatchedInvMassPt[fiCut]) fHistoMotherMatchedInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),fWeightJetJetMC);
1516  }
1517 
1518 
1519  if (!matched){
1520 
1521  if (!gamma0->GetUseForMesonPair() || !gamma1->GetUseForMesonPair()){
1522  fHistoMotherInvMassRejected[fiCut]->Fill(mesonCand->M());
1523  delete mesonCand;
1524  mesonCand=0x0;
1525  continue;
1526  }
1528  fHistoMotherInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(),fWeightJetJetMC);
1529  cellNumber = cluster->GetCellsAbsId()[0];
1530  nMod = fGeomEMCAL->GetSuperModuleNumber(cellNumber);
1531  fHistoMotherInvMassECalibSM[fiCut][nMod]->Fill(mesonCand->M(),gamma1->E(),fWeightJetJetMC);
1532  fHistoMotherInvMassECalib[fiCut]->Fill(mesonCand->M(),gamma1->E(),fWeightJetJetMC);
1533  }
1534 
1535 
1536  if (fDoMesonQA > 0){
1537  if (mesonCand->M() > fMesonInvMassWindow[0] && mesonCand->M() < fMesonInvMassWindow[1]){
1538  if (fHistoMotherMesonPtY[fiCut]) fHistoMotherMesonPtY[fiCut]->Fill(mesonCand->Pt(),mesonCand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),fWeightJetJetMC);
1539  if (fHistoMotherMesonPtAlpha[fiCut]) fHistoMotherMesonPtAlpha[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetAlpha(),fWeightJetJetMC);
1540  if (fHistoMotherMesonPtOpenAngle[fiCut]) fHistoMotherMesonPtOpenAngle[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetOpeningAngle(),fWeightJetJetMC);
1541  if (fHistoMotherMesonConvPhotonEtaPhi[fiCut]) fHistoMotherMesonConvPhotonEtaPhi[fiCut]->Fill(gamma0->GetPhotonPhi(), gamma0->GetPhotonEta(),fWeightJetJetMC);
1542  }
1543  }
1544  if(fDoTHnSparse && ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
1545  Int_t zbin = 0;
1546  Int_t mbin = 0;
1547 
1548  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
1549  zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
1550  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
1551  mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
1552  }else {
1553  mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
1554  }
1555  }else{
1556  zbin = fBGHandlerRP[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
1557  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
1558  mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
1559  }else {
1560  mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
1561  }
1562  }
1563  Double_t sparesFill[4] = {mesonCand->M(),mesonCand->Pt(),(Double_t)zbin,(Double_t)mbin};
1564  if (fSparseMotherInvMassPtZM[fiCut]) fSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
1565  }
1566  }
1567  }
1568  delete mesonCand;
1569  mesonCand=0x0;
1570  }
1571  }
1572  }
1573  } else if (fMesonRecoMode == 2){ //CALO-CALO
1574  if(fClusterCandidates->GetEntries()>0){
1575  for(Int_t firstGammaIndex=0;firstGammaIndex<fClusterCandidates->GetEntries();firstGammaIndex++){
1576  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(firstGammaIndex));
1577  if (gamma0==NULL) continue;
1578  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
1579  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
1580  if (gamma1==NULL) continue;
1581 
1582  AliAODConversionMother *mesonCand = new AliAODConversionMother(gamma0,gamma1);
1583  mesonCand->SetLabels(firstGammaIndex,secondGammaIndex);
1584 
1585  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(mesonCand, kTRUE, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), gamma0->GetLeadingCellID(), gamma1->GetLeadingCellID(),gamma0->GetIsCaloPhoton(), gamma1->GetIsCaloPhoton() ))){
1586  if (!gamma0->GetUseForMesonPair() || !gamma1->GetUseForMesonPair()){
1587  fHistoMotherInvMassRejected[fiCut]->Fill(mesonCand->M());
1588  delete mesonCand;
1589  mesonCand=0x0;
1590  continue;
1591  }
1592  if (fHistoMotherInvMassPt[fiCut]) fHistoMotherInvMassPt[fiCut]->Fill(mesonCand->M(),mesonCand->Pt(), fWeightJetJetMC);
1593  // fill new histograms
1594 
1595 
1596 
1597  if(fInputEvent->IsA()==AliESDEvent::Class()){
1598  if(arrClustersMesonCand){
1599  Cluster0 = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMesonCand->At(gamma0->GetCaloClusterRef()));
1600  Cluster1 = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMesonCand->At(gamma1->GetCaloClusterRef()));
1601  }else{
1602  Cluster0 = fInputEvent->GetCaloCluster(gamma0->GetCaloClusterRef());
1603  Cluster1 = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
1604  }
1605  } else if(fInputEvent->IsA()==AliAODEvent::Class()){
1606  if(arrClustersMesonCand){
1607  Cluster0 = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMesonCand->At(gamma0->GetCaloClusterRef()));
1608  Cluster1 = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMesonCand->At(gamma1->GetCaloClusterRef()));
1609  }else{
1610  Cluster0 = fInputEvent->GetCaloCluster(gamma0->GetCaloClusterRef());
1611  Cluster1 = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
1612  }
1613  }
1614 
1615  Double_t tempmesonCandWeight = 1; // for JetJet MC
1616  //Get SM for Cluster0 & Cluster1
1617  Int_t iCellClus0 = Cluster0->GetCellsAbsId()[0];
1618  Int_t iCellClus1 = Cluster1->GetCellsAbsId()[0];
1619  if(TMath::Abs(mesonCand->GetAlpha())<0.1 ){
1620  fHistoMotherInvMassECalib[fiCut]->Fill(mesonCand->M(),mesonCand->E(),tempmesonCandWeight);
1621  if(fGeomEMCAL->GetSuperModuleNumber(iCellClus0) == fGeomEMCAL->GetSuperModuleNumber(iCellClus1)){
1622  fHistoMotherInvMassECalibSM[fiCut][fGeomEMCAL->GetSuperModuleNumber(iCellClus0)]->Fill(mesonCand->M(),mesonCand->E(),tempmesonCandWeight);
1623  }
1624  }
1625 
1626 
1627  if (fDoMesonQA > 0 && fDoMesonQA < 3){
1628  if ( mesonCand->M() > fMesonInvMassWindow[0] && mesonCand->M() < fMesonInvMassWindow[1]){
1629  fHistoMotherMesonPtY[fiCut]->Fill(mesonCand->Pt(),mesonCand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), fWeightJetJetMC);
1630  fHistoMotherMesonPtAlpha[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetAlpha(), fWeightJetJetMC);
1631  fHistoMotherMesonPtOpenAngle[fiCut]->Fill(mesonCand->Pt(),mesonCand->GetOpeningAngle(), fWeightJetJetMC);
1632  }
1633  }
1634  if(fDoTHnSparse && ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
1635  Int_t zbin = 0;
1636  Int_t mbin = 0;
1637 
1638  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
1639  zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
1640  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
1641  mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
1642  } else {
1644  }
1645  }
1646  Double_t sparesFill[4] = {mesonCand->M(),mesonCand->Pt(),(Double_t)zbin,(Double_t)mbin};
1647  if (fSparseMotherInvMassPtZM[fiCut]) fSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
1648  }
1649  }
1650  delete mesonCand;
1651  mesonCand=0x0;
1652  }
1653  }
1654  }
1655  }
1656 }
1657 
1658 
1659 //________________________________________________________________________
1661 
1662  // set current BG handler
1663  AliGammaConversionAODBGHandler* currBGHandler = NULL;
1664  TList* currPhotonList = NULL;
1665  if (fMesonRecoMode == 0){
1666  currBGHandler = fBGHandler[fiCut];
1667  currPhotonList = fGammaCandidates;
1668  } else if (fMesonRecoMode == 1){
1669  currBGHandler = fBGClusHandler[fiCut];
1670  currPhotonList = fGammaCandidates;
1671  } else if (fMesonRecoMode == 2){
1672  currBGHandler = fBGClusHandler[fiCut];
1673  currPhotonList = fClusterCandidates;
1674  }
1675 
1676 
1677  Int_t nMod = -1;
1678  fGeomEMCAL = AliEMCALGeometry::GetInstance();
1679 
1680  Int_t zbin = currBGHandler->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
1681  Int_t mbin = 0;
1682  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
1683  mbin = currBGHandler->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
1684  } else {
1685  mbin = currBGHandler->GetMultiplicityBinIndex(currPhotonList->GetEntries());
1686  }
1687 
1689  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
1690  for(Int_t nEventsInBG=0;nEventsInBG<currBGHandler->GetNBGEvents();nEventsInBG++){
1691  AliGammaConversionAODVector *previousEventV0s = currBGHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);
1692  if (fMesonRecoMode < 2){
1693  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0 ){
1694  bgEventVertex = currBGHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
1695  }
1696  }
1697  for(Int_t iCurrent=0;iCurrent<currPhotonList->GetEntries();iCurrent++){
1698  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(currPhotonList->At(iCurrent));
1699  if (!currentEventGoodV0.GetUseForMesonPair() )continue;
1700  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
1701  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
1702  if(fMoveParticleAccordingToVertex == kTRUE){
1703  if (bgEventVertex){
1704  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
1705  }
1706  }
1707  if (fMesonRecoMode < 2){
1708  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
1709  if (bgEventVertex){
1710  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
1711  }
1712  }
1713  }
1714  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
1715  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
1716  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(backgroundCandidate, kFALSE,
1717  ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()), currentEventGoodV0.GetLeadingCellID(), previousGoodV0.GetLeadingCellID(), currentEventGoodV0.GetIsCaloPhoton(), previousGoodV0.GetIsCaloPhoton())){
1718  if (fHistoMotherBackInvMassPt[fiCut]) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(),fWeightJetJetMC);
1719  // Double_t tempBGCandidateWeight = 1;
1720 
1721  if(fDoTHnSparse){
1722  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
1723  if (fSparseMotherBackInvMassPtZM[fiCut]) fSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
1724  }
1725  }
1726  }
1727  }
1728  }
1729  }else {
1730  for(Int_t nEventsInBG=0;nEventsInBG <currBGHandler->GetNBGEvents();nEventsInBG++){
1731  AliGammaConversionAODVector *previousEventV0s = currBGHandler->GetBGGoodV0s(zbin,mbin,nEventsInBG);
1732  if(previousEventV0s){
1733  if (fMesonRecoMode < 2){
1734  if(fMoveParticleAccordingToVertex == kTRUE || ((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0 ){
1735  bgEventVertex = currBGHandler->GetBGEventVertex(zbin,mbin,nEventsInBG);
1736  }
1737  }
1738  for(Int_t iCurrent=0;iCurrent<currPhotonList->GetEntries();iCurrent++){
1739  AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(currPhotonList->At(iCurrent));
1740  if (!currentEventGoodV0.GetUseForMesonPair() )continue;
1741  for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
1742  AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
1743  if(fMoveParticleAccordingToVertex == kTRUE){
1744  if (bgEventVertex){
1745  MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
1746  }
1747  }
1748  if (fMesonRecoMode < 2){
1749  if(((AliConversionPhotonCuts*)fCutArray->At(fiCut))->GetInPlaneOutOfPlaneCut() != 0){
1750  if (bgEventVertex){
1751  RotateParticleAccordingToEP(&previousGoodV0,bgEventVertex->fEP,fEventPlaneAngle);
1752  }
1753  }
1754  }
1755  AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
1756  backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
1757  if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE,
1758  ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()), currentEventGoodV0.GetLeadingCellID(), previousGoodV0.GetLeadingCellID(), currentEventGoodV0.GetIsCaloPhoton(), previousGoodV0.GetIsCaloPhoton())){
1759  if (fHistoMotherBackInvMassPt[fiCut]) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt(),fWeightJetJetMC);
1760 
1761  if( currentEventGoodV0.GetIsCaloPhoton() > 0 && previousGoodV0.GetIsCaloPhoton() > 0 ){
1762  if( TMath::Abs(backgroundCandidate->GetAlpha())<0.1){
1763  fHistoMotherBackInvMassECalib[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->E(),fWeightJetJetMC);
1764  if(fGeomEMCAL->GetSuperModuleNumber(currentEventGoodV0.GetLeadingCellID()) == fGeomEMCAL->GetSuperModuleNumber(previousGoodV0.GetLeadingCellID())){
1765  nMod = fGeomEMCAL->GetSuperModuleNumber(currentEventGoodV0.GetLeadingCellID());
1766  fHistoMotherBackInvMassECalibSM[fiCut][nMod]->Fill(backgroundCandidate->M(),backgroundCandidate->E(),fWeightJetJetMC);
1767  }
1768  }
1769  } else{
1770  if( currentEventGoodV0.GetIsCaloPhoton() > 0 ){
1771  nMod = fGeomEMCAL->GetSuperModuleNumber(currentEventGoodV0.GetLeadingCellID());
1772  fHistoMotherBackInvMassECalibSM[fiCut][nMod]->Fill(backgroundCandidate->M(),currentEventGoodV0.E(),fWeightJetJetMC);
1773  fHistoMotherBackInvMassECalib[fiCut]->Fill(backgroundCandidate->M(),currentEventGoodV0.E(),fWeightJetJetMC);
1774  }
1775  else if(previousGoodV0.GetIsCaloPhoton() > 0){
1776  nMod = fGeomEMCAL->GetSuperModuleNumber(previousGoodV0.GetLeadingCellID());
1777  fHistoMotherBackInvMassECalibSM[fiCut][nMod]->Fill(backgroundCandidate->M(),previousGoodV0.E(),fWeightJetJetMC);
1778  fHistoMotherBackInvMassECalib[fiCut]->Fill(backgroundCandidate->M(),previousGoodV0.E(),fWeightJetJetMC);
1779  }
1780  }
1781 
1782 
1783 
1784  if(fDoTHnSparse){
1785  Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
1786  if (fSparseMotherBackInvMassPtZM[fiCut]) fSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
1787  }
1788  }
1789  delete backgroundCandidate;
1790  backgroundCandidate = 0x0;
1791  }
1792  }
1793  }
1794  }
1795  }
1796 }
1797 
1798 //________________________________________________________________________
1800 
1801  // set current BG handler
1802  AliConversionAODBGHandlerRP* currBGHandler = NULL;
1803  TList* currPhotonList = NULL;
1804  if (fMesonRecoMode == 0){
1805  currBGHandler = fBGHandlerRP[fiCut];
1806  currPhotonList = fGammaCandidates;
1807  } else if (fMesonRecoMode == 1){
1808  currBGHandler = fBGClusHandlerRP[fiCut];
1809  currPhotonList = fGammaCandidates;
1810  } else if (fMesonRecoMode == 2){
1811  currBGHandler = fBGClusHandlerRP[fiCut];
1812  currPhotonList = fClusterCandidates;
1813  }
1814 
1815  Int_t zbin = currBGHandler->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
1816  Int_t mbin = 0;
1817  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
1818  mbin = currBGHandler->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
1819  } else {
1820  mbin = currBGHandler->GetMultiplicityBinIndex(currPhotonList->GetEntries());
1821  }
1822 
1823  //Rotation Method
1824  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseRotationMethod()){
1825  // Correct for the number of rotations
1826  // BG is for rotation the same, except for factor NRotations
1827  Double_t weight=1./Double_t(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents());
1828  for(Int_t firstGammaIndex=0;firstGammaIndex<currPhotonList->GetEntries();firstGammaIndex++){
1829  AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(currPhotonList->At(firstGammaIndex));
1830  if (gamma0==NULL) continue;
1831  if (!gamma0->GetUseForMesonPair() ) continue;
1832  for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<currPhotonList->GetEntries();secondGammaIndex++){
1833  AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(currPhotonList->At(secondGammaIndex));
1834  if (gamma1 == NULL) continue;
1835  if (!gamma1->GetUseForMesonPair() ) continue;
1836  if(!((AliConversionPhotonCuts*)fCutArray->At(fiCut))->PhotonIsSelected(gamma1,fInputEvent))continue;
1837  for(Int_t nRandom=0;nRandom<((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents();nRandom++){
1838  RotateParticle(gamma1);
1839  AliAODConversionMother backgroundCandidate(gamma0,gamma1);
1840  backgroundCandidate.CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
1841  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(&backgroundCandidate, kFALSE, ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(), gamma0->GetLeadingCellID(), gamma1->GetLeadingCellID(), gamma0->GetIsCaloPhoton(), gamma1->GetIsCaloPhoton())){
1842  if (fHistoMotherBackInvMassPt[fiCut]) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt(),fWeightJetJetMC);
1843  if(fDoTHnSparse){
1844  Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)mbin};
1845  if (fSparseMotherBackInvMassPtZM[fiCut]) fSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,weight);
1846  }
1847  }
1848  }
1849  }
1850  }
1851 
1852  }else {
1853  // Do Event Mixing
1854  for(Int_t nEventsInBG=0;nEventsInBG <currBGHandler->GetNBGEvents(currPhotonList,fInputEvent);nEventsInBG++){
1855  AliGammaConversionPhotonVector *previousEventGammas = currBGHandler->GetBGGoodGammas(currPhotonList,fInputEvent,nEventsInBG);
1856  if(previousEventGammas){
1857  // test weighted background
1858  Double_t weight=1.0;
1859  // Correct for the number of eventmixing:
1860  // N gammas -> (N-1) + (N-2) +(N-3) ...+ (N-(N-1)) using sum formula sum(i)=N*(N-1)/2 -> N*(N-1)/2
1861  // real combinations (since you cannot combine a photon with its own)
1862  // but BG leads to N_{a}*N_{b}combinations
1863  weight*=0.5*(Double_t(currPhotonList->GetEntries()-1))/Double_t(previousEventGammas->size());
1864 
1865  for(Int_t iCurrent=0;iCurrent<currPhotonList->GetEntries();iCurrent++){
1866  AliAODConversionPhoton *gamma0 = (AliAODConversionPhoton*)(currPhotonList->At(iCurrent));
1867  if (!gamma0->GetUseForMesonPair() ) continue;
1868  for(UInt_t iPrevious=0;iPrevious<previousEventGammas->size();iPrevious++){
1869  AliAODConversionPhoton *gamma1 = (AliAODConversionPhoton*)(previousEventGammas->at(iPrevious));
1870  AliAODConversionMother backgroundCandidate(gamma0,gamma1);
1871  backgroundCandidate.CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
1872  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))
1873  ->MesonIsSelected(&backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift(),gamma0->GetLeadingCellID(), gamma1->GetLeadingCellID(), gamma0->GetIsCaloPhoton(), gamma1->GetIsCaloPhoton())){
1874  if (fHistoMotherBackInvMassPt[fiCut]) fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate.M(),backgroundCandidate.Pt(),fWeightJetJetMC);
1875  if(fDoTHnSparse){
1876  Double_t sparesFill[4] = {backgroundCandidate.M(),backgroundCandidate.Pt(),(Double_t)zbin,(Double_t)mbin};
1877  if (fSparseMotherBackInvMassPtZM[fiCut]) fSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,weight);
1878  }
1879  }
1880  }
1881  }
1882  }
1883  }
1884  }
1885 }
1886 
1887 //________________________________________________________________________
1888 void AliAnalysisTaskConvCaloCalibration::RotateParticle(AliAODConversionPhoton *gamma){
1889  Int_t fNDegreesPMBackground= ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->NDegreesRotation();
1890  Double_t nRadiansPM = fNDegreesPMBackground*TMath::Pi()/180;
1891  Double_t rotationValue = fRandom.Rndm()*2*nRadiansPM + TMath::Pi()-nRadiansPM;
1892  gamma->RotateZ(rotationValue);
1893 }
1894 
1895 //________________________________________________________________________
1896 void AliAnalysisTaskConvCaloCalibration::RotateParticleAccordingToEP(AliAODConversionPhoton *gamma, Double_t previousEventEP, Double_t thisEventEP){
1897  previousEventEP=previousEventEP+TMath::Pi();
1898  thisEventEP=thisEventEP+TMath::Pi();
1899  Double_t rotationValue= thisEventEP-previousEventEP;
1900  gamma->RotateZ(rotationValue);
1901 }
1902 
1903 //________________________________________________________________________
1905  //see header file for documentation
1906 
1907  Double_t dx = vertex->fX - fInputEvent->GetPrimaryVertex()->GetX();
1908  Double_t dy = vertex->fY - fInputEvent->GetPrimaryVertex()->GetY();
1909  Double_t dz = vertex->fZ - fInputEvent->GetPrimaryVertex()->GetZ();
1910 
1911  Double_t movedPlace[3] = {particle->GetConversionX() - dx,particle->GetConversionY() - dy,particle->GetConversionZ() - dz};
1912  particle->SetConversionPoint(movedPlace);
1913 }
1914 //________________________________________________________________________
1916  //see header file for documentation
1917  if(fGammaCandidates->GetEntries() >1 && fMesonRecoMode == 0 ){
1918  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
1919  fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
1920  fV0Reader->GetNumberOfPrimaryTracks(), fEventPlaneAngle);
1921  }else { // means we use #V0s for multiplicity
1922  fBGHandler[fiCut]->AddEvent(fGammaCandidates, fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
1923  fGammaCandidates->GetEntries(), fEventPlaneAngle);
1924  }
1925  } else if((fGammaCandidates->GetEntries() >0 || fClusterCandidates->GetEntries() > 0 ) && fMesonRecoMode == 1 ){
1926  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
1927  fBGHandler[fiCut]->AddEvent(fGammaCandidates,fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
1928  fV0Reader->GetNumberOfPrimaryTracks(), fEventPlaneAngle);
1929  fBGClusHandler[fiCut]->AddEvent(fClusterCandidates,fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
1930  fV0Reader->GetNumberOfPrimaryTracks(), fEventPlaneAngle);
1931  }else { // means we use #V0s for multiplicity
1932  fBGHandler[fiCut]->AddEvent(fGammaCandidates, fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
1933  fGammaCandidates->GetEntries(), fEventPlaneAngle);
1934  fBGClusHandler[fiCut]->AddEvent(fClusterCandidates, fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
1935  fGammaCandidates->GetEntries(), fEventPlaneAngle);
1936  }
1937  } else if(fClusterCandidates->GetEntries() >1 && fMesonRecoMode == 2 ){
1938  if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
1939  fBGClusHandler[fiCut]->AddEvent(fClusterCandidates,fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
1940  fV0Reader->GetNumberOfPrimaryTracks(), fEventPlaneAngle);
1941  }else { // means we use #V0s for multiplicity
1942  fBGClusHandler[fiCut]->AddEvent(fClusterCandidates, fInputEvent->GetPrimaryVertex()->GetX(), fInputEvent->GetPrimaryVertex()->GetY(), fInputEvent->GetPrimaryVertex()->GetZ(),
1943  fClusterCandidates->GetEntries(), fEventPlaneAngle);
1944  }
1945  }
1946 }
1947 
1948 //________________________________________________________________________
1950 
1951  // Relabeling For AOD Event
1952  // ESDiD -> AODiD
1953  // MCLabel -> AODMCLabel
1954 
1955  if(mode){
1956  fMCEventPos = new Int_t[fReaderGammas->GetEntries()];
1957  fMCEventNeg = new Int_t[fReaderGammas->GetEntries()];
1958  fESDArrayPos = new Int_t[fReaderGammas->GetEntries()];
1959  fESDArrayNeg = new Int_t[fReaderGammas->GetEntries()];
1960  }
1961 
1962  for(Int_t iGamma = 0;iGamma<fReaderGammas->GetEntries();iGamma++){
1963  AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(iGamma);
1964  if(!PhotonCandidate) continue;
1965  if(!mode){// Back to ESD Labels
1966  PhotonCandidate->SetMCLabelPositive(fMCEventPos[iGamma]);
1967  PhotonCandidate->SetMCLabelNegative(fMCEventNeg[iGamma]);
1968  PhotonCandidate->SetLabelPositive(fESDArrayPos[iGamma]);
1969  PhotonCandidate->SetLabelNegative(fESDArrayNeg[iGamma]);
1970  continue;
1971  }
1972  fMCEventPos[iGamma] = PhotonCandidate->GetMCLabelPositive();
1973  fMCEventNeg[iGamma] = PhotonCandidate->GetMCLabelNegative();
1974  fESDArrayPos[iGamma] = PhotonCandidate->GetTrackLabelPositive();
1975  fESDArrayNeg[iGamma] = PhotonCandidate->GetTrackLabelNegative();
1976 
1977  Bool_t AODLabelPos = kFALSE;
1978  Bool_t AODLabelNeg = kFALSE;
1979 
1980  for(Int_t i = 0; i<fInputEvent->GetNumberOfTracks();i++){
1981  AliAODTrack *tempDaughter = static_cast<AliAODTrack*>(fInputEvent->GetTrack(i));
1982  if(!AODLabelPos){
1983  if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelPositive() ){
1984  PhotonCandidate->SetMCLabelPositive(TMath::Abs(tempDaughter->GetLabel()));
1985  PhotonCandidate->SetLabelPositive(i);
1986  AODLabelPos = kTRUE;
1987  }
1988  }
1989  if(!AODLabelNeg){
1990  if( tempDaughter->GetID() == PhotonCandidate->GetTrackLabelNegative()){
1991  PhotonCandidate->SetMCLabelNegative(TMath::Abs(tempDaughter->GetLabel()));
1992  PhotonCandidate->SetLabelNegative(i);
1993  AODLabelNeg = kTRUE;
1994  }
1995  }
1996  if(AODLabelNeg && AODLabelPos){
1997  break;
1998  }
1999  }
2000  if(!AODLabelPos || !AODLabelNeg){
2001  cout<<"WARNING!!! AOD TRACKS NOT FOUND FOR"<<endl;
2002  if(!AODLabelNeg){
2003  PhotonCandidate->SetMCLabelNegative(-999999);
2004  PhotonCandidate->SetLabelNegative(-999999);
2005  }
2006  if(!AODLabelPos){
2007  PhotonCandidate->SetMCLabelPositive(-999999);
2008  PhotonCandidate->SetLabelPositive(-999999);
2009  }
2010  }
2011  }
2012 
2013  if(!mode){
2014  delete[] fMCEventPos;
2015  delete[] fMCEventNeg;
2016  delete[] fESDArrayPos;
2017  delete[] fESDArrayNeg;
2018  }
2019 }
2020 
2021 //________________________________________________________________________
2023  TAxis *axisafter = histoRebin->GetXaxis();
2024  Int_t bins = axisafter->GetNbins();
2025  Double_t from = axisafter->GetXmin();
2026  Double_t to = axisafter->GetXmax();
2027  Double_t *newbins = new Double_t[bins+1];
2028  newbins[0] = from;
2029  Double_t factor = TMath::Power(to/from, 1./bins);
2030  for(Int_t i=1; i<=bins; ++i) newbins[i] = factor * newbins[i-1];
2031  axisafter->Set(bins, newbins);
2032  delete [] newbins;
2033 }
2034 
2035 //________________________________________________________________________
2037 {
2038  //fOutputContainer->Print(); // Will crash on GRID
2039 }
2040 
2041 //_________________________________________________________________________________
2043  if(tobechecked > -1){
2044  vector<Int_t>::iterator it;
2045  it = find (vec.begin(), vec.end(), tobechecked);
2046  if (it != vec.end()) return true;
2047  else return false;
2048  }
2049  return false;
2050 }
2051 
2052 //_________________________________________________________________________________
2054  if(tobechecked > -1){
2055  vector<Int_t>::iterator it;
2056  it = find (vec.begin(), vec.end(), tobechecked);
2057  if (it != vec.end()) return true;
2058  else{
2059  vec.push_back(tobechecked);
2060  return false;
2061  }
2062  }
2063  return false;
2064 }
2065 
2066 //_________________________________________________________________________________
2067 void AliAnalysisTaskConvCaloCalibration::FillMultipleCountMap(map<Int_t,Int_t> &ma, Int_t tobechecked){
2068  if( ma.find(tobechecked) != ma.end() ) ma[tobechecked] += 1;
2069  else ma[tobechecked] = 2;
2070  return;
2071 }
2072 
2073 //_________________________________________________________________________________
2075  map<Int_t, Int_t>::iterator it;
2076  for (it = ma.begin(); it != ma.end(); it++){
2077  hist->Fill(it->second, fWeightJetJetMC);
2078  }
2079  ma.clear();
2080  return;
2081 }
TH1F ** fHistoClusGammaE
array of histos with cluster, pt
TH1F ** fHistoNV0Tracks
array of histos with number of calo gamma candidates per event
AliGammaConversionAODBGHandler ** fBGClusHandler
double Double_t
Definition: External.C:58
TH1F ** fHistoNGammaConvCandidates
array of histos with vertex y distribution for selected events
GammaConversionVertex * GetBGEventVertex(Int_t zbin, Int_t mbin, Int_t event)
Definition: External.C:236
void FillMultipleCountMap(map< Int_t, Int_t > &ma, Int_t tobechecked)
TList * fClusterCandidates
current list of photon candidates
void FillMultipleCountHistoAndClear(map< Int_t, Int_t > &ma, TH1F *hist)
TH1F ** fHistoVertexX
array of histos with vertex z distribution for selected events
TProfile ** fProfileJetJetXSection
array of profiles with eta shift
TH1F ** fHistoVertexY
array of histos with vertex x distribution for selected events
TH1F *** fHistoClusGammaESM
array of histos with cluster, pt
Bool_t CheckVectorOnly(vector< Int_t > &vec, Int_t tobechecked)
TH1F ** fHistoNEvents
array of histos with invariant mass pairs which were rejected
void RotateParticle(AliAODConversionPhoton *gamma)
TH2F ** fHistoMotherMesonPtAlpha
array of histograms with invariant mass cut around nominal mass, pt, Y
TProfile ** fProfileEtaShift
array of histos with mixed event background with alpha < 0.1 for NonLin
TH2F ** fHistoMotherMatchedInvMassPt
array of histogram with signal + BG for same event photon pairs, inv Mass, pt
TH1F ** fHistoConvGammaPt
array of profiles with xsection for jetjet
std::vector< AliAODConversionPhoton * > AliGammaConversionAODVector
TH1F ** fHistoMotherInvMassRejected
array of histos with cluster, E
TH2F ** fHistoMotherMesonConvPhotonEtaPhi
array of histograms with invariant mass cut around nominal mass, pt, openAngle
int Int_t
Definition: External.C:63
TH1F ** fHistoNGammaCaloCandidates
array of histos with number of conversion gamma candidates per event
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
TH1F ** fHistoClusGammaPt
array of histogram conversion photon pT
void AddEvent(TList *const eventGammas, Double_t xvalue, Double_t yvalue, Double_t zvalue, Int_t multiplicity, Double_t epvalue=-100)
TH1F ** fHistoVertexZ
array of histos with number of good tracks (2010 Standard track cuts)
TH1F ** fHistoNEventsWOWeight
array of histos with event information
TH2F ** fHistoMotherMesonPtY
array of histogram with BG for mixed event photon pairs, inv Mass, pt
void MoveParticleAccordingToVertex(AliAODConversionPhoton *particle, const AliGammaConversionAODBGHandler::GammaConversionVertex *vertex)
Int_t mode
Definition: anaM.C:41
TH2F ** fHistoMotherBackInvMassECalib
array of histos with signal + background with alpha < 0.1 for NonLin
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)
TList * fEventCutArray
current list of cluster candidates
short Short_t
Definition: External.C:23
THnSparseF ** fSparseMotherBackInvMassPtZM
array of THnSparseF with signal + BG for same event photon pairs, inv Mass, pt
Double_t centMax
TH2F *** fHistoMotherInvMassECalibSM
array of histos for SPD Cluster vs Tracklet plot for pileup monitoring
TH2F ** fHistoSPDClusterTrackletBackground
array of histograms with invariant mass cut around nominal mass ,eta/phi of conversion photon ...
AliGammaConversionAODVector * GetBGGoodV0s(Int_t zbin, Int_t mbin, Int_t event)
TH2F ** fHistoMotherMesonPtOpenAngle
array of histograms with invariant mass cut around nominal mass, pt, alpha
Definition: External.C:220
TH1F *** fHistoClusGammaPtSM
array of histos with cluster, E
Bool_t CheckVectorForDoubleCount(vector< Int_t > &vec, Int_t tobechecked)
TH1F ** fHistoJetJetNTrials
array of histos with V0 counts
void RotateParticleAccordingToEP(AliAODConversionPhoton *gamma, Double_t previousEventEP, Double_t thisEventEP)
const char Option_t
Definition: External.C:48
TH2F ** fHistoMotherBackInvMassPt
array of histogram with signal + BG for same event photon pairs, inv Mass, pt
TH1F ** fHistoNGoodESDTracks
array of histos with event information without event weights
bool Bool_t
Definition: External.C:53
TH2F ** fHistoMotherInvMassECalib
array of histos with mixed event background with alpha < 0.1 for NonLin for every Supermodule ...
TH2F *** fHistoMotherBackInvMassECalibSM
array of histos with signal + background with alpha < 0.1 for NonLin for every Supermodule ...
Double_t centMin