30 std::cout <<
"\t x = " << point.first <<
" y = " << point.second << std::endl;
33 std::vector<std::pair<double,double> >
MnContours::operator()(
unsigned int px,
unsigned int py,
unsigned int npoints)
const {
44 unsigned int nfcn = 0;
46 std::vector<std::pair<double,double> > result; result.reserve(npoints);
47 std::vector<MnUserParameterState> states;
63 MN_ERROR_MSG(
"MnContours is unable to find first two points.");
66 std::pair<double,double> ex = mex();
71 MN_ERROR_MSG(
"MnContours is unable to find second two points.");
74 std::pair<double,double> ey = mey();
79 migrad.
SetValue(px, valx + ex.second);
81 nfcn += exy_up.
NFcn();
83 MN_ERROR_VAL2(
"MnContours: unable to find Upper y Value for x Parameter",px);
87 migrad.
SetValue(px, valx + ex.first);
89 nfcn += exy_lo.
NFcn();
91 MN_ERROR_VAL2(
"MnContours: unable to find Lower y Value for x Parameter",px);
98 migrad1.
SetValue(py, valy + ey.second);
100 nfcn += eyx_up.
NFcn();
102 MN_ERROR_VAL2(
"MnContours: unable to find Upper x Value for y Parameter",py);
106 migrad1.
SetValue(py, valy + ey.first);
108 nfcn += eyx_lo.
NFcn();
110 MN_ERROR_VAL2(
"MnContours: unable to find Lower x Value for y Parameter",py);
114 double scalx = 1./(ex.second - ex.first);
115 double scaly = 1./(ey.second - ey.first);
117 result.push_back(std::pair<double,double>(valx + ex.first, exy_lo.
UserState().
Value(py)));
118 result.push_back(std::pair<double,double>(eyx_lo.
UserState().
Value(px), valy + ey.first));
119 result.push_back(std::pair<double,double>(valx + ex.second, exy_up.
UserState().
Value(py)));
120 result.push_back(std::pair<double,double>(eyx_up.
UserState().
Value(px), valy + ey.second));
128 if (printLevel > 0 ) {
129 std::cout <<
"MnContour : List of found points " << std::endl;
130 std::cout <<
"\t Parameter x is " << upar.
Name(px) << std::endl;
131 std::cout <<
"\t Parameter y is " << upar.
Name(py) << std::endl;
134 if (printLevel > 0) {
135 for (
unsigned int i = 0; i < 4; ++i)
142 std::vector<unsigned int> par(2); par[0] = px; par[1] = py;
145 for(
unsigned int i = 4; i < npoints; i++) {
147 std::vector<std::pair<double,double> >::iterator idist1 = result.end()-1;
148 std::vector<std::pair<double,double> >::iterator idist2 = result.begin();
149 double dx = idist1->first - (idist2)->first;
150 double dy = idist1->second - (idist2)->second;
151 double bigdis = scalx*scalx*dx*dx + scaly*scaly*dy*dy;
153 for(std::vector<std::pair<double,double> >::iterator ipair = result.begin(); ipair != result.end()-1; ++ipair) {
154 double distx = ipair->first - (ipair+1)->first;
155 double disty = ipair->second - (ipair+1)->second;
156 double dist = scalx*scalx*distx*distx + scaly*scaly*disty*disty;
170 if(nfcn > maxcalls) {
171 MN_ERROR_MSG(
"MnContours: maximum number of function calls exhausted.");
175 double xmidcr = a1*idist1->first + a2*(idist2)->first;
176 double ymidcr = a1*idist1->second + a2*(idist2)->second;
177 double xdir = (idist2)->second - idist1->second;
178 double ydir = idist1->first - (idist2)->first;
179 double scalfac = sca*std::max(
fabs(xdir*scalx),
fabs(ydir*scaly));
180 double xdircr = xdir/scalfac;
181 double ydircr = ydir/scalfac;
182 std::vector<double> pmid(2); pmid[0] = xmidcr; pmid[1] = ymidcr;
183 std::vector<double> pdir(2); pdir[0] = xdircr; pdir[1] = ydircr;
185 MnCross opt = cross(par, pmid, pdir, toler, maxcalls);
190 MN_ERROR_VAL2(
"MnContours : unable to find point on Contour",i+1);
200 double aopt = opt.
Value();
201 if(idist2 == result.begin()) {
202 result.push_back(std::pair<double,double>(xmidcr+(aopt)*xdircr, ymidcr + (aopt)*ydircr));
206 result.insert(idist2, std::pair<double,double>(xmidcr+(aopt)*xdircr, ymidcr + (aopt)*ydircr));
211 std::cout <<
"MnContour: Number of contour points = " << result.size() << std::endl;
void PrintContourPoint(const std::pair< double, double > &point)
#define MN_ERROR_MSG(str)
API class for minimization using Variable Metric technology ("MIGRAD"); allows for user interaction: ...
double dist(Rotation3D const &r1, Rotation3D const &r2)
unsigned int NFcn() const
Namespace for new ROOT classes and functions.
MinosError Minos(unsigned int, unsigned int maxcalls=0, double toler=0.1) const
ask for MinosError (Lower + Upper) can be printed via std::cout
unsigned int Strategy() const
std::vector< std::pair< double, double > > operator()(unsigned int, unsigned int, unsigned int npoints=20) const
ask for one Contour (points only) from number of points (>=4) and parameter indeces ...
unsigned int VariableParameters() const
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...
#define MN_ERROR_VAL2(loc, x)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
const FunctionMinimum & fMinimum
Class holding the result of Minos (lower and upper values) for a specific parameter.
class which holds the external user and/or internal Minuit representation of the parameters and error...
ContoursError Contour(unsigned int, unsigned int, unsigned int npoints=20) const
ask for one Contour ContoursError (MinosErrors + points) from number of points (>=4) and parameter in...
const char * Name(unsigned int) const
unsigned int NFcn() const
void SetValue(unsigned int, double)
const MnUserParameterState & UserState() const
API class for defining three levels of strategies: low (0), medium (1), high (>=2); acts on: Migrad (...
double Value(unsigned int) const