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