CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

MuonVPlusJetsIDSelectionFunctor Class Reference

#include <MuonVPlusJetsIDSelectionFunctor.h>

Inheritance diagram for MuonVPlusJetsIDSelectionFunctor:
Selector< pat::Muon > binary_function

List of all members.

Public Types

enum  Version_t { SUMMER08, FIRSTDATA, SPRING10, N_VERSIONS }

Public Member Functions

bool firstDataCuts (const pat::Muon &muon, pat::strbitset &ret)
void initialize (Version_t version, double chi2=10.0, double d0=999.0, double ed0=999.0, double sd0=3.0, int nhits=11, int nValidMuonHits=0, double ecalveto=4.0, double hcalveto=6.0, double reliso=0.05)
 MuonVPlusJetsIDSelectionFunctor ()
 MuonVPlusJetsIDSelectionFunctor (edm::ParameterSet const &parameters)
 MuonVPlusJetsIDSelectionFunctor (Version_t version, double chi2=10.0, double d0=0.2, double ed0=999.0, double sd0=999.0, int nhits=11, int nValidMuonHits=0, double ecalveto=4.0, double hcalveto=6.0, double reliso=0.05)
bool operator() (const pat::Muon &muon, edm::EventBase const &event, pat::strbitset &ret)
 This provides an alternative signature that includes extra information.
bool operator() (const pat::Muon &muon, pat::strbitset &ret)
 This provides the interface for base classes to select objects.
bool spring10Cuts (const pat::Muon &muon, edm::EventBase const &event, pat::strbitset &ret)
bool summer08Cuts (const pat::Muon &muon, pat::strbitset &ret)

Private Attributes

edm::InputTag beamLineSrc_
index_type indexChi2_
index_type indexD0_
index_type indexECalVeto_
index_type indexED0_
index_type indexHCalVeto_
index_type indexNHits_
index_type indexNValMuHits_
index_type indexRelIso_
index_type indexSD0_
bool recalcDBFromBSp_
Version_t version_

Detailed Description

Definition at line 13 of file MuonVPlusJetsIDSelectionFunctor.h.


Member Enumeration Documentation

Enumerator:
SUMMER08 
FIRSTDATA 
SPRING10 
N_VERSIONS 

Definition at line 17 of file MuonVPlusJetsIDSelectionFunctor.h.


Constructor & Destructor Documentation

MuonVPlusJetsIDSelectionFunctor::MuonVPlusJetsIDSelectionFunctor ( ) [inline]

Definition at line 19 of file MuonVPlusJetsIDSelectionFunctor.h.

{}
MuonVPlusJetsIDSelectionFunctor::MuonVPlusJetsIDSelectionFunctor ( edm::ParameterSet const &  parameters) [inline]

Definition at line 21 of file MuonVPlusJetsIDSelectionFunctor.h.

References beamLineSrc_, Exception, edm::ParameterSet::exists(), FIRSTDATA, Selector< pat::Muon >::getBitTemplate(), edm::ParameterSet::getParameter(), initialize(), N_VERSIONS, recalcDBFromBSp_, Selector< pat::Muon >::retInternal_, Selector< pat::Muon >::setIgnoredCuts(), SPRING10, SUMMER08, and AlCaRecoCosmics_cfg::version.

                                                                        {

    std::string versionStr = parameters.getParameter<std::string>("version");

    Version_t version = N_VERSIONS;

    if ( versionStr == "SUMMER08" ) {
      version = SUMMER08;
    }
    else if ( versionStr == "FIRSTDATA" ) {
      version = FIRSTDATA;
    }
    else if ( versionStr == "SPRING10" ) {
      version = SPRING10;
    }
    else {
      throw cms::Exception("InvalidInput") << "Expect version to be one of SUMMER08, FIRSTDATA, SPRING10," << std::endl;
    }

    initialize( version, 
                parameters.getParameter<double>("Chi2"),
                parameters.getParameter<double>("D0")  ,
                parameters.getParameter<double>("ED0")  ,
                parameters.getParameter<double>("SD0")  ,
                parameters.getParameter<int>   ("NHits")   ,
                parameters.getParameter<int>   ("NValMuHits"),
                parameters.getParameter<double>("ECalVeto")   ,
                parameters.getParameter<double>("HCalVeto")   ,
                parameters.getParameter<double>("RelIso") );
    if ( parameters.exists("cutsToIgnore") )
      setIgnoredCuts( parameters.getParameter<std::vector<std::string> >("cutsToIgnore") );
        
    retInternal_ = getBitTemplate();

    recalcDBFromBSp_ = parameters.getParameter<bool>("RecalcFromBeamSpot");
    beamLineSrc_ = parameters.getParameter<edm::InputTag>("beamLineSrc");    
  }
MuonVPlusJetsIDSelectionFunctor::MuonVPlusJetsIDSelectionFunctor ( Version_t  version,
double  chi2 = 10.0,
double  d0 = 0.2,
double  ed0 = 999.0,
double  sd0 = 999.0,
int  nhits = 11,
int  nValidMuonHits = 0,
double  ecalveto = 4.0,
double  hcalveto = 6.0,
double  reliso = 0.05 
) [inline]

Definition at line 60 of file MuonVPlusJetsIDSelectionFunctor.h.

References ExpressReco_HICollisions_FallBack::chi2, debug_cff::d0, and initialize().

                                     : recalcDBFromBSp_(false) {
    initialize( version, chi2, d0, ed0, sd0, nhits, nValidMuonHits, ecalveto, hcalveto, reliso );
  }

Member Function Documentation

bool MuonVPlusJetsIDSelectionFunctor::firstDataCuts ( const pat::Muon muon,
pat::strbitset ret 
) [inline]

Definition at line 201 of file MuonVPlusJetsIDSelectionFunctor.h.

References Selector< pat::Muon >::cut(), pat::Muon::dB(), pat::Muon::ecalIso(), pat::Muon::edB(), pat::Muon::hcalIso(), Selector< pat::Muon >::ignoreCut(), indexChi2_, indexD0_, indexECalVeto_, indexED0_, indexHCalVeto_, indexNHits_, indexRelIso_, indexSD0_, reco::Muon::isolationR03(), pat::Muon::normChi2(), pat::Muon::numberOfValidHits(), Selector< pat::Muon >::passCut(), ExpressReco_HICollisions_FallBack::pt, reco::LeafCandidate::pt(), runTheMatrix::ret, pat::strbitset::set(), Selector< pat::Muon >::setIgnored(), and pat::Muon::trackIso().

Referenced by operator()().

  {

    ret.set(false);

    double norm_chi2 = muon.normChi2();
    double corr_d0 = muon.dB();
    double corr_ed0 = muon.edB();
    double corr_sd0 = ( corr_ed0 > 0.000000001 ) ? corr_d0 / corr_ed0 : 999.0;
    int nhits = static_cast<int>( muon.numberOfValidHits() );
    
    double ecalVeto = muon.isolationR03().emVetoEt;
    double hcalVeto = muon.isolationR03().hadVetoEt;
        
    double hcalIso = muon.hcalIso();
    double ecalIso = muon.ecalIso();
    double trkIso  = muon.trackIso();
    double pt      = muon.pt() ;

    double relIso = (ecalIso + hcalIso + trkIso) / pt;

    if ( norm_chi2     <  cut(indexChi2_,   double()) || ignoreCut(indexChi2_)    ) passCut(ret, indexChi2_   );
    if ( fabs(corr_d0) <  cut(indexD0_,     double()) || ignoreCut(indexD0_)      ) passCut(ret, indexD0_     );
    if ( fabs(corr_ed0)<  cut(indexED0_,    double()) || ignoreCut(indexED0_)     ) passCut(ret, indexED0_    );
    if ( fabs(corr_sd0)<  cut(indexSD0_,    double()) || ignoreCut(indexSD0_)     ) passCut(ret, indexSD0_    );
    if ( nhits         >= cut(indexNHits_,  int()   ) || ignoreCut(indexNHits_)   ) passCut(ret, indexNHits_  );
    if ( hcalVeto      <  cut(indexHCalVeto_,double())|| ignoreCut(indexHCalVeto_)) passCut(ret, indexHCalVeto_);
    if ( ecalVeto      <  cut(indexECalVeto_,double())|| ignoreCut(indexECalVeto_)) passCut(ret, indexECalVeto_);
    if ( relIso        <  cut(indexRelIso_, double()) || ignoreCut(indexRelIso_)  ) passCut(ret, indexRelIso_ );

    setIgnored(ret);
    
    return (bool)ret;
  }
void MuonVPlusJetsIDSelectionFunctor::initialize ( Version_t  version,
double  chi2 = 10.0,
double  d0 = 999.0,
double  ed0 = 999.0,
double  sd0 = 3.0,
int  nhits = 11,
int  nValidMuonHits = 0,
double  ecalveto = 4.0,
double  hcalveto = 6.0,
double  reliso = 0.05 
) [inline]

Definition at line 77 of file MuonVPlusJetsIDSelectionFunctor.h.

References Selector< pat::Muon >::bits_, ExpressReco_HICollisions_FallBack::chi2, debug_cff::d0, funct::false, FIRSTDATA, indexChi2_, indexD0_, indexECalVeto_, indexED0_, indexHCalVeto_, indexNHits_, indexNValMuHits_, indexRelIso_, indexSD0_, Selector< pat::Muon >::push_back(), SPRING10, SUMMER08, AlCaRecoCosmics_cfg::version, and version_.

Referenced by MuonVPlusJetsIDSelectionFunctor().

  {
    version_ = version; 

    push_back("Chi2",      chi2   );
    push_back("D0",        d0     );
    push_back("ED0",       ed0    );
    push_back("SD0",       sd0    );
    push_back("NHits",     nhits  );
    push_back("NValMuHits",     nValidMuonHits  );
    push_back("ECalVeto",  ecalveto);
    push_back("HCalVeto",  hcalveto);
    push_back("RelIso",    reliso );

    set("Chi2");
    set("D0");
    set("ED0");
    set("SD0");
    set("NHits");
    set("NValMuHits");
    set("ECalVeto");
    set("HCalVeto");
    set("RelIso");     

    indexChi2_          = index_type(&bits_, "Chi2"         );
    indexD0_            = index_type(&bits_, "D0"           );
    indexED0_           = index_type(&bits_, "ED0"          );
    indexSD0_           = index_type(&bits_, "SD0"          );
    indexNHits_         = index_type(&bits_, "NHits"        );
    indexNValMuHits_    = index_type(&bits_, "NValMuHits"   );
    indexECalVeto_      = index_type(&bits_, "ECalVeto"     );
    indexHCalVeto_      = index_type(&bits_, "HCalVeto"     );
    indexRelIso_        = index_type(&bits_, "RelIso"       );

    if ( version == SPRING10) {
      set("ED0", false );
      set("SD0", false);
      set("ECalVeto",false);
      set("HCalVeto",false);
    } else if ( version_ == FIRSTDATA ) {
      set("D0", false );
      set("ED0", false );
      set("NValMuHits",false);
    } else if (version == SUMMER08 ) {
      set("SD0", false);
      set("NValMuHits",false);      
    }

  }
bool MuonVPlusJetsIDSelectionFunctor::operator() ( const pat::Muon t,
edm::EventBase const &  e,
pat::strbitset ret 
) [inline, virtual]

This provides an alternative signature that includes extra information.

Reimplemented from Selector< pat::Muon >.

Definition at line 137 of file MuonVPlusJetsIDSelectionFunctor.h.

References FIRSTDATA, firstDataCuts(), SPRING10, spring10Cuts(), SUMMER08, summer08Cuts(), and version_.

  { 

    if (version_ == SPRING10 ) return spring10Cuts(muon, event, ret);
    else if ( version_ == SUMMER08 ) return summer08Cuts( muon, ret );
    else if ( version_ == FIRSTDATA ) return firstDataCuts( muon, ret );
    else {
      return false;
    }
  }
bool MuonVPlusJetsIDSelectionFunctor::operator() ( const pat::Muon t,
pat::strbitset ret 
) [inline, virtual]

This provides the interface for base classes to select objects.

Implements Selector< pat::Muon >.

Definition at line 149 of file MuonVPlusJetsIDSelectionFunctor.h.

References Exception, FIRSTDATA, firstDataCuts(), SPRING10, SUMMER08, summer08Cuts(), and version_.

  { 

    if (version_ == SPRING10 ) throw cms::Exception("LogicError") 
      << "MuonVPlusJetsSelectionFunctor SPRING10 version needs the event! Call operator()(muon,event,ret)"
      <<std::endl;

    else if ( version_ == SUMMER08 ) return summer08Cuts( muon, ret );
    else if ( version_ == FIRSTDATA ) return firstDataCuts( muon, ret );
    else {
      return false;
    }
  }
bool MuonVPlusJetsIDSelectionFunctor::spring10Cuts ( const pat::Muon muon,
edm::EventBase const &  event,
pat::strbitset ret 
) [inline]

Definition at line 237 of file MuonVPlusJetsIDSelectionFunctor.h.

References beamLineSrc_, ExpressReco_HICollisions_FallBack::beamSpot, reco::BeamSpot::BeamWidthX(), reco::BeamSpot::BeamWidthY(), Selector< pat::Muon >::cut(), pat::Muon::dB(), pat::Muon::ecalIso(), pat::Muon::edB(), pat::Muon::globalTrack(), pat::Muon::hcalIso(), Selector< pat::Muon >::ignoreCut(), indexChi2_, indexD0_, indexECalVeto_, indexED0_, indexHCalVeto_, indexNHits_, indexNValMuHits_, indexRelIso_, indexSD0_, susybsm::HSCParticleType::innerTrack, pat::Muon::innerTrack(), reco::Muon::isolationR03(), edm::HandleBase::isValid(), pat::Muon::normChi2(), pat::Muon::numberOfValidHits(), Selector< pat::Muon >::passCut(), ExpressReco_HICollisions_FallBack::pt, reco::LeafCandidate::pt(), recalcDBFromBSp_, runTheMatrix::ret, pat::strbitset::set(), Selector< pat::Muon >::setIgnored(), mathSSE::sqrt(), pat::Muon::trackIso(), reco::BeamSpot::x0(), reco::BeamSpot::y0(), and reco::BeamSpot::z0().

Referenced by operator()().

  {

    ret.set(false);

    double norm_chi2 = muon.normChi2();
    double corr_d0 = muon.dB();
    double corr_ed0 = muon.edB();
    double corr_sd0 = ( corr_ed0 > 0.000000001 ) ? corr_d0 / corr_ed0 : 999.0;

    //If required, recalculate the impact parameter using the beam spot
    if (recalcDBFromBSp_) {

      //Get the beam spot
      reco::TrackBase::Point beamPoint(0,0,0);
      reco::BeamSpot beamSpot;
      edm::Handle<reco::BeamSpot> beamSpotHandle;
      event.getByLabel(beamLineSrc_, beamSpotHandle);
      
      if( beamSpotHandle.isValid() ){
        beamSpot = *beamSpotHandle;
      } else{
        edm::LogError("DataNotAvailable")
          << "No beam spot available from EventSetup, not adding high level selection \n";
      }
      beamPoint = reco::TrackBase::Point ( beamSpot.x0(), beamSpot.y0(), beamSpot.z0() );
      
      //Use the beamspot to correct the impact parameter and uncertainty
      reco::TrackRef innerTrack = muon.innerTrack();
      if ( innerTrack.isNonnull() && innerTrack.isAvailable() ) {
        corr_d0 = -1.0 * innerTrack->dxy( beamPoint );
        corr_ed0 = sqrt( innerTrack->d0Error() * innerTrack->d0Error() 
                         + 0.5* beamSpot.BeamWidthX()*beamSpot.BeamWidthX() 
                         + 0.5* beamSpot.BeamWidthY()*beamSpot.BeamWidthY() );
        corr_sd0 = ( corr_ed0 > 0.000000001 ) ? corr_d0 / corr_ed0 : 999.0;

      } else {
        corr_d0 =  999.;
        corr_ed0 = 999.;
      }
    }

    int nhits = static_cast<int>( muon.numberOfValidHits() );
    int nValidMuonHits = static_cast<int> (muon.globalTrack()->hitPattern().numberOfValidMuonHits());
    
    double ecalVeto = muon.isolationR03().emVetoEt;
    double hcalVeto = muon.isolationR03().hadVetoEt;
        
    double hcalIso = muon.hcalIso();
    double ecalIso = muon.ecalIso();
    double trkIso  = muon.trackIso();
    double pt      = muon.pt() ;

    double relIso = (ecalIso + hcalIso + trkIso) / pt;

    if ( norm_chi2     <  cut(indexChi2_,   double()) || ignoreCut(indexChi2_)    ) passCut(ret, indexChi2_   );
    if ( fabs(corr_d0) <  cut(indexD0_,     double()) || ignoreCut(indexD0_)      ) passCut(ret, indexD0_     );
    if ( fabs(corr_ed0)<  cut(indexED0_,    double()) || ignoreCut(indexED0_)     ) passCut(ret, indexED0_    );
    if ( fabs(corr_sd0)<  cut(indexSD0_,    double()) || ignoreCut(indexSD0_)     ) passCut(ret, indexSD0_    );
    if ( nhits         >= cut(indexNHits_,  int()   ) || ignoreCut(indexNHits_)   ) passCut(ret, indexNHits_  );
    if ( nValidMuonHits> cut(indexNValMuHits_,int()) || ignoreCut(indexNValMuHits_)) passCut(ret, indexNValMuHits_  );
    if ( hcalVeto      <  cut(indexHCalVeto_,double())|| ignoreCut(indexHCalVeto_)) passCut(ret, indexHCalVeto_);
    if ( ecalVeto      <  cut(indexECalVeto_,double())|| ignoreCut(indexECalVeto_)) passCut(ret, indexECalVeto_);
    if ( relIso        <  cut(indexRelIso_, double()) || ignoreCut(indexRelIso_)  ) passCut(ret, indexRelIso_ );

    setIgnored(ret);
    
    return (bool)ret;
  }
bool MuonVPlusJetsIDSelectionFunctor::summer08Cuts ( const pat::Muon muon,
pat::strbitset ret 
) [inline]

Definition at line 167 of file MuonVPlusJetsIDSelectionFunctor.h.

References Selector< pat::Muon >::cut(), pat::Muon::dB(), pat::Muon::ecalIso(), pat::Muon::hcalIso(), Selector< pat::Muon >::ignoreCut(), indexChi2_, indexD0_, indexECalVeto_, indexHCalVeto_, indexNHits_, indexRelIso_, reco::Muon::isolationR03(), pat::Muon::normChi2(), pat::Muon::numberOfValidHits(), Selector< pat::Muon >::passCut(), ExpressReco_HICollisions_FallBack::pt, reco::LeafCandidate::pt(), runTheMatrix::ret, pat::strbitset::set(), Selector< pat::Muon >::setIgnored(), and pat::Muon::trackIso().

Referenced by operator()().

  {

    ret.set(false);

    double norm_chi2 = muon.normChi2();
    double corr_d0 = muon.dB();
    int nhits = static_cast<int>( muon.numberOfValidHits() );
    
    double ecalVeto = muon.isolationR03().emVetoEt;
    double hcalVeto = muon.isolationR03().hadVetoEt;
        
    double hcalIso = muon.hcalIso();
    double ecalIso = muon.ecalIso();
    double trkIso  = muon.trackIso();
    double pt      = muon.pt() ;

    double relIso = (ecalIso + hcalIso + trkIso) / pt;

    if ( norm_chi2     <  cut(indexChi2_,   double()) || ignoreCut(indexChi2_)    ) passCut(ret, indexChi2_   );
    if ( fabs(corr_d0) <  cut(indexD0_,     double()) || ignoreCut(indexD0_)      ) passCut(ret, indexD0_     );
    if ( nhits         >= cut(indexNHits_,  int()   ) || ignoreCut(indexNHits_)   ) passCut(ret, indexNHits_  );
    if ( hcalVeto      <  cut(indexHCalVeto_,double())|| ignoreCut(indexHCalVeto_)) passCut(ret, indexHCalVeto_);
    if ( ecalVeto      <  cut(indexECalVeto_,double())|| ignoreCut(indexECalVeto_)) passCut(ret, indexECalVeto_);
    if ( relIso        <  cut(indexRelIso_, double()) || ignoreCut(indexRelIso_)  ) passCut(ret, indexRelIso_ );

    setIgnored(ret);

    return (bool)ret;
  }

Member Data Documentation

Definition at line 317 of file MuonVPlusJetsIDSelectionFunctor.h.

Referenced by firstDataCuts(), initialize(), and spring10Cuts().

Definition at line 320 of file MuonVPlusJetsIDSelectionFunctor.h.

Referenced by initialize(), and spring10Cuts().

Definition at line 318 of file MuonVPlusJetsIDSelectionFunctor.h.

Referenced by firstDataCuts(), initialize(), and spring10Cuts().

Definition at line 310 of file MuonVPlusJetsIDSelectionFunctor.h.

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