GroupSelectorRules.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_GroupSelectorRules_h
2 #define art_Framework_Core_GroupSelectorRules_h
3 
4 // ======================================================================
5 //
6 // GroupSelectorRules: rules to select specific groups in an event.
7 //
8 // ======================================================================
9 
12 
13 #include <string>
14 #include <vector>
15 
16 namespace art {
17  // defined below:
18  class GroupSelectorRules;
19 
20  // forward declarations:
21  class BranchDescription;
22  class GroupSelector;
23 } // namespace art
24 
25 // ----------------------------------------------------------------------
26 
28 public:
29  GroupSelectorRules(std::vector<std::string> const& commands,
30  std::string const& parameterName,
31  std::string const& parameterOwnerName);
32 
33  //--------------------------------------------------
34  // BranchSelectState associates a BranchDescription
35  // (*desc) with a bool indicating whether or not the branch with
36  // that name is to be selected. Note that parameter pd may not be null.
39  bool selectMe{false};
40 
41  // N.B.: We assume pd is not null.
42  explicit BranchSelectState(BranchDescription const* pd) : desc{pd} {}
43  }; // BranchSelectState
44 
45  void applyToAll(std::vector<BranchSelectState>& branchstates) const;
46 
47  bool
48  keepAll() const
49  {
50  return keepAll_;
51  }
52 
53 private:
54  class Rule {
55  public:
56  Rule(std::string const& s,
57  std::string const& parameterName,
58  std::string const& owner);
59 
60  // Apply the rule to all the given branch states. This may modify
61  // the given branch states.
62  void applyToAll(std::vector<BranchSelectState>& branchstates) const;
63 
64  // If this rule applies to the given BranchDescription, then
65  // modify 'result' to match the rule's select flag. If the rule does
66  // not apply, do not modify 'result'.
67  void applyToOne(BranchDescription const* branch, bool& result) const;
68 
69  // Return the answer to the question: "Does the rule apply to this
70  // BranchDescription?"
71  bool appliesTo(BranchDescription const* branch) const;
72 
73  private:
74  // selectflag_ carries the value to which we should set the 'select
75  // bit' if this rule matches.
76  bool selectflag_{false};
78  }; // Rule
79 
80 private:
81  std::vector<Rule> rules_{};
82  bool keepAll_;
83 }; // GroupSelectorRules
84 
85 // ======================================================================
86 
87 #endif /* art_Framework_Core_GroupSelectorRules_h */
88 
89 // Local Variables:
90 // mode: c++
91 // End:
GroupSelectorRules(std::vector< std::string > const &commands, std::string const &parameterName, std::string const &parameterOwnerName)
const XML_Char * s
Definition: expat.h:262
void applyToAll(std::vector< BranchSelectState > &branchstates) const
std::vector< Rule > rules_
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
BranchSelectState(BranchDescription const *pd)
enum BeamMode string