Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
22Plot frame and a container for graphics objects
23within that frame. As a frame, it provides the TH1-style public interface
24for setting plot ranges, configuring axes, etc. As a container, it
25holds an arbitrary set of objects that might be histograms of data,
26curves representing a fit model, or text labels. Use the Draw()
27method to draw a frame and the objects it contains. Use the various
28add...() methods to add objects to be drawn. In general, the
29add...() methods create a private copy of the object you pass them
30and return a pointer to this copy. The caller owns the input object
31and this class owns the returned object.
32All RooAbsReal and RooAbsData derived classes implement plotOn()
33functions that facilitate to plot themselves on a given RooPlot, e.g.
34~~~ {.cpp}
35RooPlot *frame = x.frame() ;
36data.plotOn(frame) ;
37pdf.plotOn(frame) ;
38~~~
39These high level functions also take care of any projections
40or other mappings that need to be made to plot a multi-dimensional
41object onto a one-dimensional plot.
42**/
43
44#include "RooPlot.h"
45
46#include "RooAbsReal.h"
47#include "RooAbsRealLValue.h"
48#include "RooPlotable.h"
49#include "RooArgSet.h"
50#include "RooCurve.h"
51#include "RooHist.h"
52#include "RooMsgService.h"
53
54#include "TClass.h"
55#include "TBuffer.h"
56#include "TH1D.h"
57#include "TBrowser.h"
58#include "TVirtualPad.h"
59
60#include "TAttLine.h"
61#include "TAttFill.h"
62#include "TAttMarker.h"
63#include "TAttText.h"
64#include "TDirectoryFile.h"
65#include "TLegend.h"
66#include "strlcpy.h"
67
68#include <algorithm>
69#include <cstring>
70#include <iostream>
71
73
74
75bool RooPlot::_addDirStatus = true ;
76
78bool RooPlot::setAddDirectoryStatus(bool flag) { bool ret = flag ; _addDirStatus = flag ; return ret ; }
79
80
81////////////////////////////////////////////////////////////////////////////////
82/// Default constructor
83/// coverity[UNINIT_CTOR]
84
86{
89 }
90}
91
92
93////////////////////////////////////////////////////////////////////////////////
94/// Constructor of RooPlot with range [xmin,xmax]
95
96RooPlot::RooPlot(double xmin, double xmax, int nBins)
97 : _normBinWidth((xmax - xmin) / nBins)
98{
99 _hist = new TH1D(histName(),"A RooPlot",nBins,xmin,xmax) ;
100 _hist->Sumw2(false) ;
101 _hist->GetSumw2()->Set(0) ;
102 _hist->SetDirectory(nullptr);
103
104 // Create an empty frame with the specified x-axis limits.
105 initialize();
106
107}
108
109
110////////////////////////////////////////////////////////////////////////////////
111/// Construct of a two-dimensional RooPlot with ranges [xmin,xmax] x [ymin,ymax]
112
113RooPlot::RooPlot(double xmin, double xmax, double ymin, double ymax) :
114 _defYmax(0)
115{
116 _hist = new TH1D(histName(),"A RooPlot",100,xmin,xmax) ;
117 _hist->Sumw2(false) ;
118 _hist->GetSumw2()->Set(0) ;
119 _hist->SetDirectory(nullptr);
120
123 initialize();
124}
125
126namespace {
127
128const RooAbsRealLValue& validateFiniteLimits(const RooAbsRealLValue &var)
129{
130 if (!var.hasMin() || !var.hasMax()) {
131 std::stringstream ss;
132 ss << "RooPlot::RooPlot: cannot create plot for variable without finite limits: " << var.GetName();
133 oocoutE(nullptr, InputArguments) << ss.str() << std::endl;
134 throw std::runtime_error(ss.str());
135 }
136 return var;
137}
138
139} // namespace
140
141////////////////////////////////////////////////////////////////////////////////
142/// Construct a two-dimensional RooPlot with ranges and properties taken
143/// from variables var1 and var2
144
146 : RooPlot{validateFiniteLimits(var1),
147 validateFiniteLimits(var2),
148 var1.getMin(),
149 var1.getMax(),
150 var2.getMin(),
151 var2.getMax()}
152{
153}
154
155
156////////////////////////////////////////////////////////////////////////////////
157/// Construct a two-dimensional RooPlot with ranges and properties taken
158/// from variables var1 and var2 but with an overriding range definition
159/// of [xmin,xmax] x [ymin,ymax]
160
161RooPlot::RooPlot(const RooAbsRealLValue &var1, const RooAbsRealLValue &var2, double xmin, double xmax, double ymin,
162 double ymax)
163 : RooPlot{xmin, xmax}
164{
167 SetXTitle(var1.getTitle(true));
168 SetYTitle(var2.getTitle(true));
169}
170
171
172////////////////////////////////////////////////////////////////////////////////
173/// Create an 1-dimensional with all properties taken from 'var', but
174/// with an explicit range [xmin,xmax] and a default binning of 'nbins'
175
176RooPlot::RooPlot(const char *name, const char *title, const RooAbsRealLValue &var, double xmin, double xmax,
177 Int_t nbins)
178 : _hist(new TH1D(name, title, nbins, xmin, xmax)),
179 _plotVar(const_cast<RooAbsRealLValue *>(&var)),
180 _normBinWidth((xmax - xmin) / nbins)
181{
182 _hist->Sumw2(false) ;
183 _hist->GetSumw2()->Set(0) ;
184 _hist->SetDirectory(nullptr);
185
186 // In the past, the plot variable was cloned, but there was no apparent reason for doing so.
187
188 TString xtitle= var.getTitle(true);
189 SetXTitle(xtitle.Data());
190
191 initialize();
192}
193
194
195////////////////////////////////////////////////////////////////////////////////
196/// Create an 1-dimensional with all properties taken from 'var', but
197/// with an explicit range [xmin,xmax] and a default binning of 'nbins'
198
199RooPlot::RooPlot(const RooAbsRealLValue &var, double xmin, double xmax, Int_t nbins)
200 : _plotVar(const_cast<RooAbsRealLValue *>(&var)), _normBinWidth((xmax - xmin) / nbins)
201{
202 _hist = new TH1D(histName(),"RooPlot",nbins,xmin,xmax) ;
203 _hist->Sumw2(false) ;
204 _hist->GetSumw2()->Set(0) ;
205 _hist->SetDirectory(nullptr);
206
207 // In the past, the plot variable was cloned, but there was no apparent reason for doing so.
208
209 TString xtitle= var.getTitle(true);
210 SetXTitle(xtitle.Data());
211
212 SetTitle("A RooPlot of \"" + var.getTitle() + "\"");
213 initialize();
214}
215
216////////////////////////////////////////////////////////////////////////////////
217/// Create a new frame for a given variable in x. This is just a
218/// wrapper for the RooPlot constructor with the same interface.
219///
220/// More details.
221/// \param[in] var The variable on the x-axis
222/// \param[in] xmin Left edge of the x-axis
223/// \param[in] xmax Right edge of the x-axis
224/// \param[in] nBins number of bins on the x-axis
225RooPlot* RooPlot::frame(const RooAbsRealLValue &var, double xmin, double xmax, Int_t nBins){
226 return new RooPlot(var,xmin,xmax,nBins);
227}
228
229////////////////////////////////////////////////////////////////////////////////
230/// Create a new frame for a given variable in x, adding bin labels.
231/// The binning will be extracted from the variable given. The bin
232/// labels will be set as "%g-%g" for the left and right edges of each
233/// bin of the given variable.
234///
235/// More details.
236/// \param[in] var The variable on the x-axis
238 RooPlot* pl = new RooPlot();
239 int nbins = var.getBinning().numBins();
240
241 pl->_hist = new TH1D(pl->histName(),"RooPlot",nbins,var.getMin(),var.getMax()) ;
242 pl->_hist->Sumw2(false) ;
243 pl->_hist->GetSumw2()->Set(0) ;
244 pl->_hist->SetDirectory(nullptr);
245
246 pl->_hist->SetNdivisions(-nbins);
247 for(int i=0; i<nbins; ++i){
248 TString s = TString::Format("%g-%g",var.getBinning().binLow(i),var.getBinning().binHigh(i));
249 pl->_hist->GetXaxis()->SetBinLabel(i+1,s);
250 }
251
252 // In the past, the plot variable was cloned, but there was no apparent reason for doing so.
253 pl->_plotVar = const_cast<RooAbsRealLValue*>(&var);
254
255 TString xtitle= var.getTitle(true);
256 pl->SetXTitle(xtitle.Data());
257
258 TString title("A RooPlot of \"");
259 title.Append(var.getTitle());
260 title.Append("\"");
261 pl->SetTitle(title.Data());
262 pl->initialize();
263
264 pl->_normBinWidth = 1.;
265 return pl;
266}
267
268////////////////////////////////////////////////////////////////////////////////
269/// Return empty clone of current RooPlot
270
272{
274 clone->SetName(name) ;
275 return clone ;
276}
277
278
279////////////////////////////////////////////////////////////////////////////////
280/// Perform initialization that is common to all constructors.
281
283{
284 SetName(histName()) ;
285
288 }
289
290 // We do not have useful stats of our own
291 _hist->SetStats(false);
292 _hist->SetDirectory(nullptr);
293 // Default vertical padding of our enclosed objects
294 setPadFactor(0.05);
295}
296
297
298////////////////////////////////////////////////////////////////////////////////
299/// Construct automatic name of internal TH1
300
302{
303 if (_plotVar) {
304 return TString(Form("frame_%s_%zx",_plotVar->GetName(),reinterpret_cast<size_t>(this))) ;
305 } else {
306 return TString(Form("frame_%zx",reinterpret_cast<size_t>(this))) ;
307 }
308}
309
310
311////////////////////////////////////////////////////////////////////////////////
312/// Destructor
313
315{
316 // Delete the items in our container and our iterator.
317 if (_dir) {
318 _dir->GetList()->RecursiveRemove(this) ;
319 }
320
321 for(auto& item : _items) delete item.first;
322 if(_plotVarSet) delete _plotVarSet;
323 if(_normVars) delete _normVars;
324 delete _hist ;
325
326}
327
328
329////////////////////////////////////////////////////////////////////////////////
330/// Set the directory that this plot is associated to.
331/// Setting it to `nullptr` will remove the object from all directories.
332/// Like TH1::SetDirectory.
334 if (_dir) {
335 _dir->GetList()->RecursiveRemove(this);
336 }
337 _dir = dir;
338 if (_dir) {
339 _dir->Append(this);
340 }
341}
342
343
344////////////////////////////////////////////////////////////////////////////////
345/// Install the given set of observables are reference normalization
346/// variables for this frame. These observables are e.g. later used
347/// to automatically project out observables when plotting functions
348/// on this frame. This function is only effective when called the
349/// first time on a frame
350
352{
353 if(_normVars == nullptr) {
354 _normVars = new RooArgSet;
355 vars.snapshot(*_normVars, true);
356 }
357}
358
359
360////////////////////////////////////////////////////////////////////////////////
361/// Add a generic object to this plot. The specified options will be
362/// used to Draw() this object later. The caller transfers ownership
363/// of the object with this call, and the object will be deleted
364/// when its containing plot object is destroyed.
365
366void RooPlot::addObject(TObject *obj, Option_t *drawOptions, bool invisible)
367{
368 if(nullptr == obj) {
369 coutE(InputArguments) << fName << "::addObject: called with a null pointer" << std::endl;
370 return;
371 }
372 DrawOpt opt(drawOptions) ;
373 opt.invisible = invisible ;
374 _items.emplace_back(obj,opt.rawOpt());
375}
376
377
378////////////////////////////////////////////////////////////////////////////////
379/// Add a TH1 histogram object to this plot. The specified options
380/// will be used to Draw() this object later. "SAME" will be added to
381/// the options if they are not already present. The caller transfers
382/// ownership of the object with this call, and the object will be
383/// deleted when its containing plot object is destroyed.
384
385void RooPlot::addTH1(TH1 *hist, Option_t *drawOptions, bool invisible)
386{
387 if(nullptr == hist) {
388 coutE(InputArguments) << fName << "::addTH1: called with a null pointer" << std::endl;
389 return;
390 }
391 // check that this histogram is really 1D
392 if(1 != hist->GetDimension()) {
393 coutE(InputArguments) << fName << "::addTH1: cannot plot histogram with "
394 << hist->GetDimension() << " dimensions" << std::endl;
395 return;
396 }
397
398 // add option "SAME" if necessary
399 TString options(drawOptions);
400 options.ToUpper();
401 if(!options.Contains("SAME")) options.Append("SAME");
402
403 // update our y-axis label and limits
404 updateYAxis(hist->GetMinimum(),hist->GetMaximum(),hist->GetYaxis()->GetTitle());
405
406 // use this histogram's normalization if necessary
407 updateFitRangeNorm(hist);
408
409 // add the histogram to our list
410 addObject(hist,options.Data(),invisible);
411}
412
413
414namespace {
415 // this helper function is intended to translate a graph from a regular axis to a labelled axis
416 // this version uses TGraph, which is a parent of RooCurve
417 void translateGraph(TH1* hist, RooAbsRealLValue* xvar, TGraph* graph){
418 // if the graph already has a labelled axis, don't do anything
419 if(graph->GetXaxis()->IsAlphanumeric()) return;
420 double xmin = hist->GetXaxis()->GetXmin();
421 double xmax = hist->GetXaxis()->GetXmax();
422 if(graph->TestBit(TGraph::kIsSortedX)){
423 // sorted graphs are "line graphs"
424 // evaluate the graph at the lower and upper edge as well as the center of each bin
425 std::vector<double> x;
426 std::vector<double> y;
427 x.push_back(xmin);
428 y.push_back(graph->Eval(xvar->getBinning().binLow(0)));
429 for(int i=0; i<hist->GetNbinsX(); ++i){
430 x.push_back(hist->GetXaxis()->GetBinUpEdge(i+1));
431 y.push_back(graph->Eval(xvar->getBinning().binHigh(i)));
432 x.push_back(hist->GetXaxis()->GetBinCenter(i+1));
433 y.push_back(graph->Eval(xvar->getBinning().binCenter(i)));
434 }
435 int n = x.size();
436 graph->Set(n);
437 for(int i=0; i<n; ++i){
438 graph->SetPoint(i,x[i],y[i]);
439 }
440 graph->Sort();
441 } else {
442 // unsorted graphs are "area graphs"
443 std::map<int,double> minValues;
444 std::map<int,double> maxValues;
445 int n = graph->GetN();
446 double x;
447 double y;
448 // for each bin, find the min and max points to form an envelope
449 for(int i=0; i<n; ++i){
450 graph->GetPoint(i,x,y);
451 int bin = xvar->getBinning().binNumber(x)+1;
452 if(maxValues.find(bin)!=maxValues.end()){
453 maxValues[bin] = std::max(maxValues[bin],y);
454 } else {
455 maxValues[bin] = y;
456 }
457 if(minValues.find(bin)!=minValues.end()){
458 minValues[bin] = std::min(minValues[bin],y);
459 } else {
460 minValues[bin] = y;
461 }
462 }
463 double xminY = graph->Eval(xmin);
464 double xmaxY = graph->Eval(xmax);
465 graph->Set(hist->GetNbinsX()+2);
466 int np=0;
467 graph->SetPoint(np,xmin,xminY);
468 // assign the calculated envelope boundaries to the bin centers of the bins
469 for(auto it = maxValues.begin(); it != maxValues.end(); ++it){
470 graph->SetPoint(++np,hist->GetXaxis()->GetBinCenter(it->first),it->second);
471 }
472 graph->SetPoint(++np,xmax,xmaxY);
473 for(auto it = minValues.rbegin(); it != minValues.rend(); ++it){
474 graph->SetPoint(++np,hist->GetXaxis()->GetBinCenter(it->first),it->second);
475 }
476 graph->SetPoint(++np,xmin,xminY);
477 }
478 // make sure that the graph also has the labels set, such that subsequent calls to translate this graph will not do anything
479 graph->GetXaxis()->Set(hist->GetNbinsX(),xmin,xmax);
480 for(int i=0; i<hist->GetNbinsX(); ++i){
481 graph->GetXaxis()->SetBinLabel(i+1,hist->GetXaxis()->GetBinLabel(i+1));
482 }
483 }
484 // this version uses TGraphErrors, which is a parent of RooHist
485 void translateGraph(TH1* hist, RooAbsRealLValue* xvar, TGraphAsymmErrors* graph){
486 // if the graph already has a labelled axis, don't do anything
487 if(graph->GetXaxis()->IsAlphanumeric()) return;
488 int n = graph->GetN();
489 double xmin = hist->GetXaxis()->GetXmin();
490 double xmax = hist->GetXaxis()->GetXmax();
491 double x;
492 double y;
493 // as this graph is histogram-like, we expect there to be one point per bin
494 // we just move these points to the respective bin centers
495 for(int i=0; i<n; ++i){
496 if(graph->GetPoint(i,x,y)!=i) break;
497 int bin = xvar->getBinning().binNumber(x);
498 graph->SetPoint(i,hist->GetXaxis()->GetBinCenter(bin+1),y);
499 graph->SetPointEXhigh(i,0.5*hist->GetXaxis()->GetBinWidth(bin+1));
500 graph->SetPointEXlow(i,0.5*hist->GetXaxis()->GetBinWidth(bin+1));
501 }
502 graph->GetXaxis()->Set(hist->GetNbinsX(),xmin,xmax);
503 // make sure that the graph also has the labels set, such that subsequent calls to translate this graph will not do anything
504 for(int i=0; i<hist->GetNbinsX(); ++i){
505 graph->GetXaxis()->SetBinLabel(i+1,hist->GetXaxis()->GetBinLabel(i+1));
506 }
507 }
508}
509
510////////////////////////////////////////////////////////////////////////////////
511/// Add the specified plotable object to our plot. Increase our y-axis
512/// limits to fit this object if necessary. The default lower-limit
513/// is zero unless we are plotting an object that takes on negative values.
514/// This call transfers ownership of the plotable object to this class.
515/// The plotable object will be deleted when this plot object is deleted.
516void RooPlot::addPlotable(RooPlotable *plotable, Option_t *drawOptions, bool invisible, bool refreshNorm)
517{
518 // update our y-axis label and limits
519 updateYAxis(plotable->getYAxisMin(),plotable->getYAxisMax(),plotable->getYAxisLabel());
520
521 // use this object's normalization if necessary
522 updateFitRangeNorm(plotable,refreshNorm) ;
523
524 // add this element to our list and remember its drawing option
525 TObject *obj= plotable->crossCast();
526 if(nullptr == obj) {
527 coutE(InputArguments) << fName << "::add: cross-cast to TObject failed (nothing added)" << std::endl;
528 }
529 else {
530 // if the frame axis is alphanumeric, the coordinates of the graph need to be translated to this binning
531 if(_hist->GetXaxis()->IsAlphanumeric()){
532 if(obj->InheritsFrom(RooCurve::Class())){
533 ::translateGraph(_hist,_plotVar,static_cast<RooCurve*>(obj));
534 } else if(obj->InheritsFrom(RooHist::Class())){
535 ::translateGraph(_hist,_plotVar,static_cast<RooHist*>(obj));
536 }
537 }
538
539 DrawOpt opt(drawOptions) ;
540 opt.invisible = invisible ;
541 _items.emplace_back(obj,opt.rawOpt());
542 }
543}
544
545
546////////////////////////////////////////////////////////////////////////////////
547/// Update our plot normalization over our plot variable's fit range,
548/// which will be determined by the first suitable object added to our plot.
549
551{
552 const TAxis* xa = const_cast<TH1 *>(hist)->GetXaxis() ;
553 _normBinWidth = (xa->GetXmax()-xa->GetXmin())/hist->GetNbinsX() ;
555}
556
557
558////////////////////////////////////////////////////////////////////////////////
559/// Update our plot normalization over our plot variable's fit range,
560/// which will be determined by the first suitable object added to our plot.
561
562void RooPlot::updateFitRangeNorm(const RooPlotable* rp, bool refreshNorm)
563{
564 if (_normNumEvts != 0) {
565
566 // If refresh feature is disabled stop here
567 if (!refreshNorm) return ;
568
569 double corFac(1.0) ;
570 if (dynamic_cast<const RooHist*>(rp)) corFac = _normBinWidth/rp->getFitRangeBinW() ;
571
572
573 if (std::abs(rp->getFitRangeNEvt()/corFac-_normNumEvts)>1e-6) {
574 coutI(Plotting) << "RooPlot::updateFitRangeNorm: New event count of " << rp->getFitRangeNEvt()/corFac
575 << " will supersede previous event count of " << _normNumEvts << " for normalization of PDF projections" << std::endl ;
576 }
577
578 // Nominal bin width (i.e event density) is already locked in by previously drawn histogram
579 // scale this histogram to match that density
580 _normNumEvts = rp->getFitRangeNEvt()/corFac ;
581 _normObj = rp ;
582 // cout << "correction factor = " << _normBinWidth << "/" << rp->getFitRangeBinW() << std::endl ;
583 // cout << "updating numevts to " << _normNumEvts << std::endl ;
584
585 } else {
586
587 _normObj = rp ;
589 if (rp->getFitRangeBinW()) {
591 }
592
593 // cout << "updating numevts to " << _normNumEvts << std::endl ;
594 }
595
596}
597
598
599
600////////////////////////////////////////////////////////////////////////////////
601/// Update our y-axis limits to accommodate an object whose spread
602/// in y is (ymin,ymax). Use the specified y-axis label if we don't
603/// have one assigned already.
604
605void RooPlot::updateYAxis(double ymin, double ymax, const char *label)
606{
607 // force an implicit lower limit of zero if appropriate
608 if(GetMinimum() == 0 && ymin > 0) ymin= 0;
609
610 // calculate padded values
611 double ypad= getPadFactor()*(ymax-ymin);
612 ymax+= ypad;
613 if(ymin < 0) ymin-= ypad;
614
615 // update our limits if necessary
616 if(GetMaximum() < ymax) {
617 _defYmax = ymax ;
619 // if we don't do this - Unzoom on y-axis will reset upper bound to 1
621 }
622 if(GetMinimum() > ymin) {
623 _defYmin = ymin ;
625 }
626
627 // use the specified y-axis label if we don't have one already
628 if(0 == strlen(_hist->GetYaxis()->GetTitle())) _hist->SetYTitle(label);
629}
630
631
632////////////////////////////////////////////////////////////////////////////////
633/// Draw this plot and all of the elements it contains. The specified options
634/// only apply to the drawing of our frame. The options specified in our add...()
635/// methods will be used to draw each object we contain.
636
638{
639 TString optArg = option ;
640 optArg.ToLower() ;
641
642 // This draw options prevents the histogram with one dummy entry
643 // to be drawn
644 if (optArg.Contains("same")) {
645 _hist->Draw("FUNCSAME");
646 } else {
647 _hist->Draw("FUNC");
648 }
649
650 for(auto const& item : _items) {
651 TObject &obj = *item.first;
652 DrawOpt opt(item.second.c_str()) ;
653 if (!opt.invisible) {
654 //LM: in case of a TGraph derived object, do not use default "" option
655 // which is "ALP" from 5.34.10 (and will then redrawn the axis) but use "LP"
656 if (!strlen(opt.drawOptions) && obj.IsA()->InheritsFrom(TGraph::Class()) ) strlcpy(opt.drawOptions,"LP",3);
657 obj.Draw(opt.drawOptions);
658 }
659 }
660
661 _hist->Draw("AXISSAME");
662}
663
664
665
666////////////////////////////////////////////////////////////////////////////////
667/// Print frame name
668
669void RooPlot::printName(std::ostream& os) const
670{
671 os << GetName() ;
672}
673
674
675////////////////////////////////////////////////////////////////////////////////
676/// Print frame title
677
678void RooPlot::printTitle(std::ostream& os) const
679{
680 os << GetTitle() ;
681}
682
683
684////////////////////////////////////////////////////////////////////////////////
685/// Print frame class name
686
687void RooPlot::printClassName(std::ostream& os) const
688{
689 os << ClassName() ;
690}
691
692
693
694////////////////////////////////////////////////////////////////////////////////
695
696void RooPlot::printArgs(std::ostream& os) const
697{
698 if (_plotVar) {
699 os << "[" ;
701 os << "]" ;
702 }
703}
704
705
706
707////////////////////////////////////////////////////////////////////////////////
708/// Print frame arguments
709
710void RooPlot::printValue(std::ostream& os) const
711{
712 os << "(" ;
713 bool first(true) ;
714 for(auto const& item : _items) {
715 TObject &obj = *item.first;
716 if (first) {
717 first=false ;
718 } else {
719 os << "," ;
720 }
721 if(obj.IsA()->InheritsFrom(RooPrintable::Class())) {
722 auto po = dynamic_cast<RooPrintable&>(obj) ;
723 // coverity[FORWARD_NULL]
725 }
726 // is it a TNamed subclass?
727 else {
728 os << obj.ClassName() << "::" << obj.GetName() ;
729 }
730 }
731 os << ")" ;
732}
733
734
735////////////////////////////////////////////////////////////////////////////////
736/// Frame detailed printing
737
738void RooPlot::printMultiline(std::ostream& os, Int_t /*content*/, bool verbose, TString indent) const
739{
740 TString deeper(indent);
741 deeper.Append(" ");
742 if(nullptr != _plotVar) {
743 os << indent << "RooPlot " << GetName() << " (" << GetTitle() << ") plots variable ";
745 }
746 else {
747 os << indent << "RooPlot " << GetName() << " (" << GetTitle() << ") has no associated plot variable" << std::endl ;
748 }
749 os << indent << " Plot frame contains " << _items.size() << " object(s):" << std::endl;
750
751 if(verbose) {
752 Int_t i=0 ;
753 for(auto const& item : _items) {
754 TObject &obj = *item.first;
755 os << deeper << "[" << i++ << "] (Options=\"" << item.second << "\") ";
756 // Is this a printable object?
757 if(obj.IsA()->InheritsFrom(RooPrintable::Class())) {
758 auto po = dynamic_cast<RooPrintable&>(obj) ;
760 }
761 // is it a TNamed subclass?
762 else {
763 os << obj.ClassName() << "::" << obj.GetName() << std::endl;
764 }
765 }
766 }
767}
768
769
770
771////////////////////////////////////////////////////////////////////////////////
772/// Return the name of the object at slot 'idx' in this RooPlot.
773/// If the given index is out of range, return a null pointer
774
775const char* RooPlot::nameOf(Int_t idx) const
776{
777 TObject* obj = _items.at(idx).first;
778 if (!obj) {
779 coutE(InputArguments) << "RooPlot::nameOf(" << GetName() << ") index " << idx << " out of range" << std::endl ;
780 return nullptr ;
781 }
782 return obj->GetName() ;
783}
784
785
786
787////////////////////////////////////////////////////////////////////////////////
788/// Return the name of the object at slot 'idx' in this RooPlot.
789/// If the given index is out of range, return a null pointer
790
792{
793 TObject* obj = _items.at(idx).first;
794 if (!obj) {
795 coutE(InputArguments) << "RooPlot::getObject(" << GetName() << ") index " << idx << " out of range" << std::endl ;
796 return nullptr ;
797 }
798 return obj ;
799}
800
801
802
803////////////////////////////////////////////////////////////////////////////////
804/// Return a pointer to the line attributes of the named object in this plot,
805/// or zero if the named object does not exist or does not have line attributes.
806
808{
809 return dynamic_cast<TAttLine*>(findObject(name));
810}
811
812
813////////////////////////////////////////////////////////////////////////////////
814/// Return a pointer to the fill attributes of the named object in this plot,
815/// or zero if the named object does not exist or does not have fill attributes.
816
818{
819 return dynamic_cast<TAttFill*>(findObject(name));
820}
821
822
823////////////////////////////////////////////////////////////////////////////////
824/// Return a pointer to the marker attributes of the named object in this plot,
825/// or zero if the named object does not exist or does not have marker attributes.
826
828{
829 return dynamic_cast<TAttMarker*>(findObject(name));
830}
831
832
833////////////////////////////////////////////////////////////////////////////////
834/// Return a pointer to the text attributes of the named object in this plot,
835/// or zero if the named object does not exist or does not have text attributes.
836
838{
839 return dynamic_cast<TAttText*>(findObject(name));
840}
841
842
843
844////////////////////////////////////////////////////////////////////////////////
845/// Return a RooCurve pointer of the named object in this plot,
846/// or zero if the named object does not exist or is not a RooCurve
847
848RooCurve* RooPlot::getCurve(const char* name) const
849{
850 return dynamic_cast<RooCurve*>(findObject(name)) ;
851}
852
853
854////////////////////////////////////////////////////////////////////////////////
855/// Return a RooCurve pointer of the named object in this plot,
856/// or zero if the named object does not exist or is not a RooCurve
857
858RooHist* RooPlot::getHist(const char* name) const
859{
860 return dynamic_cast<RooHist*>(findObject(name)) ;
861}
862
863
864
865////////////////////////////////////////////////////////////////////////////////
866/// Remove object with given name, or last object added if no name is given.
867
868void RooPlot::remove(const char* name, bool deleteToo)
869{
870 if(name == nullptr) {
871 if(!_items.empty()) {
872 if(deleteToo) delete _items.back().first;
873 _items.pop_back();
874 } else {
875 coutE(InputArguments) << "RooPlot::remove(" << GetName() << ") ERROR: plot frame is empty, cannot remove last object" << std::endl ;
876 }
877 } else {
878 auto item = findItem(name);
879 if(item == _items.end()) {
880 coutE(InputArguments) << "RooPlot::remove(" << GetName() << ") ERROR: no object found with name " << name << std::endl ;
881 } else {
882 if(deleteToo) delete item->first;
883 _items.erase(item);
884 }
885 }
886}
887
888
889namespace {
890
891template<class Iter>
892void moveBefore(Iter before, Iter target) {
893 auto d = std::distance(before, target);
894 if(d > 0) std::rotate(before, target, target + 1);
895 else if(d < 0) std::rotate(target, target+1, before);
896}
897
898} // namespace
899
900
901////////////////////////////////////////////////////////////////////////////////
902/// Change the order in which our contained objects are drawn so that
903/// the target object is drawn just before the specified object.
904/// Returns false if either object does not exist.
905
906bool RooPlot::drawBefore(const char *before, const char *target)
907{
908 auto iterBefore = findItem(before);
909 auto iterTarget = findItem(target);
910 if(iterBefore == _items.end() || iterTarget == _items.end()) return false;
911 moveBefore(iterBefore, iterTarget);
912 return true;
913}
914
915
916////////////////////////////////////////////////////////////////////////////////
917/// Change the order in which our contained objects are drawn so that
918/// the target object is drawn just after the specified object.
919/// Returns false if either object does not exist.
920
921bool RooPlot::drawAfter(const char *after, const char *target)
922{
923 auto iterAfter = findItem(after);
924 auto iterTarget = findItem(target);
925 if(iterAfter == _items.end() || iterTarget == _items.end()) return false;
926 moveBefore(iterAfter + 1, iterTarget);
927 return true;
928}
929
930
931////////////////////////////////////////////////////////////////////////////////
932/// Find the named object in our list of items and return a pointer
933/// to it. Return zero and print a warning message if the named
934/// object cannot be found. If no name is supplied the last object
935/// added is returned.
936///
937/// Note that the returned pointer is to a
938/// TObject and so will generally need casting. Use the getAtt...()
939/// methods to change the drawing style attributes of a contained
940/// object directly.
941
942TObject *RooPlot::findObject(const char *name, const TClass* tClass) const
943{
944 TObject *ret = nullptr;
945
946 for(auto const& item : _items) {
947 TObject &obj = *item.first;
948 if ((!name || name[0] == '\0' || !TString(name).CompareTo(obj.GetName()))
949 && (!tClass || (obj.IsA()==tClass))) {
950 ret = &obj ;
951 }
952 }
953
954 if (ret == nullptr) {
955 coutE(InputArguments) << "RooPlot::findObject(" << GetName() << ") cannot find object " << (name?name:"<last>") << std::endl ;
956 }
957 return ret ;
958}
959
960
961RooPlot::Items::iterator RooPlot::findItem(std::string const& name)
962{
963 return std::find_if(_items.begin(), _items.end(), [&name](auto const& item){
964 return name == item.first->GetName();
965 });
966}
967
968RooPlot::Items::const_iterator RooPlot::findItem(std::string const& name) const
969{
970 return std::find_if(_items.begin(), _items.end(), [&name](auto const& item){
971 return name == item.first->GetName();
972 });
973}
974
975
976////////////////////////////////////////////////////////////////////////////////
977/// Return the Draw() options registered for the named object. Return
978/// an empty string if the named object cannot be found.
979
981{
982 auto item = findItem(name);
983 if(item == _items.end()) return "";
984
985 return DrawOpt{item->second.c_str()}.drawOptions;
986}
987
988
989////////////////////////////////////////////////////////////////////////////////
990/// Register the specified drawing options for the named object.
991/// Return false if the named object cannot be found.
992
993bool RooPlot::setDrawOptions(const char *name, TString options)
994{
995 auto item = findItem(name);
996 if(item == _items.end()) return false;
997
998 DrawOpt opt(item->second.c_str()) ;
999 strlcpy(opt.drawOptions,options,128) ;
1000 item->second = opt.rawOpt();
1001 return true;
1002}
1003
1004
1005////////////////////////////////////////////////////////////////////////////////
1006/// Returns true of object with given name is set to be invisible
1007
1008bool RooPlot::getInvisible(const char* name) const
1009{
1010 auto item = findItem(name);
1011 if(item == _items.end()) return false;
1012
1013 return DrawOpt{item->second.c_str()}.invisible ;
1014}
1015
1016
1017////////////////////////////////////////////////////////////////////////////////
1018/// If flag is true object with 'name' is set to be invisible
1019/// i.e. it is not drawn when Draw() is called
1020
1021void RooPlot::setInvisible(const char* name, bool flag)
1022{
1023 auto item = findItem(name);
1024 if(item != _items.end()) {
1025 DrawOpt opt;
1026 opt.initialize(item->second.c_str());
1027 opt.invisible = flag;
1028 item->second = opt.rawOpt();
1029 }
1030
1031}
1032
1033
1034////////////////////////////////////////////////////////////////////////////////
1035/// Set maximum value of Y axis
1036
1037void RooPlot::SetMaximum(double maximum)
1038{
1039 _hist->SetMaximum(maximum==-1111?_defYmax:maximum) ;
1040}
1041
1042
1043
1044////////////////////////////////////////////////////////////////////////////////
1045/// Set minimum value of Y axis
1046
1047void RooPlot::SetMinimum(double minimum)
1048{
1049 _hist->SetMinimum(minimum==-1111?_defYmin:minimum) ;
1050}
1051
1052
1053
1054////////////////////////////////////////////////////////////////////////////////
1055/// Calculate and return reduced chi-squared between a curve and a histogram.
1056///
1057/// \param[in] curvename Name of the curve or nullptr for last curve
1058/// \param[in] histname Name of the histogram to compare to or nullptr for last added histogram
1059/// \param[in] nFitParam If non-zero, reduce the number of degrees of freedom by this
1060/// number. This means that the curve was fitted to the data with nFitParam floating
1061/// parameters, which needs to be reflected in the calculation of \f$\chi^2 / \mathrm{ndf}\f$.
1062///
1063/// \return \f$ \chi^2 / \mathrm{ndf} \f$ between the plotted curve and the data.
1064///
1065/// \note The \f$ \chi^2 \f$ is calculated between a *plot of the original distribution* and the data.
1066/// It therefore has more rounding errors than directly calculating the \f$ \chi^2 \f$ from a PDF or
1067/// function. To do this, use RooAbsReal::createChi2(RooDataHist&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&, const RooCmdArg&).
1068double RooPlot::chiSquare(const char* curvename, const char* histname, int nFitParam) const
1069{
1070
1071 // Find curve object
1072 RooCurve* curve = static_cast<RooCurve*>(findObject(curvename,RooCurve::Class())) ;
1073 if (!curve) {
1074 coutE(InputArguments) << "RooPlot::chiSquare(" << GetName() << ") cannot find curve" << std::endl ;
1075 return -1. ;
1076 }
1077
1078 // Find histogram object
1079 RooHist* hist = static_cast<RooHist*>(findObject(histname,RooHist::Class())) ;
1080 if (!hist) {
1081 coutE(InputArguments) << "RooPlot::chiSquare(" << GetName() << ") cannot find histogram" << std::endl ;
1082 return -1. ;
1083 }
1084
1085 return curve->chiSquare(*hist,nFitParam) ;
1086}
1087
1088
1089////////////////////////////////////////////////////////////////////////////////
1090/// Return a RooHist (derives from TGraphAsymErrors) containing the residuals of a histogram.
1091/// The plotting range of the graph is adapted to the plotting range of the current plot.
1092///
1093/// \param histname Name of the data histogram.
1094/// Passing an empty string or `nullptr` will create residuals of the last-plotted histogram.
1095/// \param curvename Name of the curve to compare to data.
1096/// Passing an empty string or `nullptr` will create residuals of the last-plotted curve.
1097/// \param normalize If true, the residuals are divided by the error
1098/// of the histogram, effectively returning a pull histogram.
1099/// \param useAverage If true, the histogram is compared with the curve averaged in each bin.
1100/// Otherwise, the curve is evaluated at the bin centres, which is not accurate for strongly curved distributions.
1101RooHist* RooPlot::residHist(const char* histname, const char* curvename, bool normalize, bool useAverage) const
1102{
1103 // Find all curve objects with the name "curvename" or the name of the last
1104 // plotted curve (there might be multiple in the case of multi-range fits).
1105 std::vector<RooCurve *> curves;
1106
1107 for(auto it = _items.rbegin(); it != _items.rend(); ++it) {
1108 TObject &obj = *it->first;
1109 if(obj.IsA() == RooCurve::Class()) {
1110 // If no curvename was passed, we take by default the last curve and all
1111 // other curves that have the same name
1112 if((!curvename || curvename[0] == '\0') || std::string(curvename) == obj.GetName()) {
1113 curvename = obj.GetName();
1114 curves.push_back(static_cast<RooCurve*>(&obj));
1115 }
1116 }
1117 }
1118
1119 if (curves.empty()) {
1120 coutE(InputArguments) << "RooPlot::residHist(" << GetName() << ") cannot find curve" << std::endl;
1121 return nullptr;
1122 }
1123
1124 // Find histogram object
1125 auto hist = static_cast<RooHist*>(findObject(histname,RooHist::Class()));
1126 if (!hist) {
1127 coutE(InputArguments) << "RooPlot::residHist(" << GetName() << ") cannot find histogram" << std::endl;
1128 return nullptr;
1129 }
1130
1131 auto residHist = hist->createEmptyResidHist(*curves.front(), normalize);
1132
1133 // We consider all curves with the same name as long as the ranges don't
1134 // overlap, to create also the full residual plot in multi-range fits.
1135 std::vector<std::pair<double, double>> coveredRanges;
1136 for(RooCurve * curve : curves) {
1137 const double xmin = curve->GetPointX(0);
1138 const double xmax = curve->GetPointX(curve->GetN() - 1);
1139
1140 for(auto const& prevRange : coveredRanges) {
1141 const double pxmin = prevRange.first;
1142 const double pxmax = prevRange.second;
1143 // If either xmin or xmax is within any previous range, the ranges
1144 // overloap and it makes to sense to also consider this curve for the
1145 // residuals (i.e., they can't come from a multi-range fit).
1146 if((pxmax > xmin && pxmin <= xmin) || (pxmax > xmax && pxmin <= xmax)) {
1147 continue;
1148 }
1149 }
1150
1151 coveredRanges.emplace_back(xmin, xmax);
1152
1153 hist->fillResidHist(*residHist, *curve, normalize, useAverage);
1154 }
1157 residHist->GetHistogram()->GetYaxis()->SetTitle(normalize ? "(Data - curve) / #sigma_{data}" : "Data - curve");
1158 return residHist.release();
1159}
1160
1161
1162
1163////////////////////////////////////////////////////////////////////////////////
1164/// Initialize the DrawOpt helper class
1165
1166void RooPlot::DrawOpt::initialize(const char* inRawOpt)
1167{
1168 if (!inRawOpt) {
1169 drawOptions[0] = 0 ;
1170 invisible=false ;
1171 return ;
1172 }
1173 strlcpy(drawOptions,inRawOpt,128) ;
1174 strtok(drawOptions,":") ;
1175 const char* extraOpt = strtok(nullptr,":") ;
1176 if (extraOpt) {
1177 invisible = (extraOpt[0]=='I') ;
1178 }
1179}
1180
1181
1182////////////////////////////////////////////////////////////////////////////////
1183/// Return the raw draw options
1184
1185const char* RooPlot::DrawOpt::rawOpt() const
1186{
1187 static char buf[128] ;
1188 strlcpy(buf,drawOptions,128) ;
1189 if (invisible) {
1190 strlcat(buf,":I",128) ;
1191 }
1192 return buf ;
1193}
1194
1195
1196
1197////////////////////////////////////////////////////////////////////////////////
1198/// Return the number of events that is associated with the range [xlo,xhi]
1199/// This method is only fully functional for ranges not equal to the full
1200/// range if the object that inserted the normalization data provided
1201/// a link to an external object that can calculate the event count in
1202/// in sub ranges. An error will be printed if this function is used
1203/// on sub-ranges while that information is not available
1204
1205double RooPlot::getFitRangeNEvt(double xlo, double xhi) const
1206{
1207 double scaleFactor = 1.0 ;
1208 if (_normObj) {
1209 scaleFactor = _normObj->getFitRangeNEvt(xlo,xhi)/_normObj->getFitRangeNEvt() ;
1210 } else {
1211 coutW(Plotting) << "RooPlot::getFitRangeNEvt(" << GetName() << ") WARNING: Unable to obtain event count in range "
1212 << xlo << " to " << xhi << ", substituting full event count" << std::endl ;
1213 }
1214 return getFitRangeNEvt()*scaleFactor ;
1215}
1216
1217
1218////////////////////////////////////////////////////////////////////////////////
1219/// Set the name of the RooPlot to 'name'
1220
1221void RooPlot::SetName(const char *name)
1222{
1223 if (_dir) _dir->GetList()->Remove(this);
1225 if (_dir) _dir->GetList()->Add(this);
1226}
1227
1228
1229////////////////////////////////////////////////////////////////////////////////
1230/// Set the name and title of the RooPlot to 'name' and 'title'
1231
1232void RooPlot::SetNameTitle(const char *name, const char* title)
1233{
1234 if (_dir) _dir->GetList()->Remove(this);
1236 if (_dir) _dir->GetList()->Add(this);
1237}
1238
1239
1240////////////////////////////////////////////////////////////////////////////////
1241/// Set the title of the RooPlot to 'title'
1242
1243void RooPlot::SetTitle(const char* title)
1244{
1246 _hist->SetTitle(title) ;
1247}
1248
1249
1250
1251////////////////////////////////////////////////////////////////////////////////
1252/// Define default print options, for a given print style
1253
1255{
1256 return kName|kArgs|kValue ;
1257}
1258
1259
1260
1261/// \see TH1::GetXaxis()
1262TAxis* RooPlot::GetXaxis() const { return _hist->GetXaxis() ; }
1263/// \see TH1::GetYaxis()
1264TAxis* RooPlot::GetYaxis() const { return _hist->GetYaxis() ; }
1265/// \see TH1::GetNbinsX()
1267/// \see TH1::GetNdivisions()
1269/// \see TH1::GetMinimum()
1270double RooPlot::GetMinimum(double minval) const { return _hist->GetMinimum(minval) ; }
1271/// \see TH1::GetMaximum()
1272double RooPlot::GetMaximum(double maxval) const { return _hist->GetMaximum(maxval) ; }
1273
1274
1275/// \see TH1::SetAxisColor()
1276void RooPlot::SetAxisColor(Color_t color, Option_t* axis) { _hist->SetAxisColor(color,axis) ; }
1277/// \see TH1::SetAxisRange()
1278void RooPlot::SetAxisRange(double xmin, double xmax, Option_t* axis) { _hist->SetAxisRange(xmin,xmax,axis) ; }
1279/// \see TH1::SetBarOffset()
1281/// \see TH1::SetBarWidth()
1283/// \see TH1::SetContour()
1284void RooPlot::SetContour(Int_t nlevels, const double* levels) { _hist->SetContour(nlevels,levels) ; }
1285/// \see TH1::SetContourLevel()
1287/// \see TH1::SetDrawOption()
1289/// \see TH1::SetFillAttributes()
1291/// \see TH1::SetFillColor()
1293/// \see TH1::SetFillStyle()
1295/// \see TH1::SetLabelColor()
1296void RooPlot::SetLabelColor(Color_t color, Option_t* axis) { _hist->SetLabelColor(color,axis) ; }
1297/// \see TH1::SetLabelFont()
1298void RooPlot::SetLabelFont(Style_t font, Option_t* axis) { _hist->SetLabelFont(font,axis) ; }
1299/// \see TH1::SetLabelOffset()
1301/// \see TH1::SetLabelSize()
1303/// \see TH1::SetLineAttributes()
1305/// \see TH1::SetLineColor()
1307/// \see TH1::SetLineStyle()
1309/// \see TH1::SetLineWidth()
1311/// \see TH1::SetMarkerAttributes()
1313/// \see TH1::SetMarkerColor()
1315/// \see TH1::SetMarkerSize()
1317/// \see TH1::SetMarkerStyle()
1319/// \see TH1::SetNdivisions()
1321/// \see TH1::SetOption()
1323/// Like TH1::SetStats(), but statistics boxes are *off* by default in RooFit.
1324void RooPlot::SetStats(bool stats) { _hist->SetStats(stats) ; }
1325/// \see TH1::SetTickLength()
1327/// \see TH1::SetTitleFont()
1328void RooPlot::SetTitleFont(Style_t font, Option_t* axis) { _hist->SetTitleFont(font,axis) ; }
1329/// \see TH1::SetTitleOffset()
1331/// \see TH1::SetTitleSize()
1333/// \see TH1::SetXTitle()
1335/// \see TH1::SetYTitle()
1337/// \see TH1::SetZTitle()
1339
1340
1341
1342
1343////////////////////////////////////////////////////////////////////////////////
1344/// Plot RooPlot when double-clicked in browser
1345
1347{
1348 Draw();
1349 gPad->Update();
1350}
1351
1352
1353
1354
1355////////////////////////////////////////////////////////////////////////////////
1356
1358{
1359 // Custom streamer, needed for backward compatibility
1360
1361 if (R__b.IsReading()) {
1362 const bool oldAddDir = TH1::AddDirectoryStatus();
1363 TH1::AddDirectory(false);
1364
1365 // The default c'tor might have registered this with a TDirectory.
1366 // Streaming the TNamed will make this not retrievable anymore, so
1367 // unregister first.
1368 if (_dir)
1369 _dir->Remove(this);
1370
1371 UInt_t R__s;
1372 UInt_t R__c;
1373 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1374 if (R__v > 1) {
1375 R__b.ReadClassBuffer(RooPlot::Class(),this,R__v,R__s,R__c);
1376 } else {
1377 // backward compatible streamer code here
1378 // Version 1 of RooPlot was deriving from TH1 and RooPrintable
1379 // Version 2 derives instead from TNamed and RooPrintable
1380 _hist = new TH1F();
1381 _hist->TH1::Streamer(R__b);
1382 SetName(_hist->GetName());
1385 {
1386 TList itemsList;
1387 itemsList.Streamer(R__b);
1389 }
1390 R__b >> _padFactor;
1391 R__b >> _plotVar;
1392 R__b >> _plotVarSet;
1393 R__b >> _normVars;
1394 R__b >> _normNumEvts;
1395 R__b >> _normBinWidth;
1396 R__b >> _defYmin;
1397 R__b >> _defYmax;
1398 R__b.CheckByteCount(R__s, R__c, RooPlot::IsA());
1399 }
1400
1401 TH1::AddDirectory(oldAddDir);
1402 if (_dir)
1403 _dir->Append(this);
1404
1405 } else {
1406 R__b.WriteClassBuffer(RooPlot::Class(),this);
1407 }
1408}
1409
1410////////////////////////////////////////////////////////////////////////////////
1411/// Build a legend that contains all objects that have been drawn on the plot.
1412std::unique_ptr<TLegend> RooPlot::BuildLegend() const {
1413 auto leg = std::make_unique<TLegend>(0.5, 0.7, 0.9, 0.9);
1414 leg->SetBorderSize(0);
1415 leg->SetFillStyle(0);
1416 for (std::size_t i=0; i < _items.size(); ++i) {
1417 leg->AddEntry(getObject(i));
1418 }
1419
1420 return leg;
1421}
1422
1423/// RooFit-internal function for backwards compatibility.
1425 for(TObject * obj : tlist) {
1426 items.emplace_back(obj, obj->GetOption());
1427 }
1428}
1429
1430/// Replaces the pointer to the plot variable with a pointer to a clone of the
1431/// plot variable that is owned by this RooPlot. The RooPlot references the
1432/// plotted variable by non-owning pointer by default since ROOT 6.28, which
1433/// resulted in a big speedup when plotting complicated pdfs that are expensive
1434/// to clone. However, going back to an owned clone is useful in rare cases.
1435/// For example in the RooUnitTest, where the registered plots need to live
1436/// longer than the scope of the unit test.
1438 // If the plot variable is already cloned, we don't need to do anything.
1439 if(_plotVarSet) return;
1440 _plotVarSet = static_cast<RooArgSet*>(RooArgSet(*_plotVar).snapshot());
1442}
#define d(i)
Definition RSha256.hxx:102
#define e(i)
Definition RSha256.hxx:103
TObject * clone(const char *newname) const override
Definition RooChi2Var.h:9
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
#define coutI(a)
#define coutW(a)
#define oocoutE(o, a)
#define coutE(a)
short Style_t
Definition RtypesCore.h:89
short Color_t
Definition RtypesCore.h:92
float Size_t
Definition RtypesCore.h:96
short Version_t
Definition RtypesCore.h:65
short Width_t
Definition RtypesCore.h:91
float Float_t
Definition RtypesCore.h:57
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
static void indent(ostringstream &buf, int indent_level)
#define gDirectory
Definition TDirectory.h:384
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t width
char name[80]
Definition TGX11.cxx:110
float xmin
float ymin
float xmax
float ymax
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
#define gPad
int binNumber(double x) const
Returns the bin number corresponding to the value x.
virtual double binCenter(Int_t bin) const =0
Int_t numBins() const
Return number of bins.
virtual double binLow(Int_t bin) const =0
virtual double binHigh(Int_t bin) const =0
RooAbsArg * find(const char *name) const
Find object with given name in list.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
virtual const RooAbsBinning & getBinning(const char *name=nullptr, bool verbose=true, bool createOnTheFly=false) const =0
Retrieve binning configuration with given name or default binning.
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
bool hasMax(const char *name=nullptr) const
Check if variable has an upper bound.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
bool hasMin(const char *name=nullptr) const
Check if variable has a lower bound.
TString getTitle(bool appendUnit=false) const
Return this variable's title string.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
RooArgSet * snapshot(bool deepCopy=true) const
Use RooAbsCollection::snapshot(), but return as RooArgSet.
Definition RooArgSet.h:191
One-dimensional graphical representation of a real-valued function.
Definition RooCurve.h:36
double chiSquare(const RooHist &hist, int nFitParam) const
Calculate the chi^2/NDOF of this curve with respect to the histogram 'hist' accounting nFitParam floa...
Definition RooCurve.cxx:535
static TClass * Class()
Graphical representation of binned data based on the TGraphAsymmErrors class.
Definition RooHist.h:29
static TClass * Class()
char drawOptions[128]
Definition RooPlot.h:224
void initialize(const char *_rawOpt)
Initialize the DrawOpt helper class.
Definition RooPlot.cxx:1166
const char * rawOpt() const
Return the raw draw options.
Definition RooPlot.cxx:1185
Plot frame and a container for graphics objects within that frame.
Definition RooPlot.h:45
RooPlot()
Default constructor coverity[UNINIT_CTOR].
Definition RooPlot.cxx:85
void SetAxisColor(Color_t color=1, Option_t *axis="X")
Definition RooPlot.cxx:1276
void remove(const char *name=nullptr, bool deleteToo=true)
Remove object with given name, or last object added if no name is given.
Definition RooPlot.cxx:868
void SetDrawOption(Option_t *option="") override
Definition RooPlot.cxx:1288
void updateYAxis(double ymin, double ymax, const char *label="")
Update our y-axis limits to accommodate an object whose spread in y is (ymin,ymax).
Definition RooPlot.cxx:605
Items _items
A list of the items we contain.
Definition RooPlot.h:239
void SetMarkerSize(Size_t msize=1)
Definition RooPlot.cxx:1316
static RooPlot * frame(const RooAbsRealLValue &var, double xmin, double xmax, Int_t nBins)
Create a new frame for a given variable in x.
Definition RooPlot.cxx:225
const RooPlotable * _normObj
! Pointer to normalization object ;
Definition RooPlot.h:245
double _normNumEvts
Number of events in histogram (for normalization)
Definition RooPlot.h:246
bool 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:906
bool getInvisible(const char *name) const
Returns true of object with given name is set to be invisible.
Definition RooPlot.cxx:1008
void SetTitle(const char *name) override
Set the title of the RooPlot to 'title'.
Definition RooPlot.cxx:1243
RooArgSet * _normVars
Variables that PDF plots should be normalized over.
Definition RooPlot.h:243
void addObject(TObject *obj, Option_t *drawOptions="", bool invisible=false)
Add a generic object to this plot.
Definition RooPlot.cxx:366
Use the constructor that doesn t take the name and title
Definition RooPlot.h:51
void addTH1(TH1 *hist, Option_t *drawOptions="", bool invisible=false)
Add a TH1 histogram object to this plot.
Definition RooPlot.cxx:385
double _padFactor
Scale our y-axis to _padFactor of our maximum contents.
Definition RooPlot.h:240
void SetMarkerColor(Color_t tcolor=1)
Definition RooPlot.cxx:1314
void printMultiline(std::ostream &os, Int_t content, bool verbose=false, TString indent="") const override
Frame detailed printing.
Definition RooPlot.cxx:738
void SetXTitle(const char *title)
Definition RooPlot.cxx:1334
void SetFillColor(Color_t fcolor)
Definition RooPlot.cxx:1292
RooArgSet * _plotVarSet
A list owning the cloned tree nodes of the plotVarClone.
Definition RooPlot.h:242
void SetNdivisions(Int_t n=510, Option_t *axis="X")
Definition RooPlot.cxx:1320
TDirectory * _dir
! non-persistent
Definition RooPlot.h:252
TString histName() const
Construct automatic name of internal TH1.
Definition RooPlot.cxx:301
TH1 * _hist
Histogram that we uses as basis for drawing the content.
Definition RooPlot.h:238
void SetMarkerStyle(Style_t mstyle=1)
Definition RooPlot.cxx:1318
void printName(std::ostream &os) const override
Print frame name.
Definition RooPlot.cxx:669
TString getDrawOptions(const char *name) const
Return the Draw() options registered for the named object.
Definition RooPlot.cxx:980
double _normBinWidth
Histogram bin width (for normalization)
Definition RooPlot.h:247
void SetZTitle(const char *title)
Definition RooPlot.cxx:1338
void setInvisible(const char *name, bool flag=true)
If flag is true object with 'name' is set to be invisible i.e.
Definition RooPlot.cxx:1021
void Streamer(TBuffer &) override
Stream an object of class TObject.
Definition RooPlot.cxx:1357
void SetContour(Int_t nlevels, const double *levels=nullptr)
Definition RooPlot.cxx:1284
void printClassName(std::ostream &os) const override
Print frame class name.
Definition RooPlot.cxx:687
bool setDrawOptions(const char *name, TString options)
Register the specified drawing options for the named object.
Definition RooPlot.cxx:993
TObject * findObject(const char *name, const TClass *tClass=nullptr) const
Find the named object in our list of items and return a pointer to it.
Definition RooPlot.cxx:942
void SetStats(bool stats=true)
Like TH1::SetStats(), but statistics boxes are off by default in RooFit.
Definition RooPlot.cxx:1324
double getFitRangeNEvt() const
Return the number of events in the fit range.
Definition RooPlot.h:145
std::vector< std::pair< TObject *, std::string > > Items
Definition RooPlot.h:47
double GetMaximum(double maxval=FLT_MAX) const
Definition RooPlot.cxx:1272
TAttLine * getAttLine(const char *name=nullptr) const
Return a pointer to the line attributes of the named object in this plot, or zero if the named object...
Definition RooPlot.cxx:807
bool 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:921
RooAbsRealLValue * _plotVar
The variable we are plotting.
Definition RooPlot.h:241
void SetDirectory(TDirectory *dir)
Set the directory that this plot is associated to.
Definition RooPlot.cxx:333
~RooPlot() override
Destructor.
Definition RooPlot.cxx:314
void SetLabelOffset(Float_t offset=0.005, Option_t *axis="X")
Definition RooPlot.cxx:1300
TAttFill * getAttFill(const char *name=nullptr) const
Return a pointer to the fill attributes of the named object in this plot, or zero if the named object...
Definition RooPlot.cxx:817
void printTitle(std::ostream &os) const override
Print frame title.
Definition RooPlot.cxx:678
void SetLineWidth(Width_t lwidth)
Definition RooPlot.cxx:1310
void SetTickLength(Float_t length=0.02, Option_t *axis="X")
Definition RooPlot.cxx:1326
void SetFillAttributes()
Definition RooPlot.cxx:1290
void SetContourLevel(Int_t level, double value)
Definition RooPlot.cxx:1286
static bool addDirectoryStatus()
Query whether new instances of RooPlot will add themselves to gDirectory.
Definition RooPlot.cxx:77
void SetLabelSize(Float_t size=0.02, Option_t *axis="X")
Definition RooPlot.cxx:1302
double chiSquare(int nFitParam=0) const
Shortcut for RooPlot::chiSquare(const char* pdfname, const char* histname, int nFitParam=nullptr)
Definition RooPlot.h:180
Items::iterator findItem(std::string const &name)
Definition RooPlot.cxx:961
void SetOption(Option_t *option=" ")
Definition RooPlot.cxx:1322
TObject * getObject(Int_t idx) const
Return the name of the object at slot 'idx' in this RooPlot.
Definition RooPlot.cxx:791
TAxis * GetYaxis() const
Definition RooPlot.cxx:1264
void Draw(Option_t *options=nullptr) override
Draw this plot and all of the elements it contains.
Definition RooPlot.cxx:637
void SetLabelFont(Style_t font=62, Option_t *axis="X")
Definition RooPlot.cxx:1298
void Browse(TBrowser *b) override
Plot RooPlot when double-clicked in browser.
Definition RooPlot.cxx:1346
double _defYmax
Default maximum for Yaxis (as calculated from contents)
Definition RooPlot.h:250
void SetLineStyle(Style_t lstyle)
Definition RooPlot.cxx:1308
TAttMarker * getAttMarker(const char *name=nullptr) const
Return a pointer to the marker attributes of the named object in this plot, or zero if the named obje...
Definition RooPlot.cxx:827
void SetTitleFont(Style_t font=62, Option_t *axis="X")
Definition RooPlot.cxx:1328
void SetAxisRange(double xmin, double xmax, Option_t *axis="X")
Definition RooPlot.cxx:1278
TAxis * GetXaxis() const
Definition RooPlot.cxx:1262
void SetLineColor(Color_t lcolor)
Definition RooPlot.cxx:1306
void SetFillStyle(Style_t fstyle)
Definition RooPlot.cxx:1294
const char * nameOf(Int_t idx) const
Return the name of the object at slot 'idx' in this RooPlot.
Definition RooPlot.cxx:775
void updateNormVars(const RooArgSet &vars)
Install the given set of observables are reference normalization variables for this frame.
Definition RooPlot.cxx:351
RooHist * residHist(const char *histname=nullptr, const char *pdfname=nullptr, bool normalize=false, bool useAverage=true) const
Return a RooHist (derives from TGraphAsymErrors) containing the residuals of a histogram.
Definition RooPlot.cxx:1101
RooPlot * emptyClone(const char *name)
Return empty clone of current RooPlot.
Definition RooPlot.cxx:271
void SetMarkerAttributes()
Definition RooPlot.cxx:1312
void createInternalPlotVarClone()
Replaces the pointer to the plot variable with a pointer to a clone of the plot variable that is owne...
Definition RooPlot.cxx:1437
void SetNameTitle(const char *name, const char *title) override
Set the name and title of the RooPlot to 'name' and 'title'.
Definition RooPlot.cxx:1232
void setPadFactor(double factor)
Definition RooPlot.h:150
Int_t defaultPrintContents(Option_t *opt) const override
Define default print options, for a given print style.
Definition RooPlot.cxx:1254
RooCurve * getCurve(const char *name=nullptr) const
Return a RooCurve pointer of the named object in this plot, or zero if the named object does not exis...
Definition RooPlot.cxx:848
static bool setAddDirectoryStatus(bool flag)
Configure whether new instances of RooPlot will add themselves to gDirectory.
Definition RooPlot.cxx:78
TAttText * getAttText(const char *name=nullptr) const
Return a pointer to the text attributes of the named object in this plot, or zero if the named object...
Definition RooPlot.cxx:837
void SetLabelColor(Color_t color=1, Option_t *axis="X")
Definition RooPlot.cxx:1296
TClass * IsA() const override
Definition RooPlot.h:256
SetMaximum(ymax)
Int_t GetNbinsX() const
Definition RooPlot.cxx:1266
static void fillItemsFromTList(Items &items, TList const &tlist)
RooFit-internal function for backwards compatibility.
Definition RooPlot.cxx:1424
void SetLineAttributes()
Definition RooPlot.cxx:1304
static bool _addDirStatus
static flag controlling AutoDirectoryAdd feature
Definition RooPlot.h:254
void printValue(std::ostream &os) const override
Print frame arguments.
Definition RooPlot.cxx:710
void SetYTitle(const char *title)
Definition RooPlot.cxx:1336
double getPadFactor() const
Definition RooPlot.h:149
void printArgs(std::ostream &os) const override
Interface for printing of object arguments.
Definition RooPlot.cxx:696
std::unique_ptr< TLegend > BuildLegend() const
Build a legend that contains all objects that have been drawn on the plot.
Definition RooPlot.cxx:1412
RooHist * getHist(const char *name=nullptr) const
Return a RooCurve pointer of the named object in this plot, or zero if the named object does not exis...
Definition RooPlot.cxx:858
void updateFitRangeNorm(const TH1 *hist)
Update our plot normalization over our plot variable's fit range, which will be determined by the fir...
Definition RooPlot.cxx:550
void SetTitleSize(Float_t size=0.02, Option_t *axis="X")
Definition RooPlot.cxx:1332
double _defYmin
Default minimum for Yaxis (as calculated from contents)
Definition RooPlot.h:249
SetMinimum(ymin)
static TClass * Class()
void SetBarOffset(Float_t offset=0.25)
Definition RooPlot.cxx:1280
void SetBarWidth(Float_t width=0.5)
Definition RooPlot.cxx:1282
Int_t GetNdivisions(Option_t *axis="X") const
Definition RooPlot.cxx:1268
void addPlotable(RooPlotable *plotable, Option_t *drawOptions="", bool invisible=false, bool refreshNorm=false)
Add the specified plotable object to our plot.
Definition RooPlot.cxx:516
void initialize()
Perform initialization that is common to all constructors.
Definition RooPlot.cxx:282
static RooPlot * frameWithLabels(const RooAbsRealLValue &var)
Create a new frame for a given variable in x, adding bin labels.
Definition RooPlot.cxx:237
void SetTitleOffset(Float_t offset=1, Option_t *axis="X")
Definition RooPlot.cxx:1330
Use the constructor that doesn t take the name and and then call SetName() and SetTitle() on the RooPlot.")
double GetMinimum(double minval=-FLT_MAX) const
Definition RooPlot.cxx:1270
Class RooPotable is a base class for objects that can be inserted into RooPlots and take advantage of...
Definition RooPlotable.h:26
virtual double getFitRangeNEvt() const =0
TObject * crossCast()
Return cast of RooPlotable as TObject.
double getYAxisMin() const
Definition RooPlotable.h:38
double getYAxisMax() const
Definition RooPlotable.h:39
const char * getYAxisLabel() const
Definition RooPlotable.h:28
virtual double getFitRangeBinW() const =0
A 'mix-in' base class that define the standard RooFit plotting and printing methods.
static TClass * Class()
virtual void Streamer(TBuffer &)
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,...
void Set(Int_t n) override
Set size of this array to n doubles.
Definition TArrayD.cxx:106
Fill Area Attributes class.
Definition TAttFill.h:19
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:37
virtual void SetFillAttributes()
Invoke the DialogCanvas Fill attributes.
Definition TAttFill.cxx:254
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:39
Line Attributes class.
Definition TAttLine.h:18
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:42
virtual void SetLineAttributes()
Invoke the DialogCanvas Line attributes.
Definition TAttLine.cxx:294
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:40
Marker Attributes class.
Definition TAttMarker.h:19
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition TAttMarker.h:38
virtual void SetMarkerAttributes()
Invoke the DialogCanvas Marker attributes.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition TAttMarker.h:40
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition TAttMarker.h:45
Text Attributes class.
Definition TAttText.h:18
Class to manage histogram axis.
Definition TAxis.h:31
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
Definition TAxis.cxx:886
Bool_t IsAlphanumeric() const
Definition TAxis.h:88
const char * GetTitle() const override
Returns title of object.
Definition TAxis.h:135
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
Definition TAxis.cxx:478
Double_t GetXmax() const
Definition TAxis.h:140
const char * GetBinLabel(Int_t bin) const
Return label for bin.
Definition TAxis.cxx:440
Double_t GetXmin() const
Definition TAxis.h:139
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
Set the viewing range for the axis from ufirst to ulast (in user coordinates, that is,...
Definition TAxis.cxx:1080
virtual Double_t GetBinWidth(Int_t bin) const
Return bin width.
Definition TAxis.cxx:540
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
Definition TAxis.cxx:528
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
Buffer base class used for serializing objects.
Definition TBuffer.h:43
virtual Version_t ReadVersion(UInt_t *start=nullptr, UInt_t *bcnt=nullptr, const TClass *cl=nullptr)=0
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=nullptr)=0
Bool_t IsReading() const
Definition TBuffer.h:86
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4874
Describe directory structure in memory.
Definition TDirectory.h:45
virtual TList * GetList() const
Definition TDirectory.h:222
virtual void Append(TObject *obj, Bool_t replace=kFALSE)
Append object to this directory.
virtual TObject * Remove(TObject *)
Remove an object from the in-memory list.
TGraph with asymmetric error bars.
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
static TClass * Class()
@ kIsSortedX
Graph is sorted in X points.
Definition TGraph.h:79
virtual TH1F * GetHistogram() const
Returns a pointer to the histogram used to draw the axis Takes into account the two following cases.
Definition TGraph.cxx:1411
1-D histogram with a double per channel (see TH1 documentation)
Definition TH1.h:669
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:621
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
virtual void SetLabelFont(Style_t font=62, Option_t *axis="X")
Set font number used to draw axis labels.
Definition Haxis.cxx:249
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
Definition TH1.cxx:8905
virtual void SetBarOffset(Float_t offset=0.25)
Set the bar offset as fraction of the bin width for drawing mode "B".
Definition TH1.h:364
virtual void SetTitleSize(Float_t size=0.02, Option_t *axis="X")
Set the axis' title size.
Definition Haxis.cxx:365
virtual void SetLabelOffset(Float_t offset=0.005, Option_t *axis="X")
Set offset between axis and axis' labels.
Definition Haxis.cxx:267
void SetTitle(const char *title) override
Change/set the title.
Definition TH1.cxx:6686
virtual void SetXTitle(const char *title)
Definition TH1.h:418
virtual Int_t GetDimension() const
Definition TH1.h:283
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
Definition TH1.cxx:1294
virtual void SetContourLevel(Int_t level, Double_t value)
Set value for one contour level.
Definition TH1.cxx:8490
TAxis * GetXaxis()
Definition TH1.h:324
virtual void SetNdivisions(Int_t n=510, Option_t *axis="X")
Set the number of divisions to draw an axis.
Definition Haxis.cxx:170
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:8513
virtual Int_t GetNbinsX() const
Definition TH1.h:297
virtual void SetMaximum(Double_t maximum=-1111)
Definition TH1.h:403
TAxis * GetYaxis()
Definition TH1.h:325
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3066
virtual Int_t GetNdivisions(Option_t *axis="X") const
Return the number of divisions for "axis".
Definition Haxis.cxx:27
virtual void SetMinimum(Double_t minimum=-1111)
Definition TH1.h:404
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:9190
virtual Double_t GetEntries() const
Return the current number of entries.
Definition TH1.cxx:4423
virtual void SetZTitle(const char *title)
Definition TH1.h:420
virtual TArrayD * GetSumw2()
Definition TH1.h:313
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' title.
Definition Haxis.cxx:345
virtual void SetLabelColor(Color_t color=1, Option_t *axis="X")
Set axis labels color.
Definition Haxis.cxx:226
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
virtual void SetOption(Option_t *option=" ")
Definition TH1.h:411
virtual void SetContour(Int_t nlevels, const Double_t *levels=nullptr)
Set the number and values of contour levels.
Definition TH1.cxx:8451
virtual void SetAxisRange(Double_t xmin, Double_t xmax, Option_t *axis="X")
Set the "axis" range.
Definition Haxis.cxx:201
virtual void SetYTitle(const char *title)
Definition TH1.h:419
virtual void SetTitleFont(Style_t font=62, Option_t *axis="X")
Set the axis' title font.
Definition Haxis.cxx:323
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:8603
virtual void SetLabelSize(Float_t size=0.02, Option_t *axis="X")
Set size of axis' labels.
Definition Haxis.cxx:285
virtual void Sumw2(Bool_t flag=kTRUE)
Create structure to store sum of squares of weights.
Definition TH1.cxx:8988
static Bool_t AddDirectoryStatus()
Static function: cannot be inlined on Windows/NT.
Definition TH1.cxx:754
virtual void SetBarWidth(Float_t width=0.5)
Set the width of bars as fraction of the bin width for drawing mode "B".
Definition TH1.h:365
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition TH1.cxx:8958
virtual void SetTickLength(Float_t length=0.02, Option_t *axis="X")
Set the axis' tick marks length.
Definition Haxis.cxx:302
A doubly linked list.
Definition TList.h:38
void Streamer(TBuffer &) override
Stream all objects in the collection to or from the I/O buffer.
Definition TList.cxx:1189
void RecursiveRemove(TObject *obj) override
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition TList.cxx:762
void Add(TObject *obj) override
Definition TList.h:83
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:820
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
TString fName
Definition TNamed.h:32
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Definition TNamed.cxx:154
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:439
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:207
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:525
virtual void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition TObject.cxx:764
virtual TClass * IsA() const
Definition TObject.h:243
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:274
Basic string class.
Definition TString.h:139
void ToLower()
Change string to lower-case.
Definition TString.cxx:1182
const char * Data() const
Definition TString.h:376
void ToUpper()
Change string to upper case.
Definition TString.cxx:1195
TString & Append(const char *cs)
Definition TString.h:572
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
leg
Definition legend1.C:34
Definition graph.py:1
th1 Draw()