|
|
Go to the documentation of this file. 1 #ifndef FastSimulation_TrackingRecHitProducer_TrackerDetIdSelector_H
2 #define FastSimulation_TrackingRecHitProducer_TrackerDetIdSelector_H
8 #include <boost/config/warning_disable.hpp>
9 #include <boost/spirit/include/qi.hpp>
10 #include <boost/spirit/include/qi_rule.hpp>
11 #include <boost/lambda/lambda.hpp>
12 #include <boost/spirit/include/phoenix.hpp>
13 #include <boost/phoenix/bind/bind_member_function.hpp>
14 #include <boost/spirit/include/qi_grammar.hpp>
20 #include <unordered_map>
27 typedef boost::variant<
Nil,
30 boost::recursive_wrapper<ExpressionAST>,
31 boost::recursive_wrapper<BinaryOP>,
32 boost::recursive_wrapper<UnaryOP> >
37 template <
typename Expr>
116 class Accessor :
public boost::static_visitor<int> {
126 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer/TrackerDetIdSelector",
127 "while evaluating a DetId selection a symbol was not set");
139 "error while parsing DetId selection: named identifier '" +
s +
"' not known. Possible values are: ";
141 msg += pair.first +
",";
143 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer/TrackerDetIdSelector",
msg);
169 boost::apply_visitor(*
this, ast.
expr);
175 boost::apply_visitor(*
this,
expr.left.expr);
202 boost::apply_visitor(*
this,
expr.right.expr);
212 boost::apply_visitor(*
this,
expr.subject.expr);
217 template <
typename ITERATOR>
220 boost::spirit::ascii::space_type,
221 boost::spirit::qi::locals<ExpressionAST> > {
227 rule<ITERATOR,
ExpressionAST(), boost::spirit::ascii::space_type, boost::spirit::qi::locals<ExpressionAST> >
231 namespace qi = boost::spirit::qi;
232 namespace ascii = boost::spirit::ascii;
233 namespace phoenix = boost::phoenix;
237 identifierRule = (qi::true_[qi::_val = 1] | qi::false_[qi::_val = 0]) | (qi::int_[qi::_val = qi::_1]) |
242 (qi::lit(
"||") >>
expressionRule[qi::_a = qi::_a || qi::_1])))[qi::_val = qi::_a];
262 bool success = boost::spirit::qi::phrase_parse(
begin,
end, grammar, boost::spirit::ascii::space, exprAST);
264 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer/TrackerDetIdSelector",
269 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer/TrackerDetIdSelector",
void operator()(std::string str) const
int operator()(const ExpressionAST &ast) const
ExpressionAST operator>(ExpressionAST const &lhs, ExpressionAST const &rhs)
int operator()(const BinaryOP &binaryOP) const
ExpressionAST operator<(ExpressionAST const &lhs, ExpressionAST const &rhs)
ExpressionAST(Expr const &expr)
ExpressionAST operator<=(ExpressionAST const &lhs, ExpressionAST const &rhs)
boost::variant< Nil, int, std::string, boost::recursive_wrapper< ExpressionAST >, boost::recursive_wrapper< BinaryOP >, boost::recursive_wrapper< UnaryOP > > Type
alpha
zGenParticlesMatch = cms.InputTag(""),
boost::spirit::qi::rule< ITERATOR, ExpressionAST(), boost::spirit::ascii::space_type > identifierRule
void operator()(ExpressionAST const &ast) const
TrackerDetIdSelector(const DetId &detId, const TrackerTopology &trackerTopology)
bool passSelection(std::string selectionStr) const
ExpressionAST operator!=(ExpressionAST const &lhs, ExpressionAST const &rhs)
int operator()(Nil i) const
TrackerDetIdSelectorGrammar()
int evaluate(const DetId &detId, const TrackerTopology &trackerTopology) const
int evaluate(const DetId &detId, const TrackerTopology &trackerTopology) const
ExpressionAST operator>=(ExpressionAST const &lhs, ExpressionAST const &rhs)
const TrackerTopology & _trackerTopology
UnaryOP(OP op, ExpressionAST const &subject)
int operator()(const std::string &s) const
boost::spirit::qi::rule< ITERATOR, std::string(), boost::spirit::ascii::space_type > identifierFctRule
int evaluate(const DetId &detId, const TrackerTopology &trackerTopology) const
ExpressionAST operator||(ExpressionAST const &lhs, ExpressionAST const &rhs)
int operator()(const UnaryOP &unaryOP) const
std::function< int(const TrackerTopology &trackerTopology, const DetId &)> DetIdFunction
boost::spirit::qi::rule< ITERATOR, ExpressionAST(), boost::spirit::ascii::space_type > expressionRule
int operator()(const int &i) const
ExpressionAST operator==(ExpressionAST const &lhs, ExpressionAST const &rhs)
ExpressionAST operator&&(ExpressionAST const &lhs, ExpressionAST const &rhs)
Container::value_type value_type
void operator()(BinaryOP const &expr) const
ExpressionAST & operator!()
void operator()(int n) const
BinaryOP(OP op, ExpressionAST const &left, ExpressionAST const &right)
const TrackerTopology & _trackerTopology
const static StringFunctionMap functionTable
void operator()(UnaryOP const &expr) const
boost::spirit::qi::rule< ITERATOR, ExpressionAST(), boost::spirit::ascii::space_type, boost::spirit::qi::locals< ExpressionAST > > comboRule
WalkAST(const DetId &detId, const TrackerTopology &trackerTopology)
std::unordered_map< std::string, DetIdFunction > StringFunctionMap
Accessor(const DetId &detId, const TrackerTopology &trackerTopology)