CMS 3D CMS Logo

DDFilter.h
Go to the documentation of this file.
1 #ifndef DDCore_DDFilter_h
2 #define DDCore_DDFilter_h
3 
4 #include <iosfwd>
5 #include <vector>
6 
8 
9 class DDExpandedView;
10 
12 enum class DDCompOp { equals, not_equals};
13 
15 class DDFilter
16 {
17 public:
18  DDFilter();
19 
20  virtual ~DDFilter();
21 
23  virtual bool accept(const DDExpandedView &) const = 0;
24 };
25 
27 class DDPassAllFilter : public DDFilter
28 {
29 public:
30  bool accept(const DDExpandedView &) const final {
31  return true;
32  }
33 };
34 
37 {
38  friend std::ostream & operator<<(std::ostream & os, const DDSpecificsFilter & f);
39 
40 public:
42 
43  ~DDSpecificsFilter() override;
44 
45  bool accept(const DDExpandedView &) const final;
46 
47  void setCriteria(const DDValue & nameVal, // name & value of a variable
48  DDCompOp );
49 
51  SpecificCriterion(const DDValue & nameVal,
52  DDCompOp op)
53  : nameVal_(nameVal),
54  comp_(op)
55  { }
56 
59  };
60 
61 protected:
62 
63  bool accept_impl(const DDExpandedView &) const;
64 
65  std::vector<SpecificCriterion> criteria_;
66 };
67 
68 std::ostream & operator<<(std::ostream & os, const DDSpecificsFilter & f);
69 
71 public:
72  explicit DDSpecificsHasNamedValueFilter(const std::string& iAttribute):
73  attribute_(iAttribute,"",0 )
74  {}
75 
76  bool accept(const DDExpandedView &) const final;
77 
78 private:
80 
81 };
82 
84 public:
85  explicit DDSpecificsMatchesValueFilter(const DDValue& iValue):
86  value_(iValue)
87  {}
88 
89  bool accept(const DDExpandedView &) const final;
90 
91 private:
93 
94 };
95 
96 template<typename F1, typename F2>
97 class DDAndFilter : public DDFilter {
98 public:
99  DDAndFilter(F1 iF1, F2 iF2):
100  f1_(std::move(iF1)),
101  f2_(std::move(iF2)) {}
102 
103  bool accept(const DDExpandedView & node) const final {
104  return f1_.accept(node) && f2_.accept(node);
105  }
106 private:
107  F1 f1_;
108  F2 f2_;
109 };
110 
111 template<typename F1, typename F2>
113 {
114  return DDAndFilter<F1,F2>(std::move(f1), std::move(f2));
115 }
116 
117 #endif
118 
119 
DDSpecificsMatchesValueFilter(const DDValue &iValue)
Definition: DDFilter.h:85
DDSpecificsHasNamedValueFilter(const std::string &iAttribute)
Definition: DDFilter.h:72
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
std::vector< SpecificCriterion > criteria_
Definition: DDFilter.h:65
SpecificCriterion(const DDValue &nameVal, DDCompOp op)
Definition: DDFilter.h:51
bool accept(const DDExpandedView &node) const final
true, if the DDExpandedNode fulfills the filter criteria
Definition: DDFilter.h:103
double f[11][100]
A DDFilter that always returns true.
Definition: DDFilter.h:27
DDCompOp
comparison operators to be used with this filter
Definition: DDFilter.h:12
bool accept(const DDExpandedView &) const final
true, if the DDExpandedNode fulfills the filter criteria
Definition: DDFilter.h:30
A Filter accepts or rejects a DDExpandedNode based on a user-coded decision rule. ...
Definition: DDFilter.h:15
DDAndFilter< F1, F2 > make_and_ddfilter(F1 f1, F2 f2)
Definition: DDFilter.h:112
std::ostream & operator<<(std::ostream &os, const DDSpecificsFilter &f)
Provides an exploded view of the detector (tree-view)
def move(src, dest)
Definition: eostools.py:511
DDAndFilter(F1 iF1, F2 iF2)
Definition: DDFilter.h:99
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:36