CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
edm::GroupSelector Class Reference

#include <GroupSelector.h>

Public Member Functions

 GroupSelector ()
 
void initialize (GroupSelectorRules const &rules, std::vector< BranchDescription const * > const &branchDescriptions)
 
bool initialized () const
 
void print (std::ostream &os) const
 
bool selected (BranchDescription const &desc) const
 

Private Attributes

std::vector< std::string > groupsToSelect_
 
bool initialized_
 

Detailed Description

Definition at line 21 of file GroupSelector.h.

Constructor & Destructor Documentation

edm::GroupSelector::GroupSelector ( )

Definition at line 18 of file GroupSelector.cc.

18 : groupsToSelect_(), initialized_(false) {}
std::vector< std::string > groupsToSelect_
Definition: GroupSelector.h:47

Member Function Documentation

void edm::GroupSelector::initialize ( GroupSelectorRules const &  rules,
std::vector< BranchDescription const * > const &  branchDescriptions 
)

Definition at line 21 of file GroupSelector.cc.

References edm::GroupSelectorRules::applyToAll(), end, groupsToSelect_, initialized_, and edm::sort_all().

Referenced by ShallowTree::beginJob(), edm::RootFile::dropOnInput(), and edm::OutputModule::selectProducts().

21  {
22  typedef GroupSelectorRules::BranchSelectState BranchSelectState;
23 
24  // Get a BranchSelectState for each branch, containing the branch
25  // name, with its 'select bit' set to false.
26  std::vector<BranchSelectState> branchstates;
27  {
28  branchstates.reserve(branchDescriptions.size());
29 
30  VCBDP::const_iterator it = branchDescriptions.begin();
31  VCBDP::const_iterator end = branchDescriptions.end();
32  for (; it != end; ++it) branchstates.push_back(BranchSelectState(*it));
33  }
34 
35  // Now apply the rules to the branchstates, in order. Each rule
36  // can override any previous rule, or all previous rules.
37  rules.applyToAll(branchstates);
38 
39  // For each of the BranchSelectStates that indicates the branch is
40  // to be selected, remember the branch name. The list of branch
41  // names must be sorted, for the implementation of 'selected' to
42  // work.
43  {
44  std::vector<BranchSelectState>::const_iterator it = branchstates.begin();
45  std::vector<BranchSelectState>::const_iterator end = branchstates.end();
46  for (; it != end; ++it) {
47  if (it->selectMe) groupsToSelect_.push_back(it->desc->branchName());
48  }
50  }
51  initialized_ = true;
52  }
#define end
Definition: vmac.h:38
std::vector< std::string > groupsToSelect_
Definition: GroupSelector.h:47
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:120
bool edm::GroupSelector::initialized ( ) const
inline

Definition at line 34 of file GroupSelector.h.

References initialized_.

Referenced by edm::OutputModule::selectProducts().

34 {return initialized_;}
void edm::GroupSelector::print ( std::ostream &  os) const

Definition at line 66 of file GroupSelector.cc.

References compareJSON::const, edm::copy_all(), and groupsToSelect_.

Referenced by edm::operator<<().

66  {
67  os << "GroupSelector at: "
68  << static_cast<void const*>(this)
69  << " has "
70  << groupsToSelect_.size()
71  << " groups to select:\n";
72  copy_all(groupsToSelect_, std::ostream_iterator<std::string>(os, "\n"));
73  }
std::vector< std::string > groupsToSelect_
Definition: GroupSelector.h:47
string const
Definition: compareJSON.py:14
Func copy_all(ForwardSequence &s, Func f)
wrappers for copy
Definition: Algorithms.h:24
bool edm::GroupSelector::selected ( BranchDescription const &  desc) const

Definition at line 54 of file GroupSelector.cc.

References edm::binary_search_all(), edm::BranchDescription::branchName(), edm::hlt::Exception, groupsToSelect_, initialized_, and edm::errors::LogicError.

Referenced by ShallowTree::beginJob(), edm::RootFile::dropOnInput(), and edm::OutputModule::selected().

54  {
55  if (!initialized_) {
57  << "GroupSelector::selected() called prematurely\n"
58  << "before the product registry has been frozen.\n";
59  }
60  // We are to select this 'branch' if its name is one of the ones we
61  // have been told to select.
62  return binary_search_all(groupsToSelect_, desc.branchName());
63  }
std::vector< std::string > groupsToSelect_
Definition: GroupSelector.h:47
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
Definition: Algorithms.h:76

Member Data Documentation

std::vector<std::string> edm::GroupSelector::groupsToSelect_
private

Definition at line 47 of file GroupSelector.h.

Referenced by initialize(), print(), and selected().

bool edm::GroupSelector::initialized_
private

Definition at line 48 of file GroupSelector.h.

Referenced by initialize(), initialized(), and selected().