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
30
31////////////////////////////////////////////////////////////////////////////////
32
33/** \class THStack
34 \ingroup Histograms
35The Histogram stack class
36
37A THStack is a collection of TH1 or TH2 histograms. By using THStack::Draw(), the entire
38histogram collection is drawn at once according to the specified drawing option.
39
40THStack::Add() allows adding a new histogram to the list. Note that the THStack does not
41take ownership of the objects in the list.
42
43\anchor HS00
44### Stack painting
45
46By default, histograms are shown stacked:
47 - the first histogram is painted
48 - then the sum of the first and second histograms is painted, and so on
49
50The axis ranges are computed automatically along the X and Y axes to display the complete
51histogram collection.
52
53Warning: Histogram bins with negative content may produce wrong plots.
54
55### Stack's drawing options
56
57The specific stack's drawing options are:
58
59 - **NOSTACK** If option "nostack" is specified, histograms are all painted in the same pad
60 as if the option "same" had been specified.
61
62 - **NOSTACKB** If the option "nostackb" is specified histograms are all painted on the same pad
63 next to each other as bar plots.
64
65 - **PADS** if option "pads" is specified, the current pad/canvas is subdivided into
66 a number of pads equal to the number of histograms and each histogram
67 is painted into a separate pad.
68
69 - **NOCLEAR** By default the background of the histograms is erased before drawing the
70 histograms. The option "noclear" avoids this behavior. This is useful when drawing a
71 THStack on top of another plot. If the patterns used to draw the histograms in the
72 stack are transparent, then the plot behind will be visible.
73
74See the THistPainter class for the list of valid histograms' painting options.
75
76
77Example;
78
79Begin_Macro(source)
80{
81 auto hs = new THStack("hs","");
82 auto h1 = new TH1F("h1","test hstack",10,-4,4);
83 h1->FillRandom("gaus",20000);
84 h1->SetFillColor(kRed);
85 hs->Add(h1);
86 auto h2 = new TH1F("h2","test hstack",10,-4,4);
87 h2->FillRandom("gaus",15000);
88 h2->SetFillColor(kBlue);
89 hs->Add(h2);
90 auto h3 = new TH1F("h3","test hstack",10,-4,4);
91 h3->FillRandom("gaus",10000);
92 h3->SetFillColor(kGreen);
93 hs->Add(h3);
94 auto cs = new TCanvas("cs","cs",10,10,700,900);
95 TText T; T.SetTextFont(42); T.SetTextAlign(21);
96 cs->Divide(2,2);
97 cs->cd(1); hs->Draw(); T.DrawTextNDC(.5,.95,"Default drawing option");
98 cs->cd(2); hs->Draw("nostack"); T.DrawTextNDC(.5,.95,"Option \"nostack\"");
99 cs->cd(3); hs->Draw("nostackb"); T.DrawTextNDC(.5,.95,"Option \"nostackb\"");
100 cs->cd(4); hs->Draw("lego1"); T.DrawTextNDC(.5,.95,"Option \"lego1\"");
101}
102End_Macro
103
104A more complex example:
105
106Begin_Macro(source)
107../../../tutorials/hist/hist023_THStack_simple.C
108End_Macro
109
110Note that picking is supported for all drawing modes.
111
112\since **ROOT version 6.07/07:**
113Stacks of 2D histograms can also be painted as candle plots:
114\since **ROOT version 6.09/02:**
115Stacks of 2D histograms can also be painted as violin plots, combinations of candle and
116violin plots are possible as well:
117
118Begin_Macro(source)
119../../../tutorials/hist/hist051_Graphics_candle_plot_stack.C
120End_Macro
121
122Automatic coloring according to the current palette is available as shown in the
123following example:
124
125Begin_Macro(source)
126../../../tutorials/hist/hist027_THStack_palette_color.C
127End_Macro
128*/
129
130////////////////////////////////////////////////////////////////////////////////
131/// constructor with name and title
132
133THStack::THStack(const char *name, const char *title)
134 : TNamed(name,title)
135{
137 gROOT->GetListOfCleanups()->Add(this);
138}
139
140
141////////////////////////////////////////////////////////////////////////////////
142/// Creates a new THStack from a TH2 or TH3.
143/// It is filled with the 1D histograms from GetProjectionX or GetProjectionY
144/// for each bin of the histogram. It illustrates the differences and total
145/// sum along an axis.
146///
147/// Parameters:
148/// - hist: the histogram used for the projections. Can be an object deriving
149/// from TH2 or TH3.
150/// - axis: for TH2: "x" for ProjectionX, "y" for ProjectionY.
151/// for TH3: see TH3::Project3D.
152/// - name: fName is set to name if given, otherwise to histo's name with
153/// "_stack_<axis>" appended, where `<axis>` is the value of the
154/// parameter axis.
155/// - title: fTitle is set to title if given, otherwise to histo's title
156/// with ", stack of <axis> projections" appended.
157/// - firstbin, lastbin:
158/// For each bin within [firstbin,lastbin] a stack entry is created.
159/// See TH2::ProjectionX/Y for use overflow bins.
160/// Defaults to "all bins but under- / overflow"
161/// - firstbin2, lastbin2:
162/// Other axis range for TH3::Project3D, defaults to "all bins but
163/// under- / overflow". Ignored for TH2s
164/// - proj_option:
165/// option passed to TH2::ProjectionX/Y and TH3::Project3D (along
166/// with axis)
167/// - draw_option:
168/// option passed to THStack::Add.
169
170THStack::THStack(TH1* hist, Option_t *axis /*="x"*/,
171 const char *name /*=nullptr*/, const char *title /*=nullptr*/,
172 Int_t firstbin /*=1*/, Int_t lastbin /*=-1*/,
173 Int_t firstbin2 /*=1*/, Int_t lastbin2 /*=-1*/,
174 Option_t* proj_option /*=""*/, Option_t* draw_option /*=""*/)
175 : TNamed(name, title) {
176 {
178 gROOT->GetListOfCleanups()->Add(this);
179 }
180 if (!axis) {
181 Warning("THStack", "Need an axis.");
182 return;
183 }
184 if (!hist) {
185 Warning("THStack", "Need a histogram.");
186 return;
187 }
188 Bool_t isTH2 = hist->IsA()->InheritsFrom(TH2::Class());
189 Bool_t isTH3 = hist->IsA()->InheritsFrom(TH3::Class());
190 if (!isTH2 && !isTH3) {
191 Warning("THStack", "Need a histogram deriving from TH2 or TH3.");
192 return;
193 }
194
195 if (!fName.Length())
196 fName.Form("%s_stack%s", hist->GetName(), axis);
197 if (!fTitle.Length()) {
198 if (hist->GetTitle() && strlen(hist->GetTitle()))
199 fTitle.Form("%s, stack of %s projections", hist->GetTitle(), axis);
200 else
201 fTitle.Form("stack of %s projections", axis);
202 }
203
204 if (isTH2) {
205 TH2* hist2 = (TH2*) hist;
206 Bool_t useX = (strchr(axis,'x')) || (strchr(axis,'X'));
207 Bool_t useY = (strchr(axis,'y')) || (strchr(axis,'Y'));
208 if ((!useX && !useY) || (useX && useY)) {
209 Warning("THStack", "Need parameter axis=\"x\" or \"y\" for a TH2, not none or both.");
210 return;
211 }
212 TAxis* haxis = useX ? hist->GetYaxis() : hist->GetXaxis();
213 if (!haxis) {
214 Warning("THStack","Histogram axis is NULL");
215 return;
216 }
217 Int_t nbins = haxis->GetNbins();
218 if (firstbin < 0) firstbin = 1;
219 if (lastbin < 0) lastbin = nbins;
220 if (lastbin > nbins+1) lastbin = nbins;
221 for (Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
222 TH1* hProj = nullptr;
223 if (useX)
224 hProj = hist2->ProjectionX(TString::Format("%s_px%d",hist2->GetName(), iBin).Data(),
226 else
227 hProj = hist2->ProjectionY(TString::Format("%s_py%d",hist2->GetName(), iBin).Data(),
230 }
231 } else {
232 // hist is a TH3
233 TH3* hist3 = (TH3*) hist;
234 TString sAxis(axis);
235 sAxis.ToLower();
236 Int_t dim=3-sAxis.Length();
237 if (dim<1 || dim>2) {
238 Warning("THStack", "Invalid length for parameter axis.");
239 return;
240 }
241
242 if (dim==1) {
243 TAxis* haxis = nullptr;
244 // look for the haxis _not_ in axis
245 if (sAxis.First('x')==kNPOS)
246 haxis = hist->GetXaxis();
247 else if (sAxis.First('y')==kNPOS)
248 haxis = hist->GetYaxis();
249 else if (sAxis.First('z')==kNPOS)
250 haxis = hist->GetZaxis();
251 if (!haxis) {
252 Warning("THStack","Histogram axis is NULL");
253 return;
254 }
255
256 Int_t nbins = haxis->GetNbins();
257 if (firstbin < 0) firstbin = 1;
258 if (lastbin < 0) lastbin = nbins;
259 if (lastbin > nbins+1) lastbin = nbins;
260 Int_t iFirstOld=haxis->GetFirst();
261 Int_t iLastOld=haxis->GetLast();
262 for (Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
263 haxis->SetRange(iBin, iBin);
264 // build projection named axis_iBin (passed through "option")
265 TH1* hProj = hist3->Project3D(TString::Format("%s_%s%s_%d", hist3->GetName(),
266 axis, proj_option, iBin).Data());
268 }
269 haxis->SetRange(iFirstOld, iLastOld);
270 } else {
271 // if dim==2
272 TAxis* haxis1 = nullptr;
273 TAxis* haxis2 = nullptr;
274 // look for the haxis _not_ in axis
275 if (sAxis.First('x')!=kNPOS) {
276 haxis1=hist->GetYaxis();
277 haxis2=hist->GetZaxis();
278 } else if (sAxis.First('y')!=kNPOS) {
279 haxis1=hist->GetXaxis();
280 haxis2=hist->GetZaxis();
281 } else if (sAxis.First('z')!=kNPOS) {
282 haxis1=hist->GetXaxis();
283 haxis2=hist->GetYaxis();
284 }
285 if (!haxis1 || !haxis2) {
286 Warning("THStack","Histogram axis is NULL");
287 return;
288 }
289
290 Int_t nbins1 = haxis1->GetNbins();
291 Int_t nbins2 = haxis2->GetNbins();
292 if (firstbin < 0) firstbin = 1;
293 if (lastbin < 0) lastbin = nbins1;
294 if (lastbin > nbins1+1) lastbin = nbins1;
295 if (firstbin2 < 0) firstbin2 = 1;
296 if (lastbin2 < 0) lastbin2 = nbins2;
297 if (lastbin2 > nbins2+1) lastbin2 = nbins2;
298 Int_t iFirstOld1 = haxis1->GetFirst();
299 Int_t iLastOld1 = haxis1->GetLast();
300 Int_t iFirstOld2 = haxis2->GetFirst();
301 Int_t iLastOld2 = haxis2->GetLast();
302 for (Int_t iBin=firstbin; iBin<=lastbin; iBin++) {
303 haxis1->SetRange(iBin, iBin);
304 for (Int_t jBin=firstbin2; jBin<=lastbin2; jBin++) {
305 haxis2->SetRange(jBin, jBin);
306 // build projection named axis_iBin (passed through "option")
307 TH1* hProj=hist3->Project3D(TString::Format("%s_%s%s_%d", hist3->GetName(),
308 axis, proj_option, iBin).Data());
310 }
311 }
312 haxis1->SetRange(iFirstOld1, iLastOld1);
313 haxis2->SetRange(iFirstOld2, iLastOld2);
314 }
315 } // if hist is TH2 or TH3
316}
317
318////////////////////////////////////////////////////////////////////////////////
319/// THStack destructor.
320
322{
323 {
325 gROOT->GetListOfCleanups()->Remove(this);
326 }
327 if (fHists) {
328 fHists->Clear("nodelete");
329 delete fHists;
330 fHists = nullptr;
331 }
332 if (fStack) {
333 fStack->Delete();
334 delete fStack;
335 fStack = nullptr;
336 }
337 delete fHistogram;
338 fHistogram = nullptr;
339}
340
341////////////////////////////////////////////////////////////////////////////////
342/// THStack copy constructor
343
345 TNamed(hstack),
346 fMaximum(hstack.fMaximum),
347 fMinimum(hstack.fMinimum)
348{
349 {
351 gROOT->GetListOfCleanups()->Add(this);
352 }
353
354 TIter next(hstack.GetHists());
355 while (auto h = static_cast<TH1 *>(next()))
356 Add(h);
357}
358
359////////////////////////////////////////////////////////////////////////////////
360/// Add a new histogram to the list.
361/// Only 1-d and 2-d histograms currently supported.
362/// A drawing option may be specified
363
365{
366 if (!h1) return;
367 if (h1->GetDimension() > 2) {
368 Error("Add","THStack supports only 1-d and 2-d histograms");
369 return;
370 }
371 if (!fHists) fHists = new TList();
373 h1->SetBit(kMustCleanup); // The histogram is likely in multiple lists now
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 auto l = strstr(opt.Data(), "pads");
764 if (l) {
765 if (!paint)
766 return;
767
768 Int_t fnx = 0;
769 if (sscanf(&l[4], "%d", &fnx) > 0) {
770 opt.ReplaceAll(TString::Format("pads%d", fnx), "");
771 } else {
772 opt.ReplaceAll("pads", "");
773 }
774
777 //if pad is not already divided into subpads, divide it
778 Int_t nps = 0;
779 TIter nextp(padsav->GetListOfPrimitives());
780 while (auto obj = nextp()) {
781 if (obj->InheritsFrom(TVirtualPad::Class()))
782 nps++;
783 }
784 if (nps < npads) {
785 if (fnx <= 0) {
786 padsav->Clear();
788 if (nx * nx < npads)
789 nx++;
790 Int_t ny = nx;
791 if (((nx * ny) - nx) >= npads)
792 ny--;
793 padsav->Divide(nx, ny);
794 } else {
795 Int_t ny = (Int_t)((Double_t)npads / fnx);
796 if (fnx * ny < npads)
797 ny++;
798 padsav->Divide(fnx, ny);
799 }
800 }
801
802 Int_t i = 1;
803 auto lnk = fHists->FirstLink();
804 while (lnk) {
805 auto subpad = padsav->GetPad(i++);
806 if (!subpad) break;
807 // check if histogram already drawn on the pad
808 if (!subpad->FindObject(lnk->GetObject())) {
809 subpad->Clear();
810 subpad->Add(lnk->GetObject(), lnk->GetOption());
811 subpad->Paint(); // need to re-paint subpad immediately
812 }
813 lnk = lnk->Next();
814 }
815 padsav->cd();
816 return;
817 }
818
819 // compute the min/max of each axis
820 TH1 *h;
821 TIter next(fHists);
822 Double_t xmin = 1e100;
823 Double_t xmax = -xmin;
824 Double_t ymin = 1e100;
825 Double_t ymax = -xmin;
826 while ((h=(TH1*)next())) {
827 // in case of automatic binning
828 if (h->GetBuffer()) h->BufferEmpty(-1);
829 if (h->GetXaxis()->GetXmin() < xmin) xmin = h->GetXaxis()->GetXmin();
830 if (h->GetXaxis()->GetXmax() > xmax) xmax = h->GetXaxis()->GetXmax();
831 if (h->GetYaxis()->GetXmin() < ymin) ymin = h->GetYaxis()->GetXmin();
832 if (h->GetYaxis()->GetXmax() > ymax) ymax = h->GetYaxis()->GetXmax();
833 }
834
835 TString loption = opt;
836 Bool_t nostack = loption.Contains("nostack");
837 Bool_t nostackb = loption.Contains("nostackb");
838 Bool_t candle = loption.Contains("candle");
839 Bool_t violin = loption.Contains("violin");
840
841
842 if (!nostack && !candle && !violin) {
843 // do not delete the stack by default - only when needed.
844 // Another pad may contain the same object and use it
845 if (rebuild_stack && fStack) {
846 fStack->Delete();
847 delete fStack;
848 fStack = nullptr;
849 }
850 BuildStack();
851 }
852
854 if (fMaximum == -1111) themax = GetMaximum(option);
855 else themax = fMaximum;
856 if (fMinimum == -1111) {
858 if (gPad->GetLogy()){
859 if (themin>0) themin *= .9;
860 else themin = themax*1.e-3;
861 }
862 else if (themin > 0)
863 themin = 0;
864 }
865 else themin = fMinimum;
866 if (!fHistogram) {
869 h = (TH1*)fHists->At(0);
870 TAxis *xaxis = h->GetXaxis();
871 TAxis *yaxis = h->GetYaxis();
872 const TArrayD *xbins = xaxis->GetXbins();
873 if (h->GetDimension() > 1) {
874 if (loption.IsNull()) loption = "lego1";
875 const TArrayD *ybins = yaxis->GetXbins();
876 if (xbins->fN != 0 && ybins->fN != 0) {
878 xaxis->GetNbins(), xbins->GetArray(),
879 yaxis->GetNbins(), ybins->GetArray());
880 } else if (xbins->fN != 0 && ybins->fN == 0) {
882 xaxis->GetNbins(), xbins->GetArray(),
883 yaxis->GetNbins(), ymin, ymax);
884 } else if (xbins->fN == 0 && ybins->fN != 0) {
886 xaxis->GetNbins(), xmin, xmax,
887 yaxis->GetNbins(), ybins->GetArray());
888 } else {
890 xaxis->GetNbins(), xmin, xmax,
891 yaxis->GetNbins(), ymin, ymax);
892 }
893 } else {
894 if (xbins->fN != 0) {
896 xaxis->GetNbins(), xbins->GetArray());
897 } else {
898 fHistogram = new TH1F(GetName(),GetTitle(),xaxis->GetNbins(),xmin, xmax);
899 }
900 }
901 fHistogram->SetStats(false);
904 } else {
906 }
907
908 if (nostackb) {
909 loption.ReplaceAll("nostackb","");
910 } else {
911 if (nostack) loption.ReplaceAll("nostack","");
913 }
914
916 if (nostack && fMaximum != -1111) fHistogram->SetMaximum(fMaximum);
917 else {
918 if (gPad->GetLogy()) fHistogram->SetMaximum(themax*(1+0.2*TMath::Log10(themax/themin)));
919 else {
920 if (fMaximum != -1111) fHistogram->SetMaximum(themax);
922 }
923 }
924 if (nostack && fMinimum != -1111) fHistogram->SetMinimum(fMinimum);
925 else {
926 if (gPad->GetLogy()) fHistogram->SetMinimum(themin/(1+0.5*TMath::Log10(themax/themin)));
928 }
929 }
930
931 // Copy the axis labels if needed.
932 TH1 *hfirst = (TH1*)fHists->First();
933 THashList* labels = hfirst->GetXaxis()->GetLabels();
934 if (labels) {
935 TIter iL(labels);
936 Int_t ilab = 1;
937 while (auto lb=(TObjString*)iL()) {
938 fHistogram->GetXaxis()->SetBinLabel(ilab,lb->String().Data());
939 ilab++;
940 }
941 }
942
943 // Set fHistogram attributes and paint it.
944 if (!lsame) {
946 if (paint)
947 fHistogram->Paint(loption.Data());
948 }
949
950 if (fHistogram->GetDimension() > 1)
951 SetDrawOption(loption.Data());
952 if (loption.Index("lego")>=0)
953 return;
954
955 char noption[32];
956 strlcpy(noption,loption.Data(),32);
958 if (nostack || candle || violin) {
959 auto lnk = fHists->FirstLink();
960 Double_t bo = 0.03;
961 Double_t bw = (1.-(2*bo))/nhists;
962 for (Int_t i=0;i<nhists;i++) {
963 if (strstr(lnk->GetOption(),"same")) {
964 if (nostackb) loption.Form("%s%s b",noption,lnk->GetOption());
965 else loption.Form("%s%s",noption,lnk->GetOption());
966 } else {
967 TString indivOpt = lnk->GetOption();
968 indivOpt.ToLower();
969 if (nostackb) loption.Form("%ssame%s b",noption,lnk->GetOption());
970 else if (candle && (indivOpt.Contains("candle") || indivOpt.Contains("violin"))) loption.Form("%ssame",lnk->GetOption());
971 else loption.Form("%ssame%s",noption,lnk->GetOption());
972 }
973 TH1* hAti = (TH1*) fHists->At(i);
974 if (nostackb) {
975 hAti->SetBarWidth(bw);
976 hAti->SetBarOffset(bo);
977 bo += bw;
978 }
979 if (candle || violin) {
980 float candleSpace = 1./(nhists*2);
981 float candleOffset = - 1./2 + candleSpace + 2*candleSpace*i;
982 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
983 hAti->SetBarWidth(candleSpace);
984 hAti->SetBarOffset(candleOffset);
985 }
986 if (paint)
987 hAti->Paint(loption.Data());
988 lnk = lnk->Next();
989 }
990 } else {
991 auto lnk = fHists->LastLink();
993 for (Int_t i=0;i<nhists;i++) {
994 if (strstr(lnk->GetOption(),"same")) {
995 loption.Form("%s%s",noption,lnk->GetOption());
996 } else {
997 loption.Form("%ssame%s",noption,lnk->GetOption());
998 }
999 TH1 *h1 = (TH1*) fStack->At(nhists-i-1);
1000 if ((i > 0) && lclear && paint) {
1001 // Erase before drawing the histogram
1002 h1col = h1->GetFillColor();
1003 h1fill = h1->GetFillStyle();
1004 h1->SetFillColor(10);
1005 h1->SetFillStyle(1001);
1006 h1->Paint(loption.Data());
1007 static TClassRef clTFrame = TClass::GetClass("TFrame", kFALSE);
1008 TAttFill *frameFill = (TAttFill*)clTFrame->DynamicCast(TAttFill::Class(),gPad->GetFrame());
1009 if (frameFill) {
1010 h1->SetFillColor(frameFill->GetFillColor());
1011 h1->SetFillStyle(frameFill->GetFillStyle());
1012 }
1013 h1->Paint(loption.Data());
1016 }
1017 if (paint)
1018 h1->Paint(loption.Data());
1019 lnk = lnk->Prev();
1020 }
1021 }
1022
1023 opt.ReplaceAll("nostack","");
1024 opt.ReplaceAll("candle","");
1025 if (!lsame && !opt.Contains("a") && paint)
1026 fHistogram->Paint("axissame");
1027}
1028
1029////////////////////////////////////////////////////////////////////////////////
1030/// Print the list of histograms
1031
1033{
1034 TIter next(fHists);
1035 while (auto h = next())
1036 h->Print(option);
1037}
1038
1039////////////////////////////////////////////////////////////////////////////////
1040/// Recursively remove the object `obj` from the list of histograms.
1041
1043{
1044 if (!fHists) return;
1045 fHists->RecursiveRemove(obj);
1046 while (fHists->IndexOf(obj) >= 0) fHists->Remove(obj);
1047}
1048
1049////////////////////////////////////////////////////////////////////////////////
1050/// Save primitive as a C++ statement(s) on output stream out.
1051
1052void THStack::SavePrimitive(std::ostream &out, Option_t *option)
1053{
1054 TString name = gInterpreter->MapCppName(GetName());
1055 if (name.IsNull())
1056 name = "hstack";
1057
1058 out << " " << ClassName() << " *" << name << " = new " << ClassName() << "();\n";
1059
1061
1062 if (fMinimum != -1111)
1063 out << " " << name << "->SetMinimum(" << fMinimum << ");\n";
1064 if (fMaximum != -1111)
1065 out << " " << name << "->SetMaximum(" << fMaximum << ");\n";
1066
1067 thread_local Int_t hcount = 0;
1068 if (fHistogram) {
1070 fHistogram->SetName(TString::Format("%s_stack_%d", name.Data(), ++hcount).Data());
1071 fHistogram->SavePrimitive(out, "nodraw");
1072 out << " " << name << "->SetHistogram(" << fHistogram->GetName() << ");\n";
1073 out << " \n";
1074 fHistogram->SetName(hname.Data()); // restore histogram name
1075 }
1076
1077 if (fHists) {
1078 auto lnk = fHists->FirstLink();
1079 while (lnk) {
1080 auto h = static_cast<TH1 *>(lnk->GetObject());
1081 TString hname = h->GetName();
1082 h->SetName(TString::Format("%s_stack_%d", name.Data(), ++hcount).Data());
1083 h->SavePrimitive(out, "nodraw");
1084 out << " " << name << "->Add(" << h->GetName() << ", \""
1085 << TString(lnk->GetOption()).ReplaceSpecialCppChars() << "\");\n";
1086 h->SetName(hname.Data()); // restore histogram name
1087 lnk = lnk->Next();
1088 }
1089 }
1090
1092}
1093
1094////////////////////////////////////////////////////////////////////////////////
1095/// Set maximum.
1096
1102
1103////////////////////////////////////////////////////////////////////////////////
1104/// Set minimum.
1105
1111
1112
1113////////////////////////////////////////////////////////////////////////////////
1114/// Get an iterator over internal hists list.
1116{
1117 return TIter(fHists);
1118}
@ kPointer
Definition GuiTypes.h:375
#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
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
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
#define gInterpreter
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:414
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:891
Int_t GetLast() const
Return last bin on the axis i.e.
Definition TAxis.cxx:473
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition TAxis.cxx:462
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:29
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4901
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:2973
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.
A class to pass information from the TFileMerger to the objects being merged.
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:878
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:109
TAxis * GetZaxis()
Definition TH1.h:573
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a line.
Definition TH1.cxx:2815
void SetTitle(const char *title) override
Change/set the title.
Definition TH1.cxx:6796
virtual Int_t GetDimension() const
Definition TH1.h:527
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
Definition TH1.cxx:1269
@ kIsZoomed
Bit set when zooming on Y axis.
Definition TH1.h:407
TAxis * GetXaxis()
Definition TH1.h:571
TVirtualHistPainter * GetPainter(Option_t *option="")
Return pointer to painter.
Definition TH1.cxx:4526
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
Definition TH1.cxx:3871
virtual void SetMaximum(Double_t maximum=-1111)
Definition TH1.h:652
TAxis * GetYaxis()
Definition TH1.h:572
virtual void SetMinimum(Double_t minimum=-1111)
Definition TH1.h:653
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TH1.cxx:7349
void SetName(const char *name) override
Change the name of this histogram.
Definition TH1.cxx:9042
void Paint(Option_t *option="") override
Control routine to paint any kind of histograms.
Definition TH1.cxx:6281
TClass * IsA() const override
Definition TH1.h:693
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
Definition TH1.cxx:9102
static Bool_t AddDirectoryStatus()
Static function: cannot be inlined on Windows/NT.
Definition TH1.cxx:747
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition TH1.cxx:9072
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:345
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:45
static TClass * Class()
The Histogram stack class.
Definition THStack.h:40
TIter begin() const
Get an iterator over internal hists list.
Definition THStack.cxx:1115
TClass * IsA() const override
Definition THStack.h:93
~THStack() override
THStack destructor.
Definition THStack.cxx:321
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:1042
virtual void Add(TH1 *h, Option_t *option="")
Add a new histogram to the list.
Definition THStack.cxx:364
void Print(Option_t *chopt="") const override
Print the list of histograms.
Definition THStack.cxx:1032
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:1097
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:1052
void Browse(TBrowser *b) override
Browse.
Definition THStack.cxx:380
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:1106
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:532
virtual TObjLink * LastLink() const
Definition TList.h:110
void RecursiveRemove(TObject *obj) override
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition TList.cxx:894
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:952
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:789
virtual TObjLink * FirstLink() const
Definition TList.h:107
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:487
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
void SavePrimitiveNameTitle(std::ostream &out, const char *variable_name)
Save object name and title into the output stream "out".
Definition TNamed.cxx:135
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
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:170
void Add(TObject *obj) override
Definition TObjArray.h:68
Collectable string class.
Definition TObjString.h:28
Mother of all ROOT objects.
Definition TObject.h:42
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:204
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition TObject.cxx:242
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition TObject.cxx:442
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1075
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:203
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:882
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1089
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition TObject.cxx:866
static void SavePrimitiveDraw(std::ostream &out, const char *variable_name, Option_t *option=nullptr)
Save invocation of primitive Draw() method Skipped if option contains "nodraw" string.
Definition TObject.cxx:840
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:70
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition TObject.h:72
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition TROOT.cxx:2894
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:2902
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition TROOT.cxx:2751
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:138
Ssiz_t Length() const
Definition TString.h:425
void ToLower()
Change string to lower-case.
Definition TString.cxx:1189
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1121
const char * Data() const
Definition TString.h:384
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:713
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:2384
Bool_t IsWhitespace() const
Definition TString.h:423
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2362
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:641
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:249
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:673
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Definition TMathBase.h:197
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:773
th1 Draw()
TLine l
Definition textangle.C:4