Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
THStack.cxx
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#include "TROOT.h"
13#include "TClassRef.h"
14#include "THStack.h"
15#include "TVirtualPad.h"
16#include "TVirtualHistPainter.h"
17#include "THashList.h"
18#include "TH2.h"
19#include "TH3.h"
20#include "TList.h"
21#include "TStyle.h"
22#include "TBrowser.h"
23#include "TMath.h"
24#include "TObjString.h"
25#include "TVirtualMutex.h"
26#include "strlcpy.h"
27
28#include <iostream>
29
31
32////////////////////////////////////////////////////////////////////////////////
33
34/** \class THStack
35 \ingroup Histograms
36The Histogram stack class
37
38A THStack is a collection of TH1 or TH2 histograms. By using THStack::Draw(), the entire
39histogram collection is drawn at once according to the specified drawing option.
40
41THStack::Add() allows adding a new histogram to the list. Note that the THStack does not
42take ownership of the objects in the list.
43
44\anchor HS00
45### Stack painting
46
47By 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
50
51The axis ranges are computed automatically along the X and Y axes to display the complete
52histogram collection.
53
54Warning: Histogram bins with negative content may produce wrong plots.
55
56### Stack's drawing options
57
58The specific stack's drawing options are:
59
60 - **NOSTACK** If option "nostack" is specified, histograms are all painted in the same pad
61 as if the option "same" had been specified.
62
63 - **NOSTACKB** If the option "nostackb" is specified histograms are all painted on the same pad
64 next to each other as bar plots.
65
66 - **PADS** if option "pads" is specified, the current pad/canvas is subdivided into
67 a number of pads equal to the number of histograms and each histogram
68 is painted into a separate pad.
69
70 - **NOCLEAR** By default the background of the histograms is erased before drawing the
71 histograms. The option "noclear" avoids this behavior. This is useful when drawing a
72 THStack on top of another plot. If the patterns used to draw the histograms in the
73 stack are transparent, then the plot behind will be visible.
74
75See the THistPainter class for the list of valid histograms' painting options.
76
77
78Example;
79
80Begin_Macro(source)
81{
82 auto hs = new THStack("hs","");
83 auto h1 = new TH1F("h1","test hstack",10,-4,4);
84 h1->FillRandom("gaus",20000);
85 h1->SetFillColor(kRed);
86 hs->Add(h1);
87 auto h2 = new TH1F("h2","test hstack",10,-4,4);
88 h2->FillRandom("gaus",15000);
89 h2->SetFillColor(kBlue);
90 hs->Add(h2);
91 auto h3 = new TH1F("h3","test hstack",10,-4,4);
92 h3->FillRandom("gaus",10000);
93 h3->SetFillColor(kGreen);
94 hs->Add(h3);
95 auto cs = new TCanvas("cs","cs",10,10,700,900);
96 TText T; T.SetTextFont(42); T.SetTextAlign(21);
97 cs->Divide(2,2);
98 cs->cd(1); hs->Draw(); T.DrawTextNDC(.5,.95,"Default drawing option");
99 cs->cd(2); hs->Draw("nostack"); T.DrawTextNDC(.5,.95,"Option \"nostack\"");
100 cs->cd(3); hs->Draw("nostackb"); T.DrawTextNDC(.5,.95,"Option \"nostackb\"");
101 cs->cd(4); hs->Draw("lego1"); T.DrawTextNDC(.5,.95,"Option \"lego1\"");
102}
103End_Macro
104
105A more complex example:
106
107Begin_Macro(source)
108../../../tutorials/hist/hist023_THStack_simple.C
109End_Macro
110
111Note that picking is supported for all drawing modes.
112
113\since **ROOT version 6.07/07:**
114Stacks of 2D histograms can also be painted as candle plots:
115\since **ROOT version 6.09/02:**
116Stacks of 2D histograms can also be painted as violin plots, combinations of candle and
117violin plots are possible as well:
118
119Begin_Macro(source)
120../../../tutorials/hist/hist051_Graphics_candle_plot_stack.C
121End_Macro
122
123Automatic coloring according to the current palette is available as shown in the
124following example:
125
126Begin_Macro(source)
127../../../tutorials/hist/hist027_THStack_palette_color.C
128End_Macro
129*/
130
131////////////////////////////////////////////////////////////////////////////////
132/// constructor with name and title
133
134THStack::THStack(const char *name, const char *title)
135 : TNamed(name,title)
136{
138 gROOT->GetListOfCleanups()->Add(this);
139}
140
141
142////////////////////////////////////////////////////////////////////////////////
143/// Creates a new THStack from a TH2 or TH3.
144/// It is filled with the 1D histograms from GetProjectionX or GetProjectionY
145/// for each bin of the histogram. It illustrates the differences and total
146/// sum along an axis.
147///
148/// Parameters:
149/// - hist: the histogram used for the projections. Can be an object deriving
150/// from TH2 or TH3.
151/// - axis: for TH2: "x" for ProjectionX, "y" for ProjectionY.
152/// for TH3: see TH3::Project3D.
153/// - name: fName is set to name if given, otherwise to histo's name with
154/// "_stack_<axis>" appended, where `<axis>` is the value of the
155/// parameter axis.
156/// - title: fTitle is set to title if given, otherwise to histo's title
157/// with ", stack of <axis> projections" appended.
158/// - firstbin, lastbin:
159/// For each bin within [firstbin,lastbin] a stack entry is created.
160/// See TH2::ProjectionX/Y for use overflow bins.
161/// Defaults to "all bins but under- / overflow"
162/// - firstbin2, lastbin2:
163/// Other axis range for TH3::Project3D, defaults to "all bins but
164/// under- / overflow". Ignored for TH2s
165/// - proj_option:
166/// option passed to TH2::ProjectionX/Y and TH3::Project3D (along
167/// with axis)
168/// - draw_option:
169/// option passed to THStack::Add.
170
171THStack::THStack(TH1* hist, Option_t *axis /*="x"*/,
172 const char *name /*=nullptr*/, const char *title /*=nullptr*/,
173 Int_t firstbin /*=1*/, Int_t lastbin /*=-1*/,
174 Int_t firstbin2 /*=1*/, Int_t lastbin2 /*=-1*/,
175 Option_t* proj_option /*=""*/, Option_t* draw_option /*=""*/)
176 : TNamed(name, title) {
177 {
179 gROOT->GetListOfCleanups()->Add(this);
180 }
181 if (!axis) {
182 Warning("THStack", "Need an axis.");
183 return;
184 }
185 if (!hist) {
186 Warning("THStack", "Need a histogram.");
187 return;
188 }
189 Bool_t isTH2 = hist->IsA()->InheritsFrom(TH2::Class());
190 Bool_t isTH3 = hist->IsA()->InheritsFrom(TH3::Class());
191 if (!isTH2 && !isTH3) {
192 Warning("THStack", "Need a histogram deriving from TH2 or TH3.");
193 return;
194 }
195
196 if (!fName.Length())
197 fName.Form("%s_stack%s", hist->GetName(), axis);
198 if (!fTitle.Length()) {
199 if (hist->GetTitle() && strlen(hist->GetTitle()))
200 fTitle.Form("%s, stack of %s projections", hist->GetTitle(), axis);
201 else
202 fTitle.Form("stack of %s projections", axis);
203 }
204
205 if (isTH2) {
206 TH2* hist2 = (TH2*) hist;
207 Bool_t useX = (strchr(axis,'x')) || (strchr(axis,'X'));
208 Bool_t useY = (strchr(axis,'y')) || (strchr(axis,'Y'));
209 if ((!useX && !useY) || (useX && useY)) {
210 Warning("THStack", "Need parameter axis=\"x\" or \"y\" for a TH2, not none or both.");
211 return;
212 }
213 TAxis* haxis = useX ? hist->GetYaxis() : hist->GetXaxis();
214 if (!haxis) {
215 Warning("THStack","Histogram axis is NULL");
216 return;
217 }
218 Int_t nbins = haxis->GetNbins();
219 if (firstbin < 0) firstbin = 1;
220 if (lastbin < 0) lastbin = nbins;
221 if (lastbin > nbins+1) lastbin = nbins;
222 for (Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
223 TH1* hProj = nullptr;
224 if (useX)
225 hProj = hist2->ProjectionX(TString::Format("%s_px%d",hist2->GetName(), iBin).Data(),
227 else
228 hProj = hist2->ProjectionY(TString::Format("%s_py%d",hist2->GetName(), iBin).Data(),
231 }
232 } else {
233 // hist is a TH3
234 TH3* hist3 = (TH3*) hist;
235 TString sAxis(axis);
236 sAxis.ToLower();
237 Int_t dim=3-sAxis.Length();
238 if (dim<1 || dim>2) {
239 Warning("THStack", "Invalid length for parameter axis.");
240 return;
241 }
242
243 if (dim==1) {
244 TAxis* haxis = nullptr;
245 // look for the haxis _not_ in axis
246 if (sAxis.First('x')==kNPOS)
247 haxis = hist->GetXaxis();
248 else if (sAxis.First('y')==kNPOS)
249 haxis = hist->GetYaxis();
250 else if (sAxis.First('z')==kNPOS)
251 haxis = hist->GetZaxis();
252 if (!haxis) {
253 Warning("THStack","Histogram axis is NULL");
254 return;
255 }
256
257 Int_t nbins = haxis->GetNbins();
258 if (firstbin < 0) firstbin = 1;
259 if (lastbin < 0) lastbin = nbins;
260 if (lastbin > nbins+1) lastbin = nbins;
261 Int_t iFirstOld=haxis->GetFirst();
262 Int_t iLastOld=haxis->GetLast();
263 for (Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
264 haxis->SetRange(iBin, iBin);
265 // build projection named axis_iBin (passed through "option")
266 TH1* hProj = hist3->Project3D(TString::Format("%s_%s%s_%d", hist3->GetName(),
267 axis, proj_option, iBin).Data());
269 }
270 haxis->SetRange(iFirstOld, iLastOld);
271 } else {
272 // if dim==2
273 TAxis* haxis1 = nullptr;
274 TAxis* haxis2 = nullptr;
275 // look for the haxis _not_ in axis
276 if (sAxis.First('x')!=kNPOS) {
277 haxis1=hist->GetYaxis();
278 haxis2=hist->GetZaxis();
279 } else if (sAxis.First('y')!=kNPOS) {
280 haxis1=hist->GetXaxis();
281 haxis2=hist->GetZaxis();
282 } else if (sAxis.First('z')!=kNPOS) {
283 haxis1=hist->GetXaxis();
284 haxis2=hist->GetYaxis();
285 }
286 if (!haxis1 || !haxis2) {
287 Warning("THStack","Histogram axis is NULL");
288 return;
289 }
290
291 Int_t nbins1 = haxis1->GetNbins();
292 Int_t nbins2 = haxis2->GetNbins();
293 if (firstbin < 0) firstbin = 1;
294 if (lastbin < 0) lastbin = nbins1;
295 if (lastbin > nbins1+1) lastbin = nbins1;
296 if (firstbin2 < 0) firstbin2 = 1;
297 if (lastbin2 < 0) lastbin2 = nbins2;
298 if (lastbin2 > nbins2+1) lastbin2 = nbins2;
299 Int_t iFirstOld1 = haxis1->GetFirst();
300 Int_t iLastOld1 = haxis1->GetLast();
301 Int_t iFirstOld2 = haxis2->GetFirst();
302 Int_t iLastOld2 = haxis2->GetLast();
303 for (Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
304 haxis1->SetRange(iBin, iBin);
305 for (Int_t jBin=firstbin2; jBin<=lastbin2; jBin++) {
306 haxis2->SetRange(jBin, jBin);
307 // build projection named axis_iBin (passed through "option")
308 TH1* hProj=hist3->Project3D(TString::Format("%s_%s%s_%d", hist3->GetName(),
309 axis, proj_option, iBin).Data());
311 }
312 }
313 haxis1->SetRange(iFirstOld1, iLastOld1);
314 haxis2->SetRange(iFirstOld2, iLastOld2);
315 }
316 } // if hist is TH2 or TH3
317}
318
319////////////////////////////////////////////////////////////////////////////////
320/// THStack destructor.
321
323{
324 {
326 gROOT->GetListOfCleanups()->Remove(this);
327 }
328 if (fHists) {
329 fHists->Clear("nodelete");
330 delete fHists;
331 fHists = nullptr;
332 }
333 if (fStack) {
334 fStack->Delete();
335 delete fStack;
336 fStack = nullptr;
337 }
338 delete fHistogram;
339 fHistogram = nullptr;
340}
341
342////////////////////////////////////////////////////////////////////////////////
343/// THStack copy constructor
344
346 TNamed(hstack),
347 fMaximum(hstack.fMaximum),
348 fMinimum(hstack.fMinimum)
349{
350 {
352 gROOT->GetListOfCleanups()->Add(this);
353 }
354
355 TIter next(hstack.GetHists());
356 while (auto h = static_cast<TH1 *>(next()))
357 Add(h);
358}
359
360////////////////////////////////////////////////////////////////////////////////
361/// Add a new histogram to the list.
362/// Only 1-d and 2-d histograms currently supported.
363/// A drawing option may be specified
364
366{
367 if (!h1) return;
368 if (h1->GetDimension() > 2) {
369 Error("Add","THStack supports only 1-d and 2-d histograms");
370 return;
371 }
372 if (!fHists) fHists = new TList();
374 Modified(); //invalidate stack
375}
376
377////////////////////////////////////////////////////////////////////////////////
378/// Browse.
379
381{
382 Draw(b ? b->GetDrawOption() : "");
383 gPad->Update();
384}
385
386////////////////////////////////////////////////////////////////////////////////
387/// Build the sum of all histograms.
388/// Build a separate list fStack containing the running sum of all histograms
389
391{
392 if (fStack) return;
393 if (!fHists) return;
395 if (!nhists) return;
396 fStack = new TObjArray(nhists);
399 TH1 *h = (TH1*)fHists->At(0)->Clone();
400 fStack->Add(h);
401 for (Int_t i=1;i<nhists;i++) {
402 h = (TH1*)fHists->At(i)->Clone();
403 if (h->GetMinimum() < 0.) {
404 Warning("BuildStack","Histograms with a negative minimum may produce wrong plots");
405 }
406 h->Add((TH1*)fStack->At(i-1));
407 fStack->AddAt(h,i);
408 }
410}
411
412////////////////////////////////////////////////////////////////////////////////
413/// Compute distance from point px, py to each graph.
414
416{
417 //*-*- Are we on the axis?
418 const Int_t kMaxDiff = 10;
419 Int_t distance = 9999;
420 if (fHistogram) {
422 if (distance <= 0) {return distance;}
423 if (distance <= 1) {gPad->SetSelected(fHistogram);return distance;}
424 }
425
426
427 //*-*- Loop on the list of histograms
428 if (!fHists) return distance;
429 const char *doption = GetDrawOption();
431 for (Int_t i=0;i<nhists;i++) {
432 TH1 *h = (TH1*)fHists->At(i);
433 if (fStack && !strstr(doption,"nostack")) h = (TH1*)fStack->At(i);
434 Int_t dist = h->DistancetoPrimitive(px,py);
435 if (dist <= 0) return 0;
436 if (dist < kMaxDiff) {
437 gPad->SetSelected(fHists->At(i));
438 gPad->SetCursor(kPointer);
439 return dist;
440 }
441 }
442 return distance;
443}
444
445////////////////////////////////////////////////////////////////////////////////
446/// Draw this stack with its current attributes.
447///
448/// Options to draw histograms are described in THistPainter::Paint
449/// By default (if the option "nostack" is not specified), histograms will be painted
450/// stacked on top of each other.
451
453{
454 TString opt = option;
455 opt.ToLower();
456 if (gPad) {
457 if (!gPad->IsEditable()) gROOT->MakeDefCanvas();
458 if (!opt.Contains("same") && !opt.Contains("pads")) {
459 //the following statement is necessary in case one attempts to draw
460 //a temporary histogram already in the current pad
461 if (TestBit(kCanDelete)) gPad->Remove(this);
462 gPad->Clear();
463 }
464 }
465 AppendPad(opt.Data());
466}
467
468////////////////////////////////////////////////////////////////////////////////
469/// Returns a pointer to the histogram used to draw the axis.
470/// Takes into account the two following cases:
471/// 1- option 'A' was specified in THStack::Draw. Return fHistogram
472/// 2- user had called TPad::DrawFrame. return pointer to hframe histogram
473///
474/// IMPORTANT NOTES
475/// - You must call Draw before calling this function. The returned histogram
476/// depends on the selected Draw options.
477/// - This function returns a pointer to an intermediate fixed bin size
478/// histogram used to set the range and for picking.
479/// You cannot use this histogram to return the bin information.
480/// You must get a pointer to one of the histograms in the stack,
481/// the first one, for example.
482
484{
485 if (fHistogram) return fHistogram;
486 if (!gPad) return nullptr;
487 gPad->Modified();
488 gPad->Update();
489 if (fHistogram) return fHistogram;
490 return (TH1*)gPad->FindObject("hframe");
491}
492
493////////////////////////////////////////////////////////////////////////////////
494/// Returns the maximum of all added histograms smaller than maxval.
495/// Returns the maximum of all histograms, smaller than maxval, if option "nostack".
496
498{
499 TString opt = option;
500 opt.ToLower();
501 Bool_t lerr = opt.Contains("e");
502 Double_t themax = -std::numeric_limits<Double_t>::max();
503 if (!fHists) return 0;
505
506 auto check_error = [&themax](TH1 *h) {
507 Int_t first = h->GetXaxis()->GetFirst();
508 Int_t last = h->GetXaxis()->GetLast();
509 for (Int_t j = first; j <= last; j++) {
510 Double_t e1 = h->GetBinError(j);
511 Double_t c1 = h->GetBinContent(j);
513 }
514 };
515
516 if (!opt.Contains("nostack")) {
517 BuildStack();
518 auto h = (TH1 *)fStack->At(nhists - 1);
519 if (fHistogram)
520 h->GetXaxis()->SetRange(fHistogram->GetXaxis()->GetFirst(),
522 themax = h->GetMaximum(maxval);
523 if (lerr)
524 check_error(h);
525 } else {
526 for (Int_t i = 0; i < nhists; i++) {
527 auto h = (TH1 *)fHists->At(i);
528 if (fHistogram)
529 h->GetXaxis()->SetRange(fHistogram->GetXaxis()->GetFirst(),
531 Double_t them = h->GetMaximum(maxval);
532 if (them > themax)
533 themax = them;
534 if (lerr)
535 check_error(h);
536 if (fHistogram)
537 h->GetXaxis()->SetRange(0,0);
538 }
539 }
540
541 return themax;
542}
543
544////////////////////////////////////////////////////////////////////////////////
545/// Returns the minimum of all added histograms larger than minval.
546/// Returns the minimum of all histograms, larger than minval, if option "nostack".
547
549{
550 if (!fHists) return 0;
551
552 TString opt = option;
553 opt.ToLower();
554 Bool_t lerr = opt.Contains("e");
555 Bool_t logy = gPad ? gPad->GetLogy() : kFALSE;
556 Double_t themin = std::numeric_limits<Double_t>::max();
558
559 auto check_error = [logy, &themin](TH1 *h) {
560 Int_t first = h->GetXaxis()->GetFirst();
561 Int_t last = h->GetXaxis()->GetLast();
562 for (Int_t j = first; j <= last; j++) {
563 Double_t e1 = h->GetBinError(j);
564 Double_t c1 = h->GetBinContent(j);
565 if (!logy || (c1 - e1 > 0))
567 }
568 };
569
570 if (!opt.Contains("nostack")) {
571 BuildStack();
572 auto h = (TH1*)fStack->At(nhists-1);
573 themin = h->GetMinimum(minval);
574 if (themin <= 0 && logy)
575 themin = h->GetMinimum(0);
576 if (lerr)
577 check_error(h);
578 } else {
579 for (Int_t i = 0; i < nhists; i++) {
580 auto h = (TH1 *)fHists->At(i);
581 Double_t them = h->GetMinimum(minval);
582 if (them <= 0 && logy)
583 them = h->GetMinimum(0);
584 if (them < themin)
585 themin = them;
586 if (lerr)
587 check_error(h);
588 }
589 }
590
591 return themin;
592}
593
594////////////////////////////////////////////////////////////////////////////////
595/// Return the number of histograms in the stack
596
598{
599 if (fHists) return fHists->GetSize();
600 return 0;
601}
602
603////////////////////////////////////////////////////////////////////////////////
604/// Return pointer to Stack. Build it if not yet done.
605
607{
608 BuildStack();
609 return fStack;
610}
611
612////////////////////////////////////////////////////////////////////////////////
613/// Get the x-axis of the histogram used to draw the stack.
614///
615/// IMPORTANT NOTE
616/// You must call Draw before calling this function. The returned histogram
617/// depends on the selected Draw options.
618
620{
621 TH1 *h = GetHistogram();
622 return h ? h->GetXaxis() : nullptr;
623}
624
625////////////////////////////////////////////////////////////////////////////////
626/// Get the y-axis of the histogram used to draw the stack.
627///
628/// IMPORTANT NOTE
629/// You must call Draw before calling this function. The returned histogram
630/// depends on the selected Draw options.
631
633{
634 TH1 *h = GetHistogram();
635 return h ? h->GetYaxis() : nullptr;
636}
637
638////////////////////////////////////////////////////////////////////////////////
639/// Get the z-axis of the histogram used to draw the stack.
640///
641/// IMPORTANT NOTE
642/// You must call Draw before calling this function. The returned histogram
643/// depends on the selected Draw options.
644
646{
647 TH1 *h = GetHistogram();
648 if (!h) return nullptr;
649 if (h->GetDimension() == 1)
650 Warning("GetZaxis","1D Histograms don't have a Z axis");
651 return h->GetZaxis();
652}
653
654////////////////////////////////////////////////////////////////////////////////
655/// List histograms in the stack.
656
658{
660 std::cout <<IsA()->GetName()
661 <<" Name= "<<GetName()<<" Title= "<<GetTitle()<<" Option="<<option<<std::endl;
663 if (fHists) fHists->ls(option);
665}
666////////////////////////////////////////////////////////////////////////////////
667/// Merge the THStack in the TList into this stack.
668/// Returns the total number of histograms in the result or -1 in case of an error.
669
671{
672 if (li==nullptr || li->GetEntries()==0) {
673 return fHists->GetEntries();
674 }
675 TIter next(li);
677 while (TObject* o = next()) {
678 THStack *stack = dynamic_cast<THStack*> (o);
679 if (!stack) {
680 Error("Merge",
681 "Cannot merge - an object which doesn't inherit from THStack found in the list");
682 return -1;
683 }
684 histLists.Add(stack->GetHists());
685 }
687 return fHists->GetEntries();
688}
689
690////////////////////////////////////////////////////////////////////////////////
691/// Note: this method invalidates the sum of histograms.
692
694{
695 if (!fStack) return;
696 fStack->Delete();
697 delete fStack;
698 fStack = nullptr;
699 delete fHistogram;
700 fHistogram = nullptr;
701}
702
703////////////////////////////////////////////////////////////////////////////////
704/// [Paint the list of histograms.](#HS00)
705
710
711////////////////////////////////////////////////////////////////////////////////
712/// Create all additional objects and stack (if specified).
713
715{
716 if (!fHists) return;
717 if (!fHists->GetSize()) return;
718
719 char option[128];
721
722 // Automatic color
723 char *l1 = strstr(option,"pfc"); // Automatic Fill Color
724 char *l2 = strstr(option,"plc"); // Automatic Line Color
725 char *l3 = strstr(option,"pmc"); // Automatic Marker Color
726 if (l1 || l2 || l3) {
728 if (l1) memcpy(l1," ",3);
729 if (l2) memcpy(l2," ",3);
730 if (l3) memcpy(l3," ",3);
731 TString ws = option;
732 if (ws.IsWhitespace()) strncpy(option,"\0",1);
734 gPad->IncrementPaletteColor(nhists, opt1);
735 for (Int_t i = 0; i < nhists; i++) {
736 auto ic = gPad->NextPaletteColor();
737 auto hAti = static_cast<TH1 *>(fHists->At(i));
738 if (l1) hAti->SetFillColor(ic);
739 if (l2) hAti->SetLineColor(ic);
740 if (l3) hAti->SetMarkerColor(ic);
741 if (fStack) {
742 auto hsAti = static_cast<TH1 *>(fStack->At(i));
743 if (l1) hsAti->SetFillColor(ic);
744 if (l2) hsAti->SetLineColor(ic);
745 if (l3) hsAti->SetMarkerColor(ic);
746 }
747 }
748 }
749
750 TString opt = option;
751 opt.ToLower();
752 opt.ReplaceAll(" ","");
754 if (opt.Contains("same")) {
755 lsame = kTRUE;
756 opt.ReplaceAll("same","");
757 }
759 if (opt.Contains("noclear")) {
760 lclear = kFALSE;
761 opt.ReplaceAll("noclear","");
762 }
763 if (opt.Contains("pads")) {
764 if (!paint)
765 return;
766
769 //if pad is not already divided into subpads, divide it
770 Int_t nps = 0;
771 TIter nextp(padsav->GetListOfPrimitives());
772 while (auto obj = nextp()) {
773 if (obj->InheritsFrom(TVirtualPad::Class()))
774 nps++;
775 }
776 if (nps < npads) {
777 padsav->Clear();
779 if (nx*nx < npads) nx++;
780 Int_t ny = nx;
781 if (((nx*ny)-nx) >= npads) ny--;
782 padsav->Divide(nx,ny);
783 }
784
785 Int_t i = 1;
786 auto lnk = fHists->FirstLink();
787 while (lnk) {
788 auto subpad = padsav->GetPad(i++);
789 if (!subpad) break;
790 subpad->Clear();
791 subpad->Add(lnk->GetObject(), lnk->GetOption());
792 lnk = lnk->Next();
793 }
794 padsav->cd();
795 return;
796 }
797
798 // compute the min/max of each axis
799 TH1 *h;
800 TIter next(fHists);
801 Double_t xmin = 1e100;
802 Double_t xmax = -xmin;
803 Double_t ymin = 1e100;
804 Double_t ymax = -xmin;
805 while ((h=(TH1*)next())) {
806 // in case of automatic binning
807 if (h->GetBuffer()) h->BufferEmpty(-1);
808 if (h->GetXaxis()->GetXmin() < xmin) xmin = h->GetXaxis()->GetXmin();
809 if (h->GetXaxis()->GetXmax() > xmax) xmax = h->GetXaxis()->GetXmax();
810 if (h->GetYaxis()->GetXmin() < ymin) ymin = h->GetYaxis()->GetXmin();
811 if (h->GetYaxis()->GetXmax() > ymax) ymax = h->GetYaxis()->GetXmax();
812 }
813
814 TString loption = opt;
815 Bool_t nostack = loption.Contains("nostack");
816 Bool_t nostackb = loption.Contains("nostackb");
817 Bool_t candle = loption.Contains("candle");
818 Bool_t violin = loption.Contains("violin");
819
820
821 if (!nostack && !candle && !violin) {
822 // do not delete the stack by default - only when needed.
823 // Another pad may contain the same object and use it
824 if (rebuild_stack && fStack) {
825 fStack->Delete();
826 delete fStack;
827 fStack = nullptr;
828 }
829 BuildStack();
830 }
831
833 if (fMaximum == -1111) themax = GetMaximum(option);
834 else themax = fMaximum;
835 if (fMinimum == -1111) {
837 if (gPad->GetLogy()){
838 if (themin>0) themin *= .9;
839 else themin = themax*1.e-3;
840 }
841 else if (themin > 0)
842 themin = 0;
843 }
844 else themin = fMinimum;
845 if (!fHistogram) {
848 h = (TH1*)fHists->At(0);
849 TAxis *xaxis = h->GetXaxis();
850 TAxis *yaxis = h->GetYaxis();
851 const TArrayD *xbins = xaxis->GetXbins();
852 if (h->GetDimension() > 1) {
853 if (loption.IsNull()) loption = "lego1";
854 const TArrayD *ybins = yaxis->GetXbins();
855 if (xbins->fN != 0 && ybins->fN != 0) {
857 xaxis->GetNbins(), xbins->GetArray(),
858 yaxis->GetNbins(), ybins->GetArray());
859 } else if (xbins->fN != 0 && ybins->fN == 0) {
861 xaxis->GetNbins(), xbins->GetArray(),
862 yaxis->GetNbins(), ymin, ymax);
863 } else if (xbins->fN == 0 && ybins->fN != 0) {
865 xaxis->GetNbins(), xmin, xmax,
866 yaxis->GetNbins(), ybins->GetArray());
867 } else {
869 xaxis->GetNbins(), xmin, xmax,
870 yaxis->GetNbins(), ymin, ymax);
871 }
872 } else {
873 if (xbins->fN != 0) {
875 xaxis->GetNbins(), xbins->GetArray());
876 } else {
877 fHistogram = new TH1F(GetName(),GetTitle(),xaxis->GetNbins(),xmin, xmax);
878 }
879 }
880 fHistogram->SetStats(false);
883 } else {
885 }
886
887 if (nostackb) {
888 loption.ReplaceAll("nostackb","");
889 } else {
890 if (nostack) loption.ReplaceAll("nostack","");
892 }
893
895 if (nostack && fMaximum != -1111) fHistogram->SetMaximum(fMaximum);
896 else {
897 if (gPad->GetLogy()) fHistogram->SetMaximum(themax*(1+0.2*TMath::Log10(themax/themin)));
898 else {
899 if (fMaximum != -1111) fHistogram->SetMaximum(themax);
901 }
902 }
903 if (nostack && fMinimum != -1111) fHistogram->SetMinimum(fMinimum);
904 else {
905 if (gPad->GetLogy()) fHistogram->SetMinimum(themin/(1+0.5*TMath::Log10(themax/themin)));
907 }
908 }
909
910 // Copy the axis labels if needed.
911 TH1 *hfirst = (TH1*)fHists->First();
912 THashList* labels = hfirst->GetXaxis()->GetLabels();
913 if (labels) {
914 TIter iL(labels);
915 Int_t ilab = 1;
916 while (auto lb=(TObjString*)iL()) {
917 fHistogram->GetXaxis()->SetBinLabel(ilab,lb->String().Data());
918 ilab++;
919 }
920 }
921
922 // Set fHistogram attributes and paint it.
923 if (!lsame) {
925 if (paint)
926 fHistogram->Paint(loption.Data());
927 }
928
929 if (fHistogram->GetDimension() > 1)
930 SetDrawOption(loption.Data());
931 if (loption.Index("lego")>=0)
932 return;
933
934 char noption[32];
935 strlcpy(noption,loption.Data(),32);
937 if (nostack || candle || violin) {
938 auto lnk = fHists->FirstLink();
939 Double_t bo = 0.03;
940 Double_t bw = (1.-(2*bo))/nhists;
941 for (Int_t i=0;i<nhists;i++) {
942 if (strstr(lnk->GetOption(),"same")) {
943 if (nostackb) loption.Form("%s%s b",noption,lnk->GetOption());
944 else loption.Form("%s%s",noption,lnk->GetOption());
945 } else {
946 TString indivOpt = lnk->GetOption();
947 indivOpt.ToLower();
948 if (nostackb) loption.Form("%ssame%s b",noption,lnk->GetOption());
949 else if (candle && (indivOpt.Contains("candle") || indivOpt.Contains("violin"))) loption.Form("%ssame",lnk->GetOption());
950 else loption.Form("%ssame%s",noption,lnk->GetOption());
951 }
952 TH1* hAti = (TH1*) fHists->At(i);
953 if (nostackb) {
954 hAti->SetBarWidth(bw);
955 hAti->SetBarOffset(bo);
956 bo += bw;
957 }
958 if (candle || violin) {
959 float candleSpace = 1./(nhists*2);
960 float candleOffset = - 1./2 + candleSpace + 2*candleSpace*i;
961 candleSpace *= 1.66; //width of the candle per bin: 1.0 means space is as great as the candle, 2.0 means there is no space
962 hAti->SetBarWidth(candleSpace);
963 hAti->SetBarOffset(candleOffset);
964 }
965 if (paint)
966 hAti->Paint(loption.Data());
967 lnk = lnk->Next();
968 }
969 } else {
970 auto lnk = fHists->LastLink();
972 for (Int_t i=0;i<nhists;i++) {
973 if (strstr(lnk->GetOption(),"same")) {
974 loption.Form("%s%s",noption,lnk->GetOption());
975 } else {
976 loption.Form("%ssame%s",noption,lnk->GetOption());
977 }
978 TH1 *h1 = (TH1*) fStack->At(nhists-i-1);
979 if ((i > 0) && lclear && paint) {
980 // Erase before drawing the histogram
981 h1col = h1->GetFillColor();
983 h1->SetFillColor(10);
984 h1->SetFillStyle(1001);
985 h1->Paint(loption.Data());
986 static TClassRef clTFrame = TClass::GetClass("TFrame", kFALSE);
987 TAttFill *frameFill = (TAttFill*)clTFrame->DynamicCast(TAttFill::Class(),gPad->GetFrame());
988 if (frameFill) {
989 h1->SetFillColor(frameFill->GetFillColor());
990 h1->SetFillStyle(frameFill->GetFillStyle());
991 }
992 h1->Paint(loption.Data());
995 }
996 if (paint)
997 h1->Paint(loption.Data());
998 lnk = lnk->Prev();
999 }
1000 }
1001
1002 opt.ReplaceAll("nostack","");
1003 opt.ReplaceAll("candle","");
1004 if (!lsame && !opt.Contains("a") && paint)
1005 fHistogram->Paint("axissame");
1006}
1007
1008////////////////////////////////////////////////////////////////////////////////
1009/// Print the list of histograms
1010
1012{
1013 TIter next(fHists);
1014 while (auto h = next())
1015 h->Print(option);
1016}
1017
1018////////////////////////////////////////////////////////////////////////////////
1019/// Recursively remove the object `obj` from the list of histograms.
1020
1022{
1023 if (!fHists) return;
1024 fHists->RecursiveRemove(obj);
1025 while (fHists->IndexOf(obj) >= 0) fHists->Remove(obj);
1026}
1027
1028////////////////////////////////////////////////////////////////////////////////
1029/// Save primitive as a C++ statement(s) on output stream out.
1030
1031void THStack::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1032{
1033 char quote = '"';
1034 out<<" "<<std::endl;
1035 if (gROOT->ClassSaved(THStack::Class())) {
1036 out<<" ";
1037 } else {
1038 out<<" THStack *";
1039 }
1040 out<<GetName()<<" = new THStack();"<<std::endl;
1041 out<<" "<<GetName()<<"->SetName("<<quote<<GetName()<<quote<<");"<<std::endl;
1042 out<<" "<<GetName()<<"->SetTitle("<<quote<<GetTitle()<<quote<<");"<<std::endl;
1043
1044 if (fMinimum != -1111) {
1045 out<<" "<<GetName()<<"->SetMinimum("<<fMinimum<<");"<<std::endl;
1046 }
1047 if (fMaximum != -1111) {
1048 out<<" "<<GetName()<<"->SetMaximum("<<fMaximum<<");"<<std::endl;
1049 }
1050
1051 static Int_t frameNumber = 0;
1052 if (fHistogram) {
1053 frameNumber++;
1055 fHistogram->SetName(TString::Format("%s_stack_%d", hname.Data(), frameNumber).Data());
1056 fHistogram->SavePrimitive(out,"nodraw");
1057 out<<" "<<GetName()<<"->SetHistogram("<<fHistogram->GetName()<<");"<<std::endl;
1058 out<<" "<<std::endl;
1059 fHistogram->SetName(hname.Data()); // restore histogram name
1060 }
1061
1062 if (fHists) {
1063 auto lnk = fHists->FirstLink();
1064 Int_t hcount = 0;
1065 while (lnk) {
1066 auto h = (TH1 *) lnk->GetObject();
1067 TString hname = h->GetName();
1068 h->SetName(TString::Format("%s_stack_%d", hname.Data(), ++hcount).Data());
1069 h->SavePrimitive(out,"nodraw");
1070 out<<" "<<GetName()<<"->Add("<<h->GetName()<<","<<quote<<lnk->GetOption()<<quote<<");"<<std::endl;
1071 lnk = lnk->Next();
1072 h->SetName(hname.Data()); // restore histogram name
1073 }
1074 }
1075 out<<" "<<GetName()<<"->Draw("<<quote<<option<<quote<<");"<<std::endl;
1076}
1077
1078////////////////////////////////////////////////////////////////////////////////
1079/// Set maximum.
1080
1086
1087////////////////////////////////////////////////////////////////////////////////
1088/// Set minimum.
1089
1095
1096
1097////////////////////////////////////////////////////////////////////////////////
1098/// Get an iterator over internal hists list.
1100{
1101 return TIter(fHists);
1102}
@ kPointer
Definition GuiTypes.h:375
#define b(i)
Definition RSha256.hxx:100
#define h(i)
Definition RSha256.hxx:106
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:117
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:374
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t option
char name[80]
Definition TGX11.cxx:110
float xmin
float ymin
float xmax
float ymax
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:406
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
#define R__LOCKGUARD(mutex)
#define gPad
Array of doubles (64 bits per element).
Definition TArrayD.h:27
Fill Area Attributes class.
Definition TAttFill.h:20
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:31
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:32
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:38
static TClass * Class()
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:40
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:45
Class to manage histogram axis.
Definition TAxis.h:32
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
Definition TAxis.cxx:882
Int_t GetLast() const
Return last bin on the axis i.e.
Definition TAxis.cxx:464
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition TAxis.cxx:453
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
TClassRef is used to implement a permanent reference to a TClass object.
Definition TClassRef.h:28
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4971
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.
Definition TClass.cxx:3069
Collection abstract base class.
Definition TCollection.h:65
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)
Definition TH1.h:645
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
TAxis * GetZaxis()
Definition TH1.h:342
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a line.
Definition TH1.cxx:2794
void SetTitle(const char *title) override
Change/set the title.
Definition TH1.cxx:6716
virtual Int_t GetDimension() const
Definition TH1.h:299
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
Definition TH1.cxx:1263
@ kIsZoomed
Bit set when zooming on Y axis.
Definition TH1.h:179
TAxis * GetXaxis()
Definition TH1.h:340
TVirtualHistPainter * GetPainter(Option_t *option="")
Return pointer to painter.
Definition TH1.cxx:4488
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
Definition TH1.cxx:3834
virtual void SetMaximum(Double_t maximum=-1111)
Definition TH1.h:420
TAxis * GetYaxis()
Definition TH1.h:341
virtual void SetMinimum(Double_t minimum=-1111)
Definition TH1.h:421
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TH1.cxx:7235
void SetName(const char *name) override
Change the name of this histogram.
Definition TH1.cxx:8962
void Paint(Option_t *option="") override
Control routine to paint any kind of histograms.
Definition TH1.cxx:6204
TClass * IsA() const override
Definition TH1.h:460
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
Definition TH1.cxx:9022
static Bool_t AddDirectoryStatus()
Static function: cannot be inlined on Windows/NT.
Definition TH1.cxx:741
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition TH1.cxx:8992
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:307
Service class for 2-D histogram classes.
Definition TH2.h:30
static TClass * Class()
The 3-D histogram classes derived from the 1-D histogram classes.
Definition TH3.h:31
static TClass * Class()
The Histogram stack class.
Definition THStack.h:40
TIter begin() const
Get an iterator over internal hists list.
Definition THStack.cxx:1099
TClass * IsA() const override
Definition THStack.h:93
~THStack() override
THStack destructor.
Definition THStack.cxx:322
THStack()
Definition THStack.h:57
void BuildAndPaint(Option_t *chopt, Bool_t paint, Bool_t rebuild_stack=kFALSE)
Create all additional objects and stack (if specified).
Definition THStack.cxx:714
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.
Definition THStack.cxx:548
void ls(Option_t *option="") const override
List histograms in the stack.
Definition THStack.cxx:657
TObjArray * fStack
! Pointer to array of sums of TH1
Definition THStack.h:46
Double_t fMinimum
Minimum value for plotting along y.
Definition THStack.h:49
void BuildStack()
Build the sum of all histograms.
Definition THStack.cxx:390
TList * GetHists() const
Definition THStack.h:72
TAxis * GetYaxis() const
Get the y-axis of the histogram used to draw the stack.
Definition THStack.cxx:632
virtual Long64_t Merge(TCollection *li, TFileMergeInfo *info)
Merge the THStack in the TList into this stack.
Definition THStack.cxx:670
TH1 * GetHistogram() const
Returns a pointer to the histogram used to draw the axis.
Definition THStack.cxx:483
void RecursiveRemove(TObject *obj) override
Recursively remove the object obj from the list of histograms.
Definition THStack.cxx:1021
virtual void Add(TH1 *h, Option_t *option="")
Add a new histogram to the list.
Definition THStack.cxx:365
void Print(Option_t *chopt="") const override
Print the list of histograms.
Definition THStack.cxx:1011
TObjArray * GetStack()
Return pointer to Stack. Build it if not yet done.
Definition THStack.cxx:606
Int_t GetNhists() const
Return the number of histograms in the stack.
Definition THStack.cxx:597
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.
Definition THStack.cxx:497
void Draw(Option_t *chopt="") override
Draw this stack with its current attributes.
Definition THStack.cxx:452
void Paint(Option_t *chopt="") override
Paint the list of histograms.
Definition THStack.cxx:706
TList * fHists
Pointer to array of TH1.
Definition THStack.h:45
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum.
Definition THStack.cxx:1081
TH1 * fHistogram
Pointer to histogram used for drawing axis.
Definition THStack.h:47
TAxis * GetZaxis() const
Get the z-axis of the histogram used to draw the stack.
Definition THStack.cxx:645
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition THStack.cxx:1031
void Browse(TBrowser *b) override
Browse.
Definition THStack.cxx:380
static TClass * Class()
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px, py to each graph.
Definition THStack.cxx:415
virtual void Modified()
Note: this method invalidates the sum of histograms.
Definition THStack.cxx:693
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum.
Definition THStack.cxx:1090
TAxis * GetXaxis() const
Get the x-axis of the histogram used to draw the stack.
Definition THStack.cxx:619
Double_t fMaximum
Maximum value for plotting along y.
Definition THStack.h:48
THashList implements a hybrid collection class consisting of a hash table and a list to store TObject...
Definition THashList.h:34
A doubly linked list.
Definition TList.h:38
void Clear(Option_t *option="") override
Remove all objects from the list.
Definition TList.cxx:400
virtual TObjLink * LastLink() const
Definition TList.h:105
void RecursiveRemove(TObject *obj) override
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition TList.cxx:762
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:820
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:657
virtual TObjLink * FirstLink() const
Definition TList.h:102
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:355
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
TString fTitle
Definition TNamed.h:33
TString fName
Definition TNamed.h:32
An array of TObjects.
Definition TObjArray.h:31
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
Definition TObjArray.h:164
void Add(TObject *obj) override
Definition TObjArray.h:68
Collectable string class.
Definition TObjString.h:28
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition TObject.cxx:241
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition TObject.cxx:440
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:991
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:202
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1005
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition TObject.cxx:782
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:62
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition TROOT.cxx:2887
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:2895
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition TROOT.cxx:2746
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.
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
void ToLower()
Change string to lower-case.
Definition TString.cxx:1182
const char * Data() const
Definition TString.h:376
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
Bool_t IsWhitespace() const
Definition TString.h:415
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2356
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
Double_t GetHistTopMargin() const
Definition TStyle.h:240
virtual void SetStack(TList *stack)=0
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
static TClass * Class()
return c1
Definition legend1.C:41
TH1F * h1
Definition legend1.C:5
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:666
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:198
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:766
th1 Draw()