CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PhysicsTools::MVAComputerCache Class Reference

Creates and and MVAComputer from calibrations via EventSetup. More...

#include <MVAComputerCache.h>

Public Member Functions

MVAComputerget ()
 
const MVAComputerget () const
 
 MVAComputerCache ()
 
 operator bool () const
 
MVAComputeroperator* ()
 
const MVAComputeroperator* () const
 
MVAComputeroperator-> ()
 
const MVAComputeroperator-> () const
 
std::unique_ptr< MVAComputerrelease ()
 
void reset ()
 
bool update (const Calibration::MVAComputer *computer)
 
bool update (const Calibration::MVAComputerContainer *container, const char *calib)
 
 ~MVAComputerCache ()
 

Private Attributes

std::unique_ptr< MVAComputercomputer
 
Calibration::MVAComputer::CacheId computerCacheId
 
Calibration::MVAComputerContainer::CacheId containerCacheId
 

Detailed Description

Creates and and MVAComputer from calibrations via EventSetup.

Definition at line 26 of file MVAComputerCache.h.

Constructor & Destructor Documentation

◆ MVAComputerCache()

PhysicsTools::MVAComputerCache::MVAComputerCache ( )

◆ ~MVAComputerCache()

PhysicsTools::MVAComputerCache::~MVAComputerCache ( )

Definition at line 13 of file MVAComputerCache.cc.

13 {}

Member Function Documentation

◆ get() [1/2]

MVAComputer* PhysicsTools::MVAComputerCache::get ( )
inline

◆ get() [2/2]

const MVAComputer* PhysicsTools::MVAComputerCache::get ( ) const
inline

◆ operator bool()

PhysicsTools::MVAComputerCache::operator bool ( ) const
inline

Definition at line 34 of file MVAComputerCache.h.

References computer.

34 { return computer.get(); }
std::unique_ptr< MVAComputer > computer

◆ operator*() [1/2]

MVAComputer& PhysicsTools::MVAComputerCache::operator* ( void  )
inline

Definition at line 36 of file MVAComputerCache.h.

References computer.

36 { return *computer; }
std::unique_ptr< MVAComputer > computer

◆ operator*() [2/2]

const MVAComputer& PhysicsTools::MVAComputerCache::operator* ( void  ) const
inline

Definition at line 37 of file MVAComputerCache.h.

References computer.

37 { return *computer; }
std::unique_ptr< MVAComputer > computer

◆ operator->() [1/2]

MVAComputer* PhysicsTools::MVAComputerCache::operator-> ( )
inline

Definition at line 39 of file MVAComputerCache.h.

References computer.

39 { return computer.get(); }
std::unique_ptr< MVAComputer > computer

◆ operator->() [2/2]

const MVAComputer* PhysicsTools::MVAComputerCache::operator-> ( ) const
inline

Definition at line 40 of file MVAComputerCache.h.

References computer.

40 { return computer.get(); }
std::unique_ptr< MVAComputer > computer

◆ release()

std::unique_ptr< MVAComputer > PhysicsTools::MVAComputerCache::release ( )

Definition at line 53 of file MVAComputerCache.cc.

References computer, computerCacheId, containerCacheId, and eostools::move().

53  {
56  return std::move(computer);
57  }
Calibration::MVAComputer::CacheId computerCacheId
Calibration::MVAComputerContainer::CacheId containerCacheId
std::unique_ptr< MVAComputer > computer
def move(src, dest)
Definition: eostools.py:511

◆ reset()

void PhysicsTools::MVAComputerCache::reset ( void  )
inline

Definition at line 47 of file MVAComputerCache.h.

References computer.

47 { computer.reset(); }
std::unique_ptr< MVAComputer > computer

◆ update() [1/2]

bool PhysicsTools::MVAComputerCache::update ( const Calibration::MVAComputer computer)

Definition at line 15 of file MVAComputerCache.cc.

References computer, computerCacheId, and containerCacheId.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), MatrixUtil.Steps::overwrite(), TtFullHadSignalSelMVAComputer::produce(), TtSemiLepJetCombMVAComputer::produce(), TtSemiLepSignalSelMVAComputer::produce(), and update().

15  {
16  if (!computer && !*this)
17  return false;
18  if (computer && !computer->changed(computerCacheId))
19  return false;
20 
21  if (computer) {
22  this->computer = std::make_unique<MVAComputer>(computer);
23  computerCacheId = computer->getCacheId();
24  } else {
25  this->computer.reset();
26  computerCacheId = Calibration::MVAComputer::CacheId();
27  }
28 
30  return true;
31  }
Calibration::MVAComputer::CacheId computerCacheId
Calibration::MVAComputerContainer::CacheId containerCacheId
std::unique_ptr< MVAComputer > computer

◆ update() [2/2]

bool PhysicsTools::MVAComputerCache::update ( const Calibration::MVAComputerContainer container,
const char *  calib 
)

Definition at line 33 of file MVAComputerCache.cc.

References PhysicsTools::Calibration::MVAComputerContainer::changed(), computer, computerCacheId, containerCacheId, PhysicsTools::Calibration::MVAComputerContainer::find(), PhysicsTools::Calibration::MVAComputerContainer::getCacheId(), mps_fire::result, and update().

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), progressbar.ProgressBar::finish(), and MatrixUtil.Steps::overwrite().

33  {
34  if (!container && !*this)
35  return false;
36  if (container && !container->changed(containerCacheId))
37  return false;
38 
39  if (container) {
40  const Calibration::MVAComputer *computer = &container->find(calib);
41  bool result = update(computer);
42  containerCacheId = container->getCacheId();
43  return result;
44  }
45 
46  this->computer.reset();
47 
50  return true;
51  }
Calibration::MVAComputer::CacheId computerCacheId
Calibration::MVAComputerContainer::CacheId containerCacheId
std::unique_ptr< MVAComputer > computer
bool update(const Calibration::MVAComputer *computer)

Member Data Documentation

◆ computer

std::unique_ptr<MVAComputer> PhysicsTools::MVAComputerCache::computer
private

Definition at line 52 of file MVAComputerCache.h.

Referenced by get(), operator bool(), operator*(), operator->(), release(), reset(), and update().

◆ computerCacheId

Calibration::MVAComputer::CacheId PhysicsTools::MVAComputerCache::computerCacheId
private

Definition at line 51 of file MVAComputerCache.h.

Referenced by release(), and update().

◆ containerCacheId

Calibration::MVAComputerContainer::CacheId PhysicsTools::MVAComputerCache::containerCacheId
private

Definition at line 50 of file MVAComputerCache.h.

Referenced by release(), and update().