PhysicsTools
SelectorUtils
plugins
ExpressionEvaluatorCut.cc
Go to the documentation of this file.
1
#include "
CommonTools/Utils/interface/ExpressionEvaluator.h
"
2
#include "
CommonTools/Utils/interface/ExpressionEvaluatorTemplates.h
"
3
4
#include "
PhysicsTools/SelectorUtils/interface/CutApplicatorBase.h
"
5
6
class
ExpressionEvaluatorCut
:
public
CutApplicatorBase
{
7
public
:
8
ExpressionEvaluatorCut
(
const
edm::ParameterSet
&
c
);
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
:
18
const
std::string
realname_
;
19
CutApplicatorBase
*
cut_
;
20
};
21
22
ExpressionEvaluatorCut::ExpressionEvaluatorCut
(
const
edm::ParameterSet
&
c
)
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
44
DEFINE_EDM_PLUGIN
(
CutApplicatorFactory
,
ExpressionEvaluatorCut
,
"ExpressionEvaluatorCut"
);
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:47
edmplugin::PluginFactory
Definition:
PluginFactory.h:34
cand
Definition:
decayParser.h:32
ExpressionEvaluatorCut
Definition:
ExpressionEvaluatorCut.cc:6
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
c
auto & c
Definition:
CAHitNtupletGeneratorKernelsImpl.h:46
Generated for CMSSW Reference Manual by
1.8.16