12 #ifndef NUTOOLS_RANDOMUTILS_PROVIDERS_PEREVENTPOLICY_H 13 #define NUTOOLS_RANDOMUTILS_PROVIDERS_PEREVENTPOLICY_H 1 19 #include <type_traits> 44 template <
typename SEED>
88 virtual void print(std::ostream& out)
const override;
96 template <
typename Hashable>
98 {
return makeValid(std::hash<Hashable>()(info)); }
136 template <
typename T>
145 static const std::vector<std::string>
algoNames;
157 template <
typename SEED>
160 std::vector<std::string> names((
size_t)
NAlgos);
168 template <
typename SEED>
174 template <
typename SEED>
178 std::ostringstream sstr;
185 template <
typename SEED>
189 std::ostringstream sstr;
190 sstr <<
" Timestamp: " << info.
time;
195 template <
typename SEED>
202 <<
"Input event has an invalid timestamp," 203 " random seed per-event policy EventTimestamp_v1 can't be used.\n";
207 +
" Module: " +
id.moduleLabel;
208 if (!
id.instanceName.empty())
209 s.append(
" Instance: ").append(
id.instanceName);
211 LOG_DEBUG(
"PerEventPolicy") <<
"Seed from: '" << s <<
"': " <<
seed;
217 template <
typename SEED>
221 std::string algorithm_name
222 = pset.
get<std::string>(
"algorithm",
"default");
226 for (
size_t iAlgo = 0; iAlgo < (size_t)
NAlgos; ++iAlgo) {
227 if (algorithm_name !=
algoNames[iAlgo])
continue;
234 <<
"No valid event random seed algorithm specified!\n";
247 template <
typename SEED>
253 out <<
"\n constant offset: " <<
offset;
258 template <
typename SEED>
269 <<
"Per-event random number seeder not configured!\n";
272 <<
"Unsupported per-event random number seeder (#" 273 << ((int)
algo) <<
")\n";
284 #endif // NUTOOLS_RANDOMUTILS_PROVIDERS_PEREVENTPOLICY_H
virtual void print(std::ostream &out) const override
Prints the details of the configuration of the random generator.
virtual seed_t createEventSeed(SeedMasterHelper::EngineId const &id, EventData_t const &info) override
Returns a seed proper for the specified event information.
static std::string UniqueEventIDString(EventData_t const &info)
Converts run, subrun and event numbers into a string.
SEED seed_t
type of the random seed
static seed_t EventTimestamp_v1(SeedMasterHelper::EngineId const &id, EventData_t const &info)
Implementation of the EventTimestamp_v1 algorithm.
SeedOffset_t offset
offset added to all the seeds
virtual seed_t createSeed(SeedMasterHelper::EngineId const &) override
Per-job seed: invalid seeds are returned.
total number of seed algorithms
typename std::make_signed< seed_t >::type SeedOffset_t
type for seed offset
virtual void print(std::ostream &out) const
Prints information on the configuration of this policy.
virtual void configure(fhicl::ParameterSet const &pset) override
Configure this policy.
static seed_t SeedFromHash(Hashable const &info)
Converts some information into a valid seed by means of hash values.
typename base_t::seed_t seed_t
static std::vector< std::string > InitAlgoNames()
Algorithm name (manual) handling.
Interface for a policy implementation.
T get(std::string const &key) const
static const std::vector< std::string > algoNames
Algorithm name (manual) handling.
Identifier for a engine, made of module name and optional instance name.
SeedAlgo_t algo
the algorithm to extract the seed
Defines an interface for random seed assignment policies.
static seed_t makeValid(T value)
Renders a seed valid.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::string value(boost::any const &)
Implementation of the "perEvent" policy.
Class storing a seed in the valid range.
static constexpr seed_t InvalidSeed
An invalid seed.
event timestamp algorithm (v1)
PerEventPolicy(fhicl::ParameterSet const &pset)
static constexpr const char * DefaultVersion
Default algorithm version.
static std::string UniqueEventString(EventData_t const &info)
Converts event ID and timestamp information into a string.
virtual bool yieldsUniqueSeeds() const override
Returns whether the returned seed should be unique: for us it "no".
An identifier for random engines.