Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TProfile2D.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: Rene Brun   16/04/2000
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_TProfile2D
0013 #define ROOT_TProfile2D
0014 
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TProfile2D                                                           //
0019 //                                                                      //
0020 // Profile2D histogram class.                                           //
0021 //                                                                      //
0022 //////////////////////////////////////////////////////////////////////////
0023 
0024 #include "TH2.h"
0025 #include "TProfile.h"
0026 
0027 class TProfile2D : public TH2D {
0028 
0029 public:
0030    friend class TProfileHelper;
0031    friend class TH1Merger;
0032 
0033 protected:
0034    TArrayD     fBinEntries;       ///< Number of entries per bin
0035    EErrorType  fErrorMode;        ///< Option to compute errors
0036    Double_t    fZmin;             ///< Lower limit in Z (if set)
0037    Double_t    fZmax;             ///< Upper limit in Z (if set)
0038    Bool_t      fScaling;          ///<! True when TProfile2D::Scale is called
0039    Double_t    fTsumwz;           ///< Total Sum of weight*Z
0040    Double_t    fTsumwz2;          ///< Total Sum of weight*Z*Z
0041    TArrayD     fBinSumw2;         ///< Array of sum of squares of weights per bin
0042    static Bool_t   fgApproximate; ///< Bin error approximation option
0043 
0044    Int_t    BufferFill(Double_t, Double_t) override {return -2;} //may not use
0045    Int_t    BufferFill(Double_t, Double_t, Double_t) override {return -2;} //may not use
0046    virtual Int_t    BufferFill(Double_t x, Double_t y, Double_t z, Double_t w);
0047 
0048    // helper methods for the Merge unification in TProfileHelper
0049    void SetBins(const Int_t* nbins, const Double_t* range) { SetBins(nbins[0], range[0], range[1],
0050                                                                      nbins[1], range[2], range[3]); };
0051    Int_t Fill(const Double_t* v) { return Fill(v[0], v[1], v[2], v[3]); };
0052 
0053    TProfile *DoProfile(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const override;
0054 
0055    using TH2::Fill;
0056    Int_t             Fill(Double_t, Double_t) override {return TH2::Fill(0); } //MayNotUse
0057 
0058    Double_t RetrieveBinContent(Int_t bin) const override { return (fBinEntries.fArray[bin] > 0) ? fArray[bin]/fBinEntries.fArray[bin] : 0; }
0059    //virtual void     UpdateBinContent(Int_t bin, Double_t content);
0060    Double_t GetBinErrorSqUnchecked(Int_t bin) const override { Double_t err = GetBinError(bin); return err*err; }
0061 
0062 private:
0063    Double_t *GetB()  {return &fBinEntries.fArray[0];}
0064    Double_t *GetB2() {return fBinSumw2.fN ? &fBinSumw2.fArray[0] : nullptr; }
0065    Double_t *GetW()  {return &fArray[0];}
0066    Double_t *GetW2() {return &fSumw2.fArray[0];}
0067    void  SetBins(Int_t, Double_t, Double_t) override
0068       { MayNotUse("SetBins(Int_t, Double_t, Double_t"); }
0069    void  SetBins(Int_t, const Double_t*) override
0070       { MayNotUse("SetBins(Int_t, const Double_t*"); }
0071    void SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t, Int_t, Double_t, Double_t) override
0072       { MayNotUse("SetBins(Int_t, Double_t, Double_t, Int_t, Double_t, Double_t, Int_t, Double_t, Double_t"); }
0073    void SetBins(Int_t, const Double_t *, Int_t, const Double_t *, Int_t, const Double_t *) override
0074       { MayNotUse("SetBins(Int_t, const Double_t*, Int_t, const Double_t*, Int_t, const Double_t*"); }
0075 
0076 public:
0077    TProfile2D();
0078    TProfile2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0079                                ,Int_t nbinsy,Double_t ylow,Double_t yup
0080                                ,Double_t zlow, Double_t zup,Option_t *option="");
0081    TProfile2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0082                                ,Int_t nbinsy,Double_t ylow,Double_t yup,Option_t *option="");
0083    TProfile2D(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0084                                ,Int_t nbinsy,Double_t ylow,Double_t yup,Option_t *option="");
0085    TProfile2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
0086                                ,Int_t nbinsy,const Double_t *ybins,Option_t *option="");
0087    TProfile2D(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
0088                                ,Int_t nbinsy,const Double_t *ybins,Option_t *option="");
0089    TProfile2D(const TProfile2D &profile);
0090    TProfile2D &operator=(const TProfile2D &profile);
0091    ~TProfile2D() override;
0092    Bool_t    Add(TF1 *h1, Double_t c1=1, Option_t *option="") override;
0093    Bool_t    Add(const TH1 *h1, Double_t c1=1) override;
0094    Bool_t    Add(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1) override; // *MENU*
0095    static  void      Approximate(Bool_t approx=kTRUE);
0096    void              BuildOptions(Double_t zmin, Double_t zmax, Option_t *option);
0097    Int_t     BufferEmpty(Int_t action=0) override;
0098    void      Copy(TObject &hnew) const override;
0099    Bool_t    Divide(TF1 *h1, Double_t c1=1) override;
0100    Bool_t    Divide(const TH1 *h1) override;
0101    Bool_t    Divide(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option="") override; // *MENU*
0102    void      ExtendAxis(Double_t x, TAxis *axis) override;
0103    Int_t             Fill(Double_t x, Double_t y, Double_t z) override;
0104    // Don't use a default w=1.0 in the Fill functions, but instead declare
0105    // inlined no-weight overloads to correctly override TH2 methods.
0106    virtual Int_t     Fill(Double_t x, const char *namey, Double_t z, Double_t w);
0107    virtual Int_t     Fill(const char *namex, Double_t y, Double_t z, Double_t w);
0108    virtual Int_t     Fill(const char *namex, const char *namey, Double_t z, Double_t w);
0109    virtual Int_t     Fill(Double_t x, Double_t y, Double_t z, Double_t w);
0110    inline  Int_t     Fill(Double_t x, const char *namey, Double_t z) override { return Fill(x, namey, z, 1.0); }
0111    inline  Int_t     Fill(const char *namex, Double_t y, Double_t z) override { return Fill(namex, y, z, 1.0); }
0112    inline  Int_t     Fill(const char *namex, const char *namey, Double_t z) override { return Fill(namex, namey, z, 1.0); }
0113    Double_t  GetBinContent(Int_t bin) const override;
0114    Double_t  GetBinContent(Int_t binx, Int_t biny) const override {return GetBinContent(GetBin(binx,biny));}
0115    Double_t  GetBinContent(Int_t binx, Int_t biny, Int_t) const override {return GetBinContent(GetBin(binx,biny));}
0116    Double_t  GetBinError(Int_t bin) const override;
0117    Double_t  GetBinError(Int_t binx, Int_t biny) const override {return GetBinError(GetBin(binx,biny));}
0118    Double_t  GetBinError(Int_t binx, Int_t biny, Int_t) const override {return GetBinError(GetBin(binx,biny));}
0119    virtual Double_t  GetBinEntries(Int_t bin) const;
0120    virtual Double_t  GetBinEffectiveEntries(Int_t bin);
0121    virtual TArrayD *GetBinSumw2() {return &fBinSumw2;}
0122    virtual const TArrayD *GetBinSumw2() const {return &fBinSumw2;}
0123    Option_t         *GetErrorOption() const;
0124    void      GetStats(Double_t *stats) const override;
0125    virtual Double_t  GetZmin() const {return fZmin;}
0126    virtual Double_t  GetZmax() const {return fZmax;}
0127    void      LabelsDeflate(Option_t *axis="X") override;
0128    void      LabelsInflate(Option_t *axis="X") override;
0129    void      LabelsOption(Option_t *option="h", Option_t *axis="X") override;
0130    Long64_t  Merge(TCollection *list) override;
0131    Bool_t    Multiply(TF1 *h1, Double_t c1=1) override;
0132    Bool_t    Multiply(const TH1 *h1) override;
0133    Bool_t    Multiply(const TH1 *h1, const TH1 *h2, Double_t c1=1, Double_t c2=1, Option_t *option="") override; // *MENU*
0134    TH2D             *ProjectionXY(const char *name="_pxy", Option_t *option="e") const;
0135    TProfile         *ProfileX(const char *name="_pfx", Int_t firstybin=0, Int_t lastybin=-1, Option_t *option="") const;   // *MENU*
0136    TProfile         *ProfileY(const char *name="_pfy", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const;   // *MENU*
0137    void      PutStats(Double_t *stats) override;
0138    void      Reset(Option_t *option="") override;
0139    TProfile2D *Rebin2D(Int_t nxgroup=2, Int_t nygroup=2, const char *newname="") override;
0140    TProfile2D *RebinX(Int_t ngroup=2, const char *newname="") override;
0141    TProfile2D *RebinY(Int_t ngroup=2, const char *newname="") override;
0142    void      SavePrimitive(std::ostream &out, Option_t *option = "") override;
0143    void      Scale(Double_t c1=1, Option_t *option="") override;
0144    virtual void      SetBinEntries(Int_t bin, Double_t w);
0145    void      SetBins(Int_t nbinsx, Double_t xmin, Double_t xmax, Int_t nbinsy, Double_t ymin, Double_t ymax) override;
0146    void      SetBins(Int_t nx, const Double_t *xBins, Int_t ny, const Double_t *yBins) override;
0147    void      SetBinsLength(Int_t n=-1) override;
0148    void      SetBuffer(Int_t buffersize, Option_t *option="") override;
0149    virtual void      SetErrorOption(Option_t *option=""); // *MENU*
0150    void      Sumw2(Bool_t flag = kTRUE) override;
0151    Double_t GetNumberOfBins() { return fBinEntries.GetSize(); }
0152 
0153    ClassDefOverride(TProfile2D,8)  //Profile2D histogram class
0154 };
0155 
0156 #endif