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 9 of file TauWPThreshold.h.

Constructor & Destructor Documentation

◆ TauWPThreshold()

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

Definition at line 11 of file TauWPThreshold.h.

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

11  {
12  bool simple_value = false;
13  try {
14  size_t pos = 0;
15  value_ = std::stod(cut_str, &pos);
16  simple_value = (pos == cut_str.size());
17  } catch (std::invalid_argument&) {
18  } catch (std::out_of_range&) {
19  }
20  if (!simple_value) {
21  static const std::string prefix =
22  "[&](double *x, double *p) { const int decayMode = p[0];"
23  "const double pt = p[1]; const double eta = p[2];";
24  static const int n_params = 3;
25  static const auto handler = [](int, Bool_t, const char*, const char*) -> void {};
26 
27  std::string fn_str = prefix;
28  if (cut_str.find("return") == std::string::npos)
29  fn_str += " return " + cut_str + ";}";
30  else
31  fn_str += 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_

Member Function Documentation

◆ operator()() [1/3]

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

Definition at line 40 of file TauWPThreshold.h.

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

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

◆ operator()() [2/3]

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

Definition at line 50 of file TauWPThreshold.h.

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

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

◆ operator()() [3/3]

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

Definition at line 56 of file TauWPThreshold.h.

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

Member Data Documentation

◆ fn_

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

Definition at line 59 of file TauWPThreshold.h.

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

◆ value_

double tau::TauWPThreshold::value_
private

Definition at line 60 of file TauWPThreshold.h.

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