Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
art
art
Framework
Modules
RandomNumberSaver_module.cc
Go to the documentation of this file.
1
// vim: set sw=2 expandtab :
2
//
3
// Store state of the RandomNumberGenerator service into the event.
4
//
5
6
#include "
art/Framework/Core/ModuleMacros.h
"
7
#include "
art/Framework/Core/ProcessingFrame.h
"
8
#include "
art/Framework/Core/SharedProducer.h
"
9
#include "
art/Framework/Principal/Event.h
"
10
#include "
art/Framework/Services/Optional/RandomNumberGenerator.h
"
11
#include "
fhiclcpp/types/Atom.h
"
12
13
#include <memory>
14
#include <vector>
15
16
using namespace
std
;
17
using namespace
fhicl
;
18
19
namespace
art
{
20
21
class
RandomNumberSaver
:
public
SharedProducer
{
22
public
:
23
struct
Config
{
24
Atom<bool>
debug
{
Name
{
"debug"
},
false
};
25
};
26
using
Parameters
=
Table<Config>
;
27
explicit
RandomNumberSaver
(
Parameters
const
&,
ProcessingFrame
const
&);
28
29
private
:
30
void
produce(
Event
&,
ProcessingFrame
const
&)
override
;
31
// When true makes produce call rng->print_().
32
bool
const
debug_
;
33
};
34
35
RandomNumberSaver::RandomNumberSaver(
Parameters
const
&
config
,
36
ProcessingFrame
const
&)
37
:
SharedProducer
{config},
debug_
{
config
().
debug
()}
38
{
39
produces<vector<RNGsnapshot>>();
40
if
(
debug_
) {
41
// If debugging information is desired, serialize so that the
42
// printing is not garbled.
43
serialize<InEvent>();
44
}
else
{
45
async<InEvent>();
46
}
47
}
48
49
void
50
RandomNumberSaver::produce
(
Event
&
e
,
ProcessingFrame
const
& frame)
51
{
52
auto
const
sid = frame.
scheduleID
();
53
auto
rng
= frame.
serviceHandle
<
RandomNumberGenerator
const
>();
54
e.
put
(make_unique<vector<RNGsnapshot>>(
rng
->accessSnapshot_(sid)));
55
if
(
debug_
) {
56
rng
->print_();
57
}
58
}
59
60
}
// namespace art
61
62
DEFINE_ART_MODULE
(
art::RandomNumberSaver
)
fhicl::Table< Config >
RandomNumberGenerator.h
test_gpu_visible.rng
rng
Definition:
test_gpu_visible.py:9
art::RandomNumberSaver::Config::debug
Atom< bool > debug
Definition:
RandomNumberSaver_module.cc:24
std
STL namespace.
art::SharedProducer
Definition:
SharedProducer.h:18
art::ProcessingFrame::scheduleID
auto scheduleID() const
Definition:
ProcessingFrame.h:20
e
const double e
Definition:
gUpMuFluxGen.cxx:165
art::RandomNumberSaver
Definition:
RandomNumberSaver_module.cc:21
DEFINE_ART_MODULE
#define DEFINE_ART_MODULE(klass)
Definition:
ModuleMacros.h:67
config
static Config * config
Definition:
config.cpp:1054
art::ProcessingFrame::serviceHandle
ServiceHandle< T > serviceHandle() const
Definition:
ProcessingFrame.h:14
fhicl
Definition:
InputSourceFactory.h:7
art::ProcessingFrame
Definition:
ProcessingFrame.h:8
fhicl::Atom< bool >
art::DataViewImpl::put
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition:
DataViewImpl.h:686
python.larbatch_posix.debug
string debug
Definition:
larbatch_posix.py:142
ModuleMacros.h
art::RandomNumberSaver::produce
void produce(Event &, ProcessingFrame const &) override
Definition:
RandomNumberSaver_module.cc:50
art::Event
Definition:
Event.h:22
SharedProducer.h
ProcessingFrame.h
Atom.h
art
Definition:
BasicOptionsHandler.h:9
art::RandomNumberGenerator
Definition:
RandomNumberGenerator.h:158
Event.h
art::RandomNumberSaver::debug_
bool const debug_
Definition:
RandomNumberSaver_module.cc:32
art::RandomNumberSaver::Config
Definition:
RandomNumberSaver_module.cc:23
fhicl::Name
Definition:
Name.h:10
Generated by
1.8.11