Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
art
art
Framework
Modules
BlockingPrescaler_module.cc
Go to the documentation of this file.
1
////////////////////////////////////////////////////////////////////////
2
// BlockingPrescaler.
3
//
4
// Accept m in n events with offset. So, for blockSize (m) = 5,
5
// stepSize (n) = 7 and offset = 4, the filter will accept events 5-9
6
// inclusive, 12-16 inclusive, 19-23 inclusive, etc.
7
//
8
// Note that BlockingPrescaler prescales based on the number of events
9
// seen by this module, *not* the event number as recorded by EventID.
10
////////////////////////////////////////////////////////////////////////
11
12
#include "
art/Framework/Core/Frameworkfwd.h
"
13
#include "
art/Framework/Core/ModuleMacros.h
"
14
#include "
art/Framework/Core/SharedFilter.h
"
15
#include "
fhiclcpp/types/Atom.h
"
16
17
#include <mutex>
18
19
using namespace
fhicl
;
20
21
namespace
art
{
22
class
BlockingPrescaler;
23
}
24
25
// ======================================================================
26
27
class
art::BlockingPrescaler
:
public
SharedFilter
{
28
public
:
29
struct
Config
{
30
Atom<size_t>
blockSize{
Name
(
"blockSize"
), 1};
31
Atom<size_t>
stepSize{
32
Name
(
"stepSize"
),
33
Comment
(
34
"The value of 'stepSize' cannot be less than that of 'blockSize'."
)};
35
Atom<size_t>
offset{
Name
(
"offset"
), 0};
36
};
37
38
using
Parameters
=
Table<Config>
;
39
explicit
BlockingPrescaler
(
Parameters
const
&,
ProcessingFrame
const
&);
40
41
private
:
42
bool
filter
(
Event
&,
ProcessingFrame
const
&)
override
;
43
44
size_t
count_{};
45
size_t
const
m_
;
// accept m in n (sequentially).
46
size_t
const
n_
;
47
size_t
const
offset_
;
// First accepted event is 1 + offset.
48
std::mutex
mutex_{};
49
};
// BlockingPrescaler
50
51
// ======================================================================
52
53
art::BlockingPrescaler::BlockingPrescaler
(
Parameters
const
&
config
,
54
ProcessingFrame
const
&)
55
:
SharedFilter
{config}
56
,
m_
{
config
().
blockSize
()}
57
,
n_
{
config
().
stepSize
()}
58
,
offset_
{
config
().
offset
()}
59
{
60
if
(
n_
<
m_
) {
61
throw
art::Exception
{
art::errors::Configuration
,
62
"There was an error configuring Blocking Prescaler.\n"
}
63
<<
"The specified step size ("
<<
n_
<<
") is less than the block size ("
64
<<
m_
<<
")\n"
;
65
}
66
async<InEvent>();
67
}
68
69
bool
70
art::BlockingPrescaler::filter
(
Event
&,
ProcessingFrame
const
&)
71
{
72
// This sequence of operations/comparisons must be serialized.
73
// Changing 'count_' to be of type std::atomic<size_t> will not
74
// help. Using a mutex here is cheaper than calling serialize(),
75
// since that will also serialize any of the module-level service
76
// callbacks invoked before and after this function is called.
77
std::lock_guard lock{
mutex_
};
78
bool
const
result
{(
count_
>=
offset_
) && ((
count_
-
offset_
) %
n_
) <
m_
};
79
++
count_
;
80
return
result
;
81
}
82
83
DEFINE_ART_MODULE
(
art::BlockingPrescaler
)
fhicl::Table< Config >
art::BlockingPrescaler::Config::offset
Atom< size_t > offset
Definition:
BlockingPrescaler_module.cc:35
result
static QCString result
Definition:
fortranscanner.cpp:56614
art::BlockingPrescaler::mutex_
std::mutex mutex_
Definition:
BlockingPrescaler_module.cc:48
art::BlockingPrescaler::BlockingPrescaler
BlockingPrescaler(Parameters const &, ProcessingFrame const &)
Definition:
BlockingPrescaler_module.cc:53
art::BlockingPrescaler
Definition:
BlockingPrescaler_module.cc:27
Name
ChannelGroupService::Name Name
Definition:
FixedChannelGroupService_service.cc:19
art::SharedFilter
Definition:
SharedFilter.h:17
SharedFilter.h
Frameworkfwd.h
filter
Framework.
Definition:
ProtoDUNEUnstableHVFilter_module.cc:44
art::errors::Configuration
Definition:
Exception.h:32
art::BlockingPrescaler::Config
Definition:
BlockingPrescaler_module.cc:29
DEFINE_ART_MODULE
#define DEFINE_ART_MODULE(klass)
Definition:
ModuleMacros.h:67
generate_CCQE_events.mutex
mutex
Definition:
generate_CCQE_events.py:53
config
static Config * config
Definition:
config.cpp:1054
fhicl
Definition:
InputSourceFactory.h:7
art::ProcessingFrame
Definition:
ProcessingFrame.h:8
fhicl::Atom< size_t >
ModuleMacros.h
art::Exception
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition:
Exception.h:66
art::BlockingPrescaler::offset_
size_t const offset_
Definition:
BlockingPrescaler_module.cc:47
art::Event
Definition:
Event.h:22
art::BlockingPrescaler::Config::blockSize
Atom< size_t > blockSize
Definition:
BlockingPrescaler_module.cc:30
Comment
#define Comment
Definition:
commentscan.cpp:4062
Atom.h
art
Definition:
BasicOptionsHandler.h:9
art::BlockingPrescaler::filter
bool filter(Event &, ProcessingFrame const &) override
Definition:
BlockingPrescaler_module.cc:70
art::BlockingPrescaler::Config::stepSize
Atom< size_t > stepSize
Definition:
BlockingPrescaler_module.cc:31
art::BlockingPrescaler::n_
size_t const n_
Definition:
BlockingPrescaler_module.cc:46
art::BlockingPrescaler::count_
size_t count_
Definition:
BlockingPrescaler_module.cc:44
art::BlockingPrescaler::m_
size_t const m_
Definition:
BlockingPrescaler_module.cc:45
Generated by
1.8.11