CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

PFJetIDSelectionFunctor Class Reference

PF Jet selector for pat::Jets. More...

#include <PhysicsTools/Utilities/interface/PFJetIDSelectionFunctor.h>

Inheritance diagram for PFJetIDSelectionFunctor:
Selector< pat::Jet > binary_function

List of all members.

Public Types

enum  Quality_t { LOOSE, TIGHT, N_QUALITY }
enum  Version_t { FIRSTDATA, N_VERSIONS }

Public Member Functions

bool firstDataCuts (reco::Jet const &jet, pat::strbitset &ret)
bool operator() (reco::PFJet const &jet, pat::strbitset &ret)
bool operator() (const pat::Jet &jet, pat::strbitset &ret)
 This provides the interface for base classes to select objects.
 PFJetIDSelectionFunctor (edm::ParameterSet const &params)
 PFJetIDSelectionFunctor ()
 PFJetIDSelectionFunctor (Version_t version, Quality_t quality)

Private Attributes

index_type indexCEF_
index_type indexCHF_
index_type indexNCH_
index_type indexNConstituents_
index_type indexNEF_
index_type indexNHF_
Quality_t quality_
Version_t version_

Detailed Description

PF Jet selector for pat::Jets.

Selector functor for pat::Jets that implements quality cuts based on studies of noise patterns.

Please see https://twiki.cern.ch/twiki/bin/view/CMS/SWGuidePATSelectors for a general overview of the selectors.

Author:
Salvatore Rappoccio
Version:
Id:
PFJetIDSelectionFunctor.h,v 1.20 2011/04/27 20:39:42 srappocc Exp

Definition at line 28 of file PFJetIDSelectionFunctor.h.


Member Enumeration Documentation

Enumerator:
LOOSE 
TIGHT 
N_QUALITY 

Definition at line 33 of file PFJetIDSelectionFunctor.h.

Enumerator:
FIRSTDATA 
N_VERSIONS 

Definition at line 32 of file PFJetIDSelectionFunctor.h.


Constructor & Destructor Documentation

PFJetIDSelectionFunctor::PFJetIDSelectionFunctor ( ) [inline]

Definition at line 35 of file PFJetIDSelectionFunctor.h.

{}
PFJetIDSelectionFunctor::PFJetIDSelectionFunctor ( edm::ParameterSet const &  params) [inline]

will have other options eventually, most likely

Definition at line 37 of file PFJetIDSelectionFunctor.h.

References Selector< pat::Jet >::bits_, edm::ParameterSet::exists(), FIRSTDATA, Selector< pat::Jet >::getBitTemplate(), edm::ParameterSet::getParameter(), indexCEF_, indexCHF_, indexNCH_, indexNConstituents_, indexNEF_, indexNHF_, LOOSE, Selector< pat::Jet >::push_back(), quality_, Selector< pat::Jet >::retInternal_, Selector< pat::Jet >::setIgnoredCuts(), TIGHT, and version_.

 {
   std::string versionStr = params.getParameter<std::string>("version");
   std::string qualityStr = params.getParameter<std::string>("quality");

   if ( versionStr == "FIRSTDATA" ) 
     version_ = FIRSTDATA;
   else
     version_ = FIRSTDATA;  

   if      ( qualityStr == "LOOSE") quality_ = LOOSE;
   else if ( qualityStr == "TIGHT") quality_ = TIGHT;
   else quality_ = LOOSE;

    push_back("CHF" );
    push_back("NHF" );
    push_back("CEF" );
    push_back("NEF" );
    push_back("NCH" );
    push_back("nConstituents");


    // Set some default cuts for LOOSE, TIGHT
    if ( quality_ == LOOSE ) {
      set("CHF", 0.0);
      set("NHF", 0.99);
      set("CEF", 0.99);
      set("NEF", 0.99);
      set("NCH", 0);
      set("nConstituents", 1);
    } else if ( quality_ == TIGHT ) {
      set("CHF", 0.0);
      set("NHF", 0.9);
      set("CEF", 0.99);
      set("NEF", 0.9);
      set("NCH", 0);
      set("nConstituents", 1);      
    }


    // Now check the configuration to see if the user changed anything
    if ( params.exists("CHF") ) set("CHF", params.getParameter<double>("CHF") );
    if ( params.exists("NHF") ) set("NHF", params.getParameter<double>("NHF") );
    if ( params.exists("CEF") ) set("CEF", params.getParameter<double>("CEF") );
    if ( params.exists("NEF") ) set("NEF", params.getParameter<double>("NEF") );
    if ( params.exists("NCH") ) set("NCH", params.getParameter<int>   ("NCH") );
    if ( params.exists("nConstuents") ) set("nConstituents", params.getParameter<int> ("nConstituents") );

    if ( params.exists("cutsToIgnore") )
      setIgnoredCuts( params.getParameter<std::vector<std::string> >("cutsToIgnore") );


    indexNConstituents_ = index_type (&bits_, "nConstituents");
    indexNEF_ = index_type (&bits_, "NEF");
    indexNHF_ = index_type (&bits_, "NHF");
    indexCEF_ = index_type (&bits_, "CEF");
    indexCHF_ = index_type (&bits_, "CHF");
    indexNCH_ = index_type (&bits_, "NCH");

    retInternal_ = getBitTemplate();
    
  }
PFJetIDSelectionFunctor::PFJetIDSelectionFunctor ( Version_t  version,
Quality_t  quality 
) [inline]

Definition at line 101 of file PFJetIDSelectionFunctor.h.

References Selector< pat::Jet >::bits_, Selector< pat::Jet >::getBitTemplate(), indexCEF_, indexCHF_, indexNCH_, indexNConstituents_, indexNEF_, indexNHF_, LOOSE, Selector< pat::Jet >::push_back(), quality_, Selector< pat::Jet >::retInternal_, and TIGHT.

                                              :
  version_(version), quality_(quality)
 {

    push_back("CHF" );
    push_back("NHF" );
    push_back("CEF" );
    push_back("NEF" );
    push_back("NCH" );
    push_back("nConstituents");


    // Set some default cuts for LOOSE, TIGHT
    if ( quality_ == LOOSE ) {
      set("CHF", 0.0);
      set("NHF", 0.99);
      set("CEF", 0.99);
      set("NEF", 0.99);
      set("NCH", 0);
      set("nConstituents", 1);
    } else if ( quality_ == TIGHT ) {
      set("CHF", 0.0);
      set("NHF", 0.9);
      set("CEF", 0.99);
      set("NEF", 0.9);
      set("NCH", 0);
      set("nConstituents", 1);      
    }


    indexNConstituents_ = index_type (&bits_, "nConstituents");
    indexNEF_ = index_type (&bits_, "NEF");
    indexNHF_ = index_type (&bits_, "NHF");
    indexCEF_ = index_type (&bits_, "CEF");
    indexCHF_ = index_type (&bits_, "CHF");
    indexNCH_ = index_type (&bits_, "NCH");

    retInternal_ = getBitTemplate();   
 }

Member Function Documentation

bool PFJetIDSelectionFunctor::firstDataCuts ( reco::Jet const &  jet,
pat::strbitset ret 
) [inline]

Definition at line 176 of file PFJetIDSelectionFunctor.h.

References abs, reco::CompositePtrCandidate::begin(), reco::PFJet::chargedEmEnergy(), reco::PFJet::chargedEmEnergyFraction(), pat::Jet::chargedEmEnergyFraction(), reco::PFJet::chargedHadronEnergy(), pat::Jet::chargedHadronEnergyFraction(), reco::PFJet::chargedHadronEnergyFraction(), pat::Jet::chargedMultiplicity(), reco::PFJet::chargedMultiplicity(), Selector< pat::Jet >::cut(), alignCSCRings::e, reco::CompositePtrCandidate::end(), reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), reco::PFJet::HFHadronEnergy(), pat::Jet::HFHadronEnergy(), Selector< pat::Jet >::ignoreCut(), indexCEF_, indexCHF_, indexNCH_, indexNConstituents_, indexNEF_, indexNHF_, pat::Jet::isBasicJet(), pat::Jet::isPFJet(), metsig::jet, reco::PFJet::neutralEmEnergy(), reco::PFJet::neutralEmEnergyFraction(), pat::Jet::neutralEmEnergyFraction(), pat::Jet::neutralHadronEnergy(), reco::PFJet::neutralHadronEnergy(), reco::CompositePtrCandidate::numberOfDaughters(), pat::Jet::numberOfDaughters(), Selector< pat::Jet >::passCut(), run_regression::ret, pat::strbitset::set(), and Selector< pat::Jet >::setIgnored().

Referenced by operator()().

  {    

    ret.set(false);

    // cache some variables
    double chf = 0.0;
    double nhf = 0.0;
    double cef = 0.0;
    double nef = 0.0;
    int    nch = 0;
    int    nconstituents = 0;

    // Have to do this because pat::Jet inherits from reco::Jet but not reco::PFJet
    reco::PFJet const * pfJet = dynamic_cast<reco::PFJet const *>(&jet);
    pat::Jet const * patJet = dynamic_cast<pat::Jet const *>(&jet);
    reco::BasicJet const * basicJet = dynamic_cast<reco::BasicJet const *>(&jet);

    if ( patJet != 0 ) {

      if ( patJet->isPFJet() ) {
        chf = patJet->chargedHadronEnergyFraction();
        nhf = ( patJet->neutralHadronEnergy() + patJet->HFHadronEnergy() ) / patJet->energy();
        cef = patJet->chargedEmEnergyFraction();
        nef = patJet->neutralEmEnergyFraction();
        nch = patJet->chargedMultiplicity();
        nconstituents = patJet->numberOfDaughters();
      } 
      // Handle the special case where this is a composed jet for
      // subjet analyses
      else if ( patJet->isBasicJet() ) {
        double e_chf = 0.0;
        double e_nhf = 0.0;
        double e_cef = 0.0;
        double e_nef = 0.0;
        nch = 0;
        nconstituents = 0;

        for ( reco::Jet::const_iterator ibegin = patJet->begin(),
                iend = patJet->end(), isub = ibegin;
              isub != iend; ++isub ) {
          reco::PFJet const * pfsub = dynamic_cast<reco::PFJet const *>( &*isub );
          e_chf += pfsub->chargedHadronEnergy();
          e_nhf += (pfsub->neutralHadronEnergy() + pfsub->HFHadronEnergy());
          e_cef += pfsub->chargedEmEnergy();
          e_nef += pfsub->neutralEmEnergy();
          nch += pfsub->chargedMultiplicity();
          nconstituents += pfsub->numberOfDaughters();
        }
        double e = patJet->energy();
        if ( e > 0.000001 ) {
          chf = e_chf / e;
          nhf = e_nhf / e;
          cef = e_cef / e;
          nef = e_nef / e;
        } else {
          chf = nhf = cef = nef = 0.0;
        }
      }
    } // end if pat jet
    else if ( pfJet != 0 ) {
      chf = pfJet->chargedHadronEnergyFraction();
      nhf = ( pfJet->neutralHadronEnergy() + pfJet->HFHadronEnergy() ) / pfJet->energy();
      cef = pfJet->chargedEmEnergyFraction();
      nef = pfJet->neutralEmEnergyFraction();
      nch = pfJet->chargedMultiplicity();
      nconstituents = pfJet->numberOfDaughters();
    } // end if PF jet
    // Handle the special case where this is a composed jet for
    // subjet analyses
    else if ( basicJet != 0 ) {
      double e_chf = 0.0;
      double e_nhf = 0.0;
      double e_cef = 0.0;
      double e_nef = 0.0;
      nch = 0;
      nconstituents = 0;
      
      for ( reco::Jet::const_iterator ibegin = basicJet->begin(),
              iend = patJet->end(), isub = ibegin;
            isub != iend; ++isub ) {
        reco::PFJet const * pfsub = dynamic_cast<reco::PFJet const *>( &*isub );
        e_chf += pfsub->chargedHadronEnergy();
        e_nhf += (pfsub->neutralHadronEnergy() + pfsub->HFHadronEnergy());
        e_cef += pfsub->chargedEmEnergy();
        e_nef += pfsub->neutralEmEnergy();
        nch += pfsub->chargedMultiplicity();
        nconstituents += pfsub->numberOfDaughters();
      }
      double e = basicJet->energy();
      if ( e > 0.000001 ) {
        chf = e_chf / e;
        nhf = e_nhf / e;
        cef = e_cef / e;
        nef = e_nef / e;
      }
    } // end if basic jet


    // Cuts for all |eta|:
    if ( ignoreCut(indexNConstituents_) || nconstituents > cut(indexNConstituents_, int() ) ) passCut( ret, indexNConstituents_);
    if ( ignoreCut(indexNEF_)           || ( nef < cut(indexNEF_, double()) ) ) passCut( ret, indexNEF_);
    if ( ignoreCut(indexNHF_)           || ( nhf < cut(indexNHF_, double()) ) ) passCut( ret, indexNHF_);    
    // Cuts for |eta| < 2.4:
    if ( ignoreCut(indexCEF_)           || ( cef < cut(indexCEF_, double()) || std::abs(jet.eta()) > 2.4 ) ) passCut( ret, indexCEF_);
    if ( ignoreCut(indexCHF_)           || ( chf > cut(indexCHF_, double()) || std::abs(jet.eta()) > 2.4 ) ) passCut( ret, indexCHF_);
    if ( ignoreCut(indexNCH_)           || ( nch > cut(indexNCH_, int())    || std::abs(jet.eta()) > 2.4 ) ) passCut( ret, indexNCH_);    

    setIgnored( ret );
    return (bool)ret;
  }
bool PFJetIDSelectionFunctor::operator() ( const pat::Jet t,
pat::strbitset ret 
) [inline, virtual]

This provides the interface for base classes to select objects.

Implements Selector< pat::Jet >.

Definition at line 146 of file PFJetIDSelectionFunctor.h.

References pat::Jet::correctedJet(), pat::Jet::currentJECLevel(), FIRSTDATA, firstDataCuts(), run_regression::ret, and version_.

  {
    if ( version_ == FIRSTDATA ) {
      if ( jet.currentJECLevel() == "Uncorrected" ) 
        return firstDataCuts( jet, ret );
      else 
        return firstDataCuts( jet.correctedJet("Uncorrected"), ret );
    }
    else {
      return false;
    }
  }
bool PFJetIDSelectionFunctor::operator() ( reco::PFJet const &  jet,
pat::strbitset ret 
) [inline]

Definition at line 164 of file PFJetIDSelectionFunctor.h.

References FIRSTDATA, firstDataCuts(), and version_.

  {
    if ( version_ == FIRSTDATA ) return firstDataCuts( jet, ret );
    else {
      return false;
    }
  }

Member Data Documentation

Definition at line 297 of file PFJetIDSelectionFunctor.h.

Referenced by firstDataCuts(), and PFJetIDSelectionFunctor().

Definition at line 298 of file PFJetIDSelectionFunctor.h.

Referenced by firstDataCuts(), and PFJetIDSelectionFunctor().

Definition at line 299 of file PFJetIDSelectionFunctor.h.

Referenced by firstDataCuts(), and PFJetIDSelectionFunctor().

Definition at line 294 of file PFJetIDSelectionFunctor.h.

Referenced by firstDataCuts(), and PFJetIDSelectionFunctor().

Definition at line 295 of file PFJetIDSelectionFunctor.h.

Referenced by firstDataCuts(), and PFJetIDSelectionFunctor().

Definition at line 296 of file PFJetIDSelectionFunctor.h.

Referenced by firstDataCuts(), and PFJetIDSelectionFunctor().

Definition at line 292 of file PFJetIDSelectionFunctor.h.

Referenced by PFJetIDSelectionFunctor().

Definition at line 291 of file PFJetIDSelectionFunctor.h.

Referenced by operator()(), and PFJetIDSelectionFunctor().