10 #define NUTOOLS_RANDOMUTILS_NURANDOMSERVICE_USECLHEP 1 // to have NuSeedService.h define CLHEPengineSeeder 11 #include "nutools/RandomUtils/NuRandomService.h" 24 #include "CLHEP/Random/RandomEngine.h" 25 #include "CLHEP/Random/Ranlux64Engine.h" 26 #include "CLHEP/Random/RandFlat.h" 74 std::map<std::string, cet::exempt_ptr<CLHEP::HepRandomEngine>>
engines;
75 std::unique_ptr<CLHEP::HepRandomEngine>
extEngine{
nullptr};
92 if (pset.get_if_present(
"externalInstance", externalInstanceName)) {
93 mf::LogInfo(
"RandomManagerTest") <<
"Creating an unmanaged engine '" 94 << externalInstanceName <<
"' in module '" <<
moduleLabel <<
"'";
95 extEngine = std::make_unique<CLHEP::Ranlux64Engine>();
100 externalInstanceName, pset,
"Seed_" + externalInstanceName
106 if (pset.get_if_present(
"standardInstance", standardInstanceName)) {
107 mf::LogInfo(
"RandomManagerTest") <<
"Creating a standard engine '" 108 << standardInstanceName <<
"' in module '" <<
moduleLabel 109 <<
"' with RandomNumberGenerator";
111 = pset.get<
unsigned int>(
"Seed_" + standardInstanceName, 0);
116 auto const instanceNames = pset.get<std::vector<std::string>>(
"instanceNames", {});
117 for (
std::string const& instanceName: instanceNames) {
118 mf::LogInfo(
"RandomManagerTest") <<
"Creating a default engine '" 119 << instanceName <<
"' in module '" <<
moduleLabel <<
"'";
120 CLHEP::HepRandomEngine& engine = EngineManager->
createEngine 121 (*
this,
"HepJamesRandom", instanceName, pset,
"Seed_" + instanceName);
122 engines.emplace(instanceName, &engine);
128 <<
"Creating a nameless default engine in module '" 130 CLHEP::HepRandomEngine& engine = EngineManager->
createEngine(*
this, pset,
"Seed");
136 log <<
"RandomManagerTest[" <<
moduleLabel <<
"]: instances:";
137 for (
std::string const& instanceName: instanceNames)
138 log <<
" " << instanceName;
143 assert(!externalInstanceName.empty());
148 assert(!standardInstanceName.empty());
161 for (
auto& [instanceName, engine] :
engines) {
164 <<
std::setw(12) << (instanceName.empty()?
"<default>": instanceName)
166 <<
" (seed: " << actualSeed <<
")";
base_engine_t & createEngine(seed_t seed)
MaybeLogger_< ELseverityLevel::ELsev_info, true > LogVerbatim
art::detail::EngineCreator::seed_t seed_t
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
EDAnalyzer(fhicl::ParameterSet const &pset)
#define DEFINE_ART_MODULE(klass)
cet::exempt_ptr< CLHEP::HepRandomEngine > stdEngine
std::string CreateCharacter(CLHEP::HepRandomEngine &engine)
Creates a "character statistics" using the specified random engine.
Identifier for a engine, made of module name and optional instance name.
Functions used in NuRandomService tests.
std::unique_ptr< CLHEP::HepRandomEngine > extEngine
std::reference_wrapper< engine_t > createEngine(Module &module, std::string type, std::string instance="")
Creates an engine with RandomNumberGenerator service.
Q_EXPORT QTSManip setw(int w)
RandomManagerTest(fhicl::ParameterSet const &pset)
void analyze(const art::Event &event) override
seed_t readSeed(CLHEP::HepRandomEngine const &engine)
Returns the seed of the specified engine (CLHEP overload)
Test module for random engine managing interface of NuRandomService.
std::map< std::string, cet::exempt_ptr< CLHEP::HepRandomEngine > > engines
seed_t registerEngine(SeedMaster_t::Seeder_t seeder, std::string instance="")
Registers an existing engine with NuRandomService.
Event finding and building.