17 #include "SealBase/Filename.h"
18 #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/paul.txt").substitute (seal::ShellEnvironment ()));
37 std::ifstream in(inputFile.Name() );
39 std::ifstream in(
"paul.txt");
42 std::cerr <<
"Error opening input data file" << std::endl;
48 double x = 0., weight = 0., width = 0., err = 0.;
49 while(in>>x>>weight>>width>>err) {
50 positions.push_back(x);
51 double ni = weight*width;
52 measurements.push_back(ni);
56 std::cout<<
"size= "<<var.size()<<std::endl;
58 std::cout<<
"nmeas: "<<nmeas<<std::endl;
62 GaussFcn fFCN(measurements, positions, var);
65 std::vector<double> pos = fFCN.
Positions();
71 double dx = pos[1]-pos[0];
73 for(
unsigned int i = 0; i < meas.size(); i++) {
75 x += (meas[i]*pos[i]);
76 x2 += (meas[i]*pos[i]*pos[i]);
80 double rms2 = x2/norm - mean*mean;
82 std::cout<<
"initial mean: "<<mean<<std::endl;
83 std::cout<<
"initial sigma: "<<
sqrt(rms2)<<std::endl;
84 std::cout<<
"initial area: "<<area<<std::endl;
87 upar.
Add(
"mean", mean, 0.1);
88 upar.
Add(
"sigma",
sqrt(rms2), 0.1);
89 upar.
Add(
"area", area, 0.1);
92 std::cout<<
"start migrad "<<std::endl;
94 std::cout<<
"minimum: "<<min<<std::endl;
96 std::cout<<
"start Minos"<<std::endl;
98 std::pair<double,double> e0 =
Minos(0);
99 std::pair<double,double> e1 =
Minos(1);
100 std::pair<double,double> e2 =
Minos(2);
102 std::cout<<
"par0: "<<min.
UserState().
Value(
"mean")<<
" "<<e0.first<<
" "<<e0.second<<std::endl;
103 std::cout<<
"par1: "<<min.
UserState().
Value(
"sigma")<<
" "<<e1.first<<
" "<<e1.second<<std::endl;
104 std::cout<<
"par2: "<<min.
UserState().
Value(
"area")<<
" "<<e2.first<<
" "<<e2.second<<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)
double Value(unsigned int) const
RooCmdArg Minos(Bool_t flag=kTRUE)
const MnUserParameterState & UserState() 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...
std::vector< double > Positions() const
API class for the user interaction with the parameters; serves as input to the minimizer as well as o...
std::vector< double > Measurements() const
double norm(double *x, double *p)