Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:58:55

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   if (params.exists("leptonId") || params.exists("qualityCut")) {
0017     std::string leptonId = params.getParameter<std::string>("leptonId");
0018     m_leptonId =
0019         reco::SoftLeptonProperties::Quality::byName<reco::SoftLeptonProperties::Quality::Generic>(leptonId.c_str());
0020     m_qualityCut = params.getParameter<double>("qualityCut");
0021   }
0022 }
0023 
0024 LeptonSelector::~LeptonSelector() {}
0025 
0026 bool LeptonSelector::operator()(const reco::SoftLeptonProperties &properties, bool use3d) const {
0027   float sipsig = use3d ? properties.sip3dsig : properties.sip2dsig;
0028   if ((isPositive() && sipsig <= 0.0) || (isNegative() && sipsig >= 0.0))
0029     return false;
0030 
0031   bool candSelection = (m_leptonId == reco::SoftLeptonProperties::Quality::btagLeptonCands);
0032   float quality = properties.quality(m_leptonId, !candSelection);
0033   if (candSelection && quality == reco::SoftLeptonProperties::Quality::undef)
0034     return true;  // for backwards compatibility
0035 
0036   return quality > m_qualityCut;
0037 }
0038 
0039 LeptonSelector::sign LeptonSelector::option(const std::string &selection) {
0040   if (selection == "any")
0041     return any;
0042   else if (selection == "negative")
0043     return negative;
0044   else if (selection == "positive")
0045     return positive;
0046   else
0047     throw edm::Exception(edm::errors::Configuration) << "invalid parameter specified for soft lepton selection";
0048 }