1#ifndef ROOT_TEfficiency_cxx
2#define ROOT_TEfficiency_cxx
703fPassedHistogram(nullptr),
704fTotalHistogram(nullptr),
710 fPassedHistogram =
new TH1F(
"h_passed",
"passed",10,0,10);
711 fTotalHistogram =
new TH1F(
"h_total",
"total",10,0,10);
744 if(CheckConsistency(passed,
total)) {
748 fTotalHistogram = (
TH1*)
total.Clone();
749 fPassedHistogram = (
TH1*)passed.
Clone();
757 if(CheckWeights(passed,
total))
759 Info(
"TEfficiency",
"given histograms are filled with weights");
760 SetUseWeightedEvents();
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)");
769 fTotalHistogram =
new TH1D(
"h1_total",
"h1 (total)",10,0,10);
770 fPassedHistogram =
new TH1D(
"h1_passed",
"h1 (passed)",10,0,10);
773 SetBit(kPosteriorMode,
false);
774 SetBit(kShortestInterval,
false);
777 SetDirectory(
nullptr);
814 fTotalHistogram =
new TH1D(
"total",
"total",nbins,xbins);
815 fPassedHistogram =
new TH1D(
"passed",
"passed",nbins,xbins);
854 fTotalHistogram =
new TH1D(
"total",
"total",nbinsx,xlow,xup);
855 fPassedHistogram =
new TH1D(
"passed",
"passed",nbinsx,xlow,xup);
897 fTotalHistogram =
new TH2D(
"total",
"total",nbinsx,xlow,xup,nbinsy,ylow,yup);
898 fPassedHistogram =
new TH2D(
"passed",
"passed",nbinsx,xlow,xup,nbinsy,ylow,yup);
940 fTotalHistogram =
new TH2D(
"total",
"total",nbinsx,xbins,nbinsy,ybins);
941 fPassedHistogram =
new TH2D(
"passed",
"passed",nbinsx,xbins,nbinsy,ybins);
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);
1027fPaintGraph(nullptr),
1028fPaintHisto(nullptr),
1034 fTotalHistogram =
new TH3D(
"total",
"total",nbinsx,xbins,nbinsy,ybins,nbinsz,zbins);
1035 fPassedHistogram =
new TH3D(
"passed",
"passed",nbinsx,xbins,nbinsy,ybins,nbinsz,zbins);
1062 fBeta_alpha(rEff.fBeta_alpha),
1063 fBeta_beta(rEff.fBeta_beta),
1064 fBeta_bin_params(rEff.fBeta_bin_params),
1065 fConfLevel(rEff.fConfLevel),
1066 fDirectory(nullptr),
1067 fFunctions(nullptr),
1068 fPaintGraph(nullptr),
1069 fPaintHisto(nullptr),
1070 fWeight(rEff.fWeight)
1073 rEff.TObject::Copy(*
this);
1091 SetDirectory(
nullptr);
1094 rEff.TAttLine::Copy(*
this);
1095 rEff.TAttFill::Copy(*
this);
1096 rEff.TAttMarker::Copy(*
this);
1157 Double_t mode = (passed + 0.5 * kappa * kappa) / (
total + kappa * kappa);
1158 Double_t delta = kappa * std::sqrt(mode * (1 - mode) / (
total + kappa * kappa));
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;
1210 FeldmanCousinsBinomialInterval fc;
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");
1374struct Beta_interval_length {
1376 fCL(level), fAlpha(alpha), fBeta(
beta)
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) {
1441 Beta_interval_length intervalLength(level,
a,
b);
1443 ROOT::Math::WrappedFunction<const Beta_interval_length &> func(intervalLength);
1444 ROOT::Math::BrentMinimizer1D minim;
1445 minim.
SetFunction(func, 0, intervalLength.LowerMax() );
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;
1559 gROOT->Info(
"TEfficiency::CheckBinning",
"Histograms are not consistent: they have different number of bins");
1563 for(
Int_t i = 1; i <= ax1->GetNbins() + 1; ++i)
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");
1683 TGraphAsymmErrors * graph =
new TGraphAsymmErrors(npoints);
1697 Error(
"CreatePaintingGraph",
"Call this function only for dimension == 2");
1702 TGraph2DAsymmErrors * graph =
new TGraph2DAsymmErrors(npoints);
1715 TString option = opt;
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() ) {
1774 TString oldTitle = graph->
GetTitle();
1776 if (oldTitle != newTitle ) {
1795 for (
int ibin = 1; ibin <=
fTotalHistogram->GetXaxis()->GetNbins(); ++ibin) {
1802 for (
int ibin = 1; ibin <=
fTotalHistogram->GetYaxis()->GetNbins(); ++ibin) {
1818 TString option = opt;
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() ) {
1865 TString oldTitle = graph->
GetTitle();
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;
2125 TString option(opt);
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)
2175 if (option.
Contains(
"mode"))
return mode;
2213 TString opt = option;
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];
2382 TGraphAsymmErrors*
gr =
new TGraphAsymmErrors(nbins_max,&
x[0],&eff[0],&xlow[0],&xhigh[0],&efflow[0],&effhigh[0]);
2421 TString option = opt;
2428 if (option.
IsNull()) option =
"colz";
2431 if (option.
IsNull()) option =
"ap";
2435 if (!option.
Contains(
"p") ) option +=
"p";
2565 TString option = opt;
2569 Bool_t bDeleteOld =
true;
2577 TFitResultPtr result = Fitter.Fit(
f1,option.
Data());
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;
2760 if (tw2 <= 0)
return 0;
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;
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);
3096 TString option(opt);
3118 while ((obj = next())) {
3121 ((TF1 *)obj)->Paint(
"sameC");
3129 bool drawGraph2D =
false;
3144 if (option.
IsNull()) option +=
"ERR PCOL Z";
3157 Warning(
"Paint",
"Painting 3D efficiency is not implemented");
3188 thread_local Int_t eff_count = 0;
3196 TString sxaxis, syaxis, szaxis;
3214 << TString(
GetTitle()).ReplaceSpecialCppChars() <<
"\"";
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);
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);
3516 TString name_total =
name + TString(
"_total");
3517 TString name_passed =
name + TString(
"_passed");
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);
3563 TString option = opt;
3694 TString title_passed = title;
3695 TString title_total = title;
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);
3757 TString option = opt;
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;
3844 Double_t mode = (passed + 0.5 * kappa * kappa) / (
total + kappa * kappa);
3846 * (1 - average) + kappa * kappa / 4);
3848 return ((mode + delta) > 1) ? 1.0 : (mode + delta);
3850 return ((mode - delta) < 0) ? 0.0 : (mode - delta);
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).
bool Bool_t
Boolean (0=false, 1=true) (bool).
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).
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
const Double_t kDefBetaAlpha
const Double_t kDefWeight
const Double_t kDefBetaBeta
const TEfficiency::EStatOption kDefStatOpt
const Double_t kDefConfLevel
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
static unsigned int total
TRObject operator()(const T1 &t1) const
TString operator+(const TString &s1, const TString &s2)
Use the special concatenation constructor.
void Calculate(const double X, const double n)
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.
const Double_t * GetArray() const
void Copy(TAttFill &attfill) const
virtual void SaveFillAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1001)
virtual void SaveLineAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t widdef=1)
void Copy(TAttLine &attline) const
void Copy(TAttMarker &attmarker) const
virtual void SaveMarkerAttributes(std::ostream &out, const char *name, Int_t coldef=1, Int_t stydef=1, Int_t sizdef=1)
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 Int_t FindFixBin(Double_t x) const
Find bin number corresponding to abscissa x.
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Collection abstract base class.
virtual Bool_t IsEmpty() const
TDirectory::TContext keeps track and restore the current directory.
Describe directory structure in memory.
void FillGraph2D(TGraph2DAsymmErrors *graph, Option_t *opt) const
void Draw(Option_t *opt="") override
Default Draw method for all objects.
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to an event at (px,py).
TH2 * CreateHistogram(Option_t *opt="") const
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)
static Double_t AgrestiCoull(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
TList * GetListOfFunctions()
Long64_t Merge(TCollection *list)
std::vector< std::pair< Double_t, Double_t > > fBeta_bin_params
Parameter for prior beta distribution different bin by bin (default vector is empty).
EStatOption fStatisticOption
Defines how the confidence intervals are determined.
void SetStatisticOption(EStatOption option)
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="")
void Paint(Option_t *opt) override
This method must be overridden if a class wants to paint itself.
void SetWeight(Double_t weight)
static Double_t BetaMode(Double_t alpha, Double_t beta)
TH1 * fTotalHistogram
Histogram for total number of events.
Int_t GetDimension() const
TGraph2DAsymmErrors * fPaintGraph2D
! Temporary graph for painting
TEfficiency & operator+=(const TEfficiency &rhs)
Bool_t SetBins(Int_t nx, Double_t xmin, Double_t xmax)
void Build(const char *name, const char *title)
TH1 * GetCopyPassedHisto() const
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)
Double_t GetEfficiencyErrorUp(Int_t bin) const
static Bool_t CheckConsistency(const TH1 &pass, const TH1 &total, Option_t *opt="")
static Double_t MidPInterval(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Double_t fBeta_alpha
Global parameter for prior beta distribution (default = 1).
Bool_t UsesBayesianStat() const
static Bool_t CheckWeights(const TH1 &pass, const TH1 &total)
void SavePrimitive(std::ostream &out, Option_t *opt="") override
Save a primitive as a C++ statement(s) on output stream "out".
static Double_t Wilson(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
static Double_t Normal(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
void SetBetaBeta(Double_t beta)
Double_t GetConfidenceLevel() const
void SetName(const char *name) override
Set the name of the TNamed.
TGraph2DAsymmErrors * CreateGraph2D(Option_t *opt="") const
Bool_t SetPassedEvents(Int_t bin, Double_t events)
Int_t GetGlobalBin(Int_t binx, Int_t biny=0, Int_t binz=0) const
TH1 * fPassedHistogram
Histogram for events which passed certain criteria.
void SetBetaAlpha(Double_t alpha)
@ 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 Double_t FeldmanCousins(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Double_t fWeight
Weight for all events (default = 1).
Bool_t SetPassedHistogram(const TH1 &rPassed, Option_t *opt)
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
static Double_t BetaCentralInterval(Double_t level, Double_t alpha, Double_t beta, Bool_t bUpper)
void FillHistogram(TH2 *h2) const
Int_t FindFixBin(Double_t x, Double_t y=0, Double_t z=0) const
TDirectory * fDirectory
! Pointer to directory holding this TEfficiency object
void SetUseWeightedEvents(Bool_t on=kTRUE)
TEfficiency & operator=(const TEfficiency &rhs)
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Computes distance from point (px,py) to the object.
Double_t fConfLevel
Confidence level (default = 0.683, 1 sigma).
static Double_t ClopperPearson(Double_t total, Double_t passed, Double_t level, Bool_t bUpper)
Double_t fBeta_beta
Global parameter for prior beta distribution (default = 1).
Double_t GetEfficiency(Int_t bin) const
Bool_t SetTotalHistogram(const TH1 &rTotal, Option_t *opt)
void Fill(Bool_t bPassed, Double_t x, Double_t y=0, Double_t z=0)
void SetDirectory(TDirectory *dir)
static Double_t BetaMean(Double_t alpha, Double_t beta)
static Bool_t CheckEntries(const TH1 &pass, const TH1 &total, Option_t *opt="")
TGraphAsymmErrors * fPaintGraph
! Temporary graph for painting
TGraphAsymmErrors * CreateGraph(Option_t *opt="") const
static Bool_t BetaShortestInterval(Double_t level, Double_t alpha, Double_t beta, Double_t &lower, Double_t &upper)
EStatOption GetStatisticOption() const
TList * fFunctions
->Pointer to list of functions
Bool_t SetTotalEvents(Int_t bin, Double_t events)
void SetBetaBinParameters(Int_t bin, Double_t alpha, Double_t beta)
Double_t GetWeight() const
static Bool_t FeldmanCousinsInterval(Double_t total, Double_t passed, Double_t level, Double_t &lower, Double_t &upper)
TH1 * GetCopyTotalHisto() const
void SetConfidenceLevel(Double_t level)
Double_t GetEfficiencyErrorLow(Int_t bin) const
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).
static Bool_t CheckBinning(const TH1 &pass, const TH1 &total)
void SetTitle(const char *title) override
Set the title of the TNamed.
TFitResultPtr Fit(TF1 *f1, Option_t *opt="")
void RecursiveRemove(TObject *obj) override
Recursively remove this object from a list.
TH2 * fPaintHisto
! Temporary histogram for painting
void Copy(TObject &f1) const override
Copy this to obj.
TClass * IsA() const override
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Double_t * GetEYlow() const override
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
void SetPoint(Int_t i, Double_t x, Double_t y, Double_t z) 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)
Double_t * GetEXlow() const override
TH2D * GetHistogram(Option_t *option="")
void SetName(const char *name) override
Set the name of the TNamed.
void SetTitle(const char *title="") override
Set the title of the TNamed.
Double_t * GetEXlow() const override
virtual void SetPointError(Double_t exl, Double_t exh, Double_t eyl, Double_t eyh)
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)
virtual void Set(Int_t n)
virtual TH1F * GetHistogram() const
void SetName(const char *name="") override
Set the name of the TNamed.
void SetTitle(const char *title="") override
Set the title of the TNamed.
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 GetBin(Int_t binx, Int_t biny=0, Int_t binz=0) const
Return Global bin number corresponding to binx,y,z.
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)
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 TNamed class is the base class for all named ROOT 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.
Mother of all ROOT objects.
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)
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)
void ToUpper()
Change string to upper case.
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_...
double beta(double x, double y)
Calculates the beta function.
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.
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
Bool_t AreEqualRel(Double_t af, Double_t bf, Double_t relPrec)
Comparing floating points.