52 #include "nutools/RandomUtils/Providers/SeedMaster.h" 68 return seeds.
getSeed(instance_name.empty()?
74 mf::LogError(
"SeedMaster") <<
"Caught an exception while asking seed for '" 75 << module_name <<
"." << instance_name <<
":\n" 102 const std::vector<std::string>& module_types,
112 if (std::find(module_types.begin(), module_types.end(),
module_type)
113 != module_types.end()
115 return { base_pset };
120 std::vector<fhicl::ParameterSet> psets;
126 psets.insert(psets.end(), new_psets.begin(), new_psets.end());
161 std::cout << "Using default message facility configuration:\n" 168 mf::LogInfo(
"MessageFacility") <<
"MessageFacility started.";
188 std::vector<std::string> instance_names;
190 unsigned int nExpectedErrors = pset.
get<
unsigned int>(
"expectedErrors", 0);
192 unsigned int nErrors = 0;
193 if (instance_names.empty()) {
194 instance_names.push_back(
"");
195 mf::LogInfo(
"SeedMaster_test") <<
"Added a default engine instance.";
198 << module_id <<
" has " << instance_names.size() <<
" seed instances:";
201 std::vector<seed_t> our_seeds;
205 <<
"Seed for '" << instance_name <<
"' is: " << seed;
208 <<
"instance " << instance_name <<
" got seed 0!";
209 if (++nErrors <= nExpectedErrors) {
211 <<
", " << nExpectedErrors <<
" expected)";
214 our_seeds.push_back(seed);
222 <<
"Seed for '" << instance_name <<
"' is: " << seed <<
" (second query)";
223 if (seed != *iOldSeed) {
225 <<
"seed has changed for instance " 226 << instance_name <<
": " << *iOldSeed <<
" => " << seed;
227 if (++nErrors <= nExpectedErrors) {
229 <<
", " << nExpectedErrors <<
" expected";
232 if (*iOldSeed == 0) {
234 <<
"instance " << instance_name <<
" got seed 0!";
235 if (++nErrors <= nExpectedErrors) {
237 <<
", " << nExpectedErrors <<
" expected)";
244 return (nErrors > nExpectedErrors)?
245 nErrors - nExpectedErrors: nExpectedErrors - nErrors;
260 std::vector<std::string> module_types{
"SeedTestPolicy" };
264 if (++iParam < argc) {
265 config_path = argv[iParam];
269 <<
"SeedMaster_test: please specify a configuration file." <<
std::endl;
274 if (++iParam < argc) {
275 parameter_set_name = argv[iParam];
279 if (++iParam < argc) {
280 module_types.assign(argv + iParam, argv + argc);
309 <<
"Failed to read the '" << parameter_set_name
310 <<
"' parameters set from configuration file '" << config_path <<
"'";
314 mf::LogInfo(
"SeedMaster_test") <<
"Parameters from '" << config_path <<
"':\n" 319 std::vector<fhicl::ParameterSet> module_psets
321 if (module_psets.empty()) {
323 <<
"could not find any suitable module configuration in '" 324 << module_base_key <<
"' of '" << config_path
331 log <<
"Found configurations for " << module_psets.size() <<
" modules.";
334 log <<
'\n' <<
"*** " << module_id <<
" ***" 341 bool endOfJobSummary = pset.
get<
bool>(
"endOfJobSummary",
false);
347 std::unique_ptr<SeedMaster_t> pSeeds;
353 <<
"Exception caught while initializing SeedMaster:\n" 359 <<
"FHiCL exception caught while initializing SeedMaster:\n" 364 unsigned int nErrors = 0;
371 <<
"Exception caught while testing module " <<
GetModuleID(module_pset)
384 if (endOfJobSummary) pSeeds->print();
388 <<
"Test terminated with " << nErrors <<
" errors.";
391 mf::LogInfo(
"SeedMaster_test") <<
"Test successful.";
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
std::vector< fhicl::ParameterSet > FindModulesConfiguration(const fhicl::ParameterSet &full_pset, const std::vector< std::string > &module_types, std::string base_key="physics.analyzers")
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
fhicl::ParameterSet FindSeedServiceConfiguration(const fhicl::ParameterSet &full_pset, std::string key="services.NuRandomService")
rndm::SeedMaster< seed_t > SeedMaster_t
fhicl::ParameterSet GetConfiguration(const fhicl::ParameterSet &full_pset, std::string key)
#define MF_LOG_ERROR(category)
void make_ParameterSet(intermediate_table const &tbl, ParameterSet &ps)
ModuleType module_type(std::string const &full_key)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::string GetModuleID(fhicl::ParameterSet const &pset)
Returns a string "ModuleType[ModuleName]" out of specified module config.
void SetContextIteration(string const &val)
MaybeLogger_< ELseverityLevel::ELsev_error, true > LogProblem
std::vector< std::string > get_pset_names() const
void StartMessageFacility(fhicl::ParameterSet const &pset, string const &applicationName)
seed_t seed_t
type of served seeds
SeedMasterHelper::EngineId EngineId
type of engine ID
int main(int argc, const char **argv)
T get(std::string const &key) const
std::string to_indented_string() const
bool get_if_present(std::string const &key, T &value) const
int TestModule(SeedMaster_t &seeds, const fhicl::ParameterSet &pset)
Tests a "module" with a given configuration.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
std::vector< TrajPoint > seeds
seed_t ObtainSeed(SeedMaster_t &seeds, std::string module_name, std::string instance_name="")
Returns the seed for the specified module/instance, or 0 on error.
seed_t getSeed(std::string moduleLabel)
Returns the seed value for this module label.
void SetContextSinglet(string const &val)
void SetApplicationName(string const &applicationName)
cet::coded_exception< error, detail::translate > exception
void parse_document(std::string const &filename, cet::filepath_maker &maker, intermediate_table &result)
void StartMessageFacility(fhicl::ParameterSet const &pset)
QTextStream & endl(QTextStream &s)