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