168void FourBinInstructional(
bool doBayesian =
false,
bool doFeldmanCousins =
false,
bool doMCMC =
false)
180 wspace->
factory(
"Poisson::on(non[0,1000], sum::splusb(s[40,0,100],b[100,0,300]))");
181 wspace->
factory(
"Poisson::off(noff[0,5000], prod::taub(b,tau[5,3,7],rho[1,0,2]))");
182 wspace->
factory(
"Poisson::onbar(nonbar[0,10000], bbar[1000,500,2000])");
183 wspace->
factory(
"Poisson::offbar(noffbar[0,1000000], prod::lambdaoffbar(bbar, tau))");
184 wspace->
factory(
"Gaussian::mcCons(rhonom[1.,0,2], rho, sigma[.2])");
185 wspace->
factory(
"PROD::model(on,off,onbar,offbar,mcCons)");
186 wspace->
defineSet(
"obs",
"non,noff,nonbar,noffbar,rhonom");
188 wspace->
factory(
"Uniform::prior_poi({s})");
189 wspace->
factory(
"Uniform::prior_nuis({b,bbar,tau, rho})");
190 wspace->
factory(
"PROD::prior(prior_poi,prior_nuis)");
197 wspace->
defineSet(
"nuis",
"b,tau,rho,bbar");
215 std::unique_ptr<RooDataSet>
data{wspace->
pdf(
"model")->
generate(*wspace->
set(
"obs"), 1)};
224 modelConfig->
SetPdf(*wspace->
pdf(
"model"));
228 wspace->
import(*modelConfig);
237 plc.SetConfidenceLevel(0.95);
246 fc.SetConfidenceLevel(0.95);
248 fc.FluctuateNumDataEntries(
false);
249 fc.UseAdaptiveSampling(
true);
252 if (doFeldmanCousins) {
258 bc.SetConfidenceLevel(0.95);
260 if (doBayesian && wspace->
set(
"poi")->
getSize() == 1) {
261 bInt = bc.GetInterval();
263 cout <<
"Bayesian Calc. only supports on parameter of interest" << endl;
278 mc.SetConfidenceLevel(0.95);
279 mc.SetProposalFunction(*pf);
280 mc.SetNumBurnInSteps(500);
281 mc.SetNumIters(50000);
282 mc.SetLeftSideTailFraction(0.5);
285 mcInt = mc.GetInterval();
293 if (doBayesian && doMCMC) {
296 }
else if (doBayesian || doMCMC) {
304 if (doBayesian && wspace->
set(
"poi")->
getSize() == 1) {
308 bc.SetScanOfPosterior(20);
309 RooPlot *bplot = bc.GetPosteriorPlot();
314 if (doBayesian && wspace->
set(
"poi")->
getSize() == 1)
324 cout <<
"Profile Likelihood interval on s = [" << plInt->
LowerLimit(*wspace->
var(
"s")) <<
", "
328 if (doBayesian && wspace->
set(
"poi")->
getSize() == 1) {
329 cout <<
"Bayesian interval on s = [" << bInt->
LowerLimit() <<
", " << bInt->
UpperLimit() <<
"]" << endl;
332 if (doFeldmanCousins) {
333 cout <<
"Feldman Cousins interval on s = [" << fcInt->
LowerLimit(*wspace->
var(
"s")) <<
", "
339 cout <<
"MCMC interval on s = [" << mcInt->
LowerLimit(*wspace->
var(
"s")) <<
", "
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Int_t getSize() const
Return the number of elements in the collection.
RooFit::OwningPtr< RooFitResult > fitTo(RooAbsData &data, CmdArgs_t const &... cmdArgs)
Fit PDF to given dataset.
RooFit::OwningPtr< RooDataSet > generate(const RooArgSet &whatVars, Int_t nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={})
See RooAbsPdf::generate(const RooArgSet&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
static RooMsgService & instance()
Return reference to singleton instance.
void setGlobalKillBelow(RooFit::MsgLevel level)
RooFit::MsgLevel globalKillBelow() const
A RooPlot is a plot frame and a container for graphics objects within that frame.
void Draw(Option_t *options=nullptr) override
Draw this plot and all of the elements it contains.
static TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
BayesianCalculator is a concrete implementation of IntervalCalculator, providing the computation of a...
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.
void Draw(const Option_t *options=nullptr) override
draw the likelihood interval or contour for the 1D case a RooPlot is drawn by default of the profiled...
LikelihoodInterval is a concrete implementation of the RooStats::ConfInterval interface.
double UpperLimit(const RooRealVar ¶m)
return the upper bound of the interval on a given parameter
double LowerLimit(const RooRealVar ¶m)
return the lower bound of the interval on a given parameter
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 UpperLimit(RooRealVar ¶m)
get the highest value of param that is within the confidence interval
virtual double 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...
virtual void SetPriorPdf(const RooAbsPdf &pdf)
Set the Prior Pdf, add to the workspace if not already there.
virtual void SetWorkspace(RooWorkspace &ws)
virtual void SetParametersOfInterest(const RooArgSet &set)
Specify parameters of interest.
virtual void SetNuisanceParameters(const RooArgSet &set)
Specify the nuisance parameters (parameters that are not POI).
virtual void SetPdf(const RooAbsPdf &pdf)
Set the Pdf, add to the workspace if not already there.
PointSetInterval is a concrete implementation of the ConfInterval interface.
double UpperLimit(RooRealVar ¶m)
return upper limit on a given parameter
double LowerLimit(RooRealVar ¶m)
return lower limit on a given parameter
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)
set the covariance matrix to use for a multi-variate Gaussian proposal
virtual ProposalFunction * GetProposalFunction()
Get the ProposalFunction that we've been designing.
virtual void SetVariables(RooArgList &vars)
virtual void SetCacheSize(Int_t size)
virtual void SetUpdateProposalParameters(bool updateParams)
SimpleInterval is a concrete implementation of the ConfInterval interface.
virtual double UpperLimit()
return the interval upper limit
virtual double LowerLimit()
return the interval lower limit
Persistable container for RooFit projects.
RooAbsPdf * pdf(RooStringView name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
bool writeToFile(const char *fileName, bool recreate=true)
Save this current workspace into given file.
const RooArgSet * set(RooStringView name)
Return pointer to previously defined named set with given nmame If no such set is found a null pointe...
bool import(const RooAbsArg &arg, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={})
Import a RooAbsArg object, e.g.
RooFactoryWSTool & factory()
Return instance to factory tool.
RooRealVar * var(RooStringView name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
bool defineSet(const char *name, const RooArgSet &aset, bool importMissing=false)
Define a named RooArgSet with given constituents.
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Print(Option_t *option="") const override
Print the real and cpu time passed between the start and stop events.
RooCmdArg Save(bool flag=true)
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...
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
Namespace for the RooStats classes.