CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Attributes
GenericMVAComputerCache Class Reference

#include <GenericMVAComputerCache.h>

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.

26  :
27  computers(labels.size()),
29  initialized(false),
30  empty(true)
31 {
32  std::vector<IndividualComputer>::iterator computer = computers.begin();
33  for(std::vector<std::string>::const_iterator iter = labels.begin();
34  iter != labels.end(); iter++) {
35  computer->label = *iter;
36  computer->cacheId = MVAComputer::CacheId();
37  computer++;
38  }
39 }
PhysicsTools::Calibration::MVAComputerContainer::CacheId cacheId
std::vector< IndividualComputer > computers
GenericMVAComputerCache::~GenericMVAComputerCache ( )

Definition at line 41 of file GenericMVAComputerCache.cc.

42 {
43 }

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

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

Definition at line 23 of file GenericMVAComputerCache.h.

References 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 progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), relval_steps.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), GenericMVAJetTagComputer::setEventSetup(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

46 {
47  // check container for changes
48  if (initialized && !calib->changed(cacheId))
49  return false;
50 
51  empty = true;
52 
53  bool changed = false;
54  for(std::vector<IndividualComputer>::iterator iter = computers.begin();
55  iter != computers.end(); iter++) {
56  // empty labels means we don't want a computer
57  if (iter->label.empty())
58  continue;
59 
60  const MVAComputer *computerCalib = &calib->find(iter->label);
61  if (!computerCalib) {
62  iter->computer.reset();
63  continue;
64  }
65 
66  // check container content for changes
67  if (iter->computer.get() &&
68  !computerCalib->changed(iter->cacheId)) {
69  empty = false;
70  continue;
71  }
72 
73  // drop old computer
74  iter->computer.reset();
75 
76  if (!computerCalib)
77  continue;
78 
79  // instantiate new MVAComputer with uptodate calibration
80  iter->computer = std::auto_ptr<GenericMVAComputer>(
81  new GenericMVAComputer(computerCalib));
82 
83  iter->cacheId = computerCalib->getCacheId();
84 
85  changed = true;
86  empty = false;
87  }
88 
89  cacheId = calib->getCacheId();
90  initialized = true;
91 
92  return changed;
93 }
PhysicsTools::Calibration::MVAComputerContainer::CacheId cacheId
virtual const MVAComputer & find(const std::string &label) const
Definition: MVAComputer.cc:192
bool changed(CacheId old) const
Definition: MVAComputer.h:175
std::vector< IndividualComputer > computers

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
bool GenericMVAComputerCache::initialized
private

Definition at line 38 of file GenericMVAComputerCache.h.

Referenced by update().