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