TH2Poly.h

Go to the documentation of this file.
00001 // @(#)root/hist:$Id: TH2Poly.h 37434 2010-12-09 12:56:54Z couet $
00002 // Author: Olivier Couet, Deniz Gunceler
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TH2Poly
00013 #define ROOT_TH2Poly
00014 
00015 //////////////////////////////////////////////////////////////////////////
00016 //                                                                      //
00017 // TH2Poly                                                              //
00018 //                                                                      //
00019 // 2-Dim histogram with polygon bins                                    //
00020 //                                                                      //
00021 //////////////////////////////////////////////////////////////////////////
00022 
00023 #ifndef ROOT_TH2
00024 #include "TH2.h"
00025 #endif
00026 
00027 #include "TList.h"
00028 
00029 class TH2PolyBin: public TObject{
00030 
00031 public:
00032    TH2PolyBin();
00033    TH2PolyBin(TObject *poly, Int_t bin_number);
00034    virtual ~TH2PolyBin();
00035 
00036    void      ClearContent(){fContent = 0;}
00037    void      Fill(Double_t w) {fContent = fContent+w; SetChanged(true);}
00038    Double_t  GetArea();
00039    Double_t  GetContent() const{return fContent;}
00040    Bool_t    GetChanged() const{return fChanged;}
00041    Int_t     GetBinNumber() const {return fNumber;}
00042    TObject  *GetPolygon() const {return fPoly;}
00043    Double_t  GetXMax();
00044    Double_t  GetXMin();
00045    Double_t  GetYMax();
00046    Double_t  GetYMin();
00047    Bool_t    IsInside(Double_t x, Double_t y) const;
00048    void      SetChanged(Bool_t flag){fChanged = flag;}
00049    void      SetContent(Double_t content){fContent = content; SetChanged(true);}
00050 
00051 protected:
00052    Bool_t    fChanged;   //For the 3D Painter
00053    Int_t     fNumber;    //Bin number of the bin in TH2Poly
00054    TObject  *fPoly;      //Object holding the polygon definition
00055    Double_t  fArea;      //Bin area
00056    Double_t  fContent;   //Bin content
00057    Double_t  fXmin;      //X minimum value
00058    Double_t  fYmin;      //Y minimum value
00059    Double_t  fXmax;      //X maximum value
00060    Double_t  fYmax;      //Y maximum value
00061 
00062    ClassDef(TH2PolyBin,1)  //2-Dim polygon bins
00063 };
00064 
00065 class TList;
00066 class TGraph;
00067 class TMultiGraph;
00068 class TPad;
00069 
00070 class TH2Poly : public TH2 {
00071 
00072 public:
00073    TH2Poly();
00074    TH2Poly(const char *name,const char *title, Double_t xlow, Double_t xup, Double_t ylow, Double_t yup);
00075    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);
00076    virtual ~TH2Poly();
00077 
00078    Int_t        AddBin(TObject *poly);
00079    Int_t        AddBin(Int_t n, const Double_t *x, const Double_t *y);
00080    Int_t        AddBin(Double_t x1, Double_t y1, Double_t x2, Double_t  y2);
00081    void         ClearBinContents();                 // Clears the content of all bins
00082    void         ChangePartition(Int_t n, Int_t m);  // Sets the number of partition cells to another value
00083    virtual TH1 *DrawCopy(Option_t *option="") const;
00084    Int_t        Fill(Double_t x,Double_t y);
00085    Int_t        Fill(Double_t x,Double_t y, Double_t w);
00086    Int_t        Fill(const char* name, Double_t w);
00087    void         FillN(Int_t ntimes, const Double_t* x, const Double_t* y, const Double_t* w, Int_t stride = 1);
00088    Int_t        Fill(Double_t){return -1;}                              //MayNotUse
00089    Int_t        Fill(Double_t , const char *, Double_t){return -1;}     //MayNotUse
00090    Int_t        Fill(const char *, Double_t , Double_t ){return -1;}    //MayNotUse
00091    Int_t        Fill(const char *, const char *, Double_t ){return -1;} //MayNotUse
00092    void         FillN(Int_t, const Double_t*, const Double_t*, Int_t){return;}  //MayNotUse
00093    Int_t        FindBin(Double_t x, Double_t y, Double_t z = 0);
00094    TList       *GetBins(){return fBins;}                                // Returns the TList of all bins in the histogram
00095    Double_t     GetBinContent(Int_t bin) const;
00096    Double_t     GetBinContent(Int_t, Int_t) const {return 0;}           //MayNotUse
00097    Double_t     GetBinContent(Int_t, Int_t, Int_t) const {return 0;}    //MayNotUse
00098    Bool_t       GetBinContentChanged() const{return fBinContentChanged;}
00099    Double_t     GetBinError(Int_t bin) const;
00100    Double_t     GetBinError(Int_t , Int_t) const {return 0;}            //MayNotUse
00101    Double_t     GetBinError(Int_t , Int_t , Int_t) const {return 0;}    //MayNotUse
00102    const char  *GetBinName(Int_t bin) const;
00103    const char  *GetBinTitle(Int_t bin) const;
00104    Bool_t       GetFloat(){return fFloat;}
00105    Double_t     GetMaximum() const;
00106    Double_t     GetMaximum(Double_t maxval) const;
00107    Double_t     GetMinimum() const;
00108    Double_t     GetMinimum(Double_t minval) const;
00109    Bool_t       GetNewBinAdded() const{return fNewBinAdded;}
00110    Int_t        GetNumberOfBins() const{return fNcells;}
00111    void         Honeycomb(Double_t xstart, Double_t ystart, Double_t a, Int_t k, Int_t s);   // Bins the histogram using a honeycomb structure
00112    Double_t     Integral(Option_t* option = "") const;
00113    Double_t     Integral(Int_t, Int_t, const Option_t*) const{return 0;}                             //MayNotUse
00114    Double_t     Integral(Int_t, Int_t, Int_t, Int_t, const Option_t*) const{return 0;}               //MayNotUse
00115    Double_t     Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, const Option_t*) const{return 0;} //MayNotUse
00116    void         SavePrimitive(ostream& out, Option_t* option = "");
00117    void         SetBinContent(Int_t bin, Double_t content);
00118    void         SetBinContent(Int_t, Int_t, Double_t){return;}           //MayNotUse
00119    void         SetBinContent(Int_t, Int_t, Int_t, Double_t){return;}    //MayNotUse
00120    void         SetBinContentChanged(Bool_t flag){fBinContentChanged = flag;}
00121    void         SetFloat(Bool_t flag = true);
00122    void         SetNewBinAdded(Bool_t flag){fNewBinAdded = flag;}
00123 
00124 protected:
00125    TList   *fBins;              //List of bins.
00126    Double_t fOverflow[9];       //Overflow bins
00127    Int_t    fCellX;             //Number of partition cells in the x-direction of the histogram
00128    Int_t    fCellY;             //Number of partition cells in the y-direction of the histogram
00129    Int_t    fNCells;            //Number of partition cells: fCellX*fCellY
00130    TList   *fCells;             //[fNCells] The array of TLists that store the bins that intersect with each cell
00131    Double_t fStepX, fStepY;     //Dimensions of a partition cell
00132    Bool_t  *fIsEmpty;           //[fNCells] The array that returns true if the cell at the given coordinate is empty
00133    Bool_t  *fCompletelyInside;  //[fNCells] The array that returns true if the cell at the given coordinate is completely inside a bin
00134    Bool_t   fFloat;             //When set to kTRUE, allows the histogram to expand if a bin outside the limits is added.
00135    Bool_t   fNewBinAdded;       //!For the 3D Painter
00136    Bool_t   fBinContentChanged; //!For the 3D Painter
00137 
00138    void   AddBinToPartition(TH2PolyBin *bin);  // Adds the input bin into the partition matrix
00139    void   Initialize(Double_t xlow, Double_t xup, Double_t ylow, Double_t yup, Int_t n, Int_t m);
00140    Bool_t IsIntersecting(TH2PolyBin *bin, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt);
00141    Bool_t IsIntersectingPolygon(Int_t bn, Double_t *x, Double_t *y, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt);
00142 
00143    ClassDef(TH2Poly,1)  //2-Dim histogram with polygon bins
00144 };
00145 
00146 #endif

Generated on Tue Jul 5 14:22:52 2011 for ROOT_528-00b_version by  doxygen 1.5.1