BufferedHistogram2D.h
Go to the documentation of this file.
1 #ifndef WIRECELL_BUFFEREDHISTOGRAM2D
2 #define WIRECELL_BUFFEREDHISTOGRAM2D
3 
4 #include <vector>
5 #include <deque>
6 
7 namespace WireCell {
8 
9  /** A 2D histogram which can expand its range based on filling and
10  * have its edge sliced off.
11  */
14 
15 
16  typedef std::vector<double> XBin;
17  typedef std::deque<XBin> XBinDeque;
18  XBinDeque m_xbindeque;
19  public:
20 
21  /// Create a buffered 2d histogram with lower corner at xmin,
22  /// ymin and with bins of given sizes.
23  BufferedHistogram2D(double xbinsize=1.0, double ybinsize=1.0,
24  double xmin=0.0, double ymin=0.0);
25 
26  /// Add v to the bin holding x,y. Return false if point is out of bounds.
27  bool fill(double x, double y, double v=1.0);
28 
29  /// Slice off the lowest X bin and return it as a vector.
30  /// Note, the zeroth element of the vector corresponds to the
31  /// bin starting at ymin but the length of vector may not
32  /// represent the global ymax.
33  std::vector<double> popx();
34 
35  /// popy is not yet implemented.
36  // std::vector<double> popy();
37 
38  // return buffer depth
39  int size() const { return m_xbindeque.size(); }
40  int xsize() const { return size(); }
41  // return the maximum size in Y
42  int ysize() const;
43 
44  double xmin() const { return m_xmin; }
45  double ymin() const { return m_ymin; }
46  double xmax() const;
47  double ymax() const;
48  double xbinsize() const { return m_xbinsize; }
49  double ybinsize() const { return m_ybinsize; }
50 
51  };
52 
53 }
54 
55 #endif
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.
BufferedHistogram2D(double xbinsize=1.0, double ybinsize=1.0, double xmin=0.0, double ymin=0.0)
double y
Definition: Main.h:22
list x
Definition: train.py:276
int size() const
popy is not yet implemented.