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 Modified(); //invalidate stack
374}
375
376////////////////////////////////////////////////////////////////////////////////
377/// Browse.
378
380{
381 Draw(b ? b->GetDrawOption() : "");
382 gPad->Update();
383}
384
385////////////////////////////////////////////////////////////////////////////////
386/// Build the sum of all histograms.
387/// Build a separate list fStack containing the running sum of all histograms
388
390{
391 if (fStack) return;
392 if (!fHists) return;
394 if (!nhists) return;
395 fStack = new TObjArray(nhists);
398 TH1 *h = (TH1*)fHists->At(0)->Clone();
399 fStack->Add(h);
400 for (Int_t i=1;i<nhists;i++) {
401 h = (TH1*)fHists->At(i)->Clone();
402 if (h->GetMinimum() < 0.) {
403 Warning("BuildStack","Histograms with a negative minimum may produce wrong plots");
404 }
405 h->Add((TH1*)fStack->At(i-1));
406 fStack->AddAt(h,i);
407 }
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 Bool_t lerr = opt.Contains("e");
501 Double_t themax = -std::numeric_limits<Double_t>::max();
502 if (!fHists) return 0;
504
505 auto check_error = [&themax](TH1 *h) {
506 Int_t first = h->GetXaxis()->GetFirst();
507 Int_t last = h->GetXaxis()->GetLast();
508 for (Int_t j = first; j <= last; j++) {
509 Double_t e1 = h->GetBinError(j);
510 Double_t c1 = h->GetBinContent(j);
512 }
513 };
514
515 if (!opt.Contains("nostack")) {
516 BuildStack();
517 auto h = (TH1 *)fStack->At(nhists - 1);
518 if (fHistogram)
519 h->GetXaxis()->SetRange(fHistogram->GetXaxis()->GetFirst(),
521 themax = h->GetMaximum(maxval);
522 if (lerr)
523 check_error(h);
524 } else {
525 for (Int_t i = 0; i < nhists; i++) {
526 auto h = (TH1 *)fHists->At(i);
527 if (fHistogram)
528 h->GetXaxis()->SetRange(fHistogram->GetXaxis()->GetFirst(),
530 Double_t them = h->GetMaximum(maxval);
531 if (them > themax)
532 themax = them;
533 if (lerr)
534 check_error(h);
535 if (fHistogram)
536 h->GetXaxis()->SetRange(0,0);
537 }
538 }
539
540 return themax;
541}
542
543////////////////////////////////////////////////////////////////////////////////
544/// Returns the minimum of all added histograms larger than minval.
545/// Returns the minimum of all histograms, larger than minval, if option "nostack".
546
548{
549 if (!fHists) return 0;
550
551 TString opt = option;
552 opt.ToLower();
553 Bool_t lerr = opt.Contains("e");
554 Bool_t logy = gPad ? gPad->GetLogy() : kFALSE;
555 Double_t themin = std::numeric_limits<Double_t>::max();
557
558 auto check_error = [logy, &themin](TH1 *h) {
559 Int_t first = h->GetXaxis()->GetFirst();
560 Int_t last = h->GetXaxis()->GetLast();
561 for (Int_t j = first; j <= last; j++) {
562 Double_t e1 = h->GetBinError(j);
563 Double_t c1 = h->GetBinContent(j);
564 if (!logy || (c1 - e1 > 0))
566 }
567 };
568
569 if (!opt.Contains("nostack")) {
570 BuildStack();
571 auto h = (TH1*)fStack->At(nhists-1);
572 themin = h->GetMinimum(minval);
573 if (themin <= 0 && logy)
574 themin = h->GetMinimum(0);
575 if (lerr)
576 check_error(h);
577 } else {
578 for (Int_t i = 0; i < nhists; i++) {
579 auto h = (TH1 *)fHists->At(i);
580 Double_t them = h->GetMinimum(minval);
581 if (them <= 0 && logy)
582 them = h->GetMinimum(0);
583 if (them < themin)
584 themin = them;
585 if (lerr)
586 check_error(h);
587 }
588 }
589
590 return themin;
591}
592
593////////////////////////////////////////////////////////////////////////////////
594/// Return the number of histograms in the stack
595
597{
598 if (fHists) return fHists->GetSize();
599 return 0;
600}
601
602////////////////////////////////////////////////////////////////////////////////
603/// Return pointer to Stack. Build it if not yet done.
604
606{
607 BuildStack();
608 return fStack;
609}
610
611////////////////////////////////////////////////////////////////////////////////
612/// Get the x-axis of the histogram used to draw the stack.
613///
614/// IMPORTANT NOTE
615/// You must call Draw before calling this function. The returned histogram
616/// depends on the selected Draw options.
617
619{
620 TH1 *h = GetHistogram();
621 return h ? h->GetXaxis() : nullptr;
622}
623
624////////////////////////////////////////////////////////////////////////////////
625/// Get the y-axis of the histogram used to draw the stack.
626///
627/// IMPORTANT NOTE
628/// You must call Draw before calling this function. The returned histogram
629/// depends on the selected Draw options.
630
632{
633 TH1 *h = GetHistogram();
634 return h ? h->GetYaxis() : nullptr;
635}
636
637////////////////////////////////////////////////////////////////////////////////
638/// Get the z-axis of the histogram used to draw the stack.
639///
640/// IMPORTANT NOTE
641/// You must call Draw before calling this function. The returned histogram
642/// depends on the selected Draw options.
643
645{
646 TH1 *h = GetHistogram();
647 if (!h) return nullptr;
648 if (h->GetDimension() == 1)
649 Warning("GetZaxis","1D Histograms don't have a Z axis");
650 return h->GetZaxis();
651}
652
653////////////////////////////////////////////////////////////////////////////////
654/// List histograms in the stack.
655
657{
659 std::cout <<IsA()->GetName()
660 <<" Name= "<<GetName()<<" Title= "<<GetTitle()<<" Option="<<option<<std::endl;
662 if (fHists) fHists->ls(option);
664}
665////////////////////////////////////////////////////////////////////////////////
666/// Merge the THStack in the TList into this stack.
667/// Returns the total number of histograms in the result or -1 in case of an error.
668
670{
671 if (li==nullptr || li->GetEntries()==0) {
672 return fHists->GetEntries();
673 }
674 TIter next(li);
676 while (TObject* o = next()) {
677 THStack *stack = dynamic_cast<THStack*> (o);
678 if (!stack) {
679 Error("Merge",
680 "Cannot merge - an object which doesn't inherit from THStack found in the list");
681 return -1;
682 }
683 histLists.Add(stack->GetHists());
684 }
686 return fHists->GetEntries();
687}
688
689////////////////////////////////////////////////////////////////////////////////
690/// Note: this method invalidates the sum of histograms.
691
693{
694 if (!fStack) return;
695 fStack->Delete();
696 delete fStack;
697 fStack = nullptr;
698 delete fHistogram;
699 fHistogram = nullptr;
700}
701
702////////////////////////////////////////////////////////////////////////////////
703/// [Paint the list of histograms.](#HS00)
704
709
710////////////////////////////////////////////////////////////////////////////////
711/// Create all additional objects and stack (if specified).
712
714{
715 if (!fHists) return;
716 if (!fHists->GetSize()) return;
717
718 char option[128];
720
721 // Automatic color
722 char *l1 = strstr(option,"pfc"); // Automatic Fill Color
723 char *l2 = strstr(option,"plc"); // Automatic Line Color
724 char *l3 = strstr(option,"pmc"); // Automatic Marker Color
725 if (l1 || l2 || l3) {
727 if (l1) memcpy(l1," ",3);
728 if (l2) memcpy(l2," ",3);
729 if (l3) memcpy(l3," ",3);
730 TString ws = option;
731 if (ws.IsWhitespace()) strncpy(option,"\0",1);
733 gPad->IncrementPaletteColor(nhists, opt1);
734 for (Int_t i = 0; i < nhists; i++) {
735 auto ic = gPad->NextPaletteColor();
736 auto hAti = static_cast<TH1 *>(fHists->At(i));
737 if (l1) hAti->SetFillColor(ic);
738 if (l2) hAti->SetLineColor(ic);
739 if (l3) hAti->SetMarkerColor(ic);
740 if (fStack) {
741 auto hsAti = static_cast<TH1 *>(fStack->At(i));
742 if (l1) hsAti->SetFillColor(ic);
743 if (l2) hsAti->SetLineColor(ic);
744 if (l3) hsAti->SetMarkerColor(ic);
745 }
746 }
747 }
748
749 TString opt = option;
750 opt.ToLower();
751 opt.ReplaceAll(" ","");
753 if (opt.Contains("same")) {
754 lsame = kTRUE;
755 opt.ReplaceAll("same","");
756 }
758 if (opt.Contains("noclear")) {
759 lclear = kFALSE;
760 opt.ReplaceAll("noclear","");
761 }
762 auto l = strstr(opt.Data(), "pads");
763 if (l) {
764 if (!paint)
765 return;
766
767 Int_t fnx = 0;
768 if (sscanf(&l[4], "%d", &fnx) > 0) {
769 opt.ReplaceAll(TString::Format("pads%d", fnx), "");
770 } else {
771 opt.ReplaceAll("pads", "");
772 }
773
776 //if pad is not already divided into subpads, divide it
777 Int_t nps = 0;
778 TIter nextp(padsav->GetListOfPrimitives());
779 while (auto obj = nextp()) {
780 if (obj->InheritsFrom(TVirtualPad::Class()))
781 nps++;
782 }
783 if (nps < npads) {
784 if (fnx <= 0) {
785 padsav->Clear();
787 if (nx * nx < npads)
788 nx++;
789 Int_t ny = nx;
790 if (((nx * ny) - nx) >= npads)
791 ny--;
792 padsav->Divide(nx, ny);
793 } else {
794 Int_t ny = (Int_t)((Double_t)npads / fnx);
795 if (fnx * ny < npads)
796 ny++;
797 padsav->Divide(fnx, ny);
798 }
799 }
800
801 Int_t i = 1;
802 auto lnk = fHists->FirstLink();
803 while (lnk) {
804 auto subpad = padsav->GetPad(i++);
805 if (!subpad) break;
806 // check if histogram already drawn on the pad
807 if (!subpad->FindObject(lnk->GetObject())) {
808 subpad->Clear();
809 subpad->Add(lnk->GetObject(), lnk->GetOption());
810 subpad->Paint(); // need to re-paint subpad immediately
811 }
812 lnk = lnk->Next();
813 }
814 padsav->cd();
815 return;
816 }
817
818 // compute the min/max of each axis
819 TH1 *h;
820 TIter next(fHists);
821 Double_t xmin = 1e100;
822 Double_t xmax = -xmin;
823 Double_t ymin = 1e100;
824 Double_t ymax = -xmin;
825 while ((h=(TH1*)next())) {
826 // in case of automatic binning
827 if (h->GetBuffer()) h->BufferEmpty(-1);
828 if (h->GetXaxis()->GetXmin() < xmin) xmin = h->GetXaxis()->GetXmin();
829 if (h->GetXaxis()->GetXmax() > xmax) xmax = h->GetXaxis()->GetXmax();
830 if (h->GetYaxis()->GetXmin() < ymin) ymin = h->GetYaxis()->GetXmin();
831 if (h->GetYaxis()->GetXmax() > ymax) ymax = h->GetYaxis()->GetXmax();
832 }
833
834 TString loption = opt;
835 Bool_t nostack = loption.Contains("nostack");
836 Bool_t nostackb = loption.Contains("nostackb");
837 Bool_t candle = loption.Contains("candle");
838 Bool_t violin = loption.Contains("violin");
839
840
841 if (!nostack && !candle && !violin) {
842 // do not delete the stack by default - only when needed.
843 // Another pad may contain the same object and use it
844 if (rebuild_stack && fStack) {
845 fStack->Delete();
846 delete fStack;
847 fStack = nullptr;
848 }
849 BuildStack();
850 }
851
853 if (fMaximum == -1111) themax = GetMaximum(option);
854 else themax = fMaximum;
855 if (fMinimum == -1111) {
857 if (gPad->GetLogy()){
858 if (themin>0) themin *= .9;
859 else themin = themax*1.e-3;
860 }
861 else if (themin > 0)
862 themin = 0;
863 }
864 else themin = fMinimum;
865 if (!fHistogram) {
868 h = (TH1*)fHists->At(0);
869 TAxis *xaxis = h->GetXaxis();
870 TAxis *yaxis = h->GetYaxis();
871 const TArrayD *xbins = xaxis->GetXbins();
872 if (h->GetDimension() > 1) {
873 if (loption.IsNull()) loption = "lego1";
874 const TArrayD *ybins = yaxis->GetXbins();
875 if (xbins->fN != 0 && ybins->fN != 0) {
877 xaxis->GetNbins(), xbins->GetArray(),
878 yaxis->GetNbins(), ybins->GetArray());
879 } else if (xbins->fN != 0 && ybins->fN == 0) {
881 xaxis->GetNbins(), xbins->GetArray(),
882 yaxis->GetNbins(), ymin, ymax);
883 } else if (xbins->fN == 0 && ybins->fN != 0) {
885 xaxis->GetNbins(), xmin, xmax,
886 yaxis->GetNbins(), ybins->GetArray());
887 } else {
889 xaxis->GetNbins(), xmin, xmax,
890 yaxis->GetNbins(), ymin, ymax);
891 }
892 } else {
893 if (xbins->fN != 0) {
895 xaxis->GetNbins(), xbins->GetArray());
896 } else {
897 fHistogram = new TH1F(GetName(),GetTitle(),xaxis->GetNbins(),xmin, xmax);
898 }
899 }
900 fHistogram->SetStats(false);
903 } else {
905 }
906
907 if (nostackb) {
908 loption.ReplaceAll("nostackb","");
909 } else {
910 if (nostack) loption.ReplaceAll("nostack","");
912 }
913
915 if (nostack && fMaximum != -1111) fHistogram->SetMaximum(fMaximum);
916 else {
917 if (gPad->GetLogy()) fHistogram->SetMaximum(themax*(1+0.2*TMath::Log10(themax/themin)));
918 else {
919 if (fMaximum != -1111) fHistogram->SetMaximum(themax);
921 }
922 }
923 if (nostack && fMinimum != -1111) fHistogram->SetMinimum(fMinimum);
924 else {
925 if (gPad->GetLogy()) fHistogram->SetMinimum(themin/(1+0.5*TMath::Log10(themax/themin)));
927 }
928 }
929
930 // Copy the axis labels if needed.
931 TH1 *hfirst = (TH1*)fHists->First();
932 THashList* labels = hfirst->GetXaxis()->GetLabels();
933 if (labels) {
934 TIter iL(labels);
935 Int_t ilab = 1;
936 while (auto lb=(TObjString*)iL()) {
937 fHistogram->GetXaxis()->SetBinLabel(ilab,lb->String().Data());
938 ilab++;
939 }
940 }
941
942 // Set fHistogram attributes and paint it.
943 if (!lsame) {
945 if (paint)
946 fHistogram->Paint(loption.Data());
947 }
948
949 if (fHistogram->GetDimension() > 1)
950 SetDrawOption(loption.Data());
951 if (loption.Index("lego")>=0)
952 return;
953
954 char noption[32];
955 strlcpy(noption,loption.Data(),32);
957 if (nostack || candle || violin) {
958 auto lnk = fHists->FirstLink();
959 Double_t bo = 0.03;
960 Double_t bw = (1.-(2*bo))/nhists;
961 for (Int_t i=0;i<nhists;i++) {
962 if (strstr(lnk->GetOption(),"same")) {
963 if (nostackb) loption.Form("%s%s b",noption,lnk->GetOption());
964 else loption.Form("%s%s",noption,lnk->GetOption());
965 } else {
966 TString indivOpt = lnk->GetOption();
967 indivOpt.ToLower();
968 if (nostackb) loption.Form("%ssame%s b",noption,lnk->GetOption());
969 else if (candle && (indivOpt.Contains("candle") || indivOpt.Contains("violin"))) loption.Form("%ssame",lnk->GetOption());
970 else loption.Form("%ssame%s",noption,lnk->GetOption());
971 }
972 TH1* hAti = (TH1*) fHists->At(i);
973 if (nostackb) {
974 hAti->SetBarWidth(bw);
975 hAti->SetBarOffset(bo);
976 bo += bw;
977 }
978 if (candle || violin) {
979 float candleSpace = 1./(nhists*2);
980 float candleOffset = - 1./2 + candleSpace + 2*candleSpace*i;
981 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
982 hAti->SetBarWidth(candleSpace);
983 hAti->SetBarOffset(candleOffset);
984 }
985 if (paint)
986 hAti->Paint(loption.Data());
987 lnk = lnk->Next();
988 }
989 } else {
990 auto lnk = fHists->LastLink();
992 for (Int_t i=0;i<nhists;i++) {
993 if (strstr(lnk->GetOption(),"same")) {
994 loption.Form("%s%s",noption,lnk->GetOption());
995 } else {
996 loption.Form("%ssame%s",noption,lnk->GetOption());
997 }
998 TH1 *h1 = (TH1*) fStack->At(nhists-i-1);
999 if ((i > 0) && lclear && paint) {
1000 // Erase before drawing the histogram
1001 h1col = h1->GetFillColor();
1002 h1fill = h1->GetFillStyle();
1003 h1->SetFillColor(10);
1004 h1->SetFillStyle(1001);
1005 h1->Paint(loption.Data());
1006 static TClassRef clTFrame = TClass::GetClass("TFrame", kFALSE);
1007 TAttFill *frameFill = (TAttFill*)clTFrame->DynamicCast(TAttFill::Class(),gPad->GetFrame());
1008 if (frameFill) {
1009 h1->SetFillColor(frameFill->GetFillColor());
1010 h1->SetFillStyle(frameFill->GetFillStyle());
1011 }
1012 h1->Paint(loption.Data());
1015 }
1016 if (paint)
1017 h1->Paint(loption.Data());
1018 lnk = lnk->Prev();
1019 }
1020 }
1021
1022 opt.ReplaceAll("nostack","");
1023 opt.ReplaceAll("candle","");
1024 if (!lsame && !opt.Contains("a") && paint)
1025 fHistogram->Paint("axissame");
1026}
1027
1028////////////////////////////////////////////////////////////////////////////////
1029/// Print the list of histograms
1030
1032{
1033 TIter next(fHists);
1034 while (auto h = next())
1035 h->Print(option);
1036}
1037
1038////////////////////////////////////////////////////////////////////////////////
1039/// Recursively remove the object `obj` from the list of histograms.
1040
1042{
1043 if (!fHists) return;
1044 fHists->RecursiveRemove(obj);
1045 while (fHists->IndexOf(obj) >= 0) fHists->Remove(obj);
1046}
1047
1048////////////////////////////////////////////////////////////////////////////////
1049/// Save primitive as a C++ statement(s) on output stream out.
1050
1051void THStack::SavePrimitive(std::ostream &out, Option_t *option)
1052{
1053 TString name = gInterpreter->MapCppName(GetName());
1054 if (name.IsNull())
1055 name = "hstack";
1056
1057 out << " " << ClassName() << " *" << name << " = new " << ClassName() << "();\n";
1058
1060
1061 if (fMinimum != -1111)
1062 out << " " << name << "->SetMinimum(" << fMinimum << ");\n";
1063 if (fMaximum != -1111)
1064 out << " " << name << "->SetMaximum(" << fMaximum << ");\n";
1065
1066 thread_local Int_t hcount = 0;
1067 if (fHistogram) {
1069 fHistogram->SetName(TString::Format("%s_stack_%d", name.Data(), ++hcount).Data());
1070 fHistogram->SavePrimitive(out, "nodraw");
1071 out << " " << name << "->SetHistogram(" << fHistogram->GetName() << ");\n";
1072 out << " \n";
1073 fHistogram->SetName(hname.Data()); // restore histogram name
1074 }
1075
1076 if (fHists) {
1077 auto lnk = fHists->FirstLink();
1078 while (lnk) {
1079 auto h = static_cast<TH1 *>(lnk->GetObject());
1080 TString hname = h->GetName();
1081 h->SetName(TString::Format("%s_stack_%d", name.Data(), ++hcount).Data());
1082 h->SavePrimitive(out, "nodraw");
1083 out << " " << name << "->Add(" << h->GetName() << ", \""
1084 << TString(lnk->GetOption()).ReplaceSpecialCppChars() << "\");\n";
1085 h->SetName(hname.Data()); // restore histogram name
1086 lnk = lnk->Next();
1087 }
1088 }
1089
1091}
1092
1093////////////////////////////////////////////////////////////////////////////////
1094/// Set maximum.
1095
1101
1102////////////////////////////////////////////////////////////////////////////////
1103/// Set minimum.
1104
1110
1111
1112////////////////////////////////////////////////////////////////////////////////
1113/// Get an iterator over internal hists list.
1115{
1116 return TIter(fHists);
1117}
@ 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:2809
void SetTitle(const char *title) override
Change/set the title.
Definition TH1.cxx:6774
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:1263
@ 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:4504
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
Definition TH1.cxx:3849
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:7327
void SetName(const char *name) override
Change the name of this histogram.
Definition TH1.cxx:9020
void Paint(Option_t *option="") override
Control routine to paint any kind of histograms.
Definition TH1.cxx:6259
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:9080
static Bool_t AddDirectoryStatus()
Static function: cannot be inlined on Windows/NT.
Definition TH1.cxx:741
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition TH1.cxx:9050
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:1114
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:713
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:547
void ls(Option_t *option="") const override
List histograms in the stack.
Definition THStack.cxx:656
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:389
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:631
virtual Long64_t Merge(TCollection *li, TFileMergeInfo *info)
Merge the THStack in the TList into this stack.
Definition THStack.cxx:669
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:1041
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:1031
TObjArray * GetStack()
Return pointer to Stack. Build it if not yet done.
Definition THStack.cxx:605
Int_t GetNhists() const
Return the number of histograms in the stack.
Definition THStack.cxx:596
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:705
TList * fHists
Pointer to array of TH1.
Definition THStack.h:45
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum.
Definition THStack.cxx:1096
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:644
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition THStack.cxx:1051
void Browse(TBrowser *b) override
Browse.
Definition THStack.cxx:379
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:692
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum.
Definition THStack.cxx:1105
TAxis * GetXaxis() const
Get the x-axis of the histogram used to draw the stack.
Definition THStack.cxx:618
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:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:202
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:441
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1074
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:203
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1088
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition TObject.cxx:865
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:839
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:68
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