CMS 3D CMS Logo

ExpressionEvaluatorCutWithEventContent.cc
Go to the documentation of this file.
3 
5 
7 public:
10 
11  result_type asCandidate(const argument_type& cand) const final { return (*cut_)(cand); }
12 
13  void setConsumes(edm::ConsumesCollector& sumes) final { cut_->setConsumes(sumes); }
14 
16 
17  double value(const reco::CandidatePtr& cand) const final { return cut_->value(cand); }
18 
19  const std::string& name() const final { return realname_; }
20 
21 private:
24 };
25 
27  : CutApplicatorWithEventContentBase(c), realname_(c.getParameter<std::string>("realCutName")) {
28  const std::string newline("\n");
29  const std::string close_function("; };");
30  const std::string candTypePreamble("CandidateType candidateType() const override final { return ");
31 
32  //construct the overload of candidateType()
33  const std::string& candType = c.getParameter<std::string>("candidateType");
34  const std::string candTypeExpr = candTypePreamble + candType + close_function;
35 
36  // read in the overload of operator()
37  const std::string& oprExpr = c.getParameter<std::string>("functionDef");
38 
39  // read in the overload of value()
40  const std::string& valExpr = c.getParameter<std::string>("valueDef");
41 
42  // read in the overload of setConsumes()
43  const std::string& setConsumesExpr = c.getParameter<std::string>("setConsumesDef");
44 
45  // read in the overload of getEventContent()
46  const std::string& getEventContentExpr = c.getParameter<std::string>("getEventContentDef");
47 
48  // concatenate and evaluate the expression
49  const std::string total_expr = (candTypeExpr + newline + oprExpr + newline + valExpr + newline + setConsumesExpr +
50  newline + getEventContentExpr);
51  reco::ExpressionEvaluator eval("PhysicsTools/SelectorUtils", "CutApplicatorWithEventContentBase", total_expr);
53 }
54 
57  "ExpressionEvaluatorCutWithEventContent");
T getParameter(std::string const &) const
result_type asCandidate(const argument_type &cand) const final
void setConsumes(edm::ConsumesCollector &sumes) final
virtual void getEventContent(const edm::EventBase &)=0
virtual double value(const reco::CandidatePtr &) const =0
void getEventContent(const edm::EventBase &event) final
double value(const reco::CandidatePtr &cand) const final
#define DEFINE_EDM_PLUGIN(factory, type, name)
virtual void setConsumes(edm::ConsumesCollector &)=0
Definition: event.py:1