Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:24:37

0001 #include <ext/functional>
0002 #include <string>
0003 #include <vector>
0004 
0005 #include "FWCore/Utilities/interface/Exception.h"
0006 #include "FWCore/Utilities/interface/EDMException.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "DataFormats/BTauReco/interface/TaggingVariable.h"
0009 #include "PhysicsTools/MVAComputer/interface/Calibration.h"
0010 #include "RecoBTau/JetTagComputer/interface/TagInfoMVACategorySelector.h"
0011 
0012 using namespace reco;
0013 
0014 TagInfoMVACategorySelector::TagInfoMVACategorySelector(const edm::ParameterSet &params) {
0015   std::string variableName = params.getParameter<std::string>("categoryVariableName");
0016 
0017   categoryVariable = getTaggingVariableName(variableName);
0018   if (categoryVariable >= btau::lastTaggingVariable)
0019     throw cms::Exception("TagInfoMVACategorySelector")
0020         << "No such tagging variable \"" << categoryVariable << "\"." << std::endl;
0021 
0022   categoryLabels = params.getParameter<std::vector<std::string> >("calibrationRecords");
0023   for (std::vector<std::string>::iterator iter = categoryLabels.begin(); iter != categoryLabels.end(); iter++)
0024     if (*iter == " " || *iter == "-" || *iter == "*")
0025       *iter = "";
0026 }
0027 
0028 TagInfoMVACategorySelector::~TagInfoMVACategorySelector() {}
0029 
0030 int TagInfoMVACategorySelector::findCategory(const TaggingVariableList &taggingVariables) const {
0031   int index = (int)taggingVariables.get(categoryVariable, -1);
0032 
0033   if (index < 0 || (unsigned int)index >= categoryLabels.size())
0034     return -1;
0035 
0036   return index;
0037 }