7#include "Framework/RunHeader.h"
12 "RandomNumberSeedService";
14static const int SEED_EXTERNAL = 2;
15static const int SEED_RUN = 3;
16static const int SEED_TIME = 4;
19 s <<
"RandomNumberSeedService(";
20 if (
seed_mode_ == SEED_RUN) s <<
"Seed on RUN";
21 if (
seed_mode_ == SEED_TIME) s <<
"Seed on TIME";
22 if (
seed_mode_ == SEED_EXTERNAL) s <<
"Seeded EXTERNALLY";
25 s <<
" " << i.first <<
"=>" << i.second << std::endl;
30 const std::string& name,
const std::string& tagname,
35 auto seeding = parameters.
get<std::string>(
"seedMode",
"run");
36 if (!strcasecmp(seeding.c_str(),
"run")) {
37 seed_mode_ = SEED_RUN;
38 }
else if (!strcasecmp(seeding.c_str(),
"external")) {
39 seed_mode_ = SEED_EXTERNAL;
40 master_seed_ = parameters.get<int>(
"masterSeed");
42 }
else if (!strcasecmp(seeding.c_str(),
"time")) {
43 master_seed_ = time(0);
44 seed_mode_ = SEED_TIME;
60 std::map<std::string, uint64_t>::const_iterator i =
seeds_.find(name);
63 for (
size_t j = 0; j < name.size(); j++)
64 seed += (uint64_t(name[j]) << (j % 8));
74 std::vector<std::string> rv;
76 rv.push_back(i.first);
81std::pair<const ConditionsObject*, ConditionsIOV>
89 return std::pair<const ConditionsObject*, ConditionsIOV>(
#define DECLARE_CONDITIONS_PROVIDER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class which represents the process under execution.
Conditions object for random number seeds.
Class which defines the run/event/type range for which a given condition is valid,...
Base class for all providers of conditions objects.
const Process & process() const
Get the process handle.
Base class for all conditions objects, very simple.
Class which represents the process under execution.
const std::string & getPassName() const
Get the processing pass label.
System for consistent seeding of random number generators.
virtual std::pair< const ConditionsObject *, ConditionsIOV > getCondition(const ldmx::EventHeader &context)
Get the seed service as a conditions object.
bool initialized_
whether the master seed has been initialized
std::map< std::string, uint64_t > seeds_
cache of seeds by name
RandomNumberSeedService(const std::string &name, const std::string &tagname, const framework::config::Parameters ¶meters, Process &process)
Create the random number seed service conditions object.
int seed_mode_
what mode of master seed are we using
std::vector< std::string > getSeedNames() const
Get a list of all the known seeds.
static const std::string CONDITIONS_OBJECT_NAME
Conditions object name.
uint64_t getSeed(const std::string &name) const
Access a given seed by name.
uint64_t master_seed_
what the master seed actually is
virtual void onNewRun(ldmx::RunHeader &header)
Configure the seed service when a new run starts.
void stream(std::ostream &s) const
Stream the configuration of this object to the input ostream.
Class encapsulating parameters for configuring a processor.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
All classes in the ldmx-sw project use this namespace.