Template for automated variable collection and MVA computation in EDM modules. More...
#include <MVAModuleHelper.h>
Classes | |
class | Value |
Public Member Functions | |
MVAModuleHelper (const std::string &label) | |
MVAModuleHelper (const MVAModuleHelper &orig) | |
double | operator() (const Object &object) const |
void | setEventSetup (const edm::EventSetup &setup, const char *esLabel) |
void | setEventSetup (const edm::EventSetup &setup) |
void | train (const Object &object, bool target, double weight=1.0) const |
~MVAModuleHelper () | |
Private Member Functions | |
void | init (const PhysicsTools::Calibration::MVAComputerContainer *container) |
Private Attributes | |
PhysicsTools::MVAComputerCache | cache |
const std::string | label |
std::vector< Value > | values |
Template for automated variable collection and MVA computation in EDM modules.
The class MVAModuleHelper can be embedded in EDM modules. It automatically collects the variables listed in the MVA training description using type traits and passes them on to the computer. The calibration and or trainer is automatically collected from the EventSetup.
Definition at line 63 of file MVAModuleHelper.h.
PhysicsTools::MVAModuleHelper< Record, Object, Filler >::MVAModuleHelper | ( | const std::string & | label | ) | [inline] |
Definition at line 65 of file MVAModuleHelper.h.
PhysicsTools::MVAModuleHelper< Record, Object, Filler >::MVAModuleHelper | ( | const MVAModuleHelper< Record, Object, Filler > & | orig | ) | [inline] |
Definition at line 66 of file MVAModuleHelper.h.
: label(orig.label) {}
PhysicsTools::MVAModuleHelper< Record, Object, Filler >::~MVAModuleHelper | ( | ) | [inline] |
Definition at line 67 of file MVAModuleHelper.h.
{}
void PhysicsTools::MVAModuleHelper< Record, Object, Filler >::init | ( | const PhysicsTools::Calibration::MVAComputerContainer * | container | ) | [private] |
Definition at line 131 of file MVAModuleHelper.h.
References PhysicsTools::Calibration::MVAComputerContainer::find(), label, and makeHLTPrescaleTable::values.
{ const std::vector<PhysicsTools::Calibration::Variable> &vars = container->find(label).inputSet; values.clear(); for(std::vector<PhysicsTools::Calibration::Variable>::const_iterator iter = vars.begin(); iter != vars.end(); ++iter) if (std::strncmp(iter->name.c_str(), "__", 2) != 0) values.push_back(Value(iter->name)); }
double PhysicsTools::MVAModuleHelper< Record, Object, Filler >::operator() | ( | const Object & | object | ) | const |
Definition at line 144 of file MVAModuleHelper.h.
References update, and makeHLTPrescaleTable::values.
{ std::for_each(values.begin(), values.end(), boost::bind(&Value::update, _1, object)); return cache->eval(values); }
void PhysicsTools::MVAModuleHelper< Record, Object, Filler >::setEventSetup | ( | const edm::EventSetup & | setup, |
const char * | esLabel | ||
) |
Definition at line 120 of file MVAModuleHelper.h.
References edm::EventSetup::get(), patZpeak::handle, init, label, and edm::ESHandle< T >::product().
void PhysicsTools::MVAModuleHelper< Record, Object, Filler >::setEventSetup | ( | const edm::EventSetup & | setup | ) |
Definition at line 109 of file MVAModuleHelper.h.
References edm::EventSetup::get(), patZpeak::handle, init, label, and edm::ESHandle< T >::product().
void PhysicsTools::MVAModuleHelper< Record, Object, Filler >::train | ( | const Object & | object, |
bool | target, | ||
double | weight = 1.0 |
||
) | const |
Definition at line 153 of file MVAModuleHelper.h.
References PhysicsTools::Variable::ValueList::add(), list(), update, and makeHLTPrescaleTable::values.
{ static const PhysicsTools::AtomicId kTargetId("__TARGET__"); static const PhysicsTools::AtomicId kWeightId("__WEIGHT__"); if (!cache) return; using boost::bind; if (std::accumulate(values.begin(), values.end(), 0, bind(std::plus<int>(), _1, bind(&Value::update, _2, object)))) return; PhysicsTools::Variable::ValueList list; list.add(kTargetId, target); list.add(kWeightId, weight); for(typename std::vector<Value>::const_iterator iter = values.begin(); iter != values.end(); ++iter) list.add(iter->getName(), iter->getValue()); cache->eval(list); }
PhysicsTools::MVAComputerCache PhysicsTools::MVAModuleHelper< Record, Object, Filler >::cache [private] |
Definition at line 80 of file MVAModuleHelper.h.
const std::string PhysicsTools::MVAModuleHelper< Record, Object, Filler >::label [private] |
Definition at line 79 of file MVAModuleHelper.h.
std::vector<Value> PhysicsTools::MVAModuleHelper< Record, Object, Filler >::values [private] |
Definition at line 105 of file MVAModuleHelper.h.