#include <math.h>
#include <iostream>
void kdTreeBinning() {
double mu[2] = {0,2};
double sig[2] = {2,3};
for (
UInt_t i = 0; i < DATADIM; ++i)
for (
UInt_t j = 0; j < DATASZ; ++j)
smp[DATASZ * i + j] =
r.Gaus(mu[i], sig[i]);
TH2D*
h1 =
new TH2D(
"h1BinTest",
"Regular binning", h1bins, -5., 5., h1bins, -5., 5.);
for (
UInt_t j = 0; j < DATASZ; ++j)
h1->
Fill(smp[j], smp[DATASZ + j]);
for (
UInt_t i = 0; i < nbins; ++i) {
h2pol->
AddBin(binsMinEdges[edgeDim], binsMinEdges[edgeDim + 1], binsMaxEdges[edgeDim], binsMaxEdges[edgeDim + 1]);
}
std::cout <<
"Bin with minimum density: " << kdBins->
GetBinMinDensity() << std::endl;
std::cout <<
"Bin with maximum density: " << kdBins->
GetBinMaxDensity() << std::endl;
std::vector<Double_t> z = std::vector<Double_t>(DATASZ, 0.);
for (
UInt_t i = 0; i < DATASZ; ++i)
h2polrebin->
AddBin(binMinEdges[0], binMinEdges[1], binMaxEdges[0], binMaxEdges[1]);
}
std::cout <<
"Bin with minimum density: " << kdBins->
GetBinMinDensity() << std::endl;
std::cout <<
"Bin with maximum density: " << kdBins->
GetBinMaxDensity() << std::endl;
for (
UInt_t i = 0; i < DATASZ; ++i)
TCanvas* c4 =
new TCanvas(
"glc4",
"TH2Poly from a kdTree (Ordered)",50,50,800,800);
h2polrebin->
Draw(
"COLZ L");
}
}
}
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
virtual void Update()
Update canvas pad buffers.
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Graphics object made of three arrays X, Y and Z with the same number of points each.
virtual void Draw(Option_t *option="P0")
Specific drawing options can be used to paint a TGraph2D:
1-D histogram with a float per channel (see TH1 documentation)}
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual void Draw(Option_t *option="")
Draw this histogram with options.
2-D histogram with a double per channel (see TH1 documentation)}
2D Histogram with Polygonal Bins
void SetFloat(Bool_t flag=true)
When set to kTRUE, allows the histogram to expand if a bin outside the limits is added.
virtual Double_t GetBinContent(Int_t bin) const
Returns the content of the input bin For the overflow/underflow/sea bins:
virtual Int_t AddBin(TObject *poly)
Adds a new bin to the histogram.
virtual void SetBinContent(Int_t bin, Double_t content)
Sets the contents of the input bin to the input content Negative values between -1 and -9 are for the...
Int_t FindBin(Double_t x, Double_t y, Double_t z=0)
Returns the bin number of the bin at the given coordinate.
<- TKDTreeBinning - A class providing multidimensional binning ->
const Double_t * GetBinMaxEdges(UInt_t bin) const
Returns the bin's maximum edges. 'bin' is between 0 and fNBins - 1.
const Double_t * GetBinsMaxEdges() const
Returns an array with all bins' maximum edges The edges are arranges as xmax_1,ymax_1,...
UInt_t GetBinMaxDensity() const
Return the bin with maximum density.
UInt_t GetNBins() const
Returns the number of bins.
Double_t GetDataMax(UInt_t dim) const
Returns the maximum of the data in the dim coordinate. 'dim' is between 0 and fDim - 1.
const Double_t * GetBinMinEdges(UInt_t bin) const
Returns the bin's minimum edges. 'bin' is between 0 and fNBins - 1.
Double_t GetDataMin(UInt_t dim) const
Returns the minimum of the data in the dim coordinate. 'dim' is between 0 and fDim - 1.
void SortBinsByDensity(Bool_t sortAsc=kTRUE)
Sorts bins by their density.
Double_t GetBinDensity(UInt_t bin) const
Returns the density in bin.
const Double_t * GetBinsMinEdges() const
Returns an array with all bins' minimum edges The edges are arranges as xmin_1,ymin_1,...
UInt_t GetBinMinDensity() const
Return the bin with minimum density.
const Double_t * GetOneDimBinEdges() const
Returns a pointer to the vector of the bin edges for one dimensional binning only.
UInt_t GetDim() const
Returns the number of dimensions.
const Double_t * SortOneDimBinEdges(Bool_t sortAsc=kTRUE)
Sort the one-dimensional bin edges and retuns a pointer to them.
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
Random number generator class based on M.