12#ifndef ROOT_Rebin2DHelpers
13#define ROOT_Rebin2DHelpers
21#include <initializer_list>
36 }
else if (
oldAxis.GetXbins()->GetSize() > 0) {
37 std::vector<Double_t> edges(
nnew + 1);
40 newAxis.
Set(
nnew, edges.data());
52 std::vector<Int_t> map(
nOld + 2);
74 "Bin edge %d of rebinned histogram does not match any bin edges of the old histogram. "
75 "Result can be inconsistent",
112 info.truncated =
true;
151 if (
newXaxis.GetXbins()->GetSize() > 0 ||
newYaxis.GetXbins()->GetSize() > 0) {
152 std::vector<Double_t>
xEdges(
nx + 1);
153 std::vector<Double_t>
yEdges(
ny + 1);
154 for (
Int_t i = 0; i <=
nx; ++i)
156 for (
Int_t i = 0; i <=
ny; ++i)
168 const std::vector<Int_t> &
mapY,
169 std::initializer_list<std::pair<const Double_t *, Double_t *>>
arrays)
int Int_t
Signed integer 4 bytes (int)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Class to manage histogram axis.
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
virtual Int_t FindFixBin(Double_t x) const
Find bin number corresponding to abscissa x
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
TH1 is the base class of all histogram classes in ROOT.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
void DefineRebinnedAxis(const TAxis &oldAxis, Int_t ngroup, Int_t nnew, const Double_t *userBins, Double_t xmin, Double_t xmax, TAxis &newAxis)
Define the axis of the rebinned histogram: either from the user-provided bin edges,...
void WarnAboutUnusedFlowContent(const TAxis &oldAxis, const RebinnedAxisInfo &info, const Double_t *userBins, char axisName, const Double_t *bins, Int_t stride, Int_t nOther, Int_t otherStride, TH1 &hist, const char *where)
Warn when the range of the new axis extends beyond the old one while the corresponding flow bins hold...
void WarnAboutMisalignedEdges(const TAxis &oldAxis, const TAxis &newAxis, TH1 &hist, const char *where)
Warn when a bin edge of the new axis that lies inside the old axis range does not line up with a bin ...
std::vector< Int_t > MakeRebinMap(const TAxis &oldAxis, const TAxis &newAxis)
Map each cell of the old axis (including underflow 0 and overflow n+1) to the cell of the new axis th...
void SetRebinnedBins2D(TH1 &hnew, const TAxis &newXaxis, const TAxis &newYaxis)
Apply the axes of the rebinned histogram, using explicit bin edges if any of the two axes has non-uni...
void MergeRebinnedCells(Int_t nOldX, Int_t nOldY, Int_t nNewX, const std::vector< Int_t > &mapX, const std::vector< Int_t > &mapY, std::initializer_list< std::pair< const Double_t *, Double_t * > > arrays)
Accumulate every old cell (including under- and overflow) into the new cell given by the per-axis bin...
bool SetupRebinnedAxis(const TAxis &oldAxis, Int_t ngroup, const Double_t *userBins, char axisName, TH1 &hist, const char *where, RebinnedAxisInfo &info)
Validate the rebinning parameters for one axis and fill the definition of the rebinned axis and the m...
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Bool_t AreEqualAbs(Double_t af, Double_t bf, Double_t epsilon)
Comparing floating points.
The definition of one axis of the rebinned histogram.
Int_t nNewBins
number of bins of the rebinned axis
TAxis newAxis
the rebinned axis
bool truncated
the group count does not divide the old bin count: top bins move to the overflow
std::vector< Int_t > binMap
map from old cell (0..n+1) to new cell
static uint64_t sum(uint64_t i)