Logo ROOT  
Reference Guide
THStack.h
Go to the documentation of this file.
1 // @(#)root/hist:$Id$
2 // Author: Rene Brun 10/12/2001
3 
4 /*************************************************************************
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  *************************************************************************/
11 
12 #ifndef ROOT_THStack
13 #define ROOT_THStack
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // THStack //
19 // //
20 // A collection of histograms //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TNamed.h"
25 #include "TObjArray.h"
26 
27 #ifdef R__LESS_INCLUDES
28 class TH1;
29 class TList;
30 class TAxis;
31 #else
32 #include "TH1.h"
33 #endif
34 
35 class TBrowser;
36 class TFileMergeInfo;
37 
38 class THStack : public TNamed {
39 private:
40  THStack& operator=(const THStack&); // Not implemented
41 
42 protected:
43  TList *fHists; //Pointer to array of TH1
44  TObjArray *fStack; //!Pointer to array of sums of TH1
45  TH1 *fHistogram; //Pointer to histogram used for drawing axis
46  Double_t fMaximum; //Maximum value for plotting along y
47  Double_t fMinimum; //Minimum value for plotting along y
48 
49  void BuildStack();
50 
51 public:
52 
53  THStack();
54  THStack(const char *name, const char *title);
55  THStack(TH1* hist, Option_t *axis="x",
56  const char *name=0, const char *title=0,
57  Int_t firstbin=1, Int_t lastbin=-1,
58  Int_t firstbin2=1, Int_t lastbin2=-1,
59  Option_t* proj_option="", Option_t* draw_option="");
60  THStack(const THStack &hstack);
61  virtual ~THStack();
62  virtual void Add(TH1 *h, Option_t *option="");
63  virtual void Browse(TBrowser *b);
64  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
65  virtual void Draw(Option_t *chopt="");
66  TH1 *GetHistogram() const;
67  TList *GetHists() const { return fHists; }
68  TIter begin() const;
69  TIter end() const { return TIter::End(); }
70  Int_t GetNhists() const;
72  virtual Double_t GetMaximum(Option_t *option="");
73  virtual Double_t GetMinimum(Option_t *option="");
74  TAxis *GetXaxis() const;
75  TAxis *GetYaxis() const;
76  virtual void ls(Option_t *option="") const;
77  virtual Long64_t Merge(TCollection* li, TFileMergeInfo *info);
78  virtual void Modified();
79  virtual void Paint(Option_t *chopt="");
80  virtual void Print(Option_t *chopt="") const;
81  virtual void RecursiveRemove(TObject *obj);
82  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
83  virtual void SetHistogram(TH1 *h) {fHistogram = h;}
84  virtual void SetMaximum(Double_t maximum=-1111); // *MENU*
85  virtual void SetMinimum(Double_t minimum=-1111); // *MENU*
86 
87  ClassDef(THStack,2) //A collection of histograms
88 };
89 
90 #endif
91 
TFileMergeInfo
Definition: TFileMergeInfo.h:42
TAxis
Class to manage histogram axis.
Definition: TAxis.h:30
THStack::BuildStack
void BuildStack()
build sum of all histograms Build a separate list fStack containing the running sum of all histograms
Definition: THStack.cxx:386
TBrowser
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
THStack::SetMinimum
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum.
Definition: THStack.cxx:1069
TObjArray
An array of TObjects.
Definition: TObjArray.h:37
Option_t
const char Option_t
Definition: RtypesCore.h:66
THStack::SetMaximum
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum.
Definition: THStack.cxx:1060
THStack
The Histogram stack class.
Definition: THStack.h:38
THStack::fHists
TList * fHists
Definition: THStack.h:43
TNamed.h
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
THStack::fStack
TObjArray * fStack
Definition: THStack.h:44
THStack::SetHistogram
virtual void SetHistogram(TH1 *h)
Definition: THStack.h:83
THStack::Add
virtual void Add(TH1 *h, Option_t *option="")
add a new histogram to the list Only 1-d and 2-d histograms currently supported.
Definition: THStack.cxx:361
THStack::operator=
THStack & operator=(const THStack &)
Int_t
int Int_t
Definition: RtypesCore.h:45
THStack::GetHistogram
TH1 * GetHistogram() const
Returns a pointer to the histogram used to draw the axis Takes into account the two following cases.
Definition: THStack.cxx:478
THStack::GetMaximum
virtual Double_t GetMaximum(Option_t *option="")
returns the maximum of all added histograms returns the maximum of all histograms if option "nostack"...
Definition: THStack.cxx:493
THStack::THStack
THStack()
THStack default constructor.
Definition: THStack.cxx:115
b
#define b(i)
Definition: RSha256.hxx:100
THStack::Print
virtual void Print(Option_t *chopt="") const
Print the list of histograms.
Definition: THStack.cxx:983
THStack::begin
TIter begin() const
Get iterator over internal hists list.
Definition: THStack.cxx:1078
THStack::end
TIter end() const
Definition: THStack.h:69
THStack::GetXaxis
TAxis * GetXaxis() const
Get x axis of the histogram used to draw the stack.
Definition: THStack.cxx:603
THStack::fMinimum
Double_t fMinimum
Definition: THStack.h:47
THStack::GetHists
TList * GetHists() const
Definition: THStack.h:67
THStack::fMaximum
Double_t fMaximum
Definition: THStack.h:46
THStack::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: THStack.cxx:1007
THStack::GetMinimum
virtual Double_t GetMinimum(Option_t *option="")
returns the minimum of all added histograms returns the minimum of all histograms if option "nostack"...
Definition: THStack.cxx:537
THStack::ls
virtual void ls(Option_t *option="") const
List histograms in the stack.
Definition: THStack.cxx:629
h
#define h(i)
Definition: RSha256.hxx:106
THStack::Browse
virtual void Browse(TBrowser *b)
Browse.
Definition: THStack.cxx:376
THStack::fHistogram
TH1 * fHistogram
Pointer to array of sums of TH1.
Definition: THStack.h:45
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
THStack::Paint
virtual void Paint(Option_t *chopt="")
Paint the list of histograms.
Definition: THStack.cxx:699
THStack::GetNhists
Int_t GetNhists() const
Return the number of histograms in the stack.
Definition: THStack.cxx:581
THStack::GetYaxis
TAxis * GetYaxis() const
Get x axis of the histogram used to draw the stack.
Definition: THStack.cxx:618
Double_t
double Double_t
Definition: RtypesCore.h:59
TIter::End
static TIter End()
Pointing to the element after the last - to a nullptr value in our case.
Definition: TCollection.cxx:810
THStack::DistancetoPrimitive
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to each graph.
Definition: THStack.cxx:409
TObjArray.h
THStack::Modified
virtual void Modified()
invalidate sum of histograms
Definition: THStack.cxx:665
THStack::Merge
virtual Long64_t Merge(TCollection *li, TFileMergeInfo *info)
Merge the THStack in the TList into this stack.
Definition: THStack.cxx:642
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TH1
TH1 is the base class of all histogramm classes in ROOT.
Definition: TH1.h:58
name
char name[80]
Definition: TGX11.cxx:110
TIter
Definition: TCollection.h:233
TCollection
Collection abstract base class.
Definition: TCollection.h:63
THStack::GetStack
TObjArray * GetStack()
Return pointer to Stack. Build it if not yet done.
Definition: THStack.cxx:590
THStack::Draw
virtual void Draw(Option_t *chopt="")
Draw this multihist with its current attributes.
Definition: THStack.cxx:447
TH1.h
TList
A doubly linked list.
Definition: TList.h:44
THStack::RecursiveRemove
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from the list of histograms.
Definition: THStack.cxx:997
THStack::~THStack
virtual ~THStack()
THStack destructor.
Definition: THStack.cxx:322
int