33 {
"GlobalEngineUserServiceEngine" };
37 : instanceNames (pset.
get<std::vector<std::string>>(
"instances", {}))
38 , perEventSeeds (pset.
get<
bool> (
"perEventSeeds",
false))
44 if (instanceNames.empty()) {
45 instanceNames.push_back(
"GlobalEngineUserTestService");
47 <<
"Using a default engine instance name: '" << instanceNames.back()
55 engines.emplace_back(std::make_unique<TRandom3>());
56 engines.back()->SetTitle(instanceName.c_str());
66 for (
auto& engine: engines) {
72 (rndm::NuRandomService::TRandomSeeder(engine.get()), engine->GetTitle());
75 <<
"Registered my random engine " 76 << engine->IsA()->GetName() <<
"[" << ((
void*) engine.get()) <<
"]" 77 <<
" with seed " << seed;
86 <<
"Check of seeds on construction skipped because policy is per event.";
97 reg.
sPreProcessEvent.watch (
this, &GlobalEngineUserTestService::preProcessEvent );
98 reg.
sPreModule.watch (
this, &GlobalEngineUserTestService::preModule );
99 reg.
sPostModule.watch (
this, &GlobalEngineUserTestService::postModule );
100 reg.
sPostProcessEvent.watch (
this, &GlobalEngineUserTestService::postProcessEvent );
101 reg.
sPreModuleEndJob.watch (
this, &GlobalEngineUserTestService::preModuleEndJob );
102 reg.
sPostModuleEndJob.watch (
this, &GlobalEngineUserTestService::postModuleEndJob );
113 auto expectedSeed = Seeds.getGlobalCurrentSeed(engine.GetTitle());
114 auto actualSeed = engine.GetSeed();
116 if (actualSeed != expectedSeed) {
118 <<
"Engine " << engine.IsA()->GetName() <<
"[" << ((
void*) &engine)
119 <<
"](\"" << engine.GetTitle() <<
"\") has seed " << actualSeed
120 <<
" (expected: " << expectedSeed <<
")";
124 <<
"Engine " << engine.IsA()->GetName() <<
"[" << ((
void*) &engine)
125 <<
"](\"" << engine.GetTitle() <<
"\") has seed " << actualSeed
128 if (actualSeed != expectedSeed) {
130 <<
"Unexpected seed " << actualSeed <<
"!\n";
137 <<
"Checking all " <<
engines.size() <<
" seeds";
149 <<
"GlobalEngineUserTestService::preModuleConstruction()";
160 <<
"GlobalEngineUserTestService::postModuleConstruction()";
171 <<
"GlobalEngineUserTestService::preModuleBeginRun()";
182 <<
"GlobalEngineUserTestService::postModuleBeginRun()";
190 <<
"GlobalEngineUserTestService::preProcessEvent()";
199 <<
"GlobalEngineUserTestService::preModule()";
209 <<
"GlobalEngineUserTestService::postModule()";
217 <<
"GlobalEngineUserTestService::postProcessEvent()";
227 <<
"GlobalEngineUserTestService::preModuleEndJob()";
238 <<
"GlobalEngineUserTestService::postModuleEndJob()";
void postProcessEvent(art::Event const &, art::ScheduleContext)
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
void postModule(art::ModuleContext const &)
void preModule(art::ModuleContext const &)
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleContext const &)> sPreModuleBeginRun
Test service registering its own ßs.
static const std::string GlobalInstanceName
Name used for the global engine instance.
void postModuleBeginRun(art::ModuleContext const &)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
#define DEFINE_ART_SERVICE(svc)
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleConstruction
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleContext const &)> sPreModule
void preModuleConstruction(art::ModuleDescription const &)
void postModuleConstruction(art::ModuleDescription const &)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
GlobalSignal< detail::SignalResponseType::LIFO, void(ModuleDescription const &)> sPostModuleConstruction
void preModuleEndJob(art::ModuleDescription const &)
std::vector< std::unique_ptr< TRandom > > engines
our random generator engines
void preProcessEvent(art::Event const &evt, art::ScheduleContext)
static void CheckSeed(TRandom const &engine)
Throws an exception if the seed is not expected.
T get(std::string const &key) const
void postModuleEndJob(art::ModuleDescription const &)
GlobalSignal< detail::SignalResponseType::LIFO, void(ModuleContext const &)> sPostModuleBeginRun
GlobalEngineUserTestService(fhicl::ParameterSet const &pset, art::ActivityRegistry ®)
GlobalSignal< detail::SignalResponseType::FIFO, void(Event const &, ScheduleContext)> sPreProcessEvent
GlobalSignal< detail::SignalResponseType::FIFO, void(ModuleDescription const &)> sPreModuleEndJob
void preModuleBeginRun(art::ModuleContext const &)
void CheckAllSeeds() const
Checks all engines by CheckSeed() calls.
bool perEventSeeds
whether to skip seed check in constructor
GlobalSignal< detail::SignalResponseType::LIFO, void(Event const &, ScheduleContext)> sPostProcessEvent
Test service registering its own engine.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
GlobalSignal< detail::SignalResponseType::LIFO, void(ModuleContext const &)> sPostModule
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
GlobalSignal< detail::SignalResponseType::LIFO, void(ModuleDescription const &)> sPostModuleEndJob
An art service to assist in the distribution of guaranteed unique seeds to all engines within an art ...
seed_t registerEngine(SeedMaster_t::Seeder_t seeder, std::string instance="")
Registers an existing engine with NuRandomService.