LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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  class GroupSelectorRules;
18 }
19 
20 // ----------------------------------------------------------------------
21 
23 public:
24  GroupSelectorRules(std::vector<std::string> const& commands,
25  std::string const& parameterName,
26  std::string const& parameterOwnerName);
27 
28  //--------------------------------------------------
29  // BranchSelectState associates a BranchDescription
30  // (*desc) with a bool indicating whether or not the branch with
31  // that name is to be selected. Note that parameter pd may not be null.
34  bool selectMe{false};
35 
36  // N.B.: We assume pd is not null.
37  explicit BranchSelectState(BranchDescription const* pd) : desc{pd} {}
38  }; // BranchSelectState
39 
40  void applyToAll(std::vector<BranchSelectState>& branchstates) const;
41 
42  bool
43  keepAll() const
44  {
45  return keepAll_;
46  }
47 
48 private:
49  class Rule {
50  public:
51  Rule(std::string const& s,
52  std::string const& parameterName,
53  std::string const& owner);
54 
55  // Apply the rule to all the given branch states. This may modify
56  // the given branch states.
57  void applyToAll(std::vector<BranchSelectState>& branchstates) const;
58 
59  // If this rule applies to the given BranchDescription, then
60  // modify 'result' to match the rule's select flag. If the rule does
61  // not apply, do not modify 'result'.
62  void applyToOne(BranchDescription const* branch, bool& result) const;
63 
64  // Return the answer to the question: "Does the rule apply to this
65  // BranchDescription?"
66  bool appliesTo(BranchDescription const* branch) const;
67 
68  private:
69  // selectflag_ carries the value to which we should set the 'select
70  // bit' if this rule matches.
71  bool selectflag_{false};
73  }; // Rule
74 
75 private:
76  std::vector<Rule> rules_{};
77  bool keepAll_;
78 }; // GroupSelectorRules
79 
80 // ======================================================================
81 
82 #endif /* art_Framework_Core_GroupSelectorRules_h */
83 
84 // Local Variables:
85 // mode: c++
86 // End:
GroupSelectorRules(std::vector< std::string > const &commands, std::string const &parameterName, std::string const &parameterOwnerName)
void applyToAll(std::vector< BranchSelectState > &branchstates) const
std::vector< Rule > rules_
Definition: MVAAlg.h:12
BranchSelectState(BranchDescription const *pd)