77 _nominal(
"!nominal",
"nominal value", this, (
RooAbsReal&)nominal),
78 _lowSet(
"!lowSet",
"low-side variation",this),
79 _highSet(
"!highSet",
"high-side variation",this),
80 _paramSet(
"!paramSet",
"high-side variation",this),
81 _positiveDefinite(false)
86 coutE(InputArguments) <<
"PiecewiseInterpolation::ctor(" <<
GetName() <<
") ERROR: input lists should be of equal length" << endl ;
92 while((comp = inputIter1.
next())) {
94 coutE(InputArguments) <<
"PiecewiseInterpolation::ctor(" <<
GetName() <<
") ERROR: component " << comp->
GetName()
95 <<
" in first list is not of type RooAbsReal" << endl ;
106 while((comp = inputIter2.
next())) {
108 coutE(InputArguments) <<
"PiecewiseInterpolation::ctor(" <<
GetName() <<
") ERROR: component " << comp->
GetName()
109 <<
" in first list is not of type RooAbsReal" << endl ;
120 while((comp = inputIter3.
next())) {
122 coutE(InputArguments) <<
"PiecewiseInterpolation::ctor(" <<
GetName() <<
") ERROR: component " << comp->
GetName()
123 <<
" in first list is not of type RooAbsReal" << endl ;
146 _normIntMgr(other._normIntMgr, this),
147 _nominal(
"!nominal",this,other._nominal),
148 _lowSet(
"!lowSet",this,other._lowSet),
149 _highSet(
"!highSet",this,other._highSet),
150 _paramSet(
"!paramSet",this,other._paramSet),
151 _positiveDefinite(other._positiveDefinite),
152 _interpCode(other._interpCode)
189 if(param->getVal()>0)
190 sum += param->getVal()*(high->getVal() - nominal );
192 sum += param->getVal()*(nominal - low->getVal());
197 if(param->getVal()>=0)
198 sum *= pow(high->getVal()/nominal, +param->getVal());
200 sum *= pow(low->getVal()/nominal, -param->getVal());
205 double a = 0.5*(high->getVal()+low->getVal())-nominal;
206 double b = 0.5*(high->getVal()-low->getVal());
208 if(param->getVal()>1 ){
209 sum += (2*
a+
b)*(param->getVal()-1)+high->getVal()-nominal;
210 }
else if(param->getVal()<-1 ) {
211 sum += -1*(2*
a-
b)*(param->getVal()+1)+low->getVal()-nominal;
213 sum +=
a*pow(param->getVal(),2) +
b*param->getVal()+
c;
219 double a = 0.5*(high->getVal()+low->getVal())-nominal;
220 double b = 0.5*(high->getVal()-low->getVal());
222 if(param->getVal()>1 ){
223 sum += (2*
a+
b)*(param->getVal()-1)+high->getVal()-nominal;
224 }
else if(param->getVal()<-1 ) {
225 sum += -1*(2*
a-
b)*(param->getVal()+1)+low->getVal()-nominal;
227 sum +=
a*pow(param->getVal(),2) +
b*param->getVal()+
c;
238 double x = param->getVal();
240 sum +=
x*(high->getVal() - nominal );
242 sum +=
x*(nominal - low->getVal());
244 double eps_plus = high->getVal() - nominal;
245 double eps_minus = nominal - low->getVal();
246 double S = 0.5 * (eps_plus + eps_minus);
247 double A = 0.0625 * (eps_plus - eps_minus);
251 double val = nominal +
x * (S +
x * A * ( 15 +
x *
x * (-10 +
x *
x * 3 ) ) );
254 if (val < 0) val = 0;
264 double x = param->getVal();
266 if (
x > x0 ||
x < -x0)
269 sum +=
x*(high->getVal() - nominal );
271 sum +=
x*(nominal - low->getVal());
273 else if (nominal != 0)
275 double eps_plus = high->getVal() - nominal;
276 double eps_minus = nominal - low->getVal();
277 double S = (eps_plus + eps_minus)/2;
278 double A = (eps_plus - eps_minus)/2;
282 double b = 3*A/(2*x0);
284 double d = -A/(2*x0*x0*x0);
286 double val = nominal +
a*
x +
b*pow(
x, 2) + 0 +
d*pow(
x, 4);
287 if (val < 0) val = 0;
296 coutE(InputArguments) <<
"PiecewiseInterpolation::evaluate ERROR: " << param->GetName()
297 <<
" with unknown interpolation code" << icode << endl ;
310 cxcoutD(Tracing) <<
"PiecewiseInterpolation::evaluate - sum < 0, not forcing positive definite"<<endl;
323 for(
unsigned int j=0; j < nominal.size(); ++j) {
336 for (
unsigned int j=0; j < nominal.size(); ++j) {
338 sum[j] += param * (high[j] - nominal[j]);
340 sum[j] += param * (nominal[j] - low[j] );
346 for (
unsigned int j=0; j < nominal.size(); ++j) {
348 sum[j] *= pow(high[j]/ nominal[j], +param);
350 sum[j] *= pow(low[j] / nominal[j], -param);
356 for (
unsigned int j=0; j < nominal.size(); ++j) {
357 const double a = 0.5*(high[j]+low[j])-nominal[j];
358 const double b = 0.5*(high[j]-low[j]);
361 sum[j] += (2*
a+
b)*(param -1)+high[j]-nominal[j];
362 }
else if (param < -1.) {
363 sum[j] += -1*(2*
a-
b)*(param +1)+low[j]-nominal[j];
365 sum[j] +=
a*pow(param ,2) +
b*param +
c;
371 for (
unsigned int j=0; j < nominal.size(); ++j) {
372 const double a = 0.5*(high[j]+low[j])-nominal[j];
373 const double b = 0.5*(high[j]-low[j]);
376 sum[j] += (2*
a+
b)*(param -1)+high[j]-nominal[j];
377 }
else if (param < -1.) {
378 sum[j] += -1*(2*
a-
b)*(param +1)+low[j]-nominal[j];
380 sum[j] +=
a*pow(param ,2) +
b*param +
c;
386 for (
unsigned int j=0; j < nominal.size(); ++j) {
387 const double x = param;
389 sum[j] +=
x * (high[j] - nominal[j]);
390 }
else if (
x < -1.) {
391 sum[j] +=
x * (nominal[j] - low[j]);
393 const double eps_plus = high[j] - nominal[j];
394 const double eps_minus = nominal[j] - low[j];
395 const double S = 0.5 * (eps_plus + eps_minus);
396 const double A = 0.0625 * (eps_plus - eps_minus);
398 double val = nominal[j] +
x * (S +
x * A * ( 15. +
x *
x * (-10. +
x *
x * 3. ) ) );
400 if (val < 0.) val = 0.;
401 sum[j] += val - nominal[j];
406 for (
unsigned int j=0; j < nominal.size(); ++j) {
407 if (param > 1. || param < -1.) {
409 sum[j] += param * (high[j] - nominal[j]);
411 sum[j] += param * (nominal[j] - low[j] );
412 }
else if (nominal[j] != 0) {
413 const double eps_plus = high[j] - nominal[j];
414 const double eps_minus = nominal[j] - low[j];
415 const double S = (eps_plus + eps_minus)/2;
416 const double A = (eps_plus - eps_minus)/2;
420 const double b = 3*A/(2*1.);
422 const double d = -A/(2*1.*1.*1.);
424 double val = nominal[j] +
a * param +
b * pow(param, 2) +
d * pow(param, 4);
425 if (val < 0.) val = 0.;
427 sum[j] += val - nominal[j];
433 <<
" with unknown interpolation code" << icode << std::endl;
434 throw std::invalid_argument(
"PiecewiseInterpolation::evaluateSpan() got invalid interpolation code " + std::to_string(icode));
440 for(
unsigned int j=0; j < nominal.size(); ++j) {
458 cout <<
"Currently BinIntegrator only knows how to deal with 1-d "<<endl;
468 const RooArgSet* normSet,
const char* )
const
483 if (allVars.
getSize()==0)
return 0 ;
495 while( paramIterExtra.
next() ) {
498 cout <<
"can't factorize integral"<<endl;
505 analVars.
add(allVars) ;
512 Int_t sterileIdx(-1) ;
537 while(paramIter.
next() ) {
635 std::cout <<
"Error: Cache Element is NULL" << std::endl;
636 throw std::exception();
643 RooAbsReal *funcInt(0), *low(0), *high(0), *param(0) ;
650 value += funcInt->getVal() ;
654 if(i==0 || i>1) { cout <<
"problem, wrong number of nominal functions"<<endl; }
666 value += param->
getVal()*(high->getVal() - nominal );
668 value += param->
getVal()*(nominal - low->getVal());
747 coutE(InputArguments) <<
"PiecewiseInterpolation::setInterpCode ERROR: " << param.
GetName()
748 <<
" is not in list" << endl ;
751 coutW(InputArguments) <<
"PiecewiseInterpolation::setInterpCode : " << param.
GetName()
752 <<
" is now " << code << endl ;
823void PiecewiseInterpolation::printMetaArgs(ostream& os) const
830 Bool_t first(kTRUE) ;
832 RooAbsArg* arg1, *arg2 ;
833 if (_highSet.getSize()!=0) {
835 while((arg1=(RooAbsArg*)_lowIter->Next())) {
841 arg2=(RooAbsArg*)_highIter->Next() ;
842 os << arg1->GetName() << " * " << arg2->GetName() ;
847 while((arg1=(RooAbsArg*)_lowIter->Next())) {
853 os << arg1->GetName() ;
The PiecewiseInterpolation is a class that can morph distributions into each other,...
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &, Double_t, Double_t) const
WVE note: assumes nominal and alternates have identical structure, must add explicit check.
RooListProxy _lowSet
Low-side variation.
std::vector< int > _interpCode
Double_t analyticalIntegralWN(Int_t code, const RooArgSet *normSet, const char *rangeName=0) const
Implement analytical integrations by doing appropriate weighting from component integrals functions t...
RooListProxy _highSet
High-side variation.
void setInterpCode(RooAbsReal ¶m, int code, bool silent=false)
Bool_t _positiveDefinite
protect against negative and 0 bins.
Bool_t setBinIntegrator(RooArgSet &allVars)
void setAllInterpCodes(int code)
RooObjCacheManager _normIntMgr
! The integration cache manager
Int_t getAnalyticalIntegralWN(RooArgSet &allVars, RooArgSet &analVars, const RooArgSet *normSet, const char *rangeName=0) const
Advertise that all integrals can be handled internally.
double evaluate() const
Calculate and return current value of self.
void computeBatch(cudaStream_t *, double *output, size_t size, RooFit::Detail::DataMap const &) const
Interpolate between input distributions for all values of the observable in evalData.
RooListProxy _paramSet
interpolation parameters
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
virtual ~PiecewiseInterpolation()
Destructor.
RooArgList _ownedList
List of owned components.
RooRealProxy _nominal
The nominal value.
virtual Bool_t isBinnedDistribution(const RooArgSet &obs) const
WVE note: assumes nominal and alternates have identical structure, must add explicit check.
void printAllInterpCodes()
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
friend void RooRefArray::Streamer(TBuffer &)
RooAbsCacheElement is the abstract base class for objects to be stored in RooAbsCache cache manager o...
Int_t index(const RooAbsArg *arg) const
Returns index of given arg, or -1 if arg is not in the collection.
RooFIter fwdIterator() const
One-time forward iterator.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual Bool_t addOwned(RooAbsArg &var, Bool_t silent=kFALSE)
Add an argument and transfer the ownership to the collection.
Storage_t::size_type size() const
Bool_t setRealValue(const char *name, Double_t newVal=0, Bool_t verbose=kFALSE)
Set value of a RooAbsRealLValye stored in set with given name to newVal No error messages are printed...
RooAbsArg * first() const
const char * GetName() const
Returns name of object.
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...
RooAbsReal * createIntegral(const RooArgSet &iset, const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create an object that represents the integral of the function over one or more observables listed in ...
virtual std::list< Double_t > * binBoundaries(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
Retrieve bin boundaries if this distribution is binned in obs.
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
RooNumIntConfig * specialIntegratorConfig() const
Returns the specialized integrator configuration for this RooAbsReal.
virtual std::list< Double_t > * plotSamplingHint(RooAbsRealLValue &obs, Double_t xlo, Double_t xhi) const
Interface for returning an optional hint for initial sampling points when constructing a curve projec...
virtual Bool_t isBinnedDistribution(const RooArgSet &) const
Tests if the distribution is binned. Unless overridden by derived classes, this always returns false.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
T * getObj(const RooArgSet *nset, Int_t *sterileIndex=0, const TNamed *isetRangeName=0)
T * getObjByIndex(Int_t index) const
Retrieve payload object by slot index.
Int_t setObj(const RooArgSet *nset, T *obj, const TNamed *isetRangeName=0)
virtual Bool_t setLabel(const char *label, bool printError=true) override
Set value by specifying the name of the desired state.
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooAbsArg * next()
Return next element or nullptr if at end.
auto & at(RooAbsArg const *arg, RooAbsArg const *=nullptr)
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Reimplementation of standard RooArgList::add()
const RooArgSet & getConfigSection(const char *name) const
Retrieve configuration information specific to integrator with given name.
RooRealVar represents a variable that can be changed from the outside.
const T & arg() const
Return reference to object held in proxy.
Buffer base class used for serializing objects.
virtual Int_t ReadClassBuffer(const TClass *cl, void *pointer, const TClass *onfile_class=0)=0
virtual Int_t WriteClassBuffer(const TClass *cl, void *pointer)=0
virtual const char * GetName() const
Returns name of object.
static uint64_t sum(uint64_t i)