CMS 3D CMS Logo

Classes | Public Member Functions | Private Attributes

GenericMVAComputerCache Class Reference

#include <GenericMVAComputerCache.h>

List of all members.

Classes

struct  IndividualComputer

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

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.

                                                                    :
        computers(labels.size()),
        cacheId(MVAComputerContainer::CacheId()),
        initialized(false),
        empty(true)
{
        std::vector<IndividualComputer>::iterator computer = computers.begin();
        for(std::vector<std::string>::const_iterator iter = labels.begin();
            iter != labels.end(); iter++) {
                computer->label = *iter;
                computer->cacheId = MVAComputer::CacheId();
                computer++;
        }
}
GenericMVAComputerCache::~GenericMVAComputerCache ( )

Definition at line 41 of file GenericMVAComputerCache.cc.

{
}

Member Function Documentation

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

Definition at line 20 of file GenericMVAComputerCache.h.

References computers, and getHLTprescales::index.

Referenced by GenericMVAJetTagComputer::discriminator().

        { return index >= 0 ? computers[index].computer.get() : 0; }
bool GenericMVAComputerCache::isEmpty ( void  ) const [inline]

Definition at line 23 of file GenericMVAComputerCache.h.

References empty.

{ 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(), and initialized.

Referenced by GenericMVAJetTagComputer::setEventSetup().

{
        // check container for changes
        if (initialized && !calib->changed(cacheId))
                return false;

        empty = true;

        bool changed = false;
        for(std::vector<IndividualComputer>::iterator iter = computers.begin();
            iter != computers.end(); iter++) {
                // empty labels means we don't want a computer
                if (iter->label.empty())
                        continue;

                const MVAComputer *computerCalib = &calib->find(iter->label);
                if (!computerCalib) {
                        iter->computer.reset();
                        continue;
                }

                // check container content for changes
                if (iter->computer.get() &&
                    !computerCalib->changed(iter->cacheId)) {
                        empty = false;
                        continue;
                }

                // drop old computer
                iter->computer.reset();

                if (!computerCalib)
                        continue;

                // instantiate new MVAComputer with uptodate calibration
                iter->computer = std::auto_ptr<GenericMVAComputer>(
                                        new GenericMVAComputer(computerCalib));

                iter->cacheId = computerCalib->getCacheId();

                changed = true;
                empty = false;
        }

        cacheId = calib->getCacheId();
        initialized = true;

        return changed;
}

Member Data Documentation

Definition at line 37 of file GenericMVAComputerCache.h.

Referenced by update().

Definition at line 36 of file GenericMVAComputerCache.h.

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

Definition at line 39 of file GenericMVAComputerCache.h.

Referenced by isEmpty(), and update().

Definition at line 38 of file GenericMVAComputerCache.h.

Referenced by update().