Logo ROOT   6.16/01
Reference Guide
rs801_HypoTestInverterOriginal.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_roostats
3/// \notebook -js
4/// 'Hypothesis Test Inversion' RooStats tutorial macro #801
5///
6/// This tutorial shows an example of using the HypoTestInverterOriginal class
7///
8/// \macro_image
9/// \macro_output
10/// \macro_code
11///
12/// \author Gregory Schott
13
14#include "RooRealVar.h"
15#include "RooConstVar.h"
16#include "RooProdPdf.h"
17#include "RooWorkspace.h"
18#include "RooDataSet.h"
19#include "RooPolynomial.h"
20#include "RooAddPdf.h"
21#include "RooExtendPdf.h"
22
27
28#include "TGraphErrors.h"
29
30using namespace RooFit;
31using namespace RooStats;
32
33
34void rs801_HypoTestInverterOriginal()
35{
36 // prepare the model
37 RooRealVar lumi("lumi","luminosity",1);
38 RooRealVar r("r","cross-section ratio",3.74,0,50);
39 RooFormulaVar ns("ns","1*r*lumi",RooArgList(lumi,r));
40 RooRealVar nb("nb","background yield",1);
41 RooRealVar x("x","dummy observable",0,1);
43 RooPolynomial flatPdf("flatPdf","flat PDF",x,p0);
44 RooAddPdf totPdf("totPdf","S+B model",RooArgList(flatPdf,flatPdf),RooArgList(ns,nb));
45 RooExtendPdf bkgPdf("bkgPdf","B-only model",flatPdf,nb);
46 RooDataSet* data = totPdf.generate(x,1);
47
48 // prepare the calculator
49 HybridCalculatorOriginal myhc(*data, totPdf, bkgPdf,0,0);
50 myhc.SetTestStatistic(2);
51 myhc.SetNumberOfToys(1000);
52 myhc.UseNuisance(false);
53
54 // run the hypothesis-test inversion
55 HypoTestInverterOriginal myInverter(myhc,r);
56 myInverter.SetTestSize(0.10);
57 myInverter.UseCLs(true);
58 // myInverter.RunFixedScan(5,1,6);
59 // scan for a 95% UL
60 myInverter.RunAutoScan(3.,5,myInverter.Size()/2,0.005);
61 // run an alternative autoscan algorithm
62 // myInverter.RunAutoScan(1,6,myInverter.Size()/2,0.005,1);
63 //myInverter.RunOnePoint(3.9);
64
65
66 HypoTestInverterResult* results = myInverter.GetInterval();
67
68 HypoTestInverterPlot myInverterPlot("myInverterPlot","",results);
69 TGraphErrors* gr1 = myInverterPlot.MakePlot();
70 gr1->Draw("ALP");
71
72 double ulError = results->UpperLimitEstimatedError();
73
74 double upperLimit = results->UpperLimit();
75 std::cout << "The computed upper limit is: " << upperLimit << std::endl;
76 std::cout << "an estimated error on this upper limit is: " << ulError << std::endl;
77 // expected result: 4.10
78}
79int main() {
80 rs801_HypoTestInverterOriginal();
81}
ROOT::R::TRInterface & r
Definition: Object.C:4
RooAddPdf is an efficient implementation of a sum of PDFs of the form.
Definition: RooAddPdf.h:29
RooConstVar represent a constant real-valued object.
Definition: RooConstVar.h:25
RooDataSet is a container class to hold unbinned data.
Definition: RooDataSet.h:31
RooExtendPdf is a wrapper around an existing PDF that adds a parameteric extended likelihood term to ...
Definition: RooExtendPdf.h:22
RooPolynomial implements a polynomial p.d.f of the form.
Definition: RooPolynomial.h:28
RooRealVar represents a fundamental (non-derived) real valued object.
Definition: RooRealVar.h:36
HybridCalculatorOriginal class.
This class is now deprecated and to be replaced by the HypoTestInverter.
Class to plot an HypoTestInverterResult, result of the HypoTestInverter calculator.
HypoTestInverterResult class holds the array of hypothesis test results and compute a confidence inte...
Double_t UpperLimitEstimatedError()
Estimate of lower limit error function evaluates only a rough error on the lower limit.
A TGraphErrors is a TGraph with error bars.
Definition: TGraphErrors.h:26
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
Definition: TGraph.cxx:747
int main(int argc, char **argv)
Double_t x[n]
Definition: legend1.C:17
RooConstVar & RooConst(Double_t val)
@(#)root/roostats:$Id$ Author: George Lewis, Kyle Cranmer
Definition: Asimov.h:20
static constexpr double ns