Selects good electrons. More...
#include <PhysicsTools/PatUtils/ElectronSelector.h>
Public Member Functions | |
ElectronSelector (const ElectronSelection &cfg) | |
const ParticleStatus | filter (const unsigned int &index, const edm::View< Electron > &electrons, const ElectronIDmap &electronIDs, const reco::ClusterShape *clusterShape) const |
~ElectronSelector () | |
Private Types | |
typedef reco::GsfElectron | Electron |
typedef reco::ElectronIDAssociationCollection | ElectronIDmap |
Private Member Functions | |
const ParticleStatus | customSelection_ (const unsigned int &index, const edm::View< Electron > &electrons, const reco::ClusterShape *clusterShape) const |
Full-fledged selection based on SusyAnalyser. | |
const reco::ElectronIDRef & | electronID_ (const unsigned int &index, const edm::View< Electron > &electrons, const ElectronIDmap &electronIDs) const |
Private Attributes | |
ElectronSelection | config_ |
Selects good electrons.
The electron selector returns a flag (see pat::ParticleStatus) based on one of the possible selections: either eId-based (cut, likelihood, neural net) or custom (user-defined set of cuts). This is driven by the configuration parameters (see the PATElectronCleaner documentation for configuration details).
The parameters are passed to the selector through an ElectronSelection struct. (An adapter exists for use in CMSSW: reco::modules::ParameterAdapter< pat::ElectronSelector >.)
Definition at line 52 of file ElectronSelector.h.
typedef reco::GsfElectron pat::ElectronSelector::Electron [private] |
Definition at line 54 of file ElectronSelector.h.
typedef reco::ElectronIDAssociationCollection pat::ElectronSelector::ElectronIDmap [private] |
Definition at line 55 of file ElectronSelector.h.
pat::ElectronSelector::ElectronSelector | ( | const ElectronSelection & | cfg | ) | [inline] |
Definition at line 58 of file ElectronSelector.h.
: config_( cfg ) {}
pat::ElectronSelector::~ElectronSelector | ( | ) | [inline] |
Definition at line 59 of file ElectronSelector.h.
{}
const pat::ParticleStatus ElectronSelector::customSelection_ | ( | const unsigned int & | index, |
const edm::View< Electron > & | electrons, | ||
const reco::ClusterShape * | clusterShape | ||
) | const [private] |
Full-fledged selection based on SusyAnalyser.
Definition at line 69 of file ElectronSelector.cc.
References pat::BAD, reco::GsfElectron::caloEnergy(), config_, reco::ClusterShape::covEtaEta(), reco::ClusterShape::covPhiPhi(), pat::ElectronSelection::DeltaEtaInBarmax, pat::ElectronSelection::DeltaEtaInEndmax, reco::GsfElectron::deltaEtaSuperClusterTrackAtVtx(), pat::ElectronSelection::DeltaPhiInBarmax, pat::ElectronSelection::DeltaPhiInEndmax, pat::ElectronSelection::DeltaPhiOutBarmax, pat::ElectronSelection::DeltaPhiOutEndmax, reco::GsfElectron::deltaPhiSeedClusterTrackAtCalo(), reco::GsfElectron::deltaPhiSuperClusterTrackAtVtx(), pat::ElectronSelection::doBremEoverPcomp, reco::ClusterShape::e3x3(), reco::ClusterShape::e5x5(), pat::ElectronSelection::E9overE25Barmin, pat::ElectronSelection::E9overE25Endmin, metsig::electron, pat::ElectronSelection::EoverPInBarmin, pat::ElectronSelection::EoverPInEndmin, reco::GsfElectron::eSuperClusterOverP(), eta(), pat::GOOD, reco::GsfElectron::hadronicOverEm(), pat::HOVERE, pat::ElectronSelection::HoverEBarmax, pat::ElectronSelection::HoverEEndmax, getHLTprescales::index, pat::ElectronSelection::InvEMinusInvPBarmax, pat::ElectronSelection::InvEMinusInvPEndmax, pat::MATCHING, reco::GsfElectron::p4(), pat::SHOWER, pat::ElectronSelection::SigmaEtaEtaBarmax, pat::ElectronSelection::SigmaEtaEtaEndmax, pat::ElectronSelection::SigmaPhiPhiBarmax, pat::ElectronSelection::SigmaPhiPhiEndmax, mathSSE::sqrt(), reco::GsfElectron::trackMomentumAtVtx(), and reco::GsfElectron::trackMomentumOut().
Referenced by filter().
{ // Note: this is all taken from SusyAnalyzer const reco::GsfElectron& electron = electrons[index]; // Retrieve information float eta = fabs(electron.p4().Eta()); float eOverPin = electron.eSuperClusterOverP(); float pin = electron.trackMomentumAtVtx().R(); float pout = electron.trackMomentumOut().R(); float fBrem = (pin-pout)/pin; float hOverE = electron.hadronicOverEm(); float deltaPhiIn = electron.deltaPhiSuperClusterTrackAtVtx(); float deltaEtaIn = electron.deltaEtaSuperClusterTrackAtVtx(); float deltaPhiOut = electron.deltaPhiSeedClusterTrackAtCalo(); float invEOverInvP = (1./electron.caloEnergy())-(1./electron.trackMomentumAtVtx().R()); float sigmaee = sqrt(clusterShape->covEtaEta()); float sigmapp = sqrt(clusterShape->covPhiPhi()); float E9overE25 = clusterShape->e3x3()/clusterShape->e5x5(); bool inEndCap = false; // Switch between barrel (0) and endcap (2) if (eta > 1.479) { // See EgammaAnalysis/ElectronIDAlgos/src/CutBasedElectronID.cc inEndCap = true; sigmaee = sigmaee - 0.02*(fabs(eta) - 2.3); // Correct sigmaetaeta dependence on eta in endcap } // Now do the selection // These ones come straight from E/gamma algo if ( (eOverPin < 0.8) && (fBrem < 0.2) ) return BAD; if ( config_.doBremEoverPcomp && (eOverPin < 0.9*(1-fBrem)) ) return BAD; if ( (hOverE > config_.HoverEBarmax && !inEndCap ) || (hOverE > config_.HoverEEndmax && inEndCap ) ) return HOVERE; if ( (E9overE25 < config_.E9overE25Barmin && !inEndCap ) || (E9overE25 < config_.E9overE25Endmin && inEndCap ) ) return SHOWER; if ( (sigmaee > config_.SigmaEtaEtaBarmax && !inEndCap ) || (sigmaee > config_.SigmaEtaEtaEndmax && inEndCap ) ) return SHOWER; if ( (sigmapp > config_.SigmaPhiPhiBarmax && !inEndCap ) || (sigmapp > config_.SigmaPhiPhiEndmax && inEndCap ) ) return SHOWER; if ( (eOverPin < config_.EoverPInBarmin && !inEndCap ) || (eOverPin < config_.EoverPInEndmin && inEndCap ) ) return MATCHING; if ( (fabs(deltaEtaIn) > config_.DeltaEtaInBarmax && !inEndCap ) || (fabs(deltaEtaIn) > config_.DeltaEtaInEndmax && inEndCap ) ) return MATCHING; if ( (fabs(deltaPhiIn) < config_.DeltaPhiInBarmax && !inEndCap ) || (fabs(deltaPhiIn) < config_.DeltaPhiInEndmax && inEndCap ) ) return MATCHING; if ( (fabs(deltaPhiOut) < config_.DeltaPhiOutBarmax && !inEndCap ) || (fabs(deltaPhiOut) < config_.DeltaPhiOutEndmax && inEndCap ) ) return MATCHING; if ( (invEOverInvP > config_.InvEMinusInvPBarmax && !inEndCap ) || (invEOverInvP > config_.InvEMinusInvPEndmax && inEndCap ) ) return MATCHING; return GOOD; }
const reco::ElectronIDRef & ElectronSelector::electronID_ | ( | const unsigned int & | index, |
const edm::View< Electron > & | electrons, | ||
const ElectronIDmap & | electronIDs | ||
) | const [private] |
Returns the electron ID object based on the given electron. The latter is defined by an index in the vector of electrons. The ID is found in the association map.
Definition at line 53 of file ElectronSelector.cc.
References edm::AssociationMap< Tag >::find(), and edm::View< T >::refAt().
Referenced by filter().
{ // Find electron ID for electron with index index edm::Ref<std::vector<Electron> > elecsRef = electrons.refAt(index).castTo<edm::Ref<std::vector<Electron> > >(); ElectronIDmap::const_iterator electronID = electronIDs.find( elecsRef ); // Return corresponding elecID return electronID->val; }
const pat::ParticleStatus ElectronSelector::filter | ( | const unsigned int & | index, |
const edm::View< Electron > & | electrons, | ||
const ElectronIDmap & | electronIDs, | ||
const reco::ClusterShape * | clusterShape | ||
) | const |
Returns 0 if electron matches criteria, a flag otherwise. Criteria depend on the selector's configuration. Electron IDs are only used if the selection is based on it (cut, neural net or likelihood). Cluster shapes are for custom selection only.
Definition at line 11 of file ElectronSelector.cc.
References pat::BAD, config_, edm::errors::Configuration, customSelection_(), electronID_(), Exception, pat::GOOD, likelihood(), pat::ElectronSelection::selectionType, and pat::ElectronSelection::value.
{ // List of possible selections if ( config_.selectionType == "none" ) { return GOOD; } else if ( config_.selectionType == "cut" ) { if ( electronID_(index,electrons,electronIDs)->cutBasedDecision() ) return GOOD; return BAD; } else if ( config_.selectionType == "likelihood" ) { if ( electronID_(index,electrons,electronIDs)->likelihood() > config_.value ) return GOOD; return BAD; } else if ( config_.selectionType == "neuralnet" ) // FIXME: Check sign of comparison! { if ( electronID_(index,electrons,electronIDs)->neuralNetOutput() > config_.value ) return GOOD; return BAD; } else if ( config_.selectionType == "custom" ) { return customSelection_( index, electrons, clusterShape ); } // Throw! unknown configuration throw edm::Exception(edm::errors::Configuration) << "Unknown electron ID selection " << config_.selectionType; }
Definition at line 76 of file ElectronSelector.h.
Referenced by customSelection_(), and filter().