ROOT
6.07/01
Reference Guide
|
The Histogram stack class.
A THStack is a collection of TH1 or TH2 histograms. Using THStack::Draw() the histogram collection is drawn in one go according to the drawing option.
THStack::Add() allows to add a new histogram to the list. The THStack does not own the objects in the list.
By default (if no option drawing option is specified), histograms will be paint stacked on top of each other. TH2 are stacked as lego plots.
If option "nostack" is specified the histograms are not drawn on top of each other but as they would if drawn using the option "same".
If option "nostackb" is specified the histograms are drawn next to each other as bar charts.
In all cases The axis range is computed automatically along the X and Y axis in order to show the complete histogram collection.
Example;
A more complex example:
Note that picking is supported for all drawing modes.
Public Member Functions | |
THStack () | |
THStack (const char *name, const char *title) | |
constructor with name and title More... | |
THStack (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. More... | |
THStack (const THStack &hstack) | |
THStack copy constructor. More... | |
virtual | ~THStack () |
THStack destructor. More... | |
virtual void | Add (TH1 *h, Option_t *option="") |
add a new histogram to the list Only 1-d and 2-d histograms currently supported. More... | |
virtual void | Browse (TBrowser *b) |
Browse. More... | |
virtual Int_t | DistancetoPrimitive (Int_t px, Int_t py) |
Compute distance from point px,py to each graph. More... | |
virtual void | Draw (Option_t *chopt="") |
Draw this multihist with its current attributes. More... | |
TH1 * | GetHistogram () const |
Returns a pointer to the histogram used to draw the axis Takes into account the two following cases. More... | |
TList * | GetHists () const |
Int_t | GetNhists () const |
Return the number of histograms in the stack. More... | |
TObjArray * | GetStack () |
Return pointer to Stack. Build it if not yet done. More... | |
virtual Double_t | GetMaximum (Option_t *option="") |
returns the maximum of all added histograms returns the maximum of all histograms if option "nostack". More... | |
virtual Double_t | GetMinimum (Option_t *option="") |
returns the minimum of all added histograms returns the minimum of all histograms if option "nostack". More... | |
TAxis * | GetXaxis () const |
Get x axis of the histogram used to draw the stack. More... | |
TAxis * | GetYaxis () const |
Get x axis of the histogram used to draw the stack. More... | |
virtual void | ls (Option_t *option="") const |
List histograms in the stack. More... | |
virtual Long64_t | Merge (TCollection *li, TFileMergeInfo *info) |
Merge the THStack in the TList into this stack. More... | |
virtual void | Modified () |
invalidate sum of histograms More... | |
virtual void | Paint (Option_t *chopt="") |
Paint the list of histograms. More... | |
virtual void | Print (Option_t *chopt="") const |
Print the list of histograms. More... | |
virtual void | RecursiveRemove (TObject *obj) |
Recursively remove object from the list of histograms. More... | |
virtual void | SavePrimitive (std::ostream &out, Option_t *option="") |
Save primitive as a C++ statement(s) on output stream out. More... | |
virtual void | SetHistogram (TH1 *h) |
virtual void | SetMaximum (Double_t maximum=-1111) |
Set maximum. More... | |
virtual void | SetMinimum (Double_t minimum=-1111) |
Set minimum. More... | |
Public Member Functions inherited from TNamed | |
TNamed () | |
TNamed (const char *name, const char *title) | |
TNamed (const TString &name, const TString &title) | |
TNamed (const TNamed &named) | |
TNamed & | operator= (const TNamed &rhs) |
TNamed assignment operator. More... | |
virtual | ~TNamed () |
virtual void | Clear (Option_t *option="") |
Set name and title to empty strings (""). More... | |
virtual TObject * | Clone (const char *newname="") const |
Make a clone of an object using the Streamer facility. More... | |
virtual Int_t | Compare (const TObject *obj) const |
Compare two TNamed objects. More... | |
virtual void | Copy (TObject &named) const |
Copy this to obj. More... | |
virtual void | FillBuffer (char *&buffer) |
Encode TNamed into output buffer. More... | |
virtual const char * | GetName () const |
Returns name of object. More... | |
virtual const char * | GetTitle () const |
Returns title of object. More... | |
virtual ULong_t | Hash () const |
Return hash value for this object. More... | |
virtual Bool_t | IsSortable () const |
virtual void | SetName (const char *name) |
Change (i.e. More... | |
virtual void | SetNameTitle (const char *name, const char *title) |
Change (i.e. set) all the TNamed parameters (name and title). More... | |
virtual void | SetTitle (const char *title="") |
Change (i.e. set) the title of the TNamed. More... | |
virtual Int_t | Sizeof () const |
Return size of the TNamed part of the TObject. More... | |
Public Member Functions inherited from TObject | |
TObject () | |
TObject (const TObject &object) | |
TObject copy ctor. More... | |
TObject & | operator= (const TObject &rhs) |
TObject assignment operator. More... | |
virtual | ~TObject () |
TObject destructor. More... | |
virtual void | AppendPad (Option_t *option="") |
Append graphics object to current pad. More... | |
virtual const char * | ClassName () const |
Returns name of class to which the object belongs. More... | |
virtual void | Delete (Option_t *option="") |
Delete this object. More... | |
virtual void | DrawClass () const |
Draw class inheritance tree of the class to which this object belongs. More... | |
virtual TObject * | DrawClone (Option_t *option="") const |
Draw a clone of this object in the current pad. More... | |
virtual void | Dump () const |
Dump contents of object on stdout. More... | |
virtual void | Execute (const char *method, const char *params, Int_t *error=0) |
Execute method on this object with the given parameter string, e.g. More... | |
virtual void | Execute (TMethod *method, TObjArray *params, Int_t *error=0) |
Execute method on this object with parameters stored in the TObjArray. More... | |
virtual void | ExecuteEvent (Int_t event, Int_t px, Int_t py) |
Execute action corresponding to an event at (px,py). More... | |
virtual TObject * | FindObject (const char *name) const |
Must be redefined in derived classes. More... | |
virtual TObject * | FindObject (const TObject *obj) const |
Must be redefined in derived classes. More... | |
virtual Option_t * | GetDrawOption () const |
Get option used by the graphics system to draw this object. More... | |
virtual UInt_t | GetUniqueID () const |
Return the unique object id. More... | |
virtual const char * | GetIconName () const |
Returns mime type name of object. More... | |
virtual Option_t * | GetOption () const |
virtual char * | GetObjectInfo (Int_t px, Int_t py) const |
Returns string containing info about the object at position (px,py). More... | |
virtual Bool_t | HandleTimer (TTimer *timer) |
Execute action in response of a timer timing out. More... | |
virtual Bool_t | InheritsFrom (const char *classname) const |
Returns kTRUE if object inherits from class "classname". More... | |
virtual Bool_t | InheritsFrom (const TClass *cl) const |
Returns kTRUE if object inherits from TClass cl. More... | |
virtual void | Inspect () const |
Dump contents of this object in a graphics canvas. More... | |
virtual Bool_t | IsFolder () const |
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects). More... | |
virtual Bool_t | IsEqual (const TObject *obj) const |
Default equal comparison (objects are equal if they have the same address in memory). More... | |
Bool_t | IsOnHeap () const |
Bool_t | IsZombie () const |
virtual Bool_t | Notify () |
This method must be overridden to handle object notification. More... | |
virtual void | Pop () |
Pop on object drawn in a pad to the top of the display list. More... | |
virtual Int_t | Read (const char *name) |
Read contents of object with specified name from the current directory. More... | |
virtual void | SaveAs (const char *filename="", Option_t *option="") const |
Save this object in the file specified by filename. More... | |
virtual void | SetDrawOption (Option_t *option="") |
Set drawing option for object. More... | |
virtual void | SetUniqueID (UInt_t uid) |
Set the unique object id. More... | |
virtual void | UseCurrentStyle () |
Set current style settings in this object This function is called when either TCanvas::UseCurrentStyle or TROOT::ForceStyle have been invoked. More... | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) |
Write this object to the current directory. More... | |
virtual Int_t | Write (const char *name=0, Int_t option=0, Int_t bufsize=0) const |
Write this object to the current directory. More... | |
void * | operator new (size_t sz) |
void * | operator new[] (size_t sz) |
void * | operator new (size_t sz, void *vp) |
void * | operator new[] (size_t sz, void *vp) |
void | operator delete (void *ptr) |
Operator delete. More... | |
void | operator delete[] (void *ptr) |
Operator delete []. More... | |
void | SetBit (UInt_t f, Bool_t set) |
Set or unset the user status bits as specified in f. More... | |
void | SetBit (UInt_t f) |
void | ResetBit (UInt_t f) |
Bool_t | TestBit (UInt_t f) const |
Int_t | TestBits (UInt_t f) const |
void | InvertBit (UInt_t f) |
virtual void | Info (const char *method, const char *msgfmt,...) const |
Issue info message. More... | |
virtual void | Warning (const char *method, const char *msgfmt,...) const |
Issue warning message. More... | |
virtual void | Error (const char *method, const char *msgfmt,...) const |
Issue error message. More... | |
virtual void | SysError (const char *method, const char *msgfmt,...) const |
Issue system error message. More... | |
virtual void | Fatal (const char *method, const char *msgfmt,...) const |
Issue fatal error message. More... | |
void | AbstractMethod (const char *method) const |
Use this method to implement an "abstract" method that you don't want to leave purely abstract. More... | |
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). More... | |
void | Obsolete (const char *method, const char *asOfVers, const char *removedFromVers) const |
Use this method to declare a method obsolete. More... | |
Protected Member Functions | |
void | BuildStack () |
build sum of all histograms Build a separate list fStack containing the running sum of all histograms More... | |
Protected Member Functions inherited from TObject | |
void | MakeZombie () |
virtual void | DoError (int level, const char *location, const char *fmt, va_list va) const |
Interface to ErrorHandler (protected). More... | |
Protected Attributes | |
TList * | fHists |
TObjArray * | fStack |
TH1 * | fHistogram |
Pointer to array of sums of TH1. More... | |
Double_t | fMaximum |
Double_t | fMinimum |
Protected Attributes inherited from TNamed | |
TString | fName |
TString | fTitle |
Private Member Functions | |
THStack & | operator= (const THStack &) |
Additional Inherited Members | |
Public Types inherited from TObject | |
enum | EStatusBits { kCanDelete = BIT(0), kMustCleanup = BIT(3), kObjInCanvas = BIT(3), kIsReferenced = BIT(4), kHasUUID = BIT(5), kCannotPick = BIT(6), kNoContextMenu = BIT(8), kInvalidObject = BIT(13) } |
enum | { kIsOnHeap = 0x01000000, kNotDeleted = 0x02000000, kZombie = 0x04000000, kBitMask = 0x00ffffff } |
enum | { kSingleKey = BIT(0), kOverwrite = BIT(1), kWriteDelete = BIT(2) } |
Static Public Member Functions inherited from TObject | |
static Long_t | GetDtorOnly () |
Return destructor only flag. More... | |
static void | SetDtorOnly (void *obj) |
Set destructor only flag. More... | |
static Bool_t | GetObjectStat () |
Get status of object stat flag. More... | |
static void | SetObjectStat (Bool_t stat) |
Turn on/off tracking of objects in the TObjectTable. More... | |
#include <THStack.h>
THStack::THStack | ( | ) |
THStack::THStack | ( | const char * | name, |
const char * | title | ||
) |
constructor with name and title
Definition at line 108 of file THStack.cxx.
THStack::THStack | ( | 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:
Definition at line 149 of file THStack.cxx.
THStack::THStack | ( | const THStack & | hstack | ) |
THStack copy constructor.
Definition at line 316 of file THStack.cxx.
|
virtual |
THStack destructor.
Definition at line 300 of file THStack.cxx.
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 336 of file THStack.cxx.
Referenced by TEveCaloDataHist::AddHistogram(), TMLPAnalyzer::DrawDInputs(), TMLPAnalyzer::DrawNetwork(), TMLPAnalyzer::DrawTruthDeviationInsOut(), TMLPAnalyzer::DrawTruthDeviations(), RooStats::HistFactory::HistFactoryNavigation::GetChannelStack(), and THStack().
|
protected |
build sum of all histograms Build a separate list fStack containing the running sum of all histograms
Definition at line 361 of file THStack.cxx.
Referenced by GetMaximum(), GetMinimum(), GetStack(), and Paint().
Compute distance from point px,py to each graph.
Reimplemented from TObject.
Definition at line 384 of file THStack.cxx.
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.
Reimplemented from TObject.
Definition at line 422 of file THStack.cxx.
Referenced by Browse(), RooStats::HistFactory::HistFactoryNavigation::DrawChannel(), TMLPAnalyzer::DrawDInputs(), TMLPAnalyzer::DrawNetwork(), TMLPAnalyzer::DrawTruthDeviationInsOut(), and TMLPAnalyzer::DrawTruthDeviations().
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
Definition at line 453 of file THStack.cxx.
Referenced by GetXaxis(), GetYaxis(), and TPad::RedrawAxis().
|
inline |
Definition at line 64 of file THStack.h.
Referenced by TEveCaloDataHist::GetHist(), Merge(), and THStack().
returns the maximum of all added histograms returns the maximum of all histograms if option "nostack".
Definition at line 468 of file THStack.cxx.
Referenced by Paint().
returns the minimum of all added histograms returns the minimum of all histograms if option "nostack".
Definition at line 512 of file THStack.cxx.
Referenced by Paint().
Int_t THStack::GetNhists | ( | ) | const |
Return the number of histograms in the stack.
Definition at line 556 of file THStack.cxx.
TObjArray * THStack::GetStack | ( | ) |
Return pointer to Stack. Build it if not yet done.
Definition at line 565 of file THStack.cxx.
TAxis * THStack::GetXaxis | ( | ) | const |
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.
Definition at line 578 of file THStack.cxx.
Referenced by TMLPAnalyzer::DrawTruthDeviationInsOut(), and TMLPAnalyzer::DrawTruthDeviations().
TAxis * THStack::GetYaxis | ( | ) | const |
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.
Definition at line 593 of file THStack.cxx.
Referenced by TMLPAnalyzer::DrawTruthDeviationInsOut(), and TMLPAnalyzer::DrawTruthDeviations().
List histograms in the stack.
Reimplemented from TNamed.
Definition at line 604 of file THStack.cxx.
|
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 617 of file THStack.cxx.
|
virtual |
Paint the list of histograms.
By default, histograms are shown stacked.
If option "nostack" is specified, histograms are all paint in the same pad as if the option "same" had been specified.
If the option nostackb is specified histograms are all paint in the same pad next to each other as bar plots.
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.
By default the background of the histograms is erased before drawing the histograms. The option "noclear" avoid this behaviour. This is useful when drawing a THStack on top of an other plot. If the patterns used to draw the histograms in the stack are transparents, then the plot behind will be visible.
See THistPainter::Paint for a list of valid options.
Reimplemented from TObject.
Definition at line 674 of file THStack.cxx.
Print the list of histograms.
Reimplemented from TNamed.
Definition at line 903 of file THStack.cxx.
Recursively remove object from the list of histograms.
Reimplemented from TObject.
Definition at line 917 of file THStack.cxx.
Save primitive as a C++ statement(s) on output stream out.
Reimplemented from TObject.
Definition at line 927 of file THStack.cxx.
Set maximum.
Definition at line 976 of file THStack.cxx.
Set minimum.
Definition at line 985 of file THStack.cxx.
|
protected |
Pointer to array of sums of TH1.
Definition at line 42 of file THStack.h.
Referenced by DistancetoPrimitive(), GetHistogram(), Modified(), Paint(), SavePrimitive(), SetHistogram(), SetMaximum(), SetMinimum(), THStack(), and ~THStack().
|
protected |
Definition at line 40 of file THStack.h.
Referenced by Add(), BuildStack(), DistancetoPrimitive(), GetHists(), GetMaximum(), GetMinimum(), GetNhists(), ls(), Merge(), Paint(), Print(), RecursiveRemove(), SavePrimitive(), THStack(), and ~THStack().
|
protected |
Definition at line 43 of file THStack.h.
Referenced by Paint(), SavePrimitive(), SetMaximum(), and THStack().
|
protected |
Definition at line 44 of file THStack.h.
Referenced by Paint(), SavePrimitive(), SetMinimum(), and THStack().
|
protected |
Definition at line 41 of file THStack.h.
Referenced by BuildStack(), DistancetoPrimitive(), GetMaximum(), GetMinimum(), GetStack(), Modified(), Paint(), THStack(), and ~THStack().