CMS 3D CMS Logo

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

◆ TauWPThreshold()

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

Definition at line 17 of file DeepTauBase.cc.

References fn_, createfilelist::int, hcallasereventfilter2012_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

◆ operator()()

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

Definition at line 46 of file DeepTauBase.cc.

References boostedTaus_cff::decayMode, fn_, metsig::tau, 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  }
std::unique_ptr< TF1 > fn_
Definition: DeepTauBase.h:44

Member Data Documentation

◆ fn_

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

Definition at line 44 of file DeepTauBase.h.

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

◆ value_

double deep_tau::TauWPThreshold::value_
private

Definition at line 45 of file DeepTauBase.h.

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