1 #ifndef FastSimulation_TrackingRecHitProducer_TrackerDetIdSelector_H
2 #define FastSimulation_TrackingRecHitProducer_TrackerDetIdSelector_H
8 #include <boost/variant/recursive_variant.hpp>
14 #include <unordered_map>
33 typedef boost::variant<
Nil,
36 boost::recursive_wrapper<ExpressionAST>,
37 boost::recursive_wrapper<BinaryOP>,
38 boost::recursive_wrapper<UnaryOP> >
43 template <
typename Expr>
124 typedef std::function<int(const TrackerTopology& trackerTopology, const DetId&)>
DetIdFunction;
134 class Accessor :
public boost::static_visitor<int> {
144 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer/TrackerDetIdSelector",
145 "while evaluating a DetId selection a symbol was not set");
157 "error while parsing DetId selection: named identifier '" + s +
"' not known. Possible values are: ";
159 msg += pair.first +
",";
161 throw cms::Exception(
"FastSimulation/TrackingRecHitProducer/TrackerDetIdSelector", msg);
187 boost::apply_visitor(*
this, ast.
expr);
193 boost::apply_visitor(*
this, expr.
left.
expr);
220 boost::apply_visitor(*
this, expr.
right.
expr);
236 return boost::apply_visitor(
Accessor(detId, trackerTopology), this->
expr);
ExpressionAST opGreaterEq(ExpressionAST const &lhs, ExpressionAST const &rhs)
friend ExpressionAST operator!=(ExpressionAST const &lhs, ExpressionAST const &rhs)
WalkAST(const DetId &detId, const TrackerTopology &trackerTopology)
void operator()(UnaryOP const &expr) const
int operator()(const UnaryOP &unaryOP) const
friend ExpressionAST operator<=(ExpressionAST const &lhs, ExpressionAST const &rhs)
void operator()(std::string str) const
ExpressionAST opLesserEq(ExpressionAST const &lhs, ExpressionAST const &rhs)
void operator()(BinaryOP const &expr) const
Accessor(const DetId &detId, const TrackerTopology &trackerTopology)
ExpressionAST & operator!()
friend ExpressionAST operator||(ExpressionAST const &lhs, ExpressionAST const &rhs)
friend ExpressionAST operator>(ExpressionAST const &lhs, ExpressionAST const &rhs)
int operator()(const int &i) const
static const StringFunctionMap functionTable
void operator()(ExpressionAST const &ast) const
friend ExpressionAST operator&&(ExpressionAST const &lhs, ExpressionAST const &rhs)
int operator()(const BinaryOP &binaryOP) const
const TrackerTopology & _trackerTopology
friend ExpressionAST operator<(ExpressionAST const &lhs, ExpressionAST const &rhs)
int operator()(const ExpressionAST &ast) const
Container::value_type value_type
std::unordered_map< std::string, DetIdFunction > StringFunctionMap
boost::variant< Nil, int, std::string, boost::recursive_wrapper< ExpressionAST >, boost::recursive_wrapper< BinaryOP >, boost::recursive_wrapper< UnaryOP > > Type
int evaluate(const DetId &detId, const TrackerTopology &trackerTopology) const
ExpressionAST opOr(ExpressionAST const &lhs, ExpressionAST const &rhs)
int evaluate(const DetId &detId, const TrackerTopology &trackerTopology) const
std::function< int(const TrackerTopology &trackerTopology, const DetId &)> DetIdFunction
friend ExpressionAST operator==(ExpressionAST const &lhs, ExpressionAST const &rhs)
int operator()(Nil i) const
ExpressionAST opAnd(ExpressionAST const &lhs, ExpressionAST const &rhs)
ExpressionAST opLesser(ExpressionAST const &lhs, ExpressionAST const &rhs)
bool passSelection(const std::string &selectionStr) const
ExpressionAST(Expr const &expr)
friend ExpressionAST operator>=(ExpressionAST const &lhs, ExpressionAST const &rhs)
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
ExpressionAST opNotEq(ExpressionAST const &lhs, ExpressionAST const &rhs)
ExpressionAST opEq(ExpressionAST const &lhs, ExpressionAST const &rhs)
int operator()(const std::string &s) const
UnaryOP(OP op, ExpressionAST const &subject)
ExpressionAST opGreater(ExpressionAST const &lhs, ExpressionAST const &rhs)