CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
deep_tau::TauWPThreshold Class Reference

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 50 of file DeepTauId.cc.

Constructor & Destructor Documentation

◆ TauWPThreshold()

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

Definition at line 52 of file DeepTauId.cc.

References fn_, createfilelist::int, hcallasereventfilter2012_cfi::prefix, AlCaHLTBitMon_QueryRunRegistry::string, and value_.

52  {
53  bool simple_value = false;
54  try {
55  size_t pos = 0;
56  value_ = std::stod(cut_str, &pos);
57  simple_value = (pos == cut_str.size());
58  } catch (std::invalid_argument&) {
59  } catch (std::out_of_range&) {
60  }
61  if (!simple_value) {
62  static const std::string prefix =
63  "[&](double *x, double *p) { const int decayMode = p[0];"
64  "const double pt = p[1]; const double eta = p[2];";
65  static const int n_params = 3;
66  static const auto handler = [](int, Bool_t, const char*, const char*) -> void {};
67 
68  std::string fn_str = prefix;
69  if (cut_str.find("return") == std::string::npos)
70  fn_str += " return " + cut_str + ";}";
71  else
72  fn_str += cut_str + "}";
73  auto old_handler = SetErrorHandler(handler);
74  fn_ = std::make_unique<TF1>("fn_", fn_str.c_str(), 0, 1, n_params);
75  SetErrorHandler(old_handler);
76  if (!fn_->IsValid())
77  throw cms::Exception("TauWPThreshold: invalid formula") << "Invalid WP cut formula = '" << cut_str << "'.";
78  }
79  }
std::unique_ptr< TF1 > fn_
Definition: DeepTauId.cc:95

Member Function Documentation

◆ operator()()

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

Definition at line 80 of file DeepTauId.cc.

References boostedTaus_cff::decayMode, fn_, metsig::tau, and value_.

80  {
81  if (!fn_) {
82  return value_;
83  }
84 
85  if (isPFTau)
86  fn_->SetParameter(0, dynamic_cast<const reco::PFTau&>(tau).decayMode());
87  else
88  fn_->SetParameter(0, dynamic_cast<const pat::Tau&>(tau).decayMode());
89  fn_->SetParameter(1, tau.pt());
90  fn_->SetParameter(2, tau.eta());
91  return fn_->Eval(0);
92  }
std::unique_ptr< TF1 > fn_
Definition: DeepTauId.cc:95

Member Data Documentation

◆ fn_

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

Definition at line 95 of file DeepTauId.cc.

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

◆ value_

double deep_tau::TauWPThreshold::value_
private

Definition at line 96 of file DeepTauId.cc.

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