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()(std::string str) const
bool passSelection(const std::string &selectionStr) const
friend ExpressionAST operator<=(ExpressionAST const &lhs, ExpressionAST const &rhs)
void operator()(UnaryOP const &expr) const
int operator()(const UnaryOP &unaryOP) const
ExpressionAST opLesserEq(ExpressionAST const &lhs, ExpressionAST const &rhs)
Accessor(const DetId &detId, const TrackerTopology &trackerTopology)
ExpressionAST & operator!()
friend ExpressionAST operator||(ExpressionAST const &lhs, ExpressionAST const &rhs)
int operator()(const BinaryOP &binaryOP) const
friend ExpressionAST operator>(ExpressionAST const &lhs, ExpressionAST const &rhs)
void operator()(int n) const
static const StringFunctionMap functionTable
int operator()(const int &i) const
const TrackerTopology & _trackerTopology
friend ExpressionAST operator<(ExpressionAST const &lhs, ExpressionAST const &rhs)
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
ExpressionAST opOr(ExpressionAST const &lhs, ExpressionAST const &rhs)
void operator()(ExpressionAST const &ast) const
void operator()(BinaryOP const &expr) const
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 evaluate(const DetId &detId, const TrackerTopology &trackerTopology) const
ExpressionAST opAnd(ExpressionAST const &lhs, ExpressionAST const &rhs)
ExpressionAST opLesser(ExpressionAST const &lhs, ExpressionAST const &rhs)
int operator()(Nil i) const
int evaluate(const DetId &detId, const TrackerTopology &trackerTopology) const
ExpressionAST(Expr const &expr)
friend ExpressionAST operator>=(ExpressionAST const &lhs, ExpressionAST const &rhs)
const TrackerTopology & _trackerTopology
TrackerDetIdSelector(const DetId &detId, const TrackerTopology &trackerTopology)
BinaryOP(OP op, ExpressionAST const &left, ExpressionAST const &right)
ExpressionAST opNotEq(ExpressionAST const &lhs, ExpressionAST const &rhs)
friend ExpressionAST operator &&(ExpressionAST const &lhs, ExpressionAST const &rhs)
int operator()(const std::string &s) const
int operator()(const ExpressionAST &ast) const
ExpressionAST opEq(ExpressionAST const &lhs, ExpressionAST const &rhs)
UnaryOP(OP op, ExpressionAST const &subject)
ExpressionAST opGreater(ExpressionAST const &lhs, ExpressionAST const &rhs)