#ifndef ROOT_TH2Poly
#define ROOT_TH2Poly
#ifndef ROOT_TH2
#include "TH2.h"
#endif
#include "TList.h"
class TH2PolyBin: public TObject{
public:
TH2PolyBin();
TH2PolyBin(TObject *poly, Int_t bin_number);
virtual ~TH2PolyBin();
void ClearContent(){fContent = 0;}
void Fill(Double_t w) {fContent = fContent+w; SetChanged(true);}
Double_t GetArea();
Double_t GetContent() const{return fContent;}
Bool_t GetChanged() const{return fChanged;}
Int_t GetBinNumber() const {return fNumber;}
TObject *GetPolygon() const {return fPoly;}
Double_t GetXMax();
Double_t GetXMin();
Double_t GetYMax();
Double_t GetYMin();
Bool_t IsInside(Double_t x, Double_t y) const;
void SetChanged(Bool_t flag){fChanged = flag;}
void SetContent(Double_t content){fContent = content; SetChanged(true);}
protected:
Bool_t fChanged;
Int_t fNumber;
TObject *fPoly;
Double_t fArea;
Double_t fContent;
Double_t fXmin;
Double_t fYmin;
Double_t fXmax;
Double_t fYmax;
ClassDef(TH2PolyBin,1)
};
class TList;
class TGraph;
class TMultiGraph;
class TPad;
class TH2Poly : public TH2 {
public:
TH2Poly();
TH2Poly(const char *name,const char *title, Double_t xlow, Double_t xup, Double_t ylow, Double_t yup);
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);
virtual ~TH2Poly();
Int_t AddBin(TObject *poly);
Int_t AddBin(Int_t n, const Double_t *x, const Double_t *y);
Int_t AddBin(Double_t x1, Double_t y1, Double_t x2, Double_t y2);
virtual Bool_t Add(const TH1 *h1, Double_t c1);
virtual Bool_t Add(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1);
virtual Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="");
void ClearBinContents();
void ChangePartition(Int_t n, Int_t m);
virtual TH1 *DrawCopy(Option_t *option="") const;
Int_t Fill(Double_t x,Double_t y);
Int_t Fill(Double_t x,Double_t y, Double_t w);
Int_t Fill(const char* name, Double_t w);
void FillN(Int_t ntimes, const Double_t* x, const Double_t* y, const Double_t* w, Int_t stride = 1);
Int_t Fill(Double_t){return -1;}
Int_t Fill(Double_t , const char *, Double_t){return -1;}
Int_t Fill(const char *, Double_t , Double_t ){return -1;}
Int_t Fill(const char *, const char *, Double_t ){return -1;}
void FillN(Int_t, const Double_t*, const Double_t*, Int_t){return;}
Int_t FindBin(Double_t x, Double_t y, Double_t z = 0);
TList *GetBins(){return fBins;}
Double_t GetBinContent(Int_t bin) const;
Double_t GetBinContent(Int_t, Int_t) const {return 0;}
Double_t GetBinContent(Int_t, Int_t, Int_t) const {return 0;}
Bool_t GetBinContentChanged() const{return fBinContentChanged;}
Double_t GetBinError(Int_t bin) const;
Double_t GetBinError(Int_t , Int_t) const {return 0;}
Double_t GetBinError(Int_t , Int_t , Int_t) const {return 0;}
const char *GetBinName(Int_t bin) const;
const char *GetBinTitle(Int_t bin) const;
Bool_t GetFloat(){return fFloat;}
Double_t GetMaximum() const;
Double_t GetMaximum(Double_t maxval) const;
Double_t GetMinimum() const;
Double_t GetMinimum(Double_t minval) const;
Bool_t GetNewBinAdded() const{return fNewBinAdded;}
Int_t GetNumberOfBins() const{return fNcells;}
void Honeycomb(Double_t xstart, Double_t ystart, Double_t a, Int_t k, Int_t s);
Double_t Integral(Option_t* option = "") const;
Double_t Integral(Int_t, Int_t, const Option_t*) const{return 0;}
Double_t Integral(Int_t, Int_t, Int_t, Int_t, const Option_t*) const{return 0;}
Double_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, const Option_t*) const{return 0;}
Long64_t Merge(TCollection *);
void Reset(Option_t *option);
void SavePrimitive(ostream& out, Option_t* option = "");
virtual void Scale(Double_t c1 = 1, Option_t* option = "");
void SetBinContent(Int_t bin, Double_t content);
void SetBinContent(Int_t, Int_t, Double_t){return;}
void SetBinContent(Int_t, Int_t, Int_t, Double_t){return;}
void SetBinContentChanged(Bool_t flag){fBinContentChanged = flag;}
void SetFloat(Bool_t flag = true);
void SetNewBinAdded(Bool_t flag){fNewBinAdded = flag;}
protected:
TList *fBins;
Double_t fOverflow[9];
Int_t fCellX;
Int_t fCellY;
Int_t fNCells;
TList *fCells;
Double_t fStepX, fStepY;
Bool_t *fIsEmpty;
Bool_t *fCompletelyInside;
Bool_t fFloat;
Bool_t fNewBinAdded;
Bool_t fBinContentChanged;
void AddBinToPartition(TH2PolyBin *bin);
void Initialize(Double_t xlow, Double_t xup, Double_t ylow, Double_t yup, Int_t n, Int_t m);
Bool_t IsIntersecting(TH2PolyBin *bin, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt);
Bool_t IsIntersectingPolygon(Int_t bn, Double_t *x, Double_t *y, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt);
ClassDef(TH2Poly,1)
};
#endif