CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  const unsigned int& mc, const bool& willFinalize,
21  DQMStore::IBooker & ibook) :
22  BaseTagInfoPlotter(folderName, etaPtBin),
23  jetTagComputer(tagName), computer(0),
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  }
33  else pSets.push_back(pSet);
34 
35  for(unsigned int i = 0; i != pSets.size(); ++i) {
36  ostringstream ss;
37  ss << "CAT" << i;
38  categoryPlotters.push_back(
39  new TaggingVariablePlotter(folderName, etaPtBin,
40  pSets[i], mc, willFinalize, ibook,
41  i ? ss.str() : string()));
42  }
43 }
44 
46 {
47  for_each(categoryPlotters.begin(), categoryPlotters.end(),
48  bind(&::operator delete, _1));
49 }
50 
52 {
54  setup.get<JetTagComputerRecord>().get(jetTagComputer, handle);
55  computer = dynamic_cast<const GenericMVAJetTagComputer*>(handle.product());
56 
57  if (!computer)
58  throw cms::Exception("Configuration")
59  << "JetTagComputer passed to "
60  "MVAJetTagPlotter::analyzeTag is not a "
61  "GenericMVAJetTagComputer." << endl;
62 }
63 
64 void MVAJetTagPlotter::analyzeTag (const vector<const BaseTagInfo*> &baseTagInfos, const double & jec,
65  const int &jetFlavour)
66 {
67  analyzeTag(baseTagInfos,jec,jetFlavour,1.);
68 }
69 
70 void MVAJetTagPlotter::analyzeTag (const vector<const BaseTagInfo*> &baseTagInfos,
71  const double & jec,
72  const int &jetFlavour,
73  const float & w)
74 {
75  const JetTagComputer::TagInfoHelper helper(baseTagInfos);
76  const TaggingVariableList& vars = computer->taggingVariables(helper);
77 
78  categoryPlotters.front()->analyzeTag(vars, jetFlavour,w);
80  unsigned int cat =
81  (unsigned int)(vars.get(categoryVariable, -1) + 1);
82  if (cat >= 1 && cat < categoryPlotters.size())
83  categoryPlotters[cat]->analyzeTag(vars, jetFlavour,w);
84  }
85 }
86 
88 {
89  //nothing done here in principle and function below does not work
90  /*
91  for_each(categoryPlotters.begin(), categoryPlotters.end(),
92  boost::bind(&TaggingVariablePlotter::finalize, _1, boost::ref(ibook_), _2, boost::ref(igetter_)));
93  */
94 }
95 
97 {
98  for_each(categoryPlotters.begin(), categoryPlotters.end(),
99  boost::bind(&TaggingVariablePlotter::psPlot, _1, boost::ref(name)));
100 }
101 
103 {
104  for_each(categoryPlotters.begin(), categoryPlotters.end(),
105  boost::bind(&TaggingVariablePlotter::epsPlot, _1, boost::ref(name)));
106 }
107 
109 {
110  vector<string> labels = computer->getInputLabels();
111  if (labels.empty())
112  labels.push_back("tagInfos");
113  return labels;
114 }
void psPlot(const std::string &name)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
const double w
Definition: UKUtility.cc:23
void epsPlot(const std::string &name)
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::string jetTagComputer
const std::vector< std::string > & getInputLabels() const
def cat
Definition: eostools.py:400
tuple handle
Definition: patZpeak.py:22
TaggingValue get(TaggingVariableName tag) const
MVAJetTagPlotter(const std::string &tagName, const EtaPtBin &etaPtBin, const edm::ParameterSet &pSet, const std::string &folderName, const unsigned int &mc, const bool &willFinalize, DQMStore::IBooker &ibook)
const T & get() const
Definition: EventSetup.h:56
std::vector< TaggingVariablePlotter * > categoryPlotters
TaggingVariableName getTaggingVariableName(const std::string &name)
T const * product() const
Definition: ESHandle.h:86
virtual void analyzeTag(const std::vector< const reco::BaseTagInfo * > &baseTagInfos, const double &jec, const int &jetFlavour)
const GenericMVAJetTagComputer * computer
virtual void setEventSetup(const edm::EventSetup &setup)
void epsPlot(const std::string &name)
virtual std::vector< std::string > tagInfoRequirements() const
reco::TaggingVariableName categoryVariable
virtual void finalize(DQMStore::IBooker &ibook_, DQMStore::IGetter &igetter_)
void psPlot(const std::string &name)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
virtual reco::TaggingVariableList taggingVariables(const reco::BaseTagInfo &tagInfo) const