CMS 3D CMS Logo

MVAJetTagPlotter.cc
Go to the documentation of this file.
1 #include <sstream>
2 
3 #include <boost/bind.hpp>
4 
8 
10 
11 using namespace std;
12 using namespace boost;
13 using namespace edm;
14 using namespace reco;
15 
17  const EtaPtBin &etaPtBin,
18  const ParameterSet &pSet,
19  const std::string& folderName,
20  unsigned int mc, bool willFinalize,
21  DQMStore::IBooker & ibook):
22  BaseTagInfoPlotter(folderName, etaPtBin),
23  jetTagComputer(tagName), computer(nullptr),
24  categoryVariable(btau::lastTaggingVariable)
25 {
26  typedef std::vector<ParameterSet> VParameterSet;
27  VParameterSet pSets;
28  if (pSet.exists("categoryVariable")) {
30  pSet.getParameter<string>("categoryVariable"));
31  pSets = pSet.getParameter<VParameterSet>("categories");
32  } else pSets.push_back(pSet);
33 
34  for (unsigned int i = 0; i != pSets.size(); ++i) {
35  std::string ss = "CAT";
36  ss += std::to_string(i);
37  categoryPlotters.push_back(
38  std::make_unique<TaggingVariablePlotter>(folderName, etaPtBin,
39  pSets[i], mc, willFinalize, ibook,
40  i ? ss : std::string())
41  );
42  }
43 }
44 
46 
48 {
50  setup.get<JetTagComputerRecord>().get(jetTagComputer, handle);
51  computer = dynamic_cast<const GenericMVAJetTagComputer*>(handle.product());
52 
53  if (!computer)
54  throw cms::Exception("Configuration")
55  << "JetTagComputer passed to "
56  "MVAJetTagPlotter::analyzeTag is not a "
57  "GenericMVAJetTagComputer." << endl;
58 }
59 
60 void MVAJetTagPlotter::analyzeTag(const vector<const BaseTagInfo*> &baseTagInfos, double jec, int jetFlavour, float w/*=1*/)
61 {
62  const JetTagComputer::TagInfoHelper helper(baseTagInfos);
64 
65  categoryPlotters.front()->analyzeTag(vars, jetFlavour, w);
67  unsigned int cat = (unsigned int)(vars.get(categoryVariable, -1) + 1);
68  if (cat >= 1 && cat < categoryPlotters.size())
69  categoryPlotters[cat]->analyzeTag(vars, jetFlavour, w);
70  }
71 }
72 
74 {
75  //nothing done here in principle and function below does not work
76  /*
77  for_each(categoryPlotters.begin(), categoryPlotters.end(),
78  boost::bind(&TaggingVariablePlotter::finalize, _1, boost::ref(ibook_), _2, boost::ref(igetter_)));
79  */
80 }
81 
83 {
84  for (const auto& plot: categoryPlotters)
85  plot->psPlot(name);
86 }
87 
89 {
90  for (const auto& plot: categoryPlotters)
91  plot->epsPlot(name);
92 }
93 
95 {
96  vector<string> labels = computer->getInputLabels();
97  if (labels.empty())
98  labels.push_back("tagInfos");
99  return labels;
100 }
T getParameter(std::string const &) const
~MVAJetTagPlotter() override
MVAJetTagPlotter(const std::string &tagName, const EtaPtBin &etaPtBin, const edm::ParameterSet &pSet, const std::string &folderName, unsigned int mc, bool willFinalize, DQMStore::IBooker &ibook)
Definition: helper.py:1
Definition: CLHEP.h:16
const double w
Definition: UKUtility.cc:23
std::vector< std::unique_ptr< TaggingVariablePlotter > > categoryPlotters
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
#define nullptr
bool exists(std::string const &parameterName) const
checks if a parameter exists
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
void finalize(DQMStore::IBooker &ibook_, DQMStore::IGetter &igetter_) override
std::string jetTagComputer
def cat(path)
Definition: eostools.py:401
const std::vector< std::string > & getInputLabels() const
std::vector< std::string > tagInfoRequirements() const override
TaggingValue get(TaggingVariableName tag) const
void epsPlot(const std::string &name) override
void psPlot(const std::string &name) override
TaggingVariableName getTaggingVariableName(const std::string &name)
const GenericMVAJetTagComputer * computer
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:71
reco::TaggingVariableName categoryVariable
void setEventSetup(const edm::EventSetup &setup) override
vars
Definition: DeepTauId.cc:77
void analyzeTag(const std::vector< const reco::BaseTagInfo * > &baseTagInfos, double jec, int jetFlavour, float w=1) override
T const * product() const
Definition: ESHandle.h:86
virtual reco::TaggingVariableList taggingVariables(const reco::BaseTagInfo &tagInfo) const