<commit_before>#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TH3F.h>
#include <TH2F.h>
#include <TH1F.h>
#include <TFile.h>
#include <TF1.h>
#include <TSystem.h>
#include <TMath.h>
#include <TTree.h>
#include <TLegend.h>
#include <TLegendEntry.h>
#include <TLatex.h>
#include <TPaveStats.h>
#include <TGraphErrors.h>
#include <TCanvas.h>
#include <TStyle.h>
#include <TProfile.h>
#endif

void Draw2D(TH2F* h, Double_t maxx);
TGraphErrors* GetResolVsMult(TH2F* h, TString axis, Int_t uConv=1);

void PlotAODvertexQA(TString filename="QAresults_AOD.root", TString suffix="QA", Int_t runNumber=-1){
  
  const Int_t totTrending=16;
  Float_t vecForTrend[totTrending];
  TString varForTrending[totTrending]={"fTrackV","fSPD3D","fSPDz","fTPC","fInvalid",
				       "meanx","meany","meanz","emeanx","emeany","emeanz","meancont",
				       "fracpilSPD","fracselpilSPD","fracpilMV","fracselpilMV"};
  
  TTree* trtree=new TTree("trendingVert","tree of trending variables");
  trtree->Branch("nrun",&runNumber,"nrun/I");
  for(Int_t j=0; j<totTrending; j++){
    trtree->Branch(varForTrending[j].Data(),&vecForTrend[j],Form("%s/F",varForTrending[j].Data()));
    vecForTrend[j]=-99.;
  }

  TFile* f=new TFile(filename.Data());
  TDirectoryFile* df=(TDirectoryFile*)f->Get("CheckVertexAOD");
  if(!df){
    printf("Directory CheckVertexAOD not found in file %s\n",filename.Data());
    return;
  }
  TList* l=(TList*)df->Get(Form("clistCheckVertexAOD%s",suffix.Data()));
  if(!l){
    printf("TList clistCheckVertexAOD%s not found in file %s\n",suffix.Data(),filename.Data());
    return;    
  }

  gStyle->SetOptTitle(0);

  TH1F*	hvt=(TH1F*)l->FindObject("hAllVtxType");
  TH1F*	hpvt=(TH1F*)l->FindObject("hPrimVtxType");
  hvt->SetStats(0);
  hpvt->SetStats(0);
  hvt->GetXaxis()->SetTitleOffset(1.7);
  hpvt->GetXaxis()->SetTitleOffset(1.7);
  hvt->GetYaxis()->SetTitleOffset(1.5);
  hpvt->GetYaxis()->SetTitleOffset(1.5);

  TCanvas* cty=new TCanvas("cty","VertexType",1400,600);
  cty->Divide(2,1);
  cty->cd(1);
  gPad->SetBottomMargin(0.15);
  gPad->SetTopMargin(0.07);
  hvt->Draw();
  cty->cd(2);
  gPad->SetBottomMargin(0.15);
  gPad->SetTopMargin(0.07);
  hpvt->Draw();
  for(Int_t ib=1; ib<=hpvt->GetNbinsX(); ib++){
    Double_t fr=hpvt->GetBinContent(ib)/hpvt->GetEntries()*100.;
    if(fr>0.09){
      TLatex* t=new TLatex(hpvt->GetBinCenter(ib)-0.3*hpvt->GetBinWidth(ib),hpvt->GetBinContent(ib)+0.015*(hpvt->GetMaximum()),Form("%.1f%%",fr));
      t->SetTextColor(kGray+1);
      t->SetTextFont(43);
      t->SetTextSize(18);
      t->Draw();
    }
  }
  cty->SaveAs("VertexAOD-Type.png");

  vecForTrend[0]=hpvt->GetBinContent(3)/hpvt->GetEntries();
  vecForTrend[1]=hpvt->GetBinContent(4)/hpvt->GetEntries();
  vecForTrend[2]=hpvt->GetBinContent(5)/hpvt->GetEntries();
  vecForTrend[3]=hpvt->GetBinContent(6)/hpvt->GetEntries();
  vecForTrend[4]=hpvt->GetBinContent(1)/hpvt->GetEntries();

  Int_t kcm2um=10000;
  Int_t kcm2mm=10;

  TH2F* hxspd=(TH2F*)l->FindObject("hXspdVsMult");
  if(!hxspd) hxspd=(TH2F*)l->FindObject("hXspdVsContrib");
  TH2F* hyspd=(TH2F*)l->FindObject("hYspdVsMult");
  if(!hyspd) hyspd=(TH2F*)l->FindObject("hYspdVsContrib");
  TH2F* hzspd=(TH2F*)l->FindObject("hZspdVsMult");
  if(!hzspd) hzspd=(TH2F*)l->FindObject("hZspdVsContrib");
  Double_t maxContrib=20;
  TH1D* hContrib=hxspd->ProjectionX();
  for(Int_t jb=1; jb<=hContrib->GetNbinsX(); jb++){
    if(hContrib->GetBinContent(jb)>0) maxContrib=hContrib->GetBinLowEdge(jb+1);
  }

  TCanvas* cvs=new TCanvas("cvs","SPDVertex",1400,800);
  cvs->Divide(3,2);
  cvs->cd(1);
  Draw2D(hxspd,maxContrib);
  cvs->cd(2);
  Draw2D(hyspd,maxContrib);
  TLatex* tspd=new TLatex(0.16,0.93,"SPD Vertexer");
  tspd->SetNDC();
  tspd->SetTextFont(43);
  tspd->SetTextSize(26);
  tspd->Draw();
  cvs->cd(3);
  Draw2D(hzspd,maxContrib);
  cvs->cd(4);
  gPad->SetTickx();
  gPad->SetTicky();
  TGraphErrors* gxs=GetResolVsMult(hxspd,"x",kcm2um);
  gxs->GetXaxis()->SetLimits(0.,maxContrib);
  gxs->SetMinimum(0);
  gxs->SetMaximum(600.);
  gxs->Draw("APZ");
  cvs->cd(5);
  gPad->SetTickx();
  gPad->SetTicky();
  TGraphErrors* gys=GetResolVsMult(hyspd,"y",kcm2um);
  gys->GetXaxis()->SetLimits(0.,maxContrib);
  gys->SetMinimum(0);
  gys->SetMaximum(600.);
  gys->Draw("APZ");
  cvs->cd(6);
  gPad->SetTickx();
  gPad->SetTicky();
  TGraphErrors* gzs=GetResolVsMult(hzspd,"z");
  gzs->GetXaxis()->SetLimits(0.,maxContrib);
  gzs->SetMinimum(0);
  gzs->SetMaximum(10.);
  gzs->Draw("APZ");
  cvs->SaveAs("VertexAOD-SPD.png");

  //-------------------

  TH2F* hxtrk=(TH2F*)l->FindObject("hXtrkVsMult");
  if(!hxtrk) hxtrk=(TH2F*)l->FindObject("hXtrkVsContrib");
  TH2F* hytrk=(TH2F*)l->FindObject("hYtrkVsMult");
  if(!hytrk) hytrk=(TH2F*)l->FindObject("hYtrkVsContrib");
  TH2F* hztrk=(TH2F*)l->FindObject("hZtrkVsMult");
  if(!hztrk) hztrk=(TH2F*)l->FindObject("hZtrkVsContrib");

  vecForTrend[5]=hxtrk->GetMean(2);
  vecForTrend[6]=hytrk->GetMean(2);
  vecForTrend[7]=hztrk->GetMean(2);
  vecForTrend[8]=hxtrk->GetMeanError(2);
  vecForTrend[9]=hytrk->GetMeanError(2);
  vecForTrend[10]=hztrk->GetMeanError(2);
  vecForTrend[11]=hztrk->GetMean(1);

  TCanvas* cvt=new TCanvas("cvt","TrackVertex",1400,800);
  cvt->Divide(3,2);
  cvt->cd(1);<commit_msg>Fix for Pb-Pb axis range<commit_after>#if !defined(__CINT__) || defined(__MAKECINT__)
#include <TH3F.h>
#include <TH2F.h>
#include <TH1F.h>
#include <TFile.h>
#include <TF1.h>
#include <TSystem.h>
#include <TMath.h>
#include <TTree.h>
#include <TLegend.h>
#include <TLegendEntry.h>
#include <TLatex.h>
#include <TPaveStats.h>
#include <TGraphErrors.h>
#include <TCanvas.h>
#include <TStyle.h>
#include <TProfile.h>
#endif

void Draw2D(TH2F* h, Double_t maxx);
TGraphErrors* GetResolVsMult(TH2F* h, TString axis, Int_t uConv=1);

void PlotAODvertexQA(TString filename="QAresults_AOD.root", TString suffix="QA", Int_t runNumber=-1){
  
  const Int_t totTrending=16;
  Float_t vecForTrend[totTrending];
  TString varForTrending[totTrending]={"fTrackV","fSPD3D","fSPDz","fTPC","fInvalid",
				       "meanx","meany","meanz","emeanx","emeany","emeanz","meancont",
				       "fracpilSPD","fracselpilSPD","fracpilMV","fracselpilMV"};
  
  TTree* trtree=new TTree("trendingVert","tree of trending variables");
  trtree->Branch("nrun",&runNumber,"nrun/I");
  for(Int_t j=0; j<totTrending; j++){
    trtree->Branch(varForTrending[j].Data(),&vecForTrend[j],Form("%s/F",varForTrending[j].Data()));
    vecForTrend[j]=-99.;
  }

  TFile* f=new TFile(filename.Data());
  TDirectoryFile* df=(TDirectoryFile*)f->Get("CheckVertexAOD");
  if(!df){
    printf("Directory CheckVertexAOD not found in file %s\n",filename.Data());
    return;
  }
  TList* l=(TList*)df->Get(Form("clistCheckVertexAOD%s",suffix.Data()));
  if(!l){
    printf("TList clistCheckVertexAOD%s not found in file %s\n",suffix.Data(),filename.Data());
    return;    
  }

  gStyle->SetOptTitle(0);

  TH1F*	hvt=(TH1F*)l->FindObject("hAllVtxType");
  TH1F*	hpvt=(TH1F*)l->FindObject("hPrimVtxType");
  hvt->SetStats(0);
  hpvt->SetStats(0);
  hvt->GetXaxis()->SetTitleOffset(1.7);
  hpvt->GetXaxis()->SetTitleOffset(1.7);
  hvt->GetYaxis()->SetTitleOffset(1.5);
  hpvt->GetYaxis()->SetTitleOffset(1.5);

  TCanvas* cty=new TCanvas("cty","VertexType",1400,600);
  cty->Divide(2,1);
  cty->cd(1);
  gPad->SetBottomMargin(0.15);
  gPad->SetTopMargin(0.07);
  hvt->Draw();
  cty->cd(2);
  gPad->SetBottomMargin(0.15);
  gPad->SetTopMargin(0.07);
  hpvt->Draw();
  for(Int_t ib=1; ib<=hpvt->GetNbinsX(); ib++){
    Double_t fr=hpvt->GetBinContent(ib)/hpvt->GetEntries()*100.;
    if(fr>0.09){
      TLatex* t=new TLatex(hpvt->GetBinCenter(ib)-0.3*hpvt->GetBinWidth(ib),hpvt->GetBinContent(ib)+0.015*(hpvt->GetMaximum()),Form("%.1f%%",fr));
      t->SetTextColor(kGray+1);
      t->SetTextFont(43);
      t->SetTextSize(18);
      t->Draw();
    }
  }
  cty->SaveAs("VertexAOD-Type.png");

  vecForTrend[0]=hpvt->GetBinContent(3)/hpvt->GetEntries();
  vecForTrend[1]=hpvt->GetBinContent(4)/hpvt->GetEntries();
  vecForTrend[2]=hpvt->GetBinContent(5)/hpvt->GetEntries();
  vecForTrend[3]=hpvt->GetBinContent(6)/hpvt->GetEntries();
  vecForTrend[4]=hpvt->GetBinContent(1)/hpvt->GetEntries();

  Int_t kcm2um=10000;
  Int_t kcm2mm=10;

  TH2F* hxspd=(TH2F*)l->FindObject("hXspdVsMult");
  if(!hxspd) hxspd=(TH2F*)l->FindObject("hXspdVsContrib");
  TH2F* hyspd=(TH2F*)l->FindObject("hYspdVsMult");
  if(!hyspd) hyspd=(TH2F*)l->FindObject("hYspdVsContrib");
  TH2F* hzspd=(TH2F*)l->FindObject("hZspdVsMult");
  if(!hzspd) hzspd=(TH2F*)l->FindObject("hZspdVsContrib");
  TH2F* hxtrk=(TH2F*)l->FindObject("hXtrkVsMult");
  if(!hxtrk) hxtrk=(TH2F*)l->FindObject("hXtrkVsContrib");
  TH2F* hytrk=(TH2F*)l->FindObject("hYtrkVsMult");
  if(!hytrk) hytrk=(TH2F*)l->FindObject("hYtrkVsContrib");
  TH2F* hztrk=(TH2F*)l->FindObject("hZtrkVsMult");
  if(!hztrk) hztrk=(TH2F*)l->FindObject("hZtrkVsContrib");

  Double_t maxContrib=20;
  TH1D* hContrib=hztrk->ProjectionX();
  for(Int_t jb=1; jb<=hContrib->GetNbinsX(); jb++){
    if(hContrib->GetBinContent(jb)>0) maxContrib=hContrib->GetBinLowEdge(jb+1);
  }

  TCanvas* cvs=new TCanvas("cvs","SPDVertex",1400,800);
  cvs->Divide(3,2);
  cvs->cd(1);
  Draw2D(hxspd,maxContrib);
  cvs->cd(2);
  Draw2D(hyspd,maxContrib);
  TLatex* tspd=new TLatex(0.16,0.93,"SPD Vertexer");
  tspd->SetNDC();
  tspd->SetTextFont(43);
  tspd->SetTextSize(26);
  tspd->Draw();
  cvs->cd(3);
  Draw2D(hzspd,maxContrib);
  cvs->cd(4);
  gPad->SetTickx();
  gPad->SetTicky();
  TGraphErrors* gxs=GetResolVsMult(hxspd,"x",kcm2um);
  gxs->GetXaxis()->SetLimits(0.,maxContrib);
  gxs->SetMinimum(0);
  gxs->SetMaximum(600.);
  gxs->Draw("APZ");
  cvs->cd(5);
  gPad->SetTickx();
  gPad->SetTicky();
  TGraphErrors* gys=GetResolVsMult(hyspd,"y",kcm2um);
  gys->GetXaxis()->SetLimits(0.,maxContrib);
  gys->SetMinimum(0);
  gys->SetMaximum(600.);
  gys->Draw("APZ");
  cvs->cd(6);
  gPad->SetTickx();
  gPad->SetTicky();
  TGraphErrors* gzs=GetResolVsMult(hzspd,"z");
  gzs->GetXaxis()->SetLimits(0.,maxContrib);
  gzs->SetMinimum(0);
  gzs->SetMaximum(10.);
  gzs->Draw("APZ");
  cvs->SaveAs("VertexAOD-SPD.png");

  //-------------------


  vecForTrend[5]=hxtrk->GetMean(2);
  vecForTrend[6]=hytrk->GetMean(2);
  vecForTrend[7]=hztrk->GetMean(2);
  vecForTrend[8]=hxtrk->GetMeanError(2);
  vecForTrend[9]=hytrk->GetMeanError(2);
  vecForTrend[10]=hztrk->GetMeanError(2);
  vecForTrend[11]=hztrk->GetMean(1);

  TCanvas* cvt=new TCanvas("cvt","TrackVertex",1400,800);
  cvt->Divide(3,2);
  cvt->cd(1);
{'fraction_non_alphanumeric': 0.2202018278750952, 'fraction_numerical': 0.03522467631378522, 'mean_word_length': 5.790562378797673, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 251, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3804494', 'n_tokens_mistral': 4950, 'n_tokens_neox': 4716, 'n_words': 485}