43 using namespace HistFactory;
48 FlexibleInterpVar::FlexibleInterpVar()
50 _paramIter = _paramList.createIterator() ;
60 FlexibleInterpVar::FlexibleInterpVar(
const char*
name,
const char* title,
62 Double_t nominal, vector<double> low, vector<double> high) :
64 _paramList(
"paramList",
"List of paramficients",this),
65 _nominal(nominal), _low(low), _high(high), _interpBoundary(1.)
74 if (!dynamic_cast<RooAbsReal*>(param)) {
76 <<
" is not of type RooAbsReal" << endl ;
99 _paramList(
"paramList",
"List of paramficients",this),
121 if (!dynamic_cast<RooAbsReal*>(param)) {
123 <<
" is not of type RooAbsReal" << endl ;
147 double nominal, vector<double> low, vector<double> high,
150 _paramList(
"paramList",
"List of paramficients",this),
160 if (!dynamic_cast<RooAbsReal*>(param)) {
162 <<
" is not of type RooAbsReal" << endl ;
184 _paramList(
"paramList",
"List of coefficients",this),
224 <<
" is not in list" << endl ;
227 <<
" is now " << code << endl ;
250 coutW(
InputArguments) <<
"FlexibleInterpVar::setNominal : nominal is now " << newNominal << endl ;
264 <<
" is not in list" << endl ;
267 <<
" is now " << newLow << endl ;
268 _low.at(index) = newLow;
282 <<
" is not in list" << endl ;
285 <<
" is now " << newHigh << endl ;
286 _high.at(index) = newHigh;
312 double x0 = boundary;
321 unsigned int n =
_low.size();
322 assert(n ==
_high.size() );
326 for (
unsigned int j = 0; j <
n ; j++) {
336 double pow_up_log =
_high[j] <= 0.0 ? 0.0 : pow_up * logHi;
337 double pow_down_log =
_low[j] <= 0.0 ? 0.0 : -pow_down * logLo;
338 double pow_up_log2 =
_high[j] <= 0.0 ? 0.0 : pow_up_log * logHi;
339 double pow_down_log2=
_low[j] <= 0.0 ? 0.0 : -pow_down_log* logLo;
341 double S0 = (pow_up+pow_down)/2;
342 double A0 = (pow_up-pow_down)/2;
343 double S1 = (pow_up_log+pow_down_log)/2;
344 double A1 = (pow_up_log-pow_down_log)/2;
345 double S2 = (pow_up_log2+pow_down_log2)/2;
346 double A2 = (pow_up_log2-pow_down_log2)/2;
351 coeff[0] = 1./(8*x0) *( 15*A0 - 7*x0*S1 + x0*x0*A2);
352 coeff[1] = 1./(8*x0*x0) *(-24 + 24*S0 - 9*x0*A1 + x0*x0*S2);
353 coeff[2] = 1./(4*
pow(x0, 3))*( - 5*A0 + 5*x0*S1 - x0*x0*A2);
354 coeff[3] = 1./(4*
pow(x0, 4))*( 12 - 12*S0 + 7*x0*A1 - x0*x0*S2);
355 coeff[4] = 1./(8*
pow(x0, 5))*( + 3*A0 - 3*x0*S1 + x0*x0*A2);
356 coeff[5] = 1./(8*
pow(x0, 6))*( -8 + 8*S0 - 5*x0*A1 + x0*x0*S2);
369 const double * coefficients = &
_polCoeff.front() + 6*i;
371 double a = coefficients[0];
372 double b = coefficients[1];
373 double c = coefficients[2];
374 double d = coefficients[3];
375 double e = coefficients[4];
376 double f = coefficients[5];
380 double value = 1. + x * (a + x * ( b + x * ( c + x * ( d + x * ( e + x *
f ) ) ) ) );
431 }
else if(param->
getVal()<-1 ) {
445 }
else if(param->
getVal()<-1 ) {
462 else if (x <= -boundary)
474 <<
" with unknown interpolation code" << endl ;
488 Bool_t verbose, TString indent)
const 491 os << indent <<
"--- FlexibleInterpVar ---" << endl;
498 for (
int i=0;i<(int)
_low.size();i++) {
500 os << setw(36) << param->
GetName()<<
": "<<setw(7) <<
_low[i]<<
" "<<setw(7) <<
_high[i]
virtual const char * GetName() const
Returns name of object.
void setNominal(Double_t newNominal)
TIterator * createIterator(Bool_t dir=kIterForward) const
Int_t index(const RooAbsArg *arg) const
std::vector< double > _low
Double_t getVal(const RooArgSet *set=0) const
void setInterpCode(RooAbsReal ¶m, int code)
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Structure printing.
Iterator abstract base class.
void setValueDirty() const
Double_t evaluate() const
cached polynomial coefficients
double PolyInterpValue(int i, double x) const
double pow(double, double)
FlexibleInterpVar()
Default constructor.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Reimplementation of standard RooArgList::add()
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Structure printing.
RooAbsArg * at(Int_t idx) const
virtual void printFlexibleInterpVars(std::ostream &os) const
void setLow(RooAbsReal ¶m, Double_t newLow)
Bool_t _logInit
do not persist
static T Min()
Returns maximum representation for type T.
void printAllInterpCodes()
static unsigned int total
Namespace for the RooStats classes.
virtual ~FlexibleInterpVar()
Destructor.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
RooFIter fwdIterator() const
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
virtual TObject * Next()=0
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
std::vector< double > _polCoeff
flag used for chaching polynomial coefficients
void setAllInterpCodes(int code)
std::vector< double > _high
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
void setHigh(RooAbsReal ¶m, Double_t newHigh)
std::vector< int > _interpCode