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