90 BinCountTestStat(
void) : fColumnName(
"tmp") {}
91 BinCountTestStat(
string columnName) : fColumnName(columnName) {}
93 virtual Double_t Evaluate(RooAbsData &data, RooArgSet & )
97 for (
int i = 0; i < data.numEntries(); i++) {
98 value += data.get(i)->getRealValue(fColumnName.c_str());
102 virtual const TString GetVarName()
const {
return fColumnName; }
115void HybridInstructional(
int ntoys = 6000)
117 double nToysRatio = 20;
143 w->factory(
"Poisson::px(x[150,0,500],sum::splusb(s[0,0,100],b[100,0.1,300]))");
144 w->factory(
"Poisson::py(y[100,0.1,500],prod::taub(tau[1.],b))");
145 w->factory(
"PROD::model(px,py)");
146 w->factory(
"Uniform::prior_b(b)");
164 w->factory(
"PROJ::averagedModel(PROD::foo(px|b,py,prior_b),b)");
171 w->var(
"s")->setVal(50.);
175 w->var(
"s")->setVal(0.);
182 w->var(
"y")->setVal(100);
183 w->var(
"x")->setVal(150);
184 std::unique_ptr<RooAbsReal> cdf{w->pdf(
"averagedModel")->createCdf(*
w->var("x"))};
186 cout <<
"-----------------------------------------" << endl;
187 cout <<
"Part 2" << endl;
188 cout <<
"Hybrid p-value from direct integration = " << 1 - cdf->getVal() << endl;
201 cout <<
"-----------------------------------------" << endl;
202 cout <<
"Part 3" << endl;
203 std::cout <<
"Z_Bi p-value (analytic): " << p_Bi << std::endl;
204 std::cout <<
"Z_Bi significance (analytic): " << Z_Bi << std::endl;
228 w->defineSet(
"obs",
"x");
229 w->defineSet(
"poi",
"s");
239 b_model.SetPdf(*w->pdf(
"px"));
240 b_model.SetObservables(*w->set(
"obs"));
241 b_model.SetParametersOfInterest(*w->set(
"poi"));
242 w->var(
"s")->setVal(0.0);
243 b_model.SetSnapshot(*w->set(
"poi"));
247 sb_model.SetPdf(*w->pdf(
"px"));
248 sb_model.SetObservables(*w->set(
"obs"));
249 sb_model.SetParametersOfInterest(*w->set(
"poi"));
250 w->var(
"s")->setVal(50.0);
251 sb_model.SetSnapshot(*w->set(
"poi"));
261 BinCountTestStat binCount(
"x");
283 w->factory(
"Gaussian::gauss_prior(b,y, expr::sqrty('sqrt(y)',y))");
287 w->factory(
"Lognormal::lognorm_prior(b,y, expr::kappa('1+1./sqrt(y)',y))");
309 hc1.SetToys(ntoys, ntoys / nToysRatio);
310 hc1.ForcePriorNuisanceAlt(*w->pdf(
"py"));
311 hc1.ForcePriorNuisanceNull(*w->pdf(
"py"));
328 cout <<
"-----------------------------------------" << endl;
329 cout <<
"Part 4" << endl;
349 slrts.SetNullParameters(*b_model.GetSnapshot());
350 slrts.SetAltParameters(*sb_model.GetSnapshot());
357 hc2.SetToys(ntoys, ntoys / nToysRatio);
358 hc2.ForcePriorNuisanceAlt(*w->pdf(
"py"));
359 hc2.ForcePriorNuisanceNull(*w->pdf(
"py"));
375 cout <<
"-----------------------------------------" << endl;
376 cout <<
"Part 5" << endl;
401 w->defineSet(
"obsXY",
"x,y");
404 w->var(
"x")->setVal(150.);
405 w->var(
"y")->setVal(100.);
407 dataXY->
add(*w->set(
"obsXY"));
411 b_modelXY.SetPdf(*w->pdf(
"model"));
412 b_modelXY.SetObservables(*w->set(
"obsXY"));
413 b_modelXY.SetParametersOfInterest(*w->set(
"poi"));
414 w->var(
"s")->setVal(0.0);
415 b_modelXY.SetSnapshot(*w->set(
"poi"));
419 sb_modelXY.SetPdf(*w->pdf(
"model"));
420 sb_modelXY.SetObservables(*w->set(
"obsXY"));
421 sb_modelXY.SetParametersOfInterest(*w->set(
"poi"));
422 w->var(
"s")->setVal(50.0);
423 sb_modelXY.SetSnapshot(*w->set(
"poi"));
435 ropl.SetSubtractMLE(
false);
450 w->factory(
"y0[100]");
451 w->factory(
"Gamma::gamma_y0(b,sum::temp0(y0,1),1,0)");
452 w->factory(
"Gaussian::gauss_prior_y0(b,y0, expr::sqrty0('sqrt(y0)',y0))");
459 hc3.SetToys(ntoys, ntoys / nToysRatio);
460 hc3.ForcePriorNuisanceAlt(*w->pdf(
"gamma_y0"));
461 hc3.ForcePriorNuisanceNull(*w->pdf(
"gamma_y0"));
477 cout <<
"-----------------------------------------" << endl;
478 cout <<
"Part 6" << endl;
487 c->GetPad(4)->SetLogy();
491 c->SaveAs(
"zbi.pdf");
double Double_t
Double 8 bytes.
#define ClassDef(name, id)
Container class to hold unbinned data.
void add(const RooArgSet &row, double weight, double weightError)
Add one ore more rows of data.
static RooMsgService & instance()
Return reference to singleton instance.
void setGlobalKillBelow(RooFit::MsgLevel level)
RooFit::MsgLevel globalKillBelow() const
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.
Same purpose as HybridCalculatorOriginal, but different implementation.
This class provides the plots for the result of a study performed with any of the HypoTestCalculatorG...
HypoTestResult is a base class for results from hypothesis tests.
void Print(const Option_t *="") const override
Print out some information about the results Note: use Alt/Null labels for the hypotheses here as the...
MaxLikelihoodEstimateTestStat: TestStatistic that returns maximum likelihood estimate of a specified ...
ProfileLikelihoodTestStat is an implementation of the TestStatistic interface that calculates the pro...
TestStatistic that returns the ratio of profiled likelihoods.
void Draw(Option_t *options=nullptr) override
Draw this plot and all of the elements it contains.
TestStatistic class that returns -log(L[null] / L[alt]) where L is the likelihood.
TestStatistic is an interface class to provide a facility for construction test statistics distributi...
ToyMCSampler is an implementation of the TestStatSampler interface.
virtual void SetTestStatistic(TestStatistic *testStatistic, unsigned int i)
Set the TestStatistic (want the argument to be a function of the data & parameter points.
virtual void SetNEventsPerToy(const Int_t nevents)
Forces the generation of exactly n events even for extended PDFs.
Persistable container for RooFit projects.
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.
RooCmdArg LineColor(TColorNumber color)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
MsgLevel
Verbosity level for RooMsgService::StreamConfig in RooMsgService.
RooStats::ModelConfig ModelConfig
double BinomialWithTauObsZ(double nObs, double bExp, double tau)
See BinomialWithTauObsP.
double BinomialWithTauObsP(double nObs, double bExp, double tau)
P-value for s=nullptr in a ratio of Poisson means.
Namespace for the RooStats classes.
double PValueToSignificance(double pvalue)
returns one-sided significance corresponding to a p-value