Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
rndm::details::PerInstancePolicy< SEED > Class Template Reference

Base class for policies reacting at engine instance level. More...

#include <BasePolicies.h>

Inheritance diagram for rndm::details::PerInstancePolicy< SEED >:
rndm::details::CheckedRangePolicy< SEED > rndm::details::CheckedRangePolicy< SEED > rndm::details::RandomSeedPolicyBase< SEED > rndm::details::RandomSeedPolicyBase< SEED > rndm::details::RandomSeedPolicyBase< SEED > rndm::details::RandomSeedPolicyBase< SEED > rndm::details::PredefinedOffsetPolicy< SEED > rndm::details::PredefinedOffsetPolicy< SEED > rndm::details::PredefinedSeedPolicy< SEED > rndm::details::PredefinedSeedPolicy< SEED >

Public Types

using base_t = CheckedRangePolicy< SEED >
 
using this_t = PerInstancePolicy< SEED >
 
using seed_t = typename base_t::seed_t
 
using base_t = CheckedRangePolicy< SEED >
 
using this_t = PerInstancePolicy< SEED >
 
using seed_t = typename base_t::seed_t
 
- Public Types inherited from rndm::details::CheckedRangePolicy< SEED >
using base_t = RandomSeedPolicyBase< SEED >
 
using this_t = CheckedRangePolicy< SEED >
 
using seed_t = typename base_t::seed_t
 
using base_t = RandomSeedPolicyBase< SEED >
 
using this_t = CheckedRangePolicy< SEED >
 
using seed_t = typename base_t::seed_t
 
- Public Types inherited from rndm::details::RandomSeedPolicyBase< SEED >
using seed_t = SEED
 type of the random seed More...
 
using EventData_t = NuRandomServiceHelper::EventSeedInputData
 type of data used for event seeds More...
 
using seed_t = SEED
 type of the random seed More...
 
using EventData_t = NuRandomServiceHelper::EventSeedInputData
 type of data used for event seeds More...
 

Public Member Functions

 PerInstancePolicy (std::string name, fhicl::ParameterSet const &pset)
 
virtual void configure (fhicl::ParameterSet const &pset) override
 Configure this policy. More...
 
 PerInstancePolicy (std::string name, fhicl::ParameterSet const &pset)
 
virtual void configure (fhicl::ParameterSet const &pset) override
 Configure this policy. More...
 
- Public Member Functions inherited from rndm::details::CheckedRangePolicy< SEED >
 CheckedRangePolicy (std::string policy_name, fhicl::ParameterSet const &pset)
 Constructor; requires the policy name. More...
 
virtual seed_t getSeed (SeedMasterHelper::EngineId const &id)
 Returns the next random number. More...
 
virtual void print (std::ostream &out) const override
 Prints information on the configuration of this policy. More...
 
 CheckedRangePolicy (std::string policy_name, fhicl::ParameterSet const &pset)
 Constructor; requires the policy name. More...
 
virtual seed_t getSeed (SeedMasterHelper::EngineId const &id) override
 Returns the next random number. More...
 
virtual void print (std::ostream &out) const override
 Prints information on the configuration of this policy. More...
 
- Public Member Functions inherited from rndm::details::RandomSeedPolicyBase< SEED >
 RandomSeedPolicyBase (std::string policy_name)
 Constructor; requires the policy name. More...
 
virtual ~RandomSeedPolicyBase ()
 
virtual seed_t getEventSeed (SeedMasterHelper::EngineId const &id, EventData_t const &eventInfo)
 Returns a random number specific to an event. More...
 
std::string getName () const
 Returns the given name of the policy. More...
 
virtual bool yieldsUniqueSeeds () const override
 Returns whether the returned seed should be unique. More...
 
 RandomSeedPolicyBase (std::string policy_name)
 Constructor; requires the policy name. More...
 
virtual ~RandomSeedPolicyBase ()
 
virtual seed_t getEventSeed (SeedMasterHelper::EngineId const &id, EventData_t const &eventInfo)
 Returns a random number specific to an event. More...
 
std::string getName () const
 Returns the given name of the policy. More...
 
virtual bool yieldsUniqueSeeds () const
 Returns whether the returned seed should be unique. More...
 

Protected Member Functions

 PerInstancePolicy (std::string name)
 Internal constructor: does not configure. For use in derived classes. More...
 
seed_t getInstanceSeed (SeedMasterHelper::EngineId const &id) const
 Retrieves the parameter (seed) for the specified engine ID. More...
 
void static_configure (fhicl::ParameterSet const &pset)
 
 PerInstancePolicy (std::string name)
 Internal constructor: does not configure. For use in derived classes. More...
 
seed_t getInstanceSeed (SeedMasterHelper::EngineId const &id) const
 Retrieves the parameter (seed) for the specified engine ID. More...
 
void static_configure (fhicl::ParameterSet const &pset)
 
- Protected Member Functions inherited from rndm::details::CheckedRangePolicy< SEED >
 CheckedRangePolicy (std::string policy_name)
 Lets the derived class to start configuration. More...
 
virtual void ensureRange (SeedMasterHelper::EngineId const &id, seed_t seed) const
 Performs the range checks and complains if needed. More...
 
void CheckRangeConfiguration () const
 Check that the configuration is complete. More...
 
void static_configure (fhicl::ParameterSet const &pset)
 Local configuration; does not require the range config to be complete. More...
 
 CheckedRangePolicy (std::string policy_name)
 Lets the derived class to start configuration. More...
 
virtual void ensureRange (SeedMasterHelper::EngineId const &id, seed_t seed) const
 Performs the range checks and complains if needed. More...
 
void CheckRangeConfiguration () const
 Check that the configuration is complete. More...
 
void static_configure (fhicl::ParameterSet const &pset)
 Local configuration; does not require the range config to be complete. More...
 
- Protected Member Functions inherited from rndm::details::RandomSeedPolicyBase< SEED >
virtual seed_t createSeed (SeedMasterHelper::EngineId const &)=0
 Extracts the next random number seed. More...
 
virtual seed_t createEventSeed (SeedMasterHelper::EngineId const &, EventData_t const &)
 Extracts a seed for specified event information; returns InvalidSeed. More...
 
virtual seed_t createSeed (SeedMasterHelper::EngineId const &)=0
 Extracts the next random number seed. More...
 
virtual seed_t createEventSeed (SeedMasterHelper::EngineId const &, EventData_t const &)
 Extracts a seed for specified event information; returns InvalidSeed. More...
 

Static Protected Member Functions

template<typename T >
static T getInstanceParameter (fhicl::ParameterSet const &pset, SeedMasterHelper::EngineId const &id)
 Retrieves the parameter (seed) for the specified engine ID. More...
 
template<typename T >
static T getInstanceParameter (fhicl::ParameterSet const &pset, SeedMasterHelper::EngineId const &id)
 Retrieves the parameter (seed) for the specified engine ID. More...
 

Protected Attributes

fhicl::ParameterSet parameters
 configuration parameters More...
 
- Protected Attributes inherited from rndm::details::CheckedRangePolicy< SEED >
RangeCheckHelper< seed_trange_check
 
- Protected Attributes inherited from rndm::details::RandomSeedPolicyBase< SEED >
std::string name
 name of the policy More...
 

Additional Inherited Members

- Static Public Attributes inherited from rndm::details::RandomSeedPolicyBase< SEED >
static constexpr seed_t InvalidSeed = 0
 An invalid seed. More...
 

Detailed Description

template<typename SEED>
class rndm::details::PerInstancePolicy< SEED >

Base class for policies reacting at engine instance level.


See also
CheckedRangePolicy

Definition at line 510 of file BasePolicies.h.

Member Typedef Documentation

template<typename SEED >
using rndm::details::PerInstancePolicy< SEED >::base_t = CheckedRangePolicy<SEED>

Definition at line 389 of file RandomSeedPolicyBase.h.

template<typename SEED >
using rndm::details::PerInstancePolicy< SEED >::base_t = CheckedRangePolicy<SEED>

Definition at line 512 of file BasePolicies.h.

template<typename SEED >
using rndm::details::PerInstancePolicy< SEED >::seed_t = typename base_t::seed_t

Definition at line 391 of file RandomSeedPolicyBase.h.

template<typename SEED >
using rndm::details::PerInstancePolicy< SEED >::seed_t = typename base_t::seed_t

Definition at line 514 of file BasePolicies.h.

template<typename SEED >
using rndm::details::PerInstancePolicy< SEED >::this_t = PerInstancePolicy<SEED>

Definition at line 390 of file RandomSeedPolicyBase.h.

template<typename SEED >
using rndm::details::PerInstancePolicy< SEED >::this_t = PerInstancePolicy<SEED>

Definition at line 513 of file BasePolicies.h.

Constructor & Destructor Documentation

template<typename SEED >
rndm::details::PerInstancePolicy< SEED >::PerInstancePolicy ( std::string  name,
fhicl::ParameterSet const &  pset 
)
inline

Configures from a parameter set

See also
configure()

Definition at line 518 of file BasePolicies.h.

518  :
519  base_t(name)
520  { this_t::configure(pset); }
CheckedRangePolicy< SEED > base_t
Definition: BasePolicies.h:512
std::string name
name of the policy
Definition: BasePolicies.h:83
virtual void configure(fhicl::ParameterSet const &pset) override
Configure this policy.
Definition: BasePolicies.h:527
template<typename SEED >
rndm::details::PerInstancePolicy< SEED >::PerInstancePolicy ( std::string  name)
inlineprotected

Internal constructor: does not configure. For use in derived classes.

Definition at line 534 of file BasePolicies.h.

534 : base_t(name) {}
CheckedRangePolicy< SEED > base_t
Definition: BasePolicies.h:512
std::string name
name of the policy
Definition: BasePolicies.h:83
template<typename SEED >
rndm::details::PerInstancePolicy< SEED >::PerInstancePolicy ( std::string  name,
fhicl::ParameterSet const &  pset 
)
inline

Configures from a parameter set

See also
configure()

Definition at line 395 of file RandomSeedPolicyBase.h.

395  :
396  base_t(name)
397  { this_t::configure(pset); }
CheckedRangePolicy< SEED > base_t
Definition: BasePolicies.h:512
std::string name
name of the policy
Definition: BasePolicies.h:83
virtual void configure(fhicl::ParameterSet const &pset) override
Configure this policy.
Definition: BasePolicies.h:527
template<typename SEED >
rndm::details::PerInstancePolicy< SEED >::PerInstancePolicy ( std::string  name)
inlineprotected

Internal constructor: does not configure. For use in derived classes.

Definition at line 411 of file RandomSeedPolicyBase.h.

411 : base_t(name) {}
CheckedRangePolicy< SEED > base_t
Definition: BasePolicies.h:512
std::string name
name of the policy
Definition: BasePolicies.h:83

Member Function Documentation

template<typename SEED >
virtual void rndm::details::PerInstancePolicy< SEED >::configure ( fhicl::ParameterSet const &  pset)
inlineoverridevirtual

Configure this policy.

Parameters
psetthe parameter set for the configuration

Reimplemented from rndm::details::CheckedRangePolicy< SEED >.

Reimplemented in rndm::details::PredefinedOffsetPolicy< SEED >, rndm::details::PredefinedSeedPolicy< SEED >, rndm::details::PredefinedOffsetPolicy< SEED >, and rndm::details::PredefinedSeedPolicy< SEED >.

Definition at line 404 of file RandomSeedPolicyBase.h.

405  { base_t::configure(pset); static_configure(pset); }
virtual void configure(fhicl::ParameterSet const &pset) override
Configure this policy.
Definition: BasePolicies.h:277
void static_configure(fhicl::ParameterSet const &pset)
Definition: BasePolicies.h:554
template<typename SEED >
virtual void rndm::details::PerInstancePolicy< SEED >::configure ( fhicl::ParameterSet const &  pset)
inlineoverridevirtual

Configure this policy.

Parameters
psetthe parameter set for the configuration

Reimplemented from rndm::details::CheckedRangePolicy< SEED >.

Reimplemented in rndm::details::PredefinedOffsetPolicy< SEED >, rndm::details::PredefinedSeedPolicy< SEED >, rndm::details::PredefinedOffsetPolicy< SEED >, and rndm::details::PredefinedSeedPolicy< SEED >.

Definition at line 527 of file BasePolicies.h.

528  { base_t::configure(pset); static_configure(pset); }
virtual void configure(fhicl::ParameterSet const &pset) override
Configure this policy.
Definition: BasePolicies.h:277
void static_configure(fhicl::ParameterSet const &pset)
Definition: BasePolicies.h:554
template<typename SEED >
template<typename T >
static T rndm::details::PerInstancePolicy< SEED >::getInstanceParameter ( fhicl::ParameterSet const &  pset,
SeedMasterHelper::EngineId const &  id 
)
staticprotected

Retrieves the parameter (seed) for the specified engine ID.

template<typename SEED >
template<typename T >
T rndm::details::PerInstancePolicy< SEED >::getInstanceParameter ( fhicl::ParameterSet const &  pset,
SeedMasterHelper::EngineId const &  id 
)
staticprotected

Retrieves the parameter (seed) for the specified engine ID.

Definition at line 562 of file BasePolicies.h.

564  {
565  // there must be /some/ configuration for the module
566  // FIXME: use ParameterSet::has_key() as soon as it's available
567  const auto cfgKeys = pset.get_names();
568  if (std::find(cfgKeys.begin(), cfgKeys.end(), id.moduleLabel) == cfgKeys.end()) {
570  << "A seed for the nameless instance '" << id
571  << "' was requested, but there is no configuration for '"
572  << id.moduleLabel << "' module label.";
573  }
574 
575  T param;
576  if (!id.hasInstanceName()) { // Case 1: no instance name.
577  // We expect the element to be just an item.
578  if (pset.is_key_to_table(id.moduleLabel)) {
579  // this is mostly a limitation of the FHiCL syntax,
580  // that we can overcome with some cumbersomeness if we need to.
582  << "A seed for the nameless instance '" << id
583  << "' was requested, but the configuration sets named instances ("
584  << pset.get<fhicl::ParameterSet>(id.moduleLabel).to_compact_string()
585  << ").\nNameless and named engine instances can't coexist.";
586  }
587  if (!pset.get_if_present(id.moduleLabel, param)) {
589  << "NuRandomService: unable to find the parameter for '" << id << "'";
590  }
591  } // if no instance name
592  else { // Case 2: instance name is given.
593 
594  if (pset.is_key_to_atom(id.moduleLabel)) {
595  // see above
597  << "A seed for '" << std::string(id) << "' was requested,"
598  " but the configuration sets a nameless instance of '"
599  << id.moduleLabel << "'.\n"
600  << "Nameless and named engine instances can't coexist.";
601  }
602  fhicl::ParameterSet subSet;
603  if (!pset.get_if_present(id.moduleLabel, subSet)) {
605  << "NuRandomService: unable to find the parameter block for: '"
606  << id << "'";
607  }
608 
609  if (!subSet.get_if_present(id.instanceName, param)) {
611  << "NuRandomService: unable to find the parameter value for: '"
612  << id << "'";
613  }
614  } // if instance name
615 
616  return param;
617  } // PerInstancePolicy<SEED>::getInstanceParameter<>()
std::string string
Definition: nybbler.cc:12
bool get_if_present(std::string const &key, T &value) const
Definition: ParameterSet.h:208
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
template<typename SEED >
seed_t rndm::details::PerInstancePolicy< SEED >::getInstanceSeed ( SeedMasterHelper::EngineId const &  id) const
inlineprotected

Retrieves the parameter (seed) for the specified engine ID.

Definition at line 414 of file RandomSeedPolicyBase.h.

415  { return getInstanceParameter<seed_t>(parameters, id); }
fhicl::ParameterSet parameters
configuration parameters
Definition: BasePolicies.h:531
template<typename SEED >
seed_t rndm::details::PerInstancePolicy< SEED >::getInstanceSeed ( SeedMasterHelper::EngineId const &  id) const
inlineprotected

Retrieves the parameter (seed) for the specified engine ID.

Definition at line 537 of file BasePolicies.h.

538  { return getInstanceParameter<seed_t>(parameters, id); }
fhicl::ParameterSet parameters
configuration parameters
Definition: BasePolicies.h:531
template<typename SEED >
void rndm::details::PerInstancePolicy< SEED >::static_configure ( fhicl::ParameterSet const &  pset)
protected
template<typename SEED >
void rndm::details::PerInstancePolicy< SEED >::static_configure ( fhicl::ParameterSet const &  pset)
protected

Definition at line 554 of file BasePolicies.h.

555  {
556  parameters = pset; // copy the parameters locally
557  } // PerInstancePolicy<SEED>::configure()
fhicl::ParameterSet parameters
configuration parameters
Definition: BasePolicies.h:531

Member Data Documentation

template<typename SEED >
fhicl::ParameterSet rndm::details::PerInstancePolicy< SEED >::parameters
protected

configuration parameters

Definition at line 531 of file BasePolicies.h.


The documentation for this class was generated from the following files: