53 double argNominal, std::vector<double> lowVec, std::vector<double> highVec) :
55 _paramList(
"paramList",
"List of paramficients",this),
56 _nominal(argNominal), _low(lowVec), _high(highVec), _interpBoundary(1.)
60 for (
auto param : paramList) {
62 coutE(InputArguments) <<
"FlexibleInterpVar::ctor(" <<
GetName() <<
") ERROR: paramficient " << param->GetName()
63 <<
" is not of type RooAbsReal" << endl ;
70 coutE(InputArguments) <<
"FlexibleInterpVar::ctor(" <<
GetName() <<
") invalid input low/high vectors " << endl;
84 _paramList(
"paramList",
"List of paramficients",this),
85 _nominal(argNominal), _interpBoundary(1.)
87 for (
auto const *val : static_range_cast<RooAbsReal *>(lowList)){
88 _low.push_back(val->getVal()) ;
91 for (
auto const *val : static_range_cast<RooAbsReal *>(highList)) {
92 _high.push_back(val->getVal()) ;
97 for (
auto param : paramList) {
99 coutE(InputArguments) <<
"FlexibleInterpVar::ctor(" <<
GetName() <<
") ERROR: paramficient " << param->GetName()
100 <<
" is not of type RooAbsReal" << endl ;
107 coutE(InputArguments) <<
"FlexibleInterpVar::ctor(" <<
GetName() <<
") invalid input low/high lists " << endl;
122 double argNominal, vector<double> lowVec, vector<double> highVec,
125 _paramList(
"paramList",
"List of paramficients",this),
126 _nominal(argNominal), _low(lowVec), _high(highVec), _interpCode(code), _interpBoundary(1.)
130 for (
auto param : paramList) {
132 coutE(InputArguments) <<
"FlexibleInterpVar::ctor(" <<
GetName() <<
") ERROR: paramficient " << param->GetName()
133 <<
" is not of type RooAbsReal" << endl ;
141 coutE(InputArguments) <<
"FlexibleInterpVar::ctor(" <<
GetName() <<
") invalid input vectors " << endl;
155 _paramList(
"paramList",
"List of coefficients",this),
156 _nominal(0), _interpBoundary(1.)
166 _paramList(
"paramList",this,other._paramList),
167 _nominal(other._nominal), _low(other._low), _high(other._high), _interpCode(other._interpCode), _interpBoundary(other._interpBoundary)
191 coutE(InputArguments) <<
"FlexibleInterpVar::setInterpCode ERROR: " << param.
GetName()
192 <<
" is not in list" << std::endl;
194 coutI(InputArguments) <<
"FlexibleInterpVar::setInterpCode : " << param.
GetName()
195 <<
" is now " << code << std::endl;
218 coutW(InputArguments) <<
"FlexibleInterpVar::setNominal : nominal is now " << newNominal << endl ;
231 coutE(InputArguments) <<
"FlexibleInterpVar::setLow ERROR: " << param.
GetName()
232 <<
" is not in list" << endl ;
234 coutW(InputArguments) <<
"FlexibleInterpVar::setLow : " << param.
GetName()
235 <<
" is now " << newLow << endl ;
249 coutE(InputArguments) <<
"FlexibleInterpVar::setHigh ERROR: " << param.
GetName()
250 <<
" is not in list" << endl ;
252 coutW(InputArguments) <<
"FlexibleInterpVar::setHigh : " << param.
GetName()
253 <<
" is now " << newHigh << endl ;
280 double x0 = boundary;
289 unsigned int n =
_low.size();
290 assert(
n ==
_high.size() );
294 for (
unsigned int j = 0; j <
n ; j++) {
302 double logHi = std::log(
_high[j]) ;
303 double logLo = std::log(
_low[j] );
304 double pow_up_log =
_high[j] <= 0.0 ? 0.0 : pow_up * logHi;
305 double pow_down_log =
_low[j] <= 0.0 ? 0.0 : -pow_down * logLo;
306 double pow_up_log2 =
_high[j] <= 0.0 ? 0.0 : pow_up_log * logHi;
307 double pow_down_log2=
_low[j] <= 0.0 ? 0.0 : -pow_down_log* logLo;
309 double S0 = (pow_up+pow_down)/2;
310 double A0 = (pow_up-pow_down)/2;
311 double S1 = (pow_up_log+pow_down_log)/2;
312 double A1 = (pow_up_log-pow_down_log)/2;
313 double S2 = (pow_up_log2+pow_down_log2)/2;
314 double A2 = (pow_up_log2-pow_down_log2)/2;
319 coeff[0] = 1./(8*x0) *( 15*A0 - 7*x0*
S1 + x0*x0*A2);
320 coeff[1] = 1./(8*x0*x0) *(-24 + 24*
S0 - 9*x0*A1 + x0*x0*S2);
321 coeff[2] = 1./(4*pow(x0, 3))*( - 5*A0 + 5*x0*
S1 - x0*x0*A2);
322 coeff[3] = 1./(4*pow(x0, 4))*( 12 - 12*
S0 + 7*x0*A1 - x0*x0*S2);
323 coeff[4] = 1./(8*pow(x0, 5))*( + 3*A0 - 3*x0*
S1 + x0*x0*A2);
324 coeff[5] = 1./(8*pow(x0, 6))*( -8 + 8*
S0 - 5*x0*A1 + x0*x0*S2);
337 const double * coefficients = &
_polCoeff.front() + 6*i;
339 double a = coefficients[0];
340 double b = coefficients[1];
341 double c = coefficients[2];
342 double d = coefficients[3];
343 double e = coefficients[4];
344 double f = coefficients[5];
348 double value = 1. +
x * (
a +
x * (
b +
x * (
c +
x * (
d +
x * (
e +
x *
f ) ) ) ) );
389 }
else if(paramVal<-1 ) {
392 total +=
a*pow(paramVal,2) +
b*paramVal+
c;
403 }
else if(paramVal<-1 ) {
406 total +=
a*pow(paramVal,2) +
b*paramVal+
c;
420 else if (
x <= -boundary)
431 coutE(InputArguments) <<
"FlexibleInterpVar::evaluate ERROR: param " << i
432 <<
" with unknown interpolation code" << endl ;
474 os <<
indent <<
"--- FlexibleInterpVar ---" << endl;
480 for (
int i=0;i<(
int)
_low.size();i++) {
482 os << setw(36) << param.
GetName()<<
": "<<setw(7) <<
_low[i]<<
" "<<setw(7) <<
_high[i]
static void indent(ostringstream &buf, int indent_level)
static unsigned int total
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Int_t getSize() const
Return the number of elements in the collection.
Int_t index(const RooAbsArg *arg) const
Returns index of given arg, or -1 if arg is not in the collection.
Storage_t::size_type size() const
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Structure printing.
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.
bool add(const RooAbsArg &var, bool valueServer, bool shapeServer, bool silent)
Overloaded RooCollection_t::add() method insert object into set and registers object as server to own...
RooSpan< const double > at(RooAbsArg const *arg, RooAbsArg const *caller=nullptr)
std::vector< int > _interpCode
std::vector< double > _polCoeff
! cached polynomial coefficients
bool _logInit
! flag used for caching polynomial coefficients
std::vector< double > _high
void printMultiline(std::ostream &os, Int_t contents, bool verbose=false, TString indent="") const override
Interface for detailed printing of object.
void setInterpCode(RooAbsReal ¶m, int code)
void printAllInterpCodes()
const std::vector< double > & high() const
void setLow(RooAbsReal ¶m, double newLow)
const std::vector< double > & low() const
void setHigh(RooAbsReal ¶m, double newHigh)
void setAllInterpCodes(int code)
void processParam(std::size_t i, double paramVal, double &total) const
std::vector< double > _low
void computeBatch(cudaStream_t *, double *output, size_t size, RooFit::Detail::DataMap const &) const override
Base function for computing multiple values of a RooAbsReal.
double evaluate() const override
Calculate and return value of polynomial.
double PolyInterpValue(int i, double x) const
~FlexibleInterpVar() override
Destructor.
void setNominal(double newNominal)
virtual void printFlexibleInterpVars(std::ostream &os) const
FlexibleInterpVar()
Default constructor.
const RooListProxy & variables() const
Const getters.
const char * GetName() const override
Returns name of object.
Namespace for the RooStats classes.
static T Min()
Returns maximum representation for type T.