CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoBTau/JetTagComputer/src/TagInfoMVACategorySelector.cc

Go to the documentation of this file.
00001 #include <ext/functional>
00002 #include <string>
00003 #include <vector>
00004 
00005 #include "FWCore/Utilities/interface/Exception.h"
00006 #include "FWCore/Utilities/interface/EDMException.h"
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008 #include "DataFormats/BTauReco/interface/TaggingVariable.h"
00009 #include "PhysicsTools/MVAComputer/interface/Calibration.h"
00010 #include "RecoBTau/JetTagComputer/interface/TagInfoMVACategorySelector.h"
00011 
00012 using namespace reco;
00013 
00014 TagInfoMVACategorySelector::TagInfoMVACategorySelector(
00015                                         const edm::ParameterSet &params)
00016 {
00017         std::string variableName =
00018                 params.getParameter<std::string>("categoryVariableName");
00019 
00020         categoryVariable = getTaggingVariableName(variableName);
00021         if (categoryVariable >= btau::lastTaggingVariable)
00022                 throw cms::Exception("TagInfoMVACategorySelector")
00023                         << "No such tagging variable \""
00024                         << categoryVariable << "\"." << std::endl;
00025 
00026         categoryLabels = params.getParameter<std::vector<std::string> >(
00027                                                         "calibrationRecords");
00028         for(std::vector<std::string>::iterator iter = categoryLabels.begin();
00029             iter != categoryLabels.end(); iter++)
00030                 if (*iter == " " || *iter == "-" || *iter == "*")
00031                         *iter = "";
00032 }
00033 
00034 TagInfoMVACategorySelector::~TagInfoMVACategorySelector()
00035 {
00036 }
00037 
00038 int TagInfoMVACategorySelector::findCategory(
00039                         const TaggingVariableList &taggingVariables) const
00040 {
00041         int index = (int)taggingVariables.get(categoryVariable, -1);
00042 
00043         if (index < 0 || (unsigned int)index >= categoryLabels.size())
00044                 return -1;
00045 
00046         return index;
00047 }