# Trouble with Integral() method for ROC curves

I am trying to calculate the integral of my ROC curves for background rejection vs signal efficiency using the Integral() method described in the ROOT TH1:Integral reference guide.
Instead of returning values between 0 and 1. For values around 0.5, indicating a straight line ROC curve, I am instead receiving values around 0 with values trending upwards towards some value from there. I am not sure why the integral method would read out 0 for what is basically a triangle.

Here is the code I am using:

``````                    // Calculate Background Vs. Signal Efficiency
int nSigBins = hist->GetNbinsX();
int nBkgBins = bkghist->GetNbinsX();

double TSigIntegral = hist->Integral();
double TBkgIntegral = bkghist->Integral();

std::vector<double> LeftSigEff(nSigBins, 0.0);
std::vector<double> RightSigEff(nSigBins, 0.0);
std::vector<double> LeftBkgEff(nBkgBins, 0.0);
std::vector<double> RightBkgEff(nBkgBins, 0.0);

for (int i = 0; i < nSigBins; i++) {
LeftSigEff[i] = (hist->Integral(0, i) / TSigIntegral);
RightSigEff[i] = (hist->Integral(i, nSigBins) / TSigIntegral);
}

for (int i = 0; i < nBkgBins; i++) {
LeftBkgEff[i] = 1 - (bkghist->Integral(0, i) / TBkgIntegral);
RightBkgEff[i] = 1 - (bkghist->Integral(i, nBkgBins) / TBkgIntegral);
}

// Plot Efficiency Comparison of Background and Signal
TCanvas *LeftCanvas = new TCanvas("LeftCanvas", "LeftCanvas", 800, 600);
TLegend *LeftLegend = new TLegend(0.6, 0.6, 0.9, 0.9);
LeftCanvas->cd();

auto g = new TGraph(nSigBins, &LeftBkgEff, &LeftSigEff);
LeftCanvas->SetTitle("Left Cut Efficiency Comparison");
g->GetXaxis()->SetTitle("#epsilon_{Sig}");
g->GetYaxis()->SetTitle("1 - #epsilon_{Bkg}");
g->GetYaxis()->SetRangeUser(0, 1);
g->GetXaxis()->SetRangeUser(0, 1);
std::cout << "----------------------------------------" << std::endl;
std::cout << "Left Cut Efficiency Comparison" << std::endl;
std::cout << "Decay Channel: " << decayinfo << std::endl;
std::cout << "Observable: " << obs << std::endl;
std::cout << "Particle: " << part << std::endl;
std::cout << "ROC Curve Plot Integral: " << 100*g->Integral() << std::endl;
g->Draw("AC*");
LeftCanvas->SaveAs(("Output/RequestAnalysis/AllSMass/" + decayinfo + "_" + part + "_" + obs + "_LeftEfficiencyComparison.png").c_str());
``````

Where hist and bkghist are histograms loaded in separately.

## Left Cut Efficiency Comparison Decay Channel: ttbb Observable: E Particle: st ROC Curve Plot Integral: 2.8683

Left Cut Efficiency Comparison
Decay Channel: ttbb
Observable: N
Particle: tau
ROC Curve Plot Integral: 0

I multiplied the output by 100 simply for readability.

_ROOT Version: 6.24/06
_Platform: lxplus
Compiler: Not Provided

The histogram bins go from 1 to nbins (included), not 0 to nbins-1 (bin = 0 and nbins+1 are under/overflow), so that may be an issue in your loops and integrals.