RooCachedReal.cxx

Go to the documentation of this file.
00001  /***************************************************************************** 
00002   * Project: RooFit                                                           * 
00003   *                                                                           * 
00004   * Copyright (c) 2000-2005, Regents of the University of California          * 
00005   *                          and Stanford University. All rights reserved.    * 
00006   *                                                                           * 
00007   * Redistribution and use in source and binary forms,                        * 
00008   * with or without modification, are permitted according to the terms        * 
00009   * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             * 
00010   *****************************************************************************/ 
00011 
00012 //////////////////////////////////////////////////////////////////////////////
00013 // 
00014 // BEGIN_HTML
00015 // RooCachedReal is an implementation of RooAbsCachedReal that can cache
00016 // any external RooAbsReal input function provided in the constructor. 
00017 // END_HTML
00018 //
00019 
00020 #include "Riostream.h" 
00021 
00022 #include "RooAbsPdf.h"
00023 #include "RooCachedReal.h" 
00024 #include "RooAbsReal.h" 
00025 #include "RooMsgService.h"
00026 #include "RooDataHist.h"
00027 #include "RooHistPdf.h"
00028 
00029 ClassImp(RooCachedReal) 
00030   ;
00031 
00032 
00033 //_____________________________________________________________________________
00034 RooCachedReal::RooCachedReal(const char *name, const char *title, RooAbsReal& _func) :
00035    RooAbsCachedReal(name,title), 
00036    func("func","func",this,_func),
00037    _useCdfBoundaries(kFALSE)
00038  { 
00039    // Constructor taking name, title and function to be cached. To control
00040    // granularity of the binning of the cache histogram set the desired properties
00041    // in the binning named "cache" in the observables of the function
00042    
00043    // Choose same expensive object cache as input function
00044    setExpensiveObjectCache(_func.expensiveObjectCache()) ;
00045  } 
00046 
00047 
00048 
00049 
00050 //_____________________________________________________________________________
00051 RooCachedReal::RooCachedReal(const char *name, const char *title, RooAbsReal& _func, const RooArgSet& cacheObs) :
00052    RooAbsCachedReal(name,title), 
00053    func("func","func",this,_func),
00054    _cacheObs("cacheObs","cacheObs",this,kFALSE,kFALSE)  
00055  { 
00056    // Constructor taking name, title and function to be cached and
00057    // fixed choice of variable to cache. To control granularity of the
00058    // binning of the cache histogram set the desired properties in the
00059    // binning named "cache" in the observables of the function.
00060    // If the fixed set of cache observables does not match the observables
00061    // defined in the use context of the p.d.f the cache is still filled
00062    // completely. Ee.g. when it is specified to cache x and p and only x 
00063    // is a observable in the given use context the cache histogram will
00064    // store sampled values for all values of observable x and parameter p.
00065    // In such a mode of operation the cache will also not be recalculated
00066    // if the observable p changes
00067 
00068    _cacheObs.add(cacheObs) ;
00069 
00070    // Choose same expensive object cache as input function
00071    setExpensiveObjectCache(_func.expensiveObjectCache()) ;
00072  } 
00073 
00074 
00075 
00076 
00077 //_____________________________________________________________________________
00078 RooCachedReal::RooCachedReal(const RooCachedReal& other, const char* name) :  
00079    RooAbsCachedReal(other,name), 
00080    func("func",this,other.func),
00081    _cacheObs("cacheObs",this,other._cacheObs),
00082    _useCdfBoundaries(other._useCdfBoundaries)
00083  { 
00084    // Copy constructor
00085  } 
00086 
00087 
00088 
00089 //_____________________________________________________________________________
00090 RooCachedReal::~RooCachedReal() 
00091 {
00092   // Destructor
00093 }
00094 
00095 
00096 
00097 //_____________________________________________________________________________
00098 void RooCachedReal::fillCacheObject(RooAbsCachedReal::FuncCacheElem& cache) const 
00099 {
00100   // Update contents of cache histogram by resampling the input function
00101 
00102   if (cache.hist()->get()->getSize()>1) {
00103     coutP(Eval) << "RooCachedReal::fillCacheObject(" << GetName() << ") filling multi-dimensional cache (" << cache.hist()->numEntries() << " points)" ;
00104   }
00105 
00106   func.arg().fillDataHist(cache.hist(),0,1.0,kFALSE,kTRUE) ;
00107   cache.func()->setCdfBoundaries(_useCdfBoundaries) ;
00108 
00109   if (cache.hist()->get()->getSize()>1) {
00110     ccoutP(Eval) << endl ;
00111   }
00112 
00113 }
00114 
00115 
00116 
00117 //_____________________________________________________________________________
00118 RooArgSet* RooCachedReal::actualObservables(const RooArgSet& nset) const 
00119 { 
00120   // If this pdf is operated with a fixed set of observables, return
00121   // the subset of the fixed observables that are actual dependents
00122   // of the external input p.d.f. If this p.d.f is operated without
00123   // a fixed set of cache observables, return the actual observables
00124   // of the external input p.d.f given the choice of observables defined
00125   // in nset
00126 
00127   if (_cacheObs.getSize()>0) {
00128     return func.arg().getObservables(_cacheObs) ;
00129   } 
00130 
00131   return func.arg().getObservables(nset) ; 
00132 }
00133 
00134 
00135 
00136 //_____________________________________________________________________________
00137 RooArgSet* RooCachedReal::actualParameters(const RooArgSet& nset) const 
00138 { 
00139   // If this p.d.f is operated with a fixed set of observables, return
00140   // all variables of the external input p.d.f that are not one of
00141   // the cache observables. If this p.d.f is operated in automatic mode,
00142   // return the parameters of the external input p.d.f
00143 
00144   if (_cacheObs.getSize()>0) {
00145     return func.arg().getParameters(_cacheObs) ;
00146   } 
00147   return func.arg().getParameters(nset) ; 
00148 }
00149 
00150 
00151 
00152 
00153 

Generated on Tue Jul 5 15:06:06 2011 for ROOT_528-00b_version by  doxygen 1.5.1