1 #include "Minuit2/VariableMetricMinimizer.h" 2 #include "Minuit2/FunctionMinimum.h" 16 theFitter =
new VariableMetricMinimizer();
25 const std::vector<float>& inputy,
27 std::vector<int>& dacoccup,
28 std::vector<float>& mypar,
29 std::vector<float>& ermypar,
37 std::vector<double> parinit(2, 0);
38 std::vector<double> erparinit(2, 0);
50 std::vector<float> ynorm;
51 std::vector<float> ery;
67 for (
size_t i = 0;
i < inputx.size();
i++) {
70 r = inputy[
i] / (
float)dacoccup[
i];
80 int nbeg = inputx.size();
85 for (
size_t i = inputx.size();
i > 0;
i--) {
86 if (ynorm[
i - 1] < 1.0)
88 if (ynorm[
i - 1] == 1.0)
92 for (
size_t i = nbeg;
i < inputx.size();
i++) {
94 x.push_back(inputx[
i]);
95 y.push_back(ynorm[i]);
97 float p = inputy[
i] / (
float)dacoccup[i];
98 float s = (
float)dacoccup[i] * p * (1.0 - p);
111 float dmin = 999999.0;
113 for (
size_t i = 0;
i < x.size();
i++) {
133 FunctionMinimum fmin =
theFitter->Minimize(*
theOBJfun, parinit, erparinit, 1, 500, 0.1);
135 status = fmin.IsValid();
138 mypar[0] = (
float)fmin.Parameters().Vec()(0);
139 mypar[1] = (
float)fmin.Parameters().Vec()(1);
140 ermypar[0] = (
float)
sqrt(fmin.Error().Matrix()(0, 0));
141 ermypar[1] = (
float)
sqrt(fmin.Error().Matrix()(1, 1));
143 if (ermypar[0] != 0.0 && ermypar[1] != 0.0)
144 ercorr = (
float)fmin.Error().Matrix()(0, 1) / (ermypar[0] * ermypar[1]);
147 ndf = y.size() - mypar.size();
void setNorm(float n)
Set the norm (if needed)
ModularFunctionMinimizer * theFitter
virtual bool ThresholdNoise(const std::vector< float > &inputx, const std::vector< float > &inputy, const int &npulses, std::vector< int > &dacoccup, std::vector< float > &mypar, std::vector< float > &ermypar, float &ercorr, float &chisq, int &ndf, int &niter, float &edm) const
void setData(const std::vector< float > &x, const std::vector< float > &y)
Cache the current data, x and y.
CSCThrTurnOnFcn * theOBJfun
void setErrors(const std::vector< float > &er)
Set the errors.