215 auto & newth2p =
dynamic_cast<TH2Poly &
>(newobj);
226 delete[] newth2p.fCells;
227 delete[] newth2p.fIsEmpty;
228 delete[] newth2p.fCompletelyInside;
234 for (
int i = 0; i<
fNCells; i++) {
239 delete newth2p.fBins;
241 newth2p.fBins =
nullptr;
244 newth2p.fBins =
dynamic_cast<TList *
>(
fBins->Clone());
246 Error(
"Copy",
"Error cloning the TH2Poly bin list");
251 for (
auto bin : *(newth2p.fBins)) {
252 newth2p.AddBinToPartition(
dynamic_cast<TH2PolyBin*
>(bin));
276 if (!poly)
return nullptr;
278 if (
fBins ==
nullptr) {
306 if (
fXaxis.GetXmin() > bin->GetXMin()) {
310 if (
fXaxis.GetXmax() < bin->GetXMax()) {
314 if (
fYaxis.GetXmin() > bin->GetYMin()) {
318 if (
fYaxis.GetXmax() < bin->GetYMax()) {
372 Error(
"Add",
"Attempt to add histograms with different number of bins");
386 Error(
"Add",
"Attempt to add histograms with different bin limits");
414 for (bin = 0; bin <
fNcells; bin++) {
419 fSumw2.fArray[bin] +=
c1 *
c1 * factor * factor * esq;
429 if (i == 1)
s1[i] +=
c1 *
c1 * s2[i];
430 else s1[i] +=
c1 * s2[i];
445 Int_t nl, nr, mb, mt;
446 Double_t xclipl, xclipr, yclipb, yclipt;
447 Double_t binXmax, binXmin, binYmax, binYmin;
469 for (
int i = nl; i <= nr; i++) {
472 for (
int j = mb; j <= mt; j++) {
478 if ((binXmin >= xclipl) && (binXmax <= xclipr) &&
479 (binYmax <= yclipt) && (binYmin >= yclipb)){
535 for (
int i = 0; i<
fNCells; i++) {
544 while((obj = next())){
559 while ((obj = next())) {
584 while ((obj = next())) {
612 if (
y >
fYaxis.GetXmax()) overflow += -1;
613 else if (
y >
fYaxis.GetXmin()) overflow += -4;
615 if (
x >
fXaxis.GetXmax()) overflow += -2;
616 else if (
x >
fXaxis.GetXmin()) overflow += -1;
617 if (overflow != -5)
return overflow;
637 while ((obj=next())) {
674 if (
y >
fYaxis.GetXmax()) overflow += -1;
675 else if (
y >
fYaxis.GetXmin()) overflow += -4;
677 if (
x >
fXaxis.GetXmax()) overflow += -2;
678 else if(
x >
fXaxis.GetXmin()) overflow += -1;
679 if (overflow != -5) {
707 while ((obj=next())) {
749 while ((obj = next())) {
775 for (
int i = 0; i < ntimes; i += stride) {
798 while ((obj = next())) {
806 while ((obj = next())) {
866 Fatal(
"GetNumberOfBins",
"Object has an invalid number of bins");
886 fSumw2.fArray[binIndex] = error * error;
897 if (bin <= 0)
return "";
907 if (bin <= 0)
return "";
927 while ((obj=next())) {
951 while ((obj=next())) {
954 if (
c>max &&
c<maxval) max=
c;
975 while ((obj=next())) {
999 while ((obj=next())) {
1001 c =
b->GetContent();
1018 Double_t xloop = xstart, yloop, xtemp, ytemp;
1022 yloop = ystart +
a / 2.0;
1023 for (
int sCounter = 0; sCounter < s; sCounter++) {
1026 if (sCounter%2 == 0)
1027 numberOfHexagonsInTheRow = k;
1029 numberOfHexagonsInTheRow = k - 1;
1038 y[2] =
y[1] +
a / 2.0;
1044 y[5] =
y[4] -
a/2.0;
1050 if (sCounter%2 == 0)
1058 for (
int sCounter = 0; sCounter < s; sCounter++) {
1061 if (sCounter%2 == 0)
1062 numberOfHexagonsInTheRow = k;
1064 numberOfHexagonsInTheRow = k - 1;
1069 x[1] =
x[0] +
a/2.0;
1073 x[3] =
x[2] +
a/2.0;
1084 if (sCounter%2 == 0)
1091 Error(
"Honeycomb",
"Unknown option");
1109 fXaxis.Set(100, xlow, xup);
1110 fYaxis.Set(100, ylow, yup);
1171 if (!gl)
return inter;
1174 while ((
g = (
TGraph*) next())) {
1180 if (inter)
return inter;
1195 Bool_t p0R, p0L, p0T, p0B, p0xM, p0yM, p1R, p1L, p1T;
1196 Bool_t p1B, p1xM, p1yM, p0In, p1In;
1198 for (
int counter = 0; counter < (bn-1); counter++) {
1200 p0L =
x[counter] <= xclipl;
1201 p1L =
x[counter + 1] <= xclipl;
1202 if (p0L && p1L)
continue;
1203 p0R =
x[counter] >= xclipr;
1204 p1R =
x[counter + 1] >= xclipr;
1205 if (p0R && p1R)
continue;
1206 p0T =
y[counter] >= yclipt;
1207 p1T =
y[counter + 1] >= yclipt;
1208 if (p0T && p1T)
continue;
1209 p0B =
y[counter] <= yclipb;
1210 p1B =
y[counter + 1] <= yclipb;
1211 if (p0B && p1B)
continue;
1214 p0xM = !p0R && !p0L;
1215 p0yM = !p0T && !p0B;
1216 p1xM = !p1R && !p1L;
1217 p1yM = !p1T && !p1B;
1218 p0In = p0xM && p0yM;
1219 p1In = p1xM && p1yM;
1224 if (p1In)
return kTRUE;
1231 if (p0xM && p1xM)
return kTRUE;
1232 if (p0yM && p1yM)
return kTRUE;
1237 xcoord[0] =
x[counter];
1238 xcoord[1] =
x[counter + 1];
1239 ycoord[0] =
y[counter];
1240 ycoord[1] =
y[counter + 1];
1307 for (
auto h2pAsObj : *coll) {
1308 if (!
Add((
TH1*)h2pAsObj, 1.)) {
1309 Warning(
"Merge",
"An issue was encountered during the merge operation.");
1335 while (
auto obj = next()) {
1345 out <<
" " << hname <<
"->SetBinContent(" << bin <<
"," << bc <<
");\n";
1353 out <<
" " << hname <<
"->SetBinError(" << bin <<
"," << be <<
");\n";
1404 if (!
fBins)
return false;
1406 if (!bin)
return false;
1477 fArea =
g->Integral(0,bn-1);
1483 if (!gl)
return fArea;
1486 while ((
g = (
TGraph*) next())) {
1511 for (i=1; i<bn; i++) {
if (
fXmax < bx[i])
fXmax = bx[i];}
1517 if (!gl)
return fXmax;
1521 while ((
g = (
TGraph*) next())) {
1525 for (i=0; i<bn; i++) {
if (
fXmax < bx[i])
fXmax = bx[i];}
1547 for (i=1; i<bn; i++) {
if (
fXmin > bx[i])
fXmin = bx[i];}
1553 if (!gl)
return fXmin;
1557 while ((
g = (
TGraph*) next())) {
1561 for (i=0; i<bn; i++) {
if (
fXmin > bx[i])
fXmin = bx[i];}
1583 for (i=1; i<bn; i++) {
if (
fYmax < by[i])
fYmax = by[i];}
1589 if (!gl)
return fYmax;
1593 while ((
g = (
TGraph*) next())) {
1597 for (i=0; i<bn; i++) {
if (
fYmax < by[i])
fYmax = by[i];}
1619 for (i=1; i<bn; i++) {
if (
fYmin > by[i])
fYmin = by[i];}
1625 if (!gl)
return fYmin;
1629 while ((
g = (
TGraph*) next())) {
1633 for (i=0; i<bn; i++) {
if (
fYmin > by[i])
fYmin = by[i];}
1649 in =
g->IsInside(
x,
y);
1669 Error(
"Add",
"Not implemented for TH2Poly");
1677 Error(
"Add",
"Not implemented for TH2Poly");
1685 Error(
"Divide",
"Not implemented for TH2Poly");
1693 Error(
"Multiply",
"Not implemented for TH2Poly");
1700 Error(
"ComputeIntegral",
"Not implemented for TH2Poly");
1707 Error(
"FFT",
"Not implemented for TH2Poly");
1714 Error(
"GetAsymmetry",
"Not implemented for TH2Poly");
1721 Error(
"Interpolate",
"Not implemented for TH2Poly");
1728 Error(
"AddBinContent",
"Not implemented for TH2Poly");
1734 Error(
"AddBinContent",
"Not implemented for TH2Poly");
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
long long Long64_t
Portable signed long integer 8 bytes.
const char Option_t
Option string (const char).
Collection abstract base class.
Double_t * fBuffer
[fBufferSize] entry buffer
Int_t fNcells
Number of bins(1D), cells (2D) +U/Overflows.
void SetTitle(const char *title) override
Change/set the title.
Double_t fTsumw
Total Sum of weights.
Double_t fTsumw2
Total Sum of squares of weights.
Double_t fTsumwx2
Total Sum of weight*X*X.
virtual Double_t GetNormFactor() const
@ kIsNotW
Histogram is forced to be not weighted even when the histogram is filled with weighted.
virtual Double_t GetSumOfWeights() const
Return the sum of weights across all bins excluding under/overflows.
Double_t fMaximum
Maximum value for plotting.
TString ProvideSaveName(Option_t *option, Bool_t testfdir=kFALSE)
Provide variable name for histogram for saving as primitive Histogram pointer has by default the hist...
Int_t fDimension
! Histogram dimension (1, 2 or 3 dim)
virtual void SavePrimitiveHelp(std::ostream &out, const char *hname, Option_t *option="")
Helper function for the SavePrimitive functions from TH1 or classes derived from TH1,...
virtual Double_t GetBinErrorSqUnchecked(Int_t bin) const
Double_t fMinimum
Minimum value for plotting.
virtual Double_t GetEntries() const
Return the current number of entries.
void SetName(const char *name) override
Change the name of this histogram.
virtual void ResetStats()
Reset the statistics including the number of entries and replace with values calculated from bin cont...
@ kNstat
Size of statistics data (up to TProfile3D).
virtual void SetBinErrorOption(EBinErrorOpt type)
Double_t fEntries
Number of entries.
@ kNormal
Errors with Normal (Wald) approximation: errorUp=errorLow= sqrt(N).
TAxis fXaxis
X axis descriptor.
TArrayD fSumw2
Array of sum of squares of weights.
virtual Int_t GetSumw2N() const
TAxis fYaxis
Y axis descriptor.
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
virtual void SetEntries(Double_t n)
Double_t fTsumwx
Total Sum of weight*X.
Helper class to represent a bin in the TH2Poly histogram.
Double_t GetXMin()
Returns the minimum value for the x coordinates of the bin.
~TH2PolyBin() override
Destructor.
Double_t GetYMax()
Returns the maximum value for the y coordinates of the bin.
Double_t GetArea()
Returns the area of the bin.
Double_t GetYMin()
Returns the minimum value for the y coordinates of the bin.
Double_t fContent
Bin content.
Bool_t IsInside(Double_t x, Double_t y) const
Return "true" if the point (x,y) is inside the bin.
Double_t fXmax
X maximum value.
Int_t fNumber
Bin number of the bin in TH2Poly.
TH2PolyBin()
Default constructor.
Double_t fYmax
Y maximum value.
Double_t GetXMax()
Returns the maximum value for the x coordinates of the bin.
Double_t GetContent() const
Double_t fYmin
Y minimum value.
void SetChanged(Bool_t flag)
Int_t GetBinNumber() const
Double_t fXmin
X minimum value.
TObject * GetPolygon() const
TObject * fPoly
Object holding the polygon definition.
Bool_t Multiply(TF1 *, Double_t) override
NOT IMPLEMENTED for TH2Poly.
void UpdateBinContent(Int_t bin, Double_t content) override
Raw update of bin content on internal data structure see convention for numbering bins in TH1::GetBin...
TH2Poly & operator=(const TH2Poly &rhs)
Assignment operator.
TList * GetBins()
Returns the TList of all bins in the histogram.
void ClearBinContents()
Clears the contents of all bins in the histogram.
Double_t fOverflow[kNOverflow]
Overflow bins.
Bool_t fFloat
When set to kTRUE, allows the histogram to expand if a bin outside the limits is added.
Bool_t IsIntersecting(TH2PolyBin *bin, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt)
Returns kTRUE if the input bin is intersecting with the input rectangle (xclipl, xclipr,...
void SetFloat(Bool_t flag=true)
When set to kTRUE, allows the histogram to expand if a bin outside the limits is added.
Double_t Integral(Option_t *option="") const override
Returns the integral of bin contents.
virtual TH2PolyBin * CreateBin(TObject *poly)
Create appropriate histogram bin.
Double_t GetBinContent(Int_t bin) const override
Returns the content of the input bin Bin numbers are from [1,nbins] and for the overflow/underflow/se...
Bool_t * fIsEmpty
[fNCells] The array that returns true if the cell at the given coordinate is empty
Double_t RetrieveBinContent(Int_t bin) const override
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
TList * fBins
List of bins. The list owns the contained objects.
void AddBinToPartition(TH2PolyBin *bin)
Adds the input bin into the partition cell matrix.
Bool_t fBinContentChanged
!For the 3D Painter
Int_t Fill(Double_t x, Double_t y) override
Increment the bin containing (x,y) by 1.
Int_t GetNumberOfBins() const
Return the number of bins : it should be the size of the bin list.
void SetBinContentChanged(Bool_t flag)
void GetStats(Double_t *stats) const override
Fill the array stats from the contents of this histogram The array stats must be correctly dimensione...
Bool_t * fCompletelyInside
[fNCells] The array that returns true if the cell at the given coordinate is completely inside a bin
TH2Poly()
Default Constructor. No boundaries specified.
Bool_t IsInsideBin(Int_t binnr, Double_t x, Double_t y)
Return "true" if the point (x,y) is inside the bin of binnr.
Bool_t fNewBinAdded
!For the 3D Painter
void Copy(TObject &newth2p) const override
Copy function for TH2Poly.
void AddBinContent(Int_t) override
NOT IMPLEMENTED for TH2Poly.
void SetBinError(Int_t bin, Double_t error) override
Set the bin Error.
const char * GetBinTitle(Int_t bin) const
Returns the bin title.
void SetNewBinAdded(Bool_t flag)
void Scale(Double_t c1=1, Option_t *option="") override
Multiply this histogram by a constant c1.
void ChangePartition(Int_t n, Int_t m)
Changes the number of partition cells in the histogram.
virtual Double_t Interpolate(Double_t, Double_t)
NOT IMPLEMENTED for TH2Poly.
Double_t GetMinimum() const
Returns the minimum value of the histogram.
const char * GetBinName(Int_t bin) const
Returns the bin name.
void FillN(Int_t ntimes, const Double_t *x, const Double_t *y, const Double_t *w, Int_t stride=1) override
Fills a 2-D histogram with an array of values and weights.
Int_t fNCells
Number of partition cells: fCellX*fCellY.
Int_t FindBin(Double_t x, Double_t y, Double_t z=0) override
Returns the bin number of the bin at the given coordinate.
Bool_t Divide(TF1 *, Double_t) override
NOT IMPLEMENTED for TH2Poly.
void Initialize(Double_t xlow, Double_t xup, Double_t ylow, Double_t yup, Int_t n, Int_t m)
Initializes the TH2Poly object. This method is called by the constructor.
Int_t fCellX
Number of partition cells in the x-direction of the histogram.
~TH2Poly() override
Destructor.
virtual Int_t AddBin(TObject *poly)
Adds a new bin to the histogram.
Double_t GetBinError(Int_t bin) const override
Returns the value of error associated to bin number bin.
Bool_t IsIntersectingPolygon(Int_t bn, Double_t *x, Double_t *y, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt)
Returns kTRUE if the input polygon (bn, x, y) is intersecting with the input rectangle (xclipl,...
Bool_t Add(const TH1 *h1, Double_t c1) override
Performs the operation: this = this + c1*h1.
virtual TH1 * GetAsymmetry(TH1 *, Double_t, Double_t)
NOT IMPLEMENTED for TH2Poly.
void Honeycomb(Double_t xstart, Double_t ystart, Double_t a, Int_t k, Int_t s, Option_t *option="v")
Bins the histogram using a honeycomb structure If the option "v" is specified, the hexagons are drawn...
Long64_t Merge(TCollection *) override
Merge TH2Polys Given the special nature of the TH2Poly, the merge is implemented in terms of subseque...
void SetBinContent(Int_t bin, Double_t content) override
Sets the contents of the input bin to the input content Negative values between -1 and -9 are for the...
Double_t GetMaximum() const
Returns the maximum value of the histogram.
void Reset(Option_t *option) override
Reset this histogram: contents, errors, etc.
Double_t fStepY
Dimensions of a partition cell.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
TH1 * FFT(TH1 *, Option_t *) override
NOT IMPLEMENTED for TH2Poly.
Double_t ComputeIntegral(Bool_t, Option_t *) override
NOT IMPLEMENTED for TH2Poly.
TList * fCells
[fNCells] The array of TLists that store the bins that intersect with each cell. List do not own the ...
Int_t fCellY
Number of partition cells in the y-direction of the histogram.
void Copy(TObject &hnew) const override
Copy.
Double_t fTsumwxy
Total Sum of weight*X*Y.
void Reset(Option_t *option="") override
Reset this histogram: contents, errors, etc.
Double_t fTsumwy2
Total Sum of weight*Y*Y.
Double_t fTsumwy
Total Sum of weight*Y.
TH2()
2-D histogram default constructor.
void PutStats(Double_t *stats) override
Replace current statistics with the values in array stats.
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
virtual Int_t IsInside(Double_t x, Double_t y) const
TList * GetListOfGraphs() const
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Mother of all ROOT objects.
Bool_t TestBit(UInt_t f) const
virtual const char * GetName() const
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
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.
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
virtual TClass * IsA() const
TObject()
TObject constructor.
void ToLower()
Change string to lower-case.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Bool_t IsInside(T xp, T yp, Int_t np, T *x, T *y)
Function which returns kTRUE if point xp,yp lies inside the polygon defined by the np points in array...
Double_t QuietNaN()
Returns a quiet NaN as defined by IEEE 754.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.