THStack


class description - source file - inheritance tree

class THStack : public TNamed


    protected:
void BuildStack() public:
THStack() THStack(const char* name, const char* title) THStack(const THStack& hstack) virtual ~THStack() virtual void Add(TH1* h, Option_t* option) virtual void Browse(TBrowser* b) static TClass* Class() virtual Int_t DistancetoPrimitive(Int_t px, Int_t py) virtual void Draw(Option_t* chopt) TH1* GetHistogram() const TList* GetHists() const virtual Double_t GetMaximum(Option_t* option) virtual Double_t GetMinimum(Option_t* option) TObjArray* GetStack() TAxis* GetXaxis() const TAxis* GetYaxis() const virtual TClass* IsA() const virtual void ls(Option_t* option) const virtual void Modified() virtual void Paint(Option_t* chopt) virtual void Print(Option_t* chopt) const virtual void SavePrimitive(ofstream& out, Option_t* option) virtual void SetMaximum(Double_t maximum = -1111) virtual void SetMinimum(Double_t minimum = -1111) virtual void ShowMembers(TMemberInspector& insp, char* parent) virtual void Streamer(TBuffer& b) void StreamerNVirtual(TBuffer& b)

Data Members


    protected:
TList* fHists Pointer to array of TH1 TObjArray* fStack !Pointer to array of sums of TH1 TH1* fHistogram !Pointer to histogram used for drawing axis Double_t fMaximum Maximum value for plotting along y Double_t fMinimum Minimum value for plotting along y

Class Description

   A THStack is a collection of TH1 (or derived) objects
   Use THStack::Add to add a new histogram to the list.
   The THStack owns the objects in the list.
   By default (if option "nostack" is not specified), histograms will be paint
   stacked on top of each other.
   Example;
      THStack hs("hs","test stacked histograms");
      TH1F *h1 = new TH1F("h1","test hstack",100,-4,4);
      h1->FillRandom("gaus",20000);
      h1->SetFillColor(kRed);
      hs.Add(h1);
      TH1F *h2 = new TH1F("h2","test hstack",100,-4,4);
      h2->FillRandom("gaus",15000);
      h2->SetFillColor(kBlue);
      hs.Add(h2);
      TH1F *h3 = new TH1F("h3","test hstack",100,-4,4);
      h3->FillRandom("gaus",10000);
      h3->SetFillColor(kGreen);
      hs.Add(h3);
      TCanvas c1("c1","stacked hists",10,10,700,900);
      c1.Divide(1,2);
      c1.cd(1);
      hs.Draw();
      c1.cd(2);
      hs->Draw("nostack");

  See a more complex example in $ROOTSYS/tutorials/hstack.C

  Note that picking is supported for all drawing modes.

THStack(): TNamed()
 THStack default constructor

THStack(const char *name, const char *title) : TNamed(name,title)
 constructor with name and title

~THStack()
 THStack destructor

THStack(const THStack &hstack) : TNamed(hstack)
 THStack copy constructor

void Add(TH1 *h1, Option_t *option)
 add a new histogram to the list
 Only 1-d and 2-d histograms currently supported.
 A drawing option may be specified

void Browse(TBrowser *)

void BuildStack()
  build sum of all histograms
  Build a separate list fStack containing the running sum of all histograms

Int_t DistancetoPrimitive(Int_t px, Int_t py)
 Compute distance from point px,py to each graph


void Draw(Option_t *option)
*-*-*-*-*-*-*-*-*-*-*Draw this multihist with its current attributes*-*-*-*-*-*-*
*-*                  ==========================================

   Options to draw histograms  are described in THistPainter::Paint
 By default (if option "nostack" is not specified), histograms will be paint
 stacked on top of each other.

TH1* GetHistogram() const
    Returns a pointer to the histogram used to draw the axis
    Takes into account the two following cases.
       1- option 'A' was specified in THStack::Draw. Return fHistogram
       2- user had called TPad::DrawFrame. return pointer to hframe histogram

Double_t GetMaximum(Option_t *option)
  returns the maximum of all added histograms
  returns the maximum of all histograms if option "nostack".

Double_t GetMinimum(Option_t *option)
  returns the minimum of all added histograms
  returns the minimum of all histograms if option "nostack".

TObjArray* GetStack()
 Return pointer to Stack. Build it if not yet done

TAxis* GetXaxis() const

TAxis* GetYaxis() const
 Get y axis of the graph.

void ls(Option_t *option) const
 List histograms in the stack

void Modified()
 invalidate sum of histograms

void Paint(Option_t *option)
 paint the list of histograms
 By default, histograms are shown stacked.
    -the first histogram is paint
    -then the sum of the first and second, etc

 If option "nostack" is specified, histograms are all paint in the same pad
 as if the option "same" had been specified.

 if option "pads" is specified, the current pad/canvas is subdivided into
 a number of pads equal to the number of histograms and each histogram
 is paint into a separate pad.

 See THistPainter::Paint for a list of valid options.

void Print(Option_t *option) const
 Print the list of histograms

void SavePrimitive(ofstream &out, Option_t *option)
 Save primitive as a C++ statement(s) on output stream out

void SetMaximum(Double_t maximum)

void SetMinimum(Double_t minimum)



Inline Functions


             TList* GetHists() const
            TClass* Class()
            TClass* IsA() const
               void ShowMembers(TMemberInspector& insp, char* parent)
               void Streamer(TBuffer& b)
               void StreamerNVirtual(TBuffer& b)


Author: Rene Brun 10/12/2001
Last update: root/hist:$Name: $:$Id: THStack.cxx,v 1.24 2003/10/08 16:36:14 brun Exp $
Copyright (C) 1995-2001, 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.