Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooCurve.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooCurve.h,v 1.24 2007/05/11 09:11:30 verkerke Exp $
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#ifndef ROO_CURVE
17#define ROO_CURVE
18
19#include <RooPlotable.h>
20
21#include <ROOT/RSpan.hxx>
22
23#include <TGraph.h>
24#include <TMatrixDfwd.h>
25
26#include <list>
27#include <vector>
28
29class RooAbsReal;
30class RooRealVar;
31class RooAbsFunc;
32class RooArgSet;
33class RooAbsRealLValue ;
34class RooHist ;
35
36class RooCurve : public TGraph, public RooPlotable {
37public:
38 RooCurve();
39 enum WingMode { NoWings=0 ,Straight=1, Extended=2 } ;
40 RooCurve(const RooAbsReal &func, RooAbsRealLValue &x, double xlo, double xhi, Int_t xbins,
41 double scaleFactor= 1, const RooArgSet *normVars= nullptr, double prec= 1e-3, double resolution= 1e-3,
42 bool shiftToZero=false, WingMode wmode=Extended, Int_t nEvalError=-1, Int_t doEEVal=false, double eeVal=0.0,
43 bool showProgress=false);
44 RooCurve(const char *name, const char *title, const RooAbsFunc &func, double xlo,
45 double xhi, UInt_t minPoints, double prec= 1e-3, double resolution= 1e-3,
46 bool shiftToZero=false, WingMode wmode=Extended, Int_t nEvalError=-1, Int_t doEEVal=false, double eeVal=0.0);
47 ~RooCurve() override;
48
49 RooCurve(const char* name, const char* title, const RooCurve& c1, const RooCurve& c2, double scale1=1., double scale2=1.) ;
50
51 void addPoint(double x, double y);
52
53 double getFitRangeBinW() const override;
54 double getFitRangeNEvt(double xlo, double xhi) const override ;
55 double getFitRangeNEvt() const override;
56
57
58 void printName(std::ostream& os) const override ;
59 void printTitle(std::ostream& os) const override ;
60 void printClassName(std::ostream& os) const override ;
61 void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent="") const override;
62
63 inline void Print(Option_t *options= nullptr) const override {
64 // Printing interface
66 }
67
68 double chiSquare(const RooHist& hist, int nFitParam) const ;
69 Int_t findPoint(double value, double tolerance=1e-10) const ;
70 double average(double lo, double hi) const ;
71 double interpolate(double x, double tolerance=1e-10) const ;
72
73 bool isIdentical(const RooCurve& other, double tol=1e-6, bool verbose=true) const ;
74
75 RooCurve* makeErrorBand(const std::vector<RooCurve*>& variations, double Z=1) const ;
76 RooCurve* makeErrorBand(const std::vector<RooCurve*>& plusVar, const std::vector<RooCurve*>& minusVar, const TMatrixD& V, double Z=1) const ;
77
78 static std::list<double>* plotSamplingHintForBinBoundaries(std::span<const double> boundaries, double xlo, double xhi);
79
80protected:
81
82 void calcBandInterval(const std::vector<RooCurve*>& variations,Int_t i,double Z,double& lo, double& hi, bool approxGauss) const ;
83 void calcBandInterval(const std::vector<RooCurve*>& plusVar, const std::vector<RooCurve*>& minusVar, Int_t i, const TMatrixD& V,
84 double Z,double& lo, double& hi) const ;
85
86 void initialize();
87 void addPoints(const RooAbsFunc &func, double xlo, double xhi,
88 Int_t minPoints, double prec, double resolution, WingMode wmode,
89 Int_t numee=0, bool doEEVal=false, double eeVal=0.0,std::list<double>* samplingHint=nullptr) ;
90 void addRange(const RooAbsFunc& func, double x1, double x2, double y1,
91 double y2, double minDy, double minDx,
92 int numee, bool doEEVal, double eeVal, double epsilon);
93
94
95 void shiftCurveToZero();
96
97 bool _showProgress = false; ///<! Show progress indication when adding points
98
99private:
100 /// The distance between two points x1 and x2 relative to the full plot range
101 /// below which two points are considered identical. No further sampling
102 /// points will be added to the curve when the distance between two sampling
103 /// points falls below this threshold.
104 static constexpr double relativeXEpsilon() { return 1e-9; }
105
106 ClassDefOverride(RooCurve,1) // 1-dimensional smooth curve for use in RooPlots
107};
108
109#endif
#define e(i)
Definition RSha256.hxx:103
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:110
#define hi
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
Definition RooAbsFunc.h:27
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
Abstract base class for objects that represent a real value and implements functionality common to al...
Definition RooAbsReal.h:59
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
One-dimensional graphical representation of a real-valued function.
Definition RooCurve.h:36
void printTitle(std::ostream &os) const override
Print the title of this curve.
Definition RooCurve.cxx:498
void initialize()
Perform initialization that is common to all curves.
Definition RooCurve.cxx:241
~RooCurve() override
double getFitRangeBinW() const override
Get the bin width associated with this plotable object.
Definition RooCurve.cxx:479
static constexpr double relativeXEpsilon()
The distance between two points x1 and x2 relative to the full plot range below which two points are ...
Definition RooCurve.h:104
void addRange(const RooAbsFunc &func, double x1, double x2, double y1, double y2, double minDy, double minDx, int numee, bool doEEVal, double eeVal, double epsilon)
Fill the range (x1,x2) with points calculated using func(&x).
Definition RooCurve.cxx:402
void printName(std::ostream &os) const override
Print name of object.
Definition RooCurve.cxx:487
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Print the details of this curve.
Definition RooCurve.cxx:517
double interpolate(double x, double tolerance=1e-10) const
Return linearly interpolated value of curve at xvalue.
Definition RooCurve.cxx:655
static std::list< double > * plotSamplingHintForBinBoundaries(std::span< const double > boundaries, double xlo, double xhi)
Returns sampling hints for a histogram with given boundaries.
Definition RooCurve.cxx:893
void printClassName(std::ostream &os) const override
Print the class name of this curve.
Definition RooCurve.cxx:507
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
Definition RooCurve.h:63
@ Extended
Definition RooCurve.h:39
@ NoWings
Definition RooCurve.h:39
@ Straight
Definition RooCurve.h:39
RooCurve()
Default constructor.
Definition RooCurve.cxx:84
bool _showProgress
! Show progress indication when adding points
Definition RooCurve.h:97
RooCurve * makeErrorBand(const std::vector< RooCurve * > &variations, double Z=1) const
Construct filled RooCurve represented error band that captures alpha% of the variations of the curves...
Definition RooCurve.cxx:701
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
void calcBandInterval(const std::vector< RooCurve * > &variations, Int_t i, double Z, double &lo, double &hi, bool approxGauss) const
Definition RooCurve.cxx:812
double getFitRangeNEvt() const override
Return the number of events associated with the plotable object, it is always 1 for curves.
Definition RooCurve.cxx:460
void shiftCurveToZero()
Find lowest point in curve and move all points in curve so that lowest point will go exactly through ...
Definition RooCurve.cxx:255
void addPoint(double x, double y)
Add a point with the specified coordinates. Update our y-axis limits.
Definition RooCurve.cxx:447
bool isIdentical(const RooCurve &other, double tol=1e-6, bool verbose=true) const
Return true if curve is identical to other curve allowing for given absolute tolerance on each point ...
Definition RooCurve.cxx:851
Int_t findPoint(double value, double tolerance=1e-10) const
Find the nearest point to xvalue.
Definition RooCurve.cxx:633
double average(double lo, double hi) const
Return average curve value in [xFirst,xLast] by integrating curve between points and dividing by xLas...
Definition RooCurve.cxx:580
Graphical representation of binned data based on the TGraphAsymmErrors class.
Definition RooHist.h:29
Class RooPotable is a base class for objects that can be inserted into RooPlots and take advantage of...
Definition RooPlotable.h:26
virtual StyleOption defaultPrintStyle(Option_t *opt) const
virtual Int_t defaultPrintContents(Option_t *opt) const
Default choice of contents to be printed (name and value)
static std::ostream & defaultPrintStream(std::ostream *os=nullptr)
Return a reference to the current default stream to use in Print().
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,...
Variable that can be changed from the outside.
Definition RooRealVar.h:37
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
Basic string class.
Definition TString.h:139
void addPoints()
Definition event_demo.C:69
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
return c2
Definition legend2.C:14