TEfficiency with floats

Hi,

I’m interested in calculating efficiency with its errors for the case when both total and passed values are floats (and not integers). The issue I’m having is shown in the excerpt below. There the first bin of that histogram represents the total values and the second one represents passed values. After that I feed the contents of these two bins to a TEfficiency object and calculate selection efficiency with its lower and upper errors.

        TH1F myHist {TH1F("myHist", ";X;Y", 2, 0, 2)};
        myHist.GetXaxis()->SetBinLabel(1, "Total");
        myHist.GetXaxis()->SetBinLabel(2, "Passed");

        for (unsigned short i=0; i<5; ++i)
                myHist.Fill(0.5, 0.03); // "total"

        for (unsigned short i=0; i<3; ++i)
                myHist.Fill(1.5, 0.03); // "passed"

//        myHist.Draw("hist text45");

        TEfficiency myEff {TEfficiency("myEff", "my efficiency;Bins;#varepsilon", 1, 0, 1)};
        myEff.SetTotalEvents(1, myHist.GetBinContent(1));
        myEff.SetPassedEvents(1, myHist.GetBinContent(2));

        printf("Selection efficiency is %.2f%% -%.2f%% +%.2f%%\n", myEff.GetEfficiency(1)*100, myEff.GetEfficiencyErrorLow(1)*100, myEff.GetEfficiencyErrorUp(1)*100);

– this gives me

Selection efficiency is 0.00% -0.00% +100.00%

Is there a way to properly calculate efficiency and its errors (especially the errors, as I can easily calculate the efficiency itself by myself with myHist.GetBinContent(2)/myHist.GetBinContent(1)*100) when dealing with events with very small weights such as 0.03 as in my example?

Thanks!


ROOT Version: ROOT 6.18/04
Platform: linuxx8664gcc


@moneta can you help?

Hi Lorenzo,

any ideas?

Hi @moneta,

I seem to have figured it out. Looks like my problem was that both SetTotalEvents and SetPassedEvents have to fed integer number of events, and I was providing floats. If I take the ctor which uses two histograms as input, it works fine:

        TH1F myHistTotal {TH1F("myHistTotal", ";X;Y", 2, 0, 2)};
        TH1F myHistPassed {TH1F("myHistPassed", ";X;Y", 2, 0, 2)};

        for (unsigned short i=0; i<5; ++i)
        {
                myHistTotal.Fill(1, 0.03);
                if (i<3) // pretend selection
                        myHistPassed.Fill(1, 0.03);
        }


        TEfficiency myEff {TEfficiency(myHistPassed, myHistTotal)};
//      myEff.SetStatisticOption(TEfficiency::kFCP);
        printf("Selection efficiency is %.2f%% -%.2f%% +%.2f%%\n", myEff.GetEfficiency(2)*100, myEff.GetEfficiencyErrorLow(2)*100, myEff.GetEfficiencyErrorUp(2)*100);

I have two closing questions though:

  • How difficult would it be to make SetTotalEvents and SetPassedEvents work with non-integer types?
  • Why the frequentist confidence intervals for weights are only supported by the normal approximation? What is the mathematical reason for not being able to use the TEfficiency::ClopperPearson here?

Thanks!

Hi,

Yes, we should be able to modify those two functions to pass non-integer types. Can you please open a JIRA ticket for those so it is not forgotten

The introduction of weights brakes the binomial statistics used for the ClopperPearson method. It is not anymore a real binomial distribution but an approximation to something else due to the introduction of weights. And one can deal with weights only in an asymptotic approximation, where the normal approximation is valid

Lorenzo

Hi Lorenzo,

great, thanks a lot!

Done: Loading...

Thank you !

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