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",
281 return boost::apply_visitor(
Accessor(detId, trackerTopology), this->
expr);