NC::Fitter::FuncCache Class Reference

#include <NCFitter.h>

Inheritance diagram for NC::Fitter::FuncCache:
NC::Fitter::ICallableND

List of all members.

Public Member Functions

 FuncCache (ICallableND *g)
virtual double EvalAtEx (const CoordNDim &r, CoordNDim *ret) const
 Find the value of the function and return additional information.

Protected Attributes

ICallableNDfFunc
std::map< CoordNDim, double > fCache
std::map< CoordNDim, CoordNDimfCacheRetCoord
int fNhit
int fNmiss

Friends

std::ostream & operator<< (std::ostream &os, const FuncCache &c)

Detailed Description

Definition at line 97 of file NCFitter.h.


Constructor & Destructor Documentation

NC::Fitter::FuncCache::FuncCache ( ICallableND g  )  [inline]

Definition at line 101 of file NCFitter.h.

00101 : fFunc(g), fNhit(0), fNmiss(0){}


Member Function Documentation

double NC::Fitter::FuncCache::EvalAtEx ( const CoordNDim r,
CoordNDim ret 
) const [virtual]

Find the value of the function and return additional information.

Parameters:
r Coordinate at which to evaluate the function
[out] ret Return additional information. By convention, the true underlying coordinates evaluated.
Returns:
Value of the function at the point r

Implementations must be prepared for ret to be null

Todo:
Rename to just EvalAt

Implements NC::Fitter::ICallableND.

Definition at line 138 of file NCFitter.cxx.

References NC::Fitter::ICallableND::EvalAtEx(), fCache, fCacheRetCoord, fFunc, fNhit, fNmiss, and it.

00139   {
00140     const std::map<CoordNDim, double>::const_iterator it = fCache.find(r);
00141     if(it != fCache.end()){
00142       ++fNhit;
00143       if(retCoord) *retCoord = fCacheRetCoord[r];
00144       return it->second;
00145     }
00146 
00147     ++fNmiss;
00148 
00149     //  const unsigned int maxCacheSize = int(1e7); // on the order of 10meg
00150     //  if(cache.size() > maxCacheSize) fCache.clear();
00151 
00152     CoordNDim myRetCoord;
00153     const double ret = fFunc->EvalAtEx(r, &myRetCoord);
00154 
00155     fCache[r] = ret;
00156     fCacheRetCoord[r] = myRetCoord;
00157 
00158     if(retCoord) *retCoord = myRetCoord;
00159     return ret;
00160   }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const FuncCache c 
) [friend]

Member Data Documentation

std::map<CoordNDim, double> NC::Fitter::FuncCache::fCache [mutable, protected]

Definition at line 105 of file NCFitter.h.

Referenced by EvalAtEx().

Definition at line 106 of file NCFitter.h.

Referenced by EvalAtEx().

Definition at line 104 of file NCFitter.h.

Referenced by EvalAtEx(), and NC::Fitter::operator<<().

int NC::Fitter::FuncCache::fNhit [mutable, protected]

Definition at line 107 of file NCFitter.h.

Referenced by EvalAtEx(), and NC::Fitter::operator<<().

int NC::Fitter::FuncCache::fNmiss [mutable, protected]

Definition at line 107 of file NCFitter.h.

Referenced by EvalAtEx(), and NC::Fitter::operator<<().


The documentation for this class was generated from the following files:

Generated on 2 Jul 2018 for loon by  doxygen 1.6.1