Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
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
28class TH1;
29class TList;
30class TAxis;
31#else
32#include "TH1.h"
33#endif
34
35#include <limits>
36
37class TBrowser;
38class TFileMergeInfo;
39
40class THStack : public TNamed {
41private:
42 THStack& operator=(const THStack&) = delete;
43
44protected:
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
50
51 void BuildStack();
52
53 void BuildAndPaint(Option_t *chopt, Bool_t paint, Bool_t rebuild_stack = kFALSE);
54
55public:
56
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 = "", Bool_t rebuild_stack = kFALSE) { BuildAndPaint(chopt, kFALSE, rebuild_stack); }
68 void Browse(TBrowser *b) 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(); }
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;
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*
92
93 ClassDefOverride(THStack,2) //A collection of histograms
94};
95
96#endif
97
#define b(i)
Definition RSha256.hxx:100
#define h(i)
Definition RSha256.hxx:106
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
char name[80]
Definition TGX11.cxx:148
Class to manage histogram axis.
Definition TAxis.h:32
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
Collection abstract base class.
Definition TCollection.h:65
A class to pass information from the TFileMerger to the objects being merged.
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:109
THStack(TH1 *hist, Option_t *axis="x", const char *name=nullptr, const char *title=nullptr, Int_t firstbin=1, Int_t lastbin=-1, Int_t firstbin2=1, Int_t lastbin2=-1, Option_t *proj_option="", Option_t *draw_option="")
TIter begin() const
virtual Double_t GetMinimum(Option_t *option="", Double_t minval=-std::numeric_limits< Double_t >::max())
void BuildPrimitives(Option_t *chopt="", Bool_t rebuild_stack=kFALSE)
Definition THStack.h:67
~THStack() override
THStack()
Definition THStack.h:57
void BuildAndPaint(Option_t *chopt, Bool_t paint, Bool_t rebuild_stack=kFALSE)
void ls(Option_t *option="") const override
The ls function lists the contents of a class on stdout.
TObjArray * fStack
! Pointer to array of sums of TH1
Definition THStack.h:46
THStack(const THStack &hstack)
Double_t fMinimum
Minimum value for plotting along y.
Definition THStack.h:49
void BuildStack()
TList * GetHists() const
Definition THStack.h:72
TAxis * GetYaxis() const
TH1 * GetHistogram() const
virtual void SetHistogram(TH1 *h)
Definition THStack.h:89
void RecursiveRemove(TObject *obj) override
Recursively remove this object from a list.
void Print(Option_t *chopt="") const override
This method must be overridden when a class wants to print itself.
TObjArray * GetStack()
THStack & operator=(const THStack &)=delete
THStack(const char *name, const char *title)
virtual Double_t GetMaximum(Option_t *option="", Double_t maxval=std::numeric_limits< Double_t >::max())
Int_t GetNhists() const
virtual void Modified()
void Draw(Option_t *chopt="") override
Default Draw method for all objects.
void Paint(Option_t *chopt="") override
This method must be overridden if a class wants to paint itself.
TIter end() const
Definition THStack.h:74
TList * fHists
Pointer to array of TH1.
Definition THStack.h:45
virtual Long64_t Merge(TCollection *li, TFileMergeInfo *info)
TH1 * fHistogram
Pointer to histogram used for drawing axis.
Definition THStack.h:47
virtual void SetMinimum(Double_t minimum=-1111)
TAxis * GetZaxis() const
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
void Browse(TBrowser *b) override
Browse object. May be overridden for another default action.
virtual void SetMaximum(Double_t maximum=-1111)
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Computes distance from point (px,py) to the object.
virtual void Add(TH1 *h, Option_t *option="")
TAxis * GetXaxis() const
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
TNamed()
Definition TNamed.h:38
An array of TObjects.
Definition TObjArray.h:31
TObject()
TObject constructor.
Definition TObject.h:259