CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronSelector.cc
Go to the documentation of this file.
4 
6 
8 
9 //______________________________________________________________________________
11 ElectronSelector::filter( const unsigned int& index,
13  const ElectronIDmap& electronIDs,
14  const reco::ClusterShape* clusterShape
15  ) const
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 }
49 
50 
51 //______________________________________________________________________________
52 const reco::ElectronIDRef&
53 ElectronSelector::electronID_( const unsigned int& index,
55  const ElectronIDmap& electronIDs
56  ) const
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 }
65 
66 
67 //______________________________________________________________________________
71  const reco::ClusterShape* clusterShape
72  ) const
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:36
Selects good electrons.
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:223
float eSuperClusterOverP() const
Definition: GsfElectron.h:243
void likelihood(int &npar, double *grad, double &fval, double *xval, int flag)
double e5x5() const
Definition: ClusterShape.h:38
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:289
const_iterator find(const key_type &k) const
find element with specified reference key
T eta() const
double covPhiPhi() const
Definition: ClusterShape.h:46
1: Failed selection (without additional info)
Definition: ParticleCode.h:34
RefToBase< value_type > refAt(size_type i) const
double covEtaEta() const
Definition: ClusterShape.h:44
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:247
float hadronicOverEm() const
Definition: GsfElectron.h:443
float deltaPhiSeedClusterTrackAtCalo() const
Definition: GsfElectron.h:251
T sqrt(T t)
Definition: SSEVec.h:48
math::XYZVectorF trackMomentumOut() const
Definition: GsfElectron.h:291
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:250
2: Bad H/E ratio
Definition: ParticleCode.h:35
4: Bad matching to track
Definition: ParticleCode.h:37
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
ParticleStatus
Definition of particle status after selection.
Definition: ParticleCode.h:32
ElectronSelection config_
float caloEnergy() const
Definition: GsfElectron.h:774
double value
Cut value for likelihood or neural net.