42 const int n3,
double min3,
double max3,
const int n4,
double min4,
double max4,
44 double indexMax = n1 * n2 * n3 * n4;
46 if (indexMax >
double(INT_MAX))
47 LOGLS_WARN(_log,
"Cannot hold a 4D histo with more than " << INT_MAX <<
" values.");
61 for (
int i = 0; i < 4; ++i) _scale[i] = _n[i] / (_maxVal[i] - _minVal[i]);
62 _data.
reset(
new int[nEntries]);
70 for (
int idim = 0; idim < 4; ++idim) {
71 int i = (int)
std::floor((
x[idim] - _minVal[idim]) * _scale[idim]);
72 if (i < 0 || i >= _n[idim])
return -1;
73 index = index * _n[idim] + i;
79 for (
int i = 3; i >= 0; --i) {
80 int bin = code % _n[i];
82 x[i] = _minVal[i] + ((double)bin + 0.5) / _scale[i];
98 if (_ndata == _dataSize) {
100 memcpy(newData.
get(), _data.
get(), _dataSize *
sizeof(_data[0]));
104 _data[_ndata++] = code;
119 if (_ndata == 0)
return 0;
120 int maxval = _data[0];
122 int oldval = _data[0];
123 int currentCount = 1;
124 for (
int i = 1; i < _ndata; ++i) {
125 if (_data[i] == oldval)
129 if (currentCount > maxCount) {
130 maxCount = currentCount;
144 while ((_data[start] < code) && start < _ndata) start++;
147 while (
end < _ndata && _data[start] == _data[
end])
end++;
148 int shift =
end - start;
149 int lastShift = _ndata - (
end - start);
150 for (
int i = start; i < lastShift; ++i) _data[i] = _data[i + shift];
158 xMin = xCenter[iDim] - 0.5 / _scale[iDim];
159 xMax = xCenter[iDim] + 0.5 / _scale[iDim];
163 for (
int i = 0; i < _ndata; ++i)