Hi all, I am trying to divide two histograms using TGraphAsymmErrors::Divide , but I get the following error message:
Info in TROOT::TEfficiency::CheckEntries: Histograms are not consistent: passed bin content > total bin content
Error in TROOT::TEfficiency::CheckConsistency: passed TEfficiency objects do not have consistent bin contents
Error in TGraphAsymmErrors::Divide: passed histograms are not consistent
However, if I then swap the places of my two histograms (so that my passed one becomes my total one) I still get the same error message, so first it says that histogram A > histogram B, and then it says that histogram B > histogram A, so Iām not sure what is going wrong here.
#include "TFile.h"
#include "TCanvas.h"
#include "TH1.h"
#include "TMultiGraph.h"
#include "TGraphAsymmErrors.h"
#include "TString.h"
#include <vector>
#include <iostream>
void function (){
auto f1 = new TFile ("HaddOutput_1.root");
auto f2 = new TFile ("HaddOutput.root");
TH1D *histo = (TH1D*)f1->Get("AfterCuts/yCut_0.6/pT1Cut_0/pT2Cut_0/LeadingJetPt");
std::vector<std::string> TriggerCut = {"L1_J20", "L1_J40", "L1_J50", "L1_J100"};
std::vector<int> mjjCut = {141, 215, 247, 414};
int n1 = TriggerCut.size();
int n2 = mjjCut.size();
TCanvas *c = new TCanvas("c", " ",1000, 1000);
c->Divide(2, 2);
c->SetGrid();
TH1D *h[n1][n2];
TMultiGraph *mg[n1];
TGraphAsymmErrors *eff[n1][n2];
for (int i = 0; i < n1; i++) {
std::cout << i << std::endl;
c->cd(i + 1);
mg[i] = new TMultiGraph();
for (int j = 0; j < n2; j++) {
if (j != i) continue;
std::cout << j << std::endl;
f2->GetObject(TString::Format("%s/yCut_0.6/pT1Cut_0/pT2Cut_0/mjjCut_%d/LeadingJetPt", TriggerCut[i].c_str(), mjjCut[j]), h[i][j]);
eff[i][j] = new TGraphAsymmErrors();
eff[i][j]->Divide(h[i][j], histo); // h[i][j] should be a subset of History
mg[i]->Add(eff[i][j], "p");
}
mg[i]->Draw("AL");
}
c->cd(0);
}