3 #include "Minuit2/FCNBase.h"
4 #include "Minuit2/FunctionMinimum.h"
5 #include "Minuit2/MnHesse.h"
6 #include "Minuit2/MnMigrad.h"
7 #include "Minuit2/MnMinos.h"
8 #include "Minuit2/MnPrint.h"
9 #include "Minuit2/MnUserParameterState.h"
10 #include "Minuit2/SimplexMinimizer.h"
16 using namespace ROOT::Minuit2;
20 double dndy(
double y,
double A,
double eta,
double T,
double mass) {
23 double deta = 2. * eta / iters;
24 for (
int i = 0;
i < iters; ++
i) {
25 double et = -eta + (0.5 +
i) * deta;
26 ret += (mass * mass / T / T + mass / T * 2. / TMath::CosH(
y - et)
27 + 2. / TMath::CosH(
y - et) / TMath::CosH(
y - et))
28 * TMath::Exp(-mass / T * TMath::CosH(
y - et));
30 return ret * deta * A * T * T * T;
37 const std::vector<double>& dndy_,
38 const std::vector<double>& err_,
42 , fMeasurements(dndy_)
51 double operator()(
const std::vector<double>& par)
const {
53 for (
unsigned int i = 0;
i < fPositions.size(); ++
i) {
54 double val =
dndy(fPositions[
i], par[0], par[1], fT, fMass);
55 chi2 += (fMeasurements[
i] - val) * (fMeasurements[
i] - val) / fErrors[
i]
61 double Up()
const {
return 1.; }
78 std::vector<double> params(2, 0.);
79 params[0] = Parameters.A.value;
80 params[1] = Parameters.eta.value;
82 MnUserParameters upar;
96 MnMigrad migrad(mfunc, upar);
98 FunctionMinimum
min = migrad();
102 ret.
A.
value = (
min.UserParameters()).Params()[0];
103 ret.
A.
error = (
min.UserParameters()).Errors()[0];
104 ret.
eta.
value = (
min.UserParameters()).Params()[1];
105 ret.
eta.
error = (
min.UserParameters()).Errors()[1];
112 std::cout <<
"A = " << params[0] <<
" "
113 <<
" eta = " << params[1] <<
" "
114 <<
" chi2/ndf = " << mfunc(params) / (
y.size() - nparams)
117 ret.
chi2ndf = mfunc(params) / (
y.size() - nparams);