File indexing completed on 2024-06-07 02:29:36
0001 #include "FWCore/Framework/interface/global/EDFilter.h"
0002 #include "FWCore/Framework/interface/MakerMacros.h"
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0007
0008 namespace edmtest {
0009 class StreamIDFilter : public edm::global::EDFilter<> {
0010 public:
0011 explicit StreamIDFilter(edm::ParameterSet const&);
0012
0013 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0014 bool filter(edm::StreamID, edm::Event& e, edm::EventSetup const& c) const final;
0015
0016 private:
0017 std::vector<unsigned int> rejectStreams_;
0018 };
0019
0020 StreamIDFilter::StreamIDFilter(edm::ParameterSet const& ps)
0021 : rejectStreams_(ps.getParameter<std::vector<unsigned int>>("rejectStreams")) {}
0022
0023 bool StreamIDFilter::filter(edm::StreamID id, edm::Event&, edm::EventSetup const&) const {
0024 return std::find(rejectStreams_.begin(), rejectStreams_.end(), id) == rejectStreams_.end();
0025 }
0026
0027 void StreamIDFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0028 edm::ParameterSetDescription desc;
0029 desc.add<std::vector<unsigned int>>("rejectStreams")
0030 ->setComment("Stream IDs for which to reject events. If empty, all events are accepted.");
0031 descriptions.addDefault(desc);
0032 }
0033 }
0034
0035 DEFINE_FWK_MODULE(edmtest::StreamIDFilter);