Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
wire-cell-build
util
src
BufferedHistogram2D.cxx
Go to the documentation of this file.
1
#include "
WireCellUtil/BufferedHistogram2D.h
"
2
3
using namespace
WireCell
;
4
using namespace
std
;
5
6
7
BufferedHistogram2D::BufferedHistogram2D
(
double
xbinsize,
double
ybinsize,
8
double
xmin,
double
ymin)
9
: m_xmin(xmin), m_ymin(ymin), m_xbinsize(xbinsize), m_ybinsize(ybinsize)
10
{
11
}
12
13
double
BufferedHistogram2D::xmax
()
const
14
{
15
return
xmin
() +
m_xbinsize
*
m_xbindeque
.size();
16
}
17
double
BufferedHistogram2D::ymax
()
const
18
{
19
return
ymin
() +
m_ybinsize
*
ysize
();
20
}
21
int
BufferedHistogram2D::ysize
()
const
22
{
23
int
imax = 0;
24
for
(
auto
v:
m_xbindeque
) {
25
imax =
std::max
((
int
)v.size(), imax);
26
}
27
return
imax;
28
}
29
30
31
bool
BufferedHistogram2D::fill
(
double
x
,
double
y
,
double
v)
32
{
33
int
ybin = (y -
m_ymin
)/
m_ybinsize
;
34
if
(ybin < 0) {
35
return
false
;
36
}
37
int
xbin = (x -
m_xmin
)/
m_xbinsize
;
38
if
(xbin < 0) {
39
return
false
;
40
}
41
42
if
((
int
)
m_xbindeque
.size() < xbin+1) {
43
m_xbindeque
.resize(xbin+1);
44
}
45
XBin
& vec =
m_xbindeque
[xbin];
46
if
((
int
)vec.size() < ybin+1) {
47
vec.resize(ybin+1, 0.0);
48
}
49
vec[ybin] += v;
50
51
return
true
;
52
}
53
54
std::vector<double>
BufferedHistogram2D::popx
()
55
{
56
std::vector<double> ret;
57
58
if
(!
m_xbindeque
.size()) {
return
ret; }
59
60
ret =
m_xbindeque
.front();
61
m_xbindeque
.pop_front();
62
m_xmin
+=
m_xbinsize
;
63
return
ret;
64
}
WireCell::BufferedHistogram2D::ysize
int ysize() const
Definition:
BufferedHistogram2D.cxx:21
WireCell::BufferedHistogram2D::fill
bool fill(double x, double y, double v=1.0)
Add v to the bin holding x,y. Return false if point is out of bounds.
Definition:
BufferedHistogram2D.cxx:31
WireCell::BufferedHistogram2D::BufferedHistogram2D
BufferedHistogram2D(double xbinsize=1.0, double ybinsize=1.0, double xmin=0.0, double ymin=0.0)
Definition:
BufferedHistogram2D.cxx:7
std
STL namespace.
WireCell::BufferedHistogram2D::ymax
double ymax() const
Definition:
BufferedHistogram2D.cxx:17
WireCell::BufferedHistogram2D::ymin
double ymin() const
Definition:
BufferedHistogram2D.h:45
WireCell::BufferedHistogram2D::m_xmin
double m_xmin
Definition:
BufferedHistogram2D.h:13
WireCell::BufferedHistogram2D::xmin
double xmin() const
Definition:
BufferedHistogram2D.h:44
WireCell::BufferedHistogram2D::m_ymin
double m_ymin
Definition:
BufferedHistogram2D.h:13
y
double y
Definition:
GapWidth_module.cc:109
WireCell::BufferedHistogram2D::XBin
std::vector< double > XBin
Definition:
BufferedHistogram2D.h:16
max
static int max(int a, int b)
Definition:
fortranscanner.cpp:60366
WireCell::BufferedHistogram2D::popx
std::vector< double > popx()
Definition:
BufferedHistogram2D.cxx:54
WireCell
Definition:
Main.h:22
WireCell::BufferedHistogram2D::m_xbinsize
double m_xbinsize
Definition:
BufferedHistogram2D.h:13
WireCell::BufferedHistogram2D::m_ybinsize
double m_ybinsize
Definition:
BufferedHistogram2D.h:13
train.x
list x
Definition:
train.py:276
WireCell::BufferedHistogram2D::xmax
double xmax() const
Definition:
BufferedHistogram2D.cxx:13
BufferedHistogram2D.h
WireCell::BufferedHistogram2D::m_xbindeque
XBinDeque m_xbindeque
Definition:
BufferedHistogram2D.h:18
Generated by
1.8.11