Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:30:02

0001 // @(#)root/hist:$Id$
0002 // Author: Rene Brun   26/12/94
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_TH2
0013 #define ROOT_TH2
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TH2                                                                  //
0019 //                                                                      //
0020 // 2-Dim histogram base class.                                          //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TH1.h"
0025 #include "TMatrixFBasefwd.h"
0026 #include "TMatrixDBasefwd.h"
0027 
0028 class TProfile;
0029 
0030 class TH2 : public TH1 {
0031 
0032 protected:
0033    Double_t     fScalefactor;     ///< Scale factor
0034    Double_t     fTsumwy;          ///< Total Sum of weight*Y
0035    Double_t     fTsumwy2;         ///< Total Sum of weight*Y*Y
0036    Double_t     fTsumwxy;         ///< Total Sum of weight*X*Y
0037 
0038    TH2();
0039    TH2(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0040                                          ,Int_t nbinsy,Double_t ylow,Double_t yup);
0041    TH2(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0042                                          ,Int_t nbinsy,Double_t ylow,Double_t yup);
0043    TH2(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0044                                          ,Int_t nbinsy,const Double_t *ybins);
0045    TH2(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0046                                          ,Int_t nbinsy,const Double_t *ybins);
0047    TH2(const char *name,const char *title,Int_t nbinsx,const Float_t  *xbins
0048                                          ,Int_t nbinsy,const Float_t  *ybins);
0049 
0050    virtual Int_t     BufferFill(Double_t x, Double_t y, Double_t w);
0051    virtual TH1D     *DoProjection(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const;
0052    virtual TProfile *DoProfile(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const;
0053    virtual TH1D     *DoQuantiles(bool onX, const char *name, Double_t prob) const;
0054    virtual void      DoFitSlices(bool onX, TF1 *f1, Int_t firstbin, Int_t lastbin, Int_t cut, Option_t *option, TObjArray* arr);
0055 
0056    Int_t    BufferFill(Double_t, Double_t) override {return -2;} //may not use
0057    Int_t    Fill(Double_t) override; //MayNotUse
0058    Int_t    Fill(const char*, Double_t) override { return Fill(0);}  //MayNotUse
0059 
0060    Double_t Interpolate(Double_t x) const override; // may not use
0061 
0062 private:
0063 
0064    TH2(const TH2&) = delete;
0065    TH2& operator=(const TH2&) = delete;
0066 
0067    // make private methods which have a TH1 signature and should not
0068    using TH1::Integral;
0069    using TH1::IntegralAndError;
0070 
0071 public:
0072    ~TH2() override;
0073    using TH1::AddBinContent;
0074            /// Increment 2D bin content by 1.
0075            /// Passing an out-of-range bin leads to undefined behavior
0076            void     AddBinContent(Int_t binx, Int_t biny) { AddBinContent(GetBin(binx, biny)); }
0077            /// Increment 2D bin content by a weight w.
0078            /// Passing an out-of-range bin leads to undefined behavior
0079            void     AddBinContent(Int_t binx, Int_t biny, Double_t w) { AddBinContent(GetBin(binx, biny), w); }
0080            Int_t    BufferEmpty(Int_t action=0) override;
0081            void     Copy(TObject &hnew) const override;
0082            Int_t    Fill(Double_t x, Double_t y) override;
0083    virtual Int_t    Fill(Double_t x, Double_t y, Double_t w);
0084    virtual Int_t    Fill(Double_t x, const char *namey, Double_t w);
0085    virtual Int_t    Fill(const char *namex, Double_t y, Double_t w);
0086    virtual Int_t    Fill(const char *namex, const char *namey, Double_t w);
0087            void     FillN(Int_t, const Double_t *, const Double_t *, Int_t) override {} //MayNotUse
0088            void     FillN(Int_t ntimes, const Double_t *x, const Double_t *y, const Double_t *w, Int_t stride=1) override;
0089    using TH1::FillRandom;
0090            void     FillRandom(TF1 *f1, Int_t ntimes=5000, TRandom *rng = nullptr) override;
0091            void     FillRandom(TH1 *h, Int_t ntimes=5000, TRandom *rng = nullptr) override;
0092    virtual void     FitSlicesX(TF1 *f1 = nullptr, Int_t firstybin=0, Int_t lastybin=-1, Int_t cut=0, Option_t *option="QNR", TObjArray* arr = nullptr);
0093    virtual void     FitSlicesY(TF1 *f1 = nullptr, Int_t firstxbin=0, Int_t lastxbin=-1, Int_t cut=0, Option_t *option="QNR", TObjArray* arr = nullptr);
0094            Int_t    GetBin(Int_t binx, Int_t biny, Int_t binz = 0) const override;
0095    virtual Double_t GetBinWithContent2(Double_t c, Int_t &binx, Int_t &biny, Int_t firstxbin=1, Int_t lastxbin=-1,Int_t firstybin=1, Int_t lastybin=-1, Double_t maxdiff=0) const;
0096    using TH1::GetBinContent;
0097            Double_t GetBinContent(Int_t binx, Int_t biny) const override { return TH1::GetBinContent( GetBin(binx, biny) ); }
0098            Double_t GetBinContent(Int_t binx, Int_t biny, Int_t) const override { return TH1::GetBinContent( GetBin(binx, biny) ); }
0099    using TH1::GetBinErrorLow;
0100    using TH1::GetBinErrorUp;
0101    virtual Double_t GetBinErrorLow(Int_t binx, Int_t biny) { return TH1::GetBinErrorLow( GetBin(binx, biny) ); }
0102    virtual Double_t GetBinErrorUp(Int_t binx, Int_t biny) { return TH1::GetBinErrorUp( GetBin(binx, biny) ); }
0103    virtual Double_t GetCorrelationFactor(Int_t axis1=1,Int_t axis2=2) const;
0104    virtual Double_t GetCovariance(Int_t axis1=1,Int_t axis2=2) const;
0105    virtual void     GetRandom2(Double_t &x, Double_t &y, TRandom * rng = nullptr, Option_t *option = "");
0106            void     GetStats(Double_t *stats) const override;
0107            Double_t Integral(Option_t *option="") const override;
0108    //virtual Double_t Integral(Int_t, Int_t, Option_t * ="") const {return 0;}
0109    virtual Double_t Integral(Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Option_t *option="") const;
0110    virtual Double_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Option_t * ="") const {return 0;}
0111    virtual Double_t IntegralAndError(Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Double_t & err, Option_t *option="") const;
0112            Double_t Interpolate(Double_t x, Double_t y) const override;
0113            Double_t Interpolate(Double_t x, Double_t y, Double_t z) const override;
0114            Double_t KolmogorovTest(const TH1 *h2, Option_t *option="") const override;
0115            TH2     *RebinX(Int_t ngroup=2, const char *newname="") override; // *MENU*
0116    virtual TH2     *RebinY(Int_t ngroup=2, const char *newname=""); // *MENU*
0117            TH2     *Rebin(Int_t ngroup=2, const char*newname="", const Double_t *xbins = nullptr) override;  // re-implementation of the TH1 function using RebinX
0118    virtual TH2     *Rebin2D(Int_t nxgroup=2, Int_t nygroup=2, const char *newname=""); // *MENU*
0119           TProfile *ProfileX(const char *name="_pfx", Int_t firstybin=1, Int_t lastybin=-1, Option_t *option="") const;   // *MENU*
0120           TProfile *ProfileY(const char *name="_pfy", Int_t firstxbin=1, Int_t lastxbin=-1, Option_t *option="") const;   // *MENU*
0121            TH1D    *ProjectionX(const char *name="_px", Int_t firstybin=0, Int_t lastybin=-1, Option_t *option="") const; // *MENU*
0122            TH1D    *ProjectionY(const char *name="_py", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const; // *MENU*
0123            void     PutStats(Double_t *stats) override;
0124            TH1D    *QuantilesX(Double_t prob = 0.5, const char * name = "_qx" ) const;
0125            TH1D    *QuantilesY(Double_t prob = 0.5, const char * name = "_qy" ) const;
0126            void     Reset(Option_t *option="") override;
0127            void     SetBinContent(Int_t bin, Double_t content) override;
0128            void     SetBinContent(Int_t binx, Int_t biny, Double_t content) override { SetBinContent(GetBin(binx, biny), content); }
0129            void     SetBinContent(Int_t binx, Int_t biny, Int_t, Double_t content) override { SetBinContent(GetBin(binx, biny), content); }
0130    virtual void     SetShowProjectionX(Int_t nbins=1);  // *MENU*
0131    virtual void     SetShowProjectionY(Int_t nbins=1);  // *MENU*
0132    virtual void     SetShowProjectionXY(Int_t nbinsY=1, Int_t nbinsX=1);  // *MENU*
0133            TH1     *ShowBackground(Int_t niter=20, Option_t *option="same") override;
0134            Int_t    ShowPeaks(Double_t sigma=2, Option_t *option="", Double_t threshold=0.05) override; // *MENU*
0135            void     Smooth(Int_t ntimes=1, Option_t *option="") override; // *MENU*
0136 
0137    ClassDefOverride(TH2,5)  //2-Dim histogram base class
0138 };
0139 
0140 
0141 //______________________________________________________________________________
0142 
0143 class TH2C : public TH2, public TArrayC {
0144 
0145 public:
0146    TH2C();
0147    TH2C(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0148                                 ,Int_t nbinsy,Double_t ylow,Double_t yup);
0149    TH2C(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0150                                           ,Int_t nbinsy,Double_t ylow,Double_t yup);
0151    TH2C(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0152                                           ,Int_t nbinsy,const Double_t *ybins);
0153    TH2C(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0154                                           ,Int_t nbinsy,const Double_t *ybins);
0155    TH2C(const char *name,const char *title,Int_t nbinsx,const Float_t  *xbins
0156                                           ,Int_t nbinsy,const Float_t  *ybins);
0157    TH2C(const TH2C &h2c);
0158    ~TH2C() override;
0159 
0160            void     AddBinContent(Int_t bin) override;
0161            void     AddBinContent(Int_t bin, Double_t w) override;
0162    using TH2::AddBinContent;
0163            void     Copy(TObject &hnew) const override;
0164            void     Reset(Option_t *option="") override;
0165            void     SetBinsLength(Int_t n=-1) override;
0166 
0167            TH2C&    operator=(const TH2C &h1);
0168    friend  TH2C     operator*(Float_t c1, TH2C const &h1);
0169    friend TH2C operator*(TH2C const &h1, Float_t c1);
0170    friend  TH2C     operator+(TH2C const &h1, TH2C const &h2);
0171    friend  TH2C     operator-(TH2C const &h1, TH2C const &h2);
0172    friend  TH2C     operator*(TH2C const &h1, TH2C const &h2);
0173    friend  TH2C     operator/(TH2C const &h1, TH2C const &h2);
0174 
0175 protected:
0176            Double_t RetrieveBinContent(Int_t bin) const override { return Double_t (fArray[bin]); }
0177            void     UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = Char_t (content); }
0178 
0179    ClassDefOverride(TH2C,4)  //2-Dim histograms (one char per channel)
0180 };
0181 
0182 TH2C operator*(Float_t c1, TH2C const &h1);
0183 inline TH2C operator*(TH2C const &h1, Float_t c1)
0184 {
0185    return operator*(c1, h1);
0186 }
0187 TH2C operator+(TH2C const &h1, TH2C const &h2);
0188 TH2C operator-(TH2C const &h1, TH2C const &h2);
0189 TH2C operator*(TH2C const &h1, TH2C const &h2);
0190 TH2C operator/(TH2C const &h1, TH2C const &h2);
0191 
0192 //______________________________________________________________________________
0193 
0194 class TH2S : public TH2, public TArrayS {
0195 
0196 public:
0197    TH2S();
0198    TH2S(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0199                                           ,Int_t nbinsy,Double_t ylow,Double_t yup);
0200    TH2S(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0201                                           ,Int_t nbinsy,Double_t ylow,Double_t yup);
0202    TH2S(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0203                                           ,Int_t nbinsy,const Double_t *ybins);
0204    TH2S(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0205                                           ,Int_t nbinsy,const Double_t *ybins);
0206    TH2S(const char *name,const char *title,Int_t nbinsx,const Float_t  *xbins
0207                                           ,Int_t nbinsy,const Float_t  *ybins);
0208    TH2S(const TH2S &h2s);
0209    ~TH2S() override;
0210 
0211            void     AddBinContent(Int_t bin) override;
0212            void     AddBinContent(Int_t bin, Double_t w) override;
0213    using TH2::AddBinContent;
0214            void     Copy(TObject &hnew) const override;
0215            void     Reset(Option_t *option="") override;
0216            void     SetBinsLength(Int_t n=-1) override;
0217 
0218            TH2S&    operator=(const TH2S &h1);
0219    friend  TH2S     operator*(Float_t c1, TH2S const &h1);
0220    friend TH2S operator*(TH2S const &h1, Float_t c1);
0221    friend  TH2S     operator+(TH2S const &h1, TH2S const &h2);
0222    friend  TH2S     operator-(TH2S const &h1, TH2S const &h2);
0223    friend  TH2S     operator*(TH2S const &h1, TH2S const &h2);
0224    friend  TH2S     operator/(TH2S const &h1, TH2S const &h2);
0225 
0226 protected:
0227            Double_t RetrieveBinContent(Int_t bin) const override { return Double_t (fArray[bin]); }
0228            void     UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = Short_t (content); }
0229 
0230    ClassDefOverride(TH2S,4)  //2-Dim histograms (one short per channel)
0231 };
0232 
0233 TH2S operator*(Float_t c1, TH2S const &h1);
0234 inline TH2S operator*(TH2S const &h1, Float_t c1)
0235 {
0236    return operator*(c1, h1);
0237 }
0238 TH2S operator+(TH2S const &h1, TH2S const &h2);
0239 TH2S operator-(TH2S const &h1, TH2S const &h2);
0240 TH2S operator*(TH2S const &h1, TH2S const &h2);
0241 TH2S operator/(TH2S const &h1, TH2S const &h2);
0242 
0243 //______________________________________________________________________________
0244 
0245 class TH2I : public TH2, public TArrayI {
0246 
0247 public:
0248    TH2I();
0249    TH2I(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0250                                           ,Int_t nbinsy,Double_t ylow,Double_t yup);
0251    TH2I(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0252                                           ,Int_t nbinsy,Double_t ylow,Double_t yup);
0253    TH2I(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0254                                           ,Int_t nbinsy,const Double_t *ybins);
0255    TH2I(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0256                                           ,Int_t nbinsy,const Double_t *ybins);
0257    TH2I(const char *name,const char *title,Int_t nbinsx,const Float_t  *xbins
0258                                           ,Int_t nbinsy,const Float_t  *ybins);
0259    TH2I(const TH2I &h2i);
0260    ~TH2I() override;
0261 
0262            void     AddBinContent(Int_t bin) override;
0263            void     AddBinContent(Int_t bin, Double_t w) override;
0264    using TH2::AddBinContent;
0265            void     Copy(TObject &hnew) const override;
0266            void     Reset(Option_t *option="") override;
0267            void     SetBinsLength(Int_t n=-1) override;
0268 
0269            TH2I&    operator=(const TH2I &h1);
0270    friend  TH2I     operator*(Float_t c1, TH2I const &h1);
0271    friend TH2I operator*(TH2I const &h1, Float_t c1);
0272    friend  TH2I     operator+(TH2I const &h1, TH2I const &h2);
0273    friend  TH2I     operator-(TH2I const &h1, TH2I const &h2);
0274    friend  TH2I     operator*(TH2I const &h1, TH2I const &h2);
0275    friend  TH2I     operator/(TH2I const &h1, TH2I const &h2);
0276 
0277 protected:
0278            Double_t RetrieveBinContent(Int_t bin) const override { return Double_t (fArray[bin]); }
0279            void     UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = Int_t (content); }
0280 
0281    ClassDefOverride(TH2I,4)  //2-Dim histograms (one 32 bit integer per channel)
0282 };
0283 
0284 TH2I operator*(Float_t c1, TH2I const &h1);
0285 inline TH2I operator*(TH2I const &h1, Float_t c1)
0286 {
0287    return operator*(c1, h1);
0288 }
0289 TH2I operator+(TH2I const &h1, TH2I const &h2);
0290 TH2I operator-(TH2I const &h1, TH2I const &h2);
0291 TH2I operator*(TH2I const &h1, TH2I const &h2);
0292 TH2I operator/(TH2I const &h1, TH2I const &h2);
0293 
0294 //______________________________________________________________________________
0295 
0296 class TH2L : public TH2, public TArrayL64 {
0297 
0298 public:
0299    TH2L();
0300    TH2L(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0301                                           ,Int_t nbinsy,Double_t ylow,Double_t yup);
0302    TH2L(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0303                                           ,Int_t nbinsy,Double_t ylow,Double_t yup);
0304    TH2L(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0305                                           ,Int_t nbinsy,const Double_t *ybins);
0306    TH2L(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0307                                           ,Int_t nbinsy,const Double_t *ybins);
0308    TH2L(const char *name,const char *title,Int_t nbinsx,const Float_t  *xbins
0309                                           ,Int_t nbinsy,const Float_t  *ybins);
0310    TH2L(const TH2L &h2l);
0311    ~TH2L() override;
0312    void     AddBinContent(Int_t bin) override;
0313    void     AddBinContent(Int_t bin, Double_t w) override;
0314    using TH2::AddBinContent;
0315    void     Copy(TObject &hnew) const override;
0316    void     Reset(Option_t *option="") override;
0317    void     SetBinsLength(Int_t n=-1) override;
0318            TH2L&    operator=(const TH2L &h1);
0319    friend  TH2L     operator*(Float_t c1, TH2L const &h1);
0320    friend TH2L operator*(TH2L const &h1, Float_t c1);
0321    friend  TH2L     operator+(TH2L const &h1, TH2L const &h2);
0322    friend  TH2L     operator-(TH2L const &h1, TH2L const &h2);
0323    friend  TH2L     operator*(TH2L const &h1, TH2L const &h2);
0324    friend  TH2L     operator/(TH2L const &h1, TH2L const &h2);
0325 
0326 protected:
0327    Double_t RetrieveBinContent(Int_t bin) const override { return Double_t (fArray[bin]); }
0328    void     UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = Long64_t (content); }
0329 
0330    ClassDefOverride(TH2L,0)  //2-Dim histograms (one 64 bit integer per channel)
0331 };
0332 
0333 TH2L operator*(Float_t c1, TH2L const &h1);
0334 inline TH2L operator*(TH2L const &h1, Float_t c1)
0335 {
0336    return operator*(c1, h1);
0337 }
0338 TH2L operator+(TH2L const &h1, TH2L const &h2);
0339 TH2L operator-(TH2L const &h1, TH2L const &h2);
0340 TH2L operator*(TH2L const &h1, TH2L const &h2);
0341 TH2L operator/(TH2L const &h1, TH2L const &h2);
0342 
0343 //______________________________________________________________________________
0344 
0345 class TH2F : public TH2, public TArrayF {
0346 
0347 public:
0348    TH2F();
0349    TH2F(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0350                                           ,Int_t nbinsy,Double_t ylow,Double_t yup);
0351    TH2F(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0352                                           ,Int_t nbinsy,Double_t ylow,Double_t yup);
0353    TH2F(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0354                                           ,Int_t nbinsy,const Double_t *ybins);
0355    TH2F(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0356                                           ,Int_t nbinsy,const Double_t *ybins);
0357    TH2F(const char *name,const char *title,Int_t nbinsx,const Float_t  *xbins
0358                                           ,Int_t nbinsy,const Float_t  *ybins);
0359    TH2F(const TMatrixFBase &m);
0360    TH2F(const TH2F &h2f);
0361    ~TH2F() override;
0362 
0363            /// Increment bin content by 1.
0364            /// Passing an out-of-range bin leads to undefined behavior
0365            void     AddBinContent(Int_t bin) override {++fArray[bin];}
0366            /// Increment bin content by a weight w.
0367            /// \warning The value of w is cast to `Float_t` before being added.
0368            /// Passing an out-of-range bin leads to undefined behavior
0369            void     AddBinContent(Int_t bin, Double_t w) override
0370                                  {fArray[bin] += Float_t (w);}
0371    using TH2::AddBinContent;
0372            void     Copy(TObject &hnew) const override;
0373            void     Reset(Option_t *option="") override;
0374            void     SetBinsLength(Int_t n=-1) override;
0375 
0376            TH2F&    operator=(const TH2F &h1);
0377    friend  TH2F     operator*(Float_t c1, TH2F const &h1);
0378    friend  TH2F     operator*(TH2F const &h1, Float_t c1);
0379    friend  TH2F     operator+(TH2F const &h1, TH2F const &h2);
0380    friend  TH2F     operator-(TH2F const &h1, TH2F const &h2);
0381    friend  TH2F     operator*(TH2F const &h1, TH2F const &h2);
0382    friend  TH2F     operator/(TH2F const &h1, TH2F const &h2);
0383 
0384 protected:
0385            Double_t RetrieveBinContent(Int_t bin) const override { return Double_t (fArray[bin]); }
0386            void     UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = Float_t (content); }
0387 
0388    ClassDefOverride(TH2F,4)  //2-Dim histograms (one float per channel)
0389 };
0390 
0391 TH2F operator*(Float_t c1, TH2F const &h1);
0392 TH2F operator*(TH2F const &h1, Float_t c1);
0393 TH2F operator+(TH2F const &h1, TH2F const &h2);
0394 TH2F operator-(TH2F const &h1, TH2F const &h2);
0395 TH2F operator*(TH2F const &h1, TH2F const &h2);
0396 TH2F operator/(TH2F const &h1, TH2F const &h2);
0397 
0398 //______________________________________________________________________________
0399 
0400 class TH2D : public TH2, public TArrayD {
0401 
0402 public:
0403    TH2D();
0404    TH2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0405                                           ,Int_t nbinsy,Double_t ylow,Double_t yup);
0406    TH2D(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0407                                           ,Int_t nbinsy,Double_t ylow,Double_t yup);
0408    TH2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0409                                           ,Int_t nbinsy,const Double_t *ybins);
0410    TH2D(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0411                                           ,Int_t nbinsy,const Double_t *ybins);
0412    TH2D(const char *name,const char *title,Int_t nbinsx,const Float_t  *xbins
0413                                           ,Int_t nbinsy,const Float_t  *ybins);
0414    TH2D(const TMatrixDBase &m);
0415    TH2D(const TH2D &h2d);
0416    ~TH2D() override;
0417 
0418            /// Increment bin content by 1.
0419            /// Passing an out-of-range bin leads to undefined behavior
0420            void     AddBinContent(Int_t bin) override {++fArray[bin];}
0421            /// Increment bin content by a weight w
0422            /// Passing an out-of-range bin leads to undefined behavior
0423            void     AddBinContent(Int_t bin, Double_t w) override
0424                                  {fArray[bin] += Double_t (w);}
0425    using TH2::AddBinContent;
0426            void     Copy(TObject &hnew) const override;
0427            void     Reset(Option_t *option="") override;
0428            void     SetBinsLength(Int_t n=-1) override;
0429 
0430            TH2D&    operator=(const TH2D &h1);
0431    friend  TH2D     operator*(Float_t c1, TH2D const &h1);
0432    friend TH2D operator*(TH2D const &h1, Float_t c1);
0433    friend  TH2D     operator+(TH2D const &h1, TH2D const &h2);
0434    friend  TH2D     operator-(TH2D const &h1, TH2D const &h2);
0435    friend  TH2D     operator*(TH2D const &h1, TH2D const &h2);
0436    friend  TH2D     operator/(TH2D const &h1, TH2D const &h2);
0437 
0438 protected:
0439            Double_t RetrieveBinContent(Int_t bin) const override { return fArray[bin]; }
0440            void     UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = content; }
0441 
0442    ClassDefOverride(TH2D,4)  //2-Dim histograms (one double per channel)
0443 };
0444 
0445 TH2D operator*(Float_t c1, TH2D const &h1);
0446 inline TH2D operator*(TH2D const &h1, Float_t c1)
0447 {
0448    return operator*(c1, h1);
0449 }
0450 TH2D operator+(TH2D const &h1, TH2D const &h2);
0451 TH2D operator-(TH2D const &h1, TH2D const &h2);
0452 TH2D operator*(TH2D const &h1, TH2D const &h2);
0453 TH2D operator/(TH2D const &h1, TH2D const &h2);
0454 
0455 #endif