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);
397
398 TDirectory::TContext ctx{nullptr}; // No self-registration to directories
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 }
409}
410
411////////////////////////////////////////////////////////////////////////////////
412/// Compute distance from point px, py to each graph.
413
415{
416 //*-*- Are we on the axis?
417 const Int_t kMaxDiff = 10;
418 Int_t distance = 9999;
419 if (fHistogram) {
421 if (distance <= 0) {return distance;}
422 if (distance <= 1) {gPad->SetSelected(fHistogram);return distance;}
423 }
424
425
426 //*-*- Loop on the list of histograms
427 if (!fHists) return distance;
428 const char *doption = GetDrawOption();
430 for (Int_t i=0;i<nhists;i++) {
431 TH1 *h = (TH1*)fHists->At(i);
432 if (fStack && !strstr(doption,"nostack")) h = (TH1*)fStack->At(i);
433 Int_t dist = h->DistancetoPrimitive(px,py);
434 if (dist <= 0) return 0;
435 if (dist < kMaxDiff) {
436 gPad->SetSelected(fHists->At(i));
437 gPad->SetCursor(kPointer);
438 return dist;
439 }
440 }
441 return distance;
442}
443
444////////////////////////////////////////////////////////////////////////////////
445/// Draw this stack with its current attributes.
446///
447/// Options to draw histograms are described in THistPainter::Paint
448/// By default (if the option "nostack" is not specified), histograms will be painted
449/// stacked on top of each other.
450
452{
453 TString opt = option;
454 opt.ToLower();
455 if (gPad) {
456 if (!gPad->IsEditable()) gROOT->MakeDefCanvas();
457 if (!opt.Contains("same") && !opt.Contains("pads")) {
458 //the following statement is necessary in case one attempts to draw
459 //a temporary histogram already in the current pad
460 if (TestBit(kCanDelete)) gPad->Remove(this);
461 gPad->Clear();
462 }
463 }
464 AppendPad(opt.Data());
465}
466
467////////////////////////////////////////////////////////////////////////////////
468/// Returns a pointer to the histogram used to draw the axis.
469/// Takes into account the two following cases:
470/// 1- option 'A' was specified in THStack::Draw. Return fHistogram
471/// 2- user had called TPad::DrawFrame. return pointer to hframe histogram
472///
473/// IMPORTANT NOTES
474/// - You must call Draw before calling this function. The returned histogram
475/// depends on the selected Draw options.
476/// - This function returns a pointer to an intermediate fixed bin size
477/// histogram used to set the range and for picking.
478/// You cannot use this histogram to return the bin information.
479/// You must get a pointer to one of the histograms in the stack,
480/// the first one, for example.
481
483{
484 if (fHistogram) return fHistogram;
485 if (!gPad) return nullptr;
486 gPad->Modified();
487 gPad->Update();
488 if (fHistogram) return fHistogram;
489 return (TH1*)gPad->FindObject("hframe");
490}
491
492////////////////////////////////////////////////////////////////////////////////
493/// Returns the maximum of all added histograms smaller than maxval.
494/// Returns the maximum of all histograms, smaller than maxval, if option "nostack".
495
497{
498 TString opt = option;
499 opt.ToLower();
500 // exclude option which can conflict with "e" draw option
501 opt.ReplaceAll("same", "");
502 opt.ReplaceAll("candle", "");
503 opt.ReplaceAll("lego", "");
504 Bool_t lerr = opt.Contains("e");
505 Double_t themax = -std::numeric_limits<Double_t>::max();
506 if (!fHists) return 0;
508
509 auto check_error = [&themax](TH1 *h) {
510 Int_t first = h->GetXaxis()->GetFirst();
511 Int_t last = h->GetXaxis()->GetLast();
512 for (Int_t j = first; j <= last; j++) {
513 Double_t e1 = h->GetBinError(j);
514 Double_t c1 = h->GetBinContent(j);
516 }
517 };
518
519 if (!opt.Contains("nostack")) {
520 BuildStack();
521 auto h = (TH1 *)fStack->At(nhists - 1);
522 if (fHistogram)
523 h->GetXaxis()->SetRange(fHistogram->GetXaxis()->GetFirst(),
525 themax = h->GetMaximum(maxval);
526 if (lerr)
527 check_error(h);
528 } else {
529 for (Int_t i = 0; i < nhists; i++) {
530 auto h = (TH1 *)fHists->At(i);
531 if (fHistogram)
532 h->GetXaxis()->SetRange(fHistogram->GetXaxis()->GetFirst(),
534 Double_t them = h->GetMaximum(maxval);
535 if (them > themax)
536 themax = them;
537 if (lerr)
538 check_error(h);
539 if (fHistogram)
540 h->GetXaxis()->SetRange(0,0);
541 }
542 }
543
544 return themax;
545}
546
547////////////////////////////////////////////////////////////////////////////////
548/// Returns the minimum of all added histograms larger than minval.
549/// Returns the minimum of all histograms, larger than minval, if option "nostack".
550
552{
553 if (!fHists) return 0;
554
555 TString opt = option;
556 opt.ToLower();
557 // exclude option which can conflict with "e" draw option
558 opt.ReplaceAll("same", "");
559 opt.ReplaceAll("candle", "");
560 opt.ReplaceAll("lego", "");
561 Bool_t lerr = opt.Contains("e");
562 Bool_t logy = gPad ? gPad->GetLogy() : kFALSE;
563 Double_t themin = std::numeric_limits<Double_t>::max();
565
566 auto check_error = [logy, &themin](TH1 *h) {
567 Int_t first = h->GetXaxis()->GetFirst();
568 Int_t last = h->GetXaxis()->GetLast();
569 for (Int_t j = first; j <= last; j++) {
570 Double_t e1 = h->GetBinError(j);
571 Double_t c1 = h->GetBinContent(j);
572 if (!logy || (c1 - e1 > 0))
574 }
575 };
576
577 if (!opt.Contains("nostack")) {
578 BuildStack();
579 auto h = (TH1*)fStack->At(nhists-1);
580 themin = h->GetMinimum(minval);
581 if (themin <= 0 && logy)
582 themin = h->GetMinimum(0);
583 if (lerr)
584 check_error(h);
585 } else {
586 for (Int_t i = 0; i < nhists; i++) {
587 auto h = (TH1 *)fHists->At(i);
588 Double_t them = h->GetMinimum(minval);
589 if (them <= 0 && logy)
590 them = h->GetMinimum(0);
591 if (them < themin)
592 themin = them;
593 if (lerr)
594 check_error(h);
595 }
596 }
597
598 return themin;
599}
600
601////////////////////////////////////////////////////////////////////////////////
602/// Return the number of histograms in the stack
603
605{
606 if (fHists) return fHists->GetSize();
607 return 0;
608}
609
610////////////////////////////////////////////////////////////////////////////////
611/// Return pointer to Stack. Build it if not yet done.
612
614{
615 BuildStack();
616 return fStack;
617}
618
619////////////////////////////////////////////////////////////////////////////////
620/// Get the x-axis of the histogram used to draw the stack.
621///
622/// IMPORTANT NOTE
623/// You must call Draw before calling this function. The returned histogram
624/// depends on the selected Draw options.
625
627{
628 TH1 *h = GetHistogram();
629 return h ? h->GetXaxis() : nullptr;
630}
631
632////////////////////////////////////////////////////////////////////////////////
633/// Get the y-axis of the histogram used to draw the stack.
634///
635/// IMPORTANT NOTE
636/// You must call Draw before calling this function. The returned histogram
637/// depends on the selected Draw options.
638
640{
641 TH1 *h = GetHistogram();
642 return h ? h->GetYaxis() : nullptr;
643}
644
645////////////////////////////////////////////////////////////////////////////////
646/// Get the z-axis of the histogram used to draw the stack.
647///
648/// IMPORTANT NOTE
649/// You must call Draw before calling this function. The returned histogram
650/// depends on the selected Draw options.
651
653{
654 TH1 *h = GetHistogram();
655 if (!h) return nullptr;
656 if (h->GetDimension() == 1)
657 Warning("GetZaxis","1D Histograms don't have a Z axis");
658 return h->GetZaxis();
659}
660
661////////////////////////////////////////////////////////////////////////////////
662/// List histograms in the stack.
663
665{
667 std::cout <<IsA()->GetName()
668 <<" Name= "<<GetName()<<" Title= "<<GetTitle()<<" Option="<<option<<std::endl;
670 if (fHists) fHists->ls(option);
672}
673////////////////////////////////////////////////////////////////////////////////
674/// Merge the THStack in the TList into this stack.
675/// Returns the total number of histograms in the result or -1 in case of an error.
676
678{
679 if (li==nullptr || li->GetEntries()==0) {
680 return fHists->GetEntries();
681 }
682 TIter next(li);
684 while (TObject* o = next()) {
685 THStack *stack = dynamic_cast<THStack*> (o);
686 if (!stack) {
687 Error("Merge",
688 "Cannot merge - an object which doesn't inherit from THStack found in the list");
689 return -1;
690 }
691 histLists.Add(stack->GetHists());
692 }
694 return fHists->GetEntries();
695}
696
697////////////////////////////////////////////////////////////////////////////////
698/// Note: this method invalidates the sum of histograms.
699
701{
702 if (!fStack) return;
703 fStack->Delete();
704 delete fStack;
705 fStack = nullptr;
706 delete fHistogram;
707 fHistogram = nullptr;
708}
709
710////////////////////////////////////////////////////////////////////////////////
711/// [Paint the list of histograms.](#HS00)
712
717
718////////////////////////////////////////////////////////////////////////////////
719/// Create all additional objects and stack (if specified).
720
722{
723 if (!fHists) return;
724 if (!fHists->GetSize()) return;
725
726 TString opt = choptin;
727 opt.ToLower();
728
729 // Automatic color
730 Bool_t pfc = opt.Contains("pfc"); // Automatic Fill Color
731 Bool_t plc = opt.Contains("plc"); // Automatic Line Color
732 Bool_t pmc = opt.Contains("pmc"); // Automatic Marker Color
733 if (pfc || plc || pmc) {
735 gPad->IncrementPaletteColor(nhists, opt);
736 for (Int_t i = 0; i < nhists; i++) {
737 auto ic = gPad->NextPaletteColor();
738 auto hAti = static_cast<TH1 *>(fHists->At(i));
739 if (pfc) hAti->SetFillColor(ic);
740 if (plc) hAti->SetLineColor(ic);
741 if (pmc) hAti->SetMarkerColor(ic);
742 if (fStack) {
743 auto hsAti = static_cast<TH1 *>(fStack->At(i));
744 if (pfc) hsAti->SetFillColor(ic);
745 if (plc) hsAti->SetLineColor(ic);
746 if (pmc) hsAti->SetMarkerColor(ic);
747 }
748 }
749 opt.ReplaceAll("pfc", "");
750 opt.ReplaceAll("plc", "");
751 opt.ReplaceAll("pmc", "");
752 }
753
754 opt.ReplaceAll(" ","");
756 if (opt.Contains("same")) {
757 lsame = kTRUE;
758 opt.ReplaceAll("same","");
759 }
761 if (opt.Contains("noclear")) {
762 lclear = kFALSE;
763 opt.ReplaceAll("noclear","");
764 }
765 auto l = strstr(opt.Data(), "pads");
766 if (l) {
767 if (!paint)
768 return;
769
770 Int_t fnx = 0;
771 if (sscanf(&l[4], "%d", &fnx) > 0) {
772 opt.ReplaceAll(TString::Format("pads%d", fnx), "");
773 } else {
774 opt.ReplaceAll("pads", "");
775 }
776
779 //if pad is not already divided into subpads, divide it
780 Int_t nps = 0;
781 TIter nextp(padsav->GetListOfPrimitives());
782 while (auto obj = nextp()) {
783 if (obj->InheritsFrom(TVirtualPad::Class()))
784 nps++;
785 }
786 if (nps < npads) {
787 if (fnx <= 0) {
788 padsav->Clear();
790 if (nx * nx < npads)
791 nx++;
792 Int_t ny = nx;
793 if (((nx * ny) - nx) >= npads)
794 ny--;
795 padsav->Divide(nx, ny);
796 } else {
797 Int_t ny = (Int_t)((Double_t)npads / fnx);
798 if (fnx * ny < npads)
799 ny++;
800 padsav->Divide(fnx, ny);
801 }
802 }
803
804 Int_t i = 1;
805 auto lnk = fHists->FirstLink();
806 while (lnk) {
807 auto subpad = padsav->GetPad(i++);
808 if (!subpad) break;
809 // check if histogram already drawn on the pad
810 if (!subpad->FindObject(lnk->GetObject())) {
811 subpad->Clear();
812 subpad->Add(lnk->GetObject(), lnk->GetOption());
813 subpad->Paint(); // need to re-paint subpad immediately
814 }
815 lnk = lnk->Next();
816 }
817 padsav->cd();
818 return;
819 }
820
821 // compute the min/max of each axis
822 TH1 *h;
823 TIter next(fHists);
824 Double_t xmin = 1e100;
825 Double_t xmax = -xmin;
826 Double_t ymin = 1e100;
827 Double_t ymax = -xmin;
828 while ((h=(TH1*)next())) {
829 // in case of automatic binning
830 if (h->GetBuffer()) h->BufferEmpty(-1);
831 if (h->GetXaxis()->GetXmin() < xmin) xmin = h->GetXaxis()->GetXmin();
832 if (h->GetXaxis()->GetXmax() > xmax) xmax = h->GetXaxis()->GetXmax();
833 if (h->GetYaxis()->GetXmin() < ymin) ymin = h->GetYaxis()->GetXmin();
834 if (h->GetYaxis()->GetXmax() > ymax) ymax = h->GetYaxis()->GetXmax();
835 }
836
837 TString loption = opt;
838 Bool_t nostack = loption.Contains("nostack");
839 Bool_t nostackb = loption.Contains("nostackb");
840 Bool_t candle = loption.Contains("candle");
841 Bool_t violin = loption.Contains("violin");
842
843
844 if (!nostack && !candle && !violin) {
845 // do not delete the stack by default - only when needed.
846 // Another pad may contain the same object and use it
847 if (rebuild_stack && fStack) {
848 fStack->Delete();
849 delete fStack;
850 fStack = nullptr;
851 }
852 BuildStack();
853 }
854
856 if (fMaximum == -1111) themax = GetMaximum(choptin);
857 else themax = fMaximum;
858 if (fMinimum == -1111) {
860 if (gPad->GetLogy()){
861 if (themin>0) themin *= .9;
862 else themin = themax*1.e-3;
863 }
864 else if (themin > 0)
865 themin = 0;
866 }
867 else themin = fMinimum;
868 if (!fHistogram) {
869 TDirectory::TContext ctx{nullptr}; // No self-registration to directories
870 h = (TH1*)fHists->At(0);
871 TAxis *xaxis = h->GetXaxis();
872 TAxis *yaxis = h->GetYaxis();
873 const TArrayD *xbins = xaxis->GetXbins();
874 if (h->GetDimension() > 1) {
875 if (loption.IsNull()) loption = "lego1";
876 const TArrayD *ybins = yaxis->GetXbins();
877 if (xbins->fN != 0 && ybins->fN != 0) {
879 xaxis->GetNbins(), xbins->GetArray(),
880 yaxis->GetNbins(), ybins->GetArray());
881 } else if (xbins->fN != 0 && ybins->fN == 0) {
883 xaxis->GetNbins(), xbins->GetArray(),
884 yaxis->GetNbins(), ymin, ymax);
885 } else if (xbins->fN == 0 && ybins->fN != 0) {
887 xaxis->GetNbins(), xmin, xmax,
888 yaxis->GetNbins(), ybins->GetArray());
889 } else {
891 xaxis->GetNbins(), xmin, xmax,
892 yaxis->GetNbins(), ymin, ymax);
893 }
894 } else {
895 if (xbins->fN != 0) {
897 xaxis->GetNbins(), xbins->GetArray());
898 } else {
899 fHistogram = new TH1F(GetName(),GetTitle(),xaxis->GetNbins(),xmin, xmax);
900 }
901 }
902 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:376
#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:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:109
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:132
constexpr Bool_t kTRUE
Definition RtypesCore.h:108
const char Option_t
Option string (const char)
Definition RtypesCore.h:81
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:142
float xmin
float ymin
float xmax
float ymax
#define gInterpreter
R__EXTERN TVirtualMutex * gROOTMutex
Definition TROOT.h:63
#define gROOT
Definition TROOT.h:417
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:21
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:32
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:33
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:40
static TClass * Class()
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:42
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:47
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:4995
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:2999
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.
TDirectory::TContext keeps track and restore the current directory.
Definition TDirectory.h:89
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:2952
void SetTitle(const char *title) override
Change/set the title.
Definition TH1.cxx:6932
virtual Int_t GetDimension() const
Definition TH1.h:527
@ 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:4662
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
Definition TH1.cxx:4008
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:7485
void SetName(const char *name) override
Change the name of this histogram.
Definition TH1.cxx:9193
void Paint(Option_t *option="") override
Control routine to paint any kind of histograms.
Definition TH1.cxx:6417
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:9253
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition TH1.cxx:9223
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:721
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:551
void ls(Option_t *option="") const override
List histograms in the stack.
Definition THStack.cxx:664
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:639
virtual Long64_t Merge(TCollection *li, TFileMergeInfo *info)
Merge the THStack in the TList into this stack.
Definition THStack.cxx:677
TH1 * GetHistogram() const
Returns a pointer to the histogram used to draw the axis.
Definition THStack.cxx:482
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:613
Int_t GetNhists() const
Return the number of histograms in the stack.
Definition THStack.cxx:604
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:496
void Draw(Option_t *chopt="") override
Draw this stack with its current attributes.
Definition THStack.cxx:451
void Paint(Option_t *chopt="") override
Paint the list of histograms.
Definition THStack.cxx:713
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:652
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:414
virtual void Modified()
Note: this method invalidates the sum of histograms.
Definition THStack.cxx:700
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:626
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:444
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1082
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:886
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1096
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition TObject.cxx:870
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:844
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:71
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition TObject.h:73
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition TROOT.cxx:3059
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:3067
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition TROOT.cxx:2916
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:137
Ssiz_t Length() const
Definition TString.h:426
void ToLower()
Change string to lower-case.
Definition TString.cxx:1190
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1122
const char * Data() const
Definition TString.h:385
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:714
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:2460
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2438
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:642
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:675
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:775
th1 Draw()
TLine l
Definition textangle.C:4