CMS 3D CMS Logo

GenericMVAComputerCache Class Reference

#include <RecoBTau/JetTagComputer/interface/GenericMVAComputerCache.h>

List of all members.

Public Member Functions

 GenericMVAComputerCache (const std::vector< std::string > &labels)
GenericMVAComputergetComputer (int index) const
bool isEmpty () const
bool update (const PhysicsTools::Calibration::MVAComputerContainer *calib)
 ~GenericMVAComputerCache ()

Private Attributes

PhysicsTools::Calibration::MVAComputerContainer::CacheId cacheId
std::vector< IndividualComputercomputers
bool empty
bool initialized

Classes

struct  IndividualComputer


Detailed Description

Definition at line 12 of file GenericMVAComputerCache.h.


Constructor & Destructor Documentation

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 (  ) 

Definition at line 41 of file GenericMVAComputerCache.cc.

00042 {
00043 }


Member Function Documentation

GenericMVAComputer* GenericMVAComputerCache::getComputer ( int  index  )  const [inline]

Definition at line 20 of file GenericMVAComputerCache.h.

References computers.

Referenced by GenericMVAJetTagComputer::discriminator().

00021         { return index >= 0 ? computers[index].computer.get() : 0; }

bool GenericMVAComputerCache::isEmpty (  )  const [inline]

Definition at line 23 of file GenericMVAComputerCache.h.

References empty.

00023 { return empty; }

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 }


Member Data Documentation

PhysicsTools::Calibration::MVAComputerContainer::CacheId GenericMVAComputerCache::cacheId [private]

Definition at line 37 of file GenericMVAComputerCache.h.

Referenced by update().

std::vector<IndividualComputer> GenericMVAComputerCache::computers [private]

Definition at line 36 of file GenericMVAComputerCache.h.

Referenced by GenericMVAComputerCache(), getComputer(), and update().

bool GenericMVAComputerCache::empty [private]

Definition at line 39 of file GenericMVAComputerCache.h.

Referenced by isEmpty(), and update().

bool GenericMVAComputerCache::initialized [private]

Definition at line 38 of file GenericMVAComputerCache.h.

Referenced by update().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:21:12 2009 for CMSSW by  doxygen 1.5.4