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.

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  const std::string fn_str = prefix + cut_str + "}";
34  auto old_handler = SetErrorHandler(handler);
35  fn_ = std::make_unique<TF1>("fn_", fn_str.c_str(), 0, 1, n_params);
36  SetErrorHandler(old_handler);
37  if (!fn_->IsValid())
38  throw cms::Exception("TauWPThreshold: invalid formula") << "Invalid WP cut formula = '" << cut_str << "'.";
39  }
40  }

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

Member Function Documentation

◆ operator()()

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

Definition at line 42 of file DeepTauBase.cc.

42  {
43  if (!fn_)
44  return value_;
45 
46  if (isPFTau)
47  fn_->SetParameter(0, dynamic_cast<const reco::PFTau&>(tau).decayMode());
48  else
49  fn_->SetParameter(0, dynamic_cast<const pat::Tau&>(tau).decayMode());
50  fn_->SetParameter(1, tau.pt());
51  fn_->SetParameter(2, tau.eta());
52  return fn_->Eval(0);
53  }

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

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().

metsig::tau
Definition: SignAlgoResolutions.h:49
pos
Definition: PixelAliasList.h:18
boostedTaus_cff.decayMode
decayMode
Definition: boostedTaus_cff.py:28
deep_tau::TauWPThreshold::value_
double value_
Definition: DeepTauBase.h:45
createfilelist.int
int
Definition: createfilelist.py:10
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
deep_tau::TauWPThreshold::fn_
std::unique_ptr< TF1 > fn_
Definition: DeepTauBase.h:44
cms::Exception
Definition: Exception.h:70
hcallasereventfilter2012_cfi.prefix
prefix
Definition: hcallasereventfilter2012_cfi.py:10