GooFit  v2.1.3
product.cpp
Go to the documentation of this file.
1 #include <goofit/Application.h>
2 #include <goofit/FitManager.h>
6 #include <goofit/Variable.h>
7 
8 using namespace std;
9 using namespace GooFit;
10 
11 int main(int argc, char **argv) {
12  GooFit::Application app("Product example", argc, argv);
13 
14  GOOFIT_PARSE(app);
15 
16  Observable xvar{"xvar", 0, log(1 + RAND_MAX / 2)};
17  Observable yvar{"yvar", 0, log(1 + RAND_MAX / 2)};
18  vector<Observable> varList = {xvar, yvar};
19  UnbinnedDataSet data{varList};
20 
21  for(int i = 0; i < 100000; ++i) {
22  xvar.setValue(xvar.getUpperLimit() - log(1 + rand() / 2));
23  yvar.setValue(yvar.getUpperLimit() - log(1 + rand() / 2));
24  data.addEvent();
25  }
26 
27  Variable alpha_x{"alpha_x", -2.4, 0.1, -10, 10};
28  Variable alpha_y{"alpha_y", -1.1, 0.1, -10, 10};
29 
30  ExpPdf exp_x{"exp_x", xvar, alpha_x};
31  ExpPdf exp_y{"exp_y", yvar, alpha_y};
32  ProdPdf product{"product", {&exp_x, &exp_y}};
33 
34  product.setData(&data);
35  FitManager fitter(&product);
36  fitter.fit();
37 
38  return fitter;
39 }
Special class for observables. Used in DataSets.
Definition: Variable.h:109
UnbinnedDataSet * data
__host__ void setData(DataSet *data)
ROOT::Minuit2::FunctionMinimum fit()
This runs the fit.
#define GOOFIT_PARSE(app,...)
Definition: Application.h:11
int main(int argc, char **argv)
Definition: product.cpp:11