5 #include <boost/config/warning_disable.hpp> 6 #include <boost/spirit/include/qi.hpp> 7 #include <boost/spirit/include/qi_rule.hpp> 8 #include <boost/spirit/include/qi_grammar.hpp> 9 #include <boost/spirit/include/phoenix.hpp> 11 #define DETIDFCT(NAME) NAME, [](const TrackerTopology& trackerTopology, const DetId& detId) -> int 13 #define TOPOFCT(NAME) \ 14 #NAME, [](const TrackerTopology& trackerTopology, const DetId& detId) -> int { return trackerTopology.NAME(detId); } 18 {
DETIDFCT(
"subdetId"){
return (uint32_t)detId.subdetId();
122 template <
typename ITERATOR>
125 boost::spirit::ascii::space_type,
126 boost::spirit::qi::locals<ExpressionAST> > {
127 boost::spirit::qi::rule<ITERATOR, std::string(), boost::spirit::ascii::space_type>
identifierFctRule;
132 rule<ITERATOR, ExpressionAST(), boost::spirit::ascii::space_type, boost::spirit::qi::locals<ExpressionAST> >
136 namespace qi = boost::spirit::qi;
137 namespace ascii = boost::spirit::ascii;
138 namespace phoenix = boost::phoenix;
142 identifierRule = (qi::true_[qi::_val = 1] | qi::false_[qi::_val = 0]) | (qi::int_[qi::_val = qi::_1]) |
147 (qi::lit(
"||") >>
expressionRule[qi::_a = qi::_a || qi::_1])))[qi::_val = qi::_a];
161 std::string::const_iterator begin =
selectionStr.cbegin();
167 bool success = boost::spirit::qi::phrase_parse(begin,
end, grammar, boost::spirit::ascii::space, exprAST);
169 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer/TrackerDetIdSelector",
174 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer/TrackerDetIdSelector",
ExpressionAST opGreaterEq(ExpressionAST const &lhs, ExpressionAST const &rhs)
static constexpr auto TEC
bool passSelection(const std::string &selectionStr) const
ExpressionAST opLesserEq(ExpressionAST const &lhs, ExpressionAST const &rhs)
boost::spirit::qi::rule< ITERATOR, ExpressionAST(), boost::spirit::ascii::space_type > expressionRule
ExpressionAST & operator!()
static const StringFunctionMap functionTable
constexpr std::array< uint8_t, layerIndexSize > layer
boost::spirit::qi::rule< ITERATOR, ExpressionAST(), boost::spirit::ascii::space_type, boost::spirit::qi::locals< ExpressionAST > > comboRule
const TrackerTopology & _trackerTopology
std::unordered_map< std::string, DetIdFunction > StringFunctionMap
ExpressionAST opOr(ExpressionAST const &lhs, ExpressionAST const &rhs)
static constexpr auto TOB
ExpressionAST opAnd(ExpressionAST const &lhs, ExpressionAST const &rhs)
ExpressionAST opLesser(ExpressionAST const &lhs, ExpressionAST const &rhs)
boost::spirit::qi::rule< ITERATOR, ExpressionAST(), boost::spirit::ascii::space_type > identifierRule
static constexpr auto TIB
TrackerDetIdSelectorGrammar()
int evaluate(const DetId &detId, const TrackerTopology &trackerTopology) const
boost::spirit::qi::rule< ITERATOR, std::string(), boost::spirit::ascii::space_type > identifierFctRule
ExpressionAST opNotEq(ExpressionAST const &lhs, ExpressionAST const &rhs)
static constexpr auto TID
ExpressionAST opEq(ExpressionAST const &lhs, ExpressionAST const &rhs)
ExpressionAST opGreater(ExpressionAST const &lhs, ExpressionAST const &rhs)