CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GenericMVAJetTagComputer.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <iostream>
3 #include <string>
4 #include <memory>
5 
16 
17 using namespace reco;
18 using namespace PhysicsTools;
19 
20 static std::vector<std::string>
22  std::auto_ptr<TagInfoMVACategorySelector> &selector)
23 {
24  if (params.getParameter<bool>("useCategories")) {
25  selector = std::auto_ptr<TagInfoMVACategorySelector>(
26  new TagInfoMVACategorySelector(params));
27 
28  return selector->getCategoryLabels();
29  } else {
30  std::string calibrationRecord =
31  params.getParameter<std::string>("calibrationRecord");
32 
33  std::vector<std::string> calibrationLabels;
34  calibrationLabels.push_back(calibrationRecord);
35  return calibrationLabels;
36  }
37 }
38 
40  const edm::ParameterSet &params) :
41  computerCache(getCalibrationLabels(params, categorySelector))
42 {
43 }
44 
46 {
47 }
48 
50 {
51  // retrieve MVAComputer calibration container
53  es.get<BTauGenericMVAJetTagComputerRcd>().get(calibHandle);
54  const Calibration::MVAComputerContainer *calib = calibHandle.product();
55 
56  // check for updates
57  computerCache.update(calib);
58 }
59 
61 {
63 
64  // retrieve index of computer in case categories are used
65  int index = 0;
66  if (categorySelector.get()) {
67  index = categorySelector->findCategory(variables);
68  if (index < 0)
69  return -10.0;
70  }
71 
72  GenericMVAComputer *computer = computerCache.getComputer(index);
73 
74  if (!computer)
75  return -10.0;
76 
77  return computer->eval(variables);
78 }
79 
82 {
84 
85  // add jet pt and jet eta variables (ordering irrelevant)
86  edm::RefToBase<Jet> jet = baseTag.jet();
87  variables.push_back(TaggingVariable(btau::jetPt, jet->pt()));
88  variables.push_back(TaggingVariable(btau::jetEta, jet->eta()));
89 
90  return variables;
91 }
92 
95 {
96  return taggingVariables(info.getBase(0));
97 }
T getParameter(std::string const &) const
void push_back(const TaggingVariable &t)
GenericMVAComputerCache computerCache
virtual TaggingVariableList taggingVariables(void) const
returns a description of the extended informations in a TaggingVariableList
Definition: BaseTagInfo.h:39
double eval(Iter_t first, Iter_t last) const
virtual void setEventSetup(const edm::EventSetup &es) const
virtual double eta() const
momentum pseudorapidity
virtual edm::RefToBase< Jet > jet(void) const
returns a polymorphic reference to the tagged jet
Definition: BaseTagInfo.h:24
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
bool update(const PhysicsTools::Calibration::MVAComputerContainer *calib)
static std::vector< std::string > getCalibrationLabels(const edm::ParameterSet &params, std::auto_ptr< TagInfoMVACategorySelector > &selector)
virtual float discriminator(const TagInfoHelper &info) const
std::pair< TaggingVariableName, TaggingValue > TaggingVariable
const reco::BaseTagInfo & getBase(unsigned int index) const
std::auto_ptr< TagInfoMVACategorySelector > categorySelector
virtual double pt() const
transverse momentum
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
GenericMVAJetTagComputer(const edm::ParameterSet &parameters)
GenericMVAComputer * getComputer(int index) const
virtual reco::TaggingVariableList taggingVariables(const reco::BaseTagInfo &tagInfo) const