139 gROOT->GetListOfCleanups()->Add(
this);
173 const char *
name ,
const char *title ,
180 gROOT->GetListOfCleanups()->Add(
this);
183 Warning(
"THStack",
"Need an axis.");
187 Warning(
"THStack",
"Need a histogram.");
193 Warning(
"THStack",
"Need a histogram deriving from TH2 or TH3.");
211 Warning(
"THStack",
"Need parameter axis=\"x\" or \"y\" for a TH2, not none or both.");
216 Warning(
"THStack",
"Histogram axis is NULL");
240 Warning(
"THStack",
"Invalid length for parameter axis.");
254 Warning(
"THStack",
"Histogram axis is NULL");
288 Warning(
"THStack",
"Histogram axis is NULL");
327 gROOT->GetListOfCleanups()->Remove(
this);
348 fMaximum(
hstack.fMaximum),
353 gROOT->GetListOfCleanups()->Add(
this);
357 while (
auto h =
static_cast<TH1 *
>(next()))
370 Error(
"Add",
"THStack supports only 1-d and 2-d histograms");
383 Draw(
b ?
b->GetDrawOption() :
"");
404 if (
h->GetMinimum() < 0.) {
405 Warning(
"BuildStack",
"Histograms with a negative minimum may produce wrong plots");
435 Int_t dist =
h->DistancetoPrimitive(px,py);
436 if (dist <= 0)
return 0;
458 if (!
gPad->IsEditable())
gROOT->MakeDefCanvas();
487 if (!
gPad)
return nullptr;
530 first =
h->GetXaxis()->GetFirst();
531 last =
h->GetXaxis()->GetLast();
533 e1 =
h->GetBinError(
j);
534 c1 =
h->GetBinContent(
j);
575 first =
h->GetXaxis()->GetFirst();
576 last =
h->GetXaxis()->GetLast();
578 e1 =
h->GetBinError(
j);
579 c1 =
h->GetBinContent(
j);
616 return h ?
h->GetXaxis() :
nullptr;
629 return h ?
h->GetYaxis() :
nullptr;
642 if (!
h)
return nullptr;
643 if (
h->GetDimension() == 1)
644 Warning(
"GetZaxis",
"1D Histograms don't have a Z axis");
645 return h->GetZaxis();
666 if (
li==
nullptr ||
li->GetEntries()==0) {
675 "Cannot merge - an object which doesn't inherit from THStack found in the list");
730 auto ic =
gPad->NextPaletteColor();
763 while (
auto obj =
nextp()) {
779 lnk->GetObject()->Draw(
lnk->GetOption());
794 while ((
h=(
TH1*)next())) {
796 if (
h->GetBuffer())
h->BufferEmpty(-1);
797 if (
h->GetXaxis()->GetXmin() <
xmin)
xmin =
h->GetXaxis()->GetXmin();
798 if (
h->GetXaxis()->GetXmax() >
xmax)
xmax =
h->GetXaxis()->GetXmax();
799 if (
h->GetYaxis()->GetXmin() <
ymin)
ymin =
h->GetYaxis()->GetXmin();
800 if (
h->GetYaxis()->GetXmax() >
ymax)
ymax =
h->GetYaxis()->GetXmax();
820 if (
gPad->GetLogy()){
835 if (
h->GetDimension() > 1) {
838 if (xbins->fN != 0 &&
ybins->fN != 0) {
840 xaxis->GetNbins(), xbins->GetArray(),
842 }
else if (xbins->fN != 0 &&
ybins->fN == 0) {
844 xaxis->GetNbins(), xbins->GetArray(),
846 }
else if (xbins->fN == 0 &&
ybins->fN != 0) {
856 if (xbins->fN != 0) {
858 xaxis->GetNbins(), xbins->GetArray());
870 loption.ReplaceAll(
"nostackb",
"");
996 while (
auto h = next())
1016 out<<
" "<<std::endl;
1022 out<<
GetName()<<
" = new THStack();"<<std::endl;
1040 out<<
" "<<std::endl;
1048 auto h = (
TH1 *)
lnk->GetObject();
1051 h->SavePrimitive(out,
"nodraw");
1054 h->SetName(
hname.Data());
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TVirtualMutex * gROOTMutex
R__EXTERN TStyle * gStyle
#define R__LOCKGUARD(mutex)
Array of doubles (64 bits per element).
Fill Area Attributes class.
virtual Color_t GetFillColor() const
Return the fill area color.
virtual Style_t GetFillStyle() const
Return the fill area style.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Class to manage histogram axis.
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
Int_t GetLast() const
Return last bin on the axis i.e.
Int_t GetFirst() const
Return first bin on the axis i.e.
Using a TBrowser one can browse all ROOT objects.
TClassRef is used to implement a permanent reference to a TClass object.
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Collection abstract base class.
void ls(Option_t *option="") const override
List (ls) all objects in this collection.
virtual Int_t GetEntries() const
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
1-D histogram with a float per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a line.
void SetTitle(const char *title) override
Change/set the title.
virtual Int_t GetDimension() const
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
@ kIsZoomed
Bit set when zooming on Y axis.
TVirtualHistPainter * GetPainter(Option_t *option="")
Return pointer to painter.
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
virtual void SetMaximum(Double_t maximum=-1111)
virtual void SetMinimum(Double_t minimum=-1111)
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
void SetName(const char *name) override
Change the name of this histogram.
void Paint(Option_t *option="") override
Control routine to paint any kind of histograms.
TClass * IsA() const override
static Bool_t AddDirectoryStatus()
Static function: cannot be inlined on Windows/NT.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
2-D histogram with a float per channel (see TH1 documentation)
Service class for 2-D histogram classes.
The 3-D histogram classes derived from the 1-D histogram classes.
The Histogram stack class.
TIter begin() const
Get an iterator over internal hists list.
TClass * IsA() const override
~THStack() override
THStack destructor.
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.
void ls(Option_t *option="") const override
List histograms in the stack.
TObjArray * fStack
! Pointer to array of sums of TH1
void BuildAndPaint(Option_t *chopt, Bool_t paint)
Create all additional objects and stack (if specified).
Double_t fMinimum
Minimum value for plotting along y.
void BuildStack()
Build the sum of all histograms.
TAxis * GetYaxis() const
Get the y-axis of the histogram used to draw the stack.
virtual Long64_t Merge(TCollection *li, TFileMergeInfo *info)
Merge the THStack in the TList into this stack.
TH1 * GetHistogram() const
Returns a pointer to the histogram used to draw the axis.
void RecursiveRemove(TObject *obj) override
Recursively remove the object obj from the list of histograms.
virtual void Add(TH1 *h, Option_t *option="")
Add a new histogram to the list.
void Print(Option_t *chopt="") const override
Print the list of histograms.
TObjArray * GetStack()
Return pointer to Stack. Build it if not yet done.
Int_t GetNhists() const
Return the number of histograms in the stack.
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.
void Draw(Option_t *chopt="") override
Draw this stack with its current attributes.
void Paint(Option_t *chopt="") override
Paint the list of histograms.
TList * fHists
Pointer to array of TH1.
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum.
TH1 * fHistogram
Pointer to histogram used for drawing axis.
TAxis * GetZaxis() const
Get the z-axis of the histogram used to draw the stack.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
void Browse(TBrowser *b) override
Browse.
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px, py to each graph.
virtual void Modified()
Note: this method invalidates the sum of histograms.
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum.
TAxis * GetXaxis() const
Get the x-axis of the histogram used to draw the stack.
Double_t fMaximum
Maximum value for plotting along y.
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
void Clear(Option_t *option="") override
Remove all objects from the list.
virtual TObjLink * LastLink() const
void RecursiveRemove(TObject *obj) override
Remove object from this collection and recursively remove the object from all other objects (and coll...
void Add(TObject *obj) override
TObject * Remove(TObject *obj) override
Remove object from the list.
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
virtual TObjLink * FirstLink() const
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
void AddAt(TObject *obj, Int_t idx) override
Add object at position ids.
void Delete(Option_t *option="") override
Remove all objects from the array AND delete all heap based objects.
TObject * At(Int_t idx) const override
void Add(TObject *obj) override
Collectable string class.
Mother of all ROOT objects.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
@ kCanDelete
if object in a list can be deleted
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
virtual Int_t IndexOf(const TObject *obj) const
Return index of object in collection.
Long64_t Merge(TCollection *list)
Merge this collection with all collections coming in the input list.
void ToLower()
Change string to lower-case.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Bool_t IsWhitespace() const
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Double_t GetHistTopMargin() const
virtual void SetStack(TList *stack)=0
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.