50void rs101_limitexample()
63 wspace->
factory(
"Poisson::countingModel(obs[150,0,300], "
64 "sum(s[50,0,120]*ratioSigEff[1.,0,3.],b[100]*ratioBkgEff[1.,0.,3.]))");
67 wspace->
factory(
"Gaussian::sigConstraint(gSigEff[1,0,3],ratioSigEff,0.05)");
68 wspace->
factory(
"Gaussian::bkgConstraint(gSigBkg[1,0,3],ratioBkgEff,0.2)");
69 wspace->
factory(
"PROD::modelWithConstraints(countingModel,sigConstraint,bkgConstraint)");
72 RooAbsPdf *modelWithConstraints = wspace->
pdf(
"modelWithConstraints");
94 RooArgSet all(*s, *ratioBkgEff, *ratioSigEff);
103 modelConfig.SetPdf(*modelWithConstraints);
104 modelConfig.SetParametersOfInterest(paramOfInterest);
105 modelConfig.SetNuisanceParameters(constrainedParams);
106 modelConfig.SetObservables(*obs);
107 modelConfig.SetGlobalObservables(
RooArgSet(*gSigEff, *gSigBkg));
108 modelConfig.SetName(
"ModelConfig");
109 wspace->
import(modelConfig);
117 plc.SetTestSize(.05);
126 plotInt.SetTitle(
"Profile Likelihood Ratio and Posterior for S");
131 fc.UseAdaptiveSampling(
true);
132 fc.FluctuateNumDataEntries(
false);
137 fcint =
fc.GetInterval();
152 mc.SetNumIters(20000);
154 mc.SetNumBurnInSteps(40);
155 mc.SetProposalFunction(*pdfProp);
156 mc.SetLeftSideTailFraction(0.5);
161 cout <<
"Profile upper limit on s = " << ((
LikelihoodInterval *)lrinterval)->UpperLimit(*s) << endl;
167 cout <<
"FC lower limit on s = " << fcll << endl;
168 cout <<
"FC upper limit on s = " << fcul << endl;
169 TLine *fcllLine =
new TLine(fcll, 0, fcll, 1);
170 TLine *fculLine =
new TLine(fcul, 0, fcul, 1);
173 fcllLine->
Draw(
"same");
174 fculLine->
Draw(
"same");
181 mcPlot.SetLineWidth(2);
184 double mcul = mcInt->UpperLimit(*s);
185 double mcll = mcInt->LowerLimit(*s);
186 cout <<
"MCMC lower limit on s = " << mcll << endl;
187 cout <<
"MCMC upper limit on s = " << mcul << endl;
188 cout <<
"MCMC Actual confidence level: " << mcInt->GetActualConfidenceLevel() << endl;
193 RooDataSet *chainData = mcInt->GetChainAsDataSet();
196 std::cout <<
"plotting the chain data - nentries = " << chainData->
numEntries() << std::endl;
202 chain->
Draw(
"s:ratioSigEff:ratioBkgEff",
"nll_MarkovChain_local_",
"box");
207 std::cout <<
"plotting the scanned points used in the frequentist construction - npoints = "
214 for (
int ievt = 0; ievt < parScanData->
numEntries(); ++ievt) {
static struct mg_connection * fc(struct mg_context *ctx)
Double_t getRealValue(const char *name, Double_t defVal=0, Bool_t verbose=kFALSE) const
Get value of a RooAbsReal stored in set with given name.
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
virtual RooFitResult * fitTo(RooAbsData &data, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none())
Fit PDF to given dataset.
void setConstant(Bool_t value=kTRUE)
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooDataSet is a container class to hold unbinned data.
virtual const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
virtual void add(const RooArgSet &row, Double_t weight=1.0, Double_t weightError=0) override
Add a data point, with its coordinates specified in the 'data' argset, to the data set.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
RooRealVar represents a variable that can be changed from the outside.
virtual void setVal(Double_t value)
Set value of variable to 'value'.
ConfInterval is an interface class for a generic interval in the RooStats framework.
The FeldmanCousins class (like the Feldman-Cousins technique) is essentially a specific configuration...
This class provides simple and straightforward utilities to plot a LikelihoodInterval object.
LikelihoodInterval is a concrete implementation of the RooStats::ConfInterval interface.
Bayesian Calculator estimating an interval or a credible region using the Markov-Chain Monte Carlo me...
This class provides simple and straightforward utilities to plot a MCMCInterval object.
MCMCInterval is a concrete implementation of the RooStats::ConfInterval interface.
virtual Double_t LowerLimit(RooRealVar ¶m)
get the lowest value of param that is within the confidence interval
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
PointSetInterval is a concrete implementation of the ConfInterval interface.
The ProfileLikelihoodCalculator is a concrete implementation of CombinedCalculator (the interface cla...
ProposalFunction is an interface for all proposal functions that would be used with a Markov Chain Mo...
virtual void SetCovMatrix(const TMatrixDSym &covMatrix)
virtual void SetUpdateProposalParameters(Bool_t updateParams)
virtual ProposalFunction * GetProposalFunction()
virtual void SetVariables(RooArgList &vars)
virtual void SetCacheSize(Int_t size)
The RooWorkspace is a persistable container for RooFit projects.
Bool_t import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
void Print(Option_t *opts=0) const
Print contents of the workspace.
Bool_t writeToFile(const char *fileName, Bool_t recreate=kTRUE)
Save this current workspace into given file.
RooRealVar * var(const char *name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
RooFactoryWSTool & factory()
Return instance to factory tool.
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
void Update() override
Update canvas pad buffers.
Graphics object made of three arrays X, Y and Z with the same number of points each.
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
Use the TLine constructor to create a simple line.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
Automatic pad generation by division.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Stop()
Stop the stopwatch.
void Print(Option_t *option="") const
Print the real and cpu time passed between the start and stop events.
A TTree represents a columnar dataset.
virtual void Draw(Option_t *opt)
Default Draw method for all objects.
RooCmdArg Constrain(const RooArgSet ¶ms)
RooCmdArg Save(Bool_t flag=kTRUE)
fit(model, train_loader, val_loader, num_epochs, batch_size, optimizer, criterion, save_best, scheduler)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Namespace for the RooStats classes.
TTree * GetAsTTree(TString name, TString desc, const RooDataSet &data)