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");
79 RooRealVar *ratioSigEff = wspace.var(
"ratioSigEff");
80 RooRealVar *ratioBkgEff = wspace.var(
"ratioBkgEff");
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);
112 wspace.writeToFile(
"rs101_ws.root");
117 plc.SetTestSize(.05);
118 std::unique_ptr<LikelihoodInterval> lrinterval{
static_cast<LikelihoodInterval*
>(plc.GetInterval())};
121 auto dataCanvas =
new TCanvas(
"dataCanvas");
122 dataCanvas->Divide(2, 1);
126 plotInt.SetTitle(
"Profile Likelihood Ratio and Posterior for S");
131 fc.UseAdaptiveSampling(
true);
132 fc.FluctuateNumDataEntries(
false);
136 std::unique_ptr<PointSetInterval> fcint{
static_cast<PointSetInterval*
>(fc.GetInterval())};
151 mc.SetNumIters(20000);
153 mc.SetNumBurnInSteps(40);
154 mc.SetProposalFunction(*pdfProp);
155 mc.SetLeftSideTailFraction(0.5);
156 std::unique_ptr<MCMCInterval> mcInt{
static_cast<MCMCInterval *
>(mc.GetInterval())};
159 std::cout <<
"Profile lower limit on s = " << lrinterval->
LowerLimit(*s) << std::endl;
160 std::cout <<
"Profile upper limit on s = " << lrinterval->UpperLimit(*s) << std::endl;
164 double fcul = fcint->UpperLimit(*s);
165 double fcll = fcint->LowerLimit(*s);
166 std::cout <<
"FC lower limit on s = " << fcll << std::endl;
167 std::cout <<
"FC upper limit on s = " << fcul << std::endl;
168 auto fcllLine =
new TLine(fcll, 0, fcll, 1);
169 auto fculLine =
new TLine(fcul, 0, fcul, 1);
170 fcllLine->SetLineColor(
kRed);
171 fculLine->SetLineColor(
kRed);
172 fcllLine->Draw(
"same");
173 fculLine->Draw(
"same");
174 dataCanvas->Update();
180 mcPlot.SetLineWidth(2);
183 double mcul = mcInt->UpperLimit(*s);
184 double mcll = mcInt->LowerLimit(*s);
185 std::cout <<
"MCMC lower limit on s = " << mcll << std::endl;
186 std::cout <<
"MCMC upper limit on s = " << mcul << std::endl;
187 std::cout <<
"MCMC Actual confidence level: " << mcInt->GetActualConfidenceLevel() << std::endl;
192 RooDataSet *chainData = mcInt->GetChainAsDataSet();
195 std::cout <<
"plotting the chain data - nentries = " << chainData->
numEntries() << std::endl;
201 chain->
Draw(
"s:ratioSigEff:ratioBkgEff",
"nll_MarkovChain_local_",
"box");
206 std::cout <<
"plotting the scanned points used in the frequentist construction - npoints = "
213 for (
int ievt = 0; ievt < parScanData->
numEntries(); ++ievt) {
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
double getRealValue(const char *name, double defVal=0.0, bool verbose=false) 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.
Abstract interface for all probability density functions.
RooFit::OwningPtr< RooFitResult > fitTo(RooAbsData &data, CmdArgs_t const &... cmdArgs)
Fit PDF to given dataset.
void setConstant(bool value=true)
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooDataSet is a container class to hold unbinned data.
const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
RooRealVar represents a variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
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 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)
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)
Persistable container for RooFit projects.
RooFactoryWSTool & factory()
Return instance to factory tool.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
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.
void Draw(Option_t *chopt="") override
Draw this graph with its current attributes.
Use the TLine constructor to create a simple line.
void Print(Option_t *option="") const override
Print TNamed name and title.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Stop()
Stop the stopwatch.
void Print(Option_t *option="") const override
Print the real and cpu time passed between the start and stop events.
A TTree represents a columnar dataset.
void Draw(Option_t *opt) override
Default Draw method for all objects.
RooCmdArg Constrain(const RooArgSet ¶ms)
RooCmdArg Save(bool flag=true)
RooCmdArg PrintLevel(Int_t code)
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)
Create a TTree with the given name and description. All RooRealVars in the RooDataSet are represented...