YODA is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis  1.3.1
ProfileBin2D.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // This file is part of YODA -- Yet more Objects for Data Analysis
4 // Copyright (C) 2008-2015 The YODA collaboration (see AUTHORS for details)
5 //
6 #ifndef YODA_ProfileBin2D_h
7 #define YODA_ProfileBin2D_h
8 
9 #include "YODA/Bin2D.h"
10 #include "YODA/Dbn3D.h"
11 #include "YODA/Exceptions.h"
12 
13 namespace YODA {
14 
15 
23  class ProfileBin2D : public Bin2D<Dbn3D> {
24  public:
25 
27 
28 
30  ProfileBin2D(double xmin, double xmax, double ymin, double ymax)
31  : Bin2D<Dbn3D>(std::make_pair(xmin, xmax), std::make_pair(ymin, ymax))
32  { }
33 
35  ProfileBin2D(const std::pair<double,double>& xedges,
36  const std::pair<double,double>& yedges)
37  : Bin2D<Dbn3D>(xedges, yedges)
38  { }
39 
43  ProfileBin2D(const std::pair<double, double>& xedges,
44  const std::pair<double, double>& yedges, const Dbn3D& dbn)
45  : Bin2D<Dbn3D>(xedges, yedges, dbn)
46  { }
47 
50  : Bin2D<Dbn3D>(pb)
51  { }
52 
56  return *this;
57  }
58 
60 
61 
63 
64 
68  void fill(double x, double y, double z, double weight=1.0) {
69  _dbn.fill(x, y, z, weight);
70  }
71 
75  void fill(std::pair<double,double> coords, double z, double weight=1.0) {
76  fill(coords.first, coords.second, z, weight);
77  }
78 
82  void fillBin(double z, double weight=1.0){
83  fill(xyMid(), z, weight);
84  }
85 
87  void reset() {
89  }
90 
92 
93 
95 
96 
100  inline void scaleZ(double az) {
101  _dbn.scaleZ(az);
102  }
103 
107  inline void scaleXYZ(double ax, double ay, double az) {
108  scaleXY(ax, ay);
109  scaleZ(az);
110  }
111 
113 
114 
116 
117 
119  double mean() const {
120  return _dbn.zMean();
121  }
122 
124  double stdDev() const {
125  return _dbn.zStdDev();
126  }
127 
129  double variance() const {
130  return _dbn.zVariance();
131  }
132 
134  double stdErr() const {
135  return _dbn.zStdErr();
136  }
137 
139  double relErr() const {
140  return stdErr() != 0 ? stdErr() / mean() : 0;
141  }
142 
144  double rms() const {
145  return _dbn.zRMS();
146  }
147 
149 
151 
152 
154 
156  double sumWZ() const {
157  return _dbn.sumWZ();
158  }
159 
160  double sumWZ2() const {
161  return _dbn.sumWZ2();
162  }
163 
165 
166  public:
167 
170  return add(toAdd);
171  }
172 
173  ProfileBin2D& operator -= (const ProfileBin2D& toSubtract) {
174  return subtract(toSubtract);
175  }
176 
177  protected:
178 
181  Bin2D<Dbn3D>::add(pb);
182  return *this;
183  }
184 
188  return *this;
189  }
190  };
191 
192 
194  inline ProfileBin2D operator + (const ProfileBin2D& a, const ProfileBin2D& b) {
195  ProfileBin2D rtn(a);
196  rtn += b;
197  return rtn;
198  }
199 
200 
202  inline ProfileBin2D operator - (const ProfileBin2D& a, const ProfileBin2D& b) {
203  ProfileBin2D rtn(a);
204  rtn -= b;
205  return rtn;
206  }
207 
208 }
209 
210 #endif
ProfileBin2D & operator-=(const ProfileBin2D &toSubtract)
Definition: ProfileBin2D.h:173
Dbn3D & dbn()
Statistical distribution in this bin (non-const)
Definition: Bin2D.h:276
A Bin1D specialised for handling profile-type information.
Definition: ProfileBin2D.h:23
void reset()
A reset function.
Definition: ProfileBin2D.h:87
Bin2D< DBN > & operator=(const Bin2D< DBN > &b)
Copy assignment.
Definition: Bin2D.h:83
void fill(double x, double y, double z, double weight=1.0)
Definition: ProfileBin2D.h:68
Axis1D< BIN1D, DBN > operator-(const Axis1D< BIN1D, DBN > &first, const Axis1D< BIN1D, DBN > &second)
Subtract the statistics on two axis.
Definition: Axis1D.h:494
double sumWZ() const
The sum of z*weight.
Definition: ProfileBin2D.h:156
std::pair< double, double > xyMid() const
The geometric centre of the bin.
Definition: Bin2D.h:173
ProfileBin2D(const ProfileBin2D &pb)
Copy constructor.
Definition: ProfileBin2D.h:49
void fillBin(double z, double weight=1.0)
Definition: ProfileBin2D.h:82
double variance() const
The variance of the z distribution about the mean.
Definition: ProfileBin2D.h:129
double stdErr() const
The standard error on the mean.
Definition: ProfileBin2D.h:134
Bin2D< DBN > & add(const Bin2D< DBN > &b)
Merge two adjacent bins.
Definition: Bin2D.h:377
ProfileBin2D & add(const ProfileBin2D &pb)
Add two bins.
Definition: ProfileBin2D.h:180
ProfileBin2D & operator+=(const ProfileBin2D &toAdd)
Add two bins (for use by Profile2D)
Definition: ProfileBin2D.h:169
double mean() const
The mean of the z distribution.
Definition: ProfileBin2D.h:119
void scaleXYZ(double ax, double ay, double az)
Definition: ProfileBin2D.h:107
Axis1D< BIN1D, DBN > operator+(const Axis1D< BIN1D, DBN > &first, const Axis1D< BIN1D, DBN > &second)
Add the statistics on two axes.
Definition: Axis1D.h:486
void scaleXY(double scaleX, double scaleY)
Definition: Bin2D.h:111
ProfileBin2D(const std::pair< double, double > &xedges, const std::pair< double, double > &yedges)
Constructor accepting a set of all edges of a bin.
Definition: ProfileBin2D.h:35
ProfileBin2D(double xmin, double xmax, double ymin, double ymax)
Make a new, empty bin with two pairs of edges.
Definition: ProfileBin2D.h:30
ProfileBin2D & subtract(const ProfileBin2D &pb)
Subtract one bin from another.
Definition: ProfileBin2D.h:186
ProfileBin2D & operator=(const ProfileBin2D &pb)
Copy assignment.
Definition: ProfileBin2D.h:54
virtual void reset()
Reset this bin.
Definition: Bin2D.h:97
A generic 2D bin type.
Definition: Bin2D.h:25
ProfileBin2D(const std::pair< double, double > &xedges, const std::pair< double, double > &yedges, const Dbn3D &dbn)
Make a bin with all the components of a fill history.
Definition: ProfileBin2D.h:43
double rms() const
The RMS of the z distribution.
Definition: ProfileBin2D.h:144
A 2D distribution.
Definition: Dbn3D.h:16
double stdDev() const
The std deviation of the z distribution about the mean.
Definition: ProfileBin2D.h:124
double sumWZ2() const
Definition: ProfileBin2D.h:160
double relErr() const
The relative size of the error on the mean.
Definition: ProfileBin2D.h:139
void fill(std::pair< double, double > coords, double z, double weight=1.0)
Definition: ProfileBin2D.h:75
void scaleZ(double az)
Definition: ProfileBin2D.h:100
Bin2D< DBN > & subtract(const Bin2D< DBN > &b)
Definition: Bin2D.h:390