87 RooRealVar mu_obs(
"mu_obs",
"mu_obs", 1.0, -10, 10);
95 RooProdPdf model(
"model",
"model", {gauss, constraint});
107 std::unique_ptr<RooDataSet> dataGlob{model.
generate({mu_obs}, 1)};
111 double mu_obs_orig_val = mu_obs.getVal();
116 std::unique_ptr<RooDataSet> data{model.generate({
x}, 1000)};
124 data->setGlobalObservables({mu_obs});
127 mu_obs.setVal(mu_obs_orig_val);
134 model.getParameters(data->get(), modelParameters);
136 modelParameters.
snapshot(origParameters);
138 using FitRes = std::unique_ptr<RooFitResult>;
146 std::cout <<
"1. model.fitTo(*data, GlobalObservables(mu_obs))\n";
147 std::cout <<
"------------------------------------------------\n\n";
150 modelParameters.
assign(origParameters);
157 std::cout <<
"2. model.fitTo(*data)\n";
158 std::cout <<
"---------------------\n\n";
161 modelParameters.
assign(origParameters);
167 std::cout <<
"3. model.fitTo(*data, GlobalObservables(mu_obs), GlobalObservablesSource(\"model\"))\n";
168 std::cout <<
"------------------------------------------------\n\n";
171 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.
RooConstVar & RooConst(Double_t val)
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...