00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "RooFit.h"
00021
00022 #include "Riostream.h"
00023 #include "Riostream.h"
00024 #include <math.h>
00025 #include "TMath.h"
00026
00027 #include "RooAbsReal.h"
00028 #include "RooRealVar.h"
00029 #include "RooArgList.h"
00030 #include "RooMsgService.h"
00031 #include "TMath.h"
00032
00033 #include "RooStats/HistFactory/LinInterpVar.h"
00034
00035 ClassImp(RooStats::HistFactory::LinInterpVar)
00036
00037 using namespace RooStats;
00038 using namespace HistFactory;
00039
00040
00041 LinInterpVar::LinInterpVar()
00042 {
00043
00044 _paramIter = _paramList.createIterator() ;
00045 }
00046
00047
00048
00049 LinInterpVar::LinInterpVar(const char* name, const char* title,
00050 const RooArgList& paramList,
00051 double nominal, vector<double> low, vector<double> high) :
00052 RooAbsReal(name, title),
00053 _paramList("paramList","List of paramficients",this),
00054 _nominal(nominal), _low(low), _high(high)
00055 {
00056
00057 _paramIter = _paramList.createIterator() ;
00058
00059
00060 TIterator* paramIter = paramList.createIterator() ;
00061 RooAbsArg* param ;
00062 while((param = (RooAbsArg*)paramIter->Next())) {
00063 if (!dynamic_cast<RooAbsReal*>(param)) {
00064 coutE(InputArguments) << "LinInterpVar::ctor(" << GetName() << ") ERROR: paramficient " << param->GetName()
00065 << " is not of type RooAbsReal" << endl ;
00066 assert(0) ;
00067 }
00068 _paramList.add(*param) ;
00069 }
00070 delete paramIter ;
00071
00072 }
00073
00074
00075 LinInterpVar::LinInterpVar(const char* name, const char* title) :
00076 RooAbsReal(name, title),
00077 _paramList("paramList","List of coefficients",this)
00078 {
00079
00080
00081 _paramIter = _paramList.createIterator() ;
00082 }
00083
00084
00085 LinInterpVar::LinInterpVar(const LinInterpVar& other, const char* name) :
00086 RooAbsReal(other, name),
00087 _paramList("paramList",this,other._paramList),
00088 _nominal(other._nominal), _low(other._low), _high(other._high)
00089
00090 {
00091
00092 _paramIter = _paramList.createIterator() ;
00093
00094 }
00095
00096
00097
00098 LinInterpVar::~LinInterpVar()
00099 {
00100
00101 delete _paramIter ;
00102 }
00103
00104
00105
00106
00107
00108 Double_t LinInterpVar::evaluate() const
00109 {
00110
00111
00112 Double_t sum(_nominal) ;
00113 _paramIter->Reset() ;
00114
00115 RooAbsReal* param ;
00116
00117 int i=0;
00118
00119 while((param=(RooAbsReal*)_paramIter->Next())) {
00120
00121
00122 if(param->getVal()>0)
00123 sum += param->getVal()*(_high.at(i) - _nominal );
00124 else
00125 sum += param->getVal()*(_nominal - _low.at(i));
00126
00127 ++i;
00128 }
00129
00130 if(sum<=0) {
00131 sum=1E-9;
00132 }
00133
00134 return sum;
00135 }
00136
00137
00138