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