GooFit  v2.1.3
Functions
exponential1.cpp File Reference
#include <goofit/Application.h>
#include <goofit/PDFs/basic/ExpPdf.h>
#include <goofit/UnbinnedDataSet.h>
#include <goofit/Variable.h>
#include <goofit/fitting/FitManagerMinuit1.h>
#include <iostream>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 11 of file exponential1.cpp.

References GooFit::UnbinnedDataSet::addEvent(), data, GooFit::FitManagerMinuit1::fit(), GOOFIT_PARSE, and GooFit::PdfBase::setData().

11  {
12  GooFit::Application app("Exponential example", argc, argv);
13 
14  GOOFIT_PARSE(app);
15 
16  // Independent variable.
17  Observable xvar{"xvar", 0, log(1 + RAND_MAX / 2)};
18 
19  // Data set
20  UnbinnedDataSet data(xvar);
21 
22  // Generate toy events.
23  for(int i = 0; i < 100000; ++i) {
24  try {
25  xvar.setValue(xvar.getUpperLimit() - log(1 + rand() / 2));
26  data.addEvent();
27  } catch(const GooFit::OutOfRange &) {
28  }
29  }
30 
31  // Fit parameter
32  Variable alpha{"alpha", -2, 0.1, -10, 10};
33  // GooPdf object
34  ExpPdf exppdf{"exppdf", xvar, alpha};
35  exppdf.setData(&data);
36 
37  GooFit::FitManagerMinuit1 fitter{&exppdf};
38  fitter.fit();
39 
40  return 0;
41 }
Special class for observables. Used in DataSets.
Definition: Variable.h:109
UnbinnedDataSet * data
__host__ void setData(DataSet *data)
#define GOOFIT_PARSE(app,...)
Definition: Application.h:11