00001 #ifndef EVENTCACHE_H_ 00002 #define EVENTCACHE_H_ 00003 00004 #include <TTreeReader.h> 00005 00006 00013 class EventCache { 00014 public: 00015 EventCache(TTreeReader const &reader); 00016 00018 bool IsUpdated() const; 00019 00020 private: 00022 TTreeReader const &reader_; 00023 00025 mutable long long latestEntry_; 00026 }; 00027 00028 00029 inline EventCache::EventCache(TTreeReader const &reader) 00030 : reader_{reader}, latestEntry_{-1} {} 00031 00032 00033 inline bool EventCache::IsUpdated() const { 00034 long long curEntry = reader_.GetCurrentEntry(); 00035 00036 if (curEntry == latestEntry_) 00037 return false; 00038 else { 00039 latestEntry_ = curEntry; 00040 return true; 00041 } 00042 } 00043 00044 00045 #endif // EVENTCACHE_H_ 00046