test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MVAObjectCache.cc
Go to the documentation of this file.
2 
3 using namespace egamma;
4 
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 }
36 
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 }
VParameterSet const & getParameterSetVector(std::string const &name) const
std::unique_ptr< const AnyMVAEstimatorRun2Base > MVAPtr
MVAObjectCache(const edm::ParameterSet &conf)
const MVAPtr & getMVA(const std::string &mva) const
std::unordered_map< std::string, MVAPtr > mvas_
T get(const Candidate &c)
Definition: component.h:55