CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ExpressionEvaluatorCut.cc
Go to the documentation of this file.
3 
5 
7 public:
10 
11  result_type asCandidate(const argument_type& cand) const override final {
12  return (*cut_)(cand);
13  }
14 
15  double value(const reco::CandidatePtr& cand) const override final {
16  return cut_->value(cand);
17  }
18 
19  const std::string& name() const override final { return realname_; }
20 
21 private:
24 };
25 
29  realname_(c.getParameter<std::string>("realCutName"))
30 {
31  const std::string newline("\n");
32  const std::string close_function("; };");
33  const std::string candTypePreamble("CandidateType candidateType() const override final { return ");
34 
35  //construct the overload of candidateType()
36  const std::string& candType = c.getParameter<std::string>("candidateType");
37  const std::string candTypeExpr = candTypePreamble + candType + close_function;
38 
39  // read in the overload of operator()
40  const std::string& oprExpr = c.getParameter<std::string>("functionDef");
41 
42  // read in the overload of value()
43  const std::string& valExpr = c.getParameter<std::string>("valueDef");
44 
45  // concatenate and evaluate the expression
46  const std::string total_expr = ( candTypeExpr + newline +
47  oprExpr + newline +
48  valExpr );
49  reco::ExpressionEvaluator eval("PhysicsTools/SelectorUtils",
50  "CutApplicatorBase",
51  total_expr.c_str());
52  cut_ = eval.expr<CutApplicatorBase>();
53 }
54 
57  "ExpressionEvaluatorCut");
T getParameter(std::string const &) const
const std::string & name() const overridefinal
result_type asCandidate(const argument_type &cand) const overridefinal
string const
Definition: compareJSON.py:14
ExpressionEvaluatorCut(const edm::ParameterSet &c)
#define DEFINE_EDM_PLUGIN(factory, type, name)
double value(const reco::CandidatePtr &cand) const overridefinal
virtual double value(const reco::CandidatePtr &) const =0