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 (
seedMode_ == SEED_RUN) s <<
"Seed on RUN";
21 if (
seedMode_ == SEED_TIME) s <<
"Seed on TIME";
22 if (
seedMode_ == SEED_EXTERNAL) s <<
"Seeded EXTERNALLY";
23 s <<
") Master seed = " <<
masterSeed_ << std::endl;
25 s <<
" " << i.first <<
"=>" << i.second << std::endl;
30 const std::string& name,
const std::string& tagname,
35 auto seeding = parameters.
getParameter<std::string>(
"seedMode",
"run");
36 if (!strcasecmp(seeding.c_str(),
"run")) {
38 }
else if (!strcasecmp(seeding.c_str(),
"external")) {
42 }
else if (!strcasecmp(seeding.c_str(),
"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_NS(NS, 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.
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.
std::vector< std::string > getSeedNames() const
Get a list of all the known seeds.
static const std::string CONDITIONS_OBJECT_NAME
Conditions object name.
int seedMode_
what mode of master seed are we using
uint64_t masterSeed_
what the master seed actually is
uint64_t getSeed(const std::string &name) const
Access a given seed by name.
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.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
All classes in the ldmx-sw project use this namespace.