CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RecoTauMVAHelper.h
Go to the documentation of this file.
1 #ifndef RecoTauTag_RecoTau_RecoTauMVAHelper_h
2 #define RecoTauTag_RecoTau_RecoTauMVAHelper_h
3 
4 /*
5  * RecoTauMVAHelper
6  *
7  * Manages DB retrieval and application of MVAComputers to reco::PFTaus. Takes
8  * as input a name (into an MVAComputerContainer) and an optional esLabel. The
9  * MVA helper retrieves the MVA from the database and determines the associated
10  * list of discriminant functions. These discriminant functions are all defined
11  * as RecoTauDiscriminantPlugins. This class then builds the appropriate
12  * plugins. When passed a tau using operator(), the class computes the output
13  * of all discriminates, passes them to the MVA, and returns the result.
14  *
15  * The plugin can also be used to pass training data to the MVA framework. See
16  * RecoTauTag/TauTagTools/test/training for examples.
17  *
18  * Options for the different plugins can be specified with the pluginOptions.
19  * Any entry in the pluginOptionPSet will passed to the plugin of the same name.
20  *
21  * Author: Evan K. Friis (UC Davis)
22  *
23  * Based on code by Christophe Saoute in -
24  * PhysicsTools/MVAComputer/interface/MVAModuleHelper.h
25  */
26 
27 #include <boost/ptr_container/ptr_map.hpp>
28 #include <string>
29 
31 
37 
38 namespace reco { namespace tau {
39 
41  public:
42  explicit RecoTauMVAHelper(const std::string &name,
43  const std::string &eslabel,
44  const edm::ParameterSet &pluginOptions);
46 
47  // Setup event information and retrive MVA from DB
48  void setEvent(const edm::Event& evt, const edm::EventSetup &es);
49 
50  // Apply MVA to tau and return result
51  double operator()(const PFTauRef &tau) const;
52 
53  // Retrive the raw input for a given tau that would be passed to the MVA
55  const PFTauRef& tau) const;
56 
57  // Add a training event of type <target> with given weight
58  void train(const PFTauRef &tau, bool target, double weight = 1.0) const;
59  private:
60  // Name of computer in the DB record
62  // Name of label for event setup record
64  // Options to pass to the plugins
66 
68  // Map our discriminant plugins to their "MVA name"
69  typedef boost::ptr_map<PhysicsTools::AtomicId, RecoTauDiscriminantPlugin>
72  // Helper function to load relevant plugins for a MVA computer
75  // Load the plugin values for this tau
76  void fillValues(const reco::PFTauRef& tau) const;
78 };
79 }} // end reco::tau
80 #endif
void setEvent(const edm::Event &evt, const edm::EventSetup &es)
void fillValues(const reco::PFTauRef &tau) const
boost::ptr_map< PhysicsTools::AtomicId, RecoTauDiscriminantPlugin > PluginMap
PhysicsTools::Variable::ValueList values_
double operator()(const PFTauRef &tau) const
edm::ParameterSet pluginOptions_
const PhysicsTools::Variable::ValueList & discriminants(const PFTauRef &tau) const
Helper class that can contain an list of identifier-value pairs.
Definition: Variable.h:82
RecoTauMVAHelper(const std::string &name, const std::string &eslabel, const edm::ParameterSet &pluginOptions)
void train(const PFTauRef &tau, bool target, double weight=1.0) const
PhysicsTools::MVAComputerCache computer_
Creates and and MVAComputer from calibrations via EventSetup.
int weight
Definition: histoStyle.py:50
void loadDiscriminantPlugins(const PhysicsTools::Calibration::MVAComputer &computer)