#include <CachingNLL.h>
Classes | |
struct | Item |
Public Member Functions | |
void | clear () |
std::pair< std::vector < Double_t > *, bool > | get () |
ValuesCache (const RooAbsCollection ¶ms, int size=MaxItems_) | |
ValuesCache (const RooAbsReal &pdf, const RooArgSet &obs, int size=MaxItems_) | |
~ValuesCache () | |
Private Types | |
enum | { MaxItems_ = 3 } |
Private Attributes | |
Item * | items [MaxItems_] |
int | maxSize_ |
int | size_ |
Definition at line 30 of file CachingNLL.h.
anonymous enum [private] |
cacheutils::ValuesCache::ValuesCache | ( | const RooAbsReal & | pdf, |
const RooArgSet & | obs, | ||
int | size = MaxItems_ |
||
) |
cacheutils::ValuesCache::ValuesCache | ( | const RooAbsCollection & | params, |
int | size = MaxItems_ |
||
) |
cacheutils::ValuesCache::~ValuesCache | ( | ) |
Definition at line 111 of file CachingNLL.cc.
References i, and edm::size_().
void cacheutils::ValuesCache::clear | ( | void | ) |
Definition at line 116 of file CachingNLL.cc.
References i, and edm::size_().
std::pair< std::vector< Double_t > *, bool > cacheutils::ValuesCache::get | ( | void | ) |
Definition at line 121 of file CachingNLL.cc.
References Clusterizer1DCommons::add(), f, newFWLiteAna::found, i, and edm::size_().
{ int found = -1; bool good = false; for (int i = 0; i < size_; ++i) { if (items[i]->good) { // valid entry, check if fresh if (!items[i]->checker.changed()) { #ifdef DEBUG_CACHE PerfCounter::add(i == 0 ? "ValuesCache::get hit first" : "ValuesCache::get hit other"); #endif // fresh: done! found = i; good = true; break; } } else if (found == -1) { // invalid entry, can be replaced found = i; #ifdef DEBUG_CACHE PerfCounter::add("ValuesCache::get hit invalid"); #endif } } if (found == -1) { // all entries are valid but old #ifdef DEBUG_CACHE PerfCounter::add("ValuesCache::get miss"); #endif if (size_ < maxSize_) { // if I can, make a new entry items[size_] = new Item(items[0]->checker); // create a new item, copying the ArgSetChecker from the first one found = size_; size_++; } else { // otherwise, pick the last one found = size_-1; } } // make sure new entry is the first one if (found != 0) { // remember what found is pointing to Item *f = items[found]; // shift the other items down one place while (found > 0) { items[found] = items[found-1]; --found; } // and put found on top items[found] = f; } if (!good) items[found]->checker.changed(true); // store new values in cache sentry items[found]->good = true; // mark this as valid entry return std::pair<std::vector<Double_t> *, bool>(&items[found]->values, good); }
Item* cacheutils::ValuesCache::items[MaxItems_] [private] |
Definition at line 51 of file CachingNLL.h.
Referenced by ValuesCache().
int cacheutils::ValuesCache::maxSize_ [private] |
Definition at line 49 of file CachingNLL.h.
int cacheutils::ValuesCache::size_ [private] |
Definition at line 49 of file CachingNLL.h.