#include <RecoBTau/JetTagComputer/interface/GenericMVAComputerCache.h>
Public Member Functions | |
GenericMVAComputerCache (const std::vector< std::string > &labels) | |
GenericMVAComputer * | getComputer (int index) const |
bool | isEmpty () const |
bool | update (const PhysicsTools::Calibration::MVAComputerContainer *calib) |
~GenericMVAComputerCache () | |
Private Attributes | |
PhysicsTools::Calibration::MVAComputerContainer::CacheId | cacheId |
std::vector< IndividualComputer > | computers |
bool | empty |
bool | initialized |
Classes | |
struct | IndividualComputer |
Definition at line 12 of file GenericMVAComputerCache.h.
GenericMVAComputerCache::GenericMVAComputerCache | ( | const std::vector< std::string > & | labels | ) |
Definition at line 25 of file GenericMVAComputerCache.cc.
References computers, and iter.
00026 : 00027 computers(labels.size()), 00028 cacheId(MVAComputerContainer::CacheId()), 00029 initialized(false), 00030 empty(true) 00031 { 00032 std::vector<IndividualComputer>::iterator computer = computers.begin(); 00033 for(std::vector<std::string>::const_iterator iter = labels.begin(); 00034 iter != labels.end(); iter++) { 00035 computer->label = *iter; 00036 computer->cacheId = MVAComputer::CacheId(); 00037 computer++; 00038 } 00039 }
GenericMVAComputerCache::~GenericMVAComputerCache | ( | ) |
GenericMVAComputer* GenericMVAComputerCache::getComputer | ( | int | index | ) | const [inline] |
Definition at line 20 of file GenericMVAComputerCache.h.
References computers.
Referenced by GenericMVAJetTagComputer::discriminator().
bool GenericMVAComputerCache::isEmpty | ( | ) | const [inline] |
bool GenericMVAComputerCache::update | ( | const PhysicsTools::Calibration::MVAComputerContainer * | calib | ) |
Definition at line 45 of file GenericMVAComputerCache.cc.
References cacheId, PhysicsTools::Calibration::MVAComputer::changed(), PhysicsTools::Calibration::MVAComputerContainer::changed(), computers, empty, PhysicsTools::Calibration::MVAComputerContainer::find(), PhysicsTools::Calibration::MVAComputer::getCacheId(), PhysicsTools::Calibration::MVAComputerContainer::getCacheId(), initialized, and iter.
Referenced by GenericMVAJetTagComputer::setEventSetup().
00046 { 00047 // check container for changes 00048 if (initialized && !calib->changed(cacheId)) 00049 return false; 00050 00051 empty = true; 00052 00053 bool changed = false; 00054 for(std::vector<IndividualComputer>::iterator iter = computers.begin(); 00055 iter != computers.end(); iter++) { 00056 // empty labels means we don't want a computer 00057 if (iter->label.empty()) 00058 continue; 00059 00060 const MVAComputer *computerCalib = &calib->find(iter->label); 00061 if (!computerCalib) { 00062 iter->computer.reset(); 00063 continue; 00064 } 00065 00066 // check container content for changes 00067 if (iter->computer.get() && 00068 !computerCalib->changed(iter->cacheId)) { 00069 empty = false; 00070 continue; 00071 } 00072 00073 // drop old computer 00074 iter->computer.reset(); 00075 00076 if (!computerCalib) 00077 continue; 00078 00079 // instantiate new MVAComputer with uptodate calibration 00080 iter->computer = std::auto_ptr<GenericMVAComputer>( 00081 new GenericMVAComputer(computerCalib)); 00082 00083 iter->cacheId = computerCalib->getCacheId(); 00084 00085 changed = true; 00086 empty = false; 00087 } 00088 00089 cacheId = calib->getCacheId(); 00090 initialized = true; 00091 00092 return changed; 00093 }
std::vector<IndividualComputer> GenericMVAComputerCache::computers [private] |
Definition at line 36 of file GenericMVAComputerCache.h.
Referenced by GenericMVAComputerCache(), getComputer(), and update().
bool GenericMVAComputerCache::empty [private] |
bool GenericMVAComputerCache::initialized [private] |