1#ifndef ROOT_TEfficiency_cxx
2#define ROOT_TEfficiency_cxx
759 Info(
"TEfficiency",
"given histograms are filled with weights");
764 Error(
"TEfficiency(const TH1&,const TH1&)",
"histograms are not consistent -> results are useless");
765 Warning(
"TEfficiency(const TH1&,const TH1&)",
"using two empty TH1D('h1','h1',10,0,10)");
987 fTotalHistogram =
new TH3D(
"total",
"total",nbinsx,xlow,xup,nbinsy,ylow,yup,nbinsz,zlow,zup);
988 fPassedHistogram =
new TH3D(
"passed",
"passed",nbinsx,xlow,xup,nbinsy,ylow,yup,nbinsz,zlow,zup);
1073 rEff.TObject::Copy(*
this);
1094 rEff.TAttLine::Copy(*
this);
1095 rEff.TAttFill::Copy(*
this);
1096 rEff.TAttMarker::Copy(*
this);
1161 return ((
mode + delta) > 1) ? 1.0 : (
mode + delta);
1163 return ((
mode - delta) < 0) ? 0.0 : (
mode - delta);
1180 ::Error(
"FeldmanCousins",
"Error running FC method - return 0 or 1");
1182 return (bUpper) ? upper : lower;
1211 double alpha = 1.-level;
1235 const double alpha = 1. - level;
1236 const bool equal_tailed =
true;
1237 const double alpha_min = equal_tailed ? alpha/2 : alpha;
1238 const double tol = 1
e-9;
1248 if ( passed > 0 && passed < 1) {
1251 p = (p1 - p0) * passed + p0;
1255 while (std::abs(pmax - pmin) > tol) {
1256 p = (pmin + pmax)/2;
1264 double vmin = (bUpper) ? alpha_min : 1.- alpha_min;
1339 return (bUpper) ? upper : lower;
1357 if((
a > 0) && (
b > 0))
1360 gROOT->Error(
"TEfficiency::BayesianCentral",
"Invalid input parameters - return 1");
1365 if((
a > 0) && (
b > 0))
1368 gROOT->Error(
"TEfficiency::BayesianCentral",
"Invalid input parameters - return 0");
1412 if (
a <= 0 ||
b <= 0) {
1413 lower = 0; upper = 1;
1414 gROOT->Error(
"TEfficiency::BayesianShortest",
"Invalid input parameters - return [0,1]");
1433 if (
a==
b &&
a<=1.0) {
1447 bool ret = minim.
Minimize(100, 1.E-10,1.E-10);
1449 gROOT->Error(
"TEfficiency::BayesianShortes",
"Error finding the shortest interval");
1466 if (
a <= 0 ||
b <= 0 ) {
1467 gROOT->Error(
"TEfficiency::BayesianMean",
"Invalid input parameters - return 0");
1489 if (
a <= 0 ||
b <= 0 ) {
1490 gROOT->Error(
"TEfficiency::BayesianMode",
"Invalid input parameters - return 0");
1493 if (
a <= 1 ||
b <= 1) {
1494 if (
a <
b)
return 0;
1495 if (
a >
b)
return 1;
1496 if (
a ==
b)
return 0.5;
1538 const TAxis* ax1 =
nullptr;
1539 const TAxis* ax2 =
nullptr;
1546 ax2 =
total.GetXaxis();
1550 ax2 =
total.GetYaxis();
1554 ax2 =
total.GetZaxis();
1559 gROOT->Info(
"TEfficiency::CheckBinning",
"Histograms are not consistent: they have different number of bins");
1565 gROOT->Info(
"TEfficiency::CheckBinning",
"Histograms are not consistent: they have different bin edges");
1587 gROOT->Error(
"TEfficiency::CheckConsistency",
"passed TEfficiency objects have different dimensions");
1592 gROOT->Error(
"TEfficiency::CheckConsistency",
"passed TEfficiency objects have different binning");
1597 gROOT->Error(
"TEfficiency::CheckConsistency",
"passed TEfficiency objects do not have consistent bin contents");
1620 Int_t nbinsx, nbinsy, nbinsz, nbins;
1627 case 1: nbins = nbinsx + 2;
break;
1628 case 2: nbins = (nbinsx + 2) * (nbinsy + 2);
break;
1629 case 3: nbins = (nbinsx + 2) * (nbinsy + 2) * (nbinsz + 2);
break;
1633 for(
Int_t i = 0; i < nbins; ++i) {
1635 gROOT->Info(
"TEfficiency::CheckEntries",
"Histograms are not consistent: passed bin content > total bin content");
1648 if (pass.
GetSumw2N() == 0 &&
total.GetSumw2N() == 0)
return false;
1655 total.GetStats(stattotal);
1678 Error(
"CreatePaintingGraph",
"Call this function only for dimension == 1");
1697 Error(
"CreatePaintingGraph",
"Call this function only for dimension == 2");
1718 Bool_t plot0Bins =
false;
1719 if (
option.Contains(
"e0") ) plot0Bins =
true;
1727 double * px = graph->
GetX();
1728 double * py = graph->
GetY();
1729 double * pz = graph->
GetZ();
1752 if (ipoint >= graph->
GetN() ) {
1776 if (oldTitle != newTitle ) {
1795 for (
int ibin = 1; ibin <=
fTotalHistogram->GetXaxis()->GetNbins(); ++ibin) {
1802 for (
int ibin = 1; ibin <=
fTotalHistogram->GetYaxis()->GetNbins(); ++ibin) {
1821 Bool_t plot0Bins =
false;
1822 if (
option.Contains(
"e0") ) plot0Bins =
true;
1831 double * px = graph->
GetX();
1832 double * py = graph->
GetY();
1838 for (
Int_t i = 0; i < npoints; ++i) {
1839 if (!plot0Bins &&
fTotalHistogram->GetBinContent(i+1) == 0 )
continue;
1847 if (j >= graph->
GetN() ) {
1867 if (oldTitle != newTitle ) {
1884 for (
int ibin = 1; ibin <=
fTotalHistogram->GetXaxis()->GetNbins(); ++ibin) {
1903 Error(
"CreatePaintingistogram",
"Call this function only for dimension == 2");
1911 TH2 * hist =
nullptr;
1954 for(
Int_t i = 0; i < nbinsx + 2; ++i) {
1955 for(
Int_t j = 0; j < nbinsy + 2; ++j) {
1963 for (
int ibinx = 1; ibinx <=
fTotalHistogram->GetXaxis()->GetNbins(); ++ibinx)
1967 for (
int ibiny = 1; ibiny <=
fTotalHistogram->GetYaxis()->GetNbins(); ++ibiny)
2026 Double_t alpha = (1.0 - level) / 2;
2137 for (
int i = 0; i <
n ; ++i) {
2138 if(pass[i] >
total[i]) {
2139 ::Error(
"TEfficiency::Combine",
"total events = %i < passed events %i",
total[i],pass[i]);
2140 ::Info(
"TEfficiency::Combine",
"stop combining");
2145 ktot +=
w[i] * pass[i];
2150 double norm = sumw/sumw2;
2154 ::Error(
"TEfficiency::Combine",
"total = %f < passed %f",ntot,ktot);
2155 ::Info(
"TEfficiency::Combine",
"stop combining");
2159 double a = ktot + alpha;
2160 double b = ntot - ktot + beta;
2162 double mean =
a/(
a+
b);
2168 if (shortestInterval)
2226 std::vector<TH1*> vTotal; vTotal.reserve(
n);
2227 std::vector<TH1*> vPassed; vPassed.reserve(
n);
2228 std::vector<Double_t> vWeights; vWeights.reserve(
n);
2244 level = atof( opt(pos,opt.
Length() ).
Data() );
2245 if((level <= 0) || (level >= 1))
2253 for(
Int_t k = 0; k <
n; ++k) {
2255 vWeights.push_back(
w[k]);
2257 gROOT->Error(
"TEfficiency::Combine",
"invalid custom weight found w = %.2lf",
w[k]);
2258 gROOT->Info(
"TEfficiency::Combine",
"stop combining");
2267 while((obj = next())) {
2293 vWeights.push_back(pEff->
fWeight);
2308 if(vTotal.empty()) {
2309 gROOT->Error(
"TEfficiency::Combine",
"no TEfficiency objects in given list");
2310 gROOT->Info(
"TEfficiency::Combine",
"stop combining");
2315 if(bWeights && (
n != (
Int_t)vTotal.size())) {
2316 gROOT->Error(
"TEfficiency::Combine",
"number of weights n=%i differs from number of TEfficiency objects k=%i which should be combined",
n,(
Int_t)vTotal.size());
2317 gROOT->Info(
"TEfficiency::Combine",
"stop combining");
2321 Int_t nbins_max = vTotal.at(0)->GetNbinsX();
2323 for(
UInt_t i=0; i<vTotal.size(); ++i) {
2325 gROOT->Warning(
"TEfficiency::Combine",
"histograms have not the same binning -> results may be useless");
2326 if(vTotal.at(i)->GetNbinsX() < nbins_max) nbins_max = vTotal.at(i)->GetNbinsX();
2331 gROOT->Info(
"TEfficiency::Combine",
"combining %i TEfficiency objects",(
Int_t)vTotal.size());
2333 gROOT->Info(
"TEfficiency::Combine",
"using custom weights");
2335 gROOT->Info(
"TEfficiency::Combine",
"using the following prior probability for the efficiency: P(e) ~ Beta(e,%.3lf,%.3lf)",alpha,beta);
2338 gROOT->Info(
"TEfficiency::Combine",
"using individual priors of each TEfficiency object");
2339 gROOT->Info(
"TEfficiency::Combine",
"confidence level = %.2lf",level);
2343 std::vector<Double_t>
x(nbins_max);
2344 std::vector<Double_t> xlow(nbins_max);
2345 std::vector<Double_t> xhigh(nbins_max);
2346 std::vector<Double_t> eff(nbins_max);
2347 std::vector<Double_t> efflow(nbins_max);
2348 std::vector<Double_t> effhigh(nbins_max);
2352 Int_t num = vTotal.size();
2353 std::vector<Int_t> pass(num);
2354 std::vector<Int_t>
total(num);
2359 for(
Int_t i=1; i <= nbins_max; ++i) {
2361 x[i-1] = vTotal.at(0)->GetBinCenter(i);
2362 xlow[i-1] =
x[i-1] - vTotal.at(0)->GetBinLowEdge(i);
2363 xhigh[i-1] = vTotal.at(0)->GetBinWidth(i) - xlow[i-1];
2365 for(
Int_t j = 0; j < num; ++j) {
2366 pass[j] = (
Int_t)(vPassed.at(j)->GetBinContent(i) + 0.5);
2367 total[j] = (
Int_t)(vTotal.at(j)->GetBinContent(i) + 0.5);
2371 eff[i-1] =
Combine(up,low,num,&pass[0],&
total[0],alpha,beta,level,&vWeights[0],opt.
Data());
2373 if(eff[i-1] == -1) {
2374 gROOT->Error(
"TEfficiency::Combine",
"error occurred during combining");
2375 gROOT->Info(
"TEfficiency::Combine",
"stop combining");
2378 efflow[i-1]= eff[i-1] - low;
2379 effhigh[i-1]= up - eff[i-1];
2569 Bool_t bDeleteOld =
true;
2570 if(
option.Contains(
"+")) {
2571 option.ReplaceAll(
"+",
"");
2580 if (!
option.Contains(
"N")) {
2581 TF1* pFunc = (
TF1*)
f1->IsA()->New();
2587 while((obj = next())) {
2707 if (tw2 <= 0 )
return pw/tw;
2710 double norm = tw/tw2;
2711 aa = pw * norm + alpha;
2712 bb = (tw - pw) * norm + beta;
2716 aa = passed + alpha;
2717 bb =
total - passed + beta;
2760 if (tw2 <= 0)
return 0;
2765 Double_t bb = (tw - pw) * norm + beta;
2781 Warning(
"GetEfficiencyErrorLow",
"frequentist confidence intervals for weights are only supported by the normal approximation");
2782 Info(
"GetEfficiencyErrorLow",
"setting statistic option to kFNormal");
2786 Double_t variance = ( pw2 * (1. - 2 * eff) + tw2 * eff *eff ) / ( tw * tw) ;
2793 return (eff - delta < 0) ? eff : delta;
2840 if (tw2 <= 0)
return 0;
2845 Double_t bb = (tw - pw) * norm + beta;
2861 Warning(
"GetEfficiencyErrorUp",
"frequentist confidence intervals for weights are only supported by the normal approximation");
2862 Info(
"GetEfficiencyErrorUp",
"setting statistic option to kFNormal");
2866 Double_t variance = ( pw2 * (1. - 2 * eff) + tw2 * eff *eff ) / ( tw * tw) ;
2872 return (eff + delta > 1) ? 1.-eff : delta;
2929 while((obj = next())) {
2963 if (
total == 0)
return (bUpper) ? 1 : 0;
2969 return ((average + delta) > 1) ? 1.0 : (average + delta);
2971 return ((average - delta) < 0) ? 0.0 : (average - delta);
2996 Fatal(
"operator+=",
"Adding to a non consistent TEfficiency object which has not a total or a passed histogram ");
3001 Warning(
"operator+=",
"no operation: adding an empty object");
3005 Fatal(
"operator+=",
"Adding a non consistent TEfficiency object which has not a total or a passed histogram ");
3063 rhs.TAttLine::Copy(*
this);
3064 rhs.TAttFill::Copy(*
this);
3065 rhs.TAttMarker::Copy(*
this);
3118 while ((obj = next())) {
3121 ((
TF1 *)obj)->Paint(
"sameC");
3129 bool drawGraph2D =
false;
3130 if (
option.Contains(
"GRAPH")) {
3131 option.ReplaceAll(
"GRAPH",
"");
3157 Warning(
"Paint",
"Painting 3D efficiency is not implemented");
3188 thread_local Int_t eff_count = 0;
3196 TString sxaxis, syaxis, szaxis;
3218 out << sxaxis <<
".data()";
3225 out << syaxis <<
".data()";
3233 out << szaxis <<
".data()";
3242 out <<
" " <<
name <<
"->SetConfidenceLevel(" <<
fConfLevel <<
");\n";
3245 out <<
" " <<
name <<
"->SetWeight(" <<
fWeight <<
");\n";
3246 out <<
" " <<
name <<
"->SetStatisticOption(static_cast<TEfficiency::EStatOption>(" <<
fStatisticOption <<
"));\n";
3250 out <<
" " <<
name <<
"->SetUseWeightedEvents();\n";
3254 out <<
" " <<
name <<
"->SetBetaBinParameters(" << i <<
"," <<
fBeta_bin_params.at(i).first <<
","
3266 for (
Int_t i = 0; i < nbins; ++i) {
3267 out <<
" " <<
name <<
"->SetTotalEvents(" << i <<
"," <<
fTotalHistogram->GetBinContent(i) <<
");\n";
3268 out <<
" " <<
name <<
"->SetPassedEvents(" << i <<
"," <<
fPassedHistogram->GetBinContent(i) <<
");\n";
3296 Warning(
"SetBetaAlpha(Double_t)",
"invalid shape parameter %.2lf",alpha);
3314 Warning(
"SetBetaBeta(Double_t)",
"invalid shape parameter %.2lf",beta);
3335 UInt_t n =
h1->GetBin(
h1->GetNbinsX()+1,
h1->GetNbinsY()+1,
h1->GetNbinsZ()+1 ) + 1;
3354 Error(
"SetBins",
"Using wrong SetBins function for a %d-d histogram",
GetDimension());
3358 Warning(
"SetBins",
"Histogram entries will be lost after SetBins");
3374 Error(
"SetBins",
"Using wrong SetBins function for a %d-d histogram",
GetDimension());
3378 Warning(
"SetBins",
"Histogram entries will be lost after SetBins");
3394 Error(
"SetBins",
"Using wrong SetBins function for a %d-d histogram",
GetDimension());
3398 Warning(
"SetBins",
"Histogram entries will be lost after SetBins");
3414 Error(
"SetBins",
"Using wrong SetBins function for a %d-d histogram",
GetDimension());
3418 Warning(
"SetBins",
"Histogram entries will be lost after SetBins");
3435 Error(
"SetBins",
"Using wrong SetBins function for a %d-d histogram",
GetDimension());
3439 Warning(
"SetBins",
"Histogram entries will be lost after SetBins");
3456 Error(
"SetBins",
"Using wrong SetBins function for a %d-d histogram",
GetDimension());
3460 Warning(
"SetBins",
"Histogram entries will be lost after SetBins");
3475 if((level > 0) && (level < 1))
3478 Warning(
"SetConfidenceLevel(Double_t)",
"invalid confidence level %.2lf",level);
3532 if(events <= fTotalHistogram->GetBinContent(bin)) {
3537 Error(
"SetPassedEvents(Int_t,Double_t)",
"total number of events (%.1lf) in bin %i is less than given number of passed events %.1lf",
fTotalHistogram->GetBinContent(bin),bin,events);
3698 title_passed.
Insert(pos,
" (passed)");
3699 title_total.
Insert(pos,
" (total)");
3702 title_passed.
Append(
" (passed)");
3703 title_total.
Append(
" (total)");
3731 Error(
"SetTotalEvents(Int_t,Double_t)",
"passed number of events (%.1lf) in bin %i is bigger than given number of total events %.1lf",
fPassedHistogram->GetBinContent(bin),bin,events);
3792 gROOT->Info(
"TEfficiency::SetUseWeightedEvents",
"Handle weighted events for computing efficiency");
3812 Warning(
"SetWeight",
"invalid weight %.2lf",weight);
3840 if (
total == 0)
return (bUpper) ? 1 : 0;
3846 * (1 - average) + kappa * kappa / 4);
3848 return ((
mode + delta) > 1) ? 1.0 : (
mode + delta);
3850 return ((
mode - delta) < 0) ? 0.0 : (
mode - delta);
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
int Ssiz_t
String size (currently int)
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
double Double_t
Double 8 bytes.
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
long long Long64_t
Portable signed long integer 8 bytes.
const char Option_t
Option string (const char)
const TEfficiency operator+(const TEfficiency &lhs, const TEfficiency &rhs)
Addition operator.
const Double_t kDefBetaAlpha
const Double_t kDefWeight
const Double_t kDefBetaBeta
const TEfficiency::EStatOption kDefStatOpt
const Double_t kDefConfLevel
static unsigned int total
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void w
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char mode
void Calculate(const double X, const double n)
User class for performing function minimization.
void SetFunction(const ROOT::Math::IGenFunction &f, double xlow, double xup)
Sets function to be minimized.
bool Minimize(int maxIter, double absTol=1.E-8, double relTol=1.E-10) override
Find minimum position iterating until convergence specified by the absolute and relative tolerance or...
void SetNpx(int npx)
Set the number of point used to bracket root using a grid.
double XMinimum() const override
Return current estimate of the position of the minimum.
double FValMinimum() const override
Return function value at current estimate of the minimum.
Template class to wrap any C++ callable object which takes one argument i.e.
const Double_t * GetArray() const
void Copy(TAttFill &attfill) const
Copy this fill attributes to a new TAttFill.
TAttFill()
AttFill default constructor.
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
Save fill attributes as C++ statement(s) on output stream out.
TAttLine()
AttLine default constructor.
void Copy(TAttLine &attline) const
Copy this line attributes to a new TAttLine.
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
Save line attributes as C++ statement(s) on output stream out.
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
Save line attributes as C++ statement(s) on output stream out.
void Copy(TAttMarker &attmarker) const
Copy this marker attributes to a new TAttMarker.
TAttMarker()
TAttMarker default constructor.
Class to manage histogram axis.
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
Bool_t IsVariableBinSize() const
const TArrayD * GetXbins() const
virtual Int_t FindBin(Double_t x)
Find bin number corresponding to abscissa x.
virtual Double_t GetBinLowEdge(Int_t bin) const
Return low edge of bin.
virtual Int_t FindFixBin(Double_t x) const
Find bin number corresponding to abscissa x
Binomial fitter for the division of two histograms.
TFitResultPtr Fit(TF1 *f1, Option_t *option="")
Carry out the fit of the given function to the given histograms.
Collection abstract base class.
virtual Bool_t IsEmpty() const
TDirectory::TContext keeps track and restore the current directory.
Describe directory structure in memory.
Class to handle efficiency histograms.
void FillGraph2D(TGraph2DAsymmErrors *graph, Option_t *opt) const
Fill the graph to be painted with information from TEfficiency Internal method called by TEfficiency:...
void Draw(Option_t *opt="") override
Draws the current TEfficiency object.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
static Bool_t FeldmanCousinsInterval(Double_t total, Double_t passed, Double_t level, Double_t &lower, Double_t &upper)
Calculates the interval boundaries using the frequentist methods of Feldman-Cousins.
static Double_t BetaMode(Double_t alpha, Double_t beta)
Compute the mode of the beta distribution.
TH2 * CreateHistogram(Option_t *opt="") const
Create the histogram used to be painted (for dim=2 TEfficiency) The return object is managed by the c...
static Bool_t BetaShortestInterval(Double_t level, Double_t alpha, Double_t beta, Double_t &lower, Double_t &upper)
Calculates the boundaries for a shortest confidence interval for a Beta distribution.
static Bool_t CheckWeights(const TH1 &pass, const TH1 &total)
Check if both histogram are weighted.
static Double_t BetaMean(Double_t alpha, Double_t beta)
Compute the mean (average) of the beta distribution.
TEfficiency()
Default constructor.
Double_t GetBetaAlpha(Int_t bin=-1) const
void FillWeighted(Bool_t bPassed, Double_t weight, Double_t x, Double_t y=0, Double_t z=0)
This function is used for filling the two histograms with a weight.
~TEfficiency() override
default destructor
TList * GetListOfFunctions()
static Double_t Bayesian(Double_t total, Double_t passed, Double_t level, Double_t alpha, Double_t beta, Bool_t bUpper, Bool_t bShortest=false)
Calculates the boundaries for a Bayesian confidence interval (shortest or central interval depending ...
static Double_t AgrestiCoull(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Calculates the boundaries for the frequentist Agresti-Coull interval.
Long64_t Merge(TCollection *list)
Merges the TEfficiency objects in the given list to the given TEfficiency object using the operator+=...
std::vector< std::pair< Double_t, Double_t > > fBeta_bin_params
Parameter for prior beta distribution different bin by bin (default vector is empty)
static Double_t FeldmanCousins(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Calculates the boundaries for the frequentist Feldman-Cousins interval.
EStatOption fStatisticOption
Defines how the confidence intervals are determined.
void SetStatisticOption(EStatOption option)
Sets the statistic option which affects the calculation of the confidence interval.
void Paint(Option_t *opt) override
Paints this TEfficiency object.
void SetWeight(Double_t weight)
Sets the global weight for this TEfficiency object.
TH1 * fTotalHistogram
Histogram for total number of events.
Int_t GetDimension() const
returns the dimension of the current TEfficiency object
TGraph2DAsymmErrors * fPaintGraph2D
! Temporary graph for painting
TEfficiency & operator+=(const TEfficiency &rhs)
Adds the histograms of another TEfficiency object to current histograms.
Bool_t SetBins(Int_t nx, Double_t xmin, Double_t xmax)
Set the bins for the underlined passed and total histograms If the class have been already filled the...
void Build(const char *name, const char *title)
Building standard data structure of a TEfficiency object.
TH1 * GetCopyPassedHisto() const
Returns a cloned version of fPassedHistogram.
Double_t GetEfficiencyErrorUp(Int_t bin) const
Returns the upper error on the efficiency in the given global bin.
Double_t fBeta_alpha
Global parameter for prior beta distribution (default = 1)
Bool_t UsesBayesianStat() const
void SavePrimitive(std::ostream &out, Option_t *opt="") override
Save primitive as a C++ statement(s) on output stream out.
void SetBetaBeta(Double_t beta)
Sets the shape parameter β.
Double_t GetConfidenceLevel() const
static Bool_t CheckBinning(const TH1 &pass, const TH1 &total)
Checks binning for each axis.
void SetName(const char *name) override
Sets the name.
TGraph2DAsymmErrors * CreateGraph2D(Option_t *opt="") const
Create the graph used be painted (for dim=1 TEfficiency) The return object is managed by the caller.
Bool_t SetPassedEvents(Int_t bin, Double_t events)
Sets the number of passed events in the given global bin.
static Double_t BetaCentralInterval(Double_t level, Double_t alpha, Double_t beta, Bool_t bUpper)
Calculates the boundaries for a central confidence interval for a Beta distribution.
Int_t GetGlobalBin(Int_t binx, Int_t biny=0, Int_t binz=0) const
Returns the global bin number which can be used as argument for the following functions:
TH1 * fPassedHistogram
Histogram for events which passed certain criteria.
static Double_t MidPInterval(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Calculates the boundaries using the mid-P binomial interval (Lancaster method) from B.
void SetBetaAlpha(Double_t alpha)
Sets the shape parameter α.
@ kIsBayesian
Bayesian statistics are used.
@ kUseWeights
Use weights.
@ kPosteriorMode
Use posterior mean for best estimate (Bayesian statistics)
@ kUseBinPrior
Use a different prior for each bin.
@ kShortestInterval
Use shortest interval.
static Bool_t CheckEntries(const TH1 &pass, const TH1 &total, Option_t *opt="")
Checks whether bin contents are compatible with binomial statistics.
static Double_t Normal(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Returns the confidence limits for the efficiency supposing that the efficiency follows a normal distr...
Double_t fWeight
Weight for all events (default = 1)
Bool_t SetPassedHistogram(const TH1 &rPassed, Option_t *opt)
Sets the histogram containing the passed events.
Double_t GetBetaBeta(Int_t bin=-1) const
Double_t(* fBoundary)(Double_t, Double_t, Double_t, Bool_t)
! Pointer to a method calculating the boundaries of confidence intervals
void FillGraph(TGraphAsymmErrors *graph, Option_t *opt) const
Fill the graph to be painted with information from TEfficiency Internal method called by TEfficiency:...
static Double_t Combine(Double_t &up, Double_t &low, Int_t n, const Int_t *pass, const Int_t *total, Double_t alpha, Double_t beta, Double_t level=0.683, const Double_t *w=nullptr, Option_t *opt="")
Calculates the combined efficiency and its uncertainties.
void FillHistogram(TH2 *h2) const
Fill the 2d histogram to be painted with information from TEfficiency 2D Internal method called by TE...
Int_t FindFixBin(Double_t x, Double_t y=0, Double_t z=0) const
Returns the global bin number containing the given values.
TDirectory * fDirectory
! Pointer to directory holding this TEfficiency object
void SetUseWeightedEvents(Bool_t on=kTRUE)
static Double_t Wilson(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Calculates the boundaries for the frequentist Wilson interval.
TEfficiency & operator=(const TEfficiency &rhs)
Assignment operator.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a graph.
Double_t fConfLevel
Confidence level (default = 0.683, 1 sigma)
Double_t fBeta_beta
Global parameter for prior beta distribution (default = 1)
Double_t GetEfficiency(Int_t bin) const
Returns the efficiency in the given global bin.
Bool_t SetTotalHistogram(const TH1 &rTotal, Option_t *opt)
Sets the histogram containing all events.
void Fill(Bool_t bPassed, Double_t x, Double_t y=0, Double_t z=0)
This function is used for filling the two histograms.
void SetDirectory(TDirectory *dir)
Sets the directory holding this TEfficiency object.
TGraphAsymmErrors * fPaintGraph
! Temporary graph for painting
TGraphAsymmErrors * CreateGraph(Option_t *opt="") const
Create the graph used be painted (for dim=1 TEfficiency) The return object is managed by the caller.
EStatOption GetStatisticOption() const
TList * fFunctions
->Pointer to list of functions
Bool_t SetTotalEvents(Int_t bin, Double_t events)
Sets the number of total events in the given global bin.
void SetBetaBinParameters(Int_t bin, Double_t alpha, Double_t beta)
Sets different shape parameter α and β for the prior distribution for each bin.
static Bool_t CheckConsistency(const TH1 &pass, const TH1 &total, Option_t *opt="")
Checks the consistence of the given histograms.
Double_t GetWeight() const
TH1 * GetCopyTotalHisto() const
Returns a cloned version of fTotalHistogram.
static Double_t ClopperPearson(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Calculates the boundaries for the frequentist Clopper-Pearson interval.
void SetConfidenceLevel(Double_t level)
Sets the confidence level (0 < level < 1) The default value is 1-sigma :~ 0.683.
Double_t GetEfficiencyErrorLow(Int_t bin) const
Returns the lower error on the efficiency in the given global bin.
EStatOption
Enumeration type for different statistic options for calculating confidence intervals kF* ....
@ kBJeffrey
Jeffrey interval (Prior ~ Beta(0.5,0.5)
@ kFWilson
Wilson interval.
@ kFAC
Agresti-Coull interval.
@ kMidP
Mid-P Lancaster interval.
@ kBUniform
Prior ~ Uniform = Beta(1,1)
@ kFFC
Feldman-Cousins interval.
@ kBBayesian
User specified Prior ~ Beta(fBeta_alpha,fBeta_beta)
@ kFNormal
Normal approximation.
@ kFCP
Clopper-Pearson interval (recommended by PDG)
void SetTitle(const char *title) override
Sets the title.
TFitResultPtr Fit(TF1 *f1, Option_t *opt="")
Fits the efficiency using the TBinomialEfficiencyFitter class.
void RecursiveRemove(TObject *obj) override
Recursively remove object from the list of functions.
TH2 * fPaintHisto
! Temporary histogram for painting
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Graph 2D class with errors.
Double_t * GetEYlow() const override
virtual void SetPointError(Int_t i, Double_t exl, Double_t exh, Double_t eyl, Double_t eyh, Double_t ezl, Double_t ezh)
Set ex, ey and ez values for point number i.
Double_t * GetEYhigh() const override
Double_t * GetEZhigh() const override
Double_t * GetEXhigh() const override
Double_t * GetEZlow() const override
void Set(Int_t n) override
Set number of points in the 2D graph.
void SetPoint(Int_t i, Double_t x, Double_t y, Double_t z) override
Set x, y and z values for point number i.
Double_t * GetEXlow() const override
TH2D * GetHistogram(Option_t *option="")
By default returns a pointer to the Delaunay histogram.
TAxis * GetZaxis() const
Get z axis of the graph.
void SetName(const char *name) override
Changes the name of this 2D graph.
void SetTitle(const char *title="") override
Sets the 2D graph title.
TAxis * GetYaxis() const
Get y axis of the graph.
TAxis * GetXaxis() const
Get x axis of the graph.
TGraph with asymmetric error bars.
Double_t * GetEXlow() const override
virtual void SetPointError(Double_t exl, Double_t exh, Double_t eyl, Double_t eyh)
Set ex and ey values for point pointed by the mouse.
Double_t * GetEYhigh() const override
Double_t * GetEXhigh() const override
Double_t * GetEYlow() const override
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
void SetName(const char *name="") override
Set graph name.
TAxis * GetXaxis() const
Get x axis of the graph.
TAxis * GetYaxis() const
Get y axis of the graph.
virtual TH1F * GetHistogram() const
Returns a pointer to the histogram used to draw the axis Takes into account the two following cases.
void SetTitle(const char *title="") override
Change (i.e.
virtual void Set(Int_t n)
Set number of points in the graph Existing coordinates are preserved New coordinates above fNpoints a...
1-D histogram with a double per channel (see TH1 documentation)
1-D histogram with a float per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
virtual void GetStats(Double_t *stats) const
fill the array stats from the contents of this histogram The array stats must be correctly dimensione...
void SetTitle(const char *title) override
Change/set the title.
virtual Int_t GetNbinsY() const
virtual Int_t GetNbinsZ() const
virtual Int_t GetDimension() const
@ kIsAverage
Bin contents are average (used by Add)
virtual Int_t GetNbinsX() const
@ kNstat
Size of statistics data (up to TProfile3D)
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual Int_t GetSumw2N() const
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
static Bool_t AddDirectoryStatus()
Check whether TH1-derived classes should register themselves to the current gDirectory.
static void SavePrimitiveFunctions(std::ostream &out, const char *varname, TList *lst)
Save list of functions Also can be used by TGraph classes.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
2-D histogram with a double per channel (see TH1 documentation)
2-D histogram with a float per channel (see TH1 documentation)
Service class for 2-D histogram classes.
void SetBinContent(Int_t bin, Double_t content) override
Set bin content.
3-D histogram with a double per channel (see TH1 documentation)
The 3-D histogram classes derived from the 1-D histogram classes.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
TObject()
TObject constructor.
static TString SavePrimitiveVector(std::ostream &out, const char *prefix, Int_t len, Double_t *arr, Int_t flag=0)
Save array in the output stream "out" as vector.
@ kInvalidObject
if object ctor succeeded but object should not be used
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
void ToLower()
Change string to lower-case.
TString & Insert(Ssiz_t pos, const char *s)
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Ssiz_t First(char c) const
Find first occurrence of a character c.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
TString & Append(const char *cs)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
double beta_pdf(double x, double a, double b)
Probability density function of the beta distribution.
double beta_cdf(double x, double a, double b)
Cumulative distribution function of the beta distribution Upper tail of the integral of the beta_pdf.
double beta_cdf_c(double x, double a, double b)
Complement of the cumulative distribution function of the beta distribution.
double normal_quantile(double z, double sigma)
Inverse ( ) of the cumulative distribution function of the lower tail of the normal (Gaussian) distri...
double normal_quantile_c(double z, double sigma)
Inverse ( ) of the cumulative distribution function of the upper tail of the normal (Gaussian) distri...
double beta_quantile_c(double x, double a, double b)
Inverse ( ) of the cumulative distribution function of the lower tail of the beta distribution (beta_...
double beta_quantile(double x, double a, double b)
Inverse ( ) of the cumulative distribution function of the upper tail of the beta distribution (beta_...
R__ALWAYS_INLINE bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
bool ObjectAutoRegistrationEnabled()
Test whether objects in this thread auto-register themselves, e.g.
Bool_t AreEqualRel(Double_t af, Double_t bf, Double_t relPrec)
Comparing floating points.
Beta_interval_length(Double_t level, Double_t alpha, Double_t beta)
Double_t operator()(double lower) const