88 _showProgress(showProg)
97 if(0 != strlen(
f.getUnit()) || 0 != strlen(
x.getUnit())) {
99 if(0 != strlen(
f.getUnit())) {
103 if(0 != strlen(
x.getUnit())) {
114 funcPtr=
f.bindVars(
x,normVars,
kTRUE);
117 if(scaleFactor != 1) {
121 assert(0 != funcPtr);
127 list<Double_t>* hint =
f.plotSamplingHint(
x,xlo,xhi) ;
128 addPoints(*funcPtr,xlo,xhi,
xbins+1,prec,resolution,wmode,nEvalError,doEEVal,eeVal,hint);
138 int nBinsX =
x.numBins();
139 for(
int i=0; i<nBinsX; ++i){
140 double xval =
x.getBinning().binCenter(i);
148 if(rawPtr)
delete rawPtr;
152 for (
int i=0 ; i<
GetN() ; i++) {
175 addPoints(func,xlo,xhi,minPoints+1,prec,resolution,wmode,nEvalError,doEEVal,eeVal);
180 for (
int i=0 ; i<
GetN() ; i++) {
209 deque<Double_t> pointList ;
214 for (i1=0 ; i1<n1 ; i1++) {
215 c1.GetPoint(i1,
x,
y) ;
216 pointList.push_back(
x) ;
221 for (i2=0 ; i2<n2 ; i2++) {
222 c2.GetPoint(i2,
x,
y) ;
223 pointList.push_back(
x) ;
227 sort(pointList.begin(),pointList.end()) ;
231 for (
auto point : pointList) {
233 if ((point-last)>1
e-10) {
235 addPoint(point,scale1*
c1.interpolate(point)+scale2*
c2.interpolate(point)) ;
278 for (i=1 ; i<
GetN()-1 ; i++) {
281 if (
y<minVal) minVal=
y ;
282 if (
y>maxVal) maxVal=
y ;
286 for (i=1 ; i<
GetN()-1 ; i++) {
316 if(minPoints <= 0 || xhi <= xlo) {
326 minPoints = samplingHint->size() ;
329 Double_t dx= (xhi-xlo)/(minPoints-1.);
330 std::vector<double> yval(minPoints);
334 std::vector<double> xval;
336 for(
int step= 0; step < minPoints; step++) {
337 xval.push_back(xlo + step*dx) ;
340 std::copy(samplingHint->begin(), samplingHint->end(), std::back_inserter(xval));
343 for (
unsigned int step=0; step < xval.size(); ++step) {
345 if (step ==
static_cast<unsigned int>(minPoints-1))
348 yval[step]= func(&xx);
366 const double ymax = *std::max_element(yval.begin(), yval.end());
367 const double ymin = *std::min_element(yval.begin(), yval.end());
371 Double_t minDx= resolution*(xhi-xlo);
386 auto iter2 = xval.begin() ;
392 if (iter2==xval.end()) {
400 addRange(func,
x1,
x2,yval[step-1],yval[step],prec*yrangeEst,minDx,numee,doEEVal,eeVal);
409 addPoint(xhi+dx,yval[minPoints-1]) ;
453 if((xmid -
x1 >= minDx) &&
fabs(dy)>0 &&
fabs(dy) >= minDy) {
455 addRange(func,
x1,xmid,
y1,ymid,minDy,minDx,numee,doEEVal,eeVal);
456 addRange(func,xmid,
x2,ymid,
y2,minDy,minDx,numee,doEEVal,eeVal);
540 os <<
indent <<
"--- RooCurve ---" << endl ;
542 os <<
indent <<
" Contains " <<
n <<
" points" << endl;
543 os <<
indent <<
" Graph points:" << endl;
544 for(
Int_t i= 0; i <
n; i++) {
545 os <<
indent << setw(3) << i <<
") x = " <<
fX[i] <<
" , y = " <<
fY[i] << endl;
570 for (i=0 ; i<
np ; i++) {
576 if (x<xstart || x>xstop) continue ;
588 Double_t pull = (
y>avg) ? ((
y-avg)/eyl) : ((
y-avg)/eyh) ;
595 return chisq / (nbin-nFitParam) ;
608 <<
") invalid range (" << xFirst <<
"," << xLast <<
")" << endl ;
619 Double_t xFirstPt,yFirstPt,xLastPt,yLastPt ;
620 GetPoint(ifirst,xFirstPt,yFirstPt) ;
626 if (ilast-ifirst==1 &&(xFirstPt-xFirst)<-1*tolerance && (xLastPt-xLast)>tolerance) {
627 return 0.5*(yFirst+yLast) ;
632 if ((xFirstPt-xFirst)<-1*tolerance) {
639 if ((xLastPt-xLast)>tolerance) {
647 sum += (xFirstPt-xFirst)*(yFirst+yFirstPt)/2 ;
651 for (i=ifirst ; i<ilast ; i++) {
658 sum += (xLast-xLastPt)*(yLastPt+yLast)/2 ;
659 return sum/(xLast-xFirst) ;
670 Double_t delta(std::numeric_limits<double>::max()),
x,
y ;
673 for (i=0 ; i<
n ; i++) {
675 if (
fabs(xvalue-
x)<delta) {
676 delta =
fabs(xvalue-
x) ;
681 return (delta<tolerance)?ibest:-1 ;
701 if (
fabs(xbest-xvalue)<tolerance) {
713 if (xother==xbest)
return ybest ;
714 retVal = ybest + (yother-ybest)*(xvalue-xbest)/(xother-xbest) ;
722 if (xother==xbest)
return ybest ;
723 retVal = yother + (ybest-yother)*(xvalue-xother)/(xbest-xother) ;
745 vector<double> bandLo(
GetN()) ;
746 vector<double> bandHi(
GetN()) ;
747 for (
int i=0 ; i<
GetN() ; i++) {
751 for (
int i=0 ; i<
GetN() ; i++) {
754 for (
int i=
GetN()-1 ; i>=0 ; i--) {
785 vector<double> bandLo(
GetN()) ;
786 vector<double> bandHi(
GetN()) ;
787 for (
int i=0 ; i<
GetN() ; i++) {
791 for (
int i=0 ; i<
GetN() ; i++) {
794 for (
int i=
GetN()-1 ; i>=0 ; i--) {
818 vector<double> y_plus(plusVar.size()), y_minus(minusVar.size()) ;
820 for (vector<RooCurve*>::const_iterator iter=plusVar.begin() ; iter!=plusVar.end() ; ++iter) {
821 y_plus[j++] = (*iter)->interpolate(
GetX()[i]) ;
824 for (vector<RooCurve*>::const_iterator iter=minusVar.begin() ; iter!=minusVar.end() ; ++iter) {
825 y_minus[j++] = (*iter)->interpolate(
GetX()[i]) ;
832 for (j=0 ; j<
n ; j++) {
833 F[j] = (y_plus[j]-y_minus[j])/2 ;
849 vector<double>
y(variations.size()) ;
851 for (vector<RooCurve*>::const_iterator iter=variations.begin() ; iter!=variations.end() ; ++iter) {
852 y[j++] = (*iter)->interpolate(
GetX()[i]) ;
859 sort(
y.begin(),
y.end()) ;
861 hi =
y[
y.size()-delta] ;
865 for (
unsigned int k=0 ; k<
y.size() ; k++) {
867 sum_ysq +=
y[k]*
y[k] ;
870 sum_ysq /=
y.size() ;
873 lo =
GetY()[i] - Z*rms ;
890 for(
Int_t i= 0; i <
n; i++) {
899 for(
Int_t i= 2; i <
n-2; i++) {
905 cout <<
"RooCurve::isIdentical[" << std::setw(3) << i <<
"] Y tolerance exceeded (" << std::setprecision(5) << std::setw(10) << rdy <<
">" << tol <<
"),";
906 cout <<
" x,y=(" << std::right << std::setw(10) <<
fX[i] <<
"," << std::setw(10) <<
fY[i] <<
")\tref: y="
907 << std::setw(10) << other.
interpolate(
fX[i], 1.E-15) <<
". [Nearest point from ref: ";
909 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 printTitle(std::ostream &os) const override
Print the title of this curve.
void addPoints(const RooAbsFunc &func, Double_t xlo, Double_t xhi, Int_t minPoints, Double_t prec, Double_t resolution, WingMode wmode, Int_t numee=0, Bool_t doEEVal=kFALSE, Double_t eeVal=0., std::list< Double_t > *samplingHint=0)
Add points calculated with the specified function, over the range (xlo,xhi).
void initialize()
Perform initialization that is common to all curves.
void addPoint(Double_t x, Double_t y)
Add a point with the specified coordinates. Update our y-axis limits.
~RooCurve() override
Destructor.
Double_t getFitRangeNEvt() const override
Return the number of events associated with the plotable object, it is always 1 for curves.
Double_t chiSquare(const RooHist &hist, int nFitParam) const
Calculate the chi^2/NDOF of this curve with respect to the histogram 'hist' accounting nFitParam floa...
Double_t getFitRangeBinW() const override
Get the bin width associated with this plotable object.
Double_t average(Double_t lo, Double_t hi) const
Return average curve value in [xFirst,xLast] by integrating curve between points and dividing by xLas...
void addRange(const RooAbsFunc &func, Double_t x1, Double_t x2, Double_t y1, Double_t y2, Double_t minDy, Double_t minDx, Int_t numee=0, Bool_t doEEVal=kFALSE, Double_t eeVal=0.)
Fill the range (x1,x2) with points calculated using func(&x).
Bool_t _showProgress
! Show progress indication when adding points
void printName(std::ostream &os) const override
Print name of object.
void shiftCurveToZero(Double_t prevYMax)
Find lowest point in curve and move all points in curve so that lowest point will go exactly through ...
Bool_t isIdentical(const RooCurve &other, Double_t tol=1e-6, bool verbose=true) const
Return true if curve is identical to other curve allowing for given absolute tolerance on each point ...
void printClassName(std::ostream &os) const override
Print the class name of this curve.
RooCurve * makeErrorBand(const std::vector< RooCurve * > &variations, Double_t Z=1) const
Construct filled RooCurve represented error band that captures alpha% of the variations of the curves...
RooCurve()
Default constructor.
TClass * IsA() const override
Double_t interpolate(Double_t x, Double_t tolerance=1e-10) const
Return linearly interpolated value of curve at xvalue.
Int_t findPoint(Double_t value, Double_t tolerance=1e-10) const
Find the nearest point to xvalue.
void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const override
Print the details of this curve.
void calcBandInterval(const std::vector< RooCurve * > &variations, Int_t i, Double_t Z, Double_t &lo, Double_t &hi, Bool_t approxGauss) const
A RooHist is a graphical representation of binned data based on the TGraphAsymmErrors class.
static Double_t infinity()
Return internal infinity representation.
Class RooPotable is a base class for objects that can be inserted into RooPlots and take advantage of...
Double_t getYAxisMin() const
void updateYAxisLimits(Double_t y)
Double_t getYAxisMax() const
void setYAxisLimits(Double_t ymin, Double_t ymax)
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.
const char * Data() const
TString & Append(const char *cs)
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
Double_t Erfc(Double_t x)
Compute the complementary error function erfc(x).
const double xbins[xbins_n]
static uint64_t sum(uint64_t i)