55 Double_t argNominal, vector<double> lowVec, vector<double> highVec) :
57 _paramList(
"paramList",
"List of paramficients",this),
58 _nominal(argNominal), _low(lowVec), _high(highVec), _interpBoundary(1.)
62 for (
auto param : paramList) {
64 coutE(InputArguments) <<
"FlexibleInterpVar::ctor(" <<
GetName() <<
") ERROR: paramficient " << param->GetName()
65 <<
" is not of type RooAbsReal" << endl ;
72 coutE(InputArguments) <<
"FlexibleInterpVar::ctor(" <<
GetName() <<
") invalid input low/high vectors " << endl;
86 _paramList(
"paramList",
"List of paramficients",this),
87 _nominal(argNominal), _interpBoundary(1.)
104 for (
auto param : paramList) {
106 coutE(InputArguments) <<
"FlexibleInterpVar::ctor(" <<
GetName() <<
") ERROR: paramficient " << param->GetName()
107 <<
" is not of type RooAbsReal" << endl ;
114 coutE(InputArguments) <<
"FlexibleInterpVar::ctor(" <<
GetName() <<
") invalid input low/high lists " << endl;
129 double argNominal, vector<double> lowVec, vector<double> highVec,
132 _paramList(
"paramList",
"List of paramficients",this),
133 _nominal(argNominal), _low(lowVec), _high(highVec), _interpCode(code), _interpBoundary(1.)
137 for (
auto param : paramList) {
139 coutE(InputArguments) <<
"FlexibleInterpVar::ctor(" <<
GetName() <<
") ERROR: paramficient " << param->GetName()
140 <<
" is not of type RooAbsReal" << endl ;
148 coutE(InputArguments) <<
"FlexibleInterpVar::ctor(" <<
GetName() <<
") invalid input vectors " << endl;
162 _paramList(
"paramList",
"List of coefficients",this),
163 _nominal(0), _interpBoundary(1.)
173 _paramList(
"paramList",this,other._paramList),
174 _nominal(other._nominal), _low(other._low), _high(other._high), _interpCode(other._interpCode), _interpBoundary(other._interpBoundary)
198 coutE(InputArguments) <<
"FlexibleInterpVar::setInterpCode ERROR: " << param.
GetName()
199 <<
" is not in list" << endl ;
201 coutW(InputArguments) <<
"FlexibleInterpVar::setInterpCode : " << param.
GetName()
202 <<
" is now " << code << endl ;
225 coutW(InputArguments) <<
"FlexibleInterpVar::setNominal : nominal is now " << newNominal << endl ;
238 coutE(InputArguments) <<
"FlexibleInterpVar::setLow ERROR: " << param.
GetName()
239 <<
" is not in list" << endl ;
241 coutW(InputArguments) <<
"FlexibleInterpVar::setLow : " << param.
GetName()
242 <<
" is now " << newLow << endl ;
243 _low.at(index) = newLow;
256 coutE(InputArguments) <<
"FlexibleInterpVar::setHigh ERROR: " << param.
GetName()
257 <<
" is not in list" << endl ;
259 coutW(InputArguments) <<
"FlexibleInterpVar::setHigh : " << param.
GetName()
260 <<
" is now " << newHigh << endl ;
261 _high.at(index) = newHigh;
287 double x0 = boundary;
296 unsigned int n =
_low.size();
297 assert(
n ==
_high.size() );
301 for (
unsigned int j = 0; j <
n ; j++) {
309 double logHi = std::log(
_high[j]) ;
310 double logLo = std::log(
_low[j] );
311 double pow_up_log =
_high[j] <= 0.0 ? 0.0 : pow_up * logHi;
312 double pow_down_log =
_low[j] <= 0.0 ? 0.0 : -pow_down * logLo;
313 double pow_up_log2 =
_high[j] <= 0.0 ? 0.0 : pow_up_log * logHi;
314 double pow_down_log2=
_low[j] <= 0.0 ? 0.0 : -pow_down_log* logLo;
316 double S0 = (pow_up+pow_down)/2;
317 double A0 = (pow_up-pow_down)/2;
318 double S1 = (pow_up_log+pow_down_log)/2;
319 double A1 = (pow_up_log-pow_down_log)/2;
320 double S2 = (pow_up_log2+pow_down_log2)/2;
321 double A2 = (pow_up_log2-pow_down_log2)/2;
326 coeff[0] = 1./(8*x0) *( 15*A0 - 7*x0*
S1 + x0*x0*A2);
327 coeff[1] = 1./(8*x0*x0) *(-24 + 24*
S0 - 9*x0*A1 + x0*x0*S2);
328 coeff[2] = 1./(4*pow(x0, 3))*( - 5*A0 + 5*x0*
S1 - x0*x0*A2);
329 coeff[3] = 1./(4*pow(x0, 4))*( 12 - 12*
S0 + 7*x0*A1 - x0*x0*S2);
330 coeff[4] = 1./(8*pow(x0, 5))*( + 3*A0 - 3*x0*
S1 + x0*x0*A2);
331 coeff[5] = 1./(8*pow(x0, 6))*( -8 + 8*
S0 - 5*x0*A1 + x0*x0*S2);
344 const double * coefficients = &
_polCoeff.front() + 6*i;
346 double a = coefficients[0];
347 double b = coefficients[1];
348 double c = coefficients[2];
349 double d = coefficients[3];
350 double e = coefficients[4];
351 double f = coefficients[5];
355 double value = 1. +
x * (
a +
x * (
b +
x * (
c +
x * (
d +
x * (
e +
x *
f ) ) ) ) );
376 auto param =
static_cast<const RooAbsReal*
>(arg);
384 if(param->getVal()>0)
392 if(param->getVal()>=0)
403 if(param->getVal()>1 ){
405 }
else if(param->getVal()<-1 ) {
408 total +=
a*pow(param->getVal(),2) +
b*param->getVal()+
c;
417 if(param->getVal()>1 ){
419 }
else if(param->getVal()<-1 ) {
422 total +=
a*pow(param->getVal(),2) +
b*param->getVal()+
c;
429 double x = param->getVal();
436 else if (
x <= -boundary)
447 coutE(InputArguments) <<
"FlexibleInterpVar::evaluate ERROR: " << param->GetName()
448 <<
" with unknown interpolation code" << endl ;
465 os <<
indent <<
"--- FlexibleInterpVar ---" << endl;
471 for (
int i=0;i<(
int)
_low.size();i++) {
473 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
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
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.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Structure printing.
Double_t getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
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.
A one-time forward iterator working on RooLinkedList or RooAbsCollection.
RooAbsArg * next()
Return next element or nullptr if at end.
RooListProxy is the concrete proxy for RooArgList objects.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE) override
Reimplementation of standard RooArgList::add()
std::vector< int > _interpCode
std::vector< double > _polCoeff
! cached polynomial coefficients
Double_t evaluate() const
Calculate and return value of polynomial.
std::vector< double > _high
void setInterpCode(RooAbsReal ¶m, int code)
void printAllInterpCodes()
void setNominal(Double_t newNominal)
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Structure printing.
const std::vector< double > & high() const
void setLow(RooAbsReal ¶m, Double_t newLow)
virtual ~FlexibleInterpVar()
Destructor.
const std::vector< double > & low() const
void setAllInterpCodes(int code)
std::vector< double > _low
Bool_t _logInit
! flag used for caching polynomial coefficients
double PolyInterpValue(int i, double x) const
virtual void printFlexibleInterpVars(std::ostream &os) const
FlexibleInterpVar()
Default constructor.
const RooListProxy & variables() const
Const getters.
void setHigh(RooAbsReal ¶m, Double_t newHigh)
virtual const char * GetName() const
Returns name of object.
Namespace for the RooStats classes.
static T Min()
Returns maximum representation for type T.