Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TH2Poly.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Olivier Couet, Deniz Gunceler
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TH2Poly
13#define ROOT_TH2Poly
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// TH2Poly //
18// //
19// 2-Dim histogram with polygon bins //
20// //
21//////////////////////////////////////////////////////////////////////////
22
23#include "TH2.h"
24
25class TH2PolyBin: public TObject{
26
27public:
28 TH2PolyBin();
29 TH2PolyBin(TObject *poly, Int_t bin_number);
30 ~TH2PolyBin() override;
31
35 Double_t GetContent() const{return fContent;}
36 Bool_t GetChanged() const{return fChanged;}
37 Int_t GetBinNumber() const {return fNumber;}
38 TObject *GetPolygon() const {return fPoly;}
44 void SetChanged(Bool_t flag){fChanged = flag;}
45 void SetContent(Double_t content){fContent = content; SetChanged(true);}
46
47protected:
48 Bool_t fChanged; ///< For the 3D Painter
49 Int_t fNumber; ///< Bin number of the bin in TH2Poly
50 TObject *fPoly; ///< Object holding the polygon definition
51 Double_t fArea; ///< Bin area
52 Double_t fContent; ///< Bin content
53 Double_t fXmin; ///< X minimum value
54 Double_t fYmin; ///< Y minimum value
55 Double_t fXmax; ///< X maximum value
56 Double_t fYmax; ///< Y maximum value
57
58 ClassDefOverride(TH2PolyBin,1) //2-Dim polygon bins
59};
60
61class TList;
62class TGraph;
63class TMultiGraph;
64class TPad;
65
66class TH2Poly : public TH2 {
67
68public:
69 TH2Poly();
70 TH2Poly(const char *name,const char *title, Double_t xlow, Double_t xup, Double_t ylow, Double_t yup);
71 TH2Poly(const char *name,const char *title, Int_t nX, Double_t xlow, Double_t xup, Int_t nY, Double_t ylow, Double_t yup);
72 ~TH2Poly() override;
73
74 virtual TH2PolyBin *CreateBin(TObject *poly);
75 virtual Int_t AddBin(TObject *poly);
76 Int_t AddBin(Int_t n, const Double_t *x, const Double_t *y);
78 Bool_t Add(const TH1 *h1, Double_t c1) override;
79 Bool_t Add(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1) override;
80 Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="") override;
81 void ClearBinContents(); // Clears the content of all bins
82 TObject *Clone(const char* newname = "") const override;
83 void ChangePartition(Int_t n, Int_t m); // Sets the number of partition cells to another value
84 using TH2::Multiply;
85 using TH2::Divide;
86 using TH2::Interpolate;
87 Bool_t Divide(TF1 *, Double_t) override;
88 Bool_t Multiply(TF1 *, Double_t) override;
90 TH1 * FFT(TH1*, Option_t * ) override;
91 virtual TH1 * GetAsymmetry(TH1* , Double_t, Double_t);
93 Int_t Fill(Double_t x,Double_t y) override;
95 Int_t Fill(const char* name, Double_t w) override;
96 void FillN(Int_t ntimes, const Double_t* x, const Double_t* y, const Double_t* w, Int_t stride = 1) override;
97 Int_t FindBin(Double_t x, Double_t y, Double_t z = 0) override;
98 TList *GetBins(){return fBins;} ///< Returns the TList of all bins in the histogram
99 Double_t GetBinContent(Int_t bin) const override;
101 Double_t GetBinError(Int_t bin) const override;
102 const char *GetBinName(Int_t bin) const;
103 const char *GetBinTitle(Int_t bin) const;
105 Double_t GetMaximum() const;
106 Double_t GetMaximum(Double_t maxval) const override;
107 Double_t GetMinimum() const;
108 Double_t GetMinimum(Double_t minval) const override;
111 void Honeycomb(Double_t xstart, Double_t ystart, Double_t a, Int_t k, Int_t s);
112 Double_t Integral(Option_t* option = "") const override;
113 Long64_t Merge(TCollection *) override;
114 void Reset(Option_t *option) override;
115 void Scale(Double_t c1 = 1, Option_t* option = "") override;
116 void SavePrimitive(std::ostream& out, Option_t* option = "") override;
117 void SetBinContent(Int_t bin, Double_t content) override;
118 void SetBinError(Int_t bin, Double_t error) override;
120 void SetFloat(Bool_t flag = true);
123 void GetStats(Double_t *stats) const override;
124
125
126protected:
127
128 //functions not to be used for TH2Poly
129
130 Int_t Fill(Double_t) override{return -1;} ///< NOT IMPLEMENTED for TH2Poly
131 Int_t Fill(Double_t , const char *, Double_t) override{return -1;} ///< NOT IMPLEMENTED for TH2Poly
132 Int_t Fill(const char *, Double_t , Double_t ) override{return -1;} ///< NOT IMPLEMENTED for TH2Poly
133 Int_t Fill(const char *, const char *, Double_t ) override{return -1;} ///< NOT IMPLEMENTED for TH2Poly
134 void FillN(Int_t, const Double_t*, const Double_t*, Int_t) override{return;} ///< NOT IMPLEMENTED for TH2Poly
135
136 Double_t Integral(Int_t, Int_t, const Option_t*) const override{return 0;} ///< NOT IMPLEMENTED for TH2Poly
137 Double_t Integral(Int_t, Int_t, Int_t, Int_t, const Option_t*) const override{return 0;} ///< NOT IMPLEMENTED for TH2Poly
138 Double_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, const Option_t*) const override{return 0;} ///< NOT IMPLEMENTED for TH2Poly
139
140 Double_t GetBinContent(Int_t, Int_t) const override {return 0;} ///< NOT IMPLEMENTED for TH2Poly
141 Double_t GetBinContent(Int_t, Int_t, Int_t) const override {return 0;} ///< NOT IMPLEMENTED for TH2Poly
142
143 Double_t GetBinError(Int_t , Int_t) const override {return 0;} ///< NOT IMPLEMENTED for TH2Poly
144 Double_t GetBinError(Int_t , Int_t , Int_t) const override {return 0;} ///< NOT IMPLEMENTED for TH2Poly
145
146 void SetBinContent(Int_t, Int_t, Double_t) override{} ///< NOT IMPLEMENTED for TH2Poly
147 void SetBinContent(Int_t, Int_t, Int_t, Double_t) override{} ///< NOT IMPLEMENTED for TH2Poly
148 void SetBinError(Int_t, Int_t, Double_t) override {} ///< NOT IMPLEMENTED for TH2Poly
149 void SetBinError(Int_t, Int_t, Int_t, Double_t) override {} ///< NOT IMPLEMENTED for TH2Poly
150
151
152protected:
153 enum {
154 kNOverflow = 9 /// Number of overflows bins
155 };
156 Double_t fOverflow[kNOverflow]; ///< Overflow bins
157 Int_t fCellX; ///< Number of partition cells in the x-direction of the histogram
158 Int_t fCellY; ///< Number of partition cells in the y-direction of the histogram
159 Int_t fNCells; ///< Number of partition cells: fCellX*fCellY
160 TList *fCells; ///<[fNCells] The array of TLists that store the bins that intersect with each cell. List do not own the contained objects
161 Double_t fStepX, fStepY; ///< Dimensions of a partition cell
162 Bool_t *fIsEmpty; ///<[fNCells] The array that returns true if the cell at the given coordinate is empty
163 Bool_t *fCompletelyInside; ///<[fNCells] The array that returns true if the cell at the given coordinate is completely inside a bin
164 Bool_t fFloat; ///< When set to kTRUE, allows the histogram to expand if a bin outside the limits is added.
165 Bool_t fNewBinAdded; ///<!For the 3D Painter
166 Bool_t fBinContentChanged; ///<!For the 3D Painter
167 TList *fBins; ///< List of bins. The list owns the contained objects
168
169 void AddBinToPartition(TH2PolyBin *bin); // Adds the input bin into the partition matrix
170 void Initialize(Double_t xlow, Double_t xup, Double_t ylow, Double_t yup, Int_t n, Int_t m);
171 Bool_t IsIntersecting(TH2PolyBin *bin, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt);
172 Bool_t IsIntersectingPolygon(Int_t bn, Double_t *x, Double_t *y, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt);
173 // needed by TH1 - no need to have a separate implementation , but internal ibin=0 is first bin.
174 Double_t RetrieveBinContent(Int_t bin) const override {
175 return (bin>=kNOverflow) ? GetBinContent(bin-kNOverflow+1) : GetBinContent(-bin-1);
176 }
177 void UpdateBinContent(Int_t bin, Double_t content) override {
178 return (bin>=kNOverflow) ? SetBinContent(bin-kNOverflow+1,content) : SetBinContent(-bin-1,content);
179 }
180
181 ClassDefOverride(TH2Poly,3) //2-Dim histogram with polygon bins
182 };
183
184#endif
#define a(i)
Definition RSha256.hxx:99
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:80
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:110
Collection abstract base class.
Definition TCollection.h:65
1-Dim function class
Definition TF1.h:213
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:58
virtual Bool_t Multiply(TF1 *f1, Double_t c1=1)
Performs the operation:
Definition TH1.cxx:6013
Int_t fNcells
Number of bins(1D), cells (2D) +U/Overflows.
Definition TH1.h:88
virtual Bool_t Divide(TF1 *f1, Double_t c1=1)
Performs the operation: this = this/(c1*f1) if errors are defined (see TH1::Sumw2),...
Definition TH1.cxx:2815
Helper class to represent a bin in the TH2Poly histogram.
Definition TH2Poly.h:25
Double_t GetXMin()
Returns the minimum value for the x coordinates of the bin.
Definition TH2Poly.cxx:1438
Bool_t GetChanged() const
Definition TH2Poly.h:36
~TH2PolyBin() override
Destructor.
Definition TH2Poly.cxx:1364
Double_t GetYMax()
Returns the maximum value for the y coordinates of the bin.
Definition TH2Poly.cxx:1474
Double_t GetArea()
Returns the area of the bin.
Definition TH2Poly.cxx:1372
void ClearContent()
Definition TH2Poly.h:32
void Fill(Double_t w)
Definition TH2Poly.h:33
Double_t GetYMin()
Returns the minimum value for the y coordinates of the bin.
Definition TH2Poly.cxx:1510
Double_t fArea
Bin area.
Definition TH2Poly.h:51
Double_t fContent
Bin content.
Definition TH2Poly.h:52
Bool_t IsInside(Double_t x, Double_t y) const
Return "true" if the point (x,y) is inside the bin.
Definition TH2Poly.cxx:1546
Double_t fXmax
X maximum value.
Definition TH2Poly.h:55
void SetContent(Double_t content)
Definition TH2Poly.h:45
Int_t fNumber
Bin number of the bin in TH2Poly.
Definition TH2Poly.h:49
TH2PolyBin()
Default constructor.
Definition TH2Poly.cxx:1332
Double_t fYmax
Y maximum value.
Definition TH2Poly.h:56
Double_t GetXMax()
Returns the maximum value for the x coordinates of the bin.
Definition TH2Poly.cxx:1402
Double_t GetContent() const
Definition TH2Poly.h:35
Double_t fYmin
Y minimum value.
Definition TH2Poly.h:54
void SetChanged(Bool_t flag)
Definition TH2Poly.h:44
Int_t GetBinNumber() const
Definition TH2Poly.h:37
Double_t fXmin
X minimum value.
Definition TH2Poly.h:53
TObject * GetPolygon() const
Definition TH2Poly.h:38
TObject * fPoly
Object holding the polygon definition.
Definition TH2Poly.h:50
Bool_t fChanged
For the 3D Painter.
Definition TH2Poly.h:48
2D Histogram with Polygonal Bins
Definition TH2Poly.h:66
Bool_t Multiply(TF1 *, Double_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.cxx:1594
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...
Definition TH2Poly.h:177
Double_t GetBinError(Int_t, Int_t) const override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:143
@ kNOverflow
Definition TH2Poly.h:154
TList * GetBins()
Returns the TList of all bins in the histogram.
Definition TH2Poly.h:98
void ClearBinContents()
Clears the contents of all bins in the histogram.
Definition TH2Poly.cxx:491
Double_t fOverflow[kNOverflow]
Overflow bins.
Definition TH2Poly.h:156
Bool_t fFloat
When set to kTRUE, allows the histogram to expand if a bin outside the limits is added.
Definition TH2Poly.h:164
Int_t Fill(const char *, Double_t, Double_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:132
Double_t ComputeIntegral(Bool_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.cxx:1601
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,...
Definition TH2Poly.cxx:1037
void Honeycomb(Double_t xstart, Double_t ystart, Double_t a, Int_t k, Int_t s)
Bins the histogram using a honeycomb structure.
Definition TH2Poly.cxx:938
Double_t GetBinContent(Int_t, Int_t) const override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:140
void SetFloat(Bool_t flag=true)
When set to kTRUE, allows the histogram to expand if a bin outside the limits is added.
Definition TH2Poly.cxx:1297
Bool_t GetBinContentChanged() const
Definition TH2Poly.h:100
Double_t Integral(Option_t *option="") const override
Returns the integral of bin contents.
Definition TH2Poly.cxx:725
virtual TH2PolyBin * CreateBin(TObject *poly)
Create appropriate histogram bin.
Definition TH2Poly.cxx:200
Double_t GetBinContent(Int_t bin) const override
Returns the content of the input bin For the overflow/underflow/sea bins:
Definition TH2Poly.cxx:765
Bool_t * fIsEmpty
[fNCells] The array that returns true if the cell at the given coordinate is empty
Definition TH2Poly.h:162
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...
Definition TH2Poly.h:174
TList * fBins
List of bins. The list owns the contained objects.
Definition TH2Poly.h:167
void AddBinToPartition(TH2PolyBin *bin)
Adds the input bin into the partition cell matrix.
Definition TH2Poly.cxx:368
Bool_t fBinContentChanged
!For the 3D Painter
Definition TH2Poly.h:166
Int_t Fill(Double_t x, Double_t y) override
Increment the bin containing (x,y) by 1.
Definition TH2Poly.cxx:589
Int_t GetNumberOfBins() const
Definition TH2Poly.h:110
void SetBinContentChanged(Bool_t flag)
Definition TH2Poly.h:119
void GetStats(Double_t *stats) const override
Fill the array stats from the contents of this histogram The array stats must be correctly dimensione...
Definition TH2Poly.cxx:1313
Bool_t * fCompletelyInside
[fNCells] The array that returns true if the cell at the given coordinate is completely inside a bin
Definition TH2Poly.h:163
Bool_t GetFloat()
Definition TH2Poly.h:104
TH2Poly()
Default Constructor. No boundaries specified.
Definition TH2Poly.cxx:147
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.
Definition TH2Poly.cxx:1305
Bool_t fNewBinAdded
!For the 3D Painter
Definition TH2Poly.h:165
void SetBinError(Int_t bin, Double_t error) override
Set the bin Error.
Definition TH2Poly.cxx:807
const char * GetBinTitle(Int_t bin) const
Returns the bin title.
Definition TH2Poly.cxx:832
void SetBinContent(Int_t, Int_t, Int_t, Double_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:147
void SetBinError(Int_t, Int_t, Double_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:148
void SetNewBinAdded(Bool_t flag)
Definition TH2Poly.h:121
void Scale(Double_t c1=1, Option_t *option="") override
Multiply this histogram by a constant c1.
Definition TH2Poly.cxx:1266
void ChangePartition(Int_t n, Int_t m)
Changes the number of partition cells in the histogram.
Definition TH2Poly.cxx:440
Double_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, const Option_t *) const override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:138
void FillN(Int_t, const Double_t *, const Double_t *, Int_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:134
void SetBinError(Int_t, Int_t, Int_t, Double_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:149
Double_t GetMinimum() const
Returns the minimum value of the histogram.
Definition TH2Poly.cxx:890
const char * GetBinName(Int_t bin) const
Returns the bin name.
Definition TH2Poly.cxx:822
Double_t Integral(Int_t, Int_t, Int_t, Int_t, const Option_t *) const override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:137
Double_t fStepX
Definition TH2Poly.h:161
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.
Definition TH2Poly.cxx:711
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
Definition TH2Poly.cxx:479
Int_t fNCells
Number of partition cells: fCellX*fCellY.
Definition TH2Poly.h:159
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.
Definition TH2Poly.cxx:546
Bool_t Divide(TF1 *, Double_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.cxx:1586
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.
Definition TH2Poly.cxx:986
Int_t fCellX
Number of partition cells in the x-direction of the histogram.
Definition TH2Poly.h:157
~TH2Poly() override
Destructor.
Definition TH2Poly.cxx:184
virtual Int_t AddBin(TObject *poly)
Adds a new bin to the histogram.
Definition TH2Poly.cxx:222
Double_t GetBinError(Int_t bin) const override
Returns the value of error associated to bin number bin.
Definition TH2Poly.cxx:780
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,...
Definition TH2Poly.cxx:1078
Bool_t Add(const TH1 *h1, Double_t c1) override
Performs the operation: this = this + c1*h1.
Definition TH2Poly.cxx:290
Double_t Integral(Int_t, Int_t, const Option_t *) const override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:136
virtual TH1 * GetAsymmetry(TH1 *, Double_t, Double_t)
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.cxx:1615
Double_t GetBinError(Int_t, Int_t, Int_t) const override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:144
Long64_t Merge(TCollection *) override
Merge TH2Polys Given the special nature of the TH2Poly, the merge is implemented in terms of subseque...
Definition TH2Poly.cxx:1192
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...
Definition TH2Poly.cxx:1280
Double_t GetMaximum() const
Returns the maximum value of the histogram.
Definition TH2Poly.cxx:842
void Reset(Option_t *option) override
Reset this histogram: contents, errors, etc.
Definition TH2Poly.cxx:516
Bool_t GetNewBinAdded() const
Definition TH2Poly.h:109
Int_t Fill(const char *, const char *, Double_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:133
Double_t GetBinContent(Int_t, Int_t, Int_t) const override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:141
Double_t fStepY
Dimensions of a partition cell.
Definition TH2Poly.h:161
void SetBinContent(Int_t, Int_t, Double_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:146
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TH2Poly.cxx:1206
TH1 * FFT(TH1 *, Option_t *) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.cxx:1608
Int_t Fill(Double_t, const char *, Double_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:131
Int_t Fill(Double_t) override
NOT IMPLEMENTED for TH2Poly.
Definition TH2Poly.h:130
TList * fCells
[fNCells] The array of TLists that store the bins that intersect with each cell. List do not own the ...
Definition TH2Poly.h:160
Int_t fCellY
Number of partition cells in the y-direction of the histogram.
Definition TH2Poly.h:158
Service class for 2-D histogram classes.
Definition TH2.h:30
Double_t Interpolate(Double_t x) const override
illegal for a TH2
Definition TH2.cxx:1306
A doubly linked list.
Definition TList.h:38
A TMultiGraph is a collection of TGraph (or derived) objects.
Definition TMultiGraph.h:34
Mother of all ROOT objects.
Definition TObject.h:41
The most important graphics class in the ROOT system.
Definition TPad.h:28
#define Interpolate(a, x, b, y)
Definition geom.c:179
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
TH1F * h1
Definition legend1.C:5
return c2
Definition legend2.C:14
TMarker m
Definition textangle.C:8