22 #include "SealBase/Filename.h"
23 #include "SealBase/ShellEnvironment.h"
30 std::vector<double> positions;
31 std::vector<double> measurements;
32 std::vector<double> var;
36 seal::Filename inputFile (seal::Filename (
"$SEAL/src/MathLibs/Minuit/tests/MnSim/paul3.txt").substitute (seal::ShellEnvironment ()));
37 std::ifstream in(inputFile.Name() );
39 std::ifstream in(
"paul3.txt");
42 std::cerr <<
"Error opening input data file" << std::endl;
49 double x = 0.,
y = 0., width = 0., err = 0., un1 = 0., un2 = 0.;
50 while(in>>x>>
y>>width>>err>>un1>>un2) {
51 if(err < 1.e-8)
continue;
52 positions.push_back(x);
53 measurements.push_back(
y);
54 var.push_back(err*err);
60 std::cout<<
"size= "<<var.size()<<std::endl;
61 std::cout<<
"nmeas: "<<nmeas<<std::endl;
65 GaussFcn2 fFCN(measurements, positions, var);
68 std::vector<double> pos = fFCN.
Positions();
74 double dx = pos[1]-pos[0];
76 for(
unsigned int i = 0; i < meas.size(); i++) {
78 x += (meas[i]*pos[i]);
79 x2 += (meas[i]*pos[i]*pos[i]);
83 double rms2 = x2/norm - mean*mean;
85 std::cout<<
"initial mean: "<<mean<<std::endl;
86 std::cout<<
"initial sigma: "<<
sqrt(rms2)<<std::endl;
87 std::cout<<
"initial area: "<<area<<std::endl;
88 std::vector<double> init_val(6);
91 init_val[1] =
sqrt(rms2);
94 init_val[4] =
sqrt(rms2);
112 std::cout<<
"initial fval: "<<fFCN(init_val)<<std::endl;
115 upar.
Add(
"mean1", mean, 10.);
116 upar.
Add(
"sig1",
sqrt(rms2), 10.);
117 upar.
Add(
"area1", area, 10.);
118 upar.
Add(
"mean2", mean, 10.);
119 upar.
Add(
"sig2",
sqrt(rms2), 10.);
120 upar.
Add(
"area2", area, 10.);
123 std::cout<<
"start migrad "<<std::endl;
127 std::cout<<
"FM is invalid, try with strategy = 2."<<std::endl;
131 std::cout<<
"minimum: "<<min<<std::endl;
API class for minimization using Variable Metric technology ("MIGRAD"); allows for user interaction: ...
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
std::vector< double > Measurements() const
bool Add(const std::string &, double, double)
Add free Parameter Name, Value, Error.
static const double x2[5]
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
std::vector< double > Positions() const
API class for the user interaction with the parameters; serves as input to the minimizer as well as o...
double norm(double *x, double *p)