File indexing completed on 2025-04-19 09:09:49
0001 #ifndef ATOOLS_Math_Histogram_2D_H
0002 #define ATOOLS_Math_Histogram_2D_H
0003
0004 #include <string>
0005
0006
0007 namespace ATOOLS {
0008
0009 class Histogram_2D {
0010 private :
0011 int m_type, m_nbin, m_nbinx, m_nbiny;
0012 double m_lowerx, m_upperx, m_lowery, m_uppery;
0013 double * m_zvalues;
0014 double * m_z2values;
0015 double * m_psvalues;
0016 double * m_tmp;
0017 double m_fills,m_psfills;
0018 double m_binsizex, m_binsizey, m_logbasex, m_logbasey, m_mcb;
0019 int m_depth;
0020 bool m_active, m_finished, m_initialized;
0021 int m_logarithmicx, m_logarithmicy,m_fuzzyexp;
0022 public :
0023 Histogram_2D(int type,double xmin, double xmax, int nbinsx,
0024 double ymin, double ymax, int nbinsy);
0025 Histogram_2D(const Histogram_2D *);
0026 Histogram_2D(const std::string &);
0027 ~Histogram_2D();
0028 void Reset();
0029 void Insert(double x, double y);
0030 void Insert(int ix, int iy, double weight, double n=1.);
0031 void Insert(double x, double y, double weight, double n=1.);
0032 void InsertMCB(double x, double y, double weight, double n=1.);
0033 void InsertMCBIM(double coordinatex, double coordinatey, double value);
0034 void FinishMCB();
0035 void InsertRange(double startx, double endx,
0036 double starty, double endy, double value);
0037 void Scale(double factor);
0038 void Output();
0039 void Output(const std::string);
0040 void Finalize();
0041 void Restore();
0042 double Mean() const;
0043 inline void SetBin(int i, double entry) { m_zvalues[i]=entry; }
0044 inline void SetBin(int ix, int iy, double entry) { m_zvalues[iy+ix*m_nbiny+1]=entry; }
0045 inline double Bin(int i) { return m_zvalues[i]; }
0046 inline double Bin(int ix, int iy) { return m_zvalues[iy+ix*m_nbiny+1]; }
0047 double Bin(double x, double y);
0048
0049 inline void SetFills(double fills) { m_fills=fills; }
0050
0051
0052 int Type() { return m_type; }
0053 int Depth() { return m_depth; }
0054 int Nbin() const { return m_nbin-2; }
0055 int NbinX() const { return m_nbinx; }
0056 int NbinY() const { return m_nbiny; }
0057 double Xmin() const { return m_lowerx; }
0058 double Xmax() const { return m_upperx; }
0059 double Ymin() const { return m_lowery; }
0060 double Ymax() const { return m_uppery; }
0061 double Value(int i) const { return m_zvalues[i]; }
0062 double Value(int ix, int iy) const { return m_zvalues[iy+ix*m_nbiny+1]; }
0063 double Value2(int i) const { return m_z2values[i]; }
0064 double Value2(int ix, int iy) const { return m_z2values[iy+ix*m_nbiny+1]; }
0065 double Fills() const { return m_fills; }
0066 double BinSize() const { return m_binsizex*m_binsizey; }
0067 double BinSizeX() const { return m_binsizex; }
0068 double BinSizeY() const { return m_binsizey; }
0069
0070 double Integral() const;
0071 double Integral(int xminbin, int xmaxbin, int yminbin, int ymaxbin) const;
0072 double Integral(double xmin, double xmax, double ymin, double ymax) const;
0073 double Zmax() const;
0074 double Zmin() const;
0075 double LogCoeff() const;
0076
0077
0078 Histogram_2D & operator+=(const Histogram_2D & histo);
0079 void Addopt(const Histogram_2D & histo);
0080 };
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228 }
0229
0230
0231 #endif