class THStack: public TNamed


   A THStack is a collection of TH1 (or derived) objects
   Use THStack::Add to add a new histogram to the list.
   The THStack does not own 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/hist/hstack.C

  Note that picking is supported for all drawing modes.

Function Members (Methods)

public:
THStack()
THStack(const THStack& hstack)
THStack(const char* name, const char* title)
THStack(const TH1* hist, Option_t* axis = "x", const char* name = 0, const char* title = 0, Int_t firstbin = 1, Int_t lastbin = -1, Int_t firstbin2 = 1, Int_t lastbin2 = -1, Option_t* proj_option = "", Option_t* draw_option = "")
virtual~THStack()
voidTObject::AbstractMethod(const char* method) const
virtual voidAdd(TH1* h, Option_t* option = "")
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidBrowse(TBrowser* b)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTNamed::Clear(Option_t* option = "")
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
virtual voidTNamed::Copy(TObject& named) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tDistancetoPrimitive(Int_t px, Int_t py)
virtual voidDraw(Option_t* chopt = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual voidTNamed::FillBuffer(char*& buffer)
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
TH1*GetHistogram() const
TList*GetHists() const
virtual const char*TObject::GetIconName() const
virtual Double_tGetMaximum(Option_t* option = "")
virtual Double_tGetMinimum(Option_t* option = "")
virtual const char*TNamed::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
TObjArray*GetStack()
virtual const char*TNamed::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
TAxis*GetXaxis() const
TAxis*GetYaxis() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTNamed::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTNamed::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual voidModified()
virtual Bool_tTObject::Notify()
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
virtual voidPaint(Option_t* chopt = "")
virtual voidTObject::Pop()
virtual voidPrint(Option_t* chopt = "") const
virtual Int_tTObject::Read(const char* name)
virtual voidRecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidSavePrimitive(ostream& out, Option_t* option = "")
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
virtual voidSetMaximum(Double_t maximum = -1111)MENU
virtual voidSetMinimum(Double_t minimum = -1111)MENU
virtual voidTNamed::SetName(const char* name)MENU
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidTNamed::SetTitle(const char* title = "")MENU
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
virtual Int_tTNamed::Sizeof() const
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
voidBuildStack()
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
voidTObject::MakeZombie()
private:
THStack&operator=(const THStack&)

Data Members

public:
enum TObject::EStatusBits { kCanDelete
kMustCleanup
kObjInCanvas
kIsReferenced
kHasUUID
kCannotPick
kNoContextMenu
kInvalidObject
};
enum TObject::[unnamed] { kIsOnHeap
kNotDeleted
kZombie
kBitMask
kSingleKey
kOverwrite
kWriteDelete
};
protected:
TH1*fHistogramPointer to histogram used for drawing axis
TList*fHistsPointer to array of TH1
Double_tfMaximumMaximum value for plotting along y
Double_tfMinimumMinimum value for plotting along y
TStringTNamed::fNameobject identifier
TObjArray*fStack!Pointer to array of sums of TH1
TStringTNamed::fTitleobject title

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

THStack(const THStack& hstack)
 THStack default constructor
THStack(const char* name, const char* title)
 constructor with name and title
THStack(const TH1* hist, Option_t* axis = "x", const char* name = 0, const char* title = 0, Int_t firstbin = 1, Int_t lastbin = -1, Int_t firstbin2 = 1, Int_t lastbin2 = -1, Option_t* proj_option = "", Option_t* draw_option = "")
 Creates a new THStack from a TH2 or TH3
 It is filled with the 1D histograms from GetProjectionX or GetProjectionY
 for each bin of the histogram. It illustrates the differences and total
 sum along an axis.

 Parameters:
 - hist:  the histogram used for the projections. Can be an object deriving
          from TH2 or TH3.
 - axis:  for TH2: "x" for ProjectionX, "y" for ProjectionY.
          for TH3: see TH3::Project3D.
 - name:  fName is set to name if given, otherwise to histo's name with
          "_stack_<axis>" appended, where <axis> is the value of the
          parameter axis.
 - title: fTitle is set to title if given, otherwise to histo's title
          with ", stack of <axis> projections" appended.
 - firstbin, lastbin:
          for each bin within [firstbin,lastbin] a stack entry is created.
          See TH2::ProjectionX/Y for use overflow bins.
          Defaults to "all bins but under- / overflow"
 - firstbin2, lastbin2:
          Other axis range for TH3::Project3D, defaults to "all bins but
          under- / overflow". Ignored for TH2s
 - proj_option:
          option passed to TH2::ProjectionX/Y and TH3::Project3D (along
          with axis)
 - draw_option:
          option passed to THStack::Add.
~THStack()
 THStack destructor
THStack(const THStack& hstack)
 THStack copy constructor
void Add(TH1* h, 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* b)
 Browse.
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* chopt = "")
-*-*-*-*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()
    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

 IMPORTANT NOTE
  You must call Draw before calling this function. The returned histogram
  depends on the selected Draw options.
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()
 Get x axis of the histogram used to draw the stack.

 IMPORTANT NOTE
  You must call Draw before calling this function. The returned histogram
  depends on the selected Draw options.
TAxis * GetYaxis()
 Get x axis of the histogram used to draw the stack.

 IMPORTANT NOTE
  You must call Draw before calling this function. The returned histogram
  depends on the selected Draw options.
void ls(Option_t* option = "") const
 List histograms in the stack
void Modified()
 invalidate sum of histograms
void Paint(Option_t* chopt = "")
 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* chopt = "") const
 Print the list of histograms
void RecursiveRemove(TObject* obj)
 Recursively remove object from the list of histograms
void SavePrimitive(ostream& out, Option_t* option = "")
 Save primitive as a C++ statement(s) on output stream out
void SetMaximum(Double_t maximum = -1111)
 Set maximum.
void SetMinimum(Double_t minimum = -1111)
 Set minimum.
THStack& operator=(const THStack& )
TList * GetHists()
{ return fHists; }

Author: Rene Brun 10/12/2001
Last change: root/hist:$Id: THStack.h 26239 2008-11-17 14:55:10Z couet $
Last generated: 2008-11-18 08:46
Copyright (C) 1995-2001, Rene Brun and Fons Rademakers. *

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.