CMS 3D CMS Logo

PFRecoTauDiscriminationAgainstElectron2.cc
Go to the documentation of this file.
1 /* class PFRecoTauDiscriminationAgainstElectron2
2  * created : Apr 3, 2014
3  * revised : ,
4  * Authorss : Aruna Nayak (DESY)
5  */
6 
8 
11 
14 
20 
21 #include <TMath.h>
22 #include "TPRegexp.h"
23 
24 #include <iostream>
25 #include <sstream>
26 #include <fstream>
27 #include <vector>
28 
29 using namespace reco;
30 typedef std::pair<double, double> pdouble;
31 
33 public:
36  {
37 
38  LeadPFChargedHadrEoP_barrel_min_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_barrel_min");
39  LeadPFChargedHadrEoP_barrel_max_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_barrel_max");
40  Hcal3x3OverPLead_barrel_max_ = iConfig.getParameter<double>("Hcal3x3OverPLead_barrel_max");
41  GammaEtaMom_barrel_max_ = iConfig.getParameter<double>("GammaEtaMom_barrel_max");
42  GammaPhiMom_barrel_max_ = iConfig.getParameter<double>("GammaPhiMom_barrel_max");
43  GammaEnFrac_barrel_max_ = iConfig.getParameter<double>("GammaEnFrac_barrel_max");
44  LeadPFChargedHadrEoP_endcap_min1_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_endcap_min1");
45  LeadPFChargedHadrEoP_endcap_max1_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_endcap_max1");
46  LeadPFChargedHadrEoP_endcap_min2_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_endcap_min2");
47  LeadPFChargedHadrEoP_endcap_max2_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_endcap_max2");
48  Hcal3x3OverPLead_endcap_max_ = iConfig.getParameter<double>("Hcal3x3OverPLead_endcap_max");
49  GammaEtaMom_endcap_max_ = iConfig.getParameter<double>("GammaEtaMom_endcap_max");
50  GammaPhiMom_endcap_max_ = iConfig.getParameter<double>("GammaPhiMom_endcap_max");
51  GammaEnFrac_endcap_max_ = iConfig.getParameter<double>("GammaEnFrac_endcap_max");
52  keepTausInEcalCrack_ = iConfig.getParameter<bool>("keepTausInEcalCrack");
53  rejectTausInEcalCrack_ = iConfig.getParameter<bool>("rejectTausInEcalCrack");
54 
55  applyCut_hcal3x3OverPLead_ = iConfig.getParameter<bool>("applyCut_hcal3x3OverPLead");
56  applyCut_leadPFChargedHadrEoP_ = iConfig.getParameter<bool>("applyCut_leadPFChargedHadrEoP");
57  applyCut_GammaEtaMom_ = iConfig.getParameter<bool>("applyCut_GammaEtaMom");
58  applyCut_GammaPhiMom_ = iConfig.getParameter<bool>("applyCut_GammaPhiMom");
59  applyCut_GammaEnFrac_ = iConfig.getParameter<bool>("applyCut_GammaEnFrac");
60  applyCut_HLTSpecific_ = iConfig.getParameter<bool>("applyCut_HLTSpecific");
61 
62  etaCracks_string_ = iConfig.getParameter<std::vector<std::string>>("etaCracks");
63 
64  verbosity_ = iConfig.getParameter<int>("verbosity");
65 
66  cuts2_ = new AntiElectronIDCut2();
67  }
68 
69  void beginEvent(const edm::Event&, const edm::EventSetup&) override;
70 
71  double discriminate(const PFTauRef&) const override;
72 
74  { }
75 
76  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
77 private:
78  bool isInEcalCrack(double) const;
79  std::vector<pdouble> etaCracks_;
80  std::vector<std::string> etaCracks_string_;
81 
83 
98 
101 
108 
110 };
111 
113 {
114  cuts2_->SetBarrelCutValues(LeadPFChargedHadrEoP_barrel_min_,
115  LeadPFChargedHadrEoP_barrel_max_,
116  Hcal3x3OverPLead_barrel_max_,
117  GammaEtaMom_barrel_max_,
118  GammaPhiMom_barrel_max_,
119  GammaEnFrac_barrel_max_
120  );
121 
122  cuts2_->SetEndcapCutValues(LeadPFChargedHadrEoP_endcap_min1_,
123  LeadPFChargedHadrEoP_endcap_max1_,
124  LeadPFChargedHadrEoP_endcap_min2_,
125  LeadPFChargedHadrEoP_endcap_max2_,
126  Hcal3x3OverPLead_endcap_max_,
127  GammaEtaMom_endcap_max_,
128  GammaPhiMom_endcap_max_,
129  GammaEnFrac_endcap_max_
130  );
131 
132  cuts2_->ApplyCut_EcalCrack(keepTausInEcalCrack_, rejectTausInEcalCrack_);
133 
134  cuts2_->ApplyCuts(applyCut_hcal3x3OverPLead_,
135  applyCut_leadPFChargedHadrEoP_,
136  applyCut_GammaEtaMom_,
137  applyCut_GammaPhiMom_,
138  applyCut_GammaEnFrac_,
139  applyCut_HLTSpecific_
140  );
141  //Ecal cracks in eta
142  etaCracks_.clear();
143  TPRegexp regexpParser_range("([0-9.e+/-]+):([0-9.e+/-]+)");
144  for ( std::vector<std::string>::const_iterator etaCrack = etaCracks_string_.begin();
145  etaCrack != etaCracks_string_.end(); ++etaCrack ) {
146  TObjArray* subStrings = regexpParser_range.MatchS(etaCrack->data());
147  if ( subStrings->GetEntries() == 3 ) {
148  //std::cout << "substrings(1) = " << ((TObjString*)subStrings->At(1))->GetString() << std::endl;
149  double range_begin = ((TObjString*)subStrings->At(1))->GetString().Atof();
150  //std::cout << "substrings(2) = " << ((TObjString*)subStrings->At(2))->GetString() << std::endl;
151  double range_end = ((TObjString*)subStrings->At(2))->GetString().Atof();
152  etaCracks_.push_back(pdouble(range_begin, range_end));
153  }
154  }
155 
156  cuts2_->SetEcalCracks(etaCracks_);
157 
158 }
159 
161 {
162  double discriminator = 0.;
163 
164  // ensure tau has at least one charged object
165 
166  if( (*thePFTauRef).leadChargedHadrCand().isNull() )
167  {
168  return 0.;
169  }
170  else
171  {
172  discriminator = cuts2_->Discriminator(*thePFTauRef);
173  }
174 
175 
176  if ( verbosity_ ) {
177  std::cout<<" Taus : "<<TauProducer_<<std::endl;
178  std::cout << "<PFRecoTauDiscriminationAgainstElectron2::discriminate>:" << std::endl;
179  std::cout << " tau: Pt = " << thePFTauRef->pt() << ", eta = " << thePFTauRef->eta() << ", phi = " << thePFTauRef->phi() << std::endl;
180  std::cout << " discriminator value = " << discriminator << std::endl;
181  std::cout << " Prongs in tau: " << thePFTauRef->signalChargedHadrCands().size() << std::endl;
182  }
183 
184  return discriminator;
185 }
186 
187 bool
189 {
190  eta = fabs(eta);
191  return (eta < 0.018 ||
192  (eta>0.423 && eta<0.461) ||
193  (eta>0.770 && eta<0.806) ||
194  (eta>1.127 && eta<1.163) ||
195  (eta>1.460 && eta<1.558));
196 }
197 
198 void
200  // pfRecoTauDiscriminationAgainstElectron2
202  desc.add<bool>("rejectTausInEcalCrack", false);
203  desc.add<edm::InputTag>("PFTauProducer", edm::InputTag("pfRecoTauProducer"));
204  desc.add<bool>("applyCut_GammaEnFrac", true);
205  desc.add<bool>("applyCut_HLTSpecific", true);
206  desc.add<double>("GammaEnFrac_barrel_max", 0.15);
207  desc.add<bool>("keepTausInEcalCrack", true);
208  {
210  psd0.add<std::string>("BooleanOperator", "and");
211  {
213  psd1.add<double>("cut");
214  psd1.add<edm::InputTag>("Producer");
215  psd0.addOptional<edm::ParameterSetDescription>("leadTrack", psd1);
216  }
217  desc.add<edm::ParameterSetDescription>("Prediscriminants", psd0);
218  }
219  desc.add<bool>("applyCut_GammaPhiMom", false);
220  desc.add<double>("GammaPhiMom_endcap_max", 1.5);
221  desc.add<double>("GammaPhiMom_barrel_max", 1.5);
222  desc.add<bool>("applyCut_leadPFChargedHadrEoP", true);
223  desc.add<double>("LeadPFChargedHadrEoP_barrel_max", 1.01);
224  desc.add<double>("GammaEtaMom_endcap_max", 1.5);
225  desc.add<double>("GammaEtaMom_barrel_max", 1.5);
226  desc.add<double>("Hcal3x3OverPLead_endcap_max", 0.1);
227  desc.add<double>("LeadPFChargedHadrEoP_barrel_min", 0.99);
228  desc.add<double>("LeadPFChargedHadrEoP_endcap_max2", 1.01);
229  desc.add<double>("LeadPFChargedHadrEoP_endcap_min1", 0.7);
230  desc.add<double>("LeadPFChargedHadrEoP_endcap_min2", 0.99);
231  desc.add<double>("LeadPFChargedHadrEoP_endcap_max1", 1.3);
232  desc.add<int>("verbosity", 0);
233  desc.add<double>("GammaEnFrac_endcap_max", 0.2);
234  desc.add<bool>("applyCut_hcal3x3OverPLead", true);
235  desc.add<bool>("applyCut_GammaEtaMom", false);
236  desc.add<std::vector<std::string>>("etaCracks", {
237  "0.0:0.018",
238  "0.423:0.461",
239  "0.770:0.806",
240  "1.127:1.163",
241  "1.460:1.558",
242  });
243  desc.add<double>("Hcal3x3OverPLead_barrel_max", 0.2);
244  descriptions.add("pfRecoTauDiscriminationAgainstElectron2", desc);
245 }
246 
T getParameter(std::string const &) const
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::pair< double, double > pdouble
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void beginEvent(const edm::Event &, const edm::EventSetup &) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
fixed size matrix
PFRecoTauDiscriminationAgainstElectron2(const edm::ParameterSet &iConfig)