CMS 3D CMS Logo

Prescaler.cc
Go to the documentation of this file.
1 
2 #include <atomic>
8 
9 namespace edm {
10  class Prescaler : public global::EDFilter<> {
11  public:
12  explicit Prescaler(ParameterSet const&);
13  ~Prescaler() override;
14 
15  static void fillDescriptions(ConfigurationDescriptions& descriptions);
16  bool filter(StreamID, Event& e, EventSetup const& c) const final;
17 
18  private:
19  mutable std::atomic<int> count_;
20  int n_; // accept one in n
21  int offset_; // with offset, ie. sequence of events does not have to start at first event
22  };
23 
25  : count_(), n_(ps.getParameter<int>("prescaleFactor")), offset_(ps.getParameter<int>("prescaleOffset")) {}
26 
28 
29  bool Prescaler::filter(StreamID, Event&, EventSetup const&) const {
30  //have to capture the value here since it could change by the time we do the comparision
31  int count = ++count_;
32  return count % n_ == offset_ ? true : false;
33  }
34 
37  desc.add<int>("prescaleFactor")->setComment("Accept one event every N events");
38  desc.add<int>("prescaleOffset")
39  ->setComment(
40  "The first event to accept should be the Mth one. Choose 'prescaleFactor'=1 to accept the first event from "
41  "the source.");
42  descriptions.add("preScaler", desc);
43  }
44 } // namespace edm
45 
46 using edm::Prescaler;
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
edm::Prescaler::count_
std::atomic< int > count_
Definition: Prescaler.cc:19
edm::Prescaler::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: Prescaler.cc:35
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::Prescaler::offset_
int offset_
Definition: Prescaler.cc:21
edm::Prescaler::filter
bool filter(StreamID, Event &e, EventSetup const &c) const final
Definition: Prescaler.cc:29
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::Prescaler
Definition: Prescaler.cc:10
funct::true
true
Definition: Factorize.h:173
edm::ParameterSet
Definition: ParameterSet.h:36
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
createfilelist.int
int
Definition: createfilelist.py:10
edm::EventSetup
Definition: EventSetup.h:57
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::Prescaler::n_
int n_
Definition: Prescaler.cc:20
edm::global::EDFilter
Definition: EDFilter.h:32
ParameterSet.h
edm::Event
Definition: Event.h:73
EDFilter.h
edm::Prescaler::Prescaler
Prescaler(ParameterSet const &)
Definition: Prescaler.cc:24
edm::Prescaler::~Prescaler
~Prescaler() override
Definition: Prescaler.cc:27
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37