55 {
56
57 auto m_fitters = m.def_submodule("fitters");
58 m_fitters.doc() =
59 "This is a Python binding of MaCh3s C++ fitters library.";
60
61
63 .def(py::init<manager* const>())
64
65 .def(
66 "run",
68 "The implementation of the fitter, you should override this with your own desired fitting algorithm"
69 )
70
71 .def(
72 "get_name",
74 " The name of the algorithm, you should override this with something like:: \n"
75 "\n"
76 " return 'mySuperCoolAlgoName' \n"
77 )
78
79 .def(
80 "run_LLH_scan",
82 "Perform a 1D likelihood scan"
83 )
84
85 .def(
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"
89 )
90
91 .def(
92 "run_2d_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."
96 )
97
98 .def(
99 "run_sigma_var",
101 " Perform a 2D and 1D sigma var for all samples. \n"
102 " :param warning: Code uses TH2Poly"
103 )
104
105 .def(
106 "drag_race",
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
111 )
112
113
114
115 .def(
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. ",
120 py::arg("sample")
121 )
122
123 .def(
124 "add_syst_object",
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. ",
128 py::arg("cov")
129 )
130
131 ;
132
133 py::class_<mcmc, FitterBase>(m_fitters, "MCMC")
134 .def(py::init<manager* const>())
135
136 .def(
137 "set_chain_length",
139 "Set how long chain should be.",
140 py::arg("length")
141 )
142 ;
143
145 .def(py::init<manager* const>())
146
147 .def(
148 "caluclate_chi2",
149 [](
LikelihoodFit &self,
const std::vector<double> ¶meterVals)
150 {
151 return self.
CalcChi2(parameterVals.data());
152 },
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")
156 )
157
158 .def(
159 "get_n_params",
161 "Get The total number of parameters across all known covariance objects associated with this LikelihoodFit object."
162 )
163 ;
164
165 py::class_<MinuitFit, LikelihoodFit>(m_fitters, "MinuitFit")
166 .def(py::init<manager* const>())
167
168 ;
169
170 py::class_<PSO, LikelihoodFit>(m_fitters, "PSO")
171 .def(py::init<manager* const>())
172
173 .def(
174 "init",
176 "Initialise the fitter"
177 )
178
179 ;
180
181}
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.
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.
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...
EW: As LikelihoodFit is an abstract base class we have to do some gymnastics to get it to get it into...
void setChainLength(unsigned int L)
Set how long chain should be.