#include <PhysicsTools/MVAComputer/interface/MVAModuleHelper.h>
Public Member Functions | |
MVAModuleHelper (const MVAModuleHelper &orig) | |
MVAModuleHelper (const std::string &label) | |
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 |
Classes | |
class | Value |
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 62 of file MVAModuleHelper.h.
PhysicsTools::MVAModuleHelper< Record, Object, Filler >::MVAModuleHelper | ( | const std::string & | label | ) | [inline] |
PhysicsTools::MVAModuleHelper< Record, Object, Filler >::MVAModuleHelper | ( | const MVAModuleHelper< Record, Object, Filler > & | orig | ) | [inline] |
PhysicsTools::MVAModuleHelper< Record, Object, Filler >::~MVAModuleHelper | ( | ) | [inline] |
void PhysicsTools::MVAModuleHelper< Record, Object, Filler >::init | ( | const PhysicsTools::Calibration::MVAComputerContainer * | container | ) | [inline, private] |
Definition at line 132 of file MVAModuleHelper.h.
References PhysicsTools::Calibration::MVAComputerContainer::find(), iter, PhysicsTools::MVAModuleHelper< Record, Object, Filler >::label, PhysicsTools::MVAModuleHelper< Record, Object, Filler >::values, and vars.
Referenced by PhysicsTools::MVAModuleHelper< Record, Object, Filler >::setEventSetup().
00134 { 00135 const std::vector<PhysicsTools::Calibration::Variable> &vars = 00136 container->find(label).inputSet; 00137 values.clear(); 00138 for(std::vector<PhysicsTools::Calibration::Variable>::const_iterator 00139 iter = vars.begin(); iter != vars.end(); ++iter) 00140 if (std::strncmp(iter->name.c_str(), "__", 2) != 0) 00141 values.push_back(Value(iter->name)); 00142 }
double PhysicsTools::MVAModuleHelper< Record, Object, Filler >::operator() | ( | const Object & | object | ) | const [inline] |
Definition at line 145 of file MVAModuleHelper.h.
References PhysicsTools::MVAModuleHelper< Record, Object, Filler >::cache, PhysicsTools::MVAModuleHelper< Record, Object, Filler >::Value::update(), and PhysicsTools::MVAModuleHelper< Record, Object, Filler >::values.
00147 { 00148 std::for_each(values.begin(), values.end(), 00149 boost::bind(&Value::update, _1, object)); 00150 return cache->eval(values); 00151 }
void PhysicsTools::MVAModuleHelper< Record, Object, Filler >::setEventSetup | ( | const edm::EventSetup & | setup, | |
const char * | esLabel | |||
) | [inline] |
Definition at line 120 of file MVAModuleHelper.h.
References PhysicsTools::MVAModuleHelper< Record, Object, Filler >::cache, edm::EventSetup::get(), PhysicsTools::MVAModuleHelper< Record, Object, Filler >::init(), PhysicsTools::MVAModuleHelper< Record, Object, Filler >::label, edm::ESHandle< T >::product(), and PhysicsTools::MVAComputerCache::update().
00122 { 00123 using namespace PhysicsTools::Calibration; 00124 edm::ESHandle<MVAComputerContainer> handle; 00125 setup.get<Record>().get(esLabel, handle); 00126 const MVAComputerContainer *container = handle.product(); 00127 if (cache.update(container, label.c_str()) && cache) 00128 init(container); 00129 }
void PhysicsTools::MVAModuleHelper< Record, Object, Filler >::setEventSetup | ( | const edm::EventSetup & | setup | ) | [inline] |
Definition at line 108 of file MVAModuleHelper.h.
References PhysicsTools::MVAModuleHelper< Record, Object, Filler >::cache, edm::EventSetup::get(), PhysicsTools::MVAModuleHelper< Record, Object, Filler >::init(), PhysicsTools::MVAModuleHelper< Record, Object, Filler >::label, edm::ESHandle< T >::product(), and PhysicsTools::MVAComputerCache::update().
00110 { 00111 using namespace PhysicsTools::Calibration; 00112 edm::ESHandle<MVAComputerContainer> handle; 00113 setup.get<Record>().get(handle); 00114 const MVAComputerContainer *container = handle.product(); 00115 if (cache.update(container, label.c_str()) && cache) 00116 init(container); 00117 }
void PhysicsTools::MVAModuleHelper< Record, Object, Filler >::train | ( | const Object & | object, | |
bool | target, | |||
double | weight = 1.0 | |||
) | const [inline] |
Definition at line 154 of file MVAModuleHelper.h.
References PhysicsTools::Variable::ValueList::add(), PhysicsTools::MVAModuleHelper< Record, Object, Filler >::cache, iter, list(), PhysicsTools::MVAModuleHelper< Record, Object, Filler >::Value::update(), and PhysicsTools::MVAModuleHelper< Record, Object, Filler >::values.
00156 { 00157 static const PhysicsTools::AtomicId kTargetId("__TARGET__"); 00158 static const PhysicsTools::AtomicId kWeightId("__WEIGHT__"); 00159 00160 if (!cache) 00161 return; 00162 00163 using boost::bind; 00164 if (std::accumulate(values.begin(), values.end(), 0, 00165 bind(std::plus<int>(), _1, 00166 bind(&Value::update, _2, object)))) 00167 return; 00168 00169 PhysicsTools::Variable::ValueList list; 00170 list.add(kTargetId, target); 00171 list.add(kWeightId, weight); 00172 for(typename std::vector<Value>::const_iterator iter = values.begin(); 00173 iter != values.end(); ++iter) 00174 list.add(iter->getName(), iter->getValue()); 00175 00176 cache->eval(list); 00177 }
PhysicsTools::MVAComputerCache PhysicsTools::MVAModuleHelper< Record, Object, Filler >::cache [private] |
const std::string PhysicsTools::MVAModuleHelper< Record, Object, Filler >::label [private] |
Definition at line 78 of file MVAModuleHelper.h.
Referenced by PhysicsTools::MVAModuleHelper< Record, Object, Filler >::init(), and PhysicsTools::MVAModuleHelper< Record, Object, Filler >::setEventSetup().
std::vector<Value> PhysicsTools::MVAModuleHelper< Record, Object, Filler >::values [private] |