TH2


class description - source file - inheritance tree

class TH2 : public TH1

    private:
protected:
public:
TH2 TH2() TH2 TH2(const char* name, const char* title, Int_t nbinsx, Axis_t xlow, Axis_t xup, Int_t nbinsy, Axis_t ylow, Axis_t yup) TH2 TH2(const char* name, const char* title, Int_t nbinsx, const Double_t* xbins, Int_t nbinsy, Axis_t ylow, Axis_t yup) TH2 TH2(const char* name, const char* title, Int_t nbinsx, Axis_t xlow, Axis_t xup, Int_t nbinsy, const Double_t* ybins) TH2 TH2(const char* name, const char* title, Int_t nbinsx, const Double_t* xbins, Int_t nbinsy, const Double_t* ybins) TH2 TH2(const char* name, const char* title, Int_t nbinsx, const Float_t* xbins, Int_t nbinsy, const Float_t* ybins) TH2 TH2(TH2&) virtual void ~TH2() static TClass* Class() virtual void Copy(TObject& hnew) virtual Int_t Fill(Axis_t) virtual Int_t Fill(Axis_t x, Axis_t y) virtual Int_t Fill(Axis_t x, Axis_t y, Stat_t w) virtual void FillN(Int_t, const Axis_t*, const Double_t*, Int_t) virtual void FillN(Int_t ntimes, const Axis_t* x, const Axis_t* y, const Double_t* w, Int_t stride = 1) virtual void FillRandom(const char* fname, Int_t ntimes = 5000) virtual void FillRandom(TH1* h, Int_t ntimes = 5000) virtual void FitSlicesX(TF1* f1 = 0, Int_t binmin = 1, Int_t binmax = 0, Int_t cut = 0, Option_t* option = QNR) virtual void FitSlicesY(TF1* f1 = 0, Int_t binmin = 1, Int_t binmax = 0, Int_t cut = 0, Option_t* option = QNR) virtual Stat_t GetCorrelationFactor(Int_t axis1 = 1, Int_t axis2 = 2) const virtual Stat_t GetCovariance(Int_t axis1 = 1, Int_t axis2 = 2) const virtual void GetRandom2(Axis_t& x, Axis_t& y) virtual void GetStats(Stat_t* stats) const virtual Stat_t Integral(Option_t* option) virtual Stat_t Integral(Int_t, Int_t, Option_t* option) virtual Stat_t Integral(Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Option_t* option) virtual Stat_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Option_t* option) virtual TClass* IsA() const virtual Double_t KolmogorovTest(TH1* h2, Option_t* option) TProfile* ProfileX(const char* name = _pfx, Int_t firstybin = 0, Int_t lastybin = 9999, Option_t* option) TProfile* ProfileY(const char* name = _pfy, Int_t firstxbin = 0, Int_t lastxbin = 9999, Option_t* option) TH1D* ProjectionX(const char* name = _px, Int_t firstybin = 0, Int_t lastybin = 9999, Option_t* option) TH1D* ProjectionY(const char* name = _py, Int_t firstxbin = 0, Int_t lastxbin = 9999, Option_t* option) virtual void PutStats(Stat_t* stats) virtual void Reset(Option_t* option) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b)

Data Members

    private:
protected:
Stat_t fScalefactor Scale factor Stat_t fTsumwy Total Sum of weight*Y Stat_t fTsumwy2 Total Sum of weight*Y*Y Stat_t fTsumwxy Total Sum of weight*X*Y public:


See also

TH2C, TH2D, TH2F, TH2S

Class Description

 Service class for 2-Dim histogram classes

  TH2C a 2-D histogram with one byte per cell (char)
  TH2S a 2-D histogram with two bytes per cell (short integer)
  TH2F a 2-D histogram with four bytes per cell (float)
  TH2D a 2-D histogram with eight bytes per cell (double)


TH2()

TH2(const char *name,const char *title,Int_t nbinsx,Axis_t xlow,Axis_t xup ,Int_t nbinsy,Axis_t ylow,Axis_t yup) :TH1(name,title,nbinsx,xlow,xup)

TH2(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins ,Int_t nbinsy,Axis_t ylow,Axis_t yup) :TH1(name,title,nbinsx,xbins)

TH2(const char *name,const char *title,Int_t nbinsx,Axis_t xlow,Axis_t xup ,Int_t nbinsy,const Double_t *ybins) :TH1(name,title,nbinsx,xlow,xup)

TH2(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins ,Int_t nbinsy,const Double_t *ybins) :TH1(name,title,nbinsx,xbins)

TH2(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins ,Int_t nbinsy,const Float_t *ybins) :TH1(name,title,nbinsx,xbins)

~TH2()

void Copy(TObject &obj)

Int_t Fill(Axis_t x,Axis_t y)
*-*-*-*-*-*-*-*-*-*-*Increment cell defined by x,y by 1*-*-*-*-*-*-*-*-*-*
*-*                  ==================================
*-*
*-* if x or/and y is less than the low-edge of the corresponding axis first bin,
*-*   the Underflow cell is incremented.
*-* if x or/and y is greater than the upper edge of corresponding axis last bin,
*-*   the Overflow cell is incremented.
*-*
*-* If the storage of the sum of squares of weights has been triggered,
*-* via the function Sumw2, then the sum of the squares of weights is incremented
*-* by 1in the cell corresponding to x,y.
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Int_t Fill(Axis_t x, Axis_t y, Stat_t w)
*-*-*-*-*-*-*-*-*-*-*Increment cell defined by x,y by a weight w*-*-*-*-*-*
*-*                  ===========================================
*-*
*-* if x or/and y is less than the low-edge of the corresponding axis first bin,
*-*   the Underflow cell is incremented.
*-* if x or/and y is greater than the upper edge of corresponding axis last bin,
*-*   the Overflow cell is incremented.
*-*
*-* If the storage of the sum of squares of weights has been triggered,
*-* via the function Sumw2, then the sum of the squares of weights is incremented
*-* by w^2 in the cell corresponding to x,y.
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

void FillN(Int_t ntimes, const Axis_t *x, const Axis_t *y, const Double_t *w, Int_t stride)
*-*-*-*-*-*-*Fill a 2-D histogram with an array of values and weights*-*-*-*
*-*          ========================================================
*-*
*-* ntimes:  number of entries in arrays x and w (array size must be ntimes*stride)
*-* x:       array of x values to be histogrammed
*-* y:       array of y values to be histogrammed
*-* w:       array of weights
*-* stride:  step size through arrays x, y and w
*-*
*-* If the storage of the sum of squares of weights has been triggered,
*-* via the function Sumw2, then the sum of the squares of weights is incremented
*-* by w[i]^2 in the cell corresponding to x[i],y[i].
*-* if w is NULL each entry is assumed a weight=1
*-*
*-* NB: function only valid for a TH2x object
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

void FillRandom(const char *fname, Int_t ntimes)
*-*-*-*-*-*-*Fill histogram following distribution in function fname*-*-*-*
*-*          =======================================================
*-*
*-*   The distribution contained in the function fname (TF2) is integrated
*-*   over the channel contents.
*-*   It is normalized to 1.
*-*   Getting one random number implies:
*-*     - Generating a random number between 0 and 1 (say r1)
*-*     - Look in which bin in the normalized integral r1 corresponds to
*-*     - Fill histogram channel
*-*   ntimes random numbers are generated
*-*
*-*  One can also call TF2::GetRandom2 to get a random variate from a function.
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*

void FillRandom(TH1 *h, Int_t ntimes)
*-*-*-*-*-*-*Fill histogram following distribution in histogram h*-*-*-*
*-*          ====================================================
*-*
*-*   The distribution contained in the histogram h (TH1) is integrated
*-*   over the channel contents.
*-*   It is normalized to 1.
*-*   Getting one random number implies:
*-*     - Generating a random number between 0 and 1 (say r1)
*-*     - Look in which bin in the normalized integral r1 corresponds to
*-*     - Fill histogram channel
*-*   ntimes random numbers are generated
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*

void FitSlicesX(TF1 *f1, Int_t binmin, Int_t binmax, Int_t cut, Option_t *option)
 Project slices along X in case of a 2-D histogram, then fit each slice
 with function f1 and make a histogram for each fit parameter
 Only bins along Y between binmin and binmax are considered.
 if f1=0, a gaussian is assumed
 Before invoking this function, one can set a subrange to be fitted along X
 via f1->SetRange(xmin,xmax)
 The argument option (default="QNR") can be used to change the fit options.
     "Q" means Quiet mode
     "N" means do not show the result of the fit
     "R" means fit the function in the specified function range

 Note that the generated histograms are added to the list of objects
 in the current directory. It is the user's responsability to delete
 these histograms.

  Example: Assume a 2-d histogram h2
   Root > h2->FitSlicesX(); produces 4 TH1D histograms
          with h2_0 containing parameter 0(Constant) for a Gaus fit
                    of each bin in Y projected along X
          with h2_1 containing parameter 1(Mean) for a gaus fit
          with h2_2 containing parameter 2(RMS)  for a gaus fit
          with h2_chi2 containing the chisquare/number of degrees of freedom for a gaus fit

   Root > h2->FitSlicesX(0,15,22,10);
          same as above, but only for bins 15 to 22 along Y
          and only for bins in Y for which the corresponding projection
          along X has more than cut bins filled.

  NOTE: To access the generated histograms in the current directory, do eg:
     TH1D *h2_1 = (TH1D*)gDirectory->Get("h2_1");

void FitSlicesY(TF1 *f1, Int_t binmin, Int_t binmax, Int_t cut, Option_t *option)
 Project slices along Y in case of a 2-D histogram, then fit each slice
 with function f1 and make a histogram for each fit parameter
 Only bins along X between binmin and binmax are considered.
 if f1=0, a gaussian is assumed
 Before invoking this function, one can set a subrange to be fitted along Y
 via f1->SetRange(ymin,ymax)
 The argument option (default="QNR") can be used to change the fit options.
     "Q" means Quiet mode
     "N" means do not show the result of the fit
     "R" means fit the function in the specified function range

 Note that the generated histograms are added to the list of objects
 in the current directory. It is the user's responsability to delete
 these histograms.

  Example: Assume a 2-d histogram h2
   Root > h2->FitSlicesY(); produces 4 TH1D histograms
          with h2_0 containing parameter 0(Constant) for a Gaus fit
                    of each bin in X projected along Y
          with h2_1 containing parameter 1(Mean) for a gaus fit
          with h2_2 containing parameter 2(RMS)  for a gaus fit
          with h2_chi2 containing the chisquare/number of degrees of freedom for a gaus fit

   Root > h2->FitSlicesY(0,15,22,10);
          same as above, but only for bins 15 to 22 along X
          and only for bins in X for which the corresponding projection
          along Y has more than cut bins filled.

  NOTE: To access the generated histograms in the current directory, do eg:
     TH1D *h2_1 = (TH1D*)gDirectory->Get("h2_1");

 A complete example of this function is given in  tutorial:fitslicesy.C 
 with the following output:

/*

*/


Stat_t GetCorrelationFactor(Int_t axis1, Int_t axis2) const
*-*-*-*-*-*-*-*Return correlation factor between axis1 and axis2*-*-*-*-*
*-*            ====================================================

Stat_t GetCovariance(Int_t axis1, Int_t axis2) const
*-*-*-*-*-*-*-*Return covariance between axis1 and axis2*-*-*-*-*
*-*            ====================================================

void GetRandom2(Axis_t &x, Axis_t &y)
 return 2 random numbers along axis x and y distributed according
 the cellcontents of a 2-dim histogram

void GetStats(Stat_t *stats) const
 fill the array stats from the contents of this histogram
 The array stats must be correctly dimensionned in the calling program.
 stats[0] = sumw
 stats[1] = sumw2
 stats[2] = sumwx
 stats[3] = sumwx2
 stats[4] = sumwy
 stats[5] = sumwy2
 stats[6] = sumwxy

Stat_t Integral(Option_t *option)
Return integral of bin contents. Only bins in the bins range are considered.
 By default the integral is computed as the sum of bin contents in the range.
 if option "width" is specified, the integral is the sum of
 the bin contents multiplied by the bin width in x and in y.

Stat_t Integral(Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Option_t *option)
Return integral of bin contents in range [binx1,binx2],[biny1,biny2]
 for a 2-D histogram
 By default the integral is computed as the sum of bin contents in the range.
 if option "width" is specified, the integral is the sum of
 the bin contents multiplied by the bin width in x and in y.

Double_t KolmogorovTest(TH1 *h2, Option_t *option)
  Statistical test of compatibility in shape between
  THIS histogram and h2, using Kolmogorov test.
     Default: Ignore under- and overflow bins in comparison

     option is a character string to specify options
         "U" include Underflows in test
         "O" include Overflows
         "N" include comparison of normalizations
         "D" Put out a line of "Debug" printout

   The returned function value is the probability of test
       (much less than one means NOT compatible)

  Code adapted by Rene Brun from original HBOOK routine HDIFF

TProfile* ProfileX(const char *name, Int_t firstybin, Int_t lastybin, Option_t *option)
*-*-*-*-*Project a 2-D histogram into a profile histogram along X*-*-*-*-*-*
*-*      ========================================================

   The projection is made from the channels along the Y axis
   ranging from firstybin to lastybin included.


TProfile* ProfileY(const char *name, Int_t firstxbin, Int_t lastxbin, Option_t *option)
*-*-*-*-*Project a 2-D histogram into a profile histogram along Y*-*-*-*-*-*
*-*      ========================================================

   The projection is made from the channels along the X axis
   ranging from firstxbin to lastxbin included.


TH1D* ProjectionX(const char *name, Int_t firstybin, Int_t lastybin, Option_t *option)
*-*-*-*-*Project a 2-D histogram into a 1-D histogram along X*-*-*-*-*-*-*
*-*      ====================================================

   The projection is always of the type TH1D.
   The projection is made from the channels along the Y axis
   ranging from firstybin to lastybin included.

   if option "E" is specified, the errors are computed.


TH1D* ProjectionY(const char *name, Int_t firstxbin, Int_t lastxbin, Option_t *option)
*-*-*-*-*Project a 2-D histogram into a 1-D histogram along Y*-*-*-*-*-*-*
*-*      ====================================================

   The projection is always of the type TH1D.
   The projection is made from the channels along the X axis
   ranging from firstxbin to lastxbin included.

   if option "E" is specified, the errors are computed.


void PutStats(Stat_t *stats)
 Replace current statistics with the values in array stats

void Reset(Option_t *option)
*-*-*-*-*-*-*-*Reset this histogram: contents, errors, etc*-*-*-*-*-*-*-*
*-*            ===========================================

void Streamer(TBuffer &R__b)
 Stream an object of class TH2.



Inline Functions


              Int_t Fill(Axis_t x, Axis_t y, Stat_t w)
               void FillN(Int_t ntimes, const Axis_t* x, const Axis_t* y, const Double_t* w, Int_t stride = 1)
             Stat_t Integral(Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Option_t* option)
             Stat_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Option_t* option)
            TClass* Class()
            TClass* IsA() const
               void ShowMembers(TMemberInspector& insp, char* parent)
               void StreamerNVirtual(TBuffer& b)
                TH2 TH2(TH2&)


Author: Rene Brun 26/12/94
Last update: root/hist:$Name: $:$Id: TH2.cxx,v 1.18 2001/05/13 06:54:17 brun Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.