CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
egamma::MVAObjectCache Class Reference

#include <MVAObjectCache.h>

Public Types

typedef std::unique_ptr< const AnyMVAEstimatorRun2BaseMVAPtr
 

Public Member Functions

const std::unordered_map< std::string, MVAPtr > & allMVAs () const
 
const MVAPtrgetMVA (const std::string &mva) const
 
 MVAObjectCache (const edm::ParameterSet &conf)
 

Private Attributes

std::unordered_map< std::string, MVAPtrmvas_
 

Detailed Description

Definition at line 14 of file MVAObjectCache.h.

Member Typedef Documentation

Definition at line 16 of file MVAObjectCache.h.

Constructor & Destructor Documentation

MVAObjectCache::MVAObjectCache ( const edm::ParameterSet conf)

Definition at line 5 of file MVAObjectCache.cc.

References Exception, reco::get(), edm::ParameterSet::getParameterSetVector(), mvas_, and AlCaHLTBitMon_QueryRunRegistry::string.

5  {
6  const std::vector<edm::ParameterSet>& mvaEstimatorConfigs
7  = conf.getParameterSetVector("mvaConfigurations");
8 
9  for( auto &imva : mvaEstimatorConfigs ){
10  // building the mva class is now done in the ObjectCache,
11  // so we loop over what's in that.
12  std::unique_ptr<AnyMVAEstimatorRun2Base> thisEstimator;
13  thisEstimator.reset(nullptr);
14  if( !imva.empty() ) {
15  const std::string& pName = imva.getParameter<std::string>("mvaName");
16  // The factory below constructs the MVA of the appropriate type based
17  // on the "mvaName" which is the name of the derived MVA class (plugin)
18  const AnyMVAEstimatorRun2Base *estimator = AnyMVAEstimatorRun2Factory::get()->create( pName, imva );
19  // Declare all event content, such as ValueMaps produced upstream or other,
20  // original event data pieces, that is needed (if any is implemented in the specific
21  // MVA classes)
22  const std::string full_name = estimator->getName() + estimator->getTag();
23  auto diditwork = mvas_.emplace( full_name, MVAPtr(estimator) );
24  if( !diditwork.second ) {
25  throw cms::Exception("MVA configured twice: ")
26  << "Tried already to make an mva of name: " << estimator->getName()
27  << " please ensure that the name of the MVA is unique!" << std::endl;
28  }
29  } else {
30  throw cms::Exception(" MVA configuration not found: ")
31  << " failed to find proper configuration for "
32  <<"one of the MVAs in the main python script " << std::endl;
33  }
34  }
35 }
VParameterSet const & getParameterSetVector(std::string const &name) const
std::unique_ptr< const AnyMVAEstimatorRun2Base > MVAPtr
std::unordered_map< std::string, MVAPtr > mvas_
T get(const Candidate &c)
Definition: component.h:55

Member Function Documentation

const std::unordered_map<std::string,MVAPtr>& egamma::MVAObjectCache::allMVAs ( ) const
inline

Definition at line 22 of file MVAObjectCache.h.

References mvas_.

Referenced by MVAValueMapProducer< ParticleType >::MVAValueMapProducer().

22  {
23  return mvas_;
24  }
std::unordered_map< std::string, MVAPtr > mvas_
const MVAObjectCache::MVAPtr & MVAObjectCache::getMVA ( const std::string &  mva) const

Definition at line 38 of file MVAObjectCache.cc.

References Exception, and mvas_.

38  {
39  auto itr = mvas_.find(mva);
40  if( itr == mvas_.end() ) {
41  throw cms::Exception("InvalidMVAName")
42  << mva << " is not managed by this evaluator!";
43  }
44  return itr->second;
45 }
std::unordered_map< std::string, MVAPtr > mvas_

Member Data Documentation

std::unordered_map<std::string,MVAPtr> egamma::MVAObjectCache::mvas_
private

Definition at line 26 of file MVAObjectCache.h.

Referenced by allMVAs(), getMVA(), and MVAObjectCache().