CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
deep_tau::TauWPThreshold Class Reference

#include <DeepTauBase.h>

Public Member Functions

double operator() (const reco::BaseTau &tau, bool isPFTau) const
 
 TauWPThreshold (const std::string &cut_str)
 

Private Attributes

std::unique_ptr< TF1 > fn_
 
double value_
 

Detailed Description

Definition at line 38 of file DeepTauBase.h.

Constructor & Destructor Documentation

deep_tau::TauWPThreshold::TauWPThreshold ( const std::string &  cut_str)
explicit

Definition at line 17 of file DeepTauBase.cc.

References fn_, PostProcessorHGCAL_cfi::prefix, AlCaHLTBitMon_QueryRunRegistry::string, and value_.

17  {
18  bool simple_value = false;
19  try {
20  size_t pos = 0;
21  value_ = std::stod(cut_str, &pos);
22  simple_value = (pos == cut_str.size());
23  } catch (std::invalid_argument&) {
24  } catch (std::out_of_range&) {
25  }
26  if (!simple_value) {
27  static const std::string prefix =
28  "[&](double *x, double *p) { const int decayMode = p[0];"
29  "const double pt = p[1]; const double eta = p[2];";
30  static const int n_params = 3;
31  static const auto handler = [](int, Bool_t, const char*, const char*) -> void {};
32 
33  std::string fn_str = prefix;
34  if (cut_str.find("return") == std::string::npos)
35  fn_str += " return " + cut_str + ";}";
36  else
37  fn_str += cut_str + "}";
38  auto old_handler = SetErrorHandler(handler);
39  fn_ = std::make_unique<TF1>("fn_", fn_str.c_str(), 0, 1, n_params);
40  SetErrorHandler(old_handler);
41  if (!fn_->IsValid())
42  throw cms::Exception("TauWPThreshold: invalid formula") << "Invalid WP cut formula = '" << cut_str << "'.";
43  }
44  }
std::unique_ptr< TF1 > fn_
Definition: DeepTauBase.h:44

Member Function Documentation

double deep_tau::TauWPThreshold::operator() ( const reco::BaseTau tau,
bool  isPFTau 
) const

Definition at line 46 of file DeepTauBase.cc.

References reco::LeafCandidate::eta(), fn_, reco::LeafCandidate::pt(), and value_.

46  {
47  if (!fn_) {
48  return value_;
49  }
50 
51  if (isPFTau)
52  fn_->SetParameter(0, dynamic_cast<const reco::PFTau&>(tau).decayMode());
53  else
54  fn_->SetParameter(0, dynamic_cast<const pat::Tau&>(tau).decayMode());
55  fn_->SetParameter(1, tau.pt());
56  fn_->SetParameter(2, tau.eta());
57  return fn_->Eval(0);
58  }
double pt() const final
transverse momentum
std::unique_ptr< TF1 > fn_
Definition: DeepTauBase.h:44
double eta() const final
momentum pseudorapidity

Member Data Documentation

std::unique_ptr<TF1> deep_tau::TauWPThreshold::fn_
private

Definition at line 44 of file DeepTauBase.h.

Referenced by operator()(), and TauWPThreshold().

double deep_tau::TauWPThreshold::value_
private

Definition at line 45 of file DeepTauBase.h.

Referenced by operator()(), and TauWPThreshold().