1 #ifndef FastSimulation_TrackingRecHitProducer_TrackerDetIdSelector_H
2 #define FastSimulation_TrackingRecHitProducer_TrackerDetIdSelector_H
9 #include <boost/config/warning_disable.hpp>
10 #include <boost/spirit/include/qi.hpp>
11 #include <boost/spirit/include/qi_rule.hpp>
12 #include <boost/lambda/lambda.hpp>
13 #include <boost/spirit/include/phoenix.hpp>
14 #include <boost/phoenix/bind/bind_member_function.hpp>
15 #include <boost/spirit/include/qi_grammar.hpp>
21 #include <unordered_map>
35 boost::recursive_wrapper<ExpressionAST>,
36 boost::recursive_wrapper<BinaryOP>,
37 boost::recursive_wrapper<UnaryOP>
46 template <
typename Expr>
141 typedef std::function<int(const TrackerTopology& trackerTopology, const DetId&)>
DetIdFunction;
155 public boost::static_visitor<int>
169 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer/TrackerDetIdSelector",
"while evaluating a DetId selection a symbol was not set");
187 std::string msg =
"error while parsing DetId selection: named identifier '"+s+
"' not known. Possible values are: ";
192 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer/TrackerDetIdSelector",msg);
219 _acc(detId,trackerTopology)
230 boost::apply_visitor(*
this, ast.
expr);
237 boost::apply_visitor(*
this, expr.
left.
expr);
265 boost::apply_visitor(*
this, expr.
right.
expr);
282 template <
typename ITERATOR>
284 boost::spirit::qi::grammar<
287 boost::spirit::ascii::space_type,
288 boost::spirit::qi::locals<ExpressionAST>
291 boost::spirit::qi::rule<
294 boost::spirit::ascii::space_type
297 boost::spirit::qi::rule<
300 boost::spirit::ascii::space_type
303 boost::spirit::qi::rule<
306 boost::spirit::ascii::space_type,
307 boost::spirit::qi::locals<ExpressionAST>
314 namespace qi = boost::spirit::qi;
315 namespace ascii = boost::spirit::ascii;
316 namespace phoenix = boost::phoenix;
319 qi::lexeme[+
qi::alpha[qi::_val+=qi::_1]];
322 (qi::true_[qi::_val=1] | qi::false_[qi::_val=0]) |
323 (qi::int_[qi::_val=qi::_1]) |
334 qi::lit(
"(") >>
comboRule[qi::_val=qi::_1] >> qi::lit(
")") |
349 std::string::const_iterator
begin = selectionStr.cbegin();
350 std::string::const_iterator
end = selectionStr.cend();
356 bool success = boost::spirit::qi::phrase_parse(begin,end, grammar, boost::spirit::ascii::space, exprAST);
359 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer/TrackerDetIdSelector",
364 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer/TrackerDetIdSelector",
"parsing selection '"+selectionStr+
"' failed.");
379 return boost::apply_visitor(
Accessor(detId,trackerTopology),this->
expr);
WalkAST(const DetId &detId, const TrackerTopology &trackerTopology)
void operator()(UnaryOP const &expr) const
int operator()(const UnaryOP &unaryOP) const
void operator()(std::string str) const
void operator()(BinaryOP const &expr) const
Accessor(const DetId &detId, const TrackerTopology &trackerTopology)
ExpressionAST & operator!()
int operator()(const int &i) const
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
static const StringFunctionMap functionTable
void operator()(ExpressionAST const &ast) const
ExpressionAST operator||(ExpressionAST const &lhs, ExpressionAST const &rhs)
boost::spirit::qi::rule< ITERATOR, ExpressionAST(), boost::spirit::ascii::space_type, boost::spirit::qi::locals< ExpressionAST > > comboRule
bool operator<=(View< T > const &, View< T > const &)
int operator()(const BinaryOP &binaryOP) const
const TrackerTopology & _trackerTopology
bool operator>=(View< T > const &, View< T > const &)
bool passSelection(std::string selectionStr) const
boost::spirit::qi::rule< ITERATOR, ExpressionAST(), boost::spirit::ascii::space_type > identifierRule
bool operator<(const FedChannelConnection &, const FedChannelConnection &)
int operator()(const ExpressionAST &ast) const
Container::value_type value_type
std::unordered_map< std::string, DetIdFunction > StringFunctionMap
int evaluate(const DetId &detId, const TrackerTopology &trackerTopology) const
ExpressionAST operator&&(ExpressionAST const &lhs, ExpressionAST const &rhs)
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
int evaluate(const DetId &detId, const TrackerTopology &trackerTopology) const
bool operator>(View< T > const &, View< T > const &)
std::function< int(const TrackerTopology &trackerTopology, const DetId &)> DetIdFunction
int operator()(Nil i) const
boost::spirit::qi::rule< ITERATOR, std::string(), boost::spirit::ascii::space_type > identifierFctRule
TrackerDetIdSelectorGrammar()
ExpressionAST(Expr const &expr)
boost::spirit::qi::rule< ITERATOR, ExpressionAST(), boost::spirit::ascii::space_type > expressionRule
boost::variant< Nil, int, std::string, boost::recursive_wrapper< ExpressionAST >, boost::recursive_wrapper< BinaryOP >, boost::recursive_wrapper< UnaryOP > > Type
void operator()(int n) const
const TrackerTopology & _trackerTopology
TrackerDetIdSelector(const DetId &detId, const TrackerTopology &trackerTopology)
BinaryOP(OP op, ExpressionAST const &left, ExpressionAST const &right)
int evaluate(const DetId &detId, const TrackerTopology &trackerTopology) const
int operator()(const std::string &s) const
UnaryOP(OP op, ExpressionAST const &subject)