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