Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TH2Poly.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/hist:$Id$
0002 // Author: Olivier Couet, Deniz Gunceler
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TH2Poly
0013 #define ROOT_TH2Poly
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TH2Poly                                                              //
0018 //                                                                      //
0019 // 2-Dim histogram with polygon bins                                    //
0020 //                                                                      //
0021 //////////////////////////////////////////////////////////////////////////
0022 
0023 #include "TH2.h"
0024 
0025 class TH2PolyBin: public TObject{
0026 
0027 public:
0028    TH2PolyBin();
0029    TH2PolyBin(TObject *poly, Int_t bin_number);
0030    ~TH2PolyBin() override;
0031 
0032    void      ClearContent(){fContent = 0;}
0033    void      Fill(Double_t w) {fContent = fContent+w; SetChanged(true);}
0034    Double_t  GetArea();
0035    Double_t  GetContent() const{return fContent;}
0036    Bool_t    GetChanged() const{return fChanged;}
0037    Int_t     GetBinNumber() const {return fNumber;}
0038    TObject  *GetPolygon() const {return fPoly;}
0039    Double_t  GetXMax();
0040    Double_t  GetXMin();
0041    Double_t  GetYMax();
0042    Double_t  GetYMin();
0043    Bool_t    IsInside(Double_t x, Double_t y) const;
0044    void      SetChanged(Bool_t flag){fChanged = flag;}
0045    void      SetContent(Double_t content){fContent = content; SetChanged(true);}
0046 
0047 protected:
0048    Bool_t    fChanged;   ///< For the 3D Painter
0049    Int_t     fNumber;    ///< Bin number of the bin in TH2Poly
0050    TObject  *fPoly;      ///< Object holding the polygon definition
0051    Double_t  fArea;      ///< Bin area
0052    Double_t  fContent;   ///< Bin content
0053    Double_t  fXmin;      ///< X minimum value
0054    Double_t  fYmin;      ///< Y minimum value
0055    Double_t  fXmax;      ///< X maximum value
0056    Double_t  fYmax;      ///< Y maximum value
0057 
0058    ClassDefOverride(TH2PolyBin,1)  //2-Dim polygon bins
0059 };
0060 
0061 class TList;
0062 class TGraph;
0063 class TMultiGraph;
0064 class TPad;
0065 
0066 class TH2Poly : public TH2 {
0067 
0068 public:
0069    TH2Poly();
0070    TH2Poly(const char *name,const char *title, Double_t xlow, Double_t xup, Double_t ylow, Double_t yup);
0071    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);
0072    ~TH2Poly() override;
0073    TH2Poly(const TH2Poly & rhs);
0074    TH2Poly & operator=(const TH2Poly & rhs);
0075 
0076    virtual TH2PolyBin *CreateBin(TObject *poly);
0077    virtual Int_t AddBin(TObject *poly);
0078    Int_t         AddBin(Int_t n, const Double_t *x, const Double_t *y);
0079    Int_t         AddBin(Double_t x1, Double_t y1, Double_t x2, Double_t  y2);
0080    Bool_t Add(const TH1 *h1, Double_t c1) override;
0081    Bool_t Add(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1) override;
0082    Bool_t Add(TF1 *h1, Double_t c1=1, Option_t *option="") override;
0083    void          ClearBinContents();                 // Clears the content of all bins
0084    TObject      *Clone(const char* newname = "") const override;
0085    void          Copy(TObject & newth2p) const override;
0086    void          ChangePartition(Int_t n, Int_t m);  // Sets the number of partition cells to another value
0087    using TH2::Multiply;
0088    using TH2::Divide;
0089    using TH2::Interpolate;
0090    Bool_t Divide(TF1 *, Double_t) override;
0091    Bool_t Multiply(TF1 *, Double_t) override;
0092    Double_t ComputeIntegral(Bool_t) override;
0093    TH1 *  FFT(TH1*, Option_t * ) override;
0094    virtual TH1 *  GetAsymmetry(TH1* , Double_t,  Double_t);
0095    virtual Double_t Interpolate(Double_t, Double_t);
0096    Int_t Fill(Double_t x,Double_t y) override;
0097    Int_t Fill(Double_t x,Double_t y, Double_t w) override;
0098    Int_t Fill(const char* name, Double_t w) override;
0099    void         FillN(Int_t ntimes, const Double_t* x, const Double_t* y, const Double_t* w, Int_t stride = 1) override;
0100    Int_t        FindBin(Double_t x, Double_t y, Double_t z = 0) override;
0101    TList       *GetBins(){return fBins;} ///< Returns the TList of all bins in the histogram
0102    Double_t     GetBinContent(Int_t bin) const override;
0103    Bool_t       GetBinContentChanged() const{return fBinContentChanged;}
0104    Double_t GetBinError(Int_t bin) const override;
0105    const char  *GetBinName(Int_t bin) const;
0106    const char  *GetBinTitle(Int_t bin) const;
0107    Bool_t       GetFloat(){return fFloat;}
0108    Double_t     GetMaximum() const;
0109    Double_t     GetMaximum(Double_t maxval) const override;
0110    Double_t     GetMinimum() const;
0111    Double_t     GetMinimum(Double_t minval) const override;
0112    Bool_t       GetNewBinAdded() const{return fNewBinAdded;}
0113    Int_t        GetNumberOfBins() const;
0114    void         Honeycomb(Double_t xstart, Double_t ystart, Double_t a, Int_t k, Int_t s, Option_t* option = "v");
0115    Double_t     Integral(Option_t* option = "") const override;
0116    Long64_t     Merge(TCollection *) override;
0117    void Reset(Option_t *option) override;
0118    void Scale(Double_t c1 = 1, Option_t* option = "") override;
0119    void         SavePrimitive(std::ostream& out, Option_t* option = "") override;
0120    void SetBinContent(Int_t bin, Double_t content) override;
0121    void SetBinError(Int_t bin, Double_t error) override;
0122    void         SetBinContentChanged(Bool_t flag){fBinContentChanged = flag;}
0123    void         SetFloat(Bool_t flag = true);
0124    void         SetNewBinAdded(Bool_t flag){fNewBinAdded = flag;}
0125    Bool_t       IsInsideBin(Int_t binnr, Double_t x, Double_t y);
0126    void GetStats(Double_t *stats) const override;
0127 
0128 
0129 protected:
0130 
0131    //functions not to be used for TH2Poly
0132 
0133    Int_t        Fill(Double_t) override{return -1;}                              ///< NOT IMPLEMENTED for TH2Poly
0134    Int_t        Fill(Double_t , const char *, Double_t) override{return -1;}     ///< NOT IMPLEMENTED for TH2Poly
0135    Int_t        Fill(const char *, Double_t , Double_t ) override{return -1;}    ///< NOT IMPLEMENTED for TH2Poly
0136    Int_t        Fill(const char *, const char *, Double_t ) override{return -1;} ///< NOT IMPLEMENTED for TH2Poly
0137    void         FillN(Int_t, const Double_t*, const Double_t*, Int_t) override{return;}  ///< NOT IMPLEMENTED for TH2Poly
0138 
0139    Double_t     Integral(Int_t, Int_t, const Option_t*) const override{return 0;}                             ///< NOT IMPLEMENTED for TH2Poly
0140    Double_t     Integral(Int_t, Int_t, Int_t, Int_t, const Option_t*) const override{return 0;}               ///< NOT IMPLEMENTED for TH2Poly
0141    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
0142 
0143    Double_t     GetBinContent(Int_t, Int_t) const override {return 0;}           ///< NOT IMPLEMENTED for TH2Poly
0144    Double_t     GetBinContent(Int_t, Int_t, Int_t) const override {return 0;}    ///< NOT IMPLEMENTED for TH2Poly
0145 
0146    Double_t GetBinError(Int_t , Int_t) const override {return 0;}            ///< NOT IMPLEMENTED for TH2Poly
0147    Double_t GetBinError(Int_t , Int_t , Int_t) const override {return 0;}    ///< NOT IMPLEMENTED for TH2Poly
0148 
0149    void         SetBinContent(Int_t, Int_t, Double_t) override{}           ///< NOT IMPLEMENTED for TH2Poly
0150    void         SetBinContent(Int_t, Int_t, Int_t, Double_t) override{}    ///< NOT IMPLEMENTED for TH2Poly
0151    void         SetBinError(Int_t, Int_t, Double_t) override {}            ///< NOT IMPLEMENTED for TH2Poly
0152    void         SetBinError(Int_t, Int_t, Int_t, Double_t) override {}     ///< NOT IMPLEMENTED for TH2Poly
0153 
0154 
0155 protected:
0156     enum {
0157       kNOverflow = 9  /// Number of overflows bins
0158    };
0159    Double_t fOverflow[kNOverflow]; ///< Overflow bins
0160    Int_t    fCellX;                ///< Number of partition cells in the x-direction of the histogram
0161    Int_t    fCellY;                ///< Number of partition cells in the y-direction of the histogram
0162    Int_t    fNCells;               ///< Number of partition cells: fCellX*fCellY
0163    TList   *fCells;                ///<[fNCells] The array of TLists that store the bins that intersect with each cell. List do not own the contained objects
0164    Double_t fStepX, fStepY;        ///< Dimensions of a partition cell
0165    Bool_t  *fIsEmpty;              ///<[fNCells] The array that returns true if the cell at the given coordinate is empty
0166    Bool_t  *fCompletelyInside;     ///<[fNCells] The array that returns true if the cell at the given coordinate is completely inside a bin
0167    Bool_t   fFloat;                ///< When set to kTRUE, allows the histogram to expand if a bin outside the limits is added.
0168    Bool_t   fNewBinAdded;          ///<!For the 3D Painter
0169    Bool_t   fBinContentChanged;    ///<!For the 3D Painter
0170    TList   *fBins;                 ///< List of bins. The list owns the contained objects
0171 
0172    void   AddBinToPartition(TH2PolyBin *bin);  // Adds the input bin into the partition matrix
0173    void   Initialize(Double_t xlow, Double_t xup, Double_t ylow, Double_t yup, Int_t n, Int_t m);
0174    Bool_t IsIntersecting(TH2PolyBin *bin, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt);
0175    Bool_t IsIntersectingPolygon(Int_t bn, Double_t *x, Double_t *y, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt);
0176    // needed by TH1 - no need to have a separate implementation , but internal ibin=0 is first bin.
0177    Double_t RetrieveBinContent(Int_t bin) const override {
0178       return (bin>=kNOverflow) ? GetBinContent(bin-kNOverflow+1) : GetBinContent(-bin-1);
0179    }
0180    void     UpdateBinContent(Int_t bin, Double_t content) override {
0181       return (bin>=kNOverflow) ? SetBinContent(bin-kNOverflow+1,content) : SetBinContent(-bin-1,content);
0182    }
0183 
0184    ClassDefOverride(TH2Poly,3)  //2-Dim histogram with polygon bins
0185  };
0186 
0187 #endif