@@ -35,22 +35,23 @@ ClassImp(THStack);
3535 \ingroup Histograms
3636The Histogram stack class
3737
38- A THStack is a collection of TH1 or TH2 histograms.
39- Using THStack::Draw() the histogram collection is drawn in one go according
40- to the drawing option.
38+ A THStack is a collection of TH1 or TH2 histograms. By using THStack::Draw(), the entire
39+ histogram collection is drawn at once according to the specified drawing option.
4140
42- THStack::Add() allows to add a new histogram to the list.
43- The THStack does not own the objects in the list.
41+ THStack::Add() allows adding a new histogram to the list. Note that the THStack does not
42+ take ownership of the objects in the list.
4443
4544\anchor HS00
4645### Stack painting
4746
48- By default, histograms are shown stacked.
49- - the first histogram is paint
50- - then the sum of the first and second, etc
47+ By default, histograms are shown stacked:
48+ - the first histogram is painted
49+ - then the sum of the first and second histograms is painted, and so on
5150
52- The axis ranges are computed automatically along the X and Y axis in
53- order to show the complete histogram collection.
51+ The axis ranges are computed automatically along the X and Y axes to display the complete
52+ histogram collection.
53+
54+ Warning: Histogram bins with negative content may produce wrong plots.
5455
5556### Stack's drawing options
5657
@@ -140,7 +141,7 @@ THStack::THStack(const char *name, const char *title)
140141
141142
142143// //////////////////////////////////////////////////////////////////////////////
143- // / Creates a new THStack from a TH2 or TH3
144+ // / Creates a new THStack from a TH2 or TH3.
144145// / It is filled with the 1D histograms from GetProjectionX or GetProjectionY
145146// / for each bin of the histogram. It illustrates the differences and total
146147// / sum along an axis.
@@ -156,7 +157,7 @@ THStack::THStack(const char *name, const char *title)
156157// / - title: fTitle is set to title if given, otherwise to histo's title
157158// / with ", stack of <axis> projections" appended.
158159// / - firstbin, lastbin:
159- // / for each bin within [firstbin,lastbin] a stack entry is created.
160+ // / For each bin within [firstbin,lastbin] a stack entry is created.
160161// / See TH2::ProjectionX/Y for use overflow bins.
161162// / Defaults to "all bins but under- / overflow"
162163// / - firstbin2, lastbin2:
@@ -317,7 +318,7 @@ THStack::THStack(TH1* hist, Option_t *axis /*="x"*/,
317318}
318319
319320// //////////////////////////////////////////////////////////////////////////////
320- // / THStack destructor
321+ // / THStack destructor.
321322
322323THStack::~THStack ()
323324{
@@ -358,7 +359,7 @@ THStack::THStack(const THStack &hstack) :
358359}
359360
360361// //////////////////////////////////////////////////////////////////////////////
361- // / add a new histogram to the list
362+ // / Add a new histogram to the list.
362363// / Only 1-d and 2-d histograms currently supported.
363364// / A drawing option may be specified
364365
@@ -384,8 +385,8 @@ void THStack::Browse(TBrowser *b)
384385}
385386
386387// //////////////////////////////////////////////////////////////////////////////
387- // / build sum of all histograms
388- // / Build a separate list fStack containing the running sum of all histograms
388+ // / Build the sum of all histograms.
389+ // / Build a separate list fStack containing the running sum of all histograms
389390
390391void THStack::BuildStack ()
391392{
@@ -400,15 +401,17 @@ void THStack::BuildStack()
400401 fStack ->Add (h);
401402 for (Int_t i=1 ;i<nhists;i++) {
402403 h = (TH1*)fHists ->At (i)->Clone ();
404+ if (h->GetMinimum () < 0 .) {
405+ Warning (" BuildStack" ," Histograms with a negative minimum may produce wrong plots" );
406+ }
403407 h->Add ((TH1*)fStack ->At (i-1 ));
404408 fStack ->AddAt (h,i);
405409 }
406410 TH1::AddDirectory (add);
407411}
408412
409413// //////////////////////////////////////////////////////////////////////////////
410- // / Compute distance from point px,py to each graph
411- // /
414+ // / Compute distance from point px, py to each graph.
412415
413416Int_t THStack::DistancetoPrimitive (Int_t px, Int_t py)
414417{
@@ -441,10 +444,10 @@ Int_t THStack::DistancetoPrimitive(Int_t px, Int_t py)
441444}
442445
443446// //////////////////////////////////////////////////////////////////////////////
444- // / Draw this multihist with its current attributes.
447+ // / Draw this stack with its current attributes.
445448// /
446- // / Options to draw histograms are described in THistPainter::Paint
447- // / By default (if option "nostack" is not specified), histograms will be paint
449+ // / Options to draw histograms are described in THistPainter::Paint
450+ // / By default (if the option "nostack" is not specified), histograms will be painted
448451// / stacked on top of each other.
449452
450453void THStack::Draw (Option_t *option)
@@ -464,10 +467,10 @@ void THStack::Draw(Option_t *option)
464467}
465468
466469// //////////////////////////////////////////////////////////////////////////////
467- // / Returns a pointer to the histogram used to draw the axis
468- // / Takes into account the two following cases.
469- // / 1- option 'A' was specified in THStack::Draw. Return fHistogram
470- // / 2- user had called TPad::DrawFrame. return pointer to hframe histogram
470+ // / Returns a pointer to the histogram used to draw the axis.
471+ // / Takes into account the two following cases:
472+ // / 1- option 'A' was specified in THStack::Draw. Return fHistogram
473+ // / 2- user had called TPad::DrawFrame. return pointer to hframe histogram
471474// /
472475// / IMPORTANT NOTES
473476// / - You must call Draw before calling this function. The returned histogram
@@ -489,8 +492,8 @@ TH1 *THStack::GetHistogram() const
489492}
490493
491494// //////////////////////////////////////////////////////////////////////////////
492- // / returns the maximum of all added histograms smaller than maxval.
493- // / returns the maximum of all histograms, smaller than maxval, if option "nostack".
495+ // / Returns the maximum of all added histograms smaller than maxval.
496+ // / Returns the maximum of all histograms, smaller than maxval, if option "nostack".
494497
495498Double_t THStack::GetMaximum (Option_t *option, Double_t maxval)
496499{
@@ -538,8 +541,8 @@ Double_t THStack::GetMaximum(Option_t *option, Double_t maxval)
538541}
539542
540543// //////////////////////////////////////////////////////////////////////////////
541- // / Returns the minimum of all added histograms larger than minval.
542- // / Returns the minimum of all histograms, larger than minval, if option "nostack".
544+ // / Returns the minimum of all added histograms larger than minval.
545+ // / Returns the minimum of all histograms, larger than minval, if option "nostack".
543546
544547Double_t THStack::GetMinimum (Option_t *option, Double_t minval)
545548{
@@ -592,7 +595,7 @@ Int_t THStack::GetNhists() const
592595}
593596
594597// //////////////////////////////////////////////////////////////////////////////
595- // / Return pointer to Stack. Build it if not yet done
598+ // / Return pointer to Stack. Build it if not yet done.
596599
597600TObjArray *THStack::GetStack ()
598601{
@@ -601,7 +604,7 @@ TObjArray *THStack::GetStack()
601604}
602605
603606// //////////////////////////////////////////////////////////////////////////////
604- // / Get x axis of the histogram used to draw the stack.
607+ // / Get the x- axis of the histogram used to draw the stack.
605608// /
606609// / IMPORTANT NOTE
607610// / You must call Draw before calling this function. The returned histogram
@@ -614,7 +617,7 @@ TAxis *THStack::GetXaxis() const
614617}
615618
616619// //////////////////////////////////////////////////////////////////////////////
617- // / Get y axis of the histogram used to draw the stack.
620+ // / Get the y- axis of the histogram used to draw the stack.
618621// /
619622// / IMPORTANT NOTE
620623// / You must call Draw before calling this function. The returned histogram
@@ -627,7 +630,7 @@ TAxis *THStack::GetYaxis() const
627630}
628631
629632// //////////////////////////////////////////////////////////////////////////////
630- // / Get z axis of the histogram used to draw the stack.
633+ // / Get the z- axis of the histogram used to draw the stack.
631634// /
632635// / IMPORTANT NOTE
633636// / You must call Draw before calling this function. The returned histogram
@@ -643,7 +646,7 @@ TAxis *THStack::GetZaxis() const
643646}
644647
645648// //////////////////////////////////////////////////////////////////////////////
646- // / List histograms in the stack
649+ // / List histograms in the stack.
647650
648651void THStack::ls (Option_t *option) const
649652{
@@ -679,7 +682,7 @@ Long64_t THStack::Merge(TCollection* li, TFileMergeInfo * /* info */)
679682}
680683
681684// //////////////////////////////////////////////////////////////////////////////
682- // / invalidate sum of histograms
685+ // / Note: this method invalidates the sum of histograms.
683686
684687void THStack::Modified ()
685688{
@@ -700,7 +703,7 @@ void THStack::Paint(Option_t *chopt)
700703}
701704
702705// //////////////////////////////////////////////////////////////////////////////
703- // / Create all additional objects and stack (if specified)
706+ // / Create all additional objects and stack (if specified).
704707
705708void THStack::BuildAndPaint (Option_t *choptin, Bool_t paint)
706709{
@@ -995,7 +998,7 @@ void THStack::Print(Option_t *option) const
995998}
996999
9971000// //////////////////////////////////////////////////////////////////////////////
998- // / Recursively remove object from the list of histograms
1001+ // / Recursively remove the object `obj` from the list of histograms.
9991002
10001003void THStack::RecursiveRemove (TObject *obj)
10011004{
@@ -1005,7 +1008,7 @@ void THStack::RecursiveRemove(TObject *obj)
10051008}
10061009
10071010// //////////////////////////////////////////////////////////////////////////////
1008- // / Save primitive as a C++ statement(s) on output stream out
1011+ // / Save primitive as a C++ statement(s) on output stream out.
10091012
10101013void THStack::SavePrimitive (std::ostream &out, Option_t *option /* = ""*/ )
10111014{
@@ -1074,7 +1077,7 @@ void THStack::SetMinimum(Double_t minimum)
10741077
10751078
10761079// //////////////////////////////////////////////////////////////////////////////
1077- // / Get iterator over internal hists list.
1080+ // / Get an iterator over internal hists list.
10781081TIter THStack::begin () const
10791082{
10801083 return TIter (fHists );
0 commit comments