Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-31 02:19:53

0001 #include <string>
0002 
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "FWCore/Utilities/interface/EDMException.h"
0005 
0006 #include "DataFormats/BTauReco/interface/SoftLeptonTagInfo.h"
0007 
0008 #include "RecoBTag/SoftLepton/interface/LeptonSelector.h"
0009 
0010 using namespace btag;
0011 
0012 LeptonSelector::LeptonSelector(const edm::ParameterSet &params)
0013     : m_sign(option(params.getParameter<std::string>("ipSign"))),
0014       m_leptonId(reco::SoftLeptonProperties::Quality::btagLeptonCands),
0015       m_qualityCut(0.5) {
0016   std::string leptonId = params.getParameter<std::string>("leptonId");
0017   double qualityCut = params.getParameter<double>("qualityCut");
0018   if (!leptonId.empty() || qualityCut != m_qualityCut) {
0019     m_leptonId =
0020         reco::SoftLeptonProperties::Quality::byName<reco::SoftLeptonProperties::Quality::Generic>(leptonId.c_str());
0021     m_qualityCut = qualityCut;
0022   }
0023 }
0024 
0025 LeptonSelector::~LeptonSelector() {}
0026 
0027 bool LeptonSelector::operator()(const reco::SoftLeptonProperties &properties, bool use3d) const {
0028   float sipsig = use3d ? properties.sip3dsig : properties.sip2dsig;
0029   if ((isPositive() && sipsig <= 0.0) || (isNegative() && sipsig >= 0.0))
0030     return false;
0031 
0032   bool candSelection = (m_leptonId == reco::SoftLeptonProperties::Quality::btagLeptonCands);
0033   float quality = properties.quality(m_leptonId, !candSelection);
0034   if (candSelection && quality == reco::SoftLeptonProperties::Quality::undef)
0035     return true;  // for backwards compatibility
0036 
0037   return quality > m_qualityCut;
0038 }
0039 
0040 LeptonSelector::sign LeptonSelector::option(const std::string &selection) {
0041   if (selection == "any")
0042     return any;
0043   else if (selection == "negative")
0044     return negative;
0045   else if (selection == "positive")
0046     return positive;
0047   else
0048     throw edm::Exception(edm::errors::Configuration) << "invalid parameter specified for soft lepton selection";
0049 }
0050 
0051 void LeptonSelector::fillPSetDescription(edm::ParameterSetDescription &desc) {
0052   desc.add<std::string>("ipSign", "any");
0053   desc.add<std::string>("leptonId", "");
0054   desc.add<double>("qualityCut", 0.5);
0055 }