CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
17 
18 #include <TMath.h>
19 #include "TPRegexp.h"
20 
21 #include <iostream>
22 #include <sstream>
23 #include <fstream>
24 #include <vector>
25 
26 using namespace reco;
27 typedef std::pair<double, double> pdouble;
28 
30 public:
33  {
34 
35  LeadPFChargedHadrEoP_barrel_min_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_barrel_min");
36  LeadPFChargedHadrEoP_barrel_max_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_barrel_max");
37  Hcal3x3OverPLead_barrel_max_ = iConfig.getParameter<double>("Hcal3x3OverPLead_barrel_max");
38  GammaEtaMom_barrel_max_ = iConfig.getParameter<double>("GammaEtaMom_barrel_max");
39  GammaPhiMom_barrel_max_ = iConfig.getParameter<double>("GammaPhiMom_barrel_max");
40  GammaEnFrac_barrel_max_ = iConfig.getParameter<double>("GammaEnFrac_barrel_max");
41  LeadPFChargedHadrEoP_endcap_min1_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_endcap_min1");
42  LeadPFChargedHadrEoP_endcap_max1_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_endcap_max1");
43  LeadPFChargedHadrEoP_endcap_min2_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_endcap_min2");
44  LeadPFChargedHadrEoP_endcap_max2_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_endcap_max2");
45  Hcal3x3OverPLead_endcap_max_ = iConfig.getParameter<double>("Hcal3x3OverPLead_endcap_max");
46  GammaEtaMom_endcap_max_ = iConfig.getParameter<double>("GammaEtaMom_endcap_max");
47  GammaPhiMom_endcap_max_ = iConfig.getParameter<double>("GammaPhiMom_endcap_max");
48  GammaEnFrac_endcap_max_ = iConfig.getParameter<double>("GammaEnFrac_endcap_max");
49  keepTausInEcalCrack_ = iConfig.getParameter<bool>("keepTausInEcalCrack");
50  rejectTausInEcalCrack_ = iConfig.getParameter<bool>("rejectTausInEcalCrack");
51 
52  applyCut_hcal3x3OverPLead_ = iConfig.getParameter<bool>("applyCut_hcal3x3OverPLead");
53  applyCut_leadPFChargedHadrEoP_ = iConfig.getParameter<bool>("applyCut_leadPFChargedHadrEoP");
54  applyCut_GammaEtaMom_ = iConfig.getParameter<bool>("applyCut_GammaEtaMom");
55  applyCut_GammaPhiMom_ = iConfig.getParameter<bool>("applyCut_GammaPhiMom");
56  applyCut_GammaEnFrac_ = iConfig.getParameter<bool>("applyCut_GammaEnFrac");
57  applyCut_HLTSpecific_ = iConfig.getParameter<bool>("applyCut_HLTSpecific");
58 
59  etaCracks_string_ = iConfig.getParameter<std::vector<std::string>>("etaCracks");
60 
61  verbosity_ = ( iConfig.exists("verbosity") ) ?
62  iConfig.getParameter<int>("verbosity") : 0;
63 
64  cuts2_ = new AntiElectronIDCut2();
65  }
66 
67  void beginEvent(const edm::Event&, const edm::EventSetup&);
68 
69  double discriminate(const PFTauRef&);
70 
72  { }
73 
74 private:
75  bool isInEcalCrack(double) const;
76  std::vector<pdouble> etaCracks_;
77  std::vector<std::string> etaCracks_string_;
78 
80 
95 
98 
105 
107 };
108 
110 {
111  cuts2_->SetBarrelCutValues(LeadPFChargedHadrEoP_barrel_min_,
112  LeadPFChargedHadrEoP_barrel_max_,
113  Hcal3x3OverPLead_barrel_max_,
114  GammaEtaMom_barrel_max_,
115  GammaPhiMom_barrel_max_,
116  GammaEnFrac_barrel_max_
117  );
118 
119  cuts2_->SetEndcapCutValues(LeadPFChargedHadrEoP_endcap_min1_,
120  LeadPFChargedHadrEoP_endcap_max1_,
121  LeadPFChargedHadrEoP_endcap_min2_,
122  LeadPFChargedHadrEoP_endcap_max2_,
123  Hcal3x3OverPLead_endcap_max_,
124  GammaEtaMom_endcap_max_,
125  GammaPhiMom_endcap_max_,
126  GammaEnFrac_endcap_max_
127  );
128 
129  cuts2_->ApplyCut_EcalCrack(keepTausInEcalCrack_, rejectTausInEcalCrack_);
130 
131  cuts2_->ApplyCuts(applyCut_hcal3x3OverPLead_,
132  applyCut_leadPFChargedHadrEoP_,
133  applyCut_GammaEtaMom_,
134  applyCut_GammaPhiMom_,
135  applyCut_GammaEnFrac_,
136  applyCut_HLTSpecific_
137  );
138  //Ecal cracks in eta
139  etaCracks_.clear();
140  TPRegexp regexpParser_range("([0-9.e+/-]+):([0-9.e+/-]+)");
141  for ( std::vector<std::string>::const_iterator etaCrack = etaCracks_string_.begin();
142  etaCrack != etaCracks_string_.end(); ++etaCrack ) {
143  TObjArray* subStrings = regexpParser_range.MatchS(etaCrack->data());
144  if ( subStrings->GetEntries() == 3 ) {
145  //std::cout << "substrings(1) = " << ((TObjString*)subStrings->At(1))->GetString() << std::endl;
146  double range_begin = ((TObjString*)subStrings->At(1))->GetString().Atof();
147  //std::cout << "substrings(2) = " << ((TObjString*)subStrings->At(2))->GetString() << std::endl;
148  double range_end = ((TObjString*)subStrings->At(2))->GetString().Atof();
149  etaCracks_.push_back(pdouble(range_begin, range_end));
150  }
151  }
152 
153  cuts2_->SetEcalCracks(etaCracks_);
154 
155 }
156 
158 {
159  double discriminator = 0.;
160 
161  // ensure tau has at least one charged object
162 
163  if( (*thePFTauRef).leadPFChargedHadrCand().isNull() )
164  {
165  return 0.;
166  }
167  else
168  {
169  discriminator = cuts2_->Discriminator(*thePFTauRef);
170  }
171 
172 
173  if ( verbosity_ ) {
174  std::cout<<" Taus : "<<TauProducer_<<std::endl;
175  std::cout << "<PFRecoTauDiscriminationAgainstElectron2::discriminate>:" << std::endl;
176  std::cout << " tau: Pt = " << thePFTauRef->pt() << ", eta = " << thePFTauRef->eta() << ", phi = " << thePFTauRef->phi() << std::endl;
177  std::cout << " discriminator value = " << discriminator << std::endl;
178  std::cout << " Prongs in tau: " << thePFTauRef->signalPFChargedHadrCands().size() << std::endl;
179  }
180 
181  return discriminator;
182 }
183 
184 bool
186 {
187  eta = fabs(eta);
188  return (eta < 0.018 ||
189  (eta>0.423 && eta<0.461) ||
190  (eta>0.770 && eta<0.806) ||
191  (eta>1.127 && eta<1.163) ||
192  (eta>1.460 && eta<1.558));
193 }
194 
T getParameter(std::string const &) const
std::pair< double, double > pdouble
bool exists(std::string const &parameterName) const
checks if a parameter exists
void beginEvent(const edm::Event &, const edm::EventSetup &)
T eta() const
DEFINE_FWK_MODULE(CosmicTrackingParticleSelector)
tuple cout
Definition: gather_cfg.py:121
PFRecoTauDiscriminationAgainstElectron2(const edm::ParameterSet &iConfig)