Logo ROOT  
Reference Guide
No Matches
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Rene Brun 10/12/2001
5 * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
12#ifndef ROOT_THStack
13#define ROOT_THStack
17// //
18// THStack //
19// //
20// A collection of histograms //
21// //
24#include "TNamed.h"
25#include "TObjArray.h"
28class TH1;
29class TList;
30class TAxis;
32#include "TH1.h"
35#include <limits>
37class TBrowser;
38class TFileMergeInfo;
40class THStack : public TNamed {
42 THStack& operator=(const THStack&) = delete;
45 TList *fHists{nullptr}; ///< Pointer to array of TH1
46 TObjArray *fStack{nullptr}; ///<! Pointer to array of sums of TH1
47 TH1 *fHistogram{nullptr}; ///< Pointer to histogram used for drawing axis
48 Double_t fMaximum{-1111}; ///< Maximum value for plotting along y
49 Double_t fMinimum{-1111}; ///< Minimum value for plotting along y
51 void BuildStack();
53 void BuildAndPaint(Option_t *chopt, Bool_t paint);
58 THStack(const char *name, const char *title);
59 THStack(TH1* hist, Option_t *axis="x",
60 const char *name = nullptr, const char *title = nullptr,
61 Int_t firstbin = 1, Int_t lastbin = -1,
62 Int_t firstbin2 = 1, Int_t lastbin2 = -1,
63 Option_t *proj_option = "", Option_t *draw_option = "");
64 THStack(const THStack &hstack);
65 ~THStack() override;
66 virtual void Add(TH1 *h, Option_t *option="");
67 void BuildPrimitives(Option_t *chopt = "") { BuildAndPaint(chopt, kFALSE); }
68 void Browse(TBrowser *b) override;
69 Int_t DistancetoPrimitive(Int_t px, Int_t py) override;
70 void Draw(Option_t *chopt="") override;
71 TH1 *GetHistogram() const;
72 TList *GetHists() const { return fHists; }
73 TIter begin() const;
74 TIter end() const { return TIter::End(); }
75 Int_t GetNhists() const;
77 virtual Double_t GetMaximum(Option_t *option = "", Double_t maxval = std::numeric_limits<Double_t>::max());
78 virtual Double_t GetMinimum(Option_t *option = "", Double_t minval = -std::numeric_limits<Double_t>::max());
79 TAxis *GetXaxis() const;
80 TAxis *GetYaxis() const;
81 TAxis *GetZaxis() const;
82 void ls(Option_t *option="") const override;
83 virtual Long64_t Merge(TCollection* li, TFileMergeInfo *info);
84 virtual void Modified();
85 void Paint(Option_t *chopt = "") override;
86 void Print(Option_t *chopt = "") const override;
87 void RecursiveRemove(TObject *obj) override;
88 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
89 virtual void SetHistogram(TH1 *h) { fHistogram = h; }
90 virtual void SetMaximum(Double_t maximum=-1111); // *MENU*
91 virtual void SetMinimum(Double_t minimum=-1111); // *MENU*
93 ClassDefOverride(THStack,2) //A collection of histograms
#define b(i)
Definition RSha256.hxx:100
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:80
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
char name[80]
Definition TGX11.cxx:110
Class to manage histogram axis.
Definition TAxis.h:31
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
Collection abstract base class.
Definition TCollection.h:65
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
The Histogram stack class.
Definition THStack.h:40
TIter begin() const
Get an iterator over internal hists list.
Definition THStack.cxx:1081
~THStack() override
THStack destructor.
Definition THStack.cxx:323
void BuildPrimitives(Option_t *chopt="")
Definition THStack.h:67
Definition THStack.h:57
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.
Definition THStack.cxx:547
void ls(Option_t *option="") const override
List histograms in the stack.
Definition THStack.cxx:651
TObjArray * fStack
! Pointer to array of sums of TH1
Definition THStack.h:46
void BuildAndPaint(Option_t *chopt, Bool_t paint)
Create all additional objects and stack (if specified).
Definition THStack.cxx:708
Double_t fMinimum
Minimum value for plotting along y.
Definition THStack.h:49
void BuildStack()
Build the sum of all histograms.
Definition THStack.cxx:391
TList * GetHists() const
Definition THStack.h:72
TAxis * GetYaxis() const
Get the y-axis of the histogram used to draw the stack.
Definition THStack.cxx:626
virtual Long64_t Merge(TCollection *li, TFileMergeInfo *info)
Merge the THStack in the TList into this stack.
Definition THStack.cxx:664
TH1 * GetHistogram() const
Returns a pointer to the histogram used to draw the axis.
Definition THStack.cxx:484
virtual void SetHistogram(TH1 *h)
Definition THStack.h:89
void RecursiveRemove(TObject *obj) override
Recursively remove the object obj from the list of histograms.
Definition THStack.cxx:1003
virtual void Add(TH1 *h, Option_t *option="")
Add a new histogram to the list.
Definition THStack.cxx:366
void Print(Option_t *chopt="") const override
Print the list of histograms.
Definition THStack.cxx:993
TObjArray * GetStack()
Return pointer to Stack. Build it if not yet done.
Definition THStack.cxx:600
THStack & operator=(const THStack &)=delete
Int_t GetNhists() const
Return the number of histograms in the stack.
Definition THStack.cxx:591
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.
Definition THStack.cxx:498
void Paint(Option_t *chopt="") override
Paint the list of histograms.
Definition THStack.cxx:700
TIter end() const
Definition THStack.h:74
TList * fHists
Pointer to array of TH1.
Definition THStack.h:45
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum.
Definition THStack.cxx:1063
TH1 * fHistogram
Pointer to histogram used for drawing axis.
Definition THStack.h:47
TAxis * GetZaxis() const
Get the z-axis of the histogram used to draw the stack.
Definition THStack.cxx:639
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition THStack.cxx:1013
void Browse(TBrowser *b) override
Definition THStack.cxx:381
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px, py to each graph.
Definition THStack.cxx:416
virtual void Modified()
Note: this method invalidates the sum of histograms.
Definition THStack.cxx:687
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum.
Definition THStack.cxx:1072
TAxis * GetXaxis() const
Get the x-axis of the histogram used to draw the stack.
Definition THStack.cxx:613
Double_t fMaximum
Maximum value for plotting along y.
Definition THStack.h:48
static TIter End()
Pointing to the element after the last - to a nullptr value in our case.
A doubly linked list.
Definition TList.h:38
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
An array of TObjects.
Definition TObjArray.h:31
Mother of all ROOT objects.
Definition TObject.h:41
th1 Draw()