45 py::enum_<SystType>(m_parameters,
"SystematicType")
53 py::init<std::string &, std::string, M3::float_t, int, int>(),
54 "Construct a parameters object from a set of yaml files that define the systematic parameters \n\
55 :param name: the name of this ParameterHandler object. \n\
56 :param file: The name of the yaml file to initialise from. \n\
57 :param threshold: threshold PCA threshold from 0 to 1. Default is -1 and means no PCA. \n\
58 :param first_PCA_par: FirstPCAdpar First PCA parameter that will be decomposed. \n\
59 :param last_PCA_par: LastPCAdpar First PCA parameter that will be decomposed.",
62 py::arg(
"threshold") = -1.0,
63 py::arg(
"firs_PCA_par") = -999,
64 py::arg(
"last_PCA_par") = -999)
67 "calculate_likelihood",
69 "Calculate penalty term based on inverted covariance matrix.")
72 "get_internal_par_name",
77 ret =
self.GetParName(index);
80 "Get the internally used name of this parameter. \n\
81 :param index: The global index of the parameter",
90 ret =
self.GetParFancyName(index);
93 "Get the name of this parameter. \n\
94 :param index: The global index of the parameter",
100 "Get the number of parameters that this ParameterHandler object knows about.")
105 "Propose a step based on the covariances. Also feel free to overwrite if you want something more funky.")
108 "get_proposal_array",
112 size_t n_pars =
self.GetNParameters();
115 const M3::float_t* data_ptr =
self.GetParPropVec().data();
119 py::array_t<M3::float_t> result(n_pars);
120 auto buf = result.request();
124 std::memcpy(result_ptr, data_ptr, n_pars *
sizeof(
M3::float_t));
128 "Get the parameter proposal values as a numpy array. \n\
129 This returns a copy of the current proposal values. \n\
130 :return: A numpy array containing the proposal values for all parameters.")
134 if (pars_obj.is_none()) {
135 self.SetParameters();
138 std::vector<double> pars_vec = pars_obj.cast<std::vector<double>>();
139 self.SetParameters(pars_vec);
140 } }, py::arg(
"pars") = py::none(),
142 Set parameter values using array.
146 pars : numpy.ndarray or list of float, optional
147 Array holding new values for every parameter.
148 Must have same size as the number of parameters in the covariance class.
149 If not provided, parameters are set to their pre-fit values.
153 >>> import numpy as np
154 >>> handler.set_parameters(np.array([1.0, 2.0, 3.0]))
155 >>> handler.set_parameters([1.0, 2.0, 3.0])
156 >>> handler.set_parameters()
161 "Get initial value of parameter at index i\n\
162 :param index: index of the parameter")
165 "Get the lower bound of parameter at index i. \n\
166 :param index: index of the parameter")
169 "Get the upper bound of parameter at index i. \n\
170 :param index: index of the parameter")
173 "Is the parameter at index i flat?. \n\
174 :param index: index of the parameter")
177 "The prior error on parameter at index i \n\
178 :param index: index of the parameter")
181 "Is the parameter at index i fixed \n\
182 :param index: index of the parameter")
186 auto mat =
self.GetCovMatrix();
188 throw std::runtime_error(
"TMatrixDSym pointer is null");
190 int n = mat->GetNrows();
191 const double *data = mat->GetMatrixArray();
192 py::array_t<float> result({n, n});
194 std::transform(data, data + n * n,
195 result.mutable_data(),
197 { return static_cast<float>(v); });
200 "Get the prior covariance")
206 py::init<
const std::vector<std::string>&,
const char *,
M3::float_t,
int,
int>(),
207 "Construct a systematic ParameterHandler object from a set of yaml files that define the systematic parameters \n\
208 :param yaml_files: The name of the yaml file to initialise from. \n\
209 :param name: the name of this ParameterHandler object. \n\
210 :param threshold: threshold PCA threshold from 0 to 1. Default is -1 and means no PCA. \n\
211 :param first_PCA_par: FirstPCAdpar First PCA parameter that will be decomposed. \n\
212 :param last_PCA_par: LastPCAdpar First PCA parameter that will be decomposed.",
213 py::arg(
"yaml_files"),
214 py::arg(
"name") =
"xsec_cov",
215 py::arg(
"threshold") = -1.0,
216 py::arg(
"firs_PCA_par") = -999,
217 py::arg(
"last_PCA_par") = -999
223 "Get what type of systematic this parameters is (see :py:class:`pyMaCh3.m_parameters.SystematicType` for possible types). \n\
224 :param index: The global index of the parameter",
@ kNorm
For normalisation parameters.
@ kSpline
For splined parameters (1D)
@ kSystTypes
This only enumerates.
@ kFunc
For functional parameters.
Base class for handling systematic uncertainty parameters.
virtual void ProposeStep()
Generate a new proposed state.
double GetUpperBound(const int i) const
Get upper parameter bound in which it is physically valid.
int GetNParameters() const
Get number of params which will be different depending if using Eigen decomposition or not.
bool IsParameterFixed(const int i) const
Is parameter fixed or not.
double GetLowerBound(const int i) const
Get lower parameter bound in which it is physically valid.
double CalcLikelihood() const _noexcept_
Calc penalty term based on inverted covariance matrix.
bool GetFlatPrior(const int i) const
Get if param has flat prior or not.
double GetError(const int i) const
Get the error for the ith parameter.
double GetParPreFit(const int i) const
Get prior parameter value.
Class responsible for handling of systematic error parameters with different types defined in the con...
SystType GetParamType(const int i) const
Returns enum describing our param type.
EW: As ParameterHandlerBase is an abstract base class we have to do some gymnastics to get it to get ...