Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
THStack Class Reference

The Histogram stack class.

A THStack is a collection of TH1 or TH2 histograms. By using THStack::Draw(), the entire histogram collection is drawn at once according to the specified drawing option.

THStack::Add() allows adding a new histogram to the list. Note that the THStack does not take ownership of the objects in the list.

Stack painting

By default, histograms are shown stacked:

  • the first histogram is painted
  • then the sum of the first and second histograms is painted, and so on

The axis ranges are computed automatically along the X and Y axes to display the complete histogram collection.

Warning: Histogram bins with negative content may produce wrong plots.

Stack's drawing options

The specific stack's drawing options are:

  • NOSTACK If option "nostack" is specified, histograms are all painted in the same pad as if the option "same" had been specified.
  • NOSTACKB If the option "nostackb" is specified histograms are all painted on the same pad next to each other as bar plots.
  • PADS 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 painted into a separate pad.
  • NOCLEAR By default the background of the histograms is erased before drawing the histograms. The option "noclear" avoids this behavior. This is useful when drawing a THStack on top of another plot. If the patterns used to draw the histograms in the stack are transparent, then the plot behind will be visible.

See the THistPainter class for the list of valid histograms' painting options.

Example;

{
auto hs = new THStack("hs","");
auto h1 = new TH1F("h1","test hstack",10,-4,4);
h1->FillRandom("gaus",20000);
hs->Add(h1);
auto h2 = new TH1F("h2","test hstack",10,-4,4);
h2->FillRandom("gaus",15000);
h2->SetFillColor(kBlue);
hs->Add(h2);
auto h3 = new TH1F("h3","test hstack",10,-4,4);
h3->FillRandom("gaus",10000);
h3->SetFillColor(kGreen);
hs->Add(h3);
auto cs = new TCanvas("cs","cs",10,10,700,900);
TText T; T.SetTextFont(42); T.SetTextAlign(21);
cs->Divide(2,2);
cs->cd(1); hs->Draw(); T.DrawTextNDC(.5,.95,"Default drawing option");
cs->cd(2); hs->Draw("nostack"); T.DrawTextNDC(.5,.95,"Option \"nostack\"");
cs->cd(3); hs->Draw("nostackb"); T.DrawTextNDC(.5,.95,"Option \"nostackb\"");
cs->cd(4); hs->Draw("lego1"); T.DrawTextNDC(.5,.95,"Option \"lego1\"");
}
@ kRed
Definition Rtypes.h:66
@ kGreen
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:37
The Canvas class.
Definition TCanvas.h:23
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:621
virtual void FillRandom(const char *fname, Int_t ntimes=5000, TRandom *rng=nullptr)
Fill histogram following distribution in function fname.
Definition TH1.cxx:3519
THStack()
Definition THStack.h:57
Base class for several text objects.
Definition TText.h:22
TH1F * h1
Definition legend1.C:5

A more complex example:

void hstack()
{
auto hs = new THStack("hs","Stacked 1D histograms");
//create three 1-d histograms
auto h1st = new TH1F("h1st","test hstack",100,-4,4);
h1st->FillRandom("gaus",20000);
h1st->SetFillColor(kRed);
h1st->SetMarkerStyle(21);
h1st->SetMarkerColor(kRed);
hs->Add(h1st);
auto h2st = new TH1F("h2st","test hstack",100,-4,4);
h2st->FillRandom("gaus",15000);
h2st->SetFillColor(kBlue);
h2st->SetMarkerStyle(21);
h2st->SetMarkerColor(kBlue);
hs->Add(h2st);
auto h3st = new TH1F("h3st","test hstack",100,-4,4);
h3st->FillRandom("gaus",10000);
h3st->SetFillColor(kGreen);
h3st->SetMarkerStyle(21);
h3st->SetMarkerColor(kGreen);
hs->Add(h3st);
auto cst = new TCanvas("cst","stacked hists",10,10,700,700);
cst->Divide(2,2);
// in top left pad, draw the stack with defaults
cst->cd(1);
hs->Draw();
// in top right pad, draw the stack in non-stack mode
// and errors option
cst->cd(2);
gPad->SetGrid();
hs->Draw("nostack,e1p");
//in bottom left, draw in stack mode with "lego1" option
cst->cd(3);
gPad->SetFrameFillColor(17);
gPad->SetTheta(3.77);
gPad->SetPhi(2.9);
hs->Draw("lego1");
cst->cd(4);
//create two 2-D histograms and draw them in stack mode
gPad->SetFrameFillColor(17);
auto a = new THStack("a","Stacked 2D histograms");
auto f1 = new TF2("f1",
"xygaus + xygaus(5) + xylandau(10)",-4,4,-4,4);
Double_t params1[] = {130,-1.4,1.8,1.5,1, 150,2,0.5,-2,0.5,
3600,-2,0.7,-3,0.3};
f1->SetParameters(params1);
auto h2sta = new TH2F("h2sta","h2sta",20,-4,4,20,-4,4);
h2sta->SetFillColor(38);
h2sta->FillRandom("f1",4000);
auto f2 = new TF2("f2","xygaus + xygaus(5)",-4,4,-4,4);
Double_t params2[] = {100,-1.4,1.9,1.1,2, 80,2,0.7,-2,0.5};
f2->SetParameters(params2);
auto h2stb = new TH2F("h2stb","h2stb",20,-4,4,20,-4,4);
h2stb->SetFillColor(46);
h2stb->FillRandom("f2",3000);
a->Add(h2sta);
a->Add(h2stb);
a->Draw();
}
#define a(i)
Definition RSha256.hxx:99
double Double_t
Definition RtypesCore.h:59
#define gPad
virtual void SetParameters(const Double_t *params)
Definition TF1.h:670
A 2-Dim function with parameters.
Definition TF2.h:29
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:307
TF1 * f1
Definition legend1.C:11

Note that picking is supported for all drawing modes.

Since
ROOT version 6.07/07: Stacks of 2D histograms can also be painted as candle plots:
ROOT version 6.09/02: Stacks of 2D histograms can also be painted as violin plots, combinations of candle and violin plots are possible as well:
void candleplotstack()
{
auto rng = new TRandom();
auto dateBegin = new TDatime(2010,1,1,0,0,0);
auto dateEnd = new TDatime(2011,1,1,0,0,0);
int bins = 1000;
auto h1 = new TH2I("h1","Machine A",6,dateBegin->Convert(),dateEnd->Convert(),bins,0,1000);
auto h2 = new TH2I("h2","Machine B",6,dateBegin->Convert(),dateEnd->Convert(),bins,0,1000);
auto hsum = new TH2I("h4","Sum",6,dateBegin->Convert(),dateEnd->Convert(),bins,0,1000);
float Rand;
for (int i = dateBegin->Convert(); i < dateEnd->Convert(); i+=86400*30) {
for (int j = 0; j < 1000; j++) {
Rand = rng->Gaus(500+sin(i/10000000.)*100,50); h1->Fill(i,Rand); hsum->Fill(i,Rand);
Rand = rng->Gaus(500+sin(i/12000000.)*100,50); h2->Fill(i,Rand); hsum->Fill(i,Rand);
}
}
h2->SetLineColor(kRed);
hsum->SetFillColor(kGreen);
TCanvas *c1 = new TCanvas();
auto hs = new THStack("hs","Machine A+B");
hs->Add(h1);
hs->Add(h2,"candle2");
hs->Add(hsum, "violin1");
hs->Draw("candle3");
hs->GetXaxis()->SetNdivisions(410);
gPad->SetGrid(1,0);
hs->GetXaxis()->SetTimeDisplay(1);
hs->GetXaxis()->SetTimeFormat("%d/%m/%y");
hs->GetXaxis()->SetNdivisions(-6);
hs->GetXaxis()->SetTitle("Date [day/month/year]");
c1->Modified();
gPad->BuildLegend(0.75,0.75,0.95,0.95,"");
}
R__EXTERN TStyle * gStyle
Definition TStyle.h:433
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition TDatime.h:37
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition TH1.cxx:3344
2-D histogram with an int per channel (see TH1 documentation)
Definition TH2.h:225
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
void SetTimeOffset(Double_t toffset)
Change the time offset for time plotting.
Definition TStyle.cxx:1909
return c1
Definition legend1.C:41
Definition hsum.py:1

Automatic coloring according to the current palette is available as shown in the following example:

void thstackpalettecolor()
{
auto hs = new THStack("hs","Stacked 1D histograms colored using kOcean palette");
// Create three 1-d histograms and add them in the stack
auto h1st = new TH1F("h1st","test hstack",100,-4,4);
h1st->FillRandom("gaus",20000);
hs->Add(h1st);
auto h2st = new TH1F("h2st","test hstack",100,-4,4);
h2st->FillRandom("gaus",15000);
hs->Add(h2st);
auto h3st = new TH1F("h3st","test hstack",100,-4,4);
h3st->FillRandom("gaus",10000);
hs->Add(h3st);
// draw the stack
hs->Draw("pfc nostack");
}
@ kOcean
Definition TColor.h:117
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
See TColor::SetPalette.
Definition TStyle.cxx:1884

Definition at line 40 of file THStack.h.

Public Member Functions

 THStack ()
 
 THStack (const char *name, const char *title)
 constructor with name and title
 
 THStack (const THStack &hstack)
 THStack copy constructor.
 
 THStack (TH1 *hist, Option_t *axis="x", const char *name=nullptr, const char *title=nullptr, 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.
 
 ~THStack () override
 THStack destructor.
 
virtual void Add (TH1 *h, Option_t *option="")
 Add a new histogram to the list.
 
TIter begin () const
 Get an iterator over internal hists list.
 
void Browse (TBrowser *b) override
 Browse.
 
void BuildPrimitives (Option_t *chopt="")
 
Int_t DistancetoPrimitive (Int_t px, Int_t py) override
 Compute distance from point px, py to each graph.
 
void Draw (Option_t *chopt="") override
 Draw this stack with its current attributes.
 
TIter end () const
 
TH1GetHistogram () const
 Returns a pointer to the histogram used to draw the axis.
 
TListGetHists () const
 
virtual Double_t GetMaximum (Option_t *option="", Double_t maxval=std::numeric_limits< Double_t >::max())
 Returns the maximum of all added histograms smaller than maxval.
 
virtual Double_t GetMinimum (Option_t *option="", Double_t minval=-std::numeric_limits< Double_t >::max())
 Returns the minimum of all added histograms larger than minval.
 
Int_t GetNhists () const
 Return the number of histograms in the stack.
 
TObjArrayGetStack ()
 Return pointer to Stack. Build it if not yet done.
 
TAxisGetXaxis () const
 Get the x-axis of the histogram used to draw the stack.
 
TAxisGetYaxis () const
 Get the y-axis of the histogram used to draw the stack.
 
TAxisGetZaxis () const
 Get the z-axis of the histogram used to draw the stack.
 
TClassIsA () const override
 
void ls (Option_t *option="") const override
 List histograms in the stack.
 
virtual Long64_t Merge (TCollection *li, TFileMergeInfo *info)
 Merge the THStack in the TList into this stack.
 
virtual void Modified ()
 Note: this method invalidates the sum of histograms.
 
void Paint (Option_t *chopt="") override
 Paint the list of histograms.
 
void Print (Option_t *chopt="") const override
 Print the list of histograms.
 
void RecursiveRemove (TObject *obj) override
 Recursively remove the object obj from the list of histograms.
 
void SavePrimitive (std::ostream &out, Option_t *option="") override
 Save primitive as a C++ statement(s) on output stream out.
 
virtual void SetHistogram (TH1 *h)
 
virtual void SetMaximum (Double_t maximum=-1111)
 Set maximum.
 
virtual void SetMinimum (Double_t minimum=-1111)
 Set minimum.
 
void Streamer (TBuffer &) override
 Stream an object of class TObject.
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
- Public Member Functions inherited from TNamed
 TNamed ()
 
 TNamed (const char *name, const char *title)
 
 TNamed (const TNamed &named)
 TNamed copy ctor.
 
 TNamed (const TString &name, const TString &title)
 
virtual ~TNamed ()
 TNamed destructor.
 
void Clear (Option_t *option="") override
 Set name and title to empty strings ("").
 
TObjectClone (const char *newname="") const override
 Make a clone of an object using the Streamer facility.
 
Int_t Compare (const TObject *obj) const override
 Compare two TNamed objects.
 
void Copy (TObject &named) const override
 Copy this to obj.
 
virtual void FillBuffer (char *&buffer)
 Encode TNamed into output buffer.
 
const char * GetName () const override
 Returns name of object.
 
const char * GetTitle () const override
 Returns title of object.
 
ULong_t Hash () const override
 Return hash value for this object.
 
TClassIsA () const override
 
Bool_t IsSortable () const override
 
void ls (Option_t *option="") const override
 List TNamed name and title.
 
TNamedoperator= (const TNamed &rhs)
 TNamed assignment operator.
 
void Print (Option_t *option="") const override
 Print TNamed name and title.
 
virtual void SetName (const char *name)
 Set the name of the TNamed.
 
virtual void SetNameTitle (const char *name, const char *title)
 Set all the TNamed parameters (name and title).
 
virtual void SetTitle (const char *title="")
 Set the title of the TNamed.
 
virtual Int_t Sizeof () const
 Return size of the TNamed part of the TObject.
 
void Streamer (TBuffer &) override
 Stream an object of class TObject.
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
- Public Member Functions inherited from TObject
 TObject ()
 TObject constructor.
 
 TObject (const TObject &object)
 TObject copy ctor.
 
virtual ~TObject ()
 TObject destructor.
 
void AbstractMethod (const char *method) const
 Use this method to implement an "abstract" method that you don't want to leave purely abstract.
 
virtual void AppendPad (Option_t *option="")
 Append graphics object to current pad.
 
ULong_t CheckedHash ()
 Check and record whether this class has a consistent Hash/RecursiveRemove setup (*) and then return the regular Hash value for this object.
 
virtual const char * ClassName () const
 Returns name of class to which the object belongs.
 
virtual void Delete (Option_t *option="")
 Delete this object.
 
virtual void DrawClass () const
 Draw class inheritance tree of the class to which this object belongs.
 
virtual TObjectDrawClone (Option_t *option="") const
 Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
 
virtual void Dump () const
 Dump contents of object on stdout.
 
virtual void Error (const char *method, const char *msgfmt,...) const
 Issue error message.
 
virtual void Execute (const char *method, const char *params, Int_t *error=nullptr)
 Execute method on this object with the given parameter string, e.g.
 
virtual void Execute (TMethod *method, TObjArray *params, Int_t *error=nullptr)
 Execute method on this object with parameters stored in the TObjArray.
 
virtual void ExecuteEvent (Int_t event, Int_t px, Int_t py)
 Execute action corresponding to an event at (px,py).
 
virtual void Fatal (const char *method, const char *msgfmt,...) const
 Issue fatal error message.
 
virtual TObjectFindObject (const char *name) const
 Must be redefined in derived classes.
 
virtual TObjectFindObject (const TObject *obj) const
 Must be redefined in derived classes.
 
virtual Option_tGetDrawOption () const
 Get option used by the graphics system to draw this object.
 
virtual const char * GetIconName () const
 Returns mime type name of object.
 
virtual char * GetObjectInfo (Int_t px, Int_t py) const
 Returns string containing info about the object at position (px,py).
 
virtual Option_tGetOption () const
 
virtual UInt_t GetUniqueID () const
 Return the unique object id.
 
virtual Bool_t HandleTimer (TTimer *timer)
 Execute action in response of a timer timing out.
 
Bool_t HasInconsistentHash () const
 Return true is the type of this object is known to have an inconsistent setup for Hash and RecursiveRemove (i.e.
 
virtual void Info (const char *method, const char *msgfmt,...) const
 Issue info message.
 
virtual Bool_t InheritsFrom (const char *classname) const
 Returns kTRUE if object inherits from class "classname".
 
virtual Bool_t InheritsFrom (const TClass *cl) const
 Returns kTRUE if object inherits from TClass cl.
 
virtual void Inspect () const
 Dump contents of this object in a graphics canvas.
 
void InvertBit (UInt_t f)
 
Bool_t IsDestructed () const
 IsDestructed.
 
virtual Bool_t IsEqual (const TObject *obj) const
 Default equal comparison (objects are equal if they have the same address in memory).
 
virtual Bool_t IsFolder () const
 Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
 
R__ALWAYS_INLINE Bool_t IsOnHeap () const
 
R__ALWAYS_INLINE Bool_t IsZombie () const
 
void MayNotUse (const char *method) const
 Use this method to signal that a method (defined in a base class) may not be called in a derived class (in principle against good design since a child class should not provide less functionality than its parent, however, sometimes it is necessary).
 
virtual Bool_t Notify ()
 This method must be overridden to handle object notification (the base implementation is no-op).
 
void Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const
 Use this method to declare a method obsolete.
 
void operator delete (void *ptr)
 Operator delete.
 
void operator delete (void *ptr, void *vp)
 Only called by placement new when throwing an exception.
 
void operator delete[] (void *ptr)
 Operator delete [].
 
void operator delete[] (void *ptr, void *vp)
 Only called by placement new[] when throwing an exception.
 
void * operator new (size_t sz)
 
void * operator new (size_t sz, void *vp)
 
void * operator new[] (size_t sz)
 
void * operator new[] (size_t sz, void *vp)
 
TObjectoperator= (const TObject &rhs)
 TObject assignment operator.
 
virtual void Pop ()
 Pop on object drawn in a pad to the top of the display list.
 
virtual Int_t Read (const char *name)
 Read contents of object with specified name from the current directory.
 
void ResetBit (UInt_t f)
 
virtual void SaveAs (const char *filename="", Option_t *option="") const
 Save this object in the file specified by filename.
 
void SetBit (UInt_t f)
 
void SetBit (UInt_t f, Bool_t set)
 Set or unset the user status bits as specified in f.
 
virtual void SetDrawOption (Option_t *option="")
 Set drawing option for object.
 
virtual void SetUniqueID (UInt_t uid)
 Set the unique object id.
 
void StreamerNVirtual (TBuffer &ClassDef_StreamerNVirtual_b)
 
virtual void SysError (const char *method, const char *msgfmt,...) const
 Issue system error message.
 
R__ALWAYS_INLINE Bool_t TestBit (UInt_t f) const
 
Int_t TestBits (UInt_t f) const
 
virtual void UseCurrentStyle ()
 Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked.
 
virtual void Warning (const char *method, const char *msgfmt,...) const
 Issue warning message.
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
 Write this object to the current directory.
 
virtual Int_t Write (const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const
 Write this object to the current directory.
 

Static Public Member Functions

static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
- Static Public Member Functions inherited from TNamed
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
- Static Public Member Functions inherited from TObject
static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 
static Longptr_t GetDtorOnly ()
 Return destructor only flag.
 
static Bool_t GetObjectStat ()
 Get status of object stat flag.
 
static void SetDtorOnly (void *obj)
 Set destructor only flag.
 
static void SetObjectStat (Bool_t stat)
 Turn on/off tracking of objects in the TObjectTable.
 

Protected Member Functions

void BuildAndPaint (Option_t *chopt, Bool_t paint)
 Create all additional objects and stack (if specified).
 
void BuildStack ()
 Build the sum of all histograms.
 
- Protected Member Functions inherited from TObject
virtual void DoError (int level, const char *location, const char *fmt, va_list va) const
 Interface to ErrorHandler (protected).
 
void MakeZombie ()
 

Protected Attributes

TH1fHistogram {nullptr}
 Pointer to histogram used for drawing axis.
 
TListfHists {nullptr}
 Pointer to array of TH1.
 
Double_t fMaximum {-1111}
 Maximum value for plotting along y.
 
Double_t fMinimum {-1111}
 Minimum value for plotting along y.
 
TObjArrayfStack {nullptr}
 ! Pointer to array of sums of TH1
 
- Protected Attributes inherited from TNamed
TString fName
 
TString fTitle
 

Private Member Functions

THStackoperator= (const THStack &)=delete
 

Additional Inherited Members

- Public Types inherited from TObject
enum  {
  kIsOnHeap = 0x01000000 , kNotDeleted = 0x02000000 , kZombie = 0x04000000 , kInconsistent = 0x08000000 ,
  kBitMask = 0x00ffffff
}
 
enum  { kSingleKey = (1ULL << ( 0 )) , kOverwrite = (1ULL << ( 1 )) , kWriteDelete = (1ULL << ( 2 )) }
 
enum  EDeprecatedStatusBits { kObjInCanvas = (1ULL << ( 3 )) }
 
enum  EStatusBits {
  kCanDelete = (1ULL << ( 0 )) , kMustCleanup = (1ULL << ( 3 )) , kIsReferenced = (1ULL << ( 4 )) , kHasUUID = (1ULL << ( 5 )) ,
  kCannotPick = (1ULL << ( 6 )) , kNoContextMenu = (1ULL << ( 8 )) , kInvalidObject = (1ULL << ( 13 ))
}
 
- Protected Types inherited from TObject
enum  { kOnlyPrepStep = (1ULL << ( 3 )) }
 

#include <THStack.h>

Inheritance diagram for THStack:
[legend]

Constructor & Destructor Documentation

◆ THStack() [1/4]

THStack::THStack ( )
inline

Definition at line 57 of file THStack.h.

◆ THStack() [2/4]

THStack::THStack ( const char *  name,
const char *  title 
)

constructor with name and title

Definition at line 135 of file THStack.cxx.

◆ THStack() [3/4]

THStack::THStack ( TH1 hist,
Option_t axis = "x",
const char *  name = nullptr,
const char *  title = nullptr,
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.

Definition at line 172 of file THStack.cxx.

◆ THStack() [4/4]

THStack::THStack ( const THStack hstack)

THStack copy constructor.

Definition at line 346 of file THStack.cxx.

◆ ~THStack()

THStack::~THStack ( )
override

THStack destructor.

Definition at line 323 of file THStack.cxx.

Member Function Documentation

◆ Add()

void THStack::Add ( TH1 h1,
Option_t option = "" 
)
virtual

Add a new histogram to the list.

Only 1-d and 2-d histograms currently supported. A drawing option may be specified

Definition at line 366 of file THStack.cxx.

◆ begin()

TIter THStack::begin ( ) const

Get an iterator over internal hists list.

Definition at line 1081 of file THStack.cxx.

◆ Browse()

void THStack::Browse ( TBrowser b)
overridevirtual

Browse.

Reimplemented from TObject.

Definition at line 381 of file THStack.cxx.

◆ BuildAndPaint()

void THStack::BuildAndPaint ( Option_t chopt,
Bool_t  paint 
)
protected

Create all additional objects and stack (if specified).

Definition at line 708 of file THStack.cxx.

◆ BuildPrimitives()

void THStack::BuildPrimitives ( Option_t chopt = "")
inline

Definition at line 67 of file THStack.h.

◆ BuildStack()

void THStack::BuildStack ( )
protected

Build the sum of all histograms.

Build a separate list fStack containing the running sum of all histograms

Definition at line 391 of file THStack.cxx.

◆ Class()

static TClass * THStack::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

static const char * THStack::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

static constexpr Version_t THStack::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 93 of file THStack.h.

◆ DeclFileName()

static const char * THStack::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 93 of file THStack.h.

◆ DistancetoPrimitive()

Int_t THStack::DistancetoPrimitive ( Int_t  px,
Int_t  py 
)
overridevirtual

Compute distance from point px, py to each graph.

Reimplemented from TObject.

Definition at line 416 of file THStack.cxx.

◆ Draw()

void THStack::Draw ( Option_t option = "")
overridevirtual

Draw this stack with its current attributes.

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

Reimplemented from TObject.

Definition at line 453 of file THStack.cxx.

◆ end()

TIter THStack::end ( ) const
inline

Definition at line 74 of file THStack.h.

◆ GetHistogram()

TH1 * THStack::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

IMPORTANT NOTES

  • You must call Draw before calling this function. The returned histogram depends on the selected Draw options.
  • This function returns a pointer to an intermediate fixed bin size histogram used to set the range and for picking. You cannot use this histogram to return the bin information. You must get a pointer to one of the histograms in the stack, the first one, for example.

Definition at line 484 of file THStack.cxx.

◆ GetHists()

TList * THStack::GetHists ( ) const
inline

Definition at line 72 of file THStack.h.

◆ GetMaximum()

Double_t THStack::GetMaximum ( Option_t option = "",
Double_t  maxval = std::numeric_limits<Double_t>::max() 
)
virtual

Returns the maximum of all added histograms smaller than maxval.

Returns the maximum of all histograms, smaller than maxval, if option "nostack".

Definition at line 498 of file THStack.cxx.

◆ GetMinimum()

Double_t THStack::GetMinimum ( Option_t option = "",
Double_t  minval = -std::numeric_limits<Double_t>::max() 
)
virtual

Returns the minimum of all added histograms larger than minval.

Returns the minimum of all histograms, larger than minval, if option "nostack".

Definition at line 547 of file THStack.cxx.

◆ GetNhists()

Int_t THStack::GetNhists ( ) const

Return the number of histograms in the stack.

Definition at line 591 of file THStack.cxx.

◆ GetStack()

TObjArray * THStack::GetStack ( )

Return pointer to Stack. Build it if not yet done.

Definition at line 600 of file THStack.cxx.

◆ GetXaxis()

TAxis * THStack::GetXaxis ( ) const

Get the 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.

Definition at line 613 of file THStack.cxx.

◆ GetYaxis()

TAxis * THStack::GetYaxis ( ) const

Get the y-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.

Definition at line 626 of file THStack.cxx.

◆ GetZaxis()

TAxis * THStack::GetZaxis ( ) const

Get the z-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.

Definition at line 639 of file THStack.cxx.

◆ IsA()

TClass * THStack::IsA ( ) const
inlineoverridevirtual
Returns
TClass describing current object

Reimplemented from TObject.

Definition at line 93 of file THStack.h.

◆ ls()

void THStack::ls ( Option_t option = "") const
overridevirtual

List histograms in the stack.

Reimplemented from TObject.

Definition at line 651 of file THStack.cxx.

◆ Merge()

Long64_t THStack::Merge ( TCollection li,
TFileMergeInfo info 
)
virtual

Merge the THStack in the TList into this stack.

Returns the total number of histograms in the result or -1 in case of an error.

Definition at line 664 of file THStack.cxx.

◆ Modified()

void THStack::Modified ( )
virtual

Note: this method invalidates the sum of histograms.

Definition at line 687 of file THStack.cxx.

◆ operator=()

THStack & THStack::operator= ( const THStack )
privatedelete

◆ Paint()

void THStack::Paint ( Option_t chopt = "")
overridevirtual

Paint the list of histograms.

Reimplemented from TObject.

Definition at line 700 of file THStack.cxx.

◆ Print()

void THStack::Print ( Option_t chopt = "") const
overridevirtual

Print the list of histograms.

Reimplemented from TObject.

Definition at line 993 of file THStack.cxx.

◆ RecursiveRemove()

void THStack::RecursiveRemove ( TObject obj)
overridevirtual

Recursively remove the object obj from the list of histograms.

Reimplemented from TObject.

Definition at line 1003 of file THStack.cxx.

◆ SavePrimitive()

void THStack::SavePrimitive ( std::ostream &  out,
Option_t option = "" 
)
overridevirtual

Save primitive as a C++ statement(s) on output stream out.

Reimplemented from TObject.

Definition at line 1013 of file THStack.cxx.

◆ SetHistogram()

virtual void THStack::SetHistogram ( TH1 h)
inlinevirtual

Definition at line 89 of file THStack.h.

◆ SetMaximum()

void THStack::SetMaximum ( Double_t  maximum = -1111)
virtual

Set maximum.

Definition at line 1063 of file THStack.cxx.

◆ SetMinimum()

void THStack::SetMinimum ( Double_t  minimum = -1111)
virtual

Set minimum.

Definition at line 1072 of file THStack.cxx.

◆ Streamer()

void THStack::Streamer ( TBuffer R__b)
overridevirtual

Stream an object of class TObject.

Reimplemented from TObject.

◆ StreamerNVirtual()

void THStack::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 93 of file THStack.h.

Member Data Documentation

◆ fHistogram

TH1* THStack::fHistogram {nullptr}
protected

Pointer to histogram used for drawing axis.

Definition at line 47 of file THStack.h.

◆ fHists

TList* THStack::fHists {nullptr}
protected

Pointer to array of TH1.

Definition at line 45 of file THStack.h.

◆ fMaximum

Double_t THStack::fMaximum {-1111}
protected

Maximum value for plotting along y.

Definition at line 48 of file THStack.h.

◆ fMinimum

Double_t THStack::fMinimum {-1111}
protected

Minimum value for plotting along y.

Definition at line 49 of file THStack.h.

◆ fStack

TObjArray* THStack::fStack {nullptr}
protected

! Pointer to array of sums of TH1

Definition at line 46 of file THStack.h.

Libraries for THStack:

The documentation for this class was generated from the following files: