// RooAbsSelfCachedReal is an abstract base class for functions whose
// output is cached in terms of a histogram in all observables between
// getVal() and evaluate(). For certain p.d.f.s that are very
// expensive to calculate it may be beneficial to implement them as a
// RooAbsSelfCachedReal rather than a RooAbsReal. Class
// RooAbsSelfCachedReal is designed to have its interface identical to
// that of RooAbsReal, so any p.d.f can make use of its caching
// functionality by merely switching its base class.  Existing
// RooAbsReal objects can also be cached a posteriori with the
// RooCachedReal wrapper function that takes any RooAbsReal object as
// input.
// END_HTML
#include "Riostream.h" 
#include "RooFit.h"
#include "RooAbsSelfCachedReal.h" 
#include "RooAbsReal.h" 
#include "RooMsgService.h"
#include "RooDataHist.h"
#include "RooHistPdf.h"
using namespace std ;
ClassImp(RooAbsSelfCachedReal) 
RooAbsSelfCachedReal::RooAbsSelfCachedReal(const char *name, const char *title, Int_t ipOrder) :
  RooAbsCachedReal(name,title,ipOrder)
 { 
   
 } 
RooAbsSelfCachedReal::RooAbsSelfCachedReal(const RooAbsSelfCachedReal& other, const char* name) :  
   RooAbsCachedReal(other,name)
 { 
   
 } 
RooAbsSelfCachedReal::~RooAbsSelfCachedReal() 
{
  
}
void RooAbsSelfCachedReal::fillCacheObject(RooAbsCachedReal::FuncCacheElem& cache) const 
{
  
  RooDataHist& cacheHist = *cache.hist() ;
  
  RooArgSet* cloneSet = (RooArgSet*) RooArgSet(*this).snapshot(kTRUE) ;
  RooAbsSelfCachedReal* clone2 = (RooAbsSelfCachedReal*) cloneSet->find(GetName()) ;
  clone2->disableCache(kTRUE) ;
  clone2->attachDataSet(cacheHist) ;
  
  for (Int_t i=0 ; i<cacheHist.numEntries() ; i++) {
    const RooArgSet* obs = cacheHist.get(i) ;
    Double_t wgt = clone2->getVal(obs) ;
    cacheHist.set(wgt) ;
  }
  delete cloneSet ;
}
RooArgSet* RooAbsSelfCachedReal::actualObservables(const RooArgSet& nset) const 
{
  
  
  
  RooArgSet servers ;
  TIterator* siter = serverIterator() ;
  siter->Reset() ;
  RooAbsArg* server ;
  while((server=(RooAbsArg*)siter->Next())) {
    servers.add(*server) ;
  }
  
  
  return (RooArgSet*) servers.selectCommon(nset) ;
  
}
RooArgSet* RooAbsSelfCachedReal::actualParameters(const RooArgSet& nset) const 
{  
  
  
  
  
  RooArgSet *servers = new RooArgSet ;
  TIterator* siter = serverIterator() ;
  siter->Reset() ;
  RooAbsArg* server ;
  while((server=(RooAbsArg*)siter->Next())) {
    servers->add(*server) ;
  }
  
  
  servers->remove(nset,kTRUE,kTRUE) ;
  return servers ;
}
Last change: Wed Jun 25 08:31:46 2008
Last generated: 2008-06-25 08:31
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.