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
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TH2Poly
0013 #define ROOT_TH2Poly
0014
0015
0016
0017
0018
0019
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;
0049 Int_t fNumber;
0050 TObject *fPoly;
0051 Double_t fArea;
0052 Double_t fContent;
0053 Double_t fXmin;
0054 Double_t fYmin;
0055 Double_t fXmax;
0056 Double_t fYmax;
0057
0058 ClassDefOverride(TH2PolyBin,1)
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();
0084 void Copy(TObject & newth2p) const override;
0085 void ChangePartition(Int_t n, Int_t m);
0086 using TH2::Multiply;
0087 using TH2::Divide;
0088 using TH2::Interpolate;
0089 Bool_t Divide(TF1 *, Double_t) override;
0090 Bool_t Multiply(TF1 *, Double_t) override;
0091 Double_t ComputeIntegral(Bool_t) override;
0092 TH1 * FFT(TH1*, Option_t * ) override;
0093 virtual TH1 * GetAsymmetry(TH1* , Double_t, Double_t);
0094 virtual Double_t Interpolate(Double_t, Double_t);
0095 Int_t Fill(Double_t x,Double_t y) override;
0096 Int_t Fill(Double_t x,Double_t y, Double_t w) override;
0097 Int_t Fill(const char* name, Double_t w) override;
0098 void FillN(Int_t ntimes, const Double_t* x, const Double_t* y, const Double_t* w, Int_t stride = 1) override;
0099 Int_t FindBin(Double_t x, Double_t y, Double_t z = 0) override;
0100 TList *GetBins(){return fBins;}
0101 Double_t GetBinContent(Int_t bin) const override;
0102 Bool_t GetBinContentChanged() const{return fBinContentChanged;}
0103 Double_t GetBinError(Int_t bin) const override;
0104 const char *GetBinName(Int_t bin) const;
0105 const char *GetBinTitle(Int_t bin) const;
0106 Bool_t GetFloat(){return fFloat;}
0107 Double_t GetMaximum() const;
0108 Double_t GetMaximum(Double_t maxval) const override;
0109 Double_t GetMinimum() const;
0110 Double_t GetMinimum(Double_t minval) const override;
0111 Bool_t GetNewBinAdded() const{return fNewBinAdded;}
0112 Int_t GetNumberOfBins() const;
0113 void Honeycomb(Double_t xstart, Double_t ystart, Double_t a, Int_t k, Int_t s, Option_t* option = "v");
0114 Double_t Integral(Option_t* option = "") const override;
0115 Long64_t Merge(TCollection *) override;
0116 void Reset(Option_t *option) override;
0117 void Scale(Double_t c1 = 1, Option_t* option = "") override;
0118 void SavePrimitive(std::ostream& out, Option_t* option = "") override;
0119 void SetBinContent(Int_t bin, Double_t content) override;
0120 void SetBinError(Int_t bin, Double_t error) override;
0121 void SetBinContentChanged(Bool_t flag){fBinContentChanged = flag;}
0122 void SetFloat(Bool_t flag = true);
0123 void SetNewBinAdded(Bool_t flag){fNewBinAdded = flag;}
0124 Bool_t IsInsideBin(Int_t binnr, Double_t x, Double_t y);
0125 void GetStats(Double_t *stats) const override;
0126
0127
0128 protected:
0129
0130
0131
0132 void AddBinContent(Int_t) override;
0133 void AddBinContent(Int_t, Double_t) override;
0134
0135 Int_t Fill(Double_t) override{return -1;}
0136 Int_t Fill(Double_t , const char *, Double_t) override{return -1;}
0137 Int_t Fill(const char *, Double_t , Double_t ) override{return -1;}
0138 Int_t Fill(const char *, const char *, Double_t ) override{return -1;}
0139 void FillN(Int_t, const Double_t*, const Double_t*, Int_t) override{return;}
0140
0141 Double_t Integral(Int_t, Int_t, const Option_t*) const override{return 0;}
0142 Double_t Integral(Int_t, Int_t, Int_t, Int_t, const Option_t*) const override{return 0;}
0143 Double_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, const Option_t*) const override{return 0;}
0144
0145 Double_t GetBinContent(Int_t, Int_t) const override {return 0;}
0146 Double_t GetBinContent(Int_t, Int_t, Int_t) const override {return 0;}
0147
0148 Double_t GetBinError(Int_t , Int_t) const override {return 0;}
0149 Double_t GetBinError(Int_t , Int_t , Int_t) const override {return 0;}
0150
0151 void SetBinContent(Int_t, Int_t, Double_t) override{}
0152 void SetBinContent(Int_t, Int_t, Int_t, Double_t) override{}
0153 void SetBinError(Int_t, Int_t, Double_t) override {}
0154 void SetBinError(Int_t, Int_t, Int_t, Double_t) override {}
0155
0156
0157 protected:
0158 enum {
0159 kNOverflow = 9
0160 };
0161 Double_t fOverflow[kNOverflow];
0162 Int_t fCellX;
0163 Int_t fCellY;
0164 Int_t fNCells;
0165 TList *fCells;
0166 Double_t fStepX, fStepY;
0167 Bool_t *fIsEmpty;
0168 Bool_t *fCompletelyInside;
0169 Bool_t fFloat;
0170 Bool_t fNewBinAdded;
0171 Bool_t fBinContentChanged;
0172 TList *fBins;
0173
0174 void AddBinToPartition(TH2PolyBin *bin);
0175 void Initialize(Double_t xlow, Double_t xup, Double_t ylow, Double_t yup, Int_t n, Int_t m);
0176 Bool_t IsIntersecting(TH2PolyBin *bin, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt);
0177 Bool_t IsIntersectingPolygon(Int_t bn, Double_t *x, Double_t *y, Double_t xclipl, Double_t xclipr, Double_t yclipb, Double_t yclipt);
0178
0179 Double_t RetrieveBinContent(Int_t bin) const override {
0180 return (bin>=kNOverflow) ? GetBinContent(bin-kNOverflow+1) : GetBinContent(-bin-1);
0181 }
0182 void UpdateBinContent(Int_t bin, Double_t content) override {
0183 return (bin>=kNOverflow) ? SetBinContent(bin-kNOverflow+1,content) : SetBinContent(-bin-1,content);
0184 }
0185
0186 ClassDefOverride(TH2Poly,3)
0187 };
0188
0189 #endif