CMS 3D CMS Logo

PTDRElectronID.cc
Go to the documentation of this file.
1 #include "PTDRElectronID.h"
2 
4  // Get all the parameters
5  //baseSetup(conf);
6 
7  quality_ = conf.getParameter<std::string>("electronQuality");
8 
9  useEoverPIn_ = conf.getParameter<std::vector<int> >("useEoverPIn");
10  useDeltaEtaIn_ = conf.getParameter<std::vector<int> >("useDeltaEtaIn");
11  useDeltaPhiIn_ = conf.getParameter<std::vector<int> >("useDeltaPhiIn");
12  useHoverE_ = conf.getParameter<std::vector<int> >("useHoverE");
13  useE9overE25_ = conf.getParameter<std::vector<int> >("useE9overE25");
14  useEoverPOut_ = conf.getParameter<std::vector<int> >("useEoverPOut");
15  useDeltaPhiOut_ = conf.getParameter<std::vector<int> >("useDeltaPhiOut");
16  useInvEMinusInvP_ = conf.getParameter<std::vector<int> >("useInvEMinusInvP");
17  useBremFraction_ = conf.getParameter<std::vector<int> >("useBremFraction");
18  useSigmaEtaEta_ = conf.getParameter<std::vector<int> >("useSigmaEtaEta");
19  useSigmaPhiPhi_ = conf.getParameter<std::vector<int> >("useSigmaPhiPhi");
20  acceptCracks_ = conf.getParameter<std::vector<int> >("acceptCracks");
21 
22  if (quality_ == "tight") {
23  cuts_ = conf.getParameter<edm::ParameterSet>("tightEleIDCuts");
24  variables_ = 2;
25  } else if (quality_ == "medium") {
26  cuts_ = conf.getParameter<edm::ParameterSet>("mediumEleIDCuts");
27  variables_ = 1;
28  } else if (quality_ == "loose") {
29  cuts_ = conf.getParameter<edm::ParameterSet>("looseEleIDCuts");
30  variables_ = 0;
31  } else {
32  throw cms::Exception("Configuration")
33  << "Invalid electronQuality parameter in PTDElectronID: must be tight, medium or loose.";
34  }
35 }
36 
38  //determine which element of the cut arrays in cfi file to read
39  //depending on the electron classification
40  int icut = 0;
41  int elClass = electron->classification();
42  if (electron->isEB()) //barrel
43  {
44  if (elClass == reco::GsfElectron::GOLDEN)
45  icut = 0;
46  if (elClass == reco::GsfElectron::BIGBREM)
47  icut = 1;
48  //if (elClass == reco::GsfElectron::NARROW) icut=2;
49  if (elClass == reco::GsfElectron::SHOWERING)
50  icut = 3;
51  if (elClass == reco::GsfElectron::GAP)
52  icut = 8;
53  }
54  if (electron->isEE()) //endcap
55  {
56  if (elClass == reco::GsfElectron::GOLDEN)
57  icut = 4;
58  if (elClass == reco::GsfElectron::BIGBREM)
59  icut = 5;
60  //if (elClass == reco::GsfElectron::NARROW) icut=6;
61  if (elClass == reco::GsfElectron::SHOWERING)
62  icut = 7;
63  if (elClass == reco::GsfElectron::GAP)
64  icut = 8;
65  }
66  if (elClass == reco::GsfElectron::UNKNOWN) {
67  edm::LogError("PTDRElectronID") << "Error: unrecognized electron classification ";
68  return 1.;
69  }
70 
72  if (elClass == reco::GsfElectron::GAP)
73  return 1.;
74 
75  if (useEoverPIn_[variables_]) {
76  double value = electron->eSuperClusterOverP();
77  std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("EoverPInMax");
78  std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("EoverPInMin");
79  if (value < mincut[icut] || value > maxcut[icut])
80  return 0.;
81  }
82 
84  double value = electron->deltaEtaSuperClusterTrackAtVtx();
85  std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("deltaEtaIn");
86  if (fabs(value) > maxcut[icut])
87  return 0.;
88  }
89 
91  double value = electron->deltaPhiSuperClusterTrackAtVtx();
92  std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("deltaPhiIn");
93  if (fabs(value) > maxcut[icut])
94  return 0.;
95  }
96 
97  if (useHoverE_[variables_]) {
98  double value = electron->hadronicOverEm();
99  std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("HoverE");
100  if (value > maxcut[icut])
101  return 0.;
102  }
103 
104  if (useEoverPOut_[variables_]) {
105  double value = electron->eSeedClusterOverPout();
106  std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("EoverPOutMax");
107  std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("EoverPOutMin");
108  if (value < mincut[icut] || value > maxcut[icut])
109  return 0.;
110  }
111 
113  double value = electron->deltaPhiSeedClusterTrackAtCalo();
114  std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("deltaPhiOut");
115  if (fabs(value) > maxcut[icut])
116  return 0.;
117  }
118 
120  double value = (1. / electron->caloEnergy()) - (1. / electron->trackMomentumAtVtx().R());
121  std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("invEMinusInvP");
122  if (value > maxcut[icut])
123  return 0.;
124  }
125 
127  double value = electron->trackMomentumAtVtx().R() - electron->trackMomentumOut().R();
128  std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("bremFraction");
129  if (value < mincut[icut])
130  return 0.;
131  }
132 
133  //EcalClusterLazyTools lazyTools = getClusterShape(e,es);
134  //std::vector<float> vCov = lazyTools.localCovariances(*(electron->superCluster()->seed())) ;
135  //std::vector<float> vCov = lazyTools.covariances(*(electron->superCluster()->seed())) ;
136 
137  if (useE9overE25_[variables_]) {
138  double value = electron->r9() * electron->superCluster()->energy() / electron->e5x5();
139  std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("E9overE25");
140  if (fabs(value) < mincut[icut])
141  return 0.;
142  }
143 
145  std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("sigmaEtaEtaMax");
146  std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("sigmaEtaEtaMin");
147  if (electron->sigmaIetaIeta() < mincut[icut] || electron->sigmaIetaIeta() > maxcut[icut])
148  return 0.;
149  }
150 
152  std::vector<double> mincut = cuts_.getParameter<std::vector<double> >("sigmaPhiPhiMin");
153  std::vector<double> maxcut = cuts_.getParameter<std::vector<double> >("sigmaPhiPhiMax");
154  if (electron->sigmaIphiIphi() < mincut[icut] || electron->sigmaIphiIphi() > maxcut[icut])
155  return 0.;
156  }
157 
158  return 1.;
159 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ParameterSet cuts_
std::vector< int > useHoverE_
std::vector< int > useInvEMinusInvP_
std::vector< int > useDeltaPhiOut_
Log< level::Error, false > LogError
std::vector< int > useSigmaPhiPhi_
double result(const reco::GsfElectron *, const edm::Event &, const edm::EventSetup &) override
std::vector< int > useEoverPIn_
Definition: value.py:1
std::vector< int > useDeltaEtaIn_
std::vector< int > useEoverPOut_
std::vector< int > useSigmaEtaEta_
std::vector< int > useBremFraction_
std::vector< int > useDeltaPhiIn_
std::string quality_
std::vector< int > useE9overE25_
void setup(const edm::ParameterSet &conf) override
std::vector< int > acceptCracks_