21 #include "SealBase/Filename.h" 22 #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/paul2.txt").substitute (seal::ShellEnvironment ()));
37 std::ifstream in(inputFile.Name() );
39 std::ifstream in(
"paul2.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);
57 std::cout<<
"size= "<<var.size()<<std::endl;
58 assert(var.size() > 0);
59 std::cout<<
"nmeas: "<<nmeas<<std::endl;
63 GaussFcn fFCN(measurements, positions, var);
66 std::vector<double> pos = fFCN.
Positions();
73 double dx = pos[1]-pos[0];
74 for(
unsigned int i = 0; i < meas.size(); i++) {
76 x += (meas[i]*pos[i]);
77 x2 += (meas[i]*pos[i]*pos[i]);
81 double rms2 = x2/norm - mean*mean;
83 std::cout<<
"initial mean: "<<mean<<std::endl;
84 std::cout<<
"initial sigma: "<<
sqrt(rms2)<<std::endl;
85 std::cout<<
"initial area: "<<area<<std::endl;
86 std::vector<double> init_val(3);
88 init_val[1] =
sqrt(rms2);
90 std::cout<<
"initial fval: "<<fFCN(init_val)<<std::endl;
93 upar.
Add(
"mean", mean, 1.);
94 upar.
Add(
"sigma",
sqrt(rms2), 1.);
95 upar.
Add(
"area", area, 10.);
98 std::cout<<
"start migrad "<<std::endl;
100 std::cout<<
"minimum: "<<min<<std::endl;
102 std::cout<<
"start Minos"<<std::endl;
104 std::pair<double,double> e0 =
Minos(0);
105 std::pair<double,double> e1 =
Minos(1);
106 std::pair<double,double> e2 =
Minos(2);
108 std::cout<<
"par0: "<<min.
UserState().
Value(
"mean")<<
" "<<e0.first<<
" "<<e0.second<<std::endl;
109 std::cout<<
"par1: "<<min.
UserState().
Value(1)<<
" "<<e1.first<<
" "<<e1.second<<std::endl;
110 std::cout<<
"par2: "<<min.
UserState().
Value(2)<<
" "<<e2.first<<
" "<<e2.second<<std::endl;
API class for minimization using Variable Metric technology ("MIGRAD"); allows for user interaction: ...
RooCmdArg Minos(Bool_t flag=kTRUE)
std::vector< double > Measurements() const
std::vector< double > Positions() 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) ...
API class for Minos Error analysis (asymmetric errors); minimization has to be done before and Minimu...
API class for the user interaction with the parameters; serves as input to the minimizer as well as o...
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
const MnUserParameterState & UserState() const
double norm(double *x, double *p)
double Value(unsigned int) const