TEfficiency Histograms are not consistent: passed bin content > total bin content

Hello,

I have two histograms have both 1 bin. I would like to calculate the efficiency using Tefficiency class but got an issue (below)

I’m calculating the efficiency like that :

TEfficiency *eff = new TEfficiency(*hpass,*htot)

where the total number of events in each is
hpass====>5939
htot ======>35943

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 <TEfficiency::TEfficiency(const TH1&,const TH1&)>: histograms are not consistent -> results are useless
Warning in <TEfficiency::TEfficiency(const TH1&,const TH1&)>: using two empty TH1D(‘h1’,‘h1’,10,0,10)

I am not sure that’s the explanation but histograms with 1 bin only do not make real sense ? what do you think ?

I meant that the histogram I filled have 1 bin
i.e TH1F *h = new TH1F("","#eta",1, 2.5,4.5)

I just want the total efficiency and its error, I dont want to draw it
Did I miss something ?

I am not sure If I understood you ? what exactly wrong using histograms with 1 bin ?

If you have only one bin how can you see a distribution ?

Hi,

can you please share your code? I can’t seem to reproduce the issue: the following works perfectly fine for me, printing out “Efficiency of that only bin is 0.165234” :

        TH1F* hpass = new TH1F("hpass", ";#eta;Number of particles", 1, 2.5, 4.5);
        hpass->Fill(3., 5939);
        TH1F* htot = new TH1F("htot", ";#eta;Number of particles", 1, 2.5, 4.5);
        htot->Fill(3., 35943);

        TEfficiency *eff = new TEfficiency(*hpass,*htot);
        printf("Efficiency of that only bin is %f\n", eff->GetEfficiency(1));

I just the total number shown in a table not the distribution ? I already made distributions in 20 bins but had problem getting the total efficiency and its error ? I heard it’s not practical to get the total efficiency by doing the mean of efficiency in each bin.
this the reason that lead me to do
I don’t know if you have any suggestion

you can access the file by doing

root -l /afs/cern.ch/user/y/yelghaza/public/100GeV_signal_pu_NN.root
root [1] TEfficiency *ef =new TEfficiency(*loose_trk_misID,*signal_truth)

the problem appears only in loose_trk_misID, medium_trk_misID and tight_trk_misID histograms
Thanks

Your problem is that the content of the underflow bin of the hpass histogram (3950 for loose_trk_misID, 3653 for medium_trk_misID, and 3305 for tight_trk_misID) is larger than the content of the underflow bin of the htot histogram (zero). The documentation clearly states that

pass.GetBinContent(i) has to be <= total.GetBinContent(i) for each bin i

Thanks for your clarification ! i there any way to ensure that the problem won’t appear while filling the histograms ?

I think you should modify your selection code. With the correct code you shouldn’t have the content of the underflow bin of the pass histogram greater than the content of the same bin of the total histogram.

On the other hand, you could simply manually nullify the underflow bin in the pass histogram. Provided, of course, that you aren’t interested in it. And the issue will disappear.

Hi yus,

Sorry for the naive question, but how can I do it manually ?

Thanks

Just do

hpass->SetBinContent(0, 0.); // set the content of bin #0 to 0.0

as in

        std::unique_ptr<TFile> file{TFile::Open("~yelghaza/public/100GeV_signal_pu_NN.root")};

        if (!file || file->IsZombie())
        {
                printf("ERROR: can't open input file, bailing out...\n");
                return;
        }

        std::unique_ptr<TH1> hpass(static_cast<TH1*>(file->Get("loose_trk_misID")));
        if (!hpass)
        {
                printf("ERROR: can't fetch the \"loose_trk_misIDfrom\" histogram from the input file, bailing out...\n");
                return;
        }

        std::unique_ptr<TH1> htot(static_cast<TH1*>(file->Get("signal_truth")));
        if (!htot)
        {
                printf("ERROR: can't fetch the \"signal_truth\" histogram from the input file, bailing out...\n");
                return;
        }

        hpass->SetBinContent(0, 0.);

        TEfficiency *eff = new TEfficiency(*hpass, *htot);
        printf("Efficiency of the only visible bin is %f\n", eff->GetEfficiency(1));
        return;

Thank you so much I already found this method TH1::ClearUnderflowAndOverflow () and seems to be working

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.