82 double scaleFactor,
const RooArgSet *normVars,
double prec,
double resolution,
87 _showProgress(showProg)
96 if(0 != strlen(
f.getUnit()) || 0 != strlen(
x.getUnit())) {
98 if(0 != strlen(
f.getUnit())) {
102 if(0 != strlen(
x.getUnit())) {
113 funcPtr=
f.bindVars(
x,normVars,
true);
116 if(scaleFactor != 1) {
120 assert(0 != funcPtr);
126 list<double>* hint =
f.plotSamplingHint(
x,xlo,xhi) ;
127 addPoints(*funcPtr,xlo,xhi,
xbins+1,prec,resolution,wmode,nEvalError,doEEVal,eeVal,hint);
137 int nBinsX =
x.numBins();
138 for(
int i=0; i<nBinsX; ++i){
139 double xval =
x.getBinning().binCenter(i);
147 if(rawPtr)
delete rawPtr;
151 for (
int i=0 ; i<
GetN() ; i++) {
167 double xlo,
double xhi,
UInt_t minPoints,
double prec,
double resolution,
174 addPoints(func,xlo,xhi,minPoints+1,prec,resolution,wmode,nEvalError,doEEVal,eeVal);
179 for (
int i=0 ; i<
GetN() ; i++) {
208 deque<double> pointList ;
213 for (i1=0 ; i1<n1 ; i1++) {
214 c1.GetPoint(i1,
x,
y) ;
215 pointList.push_back(
x) ;
220 for (i2=0 ; i2<n2 ; i2++) {
221 c2.GetPoint(i2,
x,
y) ;
222 pointList.push_back(
x) ;
226 sort(pointList.begin(),pointList.end()) ;
230 for (
auto point : pointList) {
232 if ((point-last)>1
e-10) {
234 addPoint(point,scale1*
c1.interpolate(point)+scale2*
c2.interpolate(point)) ;
273 double minVal(1e30) ;
274 double maxVal(-1e30) ;
277 for (i=1 ; i<
GetN()-1 ; i++) {
280 if (
y<minVal) minVal=
y ;
281 if (
y>maxVal) maxVal=
y ;
285 for (i=1 ; i<
GetN()-1 ; i++) {
293 double newMax = maxVal - minVal ;
307 Int_t minPoints,
double prec,
double resolution,
WingMode wmode,
308 Int_t numee,
bool doEEVal,
double eeVal, list<double>* samplingHint)
315 if(minPoints <= 0 || xhi <= xlo) {
325 minPoints = samplingHint->size() ;
328 double dx= (xhi-xlo)/(minPoints-1.);
329 std::vector<double> yval(minPoints);
333 std::vector<double> xval;
335 for(
int step= 0; step < minPoints; step++) {
336 xval.push_back(xlo + step*dx) ;
339 std::copy(samplingHint->begin(), samplingHint->end(), std::back_inserter(xval));
342 for (
unsigned int step=0; step < xval.size(); ++step) {
343 double xx = xval[step];
344 if (step ==
static_cast<unsigned int>(minPoints-1))
347 yval[step]= func(&xx);
365 const double ymax = *std::max_element(yval.begin(), yval.end());
366 const double ymin = *std::min_element(yval.begin(), yval.end());
370 double minDx= resolution*(xhi-xlo);
385 auto iter2 = xval.begin() ;
391 if (iter2==xval.end()) {
399 addRange(func,
x1,
x2,yval[step-1],yval[step],prec*yrangeEst,minDx,numee,doEEVal,eeVal);
408 addPoint(xhi+dx,yval[minPoints-1]) ;
423 double y1,
double y2,
double minDy,
double minDx,
424 Int_t numee,
bool doEEVal,
double eeVal)
432 double xmid= 0.5*(
x1+
x2);
433 double ymid= func(&xmid);
451 double dy= ymid - 0.5*(
y1+
y2);
454 addRange(func,
x1,xmid,
y1,ymid,minDy,minDx,numee,doEEVal,eeVal);
455 addRange(func,xmid,
x2,ymid,
y2,minDy,minDx,numee,doEEVal,eeVal);
539 os <<
indent <<
"--- RooCurve ---" << endl ;
541 os <<
indent <<
" Contains " <<
n <<
" points" << endl;
542 os <<
indent <<
" Graph points:" << endl;
543 for(
Int_t i= 0; i <
n; i++) {
544 os <<
indent << setw(3) << i <<
") x = " <<
fX[i] <<
" , y = " <<
fY[i] << endl;
558 double x,
y,eyl,eyh,exl,exh ;
561 double xstart,xstop ;
569 for (i=0 ; i<
np ; i++) {
575 if (x<xstart || x>xstop) continue ;
587 double pull = (
y>avg) ? ((
y-avg)/eyl) : ((
y-avg)/eyh) ;
594 return chisq.
Sum() / (nbin-nFitParam) ;
607 <<
") invalid range (" << xFirst <<
"," << xLast <<
")" << endl ;
618 double xFirstPt,yFirstPt,xLastPt,yLastPt ;
619 GetPoint(ifirst,xFirstPt,yFirstPt) ;
622 double tolerance=1
e-3*(xLast-xFirst) ;
625 if (ilast-ifirst==1 &&(xFirstPt-xFirst)<-1*tolerance && (xLastPt-xLast)>tolerance) {
626 return 0.5*(yFirst+yLast) ;
631 if ((xFirstPt-xFirst)<-1*tolerance) {
638 if ((xLastPt-xLast)>tolerance) {
646 sum += (xFirstPt-xFirst)*(yFirst+yFirstPt)/2 ;
650 for (i=ifirst ; i<ilast ; i++) {
657 sum += (xLast-xLastPt)*(yLastPt+yLast)/2 ;
658 return sum/(xLast-xFirst) ;
669 double delta(std::numeric_limits<double>::max()),
x,
y ;
672 for (i=0 ; i<
n ; i++) {
680 return (delta<tolerance)?ibest:-1 ;
696 double xbest, ybest ;
700 if (
std::abs(xbest-xvalue)<tolerance) {
705 double xother,yother, retVal(0) ;
712 if (xother==xbest)
return ybest ;
713 retVal = ybest + (yother-ybest)*(xvalue-xbest)/(xother-xbest) ;
721 if (xother==xbest)
return ybest ;
722 retVal = yother + (ybest-yother)*(xvalue-xother)/(xbest-xother) ;
744 vector<double> bandLo(
GetN()) ;
745 vector<double> bandHi(
GetN()) ;
746 for (
int i=0 ; i<
GetN() ; i++) {
750 for (
int i=0 ; i<
GetN() ; i++) {
753 for (
int i=
GetN()-1 ; i>=0 ; i--) {
784 vector<double> bandLo(
GetN()) ;
785 vector<double> bandHi(
GetN()) ;
786 for (
int i=0 ; i<
GetN() ; i++) {
790 for (
int i=0 ; i<
GetN() ; i++) {
793 for (
int i=
GetN()-1 ; i>=0 ; i--) {
817 vector<double> y_plus(plusVar.size()), y_minus(minusVar.size()) ;
819 for (vector<RooCurve*>::const_iterator iter=plusVar.begin() ; iter!=plusVar.end() ; ++iter) {
820 y_plus[j++] = (*iter)->interpolate(
GetX()[i]) ;
823 for (vector<RooCurve*>::const_iterator iter=minusVar.begin() ; iter!=minusVar.end() ; ++iter) {
824 y_minus[j++] = (*iter)->interpolate(
GetX()[i]) ;
826 double y_cen =
GetY()[i] ;
831 for (j=0 ; j<
n ; j++) {
832 F[j] = (y_plus[j]-y_minus[j])/2 ;
848 vector<double>
y(variations.size()) ;
850 for (vector<RooCurve*>::const_iterator iter=variations.begin() ; iter!=variations.end() ; ++iter) {
851 y[j++] = (*iter)->interpolate(
GetX()[i]) ;
858 sort(
y.begin(),
y.end()) ;
860 hi =
y[
y.size()-delta] ;
863 double sum_y(0), sum_ysq(0) ;
864 for (
unsigned int k=0 ; k<
y.size() ; k++) {
866 sum_ysq +=
y[k]*
y[k] ;
869 sum_ysq /=
y.size() ;
871 double rms =
sqrt(sum_ysq - (sum_y*sum_y)) ;
872 lo =
GetY()[i] - Z*rms ;
889 for(
Int_t i= 0; i <
n; i++) {
898 for(
Int_t i= 2; i <
n-2; i++) {
900 double rdy =
std::abs(yTest-other.
fY[i])/Yrange ;
904 cout <<
"RooCurve::isIdentical[" << std::setw(3) << i <<
"] Y tolerance exceeded (" << std::setprecision(5) << std::setw(10) << rdy <<
">" << tol <<
"),";
905 cout <<
" x,y=(" << std::right << std::setw(10) <<
fX[i] <<
"," << std::setw(10) <<
fY[i] <<
")\tref: y="
906 << std::setw(10) << other.
interpolate(
fX[i], 1.E-15) <<
". [Nearest point from ref: ";
908 std::cout <<
"j=" << j <<
"\tx,y=(" << std::setw(10) << other.
fX[j] <<
"," << std::setw(10) << other.
fY[j] <<
") ]" <<
"\trange=" << Yrange << std::endl;
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 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 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 * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
static Int_t numEvalErrors()
Return the number of logged evaluation errors since the last clearing.
static void printEvalErrors(std::ostream &os=std::cout, Int_t maxPerNode=10000000)
Print all outstanding logged evaluation error on the given ostream.
static void clearEvalErrorLog()
Clear the stack of evaluation error messages.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
A RooCurve is a one-dimensional graphical representation of a real-valued function.
void addPoints(const RooAbsFunc &func, double xlo, double xhi, Int_t minPoints, double prec, double resolution, WingMode wmode, Int_t numee=0, bool doEEVal=false, double eeVal=0.0, std::list< double > *samplingHint=nullptr)
Add points calculated with the specified function, over the range (xlo,xhi).
void printTitle(std::ostream &os) const override
Print the title of this curve.
void initialize()
Perform initialization that is common to all curves.
~RooCurve() override
Destructor.
double getFitRangeBinW() const override
Get the bin width associated with this plotable object.
void shiftCurveToZero(double prevYMax)
Find lowest point in curve and move all points in curve so that lowest point will go exactly through ...
void printName(std::ostream &os) const override
Print name of object.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Print the details of this curve.
double interpolate(double x, double tolerance=1e-10) const
Return linearly interpolated value of curve at xvalue.
void printClassName(std::ostream &os) const override
Print the class name of this curve.
void addRange(const RooAbsFunc &func, double x1, double x2, double y1, double y2, double minDy, double minDx, Int_t numee=0, bool doEEVal=false, double eeVal=0.0)
Fill the range (x1,x2) with points calculated using func(&x).
RooCurve()
Default constructor.
bool _showProgress
! Show progress indication when adding points
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...
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...
void calcBandInterval(const std::vector< RooCurve * > &variations, Int_t i, double Z, double &lo, double &hi, bool approxGauss) const
double getFitRangeNEvt() const override
Return the number of events associated with the plotable object, it is always 1 for curves.
void addPoint(double x, double y)
Add a point with the specified coordinates. Update our y-axis limits.
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 ...
Int_t findPoint(double value, double tolerance=1e-10) const
Find the nearest point to xvalue.
double average(double lo, double hi) const
Return average curve value in [xFirst,xLast] by integrating curve between points and dividing by xLas...
A RooHist is a graphical representation of binned data based on the TGraphAsymmErrors class.
static constexpr double infinity()
Return internal infinity representation.
Class RooPotable is a base class for objects that can be inserted into RooPlots and take advantage of...
void updateYAxisLimits(double y)
double getYAxisMin() const
void setYAxisLimits(double ymin, double ymax)
double getYAxisMax() const
void setYAxisLabel(const char *label)
Lightweight RooAbsFunction implementation that applies a constant scale factor to another RooAbsFunc.
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetBinLabel(Int_t bin, const char *label)
Set label for bin.
Bool_t IsAlphanumeric() const
const char * GetBinLabel(Int_t bin) const
Return label for bin.
virtual void Set(Int_t nbins, Double_t xmin, Double_t xmax)
Initialize axis with fix bins.
Double_t * GetEXlow() const override
Double_t * GetEYhigh() const override
Double_t * GetEXhigh() const override
Double_t * GetEYlow() const override
A TGraph is an object made of two arrays X and Y with npoints each.
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Double_t * fY
[fNpoints] array of Y points
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.
void SetName(const char *name="") override
Set graph name.
TAxis * GetXaxis() const
Get x axis of the graph.
Double_t * fX
[fNpoints] array of X points
void SetTitle(const char *title="") override
Change (i.e.
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
Get x and y values for point number i.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
const char * Data() const
TString & Append(const char *cs)
RVec< PromoteType< T > > abs(const RVec< T > &v)
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
Double_t Erfc(Double_t x)
Computes the complementary error function erfc(x).
const double xbins[xbins_n]
static uint64_t sum(uint64_t i)