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 if (opt.Contains("pads")) {
763 if (!paint)
764 return;
765
768 //if pad is not already divided into subpads, divide it
769 Int_t nps = 0;
770 TIter nextp(padsav->GetListOfPrimitives());
771 while (auto obj = nextp()) {
772 if (obj->InheritsFrom(TVirtualPad::Class()))
773 nps++;
774 }
775 if (nps < npads) {
776 padsav->Clear();
778 if (nx*nx < npads) nx++;
779 Int_t ny = nx;
780 if (((nx*ny)-nx) >= npads) ny--;
781 padsav->Divide(nx,ny);
782 }
783
784 Int_t i = 1;
785 auto lnk = fHists->FirstLink();
786 while (lnk) {
787 auto subpad = padsav->GetPad(i++);
788 if (!subpad) break;
789 // check if histogram already drawn on the pad
790 if (!subpad->FindObject(lnk->GetObject())) {
791 subpad->Clear();
792 subpad->Add(lnk->GetObject(), lnk->GetOption());
793 subpad->Paint(); // need to re-paint subpad immediately
794 }
795 lnk = lnk->Next();
796 }
797 padsav->cd();
798 return;
799 }
800
801 // compute the min/max of each axis
802 TH1 *h;
803 TIter next(fHists);
804 Double_t xmin = 1e100;
805 Double_t xmax = -xmin;
806 Double_t ymin = 1e100;
807 Double_t ymax = -xmin;
808 while ((h=(TH1*)next())) {
809 // in case of automatic binning
810 if (h->GetBuffer()) h->BufferEmpty(-1);
811 if (h->GetXaxis()->GetXmin() < xmin) xmin = h->GetXaxis()->GetXmin();
812 if (h->GetXaxis()->GetXmax() > xmax) xmax = h->GetXaxis()->GetXmax();
813 if (h->GetYaxis()->GetXmin() < ymin) ymin = h->GetYaxis()->GetXmin();
814 if (h->GetYaxis()->GetXmax() > ymax) ymax = h->GetYaxis()->GetXmax();
815 }
816
817 TString loption = opt;
818 Bool_t nostack = loption.Contains("nostack");
819 Bool_t nostackb = loption.Contains("nostackb");
820 Bool_t candle = loption.Contains("candle");
821 Bool_t violin = loption.Contains("violin");
822
823
824 if (!nostack && !candle && !violin) {
825 // do not delete the stack by default - only when needed.
826 // Another pad may contain the same object and use it
827 if (rebuild_stack && fStack) {
828 fStack->Delete();
829 delete fStack;
830 fStack = nullptr;
831 }
832 BuildStack();
833 }
834
836 if (fMaximum == -1111) themax = GetMaximum(option);
837 else themax = fMaximum;
838 if (fMinimum == -1111) {
840 if (gPad->GetLogy()){
841 if (themin>0) themin *= .9;
842 else themin = themax*1.e-3;
843 }
844 else if (themin > 0)
845 themin = 0;
846 }
847 else themin = fMinimum;
848 if (!fHistogram) {
851 h = (TH1*)fHists->At(0);
852 TAxis *xaxis = h->GetXaxis();
853 TAxis *yaxis = h->GetYaxis();
854 const TArrayD *xbins = xaxis->GetXbins();
855 if (h->GetDimension() > 1) {
856 if (loption.IsNull()) loption = "lego1";
857 const TArrayD *ybins = yaxis->GetXbins();
858 if (xbins->fN != 0 && ybins->fN != 0) {
860 xaxis->GetNbins(), xbins->GetArray(),
861 yaxis->GetNbins(), ybins->GetArray());
862 } else if (xbins->fN != 0 && ybins->fN == 0) {
864 xaxis->GetNbins(), xbins->GetArray(),
865 yaxis->GetNbins(), ymin, ymax);
866 } else if (xbins->fN == 0 && ybins->fN != 0) {
868 xaxis->GetNbins(), xmin, xmax,
869 yaxis->GetNbins(), ybins->GetArray());
870 } else {
872 xaxis->GetNbins(), xmin, xmax,
873 yaxis->GetNbins(), ymin, ymax);
874 }
875 } else {
876 if (xbins->fN != 0) {
878 xaxis->GetNbins(), xbins->GetArray());
879 } else {
880 fHistogram = new TH1F(GetName(),GetTitle(),xaxis->GetNbins(),xmin, xmax);
881 }
882 }
883 fHistogram->SetStats(false);
886 } else {
888 }
889
890 if (nostackb) {
891 loption.ReplaceAll("nostackb","");
892 } else {
893 if (nostack) loption.ReplaceAll("nostack","");
895 }
896
898 if (nostack && fMaximum != -1111) fHistogram->SetMaximum(fMaximum);
899 else {
900 if (gPad->GetLogy()) fHistogram->SetMaximum(themax*(1+0.2*TMath::Log10(themax/themin)));
901 else {
902 if (fMaximum != -1111) fHistogram->SetMaximum(themax);
904 }
905 }
906 if (nostack && fMinimum != -1111) fHistogram->SetMinimum(fMinimum);
907 else {
908 if (gPad->GetLogy()) fHistogram->SetMinimum(themin/(1+0.5*TMath::Log10(themax/themin)));
910 }
911 }
912
913 // Copy the axis labels if needed.
914 TH1 *hfirst = (TH1*)fHists->First();
915 THashList* labels = hfirst->GetXaxis()->GetLabels();
916 if (labels) {
917 TIter iL(labels);
918 Int_t ilab = 1;
919 while (auto lb=(TObjString*)iL()) {
920 fHistogram->GetXaxis()->SetBinLabel(ilab,lb->String().Data());
921 ilab++;
922 }
923 }
924
925 // Set fHistogram attributes and paint it.
926 if (!lsame) {
928 if (paint)
929 fHistogram->Paint(loption.Data());
930 }
931
932 if (fHistogram->GetDimension() > 1)
933 SetDrawOption(loption.Data());
934 if (loption.Index("lego")>=0)
935 return;
936
937 char noption[32];
938 strlcpy(noption,loption.Data(),32);
940 if (nostack || candle || violin) {
941 auto lnk = fHists->FirstLink();
942 Double_t bo = 0.03;
943 Double_t bw = (1.-(2*bo))/nhists;
944 for (Int_t i=0;i<nhists;i++) {
945 if (strstr(lnk->GetOption(),"same")) {
946 if (nostackb) loption.Form("%s%s b",noption,lnk->GetOption());
947 else loption.Form("%s%s",noption,lnk->GetOption());
948 } else {
949 TString indivOpt = lnk->GetOption();
950 indivOpt.ToLower();
951 if (nostackb) loption.Form("%ssame%s b",noption,lnk->GetOption());
952 else if (candle && (indivOpt.Contains("candle") || indivOpt.Contains("violin"))) loption.Form("%ssame",lnk->GetOption());
953 else loption.Form("%ssame%s",noption,lnk->GetOption());
954 }
955 TH1* hAti = (TH1*) fHists->At(i);
956 if (nostackb) {
957 hAti->SetBarWidth(bw);
958 hAti->SetBarOffset(bo);
959 bo += bw;
960 }
961 if (candle || violin) {
962 float candleSpace = 1./(nhists*2);
963 float candleOffset = - 1./2 + candleSpace + 2*candleSpace*i;
964 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
965 hAti->SetBarWidth(candleSpace);
966 hAti->SetBarOffset(candleOffset);
967 }
968 if (paint)
969 hAti->Paint(loption.Data());
970 lnk = lnk->Next();
971 }
972 } else {
973 auto lnk = fHists->LastLink();
975 for (Int_t i=0;i<nhists;i++) {
976 if (strstr(lnk->GetOption(),"same")) {
977 loption.Form("%s%s",noption,lnk->GetOption());
978 } else {
979 loption.Form("%ssame%s",noption,lnk->GetOption());
980 }
981 TH1 *h1 = (TH1*) fStack->At(nhists-i-1);
982 if ((i > 0) && lclear && paint) {
983 // Erase before drawing the histogram
984 h1col = h1->GetFillColor();
986 h1->SetFillColor(10);
987 h1->SetFillStyle(1001);
988 h1->Paint(loption.Data());
989 static TClassRef clTFrame = TClass::GetClass("TFrame", kFALSE);
990 TAttFill *frameFill = (TAttFill*)clTFrame->DynamicCast(TAttFill::Class(),gPad->GetFrame());
991 if (frameFill) {
992 h1->SetFillColor(frameFill->GetFillColor());
993 h1->SetFillStyle(frameFill->GetFillStyle());
994 }
995 h1->Paint(loption.Data());
998 }
999 if (paint)
1000 h1->Paint(loption.Data());
1001 lnk = lnk->Prev();
1002 }
1003 }
1004
1005 opt.ReplaceAll("nostack","");
1006 opt.ReplaceAll("candle","");
1007 if (!lsame && !opt.Contains("a") && paint)
1008 fHistogram->Paint("axissame");
1009}
1010
1011////////////////////////////////////////////////////////////////////////////////
1012/// Print the list of histograms
1013
1015{
1016 TIter next(fHists);
1017 while (auto h = next())
1018 h->Print(option);
1019}
1020
1021////////////////////////////////////////////////////////////////////////////////
1022/// Recursively remove the object `obj` from the list of histograms.
1023
1025{
1026 if (!fHists) return;
1027 fHists->RecursiveRemove(obj);
1028 while (fHists->IndexOf(obj) >= 0) fHists->Remove(obj);
1029}
1030
1031////////////////////////////////////////////////////////////////////////////////
1032/// Save primitive as a C++ statement(s) on output stream out.
1033
1034void THStack::SavePrimitive(std::ostream &out, Option_t *option)
1035{
1036 TString name = gInterpreter->MapCppName(GetName());
1037
1040
1041 if (fMinimum != -1111)
1042 out << " " << name << "->SetMinimum(" << fMinimum << ");\n";
1043 if (fMaximum != -1111)
1044 out << " " << name << "->SetMaximum(" << fMaximum << ");\n";
1045
1046 thread_local Int_t hcount = 0;
1047 if (fHistogram) {
1049 fHistogram->SetName(TString::Format("%s_stack_%d", name.Data(), ++hcount).Data());
1050 fHistogram->SavePrimitive(out, "nodraw");
1051 out << " " << name << "->SetHistogram(" << fHistogram->GetName() << ");\n";
1052 out << " \n";
1053 fHistogram->SetName(hname.Data()); // restore histogram name
1054 }
1055
1056 if (fHists) {
1057 auto lnk = fHists->FirstLink();
1058 while (lnk) {
1059 auto h = static_cast<TH1 *>(lnk->GetObject());
1060 TString hname = h->GetName();
1061 h->SetName(TString::Format("%s_stack_%d", name.Data(), ++hcount).Data());
1062 h->SavePrimitive(out, "nodraw");
1063 out << " " << name << "->Add(" << h->GetName() << ", \""
1064 << TString(lnk->GetOption()).ReplaceSpecialCppChars() << "\");\n";
1065 h->SetName(hname.Data()); // restore histogram name
1066 lnk = lnk->Next();
1067 }
1068 }
1069
1071}
1072
1073////////////////////////////////////////////////////////////////////////////////
1074/// Set maximum.
1075
1081
1082////////////////////////////////////////////////////////////////////////////////
1083/// Set minimum.
1084
1090
1091
1092////////////////////////////////////////////////////////////////////////////////
1093/// Get an iterator over internal hists list.
1095{
1096 return TIter(fHists);
1097}
@ 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:411
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:875
Int_t GetLast() const
Return last bin on the axis i.e.
Definition TAxis.cxx:472
Int_t GetFirst() const
Return first bin on the axis i.e.
Definition TAxis.cxx:461
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.
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:879
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:109
TAxis * GetZaxis()
Definition TH1.h:574
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a line.
Definition TH1.cxx:2794
void SetTitle(const char *title) override
Change/set the title.
Definition TH1.cxx:6753
virtual Int_t GetDimension() const
Definition TH1.h:528
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:408
TAxis * GetXaxis()
Definition TH1.h:572
TVirtualHistPainter * GetPainter(Option_t *option="")
Return pointer to painter.
Definition TH1.cxx:4488
TObject * FindObject(const char *name) const override
Search object named name in the list of functions.
Definition TH1.cxx:3834
virtual void SetMaximum(Double_t maximum=-1111)
Definition TH1.h:653
TAxis * GetYaxis()
Definition TH1.h:573
virtual void SetMinimum(Double_t minimum=-1111)
Definition TH1.h:654
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save primitive as a C++ statement(s) on output stream out.
Definition TH1.cxx:7299
void SetName(const char *name) override
Change the name of this histogram.
Definition TH1.cxx:8988
void Paint(Option_t *option="") override
Control routine to paint any kind of histograms.
Definition TH1.cxx:6241
TClass * IsA() const override
Definition TH1.h:694
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
Definition TH1.cxx:9048
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:9018
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:307
Service class for 2-D histogram classes.
Definition TH2.h:30
static TClass * Class()
The 3-D histogram classes derived from the 1-D histogram classes.
Definition TH3.h:40
static TClass * Class()
The Histogram stack class.
Definition THStack.h:40
TIter begin() const
Get an iterator over internal hists list.
Definition THStack.cxx:1094
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:1024
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:1014
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:1076
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:1034
void Browse(TBrowser *b) override
Browse.
Definition THStack.cxx:379
static TClass * Class()
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px, py to each graph.
Definition THStack.cxx: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:1085
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:399
virtual TObjLink * LastLink() const
Definition TList.h:105
void RecursiveRemove(TObject *obj) override
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition TList.cxx:761
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:819
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:656
virtual TObjLink * FirstLink() const
Definition TList.h:102
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:354
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:164
void Add(TObject *obj) override
Definition TObjArray.h:68
Collectable string class.
Definition TObjString.h:28
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:202
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition TObject.cxx:242
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:1057
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:1071
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition TObject.cxx:848
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:822
static void SavePrimitiveConstructor(std::ostream &out, TClass *cl, const char *variable_name, const char *constructor_agrs="", Bool_t empty_line=kTRUE)
Save object constructor in the output stream "out".
Definition TObject.cxx:771
@ 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:2890
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:2898
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition TROOT.cxx:2748
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:712
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:640
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:251
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:199
Double_t Log10(Double_t x)
Returns the common (base-10) logarithm of x.
Definition TMath.h:773
th1 Draw()