ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DGele/PhysicsTools/PatUtils/src/ElectronSelector.cc
Revision: 1.2
Committed: Tue Oct 20 17:43:13 2009 UTC (15 years, 6 months ago) by dgele
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Log Message:
remove

File Contents

# Content
1 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
2 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
3 #include "DataFormats/EgammaReco/interface/ClusterShape.h"
4
5 #include "PhysicsTools/PatUtils/interface/ElectronSelector.h"
6
7 using pat::ElectronSelector;
8
9 //______________________________________________________________________________
10 const pat::ParticleStatus
11 ElectronSelector::filter( const unsigned int& index,
12 const edm::View<Electron>& electrons,
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
45 throw edm::Exception(edm::errors::Configuration)
46 << "Unknown electron ID selection " << config_.selectionType;
47
48 }
49
50
51 //______________________________________________________________________________
52 const reco::ElectronIDRef&
53 ElectronSelector::electronID_( const unsigned int& index,
54 const edm::View<Electron>& electrons,
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 //______________________________________________________________________________
68 const pat::ParticleStatus
69 ElectronSelector::customSelection_( const unsigned int& index,
70 const edm::View<Electron>& electrons,
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 }