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