Example: create a twodimensional TEfficiency object with - name = "eff" - title = "my efficiency" - axistitles: x, y and LaTeX formated epsilon as label for Z axis - 10 bins with constant bin width (= 1) along X axis starting at 0 (lower edge from first bin) upto 10 (upper edge of last bin) - 20 bins with constant bin width (= 0.5) along Y axis starting at -5 (lower edge from first bin) upto 5 (upper edge of last bin) TEfficiency* pEff = new TEfficiency("eff","my efficiency;x;y;#epsilon",10,0,10,20,-5,5);
Example 1: TEfficiency* pEff = 0; TFile* pFile = new TFile("myfile.root","recreate"); //h_pass and h_total are valid and consistent histograms if(TEfficiency::CheckConsistency(h_pass,h_total)) { pEff = new TEfficiency(h_pass,h_total); // this will write the TEfficiency object to "myfile.root" // AND pEff will be attached to the current directory pEff->Write(); } Example 2: TEfficiency* pEff = 0; TFile* pFile = new TFile("myfile.root","recreate"); //h_pass and h_total are valid and consistent histograms if(TEfficiency::CheckConsistency(h_pass,h_total)) { pEff = new TEfficiency(h_pass,h_total); //this will attach the TEfficiency object to the current directory pEff->SetDirectory(gDirectory); //now all objects in gDirectory will be written to "myfile.root" pFile->Write(); }
{ //canvas only needed for this documentation TCanvas* c1 = new TCanvas("example","",600,400); c1->SetFillStyle(1001); c1->SetFillColor(kWhite); //create one-dimensional TEfficiency object with fixed bin size TEfficiency* pEff = new TEfficiency("eff","my efficiency;x;#epsilon",20,0,10); TRandom3 rand; bool bPassed; double x; for(int i=0; i<10000; ++i) { //simulate events with variable under investigation x = rand.Uniform(10); //check selection: bPassed = DoesEventPassSelection(x) bPassed = rand.Rndm() < TMath::Gaus(x,5,4); pEff->Fill(bPassed,x); } pEff->Draw("AP"); //only for this documentation return c1; }
You can also set the number of passed or total events for a bin directly by using the SetPassedEvents or SetTotalEvents method.
Bayesian methods
By default the expectation value of this posterior distribution is used as estimator for the efficiency:
Optionally the mode can also be used as value for the estimated efficiency. This can be done by calling SetBit(kPosteriorMode) or SetPosteriorMode. In this case the estimated efficiency is:
In the case of a uniform prior distribution, B(x,1,1), the posterior mode is k/n, equivalent to the frequentist estimate (the maximum likelihood value). The statistic options also specifiy which confidence interval is used for calculating the uncertainties of the efficiency. The following properties define the error calculation:
name | statistic option | function | kIsBayesian | parameters |
---|---|---|---|---|
Clopper-Pearson | kFCP | ClopperPearson | false |
|
normal approximation | kFNormal | Normal | false |
|
Wilson | kFWilson | Wilson | false |
|
Agresti-Coull | kFAC | AgrestiCoull | false |
|
Feldman-Cousins | kFFC | FeldmanCousins | false |
|
Jeffrey | kBJeffrey | Bayesian | true |
|
Uniform prior | kBUniform | Bayesian | true |
|
custom prior | kBBayesian | Bayesian | true |
|
{ //canvas only needed for the documentation TCanvas* c1 = new TCanvas("c1","",600,400); c1->Divide(2); c1->SetFillStyle(1001); c1->SetFillColor(kWhite); //create one-dimensional TEfficiency object with fixed bin size TEfficiency* pEff = new TEfficiency("eff","different confidence levels;x;#epsilon",20,0,10); TRandom3 rand; bool bPassed; double x; for(int i=0; i<1000; ++i) { //simulate events with variable under investigation x = rand.Uniform(10); //check selection: bPassed = DoesEventPassSelection(x) bPassed = rand.Rndm() < TMath::Gaus(x,5,4); pEff->Fill(bPassed,x); } //set style attributes pEff->SetFillStyle(3004); pEff->SetFillColor(kRed); //copy current TEfficiency object and set new confidence level TEfficiency* pCopy = new TEfficiency(*pEff); pCopy->SetConfidenceLevel(0.90); //set style attributes pCopy->SetFillStyle(3005); pCopy->SetFillColor(kBlue); c1->cd(1); //add legend TLegend* leg1 = new TLegend(0.3,0.1,0.7,0.5); leg1->AddEntry(pEff,"95%","F"); leg1->AddEntry(pCopy,"68.3%","F"); pEff->Draw("A4"); pCopy->Draw("same4"); leg1->Draw("same"); //use same confidence level but different statistic methods TEfficiency* pEff2 = new TEfficiency(*pEff); TEfficiency* pCopy2 = new TEfficiency(*pEff); pEff2->SetStatisticOption(TEfficiency::kFNormal); pCopy2->SetStatisticOption(TEfficiency::kFAC); pEff2->SetTitle("different statistic options;x;#epsilon"); //set style attributes pCopy2->SetFillStyle(3005); pCopy2->SetFillColor(kBlue); c1->cd(2); //add legend TLegend* leg2 = new TLegend(0.3,0.1,0.7,0.5); leg2->AddEntry(pEff2,"kFNormal","F"); leg2->AddEntry(pCopy2,"kFAC","F"); pEff2->Draw("a4"); pCopy2->Draw("same4"); leg2->Draw("same"); //only for this documentation c1->cd(0); return c1; }
The prior probability of the efficiency in bayesian statistics can be given in terms of a beta distribution. The beta distribution has to positive shape parameters. The resulting priors for different combinations of these shape parameters are shown in the plot below.
{ //canvas only needed for the documentation TCanvas* c1 = new TCanvas("c1","",600,400); c1->SetFillStyle(1001); c1->SetFillColor(kWhite); //create different beta distributions TF1* f1 = new TF1("f1","TMath::BetaDist(x,1,1)",0,1); f1->SetLineColor(kBlue); TF1* f2 = new TF1("f2","TMath::BetaDist(x,0.5,0.5)",0,1); f2->SetLineColor(kRed); TF1* f3 = new TF1("f3","TMath::BetaDist(x,1,5)",0,1); f3->SetLineColor(kGreen+3); f3->SetTitle("Beta distributions as priors;#epsilon;P(#epsilon)"); TF1* f4 = new TF1("f4","TMath::BetaDist(x,4,3)",0,1); f4->SetLineColor(kViolet); //add legend TLegend* leg = new TLegend(0.25,0.5,0.85,0.89); leg->SetFillColor(kWhite); leg->SetFillStyle(1001); leg->AddEntry(f1,"a=1, b=1","L"); leg->AddEntry(f2,"a=0.5, b=0.5","L"); leg->AddEntry(f3,"a=1, b=5","L"); leg->AddEntry(f4,"a=4, b=3","L"); f3->Draw(); f1->Draw("same"); f2->Draw("Same"); f4->Draw("same"); leg->Draw("same"); //only for this documentation return c1; }
The reason for different weights can therefore be:
Example:
Example:
Example: //open a root file which contains a TEfficiency object TFile* pFile = new TFile("myfile.root","update"); //get TEfficiency object with name "my_eff" TEfficiency* pEff = (TEfficiency*)pFile->Get("my_eff"); //get clone of total histogram TH1* clone = pEff->GetCopyTotalHisto(); //change clone... //save changes of clone directly clone->Write(); //or append it to the current directoy and write the file //clone->SetDirectory(gDirectory); //pFile->Wrtie(); //delete histogram object delete clone; clone = 0;
{ //canvas only needed for this documentation TCanvas* c1 = new TCanvas("example","",600,400); c1->SetFillStyle(1001); c1->SetFillColor(kWhite); //create one-dimensional TEfficiency object with fixed bin size TEfficiency* pEff = new TEfficiency("eff","my efficiency;x;#epsilon",20,0,10); TRandom3 rand; bool bPassed; double x; for(int i=0; i<10000; ++i) { //simulate events with variable under investigation x = rand.Uniform(10); //check selection: bPassed = DoesEventPassSelection(x) bPassed = rand.Rndm() < TMath::Gaus(x,5,4); pEff->Fill(bPassed,x); } //create a function for fitting and do the fit TF1* f1 = new TF1("f1","gaus",0,10); f1->SetParameters(1,5,2); pEff->Fit(f1); //create a threshold function TF1* f2 = new TF1("thres","0.8",0,10); f2->SetLineColor(kRed); //add it to the list of functions //use add first because the parameters of the last function will be displayed pEff->GetListOfFunctions()->AddFirst(f2); pEff->Draw("AP"); //only for this documentation return c1; }
void | Build(const char* name, const char* title) |
virtual void | TObject::DoError(int level, const char* location, const char* fmt, va_list va) const |
void | FillGraph(TGraphAsymmErrors* graph, Option_t* opt) const |
void | FillHistogram(TH2* h2) const |
void | TObject::MakeZombie() |
enum EStatOption { | kFCP | |
kFNormal | ||
kFWilson | ||
kFAC | ||
kFFC | ||
kBJeffrey | ||
kBUniform | ||
kBBayesian | ||
}; | ||
enum { | kIsBayesian | |
kPosteriorMode | ||
kShortestInterval | ||
kUseBinPrior | ||
kUseWeights | ||
}; | ||
enum TObject::EStatusBits { | kCanDelete | |
kMustCleanup | ||
kObjInCanvas | ||
kIsReferenced | ||
kHasUUID | ||
kCannotPick | ||
kNoContextMenu | ||
kInvalidObject | ||
}; | ||
enum TObject::[unnamed] { | kIsOnHeap | |
kNotDeleted | ||
kZombie | ||
kBitMask | ||
kSingleKey | ||
kOverwrite | ||
kWriteDelete | ||
}; |
Double_t | fBeta_alpha | global parameter for prior beta distribution (default = 1) |
Double_t | fBeta_beta | global parameter for prior beta distribution (default = 1) |
vector<std::pair<Double_t,Double_t> > | fBeta_bin_params | parameter for prior beta distribution different bin by bin |
void | fBoundary | !pointer to a method calculating the boundaries of confidence intervals |
Double_t | fConfLevel | confidence level (default = 0.683, 1 sigma) |
TDirectory* | fDirectory | !pointer to directory holding this TEfficiency object |
Color_t | TAttFill::fFillColor | fill area color |
Style_t | TAttFill::fFillStyle | fill area style |
TList* | fFunctions | ->pointer to list of functions |
Color_t | TAttLine::fLineColor | line color |
Style_t | TAttLine::fLineStyle | line style |
Width_t | TAttLine::fLineWidth | line width |
Color_t | TAttMarker::fMarkerColor | Marker color index |
Size_t | TAttMarker::fMarkerSize | Marker size |
Style_t | TAttMarker::fMarkerStyle | Marker style |
TString | TNamed::fName | object identifier |
TGraphAsymmErrors* | fPaintGraph | !temporary graph for painting |
TH2* | fPaintHisto | !temporary histogram for painting |
TH1* | fPassedHistogram | histogram for events which passed certain criteria |
TEfficiency::EStatOption | fStatisticOption | defines how the confidence intervals are determined |
TString | TNamed::fTitle | object title |
TH1* | fTotalHistogram | histogram for total number of events |
Double_t | fWeight | weight for all events (default = 1) |
constructor using two existing histograms as input Input: passed - contains the events fullfilling some criteria total - contains all investigated events Notes: - both histograms have to fullfill the conditions of CheckConsistency (with option 'w') - dimension of the resulating efficiency object depends on the dimension of the given histograms - Clones of both histograms are stored internally - The function SetName(total.GetName() + "_clone") is called to set the names of the new object and the internal histograms.. - The created TEfficiency object is NOT appended to a directory. It will not be written to disk during the next TFile::Write() command in order to prevent duplication of data. If you want to save this TEfficiency object anyway, you can either append it to a directory by calling SetDirectory(TDirectory*) or write it explicitly to disk by calling Write().
create 1-dimensional TEfficiency object with variable bin size constructor creates two new and empty histograms with a given binning Input: name - the common part of the name for both histograms (no blanks) fTotalHistogram has name: name + "_total" fPassedHistogram has name: name + "_passed" title - the common part of the title for both histogram fTotalHistogram has title: title + " (total)" fPassedHistogram has title: title + " (passed)" It is possible to label the axis by passing a title with the following format: "title;xlabel;ylabel". nbins - number of bins on the x-axis xbins - array of length (nbins + 1) with low-edges for each bin xbins[nbinsx] ... lower edge for overflow bin
create 1-dimensional TEfficiency object with fixed bins isze constructor creates two new and empty histograms with a fixed binning Input: name - the common part of the name for both histograms(no blanks) fTotalHistogram has name: name + "_total" fPassedHistogram has name: name + "_passed" title - the common part of the title for both histogram fTotalHistogram has title: title + " (total)" fPassedHistogram has title: title + " (passed)" It is possible to label the axis by passing a title with the following format: "title;xlabel;ylabel". nbinsx - number of bins on the x-axis xlow - lower edge of first bin xup - upper edge of last bin
create 2-dimensional TEfficiency object with fixed bin size constructor creates two new and empty histograms with a fixed binning Input: name - the common part of the name for both histograms(no blanks) fTotalHistogram has name: name + "_total" fPassedHistogram has name: name + "_passed" title - the common part of the title for both histogram fTotalHistogram has title: title + " (total)" fPassedHistogram has title: title + " (passed)" It is possible to label the axis by passing a title with the following format: "title;xlabel;ylabel;zlabel". nbinsx - number of bins on the x-axis xlow - lower edge of first x-bin xup - upper edge of last x-bin nbinsy - number of bins on the y-axis ylow - lower edge of first y-bin yup - upper edge of last y-bin
create 2-dimensional TEfficiency object with variable bin size constructor creates two new and empty histograms with a given binning Input: name - the common part of the name for both histograms(no blanks) fTotalHistogram has name: name + "_total" fPassedHistogram has name: name + "_passed" title - the common part of the title for both histogram fTotalHistogram has title: title + " (total)" fPassedHistogram has title: title + " (passed)" It is possible to label the axis by passing a title with the following format: "title;xlabel;ylabel;zlabel". nbinsx - number of bins on the x-axis xbins - array of length (nbins + 1) with low-edges for each bin xbins[nbinsx] ... lower edge for overflow x-bin nbinsy - number of bins on the y-axis ybins - array of length (nbins + 1) with low-edges for each bin ybins[nbinsy] ... lower edge for overflow y-bin
create 3-dimensional TEfficiency object with fixed bin size constructor creates two new and empty histograms with a fixed binning Input: name - the common part of the name for both histograms(no blanks) fTotalHistogram has name: name + "_total" fPassedHistogram has name: name + "_passed" title - the common part of the title for both histogram fTotalHistogram has title: title + " (total)" fPassedHistogram has title: title + " (passed)" It is possible to label the axis by passing a title with the following format: "title;xlabel;ylabel;zlabel". nbinsx - number of bins on the x-axis xlow - lower edge of first x-bin xup - upper edge of last x-bin nbinsy - number of bins on the y-axis ylow - lower edge of first y-bin yup - upper edge of last y-bin nbinsz - number of bins on the z-axis zlow - lower edge of first z-bin zup - upper edge of last z-bin
create 3-dimensional TEfficiency object with variable bin size constructor creates two new and empty histograms with a given binning Input: name - the common part of the name for both histograms(no blanks) fTotalHistogram has name: name + "_total" fPassedHistogram has name: name + "_passed" title - the common part of the title for both histogram fTotalHistogram has title: title + " (total)" fPassedHistogram has title: title + " (passed)" It is possible to label the axis by passing a title with the following format: "title;xlabel;ylabel;zlabel". nbinsx - number of bins on the x-axis xbins - array of length (nbins + 1) with low-edges for each bin xbins[nbinsx] ... lower edge for overflow x-bin nbinsy - number of bins on the y-axis ybins - array of length (nbins + 1) with low-edges for each bin xbins[nbinsx] ... lower edge for overflow y-bin nbinsz - number of bins on the z-axis zbins - array of length (nbins + 1) with low-edges for each bin xbins[nbinsx] ... lower edge for overflow z-bin
copy constructor The list of associated objects (e.g. fitted functions) is not copied. Note: - SetName(rEff.GetName() + "_copy") is called to set the names of the object and the histograms. - The titles are set by calling SetTitle("[copy] " + rEff.GetTitle()). - The copied TEfficiency object is NOT appended to a directory. It will not be written to disk during the next TFile::Write() command in order to prevent duplication of data. If you want to save this TEfficiency object anyway, you can either append it to a directory by calling SetDirectory(TDirectory*) or write it explicitly to disk by calling Write().
calculates the interval boundaries using the frequentist methods of Feldman-Cousins Input: - total : number of total events - passed: 0 <= number of passed events <= total - level : confidence level Output: - lower : lower boundary returned on exit - upper : lower boundary returned on exit Return a flag with the status of the calculation Calculation: The Feldman-Cousins is a frequentist method where the interval is estimated using a Neyman construction where the ordering is based on the likelihood ratio: See G. J. Feldman and R. D. Cousins, Phys. Rev. D57 (1998) 3873 and R. D. Cousins, K. E. Hymes, J. Tucker, Nuclear Instruments and Methods in Physics Research A 612 (2010) 388 Implemented using classes developed by Jordan Tucker and Luca Lista See File hist/hist/src/TEfficiencyHelper.h
calculates the boundaries for a Bayesian confidence interval (shortest or central interval depending on the option) Input: - total : number of total events - passed: 0 <= number of passed events <= total - level : confidence level - alpha : shape parameter > 0 for the prior distribution (fBeta_alpha) - beta : shape parameter > 0 for the prior distribution (fBeta_beta) - bUpper: true - upper boundary is returned false - lower boundary is returned Note: In the case central confidence interval is calculated. when passed = 0 (or passed = total) the lower (or upper) interval values will be larger than 0 (or smaller than 1). Calculation: The posterior probability in bayesian statistics is given by: As an efficiency can be interpreted as probability of a positive outcome of a Bernoullli trial the likelihood function is given by the binomial distribution: At the moment only beta distributions are supported as prior probabilities of the efficiency ( is the beta function): The posterior probability is therefore again given by a beta distribution: In case of central intervals the lower boundary for the equal-tailed confidence interval is given by the inverse cumulative (= quantile) function for the quantile . The upper boundary for the equal-tailed confidence interval is given by the inverse cumulative (= quantile) function for the quantile . Hence it is the solution of the following equation: In the case of shortest interval the minimum interval aorund the mode is found by minimizing the length of all intervals whith the given probability content. See TEfficiency::BetaShortestInterval
calculates the boundaries for a central confidence interval for a Beta distribution Input: - level : confidence level - a : parameter > 0 for the beta distribution (for a posterior is passed + prior_alpha - b : parameter > 0 for the beta distribution (for a posterior is (total-passed) + prior_beta - bUpper: true - upper boundary is returned false - lower boundary is returned
calculates the boundaries for a shortest confidence interval for a Beta distribution Input: - level : confidence level - a : parameter > 0 for the beta distribution (for a posterior is passed + prior_alpha - b : parameter > 0 for the beta distribution (for a posterior is (total-passed) + prior_beta - bUpper: true - upper boundary is returned false - lower boundary is returned The lower/upper boundary are then obtained by finding the shortest interval of the beta distribbution contained the desired probability level. The length of all possible intervals is minimized in order to find the shortest one
compute the mean (average) of the beta distribution Input: a : parameter > 0 for the beta distribution (for a posterior is passed + prior_alpha b : parameter > 0 for the beta distribution (for a posterior is (total-passed) + prior_beta
compute the mode of the beta distribution Input: a : parameter > 0 for the beta distribution (for a posterior is passed + prior_alpha b : parameter > 0 for the beta distribution (for a posterior is (total-passed) + prior_beta note the mode is defined for a Beta(a,b) only if (a,b)>1 (a = passed+alpha; b = total-passed+beta) return then the following in case (a,b) < 1: if (a==b) return 0.5 (it is really undefined) if (a < b) return 0; if (a > b) return 1;
building standard data structure of a TEfficiency object Notes: - calls: SetName(name), SetTitle(title) - set the statistic option to the default (kFCP) - appends this object to the current directory SetDirectory(gDirectory)
checks binning for each axis It is assumed that the passed histograms have the same dimension.
checks the consistence of the given histograms The histograms are considered as consistent if: - both have the same dimension - both have the same binning - pass.GetBinContent(i) <= total.GetBinContent(i) for each bin i Option: - w: The check for unit weights is skipped and therefore histograms filled with weights are accepted.
checks whether bin contents are compatible with binomial statistics The following inequality has to be valid for each bin i: total.GetBinContent(i) >= pass.GetBinContent(i) and the histogram have to be filled with unit weights. Option: - w: Do not check for unit weights -> accept histograms filled with weights Note: - It is assumed that both histograms have the same dimension and binning.
Create the graph used be painted (for dim=1 TEfficiency) The return object is managed by the caller
Fill the graph to be painted with information from TEfficiency Internal metyhod called by TEfficiency::Paint or TEfficiency::CreateGraph
Create the histogram used to be painted (for dim=2 TEfficiency) The return object is managed by the caller
Fill the 2d histogram to be painted with information from TEfficiency 2D Internal metyhod called by TEfficiency::Paint or TEfficiency::CreatePaintingGraph
calculates the boundaries for the frequentist Clopper-Pearson interval This interval is recommended by the PDG. Input: - total : number of total events - passed: 0 <= number of passed events <= total - level : confidence level - bUpper: true - upper boundary is returned false - lower boundary is returned calculation: The lower boundary of the Clopper-Pearson interval is the "exact" inversion of the test: The lower boundary is therfore given by the quantile of the beta distribution. The upper boundary of the Clopper-Pearson interval is the "exact" inversion of the test: The upper boundary is therfore given by the quantile of the beta distribution. Note: The connection between the binomial distribution and the regularized incomplete beta function has been used.
calculates the combined efficiency and its uncertainties This method does a bayesian combination of the given samples. Input: - up : contains the upper limit of the confidence interval afterwards - low : contains the lower limit of the confidence interval afterwards - n : number of samples which are combined - pass : array of length n containing the number of passed events - total : array of length n containing the corresponding numbers of total events - alpha : shape parameters for the beta distribution as prior - beta : shape parameters for the beta distribution as prior - level : desired confidence level - w : weights for each sample; if not given, all samples get the weight 1 The weights do not need to be normalized, since they are internally renormalized to the number of effective entries. - options: + mode : The mode is returned instead of the mean of the posterior as best value When using the mode the shortest interval is also computed instead of the central one + shortest: compute shortest interval (done by default if mode option is set) + central: compute central interval (done by default if mode option is NOT set)Calculation:
Example (uniform prior distribution):
{ TCanvas* c1 = new TCanvas("c1","",600,800); c1->Divide(1,2); c1->SetFillStyle(1001); c1->SetFillColor(kWhite); TF1* p1 = new TF1("p1","TMath::BetaDist(x,19,9)",0,1); TF1* p2 = new TF1("p2","TMath::BetaDist(x,4,8)",0,1); TF1* comb = new TF1("comb2","TMath::BetaDist(x,[0],[1])",0,1); double norm = 1./(0.6*0.6+0.4*0.4); // weight normalization double b = 0.6*10+0.4*7+1.0; comb->SetParameters(norm*a ,norm *b ); TF1* const1 = new TF1("const1","0.05",0,1); TF1* const2 = new TF1("const2","0.95",0,1); p1->SetLineColor(kRed); p1->SetTitle("combined posteriors;#epsilon;P(#epsilon|k,N)"); p2->SetLineColor(kBlue); comb->SetLineColor(kGreen+2); TLegend* leg1 = new TLegend(0.12,0.65,0.5,0.85); leg1->AddEntry(p1,"k1 = 18, N1 = 26","l"); leg1->AddEntry(p2,"k2 = 3, N2 = 10","l"); leg1->AddEntry(comb,"combined: p1 = 0.6, p2=0.4","l"); c1->cd(1); comb->Draw(); p1->Draw("same"); p2->Draw("same"); leg1->Draw("same"); c1->cd(2); const1->SetLineWidth(1); const2->SetLineWidth(1); TGraph* gr = (TGraph*)comb->DrawIntegral(); gr->SetTitle("cumulative function of combined posterior with boundaries for cl = 95%;#epsilon;CDF"); const1->Draw("same"); const2->Draw("same"); c1->cd(0); return c1; }
combines a list of 1-dimensional TEfficiency objects A TGraphAsymmErrors object is returned which contains the estimated efficiency and its uncertainty for each bin. If the combination fails, a zero pointer is returned. At the moment the combining is only implemented for bayesian statistics. Input: - pList : list containing TEfficiency objects which should be combined only one-dimensional efficiencies are taken into account - options + s : strict combining; only TEfficiency objects with the same beta prior and the flag kIsBayesian == true are combined If not specified the prior parameter of the first TEfficiency object is used + v : verbose mode; print information about combining + cl=x : set confidence level (0 < cl < 1). If not specified, the confidence level of the first TEfficiency object is used. + mode Use mode of combined posterior as estimated value for the efficiency + shortest: compute shortest interval (done by default if mode option is set) + central: compute central interval (done by default if mode option is NOT set) - n : number of weights (has to be the number of one-dimensional TEfficiency objects in pList) If no weights are passed, the internal weights GetWeight() of the given TEfficiency objects are used. - w : array of length n with weights for each TEfficiency object in pList (w[0] correspond to pList->First ... w[n-1] -> pList->Last) The weights do not have to be normalised. For each bin the calculation is done by the Combine(double&, double& ...) method.
Compute distance from point px,py to a graph. Compute the closest distance of approach from point px,py to this line. The distance is computed in pixels units. Forward the call to the painted graph
draws the current TEfficiency object options: - 1-dimensional case: same options as TGraphAsymmErrors::Draw() but as default "AP" is used - 2-dimensional case: same options as TH2::Draw() - 3-dimensional case: not yet supported specific TEfficiency drawing options: - E0 - plot bins where the total number of passed events is zero (the error interval will be [0,1] )
Execute action corresponding to one event. This member function is called when the drawn class is clicked with the locator If Left button clicked on one of the line end points, this point follows the cursor until button is released. if Middle button clicked, the line is moved parallel to itself until the button is released. Forward the call to the underlying graph
This function is used for filling the two histograms. Input: bPassed - flag whether the current event passed the selection true: both histograms are filled false: only the total histogram is filled x - x value y - y value (use default=0 for 1-D efficiencies) z - z value (use default=0 for 2-D or 1-D efficiencies)
This function is used for filling the two histograms with a weight. Input: bPassed - flag whether the current event passed the selection true: both histograms are filled false: only the total histogram is filled weight - weight for the event x - x value y - y value (use default=0 for 1-D efficiencies) z - z value (use default=0 for 2-D or 1-D efficiencies) Note: - this function will call SetUseWeightedEvents if it was not called by the user before
returns the global bin number containing the given values Note: - values which belong to dimensions higher than the current dimension of the TEfficiency object are ignored (i.e. for 1-dimensional efficiencies only the x-value is considered)
fits the efficiency using the TBinomialEfficiencyFitter class The resulting fit function is added to the list of associated functions. Options: - "+": previous fitted functions in the list are kept, by default all functions in the list are deleted - for more fitting options see TBinomialEfficiencyFitter::Fit
returns a cloned version of fPassedHistogram Notes: - The histogram is filled with unit weights. You might want to scale it with the global weight GetWeight(). - The returned object is owned by the user who has to care about the deletion of the new TH1 object. - This histogram is by default NOT attached to the current directory to avoid duplication of data. If you want to store it automatically during the next TFile::Write() command, you have to attach it to the corresponding directory.
TFile* pFile = new TFile("passed.root","update"); TEfficiency* pEff = (TEfficiency*)gDirectory->Get("my_eff"); TH1* copy = pEff->GetCopyPassedHisto(); copy->SetDirectory(gDirectory); pFile->Write();
returns a cloned version of fTotalHistogram Notes: - The histogram is filled with unit weights. You might want to scale it with the global weight GetWeight(). - The returned object is owned by the user who has to care about the deletion of the new TH1 object. - This histogram is by default NOT attached to the current directory to avoid duplication of data. If you want to store it automatically during the next TFile::Write() command, you have to attach it to the corresponding directory.
TFile* pFile = new TFile("total.root","update"); TEfficiency* pEff = (TEfficiency*)gDirectory->Get("my_eff"); TH1* copy = pEff->GetCopyTotalHisto(); copy->SetDirectory(gDirectory); pFile->Write();
returns the efficiency in the given global bin Note: - The estimated efficiency depends on the chosen statistic option: for frequentist ones: for bayesian ones the expectation value of the resulting posterior distribution is returned: If the bit kPosteriorMode is set (or the method TEfficiency::UsePosteriorMode() has been called ) the mode (most probable value) of the posterior is returned: - If the denominator is equal to 0, an efficiency of 0 is returned. - When or the above formula for the mode is not valid. In these cases values the estimated efficiency is 0 or 1.
returns the lower error on the efficiency in the given global bin The result depends on the current confidence level fConfLevel and the chosen statistic option fStatisticOption. See SetStatisticOption(Int_t) for more details. Note: If the histograms are filled with weights, only bayesian methods and the normal approximation are supported.
returns the upper error on the efficiency in the given global bin The result depends on the current confidence level fConfLevel and the chosen statistic option fStatisticOption. See SetStatisticOption(Int_t) for more details. Note: If the histograms are filled with weights, only bayesian methods and the normal approximation are supported.
returns the global bin number which can be used as argument for the following functions: - GetEfficiency(bin), GetEfficiencyErrorLow(bin), GetEfficiencyErrorUp(bin) - SetPassedEvents(bin), SetTotalEvents(bin) see TH1::GetBin() for conventions on numbering bins
merges the TEfficiency objects in the given list to the given TEfficiency object using the operator+=(TEfficiency&) The merged result is stored in the current object. The statistic options and the confidence level are taken from the current object. This function should be used when all TEfficiency objects correspond to the same process. The new weight is set according to:
returns the confidence limits for the efficiency supposing that the efficiency follows a normal distribution with the rms below Input: - total : number of total events - passed: 0 <= number of passed events <= total - level : confidence level - bUpper: true - upper boundary is returned false - lower boundary is returned calculation:
adds the histograms of another TEfficiency object to current histograms The statistic options and the confidence level remain unchanged. fTotalHistogram += rhs.fTotalHistogram; fPassedHistogram += rhs.fPassedHistogram; calculates a new weight: current weight of this TEfficiency object = weight of rhs =
assignment operator The histograms, statistic option, confidence level, weight and paint styles of rhs are copied to the this TEfficiency object. Note: - The list of associated functions is not copied. After this operation the list of associated functions is empty.
paints this TEfficiency object For details on the possible option see Draw(Option_t*) Note for 1D classes In 1D the TEfficiency uses a TGraphAsymmErrors for drawing The TGraph is created only the first time Paint is used. The user can manipulate the TGraph via the method TEfficiency::GetPaintedGraph() The TGraph creates behing an histogram for the axis. The histogram is created also only the first time. If the axis needs to be updated because in the meantime the class changed use this trick which will trigger a re-calculation of the axis of the graph TEfficiency::GetPaintedGraph()->Set(0) Note that in order to access the painted graph via GetPaintedGraph() you need either to call Paint or better gPad->Update();
sets the shape parameter The prior probability of the efficiency is given by the beta distribution: Note: - both shape parameters have to be positive (i.e. > 0)
sets the shape parameter The prior probability of the efficiency is given by the beta distribution: Note: - both shape parameters have to be positive (i.e. > 0)
sets different shape parameter for the prior distribution for each bin. By default the global parameter are used if they are not set for the specific bin The prior probability of the efficiency is given by the beta distribution: Note: - both shape parameters have to be positive (i.e. > 0) - bin gives the global bin number (cf. GetGlobalBin)
set the bins for the underlined passed and total histograms If the class have been already filled the previous contents will be lost
set the bins for the underlined passed and total histograms If the class have been already filled the previous contents will be lost
set the bins for the underlined passed and total histograms If the class have been already filled the previous contents will be lost
set the bins for the underlined passed and total histograms If the class have been already filled the previous contents will be lost
set the bins for the underlined passed and total histograms If the class have been already filled the previous contents will be lost
set the bins for the underlined passed and total histograms If the class have been already filled the previous contents will be lost
sets the confidence level (0 < level < 1) The default value is 1-sigma :~ 0.683
sets the directory holding this TEfficiency object A reference to this TEfficiency object is removed from the current directory (if it exists) and a new reference to this TEfficiency object is added to the given directory. Notes: - If the given directory is 0, the TEfficiency object does not belong to any directory and will not be written to file during the next TFile::Write() command.
sets the name Note: The names of the internal histograms are set to "name + _total" and "name + _passed" respectively.
sets the number of passed events in the given global bin returns "true" if the number of passed events has been updated otherwise "false" ist returned Note: - requires: 0 <= events <= fTotalHistogram->GetBinContent(bin)
sets the histogram containing the passed events The given histogram is cloned and stored internally as histogram containing the passed events. The given histogram has to be consistent with the current fTotalHistogram (see CheckConsistency(const TH1&,const TH1&)). The method returns whether the fPassedHistogram has been replaced (true) or not (false). Note: The list of associated functions fFunctions is cleared. Option: - "f": force the replacement without checking the consistency This can lead to inconsistent histograms and useless results or unexpected behaviour. But sometimes it might be the only way to change the histograms. If you use this option, you should ensure that the fTotalHistogram is replaced by a consistent one (with respect to rPassed) as well.
sets the statistic option which affects the calculation of the confidence interval Options: - kFCP (=0)(default): using the Clopper-Pearson interval (recommended by PDG) sets kIsBayesian = false see also ClopperPearson - kFNormal (=1) : using the normal approximation sets kIsBayesian = false see also Normal - kFWilson (=2) : using the Wilson interval sets kIsBayesian = false see also Wilson - kFAC (=3) : using the Agresti-Coull interval sets kIsBayesian = false see also AgrestiCoull - kFFC (=4) : using the Feldman-Cousins frequentist method sets kIsBayesian = false see also FeldmanCousins - kBJeffrey (=5) : using the Jeffrey interval sets kIsBayesian = true, fBeta_alpha = 0.5 and fBeta_beta = 0.5 see also Bayesian - kBUniform (=6) : using a uniform prior sets kIsBayesian = true, fBeta_alpha = 1 and fBeta_beta = 1 see also Bayesian - kBBayesian (=7) : using a custom prior defined by fBeta_alpha and fBeta_beta sets kIsBayesian = true see also Bayesian
sets the title Notes: - The titles of the internal histograms are set to "title + (total)" or "title + (passed)" respectively. - It is possible to label the axis of the histograms as usual (see TH1::SetTitle). Example: Setting the title to "My Efficiency" and label the axis
pEff->SetTitle("My Efficiency;x label;eff");
sets the number of total events in the given global bin returns "true" if the number of total events has been updated otherwise "false" ist returned Note: - requires: fPassedHistogram->GetBinContent(bin) <= events
sets the histogram containing all events The given histogram is cloned and stored internally as histogram containing all events. The given histogram has to be consistent with the current fPassedHistogram (see CheckConsistency(const TH1&,const TH1&)). The method returns whether the fTotalHistogram has been replaced (true) or not (false). Note: The list of associated functions fFunctions is cleared. Option: - "f": force the replacement without checking the consistency This can lead to inconsistent histograms and useless results or unexpected behaviour. But sometimes it might be the only way to change the histograms. If you use this option, you should ensure that the fPassedHistogram is replaced by a consistent one (with respect to rTotal) as well.
sets the global weight for this TEfficiency object Note: - weight has to be positive ( > 0)
use trick of -1 to return global parameters
{return (fBeta_bin_params.size() > (UInt_t)bin) ? fBeta_bin_params[bin].first : fBeta_alpha;}
{return (fBeta_bin_params.size() > (UInt_t)bin) ? fBeta_bin_params[bin].second : fBeta_beta;}