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

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

Definition at line 15 of file DeepTauBase.cc.

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

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

Member Function Documentation

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

Definition at line 40 of file DeepTauBase.cc.

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

41 {
42  if(!fn_)
43  return value_;
44  fn_->SetParameter(0, tau.decayMode());
45  fn_->SetParameter(1, tau.pt());
46  fn_->SetParameter(2, tau.eta());
47  return fn_->Eval(0);
48 }
double eta() const final
momentum pseudorapidity
std::unique_ptr< TF1 > fn_
Definition: DeepTauBase.h:36
double pt() const final
transverse momentum
int decayMode() const
reconstructed tau decay mode (specific to PFTau)
Definition: Tau.h:365

Member Data Documentation

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

Definition at line 36 of file DeepTauBase.h.

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

double deep_tau::TauWPThreshold::value_
private

Definition at line 37 of file DeepTauBase.h.

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