yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis  1.7.2
ProfileBin1D.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-2017 The YODA collaboration (see AUTHORS for details)
5 //
6 #ifndef YODA_ProfileBin1D_h
7 #define YODA_ProfileBin1D_h
8 
9 #include "YODA/Bin1D.h"
10 #include "YODA/Dbn2D.h"
11 #include "YODA/Exceptions.h"
12 
13 namespace YODA {
14 
15 
23  class ProfileBin1D : public Bin1D<Dbn2D> {
24  public:
25 
27 
28 
30  ProfileBin1D(double lowedge, double highedge)
31  : Bin1D<Dbn2D>(std::make_pair(lowedge, highedge))
32  { }
33 
34 
36  ProfileBin1D(const std::pair<double,double>& edges)
37  : Bin1D<Dbn2D>(edges)
38  { }
39 
40 
44  ProfileBin1D(std::pair<double, double> edges, const Dbn2D& dbnxy)
45  : Bin1D<Dbn2D>(edges, dbnxy)
46  { }
47 
48 
51  : Bin1D<Dbn2D>(pb)
52  { }
53 
54 
58  return *this;
59  }
60 
62 
63 
65 
66 
70  void fill(double x, double y, double weight=1.0, double fraction=1.0) {
71  _dbn.fill(x, y, weight, fraction);
72  }
73 
77  void fillBin(double y, double weight=1.0, double fraction=1.0) {
78  fill(xMid(), y, weight, fraction);
79  }
80 
82 
83 
85 
86 
90  inline void scaleY(double ay) {
91  _dbn.scaleY(ay);
92  }
93 
97  inline void scaleXY(double ax, double ay) {
98  scaleX(ax);
99  scaleY(ay);
100  }
101 
103 
104 
105  public:
106 
108 
109 
111  double mean() const {
112  return _dbn.yMean();
113  }
114 
116  double stdDev() const {
117  return _dbn.yStdDev();
118  }
119 
121  double variance() const {
122  return _dbn.yVariance();
123  }
124 
126  double stdErr() const {
127  return _dbn.yStdErr();
128  }
129 
131  double relErr() const {
132  return stdErr() != 0 ? stdErr() / mean() : 0;
133  }
134 
136  double rms() const {
137  return _dbn.yRMS();
138  }
139 
141 
142 
144 
145 
147  double sumWY() const {
148  return _dbn.sumWY();
149  }
150 
152  double sumWY2() const {
153  return _dbn.sumWY2();
154  }
155 
157 
158 
159  public:
160 
163  return add(toAdd);
164  }
165 
167  ProfileBin1D& operator -= (const ProfileBin1D& toSubtract) {
168  return subtract(toSubtract);
169  }
170 
171 
172  protected:
173 
176  Bin1D<Dbn2D>::add(pb);
177  return *this;
178  }
179 
183  return *this;
184  }
185 
186  };
187 
188 
189  inline ProfileBin1D operator + (const ProfileBin1D& a, const ProfileBin1D& b) {
190  ProfileBin1D rtn(a);
191  rtn += b;
192  return rtn;
193  }
194 
195  inline ProfileBin1D operator - (const ProfileBin1D& a, const ProfileBin1D& b) {
196  ProfileBin1D rtn(a);
197  rtn -= b;
198  return rtn;
199  }
200 
201 
202 }
203 
204 #endif
void fill(double x, double y, double weight=1.0, double fraction=1.0)
Definition: ProfileBin1D.h:70
ProfileBin1D(std::pair< double, double > edges, const Dbn2D &dbnxy)
Make a profile bin with all the components of a fill history.
Definition: ProfileBin1D.h:44
Bin1D & operator=(const Bin1D< DBN > &b)
Copy assignment.
Definition: Bin1D.h:73
double rms() const
The RMS of the y distribution.
Definition: ProfileBin1D.h:136
Axis1D< BIN1D, DBN > operator-(const Axis1D< BIN1D, DBN > &first, const Axis1D< BIN1D, DBN > &second)
Subtract the statistics on two axis.
Definition: Axis1D.h:597
STL namespace.
ProfileBin1D & operator-=(const ProfileBin1D &toSubtract)
Subtract two bins.
Definition: ProfileBin1D.h:167
double sumWY() const
The sum of y*weight.
Definition: ProfileBin1D.h:147
A generic 1D bin type.
Definition: Bin1D.h:27
void fillBin(double y, double weight=1.0, double fraction=1.0)
Definition: ProfileBin1D.h:77
ProfileBin1D & subtract(const ProfileBin1D &pb)
Subtract one bin from another (internal, explicitly named version)
Definition: ProfileBin1D.h:181
A 2D distribution.
Definition: Dbn2D.h:16
double xMid() const
Geometric centre of the bin, i.e. high+low/2.0.
Definition: Bin1D.h:136
ProfileBin1D(const std::pair< double, double > &edges)
Constructor giving bin low and high edges as a pair.
Definition: ProfileBin1D.h:36
void scaleX(double factor)
Definition: Bin1D.h:106
Axis1D< BIN1D, DBN > operator+(const Axis1D< BIN1D, DBN > &first, const Axis1D< BIN1D, DBN > &second)
Add the statistics on two axes.
Definition: Axis1D.h:589
double stdErr() const
The standard error on the mean.
Definition: ProfileBin1D.h:126
Bin1D< DBN > & add(const Bin1D< DBN > &b)
Definition: Bin1D.h:281
Bin1D< DBN > & subtract(const Bin1D< DBN > &b)
Definition: Bin1D.h:295
double stdDev() const
The std deviation of the y distribution about the mean.
Definition: ProfileBin1D.h:116
ProfileBin1D & add(const ProfileBin1D &pb)
Add two bins (internal, explicitly named version)
Definition: ProfileBin1D.h:175
A Bin1D specialised for handling profile-type information.
Definition: ProfileBin1D.h:23
ProfileBin1D & operator+=(const ProfileBin1D &toAdd)
Add two bins (for use by Profile1D).
Definition: ProfileBin1D.h:162
double variance() const
The variance of the y distribution about the mean.
Definition: ProfileBin1D.h:121
double relErr() const
The relative size of the error on the mean.
Definition: ProfileBin1D.h:131
void scaleXY(double ax, double ay)
Definition: ProfileBin1D.h:97
double mean() const
The mean of the y distribution.
Definition: ProfileBin1D.h:111
void scaleY(double ay)
Definition: ProfileBin1D.h:90
ProfileBin1D(double lowedge, double highedge)
Constructor giving bin low and high edges.
Definition: ProfileBin1D.h:30
ProfileBin1D & operator=(const ProfileBin1D &pb)
Copy assignment.
Definition: ProfileBin1D.h:56
ProfileBin1D(const ProfileBin1D &pb)
Copy constructor.
Definition: ProfileBin1D.h:50
double sumWY2() const
The sum of y^2 * weight.
Definition: ProfileBin1D.h:152