12 #define _USE_MATH_DEFINES 25 class ReneFcn :
public FCNBase {
30 ReneFcn(
const std::vector<double>& meas) : fMeasurements(meas) {}
34 virtual double operator()(
const std::vector<double>&
par)
const {
43 for(
unsigned int i = 0; i < fMeasurements.size(); i++) {
44 double ni = fMeasurements[i];
45 if(ni < 1.
e-10)
continue;
49 double xi = (i+1.)/40. - 1./80.;
55 double nexp = a*xi*xi + b*xi + c + (0.5*p0*p1/
M_PI)/std::max(1.
e-10, (xi-p2)*(xi-
p2) + 0.25*p1*p1);
56 fval += (ni-nexp)*(ni-nexp)/ei;
61 virtual double Up()
const {
return 1.;}
64 std::vector<double> fMeasurements;
124 double tmp[120] = {38.,36.,46.,52.,54.,52.,61.,52.,64.,77.,
125 60.,56.,78.,71.,81.,83.,89.,96.,118.,96.,
126 109.,111.,107.,107.,135.,156.,196.,137.,
127 160.,153.,185.,222.,251.,270.,329.,422.,
128 543.,832.,1390.,2835.,3462.,2030.,1130.,
129 657.,469.,411.,375.,295.,281.,281.,289.,
130 273.,297.,256.,274.,287.,280.,274.,286.,
131 279.,293.,314.,285.,322.,307.,313.,324.,
132 351.,314.,314.,301.,361.,332.,342.,338.,
133 396.,356.,344.,395.,416.,406.,411.,422.,
134 393.,393.,409.,455.,427.,448.,459.,403.,
135 441.,510.,501.,502.,482.,487.,506.,506.,
136 526.,517.,534.,509.,482.,591.,569.,518.,
137 609.,569.,598.,627.,617.,610.,662.,666.,
138 652.,671.,647.,650.,701.};
140 std::vector<double> measurements(tmp, tmp+120);
142 ReneFcn fFCN(measurements);
145 upar.
Add(
"p0", 100., 10.);
146 upar.
Add(
"p1", 100., 10.);
147 upar.
Add(
"p2", 100., 10.);
148 upar.
Add(
"p3", 100., 10.);
149 upar.
Add(
"p4", 1., 0.3);
150 upar.
Add(
"p5", 1., 0.3);
169 std::cout<<
"initial parameters: "<<upar<<std::endl;
171 std::cout<<
"start migrad "<<std::endl;
176 std::cout<<
"FM is invalid, try with strategy = 2."<<std::endl;
180 std::cout<<
"minimum: "<<min<<std::endl;
194 std::vector<double> params(6, 1.);
195 std::vector<double>
Error(6, 1.);
196 MnScan scan(fFCN, params, Error);
197 std::cout<<
"scan parameters: "<<scan.
Parameters()<<std::endl;
200 std::vector<std::pair<double, double> >
xy = scan.
Scan(i);
208 std::vector<double> params(6, 1.);
209 std::vector<double>
Error(6, 1.);
210 MnScan scan(fFCN, params, Error);
211 std::cout<<
"scan parameters: "<<scan.
Parameters()<<std::endl;
API class for minimization using Variable Metric technology ("MIGRAD"); allows for user interaction: ...
const MnUserParameters & Parameters() const
MnPlot produces a text-screen graphical output of (x,y) points, e.g.
bool Add(const std::string &, double, double)
Add free Parameter Name, Value, Error.
static double p2(double t, double a, double b, double c)
class holding the full result of the minimization; both internal and external (MnUserParameterState) ...
Interface (abstract class) defining the function to be minimized, which has to be implemented by the ...
static double p1(double t, double a, double b)
API class for the user interaction with the parameters; serves as input to the minimizer as well as o...
API class for minimization using a scan method to find the minimum; allows for user interaction: set/...
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
std::vector< std::pair< double, double > > Scan(unsigned int par, unsigned int maxsteps=41, double low=0., double high=0.)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
unsigned int VariableParameters() const
const MnUserParameterState & UserState() const
API class for defining three levels of strategies: low (0), medium (1), high (>=2); acts on: Migrad (...
void Error(ErrorHandler_t func, int code, const char *va_(fmt),...)
Write error message and call a handler, if required.