CMS 3D CMS Logo

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