CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
PhysicsTools::MVAModuleHelper< Record, Object, Filler > Class Template Reference

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)
 
void setEventSetup (const edm::EventSetup &setup, const char *esLabel)
 
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< Valuevalues
 

Detailed Description

template<class Record, typename Object, class Filler = MVAModuleHelperDefaultFiller<Object>>
class PhysicsTools::MVAModuleHelper< Record, Object, Filler >

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 62 of file MVAModuleHelper.h.

Constructor & Destructor Documentation

template<class Record , typename Object , class Filler = MVAModuleHelperDefaultFiller<Object>>
PhysicsTools::MVAModuleHelper< Record, Object, Filler >::MVAModuleHelper ( const std::string &  label)
inline

Definition at line 64 of file MVAModuleHelper.h.

64 : label(label) {}
template<class Record , typename Object , class Filler = MVAModuleHelperDefaultFiller<Object>>
PhysicsTools::MVAModuleHelper< Record, Object, Filler >::MVAModuleHelper ( const MVAModuleHelper< Record, Object, Filler > &  orig)
inline

Definition at line 65 of file MVAModuleHelper.h.

65 : label(orig.label) {}
template<class Record , typename Object , class Filler = MVAModuleHelperDefaultFiller<Object>>
PhysicsTools::MVAModuleHelper< Record, Object, Filler >::~MVAModuleHelper ( )
inline

Definition at line 66 of file MVAModuleHelper.h.

66 {}

Member Function Documentation

template<class Record , typename Object , class Filler >
void PhysicsTools::MVAModuleHelper< Record, Object, Filler >::init ( const PhysicsTools::Calibration::MVAComputerContainer container)
private

Definition at line 130 of file MVAModuleHelper.h.

References PhysicsTools::Calibration::MVAComputerContainer::find(), getDQMSummary::iter, diffTwoXMLs::label, and makeHLTPrescaleTable::values.

132 {
133  const std::vector<PhysicsTools::Calibration::Variable> &vars =
134  container->find(label).inputSet;
135  values.clear();
136  for(std::vector<PhysicsTools::Calibration::Variable>::const_iterator
137  iter = vars.begin(); iter != vars.end(); ++iter)
138  if (std::strncmp(iter->name.c_str(), "__", 2) != 0)
139  values.push_back(Value(iter->name));
140 }
virtual const MVAComputer & find(const std::string &label) const
Definition: MVAComputer.cc:192
reco::JetExtendedAssociation::JetExtendedData Value
std::vector< Value > values
std::vector< Variable > inputSet
Definition: MVAComputer.h:217
template<class Record , typename Object , class Filler >
double PhysicsTools::MVAModuleHelper< Record, Object, Filler >::operator() ( const Object &  object) const

Definition at line 143 of file MVAModuleHelper.h.

References update, and makeHLTPrescaleTable::values.

145 {
146  std::for_each(values.begin(), values.end(),
147  boost::bind(&Value::update, _1, object));
148  return cache->eval(values);
149 }
PhysicsTools::MVAComputerCache cache
double eval(Iterator_t first, Iterator_t last) const
evaluate variables given by a range of iterators given by first and last
std::vector< Value > values
bool update(const Object &object) const
template<class Record , typename Object , class Filler >
void PhysicsTools::MVAModuleHelper< Record, Object, Filler >::setEventSetup ( const edm::EventSetup setup)

Definition at line 108 of file MVAModuleHelper.h.

References edm::EventSetup::get(), patZpeak::handle, init, diffTwoXMLs::label, and edm::ESHandle< class >::product().

110 {
112  setup.get<Record>().get(handle);
113  const PhysicsTools::Calibration::MVAComputerContainer *container = handle.product();
114  if (cache.update(container, label.c_str()) && cache)
115  init(container);
116 }
PhysicsTools::MVAComputerCache cache
tuple handle
Definition: patZpeak.py:22
bool update(const Calibration::MVAComputer *computer)
const T & get() const
Definition: EventSetup.h:55
void init(const PhysicsTools::Calibration::MVAComputerContainer *container)
T const * product() const
Definition: ESHandle.h:62
template<class Record , typename Object , class Filler >
void PhysicsTools::MVAModuleHelper< Record, Object, Filler >::setEventSetup ( const edm::EventSetup setup,
const char *  esLabel 
)

Definition at line 119 of file MVAModuleHelper.h.

References edm::EventSetup::get(), patZpeak::handle, init, diffTwoXMLs::label, and edm::ESHandle< class >::product().

121 {
123  setup.get<Record>().get(esLabel, handle);
124  const PhysicsTools::Calibration::MVAComputerContainer *container = handle.product();
125  if (cache.update(container, label.c_str()) && cache)
126  init(container);
127 }
PhysicsTools::MVAComputerCache cache
tuple handle
Definition: patZpeak.py:22
bool update(const Calibration::MVAComputer *computer)
const T & get() const
Definition: EventSetup.h:55
void init(const PhysicsTools::Calibration::MVAComputerContainer *container)
T const * product() const
Definition: ESHandle.h:62
template<class Record , typename Object , class Filler >
void PhysicsTools::MVAModuleHelper< Record, Object, Filler >::train ( const Object &  object,
bool  target,
double  weight = 1.0 
) const

Definition at line 152 of file MVAModuleHelper.h.

References PhysicsTools::Variable::ValueList::add(), getDQMSummary::iter, list(), update, and makeHLTPrescaleTable::values.

154 {
155  static const PhysicsTools::AtomicId kTargetId("__TARGET__");
156  static const PhysicsTools::AtomicId kWeightId("__WEIGHT__");
157 
158  if (!cache)
159  return;
160 
161  using boost::bind;
162  if (std::accumulate(values.begin(), values.end(), 0,
163  bind(std::plus<int>(), _1,
164  bind(&Value::update, _2, object))))
165  return;
166 
168  list.add(kTargetId, target);
169  list.add(kWeightId, weight);
170  for(typename std::vector<Value>::const_iterator iter = values.begin();
171  iter != values.end(); ++iter)
172  list.add(iter->getName(), iter->getValue());
173 
174  cache->eval(list);
175 }
PhysicsTools::MVAComputerCache cache
double eval(Iterator_t first, Iterator_t last) const
evaluate variables given by a range of iterators given by first and last
Cheap generic unique keyword identifier class.
Definition: AtomicId.h:31
std::vector< Value > values
bool update(const Object &object) const
Helper class that can contain an list of identifier-value pairs.
Definition: Variable.h:81
int weight
Definition: histoStyle.py:50
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
void add(AtomicId id, double value)
Definition: Variable.h:106

Member Data Documentation

template<class Record , typename Object , class Filler = MVAModuleHelperDefaultFiller<Object>>
PhysicsTools::MVAComputerCache PhysicsTools::MVAModuleHelper< Record, Object, Filler >::cache
private

Definition at line 79 of file MVAModuleHelper.h.

template<class Record , typename Object , class Filler = MVAModuleHelperDefaultFiller<Object>>
const std::string PhysicsTools::MVAModuleHelper< Record, Object, Filler >::label
private
template<class Record , typename Object , class Filler = MVAModuleHelperDefaultFiller<Object>>
std::vector<Value> PhysicsTools::MVAModuleHelper< Record, Object, Filler >::values
private

Definition at line 104 of file MVAModuleHelper.h.

Referenced by python.seqvaluedict.seqdict::items().