NC::Fitter::FuncCacheInt Class Reference

#include <NCFitter.h>

Inheritance diagram for NC::Fitter::FuncCacheInt:
NC::Fitter::ICallableInt

List of all members.

Public Member Functions

 FuncCacheInt (const ICallableInt *g)
virtual double EvalAtEx (const CoordInt &r, CoordInt *) const

Protected Attributes

const ICallableIntfFunc
std::map< CoordInt, double > fCache
std::map< CoordInt, CoordIntfRetCache
int fNhit
int fNmiss

Friends

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

Detailed Description

Definition at line 114 of file NCFitter.h.


Constructor & Destructor Documentation

NC::Fitter::FuncCacheInt::FuncCacheInt ( const ICallableInt g  )  [inline]

Definition at line 118 of file NCFitter.h.

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


Member Function Documentation

double NC::Fitter::FuncCacheInt::EvalAtEx ( const CoordInt r,
CoordInt ret 
) const [virtual]

Reimplemented from NC::Fitter::ICallableInt.

Definition at line 172 of file NCFitter.cxx.

References NC::Fitter::ICallableInt::EvalAtEx(), fCache, fFunc, fNhit, fNmiss, fRetCache, and it.

00173   {
00174     const std::map<CoordInt, double>::const_iterator it = fCache.find(r);
00175 
00176     if(it != fCache.end()){
00177       ++fNhit;
00178       if(ret) *ret = fRetCache[r];
00179       return it->second;
00180     }
00181 
00182     ++fNmiss;
00183 
00184     //  const unsigned int maxCacheSize = int(1e7); // on the order of 10meg
00185     //  if(cache.size() > maxCacheSize) cache.clear();
00186 
00187     CoordInt myret;
00188     const double val = fFunc->EvalAtEx(r, &myret);
00189     if(ret) *ret = myret;
00190 
00191     fCache[r] = val;
00192     fRetCache[r] = myret;
00193 
00194     return val;
00195   }


Friends And Related Function Documentation

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

Member Data Documentation

std::map<CoordInt, double> NC::Fitter::FuncCacheInt::fCache [mutable, protected]

Definition at line 123 of file NCFitter.h.

Referenced by EvalAtEx().

Definition at line 122 of file NCFitter.h.

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

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

Definition at line 125 of file NCFitter.h.

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

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

Definition at line 125 of file NCFitter.h.

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

std::map<CoordInt, CoordInt> NC::Fitter::FuncCacheInt::fRetCache [mutable, protected]

Definition at line 124 of file NCFitter.h.

Referenced by EvalAtEx().


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

Generated on 16 Apr 2018 for loon by  doxygen 1.6.1