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