CMS 3D CMS Logo

BunchCrossingFilter.cc
Go to the documentation of this file.
1 
8 
9 namespace {
10 
11  template <typename T>
12  std::vector<T> sorted(std::vector<T> v) {
13  std::sort(v.begin(), v.end());
14  return v;
15  }
16 
17 } // namespace
18 
19 namespace edm {
20 
22  public:
23  explicit BunchCrossingFilter(ParameterSet const& config);
24 
25  static void fillDescriptions(ConfigurationDescriptions& descriptions);
26  bool filter(StreamID, Event& event, EventSetup const&) const final;
27 
28  private:
29  const std::vector<unsigned int> bunches_;
30  };
31 
33  : bunches_(sorted(config.getParameter<std::vector<unsigned int>>("bunches"))) {}
34 
36  return std::binary_search(bunches_.begin(), bunches_.end(), event.bunchCrossing());
37  }
38 
41  desc.add<std::vector<unsigned int>>("bunches", {})
42  ->setComment("List of bunch crossings for which events should be accepted [1-3564].");
43  descriptions.add("bunchCrossingFilter", desc);
44  }
45 
46 } // namespace edm
47 
Definition: config.py:1
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
BunchCrossingFilter(ParameterSet const &config)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool filter(StreamID, Event &event, EventSetup const &) const final
HLT enums.
const std::vector< unsigned int > bunches_
Definition: event.py:1