2#include <pybind11/pybind11.h>
3#include <pybind11/stl.h>
10namespace py = pybind11;
20 PYBIND11_OVERRIDE_PURE_NAME(
29 PYBIND11_OVERRIDE_PURE_NAME(
46 PYBIND11_OVERRIDE_PURE_NAME(
57 auto m_fitters = m.def_submodule(
"fitters");
59 "This is a Python binding of MaCh3s C++ fitters library.";
63 .def(py::init<manager* const>())
68 "The implementation of the fitter, you should override this with your own desired fitting algorithm"
74 " The name of the algorithm, you should override this with something like:: \n"
76 " return 'mySuperCoolAlgoName' \n"
82 "Perform a 1D likelihood scan"
86 "get_step_scale_from_LLH_scan",
88 "LLH scan is good first estimate of step scale, this will get the rough estimates for the step scales based on running an LLH scan"
94 " Perform a 2D likelihood scan. \n"
95 " :param warning: This operation may take a significant amount of time, especially for complex models."
101 " Perform a 2D and 1D sigma var for all samples. \n"
102 " :param warning: Code uses TH2Poly"
108 " Calculates the required time for each sample or covariance object in a drag race simulation. Inspired by Dan's feature \n"
109 " :param NLaps: number of laps, every part of Fitter will be tested with given number of laps and you will get total and average time",
110 py::arg(
"NLaps") = 100
116 "add_sample_handler",
118 " This function adds a sample handler object to the analysis framework. The sample handler object will be utilized in fitting procedures or likelihood scans. \n"
119 " :param sample: A sample handler object derived from SampleHandlerBase. ",
126 " This function adds a Covariance object to the analysis framework. The Covariance object will be utilized in fitting procedures or likelihood scans. \n"
127 " :param cov: A Covariance object derived from ParameterHandlerBase. ",
133 py::class_<mcmc, FitterBase>(m_fitters,
"MCMC")
134 .def(py::init<manager* const>())
139 "Set how long chain should be.",
145 .def(py::init<manager* const>())
149 [](
LikelihoodFit &self,
const std::vector<double> ¶meterVals)
151 return self.
CalcChi2(parameterVals.data());
153 "Get the Chi2 calculation over all included samples and syst objects for the specified parameter_values \n\
154 :param parameter_valuse: The location to evaluate the chi2 at.",
155 py::arg(
"parameter_values")
161 "Get The total number of parameters across all known covariance objects associated with this LikelihoodFit object."
165 py::class_<MinuitFit, LikelihoodFit>(m_fitters,
"MinuitFit")
166 .def(py::init<manager* const>())
170 py::class_<PSO, LikelihoodFit>(m_fitters,
"PSO")
171 .def(py::init<manager* const>())
176 "Initialise the fitter"
Base class for implementing fitting algorithms.
void RunLLHScan()
Perform a 1D likelihood scan.
void AddSystObj(ParameterHandlerBase *cov)
This function adds a Covariance object to the analysis framework. The Covariance object will be utili...
void AddSampleHandler(SampleHandlerBase *sample)
This function adds a sample PDF object to the analysis framework. The sample PDF object will be utili...
virtual std::string GetName() const
Get name of class.
virtual void RunMCMC()=0
The specific fitting algorithm implemented in this function depends on the derived class....
void GetStepScaleBasedOnLLHScan()
LLH scan is good first estimate of step scale.
void RunSigmaVar()
Perform a 2D and 1D sigma var for all samples.
void DragRace(const int NLaps=100)
Calculates the required time for each sample or covariance object in a drag race simulation....
void Run2DLLHScan()
Perform a 2D likelihood scan.
FitterBase(manager *const fitMan)
Constructor.
Implementation of base Likelihood Fit class, it is mostly responsible for likelihood calculation whil...
int GetNPars()
Get total number of params, this sums over all covariance objects.
LikelihoodFit(manager *const fitMan)
Constructor.
virtual double CalcChi2(const double *x)
Chi2 calculation over all included samples and syst objects.
EW: As FitterBase is an abstract base class we have to do some gymnastics to get it to get it into py...
void RunMCMC() override
The specific fitting algorithm implemented in this function depends on the derived class....
std::string GetName() const override
Get name of class.
EW: As LikelihoodFit is an abstract base class we have to do some gymnastics to get it to get it into...
void RunMCMC() override
Implementation of fitting algorithm.
void setChainLength(unsigned int L)
Set how long chain should be.
void initFitters(py::module &m)