#include "RooFit.h"
#include "Riostream.h"
#include "Riostream.h"
#include <math.h>
#include "TMath.h"
#include "RooAbsReal.h"
#include "RooRealVar.h"
#include "RooArgList.h"
#include "RooMsgService.h"
#include "TMath.h"
#include "RooStats/HistFactory/LinInterpVar.h"
using namespace std;
ClassImp(RooStats::HistFactory::LinInterpVar)
using namespace RooStats;
using namespace HistFactory;
LinInterpVar::LinInterpVar()
{
_paramIter = _paramList.createIterator() ;
_nominal = 0 ;
}
LinInterpVar::LinInterpVar(const char* name, const char* title,
const RooArgList& paramList,
double nominal, vector<double> low, vector<double> high) :
RooAbsReal(name, title),
_paramList("paramList","List of paramficients",this),
_nominal(nominal), _low(low), _high(high)
{
_paramIter = _paramList.createIterator() ;
TIterator* paramIter = paramList.createIterator() ;
RooAbsArg* param ;
while((param = (RooAbsArg*)paramIter->Next())) {
if (!dynamic_cast<RooAbsReal*>(param)) {
coutE(InputArguments) << "LinInterpVar::ctor(" << GetName() << ") ERROR: paramficient " << param->GetName()
<< " is not of type RooAbsReal" << endl ;
assert(0) ;
}
_paramList.add(*param) ;
}
delete paramIter ;
}
LinInterpVar::LinInterpVar(const char* name, const char* title) :
RooAbsReal(name, title),
_paramList("paramList","List of coefficients",this)
{
_paramIter = _paramList.createIterator() ;
}
LinInterpVar::LinInterpVar(const LinInterpVar& other, const char* name) :
RooAbsReal(other, name),
_paramList("paramList",this,other._paramList),
_nominal(other._nominal), _low(other._low), _high(other._high)
{
_paramIter = _paramList.createIterator() ;
}
LinInterpVar::~LinInterpVar()
{
delete _paramIter ;
}
Double_t LinInterpVar::evaluate() const
{
Double_t sum(_nominal) ;
_paramIter->Reset() ;
RooAbsReal* param ;
int i=0;
while((param=(RooAbsReal*)_paramIter->Next())) {
if(param->getVal()>0)
sum += param->getVal()*(_high.at(i) - _nominal );
else
sum += param->getVal()*(_nominal - _low.at(i));
++i;
}
if(sum<=0) {
sum=1E-9;
}
return sum;
}