Logo ROOT   6.10/09
Reference Guide
RooPlot.cxx
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * @(#)root/roofitcore:$Id$
5  * Authors: *
6  * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7  * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8  * *
9  * Copyright (c) 2000-2005, Regents of the University of California *
10  * and Stanford University. All rights reserved. *
11  * *
12  * Redistribution and use in source and binary forms, *
13  * with or without modification, are permitted according to the terms *
14  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15  *****************************************************************************/
16 
17 /**
18 \file RooPlot.cxx
19 \class RooPlot
20 \ingroup Roofitcore
21 
22 A RooPlot is a plot frame and a container for graphics objects
23 within that frame. As a frame, it provides the TH1-style public interface
24 for settting plot ranges, configuring axes, etc. As a container, it
25 holds an arbitrary set of objects that might be histograms of data,
26 curves representing a fit model, or text labels. Use the Draw()
27 method to draw a frame and the objects it contains. Use the various
28 add...() methods to add objects to be drawn. In general, the
29 add...() methods create a private copy of the object you pass them
30 and return a pointer to this copy. The caller owns the input object
31 and this class owns the returned object.
32 All RooAbsReal and RooAbsData derived classes implement plotOn()
33 functions that facilitate to plot themselves on a given RooPlot, e.g.
34 ~~~ {.cpp}
35 RooPlot *frame = x.frame() ;
36 data.plotOn(frame) ;
37 pdf.plotOn(frame) ;
38 ~~~
39 These high level functions also take care of any projections
40 or other mappings that need to be made to plot a multi-dimensional
41 object onto a one-dimensional plot.
42 **/
43 
44 
45 #include "RooFit.h"
46 
47 #include "TClass.h"
48 #include "TH1D.h"
49 #include "TBrowser.h"
50 #include "TPad.h"
51 
52 #include "RooPlot.h"
53 #include "RooAbsReal.h"
54 #include "RooAbsRealLValue.h"
55 #include "RooPlotable.h"
56 #include "RooArgSet.h"
57 #include "RooCurve.h"
58 #include "RooHist.h"
59 #include "RooMsgService.h"
60 
61 #include "TAttLine.h"
62 #include "TAttFill.h"
63 #include "TAttMarker.h"
64 #include "TAttText.h"
65 #include "TDirectory.h"
66 #include "TDirectoryFile.h"
67 
68 #include "Riostream.h"
69 #include <string.h>
70 #include <assert.h>
71 
72 using namespace std;
73 
75 ;
76 
78 
79 Bool_t RooPlot::addDirectoryStatus() { return _addDirStatus ; }
80 Bool_t RooPlot::setAddDirectoryStatus(Bool_t flag) { Bool_t ret = flag ; _addDirStatus = flag ; return ret ; }
81 
82 
83 ////////////////////////////////////////////////////////////////////////////////
84 /// Default constructor
85 /// coverity[UNINIT_CTOR]
86 
87 RooPlot::RooPlot() : _hist(0), _plotVarClone(0), _plotVarSet(0), _normVars(0), _normObj(0), _dir(0)
88 {
90 
91  if (gDirectory && addDirectoryStatus()) {
92  _dir = gDirectory ;
93  gDirectory->Append(this) ;
94  }
95 }
96 
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 /// Constructor of RooPlot with range [xmin,xmax]
100 
102  _hist(0), _items(), _plotVarClone(0), _plotVarSet(0), _normObj(0),
103  _defYmin(1e-5), _defYmax(1), _dir(0)
104 {
105  Bool_t histAddDirStatus = TH1::AddDirectoryStatus();
107 
108  _hist = new TH1D(histName(),"A RooPlot",100,xmin,xmax) ;
109  _hist->Sumw2(kFALSE) ;
110  _hist->GetSumw2()->Set(0) ;
111 
112 
113  TH1::AddDirectory(histAddDirStatus) ;
114 
115 
116  // Create an empty frame with the specified x-axis limits.
117  initialize();
118 
119 }
120 
121 
122 
123 ////////////////////////////////////////////////////////////////////////////////
124 /// Construct of a two-dimensioanl RooPlot with ranges [xmin,xmax] x [ymin,ymax]
125 
127  _hist(0), _items(), _plotVarClone(0),
128  _plotVarSet(0), _normObj(0), _defYmin(1e-5), _defYmax(0), _dir(0)
129 {
130  Bool_t histAddDirStatus = TH1::AddDirectoryStatus();
132 
133  _hist = new TH1D(histName(),"A RooPlot",100,xmin,xmax) ;
134  _hist->Sumw2(kFALSE) ;
135  _hist->GetSumw2()->Set(0) ;
136 
137  TH1::AddDirectory(histAddDirStatus) ;
138 
139  SetMinimum(ymin);
140  SetMaximum(ymax);
141  initialize();
142 }
143 
144 
145 ////////////////////////////////////////////////////////////////////////////////
146 /// Construct a two-dimensional RooPlot with ranges and properties taken
147 /// from variables var1 and var2
148 
150  _hist(0), _items(),
151  _plotVarClone(0), _plotVarSet(0), _normObj(0), _defYmin(1e-5), _defYmax(0), _dir(0)
152 {
153  Bool_t histAddDirStatus = TH1::AddDirectoryStatus();
155 
156  _hist = new TH1D(histName(),"A RooPlot",100,var1.getMin(),var1.getMax()) ;
157  _hist->Sumw2(kFALSE) ;
158  _hist->GetSumw2()->Set(0) ;
159 
160  TH1::AddDirectory(histAddDirStatus) ;
161 
162  if(!var1.hasMin() || !var1.hasMax()) {
163  coutE(InputArguments) << "RooPlot::RooPlot: cannot create plot for variable without finite limits: "
164  << var1.GetName() << endl;
165  return;
166  }
167  if(!var2.hasMin() || !var2.hasMax()) {
168  coutE(InputArguments) << "RooPlot::RooPlot: cannot create plot for variable without finite limits: "
169  << var1.GetName() << endl;
170  return;
171  }
172  SetMinimum(var2.getMin());
173  SetMaximum(var2.getMax());
174  SetXTitle(var1.getTitle(kTRUE));
175  SetYTitle(var2.getTitle(kTRUE));
176  initialize();
177 }
178 
179 
180 ////////////////////////////////////////////////////////////////////////////////
181 /// Construct a two-dimensional RooPlot with ranges and properties taken
182 /// from variables var1 and var2 but with an overriding range definition
183 /// of [xmin,xmax] x [ymin,ymax]
184 
187  _hist(0), _items(), _plotVarClone(0),
188  _plotVarSet(0), _normObj(0), _defYmin(1e-5), _defYmax(0), _dir(0)
189 {
190  Bool_t histAddDirStatus = TH1::AddDirectoryStatus();
192 
193  _hist = new TH1D(histName(),"A RooPlot",100,xmin,xmax) ;
194  _hist->Sumw2(kFALSE) ;
195  _hist->GetSumw2()->Set(0) ;
196 
197  TH1::AddDirectory(histAddDirStatus) ;
198 
199  SetMinimum(ymin);
200  SetMaximum(ymax);
201  SetXTitle(var1.getTitle(kTRUE));
202  SetYTitle(var2.getTitle(kTRUE));
203  initialize();
204 }
205 
206 
207 ////////////////////////////////////////////////////////////////////////////////
208 /// Create an 1-dimensional with all properties taken from 'var', but
209 /// with an explicit range [xmin,xmax] and a default binning of 'nbins'
210 
211 RooPlot::RooPlot(const char* name, const char* title, const RooAbsRealLValue &var, Double_t xmin, Double_t xmax, Int_t nbins) :
212  _hist(0), _items(),
213  _plotVarClone(0), _plotVarSet(0), _normObj(0), _defYmin(1e-5), _defYmax(1), _dir(0)
214 {
215  Bool_t histAddDirStatus = TH1::AddDirectoryStatus();
217 
218  _hist = new TH1D(name,title,nbins,xmin,xmax) ;
219  _hist->Sumw2(kFALSE) ;
220  _hist->GetSumw2()->Set(0) ;
221 
222  TH1::AddDirectory(histAddDirStatus) ;
223 
224  // plotVar can be a composite in case of a RooDataSet::plot, need deepClone
227 
228  TString xtitle= var.getTitle(kTRUE);
229  SetXTitle(xtitle.Data());
230 
231  initialize();
232 
233  _normBinWidth = (xmax-xmin)/nbins ;
234 }
235 
236 
237 ////////////////////////////////////////////////////////////////////////////////
238 /// Create an 1-dimensional with all properties taken from 'var', but
239 /// with an explicit range [xmin,xmax] and a default binning of 'nbins'
240 
242  _hist(0), _items(),
243  _plotVarClone(0), _plotVarSet(0), _normObj(0), _defYmin(1e-5), _defYmax(1), _dir(0)
244 {
245  Bool_t histAddDirStatus = TH1::AddDirectoryStatus();
247 
248  _hist = new TH1D(histName(),"RooPlot",nbins,xmin,xmax) ;
249  _hist->Sumw2(kFALSE) ;
250  _hist->GetSumw2()->Set(0) ;
251 
252  TH1::AddDirectory(histAddDirStatus) ;
253 
254  // plotVar can be a composite in case of a RooDataSet::plot, need deepClone
257 
258  TString xtitle= var.getTitle(kTRUE);
259  SetXTitle(xtitle.Data());
260 
261  TString title("A RooPlot of \"");
262  title.Append(var.getTitle());
263  title.Append("\"");
264  SetTitle(title.Data());
265  initialize();
266 
267  _normBinWidth = (xmax-xmin)/nbins ;
268 }
269 
270 
271 
272 ////////////////////////////////////////////////////////////////////////////////
273 /// Return empty clone of current RooPlot
274 
276 {
278  clone->SetName(name) ;
279  return clone ;
280 }
281 
282 
283 ////////////////////////////////////////////////////////////////////////////////
284 /// Perform initialization that is common to all constructors.
285 
287 {
288  SetName(histName()) ;
289 
290  if (gDirectory && addDirectoryStatus()) {
291  _dir = gDirectory ;
292  gDirectory->Append(this) ;
293  }
294 
295  // We do not have useful stats of our own
297  // Default vertical padding of our enclosed objects
298  setPadFactor(0.05);
299  // We don't know our normalization yet
300  _normNumEvts= 0;
301  _normBinWidth = 0;
302  _normVars= 0;
303  // Create an iterator over our enclosed objects
305  assert(0 != _iterator);
306 }
307 
308 
309 ////////////////////////////////////////////////////////////////////////////////
310 /// Construct automatic name of internal TH1
311 
312 TString RooPlot::histName() const
313 {
314  if (_plotVarClone) {
315  return TString(Form("frame_%s_%lx",_plotVarClone->GetName(),(ULong_t)this)) ;
316  } else {
317  return TString(Form("frame_%lx",(ULong_t)this)) ;
318  }
319 }
320 
321 
322 ////////////////////////////////////////////////////////////////////////////////
323 /// Destructor
324 
326 {
327  // Delete the items in our container and our iterator.
328  if (_dir) {
330  _dir->GetList()->RecursiveRemove(this) ;
331  }
332  }
333 
334  _items.Delete();
335  delete _iterator;
336  if(_plotVarSet) delete _plotVarSet;
337  if(_normVars) delete _normVars;
338  delete _hist ;
339 
340 }
341 
342 
343 ////////////////////////////////////////////////////////////////////////////////
344 /// Install the given set of observables are reference normalization
345 /// variables for this frame. These observables are e.g. later used
346 /// to automatically project out observables when plotting functions
347 /// on this frame. This function is only effective when called the
348 /// first time on a frame
349 
351 {
352  if(0 == _normVars) _normVars= (RooArgSet*) vars.snapshot(kTRUE);
353 }
354 
355 
356 ////////////////////////////////////////////////////////////////////////////////
357 /// A plot object is a frame without any bin contents of its own so this
358 /// method always returns zero.
359 
361  return 0;
362 }
363 
364 
365 ////////////////////////////////////////////////////////////////////////////////
366 /// A plot object is a frame without any bin contents of its own so this
367 /// method always returns zero.
368 
370 {
371  return 0;
372 }
373 
374 
375 ////////////////////////////////////////////////////////////////////////////////
376 /// A plot object is a frame without any bin contents of its own so this
377 /// method always returns zero.
378 
380 {
381  return 0;
382 }
383 
384 
385 
386 ////////////////////////////////////////////////////////////////////////////////
387 /// Add a generic object to this plot. The specified options will be
388 /// used to Draw() this object later. The caller transfers ownership
389 /// of the object with this call, and the object will be deleted
390 /// when its containing plot object is destroyed.
391 
392 void RooPlot::addObject(TObject *obj, Option_t *drawOptions, Bool_t invisible)
393 {
394  if(0 == obj) {
395  coutE(InputArguments) << fName << "::addObject: called with a null pointer" << endl;
396  return;
397  }
398  DrawOpt opt(drawOptions) ;
399  opt.invisible = invisible ;
400  _items.Add(obj,opt.rawOpt());
401 }
402 
403 
404 ////////////////////////////////////////////////////////////////////////////////
405 /// Add a TH1 histogram object to this plot. The specified options
406 /// will be used to Draw() this object later. "SAME" will be added to
407 /// the options if they are not already present. The caller transfers
408 /// ownership of the object with this call, and the object will be
409 /// deleted when its containing plot object is destroyed.
410 
411 void RooPlot::addTH1(TH1 *hist, Option_t *drawOptions, Bool_t invisible)
412 {
413  if(0 == hist) {
414  coutE(InputArguments) << fName << "::addTH1: called with a null pointer" << endl;
415  return;
416  }
417  // check that this histogram is really 1D
418  if(1 != hist->GetDimension()) {
419  coutE(InputArguments) << fName << "::addTH1: cannot plot histogram with "
420  << hist->GetDimension() << " dimensions" << endl;
421  return;
422  }
423 
424  // add option "SAME" if necessary
425  TString options(drawOptions);
426  options.ToUpper();
427  if(!options.Contains("SAME")) options.Append("SAME");
428 
429  // update our y-axis label and limits
430  updateYAxis(hist->GetMinimum(),hist->GetMaximum(),hist->GetYaxis()->GetTitle());
431 
432  // use this histogram's normalization if necessary
433  updateFitRangeNorm(hist);
434 
435  // add the histogram to our list
436  addObject(hist,options.Data(),invisible);
437 }
438 
439 
440 ////////////////////////////////////////////////////////////////////////////////
441 /// Add the specified plotable object to our plot. Increase our y-axis
442 /// limits to fit this object if necessary. The default lower-limit
443 /// is zero unless we are plotting an object that takes on negative values.
444 /// This call transfers ownership of the plotable object to this class.
445 /// The plotable object will be deleted when this plot object is deleted.
446 
447 void RooPlot::addPlotable(RooPlotable *plotable, Option_t *drawOptions, Bool_t invisible, Bool_t refreshNorm)
448 {
449  // update our y-axis label and limits
450  updateYAxis(plotable->getYAxisMin(),plotable->getYAxisMax(),plotable->getYAxisLabel());
451 
452  // use this object's normalization if necessary
453  updateFitRangeNorm(plotable,refreshNorm) ;
454 
455  // add this element to our list and remember its drawing option
456  TObject *obj= plotable->crossCast();
457  if(0 == obj) {
458  coutE(InputArguments) << fName << "::add: cross-cast to TObject failed (nothing added)" << endl;
459  }
460  else {
461  DrawOpt opt(drawOptions) ;
462  opt.invisible = invisible ;
463  _items.Add(obj,opt.rawOpt());
464  }
465 }
466 
467 
468 ////////////////////////////////////////////////////////////////////////////////
469 /// Update our plot normalization over our plot variable's fit range,
470 /// which will be determined by the first suitable object added to our plot.
471 
473 {
474  const TAxis* xa = ((TH1*)hist)->GetXaxis() ;
475  _normBinWidth = (xa->GetXmax()-xa->GetXmin())/hist->GetNbinsX() ;
477 }
478 
479 
480 ////////////////////////////////////////////////////////////////////////////////
481 /// Update our plot normalization over our plot variable's fit range,
482 /// which will be determined by the first suitable object added to our plot.
483 
484 void RooPlot::updateFitRangeNorm(const RooPlotable* rp, Bool_t refreshNorm)
485 {
486  if (_normNumEvts != 0) {
487 
488  // If refresh feature is disabled stop here
489  if (!refreshNorm) return ;
490 
491  Double_t corFac(1.0) ;
492  if (dynamic_cast<const RooHist*>(rp)) corFac = _normBinWidth/rp->getFitRangeBinW() ;
493 
494 
495  if (fabs(rp->getFitRangeNEvt()/corFac-_normNumEvts)>1e-6) {
496  coutI(Plotting) << "RooPlot::updateFitRangeNorm: New event count of " << rp->getFitRangeNEvt()/corFac
497  << " will supercede previous event count of " << _normNumEvts << " for normalization of PDF projections" << endl ;
498  }
499 
500  // Nominal bin width (i.e event density) is already locked in by previously drawn histogram
501  // scale this histogram to match that density
502  _normNumEvts = rp->getFitRangeNEvt()/corFac ;
503  _normObj = rp ;
504  // cout << "correction factor = " << _normBinWidth << "/" << rp->getFitRangeBinW() << endl ;
505  // cout << "updating numevts to " << _normNumEvts << endl ;
506 
507  } else {
508 
509  _normObj = rp ;
510  _normNumEvts = rp->getFitRangeNEvt() ;
511  if (rp->getFitRangeBinW()) {
513  }
514 
515  // cout << "updating numevts to " << _normNumEvts << endl ;
516  }
517 
518 }
519 
520 
521 
522 ////////////////////////////////////////////////////////////////////////////////
523 /// Update our y-axis limits to accomodate an object whose spread
524 /// in y is (ymin,ymax). Use the specified y-axis label if we don't
525 /// have one assigned already.
526 
527 void RooPlot::updateYAxis(Double_t ymin, Double_t ymax, const char *label)
528 {
529  // force an implicit lower limit of zero if appropriate
530  if(GetMinimum() == 0 && ymin > 0) ymin= 0;
531 
532  // calculate padded values
533  Double_t ypad= getPadFactor()*(ymax-ymin);
534  ymax+= ypad;
535  if(ymin < 0) ymin-= ypad;
536 
537  // update our limits if necessary
538  if(GetMaximum() < ymax) {
539  _defYmax = ymax ;
540  SetMaximum(ymax);
541  // if we don't do this - Unzoom on y-axis will reset upper bound to 1
542  _hist->SetBinContent(1,ymax) ;
543  }
544  if(GetMinimum() > ymin) {
545  _defYmin = ymin ;
546  SetMinimum(ymin);
547  }
548 
549  // use the specified y-axis label if we don't have one already
550  if(0 == strlen(_hist->GetYaxis()->GetTitle())) _hist->SetYTitle(label);
551 }
552 
553 
554 ////////////////////////////////////////////////////////////////////////////////
555 /// Draw this plot and all of the elements it contains. The specified options
556 /// only apply to the drawing of our frame. The options specified in our add...()
557 /// methods will be used to draw each object we contain.
558 
559 void RooPlot::Draw(Option_t *option)
560 {
561  TString optArg = option ;
562  optArg.ToLower() ;
563 
564  // This draw options prevents the histogram with one dummy entry
565  // to be drawn
566  if (optArg.Contains("same")) {
567  _hist->Draw("FUNCSAME");
568  } else {
569  _hist->Draw("FUNC");
570  }
571 
572  _iterator->Reset();
573  TObject *obj = 0;
574  while((obj= _iterator->Next())) {
575  DrawOpt opt(_iterator->GetOption()) ;
576  if (!opt.invisible) {
577  //LM: in case of a TGraph derived object, do not use default "" option
578  // which is "ALP" from 5.34.10 (and will then redrawn the axis) but use "LP"
579  if (!strlen(opt.drawOptions) && obj->IsA()->InheritsFrom(TGraph::Class()) ) strlcpy(opt.drawOptions,"LP",3);
580  obj->Draw(opt.drawOptions);
581  }
582  }
583 
584  _hist->Draw("AXISSAME");
585 }
586 
587 
588 
589 ////////////////////////////////////////////////////////////////////////////////
590 /// Print frame name
591 
592 void RooPlot::printName(ostream& os) const
593 {
594  os << GetName() ;
595 }
596 
597 
598 ////////////////////////////////////////////////////////////////////////////////
599 /// Print frame title
600 
601 void RooPlot::printTitle(ostream& os) const
602 {
603  os << GetTitle() ;
604 }
605 
606 
607 ////////////////////////////////////////////////////////////////////////////////
608 /// Print frame class name
609 
610 void RooPlot::printClassName(ostream& os) const
611 {
612  os << IsA()->GetName() ;
613 }
614 
615 
616 
617 ////////////////////////////////////////////////////////////////////////////////
618 
619 void RooPlot::printArgs(ostream& os) const
620 {
621  if (_plotVarClone) {
622  os << "[" ;
624  os << "]" ;
625  }
626 }
627 
628 
629 
630 ////////////////////////////////////////////////////////////////////////////////
631 /// Print frame arguments
632 
633 void RooPlot::printValue(ostream& os) const
634 {
635  os << "(" ;
636  _iterator->Reset();
637  TObject *obj = 0;
638  Bool_t first(kTRUE) ;
639  while((obj= _iterator->Next())) {
640  if (first) {
641  first=kFALSE ;
642  } else {
643  os << "," ;
644  }
645  if(obj->IsA()->InheritsFrom(RooPrintable::Class())) {
646  RooPrintable* po = dynamic_cast<RooPrintable*>(obj) ;
647  // coverity[FORWARD_NULL]
649  }
650  // is it a TNamed subclass?
651  else {
652  os << obj->ClassName() << "::" << obj->GetName() ;
653  }
654  }
655  os << ")" ;
656 }
657 
658 
659 ////////////////////////////////////////////////////////////////////////////////
660 /// Frame detailed printing
661 
662 void RooPlot::printMultiline(ostream& os, Int_t /*content*/, Bool_t verbose, TString indent) const
663 {
664  TString deeper(indent);
665  deeper.Append(" ");
666  if(0 != _plotVarClone) {
667  os << indent << "RooPlot " << GetName() << " (" << GetTitle() << ") plots variable ";
669  }
670  else {
671  os << indent << "RooPlot " << GetName() << " (" << GetTitle() << ") has no associated plot variable" << endl ;
672  }
673  os << indent << " Plot frame contains " << _items.GetSize() << " object(s):" << endl;
674 
675  if(verbose) {
676  _iterator->Reset();
677  TObject *obj = 0;
678  Int_t i=0 ;
679  while((obj= _iterator->Next())) {
680  os << deeper << "[" << i++ << "] (Options=\"" << _iterator->GetOption() << "\") ";
681  // Is this a printable object?
682  if(obj->IsA()->InheritsFrom(RooPrintable::Class())) {
683  RooPrintable* po = dynamic_cast<RooPrintable*>(obj) ;
684  if (po) {
686  }
687  }
688  // is it a TNamed subclass?
689  else {
690  os << obj->ClassName() << "::" << obj->GetName() << endl;
691  }
692  }
693  }
694 }
695 
696 
697 
698 ////////////////////////////////////////////////////////////////////////////////
699 /// Return the name of the object at slot 'idx' in this RooPlot.
700 /// If the given index is out of range, return a null pointer
701 
702 const char* RooPlot::nameOf(Int_t idx) const
703 {
704  TObject* obj = _items.At(idx) ;
705  if (!obj) {
706  coutE(InputArguments) << "RooPlot::nameOf(" << GetName() << ") index " << idx << " out of range" << endl ;
707  return 0 ;
708  }
709  return obj->GetName() ;
710 }
711 
712 
713 
714 ////////////////////////////////////////////////////////////////////////////////
715 /// Return the name of the object at slot 'idx' in this RooPlot.
716 /// If the given index is out of range, return a null pointer
717 
719 {
720  TObject* obj = _items.At(idx) ;
721  if (!obj) {
722  coutE(InputArguments) << "RooPlot::getObject(" << GetName() << ") index " << idx << " out of range" << endl ;
723  return 0 ;
724  }
725  return obj ;
726 }
727 
728 
729 
730 ////////////////////////////////////////////////////////////////////////////////
731 /// Return a pointer to the line attributes of the named object in this plot,
732 /// or zero if the named object does not exist or does not have line attributes.
733 
734 TAttLine *RooPlot::getAttLine(const char *name) const
735 {
736  return dynamic_cast<TAttLine*>(findObject(name));
737 }
738 
739 
740 ////////////////////////////////////////////////////////////////////////////////
741 /// Return a pointer to the fill attributes of the named object in this plot,
742 /// or zero if the named object does not exist or does not have fill attributes.
743 
744 TAttFill *RooPlot::getAttFill(const char *name) const
745 {
746  return dynamic_cast<TAttFill*>(findObject(name));
747 }
748 
749 
750 ////////////////////////////////////////////////////////////////////////////////
751 /// Return a pointer to the marker attributes of the named object in this plot,
752 /// or zero if the named object does not exist or does not have marker attributes.
753 
755 {
756  return dynamic_cast<TAttMarker*>(findObject(name));
757 }
758 
759 
760 ////////////////////////////////////////////////////////////////////////////////
761 /// Return a pointer to the text attributes of the named object in this plot,
762 /// or zero if the named object does not exist or does not have text attributes.
763 
764 TAttText *RooPlot::getAttText(const char *name) const
765 {
766  return dynamic_cast<TAttText*>(findObject(name));
767 }
768 
769 
770 
771 ////////////////////////////////////////////////////////////////////////////////
772 /// Return a RooCurve pointer of the named object in this plot,
773 /// or zero if the named object does not exist or is not a RooCurve
774 
775 RooCurve* RooPlot::getCurve(const char* name) const
776 {
777  return dynamic_cast<RooCurve*>(findObject(name)) ;
778 }
779 
780 
781 ////////////////////////////////////////////////////////////////////////////////
782 /// Return a RooCurve pointer of the named object in this plot,
783 /// or zero if the named object does not exist or is not a RooCurve
784 
785 RooHist* RooPlot::getHist(const char* name) const
786 {
787  return dynamic_cast<RooHist*>(findObject(name)) ;
788 }
789 
790 
791 
792 ////////////////////////////////////////////////////////////////////////////////
793 /// Remove object with given name, or last object added if no name is given.
794 /// If deleteToo is true (default), the object removed from the RooPlot is
795 /// also deleted.
796 
797 void RooPlot::remove(const char* name, Bool_t deleteToo)
798 {
799  TObject* obj = findObject(name) ;
800  if (!obj) {
801  if (name) {
802  coutE(InputArguments) << "RooPlot::remove(" << GetName() << ") ERROR: no object found with name " << name << endl ;
803  } else {
804  coutE(InputArguments) << "RooPlot::remove(" << GetName() << ") ERROR: plot frame is empty, cannot remove last object" << endl ;
805  }
806  return ;
807  }
808 
809  _items.Remove(obj) ;
810 
811  if (deleteToo) {
812  delete obj ;
813  }
814 }
815 
816 
817 ////////////////////////////////////////////////////////////////////////////////
818 /// Change the order in which our contained objects are drawn so that
819 /// the target object is drawn just before the specified object.
820 /// Returns kFALSE if either object does not exist.
821 
822 Bool_t RooPlot::drawBefore(const char *before, const char *target)
823 {
824  return _items.moveBefore(before, target, caller("drawBefore"));
825 }
826 
827 
828 ////////////////////////////////////////////////////////////////////////////////
829 /// Change the order in which our contained objects are drawn so that
830 /// the target object is drawn just after the specified object.
831 /// Returns kFALSE if either object does not exist.
832 
833 Bool_t RooPlot::drawAfter(const char *after, const char *target)
834 {
835  return _items.moveAfter(after, target, caller("drawAfter"));
836 }
837 
838 
839 ////////////////////////////////////////////////////////////////////////////////
840 /// Find the named object in our list of items and return a pointer
841 /// to it. Return zero and print a warning message if the named
842 /// object cannot be found. If no name is supplied the last object
843 /// added is returned.
844 ///
845 /// Note that the returned pointer is to a
846 /// TObject and so will generally need casting. Use the getAtt...()
847 /// methods to change the drawing style attributes of a contained
848 /// object directly.
849 
850 TObject *RooPlot::findObject(const char *name, const TClass* clas) const
851 {
852  TObject *obj = 0;
853  TObject *ret = 0;
854 
855  TIterator* iter = _items.MakeIterator() ;
856  while((obj=iter->Next())) {
857  if ((!name || !TString(name).CompareTo(obj->GetName())) &&
858  (!clas || (obj->IsA()==clas))) {
859  ret = obj ;
860  }
861  }
862  delete iter ;
863 
864  if (ret==0) {
865  coutE(InputArguments) << "RooPlot::findObject(" << GetName() << ") cannot find object " << (name?name:"<last>") << endl ;
866  }
867  return ret ;
868 }
869 
870 
871 ////////////////////////////////////////////////////////////////////////////////
872 /// Return the Draw() options registered for the named object. Return
873 /// an empty string if the named object cannot be found.
874 
875 TString RooPlot::getDrawOptions(const char *name) const
876 {
877  TObjOptLink *link= _items.findLink(name,caller("getDrawOptions"));
878  DrawOpt opt(0 == link ? "" : link->GetOption()) ;
879  return TString(opt.drawOptions) ;
880 }
881 
882 
883 ////////////////////////////////////////////////////////////////////////////////
884 /// Register the specified drawing options for the named object.
885 /// Return kFALSE if the named object cannot be found.
886 
887 Bool_t RooPlot::setDrawOptions(const char *name, TString options)
888 {
889  TObjOptLink *link= _items.findLink(name,caller("setDrawOptions"));
890  if(0 == link) return kFALSE;
891 
892  DrawOpt opt(link->GetOption()) ;
893  strlcpy(opt.drawOptions,options,128) ;
894  link->SetOption(opt.rawOpt());
895  return kTRUE;
896 }
897 
898 
899 ////////////////////////////////////////////////////////////////////////////////
900 /// Returns true of object with given name is set to be invisible
901 
903 {
904  TObjOptLink *link= _items.findLink(name,caller("getInvisible"));
905  if(0 == link) return kFALSE;
906 
907  return DrawOpt(link->GetOption()).invisible ;
908 }
909 
910 
911 ////////////////////////////////////////////////////////////////////////////////
912 /// If flag is true object with 'name' is set to be invisible
913 /// i.e. it is not drawn when Draw() is called
914 
915 void RooPlot::setInvisible(const char* name, Bool_t flag)
916 {
917  TObjOptLink *link= _items.findLink(name,caller("getInvisible"));
918 
919  DrawOpt opt ;
920 
921  if(link) {
922  opt.initialize(link->GetOption()) ;
923  opt.invisible = flag ;
924  link->SetOption(opt.rawOpt()) ;
925  }
926 
927 }
928 
929 
930 
931 ////////////////////////////////////////////////////////////////////////////////
932 /// Utility function
933 
934 TString RooPlot::caller(const char *method) const
935 {
936  TString name(fName);
937  if(strlen(method)) {
938  name.Append("::");
939  name.Append(method);
940  }
941  return name;
942 }
943 
944 
945 
946 ////////////////////////////////////////////////////////////////////////////////
947 /// Set maximum value of Y axis
948 
950 {
951  _hist->SetMaximum(maximum==-1111?_defYmax:maximum) ;
952 }
953 
954 
955 
956 ////////////////////////////////////////////////////////////////////////////////
957 /// Set minimum value of Y axis
958 
960 {
961  _hist->SetMinimum(minimum==-1111?_defYmin:minimum) ;
962 }
963 
964 
965 
966 ////////////////////////////////////////////////////////////////////////////////
967 /// Calculate and return reduced chi-squared of curve with given name with respect
968 /// to histogram with given name. If nFitParam is non-zero, it is used to reduce the
969 /// number of degrees of freedom for a chi^2 for a curve that was fitted to the
970 /// data with that number of floating parameters
971 
972 Double_t RooPlot::chiSquare(const char* curvename, const char* histname, Int_t nFitParam) const
973 {
974 
975  // Find curve object
976  RooCurve* curve = (RooCurve*) findObject(curvename,RooCurve::Class()) ;
977  if (!curve) {
978  coutE(InputArguments) << "RooPlot::chiSquare(" << GetName() << ") cannot find curve" << endl ;
979  return -1. ;
980  }
981 
982  // Find histogram object
983  RooHist* hist = (RooHist*) findObject(histname,RooHist::Class()) ;
984  if (!hist) {
985  coutE(InputArguments) << "RooPlot::chiSquare(" << GetName() << ") cannot find histogram" << endl ;
986  return -1. ;
987  }
988 
989  return curve->chiSquare(*hist,nFitParam) ;
990 }
991 
992 
993 ////////////////////////////////////////////////////////////////////////////////
994 /// Return a RooHist containing the residuals of histogram 'histname' with respect
995 /// to curve 'curvename'. If normalize is true the residuals are divided by the error
996 /// on the histogram, effectively returning a pull histogram
997 
998 RooHist* RooPlot::residHist(const char* histname, const char* curvename, bool normalize, bool useAverage) const
999 {
1000  // Find curve object
1001  RooCurve* curve = (RooCurve*) findObject(curvename,RooCurve::Class()) ;
1002  if (!curve) {
1003  coutE(InputArguments) << "RooPlot::residHist(" << GetName() << ") cannot find curve" << endl ;
1004  return 0 ;
1005  }
1006 
1007  // Find histogram object
1008  RooHist* hist = (RooHist*) findObject(histname,RooHist::Class()) ;
1009  if (!hist) {
1010  coutE(InputArguments) << "RooPlot::residHist(" << GetName() << ") cannot find histogram" << endl ;
1011  return 0 ;
1012  }
1013 
1014  return hist->makeResidHist(*curve,normalize,useAverage) ;
1015 }
1016 
1017 
1018 
1019 ////////////////////////////////////////////////////////////////////////////////
1020 /// Initialize the DrawOpt helper class
1021 
1022 void RooPlot::DrawOpt::initialize(const char* inRawOpt)
1023 {
1024  if (!inRawOpt) {
1025  drawOptions[0] = 0 ;
1026  invisible=kFALSE ;
1027  return ;
1028  }
1029  strlcpy(drawOptions,inRawOpt,128) ;
1030  strtok(drawOptions,":") ;
1031  const char* extraOpt = strtok(0,":") ;
1032  if (extraOpt) {
1033  invisible = (extraOpt[0]=='I') ;
1034  }
1035 }
1036 
1037 
1038 ////////////////////////////////////////////////////////////////////////////////
1039 /// Return the raw draw options
1040 
1041 const char* RooPlot::DrawOpt::rawOpt() const
1042 {
1043  static char buf[128] ;
1044  strlcpy(buf,drawOptions,128) ;
1045  if (invisible) {
1046  strlcat(buf,":I",128) ;
1047  }
1048  return buf ;
1049 }
1050 
1051 
1052 
1053 ////////////////////////////////////////////////////////////////////////////////
1054 /// Return the number of events that is associated with the range [xlo,xhi]
1055 /// This method is only fully functional for ranges not equal to the full
1056 /// range if the object that inserted the normalization data provided
1057 /// a link to an external object that can calculate the event count in
1058 /// in sub ranges. An error will be printed if this function is used
1059 /// on sub-ranges while that information is not available
1060 
1062 {
1063  Double_t scaleFactor = 1.0 ;
1064  if (_normObj) {
1065  scaleFactor = _normObj->getFitRangeNEvt(xlo,xhi)/_normObj->getFitRangeNEvt() ;
1066  } else {
1067  coutW(Plotting) << "RooPlot::getFitRangeNEvt(" << GetName() << ") WARNING: Unable to obtain event count in range "
1068  << xlo << " to " << xhi << ", substituting full event count" << endl ;
1069  }
1070  return getFitRangeNEvt()*scaleFactor ;
1071 }
1072 
1073 
1074 ////////////////////////////////////////////////////////////////////////////////
1075 /// Set the name of the RooPlot to 'name'
1076 
1077 void RooPlot::SetName(const char *name)
1078 {
1079  if (_dir) _dir->GetList()->Remove(this);
1080  TNamed::SetName(name) ;
1081  if (_dir) _dir->GetList()->Add(this);
1082 }
1083 
1084 
1085 ////////////////////////////////////////////////////////////////////////////////
1086 /// Set the name and title of the RooPlot to 'name' and 'title'
1087 
1088 void RooPlot::SetNameTitle(const char *name, const char* title)
1089 {
1090  if (_dir) _dir->GetList()->Remove(this);
1091  TNamed::SetNameTitle(name,title) ;
1092  if (_dir) _dir->GetList()->Add(this);
1093 }
1094 
1095 
1096 ////////////////////////////////////////////////////////////////////////////////
1097 /// Set the title of the RooPlot to 'title'
1098 
1099 void RooPlot::SetTitle(const char* title)
1100 {
1101  TNamed::SetTitle(title) ;
1102  _hist->SetTitle(title) ;
1103 }
1104 
1105 
1106 
1107 ////////////////////////////////////////////////////////////////////////////////
1108 /// Define default print options, for a given print style
1109 
1111 {
1112  return kName|kArgs|kValue ;
1113 }
1114 
1115 
1116 
1117 TAxis* RooPlot::GetXaxis() const { return _hist->GetXaxis() ; }
1118 TAxis* RooPlot::GetYaxis() const { return _hist->GetYaxis() ; }
1119 Int_t RooPlot::GetNbinsX() const { return _hist->GetNbinsX() ; }
1120 Int_t RooPlot::GetNdivisions(Option_t* axis) const { return _hist->GetNdivisions(axis) ; }
1121 Double_t RooPlot::GetMinimum(Double_t minval) const { return _hist->GetMinimum(minval) ; }
1122 Double_t RooPlot::GetMaximum(Double_t maxval) const { return _hist->GetMaximum(maxval) ; }
1123 
1124 
1125 void RooPlot::SetAxisColor(Color_t color, Option_t* axis) { _hist->SetAxisColor(color,axis) ; }
1129 void RooPlot::SetContour(Int_t nlevels, const Double_t* levels) { _hist->SetContour(nlevels,levels) ; }
1130 void RooPlot::SetContourLevel(Int_t level, Double_t value) { _hist->SetContourLevel(level,value) ; }
1135 void RooPlot::SetLabelColor(Color_t color, Option_t* axis) { _hist->SetLabelColor(color,axis) ; }
1136 void RooPlot::SetLabelFont(Style_t font, Option_t* axis) { _hist->SetLabelFont(font,axis) ; }
1137 void RooPlot::SetLabelOffset(Float_t offset, Option_t* axis) { _hist->SetLabelOffset(offset,axis) ; }
1138 void RooPlot::SetLabelSize(Float_t size, Option_t* axis) { _hist->SetLabelSize(size,axis) ; }
1148 void RooPlot::SetOption(Option_t* option) { _hist->SetOption(option) ; }
1149 void RooPlot::SetStats(Bool_t stats) { _hist->SetStats(stats) ; }
1150 void RooPlot::SetTickLength(Float_t length, Option_t* axis) { _hist->SetTickLength(length,axis) ; }
1151 void RooPlot::SetTitleFont(Style_t font, Option_t* axis) { _hist->SetTitleFont(font,axis) ; }
1152 void RooPlot::SetTitleOffset(Float_t offset, Option_t* axis) { _hist->SetTitleOffset(offset,axis) ; }
1153 void RooPlot::SetTitleSize(Float_t size, Option_t* axis) { _hist->SetTitleSize(size,axis) ; }
1154 void RooPlot::SetXTitle(const char *title) { _hist->SetXTitle(title) ; }
1155 void RooPlot::SetYTitle(const char *title) { _hist->SetYTitle(title) ; }
1156 void RooPlot::SetZTitle(const char *title) { _hist->SetZTitle(title) ; }
1157 
1158 
1159 
1160 
1161 ////////////////////////////////////////////////////////////////////////////////
1162 /// Plot RooPlot when double-clicked in browser
1163 
1165 {
1166  Draw();
1167  gPad->Update();
1168 }
1169 
1170 
1171 
1172 
1173 ////////////////////////////////////////////////////////////////////////////////
1174 
1175 void RooPlot::Streamer(TBuffer &R__b)
1176 {
1177  // Custom streamer, needed for backward compatibility
1178 
1179  if (R__b.IsReading()) {
1180 
1182 
1183  // The default c'tor might have registered this with a TDirectory.
1184  // Streaming the TNamed will make this not retrievable anymore, so
1185  // unregister first.
1186  if (_dir)
1187  _dir->Remove(this);
1188 
1189  UInt_t R__s, R__c;
1190  Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1191  if (R__v > 1) {
1192  R__b.ReadClassBuffer(RooPlot::Class(),this,R__v,R__s,R__c);
1193  } else {
1194  // backward compatible streamer code here
1195  // Version 1 of RooPlot was deriving from TH1 and RooPrintable
1196  // Version 2 derives instead from TNamed and RooPrintable
1197  _hist = new TH1F();
1198  _hist->TH1::Streamer(R__b);
1199  SetName(_hist->GetName());
1200  SetTitle(_hist->GetTitle());
1201  RooPrintable::Streamer(R__b);
1202  _items.Streamer(R__b);
1203  R__b >> _padFactor;
1204  R__b >> _plotVarClone;
1205  R__b >> _plotVarSet;
1206  R__b >> _normVars;
1207  R__b >> _normNumEvts;
1208  R__b >> _normBinWidth;
1209  R__b >> _defYmin;
1210  R__b >> _defYmax;
1211  R__b.CheckByteCount(R__s, R__c, RooPlot::IsA());
1212  }
1213 
1215  if (_dir)
1216  _dir->Append(this);
1217 
1218  } else {
1219  R__b.WriteClassBuffer(RooPlot::Class(),this);
1220  }
1221 }
Double_t _padFactor
Definition: RooPlot.h:204
void SetNdivisions(Int_t n=510, Option_t *axis="X")
Definition: RooPlot.cxx:1147
void SetOption(Option_t *option=" ")
Definition: RooPlot.cxx:1148
virtual Double_t getMin(const char *name=0) const
void SetXTitle(const char *title)
Definition: RooPlot.cxx:1154
virtual void SetZTitle(const char *title)
Definition: TH1.h:391
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
Bool_t IsReading() const
Definition: TBuffer.h:81
TString getDrawOptions(const char *name) const
Return the Draw() options registered for the named object.
Definition: RooPlot.cxx:875
virtual void SetBarOffset(Float_t offset=0.25)
Definition: TH1.h:337
void SetBarWidth(Float_t width=0.5)
Definition: RooPlot.cxx:1128
TAttText * getAttText(const char *name=0) const
Return a pointer to the text attributes of the named object in this plot, or zero if the named object...
Definition: RooPlot.cxx:764
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:7666
#define coutE(a)
Definition: RooMsgService.h:34
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer, which is interpreted as an OR of &#39;enum ContentsOptions&#39; values and in the style given by &#39;enum StyleOption&#39;.
Bool_t getInvisible(const char *name) const
Returns true of object with given name is set to be invisible.
Definition: RooPlot.cxx:902
float xmin
Definition: THbookFile.cxx:93
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual void SetLineAttributes()
Invoke the DialogCanvas Line attributes.
Definition: TAttLine.cxx:280
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:409
virtual void SetFillAttributes()
Invoke the DialogCanvas Fill attributes.
Definition: TAttFill.cxx:249
void SetLineColor(Color_t lcolor)
Definition: RooPlot.cxx:1140
virtual Option_t * GetOption() const
Definition: TIterator.h:40
A RooCurve is a one-dimensional graphical representation of a real-valued function.
Definition: RooCurve.h:32
Bool_t hasMin(const char *name=0) const
virtual void SetTitleFont(Style_t font=62, Option_t *axis="X")
Set the axis&#39; title font.
Definition: Haxis.cxx:323
RooArgSet * _plotVarSet
Definition: RooPlot.h:206
virtual Double_t getMax(const char *name=0) const
TAxis * GetYaxis() const
Definition: RooPlot.cxx:1118
virtual void SetMaximum(Double_t maximum=-1111)
Definition: TH1.h:375
void SetLabelColor(Color_t color=1, Option_t *axis="X")
Definition: RooPlot.cxx:1135
short Style_t
Definition: RtypesCore.h:76
virtual void Reset()=0
void SetName(const char *name)
Set the name of the RooPlot to &#39;name&#39;.
Definition: RooPlot.cxx:1077
short Version_t
Definition: RtypesCore.h:61
TAxis * GetXaxis() const
Definition: RooPlot.cxx:1117
virtual ~RooPlot()
Destructor.
Definition: RooPlot.cxx:325
float Float_t
Definition: RtypesCore.h:53
float Size_t
Definition: RtypesCore.h:83
virtual Double_t getFitRangeBinW() const =0
const char Option_t
Definition: RtypesCore.h:62
void addObject(TObject *obj, Option_t *drawOptions="", Bool_t invisible=kFALSE)
Add a generic object to this plot.
Definition: RooPlot.cxx:392
#define coutI(a)
Definition: RooMsgService.h:31
float ymin
Definition: THbookFile.cxx:93
Double_t chiSquare(int nFitParam=0) const
Definition: RooPlot.h:166
virtual void SetContour(Int_t nlevels, const Double_t *levels=0)
Set the number and values of contour levels.
Definition: TH1.cxx:7607
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:159
void SetYTitle(const char *title)
Definition: RooPlot.cxx:1155
void SetLineAttributes()
Definition: RooPlot.cxx:1139
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:131
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
Definition: THist.hxx:311
void SetMarkerColor(Color_t tcolor=1)
Definition: RooPlot.cxx:1144
TIterator * _iterator
Definition: RooPlot.h:213
void addTH1(TH1 *hist, Option_t *drawOptions="", Bool_t invisible=kFALSE)
Add a TH1 histogram object to this plot.
Definition: RooPlot.cxx:411
virtual void SetNdivisions(Int_t n=510, Option_t *axis="X")
Set the number of divisions to draw an axis.
Definition: Haxis.cxx:170
void addPlotable(RooPlotable *plotable, Option_t *drawOptions="", Bool_t invisible=kFALSE, Bool_t refreshNorm=kFALSE)
Add the specified plotable object to our plot.
Definition: RooPlot.cxx:447
void SetZTitle(const char *title)
Definition: RooPlot.cxx:1156
Class RooPotable is a base class for objects that can be inserted into RooPlots and take advantage of...
Definition: RooPlotable.h:26
Buffer base class used for serializing objects.
Definition: TBuffer.h:40
Bool_t hasMax(const char *name=0) const
virtual void SetMinimum(Double_t minimum=-1111)
Definition: TH1.h:376
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
TString getTitle(Bool_t appendUnit=kFALSE) const
Return this variable&#39;s title string.
Definition: RooAbsReal.cxx:229
void SetStats(Bool_t stats=kTRUE)
Definition: RooPlot.cxx:1149
virtual void SetLabelSize(Float_t size=0.02, Option_t *axis="X")
Set size of axis&#39; labels.
Definition: Haxis.cxx:285
void updateNormVars(const RooArgSet &vars)
Install the given set of observables are reference normalization variables for this frame...
Definition: RooPlot.cxx:350
static Bool_t AddDirectoryStatus()
Static function: cannot be inlined on Windows/NT.
Definition: TH1.cxx:700
virtual void SetMarkerAttributes()
Invoke the DialogCanvas Marker attributes.
Definition: TAttMarker.cxx:264
int Int_t
Definition: RtypesCore.h:41
virtual void SetYTitle(const char *title)
Definition: TH1.h:390
bool Bool_t
Definition: RtypesCore.h:59
TAttFill * getAttFill(const char *name=0) const
Return a pointer to the fill attributes of the named object in this plot, or zero if the named object...
Definition: RooPlot.cxx:744
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:202
Int_t GetNdivisions(Option_t *axis="X") const
Definition: RooPlot.cxx:1120
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
void SetTitle(const char *name)
Set the title of the RooPlot to &#39;title&#39;.
Definition: RooPlot.cxx:1099
virtual Int_t GetNdivisions(Option_t *axis="X") const
Return the number of divisions for "axis".
Definition: Haxis.cxx:27
int nbins[3]
STL namespace.
#define coutW(a)
Definition: RooMsgService.h:33
virtual void SetAxisRange(Double_t xmin, Double_t xmax, Option_t *axis="X")
Set the "axis" range.
Definition: Haxis.cxx:201
Double_t _normBinWidth
Definition: RooPlot.h:211
void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition: RooPlot.cxx:1131
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Definition: TNamed.cxx:145
Iterator abstract base class.
Definition: TIterator.h:30
Bool_t moveAfter(const char *after, const char *target, const char *caller=0)
Move the target object immediately after the specified object, preserving any Option_t associated wit...
Definition: RooList.cxx:104
TObject * crossCast()
Return cast of RooPlotable as TObject.
Definition: RooPlotable.cxx:55
Double_t chiSquare(const RooHist &hist, int nFitParam) const
Calculate the chi^2/NDOF of this curve with respect to the histogram &#39;hist&#39; accounting nFitParam floa...
Definition: RooCurve.cxx:546
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
Definition: TH1.cxx:1218
virtual void SetBarWidth(Float_t width=0.5)
Definition: TH1.h:338
void SetTitleSize(Float_t size=0.02, Option_t *axis="X")
Definition: RooPlot.cxx:1153
Marker Attributes class.
Definition: TAttMarker.h:19
virtual Int_t GetDimension() const
Definition: TH1.h:263
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum value of Y axis.
Definition: RooPlot.cxx:959
void setInvisible(const char *name, Bool_t flag=kTRUE)
If flag is true object with &#39;name&#39; is set to be invisible i.e.
Definition: RooPlot.cxx:915
Double_t GetXmin() const
Definition: TAxis.h:133
A RooHist is a graphical representation of binned data based on the TGraphAsymmErrors class...
Definition: RooHist.h:26
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:135
Fill Area Attributes class.
Definition: TAttFill.h:19
static Bool_t _addDirStatus
non-persistent
Definition: RooPlot.h:220
RooPlotable is a &#39;mix-in&#39; base class that define the standard RooFit plotting and printing methods...
Definition: RooPrintable.h:25
void Class()
Definition: Class.C:29
TAttMarker * getAttMarker(const char *name=0) const
Return a pointer to the marker attributes of the named object in this plot, or zero if the named obje...
Definition: RooPlot.cxx:754
virtual Double_t getFitRangeNEvt() const =0
Bool_t invisible
Definition: RooPlot.h:190
virtual void SetOption(Option_t *option=" ")
Definition: TH1.h:383
TH1 * _hist
Definition: RooPlot.h:201
virtual void SetContourLevel(Int_t level, Double_t value)
Set value for one contour level.
Definition: TH1.cxx:7646
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition: TAttMarker.h:38
Bool_t setDrawOptions(const char *name, TString options)
Register the specified drawing options for the named object.
Definition: RooPlot.cxx:887
Double_t _defYmin
non-persistent
Definition: RooPlot.h:215
void SetLineWidth(Width_t lwidth)
Definition: RooPlot.cxx:1142
Double_t getYAxisMax() const
Definition: RooPlotable.h:42
Double_t _normNumEvts
Pointer to normalization object ;.
Definition: RooPlot.h:210
const char * rawOpt() const
Return the raw draw options.
Definition: RooPlot.cxx:1041
Double_t GetMinimum(Double_t minval=-FLT_MAX) const
Definition: RooPlot.cxx:1121
virtual TList * GetList() const
Definition: TDirectory.h:147
virtual TArrayD * GetSumw2()
Definition: TH1.h:293
virtual void SetLabelFont(Style_t font=62, Option_t *axis="X")
Set font number used to draw axis labels.
Definition: Haxis.cxx:249
short Color_t
Definition: RtypesCore.h:79
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
Definition: TList.cxx:608
virtual void SetAxisColor(Color_t color=1, Option_t *axis="X")
Set color to draw the axis line and tick marks.
Definition: Haxis.cxx:187
void initialize(const char *_rawOpt)
Initialize the DrawOpt helper class.
Definition: RooPlot.cxx:1022
virtual Stat_t GetBinContent(Int_t) const
A plot object is a frame without any bin contents of its own so this method always returns zero...
Definition: RooPlot.cxx:360
void SetLineStyle(Style_t lstyle)
Definition: RooPlot.cxx:1141
void SetLabelOffset(Float_t offset=0.005, Option_t *axis="X")
Definition: RooPlot.cxx:1137
virtual void printName(std::ostream &os) const
Print frame name.
Definition: RooPlot.cxx:592
void SetAxisRange(Double_t xmin, Double_t xmax, Option_t *axis="X")
Definition: RooPlot.cxx:1126
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
void initialize()
Perform initialization that is common to all constructors.
Definition: RooPlot.cxx:286
float ymax
Definition: THbookFile.cxx:93
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
void SetLabelSize(Float_t size=0.02, Option_t *axis="X")
Definition: RooPlot.cxx:1138
RooAbsCollection * snapshot(Bool_t deepCopy=kTRUE) const
Take a snap shot of current collection contents: An owning collection is returned containing clones o...
TString caller(const char *method) const
Utility function.
Definition: RooPlot.cxx:934
const char * GetTitle() const
Returns title of object.
Definition: TAxis.h:129
void SetContourLevel(Int_t level, Double_t value)
Definition: RooPlot.cxx:1130
Class to manage histogram axis.
Definition: TAxis.h:30
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2851
RooHist * makeResidHist(const RooCurve &curve, bool normalize=false, bool useAverage=false) const
Create and return RooHist containing residuals w.r.t to given curve.
Definition: RooHist.cxx:701
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum value of Y axis.
Definition: RooPlot.cxx:949
void updateFitRangeNorm(const TH1 *hist)
Update our plot normalization over our plot variable&#39;s fit range, which will be determined by the fir...
Definition: RooPlot.cxx:472
void SetMarkerAttributes()
Definition: RooPlot.cxx:1143
const char * nameOf(Int_t idx) const
Return the name of the object at slot &#39;idx&#39; in this RooPlot.
Definition: RooPlot.cxx:702
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:679
void SetNameTitle(const char *name, const char *title)
Set the name and title of the RooPlot to &#39;name&#39; and &#39;title&#39;.
Definition: RooPlot.cxx:1088
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:436
Text Attributes class.
Definition: TAttText.h:18
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
Definition: TH1.cxx:8325
void SetMarkerSize(Size_t msize=1)
Definition: RooPlot.cxx:1145
void SetContour(Int_t nlevels, const Double_t *levels=0)
Definition: RooPlot.cxx:1129
unsigned int UInt_t
Definition: RtypesCore.h:42
bool verbose
char * Form(const char *fmt,...)
virtual void Append(TObject *obj, Bool_t replace=kFALSE)
Append object to this directory.
Definition: TDirectory.cxx:153
RooArgSet * _normVars
Definition: RooPlot.h:207
RooAbsRealLValue * _plotVarClone
Definition: RooPlot.h:205
void SetLabelFont(Style_t font=62, Option_t *axis="X")
Definition: RooPlot.cxx:1136
void SetTitleFont(Style_t font=62, Option_t *axis="X")
Definition: RooPlot.cxx:1151
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:71
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition: TAttMarker.h:40
TAxis * GetYaxis()
Definition: TH1.h:301
void Browse(TBrowser *b)
Plot RooPlot when double-clicked in browser.
Definition: RooPlot.cxx:1164
Bool_t drawBefore(const char *before, const char *target)
Change the order in which our contained objects are drawn so that the target object is drawn just bef...
Definition: RooPlot.cxx:822
float xmax
Definition: THbookFile.cxx:93
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:315
virtual void printClassName(std::ostream &os) const
Print frame class name.
Definition: RooPlot.cxx:610
void SetTickLength(Float_t length=0.02, Option_t *axis="X")
Definition: RooPlot.cxx:1150
TString fName
Definition: TNamed.h:32
const char * getYAxisLabel() const
Definition: RooPlotable.h:31
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition: TAttMarker.h:41
short Width_t
Definition: RtypesCore.h:78
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:7751
Bool_t drawAfter(const char *after, const char *target)
Change the order in which our contained objects are drawn so that the target object is drawn just aft...
Definition: RooPlot.cxx:833
A RooPlot is a plot frame and a container for graphics objects within that frame. ...
Definition: RooPlot.h:41
const Bool_t kFALSE
Definition: RtypesCore.h:92
Double_t getYAxisMin() const
Definition: RooPlotable.h:41
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
Double_t getPadFactor() const
Definition: RooPlot.h:136
TDirectory * _dir
Definition: RooPlot.h:218
virtual TObject * Remove(TObject *)
Remove an object from the in-memory list.
#define ClassImp(name)
Definition: Rtypes.h:336
RooCurve * getCurve(const char *name=0) const
Return a RooCurve pointer of the named object in this plot, or zero if the named object does not exis...
Definition: RooPlot.cxx:775
RooAbsArg * find(const char *name) const
Find object with given name in list.
double Double_t
Definition: RtypesCore.h:55
void SetMarkerStyle(Style_t mstyle=1)
Definition: RooPlot.cxx:1146
virtual void printArgs(std::ostream &os) const
Interface for printing of object arguments.
Definition: RooPlot.cxx:619
virtual void SetTitleSize(Float_t size=0.02, Option_t *axis="X")
Set the axis&#39; title size.
Definition: Haxis.cxx:365
const RooPlotable * _normObj
Definition: RooPlot.h:209
unsigned long ULong_t
Definition: RtypesCore.h:51
static Bool_t setAddDirectoryStatus(Bool_t flag)
Definition: RooPlot.cxx:80
virtual void printMultiline(std::ostream &os, Int_t content, Bool_t verbose=kFALSE, TString indent="") const
Frame detailed printing.
Definition: RooPlot.cxx:662
void setPadFactor(Double_t factor)
Definition: RooPlot.h:137
The TH1 histogram class.
Definition: TH1.h:56
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
virtual Double_t GetEntries() const
Return the current number of entries.
Definition: TH1.cxx:4054
RooHist * residHist(const char *histname=0, const char *pdfname=0, bool normalize=false, bool useAverage=kFALSE) const
Return a RooHist containing the residuals of histogram &#39;histname&#39; with respect to curve &#39;curvename&#39;...
Definition: RooPlot.cxx:998
TObject * getObject(Int_t idx) const
Return the name of the object at slot &#39;idx&#39; in this RooPlot.
Definition: RooPlot.cxx:718
void SetBarOffset(Float_t offset=0.25)
Definition: RooPlot.cxx:1127
virtual Int_t defaultPrintContents(Option_t *opt) const
Define default print options, for a given print style.
Definition: RooPlot.cxx:1110
Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Definition: RooPlot.cxx:1122
RooPlot * emptyClone(const char *name)
Return empty clone of current RooPlot.
Definition: RooPlot.cxx:275
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
double Stat_t
Definition: RtypesCore.h:73
Int_t GetNbinsX() const
Definition: RooPlot.cxx:1119
TAttLine * getAttLine(const char *name=0) const
Return a pointer to the line attributes of the named object in this plot, or zero if the named object...
Definition: RooPlot.cxx:734
void SetTitleOffset(Float_t offset=1, Option_t *axis="X")
Definition: RooPlot.cxx:1152
virtual void SetTickLength(Float_t length=0.02, Option_t *axis="X")
Set the axis&#39; tick marks length.
Definition: Haxis.cxx:302
Mother of all ROOT objects.
Definition: TObject.h:37
TObjOptLink * findLink(const char *name, const char *caller=0) const
Find the link corresponding to the named object in this list.
Definition: RooList.cxx:46
virtual void SetXTitle(const char *title)
Definition: TH1.h:389
TString histName() const
Construct automatic name of internal TH1.
Definition: RooPlot.cxx:312
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
virtual void Add(TObject *obj)
Definition: TList.h:77
virtual void RecursiveRemove(TObject *obj)
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition: TList.cxx:639
RooList _items
Definition: RooPlot.h:203
virtual TObject * Next()=0
void SetAxisColor(Color_t color=1, Option_t *axis="X")
Definition: RooPlot.cxx:1125
RooHist * getHist(const char *name=0) const
Return a RooCurve pointer of the named object in this plot, or zero if the named object does not exis...
Definition: RooPlot.cxx:785
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
Definition: TH1.cxx:8132
virtual void printTitle(std::ostream &os) const
Print frame title.
Definition: RooPlot.cxx:601
THist< 1, double, THistStatContent, THistStatUncertainty > TH1D
Definition: THist.hxx:310
#define gPad
Definition: TVirtualPad.h:284
Double_t getFitRangeNEvt() const
Definition: RooPlot.h:133
Double_t _defYmax
Definition: RooPlot.h:216
#define gDirectory
Definition: TDirectory.h:211
virtual void SetTitle(const char *title)
Change (i.e.
Definition: TH1.cxx:6028
Definition: first.py:1
virtual Int_t GetNbinsX() const
Definition: TH1.h:277
Bool_t moveBefore(const char *before, const char *target, const char *caller=0)
Move the target object immediately before the specified object, preserving any Option_t associated wi...
Definition: RooList.cxx:69
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition: TObject.cxx:670
void SetFillColor(Color_t fcolor)
Definition: RooPlot.cxx:1133
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:364
virtual Int_t GetSize() const
Definition: TCollection.h:89
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:155
const Bool_t kTRUE
Definition: RtypesCore.h:91
void SetFillStyle(Style_t fstyle)
Definition: RooPlot.cxx:1134
void Set(Int_t n)
Set size of this array to n doubles.
Definition: TArrayD.cxx:105
Double_t GetXmax() const
Definition: TAxis.h:134
const Int_t n
Definition: legend1.C:16
void updateYAxis(Double_t ymin, Double_t ymax, const char *label="")
Update our y-axis limits to accomodate an object whose spread in y is (ymin,ymax).
Definition: RooPlot.cxx:527
Line Attributes class.
Definition: TAttLine.h:18
void SetFillAttributes()
Definition: RooPlot.cxx:1132
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition: TH1.cxx:8103
static Bool_t addDirectoryStatus()
Definition: RooPlot.cxx:79
RooPlot()
Default constructor coverity[UNINIT_CTOR].
Definition: RooPlot.cxx:87
void remove(const char *name=0, Bool_t deleteToo=kTRUE)
Remove object with given name, or last object added if no name is given.
Definition: RooPlot.cxx:797
TAxis * GetXaxis()
Definition: TH1.h:300
TObject * findObject(const char *name, const TClass *clas=0) const
Find the named object in our list of items and return a pointer to it.
Definition: RooPlot.cxx:850
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
Definition: RooPlot.cxx:559
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual void SetLabelColor(Color_t color=1, Option_t *axis="X")
Set axis labels color.
Definition: Haxis.cxx:226
virtual void SetLabelOffset(Float_t offset=0.005, Option_t *axis="X")
Set offset between axis and axis&#39; labels.
Definition: Haxis.cxx:267
virtual void printValue(std::ostream &os) const
Print frame arguments.
Definition: RooPlot.cxx:633
virtual void SetTitleOffset(Float_t offset=1, Option_t *axis="X")
Specify a parameter offset to control the distance between the axis and the axis&#39; title...
Definition: Haxis.cxx:345