TH1
class description - source file - inheritance tree
private:
Int_t AxisChoice(Option_t* axis) const
void Build()
Int_t FitOptionsMake(Option_t* option)
protected:
virtual void Copy(TObject& hnew)
public:
TH1 TH1()
TH1 TH1(const char* name, const char* title, Int_t nbinsx, Axis_t xlow, Axis_t xup)
TH1 TH1(const char* name, const char* title, Int_t nbinsx, Float_t* xbins)
TH1 TH1(const char* name, const char* title, Int_t nbinsx, Double_t* xbins)
TH1 TH1(TH1&)
virtual void ~TH1()
virtual void Add(TF1* h1, Double_t c1 = 1)
virtual void Add(TH1* h1, Double_t c1 = 1)
virtual void Add(TH1* h1, TH1* h2, Double_t c1 = 1, Double_t c2 = 1)
virtual void AddBinContent(Int_t bin)
virtual void AddBinContent(Int_t bin, Stat_t w)
static void AddDirectory(Bool_t add = kTRUE)
virtual void Browse(TBrowser* b)
static TClass* Class()
virtual Double_t ComputeIntegral()
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
virtual void Divide(TF1* f1, Double_t c1 = 1)
virtual void Divide(TH1* h1)
virtual void Divide(TH1* h1, TH1* h2, Double_t c1 = 1, Double_t c2 = 1, Option_t* option)
virtual void Draw(Option_t* option)
virtual TH1* DrawCopy(Option_t* option)
virtual void DrawPanel()
virtual void Eval(TF1* f1, Option_t* option)
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual Int_t Fill(Axis_t x)
virtual Int_t Fill(Axis_t x, Stat_t w)
virtual void FillN(Int_t ntimes, Axis_t* x, Double_t* w, Int_t stride = 1)
virtual void FillN(Int_t, Axis_t*, Axis_t*, Double_t*, Int_t)
virtual void FillRandom(const char* fname, Int_t ntimes = 5000)
virtual void FillRandom(TH1* h, Int_t ntimes = 5000)
virtual Int_t FindBin(Axis_t x, Axis_t y = 0, Axis_t z = 0)
virtual void Fit(const char* formula, Option_t* option, Option_t* goption, Axis_t xmin = 0, Axis_t xmax = 0)
virtual void Fit(TF1* f1, Option_t* option, Option_t* goption, Axis_t xmin = 0, Axis_t xmax = 0)
virtual void FitPanel()
virtual Color_t GetAxisColor(Option_t* axis = X) const
virtual Float_t GetBarOffset() const
virtual Float_t GetBarWidth() const
virtual Int_t GetBin(Int_t binx, Int_t biny = 0, Int_t binz = 0) const
virtual Axis_t GetBinCenter(Int_t bin) const
virtual Stat_t GetBinContent(Int_t bin) const
virtual Stat_t GetBinError(Int_t bin) const
virtual Axis_t GetBinLowEdge(Int_t bin) const
virtual Axis_t GetBinWidth(Int_t bin) const
virtual Stat_t GetCellContent(Int_t binx, Int_t biny) const
virtual Stat_t GetCellError(Int_t binx, Int_t biny) const
virtual void GetCenter(Axis_t* center)
virtual Int_t GetContour(Double_t* levels = 0)
virtual Double_t GetContourLevel(Int_t level) const
virtual Int_t GetDimension() const
TDirectory* GetDirectory() const
virtual Stat_t GetEntries() const
virtual TF1* GetFunction(const char* name) const
virtual Double_t* GetIntegral()
virtual Color_t GetLabelColor(Option_t* axis = X) const
virtual Style_t GetLabelFont(Option_t* axis = X) const
virtual Float_t GetLabelOffset(Option_t* axis = X) const
virtual Float_t GetLabelSize(Option_t* axis = X) const
TList* GetListOfFunctions() const
virtual void GetLowEdge(Axis_t* edge)
virtual Double_t GetMaximum() const
virtual Int_t GetMaximumBin() const
virtual Int_t GetMaximumBin(Int_t& locmax, Int_t& locmay, Int_t& locmaz) const
virtual Double_t GetMaximumStored() const
virtual Stat_t GetMean(Int_t axis = 1) const
virtual Double_t GetMinimum() const
virtual Int_t GetMinimumBin() const
virtual Int_t GetMinimumBin(Int_t& locmix, Int_t& locmiy, Int_t& locmiz) const
virtual Double_t GetMinimumStored() const
virtual Int_t GetNbinsX() const
virtual Int_t GetNbinsY() const
virtual Int_t GetNbinsZ() const
virtual Int_t GetNdivisions(Option_t* axis = X) const
virtual Double_t GetNormFactor() const
virtual char* GetObjectInfo(Int_t px, Int_t py) const
virtual Option_t* GetOption() const
TVirtualHistPainter* GetPainter() const
virtual Axis_t GetRandom()
virtual Stat_t GetRMS(Int_t axis = 1) const
virtual void GetStats(Stat_t* stats) const
virtual Stat_t GetSumOfWeights() const
virtual Int_t GetSumw2N() const
virtual Float_t GetTickLength(Option_t* axis = X) const
virtual Float_t GetTitleOffset(Option_t* axis = X) const
virtual Float_t GetTitleSize(Option_t* axis = X) const
virtual TAxis* GetXaxis()
virtual TAxis* GetYaxis()
virtual TAxis* GetZaxis()
virtual Stat_t Integral()
virtual Stat_t Integral(Int_t binx1, Int_t binx2)
virtual Stat_t Integral(Int_t, Int_t, Int_t, Int_t)
virtual Stat_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t)
virtual TClass* IsA() const
virtual Double_t KolmogorovTest(TH1* h2, Option_t* option)
virtual void Multiply(TF1* h1, Double_t c1 = 1)
virtual void Multiply(TH1* h1)
virtual void Multiply(TH1* h1, TH1* h2, Double_t c1 = 1, Double_t c2 = 1, Option_t* option)
virtual void Paint(Option_t* option)
virtual void Print(Option_t* option) const
virtual void PutStats(Stat_t* stats)
virtual TH1* Rebin(Int_t ngroup = 2, const char* newname)
virtual void RebinAxis(Axis_t x, Option_t* axis = X)
virtual void Reset(Option_t* option)
virtual void SavePrimitive(ofstream& out, Option_t* option)
virtual void Scale(Double_t c1 = 1)
virtual void SetAxisColor(Color_t color = 1, Option_t* axis = X)
virtual void SetAxisRange(Axis_t xmin, Axis_t xmax, Option_t* axis = X)
virtual void SetBarOffset(Float_t offset = 0.25)
virtual void SetBarWidth(Float_t width = 0.5)
virtual void SetBinContent(Int_t bin, Stat_t content)
virtual void SetBinError(Int_t bin, Stat_t error)
virtual void SetBins(Int_t nx, Axis_t xmin, Axis_t xmax)
virtual void SetBins(Int_t nx, Axis_t xmin, Axis_t xmax, Int_t ny, Axis_t ymin, Axis_t ymax)
virtual void SetBins(Int_t nx, Axis_t xmin, Axis_t xmax, Int_t ny, Axis_t ymin, Axis_t ymax, Int_t nz, Axis_t zmin, Axis_t zmax)
virtual void SetBinsLength(Int_t)
virtual void SetCellContent(Int_t binx, Int_t biny, Stat_t content)
virtual void SetCellError(Int_t binx, Int_t biny, Stat_t content)
virtual void SetContent(Stat_t* content)
virtual void SetContour(Int_t nlevels, Double_t* levels = 0)
virtual void SetContourLevel(Int_t level, Double_t value)
virtual void SetDirectory(TDirectory* dir)
virtual void SetEntries(Stat_t n)
virtual void SetError(Stat_t* error)
virtual void SetLabelColor(Color_t color = 1, Option_t* axis = X)
virtual void SetLabelFont(Style_t font = 62, Option_t* axis = X)
virtual void SetLabelOffset(Float_t offset = 0.005, Option_t* axis = X)
virtual void SetLabelSize(Float_t size = 0.02, Option_t* axis = X)
virtual void SetMaximum(Double_t maximum = -1111)
virtual void SetMinimum(Double_t minimum = -1111)
virtual void SetName(const char* name)
virtual void SetNdivisions(Int_t n = 510, Option_t* axis = X)
virtual void SetNormFactor(Double_t factor = 1)
virtual void SetObject(const char* name, const char* title)
virtual void SetOption(Option_t* option = )
virtual void SetStats(Bool_t stats = kTRUE)
virtual void SetTickLength(Float_t length = 0.02, Option_t* axis = X)
virtual void SetTitleOffset(Float_t offset = 1, Option_t* axis = X)
virtual void SetTitleSize(Float_t size = 0.02, Option_t* axis = X)
virtual void SetXTitle(const char* title)
virtual void SetYTitle(const char* title)
virtual void SetZTitle(const char* title)
virtual void ShowMembers(TMemberInspector& insp, char* parent)
virtual void Smooth(Int_t ntimes = 1)
static void SmoothArray(Int_t NN, Double_t* XX, Int_t ntimes = 1)
static Double_t SmoothMedian(Int_t n, Double_t* a)
virtual void Streamer(TBuffer& b)
void StreamerNVirtual(TBuffer& b)
virtual void Sumw2()
virtual void UseCurrentStyle()
protected:
Int_t fNcells number of bins(1D), cells (2D) +U/Overflows
TAxis fXaxis X axis descriptor
TAxis fYaxis Y axis descriptor
TAxis fZaxis Z axis descriptor
Short_t fBarOffset (1000*offset) for bar charts or legos
Short_t fBarWidth (1000*width) for bar charts or legos
Stat_t fEntries Number of entries
Stat_t fTsumw Total Sum of weights
Stat_t fTsumw2 Total Sum of squares of weights
Stat_t fTsumwx Total Sum of weight*X
Stat_t fTsumwx2 Total Sum of weight*X*X
Double_t fMaximum Maximum value for plotting
Double_t fMinimum Minimum value for plotting
Double_t fNormFactor Normalization factor
TArrayD fContour Array to display contour levels
TArrayD fSumw2 Array of sum of squares of weights
TString fOption histogram options
TList* fFunctions ->Pointer to list of functions (fits and user)
TDirectory* fDirectory !Pointer to directory holding this histogram
Int_t fDimension !Histogram dimension (1, 2 or 3 dim)
Double_t* fIntegral !Integral of bins used by GetRandom
TVirtualHistPainter* fPainter !pointer to histogram painter
static Bool_t fgAddDirectory !flag to add histograms to the directory
public:
static const enum TObject:: kNoStats
static const enum TObject:: kUserContour
static const enum TObject:: kCanRebin
static const enum TObject:: kLogX
See also
-
TH1C, TH1D, TH1F, TH1S, TH2, TH3
*-*-*-*-*-*-*-*-*-*-*The H I S T O G R A M Classes*-*-*-*-*-*-*-*-*-*-*-*
*-* ===============================
*-*
*-* ROOT supports the following histogram types:
*-*
*-* 1-D histograms:
*-* TH1C : histograms with one byte per channel. Maximum bin content = 255
*-* TH1S : histograms with one short per channel. Maximum bin content = 65535
*-* TH1F : histograms with one float per channel. Maximum precision 7 digits
*-* TH1D : histograms with one double per channel. Maximum precision 14 digits
*-*
*-* 2-D histograms:
*-* TH2C : histograms with one byte per channel. Maximum bin content = 255
*-* TH2S : histograms with one short per channel. Maximum bin content = 65535
*-* TH2F : histograms with one float per channel. Maximum precision 7 digits
*-* TH2D : histograms with one double per channel. Maximum precision 14 digits
*-*
*-* 3-D histograms:
*-* TH3C : histograms with one byte per channel. Maximum bin content = 255
*-* TH3S : histograms with one short per channel. Maximum bin content = 65535
*-* TH3F : histograms with one float per channel. Maximum precision 7 digits
*-* TH3D : histograms with one double per channel. Maximum precision 14 digits
*-*
*-* Profile histograms: See classes TProfile and TProfile2D
*-* Profile histograms are used to display the mean value of Y and its RMS
*-* for each bin in X. Profile histograms are in many cases an elegant
*-* replacement of two-dimensional histograms : the inter-relation of two
*-* measured quantities X and Y can always be visualized by a two-dimensional
*-* histogram or scatter-plot; If Y is an unknown (but single-valued)
*-* approximate function of X, this function is displayed by a profile
*-* histogram with much better precision than by a scatter-plot.
/*-*
*-*- All histogram classes are derived from the base class TH1
*-*
*-* TH1
*-* ^
*-* |
*-* |
*-* |
*-* -----------------------------------------------------
*-* | | | | | |
*-* | | TH1C TH1S TH1F TH1D
*-* | | |
*-* | | |
*-* | TH2 TProfile
*-* | |
*-* | |
*-* | -----------------------------
*-* | | | | |
*-* | TH2C TH2S TH2F TH2D
*-* | |
*-* TH3 |
*-* | TProfile2D
*-* |
*-* ------------------------------
*-* | | | |
*-* TH3C TH3S TH3F TH3D
*-*
*-* The TH*C classes also inherit from the array class TArrayC.
*-* The TH*S classes also inherit from the array class TArrayS.
*-* The TH*F classes also inherit from the array class TArrayF.
*-* The TH*D classes also inherit from the array class TArrayD.
*-*
*-* Creating histograms
*-* ===================
*-* Histograms are created by invoking one of the constructors, eg
*-* TH1F *h1 = new TH1F("h1","h1 title",100,0,4.4);
*-* TH2F *h2 = new TH2F("h2","h2 title",40,0,4,30,-3,3);
*-* histograms may also be created by:
*-* - calling the Clone function, see below
*-* - making a projection from a 2-D or 3-D histogram, see below
*-* - reading an histogram from a file
*-* When an histogram is created, a reference to it is automatically added
*-* to the list of in-memory objects for the current file or directory.
*-* This default behaviour can be changed by:
*-* h->SetDirectory(0); // for the current histogram h
*-* TH1::AddDirectory(kFALSE); // sets a global switch disabling the reference
*-* When the histogram is deleted, the reference to it is removed from
*-* the list of objects in memory.
*-* When a file is closed, all histograms in memory associated with this file
*-* are automatically deleted.
*-*
*-* Fix or variable bin size
*-* ========================
*-*
*-* All histogram types support either fix or variable bin sizes.
*-* 2-D histograms may have fix size bins along X and variable size bins
*-* along Y or vice-versa. The functions to fill, manipulate, draw or access
*-* histograms are identical in both cases.
*-* Each histogram always contains 3 objects TAxis: fXaxis, fYaxis and fZaxis
*-* To access the axis parameters, do:
*-* TAxis *xaxis = h->GetXaxis(); etc.
*-* Double_t binCenter = xaxis->GetBinCenter(bin), etc.
*-* See class TAxis for a description of all the access functions.
*-* The axis range is always stored internally in double precision.
*-*
*-* Convention for numbering bins
*-* =============================
*-* For all histogram types: nbins, xlow, xup
*-* bin = 0; underflow bin
*-* bin = 1; first bin with low-edge xlow INCLUDED
*-* bin = nbins; last bin with upper-edge xup EXCLUDED
*-* bin = nbins+1; overflow bin
*-* In case of 2-D or 3-D histograms, a "global bin" number is defined.
*-* For example, assuming a 3-D histogram with binx,biny,binz, the function
*-* Int_t bin = h->GetBin(binx,biny,binz);
*-* returns a global/linearized bin number. This
*-* to access the bin information independently of the dimension.
*-*
*-* Filling histograms
*-* ==================
*-* An histogram is typically filled with statements like:
*-* h1->Fill(x);
*-* h1->Fill(x,w); //fill with weight
*-* h2->Fill(x,y)
*-* h2->Fill(x,y,w)
*-* h3->Fill(x,y,z)
*-* h3->Fill(x,y,z,w)
*-* The Fill functions compute the bin number corresponding to the given
*-* x,y or z argument and increment this bin by the given weight.
*-* The Fill functions return the bin number for 1-D histograms or global
*-* bin number for 2-D and 3-D histograms.
*-* If TH1::Sumw2 has been called before filling, the sum of squares of
*-* weights is also stored.
*-* One can also increment directly a bin number via TH1::AddBinContent
*-* or replace the existing content via TH1::SetBinContent.
*-* To access the bin content of a given bin, do:
*-* Double_t binContent = h->GetBinContent(bin);
*-*
*-* By default, the bin number is computed using the current axis ranges.
*-* If the automatic binning option has been set via
*-* h->SetBit(TH1::kCanRebin);
*-* then, the Fill Function will automatically extend the axis range to
*-* accomodate the new value specified in the Fill argument. The method
*-* used is to double the bin size until the new value fits in the range,
*-* merging bins two by two. This automatic binning options is extensively
*-* used by the TTree::Draw function when histogramming Tree variables
*-* with an unknown range.
*-* This automatic binning option is supported for 1-d, 2-D and 3-D histograms.
*-*
*-* During filling, some statistics parameters are incremented to compute
*-* the mean value and Root Mean Square with the maximum precision.
*-*
*-* In case of histograms of type TH1C, TH1S, TH2C, TH2S, TH3C, TH3S
*-* a check is made that the bin contents do not exceed the maximum positive
*-* capacity (127 or 65535). Histograms of all types may have positive
*-* or/and negative bin contents.
*-*
*-* Rebinning
*-* =========
*-* At any time, an histogram can be rebinned via TH1::Rebin. This function
*-* returns a new histogram with the rebinned contents.
*-* If bin errors were stored, they are recomputed during the rebinning.
*-*
*-* Associated errors
*-* =================
*-* By default, for each bin, the sum of weights is computed at fill time.
*-* One can also call TH1::Sumw2 to force the storage and computation
*-* of the sum of the square of weights per bin.
*-* If Sumw2 has been called, the error per bin is computed as the
*-* sqrt(sum of squares of weights), otherwise the error is set equal
*-* to the sqrt(bin content).
*-* To return the error for a given bin number, do:
*-* Double_t error = h->GetBinError(bin);
*-*
*-* Associated functions
*-* ====================
*-* One or more object (typically a TF1*) can be added to the list
*-* of functions (fFunctions) associated to each histogram.
*-* When TH1::Fit is invoked, the fitted function is added to this list.
*-* Given an histogram h, one can retrieve an associated function
*-* with: TF1 *myfunc = h->GetFunction("myfunc");
*-*
*-* Operations on histograms
*-* ========================
*-*
*-* Many types of operations are supported on histograms or between histograms
*-* - Addition of an histogram to the current histogram
*-* - Additions of two histograms with coefficients and storage into the current
*-* histogram
*-* - Multiplications and Divisions are supported in the same way as additions.
*-* - The Add, Divide and Multiply functions also exist to add,divide or multiply
*-* an histogram by a function.
*-* If an histogram has associated error bars (TH1::Sumw2 has been called),
*-* the resulting error bars are also computed assuming independent histograms.
*-* In case of divisions, Binomial errors are also supported.
*-*
*-*
*-* Fitting histograms
*-* ==================
*-*
*-* Histograms (1-D,2-D,3-D and Profiles) can be fitted with a user
*-* specified function via TH1::Fit. When an histogram is fitted, the
*-* resulting function with its parameters is added to the list of functions
*-* of this histogram. If the histogram is made persistent, the list of
*-* associated functions is also persistent. Given a pointer (see above)
*-* to an associated function myfunc, one can retrieve the function/fit
*-* parameters with calls such as:
*-* Double_t chi2 = myfunc->GetChisquare();
*-* Double_t par0 = myfunc->GetParameter(0); //value of 1st parameter
*-* Double_t err0 = myfunc->GetParError(0); //error on first parameter
*-*
*-*
*-* Projections of histograms
*-* ========================
*-* One can:
*-* - make a 1-D projection of a 2-D histogram or Profile
*-* see functions TH2::ProjectionX,Y, TH2::ProfileX,Y, TProfile::ProjectionX
*-* - make a 1-D, 2-D or profile out of a 3-D histogram
*-* see functions TH3::ProjectionZ, TH3::Project3D.
*-*
*-* One can fit these projections via:
*-* TH2::FitSlicesX,Y, TH3::FitSlicesZ.
*-*
*-* Random Numbers and histograms
*-* =============================
*-* TH1::FillRandom can be used to randomly fill an histogram using
*-* the contents of an existing TF1 function or another
*-* TH1 histogram (for all dimensions).
*-* For example the following two statements create and fill an histogram
*-* 10000 times with a default gaussian distribution of mean 0 and sigma 1:
*-* TH1F h1("h1","histo from a gaussian",100,-3,3);
*-* h1.FillRandom("gaus",10000);
*-* TH1::GetRandom can be used to return a random number distributed
*-* according the contents of an histogram.
*-*
*-* Making a copy of an histogram
*-* =============================
*-* Like for any other Root object derived from TObject, one can use
*-* the Clone function. This makes an identical copy of the original histogram
*-* including all associated errors and functions, eg:
*-* TH1F *hnew = (TH1F*)h->Clone();
*-* hnew->SetName("hnew"); //recommended, otherwise you get 2 histograms
*-* //with the same name
*-*
*-* Normalizing histograms
*-* ======================
*-* One can scale an histogram such that the bins integral is equal to
*-* to the normalization parameter via TH1::Scale(Double_t norm);
*-*
*-* Drawing histograms
*-* ==================
*-* Histograms are drawn via the THistPainter class. Each histogram has
*-* a pointer to its own painter (to be usable in a multithreaded program).
*-* Many drawing options are supported.
*-* See THistPainter::Paint for more details.
*-* The same histogram can be drawn with different options in different pads.
*-* When an histogram drawn in a pad is deleted, the histogram is
*-* automatically removed from the pad or pads where it was drawn.
*-* If an histogram is drawn in a pad, then filled again, the new status
*-* of the histogram will be automatically shown in the pad next time
*-* the pad is updated. One does not need to redraw the histogram.
*-* To draw the current version of an histogram in a pad, one can use
*-* h->DrawCopy();
*-* This makes a clone (see Clone below) of the histogram. Once the clone
*-* is drawn, the original histogram may be modified or deleted without
*-* affecting the aspect of the clone.
*-*
*-* One can use TH1::SetMaximum and TH1::SetMinimum to force a particular
*-* value for the maximum or the minimum scale on the plot.
*-*
*-* TH1::UseCurrentStyle can be used to change all histogram graphics
*-* attributes to correspond to the current selected style.
*-* This function must be called for each histogram.
*-* In case one reads and draws many histograms from a file, one can force
*-* the histograms to inherit automatically the current graphics style
*-* by calling before gROOT->ForceStyle();
*-*
*-*
*-* Setting Drawing histogram contour levels (2-D hists only)
*-* =========================================================
*-* By default contours are automatically generated at equidistant
*-* intervals. A default value of 20 levels is used. This can be modified
*-* via TH1::SetContour or TH1::SetContourLevel.
*-* the contours level info is used by the drawing options "cont", "surf",
*-* and "lego".
*-*
*-* Setting histogram graphics attributes
*-* =====================================
*-* The histogram classes inherit from the attribute classes:
*-* TAttLine, TAttFill, TAttMarker and TAttText.
*-* See the member functions of these classes for the list of options.
*-*
*-* Giving titles to the X, Y and Z axis
*-* =================================
*-* h->GetXaxis()->SetTitle("X axis title");
*-* h->GetYaxis()->SetTitle("Y axis title");
*-* The histogram title and the axis titles can be any TLatex string.
*-* The titles are part of the persistent histogram.
*-*
*-* Saving/Reading histograms to/from a Root file
*-* ================================
*-* The following statements create a Root file and store an histogram
*-* on the file. Because TH1 derives from TNamed, the key identifier on
*-* the file is the histogram name:
*-* TFile f("histos.root","new");
*-* TH1F h1("hgaus","histo from a gaussian",100,-3,3);
*-* h1.FillRandom("gaus",10000);
*-* h1->Write();
*-* To Read this histogram in another Root session, do:
*-* TFile f("histos.root");
*-* TH1F *h = (TH1F*)f.Get("hgaus");
*-* One can save all histograms in memory to the file by:
*-* file->Write();
*-*
*-* Miscelaneous operations
*-* =======================
*-*
*-* TH1::KolmogorovTest: Statistical test of compatibility in shape between
*-* two histograms.
*-* TH1::Smooth smooths the bin contents of a 1-d histogram
*-* TH1::Integral returns the integral of bin contents in a given bin range
*-* TH1::GetMean(int axis) returns the mean value along axis
*-* TH1::GetRMS(int axis) returns the Root Mean Square along axis
*-* TH1::GetEntries returns the number of entries
*-* TH1::Reset() resets the bin contents and errors of an histogram.
*-*
/*
*/
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
TH1(): TNamed(), TAttLine(), TAttFill(), TAttMarker()
*-*-*-*-*-*-*-*-*-*-*Histogram default constructor*-*-*-*-*-*-*-*-*-*-*-*-*
*-* =============================
~TH1()
*-*-*-*-*-*-*-*-*-*-*Histogram default destructor*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-* ============================
TH1(const char *name,const char *title,Int_t nbins,Axis_t xlow,Axis_t xup)
:TNamed(name,title), TAttLine(), TAttFill(), TAttMarker()
*-*-*-*-*-*-*-*-*Normal constructor for fix bin size histograms*-*-*-*-*-*-*
*-* ==============================================
Creates the main histogram structure:
name : name of histogram (avoid blanks)
title : histogram title
nbins : number of bins
xlow : low edge of first bin
xup : upper edge of last bin (not included in last bin)
When an histogram is created, it is automatically added to the list
of special objects in the current directory.
To find the pointer to this histogram in the current directory
by its name, do:
TH1F *h1 = (TH1F*)gDirectory->FindObject(name);
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
TH1(const char *name,const char *title,Int_t nbins,Float_t *xbins)
:TNamed(name,title), TAttLine(), TAttFill(), TAttMarker()
*-*-*-*-*-*-*Normal constructor for variable bin size histograms*-*-*-*-*-*-*
*-* ===================================================
Creates the main histogram structure:
name : name of histogram (avoid blanks)
title : histogram title
nbins : number of bins
xbins : array of low-edges for each bin
This is an array of size nbins+1
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
TH1(const char *name,const char *title,Int_t nbins,Double_t *xbins)
:TNamed(name,title), TAttLine(), TAttFill(), TAttMarker()
*-*-*-*-*-*-*Normal constructor for variable bin size histograms*-*-*-*-*-*-*
*-* ===================================================
Creates the main histogram structure:
name : name of histogram (avoid blanks)
title : histogram title
nbins : number of bins
xbins : array of low-edges for each bin
This is an array of size nbins+1
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
void Browse(TBrowser *)
void Build()
*-*-*-*-*-*-*-*-*-*Creates histogram basic data structure*-*-*-*-*-*-*-*-*-*
*-* ======================================
void Add(TF1 *f1, Double_t c1)
Performs the operation: this = this + c1*f1
if errors are defined (see TH1::Sumw2), errors are also recalculated.
void Add(TH1 *h1, Double_t c1)
Performs the operation: this = this + c1*h1
if errors are defined (see TH1::Sumw2), errors are also recalculated.
Note that if h1 has Sumw2 set, Sumw2 is automatically called for this
if not already set.
void Add(TH1 *h1, TH1 *h2, Double_t c1, Double_t c2)
*-*-*-*-*Replace contents of this histogram by the addition of h1 and h2*-*-*
*-* ===============================================================
this = c1*h1 + c2*h2
if errors are defined (see TH1::Sumw2), errors are also recalculated
Note that if h1 or h2 have Sumw2 set, Sumw2 is automatically called for this
if not already set.
void AddBinContent(Int_t)
*-*-*-*-*-*-*-*-*-*Increment bin content by 1*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-* ==========================
void AddBinContent(Int_t, Stat_t)
*-*-*-*-*-*-*-*-*-*Increment bin content by a weight w*-*-*-*-*-*-*-*-*-*-*
*-* ===================================
void AddDirectory(Bool_t add)
Sets the flag controlling the automatic add of histograms in memory
By default (fAddDirectory = kTRUE), histograms are automatically added
to the list of objects in memory.
Note that one histogram can be removed from its support directory
by calling h->SetDirectory(0) or h->SetDirectory(dir) to add it
to the list of objects in the directory dir.
NOTE that this is a static function. To call it, use;
TH1::AddDirectory
Double_t ComputeIntegral()
Compute integral (cumulative sum of bins)
The result stored in fIntegral is used by the GetRandom functions.
This function is automatically called by GetRandom when the fIntegral
array does not exist or when the number of entries in the histogram
has changed since the previous call to GetRandom.
The resulting integral is normalized to 1
void Copy(TObject &obj)
*-*-*-*-*-*-*Copy this histogram structure to newth1*-*-*-*-*-*-*-*-*-*-*-*
*-* =======================================
Note that this function does not copy the list of associated functions.
Use TObJect::Clone to make a full copy of an histogram.
Int_t DistancetoPrimitive(Int_t px, Int_t py)
*-*-*-*-*-*-*-*-*-*-*Compute distance from point px,py to a line*-*-*-*-*-*
*-* ===========================================
*-* Compute the closest distance of approach from point px,py to elements
*-* of an histogram.
*-* The distance is computed in pixels units.
*-*
*-* Algorithm:
*-* Currently, this simple model computes the distance from the mouse
*-* to the histogram contour only.
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
void Divide(TF1 *f1, Double_t c1)
Performs the operation: this = this/(c1*f1)
if errors are defined (see TH1::Sumw2), errors are also recalculated.
void Divide(TH1 *h1)
*-*-*-*-*-*-*-*-*-*-*Divide this histogram by h1*-*-*-*-*-*-*-*-*-*-*-*-*
*-* ===========================
this = this/h1
if errors are defined (see TH1::Sumw2), errors are also recalculated.
Note that if h1 has Sumw2 set, Sumw2 is automatically called for this
if not already set.
The resulting errors are calculated assuming uncorrelated histograms.
See the other TH1::Divide that gives the possibility to optionaly
compute Binomial errors.
void Divide(TH1 *h1, TH1 *h2, Double_t c1, Double_t c2, Option_t *option)
*-*-*-*-*Replace contents of this histogram by the division of h1 by h2*-*-*
*-* ==============================================================
this = c1*h1/(c2*h2)
if errors are defined (see TH1::Sumw2), errors are also recalculated
Note that if h1 or h2 have Sumw2 set, Sumw2 is automatically called for this
if not already set.
The resulting errors are calculated assuming uncorrelated histograms.
However, if option ="B" is specified, Binomial errors are computed.
void Draw(Option_t *option)
*-*-*-*-*-*-*-*-*-*-*Draw this histogram with options*-*-*-*-*-*-*-*-*-*-*-*
*-* ================================
*-*
*-* Histograms are drawn via the THistPainter class. Each histogram has
*-* a pointer to its own painter (to be usable in a multithreaded program).
*-* The same histogram can be drawn with different options in different pads.
*-* When an histogram drawn in a pad is deleted, the histogram is
*-* automatically removed from the pad or pads where it was drawn.
*-* If an histogram is drawn in a pad, then filled again, the new status
*-* of the histogram will be automatically shown in the pad next time
*-* the pad is updated. One does not need to redraw the histogram.
*-* To draw the current version of an histogram in a pad, one can use
*-* h->DrawCopy();
*-* This makes a clone of the histogram. Once the clone is drawn, the original
*-* histogram may be modified or deleted without affecting the aspect of the
*-* clone.
*-* By default, TH1::Draw clears the current pad.
*-*
*-* One can use TH1::SetMaximum and TH1::SetMinimum to force a particular
*-* value for the maximum or the minimum scale on the plot.
*-*
*-* TH1::UseCurrentStyle can be used to change all histogram graphics
*-* attributes to correspond to the current selected style.
*-* This function must be called for each histogram.
*-* In case one reads and draws many histograms from a file, one can force
*-* the histograms to inherit automatically the current graphics style
*-* by calling before gROOT->ForceStyle();
*-*
*-* See THistPainter::Paint for a description of all the drawing options
*-* =======================
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
TH1* DrawCopy(Option_t *)
*-*-*-*-*-*-*Copy this histogram and Draw in the current pad*-*-*-*-*-*-*-*
*-* ===============================================
*-*
*-* Once the histogram is drawn into the pad, any further modification
*-* using graphics input will be made on the copy of the histogram,
*-* and not to the original object.
*-*
*-* See Draw for the list of options
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
void DrawPanel()
*-*-*-*-*-*-*Display a panel with all histogram drawing options*-*-*-*-*-*
*-* ==================================================
*-*
*-* See class TDrawPanelHist for example
void Eval(TF1 *f1, Option_t *option)
*-*-*-*-*Evaluate function f1 at the center of bins of this histogram-*-*-*-*
*-* ============================================================
*-*
*-* If option "R" is specified, the function is evaluated only
*-* for the bins included in the function range.
*-* If option "A" is specified, the value of the function is added to the
*-* existing bin contents
*-* If option "S" is specified, the value of the function is used to
*-* generate an integer value, distributed according to the Poisson
*-* distribution, with f1 as the mean.
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
*-*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*
*-* =========================================
*-* This member function is called when a histogram is clicked with the locator
*-*
*-* If Left button clicked on the bin top value, then the content of this bin
*-* is modified according to the new position of the mouse when it is released.
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Int_t Fill(Axis_t x)
*-*-*-*-*-*-*-*-*-*Increment bin with abscissa X by 1*-*-*-*-*-*-*-*-*-*-*
*-* ==================================
*-*
*-* if x is less than the low-edge of the first bin, the Underflow bin is incremented
*-* if x is greater than the upper edge of last bin, the Overflow bin 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 1 in the bin corresponding to x.
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Int_t Fill(Axis_t x, Stat_t w)
*-*-*-*-*-*-*-*Increment bin with abscissa X with a weight w*-*-*-*-*-*-*-*
*-* =============================================
*-*
*-* if x is less than the low-edge of the first bin, the Underflow bin is incremented
*-* if x is greater than the upper edge of last bin, the Overflow bin 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 bin corresponding to x.
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
void FillN(Int_t ntimes, Axis_t *x, Double_t *w, Int_t stride)
*-*-*-*-*-*-*-*Fill this histogram with an array x and weights w*-*-*-*-*
*-* =================================================
*-*
*-* ntimes: number of entries in arrays x and w (array size must be ntimes*stride)
*-* x: array of values to be histogrammed
*-* w: array of weighs
*-* stride: step size through arrays x 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 bin corresponding to x[i].
*-* if w is NULL each entry is assumed a weight=1
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
void FillRandom(const char *fname, Int_t ntimes)
*-*-*-*-*-*-*Fill histogram following distribution in function fname*-*-*-*
*-* =======================================================
*-*
*-* The distribution contained in the function fname (TF1) 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 TF1::GetRandom 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
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-*-*-*
Int_t FindBin(Axis_t x, Axis_t y, Axis_t z)
*-*-*-*-*-*Return Global bin number corresponding to x,y,z*-*-*-*-*-*-*
*-* ===============================================
*-*
*-* 2-D and 3-D histograms are represented with a one dimensional
*-* structure.
*-* This has the advantage that all existing functions, such as
*-* GetBinContent, GetBinError, GetBinFunction work for all dimensions.
*-* See also TH1::GetBin
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
void Fit(const char *fname ,Option_t *option ,Option_t *goption, Axis_t xxmin, Axis_t xxmax)
*-*-*-*-*-*-*-*-*-*-*Fit histogram with function fname*-*-*-*-*-*-*-*-*-*-*
*-* =================================
*-* fname is the name of an already predefined function created by TF1 or TF2
*-* Predefined functions such as gaus, expo and poln are automatically
*-* created by ROOT.
*-*
This function finds a pointer to the TF1 object with name fname
and calls TH1::Fit(TF1 *f1,...)
void Fit(TF1 *f1 ,Option_t *option ,Option_t *goption, Axis_t xxmin, Axis_t xxmax)
*-*-*-*-*-*-*-*-*-*-*Fit histogram with function f1*-*-*-*-*-*-*-*-*-*-*
*-* ==============================
*-*
*-* Fit this histogram with function f1.
*-*
*-* The list of fit options is given in parameter option.
*-* option = "W" Set all errors to 1
*-* = "I" Use integral of function in bin instead of value at bin center
*-* = "L" Use Loglikelihood method (default is chisquare method)
*-* = "U" Use a User specified fitting algorithm (via SetFCN)
*-* = "Q" Quiet mode (minimum printing)
*-* = "V" Verbose mode (default is between Q and V)
*-* = "E" Perform better Errors estimation using Minos technique
*-* = "M" More. Improve fit results
*-* = "R" Use the Range specified in the function range
*-* = "N" Do not store the graphics function, do not draw
*-* = "0" Do not plot the result of the fit. By default the fitted function
*-* is drawn unless the option"N" above is specified.
*-* = "+" Add this new fitted function to the list of fitted functions
*-* (by default, any previous function is deleted)
*-*
*-* When the fit is drawn (by default), the parameter goption may be used
*-* to specify a list of graphics options. See TH1::Draw for a complete
*-* list of these options.
*-*
*-* In order to use the Range option, one must first create a function
*-* with the expression to be fitted. For example, if your histogram
*-* has a defined range between -4 and 4 and you want to fit a gaussian
*-* only in the interval 1 to 3, you can do:
*-* TF1 *f1 = new TF1("f1","gaus",1,3);
*-* histo->Fit("f1","R");
*-*
*-* You can specify boundary limits for some or all parameters via
*-* f1->SetParLimits(p_number, parmin, parmax);
*-* if parmin>=parmax, the parameter is fixed
*-* Note that you are not forced to fix the limits for all parameters.
*-* For example, if you fit a function with 6 parameters, you can do:
*-* func->SetParameters(0,3.1,1.e-6,0.1,-8,100);
*-* func->SetParLimits(4,-10,-4);
*-* func->SetParLimits(5, 1,1);
*-* With this setup, parameters 0->3 can vary freely
*-* Parameter 4 has boundaries [-10,-4] with initial value -8
*-* Parameter 5 is fixed to 100.
*-*
*-* Note that option "I" gives better results but is slower.
*-*
*-*
*-* Changing the fitting function
*-* =============================
*-* By default the fitting function H1FitChisquare is used.
*-* To specify a User defined fitting function, specify option "U" and
*-* call the following functions:
*-* TVirtualFitter::Fitter(myhist)->SetFCN(MyFittingFunction)
*-* where MyFittingFunction is of type:
*-* extern void MyFittingFunction(Int_t &npar, Double_t *gin, Double_t &f, Double_t *u, Int_t flag);
*-*
*-* Associated functions
*-* ====================
*-* One or more object (typically a TF1*) can be added to the list
*-* of functions (fFunctions) associated to each histogram.
*-* When TH1::Fit is invoked, the fitted function is added to this list.
*-* Given an histogram h, one can retrieve an associated function
*-* with: TF1 *myfunc = h->GetFunction("myfunc");
*-*
*-* Access to the fit results
*-* =========================
*-* If the histogram is made persistent, the list of
*-* associated functions is also persistent. Given a pointer (see above)
*-* to an associated function myfunc, one can retrieve the function/fit
*-* parameters with calls such as:
*-* Double_t chi2 = myfunc->GetChisquare();
*-* Double_t par0 = myfunc->GetParameter(0); //value of 1st parameter
*-* Double_t err0 = myfunc->GetParError(0); //error on first parameter
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
void FitPanel()
*-*-*-*-*-*-*Display a panel with all histogram fit options*-*-*-*-*-*
*-* ==============================================
*-*
*-* See class TFitPanel for example
char* GetObjectInfo(Int_t px, Int_t py) const
Redefines TObject::GetObjectInfo.
Displays the histogram info (bin number, contents, integral up to bin
corresponding to cursor position px,py
Int_t FitOptionsMake(Option_t *choptin)
*-*-*-*-*-*-*-*-*Decode string choptin and fill Foption structure*-*-*-*-*-*
*-* ================================================
Int_t GetBin(Int_t binx, Int_t biny, Int_t binz) const
*-*-*-*-*-*Return Global bin number corresponding to binx,y,z*-*-*-*-*-*-*
*-* ==================================================
*-*
*-* 2-D and 3-D histograms are represented with a one dimensional
*-* structure.
*-* This has the advantage that all existing functions, such as
*-* GetBinContent, GetBinError, GetBinFunction work for all dimensions.
*-*
*-* In case of a TH1x, returns binx directly.
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Axis_t GetRandom()
return a random number distributed according the histogram bin contents.
This function checks if the bins integral exists. If not, the integral
is evaluated, normalized to one.
The integral is automatically recomputed if the number of entries
is not the same then when the integral was computed.
NB Only valid for 1-d histograms. Use GetRandom2 or 3 otherwise.
Stat_t GetBinContent(Int_t) const
*-*-*-*-*-*-*Return content of global bin number bin*-*-*-*-*-*-*-*-*-*-*-*
*-* =======================================
void Multiply(TF1 *f1, Double_t c1)
Performs the operation: this = this*c1*f1
if errors are defined (see TH1::Sumw2), errors are also recalculated.
void Multiply(TH1 *h1)
*-*-*-*-*-*-*-*-*-*-*Multiply this histogram by h1*-*-*-*-*-*-*-*-*-*-*-*-*
*-* =============================
this = this*h1
If errors of this are available (TH1::Sumw2), errors are recalculated.
Note that if h1 has Sumw2 set, Sumw2 is automatically called for this
if not already set.
void Multiply(TH1 *h1, TH1 *h2, Double_t c1, Double_t c2, Option_t *option)
*-*-*-*-*Replace contents of this histogram by multiplication of h1 by h2*-*
*-* ================================================================
this = (c1*h1)*(c2*h2)
If errors of this are available (TH1::Sumw2), errors are recalculated.
Note that if h1 or h2 have Sumw2 set, Sumw2 is automatically called for this
if not already set.
void Paint(Option_t *option)
*-*-*-*-*-*-*-*-*Control routine to paint any kind of histograms*-*-*-*-*-*-*
*-* ===============================================
This function is automatically called by TCanvas::Update.
(see TH1::Draw for the list of options)
TH1* Rebin(Int_t ngroup, const char*newname)
*-*-*-*-*Rebin this histogram grouping ngroup bins together*-*-*-*-*-*-*-*-*
*-* ==================================================
if newname is not blank a new temporary histogram hnew is created.
else the current histogram is modified (default)
The parameter ngroup indicates how many bins of this have to me merged
into one bin of hnew
If the original histogram has errors stored (via Sumw2), the resulting
histograms has new errors correctly calculated.
examples: if h1 is an existing TH1F histogram with 100 bins
h1->Rebin(); //merges two bins in one in h1: previous contents of h1 are lost
h1->Rebin(5); //merges five bins in one in h1
TH1F *hnew = h1->Rebin(5,"hnew"); // creates a new histogram hnew
//merging 5 bins of h1 in one bin
NOTE1: This function is currently implemented only for 1-D histograms
NOTE2: If ngroup is not an exact divider of the number of bins,
the top limit of the rebinned histogram is changed
to the upper edge of the bin=newbins*ngroup and the corresponding
bins are added to the overflow bin.
Statistics will be recomputed from the new bin contents.
void RebinAxis(Axis_t x, const char *ax)
Histogram is resized along ax such that x is in the axis range.
The new axis limits are recomputed by doubling iteratively
the current axis range until the specified value x is within the limits.
The algorithm makes a copy of the histogram, then loops on all bins
of the old histogram to fill the rebinned histogram.
Takes into account errors (Sumw2) if any.
The algorithm works for 1-d, 2-d and 3-d histograms.
The bit kCanRebin must be set before invoking this function.
Ex: h->SetBit(TH1::kCanRebin);
void Scale(Double_t c1)
*-*-*-*-*Multiply this histogram by a constant c1*-*-*-*-*-*-*-*-*
*-* ========================================
this = c1*this
Note that both contents and errors(if any) are scaled.
This function uses the services of TH1::Add
void SmoothArray(Int_t NN, Double_t *XX, Int_t ntimes)
smooth array XX, translation of Hbook routine hsmoof.F
based on algorithm 353QH twice presented by J. Friedman
in Proc.of the 1974 CERN School of Computing, Norway, 11-24 August, 1974.
Double_t SmoothMedian(Int_t n, Double_t *a)
return the median of a vector a in monotonic order with length n
where median is a number which divides sequence of n numbers
into 2 halves. When n is odd, the median is kth element k = (n + 1) / 2.
when n is even the median is a mean of the elements k = n/2 and k = n/2 + 1.
void Smooth(Int_t ntimes)
Smooth bin contents of this histogram.
bin contents are replaced by their smooth values.
Errors (if any) are not modified.
algorithm can only be applied to 1-d histograms
void Streamer(TBuffer &b)
*-*-*-*-*-*-*-*-*Stream a class object*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*-* =====================
void Print(Option_t *option) const
*-*-*-*-*-*-*Print some global quantities for this histogram*-*-*-*-*-*-*-*
*-* ===============================================
If option "range" is given, bin contents and errors are also printed
for all bins in the current range (default 1-->nbins)
If option "all" is given, bin contents and errors are also printed
for all bins including under and overflows.
void Reset(Option_t *option)
*-*-*-*-*-*-*-*Reset this histogram: contents, errors, etc*-*-*-*-*-*-*-*
*-* ===========================================
if option "ICE" is specified, resets only Integral, Contents and Errors
void SavePrimitive(ofstream &out, Option_t *option)
Save primitive as a C++ statement(s) on output stream out
void UseCurrentStyle()
*-*-*-*-*-*Replace current attributes by current style*-*-*-*-*
*-* ===========================================
Stat_t GetMean(Int_t axis) const
*-*-*-*-*-*-*-*Return mean value of this histogram along the X axis*-*-*-*-*
*-* ====================================================
Stat_t GetRMS(Int_t axis) const
*-*-*-*-*-*-*-*Return the Root Mean Square value of this 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
If no axis-subrange is specified (via TAxis::SetRange), the array stats
is simply a copy of the statistics quantities computed at filling time.
If a sub-range is specified, the function recomputes these quantities
from the bin contents in the current axis range.
void PutStats(Stat_t *stats)
Replace current statistics with the values in array stats
Stat_t GetSumOfWeights() const
*-*-*-*-*-*-*-*Return the sum of weights excluding under/overflows*-*-*-*-*
*-* ===================================================
Stat_t Integral()
Return integral of bin contents. Only bins in the bins range are considered.
Stat_t Integral(Int_t binx1, Int_t binx2)
Return integral of bin contents between binx1 and binx2 for a 1-D histogram
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 (also for 2-dim)
"O" include Overflows (also valid for 2-dim)
"N" include comparison of normalizations
"D" Put out a line of "Debug" printout
"M" Return the Maximum Kolmogorov distance instead of prob
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
void SetContent(Stat_t *content)
*-*-*-*-*-*-*-*Replace bin contents by the contents of array content*-*-*-*
*-* =====================================================
Int_t GetContour(Double_t *levels)
Return contour values into array levels if pointer levels is non zero
The function returns the number of contour levels.
see GetContourLevel to return one contour only
Double_t GetContourLevel(Int_t level) const
Return value of contour number level
see GetContour to return the array of all contour levels
void SetContour(Int_t nlevels, Double_t *levels)
*-*-*-*-*-*-*-*Set the number and values of contour levels*-*-*-*-*-*-*-*-*
*-* ===========================================
By default the number of contour levels is set to 20.
if argument levels = 0 or issing, equidistant contours are computed
void SetContourLevel(Int_t level, Double_t value)
*-*-*-*-*-*-*-*-*-*-*Set value for one contour level*-*-*-*-*-*-*-*-*-*-*-*
*-* ===============================
Double_t GetMaximum() const
*-*-*-*-*-*-*-*-*-*-*Return maximum value of bins in the range*-*-*-*-*-*
*-* =========================================
Int_t GetMaximumBin() const
*-*-*-*-*-*-*Return location of bin with maximum value in the range*-*
*-* ======================================================
Int_t GetMaximumBin(Int_t &locmax, Int_t &locmay, Int_t &locmaz) const
*-*-*-*-*-*-*Return location of bin with maximum value in the range*-*
*-* ======================================================
Double_t GetMinimum() const
*-*-*-*-*-*-*-*-*-*-*Return minimum value of bins in the range-*-*-*-*-*
*-* =========================================
Int_t GetMinimumBin() const
*-*-*-*-*-*-*Return location of bin with minimum value in the range*-*
*-* ======================================================
Int_t GetMinimumBin(Int_t &locmix, Int_t &locmiy, Int_t &locmiz) const
*-*-*-*-*-*-*Return location of bin with minimum value in the range*-*
*-* ======================================================
void SetBins(Int_t nx, Axis_t xmin, Axis_t xmax)
*-*-*-*-*-*-*-*-*Redefine x axis parameters*-*-*-*-*-*-*-*-*-*-*-*
*-* ===========================
The X axis parameters are modified.
The bins content array is resized
if errors (Sumw2) the errors array is resized
The previous bin contents are lost
To change only the axis limits, see TAxis::SetRange
void SetBins(Int_t nx, Axis_t xmin, Axis_t xmax, Int_t ny, Axis_t ymin, Axis_t ymax)
*-*-*-*-*-*-*-*-*Redefine x and y axis parameters*-*-*-*-*-*-*-*-*-*-*-*
*-* =================================
The X and Y axis parameters are modified.
The bins content array is resized
if errors (Sumw2) the errors array is resized
The previous bin contents are lost
To change only the axis limits, see TAxis::SetRange
void SetBins(Int_t nx, Axis_t xmin, Axis_t xmax, Int_t ny, Axis_t ymin, Axis_t ymax, Int_t nz, Axis_t zmin, Axis_t zmax)
*-*-*-*-*-*-*-*-*Redefine x, y and z axis parameters*-*-*-*-*-*-*-*-*-*-*-*
*-* ====================================
The X, Y and Z axis parameters are modified.
The bins content array is resized
if errors (Sumw2) the errors array is resized
The previous bin contents are lost
To change only the axis limits, see TAxis::SetRange
void SetMaximum(Double_t maximum)
*-*-*-*-*-*-*-*-*Set the maximum value for the Y axis*-*-*-*-*-*-*-*-*-*-*-*
*-* ====================================
By default the maximum value is automatically set to the maximum
bin content plus a margin of 10 per cent.
Use TH1::GetMaximum to find the maximum value of an histogram
Use TH1::GetMaximumBin to find the bin with the maximum value of an histogram
void SetMinimum(Double_t minimum)
*-*-*-*-*-*-*-*-*Set the minimum value for the Y axis*-*-*-*-*-*-*-*-*-*-*-*
*-* ====================================
By default the minimum value is automatically set to zero if all bin contents
are positive or the minimum - 10 per cent otherwise.
Use TH1::GetMinimum to find the minimum value of an histogram
Use TH1::GetMinimumBin to find the bin with the minimum value of an histogram
void SetDirectory(TDirectory *dir)
By default when an histogram is created, it is added to the list
of histogram objects in the current directory in memory.
Remove reference to this histogram from current directory and add
reference to new directory dir. dir can be 0 in which case the
histogram does not belong to any directory.
void SetError(Stat_t *error)
*-*-*-*-*-*-*-*-*Replace bin errors by values in array error*-*-*-*-*-*-*-*-*
*-* ===========================================
void SetName(const char *name)
Change the name of this histogram
void SetObject(const char *name, const char *title)
Change the name and title of this histogram
void SetStats(Bool_t stats)
*-*-*-*-*-*-*-*-*Set statistics option on/off
*-* ============================
By default, the statistics box is drawn.
The paint options can be selected via gStyle->SetOptStats.
This function sets/resets the kNoStats bin in the histogram object.
It has priority over the Style option.
void Sumw2()
*-*-*-*-*Create structure to store sum of squares of weights*-*-*-*-*-*-*-*
*-* ===================================================
*-*
*-* if histogram is already filled, the sum of squares of weights
*-* is filled with the existing bin contents
*-*
*-* The error per bin will be computed as sqrt(sum of squares of weight)
*-* for each bin.
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
TF1* GetFunction(const char *name) const
*-*-*-*-*Return pointer to function with name*-*-*-*-*-*-*-*-*-*-*-*-*
*-* ===================================
Functions such as TH1::Fit store the fitted function in the list of
functions of this histogram.
Stat_t GetBinError(Int_t bin) const
*-*-*-*-*-*-*Return value of error associated to bin number bin*-*-*-*-*
*-* ==================================================
*-*
*-* if the sum of squares of weights has been defined (via Sumw2),
*-* this function returns the sqrt(sum of w2).
*-* otherwise it returns the sqrt(contents) for this bin.
*-*
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Stat_t GetCellContent(Int_t binx, Int_t biny) const
Stat_t GetCellError(Int_t binx, Int_t biny) const
void SetBinError(Int_t bin, Stat_t error)
void SetCellContent(Int_t binx, Int_t biny, Stat_t content)
void SetCellError(Int_t binx, Int_t biny, Stat_t error)
void SetBinContent(Int_t, Stat_t)
Inline Functions
Int_t AxisChoice(Option_t* axis) const
void FillN(Int_t, Axis_t*, Axis_t*, Double_t*, Int_t)
Double_t* GetIntegral()
TList* GetListOfFunctions() const
Int_t GetNdivisions(Option_t* axis = X) const
Color_t GetAxisColor(Option_t* axis = X) const
Color_t GetLabelColor(Option_t* axis = X) const
Style_t GetLabelFont(Option_t* axis = X) const
Float_t GetLabelOffset(Option_t* axis = X) const
Float_t GetLabelSize(Option_t* axis = X) const
Float_t GetTitleOffset(Option_t* axis = X) const
Float_t GetTitleSize(Option_t* axis = X) const
Float_t GetTickLength(Option_t* axis = X) const
Float_t GetBarOffset() const
Float_t GetBarWidth() const
Axis_t GetBinCenter(Int_t bin) const
Axis_t GetBinLowEdge(Int_t bin) const
Axis_t GetBinWidth(Int_t bin) const
void GetCenter(Axis_t* center)
TDirectory* GetDirectory() const
Stat_t GetEntries() const
Int_t GetDimension() const
void GetLowEdge(Axis_t* edge)
Double_t GetMaximumStored() const
Double_t GetMinimumStored() const
Int_t GetNbinsX() const
Int_t GetNbinsY() const
Int_t GetNbinsZ() const
Double_t GetNormFactor() const
Option_t* GetOption() const
TVirtualHistPainter* GetPainter() const
Int_t GetSumw2N() const
TAxis* GetXaxis()
TAxis* GetYaxis()
TAxis* GetZaxis()
Stat_t Integral(Int_t, Int_t, Int_t, Int_t)
Stat_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t)
void SetAxisColor(Color_t color = 1, Option_t* axis = X)
void SetAxisRange(Axis_t xmin, Axis_t xmax, Option_t* axis = X)
void SetBarOffset(Float_t offset = 0.25)
void SetBarWidth(Float_t width = 0.5)
void SetBinsLength(Int_t)
void SetEntries(Stat_t n)
void SetLabelColor(Color_t color = 1, Option_t* axis = X)
void SetLabelFont(Style_t font = 62, Option_t* axis = X)
void SetLabelOffset(Float_t offset = 0.005, Option_t* axis = X)
void SetLabelSize(Float_t size = 0.02, Option_t* axis = X)
void SetNdivisions(Int_t n = 510, Option_t* axis = X)
void SetNormFactor(Double_t factor = 1)
void SetOption(Option_t* option = )
void SetTickLength(Float_t length = 0.02, Option_t* axis = X)
void SetTitleOffset(Float_t offset = 1, Option_t* axis = X)
void SetTitleSize(Float_t size = 0.02, Option_t* axis = X)
void SetXTitle(const char* title)
void SetYTitle(const char* title)
void SetZTitle(const char* title)
TClass* Class()
TClass* IsA() const
void ShowMembers(TMemberInspector& insp, char* parent)
void StreamerNVirtual(TBuffer& b)
TH1 TH1(TH1&)
Author: Rene Brun 26/12/94
Last update: root/hist:$Name: $:$Id: TH1.cxx,v 1.32 2000/12/22 12:44:33 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.