CMS 3D CMS Logo

ExpressionEvaluatorCut.cc
Go to the documentation of this file.
3 
5 
7 public:
9  ~ExpressionEvaluatorCut() override{};
10 
11  result_type asCandidate(const argument_type& cand) const final { return (*cut_)(cand); }
12 
13  double value(const reco::CandidatePtr& cand) const final { return cut_->value(cand); }
14 
15  const std::string& name() const final { return realname_; }
16 
17 private:
20 };
21 
23  : CutApplicatorBase(c), realname_(c.getParameter<std::string>("realCutName")) {
24  const std::string newline("\n");
25  const std::string close_function("; };");
26  const std::string candTypePreamble("CandidateType candidateType() const override final { return ");
27 
28  //construct the overload of candidateType()
29  const std::string& candType = c.getParameter<std::string>("candidateType");
30  const std::string candTypeExpr = candTypePreamble + candType + close_function;
31 
32  // read in the overload of operator()
33  const std::string& oprExpr = c.getParameter<std::string>("functionDef");
34 
35  // read in the overload of value()
36  const std::string& valExpr = c.getParameter<std::string>("valueDef");
37 
38  // concatenate and evaluate the expression
39  const std::string total_expr = (candTypeExpr + newline + oprExpr + newline + valExpr);
40  reco::ExpressionEvaluator eval("PhysicsTools/SelectorUtils", "CutApplicatorBase", total_expr);
41  cut_ = eval.expr<CutApplicatorBase>();
42 }
43 
double value(const reco::CandidatePtr &cand) const final
result_type asCandidate(const argument_type &cand) const final
const std::string & name() const final
ExpressionEvaluatorCut(const edm::ParameterSet &c)
#define DEFINE_EDM_PLUGIN(factory, type, name)
virtual double value(const reco::CandidatePtr &) const =0