CMS 3D CMS Logo

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

#include <TauWPThreshold.h>

Public Member Functions

double operator() (int dm, double pt, double eta) const
 
double operator() (const reco::BaseTau &tau, bool isPFTau) const
 
double operator() (const reco::Candidate &tau) const
 
 TauWPThreshold (const std::string &cut_str)
 

Private Attributes

std::unique_ptr< TF1 > fn_
 
double value_
 

Detailed Description

Definition at line 13 of file TauWPThreshold.h.

Constructor & Destructor Documentation

◆ TauWPThreshold()

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

Definition at line 15 of file TauWPThreshold.h.

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

15  {
16  bool simple_value = false;
17  const char* cut_cstr = cut_str.c_str();
18  char* end_cstr{};
19  value_ = std::strtod(cut_cstr, &end_cstr);
20  // simple number if end_cstr is empty and not equal to initial string (cut_cstr), and returned value is finite
21  simple_value = !*end_cstr && cut_cstr != end_cstr && std::isfinite(value_);
22  if (!simple_value) {
23  static const std::string prefix =
24  "[&](double *x, double *p) { const int decayMode = p[0];"
25  "const double pt = p[1]; const double eta = p[2];";
26  static const int n_params = 3;
27  static const auto handler = [](int, Bool_t, const char*, const char*) -> void {};
28 
29  std::string fn_str = prefix;
30  if (cut_str.find("return") == std::string::npos)
31  fn_str += " return " + cut_str + ";}";
32  else
33  fn_str += 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  }
std::unique_ptr< TF1 > fn_

Member Function Documentation

◆ operator()() [1/3]

double tau::TauWPThreshold::operator() ( int  dm,
double  pt,
double  eta 
) const
inline

Definition at line 42 of file TauWPThreshold.h.

References symbols::dm, PVValHelper::eta, fn_, DiDispStaMuonMonitor_cfi::pt, and value_.

42  {
43  if (!fn_)
44  return value_;
45 
46  fn_->SetParameter(0, dm);
47  fn_->SetParameter(1, pt);
48  fn_->SetParameter(2, eta);
49  return fn_->Eval(0);
50  }
std::unique_ptr< TF1 > fn_

◆ operator()() [2/3]

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

Definition at line 52 of file TauWPThreshold.h.

References boostedTaus_cff::decayMode, symbols::dm, and metsig::tau.

52  {
53  const int dm =
54  isPFTau ? dynamic_cast<const reco::PFTau&>(tau).decayMode() : dynamic_cast<const pat::Tau&>(tau).decayMode();
55  return (*this)(dm, tau.pt(), tau.eta());
56  }
Definition: HeavyIon.h:7
Definition: Tau.py:1

◆ operator()() [3/3]

double tau::TauWPThreshold::operator() ( const reco::Candidate tau) const
inline

Definition at line 58 of file TauWPThreshold.h.

58 { return (*this)(-1, tau.pt(), tau.eta()); }

Member Data Documentation

◆ fn_

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

Definition at line 61 of file TauWPThreshold.h.

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

◆ value_

double tau::TauWPThreshold::value_
private

Definition at line 62 of file TauWPThreshold.h.

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