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 
ExpressionEvaluatorCut::realname_
const std::string realname_
Definition: ExpressionEvaluatorCut.cc:18
watchdog.const
const
Definition: watchdog.py:83
candidate_functions::CandidateCut::result_type
bool result_type
Definition: CandidateCut.h:11
ExpressionEvaluatorTemplates.h
ExpressionEvaluatorCut::name
const std::string & name() const final
Definition: ExpressionEvaluatorCut.cc:15
ExpressionEvaluatorCut::ExpressionEvaluatorCut
ExpressionEvaluatorCut(const edm::ParameterSet &c)
Definition: ExpressionEvaluatorCut.cc:22
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:36
edmplugin::PluginFactory
Definition: PluginFactory.h:34
cand
Definition: decayParser.h:34
ExpressionEvaluatorCut
Definition: ExpressionEvaluatorCut.cc:6
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::Ptr< Candidate >
ExpressionEvaluatorCut::asCandidate
result_type asCandidate(const argument_type &cand) const final
Definition: ExpressionEvaluatorCut.cc:11
CutApplicatorBase
Definition: CutApplicatorBase.h:45
ExpressionEvaluator.h
std
Definition: JetResolutionObject.h:76
ExpressionEvaluatorCut::~ExpressionEvaluatorCut
~ExpressionEvaluatorCut() override
Definition: ExpressionEvaluatorCut.cc:9
candidate_functions::CandidateCut::value
virtual double value(const reco::CandidatePtr &) const =0
ExpressionEvaluatorCut::cut_
CutApplicatorBase * cut_
Definition: ExpressionEvaluatorCut.cc:19
ExpressionEvaluatorCut::value
double value(const reco::CandidatePtr &cand) const final
Definition: ExpressionEvaluatorCut.cc:13
reco::ExpressionEvaluator::expr
EXPR * expr() const
Definition: ExpressionEvaluator.h:14
CutApplicatorBase.h
reco::ExpressionEvaluator
Definition: ExpressionEvaluator.h:8