5 #include "lsst/log/Log.h" 9 LOG_LOGGER _log = LOG_GET(
"jointcal.Histo2d");
15 Histo2d::Histo2d(
int nnx,
float mminx,
float mmaxx,
int nny,
float mminy,
float mmaxy) {
21 scalex = nx / (mmaxx - mminx);
23 LOGL_WARN(_log,
"Histo2d: minx = maxx requested");
27 scaley = ny / (mmaxy - mminy);
29 LOGL_WARN(_log,
"Histo2d: maxy = miny requested");
32 data.reset(
new float[nx * ny]);
33 memset(data.get(), 0, nx * ny *
sizeof(float));
37 memcpy(
this, &other,
sizeof(
Histo2d));
38 data.reset(
new float[nx * ny]);
39 memcpy((this->data).
get(), other.data.get(), nx * ny *
sizeof(float));
42 bool Histo2d::indices(
double x,
double y,
int &ix,
int &iy)
const {
43 ix = (int)floor((x - minx) * scalex);
44 if (ix < 0 || ix >= nx)
return false;
45 iy = (int)floor((y - miny) * scaley);
46 return (iy >= 0 && iy < ny);
51 if (indices(x, y, ix, iy)) data[iy + ny * ix] += weight;
59 for (p = data.get(), pend = p + nx * ny; pend - p; p++) {
62 imax = p - (data.get());
66 int iy = imax - ix * ny;
67 x = minx + ((float)ix + 0.5) / scalex;
68 y = miny + ((float)iy + 0.5) / scaley;
74 if (indices(x, y, ix, iy)) data[iy + ny * ix] = 0;
79 if (indices(x, y, ix, iy))
return data[iy + ny * ix];
80 LOGL_WARN(_log,
"Histo2D::binContent outside limits requested");
double binContent(double x, double y) const
void fill(float x, float y, float weight=1.)
void zeroBin(double x, double y)
double maxBin(double &x, double &y) const
Class for a simple mapping implementing a generic Gtransfo.