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