CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/PhysicsTools/MVAComputer/src/MVAComputerCache.cc

Go to the documentation of this file.
00001 #include <memory>
00002 
00003 #include "PhysicsTools/MVAComputer/interface/Calibration.h"
00004 #include "PhysicsTools/MVAComputer/interface/MVAComputer.h"
00005 #include "PhysicsTools/MVAComputer/interface/MVAComputerCache.h"
00006 
00007 namespace PhysicsTools {
00008 
00009 MVAComputerCache::MVAComputerCache() :
00010         containerCacheId(Calibration::MVAComputerContainer::CacheId()),
00011         computerCacheId(Calibration::MVAComputer::CacheId())
00012 {
00013 }
00014 
00015 MVAComputerCache::~MVAComputerCache()
00016 {
00017 }
00018 
00019 bool MVAComputerCache::update(const Calibration::MVAComputer *computer)
00020 {
00021         if (!computer && !*this)
00022                 return false;
00023         if (computer && !computer->changed(computerCacheId))
00024                 return false;
00025 
00026         if (computer) {
00027                 this->computer.reset(new MVAComputer(computer));
00028                 computerCacheId = computer->getCacheId();
00029         } else {
00030                 this->computer.reset();
00031                 computerCacheId = Calibration::MVAComputer::CacheId();
00032         }
00033 
00034         containerCacheId = Calibration::MVAComputerContainer::CacheId();
00035         return true;
00036 }
00037 
00038 bool MVAComputerCache::update(
00039                         const Calibration::MVAComputerContainer *container,
00040                         const char *calib)
00041 {
00042         if (!container && !*this)
00043                 return false;
00044         if (container && !container->changed(containerCacheId))
00045                 return false;
00046 
00047         if (container) {
00048                 const Calibration::MVAComputer *computer =
00049                                                 &container->find(calib);
00050                 bool result = update(computer);
00051                 containerCacheId = container->getCacheId();
00052                 return result;
00053         }
00054 
00055         this->computer.reset();
00056 
00057         computerCacheId = Calibration::MVAComputer::CacheId();
00058         containerCacheId = Calibration::MVAComputerContainer::CacheId();
00059         return true;
00060 }
00061 
00062 std::auto_ptr<MVAComputer> MVAComputerCache::release()
00063 {
00064         computerCacheId = Calibration::MVAComputer::CacheId();
00065         containerCacheId = Calibration::MVAComputerContainer::CacheId();
00066         return computer;
00067 }
00068 
00069 } // namespace PhysicsTools