CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClassBasedElectronID.cc
Go to the documentation of this file.
2 
3 // ===========================================================================================================
5 // ===========================================================================================================
6 {
7 
8 
9  // Get all the parameters
10  baseSetup(conf);
11 
12  quality_ = conf.getParameter<std::string>("electronQuality");
13 
14  if(quality_=="Eff95Cuts") {
15  cuts_ = conf.getParameter<edm::ParameterSet>("Eff95Cuts");
16  }
17 
18  else if(quality_=="Eff90Cuts") {
19  cuts_ = conf.getParameter<edm::ParameterSet>("Eff90Cuts");
20  }
21 
22  else {
23  edm::LogError("ClassBasedElectronID") << "Invalid electronQuality parameter: must be tight, medium or loose." ;
24  exit (1);
25  }
26 
27 } // end of setup
28 
30  const edm::Event& e ,
31  const edm::EventSetup& es)
32 {
33 
34  //determine which element of the cut arrays in cfi file to read
35  //depending on the electron classification
36  int icut=0;
37  int elClass = electron->classification() ;
38  if (electron->isEB()) //barrel
39  {
40  if (elClass == reco::GsfElectron::GOLDEN) icut=0;
41  if (elClass == reco::GsfElectron::BIGBREM) icut=1;
42  if (elClass == reco::GsfElectron::SHOWERING) icut=2;
43  if (elClass == reco::GsfElectron::GAP) icut=6;
44  }
45  if (electron->isEE()) //endcap
46  {
47  if (elClass == reco::GsfElectron::GOLDEN) icut=3;
48  if (elClass == reco::GsfElectron::BIGBREM) icut=4;
49  if (elClass == reco::GsfElectron::SHOWERING) icut=5;
50  if (elClass == reco::GsfElectron::GAP) icut=7;
51  }
52  if (elClass == reco::GsfElectron::UNKNOWN)
53  {
54  edm::LogError("ClassBasedElectronID") << "Error: unrecognized electron classification ";
55  return 1.;
56  }
57 
58  bool useDeltaEtaIn = true;
59  bool useSigmaIetaIeta = true;
60  bool useHoverE = true;
61  bool useEoverPOut = true;
62  bool useDeltaPhiInCharge = true;
63 
64  // DeltaEtaIn
65  if (useDeltaEtaIn) {
66  double value = electron->deltaEtaSuperClusterTrackAtVtx();
67  std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("deltaEtaIn");
68  if (fabs(value)>maxcut[icut]) return 0.;
69  }
70 
71  // SigmaIetaIeta
72  if(useSigmaIetaIeta) {
73  double value = electron->sigmaIetaIeta() ;
74  std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("sigmaIetaIetaMax");
75  std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("sigmaIetaIetaMin");
76  if(value<mincut[icut] || value>maxcut[icut]) return 0.;
77  }
78 
79  // H/E
80  if (useHoverE) { //_[variables_]) {
81  double value = electron->hadronicOverEm();
82  std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("HoverE");
83  if (value>maxcut[icut]) return 0.;
84  } // if use
85 
86  // Eseed/Pout
87  if (useEoverPOut) {
88  double value = electron->eSeedClusterOverPout();
89  std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("EoverPOutMax");
90  std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("EoverPOutMin");
91  if (value<mincut[icut] || value>maxcut[icut]) return 0.;
92  }
93 
94  // DeltaPhiIn*Charge
95  if (useDeltaPhiInCharge) {
96  double value1 = electron->deltaPhiSuperClusterTrackAtVtx();
97  double value2 = electron->charge();
98  double value = value1*value2;
99  std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("deltaPhiInChargeMax");
100  std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("deltaPhiInChargeMin");
101  if (value<mincut[icut] || value>maxcut[icut]) return 0.;
102  }
103 
104  return 1.;
105 
106 }
T getParameter(std::string const &) const
void baseSetup(const edm::ParameterSet &conf)
bool isEE() const
Definition: GsfElectron.h:335
bool isEB() const
Definition: GsfElectron.h:334
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:234
float sigmaIetaIeta() const
Definition: GsfElectron.h:386
float hadronicOverEm() const
Definition: GsfElectron.h:410
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:237
float eSeedClusterOverPout() const
Definition: GsfElectron.h:232
double result(const reco::GsfElectron *, const edm::Event &, const edm::EventSetup &)
tuple conf
Definition: dbtoconf.py:185
virtual int charge() const GCC11_FINAL
electric charge
Classification classification() const
Definition: GsfElectron.h:649
edm::ParameterSet cuts_
void setup(const edm::ParameterSet &conf)