Logo ROOT   6.08/07
Reference Guide
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 #ifndef ROOT_TH2
24 #include "TH2.h"
25 #endif
26 
27 class TH2PolyBin: public TObject{
28 
29 public:
30  TH2PolyBin();
31  TH2PolyBin(TObject *poly, Int_t bin_number);
32  virtual ~TH2PolyBin();
33 
34  void ClearContent(){fContent = 0;}
35  void Fill(Double_t w) {fContent = fContent+w; SetChanged(true);}
36  Double_t GetArea();
37  Double_t GetContent() const{return fContent;}
38  Bool_t GetChanged() const{return fChanged;}
39  Int_t GetBinNumber() const {return fNumber;}
40  TObject *GetPolygon() const {return fPoly;}
41  Double_t GetXMax();
42  Double_t GetXMin();
43  Double_t GetYMax();
44  Double_t GetYMin();
46  void SetChanged(Bool_t flag){fChanged = flag;}
47  void SetContent(Double_t content){fContent = content; SetChanged(true);}
48 
49 protected:
50  Bool_t fChanged; //For the 3D Painter
51  Int_t fNumber; //Bin number of the bin in TH2Poly
52  TObject *fPoly; //Object holding the polygon definition
53  Double_t fArea; //Bin area
54  Double_t fContent; //Bin content
55  Double_t fXmin; //X minimum value
56  Double_t fYmin; //Y minimum value
57  Double_t fXmax; //X maximum value
58  Double_t fYmax; //Y maximum value
59 
60  ClassDef(TH2PolyBin,1) //2-Dim polygon bins
61 };
62 
63 class TList;
64 class TGraph;
65 class TMultiGraph;
66 class TPad;
67 
68 class TH2Poly : public TH2 {
69 
70 public:
71  TH2Poly();
72  TH2Poly(const char *name,const char *title, Double_t xlow, Double_t xup, Double_t ylow, Double_t yup);
73  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);
74  virtual ~TH2Poly();
75 
76  Int_t AddBin(TObject *poly);
77  Int_t AddBin(Int_t n, const Double_t *x, const Double_t *y);
78  Int_t AddBin(Double_t x1, Double_t y1, Double_t x2, Double_t y2);
79  virtual Bool_t Add(const TH1 *h1, Double_t c1);
80  virtual Bool_t Add(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1);
81  virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="");
82  void ClearBinContents(); // Clears the content of all bins
83  TObject *Clone(const char* newname = "") const;
84  void ChangePartition(Int_t n, Int_t m); // Sets the number of partition cells to another value
87  Int_t Fill(const char* name, Double_t w);
88  void FillN(Int_t ntimes, const Double_t* x, const Double_t* y, const Double_t* w, Int_t stride = 1);
89  Int_t Fill(Double_t){return -1;} //MayNotUse
90  Int_t Fill(Double_t , const char *, Double_t){return -1;} //MayNotUse
91  Int_t Fill(const char *, Double_t , Double_t ){return -1;} //MayNotUse
92  Int_t Fill(const char *, const char *, Double_t ){return -1;} //MayNotUse
93  void FillN(Int_t, const Double_t*, const Double_t*, Int_t){return;} //MayNotUse
94  Int_t FindBin(Double_t x, Double_t y, Double_t z = 0);
95  TList *GetBins(){return fBins;} // Returns the TList of all bins in the histogram
96  Double_t GetBinContent(Int_t bin) const;
97  Double_t GetBinContent(Int_t, Int_t) const {return 0;} //MayNotUse
98  Double_t GetBinContent(Int_t, Int_t, Int_t) const {return 0;} //MayNotUse
99  Bool_t GetBinContentChanged() const{return fBinContentChanged;}
100  Double_t GetBinError(Int_t bin) const;
101  Double_t GetBinError(Int_t , Int_t) const {return 0;} //MayNotUse
102  Double_t GetBinError(Int_t , Int_t , Int_t) const {return 0;} //MayNotUse
103  const char *GetBinName(Int_t bin) const;
104  const char *GetBinTitle(Int_t bin) const;
105  Bool_t GetFloat(){return fFloat;}
106  Double_t GetMaximum() const;
107  Double_t GetMaximum(Double_t maxval) const;
108  Double_t GetMinimum() const;
109  Double_t GetMinimum(Double_t minval) const;
110  Bool_t GetNewBinAdded() const{return fNewBinAdded;}
111  Int_t GetNumberOfBins() const{return fNcells;}
112  void Honeycomb(Double_t xstart, Double_t ystart, Double_t a, Int_t k, Int_t s); // Bins the histogram using a honeycomb structure
113  Double_t Integral(Option_t* option = "") const;
114  Double_t Integral(Int_t, Int_t, const Option_t*) const{return 0;} //MayNotUse
115  Double_t Integral(Int_t, Int_t, Int_t, Int_t, const Option_t*) const{return 0;} //MayNotUse
116  Double_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, const Option_t*) const{return 0;} //MayNotUse
117  Long64_t Merge(TCollection *);
118  void Reset(Option_t *option);
119  void SavePrimitive(std::ostream& out, Option_t* option = "");
120  virtual void Scale(Double_t c1 = 1, Option_t* option = "");
121  void SetBinContent(Int_t bin, Double_t content);
122  void SetBinContent(Int_t, Int_t, Double_t){return;} //MayNotUse
123  void SetBinContent(Int_t, Int_t, Int_t, Double_t){return;} //MayNotUse
124  void SetBinContentChanged(Bool_t flag){fBinContentChanged = flag;}
125  void SetFloat(Bool_t flag = true);
126  void SetNewBinAdded(Bool_t flag){fNewBinAdded = flag;}
127 
128 protected:
129  TList *fBins; //List of bins. The list owns the contained objects
130  Double_t fOverflow[9]; //Overflow bins
131  Int_t fCellX; //Number of partition cells in the x-direction of the histogram
132  Int_t fCellY; //Number of partition cells in the y-direction of the histogram
133  Int_t fNCells; //Number of partition cells: fCellX*fCellY
134  TList *fCells; //[fNCells] The array of TLists that store the bins that intersect with each cell. List do not own the contained objects
135  Double_t fStepX, fStepY; //Dimensions of a partition cell
136  Bool_t *fIsEmpty; //[fNCells] The array that returns true if the cell at the given coordinate is empty
137  Bool_t *fCompletelyInside; //[fNCells] The array that returns true if the cell at the given coordinate is completely inside a bin
138  Bool_t fFloat; //When set to kTRUE, allows the histogram to expand if a bin outside the limits is added.
139  Bool_t fNewBinAdded; //!For the 3D Painter
140  Bool_t fBinContentChanged; //!For the 3D Painter
141 
142  void AddBinToPartition(TH2PolyBin *bin); // Adds the input bin into the partition matrix
143  void Initialize(Double_t xlow, Double_t xup, Double_t ylow, Double_t yup, Int_t n, Int_t m);
144  Bool_t IsIntersecting(TH2PolyBin *bin, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt);
145  Bool_t IsIntersectingPolygon(Int_t bn, Double_t *x, Double_t *y, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt);
146  // needed by TH1 - no need to have a separate implementation
147  virtual Double_t RetrieveBinContent(Int_t bin) const { return GetBinContent(bin); }
148  virtual void UpdateBinContent(Int_t bin, Double_t content) { return SetBinContent(bin,content); }
149 
150  ClassDef(TH2Poly,1) //2-Dim histogram with polygon bins
151 };
152 
153 #endif
Bool_t fBinContentChanged
For the 3D Painter.
Definition: TH2Poly.h:140
long long Long64_t
Definition: RtypesCore.h:69
Bool_t * fCompletelyInside
Definition: TH2Poly.h:137
const char Option_t
Definition: RtypesCore.h:62
return c1
Definition: legend1.C:41
Int_t GetBinNumber() const
Definition: TH2Poly.h:39
void SetChanged(Bool_t flag)
Definition: TH2Poly.h:46
A TMultiGraph is a collection of TGraph (or derived) objects.
Definition: TMultiGraph.h:37
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TArc * a
Definition: textangle.C:12
Double_t fXmax
Definition: TH2Poly.h:57
Bool_t IsInside(Double_t x, Double_t y) const
Return "true" if the point (x,y) is inside the bin.
Definition: TH2Poly.cxx:1458
void SetBinContentChanged(Bool_t flag)
Definition: TH2Poly.h:124
Helper class to represent a bin in the TH2Poly histogram.
Definition: TH2Poly.h:27
Bool_t * fIsEmpty
Definition: TH2Poly.h:136
Int_t fCellX
Definition: TH2Poly.h:131
static const double x2[5]
TList * fCells
Definition: TH2Poly.h:134
Double_t x[n]
Definition: legend1.C:17
Double_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, const Option_t *) const
Definition: TH2Poly.h:116
#define ClassDef(name, id)
Definition: Rtypes.h:254
Bool_t GetChanged() const
Definition: TH2Poly.h:38
Int_t Fill(Double_t, const char *, Double_t)
Increment cell defined by x,namey by a weight w.
Definition: TH2Poly.h:90
Double_t Integral(Int_t, Int_t, const Option_t *) const
Definition: TH2Poly.h:114
void Add(THist< DIMENSIONS, PRECISION_TO, STAT_TO... > &to, THist< DIMENSIONS, PRECISION_FROM, STAT_FROM... > &from)
Add two histograms.
Definition: THist.hxx:327
Double_t GetXMax()
Returns the maximum value for the x coordinates of the bin.
Definition: TH2Poly.cxx:1314
Double_t GetBinError(Int_t, Int_t) const
Definition: TH2Poly.h:101
Double_t GetYMin()
Returns the minimum value for the y coordinates of the bin.
Definition: TH2Poly.cxx:1422
void SetBinContent(Int_t, Int_t, Int_t, Double_t)
Definition: TH2Poly.h:123
Double_t GetYMax()
Returns the maximum value for the y coordinates of the bin.
Definition: TH2Poly.cxx:1386
TH1F * h1
Definition: legend1.C:5
void SetContent(Double_t content)
Definition: TH2Poly.h:47
TObject * fPoly
Definition: TH2Poly.h:52
void SetBinContent(Int_t, Int_t, Double_t)
Definition: TH2Poly.h:122
Bool_t fFloat
Definition: TH2Poly.h:138
A doubly linked list.
Definition: TList.h:47
Double_t GetBinError(Int_t, Int_t, Int_t) const
Definition: TH2Poly.h:102
TObject * GetPolygon() const
Definition: TH2Poly.h:40
Double_t GetBinContent(Int_t, Int_t) const
Definition: TH2Poly.h:97
Int_t fNumber
Definition: TH2Poly.h:51
TList * GetBins()
Definition: TH2Poly.h:95
Int_t fCellY
Definition: TH2Poly.h:132
Service class for 2-Dim histogram classes.
Definition: TH2.h:36
void Initialize(Bool_t useTMVAStyle=kTRUE)
Definition: tmvaglob.cxx:176
virtual ~TH2PolyBin()
Destructor.
Definition: TH2Poly.cxx:1276
Double_t GetContent() const
Definition: TH2Poly.h:37
Collection abstract base class.
Definition: TCollection.h:48
Double_t Integral(Int_t, Int_t, Int_t, Int_t, const Option_t *) const
Definition: TH2Poly.h:115
The most important graphics class in the ROOT system.
Definition: TPad.h:37
TMarker * m
Definition: textangle.C:8
Int_t GetNumberOfBins() const
Definition: TH2Poly.h:111
Double_t fArea
Definition: TH2Poly.h:53
Bool_t GetFloat()
Definition: TH2Poly.h:105
Int_t fNCells
Definition: TH2Poly.h:133
void Reset(Detail::TBranchProxy *x)
TList * fBins
Definition: TH2Poly.h:129
virtual void UpdateBinContent(Int_t bin, Double_t content)
Raw update of bin content on internal data structure see convention for numbering bins in TH1::GetBin...
Definition: TH2Poly.h:148
Int_t Fill(const char *, Double_t, Double_t)
Increment cell defined by namex,y by a weight w.
Definition: TH2Poly.h:91
return c2
Definition: legend2.C:14
static const double x1[5]
Bool_t GetNewBinAdded() const
Definition: TH2Poly.h:110
Double_t GetBinContent(Int_t, Int_t, Int_t) const
Definition: TH2Poly.h:98
double Double_t
Definition: RtypesCore.h:55
Double_t fXmin
Definition: TH2Poly.h:55
Double_t y[n]
Definition: legend1.C:17
Bool_t fNewBinAdded
Definition: TH2Poly.h:139
Double_t fYmin
Definition: TH2Poly.h:56
The TH1 histogram class.
Definition: TH1.h:80
void ClearContent()
Definition: TH2Poly.h:34
Mother of all ROOT objects.
Definition: TObject.h:37
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition: TObject.cxx:204
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
void FillN(Int_t, const Double_t *, const Double_t *, Int_t)
Fill this histogram with an array x and weights w.
Definition: TH2Poly.h:93
Bool_t GetBinContentChanged() const
Definition: TH2Poly.h:99
1-Dim function class
Definition: TF1.h:149
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition: TGraph.h:53
Double_t GetArea()
Returns the area of the bin.
Definition: TH2Poly.cxx:1284
Double_t fStepY
Definition: TH2Poly.h:135
void Fill(Double_t w)
Definition: TH2Poly.h:35
Int_t Fill(const char *, const char *, Double_t)
Increment cell defined by namex,namey by a weight w.
Definition: TH2Poly.h:92
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH2Poly.h:89
Double_t GetXMin()
Returns the minimum value for the x coordinates of the bin.
Definition: TH2Poly.cxx:1350
Double_t fContent
Definition: TH2Poly.h:54
Double_t fYmax
Definition: TH2Poly.h:58
Bool_t fChanged
Definition: TH2Poly.h:50
const Int_t n
Definition: legend1.C:16
char name[80]
Definition: TGX11.cxx:109
2D Histogram with Polygonal Bins
Definition: TH2Poly.h:68
void SetNewBinAdded(Bool_t flag)
Definition: TH2Poly.h:126
TH2PolyBin()
Default constructor.
Definition: TH2Poly.cxx:1244
virtual Double_t RetrieveBinContent(Int_t bin) const
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
Definition: TH2Poly.h:147
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TObject.cxx:709