macro to plot ouput file from QA analysis wagon
authorgconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 22 Nov 2013 13:09:32 +0000 (13:09 +0000)
committergconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 22 Nov 2013 13:09:32 +0000 (13:09 +0000)
PWGGA/CaloTrackCorrelations/macros/QA/DrawAnaCaloTrackQA.C [new file with mode: 0644]

diff --git a/PWGGA/CaloTrackCorrelations/macros/QA/DrawAnaCaloTrackQA.C b/PWGGA/CaloTrackCorrelations/macros/QA/DrawAnaCaloTrackQA.C
new file mode 100644 (file)
index 0000000..a630777
--- /dev/null
@@ -0,0 +1,606 @@
+///////////////////////////////////////////
+//
+// Macro to plot few selected histograms
+// to QA data productions at 0th order
+// Analysis performed with the wagon
+// AddTaskPi0IMGammaCorrQA.C
+// It generates 5 eps plots, each containing 2 to 4 canvases
+//
+// To execute: root -q -b -l DrawAnaCaloTrackQA.C'("Pi0IM_GammaTrackCorr_EMCAL_default","AnalysisResults.root")'
+// The input list name might change depending on the wagon / data type
+// In case output file is too large, possiblity to dump the list content in a sepate file:  export = kTRUE
+//
+// Author: Gustavo.Conesa.Balbastre@cern.ch
+//
+//
+
+// Some global variables
+TList *list = 0;
+TFile *file = 0;
+TString histoTag = "";
+Int_t color[]={kBlack,kRed,kOrange+1,kYellow+1,kGreen+2,kBlue,kCyan+1,kViolet,kMagenta+2,kGray};
+
+//_______________________________________________________________________
+void DrawAnaCaloTrackQA(TString listName = "Pi0IM_GammaTrackCorr_EMCAL_default",
+                        TString fileName = "AnalysisResultsQATrain.root",
+                        Bool_t export = kFALSE)
+{
+
+  printf("Open <%s>; Get List : <%s>; Export list? <%d>\n",fileName.Data(),listName.Data(),export);
+  
+  histoTag = listName;
+  
+  //Access the file and list of histograms, global variables
+  GetFileAndList(fileName, listName, export);
+  
+  gStyle->SetOptTitle(1);
+  gStyle->SetOptStat(0);
+  gStyle->SetOptFit(000000);
+  gStyle->SetPadRightMargin(0.15);
+  //gStyle->SetPadTopMargin(0.02);
+  //gStyle->SetPadLeftMargin(0.15);
+  gStyle->SetTitleFontSize(0.06);
+
+  //Plot basic Calorimeter QA
+  CaloQA();
+
+  //Plot basic Track QA
+  TrackQA();
+
+  //Plot basic Pi0 QA
+  Pi0QA();
+
+  //Plot basic correlation QA
+  CorrelationQA();
+  
+}
+
+//___________
+void CaloQA()
+{
+  // Basic calorimeter QA histograms
+  
+  TCanvas * ccalo = new TCanvas(Form("CaloHisto_%s",histoTag.Data()),"",1000,1000);
+  ccalo->Divide(2,2);
+  
+  ccalo->cd(1);
+  gPad->SetLogy();
+  
+  TH1F* hCellAmplitude = (TH1F*) GetHisto("QA_hAmplitude");
+  TH1F* hClusterEnergy = (TH1F*) GetHisto("QA_hE");
+  
+  hClusterEnergy->SetTitle("Cluster-cell energy spectra");
+  hClusterEnergy->Sumw2();
+  hClusterEnergy->SetMarkerColor(1);
+  hClusterEnergy->SetMarkerStyle(20);
+  hClusterEnergy->SetAxisRange(0.,50.,"X");
+  hClusterEnergy->Draw();
+  
+  hCellAmplitude->Sumw2();
+  hCellAmplitude->SetMarkerColor(4);
+  hCellAmplitude->SetMarkerStyle(25);
+  hCellAmplitude->Draw("same");
+  
+  TLegend l(0.3,0.7,0.83,0.85);
+  l.SetTextSize(0.04);
+  l.AddEntry(hClusterEnergy,"Cluster (no exotic+non lin)","P");
+  l.AddEntry(hCellAmplitude,"Cell","P");
+  l.SetBorderSize(0);
+  l.SetFillColor(0);
+  l.Draw();
+  
+  
+  ccalo->cd(2);
+  //gPad->SetLogy();
+  
+  TH1F* hRaw  = (TH1F*) GetHisto("AnaPhoton_hCut_0_Open");
+  TH1F* hCorr = (TH1F*) GetHisto("AnaPhoton_hCut_4_NCells");
+  TH1F* hTM   = (TH1F*) GetHisto("AnaPhoton_hCut_7_Matching");
+  TH1F* hShSh = (TH1F*) GetHisto("AnaPhoton_hCut_9_PID");
+  
+  hRaw->Sumw2();
+  
+  hCorr->SetTitle("Ratio after cluster cuts application");
+  hCorr->SetYTitle("Selected clusters / Raw clusters");
+  hCorr->SetTitleOffset(1.5,"Y");
+  hCorr->Sumw2();
+  hCorr->SetMarkerColor(1);
+  hCorr->SetMarkerStyle(20);
+  hCorr->Divide(hRaw);
+  hCorr->SetAxisRange(0.,30.,"X");
+  hCorr->SetMaximum(1);
+  hCorr->SetMinimum(0);
+  hCorr->Draw();
+  
+  hTM  ->Sumw2();
+  hTM  ->SetMarkerColor(2);
+  hTM  ->SetMarkerStyle(21);
+  hTM  ->Divide(hRaw);
+  hTM  ->Draw("same");
+  
+  hShSh->Sumw2();
+  hShSh->SetMarkerColor(4);
+  hShSh->SetMarkerStyle(22);
+  hShSh->Divide(hRaw);
+  hShSh->Draw("same");
+  
+  TLegend l2(0.3,0.7,0.83,0.85);
+  l2.SetTextSize(0.04);
+  l2.AddEntry(hCorr,"No Exotics + non linearity","P");
+  l2.AddEntry(hTM,  "+ Track matching","P");
+  l2.AddEntry(hShSh,"+ #lambda^{2}_{0} < 0.4","P");
+  l2.SetBorderSize(0);
+  l2.SetFillColor(0);
+  l2.Draw();
+  
+  
+  ccalo->cd(3);
+  gPad->SetLogz();
+  
+  TH2F* hClusterTime   = (TH2F*) GetHisto("QA_hClusterTimeEnergy");
+  hClusterTime->SetTitle("Cluster energy vs time");
+  hClusterTime->SetYTitle("time (ns)");
+  hClusterTime->SetAxisRange(300.,900.,"Y");
+  hClusterTime->SetAxisRange(0.,30.,"X");
+  hClusterTime->SetTitleOffset(1.5,"Y");
+  
+  hClusterTime->Draw("colz");
+  
+  ccalo->cd(4);
+  gPad->SetLogz();
+  
+  TH2F* hClusterM02   = (TH2F*) GetHisto("AnaPhoton_hLam0E");
+  hClusterM02->SetTitle("Cluster energy vs #lambda^{2}_{0}");
+  //hClusterM02->SetAxisRange(300.,900.,"Y");
+  hClusterM02->SetAxisRange(0.,30.,"X");
+  hClusterM02->SetTitleOffset(1.5,"Y");
+  hClusterM02->Draw("colz");
+  
+  ccalo->Print(Form("%s_CaloHisto.eps",histoTag.Data()));
+  
+  
+  TCanvas * ccalo2 = new TCanvas(Form("CaloHisto2_%s",histoTag.Data()),"",500,500);
+  ccalo2->Divide(2,2);
+  
+  ccalo2->cd(1);
+  gPad->SetLogz();
+  TH2F* hCellAmpId   = (TH2F*) GetHisto("QA_hAmpId");
+  hCellAmpId->SetTitle("Cell Id vs energy");
+  hCellAmpId->SetYTitle("Cell Id");
+  //hCellAmpId->SetAxisRange(300.,900.,"Y");
+  hCellAmpId->SetAxisRange(0.,30.,"X");
+  hCellAmpId->SetTitleOffset(1.5,"Y");
+  hCellAmpId->Draw("colz");
+  
+  ccalo2->cd(2);
+  
+  TH2F* hCellActivity  = (TH2F*) GetHisto("QA_hGridCells");
+  hCellActivity->SetTitle("Hits per cell (E > 0.2 GeV)");
+  hCellActivity->SetTitleOffset(1.5,"Y");
+  hCellActivity->Draw("colz");
+  
+  ccalo2->cd(3);
+  
+  TH2F* hCellActivity  = (TH2F*) GetHisto("QA_hGridCells");
+  TH2F* hCellActivityE = (TH2F*) GetHisto("QA_hGridCellsE");
+  hCellActivityE->SetTitle("Mean energy per cell (E > 0.2 GeV)");
+  hCellActivityE->Divide(hCellActivity);
+  hCellActivityE->SetTitleOffset(1.5,"Y");
+  hCellActivityE->Draw("colz");
+  
+  ccalo2->cd(4);
+  //gPad->SetLogz();
+  TH2F* hClusterActivity  = (TH2F*) GetHisto("AnaPhoton_hEtaPhi");
+  hClusterActivity->SetTitle("Clusters activity (E > 0.5 GeV)");
+  hClusterActivity->SetTitleOffset(1.5,"Y");
+  hClusterActivity->Draw("colz");
+  
+  ccalo2->Print(Form("%s_CaloHisto2.eps",histoTag.Data()));
+  
+}
+
+//____________
+void TrackQA()
+{
+  // Basic hybrid tracks histograms
+  
+  TCanvas * ctrack = new TCanvas(Form("TrackHisto_%s",histoTag.Data()),"",1000,500);
+  ctrack->Divide(2,1);
+  
+  ctrack->cd(1);
+  //gPad->SetLogz();
+  TH2F * hTrackEtaPhi = (TH2F*) GetHisto("AnaHadrons_hEtaPhiNegative");
+  hTrackEtaPhi ->Add((TH2F*) GetHisto("AnaHadrons_hEtaPhiNegative"));
+  hTrackEtaPhi ->SetAxisRange(-0.9,0.9,"X");
+  hTrackEtaPhi ->SetTitle("Hybrid tracks #eta vs #phi (p_{T} > 0.2 GeV)");
+  hTrackEtaPhi ->Draw("colz");
+  
+  ctrack->cd(2);
+  //gPad->SetLogy();
+  TH2F * hTrackEtaPhiSPD   = (TH2F*) GetHisto("AnaHadrons_hEtaPhiSPDRefitPt02");
+  TH2F * hTrackEtaPhiNoSPD = (TH2F*) GetHisto("AnaHadrons_hEtaPhiNoSPDRefitPt02");
+  
+  TH1F* hPhiSPD   = (TH1F*)hTrackEtaPhiSPD  ->ProjectionY("hTrackPhiSPD"  ,0,1000);
+  TH1F* hPhiNoSPD = (TH1F*)hTrackEtaPhiNoSPD->ProjectionY("hTrackPhiNoSPD",0,1000);
+  //TH1F* hPhi      = (TH1F*)hTrackEtaPhi     ->ProjectionY("hTrackPhi"     ,0,1000);
+  TH1F* hPhi      = hPhiSPD->Clone("hTrackPhi");
+  hPhi->Add(hPhiNoSPD);
+  hPhi     ->SetTitle("Hybrid track in #phi, composition, p_{T} > 0.2 GeV");
+  hPhi     ->SetLineColor(1);
+  hPhiSPD  ->SetLineColor(2);
+  hPhiNoSPD->SetLineColor(4);
+  
+  hPhi     ->SetMinimum(1);
+  
+  hPhi     ->Draw();
+  hPhiSPD  ->Draw("same");
+  hPhiNoSPD->Draw("same");
+  
+  TLegend l(0.12,0.8,0.4,0.9);
+  l.SetTextSize(0.04);
+  l.AddEntry(hPhi,"Sum","L");
+  l.AddEntry(hPhiSPD  ,"SPD+Refit","L");
+  l.AddEntry(hPhiNoSPD,"No SPD+Refit","L");
+  l.SetBorderSize(0);
+  l.SetFillColor(0);
+  l.Draw();
+//  ctrack->cd(3);
+//  gPad->SetLogz();
+//  
+//  TH2F* hPtDCAxy = (TH2F*) GetHisto("AnaHadrons_hPtDCAxy");
+//  hPtDCAxy->SetAxisRange(-1,1,"Y");
+//  hPtDCAxy->SetAxisRange(0,30,"X");
+//  hPtDCAxy->Draw("colz");
+//  
+//  ctrack->cd(4);
+//  gPad->SetLogz();
+//  
+//  TH2F* hPtDCAz = (TH2F*) GetHisto("AnaHadrons_hPtDCAz");
+//  hPtDCAz->SetAxisRange(-1,1,"Y");
+//  hPtDCAz->SetAxisRange(0,30,"X");
+//  hPtDCAz->Draw("colz");
+  
+  ctrack->Print(Form("%s_TrackHisto.eps",histoTag.Data()));
+  
+}
+
+//__________
+void Pi0QA()
+{
+  // Basic invariant mass QA
+  
+  TCanvas * cpi0 = new TCanvas(Form("Pi0Histo_%s",histoTag.Data()),"",500,500);
+  cpi0->Divide(2,2);
+  
+  TH2F* hMassE[10];
+  TH2F* hMixMassE[10];
+  for(Int_t icen = 0; icen < 10; icen++)
+  {
+    hMassE   [icen] = (TH2F*) GetHisto(Form("AnaPi0_hRe_cen%d_pidbit0_asy1_dist1",icen));
+    hMixMassE[icen] = (TH2F*) GetHisto(Form("AnaPi0_hMi_cen%d_pidbit0_asy1_dist1",icen));
+  }
+  
+  // 2D Invariant mass vs E, in PbPb from 60 to 100 %, all in pp
+  cpi0->cd(1);
+  gPad->SetLogz();
+  TH2F* h2DMass;
+  
+  if(hMassE[1]) // Plot centrality from 60 to 100%
+  {
+    h2DMass = (TH2F*) hMassE[6]->Clone("h2DMass");
+    for(Int_t icen = 7; icen < 10; icen++) h2DMass->Add(hMassE[icen]);
+    h2DMass->SetTitle("Invariant mass vs pair E, Cen: 60-100%");
+  }
+  else
+  {
+    h2DMass->SetTitle("Invariant mass vs cluster pair E");
+    h2DMass = hMassE[0];
+  }
+  
+  h2DMass->SetTitleOffset(1.6,"Y");
+  h2DMass->SetAxisRange(0.0,0.7,"Y");
+  h2DMass->SetAxisRange(0,30,"X");
+  h2DMass->Draw("colz");
+  
+  // Pi0 Invariant mass projection, in PbPb 6 centrality bins from 0 to 50%, all in pp
+  cpi0->cd(2);
+  TH1F* hMass[10];
+  TH1F* hMix [10];
+  TH1F* hMassEta[10];
+  TH1F* hMassPi0[10];
+  
+  TH1F * hX = (TH1F*) hMassE[0]->ProjectionX("hEPairCen0",0,10000);
+  Int_t binmin = hX->FindBin(2);  // Project histo from 2 GeV pairs
+  Int_t binmax = hX->FindBin(10); // Project histo up to 10 GeV pairs
+  for(Int_t icen = 0; icen < 6; icen++)
+  {
+    if(!hMassE[icen]) continue;
+    
+    hMass[icen] = (TH1F*) hMassE   [icen]->ProjectionY(Form("hMassCen%d",icen),binmin,binmax);
+    hMix [icen] = (TH1F*) hMixMassE[icen]->ProjectionY(Form("hMixCen%d" ,icen),binmin,binmax);
+    hMass[icen]->Sumw2();
+    hMix [icen]->Sumw2();
+    
+    hMassPi0[icen] = (TH1F*) hMass[icen]->Clone(Form("hMassPi0Cen%d",icen));
+    hMassEta[icen] = (TH1F*) hMass[icen]->Clone(Form("hMassEtaCen%d",icen));
+    
+    hMassPi0[icen]->Divide(hMix[icen]);
+    hMassPi0[icen]->Fit("pol0","Q","",0.25,0.35);
+    Float_t scale = 1;
+    if(hMassPi0[icen]->GetFunction("pol0")) scale = hMassPi0[icen]->GetFunction("pol0")->GetParameter(0);
+    //printf("Scale factor %f for cen %d\n",scale,icen);
+    hMassPi0[icen]->Scale(1./scale);
+    hMassPi0[icen]->SetMarkerStyle(24);
+    hMassPi0[icen]->SetMarkerColor(color[icen]);
+    hMassPi0[icen]->SetLineColor(color[icen]);
+    hMassPi0[icen]->SetAxisRange(0.04,0.24);
+    hMassPi0[icen]->SetMarkerSize(0.5);
+    
+    hMassEta[icen]->Rebin(4);
+    hMix    [icen]->Rebin(4);
+    hMassEta[icen]->Divide(hMix[icen]);
+    hMassEta[icen]->SetMarkerStyle(25);
+    hMassEta[icen]->SetMarkerColor(color[icen]);
+    hMassEta[icen]->SetLineColor(color[icen]);
+    hMassEta[icen]->SetAxisRange(0.4,0.9);
+    hMassEta[icen]->SetMarkerSize(0.5);
+    hMassEta[icen]->Scale(1./scale);
+  }
+  
+  //gPad->SetLogy();
+  //gPad->SetGridy();
+  hMassPi0[0]->SetMinimum(0.9);
+  hMassPi0[0]->SetTitleOffset(1.6,"Y");
+  hMassPi0[0]->SetYTitle("Real / Mixed");
+  hMassPi0[0]->SetTitle("#pi^{0} peak, 2 < E_{pair}< 10 GeV");
+  hMassPi0[0]->Draw();
+  
+  if(hMass[1]) // PbPb
+  {
+    hMassPi0[0]->SetMaximum(hMassPi0[5]->GetMaximum()*1.2);
+    hMassPi0[5]->Draw("Hsame");
+    hMassPi0[4]->Draw("Hsame");
+    hMassPi0[3]->Draw("Hsame");
+    hMassPi0[2]->Draw("Hsame");
+    hMassPi0[1]->Draw("Hsame");
+    hMassPi0[0]->Draw("Hsame");
+    //hMass[6]->Draw("Hsame");
+    //hMass[7]->Draw("same");
+    //hMass[8]->Draw("same");
+    //hMass[9]->Draw("same");
+    
+    TLegend l(0.12,0.6,0.4,0.85);
+    l.SetTextSize(0.04);
+    l.AddEntry(hMassPi0[0],"0-10%","P");
+    l.AddEntry(hMassPi0[1],"10-20%","P");
+    l.AddEntry(hMassPi0[2],"20-30%","P");
+    l.AddEntry(hMassPi0[3],"30-40%","P");
+    l.AddEntry(hMassPi0[4],"40-70%","P");
+    l.AddEntry(hMassPi0[5],"50-60%","P");
+    l.SetBorderSize(0);
+    l.SetFillColor(0);
+    l.Draw();
+  }
+  
+  TLine l1(0.04,1,0.24,1);
+  l1.Draw("same");
+  
+  // Pi0 invariant mass per EMCal super module
+  cpi0->cd(3);
+  
+  TH1F* hSM[10];
+  binmin = hX->FindBin(4);  // Project histo from 3 GeV pairs
+  binmax = hX->FindBin(20); // Project histo up to 20 GeV pairs
+  for(Int_t ism = 0; ism < 10; ism++)
+  {
+    TH2F* hTmpSM = (TH2F*) GetHisto(Form("QA_hIM_Mod%d",ism));
+    hSM[ism] = (TH1F*) hTmpSM->ProjectionY(Form("hMassSM%d",ism),binmin,binmax);
+    hSM[ism]->Sumw2();
+    hSM[ism]->SetMarkerStyle(26);
+    hSM[ism]->Rebin(2);
+    //hSM[ism]->Scale(1./hSM[ism]->Integral(0,10000));
+    hSM[ism]->SetMarkerColor(color[ism]);
+    hSM[ism]->SetLineColor(color[ism]);
+    hSM[ism]->SetAxisRange(0.04,0.24);
+    hSM[ism]->SetMarkerSize(0.5);
+  }
+  
+  hSM[0]->SetTitle("#pi^{0} peak in Modules, 4 < E_{pair}< 10 GeV");
+  hSM[0]->SetTitleOffset(1.6,"Y");
+  hSM[0]->Draw("H");
+  
+  TLegend lsm(0.12,0.5,0.35,0.85);
+  lsm.SetTextSize(0.04);
+  lsm.AddEntry(hSM[0],Form("Mod %d",0),"P");
+  
+  for(Int_t ism = 1; ism < 10; ism++)
+  {
+    hSM[ism]->Draw("Hsame");
+    lsm.AddEntry(hSM[ism],Form("Mod %d",ism),"P");
+  }
+  
+  lsm.SetBorderSize(0);
+  lsm.SetFillColor(0);
+  lsm.Draw();
+  
+  // Pi0 Invariant mass projection, in PbPb 6 centrality bins from 0 to 50%, all in pp
+  cpi0->cd(4);
+  
+  //gPad->SetLogy();
+  //gPad->SetGridy();
+  hMassEta[0]->SetMinimum(0.9);
+  hMassEta[0]->SetTitleOffset(1.6,"Y");
+  hMassEta[0]->SetYTitle("Real / Mixed");
+  hMassEta[0]->SetTitle("#eta peak, 2 < E_{pair}< 10 GeV");
+  hMassEta[0]->Draw("H");
+  
+  if(hMass[1]) // PbPb
+  {
+    hMassEta[0]->SetMaximum(hMassEta[5]->GetMaximum()*1.2);
+    hMassEta[5]->Draw("Hsame");
+    hMassEta[4]->Draw("Hsame");
+    hMassEta[3]->Draw("Hsame");
+    hMassEta[2]->Draw("Hsame");
+    hMassEta[1]->Draw("Hsame");
+    hMassEta[0]->Draw("Hsame");
+    
+    
+    TLegend l2(0.12,0.6,0.4,0.85);
+    l2.SetTextSize(0.04);
+    l2.AddEntry(hMassEta[0],"0-10%","P");
+    l2.AddEntry(hMassEta[1],"10-20%","P");
+    l2.AddEntry(hMassEta[2],"20-30%","P");
+    l2.AddEntry(hMassEta[3],"30-40%","P");
+    l2.AddEntry(hMassEta[4],"40-70%","P");
+    l2.AddEntry(hMassEta[5],"50-60%","P");
+    l2.SetBorderSize(0);
+    l2.SetFillColor(0);
+    l2.Draw();
+  }
+  
+  cpi0->Print(Form("%s_Pi0Histo.eps",histoTag.Data()));
+  
+}
+
+//__________________
+void CorrelationQA()
+{
+
+  TCanvas * cCorrelation = new TCanvas(Form("CorrelationHisto_%s",histoTag.Data()),"",1000,500);
+  cCorrelation->Divide(2,1);
+  
+  Float_t minClusterE = 8;
+  Float_t assocBins[] = {0.5,2.,5.,10.,20.};
+  Int_t nAssocBins = 4;
+  
+  TH1F * hLeading = (TH1F*) GetHisto("AnaPhotonHadronCorr_hPtLeading");
+  Int_t minClusterEBin = hLeading->FindBin(minClusterE);
+  Float_t nTrig = hLeading->Integral(minClusterE,100000);
+  
+  //Azimuthal correlation
+  cCorrelation->cd(1);
+  //gPad->SetLogy();
+  TH1F* hDeltaPhi[4];
+  
+  TLegend l(0.35,0.6,0.83,0.85);
+  l.SetHeader(Form("p_{T,T} > %2.1f GeV/c",minClusterE));
+  l.SetTextSize(0.04);
+  l.SetBorderSize(0);
+  l.SetFillColor(0);
+
+  for(Int_t ibin = 0; ibin < nAssocBins; ibin++ )
+  {
+    TH2F* hDeltaPhiE = (TH2F*) GetHisto(Form("AnaPhotonHadronCorr_hDeltaPhiPtAssocPt%2.1f_%2.1f",assocBins[ibin],assocBins[ibin+1]));
+    hDeltaPhi[ibin]  = (TH1F*) hDeltaPhiE->ProjectionY(Form("DeltaPhi%2.1f",assocBins[ibin]),minClusterEBin,10000);
+    hDeltaPhi[ibin]->Sumw2();
+    hDeltaPhi[ibin]->Rebin(2);
+    hDeltaPhi[ibin]->Scale(1./nTrig);
+
+    hDeltaPhi[ibin]->Fit("pol0","Q","",1,2);
+    Float_t scale = 1;
+    if(hDeltaPhi[ibin]->GetFunction("pol0"))
+    {
+      scale = hDeltaPhi[ibin]->GetFunction("pol0")->GetParameter(0);
+      hDeltaPhi[ibin]->GetFunction("pol0")->SetRange(6,7); // move from plot
+    }
+    hDeltaPhi[ibin]->Scale(1./scale);
+    //printf("ibin %d, scale %f\n",ibin,scale);
+
+    hDeltaPhi[ibin]->SetAxisRange(-1.8,4.1);
+
+    hDeltaPhi[ibin]->SetMarkerStyle(24);
+    hDeltaPhi[ibin]->SetMarkerColor(color[ibin]);
+    hDeltaPhi[ibin]->SetLineColor(color[ibin]);
+    hDeltaPhi[ibin]->SetTitleOffset(1.5,"Y");
+    hDeltaPhi[ibin]->SetYTitle("N_{pairs} / N_{trig} / ZYAM");
+    hDeltaPhi[ibin]->SetTitle("#gamma (#lambda_{0}^{2} < 0.4, neutral cluster) trigger");
+    
+    l.AddEntry(hDeltaPhi[ibin],Form("%2.1f< p_{T,A}< %2.1f GeV/c",assocBins[ibin],assocBins[ibin+1]),"P");
+  }
+  
+  
+  //hDeltaPhi[2]->SetMaximum(hDeltaPhi[2]->GetMaximum()*1.1);
+  //hDeltaPhi[2]->SetMinimum(0.0001);
+  
+   hDeltaPhi[2]->Draw("H");
+   hDeltaPhi[1]->Draw("Hsame");
+   hDeltaPhi[3]->Draw("Hsame");
+   hDeltaPhi[0]->Draw("Hsame");
+  
+  l.Draw("same");
+  
+  
+  // xE correlation
+  cCorrelation->cd(2);
+  gPad->SetLogy();
+  
+  TLegend l2(0.35,0.6,0.83,0.85);
+  l2.SetHeader(Form("p_{T,T} > %2.1f GeV/c",minClusterE));
+  l2.SetTextSize(0.04);
+  l2.SetBorderSize(0);
+  l2.SetFillColor(0);
+  
+  TH2F* hEXE   = (TH2F*) GetHisto("AnaPhotonHadronCorr_hXECharged");
+  TH2F* hEXEUE = (TH2F*) GetHisto("AnaPhotonHadronCorr_hXEUeCharged");
+  
+  TH1F* hXE  = (TH1F*) hEXE->ProjectionY(Form("XE%2.1fGeV",minClusterE),minClusterEBin,10000);
+  hXE->Sumw2();
+  hXE->Rebin(2);
+  hXE->Scale(1./nTrig);
+  hXE->SetAxisRange(0,1);
+  hXE->SetMarkerStyle(24);
+  hXE->SetMarkerColor(1);
+  hXE->SetLineColor(1);
+  hXE->SetTitleOffset(1.5,"Y");
+  hXE->SetYTitle("N_{pairs} / N_{trig}");
+  hXE->SetTitle("#gamma (#lambda_{0}^{2} < 0.4, neutral cluster) trigger");
+  l2.AddEntry(hXE,"raw x_{E}","P");
+  hXE->Draw();
+
+  TH1F* hXEUE  = (TH1F*) hEXEUE->ProjectionY(Form("XEUE%2.1fGeV",minClusterE),minClusterEBin,10000);
+  hXEUE->Sumw2();
+  hXEUE->Rebin(2);
+  hXEUE->Scale(1./nTrig);
+  hXEUE->SetAxisRange(0,1);
+  hXEUE->SetMarkerStyle(25);
+  hXEUE->SetMarkerColor(2);
+  hXEUE->SetLineColor(2);
+  l2.AddEntry(hXEUE,"raw Und. Event x_{E}","P");
+  hXEUE->Draw("same");
+
+  
+  l2.Draw("same");
+
+  
+  cCorrelation->Print(Form("%s_CorrelationHisto.eps",histoTag.Data()));
+
+}
+
+
+//____________________________________________________________________
+void GetFileAndList(TString fileName, TString listName, Bool_t export)
+{
+  file  = new TFile(fileName,"read");
+  
+  TDirectory * dir = (TDirectory*) file->Get(listName);
+  if(dir)
+  {
+    list = (TList*) dir->Get(listName);
+    if(export)
+    {
+      TFile * outputFile = new TFile("AnalysisResultsList.root","RECREATE");
+      list->Write();
+      outputFile->Close();
+    }
+  }
+}
+
+//___________________________________
+TObject * GetHisto(TString histoName)
+{
+  // Check if the list is available, if not get the histo directly from file
+  
+  if(list) return list->FindObject(histoName);
+  else     return file->Get       (histoName);
+}
+