Logo ROOT   6.14/05
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 "TH1.h"
25 #include "TObjArray.h"
26 
27 
28 class TBrowser;
29 class TFileMergeInfo;
30 
31 class THStack : public TNamed {
32 private:
33  THStack& operator=(const THStack&); // Not implemented
34 
35 protected:
36  TList *fHists; //Pointer to array of TH1
37  TObjArray *fStack; //!Pointer to array of sums of TH1
38  TH1 *fHistogram; //Pointer to histogram used for drawing axis
39  Double_t fMaximum; //Maximum value for plotting along y
40  Double_t fMinimum; //Minimum value for plotting along y
41 
42  void BuildStack();
43 
44 public:
45 
46  THStack();
47  THStack(const char *name, const char *title);
48  THStack(TH1* hist, Option_t *axis="x",
49  const char *name=0, const char *title=0,
50  Int_t firstbin=1, Int_t lastbin=-1,
51  Int_t firstbin2=1, Int_t lastbin2=-1,
52  Option_t* proj_option="", Option_t* draw_option="");
53  THStack(const THStack &hstack);
54  virtual ~THStack();
55  virtual void Add(TH1 *h, Option_t *option="");
56  virtual void Browse(TBrowser *b);
57  virtual Int_t DistancetoPrimitive(Int_t px, Int_t py);
58  virtual void Draw(Option_t *chopt="");
59  TH1 *GetHistogram() const;
60  TList *GetHists() const { return fHists; }
61  TIter begin() const;
62  TIter end() const { return TIter::End(); }
63  Int_t GetNhists() const;
65  virtual Double_t GetMaximum(Option_t *option="");
66  virtual Double_t GetMinimum(Option_t *option="");
67  TAxis *GetXaxis() const;
68  TAxis *GetYaxis() const;
69  virtual void ls(Option_t *option="") const;
70  virtual Long64_t Merge(TCollection* li, TFileMergeInfo *info);
71  virtual void Modified();
72  virtual void Paint(Option_t *chopt="");
73  virtual void Print(Option_t *chopt="") const;
74  virtual void RecursiveRemove(TObject *obj);
75  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
76  virtual void SetHistogram(TH1 *h) {fHistogram = h;}
77  virtual void SetMaximum(Double_t maximum=-1111); // *MENU*
78  virtual void SetMinimum(Double_t minimum=-1111); // *MENU*
79 
80  ClassDef(THStack,2) //A collection of histograms
81 };
82 
83 #endif
84 
virtual void Print(Option_t *chopt="") const
Print the list of histograms.
Definition: THStack.cxx:972
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from the list of histograms.
Definition: THStack.cxx:986
An array of TObjects.
Definition: TObjArray.h:37
Double_t fMinimum
Definition: THStack.h:40
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:476
The Histogram stack class.
Definition: THStack.h:31
const char Option_t
Definition: RtypesCore.h:62
THStack & operator=(const THStack &)
TAxis * GetXaxis() const
Get x axis of the histogram used to draw the stack.
Definition: THStack.cxx:601
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save primitive as a C++ statement(s) on output stream out.
Definition: THStack.cxx:996
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:640
virtual void Draw(Option_t *chopt="")
Draw this multihist with its current attributes.
Definition: THStack.cxx:445
Double_t fMaximum
Definition: THStack.h:39
virtual void Paint(Option_t *chopt="")
Paint the list of histograms.
Definition: THStack.cxx:697
#define ClassDef(name, id)
Definition: Rtypes.h:320
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:491
TObjArray * GetStack()
Return pointer to Stack. Build it if not yet done.
Definition: THStack.cxx:588
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void ls(Option_t *option="") const
List histograms in the stack.
Definition: THStack.cxx:627
virtual void Modified()
invalidate sum of histograms
Definition: THStack.cxx:663
TList * fHists
Definition: THStack.h:36
virtual ~THStack()
THStack destructor.
Definition: THStack.cxx:320
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to each graph.
Definition: THStack.cxx:407
A doubly linked list.
Definition: TList.h:44
void BuildStack()
build sum of all histograms Build a separate list fStack containing the running sum of all histograms...
Definition: THStack.cxx:384
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum.
Definition: THStack.cxx:1058
virtual void SetHistogram(TH1 *h)
Definition: THStack.h:76
Class to manage histogram axis.
Definition: TAxis.h:30
TList * GetHists() const
Definition: THStack.h:60
TObjArray * fStack
Definition: THStack.h:37
TIter begin() const
Get iterator over internal hists list.
Definition: THStack.cxx:1067
Collection abstract base class.
Definition: TCollection.h:63
TIter end() const
Definition: THStack.h:62
THStack()
THStack default constructor.
Definition: THStack.cxx:113
#define h(i)
Definition: RSha256.hxx:106
static TIter End()
Pointing to the element after the last - to a nullptr value in our case.
virtual void Browse(TBrowser *b)
Browse.
Definition: THStack.cxx:374
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:359
The TH1 histogram class.
Definition: TH1.h:56
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:616
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:579
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum.
Definition: THStack.cxx:1049
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:535
char name[80]
Definition: TGX11.cxx:109
TH1 * fHistogram
Pointer to array of sums of TH1.
Definition: THStack.h:38