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 Histograms
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### 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### 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("THStack","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("THStack","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("THStack","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 if (fHistogram) h->GetXaxis()->SetRange(fHistogram->GetXaxis()->GetFirst(),
530 themax = h->GetMaximum();
531 } else {
532 for (Int_t i=0;i<nhists;i++) {
533 h = (TH1*)fHists->At(i);
534 if (fHistogram) h->GetXaxis()->SetRange(fHistogram->GetXaxis()->GetFirst(),
536 them = h->GetMaximum();
537 if (fHistogram) h->GetXaxis()->SetRange(0,0);
538 if (them > themax) themax = them;
539 }
540 }
541
542 if (lerr) {
543 for (Int_t i=0;i<nhists;i++) {
544 h = (TH1*)fHists->At(i);
545 first = h->GetXaxis()->GetFirst();
546 last = h->GetXaxis()->GetLast();
547 for (Int_t j=first; j<=last;j++) {
548 e1 = h->GetBinError(j);
549 c1 = h->GetBinContent(j);
550 themax = TMath::Max(themax,c1+e1);
551 }
552 }
553 }
554
555 return themax;
556}
557
558////////////////////////////////////////////////////////////////////////////////
559/// returns the minimum of all added histograms
560/// returns the minimum of all histograms if option "nostack".
561
563{
564 TString opt = option;
565 opt.ToLower();
566 Bool_t lerr = kFALSE;
567 if (opt.Contains("e")) lerr = kTRUE;
568 Double_t them=0, themin = 1e300, c1, e1;
569 if (!fHists) return 0;
570 Int_t nhists = fHists->GetSize();
571 Int_t first,last;
572 TH1 *h;
573
574 if (!opt.Contains("nostack")) {
575 BuildStack();
576 h = (TH1*)fStack->At(nhists-1);
577 themin = h->GetMinimum();
578 } else {
579 for (Int_t i=0;i<nhists;i++) {
580 h = (TH1*)fHists->At(i);
581 them = h->GetMinimum();
582 if (them <= 0 && gPad && gPad->GetLogy()) them = h->GetMinimum(0);
583 if (them < themin) themin = them;
584 }
585 }
586
587 if (lerr) {
588 for (Int_t i=0;i<nhists;i++) {
589 h = (TH1*)fHists->At(i);
590 first = h->GetXaxis()->GetFirst();
591 last = h->GetXaxis()->GetLast();
592 for (Int_t j=first; j<=last;j++) {
593 e1 = h->GetBinError(j);
594 c1 = h->GetBinContent(j);
595 themin = TMath::Min(themin,c1-e1);
596 }
597 }
598 }
599
600 return themin;
601}
602
603////////////////////////////////////////////////////////////////////////////////
604/// Return the number of histograms in the stack
605
607{
608 if (fHists) return fHists->GetSize();
609 return 0;
610}
611
612////////////////////////////////////////////////////////////////////////////////
613/// Return pointer to Stack. Build it if not yet done
614
616{
617 BuildStack();
618 return fStack;
619}
620
621////////////////////////////////////////////////////////////////////////////////
622/// Get x axis of the histogram used to draw the stack.
623///
624/// IMPORTANT NOTE
625/// You must call Draw before calling this function. The returned histogram
626/// depends on the selected Draw options.
627
629{
630 if (!gPad) return nullptr;
631 TH1 *h = GetHistogram();
632 if (!h) return nullptr;
633 return h->GetXaxis();
634}
635
636////////////////////////////////////////////////////////////////////////////////
637/// Get y axis of the histogram used to draw the stack.
638///
639/// IMPORTANT NOTE
640/// You must call Draw before calling this function. The returned histogram
641/// depends on the selected Draw options.
642
644{
645 if (!gPad) return nullptr;
646 TH1 *h = GetHistogram();
647 if (!h) return nullptr;
648 return h->GetYaxis();
649}
650
651////////////////////////////////////////////////////////////////////////////////
652/// Get z axis of the histogram used to draw the stack.
653///
654/// IMPORTANT NOTE
655/// You must call Draw before calling this function. The returned histogram
656/// depends on the selected Draw options.
657
659{
660 if (!gPad) return nullptr;
661 TH1 *h = GetHistogram();
662 if (!h->IsA()->InheritsFrom(TH2::Class())) Warning("THStack","1D Histograms don't have a Z axis");
663 if (!h) return nullptr;
664 return h->GetZaxis();
665}
666
667////////////////////////////////////////////////////////////////////////////////
668/// List histograms in the stack
669
670void THStack::ls(Option_t *option) const
671{
673 std::cout <<IsA()->GetName()
674 <<" Name= "<<GetName()<<" Title= "<<GetTitle()<<" Option="<<option<<std::endl;
676 if (fHists) fHists->ls(option);
678}
679////////////////////////////////////////////////////////////////////////////////
680/// Merge the THStack in the TList into this stack.
681/// Returns the total number of histograms in the result or -1 in case of an error.
682
684{
685 if (li==0 || li->GetEntries()==0) {
686 return fHists->GetEntries();
687 }
688 TIter next(li);
689 TList histLists;
690 while (TObject* o = next()) {
691 THStack *stack = dynamic_cast<THStack*> (o);
692 if (!stack) {
693 Error("Merge",
694 "Cannot merge - an object which doesn't inherit from THStack found in the list");
695 return -1;
696 }
697 histLists.Add(stack->GetHists());
698 }
699 fHists->Merge(&histLists);
700 return fHists->GetEntries();
701}
702
703////////////////////////////////////////////////////////////////////////////////
704/// invalidate sum of histograms
705
707{
708 if (!fStack) return;
709 fStack->Delete();
710 delete fStack;
711 fStack = 0;
712 delete fHistogram;
713 fHistogram = 0;
714}
715
716////////////////////////////////////////////////////////////////////////////////
717/// [Paint the list of histograms.](#HS00)
718
720{
721 if (!fHists) return;
722 if (!fHists->GetSize()) return;
723
724 char option[128];
725 strlcpy(option,choptin,128);
726
727 // Automatic color
728 char *l1 = strstr(option,"pfc"); // Automatic Fill Color
729 char *l2 = strstr(option,"plc"); // Automatic Line Color
730 char *l3 = strstr(option,"pmc"); // Automatic Marker Color
731 if (l1 || l2 || l3) {
732 TString opt1 = option;
733 if (l1) memcpy(l1," ",3);
734 if (l2) memcpy(l2," ",3);
735 if (l3) memcpy(l3," ",3);
736 TString ws = option;
737 if (ws.IsWhitespace()) strncpy(option,"\0",1);
739 TH1* hAti;
740 TH1* hsAti;
741 Int_t nhists = fHists->GetSize();
742 Int_t ic;
743 gPad->IncrementPaletteColor(nhists, opt1);
744 for (Int_t i=0;i<nhists;i++) {
745 ic = gPad->NextPaletteColor();
746 hAti = (TH1F*)(fHists->At(i));
747 if (l1) hAti->SetFillColor(ic);
748 if (l2) hAti->SetLineColor(ic);
749 if (l3) hAti->SetMarkerColor(ic);
750 if (fStack) {
751 hsAti = (TH1*)fStack->At(i);
752 if (l1) hsAti->SetFillColor(ic);
753 if (l2) hsAti->SetLineColor(ic);
754 if (l3) hsAti->SetMarkerColor(ic);
755 }
756 lnk = (TObjOptLink*)lnk->Next();
757 }
758 }
759
760 TString opt = option;
761 opt.ToLower();
762 opt.ReplaceAll(" ","");
763 Bool_t lsame = kFALSE;
764 if (opt.Contains("same")) {
765 lsame = kTRUE;
766 opt.ReplaceAll("same","");
767 }
768 Bool_t lclear = kTRUE;
769 if (opt.Contains("noclear")) {
770 lclear = kFALSE;
771 opt.ReplaceAll("noclear","");
772 }
773 if (opt.Contains("pads")) {
774 Int_t npads = fHists->GetSize();
775 TVirtualPad *padsav = gPad;
776 //if pad is not already divided into subpads, divide it
777 Int_t nps = 0;
778 TObject *obj;
779 TIter nextp(padsav->GetListOfPrimitives());
780 while ((obj = nextp())) {
781 if (obj->InheritsFrom(TVirtualPad::Class())) nps++;
782 }
783 if (nps < npads) {
784 padsav->Clear();
785 Int_t nx = (Int_t)TMath::Sqrt((Double_t)npads);
786 if (nx*nx < npads) nx++;
787 Int_t ny = nx;
788 if (((nx*ny)-nx) >= npads) ny--;
789 padsav->Divide(nx,ny);
790
791 TH1 *h;
792 Int_t i = 0;
794 while (lnk) {
795 i++;
796 padsav->cd(i);
797 h = (TH1*)lnk->GetObject();
798 h->Draw(lnk->GetOption());
799 lnk = (TObjOptLink*)lnk->Next();
800 }
801 padsav->cd();
802 }
803 return;
804 }
805
806 // compute the min/max of each axis
807 TH1 *h;
808 TIter next(fHists);
809 Double_t xmin = 1e100;
810 Double_t xmax = -xmin;
811 Double_t ymin = 1e100;
812 Double_t ymax = -xmin;
813 while ((h=(TH1*)next())) {
814 // in case of automatic binning
815 if (h->GetBuffer()) h->BufferEmpty(-1);
816 if (h->GetXaxis()->GetXmin() < xmin) xmin = h->GetXaxis()->GetXmin();
817 if (h->GetXaxis()->GetXmax() > xmax) xmax = h->GetXaxis()->GetXmax();
818 if (h->GetYaxis()->GetXmin() < ymin) ymin = h->GetYaxis()->GetXmin();
819 if (h->GetYaxis()->GetXmax() > ymax) ymax = h->GetYaxis()->GetXmax();
820 }
821
822 TString loption = opt;
823 Bool_t nostack = loption.Contains("nostack");
824 Bool_t nostackb = loption.Contains("nostackb");
825 Bool_t candle = loption.Contains("candle");
826 Bool_t violin = loption.Contains("violin");
827
828 // do not delete the stack. Another pad may contain the same object
829 // drawn in stack mode!
830 //if (nostack && fStack) {fStack->Delete(); delete fStack; fStack = 0;}
831
832 if (!nostack && !candle && !violin) BuildStack();
833
834 Double_t themax,themin;
835 if (fMaximum == -1111) themax = GetMaximum(option);
836 else themax = fMaximum;
837 if (fMinimum == -1111) {
838 themin = GetMinimum(option);
839 if (gPad->GetLogy()){
840 if (themin>0) themin *= .9;
841 else themin = themax*1.e-3;
842 }
843 else if (themin > 0)
844 themin = 0;
845 }
846 else themin = fMinimum;
847 if (!fHistogram) {
850 h = (TH1*)fHists->At(0);
851 TAxis *xaxis = h->GetXaxis();
852 TAxis *yaxis = h->GetYaxis();
853 const TArrayD *xbins = xaxis->GetXbins();
854 if (h->GetDimension() > 1) {
855 if (loption.IsNull()) loption = "lego1";
856 const TArrayD *ybins = yaxis->GetXbins();
857 if (xbins->fN != 0 && ybins->fN != 0) {
859 xaxis->GetNbins(), xbins->GetArray(),
860 yaxis->GetNbins(), ybins->GetArray());
861 } else if (xbins->fN != 0 && ybins->fN == 0) {
863 xaxis->GetNbins(), xbins->GetArray(),
864 yaxis->GetNbins(), ymin, ymax);
865 } else if (xbins->fN == 0 && ybins->fN != 0) {
867 xaxis->GetNbins(), xmin, xmax,
868 yaxis->GetNbins(), ybins->GetArray());
869 } else {
871 xaxis->GetNbins(), xmin, xmax,
872 yaxis->GetNbins(), ymin, ymax);
873 }
874 } else {
875 if (xbins->fN != 0) {
877 xaxis->GetNbins(), xbins->GetArray());
878 } else {
879 fHistogram = new TH1F(GetName(),GetTitle(),xaxis->GetNbins(),xmin, xmax);
880 }
881 }
884 } else {
886 }
887
888 if (nostackb) {
889 loption.ReplaceAll("nostackb","");
890 } else {
891 if (nostack) loption.ReplaceAll("nostack","");
893 }
894
896 if (nostack && fMaximum != -1111) fHistogram->SetMaximum(fMaximum);
897 else {
898 if (gPad->GetLogy()) fHistogram->SetMaximum(themax*(1+0.2*TMath::Log10(themax/themin)));
899 else {
900 if (fMaximum != -1111) fHistogram->SetMaximum(themax);
901 else fHistogram->SetMaximum((1+gStyle->GetHistTopMargin())*themax);
902 }
903 }
904 if (nostack && fMinimum != -1111) fHistogram->SetMinimum(fMinimum);
905 else {
906 if (gPad->GetLogy()) fHistogram->SetMinimum(themin/(1+0.5*TMath::Log10(themax/themin)));
907 else fHistogram->SetMinimum(themin);
908 }
909 }
910
911 // Copy the axis labels if needed.
912 TH1 *hfirst;
914 hfirst = (TH1*)lnk->GetObject();
915 THashList* labels = hfirst->GetXaxis()->GetLabels();
916 if (labels) {
917 TIter iL(labels);
918 TObjString* lb;
919 Int_t ilab = 1;
920 while ((lb=(TObjString*)iL())) {
921 fHistogram->GetXaxis()->SetBinLabel(ilab,lb->String().Data());
922 ilab++;
923 }
924 }
925
926 if (!lsame) fHistogram->Paint(loption.Data());
927
928 if (fHistogram->GetDimension() > 1) SetDrawOption(loption.Data());
929 if (loption.Index("lego")>=0) return;
930
931 char noption[32];
932 strlcpy(noption,loption.Data(),32);
933 Int_t nhists = fHists->GetSize();
934 if (nostack || candle || violin) {
935 lnk = (TObjOptLink*)fHists->FirstLink();
936 TH1* hAti;
937 Double_t bo=0.03;
938 Double_t bw = (1.-(2*bo))/nhists;
939 for (Int_t i=0;i<nhists;i++) {
940 if (strstr(lnk->GetOption(),"same")) {
941 if (nostackb) loption.Form("%s%s b",noption,lnk->GetOption());
942 else loption.Form("%s%s",noption,lnk->GetOption());
943 } else {
944 TString indivOpt = lnk->GetOption();
945 indivOpt.ToLower();
946 if (nostackb) loption.Form("%ssame%s b",noption,lnk->GetOption());
947 else if (candle && (indivOpt.Contains("candle") || indivOpt.Contains("violin"))) loption.Form("%ssame",lnk->GetOption());
948 else loption.Form("%ssame%s",noption,lnk->GetOption());
949 }
950 hAti = (TH1F*)(fHists->At(i));
951 if (nostackb) {
952 hAti->SetBarWidth(bw);
953 hAti->SetBarOffset(bo);
954 bo += bw;
955 }
956 if (candle || violin) {
957 float candleSpace = 1./(nhists*2);
958 float candleOffset = - 1./2 + candleSpace + 2*candleSpace*i;
959 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
960 hAti->SetBarWidth(candleSpace);
961 hAti->SetBarOffset(candleOffset);
962 }
963 hAti->Paint(loption.Data());
964 lnk = (TObjOptLink*)lnk->Next();
965 }
966 } else {
967 lnk = (TObjOptLink*)fHists->LastLink();
968 TH1 *h1;
969 Int_t h1col, h1fill;
970 for (Int_t i=0;i<nhists;i++) {
971 if (strstr(lnk->GetOption(),"same")) {
972 loption.Form("%s%s",noption,lnk->GetOption());
973 } else {
974 loption.Form("%ssame%s",noption,lnk->GetOption());
975 }
976 h1 = (TH1*)fStack->At(nhists-i-1);
977 if (i>0 && lclear) {
978 // Erase before drawing the histogram
979 h1col = h1->GetFillColor();
980 h1fill = h1->GetFillStyle();
981 h1->SetFillColor(10);
982 h1->SetFillStyle(1001);
983 h1->Paint(loption.Data());
984 static TClassRef clTFrame = TClass::GetClass("TFrame",kFALSE);
985 TAttFill *frameFill = (TAttFill*)clTFrame->DynamicCast(TAttFill::Class(),gPad->GetFrame());
986 if (frameFill) {
987 h1->SetFillColor(frameFill->GetFillColor());
988 h1->SetFillStyle(frameFill->GetFillStyle());
989 }
990 h1->Paint(loption.Data());
991 h1->SetFillColor(h1col);
992 h1->SetFillStyle(h1fill);
993 }
994 h1->Paint(loption.Data());
995 lnk = (TObjOptLink*)lnk->Prev();
996 }
997 }
998
999 opt.ReplaceAll("nostack","");
1000 opt.ReplaceAll("candle","");
1001 if (!lsame && !opt.Contains("a")) fHistogram->Paint("axissame");
1002}
1003
1004////////////////////////////////////////////////////////////////////////////////
1005/// Print the list of histograms
1006
1007void THStack::Print(Option_t *option) const
1008{
1009 TH1 *h;
1010 if (fHists) {
1011 TIter next(fHists);
1012 while ((h = (TH1*) next())) {
1013 h->Print(option);
1014 }
1015 }
1016}
1017
1018////////////////////////////////////////////////////////////////////////////////
1019/// Recursively remove object from the list of histograms
1020
1022{
1023 if (!fHists) return;
1024 fHists->RecursiveRemove(obj);
1025 while (fHists->IndexOf(obj) >= 0) fHists->Remove(obj);
1026}
1027
1028////////////////////////////////////////////////////////////////////////////////
1029/// Save primitive as a C++ statement(s) on output stream out
1030
1031void THStack::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1032{
1033 char quote = '"';
1034 out<<" "<<std::endl;
1035 if (gROOT->ClassSaved(THStack::Class())) {
1036 out<<" ";
1037 } else {
1038 out<<" THStack *";
1039 }
1040 out<<GetName()<<" = new THStack();"<<std::endl;
1041 out<<" "<<GetName()<<"->SetName("<<quote<<GetName()<<quote<<");"<<std::endl;
1042 out<<" "<<GetName()<<"->SetTitle("<<quote<<GetTitle()<<quote<<");"<<std::endl;
1043
1044 if (fMinimum != -1111) {
1045 out<<" "<<GetName()<<"->SetMinimum("<<fMinimum<<");"<<std::endl;
1046 }
1047 if (fMaximum != -1111) {
1048 out<<" "<<GetName()<<"->SetMaximum("<<fMaximum<<");"<<std::endl;
1049 }
1050
1051 static Int_t frameNumber = 0;
1052 if (fHistogram) {
1053 frameNumber++;
1054 TString hname = fHistogram->GetName();
1055 hname += "_stack_";
1056 hname += frameNumber;
1057 fHistogram->SetName(hname.Data());
1058 fHistogram->SavePrimitive(out,"nodraw");
1059 out<<" "<<GetName()<<"->SetHistogram("<<fHistogram->GetName()<<");"<<std::endl;
1060 out<<" "<<std::endl;
1061 }
1062
1063 TH1 *h;
1064 if (fHists) {
1066 Int_t hcount = 0;
1067 while (lnk) {
1068 h = (TH1*)lnk->GetObject();
1069 TString hname = h->GetName();
1070 hname += Form("_stack_%d",++hcount);
1071 h->SetName(hname);
1072 h->SavePrimitive(out,"nodraw");
1073 out<<" "<<GetName()<<"->Add("<<h->GetName()<<","<<quote<<lnk->GetOption()<<quote<<");"<<std::endl;
1074 lnk = (TObjOptLink*)lnk->Next();
1075 }
1076 }
1077 out<<" "<<GetName()<<"->Draw("
1078 <<quote<<option<<quote<<");"<<std::endl;
1079}
1080
1081////////////////////////////////////////////////////////////////////////////////
1082/// Set maximum.
1083
1085{
1086 fMaximum = maximum;
1087 if (fHistogram) fHistogram->SetMaximum(maximum);
1088}
1089
1090////////////////////////////////////////////////////////////////////////////////
1091/// Set minimum.
1092
1094{
1095 fMinimum = minimum;
1096 if (fHistogram) fHistogram->SetMinimum(minimum);
1097}
1098
1099
1100////////////////////////////////////////////////////////////////////////////////
1101/// Get iterator over internal hists list.
1103{
1104 return TIter(fHists);
1105}
@ 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:124
int Int_t
Definition RtypesCore.h:45
const Bool_t kFALSE
Definition RtypesCore.h:101
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:80
const Bool_t kTRUE
Definition RtypesCore.h:100
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:404
char * Form(const char *fmt,...)
R__EXTERN TStyle * gStyle
Definition TStyle.h:413
#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: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:2966
Collection abstract base class.
Definition TCollection.h:65
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:7111
virtual void SetTitle(const char *title)
See GetStatOverflows for more information.
Definition TH1.cxx:6667
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:1283
@ 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:4453
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:3866
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:8790
virtual void Paint(Option_t *option="")
Control routine to paint any kind of histograms.
Definition TH1.cxx:6157
static Bool_t AddDirectoryStatus()
Static function: cannot be inlined on Windows/NT.
Definition TH1.cxx:751
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Compute distance from point px,py to a line.
Definition TH1.cxx:2812
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:8820
2-D histogram with a float per channel (see TH1 documentation)}
Definition TH2.h:251
Service class for 2-D 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:2429
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:2389
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:2362
The Histogram stack class.
Definition THStack.h:38
virtual void Print(Option_t *chopt="") const
Print the list of histograms.
Definition THStack.cxx:1007
TIter begin() const
Get iterator over internal hists list.
Definition THStack.cxx:1102
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:670
TObjArray * fStack
! Pointer to array of sums of TH1
Definition THStack.h:44
Double_t fMinimum
Minimum value for plotting along y.
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 y axis of the histogram used to draw the stack.
Definition THStack.cxx:643
virtual Long64_t Merge(TCollection *li, TFileMergeInfo *info)
Merge the THStack in the TList into this stack.
Definition THStack.cxx:683
virtual void Paint(Option_t *chopt="")
Paint the list of histograms.
Definition THStack.cxx:719
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:1031
TObjArray * GetStack()
Return pointer to Stack. Build it if not yet done.
Definition THStack.cxx:615
Int_t GetNhists() const
Return the number of histograms in the stack.
Definition THStack.cxx:606
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:562
TList * fHists
Pointer to array of TH1.
Definition THStack.h:43
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum.
Definition THStack.cxx:1084
TH1 * fHistogram
Pointer to histogram used for drawing axis.
Definition THStack.h:45
TAxis * GetZaxis() const
Get z axis of the histogram used to draw the stack.
Definition THStack.cxx:658
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from the list of histograms.
Definition THStack.cxx:1021
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:706
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum.
Definition THStack.cxx:1093
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:628
Double_t fMaximum
Maximum value for plotting along y.
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:38
virtual void Add(TObject *obj)
Definition TList.h:81
virtual TObjLink * LastLink() const
Definition TList.h:105
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition TList.cxx:822
virtual TObjLink * FirstLink() const
Definition TList.h:102
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:31
void Add(TObject *obj)
Definition TObjArray.h:68
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:164
Collectable string class.
Definition TObjString.h:28
TString & String()
Definition TObjString.h:48
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:201
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
Definition TObject.cxx:216
virtual Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition TObject.cxx:413
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:949
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:177
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:515
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:963
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition TObject.cxx:749
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:267
@ kCanDelete
if object in a list can be deleted
Definition TObject.h:62
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition TROOT.cxx:2811
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:2819
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition TROOT.cxx:2704
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:1150
Ssiz_t First(char c) const
Find first occurrence of a character c.
Definition TString.cxx:523
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:2314
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:208
Double_t Sqrt(Double_t x)
Definition TMath.h:641
Short_t Min(Short_t a, Short_t b)
Definition TMathBase.h:176
Double_t Log10(Double_t x)
Definition TMath.h:714
Definition first.py:1
th1 Draw()
void ws()
Definition ws.C:66