Logo ROOT  
Reference Guide
mntplot.cxx
Go to the documentation of this file.
1// @(#)root/minuit2:$Id$
2// Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7 * *
8 **********************************************************************/
9
10/* mnplot.F -- translated by f2c (version 20010320).
11 You must link the resulting object file with the libraries:
12 -lf2c -lm (in that order)
13*/
14
15#include <cmath>
16#include <cstdio>
17#include <cstring>
18
19namespace ROOT {
20
21namespace Minuit2 {
22
23void mnbins(double, double, int, double &, double &, int &, double &);
24
25void mnplot(double *xpt, double *ypt, char *chpt, int nxypt, int npagwd, int npagln)
26{
27 //*-*-*-*Plots points in array xypt onto one page with labelled axes*-*-*-*-*
28 //*-* ===========================================================
29 //*-* NXYPT is the number of points to be plotted
30 //*-* XPT(I) = x-coord. of ith point
31 //*-* YPT(I) = y-coord. of ith point
32 //*-* CHPT(I) = character to be plotted at this position
33 //*-* the input point arrays XPT, YPT, CHPT are destroyed.
34 //*-*
35 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
36
37 // char cdot[] = ".";
38 // char cslash[] = "/";
39
40 /* Local variables */
41 double xmin, ymin, xmax, ymax, savx, savy, yprt;
42 double bwidx, bwidy, xbest, ybest, ax, ay, bx, by;
43 double xvalus[12], any, dxx, dyy;
44 int iten, i, j, k, maxnx, maxny, iquit, ni, linodd;
45 int nxbest, nybest, km1, ibk, isp1, nx, ny, ks, ix;
46 char ctemp[120];
47 bool overpr;
48 char cline[120];
49 char chsav, chbest;
50
51 /* Function Body */
52 //*-* Computing MIN
53 maxnx = npagwd - 20 < 100 ? npagwd - 20 : 100;
54 if (maxnx < 10)
55 maxnx = 10;
56 maxny = npagln;
57 if (maxny < 10)
58 maxny = 10;
59 if (nxypt <= 1)
60 return;
61 xbest = xpt[0];
62 ybest = ypt[0];
63 chbest = chpt[0];
64 //*-*- order the points by decreasing y
65 km1 = nxypt - 1;
66 for (i = 1; i <= km1; ++i) {
67 iquit = 0;
68 ni = nxypt - i;
69 for (j = 1; j <= ni; ++j) {
70 if (ypt[j - 1] > ypt[j])
71 continue;
72 savx = xpt[j - 1];
73 xpt[j - 1] = xpt[j];
74 xpt[j] = savx;
75 savy = ypt[j - 1];
76 ypt[j - 1] = ypt[j];
77 ypt[j] = savy;
78 chsav = chpt[j - 1];
79 chpt[j - 1] = chpt[j];
80 chpt[j] = chsav;
81 iquit = 1;
82 }
83 if (iquit == 0)
84 break;
85 }
86 //*-*- find extreme values
87 xmax = xpt[0];
88 xmin = xmax;
89 for (i = 1; i <= nxypt; ++i) {
90 if (xpt[i - 1] > xmax)
91 xmax = xpt[i - 1];
92 if (xpt[i - 1] < xmin)
93 xmin = xpt[i - 1];
94 }
95 dxx = (xmax - xmin) * .001;
96 xmax += dxx;
97 xmin -= dxx;
98 mnbins(xmin, xmax, maxnx, xmin, xmax, nx, bwidx);
99 ymax = ypt[0];
100 ymin = ypt[nxypt - 1];
101 if (ymax == ymin)
102 ymax = ymin + 1;
103 dyy = (ymax - ymin) * .001;
104 ymax += dyy;
105 ymin -= dyy;
106 mnbins(ymin, ymax, maxny, ymin, ymax, ny, bwidy);
107 any = (double)ny;
108 //*-*- if first point is blank, it is an 'origin'
109 if (chbest == ' ')
110 goto L50;
111 xbest = (xmax + xmin) * .5;
112 ybest = (ymax + ymin) * .5;
113L50:
114 //*-*- find Scale constants
115 ax = 1 / bwidx;
116 ay = 1 / bwidy;
117 bx = -ax * xmin + 2;
118 by = -ay * ymin - 2;
119 //*-*- convert points to grid positions
120 for (i = 1; i <= nxypt; ++i) {
121 xpt[i - 1] = ax * xpt[i - 1] + bx;
122 ypt[i - 1] = any - ay * ypt[i - 1] - by;
123 }
124 nxbest = int((ax * xbest + bx));
125 nybest = int((any - ay * ybest - by));
126 //*-*- print the points
127 ny += 2;
128 nx += 2;
129 isp1 = 1;
130 linodd = 1;
131 overpr = false;
132 for (i = 1; i <= ny; ++i) {
133 for (ibk = 1; ibk <= nx; ++ibk) {
134 cline[ibk - 1] = ' ';
135 }
136 cline[nx] = '\0';
137 cline[nx + 1] = '\0';
138 cline[0] = '.';
139 // not needed - but to avoid a wrongly reported compiler warning (see ROOT-6496)
140 if (nx > 0)
141 cline[nx - 1] = '.';
142 cline[nxbest - 1] = '.';
143 if (i != 1 && i != nybest && i != ny)
144 goto L320;
145 for (j = 1; j <= nx; ++j) {
146 cline[j - 1] = '.';
147 }
148 L320:
149 yprt = ymax - double(i - 1) * bwidy;
150 if (isp1 > nxypt)
151 goto L350;
152 //*-*- find the points to be plotted on this line
153 for (k = isp1; k <= nxypt; ++k) {
154 ks = int(ypt[k - 1]);
155 if (ks > i)
156 goto L345;
157 ix = int(xpt[k - 1]);
158 if (cline[ix - 1] == '.')
159 goto L340;
160 if (cline[ix - 1] == ' ')
161 goto L340;
162 if (cline[ix - 1] == chpt[k - 1])
163 continue;
164 overpr = true;
165 //*-*- OVERPR is true if one or more positions contains more than
166 //*-*- one point
167 cline[ix - 1] = '&';
168 continue;
169 L340:
170 cline[ix - 1] = chpt[k - 1];
171 }
172 isp1 = nxypt + 1;
173 goto L350;
174 L345:
175 isp1 = k;
176 L350:
177 if (linodd == 1 || i == ny)
178 goto L380;
179 linodd = 1;
180 memcpy(ctemp, cline, 120);
181 printf(" %s", (const char *)ctemp);
182 goto L400;
183 L380:
184 // ctemp = cline;
185 memcpy(ctemp, cline, 120);
186 printf(" %14.7g ..%s", yprt, (const char *)ctemp);
187 linodd = 0;
188 L400:
189 printf("\n");
190 }
191 //*-*- print labels on x-axis every ten columns
192 for (ibk = 1; ibk <= nx; ++ibk) {
193 cline[ibk - 1] = ' ';
194 if (ibk % 10 == 1)
195 cline[ibk - 1] = '/';
196 }
197 printf(" %s", cline);
198 printf("\n");
199
200 for (ibk = 1; ibk <= 12; ++ibk) {
201 xvalus[ibk - 1] = xmin + double(ibk - 1) * 10 * bwidx;
202 }
203 printf(" ");
204 iten = (nx + 9) / 10;
205 for (ibk = 1; ibk <= iten; ++ibk) {
206 printf(" %9.4g", xvalus[ibk - 1]);
207 }
208 printf("\n");
209
210 if (overpr) {
211 char chmess[] = " Overprint character is &";
212 printf(" ONE COLUMN=%13.7g%s", bwidx, (const char *)chmess);
213 } else {
214 char chmess[] = " ";
215 printf(" ONE COLUMN=%13.7g%s", bwidx, (const char *)chmess);
216 }
217 printf("\n");
218
219} /* mnplot_ */
220
221} // namespace Minuit2
222
223} // namespace ROOT
float xmin
Definition: THbookFile.cxx:95
float ymin
Definition: THbookFile.cxx:95
float xmax
Definition: THbookFile.cxx:95
float ymax
Definition: THbookFile.cxx:95
void mnplot(double *xpt, double *ypt, char *chpt, int nxypt, int npagwd, int npagln)
Definition: mntplot.cxx:25
void mnbins(double a1, double a2, int naa, double &bl, double &bh, int &nb, double &bwid)
Definition: mnbins.cxx:16
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.