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 
17 
18 using namespace reco;
19 using namespace PhysicsTools;
20 
21 static std::vector<std::string>
23  std::auto_ptr<TagInfoMVACategorySelector> &selector)
24 {
25  if (params.getParameter<bool>("useCategories")) {
26  selector = std::auto_ptr<TagInfoMVACategorySelector>(
27  new TagInfoMVACategorySelector(params));
28 
29  return selector->getCategoryLabels();
30  } else {
31  std::string calibrationRecord =
32  params.getParameter<std::string>("calibrationRecord");
33 
34  std::vector<std::string> calibrationLabels;
35  calibrationLabels.push_back(calibrationRecord);
36  return calibrationLabels;
37  }
38 }
39 
41  const edm::ParameterSet &params) :
42  computerCache_(getCalibrationLabels(params, categorySelector_)),
43  recordLabel_(params.getParameter<std::string>("recordLabel"))
44 {
45 }
46 
48 {
49 }
50 
52 
54 
55  // retrieve MVAComputer calibration container
57  dependentRecord.get(recordLabel_, calibHandle);
58  const Calibration::MVAComputerContainer *calib = calibHandle.product();
59 
60  // check for updates
61  computerCache_.update(calib);
62 }
63 
65 {
67 
68  // retrieve index of computer in case categories are used
69  int index = 0;
70  if (categorySelector_.get()) {
71  index = categorySelector_->findCategory(variables);
72  if (index < 0)
73  return -10.0;
74  }
75 
76  GenericMVAComputer const* computer = computerCache_.getComputer(index);
77 
78  if (!computer)
79  return -10.0;
80 
81  return computer->eval(variables);
82 }
83 
86 {
88 
89  // add jet pt and jet eta variables (ordering irrelevant)
90  edm::RefToBase<Jet> jet = baseTag.jet();
91  variables.push_back(TaggingVariable(btau::jetPt, jet->pt()));
92  variables.push_back(TaggingVariable(btau::jetEta, jet->eta()));
93 
94  return variables;
95 }
96 
99 {
100  return taggingVariables(info.getBase(0));
101 }
T getParameter(std::string const &) const
static const TGPicture * info(bool iBackgroundIsBlack)
void push_back(const TaggingVariable &t)
JetCorrectorParameters::Record record
Definition: classes.h:7
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 double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
virtual void initialize(const JetTagComputerRecord &)
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)
GenericMVAComputerCache computerCache_
void get(HolderT &iHolder) const
virtual float discriminator(const TagInfoHelper &info) const
std::pair< TaggingVariableName, TaggingValue > TaggingVariable
std::auto_ptr< TagInfoMVACategorySelector > categorySelector_
const reco::BaseTagInfo & getBase(unsigned int index) const
GenericMVAComputer const * getComputer(int index) const
GenericMVAJetTagComputer(const edm::ParameterSet &parameters)
virtual reco::TaggingVariableList taggingVariables(const reco::BaseTagInfo &tagInfo) const