LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
EngineCreator.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // EngineCreator - enable a derived class to access the
4 // RandomNumberGenerator::createEngine()
5 //
6 // ======================================================================
7 
10 #include <vector>
11 
12 namespace {
13  // MT-TODO: Placeholder until we're multi-threaded.
14  auto
15  placeholder_schedule_id()
16  {
17  return art::ScheduleID::first();
18  }
19 }
20 
21 using art::EngineCreator;
22 
23 // ======================================================================
24 
25 EngineCreator::base_engine_t&
26 EngineCreator::createEngine(seed_t const seed)
27 {
28  return rng()->createEngine(placeholder_schedule_id(), seed);
29 }
30 
33  std::string const& kind_of_engine_to_make)
34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
38 
41  std::string const& kind_of_engine_to_make,
42  label_t const& engine_label)
43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
47 
50  char const key[],
51  seed_t const implicit_seed)
52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
56 
59 {
61  return rng;
62 }
63 
64 // ======================================================================
seed_t get_seed_value(fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
RNGservice::label_t label_t
Definition: EngineCreator.h:37
static ScheduleID first()
Definition: ScheduleID.h:82
RNGservice::seed_t seed_t
Definition: EngineCreator.h:38
base_engine_t & createEngine(seed_t seed)
long seed
Definition: chem4.cc:68
T get(std::string const &key) const
Definition: ParameterSet.h:231
RNGservice::base_engine_t base_engine_t
Definition: EngineCreator.h:39
static art::ServiceHandle< art::RandomNumberGenerator > & rng()