CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/RecoBTag/SoftLepton/src/LeptonSelector.cc

Go to the documentation of this file.
00001 #include <string>
00002 
00003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00004 #include "FWCore/Utilities/interface/EDMException.h"
00005 
00006 #include "DataFormats/BTauReco/interface/SoftLeptonTagInfo.h"
00007 
00008 #include "RecoBTag/SoftLepton/interface/LeptonSelector.h"
00009 
00010 using namespace btag;
00011 
00012 LeptonSelector::LeptonSelector(const edm::ParameterSet &params) :
00013   m_sign(option(params.getParameter<std::string>("ipSign"))),
00014   m_leptonId(reco::SoftLeptonProperties::quality::btagLeptonCands),
00015   m_qualityCut(0.5)
00016 {
00017   if (params.exists("leptonId") || params.exists("reco::SoftLeptonProperties::qualityCut")) {
00018     std::string leptonId = params.getParameter<std::string>("leptonId");
00019     m_leptonId = reco::SoftLeptonProperties::quality::byName<reco::SoftLeptonProperties::quality::Generic>(leptonId.c_str());
00020     m_qualityCut = params.getParameter<double>("reco::SoftLeptonProperties::qualityCut");
00021   }
00022 }
00023 
00024 LeptonSelector::~LeptonSelector()
00025 {
00026 }
00027 
00028 bool LeptonSelector::operator() (const reco::SoftLeptonProperties &properties, bool use3d) const
00029 {
00030   float sip = use3d ? properties.sip3d : properties.sip2d;
00031   if ((isPositive() && sip <= 0.0) ||
00032       (isNegative() && sip >= 0.0))
00033     return false;
00034 
00035   bool candSelection = (m_leptonId == reco::SoftLeptonProperties::quality::btagLeptonCands);
00036   float quality = properties.quality(m_leptonId, !candSelection);
00037   if (candSelection && quality == reco::SoftLeptonProperties::quality::undef)
00038    return true;         // for backwards compatibility
00039 
00040   return quality > m_qualityCut;
00041 }
00042 
00043 LeptonSelector::sign LeptonSelector::option(const std::string & selection)
00044 {
00045   if (selection == "any")
00046     return any;
00047   else if (selection == "negative")
00048     return negative;
00049   else if (selection == "positive")
00050     return positive;
00051   else 
00052     throw edm::Exception( edm::errors::Configuration ) << "invalid parameter specified for soft lepton selection";
00053 }