Logo ROOT   6.08/07
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 #ifndef ROOT_TH1
25 #include "TH1.h"
26 #endif
27 #ifndef ROOT_TObjArray
28 #include "TObjArray.h"
29 #endif
30 
31 
32 class TBrowser;
33 class TFileMergeInfo;
34 
35 class THStack : public TNamed {
36 private:
37  THStack& operator=(const THStack&); // Not implemented
38 
39 protected:
40  TList *fHists; //Pointer to array of TH1
41  TObjArray *fStack; //!Pointer to array of sums of TH1
42  TH1 *fHistogram; //Pointer to histogram used for drawing axis
43  Double_t fMaximum; //Maximum value for plotting along y
44  Double_t fMinimum; //Minimum value for plotting along y
45 
46  void BuildStack();
47 
48 public:
49 
50  THStack();
51  THStack(const char *name, const char *title);
52  THStack(TH1* hist, Option_t *axis="x",
53  const char *name=0, const char *title=0,
54  Int_t firstbin=1, Int_t lastbin=-1,
55  Int_t firstbin2=1, Int_t lastbin2=-1,
56  Option_t* proj_option="", Option_t* draw_option="");
57  THStack(const THStack &hstack);
58  virtual ~THStack();
59  virtual void Add(TH1 *h, Option_t *option="");
60  virtual void Browse(TBrowser *b);
61  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
62  virtual void Draw(Option_t *chopt="");
63  TH1 *GetHistogram() const;
64  TList *GetHists() const { return fHists; }
65  Int_t GetNhists() const;
67  virtual Double_t GetMaximum(Option_t *option="");
68  virtual Double_t GetMinimum(Option_t *option="");
69  TAxis *GetXaxis() const;
70  TAxis *GetYaxis() const;
71  virtual void ls(Option_t *option="") const;
72  virtual Long64_t Merge(TCollection* li, TFileMergeInfo *info);
73  virtual void Modified();
74  virtual void Paint(Option_t *chopt="");
75  virtual void Print(Option_t *chopt="") const;
76  virtual void RecursiveRemove(TObject *obj);
77  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
78  virtual void SetHistogram(TH1 *h) {fHistogram = h;}
79  virtual void SetMaximum(Double_t maximum=-1111); // *MENU*
80  virtual void SetMinimum(Double_t minimum=-1111); // *MENU*
81 
82  ClassDef(THStack,2) //A collection of histograms
83 };
84 
85 #endif
86 
virtual void Print(Option_t *chopt="") const
Print the list of histograms.
Definition: THStack.cxx:926
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from the list of histograms.
Definition: THStack.cxx:940
An array of TObjects.
Definition: TObjArray.h:39
Double_t fMinimum
Definition: THStack.h:44
long long Long64_t
Definition: RtypesCore.h:69
TH1 * GetHistogram() const
Returns a pointer to the histogram used to draw the axis Takes into account the two following cases...
Definition: THStack.cxx:462
The Histogram stack class.
Definition: THStack.h:35
const char Option_t
Definition: RtypesCore.h:62
THStack & operator=(const THStack &)
TH1 * h
Definition: legend2.C:5
TAxis * GetXaxis() const
Get x axis of the histogram used to draw the stack.
Definition: THStack.cxx:587
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: THStack.cxx:950
int Int_t
Definition: RtypesCore.h:41
virtual Long64_t Merge(TCollection *li, TFileMergeInfo *info)
Merge the THStack in the TList into this stack.
Definition: THStack.cxx:626
virtual void Draw(Option_t *chopt="")
Draw this multihist with its current attributes.
Definition: THStack.cxx:431
Double_t fMaximum
Definition: THStack.h:43
virtual void Paint(Option_t *chopt="")
Paint the list of histograms.
Definition: THStack.cxx:683
#define ClassDef(name, id)
Definition: Rtypes.h:254
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:477
TObjArray * GetStack()
Return pointer to Stack. Build it if not yet done.
Definition: THStack.cxx:574
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
virtual void ls(Option_t *option="") const
List histograms in the stack.
Definition: THStack.cxx:613
virtual void Modified()
invalidate sum of histograms
Definition: THStack.cxx:649
TList * fHists
Definition: THStack.h:40
virtual ~THStack()
THStack destructor.
Definition: THStack.cxx:309
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to each graph.
Definition: THStack.cxx:393
A doubly linked list.
Definition: TList.h:47
void BuildStack()
build sum of all histograms Build a separate list fStack containing the running sum of all histograms...
Definition: THStack.cxx:370
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum.
Definition: THStack.cxx:1008
virtual void SetHistogram(TH1 *h)
Definition: THStack.h:78
Class to manage histogram axis.
Definition: TAxis.h:36
TList * GetHists() const
Definition: THStack.h:64
TObjArray * fStack
Definition: THStack.h:41
Collection abstract base class.
Definition: TCollection.h:48
THStack()
THStack default constructor.
Definition: THStack.cxx:105
virtual void Browse(TBrowser *b)
Browse.
Definition: THStack.cxx:360
double Double_t
Definition: RtypesCore.h:55
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:345
The TH1 histogram class.
Definition: TH1.h:80
Mother of all ROOT objects.
Definition: TObject.h:37
TAxis * GetYaxis() const
Get x axis of the histogram used to draw the stack.
Definition: THStack.cxx:602
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
Int_t GetNhists() const
Return the number of histograms in the stack.
Definition: THStack.cxx:565
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum.
Definition: THStack.cxx:999
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:521
char name[80]
Definition: TGX11.cxx:109
TH1 * fHistogram
Pointer to array of sums of TH1.
Definition: THStack.h:42