76 :
RooXYChi2Var{
name, title, func, xydata, nullptr, integrate, makeRooAbsTestStatisticCfg()}
100 :
RooXYChi2Var{
name, title, func, xydata, &yvar, integrate, makeRooAbsTestStatisticCfg()}
110 _integrate(integrate),
111 _intConfig(*defaultIntegratorConfig())
113 bool isPdf =
dynamic_cast<RooAbsPdf const *
>(&func) !=
nullptr;
116 auto &extPdf =
static_cast<RooAbsPdf const &
>(func);
117 if (!extPdf.canBeExtended()) {
118 throw std::runtime_error(
119 Form(
"RooXYChi2Var::RooXYChi2Var(%s) ERROR: Input p.d.f. must be extendible",
GetName()));
136 _extended(other._extended),
137 _integrate(other._integrate),
138 _yvar(other._yvar ? static_cast<
RooRealVar *>(_dataClone->get()->find(other._yvar->GetName())) : nullptr),
139 _intConfig(other._intConfig)
158 if (
auto* var =
dynamic_cast<RooRealVar*
>(arg)) {
171#ifdef R__HAS_MATHMORE
189 for(
auto *
x : static_range_cast<RooRealVar*>(
_rrvArgs)) {
190 _binList.push_back(&
x->getBinning(
"bin",
false,
true)) ;
208 for(
auto * var : static_range_cast<RooRealVar*>(
_rrvArgs)) {
210 if (var->hasAsymError()) {
213 double cxval = var->getVal() ;
214 double xerrLo = -var->getAsymErrorLo() ;
215 double xerrHi = var->getAsymErrorHi() ;
216 double xerr = (xerrLo+xerrHi)/2 ;
219 var->setVal(cxval - xerr/100) ;
220 double fxmin =
fy() ;
223 var->setVal(cxval + xerr/100) ;
224 double fxmax =
fy() ;
227 double slope = (fxmax-fxmin)/(2*xerr/100.) ;
232 if ((ydata>cxval && fxmax>fxmin) || (ydata<=cxval && fxmax<=fxmin)) {
234 ret += pow(xerrHi*slope,2) ;
237 ret += pow(xerrLo*slope,2) ;
240 }
else if (var->hasError()) {
243 double cxval = var->getVal() ;
244 double xerr = var->getError() ;
247 var->setVal(cxval - xerr/100) ;
248 double fxmin =
fy() ;
251 var->setVal(cxval + xerr/100) ;
252 double fxmax =
fy() ;
255 double slope = (fxmax-fxmin)/(2*xerr/100.) ;
263 ret += pow(xerr*slope,2) ;
294 double xmin =
x->getVal() +
x->getErrorLo() ;
295 double xmax =
x->getVal() +
x->getErrorHi() ;
302 return ret / volume ;
325 for (
auto i=firstEvent ; i<lastEvent ; i+=stepSize) {
331 double yfunc =
fy() ;
342 ydata = xydata->
weight() ;
347 double eExt = yfunc-ydata ;
350 double eInt = (eExt>0) ? eyhi : eylo ;
359 coutE(Eval) <<
"RooXYChi2Var::RooXYChi2Var(" <<
GetName() <<
") INFINITY ERROR: data point " << i
360 <<
" has zero error, but function is not zero (f=" << yfunc <<
")" << std::endl ;
365 double term = eExt*eExt/(eInt*eInt+ eIntX2);
366 double y = term - carry;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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 result
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Common abstract base class for objects that represent a value and a "shape" in RooFit.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
const_iterator begin() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
Abstract base class for binned and unbinned datasets.
virtual const RooArgSet * get() const
Abstract base class for test statistics objects that evaluate a function or PDF at each point of a gi...
RooAbsReal * _funcClone
Pointer to internal clone of input function.
RooArgSet * _funcObsSet
List of observables in the pdf expression.
RooAbsData * _dataClone
Pointer to internal clone if input data.
Abstract interface for all probability density functions.
virtual double expectedEvents(const RooArgSet *nset) const
Return expected number of events to be used in calculation of extended likelihood.
Abstract base class for objects that represent a real value and implements functionality common to al...
RooFit::OwningPtr< RooAbsReal > createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
Create an object that represents the integral of the function over one or more observables listed in ...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
double _evalCarry
! carry of Kahan sum in evaluatePartition
GOFOpMode operMode() const
RooArgSet is a container object that can hold multiple RooAbsArg objects.
bool setLabel(const char *label, bool printError=true) override
Set value by specifying the name of the desired state.
Container class to hold unbinned data.
const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
void weightError(double &lo, double &hi, ErrorType etype=SumW2) const override
Return the asymmetric errors on the current weight.
double weight() const override
Return event weight of current event.
void setEpsRel(double newEpsRel)
Set relative convergence criteria (convergence if std::abs(Err)/abs(Int)<newEpsRel)
void setEpsAbs(double newEpsAbs)
Set absolute convergence criteria (convergence if std::abs(Err)<newEpsAbs)
Variable that can be changed from the outside.
double getErrorLo() const
double getErrorHi() const
RooXYChi2Var implements a simple chi^2 calculation from an unbinned dataset with values x,...
double fy() const
Return function value requested bu present configuration.
std::unique_ptr< RooAbsReal > _funcInt
! Function integral
std::list< RooAbsBinning * > _binList
! Bin ranges
bool _extended
Is the input function and extended p.d.f.
void initIntegrator()
Initialize bin content integrator.
RooRealVar * _yvar
Y variable if so designated.
RooXYChi2Var(const char *name, const char *title, RooAbsReal &func, RooDataSet &data, bool integrate=false)
RooXYChi2Var constructor with function and X-Y values dataset.
RooArgSet requiredExtraObservables() const override
double evaluatePartition(std::size_t firstEvent, std::size_t lastEvent, std::size_t stepSize) const override
Calculate chi^2 in partition from firstEvent to lastEvent using given stepSize.
bool _integrate
Is integration over the bin volume requested.
RooArgSet _rrvArgs
Set of real-valued observables.
double xErrorContribution(double ydata) const
Calculate contribution to internal error due to error on 'x' coordinates at point i.
void initialize()
Common constructor initialization.
RooNumIntConfig _intConfig
Numeric integrator configuration for integration of function over bin.
const char * GetName() const override
Returns name of object.