#include #include #include #include "TChain.h" #include "TCut.h" #include "TDirectory.h" #include "TH1F.h" #include "TH1.h" #include "TMath.h" #include "TFile.h" #include "TStopwatch.h" #include "TROOT.h" #include "TSystem.h" #include "TString.h" #include "TLatex.h" using namespace std; void TMVAplot_RocCurve(){ TFile file_S("TMVAb_privateMCs_16Vars_40Epochs_Adam_tanh15_b1_sb.root"); TH1* hist_eff_S = (TH1*)file_S.Get("TMVAb15_b1_sb/Method_PyKeras/PyKeras/MVA_PyKeras_effBvsS"); int nBins = hist_eff_S->GetNbinsX(); cout << "nBins = " << nBins << endl; double x[nBins]; double y_S[nBins]; for (Int_t i=0; iGetBinContent(i); } //=============================================== C0 =================================================================================== TCanvas *c0 = new TCanvas("c0","c0",1200,800); TGraph *grS = new TGraph(nBins,y_S,x); grS->SetLineWidth(2); grS->SetLineColor(kGreen+1); grS->GetXaxis()->SetTitle("Signal efficiency"); grS->GetYaxis()->SetTitle("Background rejection"); grS->SetMinimum(0.0); grS->SetMaximum(1.0); TLine *line = new TLine(0,0,0.8,0.8); //1.0,1.0 line->SetLineColor(kBlack); line->SetLineWidth(2); line->SetLineStyle(5); float AUC, IS_t; IS_t = hist_eff_S->Integral(0,nBins,"width"); AUC = 1 - IS_t; auto legend0 = new TLegend(0.5,0.1,0.9,0.3); legend0->AddEntry(grS, TString::Format("tH vs combined background, AUC=%.4f", AUC),"l"); c0->cd(); c0->SetGrid(); grS->Draw(); legend0->Draw(); line->Draw(); }