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 pat::Tau &tau) const
 
 TauWPThreshold (const std::string &cut_str)
 

Private Attributes

std::unique_ptr< TF1 > fn_
 
double value_
 

Detailed Description

Definition at line 30 of file DeepTauBase.h.

Constructor & Destructor Documentation

◆ TauWPThreshold()

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

Definition at line 14 of file DeepTauBase.cc.

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

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

Member Function Documentation

◆ operator()()

double deep_tau::TauWPThreshold::operator() ( const pat::Tau tau) const

Definition at line 39 of file DeepTauBase.cc.

39  {
40  if (!fn_)
41  return value_;
42  fn_->SetParameter(0, tau.decayMode());
43  fn_->SetParameter(1, tau.pt());
44  fn_->SetParameter(2, tau.eta());
45  return fn_->Eval(0);
46  }

References fn_, metsig::tau, and value_.

Member Data Documentation

◆ fn_

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

Definition at line 36 of file DeepTauBase.h.

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

◆ value_

double deep_tau::TauWPThreshold::value_
private

Definition at line 37 of file DeepTauBase.h.

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

metsig::tau
Definition: SignAlgoResolutions.h:49
pos
Definition: PixelAliasList.h:18
deep_tau::TauWPThreshold::value_
double value_
Definition: DeepTauBase.h:37
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
createfilelist.int
int
Definition: createfilelist.py:10
deep_tau::TauWPThreshold::fn_
std::unique_ptr< TF1 > fn_
Definition: DeepTauBase.h:36
cms::Exception
Definition: Exception.h:70
ZMuMuAnalysisNtupler_cff.prefix
prefix
Definition: ZMuMuAnalysisNtupler_cff.py:14