30 auto item = std::make_unique<RHistDisplayItem>(*
this);
34 if (frame) frame->GetClientRanges(ctxt.
GetConnId(), ranges);
40 int nbinsx = himpl->GetAxis(0).GetNBinsNoOver();
42 int i1 = 0, i2 = nbinsx, stepi = 1;
45 i1 = himpl->GetAxis(0).FindBin(ranges.
GetMin(0));
46 i2 = himpl->GetAxis(0).FindBin(ranges.
GetMax(0));
47 if (i1 <= 1) i1 = 0;
else i1--;
48 if ((i2 <= 0) || (i2 >= nbinsx)) i2 = nbinsx;
else i2++;
57 static const int NumVisibleBins = 5000;
63 bool needrebin =
false, produce_minmax =
false;
65 if (i2 - i1 > NumVisibleBins) {
66 stepi = (i2 - i1) / NumVisibleBins;
67 if (stepi < 2) stepi = 2;
69 produce_minmax =
true;
70 if (stepi % 2 == 1) stepi++;
72 i1 = (i1 / stepi) * stepi;
73 if (i2 % stepi > 0) i2 = (i2/stepi + 1) * stepi;
80 auto &bins = item->GetBinContent();
82 bins.resize((i2 - i1) / stepi * (produce_minmax ? 2 : 1));
87 double min{0}, minpos{0}, max{0};
89 min = max = himpl->GetBinContentAsDouble(1);
90 if (max > 0) minpos = max;
94 for (
int i = 0; i < nbinsx; ++i) {
95 double val = himpl->GetBinContentAsDouble(i + 1);
96 if (val < min) min = val;
else
97 if (val > max) max = val;
98 if ((val > 0.) && (val < minpos)) minpos = val;
99 if (!needrebin && (i>=i1) && (i<i2)) {
108 for (
int i = i1; i < i2; i += stepi) {
109 int ir = std::min(i+stepi, nbinsx);
110 double vmin = himpl->GetBinContentAsDouble(i + 1);
111 if (produce_minmax) {
115 for(
int ii = i+1; ii < ir; ++ii) {
116 double val = himpl->GetBinContentAsDouble(ii + 1);
117 if (val < vmin) { vmin = val; imin = ii; }
118 if (val > vmax) { vmax = val; imax = ii; }
120 int indx = (i-i1)/stepi*2;
121 bins[indx] = (imin<imax) ? vmin : vmax;
122 bins[indx+1] = (imin<imax) ? vmax : vmin;
124 int indx = (i-i1)/stepi;
129 item->SetContentMinMax(min, minpos, max);
130 item->AddAxis(&himpl->GetAxis(0), i1, i2, !needrebin ? 1 : stepi / (produce_minmax ? 2 : 1));
138 auto item = std::make_unique<RHistDisplayItem>(*
this);
142 if (frame) frame->GetClientRanges(ctxt.
GetConnId(), ranges);
148 int nbinsx = himpl->GetAxis(0).GetNBinsNoOver();
149 int nbinsy = himpl->GetAxis(1).GetNBinsNoOver();
151 int i1 = 0, i2 = nbinsx, j1 = 0, j2 = nbinsy, stepi = 1, stepj = 1;
154 i1 = himpl->GetAxis(0).FindBin(ranges.
GetMin(0));
155 i2 = himpl->GetAxis(0).FindBin(ranges.
GetMax(0));
156 if (i1 <= 1) i1 = 0;
else i1--;
157 if ((i2 <= 0) || (i2 >= nbinsx)) i2 = nbinsx;
else i2++;
161 j1 = himpl->GetAxis(1).FindBin(ranges.
GetMin(1));
162 j2 = himpl->GetAxis(1).FindBin(ranges.
GetMax(1));
163 if (j1 <= 1) j1 = 0;
else j1--;
164 if ((j2 <= 0) || (j2 >= nbinsy)) j2 = nbinsy;
else j2++;
167 if ((i1 >= i2) || (j1 >= j2)) {
174 static const int NumVisibleBins = 200;
176 bool needrebin =
false;
178 if (i2 - i1 > NumVisibleBins) {
179 stepi = (i2 - i1) / NumVisibleBins;
180 if (stepi < 2) stepi = 2;
181 i1 = (i1 / stepi) * stepi;
182 if (i2 % stepi > 0) i2 = (i2/stepi + 1) * stepi;
186 if (j2 - j1 > NumVisibleBins) {
187 stepj = (j2 - j1) / NumVisibleBins;
188 if (stepj < 2) stepj = 2;
189 j1 = (j1 / stepj) * stepj;
190 if (j2 % stepj > 0) j2 = (j2/stepj + 1) * stepj;
197 auto &bins = item->GetBinContent();
198 bins.resize((i2 - i1) / stepi * (j2 - j1) / stepj);
200 double min{0}, minpos{0}, max{0};
202 min = max = himpl->GetBinContentAsDouble(1);
203 if (max > 0) minpos = max;
206 for (
int j = 0; j < nbinsy; ++j)
207 for (
int i = 0; i < nbinsx; ++i) {
208 double val = himpl->GetBinContentAsDouble(j*nbinsx + i + 1);
209 if (val < min) min = val;
else
210 if (val > max) max = val;
211 if ((val > 0.) && (val < minpos)) minpos = val;
212 if (!needrebin && (i>=i1) && (i<i2) && (j>=j1) && (j<j2)) {
213 int indx = (j-j1)*(i2-i1) + (i-i1);
221 for (
int j = j1; j < j2; j += stepj) {
222 int jr = std::min(j+stepj, nbinsy);
223 for (
int i = i1; i < i2; i += stepi) {
225 int ir = std::min(i+stepi, nbinsx);
227 for(
int jj = j; jj < jr; ++jj)
228 for(
int ii = i; ii < ir; ++ii) {
229 sum += himpl->GetBinContentAsDouble(jj*nbinsx + ii + 1);
233 int indx = (j-j1)/stepj * (i2-i1)/stepi + (i-i1)/stepi;
234 bins[indx] =
sum/cnt;
238 item->SetContentMinMax(min, minpos, max);
239 item->AddAxis(&himpl->GetAxis(0), i1, i2, stepi);
240 item->AddAxis(&himpl->GetAxis(1), j1, j2, stepj);
249 auto item = std::make_unique<RHistDisplayItem>(*
this);
253 if (frame) frame->GetClientRanges(ctxt.
GetConnId(), ranges);
259 int nbinsx = himpl->GetAxis(0).GetNBinsNoOver();
260 int nbinsy = himpl->GetAxis(1).GetNBinsNoOver();
261 int nbinsz = himpl->GetAxis(2).GetNBinsNoOver();
263 int i1 = 0, i2 = nbinsx, stepi = 1,
264 j1 = 0, j2 = nbinsy, stepj = 1,
265 k1 = 0, k2 = nbinsz, stepk = 1;
268 i1 = himpl->GetAxis(0).FindBin(ranges.
GetMin(0));
269 i2 = himpl->GetAxis(0).FindBin(ranges.
GetMax(0));
270 if (i1 <= 1) i1 = 0;
else i1--;
271 if ((i2 <= 0) || (i2 >= nbinsx)) i2 = nbinsx;
else i2++;
275 j1 = himpl->GetAxis(1).FindBin(ranges.
GetMin(1));
276 j2 = himpl->GetAxis(1).FindBin(ranges.
GetMax(1));
277 if (j1 <= 1) j1 = 0;
else j1--;
278 if ((j2 <= 0) || (j2 >= nbinsy)) j2 = nbinsy;
else j2++;
282 k1 = himpl->GetAxis(2).FindBin(ranges.
GetMin(2));
283 k2 = himpl->GetAxis(2).FindBin(ranges.
GetMax(2));
284 if (k1 <= 1) k1 = 0;
else k1--;
285 if ((k2 <= 0) || (k2 >= nbinsz)) k2 = nbinsz;
else k2++;
288 if ((i1 >= i2) || (j1 >= j2) || (k1 >= k2)) {
296 static const int NumVisibleBins = 25;
298 bool needrebin =
false;
300 if (i2 - i1 > NumVisibleBins) {
301 stepi = (i2 - i1) / NumVisibleBins;
302 if (stepi < 2) stepi = 2;
303 i1 = (i1 / stepi) * stepi;
304 if (i2 % stepi > 0) i2 = (i2/stepi + 1) * stepi;
308 if (j2 - j1 > NumVisibleBins) {
309 stepj = (j2 - j1) / NumVisibleBins;
310 if (stepj < 2) stepj = 2;
311 j1 = (j1 / stepj) * stepj;
312 if (j2 % stepj > 0) j2 = (j2/stepj + 1) * stepj;
316 if (k2 - k1 > NumVisibleBins) {
317 stepk = (k2 - k1) / NumVisibleBins;
318 if (stepk < 2) stepk = 2;
319 k1 = (k1 / stepk) * stepk;
320 if (k2 % stepk > 0) k2 = (k2/stepk + 1) * stepk;
327 auto &bins = item->GetBinContent();
328 bins.resize((i2 - i1) / stepi * (j2 - j1) / stepj * (k2 - k1) / stepk);
330 double min{0}, minpos{0}, max{0};
332 min = max = himpl->GetBinContentAsDouble(1);
333 if (max > 0) minpos = max;
336 for (
int k = 0; k < nbinsz; ++k)
337 for (
int j = 0; j < nbinsy; ++j)
338 for (
int i = 0; i < nbinsx; ++i) {
339 double val = himpl->GetBinContentAsDouble(k*nbinsx*nbinsy + j*nbinsx + i + 1);
340 if (val < min) min = val;
else
341 if (val > max) max = val;
342 if ((val > 0.) && (val < minpos)) minpos = val;
343 if (!needrebin && (i>=i1) && (i<i2) && (j>=j1) && (j<j2) && (k>=k1) && (k<k2)) {
344 int indx = (k-k1)*(j2-j1)*(i2-i1) + (j-j1)*(i2-i1) + (i-i1);
352 for (
int k = k1; k < k2; k += stepk) {
353 int kr = std::min(k+stepk, nbinsz);
354 for (
int j = j1; j < j2; j += stepj) {
355 int jr = std::min(j+stepj, nbinsy);
356 for (
int i = i1; i < i2; i += stepi) {
358 int ir = std::min(i+stepi, nbinsx);
360 for(
int kk = k; kk < kr; ++kk)
361 for(
int jj = j; jj < jr; ++jj)
362 for(
int ii = i; ii < ir; ++ii) {
363 sum += himpl->GetBinContentAsDouble(kk*nbinsx*nbinsy + jj*nbinsx + ii + 1);
367 int indx = (k-k1)/stepk * (j2-j1)/stepj * (i2-i1)/stepi + (j-j1)/stepj * (i2-i1)/stepi + (i-i1)/stepi;
368 bins[indx] =
sum/cnt;
373 item->SetContentMinMax(min, minpos, max);
374 item->AddAxis(&himpl->GetAxis(0), i1, i2, stepi);
375 item->AddAxis(&himpl->GetAxis(1), j1, j2, stepj);
376 item->AddAxis(&himpl->GetAxis(2), k1, k2, stepk);
unsigned GetConnId() const
RPadBase * GetPad() const
bool HasMin(unsigned ndim) const
bool HasMax(unsigned ndim) const
double GetMax(unsigned ndim) const
double GetMin(unsigned ndim) const
std::unique_ptr< RDisplayItem > CreateHistDisplay(const RDisplayContext &) override
std::unique_ptr< RDisplayItem > CreateHistDisplay(const RDisplayContext &) override
std::unique_ptr< RDisplayItem > CreateHistDisplay(const RDisplayContext &) override
Internal::RIOShared< HistImpl_t > fHistImpl
I/O capable reference on histogram.
std::shared_ptr< RFrame > GetFrame()
Get a frame object if exists.
static uint64_t sum(uint64_t i)