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 #include <TObjString.h>
24 
25 #include <iostream>
26 #include <sstream>
27 #include <fstream>
28 #include <vector>
29 
30 using namespace reco;
31 typedef std::pair<double, double> pdouble;
32 
34 public:
37  LeadPFChargedHadrEoP_barrel_min_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_barrel_min");
38  LeadPFChargedHadrEoP_barrel_max_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_barrel_max");
39  Hcal3x3OverPLead_barrel_max_ = iConfig.getParameter<double>("Hcal3x3OverPLead_barrel_max");
40  GammaEtaMom_barrel_max_ = iConfig.getParameter<double>("GammaEtaMom_barrel_max");
41  GammaPhiMom_barrel_max_ = iConfig.getParameter<double>("GammaPhiMom_barrel_max");
42  GammaEnFrac_barrel_max_ = iConfig.getParameter<double>("GammaEnFrac_barrel_max");
43  LeadPFChargedHadrEoP_endcap_min1_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_endcap_min1");
44  LeadPFChargedHadrEoP_endcap_max1_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_endcap_max1");
45  LeadPFChargedHadrEoP_endcap_min2_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_endcap_min2");
46  LeadPFChargedHadrEoP_endcap_max2_ = iConfig.getParameter<double>("LeadPFChargedHadrEoP_endcap_max2");
47  Hcal3x3OverPLead_endcap_max_ = iConfig.getParameter<double>("Hcal3x3OverPLead_endcap_max");
48  GammaEtaMom_endcap_max_ = iConfig.getParameter<double>("GammaEtaMom_endcap_max");
49  GammaPhiMom_endcap_max_ = iConfig.getParameter<double>("GammaPhiMom_endcap_max");
50  GammaEnFrac_endcap_max_ = iConfig.getParameter<double>("GammaEnFrac_endcap_max");
51  keepTausInEcalCrack_ = iConfig.getParameter<bool>("keepTausInEcalCrack");
52  rejectTausInEcalCrack_ = iConfig.getParameter<bool>("rejectTausInEcalCrack");
53 
54  applyCut_hcal3x3OverPLead_ = iConfig.getParameter<bool>("applyCut_hcal3x3OverPLead");
55  applyCut_leadPFChargedHadrEoP_ = iConfig.getParameter<bool>("applyCut_leadPFChargedHadrEoP");
56  applyCut_GammaEtaMom_ = iConfig.getParameter<bool>("applyCut_GammaEtaMom");
57  applyCut_GammaPhiMom_ = iConfig.getParameter<bool>("applyCut_GammaPhiMom");
58  applyCut_GammaEnFrac_ = iConfig.getParameter<bool>("applyCut_GammaEnFrac");
59  applyCut_HLTSpecific_ = iConfig.getParameter<bool>("applyCut_HLTSpecific");
60 
61  etaCracks_string_ = iConfig.getParameter<std::vector<std::string>>("etaCracks");
62 
63  verbosity_ = iConfig.getParameter<int>("verbosity");
64 
65  cuts2_ = new AntiElectronIDCut2();
66  }
67 
68  void beginEvent(const edm::Event&, const edm::EventSetup&) override;
69 
70  double discriminate(const PFTauRef&) const override;
71 
73 
74  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
75 
76 private:
77  bool isInEcalCrack(double) const;
78  std::vector<pdouble> etaCracks_;
79  std::vector<std::string> etaCracks_string_;
80 
82 
97 
100 
107 
109 };
110 
112  cuts2_->SetBarrelCutValues(LeadPFChargedHadrEoP_barrel_min_,
113  LeadPFChargedHadrEoP_barrel_max_,
114  Hcal3x3OverPLead_barrel_max_,
115  GammaEtaMom_barrel_max_,
116  GammaPhiMom_barrel_max_,
117  GammaEnFrac_barrel_max_);
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  cuts2_->ApplyCut_EcalCrack(keepTausInEcalCrack_, rejectTausInEcalCrack_);
129 
130  cuts2_->ApplyCuts(applyCut_hcal3x3OverPLead_,
131  applyCut_leadPFChargedHadrEoP_,
132  applyCut_GammaEtaMom_,
133  applyCut_GammaPhiMom_,
134  applyCut_GammaEnFrac_,
135  applyCut_HLTSpecific_);
136  //Ecal cracks in eta
137  etaCracks_.clear();
138  TPRegexp regexpParser_range("([0-9.e+/-]+):([0-9.e+/-]+)");
139  for (std::vector<std::string>::const_iterator etaCrack = etaCracks_string_.begin();
140  etaCrack != etaCracks_string_.end();
141  ++etaCrack) {
142  TObjArray* subStrings = regexpParser_range.MatchS(etaCrack->data());
143  if (subStrings->GetEntries() == 3) {
144  //std::cout << "substrings(1) = " << ((TObjString*)subStrings->At(1))->GetString() << std::endl;
145  double range_begin = ((TObjString*)subStrings->At(1))->GetString().Atof();
146  //std::cout << "substrings(2) = " << ((TObjString*)subStrings->At(2))->GetString() << std::endl;
147  double range_end = ((TObjString*)subStrings->At(2))->GetString().Atof();
148  etaCracks_.push_back(pdouble(range_begin, range_end));
149  }
150  }
151 
152  cuts2_->SetEcalCracks(etaCracks_);
153 }
154 
156  double discriminator = 0.;
157 
158  // ensure tau has at least one charged object
159 
160  if ((*thePFTauRef).leadChargedHadrCand().isNull()) {
161  return 0.;
162  } else {
163  discriminator = cuts2_->Discriminator(*thePFTauRef);
164  }
165 
166  if (verbosity_) {
167  std::cout << " Taus : " << TauProducer_ << std::endl;
168  std::cout << "<PFRecoTauDiscriminationAgainstElectron2::discriminate>:" << std::endl;
169  std::cout << " tau: Pt = " << thePFTauRef->pt() << ", eta = " << thePFTauRef->eta()
170  << ", phi = " << thePFTauRef->phi() << std::endl;
171  std::cout << " discriminator value = " << discriminator << std::endl;
172  std::cout << " Prongs in tau: " << thePFTauRef->signalChargedHadrCands().size() << std::endl;
173  }
174 
175  return discriminator;
176 }
177 
179  eta = fabs(eta);
180  return (eta < 0.018 || (eta > 0.423 && eta < 0.461) || (eta > 0.770 && eta < 0.806) || (eta > 1.127 && eta < 1.163) ||
181  (eta > 1.460 && eta < 1.558));
182 }
183 
185  // pfRecoTauDiscriminationAgainstElectron2
187  desc.add<bool>("rejectTausInEcalCrack", false);
188  desc.add<edm::InputTag>("PFTauProducer", edm::InputTag("pfRecoTauProducer"));
189  desc.add<bool>("applyCut_GammaEnFrac", true);
190  desc.add<bool>("applyCut_HLTSpecific", true);
191  desc.add<double>("GammaEnFrac_barrel_max", 0.15);
192  desc.add<bool>("keepTausInEcalCrack", true);
193  {
195  psd0.add<std::string>("BooleanOperator", "and");
196  {
198  psd1.add<double>("cut");
199  psd1.add<edm::InputTag>("Producer");
200  psd0.addOptional<edm::ParameterSetDescription>("leadTrack", psd1);
201  }
202  desc.add<edm::ParameterSetDescription>("Prediscriminants", psd0);
203  }
204  desc.add<bool>("applyCut_GammaPhiMom", false);
205  desc.add<double>("GammaPhiMom_endcap_max", 1.5);
206  desc.add<double>("GammaPhiMom_barrel_max", 1.5);
207  desc.add<bool>("applyCut_leadPFChargedHadrEoP", true);
208  desc.add<double>("LeadPFChargedHadrEoP_barrel_max", 1.01);
209  desc.add<double>("GammaEtaMom_endcap_max", 1.5);
210  desc.add<double>("GammaEtaMom_barrel_max", 1.5);
211  desc.add<double>("Hcal3x3OverPLead_endcap_max", 0.1);
212  desc.add<double>("LeadPFChargedHadrEoP_barrel_min", 0.99);
213  desc.add<double>("LeadPFChargedHadrEoP_endcap_max2", 1.01);
214  desc.add<double>("LeadPFChargedHadrEoP_endcap_min1", 0.7);
215  desc.add<double>("LeadPFChargedHadrEoP_endcap_min2", 0.99);
216  desc.add<double>("LeadPFChargedHadrEoP_endcap_max1", 1.3);
217  desc.add<int>("verbosity", 0);
218  desc.add<double>("GammaEnFrac_endcap_max", 0.2);
219  desc.add<bool>("applyCut_hcal3x3OverPLead", true);
220  desc.add<bool>("applyCut_GammaEtaMom", false);
221  desc.add<std::vector<std::string>>("etaCracks",
222  {
223  "0.0:0.018",
224  "0.423:0.461",
225  "0.770:0.806",
226  "1.127:1.163",
227  "1.460:1.558",
228  });
229  desc.add<double>("Hcal3x3OverPLead_barrel_max", 0.2);
230  descriptions.add("pfRecoTauDiscriminationAgainstElectron2", desc);
231 }
232 
ConfigurationDescriptions.h
PFRecoTauDiscriminationAgainstElectron2::~PFRecoTauDiscriminationAgainstElectron2
~PFRecoTauDiscriminationAgainstElectron2() override
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:72
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
PFRecoTauDiscriminationAgainstElectron2::verbosity_
int verbosity_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:108
PFRecoTauDiscriminationAgainstElectron2::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:184
TauDiscriminationProducerBase.h
PFRecoTauDiscriminationAgainstElectron2::applyCut_GammaEnFrac_
bool applyCut_GammaEnFrac_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:105
PFTauDiscriminator.h
PFRecoTauDiscriminationAgainstElectron2::LeadPFChargedHadrEoP_barrel_max_
double LeadPFChargedHadrEoP_barrel_max_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:84
PFCandidate.h
PFRecoTauDiscriminationAgainstElectron2::LeadPFChargedHadrEoP_endcap_min2_
double LeadPFChargedHadrEoP_endcap_min2_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:91
PFRecoTauDiscriminationAgainstElectron2::applyCut_GammaEtaMom_
bool applyCut_GammaEtaMom_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:103
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
PFRecoTauDiscriminationAgainstElectron2::isInEcalCrack
bool isInEcalCrack(double) const
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:178
PFRecoTauDiscriminationAgainstElectron2::PFRecoTauDiscriminationAgainstElectron2
PFRecoTauDiscriminationAgainstElectron2(const edm::ParameterSet &iConfig)
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:35
PFRecoTauDiscriminationAgainstElectron2::keepTausInEcalCrack_
bool keepTausInEcalCrack_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:98
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::ParameterSetDescription::addOptional
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:105
PFRecoTauDiscriminationAgainstElectron2::cuts2_
AntiElectronIDCut2 * cuts2_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:81
PFRecoTauDiscriminationAgainstElectron2::applyCut_leadPFChargedHadrEoP_
bool applyCut_leadPFChargedHadrEoP_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:102
PFRecoTauDiscriminationAgainstElectron2::GammaEtaMom_barrel_max_
double GammaEtaMom_barrel_max_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:86
edm::Ref< PFTauCollection >
PFRecoTauDiscriminationAgainstElectron2::LeadPFChargedHadrEoP_barrel_min_
double LeadPFChargedHadrEoP_barrel_min_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:83
Track.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
PFRecoTauDiscriminationAgainstElectron2::discriminate
double discriminate(const PFTauRef &) const override
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:155
PVValHelper::eta
Definition: PVValidationHelpers.h:70
PDWG_TauSkim_cff.discriminator
discriminator
Definition: PDWG_TauSkim_cff.py:7
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
TauDiscriminationProducerBase
Definition: TauDiscriminationProducerBase.h:55
PFRecoTauDiscriminationAgainstElectron2::applyCut_hcal3x3OverPLead_
bool applyCut_hcal3x3OverPLead_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:101
PFRecoTauDiscriminationAgainstElectron2::GammaEnFrac_barrel_max_
double GammaEnFrac_barrel_max_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:88
ParameterSetDescription.h
PFRecoTauDiscriminationAgainstElectron2::GammaPhiMom_endcap_max_
double GammaPhiMom_endcap_max_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:95
PFRecoTauDiscriminationAgainstElectron2::rejectTausInEcalCrack_
bool rejectTausInEcalCrack_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:99
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
pdouble
std::pair< double, double > pdouble
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:31
deltaR.h
AntiElectronIDCut2.h
PFRecoTauDiscriminationAgainstElectron2::GammaEnFrac_endcap_max_
double GammaEnFrac_endcap_max_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:96
edm::EventSetup
Definition: EventSetup.h:58
PFRecoTauDiscriminationAgainstElectron2::Hcal3x3OverPLead_endcap_max_
double Hcal3x3OverPLead_endcap_max_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:93
PFRecoTauDiscriminationAgainstElectron2::LeadPFChargedHadrEoP_endcap_max1_
double LeadPFChargedHadrEoP_endcap_max1_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:90
PFRecoTauDiscriminationAgainstElectron2::LeadPFChargedHadrEoP_endcap_min1_
double LeadPFChargedHadrEoP_endcap_min1_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:89
AntiElectronIDCut2
Definition: AntiElectronIDCut2.h:22
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
PFRecoTauDiscriminationAgainstElectron2::GammaEtaMom_endcap_max_
double GammaEtaMom_endcap_max_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:94
PFRecoTauDiscriminationAgainstElectron2::applyCut_GammaPhiMom_
bool applyCut_GammaPhiMom_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:104
PFRecoTauDiscriminationAgainstElectron2::LeadPFChargedHadrEoP_endcap_max2_
double LeadPFChargedHadrEoP_endcap_max2_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:92
PFRecoTauDiscriminationAgainstElectron2::applyCut_HLTSpecific_
bool applyCut_HLTSpecific_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:106
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PFRecoTauDiscriminationAgainstElectron2::beginEvent
void beginEvent(const edm::Event &, const edm::EventSetup &) override
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:111
Exception.h
PFRecoTauDiscriminationAgainstElectron2::etaCracks_
std::vector< pdouble > etaCracks_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:78
PFRecoTauDiscriminationAgainstElectron2::Hcal3x3OverPLead_barrel_max_
double Hcal3x3OverPLead_barrel_max_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:85
PFRecoTauDiscriminationAgainstElectron2::etaCracks_string_
std::vector< std::string > etaCracks_string_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:79
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
PFRecoTauDiscriminationAgainstElectron2::GammaPhiMom_barrel_max_
double GammaPhiMom_barrel_max_
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:87
PFRecoTauDiscriminationAgainstElectron2
Definition: PFRecoTauDiscriminationAgainstElectron2.cc:33
PFCandidateFwd.h