CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
pat::ElectronSelector Class Reference

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. More...
 
const reco::ElectronIDRefelectronID_ (const unsigned int &index, const edm::View< Electron > &electrons, const ElectronIDmap &electronIDs) const
 

Private Attributes

ElectronSelection config_
 

Detailed Description

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 >.)

Author
F.J. Ronga (ETH Zurich)
Version
Id:
ElectronSelector.h,v 1.12 2008/04/09 12:05:13 llista Exp

Definition at line 52 of file ElectronSelector.h.

Member Typedef Documentation

Definition at line 54 of file ElectronSelector.h.

Definition at line 55 of file ElectronSelector.h.

Constructor & Destructor Documentation

pat::ElectronSelector::ElectronSelector ( const ElectronSelection cfg)
inline

Definition at line 58 of file ElectronSelector.h.

58 : config_( cfg ) {}
ElectronSelection config_
pat::ElectronSelector::~ElectronSelector ( )
inline

Definition at line 59 of file ElectronSelector.h.

59 {}

Member Function Documentation

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().

73 {
74 
75  // Note: this is all taken from SusyAnalyzer
76 
77  const reco::GsfElectron& electron = electrons[index];
78 
79  // Retrieve information
80  float eta = fabs(electron.p4().Eta());
81  float eOverPin = electron.eSuperClusterOverP();
82  float pin = electron.trackMomentumAtVtx().R();
83  float pout = electron.trackMomentumOut().R();
84  float fBrem = (pin-pout)/pin;
85  float hOverE = electron.hadronicOverEm();
86  float deltaPhiIn = electron.deltaPhiSuperClusterTrackAtVtx();
87  float deltaEtaIn = electron.deltaEtaSuperClusterTrackAtVtx();
88  float deltaPhiOut = electron.deltaPhiSeedClusterTrackAtCalo();
89  float invEOverInvP = (1./electron.caloEnergy())-(1./electron.trackMomentumAtVtx().R());
90  float sigmaee = sqrt(clusterShape->covEtaEta());
91  float sigmapp = sqrt(clusterShape->covPhiPhi());
92  float E9overE25 = clusterShape->e3x3()/clusterShape->e5x5();
93 
94  bool inEndCap = false; // Switch between barrel (0) and endcap (2)
95  if (eta > 1.479) { // See EgammaAnalysis/ElectronIDAlgos/src/CutBasedElectronID.cc
96  inEndCap = true;
97  sigmaee = sigmaee - 0.02*(fabs(eta) - 2.3); // Correct sigmaetaeta dependence on eta in endcap
98  }
99 
100  // Now do the selection
101  // These ones come straight from E/gamma algo
102  if ( (eOverPin < 0.8) && (fBrem < 0.2) ) return BAD;
103  if ( config_.doBremEoverPcomp && (eOverPin < 0.9*(1-fBrem)) ) return BAD;
104 
105  if ( (hOverE > config_.HoverEBarmax && !inEndCap )
106  || (hOverE > config_.HoverEEndmax && inEndCap ) )
107  return HOVERE;
108 
109  if ( (E9overE25 < config_.E9overE25Barmin && !inEndCap )
110  || (E9overE25 < config_.E9overE25Endmin && inEndCap ) )
111  return SHOWER;
112 
113  if ( (sigmaee > config_.SigmaEtaEtaBarmax && !inEndCap )
114  || (sigmaee > config_.SigmaEtaEtaEndmax && inEndCap ) )
115  return SHOWER;
116 
117  if ( (sigmapp > config_.SigmaPhiPhiBarmax && !inEndCap )
118  || (sigmapp > config_.SigmaPhiPhiEndmax && inEndCap ) )
119  return SHOWER;
120 
121  if ( (eOverPin < config_.EoverPInBarmin && !inEndCap )
122  || (eOverPin < config_.EoverPInEndmin && inEndCap ) )
123  return MATCHING;
124 
125  if ( (fabs(deltaEtaIn) > config_.DeltaEtaInBarmax && !inEndCap )
126  || (fabs(deltaEtaIn) > config_.DeltaEtaInEndmax && inEndCap ) )
127  return MATCHING;
128 
129  if ( (fabs(deltaPhiIn) < config_.DeltaPhiInBarmax && !inEndCap )
130  || (fabs(deltaPhiIn) < config_.DeltaPhiInEndmax && inEndCap ) )
131  return MATCHING;
132 
133  if ( (fabs(deltaPhiOut) < config_.DeltaPhiOutBarmax && !inEndCap )
134  || (fabs(deltaPhiOut) < config_.DeltaPhiOutEndmax && inEndCap ) )
135  return MATCHING;
136 
137  if ( (invEOverInvP > config_.InvEMinusInvPBarmax && !inEndCap )
138  || (invEOverInvP > config_.InvEMinusInvPEndmax && inEndCap ) )
139  return MATCHING;
140 
141  return GOOD;
142 
143 }
double e3x3() const
Definition: ClusterShape.h:37
3: Bad ECAL shower shape
Definition: ParticleCode.h:36
bool doBremEoverPcomp
switch to apply cut on comparison between brem and E/P
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:204
float eSuperClusterOverP() const
Definition: GsfElectron.h:229
double e5x5() const
Definition: ClusterShape.h:39
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:272
T eta() const
double covPhiPhi() const
Definition: ClusterShape.h:47
1: Failed selection (without additional info)
Definition: ParticleCode.h:34
double covEtaEta() const
Definition: ClusterShape.h:45
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:233
float hadronicOverEm() const
Definition: GsfElectron.h:403
float deltaPhiSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:237
T sqrt(T t)
Definition: SSEVec.h:46
math::XYZVectorF trackMomentumOut() const
Definition: GsfElectron.h:274
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:236
2: Bad H/E ratio
Definition: ParticleCode.h:35
4: Bad matching to track
Definition: ParticleCode.h:37
0: Passed selection
Definition: ParticleCode.h:33
ElectronSelection config_
float caloEnergy() const
Definition: GsfElectron.h:727
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().

57 {
58  // Find electron ID for electron with index index
59  edm::Ref<std::vector<Electron> > elecsRef = electrons.refAt(index).castTo<edm::Ref<std::vector<Electron> > >();
60  ElectronIDmap::const_iterator electronID = electronIDs.find( elecsRef );
61 
62  // Return corresponding elecID
63  return electronID->val;
64 }
friend struct const_iterator
RefToBase< value_type > refAt(size_type i) const
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_(), edm::hlt::Exception, pat::GOOD, likelihood(), pat::ElectronSelection::selectionType, and pat::ElectronSelection::value.

16 {
17 
18  // List of possible selections
19  if ( config_.selectionType == "none" )
20  {
21  return GOOD;
22  }
23  else if ( config_.selectionType == "cut" )
24  {
25  if ( electronID_(index,electrons,electronIDs)->cutBasedDecision() ) return GOOD;
26  return BAD;
27  }
28  else if ( config_.selectionType == "likelihood" )
29  {
30  if ( electronID_(index,electrons,electronIDs)->likelihood() > config_.value ) return GOOD;
31  return BAD;
32  }
33  else if ( config_.selectionType == "neuralnet" ) // FIXME: Check sign of comparison!
34  {
35  if ( electronID_(index,electrons,electronIDs)->neuralNetOutput() > config_.value ) return GOOD;
36  return BAD;
37  }
38  else if ( config_.selectionType == "custom" )
39  {
40  return customSelection_( index, electrons, clusterShape );
41  }
42 
43 
44  // Throw! unknown configuration
46  << "Unknown electron ID selection " << config_.selectionType;
47 
48 }
void likelihood(int &npar, double *grad, double &fval, double *xval, int flag)
1: Failed selection (without additional info)
Definition: ParticleCode.h:34
const ParticleStatus customSelection_(const unsigned int &index, const edm::View< Electron > &electrons, const reco::ClusterShape *clusterShape) const
Full-fledged selection based on SusyAnalyser.
std::string selectionType
Choose selection type (see PATElectronCleaner)
0: Passed selection
Definition: ParticleCode.h:33
const reco::ElectronIDRef & electronID_(const unsigned int &index, const edm::View< Electron > &electrons, const ElectronIDmap &electronIDs) const
ElectronSelection config_
double value
Cut value for likelihood or neural net.

Member Data Documentation

ElectronSelection pat::ElectronSelector::config_
private

Definition at line 76 of file ElectronSelector.h.

Referenced by customSelection_(), and filter().