CMS 3D CMS Logo

PFRecoTauDiscriminationAgainstElectron.cc
Go to the documentation of this file.
1 /* class PFRecoTauDiscriminationAgainstElectron
2  * created : May 02 2008,
3  * revised : ,
4  * Authorss : Chi Nhan Nguyen (Texas A&M)
5  */
6 
9 
12 
13 namespace {
14 
15  using namespace reco;
16 
17  class PFRecoTauDiscriminationAgainstElectron final : public PFTauDiscriminationProducerBase {
18  public:
19  explicit PFRecoTauDiscriminationAgainstElectron(const edm::ParameterSet& iConfig)
21  emFraction_maxValue_ = iConfig.getParameter<double>("EmFraction_maxValue");
22  applyCut_emFraction_ = iConfig.getParameter<bool>("ApplyCut_EmFraction");
23  hcalTotOverPLead_minValue_ = iConfig.getParameter<double>("HcalTotOverPLead_minValue");
24  applyCut_hcalTotOverPLead_ = iConfig.getParameter<bool>("ApplyCut_HcalTotOverPLead");
25  hcalMaxOverPLead_minValue_ = iConfig.getParameter<double>("HcalMaxOverPLead_minValue");
26  applyCut_hcalMaxOverPLead_ = iConfig.getParameter<bool>("ApplyCut_HcalMaxOverPLead");
27  hcal3x3OverPLead_minValue_ = iConfig.getParameter<double>("Hcal3x3OverPLead_minValue");
28 
29  applyCut_hcal3x3OverPLead_ = iConfig.getParameter<bool>("ApplyCut_Hcal3x3OverPLead");
30  EOverPLead_minValue_ = iConfig.getParameter<double>("EOverPLead_minValue");
31  EOverPLead_maxValue_ = iConfig.getParameter<double>("EOverPLead_maxValue");
32  applyCut_EOverPLead_ = iConfig.getParameter<bool>("ApplyCut_EOverPLead");
33  bremsRecoveryEOverPLead_minValue_ = iConfig.getParameter<double>("BremsRecoveryEOverPLead_minValue");
34  bremsRecoveryEOverPLead_maxValue_ = iConfig.getParameter<double>("BremsRecoveryEOverPLead_maxValue");
35 
36  applyCut_bremsRecoveryEOverPLead_ = iConfig.getParameter<bool>("ApplyCut_BremsRecoveryEOverPLead");
37 
38  applyCut_electronPreID_ = iConfig.getParameter<bool>("ApplyCut_ElectronPreID");
39 
40  applyCut_electronPreID_2D_ = iConfig.getParameter<bool>("ApplyCut_ElectronPreID_2D");
41 
42  elecPreID0_EOverPLead_maxValue_ = iConfig.getParameter<double>("ElecPreID0_EOverPLead_maxValue");
43  elecPreID0_HOverPLead_minValue_ = iConfig.getParameter<double>("ElecPreID0_HOverPLead_minValue");
44  elecPreID1_EOverPLead_maxValue_ = iConfig.getParameter<double>("ElecPreID1_EOverPLead_maxValue");
45  elecPreID1_HOverPLead_minValue_ = iConfig.getParameter<double>("ElecPreID1_HOverPLead_minValue");
46 
47  applyCut_PFElectronMVA_ = iConfig.getParameter<bool>("ApplyCut_PFElectronMVA");
48  pfelectronMVA_maxValue_ = iConfig.getParameter<double>("PFElectronMVA_maxValue");
49 
50  applyCut_ecalCrack_ = iConfig.getParameter<bool>("ApplyCut_EcalCrackCut");
51 
52  applyCut_bremCombined_ = iConfig.getParameter<bool>("ApplyCut_BremCombined");
53  bremCombined_fraction_ = iConfig.getParameter<double>("BremCombined_Fraction");
54  bremCombined_maxHOP_ = iConfig.getParameter<double>("BremCombined_HOP");
55  bremCombined_minMass_ = iConfig.getParameter<double>("BremCombined_Mass");
56  bremCombined_stripSize_ = iConfig.getParameter<double>("BremCombined_StripSize");
57  }
58 
59  double discriminate(const PFTauRef& pfTau) const override;
60 
61  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
62 
63  ~PFRecoTauDiscriminationAgainstElectron() override {}
64 
65  private:
66  bool isInEcalCrack(double) const;
67  edm::InputTag PFTauProducer_;
68  bool applyCut_emFraction_;
69  double emFraction_maxValue_;
70  bool applyCut_hcalTotOverPLead_;
71  double hcalTotOverPLead_minValue_;
72  bool applyCut_hcalMaxOverPLead_;
73  double hcalMaxOverPLead_minValue_;
74  bool applyCut_hcal3x3OverPLead_;
75  double hcal3x3OverPLead_minValue_;
76 
77  bool applyCut_EOverPLead_;
78  double EOverPLead_minValue_;
79  double EOverPLead_maxValue_;
80  bool applyCut_bremsRecoveryEOverPLead_;
81  double bremsRecoveryEOverPLead_minValue_;
82  double bremsRecoveryEOverPLead_maxValue_;
83 
84  bool applyCut_electronPreID_;
85 
86  bool applyCut_electronPreID_2D_;
87  double elecPreID0_EOverPLead_maxValue_;
88  double elecPreID0_HOverPLead_minValue_;
89  double elecPreID1_EOverPLead_maxValue_;
90  double elecPreID1_HOverPLead_minValue_;
91 
92  bool applyCut_PFElectronMVA_;
93  double pfelectronMVA_maxValue_;
94  bool applyCut_ecalCrack_;
95 
96  bool applyCut_bremCombined_;
97  double bremCombined_fraction_;
98  double bremCombined_maxHOP_;
99  double bremCombined_minMass_;
100  double bremCombined_stripSize_;
101  };
102 
103  double PFRecoTauDiscriminationAgainstElectron::discriminate(const PFTauRef& thePFTauRef) const {
104  // ensure tau has at least one charged object
105 
106  if ((*thePFTauRef).leadPFChargedHadrCand().isNull()) {
107  return 0.;
108  } else {
109  // Check if track goes to Ecal crack
110  TrackRef myleadTk;
111  myleadTk = (*thePFTauRef).leadPFChargedHadrCand()->trackRef();
112  math::XYZPointF myleadTkEcalPos = (*thePFTauRef).leadPFChargedHadrCand()->positionAtECALEntrance();
113  if (myleadTk.isNonnull()) {
114  if (applyCut_ecalCrack_ && isInEcalCrack(myleadTkEcalPos.eta())) {
115  return 0.;
116  }
117  }
118  }
119 
120  bool decision = false;
121  bool emfPass = true, htotPass = true, hmaxPass = true;
122  bool h3x3Pass = true, estripPass = true, erecovPass = true;
123  bool epreidPass = true, epreid2DPass = true;
124  bool mvaPass = true, bremCombinedPass = true;
125 
126  if (applyCut_emFraction_) {
127  if ((*thePFTauRef).emFraction() > emFraction_maxValue_) {
128  emfPass = false;
129  }
130  }
131  if (applyCut_hcalTotOverPLead_) {
132  if ((*thePFTauRef).hcalTotOverPLead() < hcalTotOverPLead_minValue_) {
133  htotPass = false;
134  }
135  }
136  if (applyCut_hcalMaxOverPLead_) {
137  if ((*thePFTauRef).hcalMaxOverPLead() < hcalMaxOverPLead_minValue_) {
138  hmaxPass = false;
139  }
140  }
141  if (applyCut_hcal3x3OverPLead_) {
142  if ((*thePFTauRef).hcal3x3OverPLead() < hcal3x3OverPLead_minValue_) {
143  h3x3Pass = false;
144  }
145  }
146  if (applyCut_EOverPLead_) {
147  if ((*thePFTauRef).ecalStripSumEOverPLead() > EOverPLead_minValue_ &&
148  (*thePFTauRef).ecalStripSumEOverPLead() < EOverPLead_maxValue_) {
149  estripPass = false;
150  } else {
151  estripPass = true;
152  }
153  }
154  if (applyCut_bremsRecoveryEOverPLead_) {
155  if ((*thePFTauRef).bremsRecoveryEOverPLead() > bremsRecoveryEOverPLead_minValue_ &&
156  (*thePFTauRef).bremsRecoveryEOverPLead() < bremsRecoveryEOverPLead_maxValue_) {
157  erecovPass = false;
158  } else {
159  erecovPass = true;
160  }
161  }
162  if (applyCut_electronPreID_) {
163  if ((*thePFTauRef).electronPreIDDecision()) {
164  epreidPass = false;
165  } else {
166  epreidPass = true;
167  }
168  }
169 
170  if (applyCut_electronPreID_2D_) {
171  if (((*thePFTauRef).electronPreIDDecision() &&
172  ((*thePFTauRef).ecalStripSumEOverPLead() < elecPreID1_EOverPLead_maxValue_ ||
173  (*thePFTauRef).hcal3x3OverPLead() > elecPreID1_HOverPLead_minValue_)) ||
174  (!(*thePFTauRef).electronPreIDDecision() &&
175  ((*thePFTauRef).ecalStripSumEOverPLead() < elecPreID0_EOverPLead_maxValue_ ||
176  (*thePFTauRef).hcal3x3OverPLead() > elecPreID0_HOverPLead_minValue_))) {
177  epreid2DPass = true;
178  } else {
179  epreid2DPass = false;
180  }
181  }
182 
183  if (applyCut_PFElectronMVA_) {
184  if ((*thePFTauRef).electronPreIDOutput() > pfelectronMVA_maxValue_) {
185  mvaPass = false;
186  }
187  }
188  if (applyCut_bremCombined_) {
189  if (thePFTauRef->leadPFChargedHadrCand()->trackRef().isNull()) {
190  // No KF track found
191  return 0;
192  }
193  if (thePFTauRef->signalPFChargedHadrCands().size() == 1 && thePFTauRef->signalPFGammaCands().empty()) {
194  if (thePFTauRef->leadPFChargedHadrCand()->hcalEnergy() / thePFTauRef->leadPFChargedHadrCand()->trackRef()->p() <
195  bremCombined_maxHOP_)
196  bremCombinedPass = false;
197  } else if (thePFTauRef->signalPFChargedHadrCands().size() == 1 && !thePFTauRef->signalPFGammaCands().empty()) {
198  //calculate the brem ratio energy
199  float bremEnergy = 0.;
200  float emEnergy = 0.;
201  for (unsigned int Nc = 0; Nc < thePFTauRef->signalPFGammaCands().size(); ++Nc) {
202  PFCandidatePtr cand = thePFTauRef->signalPFGammaCands().at(Nc);
203  if (fabs(thePFTauRef->leadPFChargedHadrCand()->trackRef()->eta() - cand->eta()) < bremCombined_stripSize_)
204  bremEnergy += cand->energy();
205  emEnergy += cand->energy();
206  }
207  if (bremEnergy / emEnergy > bremCombined_fraction_ && thePFTauRef->mass() < bremCombined_minMass_)
208  bremCombinedPass = false;
209  }
210  }
211 
212  decision = emfPass && htotPass && hmaxPass && h3x3Pass && estripPass && erecovPass && epreidPass && epreid2DPass &&
213  mvaPass && bremCombinedPass;
214 
215  return (decision ? 1. : 0.);
216  }
217 
218  bool PFRecoTauDiscriminationAgainstElectron::isInEcalCrack(double eta) const {
219  eta = fabs(eta);
220  return (eta < 0.018 || (eta > 0.423 && eta < 0.461) || (eta > 0.770 && eta < 0.806) ||
221  (eta > 1.127 && eta < 1.163) || (eta > 1.460 && eta < 1.558));
222  }
223 } // namespace
224 
226  // pfRecoTauDiscriminationAgainstElectron
228  desc.add<bool>("ApplyCut_ElectronPreID_2D", false);
229  desc.add<double>("ElecPreID0_HOverPLead_minValue", 0.05);
230  desc.add<edm::InputTag>("PFTauProducer", edm::InputTag("pfRecoTauProducer"));
231  desc.add<bool>("ApplyCut_ElectronPreID", false);
232  desc.add<bool>("ApplyCut_HcalTotOverPLead", false);
233  desc.add<double>("EOverPLead_minValue", 0.8);
234  desc.add<double>("ElecPreID1_EOverPLead_maxValue", 0.8);
235  desc.add<double>("HcalMaxOverPLead_minValue", 0.1);
236  desc.add<double>("BremCombined_HOP", 0.1);
237  desc.add<bool>("ApplyCut_EmFraction", false);
238  desc.add<double>("EmFraction_maxValue", 0.9);
239  desc.add<double>("BremCombined_Mass", 0.55);
240  desc.add<bool>("ApplyCut_PFElectronMVA", true);
241  desc.add<double>("PFElectronMVA_maxValue", -0.1);
242  desc.add<bool>("ApplyCut_HcalMaxOverPLead", false);
243  {
245  psd0.add<std::string>("BooleanOperator", "and");
246  {
248  psd1.add<double>("cut");
249  psd1.add<edm::InputTag>("Producer");
250  psd0.addOptional<edm::ParameterSetDescription>("leadTrack", psd1);
251  }
252  desc.add<edm::ParameterSetDescription>("Prediscriminants", psd0);
253  }
254  desc.add<bool>("ApplyCut_BremCombined", false);
255  desc.add<double>("Hcal3x3OverPLead_minValue", 0.1);
256  desc.add<double>("ElecPreID1_HOverPLead_minValue", 0.15);
257  desc.add<double>("ElecPreID0_EOverPLead_maxValue", 0.95);
258  desc.add<double>("BremsRecoveryEOverPLead_minValue", 0.8);
259  desc.add<bool>("ApplyCut_EcalCrackCut", false);
260  desc.add<double>("BremCombined_StripSize", 0.03);
261  desc.add<double>("EOverPLead_maxValue", 1.8);
262  desc.add<double>("HcalTotOverPLead_minValue", 0.1);
263  desc.add<bool>("ApplyCut_BremsRecoveryEOverPLead", false);
264  desc.add<bool>("ApplyCut_Hcal3x3OverPLead", false);
265  desc.add<bool>("ApplyCut_EOverPLead", false);
266  desc.add<double>("BremCombined_Fraction", 0.99);
267  desc.add<double>("BremsRecoveryEOverPLead_maxValue", 1.8);
268  descriptions.add("pfRecoTauDiscriminationAgainstElectron", desc);
269 }
270 
271 DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectron);
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:10
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isNull() const
Checks for null.
Definition: Ref.h:235
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
fixed size matrix