FWCore
Modules
src
Prescaler.cc
Go to the documentation of this file.
1
2
#include <atomic>
3
#include "
FWCore/Framework/interface/global/EDFilter.h
"
4
#include "
FWCore/Framework/interface/MakerMacros.h
"
5
#include "
FWCore/ParameterSet/interface/ConfigurationDescriptions.h
"
6
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
7
#include "
FWCore/ParameterSet/interface/ParameterSetDescription.h
"
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
24
Prescaler::Prescaler
(
ParameterSet
const
& ps)
25
: count_(), n_(ps.getParameter<
int
>(
"prescaleFactor"
)), offset_(ps.getParameter<
int
>(
"prescaleOffset"
)) {}
26
27
Prescaler::~Prescaler
() {}
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
35
void
Prescaler::fillDescriptions
(
ConfigurationDescriptions
& descriptions) {
36
ParameterSetDescription
desc
;
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
;
47
DEFINE_FWK_MODULE
(
Prescaler
);
edm::Prescaler::Prescaler
Prescaler(ParameterSet const &)
Definition:
Prescaler.cc:24
edm::Prescaler::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition:
Prescaler.cc:35
edm::Prescaler::n_
int n_
Definition:
Prescaler.cc:20
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
edm::StreamID
Definition:
StreamID.h:30
MakerMacros.h
edm::Prescaler::count_
std::atomic< int > count_
Definition:
Prescaler.cc:19
MillePedeFileConverter_cfg.e
e
Definition:
MillePedeFileConverter_cfg.py:37
edm::ParameterSetDescription
Definition:
ParameterSetDescription.h:52
EDFilter.h
ParameterSet.h
funct::true
true
Definition:
Factorize.h:173
c
auto & c
Definition:
CAHitNtupletGeneratorKernelsImpl.h:56
edm::Prescaler
Definition:
Prescaler.cc:10
createfilelist.int
int
Definition:
createfilelist.py:10
ParameterSetDescription.h
submitPVResolutionJobs.desc
string desc
Definition:
submitPVResolutionJobs.py:251
edm::Prescaler::offset_
int offset_
Definition:
Prescaler.cc:21
edm::EventSetup
Definition:
EventSetup.h:59
edm::Prescaler::filter
bool filter(StreamID, Event &e, EventSetup const &c) const final
Definition:
Prescaler.cc:29
submitPVResolutionJobs.count
count
Definition:
submitPVResolutionJobs.py:352
edm::Prescaler::~Prescaler
~Prescaler() override
Definition:
Prescaler.cc:27
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition:
ConfigurationDescriptions.cc:57
edm::global::EDFilter
Definition:
EDFilter.h:32
edm
HLT enums.
Definition:
AlignableModifier.h:19
edm::ParameterSet
Definition:
ParameterSet.h:47
ConfigurationDescriptions.h
edm::Event
Definition:
Event.h:73
edm::ConfigurationDescriptions
Definition:
ConfigurationDescriptions.h:28
Generated for CMSSW Reference Manual by
1.8.14