This tutorial explains the concept of global observables in RooFit, and showcases how their values can be stored either in the model or in the dataset.
Introduction
Note: in this tutorial, we are multiplying the likelihood with an additional likelihood to constrain the parameters with auxiliary measurements. This is different from the rf604_constraints
tutorial, where the likelihood is multiplied with a Bayesian prior to constrain the parameters.
With RooFit, you usually optimize some model parameters p
to maximize the likelihood L
given the per-event or per-bin ## observations x
:
\[ L( x | p ) \]
Often, the parameters are constrained with some prior likelihood C
, which doesn't depend on the observables x
:
\[ L'( x | p ) = L( x | p ) * C( p ) \]
Usually, these constraint terms depend on some auxiliary measurements of other observables g
. The constraint term is then the likelihood of the so-called global observables:
\[ L'( x | p ) = L( x | p ) * C( g | p ) \]
For example, think of a model where the true luminosity lumi
is a nuisance parameter that is constrained by an auxiliary measurement lumi_obs
with uncertainty lumi_obs_sigma
:
\[ L'(data | mu, lumi) = L(data | mu, lumi) * Gauss(lumi_obs | lumi, lumi_obs_sigma) \]
As a Gaussian is symmetric under exchange of the observable and the mean parameter, you can also sometimes find this equivalent but less conventional formulation for Gaussian constraints:
\[ L'(data | mu, lumi) = L(data | mu, lumi) * Gauss(lumi | lumi_obs, lumi_obs_sigma) \]
If you wanted to constrain a parameter that represents event counts, you would use a Poissonian constraint, e.g.:
\[ L'(data | mu, count) = L(data | mu, count) * Poisson(count_obs | count) \]
Unlike a Guassian, a Poissonian is not symmetric under exchange of the observable and the parameter, so here you need to be more careful to follow the global observable prescription correctly.
{
RooRealVar mu_obs(
"mu_obs",
"mu_obs", 1.0, -10, 10);
mu_obs.setConstant();
RooGaussian constraint(
"constraint",
"constraint", mu_obs, mu, RooConst(0.2));
RooProdPdf model(
"model",
"model", {gauss, constraint});
std::unique_ptr<RooDataSet> dataGlob{model.
generate({mu_obs}, 1)};
double mu_obs_orig_val = mu_obs.getVal();
std::unique_ptr<RooDataSet> data{model.generate({
x}, 1000)};
data->setGlobalObservables({mu_obs});
mu_obs.setVal(mu_obs_orig_val);
model.getParameters(data->get(), modelParameters);
modelParameters.
snapshot(origParameters);
using FitRes = std::unique_ptr<RooFitResult>;
std::cout << "1. model.fitTo(*data, GlobalObservables(mu_obs))\n";
std::cout << "------------------------------------------------\n\n";
modelParameters.
assign(origParameters);
std::cout << "2. model.fitTo(*data)\n";
std::cout << "---------------------\n\n";
res2->Print();
modelParameters.
assign(origParameters);
std::cout << "3. model.fitTo(*data, GlobalObservables(mu_obs), GlobalObservablesSource(\"model\"))\n";
std::cout << "------------------------------------------------\n\n";
res3->Print();
modelParameters.
assign(origParameters);
}
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
RooDataSet * generate(const RooArgSet &whatVars, Int_t nEvents, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none())
See RooAbsPdf::generate(const RooArgSet&,const RooCmdArg&,const RooCmdArg&,const RooCmdArg&,...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
RooProdPdf is an efficient implementation of a product of PDFs of the form.
RooRealVar represents a variable that can be changed from the outside.
RooCmdArg GlobalObservables(Args_t &&... argsOrArgSet)
RooCmdArg GlobalObservablesSource(const char *sourceName)
RooCmdArg Save(Bool_t flag=kTRUE)
RooCmdArg PrintLevel(Int_t code)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
- Date
- January 2022
- Author
- Jonas Rembser
Definition in file rf613_global_observables.C.