LinInterpVar.cxx

Go to the documentation of this file.
00001 // @(#)root/roostats:$Id:  cranmer $
00002 // Author: Kyle Cranmer, Akira Shibata
00003 /*************************************************************************
00004  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
00005  * All rights reserved.                                                  *
00006  *                                                                       *
00007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00009  *************************************************************************/
00010 
00011 //_________________________________________________
00012 /*
00013 BEGIN_HTML
00014 <p>
00015 </p>
00016 END_HTML
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   // Default constructor
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   // Constructor of flat polynomial function
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   // Copy constructor
00092   _paramIter = _paramList.createIterator() ;
00093   
00094 }
00095 
00096 
00097 //_____________________________________________________________________________
00098 LinInterpVar::~LinInterpVar() 
00099 {
00100   // Destructor
00101   delete _paramIter ;
00102 }
00103 
00104 
00105 
00106 
00107 //_____________________________________________________________________________
00108 Double_t LinInterpVar::evaluate() const 
00109 {
00110   // Calculate and return value of polynomial
00111 
00112   Double_t sum(_nominal) ;
00113   _paramIter->Reset() ;
00114 
00115   RooAbsReal* param ;
00116   //const RooArgSet* nset = _paramList.nset() ;
00117   int i=0;
00118 
00119   while((param=(RooAbsReal*)_paramIter->Next())) {
00120     //    param->Print("v");
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 

Generated on Tue Jul 5 14:52:33 2011 for ROOT_528-00b_version by  doxygen 1.5.1