File indexing completed on 2024-04-06 12:18:40
0001 #include "FWCore/Framework/interface/Frameworkfwd.h"
0002 #include "FWCore/Framework/interface/global/EDFilter.h"
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0007
0008 class HLTDynamicPrescaler : public edm::global::EDFilter<> {
0009 public:
0010 explicit HLTDynamicPrescaler(edm::ParameterSet const& configuration);
0011 ~HLTDynamicPrescaler() override;
0012 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0013 bool filter(edm::StreamID, edm::Event& event, edm::EventSetup const& setup) const override;
0014
0015 private:
0016 mutable std::atomic<unsigned int> m_count;
0017 };
0018
0019 HLTDynamicPrescaler::HLTDynamicPrescaler(edm::ParameterSet const& configuration) : m_count(0) {}
0020
0021 HLTDynamicPrescaler::~HLTDynamicPrescaler() = default;
0022
0023 void HLTDynamicPrescaler::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0024 edm::ParameterSetDescription desc;
0025 desc.add<bool>("saveTags", false);
0026 descriptions.add("hltDynamicPrescaler", desc);
0027 }
0028
0029 bool HLTDynamicPrescaler::filter(edm::StreamID, edm::Event& event, edm::EventSetup const& setup) const {
0030 auto count = ++m_count;
0031
0032 unsigned int dynamicScale = 1;
0033 while (count > dynamicScale * 10) {
0034 dynamicScale *= 10;
0035 }
0036
0037 return (0 == count % dynamicScale);
0038 }
0039
0040 #include "FWCore/Framework/interface/MakerMacros.h"
0041 DEFINE_FWK_MODULE(HLTDynamicPrescaler);