Go to the documentation of this file.00001 #include <sstream>
00002
00003 #include <boost/bind.hpp>
00004
00005 #include "FWCore/Framework/interface/ESHandle.h"
00006 #include "RecoBTau/JetTagComputer/interface/JetTagComputer.h"
00007 #include "RecoBTau/JetTagComputer/interface/JetTagComputerRecord.h"
00008
00009 #include "DQMOffline/RecoB/interface/MVAJetTagPlotter.h"
00010
00011 using namespace std;
00012 using namespace boost;
00013 using namespace edm;
00014 using namespace reco;
00015
00016 MVAJetTagPlotter::MVAJetTagPlotter(const std::string &tagName,
00017 const EtaPtBin &etaPtBin,
00018 const ParameterSet &pSet,
00019 const std::string& folderName,
00020 const bool& update,
00021 const bool& mc) :
00022 BaseTagInfoPlotter(folderName, etaPtBin),
00023 jetTagComputer(tagName), computer(0),
00024 categoryVariable(btau::lastTaggingVariable)
00025 {
00026 typedef std::vector<ParameterSet> VParameterSet;
00027 VParameterSet pSets;
00028 if (pSet.exists("categoryVariable")) {
00029 categoryVariable = getTaggingVariableName(
00030 pSet.getParameter<string>("categoryVariable"));
00031 pSets = pSet.getParameter<VParameterSet>("categories");
00032 } else
00033 pSets.push_back(pSet);
00034
00035 for(unsigned int i = 0; i != pSets.size(); ++i) {
00036 ostringstream ss;
00037 ss << "CAT" << i;
00038 categoryPlotters.push_back(
00039 new TaggingVariablePlotter(folderName, etaPtBin,
00040 pSets[i], update,mc,
00041 i ? ss.str() : string()));
00042 }
00043 }
00044
00045 MVAJetTagPlotter::~MVAJetTagPlotter ()
00046 {
00047 for_each(categoryPlotters.begin(), categoryPlotters.end(),
00048 bind(&::operator delete, _1));
00049 }
00050
00051 void MVAJetTagPlotter::setEventSetup(const edm::EventSetup &setup)
00052 {
00053 ESHandle<JetTagComputer> handle;
00054 setup.get<JetTagComputerRecord>().get(jetTagComputer, handle);
00055 computer = dynamic_cast<const GenericMVAJetTagComputer*>(handle.product());
00056
00057 if (!computer)
00058 throw cms::Exception("Configuration")
00059 << "JetTagComputer passed to "
00060 "MVAJetTagPlotter::analyzeTag is not a "
00061 "GenericMVAJetTagComputer." << endl;
00062 }
00063
00064 void MVAJetTagPlotter::analyzeTag (const vector<const BaseTagInfo*> &baseTagInfos,
00065 const int &jetFlavour)
00066 {
00067
00068
00069
00070 const JetTagComputer::TagInfoHelper helper(baseTagInfos);
00071 const TaggingVariableList& vars = computer->taggingVariables(helper);
00072
00073 categoryPlotters.front()->analyzeTag(vars, jetFlavour);
00074 if (categoryVariable != btau::lastTaggingVariable) {
00075 unsigned int cat =
00076 (unsigned int)(vars.get(categoryVariable, -1) + 1);
00077 if (cat >= 1 && cat < categoryPlotters.size())
00078 categoryPlotters[cat]->analyzeTag(vars, jetFlavour);
00079 }
00080 }
00081
00082 void MVAJetTagPlotter::finalize()
00083 {
00084 for_each(categoryPlotters.begin(), categoryPlotters.end(),
00085 bind(&TaggingVariablePlotter::finalize, _1));
00086 }
00087
00088 void MVAJetTagPlotter::psPlot(const std::string &name)
00089 {
00090 for_each(categoryPlotters.begin(), categoryPlotters.end(),
00091 boost::bind(&TaggingVariablePlotter::psPlot, _1, boost::ref(name)));
00092 }
00093
00094
00095
00096
00097
00098
00099
00100 void MVAJetTagPlotter::epsPlot(const std::string &name)
00101 {
00102 for_each(categoryPlotters.begin(), categoryPlotters.end(),
00103 boost::bind(&TaggingVariablePlotter::epsPlot, _1, boost::ref(name)));
00104 }
00105
00106 vector<string> MVAJetTagPlotter::tagInfoRequirements() const
00107 {
00108 vector<string> labels = computer->getInputLabels();
00109 if (labels.empty())
00110 labels.push_back("tagInfos");
00111 return labels;
00112 }